[BUGFIX] Clearing label through TS doesn't work
[Packages/TYPO3.CMS.git] / typo3 / sysext / frontend / Classes / Plugin / AbstractPlugin.php
index 70c736e..ac90986 100644 (file)
@@ -98,6 +98,16 @@ class AbstractPlugin {
         */
        public $LOCAL_LANG = array();
 
+       /**
+        * Contains those LL keys, which have been set to (empty) in TypoScript.
+        * This is necessary, as we cannot distinguish between a nonexisting
+        * translation and a label that has been cleared by TS.
+        * In both cases ['key'][0]['target'] is "".
+        *
+        * @var array
+        */
+       protected $LOCAL_LANG_UNSET = array();
+
        // Local Language content charset for individual labels (overriding)
        /**
         * @todo Define visibility
@@ -865,7 +875,9 @@ class AbstractPlugin {
         */
        public function pi_getLL($key, $alternativeLabel = '', $hsc = FALSE) {
                $word = NULL;
-               if (!empty($this->LOCAL_LANG[$this->LLkey][$key][0]['target'])) {
+               if (!empty($this->LOCAL_LANG[$this->LLkey][$key][0]['target'])
+                       || isset($this->LOCAL_LANG_UNSET[$this->LLkey][$key])
+               ) {
                        // The "from" charset of csConv() is only set for strings from TypoScript via _LOCAL_LANG
                        if (isset($this->LOCAL_LANG_charset[$this->LLkey][$key])) {
                                $word = $GLOBALS['TSFE']->csConv($this->LOCAL_LANG[$this->LLkey][$key][0]['target'], $this->LOCAL_LANG_charset[$this->LLkey][$key]);
@@ -876,7 +888,9 @@ class AbstractPlugin {
                        $alternativeLanguageKeys = \TYPO3\CMS\Core\Utility\GeneralUtility::trimExplode(',', $this->altLLkey, TRUE);
                        $alternativeLanguageKeys = array_reverse($alternativeLanguageKeys);
                        foreach ($alternativeLanguageKeys as $languageKey) {
-                               if (!empty($this->LOCAL_LANG[$languageKey][$key][0]['target'])) {
+                               if (!empty($this->LOCAL_LANG[$languageKey][$key][0]['target'])
+                                       || isset($this->LOCAL_LANG_UNSET[$languageKey][$key])
+                               ) {
                                        // Alternative language translation for key exists
                                        $word = $this->LOCAL_LANG[$languageKey][$key][0]['target'];
                                        // The "from" charset of csConv() is only set for strings from TypoScript via _LOCAL_LANG
@@ -891,7 +905,9 @@ class AbstractPlugin {
                        }
                }
                if ($word === NULL) {
-                       if (!empty($this->LOCAL_LANG['default'][$key][0]['target'])) {
+                       if (!empty($this->LOCAL_LANG['default'][$key][0]['target'])
+                               || isset($this->LOCAL_LANG_UNSET['default'][$key])
+                       ) {
                                // Get default translation (without charset conversion, english)
                                $word = $this->LOCAL_LANG['default'][$key][0]['target'];
                        } else {
@@ -928,16 +944,20 @@ class AbstractPlugin {
                                }
                        }
                        // Overlaying labels from TypoScript (including fictitious language keys for non-system languages!):
-                       $confLL = $this->conf['_LOCAL_LANG.'];
-                       if (is_array($confLL)) {
-                               foreach ($confLL as $languageKey => $languageArray) {
-                                       // Don't process label if the langue is not loaded
+                       if (isset($this->conf['_LOCAL_LANG.'])) {
+                               // Clear the "unset memory"
+                               $this->LOCAL_LANG_UNSET = array();
+                               foreach ($this->conf['_LOCAL_LANG.'] as $languageKey => $languageArray) {
+                                       // Remove the dot after the language key
                                        $languageKey = substr($languageKey, 0, -1);
-                                       if (is_array($languageArray) && is_array($this->LOCAL_LANG[$languageKey])) {
-                                               // Remove the dot after the language key
+                                       // Don't process label if the language is not loaded
+                                       if (is_array($languageArray) && isset($this->LOCAL_LANG[$languageKey])) {
                                                foreach ($languageArray as $labelKey => $labelValue) {
                                                        if (!is_array($labelValue)) {
                                                                $this->LOCAL_LANG[$languageKey][$labelKey][0]['target'] = $labelValue;
+                                                               if ($labelValue === '') {
+                                                                       $this->LOCAL_LANG_UNSET[$languageKey][$labelKey] = '';
+                                                               }
                                                                $this->LOCAL_LANG_charset[$languageKey][$labelKey] = 'utf-8';
                                                        }
                                                }