Commit bd192708 authored by Sebastian Kotte's avatar Sebastian Kotte

Use membership logos to render platinum banners

addad apossible reference to a platinum member in the banner. If chosen it renders the image from the member instead of the banner image. dependency to https://git-t3o.typo3.org/t3o/t3o_membership/issues/15
parent 2507ddaf
......@@ -15,6 +15,7 @@ namespace T3o\Randombanners\Controller;
*/
use T3o\Randombanners\Domain\Repository\BannerRepository;
use T3o\T3oMembership\Domain\Repository\MemberRepository;
/**
* Class BannerController
......@@ -38,6 +39,7 @@ class BannerController extends \TYPO3\CMS\Extbase\Mvc\Controller\ActionControlle
{
$this->objectManager->get(\TYPO3\CMS\Core\Page\PageRenderer::class)
->addJsFooterFile('EXT:randombanners/Resources/Public/Javascript/randombanners.js');
$this->view->assign('banners', $this->bannerRepository->findAll());
$this->view->assign('contentData', $this->configurationManager->getContentObject()->data);
}
......
......@@ -14,6 +14,9 @@ namespace T3o\Randombanners\Domain\Model;
* The TYPO3 project - inspiring people to share!
*/
use T3o\T3oMembership\Domain\Model\Member;
use TYPO3\CMS\Extbase\Persistence\ObjectStorage;
class Banner extends \TYPO3\CMS\Extbase\DomainObject\AbstractEntity
{
......@@ -59,6 +62,13 @@ class Banner extends \TYPO3\CMS\Extbase\DomainObject\AbstractEntity
*/
protected $clickedLastMonth;
/**
* $member
*
* @var \TYPO3\CMS\Extbase\Persistence\ObjectStorage<\T3o\T3oMembership\Domain\Model\Member>
*/
protected $member = 0;
/**
* @param string $name
* @return void
......@@ -90,17 +100,17 @@ class Banner extends \TYPO3\CMS\Extbase\DomainObject\AbstractEntity
}
/**
* @param \TYPO3\CMS\Extbase\Persistence\ObjectStorage $logo
* @param ObjectStorage $logo
* @return void
*/
public function setLogo(\TYPO3\CMS\Extbase\Persistence\ObjectStorage $logo) {
public function setLogo(ObjectStorage $logo) {
$this->logo = $logo;
}
/**
* Get logo
*
* @return \TYPO3\CMS\Extbase\Persistence\ObjectStorage
* @return ObjectStorage
*/
public function getLogo() {
return $this->logo;
......@@ -151,4 +161,47 @@ class Banner extends \TYPO3\CMS\Extbase\DomainObject\AbstractEntity
return $this->clickedLastMonth;
}
/**
* Adds a Member
*
* @param Member $member
* @return void
*/
public function addMember(Member $member)
{
$this->member->attach($member);
}
/**
* Removes a Member
*
* @param Member $memberToRemove The Member to be removed
* @return void
*/
public function removeMember(Member $memberToRemove)
{
$this->member->detach($memberToRemove);
}
/**
* Returns the member
*
* @return ObjectStorage<\T3o\T3oMembership\Domain\Model\Member> $member
*/
public function getMember()
{
return $this->member;
}
/**
* Sets the members
*
* @param ObjectStorage<\T3o\T3oMembership\Domain\Model\Member> $member
* @return void
*/
public function setMember(ObjectStorage $member)
{
$this->member = $member;
}
}
\ No newline at end of file
......@@ -24,10 +24,11 @@ return [
'iconfile' => 'EXT:randombanners/Resources/Public/Icons/tx_randombanners_domain_model_banner.gif'
],
'interface' => [
'showRecordFieldList' => 'cruser_id, pid, sys_language_uid, l10n_parent, l10n_diffsource, hidden, name, link, email, logo, clicked_this_month, clicked_last_month',
'showRecordFieldList' => 'cruser_id, pid, sys_language_uid, l10n_parent, l10n_diffsource, hidden, name, link, email, logo, clicked_this_month, clicked_last_month, member',
],
'types' => [
'1' => ['showitem' => 'sys_language_uid;;;;1-1-1, l10n_parent, l10n_diffsource, hidden;;1, name, link, email, logo, clicked_this_month, clicked_last_month,--div--;LLL:EXT:cms/locallang_ttc.xml:tabs.access,starttime, endtime'],
'1' => [
'showitem' => 'sys_language_uid;;;;1-1-1, l10n_parent, l10n_diffsource, hidden;;1, name, link, email, logo, clicked_this_month, clicked_last_month, member,--div--;LLL:EXT:cms/locallang_ttc.xml:tabs.access,starttime, endtime'],
],
'palettes' => [
'1' => ['showitem' => ''],
......@@ -177,5 +178,17 @@ return [
'readOnly' => 1,
],
],
'member' => array(
'exclude' => 0,
'label' => 'LLL:EXT:t3o_membership/Resources/Private/Language/locallang_db.xlf:tx_t3omembership_domain_model_member',
'config' => array(
'type' => 'select',
'items' => [['none', 0]],
'foreign_table' => 'tx_t3omembership_domain_model_member',
'foreign_table_where' => 'tx_t3omembership_domain_model_member.membership=1',
'minitems' => 0,
'maxitems' => 1,
),
),
],
];
\ No newline at end of file
......@@ -9,7 +9,14 @@
<f:for each="{banners}" as="banner">
<li>
<f:link.external class="t3js-banner" uri="{f:uri.external(uri: banner.link)}" target="_blank" additionalAttributes="{data-uid: banner.uid, rel: settings.linkAttributeRel}">
<f:image image="{banner.logo.0}" alt="{banner.name}" maxWidth="150" />
<f:if condition="{banner.member.0.logo}">
<f:then>
<f:image class="membership-logo" image="{banner.member.0.logo}" alt="{banner.name}" maxWidth="150" />
</f:then>
<f:else>
<f:image image="{banner.logo.0}" alt="{banner.name}" maxWidth="150" />
</f:else>
</f:if>
</f:link.external>
</li>
</f:for>
......
......@@ -12,6 +12,8 @@ CREATE TABLE tx_randombanners_domain_model_banner (
clicked_this_month int(11) DEFAULT '0' NOT NULL,
clicked_last_month int(11) DEFAULT '0' NOT NULL,
member int(11) DEFAULT '0' NOT NULL,
tstamp int(11) DEFAULT '0' NOT NULL,
crdate int(11) DEFAULT '0' NOT NULL,
cruser_id int(11) DEFAULT '0' NOT NULL,
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment