Fixed bug #17349: htmlArea RTE: JS error when using "Edit element"
authorStanislas Rolland <typo3@sjbr.ca>
Tue, 1 Feb 2011 16:50:53 +0000 (16:50 +0000)
committerStanislas Rolland <typo3@sjbr.ca>
Tue, 1 Feb 2011 16:50:53 +0000 (16:50 +0000)
git-svn-id: https://svn.typo3.org/TYPO3v4/Core/branches/TYPO3_4-5@10362 709f56b5-9817-0410-a4d7-c38de5d9e867

ChangeLog
typo3/sysext/rtehtmlarea/ChangeLog
typo3/sysext/rtehtmlarea/extensions/Language/class.tx_rtehtmlarea_language.php
typo3/sysext/rtehtmlarea/htmlarea/plugins/EditElement/edit-element.js

index b485d81..ae651a2 100755 (executable)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,6 +1,7 @@
 2011-02-01  Stanislas Rolland  <typo3@sjbr.ca>
 
        * Fixed bug #17373: Standalone images in RTE-enabled field not rendered in frontend
+       * Fixed bug #17349: htmlArea RTE: JS error when using "Edit element"
 
 2011-02-01  Steffen Kamper  <steffen@typo3.org>
 
index 6f076f3..b50983b 100644 (file)
@@ -1,3 +1,7 @@
+2011-02-01  Stanislas Rolland  <typo3@sjbr.ca>
+
+       * Fixed bug #17349: htmlArea RTE: JS error when using "Edit element"
+
 2011-01-21  Stanislas Rolland  <typo3@sjbr.ca>
 
        * Fixed bug #16975: htmlArea RTE: Use parentNode rather than parentElement
index 2c38bdd..05743a6 100644 (file)
@@ -71,31 +71,29 @@ class tx_rtehtmlarea_language extends tx_rtehtmlarea_api {
        public function buildJavascriptConfiguration($RTEcounter) {
                $button = 'language';
                $registerRTEinJavascriptString = '';
-               if (in_array($button, $this->toolbar)) {
-                       if (!is_array( $this->thisConfig['buttons.']) || !is_array($this->thisConfig['buttons.'][$button . '.'])) {
-                               $registerRTEinJavascriptString .= '
-                       RTEarea['.$RTEcounter.'].buttons.'. $button .' = new Object();';
-                       }
-                       if ($this->htmlAreaRTE->is_FE()) {
-                               $first = $GLOBALS['TSFE']->getLLL('No language mark',$this->LOCAL_LANG);
-                       } else {
-                               $first = $GLOBALS['LANG']->getLL('No language mark');
-                       }
-                       $languages = array('none' => $first);
-                       $languages = array_flip(array_merge($languages, $this->getLanguages()));
-                       $languagesJSArray = array();
-                       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));
+               if (!is_array( $this->thisConfig['buttons.']) || !is_array($this->thisConfig['buttons.'][$button . '.'])) {
                        $registerRTEinJavascriptString .= '
-                       RTEarea['.$RTEcounter.'].buttons.'. $button .'.dataUrl = "' . $this->htmlAreaRTE->writeTemporaryFile('', $button . '_' . $this->htmlAreaRTE->contentLanguageUid, 'js', $languagesJSArray) . '";';
+               RTEarea['.$RTEcounter.'].buttons.'. $button .' = new Object();';
+               }
+               if ($this->htmlAreaRTE->is_FE()) {
+                       $first = $GLOBALS['TSFE']->getLLL('No language mark',$this->LOCAL_LANG);
+               } else {
+                       $first = $GLOBALS['LANG']->getLL('No language mark');
+               }
+               $languages = array('none' => $first);
+               $languages = array_flip(array_merge($languages, $this->getLanguages()));
+               $languagesJSArray = array();
+               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) . '";';
                return $registerRTEinJavascriptString;
        }
        /**
@@ -107,45 +105,47 @@ class tx_rtehtmlarea_language extends tx_rtehtmlarea_api {
         * @return      array           An array of names of languages
         */
        function getLanguages() {
-               $where = '1=1';
-               $table = 'static_languages';
-               $lang = tx_staticinfotables_div::getCurrentLanguage();
                $nameArray = array();
-               $titleFields = tx_staticinfotables_div::getTCAlabelField($table, TRUE, $lang);
-               $prefixedTitleFields = array();
-               foreach ($titleFields as $titleField) {
-                       $prefixedTitleFields[] = $table.'.'.$titleField;
-               }
-               $labelFields = implode(',', $prefixedTitleFields);
-                       // Restrict to certain languages
-               if (is_array($this->thisConfig['buttons.']) && is_array($this->thisConfig['buttons.']['language.']) && isset($this->thisConfig['buttons.']['language.']['restrictToItems'])) {
-                       $languageList = implode("','", t3lib_div::trimExplode(',', $GLOBALS['TYPO3_DB']->fullQuoteStr(strtoupper($this->thisConfig['buttons.']['language.']['restrictToItems']), $table)));
-                       $where .= ' AND '. $table . '.lg_iso_2 IN (' . $languageList . ')';
-               }
-               $res = $GLOBALS['TYPO3_DB']->exec_SELECTquery(
-                       $table.'.lg_iso_2,'.$table.'.lg_country_iso_2,'.$labelFields,
-                       $table,
-                       $where.' AND lg_constructed = 0 '.
-                       ($this->htmlAreaRTE->is_FE() ? $GLOBALS['TSFE']->sys_page->enableFields($table) : t3lib_BEfunc::BEenableFields($table) .  t3lib_BEfunc::deleteClause($table))
-                       );
-               $prefixLabelWithCode = !$this->thisConfig['buttons.']['language.']['prefixLabelWithCode'] ? false : true;
-               $postfixLabelWithCode = !$this->thisConfig['buttons.']['language.']['postfixLabelWithCode'] ? false : true;
-               while ($row = $GLOBALS['TYPO3_DB']->sql_fetch_assoc($res)) {
-                       $code = strtolower($row['lg_iso_2']).($row['lg_country_iso_2']?'-'.strtoupper($row['lg_country_iso_2']):'');
+               if (t3lib_extMgm::isLoaded('static_info_tables')) {
+                       $where = '1=1';
+                       $table = 'static_languages';
+                       $lang = tx_staticinfotables_div::getCurrentLanguage();
+                       $titleFields = tx_staticinfotables_div::getTCAlabelField($table, TRUE, $lang);
+                       $prefixedTitleFields = array();
                        foreach ($titleFields as $titleField) {
-                               if ($row[$titleField]) {
-                                       $nameArray[$code] = $prefixLabelWithCode ? ($code . ' - ' . $row[$titleField]) : ($postfixLabelWithCode ? ($row[$titleField] . ' - ' . $code) : $row[$titleField]);
-                                       break;
+                               $prefixedTitleFields[] = $table.'.'.$titleField;
+                       }
+                       $labelFields = implode(',', $prefixedTitleFields);
+                               // Restrict to certain languages
+                       if (is_array($this->thisConfig['buttons.']) && is_array($this->thisConfig['buttons.']['language.']) && isset($this->thisConfig['buttons.']['language.']['restrictToItems'])) {
+                               $languageList = implode("','", t3lib_div::trimExplode(',', $GLOBALS['TYPO3_DB']->fullQuoteStr(strtoupper($this->thisConfig['buttons.']['language.']['restrictToItems']), $table)));
+                               $where .= ' AND '. $table . '.lg_iso_2 IN (' . $languageList . ')';
+                       }
+                       $res = $GLOBALS['TYPO3_DB']->exec_SELECTquery(
+                               $table.'.lg_iso_2,'.$table.'.lg_country_iso_2,'.$labelFields,
+                               $table,
+                               $where.' AND lg_constructed = 0 '.
+                               ($this->htmlAreaRTE->is_FE() ? $GLOBALS['TSFE']->sys_page->enableFields($table) : t3lib_BEfunc::BEenableFields($table) .  t3lib_BEfunc::deleteClause($table))
+                               );
+                       $prefixLabelWithCode = !$this->thisConfig['buttons.']['language.']['prefixLabelWithCode'] ? false : true;
+                       $postfixLabelWithCode = !$this->thisConfig['buttons.']['language.']['postfixLabelWithCode'] ? false : true;
+                       while ($row = $GLOBALS['TYPO3_DB']->sql_fetch_assoc($res)) {
+                               $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] = $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');
                }
-               $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 90641b2..5d33533 100644 (file)
@@ -316,7 +316,11 @@ HTMLArea.EditElement = HTMLArea.Plugin.extend({
        buildLanguageFieldsetConfig: function (element) {
                var itemsConfig = [];
                var languagePlugin = this.getPluginInstance('Language');
-               if (this.removedProperties.indexOf('language') == -1) {
+               var languageConfigurationUrl;
+               if (this.editorConfiguration.buttons && this.editorConfiguration.buttons.language && this.editorConfiguration.buttons.language.dataUrl) {
+                       languageConfigurationUrl = this.editorConfiguration.buttons.language.dataUrl;
+               }
+               if (languagePlugin && languageConfigurationUrl && this.removedProperties.indexOf('language') == -1) {
                        var selectedLanguage = !Ext.isEmpty(element) ? languagePlugin.getLanguageAttribute(element) : 'none';
                        function initLanguageStore (store) {
                                if (selectedLanguage !== 'none') {
@@ -332,7 +336,7 @@ HTMLArea.EditElement = HTMLArea.Plugin.extend({
                                autoLoad: true,
                                root: 'options',
                                fields: [ { name: 'text'}, { name: 'value'} ],
-                               url: this.getDropDownConfiguration('Language').dataUrl,
+                               url: languageConfigurationUrl,
                                listeners: {
                                        load: initLanguageStore
                                }