Fixed bug #14397: htmlArea RTE: Incorrect encoding of some labels when BE is not...
authorStanislas Rolland <typo3@sjbr.ca>
Thu, 3 Jun 2010 21:41:58 +0000 (21:41 +0000)
committerStanislas Rolland <typo3@sjbr.ca>
Thu, 3 Jun 2010 21:41:58 +0000 (21:41 +0000)
git-svn-id: https://svn.typo3.org/TYPO3v4/Core/trunk@7802 709f56b5-9817-0410-a4d7-c38de5d9e867

ChangeLog
typo3/sysext/rtehtmlarea/ChangeLog
typo3/sysext/rtehtmlarea/extensions/BlockElements/class.tx_rtehtmlarea_blockelements.php
typo3/sysext/rtehtmlarea/extensions/InlineElements/class.tx_rtehtmlarea_inlineelements.php
typo3/sysext/rtehtmlarea/extensions/Language/class.tx_rtehtmlarea_language.php
typo3/sysext/rtehtmlarea/extensions/SelectFont/class.tx_rtehtmlarea_selectfont.php
typo3/sysext/rtehtmlarea/extensions/TYPO3Color/class.tx_rtehtmlarea_typo3color.php

index 894699c..1471090 100755 (executable)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,7 @@
+2010-06-03  Stanislas Rolland  <typo3@sjbr.ca>
+
+       * Fixed bug #14397: htmlArea RTE: Incorrect encoding of some labels when BE is not utf-8
+
 2010-06-03  Xavier Perseguers  <typo3@perseguers.ch>
 
        * Fixed bug #14130: Switching pages with browsebox doesn't work (thanks to Mark Kuiphuis)
index 709b09d..8fc8d96 100644 (file)
@@ -1,3 +1,7 @@
+2010-06-03  Stanislas Rolland  <typo3@sjbr.ca>
+
+       * Fixed bug #14397: htmlArea RTE: Incorrect encoding of some labels when BE is not utf-8
+
 2010-05-27  Stanislas Rolland  <typo3@sjbr.ca>
 
        * Fixed bug #14489: htmlArea RTE: color dialogues do not show all configured colors
index c313d48..89adb5c 100644 (file)
@@ -165,28 +165,24 @@ class tx_rtehtmlarea_blockelements extends tx_rtehtmlareaapi {
                        if (!is_array($this->thisConfig['buttons.']) || !is_array($this->thisConfig['buttons.']['formatblock.']) || !$this->thisConfig['buttons.']['formatblock.']['orderItems']) {
                                asort($blockElementsOptions);
                        }
-                               // utf8-encode labels if we are responding to an IRRE ajax call
-                       if (!$this->htmlAreaRTE->is_FE() && $this->htmlAreaRTE->TCEform->inline->isAjaxCall) {
-                               foreach ($blockElementsOptions as $item => $label) {
-                                       $blockElementsOptions[$item] = $GLOBALS['LANG']->csConvObj->utf8_encode($label, $GLOBALS['LANG']->charSet);
-                               }
-                       }
                                // Generating the javascript options
                        $JSBlockElements = array();
                        $JSBlockElements[] = array($first, 'none');
                        foreach ($blockElementsOptions as $item => $label) {
                                $JSBlockElements[] = array($label, $item);
                        }
+                       if ($this->htmlAreaRTE->is_FE()) {
+                               $GLOBALS['TSFE']->csConvObj->convArray($JSBlockElements, $this->htmlAreaRTE->OutputCharset, 'utf-8');
+                       } else {
+                               $GLOBALS['LANG']->csConvObj->convArray($JSBlockElements, $GLOBALS['LANG']->charSet, 'utf-8');
+                       }
                        $registerRTEinJavascriptString .= '
                        RTEarea['.$RTEcounter.'].buttons.formatblock.options = ' . json_encode($JSBlockElements) . ';';
                }
                return $registerRTEinJavascriptString;
        }
-
-} // end of class
-
+}
 if (defined('TYPO3_MODE') && $TYPO3_CONF_VARS[TYPO3_MODE]['XCLASS']['ext/rtehtmlarea/extensions/BlockElements/class.tx_rtehtmlarea_blockelements.php']) {
        include_once($TYPO3_CONF_VARS[TYPO3_MODE]['XCLASS']['ext/rtehtmlarea/extensions/BlockElements/class.tx_rtehtmlarea_blockelements.php']);
 }
-
 ?>
\ No newline at end of file
index 935bec4..b15efd8 100644 (file)
@@ -195,18 +195,17 @@ class tx_rtehtmlarea_inlineelements extends tx_rtehtmlareaapi {
                        if (!is_array($this->thisConfig['buttons.']) || !is_array($this->thisConfig['buttons.']['formattext.']) || !$this->thisConfig['buttons.']['formattext.']['orderItems']) {
                                asort($inlineElementsOptions);
                        }
-                               // utf8-encode labels if we are responding to an IRRE ajax call
-                       if (!$this->htmlAreaRTE->is_FE() && $this->htmlAreaRTE->TCEform->inline->isAjaxCall) {
-                               foreach ($inlineElementsOptions as $item => $label) {
-                                       $inlineElementsOptions[$item] = $GLOBALS['LANG']->csConvObj->utf8_encode($label, $GLOBALS['LANG']->charSet);
-                               }
-                       }
                                // Generating the javascript options
                        $JSInlineElements = array();
                        $JSInlineElements[] = array($first, 'none');
                        foreach ($inlineElementsOptions as $item => $label) {
                                $JSInlineElements[] = array($label, $item);
                        }
+                       if ($this->htmlAreaRTE->is_FE()) {
+                               $GLOBALS['TSFE']->csConvObj->convArray($JSInlineElements, $this->htmlAreaRTE->OutputCharset, 'utf-8');
+                       } else {
+                               $GLOBALS['LANG']->csConvObj->convArray($JSInlineElements, $GLOBALS['LANG']->charSet, 'utf-8');
+                       }
                        $registerRTEinJavascriptString .= '
                        RTEarea['.$RTEcounter.'].buttons.formattext.options = ' . json_encode($JSInlineElements) . ';';
                }
index 4881d9c..899f66e 100644 (file)
@@ -90,6 +90,11 @@ class tx_rtehtmlarea_language extends tx_rtehtmlareaapi {
                        foreach ($languages as $key => $value) {
                                $languagesJSArray[] = array('text' => $key, 'value' => $value);
                        }
+                       if ($this->htmlAreaRTE->is_FE()) {
+                               $GLOBALS['TSFE']->csConvObj->convArray($languagesJSArray, $this->htmlAreaRTE->OutputCharset, 'utf-8');
+                       } else {
+                               $GLOBALS['LANG']->csConvObj->convArray($languagesJSArray, $GLOBALS['LANG']->charSet, 'utf-8');
+                       }
                        $languagesJSArray = json_encode(array('options' => $languagesJSArray));
                        $registerRTEinJavascriptString .= '
                        RTEarea['.$RTEcounter.'].buttons.'. $button .'.dataUrl = "' . $this->htmlAreaRTE->writeTemporaryFile('', $button . '_' . $this->htmlAreaRTE->contentLanguageUid, 'js', $languagesJSArray) . '";';
@@ -132,13 +137,17 @@ class tx_rtehtmlarea_language extends tx_rtehtmlareaapi {
                        $code = strtolower($row['lg_iso_2']).($row['lg_country_iso_2']?'-'.strtoupper($row['lg_country_iso_2']):'');
                        foreach ($titleFields as $titleField) {
                                if ($row[$titleField]) {
-                                       $nameArray[$code] = $this->htmlAreaRTE->is_FE() ? $GLOBALS['TSFE']->csConv($row[$titleField], $GLOBALS['TYPO3_CONF_VARS']['EXTCONF']['static_info_tables']['charset']) : ($this->htmlAreaRTE->TCEform->inline->isAjaxCall ? $GLOBALS['LANG']->csConvObj->utf8_encode($row[$titleField], $GLOBALS['LANG']->charSet) : $row[$titleField]);
-                                       $nameArray[$code] = $prefixLabelWithCode ? ($code . ' - ' . $nameArray[$code]) : ($postfixLabelWithCode ? ($nameArray[$code] . ' - ' . $code) : $nameArray[$code]);
+                                       $nameArray[$code] = $prefixLabelWithCode ? ($code . ' - ' . $row[$titleField]) : ($postfixLabelWithCode ? ($row[$titleField] . ' - ' . $code) : $row[$titleField]);
                                        break;
                                }
                        }
                }
                $GLOBALS['TYPO3_DB']->sql_free_result($res);
+               if ($this->htmlAreaRTE->is_FE()) {
+                       $GLOBALS['TSFE']->csConvObj->convArray($nameArray, $GLOBALS['TYPO3_CONF_VARS']['EXTCONF']['static_info_tables']['charset'], $this->htmlAreaRTE->OutputCharset);
+               } else {
+                       $GLOBALS['LANG']->csConvObj->convArray($nameArray, $GLOBALS['TYPO3_CONF_VARS']['EXTCONF']['static_info_tables']['charset'], $GLOBALS['LANG']->charSet);
+               }
                uasort($nameArray, 'strcoll');
                return $nameArray;
        }
index f3b4e0e..c509551 100644 (file)
@@ -135,9 +135,7 @@ class tx_rtehtmlarea_selectfont extends tx_rtehtmlareaapi {
                if ($this->htmlAreaRTE->is_FE()) {
                        $items['none'] = array($GLOBALS['TSFE']->getLLL((($buttonId == 'fontstyle') ? 'Default font' : 'Default size'), $this->LOCAL_LANG), 'none');
                } else {
-                       $items['none'] = array(($this->htmlAreaRTE->TCEform->inline->isAjaxCall
-                                       ? $GLOBALS['LANG']->csConvObj->utf8_encode($GLOBALS['LANG']->getLL(($buttonId == 'fontstyle') ? 'Default font' : 'Default size'), $GLOBALS['LANG']->charSet)
-                                       : $GLOBALS['LANG']->getLL(($buttonId == 'fontstyle') ? 'Default font' : 'Default size')), 'none');
+                       $items['none'] = array(($GLOBALS['LANG']->getLL(($buttonId == 'fontstyle') ? 'Default font' : 'Default size')), 'none');
                }
                        // Inserting and localizing default items
                if ($hideItems != '*') {
@@ -151,7 +149,6 @@ class tx_rtehtmlarea_selectfont extends tx_rtehtmlareaapi {
                                                if (!$label) {
                                                        $label = $name;
                                                }
-                                               $label = $this->htmlAreaRTE->TCEform->inline->isAjaxCall ? $GLOBALS['LANG']->csConvObj->utf8_encode($label, $GLOBALS['LANG']->charSet) : $label;
                                        }
                                        $items[$name] = array($label, $this->htmlAreaRTE->cleanList($value));
                                }
@@ -164,7 +161,6 @@ class tx_rtehtmlarea_selectfont extends tx_rtehtmlareaapi {
                                $name = substr($name,0,-1);
                                if (in_array($name, $addItems)) {
                                        $label = $this->htmlAreaRTE->getPageConfigLabel($conf['name'],0);
-                                       $label = (!$this->htmlAreaRTE->is_FE() && $this->htmlAreaRTE->TCEform->inline->isAjaxCall) ? $GLOBALS['LANG']->csConvObj->utf8_encode($label, $GLOBALS['LANG']->charSet) : $label;
                                        $items[$name] = array($label, $this->htmlAreaRTE->cleanList($conf['value']));
                                }
                        }
@@ -179,6 +175,11 @@ class tx_rtehtmlarea_selectfont extends tx_rtehtmlareaapi {
                foreach ($items as $name => $option) {
                        $itemsJSArray[] = array('text' => $option[0], 'value' => $option[1]);
                }
+               if ($this->htmlAreaRTE->is_FE()) {
+                       $GLOBALS['TSFE']->csConvObj->convArray($itemsJSArray, $this->htmlAreaRTE->OutputCharset, 'utf-8');
+               } else {
+                       $GLOBALS['LANG']->csConvObj->convArray($itemsJSArray, $GLOBALS['LANG']->charSet, 'utf-8');
+               }
                $itemsJSArray = json_encode(array('options' => $itemsJSArray));
                        // Adding to button JS configuration
                if (!is_array( $this->thisConfig['buttons.']) || !is_array($this->thisConfig['buttons.'][$buttonId . '.'])) {
index 5508266..ca09420 100644 (file)
@@ -94,7 +94,6 @@ class tx_rtehtmlarea_typo3color extends tx_rtehtmlareaapi {
                        foreach ($RTEProperties['colors.'] as $colorName => $conf) {
                                $colorName = substr($colorName, 0, -1);
                                $colorLabel = $this->htmlAreaRTE->getPageConfigLabel($conf['name'], 0);
-                               $colorLabel = (!$this->htmlAreaRTE->is_FE() && $this->htmlAreaRTE->TCEform->inline->isAjaxCall) ? $GLOBALS['LANG']->csConvObj->utf8_encode($colorLabel, $GLOBALS['LANG']->charSet) : $colorLabel;
                                $HTMLAreaColorname[$colorName] = array($colorLabel, strtoupper(substr($conf['value'], 1, 6)));
                        }
                }
@@ -107,6 +106,11 @@ class tx_rtehtmlarea_typo3color extends tx_rtehtmlareaapi {
                                        $HTMLAreaJSColors[] = $HTMLAreaColorname[$colorName];
                                }
                        }
+                       if ($this->htmlAreaRTE->is_FE()) {
+                               $GLOBALS['TSFE']->csConvObj->convArray($HTMLAreaJSColors, $this->htmlAreaRTE->OutputCharset, 'utf-8');
+                       } else {
+                               $GLOBALS['LANG']->csConvObj->convArray($HTMLAreaJSColors, $GLOBALS['LANG']->charSet, 'utf-8');
+                       }
                        $configureRTEInJavascriptString .= '
                        RTEarea['.$RTEcounter.'].colors = ' . json_encode($HTMLAreaJSColors) . ';';
                }