* Feature #6579 continued: correction to plugin registration for FE case
authorStanislas Rolland <typo3@sjbr.ca>
Sat, 10 Nov 2007 22:01:12 +0000 (22:01 +0000)
committerStanislas Rolland <typo3@sjbr.ca>
Sat, 10 Nov 2007 22:01:12 +0000 (22:01 +0000)
git-svn-id: https://svn.typo3.org/TYPO3v4/Core/trunk@2687 709f56b5-9817-0410-a4d7-c38de5d9e867

ChangeLog
typo3/sysext/rtehtmlarea/ChangeLog
typo3/sysext/rtehtmlarea/class.tx_rtehtmlarea_base.php
typo3/sysext/rtehtmlarea/pi2/class.tx_rtehtmlarea_pi2.php

index d801ee2..42d41ca 100755 (executable)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,6 +1,7 @@
 2007-11-10  Stanislas Rolland  <stanislas.rolland@fructifor.ca>
 
        * (cleanup) Protect rtehtmlarea 'for' loops from properties possibly added by JS frameworks.
+       * Feature #6579 continued: correction to plugin registration for FE case
 
 2007-11-10  Ingmar Schlecht  <ingmar@typo3.org>
 
index e987efd..7ca809f 100644 (file)
@@ -1,6 +1,7 @@
 2007-11-10  Stanislas Rolland  <stanislas.rolland@fructifor.ca>
 
        * (cleanup) Protect rtehtmlarea 'for' loops from properties possibly added by JS frameworks.
+       * Feature #6579 continued: correction to plugin registration for FE case
 
 2007-11-08  Stanislas Rolland  <stanislas.rolland@fructifor.ca>
 
index 5bb7a44..eff19c8 100644 (file)
@@ -452,39 +452,11 @@ class tx_rtehtmlarea_base extends t3lib_rteapi {
                         * TOOLBAR CONFIGURATION
                         * =======================================
                         */
-                               // Traverse registered plugins
-                       if (is_array($TYPO3_CONF_VARS['EXTCONF'][$this->ID]['plugins'])) {
-                               foreach($TYPO3_CONF_VARS['EXTCONF'][$this->ID]['plugins'] as $pluginId => $pluginObjectConfiguration) {
-                                       $plugin = &t3lib_div::getUserObj($pluginObjectConfiguration['objectReference']);
-                                       if (is_object($plugin)) {
-                                               if ($plugin->main($this)) {
-                                                       $this->registeredPlugins[$pluginId] = $plugin;
-                                                               // Override buttons from previously registered plugins
-                                                       $pluginButtons = t3lib_div::trimExplode(',', $plugin->getPluginButtons(), 1);
-                                                       foreach ($this->pluginButton as $previousPluginId => $buttonList) {
-                                                               $this->pluginButton[$previousPluginId] = implode(',',array_diff(t3lib_div::trimExplode(',', $this->pluginButton[$previousPluginId], 1), $pluginButtons));
-                                                       }
-                                                       $this->pluginButton[$pluginId] = $plugin->getPluginButtons();
-                                                       $pluginLabels = t3lib_div::trimExplode(',', $plugin->getPluginLabels(), 1);
-                                                       foreach ($this->pluginLabel as $previousPluginId => $labelList) {
-                                                               $this->pluginLabel[$previousPluginId] = implode(',',array_diff(t3lib_div::trimExplode(',', $this->pluginLabel[$previousPluginId], 1), $pluginLabels));
-                                                       }
-                                                       $this->pluginLabel[$pluginId] = $plugin->getPluginLabels();
-                                                       $this->pluginList .= ','.$pluginId;
-                                               }
-                                       }
-                               }
-                       }
-                               // Process overrides
-                       $hidePlugins = array();
-                       foreach ($this->registeredPlugins as $pluginId => $plugin) {
-                               if (!$this->pluginButton[$pluginId]) {
-                                       $hidePlugins[] = $pluginId;
-                               }
-                       }
                        
                                // htmlArea plugins list
                        $this->pluginEnabledArray = t3lib_div::trimExplode(',', $this->pluginList, 1);
+                       $this->enableRegisteredPlugins();
+                       $hidePlugins = array();
                        if(!t3lib_extMgm::isLoaded('static_info_tables') || in_array($this->language, t3lib_div::trimExplode(',', $TYPO3_CONF_VARS['EXTCONF'][$this->ID]['noSpellCheckLanguages']))) $hidePlugins[] = 'SpellChecker';
                        if ($this->client['BROWSER'] == 'msie') $hidePlugins[] = 'Acronym';
                        if ($this->client['BROWSER'] == 'opera') {
@@ -656,7 +628,46 @@ class tx_rtehtmlarea_base extends t3lib_rteapi {
                        // Return form item:
                return $item;
        }
-
+       
+       /**
+        * Add registered plugins to the array of enabled plugins
+        *
+        */
+       function enableRegisteredPlugins() {
+               global $TYPO3_CONF_VARS;
+                                       // Traverse registered plugins
+               if (is_array($TYPO3_CONF_VARS['EXTCONF'][$this->ID]['plugins'])) {
+                       foreach($TYPO3_CONF_VARS['EXTCONF'][$this->ID]['plugins'] as $pluginId => $pluginObjectConfiguration) {
+                               $plugin = &t3lib_div::getUserObj($pluginObjectConfiguration['objectReference']);
+                               if (is_object($plugin)) {
+                                       if ($plugin->main($this)) {
+                                               $this->registeredPlugins[$pluginId] = $plugin;
+                                                       // Override buttons from previously registered plugins
+                                               $pluginButtons = t3lib_div::trimExplode(',', $plugin->getPluginButtons(), 1);
+                                               foreach ($this->pluginButton as $previousPluginId => $buttonList) {
+                                                       $this->pluginButton[$previousPluginId] = implode(',',array_diff(t3lib_div::trimExplode(',', $this->pluginButton[$previousPluginId], 1), $pluginButtons));
+                                               }
+                                               $this->pluginButton[$pluginId] = $plugin->getPluginButtons();
+                                               $pluginLabels = t3lib_div::trimExplode(',', $plugin->getPluginLabels(), 1);
+                                               foreach ($this->pluginLabel as $previousPluginId => $labelList) {
+                                                       $this->pluginLabel[$previousPluginId] = implode(',',array_diff(t3lib_div::trimExplode(',', $this->pluginLabel[$previousPluginId], 1), $pluginLabels));
+                                               }
+                                               $this->pluginLabel[$pluginId] = $plugin->getPluginLabels();
+                                               $this->pluginEnabledArray[] = $pluginId;
+                                       }
+                               }
+                       }
+               }
+                       // Process overrides
+               $hidePlugins = array();
+               foreach ($this->registeredPlugins as $pluginId => $plugin) {
+                       if (!$this->pluginButton[$pluginId]) {
+                               $hidePlugins[] = $pluginId;
+                       }
+               }
+               $this->pluginEnabledArray = array_diff($this->pluginEnabledArray, $hidePlugins);
+       }
+       
        /**
         * Set the toolbar config (only in this PHP-Object, not in JS):
         *
@@ -985,12 +996,9 @@ class tx_rtehtmlarea_base extends t3lib_rteapi {
                        // Setting the plugin flags
                $configureRTEInJavascriptString .= '
                        RTEarea['.$RTEcounter.']["plugin"] = new Object();';
-               $pluginArray = t3lib_div::trimExplode(',', $this->pluginList , 1);
-               foreach ($pluginArray as $pluginId) {
-                       if ($this->isPluginEnabled($pluginId)) {
-                               $configureRTEInJavascriptString .= '
+               foreach ($this->pluginEnabledArray as $pluginId) {
+                       $configureRTEInJavascriptString .= '
                        RTEarea['.$RTEcounter.']["plugin"]["'.$pluginId.'"] = true;';
-                       }
                }
                
                        // Setting the buttons configuration
index 53e6e5f..6b0188f 100644 (file)
@@ -140,24 +140,10 @@ class tx_rtehtmlarea_pi2 extends tx_rtehtmlarea_base {
                 * TOOLBAR CONFIGURATION
                 * =======================================
                 */
-                
-                       // Traverse registered plugins
-               if (is_array($TYPO3_CONF_VARS['EXTCONF'][$this->ID]['plugins'])) {
-                       foreach($TYPO3_CONF_VARS['EXTCONF'][$this->ID]['plugins'] as $pluginId => $pluginObjectConfiguration) {
-                               $plugin = &t3lib_div::getUserObj($pluginObjectConfiguration['objectReference']);
-                               if (is_object($plugin)) {
-                                       if ($plugin->main($this)) {
-                                               $this->registeredPlugins[$pluginId] = $plugin;
-                                               $this->pluginButton[$pluginId] = $plugin->getPluginButtons();
-                                               $this->pluginList .= ','.$pluginId;
-                                               $this->convertToolbarForHtmlAreaArray = array_unique(array_merge($this->convertToolbarForHtmlAreaArray, $plugin->getConvertToolbarForHtmlAreaArray()));
-                                       }
-                               }
-                       }
-               }
                
                        // htmlArea plugins list
                $this->pluginEnabledArray = t3lib_div::trimExplode(',', $this->pluginList, 1);
+               $this->enableRegisteredPlugins();
                $hidePlugins = array('TYPO3Browsers', 'UserElements', 'Acronym', 'TYPO3HtmlParser');
                if ($this->client['BROWSER'] == 'opera') {
                        $hidePlugins[] = 'ContextMenu';
@@ -175,7 +161,9 @@ class tx_rtehtmlarea_pi2 extends tx_rtehtmlarea_base {
                
                        // Merge the list of enabled plugins with the lists from the previous RTE editing areas on the same form
                $this->pluginEnabledCumulativeArray[$this->TCEform->RTEcounter] = $this->pluginEnabledArray;
-               if ($this->TCEform->RTEcounter > 1) $this->pluginEnabledCumulativeArray[$this->TCEform->RTEcounter] = array_unique(array_values(array_merge($this->pluginEnabledArray,$this->pluginEnabledCumulativeArray[$this->TCEform->RTEcounter-1])));
+               if ($this->TCEform->RTEcounter > 1 && isset($this->pluginEnabledCumulativeArray[$this->TCEform->RTEcounter-1]) && is_array($this->pluginEnabledCumulativeArray[$this->TCEform->RTEcounter-1])) {
+                       $this->pluginEnabledCumulativeArray[$this->TCEform->RTEcounter] = array_unique(array_values(array_merge($this->pluginEnabledArray,$this->pluginEnabledCumulativeArray[$this->TCEform->RTEcounter-1])));
+               }
                
                /* =======================================
                 * PLUGIN-SPECIFIC CONFIGURATION