[TASK] Change language handling with realurl
authorChristian Futterlieb <christian@futterlieb.ch>
Wed, 6 Apr 2016 09:47:36 +0000 (11:47 +0200)
committerChristian Futterlieb <christian@futterlieb.ch>
Tue, 10 May 2016 09:00:15 +0000 (11:00 +0200)
* Do not xclass realurl >2.0.11
* Remove the registers and reproduce the realurl behaviour

Classes/Controller/PagenotfoundController.php
Classes/Realurl/Decoder/UrlDecoder.php
Classes/Realurl/RealurlV1.php
ext_localconf.php

index 43f6228..3454cc5 100644 (file)
@@ -766,32 +766,13 @@ class PagenotfoundController
      */
     protected function _getLanguageQueryString()
     {
-        $languageUid = null;
-
         if(!empty($this->_forceLanguage)) {
-            $languageUid = $this->_forceLanguage;
-        } elseif(($languageUidFromRealurl = $this->_getLanguageUidFromRealurl())) {
-            $languageUid = $languageUidFromRealurl;
-        }
-
-        if ($languageUid) {
-            return '&' . $this->_languageParam . '=' . $languageUid;
+            return '&' . rawurlencode($this->_languageParam) . '=' . rawurlencode($this->_forceLanguage);
         }
         return '';
     }
 
     /**
-     * @return integer|null
-     */
-    protected function _getLanguageUidFromRealurl()
-    {
-        if (\TYPO3\CMS\Core\Utility\ExtensionManagementUtility::isLoaded('realurl') && array_key_exists('realurl_detectedLanguageId', $this->_getTyposcriptFrontendController()->register)) {
-            return (int) $this->_getTyposcriptFrontendController()->register['realurl_detectedLanguageId'];
-        }
-        return null;
-    }
-
-    /**
      * @return \TYPO3\CMS\Frontend\Controller\TypoScriptFrontendController
      */
     protected function _getTyposcriptFrontendController()
index 540e3c4..0d771e2 100644 (file)
@@ -36,7 +36,7 @@ namespace Aaw\Pagenotfoundhandling\Realurl\Decoder;
 /**
  * Realurl UrlDecoder XCLASS
  *
- * It is used for realurl versions >=2.0 (and <2.0.x ???).
+ * It is used for realurl versions >=2.0 (and <2.0.12).
  *
  * For older realurl versions, \Aaw\Pagenotfoundhandling\Realurl\RealurlV1 is
  * used for the very same job.
@@ -55,8 +55,9 @@ class UrlDecoder extends \DmitryDulepov\Realurl\Decoder\UrlDecoder
      */
     protected function throw404($errorMessage)
     {
-        // Register the detectedLanguageId
-        $this->caller->register['realurl_detectedLanguageId'] = $this->detectedLanguageId;
+        // Set language to allow localized error pages
+        $_GET['L'] = $this->detectedLanguageId;
+
         return parent::throw404($errorMessage);
     }
 }
index 57a2247..0212037 100644 (file)
@@ -56,10 +56,11 @@ class RealurlV1 extends \tx_realurl
      */
     public function decodeSpURL_throw404($msg)
     {
-        // Register the detectedLanguageId
+        // Set language to allow localized error pages
         if ($this->detectedLanguage > 0) {
-            $this->pObj->register['realurl_detectedLanguageId'] = $this->detectedLanguage;
+            $_GET['L'] = $this->detectedLanguage;
         }
+
         return parent::decodeSpURL_throw404($msg);
     }
 }
index 325e6e2..5564568 100644 (file)
@@ -7,15 +7,15 @@ if (!defined ('TYPO3_MODE')) {
 $GLOBALS['TYPO3_CONF_VARS']['FE']['pageNotFound_handling'] = 'USER_FUNCTION:Aaw\\Pagenotfoundhandling\\Controller\\PagenotfoundController->main';
 
 // Register an XCLASS for the realurl UrlDecoder
+// Realurl versions below 1.12.8 are not supported, as of realurl version 2.0.12 $_GET['L'] will be provided anyway
 if (\TYPO3\CMS\Core\Utility\ExtensionManagementUtility::isLoaded('realurl')) {
     $packageManager = \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance('TYPO3\\CMS\\Core\\Package\\PackageManager');
-    //$packageManager instanceof \TYPO3\CMS\Core\Package\PackageManager;
     $realurlVersion = $packageManager->getPackage('realurl')->getPackageMetaData()->getVersion();
-    if(version_compare($realurlVersion, '2.0') >= 0) {
+    if(version_compare($realurlVersion, '2.0') >= 0 && version_compare($realurlVersion, '2.0.12') < 0) {
         $GLOBALS['TYPO3_CONF_VARS']['SYS']['Objects']['DmitryDulepov\\Realurl\\Decoder\\UrlDecoder'] = array(
             'className' => 'Aaw\\Pagenotfoundhandling\\Realurl\\Decoder\\UrlDecoder',
         );
-    } elseif(version_compare($realurlVersion, '1.12.8') >= 0) {
+    } elseif(version_compare($realurlVersion, '2.0') < 0 && version_compare($realurlVersion, '1.12.8') >= 0) {
         // version 1.12.8 was the first realurl version with official TYPO3 6.2 support
         $GLOBALS['TYPO3_CONF_VARS']['SYS']['Objects']['tx_realurl'] = array(
             'className' => 'Aaw\\Pagenotfoundhandling\\Realurl\\RealurlV1',