Fixed bug #17677: htmlArea RTE: Classes configuration is loaded twice
authorstan <stan@709f56b5-9817-0410-a4d7-c38de5d9e867>
Sun, 20 Feb 2011 04:18:31 +0000 (04:18 +0000)
committerstan <stan@709f56b5-9817-0410-a4d7-c38de5d9e867>
Sun, 20 Feb 2011 04:18:31 +0000 (04:18 +0000)
git-svn-id: https://svn.typo3.org/TYPO3v4/Core/trunk@10502 709f56b5-9817-0410-a4d7-c38de5d9e867

ChangeLog
typo3/sysext/rtehtmlarea/ChangeLog
typo3/sysext/rtehtmlarea/class.tx_rtehtmlarea_base.php
typo3/sysext/rtehtmlarea/extensions/TYPO3Link/class.tx_rtehtmlarea_typo3link.php
typo3/sysext/rtehtmlarea/pi2/class.tx_rtehtmlarea_pi2.php

index a7cf70e..bd48240 100755 (executable)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,6 +1,7 @@
 2011-02-19  Stanislas Rolland  <typo3@sjbr.ca>
 
        * Fixed bug #17676: htmlArea RTE: Some combo stores are loaded twice
+       * Fixed bug #17677: htmlArea RTE: Classes configuration is loaded twice
 
 2011-02-19  Christian Kuhn  <lolli@schwarzbuch>
 
index 099da61..a00e1b3 100644 (file)
@@ -1,6 +1,7 @@
 2011-02-19  Stanislas Rolland  <typo3@sjbr.ca>
 
        * Fixed bug #17676: htmlArea RTE: Some combo stores are loaded twice
+       * Fixed bug #17677: htmlArea RTE: Classes configuration is loaded twice 
 
 2011-02-18  Stanislas Rolland  <typo3@sjbr.ca>
 
index 8db361d..96aeb25 100644 (file)
@@ -280,6 +280,10 @@ class tx_rtehtmlarea_base extends t3lib_rteapi {
                                $this->siteURL = preg_replace('/^(http|https)/', 'https', $this->siteURL);
                                $this->hostURL = preg_replace('/^(http|https)/', 'https', $this->hostURL);
                        }
+                               // Register RTE windows
+                       $this->TCEform->RTEwindows[] = $PA['itemFormElName'];
+                       $textAreaId = preg_replace('/[^a-zA-Z0-9_:.-]/', '_', $PA['itemFormElName']);
+                       $textAreaId = htmlspecialchars(preg_replace('/^[^a-zA-Z]/', 'x', $textAreaId));
 
                        /* =======================================
                         * LANGUAGES & CHARACTER SETS
@@ -370,6 +374,15 @@ class tx_rtehtmlarea_base extends t3lib_rteapi {
                                // Preloading the pageStyle and including RTE skin stylesheets
                        $this->addPageStyle();
                        $this->addSkin();
+                               // Re-initialize the scripts array so that only the cumulative set of plugins of the last RTE on the page is used
+                       $this->cumulativeScripts[$this->TCEform->RTEcounter] = array();
+                       $this->includeScriptFiles($this->TCEform->RTEcounter);
+                       $this->buildJSMainLangFile($this->TCEform->RTEcounter);
+                               // Register RTE in JS:
+                       $this->TCEform->additionalJS_post[] = $this->registerRTEinJS($this->TCEform->RTEcounter, $table, $row['uid'], $field, $textAreaId);
+                               // Set the save option for the RTE:
+                       $this->TCEform->additionalJS_submit[] = $this->setSaveRTE($this->TCEform->RTEcounter, $this->TCEform->formName, $textAreaId, $PA['itemFormElName']);
+                       $this->TCEform->additionalJS_delete[] = $this->setDeleteRTE($this->TCEform->RTEcounter, $this->TCEform->formName, $textAreaId);
                                // Loading JavaScript files and code
                        if ($this->TCEform->RTEcounter == 1) {
                                $this->TCEform->additionalJS_pre['rtehtmlarea-loadJScode'] = $this->loadJScode($this->TCEform->RTEcounter);
@@ -395,11 +408,6 @@ class tx_rtehtmlarea_base extends t3lib_rteapi {
                                        $value = $plugin->transformContent($value);
                                }
                        }
-                               // Register RTE windows
-                       $this->TCEform->RTEwindows[] = $PA['itemFormElName'];
-                       $textAreaId = preg_replace('/[^a-zA-Z0-9_:.-]/', '_', $PA['itemFormElName']);
-                       $textAreaId = htmlspecialchars(preg_replace('/^[^a-zA-Z]/', 'x', $textAreaId));
-
                                // Check if wizard_rte called this for fullscreen edtition; if so, change the size of the RTE to fullscreen using JS
                        if (basename(PATH_thisScript) == 'wizard_rte.php') {
                                $this->fullScreen = true;
@@ -407,14 +415,6 @@ class tx_rtehtmlarea_base extends t3lib_rteapi {
                                $editorWrapHeight = '100%';
                                $this->RTEdivStyle = 'position:relative; left:0px; top:0px; height:100%; width:100%; border: 1px solid black; padding: 2px 0px 2px 2px;';
                        }
-
-                               // Register RTE in JS:
-                       $this->TCEform->additionalJS_post[] = $this->registerRTEinJS($this->TCEform->RTEcounter, $table, $row['uid'], $field, $textAreaId);
-
-                               // Set the save option for the RTE:
-                       $this->TCEform->additionalJS_submit[] = $this->setSaveRTE($this->TCEform->RTEcounter, $this->TCEform->formName, $textAreaId, $PA['itemFormElName']);
-                       $this->TCEform->additionalJS_delete[] = $this->setDeleteRTE($this->TCEform->RTEcounter, $this->TCEform->formName, $textAreaId);
-
                                // Draw the textarea
                        $visibility = 'hidden';
                        $item = $this->triggerField($PA['itemFormElName']).'
@@ -732,11 +732,9 @@ class tx_rtehtmlarea_base extends t3lib_rteapi {
         *
         * @param       integer         $RTEcounter: The index number of the current RTE editing area within the form.
         *
-        * @return      string          the html code for loading the Javascript Files
+        * @return      void
         */
-       function loadJSfiles($RTEcounter) {
-                       // Re-initialize the scripts array so that only the cumulative set of plugins of the last RTE on the page is used
-               $this->cumulativeScripts[$RTEcounter] = array();
+       protected function includeScriptFiles($RTEcounter) {
                $this->writeTemporaryFile('EXT:' . $this->ID . '/htmlarea/htmlarea.js', 'htmlarea', 'js', '', TRUE);
                if ($this->client['browser'] == 'msie') {
                        $this->writeTemporaryFile('EXT:' . $this->ID . '/htmlarea/htmlarea-ie.js', 'htmlarea-ie', 'js', '', TRUE);
@@ -747,9 +745,16 @@ class tx_rtehtmlarea_base extends t3lib_rteapi {
                        $extensionKey = is_object($this->registeredPlugins[$pluginId]) ? $this->registeredPlugins[$pluginId]->getExtensionKey() : $this->ID;
                        $this->writeTemporaryFile('EXT:' . $extensionKey . '/htmlarea/plugins/' . $pluginId . '/' . strtolower(preg_replace('/([a-z])([A-Z])([a-z])/', "$1".'-'."$2"."$3", $pluginId)) . '.js', $pluginId, 'js', '', TRUE);
                }
-               $this->buildJSMainLangFile($RTEcounter);
-                       // Avoid re-initialization on AJax call when RTEarea object was already initialized
-               $loadJavascriptCode = '<script type="text/javascript" src="' . $this->doConcatenate($RTEcounter) . '"></script>'. LF;
+       }
+       /**
+        * Return the HTML code for loading the Javascript files
+        *
+        * @param       integer         $RTEcounter: The index number of the current RTE editing area within the form.
+        *
+        * @return      string          the html code for loading the Javascript Files
+        */
+       protected function loadJSfiles($RTEcounter) {
+               $loadJavascriptCode = '<script type="text/javascript" src="' . $this->doConcatenate($RTEcounter) . '"></script>' . LF;
                $loadJavascriptCode .= t3lib_div::wrapJS('
                        if (typeof(RTEarea) == "undefined") {
                                RTEarea = new Object();
@@ -1003,7 +1008,7 @@ class tx_rtehtmlarea_base extends t3lib_rteapi {
                }
                        // Include JS arrays of configured classes
                $configureRTEInJavascriptString .= '
-                       RTEarea[editornumber].classesUrl = "' . $this->writeTemporaryFile('', 'classes_'.$LANG->lang, 'js', $this->buildJSClassesArray()) . '";';
+                       RTEarea[editornumber].classesUrl = "' . $this->writeTemporaryFile('', 'classes_' . $this->language, 'js', $this->buildJSClassesArray(), TRUE) . '";';
                return $configureRTEInJavascriptString;
        }
 
index a8b7fc8..d9616dc 100644 (file)
@@ -82,7 +82,7 @@ class tx_rtehtmlarea_typo3link extends tx_rtehtmlarea_api {
                        }
                        if (is_array($RTEProperties['classesAnchor.'])) {
                                $registerRTEinJavascriptString .= '
-                       RTEarea['.$RTEcounter.'].buttons.'. $button .'.classesAnchorUrl = "' . $this->htmlAreaRTE->writeTemporaryFile('', 'classesAnchor_'.$this->htmlAreaRTE->contentLanguageUid, 'js', $this->buildJSClassesAnchorArray()) . '";';
+                       RTEarea['.$RTEcounter.'].buttons.'. $button .'.classesAnchorUrl = "' . $this->htmlAreaRTE->writeTemporaryFile('', 'classesAnchor_'.$this->htmlAreaRTE->contentLanguageUid, 'js', $this->buildJSClassesAnchorArray(), TRUE) . '";';
                        }
                        $registerRTEinJavascriptString .= '
                        RTEarea['.$RTEcounter.'].buttons.'. $button .'.additionalAttributes = "external' . ($GLOBALS['TYPO3_CONF_VARS']['EXTCONF'][$this->extensionKey]['plugins'][$this->pluginName]['additionalAttributes'] ? (',' . $GLOBALS['TYPO3_CONF_VARS']['EXTCONF'][$this->extensionKey]['plugins'][$this->pluginName]['additionalAttributes']) : '') . '";';
index 4cea5fa..4fb6f36 100644 (file)
@@ -117,6 +117,10 @@ class tx_rtehtmlarea_pi2 extends tx_rtehtmlarea_base {
                        $this->siteURL = preg_replace('/^(http|https)/', 'https', $this->siteURL);
                        $this->hostURL = preg_replace('/^(http|https)/', 'https', $this->hostURL);
                }
+                       // Register RTE windows:
+               $this->TCEform->RTEwindows[] = $PA['itemFormElName'];
+               $textAreaId = preg_replace('/[^a-zA-Z0-9_:.-]/', '_', $PA['itemFormElName']);
+               $textAreaId = htmlspecialchars(preg_replace('/^[^a-zA-Z]/', 'x', $textAreaId)) . '_' . strval($this->TCEform->RTEcounter);
                /* =======================================
                 * LANGUAGES & CHARACTER SETS
                 * =======================================
@@ -209,6 +213,14 @@ class tx_rtehtmlarea_pi2 extends tx_rtehtmlarea_base {
                        // Preloading the pageStyle and including RTE skin stylesheets
                $this->addPageStyle();
                $this->addSkin();
+                       // Re-initialize the scripts array so that only the cumulative set of plugins of the last RTE on the page is used
+               $this->cumulativeScripts[$this->TCEform->RTEcounter] = array();
+               $this->includeScriptFiles($this->TCEform->RTEcounter);
+               $this->buildJSMainLangFile($this->TCEform->RTEcounter);
+                       // Register RTE in JS:
+               $this->TCEform->additionalJS_post[] = $this->wrapCDATA($this->registerRTEinJS($this->TCEform->RTEcounter, '', '', '',$textAreaId));
+                       // Set the save option for the RTE:
+               $this->TCEform->additionalJS_submit[] = $this->setSaveRTE($this->TCEform->RTEcounter, $this->TCEform->formName, $textAreaId);
                        // Loading ExtJs JavaScript files and inline code, if not configured in TS setup
                if (!$GLOBALS['TSFE']->isINTincScript() || !is_array($GLOBALS['TSFE']->pSetup['javascriptLibs.']['ExtJs.'])) {
                        $pageRenderer->loadExtJs();
@@ -240,18 +252,6 @@ class tx_rtehtmlarea_pi2 extends tx_rtehtmlarea_base {
                                $value = $plugin->transformContent($value);
                        }
                }
-
-                       // Register RTE windows:
-               $this->TCEform->RTEwindows[] = $PA['itemFormElName'];
-               $textAreaId = preg_replace('/[^a-zA-Z0-9_:.-]/', '_', $PA['itemFormElName']);
-               $textAreaId = htmlspecialchars(preg_replace('/^[^a-zA-Z]/', 'x', $textAreaId)) . '_' . strval($this->TCEform->RTEcounter);
-
-                       // Register RTE in JS:
-               $this->TCEform->additionalJS_post[] = $this->wrapCDATA($this->registerRTEinJS($this->TCEform->RTEcounter, '', '', '',$textAreaId));
-
-                       // Set the save option for the RTE:
-               $this->TCEform->additionalJS_submit[] = $this->setSaveRTE($this->TCEform->RTEcounter, $this->TCEform->formName, $textAreaId);
-
                        // draw the textarea
                $item = $this->triggerField($PA['itemFormElName']).'
                        <div id="pleasewait' . $textAreaId . '" class="pleasewait" style="display: block;" >' . $TSFE->csConvObj->conv($TSFE->getLLL('Please wait',$this->LOCAL_LANG), $this->charset, $TSFE->renderCharset) . '</div>