Make custom redirects domain based
This commit is contained in:
@@ -0,0 +1,26 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace EP\EpTrack\Hook;
|
||||||
|
|
||||||
|
use TYPO3\CMS\Core\Site\Entity\Site;
|
||||||
|
use TYPO3\CMS\Core\Site\SiteFinder;
|
||||||
|
use TYPO3\CMS\Core\Utility\GeneralUtility;
|
||||||
|
|
||||||
|
class ItemsProcFunc
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* @param $config
|
||||||
|
*/
|
||||||
|
public function user_domainItems(&$config)
|
||||||
|
{
|
||||||
|
$siteFinder = GeneralUtility::makeInstance(SiteFinder::class);
|
||||||
|
$domains = [
|
||||||
|
['*', '*'],
|
||||||
|
];
|
||||||
|
foreach ($siteFinder->getAllSites() as $site) {
|
||||||
|
/** @var Site $site */
|
||||||
|
$domains[] = [$site->getBase()->getHost(), $site->getBase()->getHost()];
|
||||||
|
}
|
||||||
|
$config['items'] = $domains;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -76,6 +76,7 @@ class TrackingMiddleware implements MiddlewareInterface
|
|||||||
{
|
{
|
||||||
/** @var NormalizedParams $params */
|
/** @var NormalizedParams $params */
|
||||||
$params = $request->getAttribute('normalizedParams');
|
$params = $request->getAttribute('normalizedParams');
|
||||||
|
$sourceHost = $params->getHttpHost();
|
||||||
$uri = strtok(strtolower($params->getRequestUri()), '?');
|
$uri = strtok(strtolower($params->getRequestUri()), '?');
|
||||||
|
|
||||||
if (substr($uri, -1) !== '/') {
|
if (substr($uri, -1) !== '/') {
|
||||||
@@ -88,6 +89,10 @@ class TrackingMiddleware implements MiddlewareInterface
|
|||||||
->select('*')
|
->select('*')
|
||||||
->from('tx_eptrack_domain_model_redirect')
|
->from('tx_eptrack_domain_model_redirect')
|
||||||
->where('redirect_from = LOWER(:uri)')
|
->where('redirect_from = LOWER(:uri)')
|
||||||
|
->andWhere($qb->expr()->orX(
|
||||||
|
$qb->expr()->eq('source_host', $qb->createNamedParameter('*')),
|
||||||
|
$qb->expr()->eq('source_host', $qb->createNamedParameter($sourceHost))
|
||||||
|
))
|
||||||
->andWhere('deleted = 0')
|
->andWhere('deleted = 0')
|
||||||
->andWhere('hidden = 0')
|
->andWhere('hidden = 0')
|
||||||
->setParameter('uri', $uri)
|
->setParameter('uri', $uri)
|
||||||
|
|||||||
+10
-1
@@ -28,7 +28,8 @@ return [
|
|||||||
],
|
],
|
||||||
'types' => [
|
'types' => [
|
||||||
'1' => [
|
'1' => [
|
||||||
'showitem' => 'hidden, label, redirect_from, target_page_uid, --palette--;;codes, --palette--;UTM;utm',
|
'showitem' => 'hidden, label, source_host, redirect_from, target_page_uid, --palette--;;codes,
|
||||||
|
--palette--;UTM;utm',
|
||||||
],
|
],
|
||||||
],
|
],
|
||||||
'palettes' => [
|
'palettes' => [
|
||||||
@@ -129,6 +130,14 @@ return [
|
|||||||
],
|
],
|
||||||
],
|
],
|
||||||
|
|
||||||
|
'source_host' => [
|
||||||
|
'label' => 'Domain',
|
||||||
|
'config' => [
|
||||||
|
'type' => 'select',
|
||||||
|
'renderType' => 'selectSingle',
|
||||||
|
'itemsProcFunc' => \EP\EpTrack\Hook\ItemsProcFunc::class.'->user_domainItems',
|
||||||
|
],
|
||||||
|
],
|
||||||
'label' => [
|
'label' => [
|
||||||
'exclude' => 0,
|
'exclude' => 0,
|
||||||
'label' => 'LLL:EXT:ep_track/Resources/Private/Language/locallang.xlf:tx_eptrack_domain_model_redirect.label',
|
'label' => 'LLL:EXT:ep_track/Resources/Private/Language/locallang.xlf:tx_eptrack_domain_model_redirect.label',
|
||||||
|
|||||||
@@ -8,6 +8,7 @@ CREATE TABLE tx_eptrack_domain_model_redirect (
|
|||||||
pid int(11) DEFAULT '0' NOT NULL,
|
pid int(11) DEFAULT '0' NOT NULL,
|
||||||
|
|
||||||
label varchar(255) DEFAULT '' NOT NULL,
|
label varchar(255) DEFAULT '' NOT NULL,
|
||||||
|
source_host varchar(255) DEFAULT '' NOT NULL,
|
||||||
redirect_from varchar(255) DEFAULT '' NOT NULL,
|
redirect_from varchar(255) DEFAULT '' NOT NULL,
|
||||||
target_page_uid varchar(255) DEFAULT '' NOT NULL,
|
target_page_uid varchar(255) DEFAULT '' NOT NULL,
|
||||||
tracking_code varchar(255) DEFAULT '' NOT NULL,
|
tracking_code varchar(255) DEFAULT '' NOT NULL,
|
||||||
|
|||||||
Reference in New Issue
Block a user