[BUGFIX] RTE: Multilingual classesAnchor titleText not possible 06/33506/2
authorStanislas Rolland <typo3@sjbr.ca>
Thu, 23 Oct 2014 16:20:58 +0000 (12:20 -0400)
committerStanislas Rolland <typo3@sjbr.ca>
Fri, 24 Oct 2014 14:36:11 +0000 (16:36 +0200)
Content language is not correctly set by RTE controller.

Releases: master, 6.2
Resolves: #62399
Change-Id: I85eb570dc266bdc71e4768a13d27c6f2937f7251
Reviewed-on: http://review.typo3.org/33488
Reviewed-by: Jan Kiesewetter <jan@t3easy.de>
Tested-by: Jan Kiesewetter <jan@t3easy.de>
Reviewed-by: Stanislas Rolland <typo3@sjbr.ca>
Tested-by: Stanislas Rolland <typo3@sjbr.ca>
(cherry picked from commit 07fb3d8afea5bd3ff35e34e7eac97d59502d9b8a)
Reviewed-on: http://review.typo3.org/33506

typo3/sysext/rtehtmlarea/Classes/Controller/FrontendRteController.php
typo3/sysext/rtehtmlarea/Classes/RteHtmlAreaBase.php

index 2c08853..d9d7e59 100644 (file)
@@ -153,44 +153,28 @@ class FrontendRteController extends \TYPO3\CMS\Rtehtmlarea\RteHtmlAreaBase {
                 * =======================================
                 */
                // Language
-               $TSFE->initLLvars();
-               $this->language = $TSFE->lang;
+               $GLOBALS['TSFE']->initLLvars();
+               $this->language = $GLOBALS['TSFE']->lang;
                $this->LOCAL_LANG = \TYPO3\CMS\Core\Utility\GeneralUtility::readLLfile('EXT:' . $this->ID . '/locallang.xml', $this->language);
-               if ($this->language == 'default' || !$this->language) {
+               if ($this->language === 'default' || !$this->language) {
                        $this->language = 'en';
                }
+               $this->contentISOLanguage = $GLOBALS['TSFE']->sys_language_isocode ?: 'en';
                $this->contentLanguageUid = max($row['sys_language_uid'], 0);
-               if (\TYPO3\CMS\Core\Utility\ExtensionManagementUtility::isLoaded('static_info_tables')) {
-                       if ($this->contentLanguageUid) {
-                               $tableA = 'sys_language';
-                               $tableB = 'static_languages';
-                               $languagesUidsList = $this->contentLanguageUid;
-                               $selectFields = $tableA . '.uid,' . $tableB . '.lg_iso_2,' . $tableB . '.lg_country_iso_2,' . $tableB . '.lg_typo3';
-                               $tableAB = $tableA . ' LEFT JOIN ' . $tableB . ' ON ' . $tableA . '.static_lang_isocode=' . $tableB . '.uid';
-                               $whereClause = $tableA . '.uid IN (' . $languagesUidsList . ') ';
-                               $whereClause .= \TYPO3\CMS\Backend\Utility\BackendUtility::BEenableFields($tableA);
-                               $whereClause .= \TYPO3\CMS\Backend\Utility\BackendUtility::deleteClause($tableA);
-                               $res = $TYPO3_DB->exec_SELECTquery($selectFields, $tableAB, $whereClause);
-                               while ($languageRow = $TYPO3_DB->sql_fetch_assoc($res)) {
-                                       $this->contentISOLanguage = strtolower(trim($languageRow['lg_iso_2']) . (trim($languageRow['lg_country_iso_2']) ? '_' . trim($languageRow['lg_country_iso_2']) : ''));
-                                       $this->contentTypo3Language = strtolower(trim($languageRow['lg_typo3']));
-                               }
-                       } else {
-                               $this->contentISOLanguage = $GLOBALS['TSFE']->sys_language_isocode ?: 'en';
-                               $selectFields = 'lg_iso_2, lg_typo3';
-                               $tableAB = 'static_languages';
-                               $whereClause = 'lg_iso_2 = ' . $TYPO3_DB->fullQuoteStr(strtoupper($this->contentISOLanguage), $tableAB);
-                               $res = $TYPO3_DB->exec_SELECTquery($selectFields, $tableAB, $whereClause);
-                               while ($languageRow = $TYPO3_DB->sql_fetch_assoc($res)) {
-                                       $this->contentTypo3Language = strtolower(trim($languageRow['lg_typo3']));
-                               }
+               if ($this->contentLanguageUid && \TYPO3\CMS\Core\Utility\ExtensionManagementUtility::isLoaded('static_info_tables')) {
+                       $tableA = 'sys_language';
+                       $tableB = 'static_languages';
+                       $selectFields = $tableA . '.uid,' . $tableB . '.lg_iso_2,' . $tableB . '.lg_country_iso_2';
+                       $tableAB = $tableA . ' LEFT JOIN ' . $tableB . ' ON ' . $tableA . '.static_lang_isocode=' . $tableB . '.uid';
+                       $whereClause = $tableA . '.uid = ' . intval($this->contentLanguageUid);
+                       $whereClause .= \TYPO3\CMS\Backend\Utility\BackendUtility::BEenableFields($tableA);
+                       $whereClause .= \TYPO3\CMS\Backend\Utility\BackendUtility::deleteClause($tableA);
+                       $res = $GLOBALS['TYPO3_DB']->exec_SELECTquery($selectFields, $tableAB, $whereClause);
+                       while ($languageRow = $GLOBALS['TYPO3_DB']->sql_fetch_assoc($res)) {
+                               $this->contentISOLanguage = strtolower(trim($languageRow['lg_iso_2']) . (trim($languageRow['lg_country_iso_2']) ? '_' . trim($languageRow['lg_country_iso_2']) : ''));
                        }
                }
-               $this->contentISOLanguage = $this->contentISOLanguage ?: ($GLOBALS['TSFE']->sys_language_isocode ?: 'en');
-               $this->contentTypo3Language = $this->contentTypo3Language ?: $GLOBALS['TSFE']->lang;
-               if ($this->contentTypo3Language == 'default') {
-                       $this->contentTypo3Language = 'en';
-               }
+               $this->contentTypo3Language = $this->contentISOLanguage;
                // Character set
                $this->charset = $TSFE->renderCharset;
                $this->OutputCharset = $TSFE->metaCharset ?: $TSFE->renderCharset;
index 1fe7a89..f607f8e 100644 (file)
@@ -389,41 +389,41 @@ class RteHtmlAreaBase extends \TYPO3\CMS\Backend\Rte\AbstractRte {
                         * =======================================
                         */
                        // Languages: interface and content
-                       $this->language = $LANG->lang;
-                       if ($this->language == 'default' || !$this->language) {
+                       $this->language = $GLOBALS['LANG']->lang;
+                       if ($this->language === 'default' || !$this->language) {
                                $this->language = 'en';
                        }
-                       $this->contentTypo3Language = $this->language == 'en' ? 'default' : $this->language;
-                       $this->contentISOLanguage = 'en';
                        $this->contentLanguageUid = max($row['sys_language_uid'], 0);
-                       if (\TYPO3\CMS\Core\Utility\ExtensionManagementUtility::isLoaded('static_info_tables')) {
-                               if ($this->contentLanguageUid) {
+                       if ($this->contentLanguageUid) {
+                               $this->contentISOLanguage = $this->language;
+                               if (\TYPO3\CMS\Core\Utility\ExtensionManagementUtility::isLoaded('static_info_tables')) {
                                        $tableA = 'sys_language';
                                        $tableB = 'static_languages';
-                                       $languagesUidsList = $this->contentLanguageUid;
-                                       $selectFields = $tableA . '.uid,' . $tableB . '.lg_iso_2,' . $tableB . '.lg_country_iso_2,' . $tableB . '.lg_typo3';
+                                       $selectFields = $tableA . '.uid,' . $tableB . '.lg_iso_2,' . $tableB . '.lg_country_iso_2';
                                        $tableAB = $tableA . ' LEFT JOIN ' . $tableB . ' ON ' . $tableA . '.static_lang_isocode=' . $tableB . '.uid';
-                                       $whereClause = $tableA . '.uid IN (' . $languagesUidsList . ') ';
+                                       $whereClause = $tableA . '.uid = ' . intval($this->contentLanguageUid);
                                        $whereClause .= BackendUtility::BEenableFields($tableA);
                                        $whereClause .= BackendUtility::deleteClause($tableA);
-                                       $res = $TYPO3_DB->exec_SELECTquery($selectFields, $tableAB, $whereClause);
-                                       while ($languageRow = $TYPO3_DB->sql_fetch_assoc($res)) {
+                                       $res = $GLOBALS['TYPO3_DB']->exec_SELECTquery($selectFields, $tableAB, $whereClause);
+                                       while ($languageRow = $GLOBALS['TYPO3_DB']->sql_fetch_assoc($res)) {
                                                $this->contentISOLanguage = strtolower(trim($languageRow['lg_iso_2']) . (trim($languageRow['lg_country_iso_2']) ? '_' . trim($languageRow['lg_country_iso_2']) : ''));
-                                               $this->contentTypo3Language = trim($languageRow['lg_typo3']) ? strtolower(trim($languageRow['lg_typo3'])) : 'default';
-                                       }
-                               } else {
-                                       $this->contentISOLanguage = trim($this->thisConfig['defaultContentLanguage']) ?: 'en';
-                                       $selectFields = 'lg_iso_2, lg_typo3';
-                                       $tableAB = 'static_languages';
-                                       $whereClause = 'lg_iso_2 = ' . $TYPO3_DB->fullQuoteStr(strtoupper($this->contentISOLanguage), $tableAB);
-                                       $res = $TYPO3_DB->exec_SELECTquery($selectFields, $tableAB, $whereClause);
-                                       while ($languageRow = $TYPO3_DB->sql_fetch_assoc($res)) {
-                                               $this->contentTypo3Language = trim($languageRow['lg_typo3']) ? strtolower(trim($languageRow['lg_typo3'])) : 'default';
                                        }
                                }
+                       } else {
+                               $this->contentISOLanguage = trim($this->thisConfig['defaultContentLanguage']) ?: 'en';
+                               $languageCodeParts = explode('_', $this->contentISOLanguage);
+                               $this->contentISOLanguage = strtolower($languageCodeParts[0]) . ($languageCodeParts[1] ? '_' . strtoupper($languageCodeParts[1]) : '');
+                               // Find the configured language in the list of localization locales
+                               /** @var $locales \TYPO3\CMS\Core\Localization\Locales */
+                               $locales = GeneralUtility::makeInstance('TYPO3\\CMS\\Core\\Localization\\Locales');
+                               // If not found, default to 'en'
+                               if (!in_array($this->contentISOLanguage, $locales->getLocales())) {
+                                       $this->contentISOLanguage = 'en';
+                               }
                        }
                        // Create content laguage service
                        $this->contentLanguageService = GeneralUtility::makeInstance('TYPO3\\CMS\\Lang\\LanguageService');
+                       $this->contentTypo3Language = $this->contentISOLanguage === 'en' ? 'default' : $this->contentISOLanguage;
                        $this->contentLanguageService->init($this->contentTypo3Language);
                        /* =======================================
                         * TOOLBAR CONFIGURATION