diff --git a/web/typo3conf/ext/ep_products/ext_localconf.php b/web/typo3conf/ext/ep_products/ext_localconf.php index b7632434..a9bff748 100644 --- a/web/typo3conf/ext/ep_products/ext_localconf.php +++ b/web/typo3conf/ext/ep_products/ext_localconf.php @@ -350,6 +350,7 @@ $GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['cms/layout/class.tx_cms_layout.php'][ $GLOBALS['TYPO3_CONF_VARS']['FE']['cacheHash']['excludedParameters'][] = 'gclid'; $GLOBALS['TYPO3_CONF_VARS']['FE']['cacheHash']['excludedParameters'][] = 'ref'; +$GLOBALS['TYPO3_CONF_VARS']['FE']['cacheHash']['excludedParameters'][] = 'pa'; $GLOBALS['TYPO3_CONF_VARS']['FE']['cacheHash']['excludedParameters'][] = 'tx_epproducts_searchresult[searchParams]'; $GLOBALS['TYPO3_CONF_VARS']['FE']['cacheHash']['excludedParameters'][] = 'tx_epproducts_searchresult[filterSettings]'; $GLOBALS['TYPO3_CONF_VARS']['FE']['cacheHash']['excludedParameters'][] = 'tx_epproducts_product_detail[filterSettings]'; diff --git a/web/typo3conf/ext/ep_theme/Classes/DataProcessing/ContextProcessor.php b/web/typo3conf/ext/ep_theme/Classes/DataProcessing/ContextProcessor.php index 77f18431..98e7cd12 100644 --- a/web/typo3conf/ext/ep_theme/Classes/DataProcessing/ContextProcessor.php +++ b/web/typo3conf/ext/ep_theme/Classes/DataProcessing/ContextProcessor.php @@ -27,7 +27,10 @@ namespace EP\EpTheme\DataProcessing; * This copyright notice MUST APPEAR in all copies of the script! ***************************************************************/ +use EP\EpProducts\Service\ResellerDataService; use EP\EpProducts\Traits\DbConnectionTrait; +use TYPO3\CMS\Core\Utility\GeneralUtility; +use TYPO3\CMS\Extbase\Object\ObjectManager; use TYPO3\CMS\Frontend\ContentObject\ContentObjectRenderer; use TYPO3\CMS\Frontend\ContentObject\DataProcessorInterface; @@ -59,9 +62,69 @@ class ContextProcessor implements DataProcessorInterface if ($regionUid > 0) { $processedData['context']['region'] = $this->getContextRecord($regionUid, 'tx_epproducts_domain_model_region'); } + $resellerData = $this->getResellerData(); + if ($resellerData) { + $processedData['context']['paCode'] = $resellerData['paCode']; + } elseif ($paCode = $this->getPaCodeFromRequest()) { + $processedData['context']['paCode'] = $paCode; + } elseif ($cookieData = $this->getCookieData()) { + $processedData['context']['paCode'] = $cookieData; + } + return $processedData; } + /** + * @return array|bool + * @throws \Doctrine\DBAL\DBALException + */ + private function getResellerData() + { + /** @var \TYPO3\CMS\Extbase\Object\ObjectManager $objectManager */ + $objectManager = GeneralUtility::makeInstance(ObjectManager::class); + /** @var ResellerDataService $resellerService */ + $resellerService = $objectManager->get(ResellerDataService::class); + return $resellerService->getResellerForCurrentDomain(); + } + + /** + * @return string + */ + private function getPaCodeFromRequest() + { + $currentUri = GeneralUtility::getIndpEnv('REQUEST_URI'); + $query = parse_url($currentUri, \PHP_URL_QUERY); + + if (!$query) { + return ''; + } + + parse_str($query, $items); + + if (array_key_exists('pa', $items)) { + $paCode = $items['pa']; + $expiratonDate = new \DateTime('now'); + $expiratonDate->add(new \DateInterval('P' . '30D')); + setcookie('ep_trk', $paCode, $expiratonDate->getTimestamp(), '/'); + + return $paCode; + } + + return ''; + } + + /** + * @return string + */ + private function getCookieData() + { + if ($_COOKIE['ep_trk']) { + return $_COOKIE['ep_trk']; + } + + return ''; + } + /** * @param int $uid * @param string $table diff --git a/web/typo3conf/ext/ep_theme/Resources/Private/Assets/js/_app.js b/web/typo3conf/ext/ep_theme/Resources/Private/Assets/js/_app.js index ca474cd3..31391dc0 100644 --- a/web/typo3conf/ext/ep_theme/Resources/Private/Assets/js/_app.js +++ b/web/typo3conf/ext/ep_theme/Resources/Private/Assets/js/_app.js @@ -69,6 +69,7 @@ new Vue({ }, data () { return { + config: {}, maxWindowWidth: 991, lastScrollPosition: 0, scrollTopVisible: false, @@ -86,6 +87,10 @@ new Vue({ } }, methods: { + parseConfig () { + const configElement = document.getElementById('appconfig'); + this.config = JSON.parse(configElement.innerHTML); + }, setMobileMode () { this.mobileMode = $window.outerWidth() < this.maxWindowWidth; }, @@ -343,9 +348,31 @@ new Vue({ .on('affixed-top.bs.affix', () => { this.searchbarFixed = false; }); + }, + appendPaCode () { + const paCode = this.config.paCode; + if (!paCode) { + return; + } + $('a').each(function () { + if (this.hostname === location.hostname) { + return; + } + let url = $(this).attr('href'); + if (!url) { + return; + } + if (url.indexOf('pa=') !== -1) { + return; + } + const separator = url.indexOf('?') === -1 ? '?' : '&'; + url += separator + 'pa=' + paCode; + $(this).attr('href', url); + }); } }, created () { + this.parseConfig(); EventBus.$on('ajaxContentLoaded', () => { Vue.nextTick(() => { this.initContentsliders(); @@ -398,6 +425,7 @@ new Vue({ this.initDropdownMenuBehavior(); this.initPartnerIdSelect(); this.initFaqFilter(); + this.appendPaCode(); }); } }); diff --git a/web/typo3conf/ext/ep_theme/Resources/Private/Layouts/Page/Detail.html b/web/typo3conf/ext/ep_theme/Resources/Private/Layouts/Page/Detail.html index 7e9c1ec6..2b9b3cb2 100644 --- a/web/typo3conf/ext/ep_theme/Resources/Private/Layouts/Page/Detail.html +++ b/web/typo3conf/ext/ep_theme/Resources/Private/Layouts/Page/Detail.html @@ -19,4 +19,5 @@ + diff --git a/web/typo3conf/ext/ep_theme/Resources/Private/Layouts/Page/Frontpage.html b/web/typo3conf/ext/ep_theme/Resources/Private/Layouts/Page/Frontpage.html index 434fb135..a5e6ba45 100644 --- a/web/typo3conf/ext/ep_theme/Resources/Private/Layouts/Page/Frontpage.html +++ b/web/typo3conf/ext/ep_theme/Resources/Private/Layouts/Page/Frontpage.html @@ -19,5 +19,5 @@ - + diff --git a/web/typo3conf/ext/ep_theme/Resources/Private/Layouts/Page/FrontpageEvent.html b/web/typo3conf/ext/ep_theme/Resources/Private/Layouts/Page/FrontpageEvent.html index 07a1bdc8..32683d3d 100644 --- a/web/typo3conf/ext/ep_theme/Resources/Private/Layouts/Page/FrontpageEvent.html +++ b/web/typo3conf/ext/ep_theme/Resources/Private/Layouts/Page/FrontpageEvent.html @@ -15,5 +15,5 @@ - + diff --git a/web/typo3conf/ext/ep_theme/Resources/Private/Layouts/Page/Search.html b/web/typo3conf/ext/ep_theme/Resources/Private/Layouts/Page/Search.html index 76f02b65..38285d8b 100644 --- a/web/typo3conf/ext/ep_theme/Resources/Private/Layouts/Page/Search.html +++ b/web/typo3conf/ext/ep_theme/Resources/Private/Layouts/Page/Search.html @@ -13,5 +13,5 @@ - + diff --git a/web/typo3conf/ext/ep_theme/Resources/Private/Layouts/Page/Subpage.html b/web/typo3conf/ext/ep_theme/Resources/Private/Layouts/Page/Subpage.html index 69f32f9a..8a7e18a9 100644 --- a/web/typo3conf/ext/ep_theme/Resources/Private/Layouts/Page/Subpage.html +++ b/web/typo3conf/ext/ep_theme/Resources/Private/Layouts/Page/Subpage.html @@ -21,5 +21,5 @@ - + diff --git a/web/typo3conf/ext/ep_theme/Resources/Private/Layouts/Page/SubpageSidebarLeft.html b/web/typo3conf/ext/ep_theme/Resources/Private/Layouts/Page/SubpageSidebarLeft.html index a1c7df51..dba29fe1 100644 --- a/web/typo3conf/ext/ep_theme/Resources/Private/Layouts/Page/SubpageSidebarLeft.html +++ b/web/typo3conf/ext/ep_theme/Resources/Private/Layouts/Page/SubpageSidebarLeft.html @@ -34,5 +34,5 @@ - + diff --git a/web/typo3conf/ext/ep_theme/Resources/Private/Layouts/Page/SubpageSidebarLeftEvent.html b/web/typo3conf/ext/ep_theme/Resources/Private/Layouts/Page/SubpageSidebarLeftEvent.html index 0b6cd442..9c370ace 100644 --- a/web/typo3conf/ext/ep_theme/Resources/Private/Layouts/Page/SubpageSidebarLeftEvent.html +++ b/web/typo3conf/ext/ep_theme/Resources/Private/Layouts/Page/SubpageSidebarLeftEvent.html @@ -26,5 +26,5 @@ - + diff --git a/web/typo3conf/ext/ep_theme/Resources/Private/Layouts/Page/SubpageSidebarRight.html b/web/typo3conf/ext/ep_theme/Resources/Private/Layouts/Page/SubpageSidebarRight.html index 3e538e0e..13b367b6 100644 --- a/web/typo3conf/ext/ep_theme/Resources/Private/Layouts/Page/SubpageSidebarRight.html +++ b/web/typo3conf/ext/ep_theme/Resources/Private/Layouts/Page/SubpageSidebarRight.html @@ -36,5 +36,5 @@ - + diff --git a/web/typo3conf/ext/ep_theme/Resources/Private/Layouts/Page/SubpageSidebarRightEvent.html b/web/typo3conf/ext/ep_theme/Resources/Private/Layouts/Page/SubpageSidebarRightEvent.html index b1413cc1..7db010ed 100644 --- a/web/typo3conf/ext/ep_theme/Resources/Private/Layouts/Page/SubpageSidebarRightEvent.html +++ b/web/typo3conf/ext/ep_theme/Resources/Private/Layouts/Page/SubpageSidebarRightEvent.html @@ -26,5 +26,5 @@ - + diff --git a/web/typo3conf/ext/ep_theme/Resources/Private/Partials/Config.html b/web/typo3conf/ext/ep_theme/Resources/Private/Partials/Config.html index 5f167a27..b76db006 100644 --- a/web/typo3conf/ext/ep_theme/Resources/Private/Partials/Config.html +++ b/web/typo3conf/ext/ep_theme/Resources/Private/Partials/Config.html @@ -1,6 +1,7 @@ diff --git a/web/typo3conf/ext/ep_theme/Resources/Private/Partials/Topnav.html b/web/typo3conf/ext/ep_theme/Resources/Private/Partials/Topnav.html index 2d9f322d..7f0b0f9e 100644 --- a/web/typo3conf/ext/ep_theme/Resources/Private/Partials/Topnav.html +++ b/web/typo3conf/ext/ep_theme/Resources/Private/Partials/Topnav.html @@ -10,7 +10,9 @@
  • - {menuitem.title -> ep:topnavItem()} + {menuitem.title -> ep:topnavItem()}