From cb5d264dcbbd5736f06ee90f46015948f468b3d3 Mon Sep 17 00:00:00 2001 From: Steffen Thierock Date: Fri, 28 Oct 2016 13:55:59 +0200 Subject: [PATCH 1/3] fix for missing slash issue on path forwarding --- Classes/Domain/Model/Redirect.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Classes/Domain/Model/Redirect.php b/Classes/Domain/Model/Redirect.php index 4b3985e..76a16a3 100644 --- a/Classes/Domain/Model/Redirect.php +++ b/Classes/Domain/Model/Redirect.php @@ -232,7 +232,7 @@ protected function constructUrlForExternal() */ protected function constructUrlForPath($scheme, $host, $oldPath) { - $needle = '/'.preg_quote($this->path, '/').'/'; + $needle = '/'.preg_quote(trim($this->path, '/'), '/').'/'; $newPath = preg_replace($needle, trim($this->forwardUrl, '/'), $oldPath, 1); From e07f1d1a73a0f47bd4f31d046fa096279cb0ed1e Mon Sep 17 00:00:00 2001 From: Steffen Thierock Date: Wed, 30 Nov 2016 18:06:26 +0100 Subject: [PATCH 2/3] new field additional_params for internal page forwarding --- Classes/Domain/Model/Redirect.php | 12 +++++++++++- Classes/Domain/Repository/RedirectRepository.php | 2 ++ .../TCA/tx_urlforwarding_domain_model_redirect.php | 11 +++++++++++ Resources/Private/Language/TCA/Redirect.xlf | 6 ++++++ Resources/Private/Language/TCA/Redirect_csh.xlf | 11 +++++++++++ ext_tables.php | 7 +++++++ ext_tables.sql | 1 + 7 files changed, 49 insertions(+), 1 deletion(-) create mode 100644 Resources/Private/Language/TCA/Redirect_csh.xlf create mode 100644 ext_tables.php diff --git a/Classes/Domain/Model/Redirect.php b/Classes/Domain/Model/Redirect.php index 76a16a3..d957913 100644 --- a/Classes/Domain/Model/Redirect.php +++ b/Classes/Domain/Model/Redirect.php @@ -55,6 +55,13 @@ class Redirect */ protected $forwardUrl; + /** + * Additional params for the URL + * + * @var string + */ + protected $additionalParams; + /** * The scheme * @@ -110,6 +117,7 @@ class Redirect * @param int $languageUid The language uid * @param int $type The type of redirect * @param string $forwardUrl The URL to be forwarded + * @param string $additionalParams Additional params for the URL * @param int $internalPage Uid of the internal page * @param string $externalUrl External URL * @param string $internalFile Path to the internal file @@ -120,6 +128,7 @@ public function __construct( $languageUid, $type, $forwardUrl, + $additionalParams, $internalPage, $externalUrl, $internalFile, @@ -129,6 +138,7 @@ public function __construct( $this->languageUid = (int) $languageUid; $this->type = (int) $type; $this->forwardUrl = (string) $forwardUrl; + $this->additionalParams = (string) $additionalParams; $this->internalPage = (int) $internalPage; $this->externalUrl = (string) $externalUrl; $this->internalFile = (string) $internalFile; @@ -198,7 +208,7 @@ protected function constructUrlForInternalPage() [ 'parameter' => $this->internalPage, 'forceAbsoluteUrl' => true, - 'additionalParams' => '&L=' . $this->languageUid + 'additionalParams' => '&L=' . $this->languageUid . $this->additionalParams ] ); } diff --git a/Classes/Domain/Repository/RedirectRepository.php b/Classes/Domain/Repository/RedirectRepository.php index a3e63dc..2e0476c 100755 --- a/Classes/Domain/Repository/RedirectRepository.php +++ b/Classes/Domain/Repository/RedirectRepository.php @@ -56,6 +56,7 @@ public function findByPathAndDomain($host, $path) tx_urlforwarding_domain_model_redirect.sys_language_uid, tx_urlforwarding_domain_model_redirect.type, tx_urlforwarding_domain_model_redirect.forward_url, + tx_urlforwarding_domain_model_redirect.additional_params, tx_urlforwarding_domain_model_redirect.internal_page, tx_urlforwarding_domain_model_redirect.external_url, tx_urlforwarding_domain_model_redirect.internal_file, @@ -110,6 +111,7 @@ public function findByPathAndDomain($host, $path) $result['sys_language_uid'], $result['type'], $result['forward_url'], + $result['additional_params'], $result['internal_page'], $result['external_url'], $result['internal_file'], diff --git a/Configuration/TCA/tx_urlforwarding_domain_model_redirect.php b/Configuration/TCA/tx_urlforwarding_domain_model_redirect.php index 0f52467..0649528 100644 --- a/Configuration/TCA/tx_urlforwarding_domain_model_redirect.php +++ b/Configuration/TCA/tx_urlforwarding_domain_model_redirect.php @@ -38,6 +38,7 @@ hidden, type, forward_url, + additional_params, internal_page, external_url, internal_file, @@ -57,6 +58,7 @@ --palette--;;general, forward_url, internal_page, + additional_params, http_status, domain, --div--;LLL:EXT:cms/locallang_ttc.xlf:tabs.access, @@ -305,6 +307,15 @@ ] ] ], + 'additional_params' => [ + 'exclude' => false, + 'label' => 'LLL:EXT:url_forwarding/Resources/Private/Language/TCA/Redirect.xlf:additional_params', + 'config' => [ + 'type' => 'input', + 'size' => 30, + 'eval' => 'trim', + ] + ], 'external_url' => [ 'exclude' => false, 'label' => 'LLL:EXT:url_forwarding/Resources/Private/Language/TCA/Redirect.xlf:external_url', diff --git a/Resources/Private/Language/TCA/Redirect.xlf b/Resources/Private/Language/TCA/Redirect.xlf index 3f15e3b..e9bfe08 100644 --- a/Resources/Private/Language/TCA/Redirect.xlf +++ b/Resources/Private/Language/TCA/Redirect.xlf @@ -45,6 +45,12 @@ Source + + Additional Params + + + For example: &utm_source=old_Domain&utm_medium=301 + New path diff --git a/Resources/Private/Language/TCA/Redirect_csh.xlf b/Resources/Private/Language/TCA/Redirect_csh.xlf new file mode 100644 index 0000000..085b4a5 --- /dev/null +++ b/Resources/Private/Language/TCA/Redirect_csh.xlf @@ -0,0 +1,11 @@ + + + +
+ + + + + + + \ No newline at end of file diff --git a/ext_tables.php b/ext_tables.php new file mode 100644 index 0000000..a73b57f --- /dev/null +++ b/ext_tables.php @@ -0,0 +1,7 @@ + Date: Wed, 30 Nov 2016 18:07:38 +0100 Subject: [PATCH 3/3] new field additional_params for internal page forwarding --- Resources/Private/Language/TCA/Redirect.xlf | 3 --- 1 file changed, 3 deletions(-) diff --git a/Resources/Private/Language/TCA/Redirect.xlf b/Resources/Private/Language/TCA/Redirect.xlf index e9bfe08..34c61b3 100644 --- a/Resources/Private/Language/TCA/Redirect.xlf +++ b/Resources/Private/Language/TCA/Redirect.xlf @@ -47,9 +47,6 @@ Additional Params - - - For example: &utm_source=old_Domain&utm_medium=301 New path