Fixed bug #9516: htmlARea RTE: Move link tags to head
authorStanislas Rolland <typo3@sjbr.ca>
Wed, 8 Oct 2008 15:23:55 +0000 (15:23 +0000)
committerStanislas Rolland <typo3@sjbr.ca>
Wed, 8 Oct 2008 15:23:55 +0000 (15:23 +0000)
git-svn-id: https://svn.typo3.org/TYPO3v4/Core/trunk@4298 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 36772e1..5caee0e 100755 (executable)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,7 @@
+2008-10-08  Stanislas Rolland  <typo3@sjbr.ca>
+
+       * Fixed bug #9516: htmlARea RTE: Move link tags to head
+
 2008-10-05  Stanislas Rolland  <typo3@sjbr.ca>
 
        * Fixed bug #9490: htmlArea RTE: Opera 9.52 sometimes refuses to insert a node
index 40915fb..983f13e 100644 (file)
@@ -1,3 +1,7 @@
+2008-10-08  Stanislas Rolland  <typo3@sjbr.ca>
+
+       * Fixed bug #9516: htmlARea RTE: Move link tags to head
+
 2008-10-05  Stanislas Rolland  <typo3@sjbr.ca>
 
        * Fixed bug #9490: htmlArea RTE: Opera 9.52 sometimes refuses to insert a node
index dbcac61..6944262 100644 (file)
@@ -339,55 +339,13 @@ class tx_rtehtmlarea_base extends t3lib_rteapi {
                         * LOAD CSS AND JAVASCRIPT
                         * =======================================
                         */
-
                                // Preloading the pageStyle
-                       $filename = trim($this->thisConfig['contentCSS']) ? trim($this->thisConfig['contentCSS']) : 'EXT:' . $this->ID . '/res/contentcss/default.css';
-                       $this->TCEform->additionalCode_pre['loadCSS'] = '
-               <link rel="alternate stylesheet" type="text/css" href="' . $this->getFullFileName($filename) . '" title="HTMLArea RTE Content CSS" />';
-
-                               // Loading the editor skin
-                       $skinFilename = trim($this->thisConfig['skin']) ? trim($this->thisConfig['skin']) : 'EXT:' . $this->ID . '/htmlarea/skins/default/htmlarea.css';
-                       if($this->client['BROWSER'] == 'gecko' && $this->client['VERSION'] == '1.3' && substr($skinFilename,0,4) == 'EXT:')  {
-                               $skinFilename = 'EXT:' . $this->ID . '/htmlarea/skins/default/htmlarea.css';
-                       }
-                       if (substr($skinFilename,0,4) == 'EXT:')      {       // extension
-                               list($extKey,$local) = explode('/',substr($skinFilename,4),2);
-                               $skinFilename='';
-                               if (strcmp($extKey,'') &&  t3lib_extMgm::isLoaded($extKey) && strcmp($local,'')) {
-                                       $skinFilename = $this->httpTypo3Path . t3lib_extMgm::siteRelPath($extKey) . $local;
-                                       $skinDir = $this->siteURL . t3lib_extMgm::siteRelPath($extKey) . dirname($local);
-                               }
-                       } elseif (substr($skinFilename,0,1) != '/') {
-                               $skinDir = $this->siteURL.dirname($skinFilename);
-                               $skinFilename = $this->siteURL . $skinFilename;
-                       } else {
-                               $skinDir = substr($this->siteURL,0,-1) . dirname($skinFilename);
-                       }
-                       $this->editorCSS = $skinFilename;
-                       $this->editedContentCSS = $skinDir . '/htmlarea-edited-content.css';
-                       $this->TCEform->additionalCode_pre['loadCSS'] .= '
-               <link rel="alternate stylesheet" type="text/css" href="' . $this->editedContentCSS . '" />';
-                       
-                               // Main skin
-                       $this->TCEform->additionalCode_pre['loadCSS'] .= '
-               <link rel="stylesheet" type="text/css" href="' . $this->editorCSS . '" />';
-                       
-                               // Additional icons from registered plugins
-                       foreach ($this->pluginEnabledCumulativeArray[$this->TCEform->RTEcounter] as $pluginId) {
-                               if (is_object($this->registeredPlugins[$pluginId])) {
-                                       $pathToSkin = $this->registeredPlugins[$pluginId]->getPathToSkin();
-                                       if ($pathToSkin) {
-                                               $this->TCEform->additionalCode_pre['loadCSS'] .= '
-               <link rel="stylesheet" type="text/css" href="' . $this->httpTypo3Path . t3lib_extMgm::siteRelPath($this->registeredPlugins[$pluginId]->getExtensionKey()) . $pathToSkin . '" />';
-                                       }
-                               }
-                       }
-                       
+                       $GLOBALS['SOBE']->doc->JScodeLibArray['rtehtmlarea-contentCSS'] = $this->getPageStyle();
+                               // Including RTE skin stylesheets
+                       $GLOBALS['SOBE']->doc->JScodeLibArray['rtehtmlarea-skin'] = $this->getSkin();
                                // Loading JavaScript files and code
-                       if ($this->TCEform->RTEcounter == 1) {
-                               $this->TCEform->additionalCode_pre['loadJSfiles'] = $this->loadJSfiles($this->TCEform->RTEcounter);
-                               $this->TCEform->additionalJS_pre['loadJScode'] = $this->loadJScode($this->TCEform->RTEcounter);
-                       }
+                       $this->TCEform->additionalCode_pre['rtehtmlarea-loadJSfiles'] = $this->loadJSfiles($this->TCEform->RTEcounter);
+                       $this->TCEform->additionalJS_pre['rtehtmlarea-loadJScode'] = $this->loadJScode($this->TCEform->RTEcounter);
 
                        /* =======================================
                         * DRAW THE EDITOR
@@ -448,6 +406,62 @@ class tx_rtehtmlarea_base extends t3lib_rteapi {
        }
 
        /**
+        * Get links to content style sheet(s)
+        *
+        * @return      string  link tag referenceing the content stylesheet
+        */
+       protected function getPageStyle() {
+                       // Get stylesheet file name from Page TSConfig if any
+               $filename = trim($this->thisConfig['contentCSS']) ? trim($this->thisConfig['contentCSS']) : 'EXT:' . $this->ID . '/res/contentcss/default.css';
+               return '<link rel="alternate stylesheet" type="text/css" href="' . $this->getFullFileName($filename) . '" title="HTMLArea RTE Content CSS" />';
+       }
+
+       /**
+        * Get links to skin style sheet(s)
+        *
+        * @return      string  link tags referenceing the skin stylesheets
+        */
+       protected function getSkin() {
+                       // Get skin file name from Page TSConfig if any
+               $skinFilename = trim($this->thisConfig['skin']) ? trim($this->thisConfig['skin']) : 'EXT:' . $this->ID . '/htmlarea/skins/default/htmlarea.css';
+               if($this->client['BROWSER'] == 'gecko' && $this->client['VERSION'] == '1.3' && substr($skinFilename,0,4) == 'EXT:')  {
+                       $skinFilename = 'EXT:' . $this->ID . '/htmlarea/skins/default/htmlarea.css';
+               }
+                       // Skin provided by some extension
+               if (substr($skinFilename,0,4) == 'EXT:') {
+                       list($extKey,$local) = explode('/',substr($skinFilename,4),2);
+                       $skinFilename='';
+                       if (strcmp($extKey,'') &&  t3lib_extMgm::isLoaded($extKey) && strcmp($local,'')) {
+                               $skinFilename = $this->httpTypo3Path . t3lib_extMgm::siteRelPath($extKey) . $local;
+                               $skinDir = $this->siteURL . t3lib_extMgm::siteRelPath($extKey) . dirname($local);
+                       }
+               } elseif (substr($skinFilename,0,1) != '/') {
+                       $skinDir = $this->siteURL.dirname($skinFilename);
+                       $skinFilename = $this->siteURL . $skinFilename;
+               } else {
+                       $skinDir = substr($this->siteURL,0,-1) . dirname($skinFilename);
+               }
+               $this->editorCSS = $skinFilename;
+                       // Editing area style sheet
+               $this->editedContentCSS = $skinDir . '/htmlarea-edited-content.css';
+               $skin = '<link rel="alternate stylesheet" type="text/css" href="' . $this->editedContentCSS . '" title="HTMLArea RTE Editing Area CSS" />';
+                       // Main skin
+               $skin .= '
+<link rel="stylesheet" type="text/css" href="' . $this->editorCSS . '" title="HTMLArea RTE Skin" />';
+                       // Additional icons from registered plugins
+               foreach ($this->pluginEnabledCumulativeArray[$this->TCEform->RTEcounter] as $pluginId) {
+                       if (is_object($this->registeredPlugins[$pluginId])) {
+                               $pathToSkin = $this->registeredPlugins[$pluginId]->getPathToSkin();
+                               if ($pathToSkin) {
+                                       $skin .= '
+<link rel="stylesheet" type="text/css" href="' . $this->httpTypo3Path . t3lib_extMgm::siteRelPath($this->registeredPlugins[$pluginId]->getExtensionKey()) . $pathToSkin . '" />';
+                               }
+                       }
+               }
+               return $skin;
+       }
+
+       /**
         * Initialize toolbar configuration and enable registered plugins
         *
         * @return      void
@@ -509,7 +523,7 @@ class tx_rtehtmlarea_base extends t3lib_rteapi {
                                $hidePlugins[] = $pluginId;
                        }
                }
-               $this->pluginEnabledArray = array_diff($this->pluginEnabledArray, $hidePlugins);
+               $this->pluginEnabledArray = array_unique(array_diff($this->pluginEnabledArray, $hidePlugins));
        }
        
        /**
@@ -684,8 +698,9 @@ class tx_rtehtmlarea_base extends t3lib_rteapi {
                                $this->pluginEnabledArray[] = $pluginId;
                        }
                }
+               $this->pluginEnabledArray = array_unique($this->pluginEnabledArray);
 
-                       // Completing the toolbar converion array for htmlArea
+                       // Completing the toolbar conversion array for htmlArea
                foreach ($this->registeredPlugins as $pluginId => $plugin) {
                        if ($this->isPluginEnabled($pluginId)) {
                                $this->convertToolbarForHtmlAreaArray = array_unique(array_merge($this->convertToolbarForHtmlAreaArray, $plugin->getConvertToolbarForHtmlAreaArray()));
@@ -786,7 +801,6 @@ class tx_rtehtmlarea_base extends t3lib_rteapi {
         */
         
        function loadJScode($RTEcounter) {
-               global $TYPO3_CONF_VARS;
                
                $loadPluginCode = '';
                foreach ($this->pluginEnabledCumulativeArray[$RTEcounter] as $pluginId) {
index c604ec8..8964015 100644 (file)
@@ -213,53 +213,12 @@ class tx_rtehtmlarea_pi2 extends tx_rtehtmlarea_base {
                 * =======================================
                 */
                        // Preloading the pageStyle
-               $filename = trim($this->thisConfig['contentCSS']) ? trim($this->thisConfig['contentCSS']) : 'EXT:' . $this->ID . '/res/contentcss/default.css';
-               $additionalCode_loadCSS = '
-               <link rel="alternate stylesheet" type="text/css" href="' . $this->getFullFileName($filename) . '" title="HTMLArea RTE Content CSS" />';
-
-                       // Loading the editor skin
-               $skinFilename = trim($this->thisConfig['skin']) ? trim($this->thisConfig['skin']) : 'EXT:' . $this->ID . '/htmlarea/skins/default/htmlarea.css';
-               if($this->client['BROWSER'] == 'gecko' && $this->client['VERSION'] == '1.3' && substr($skinFilename,0,4) == 'EXT:')  {
-                       $skinFilename = 'EXT:' . $this->ID . '/htmlarea/skins/default/htmlarea.css';
-               }
-               if (substr($skinFilename,0,4) == 'EXT:')      {       // extension
-                       list($extKey,$local) = explode('/',substr($skinFilename,4),2);
-                       $skinFilename='';
-                       if (strcmp($extKey,'') &&  t3lib_extMgm::isLoaded($extKey) && strcmp($local,'')) {
-                               $skinFilename = $this->httpTypo3Path . t3lib_extMgm::siteRelPath($extKey).$local;
-                               $skinDir = $this->siteURL . t3lib_extMgm::siteRelPath($extKey) . dirname($local);
-                       }
-               } elseif (substr($skinFilename,0,1) != '/') {
-                       $skinDir = $this->siteURL.dirname($skinFilename);
-                       $skinFilename = $this->siteURL.$skinFilename;
-               } else {
-                       $skinDir = substr($this->siteURL,0,-1) . dirname($skinFilename);
-               }
-
-               $this->editorCSS = $skinFilename;
-               $this->editedContentCSS = $skinDir . '/htmlarea-edited-content.css';
-               $additionalCode_loadCSS .= '
-               <link rel="alternate stylesheet" type="text/css" href="' . $this->editedContentCSS . '" />';
-               
-                       // Main stylesheet
-               $additionalCode_loadCSS .= '
-               <link rel="stylesheet" type="text/css" href="' . $this->editorCSS . '" />';
-               
-                       // Additional icons from registered plugins
-               foreach ($this->pluginEnabledCumulativeArray[$this->TCEform->RTEcounter] as $pluginId) {
-                       if (is_object($this->registeredPlugins[$pluginId])) {
-                               $pathToSkin = $this->registeredPlugins[$pluginId]->getPathToSkin();
-                               if ($pathToSkin) {
-                                       $additionalCode_loadCSS .= '
-               <link rel="stylesheet" type="text/css" href="' . $this->httpTypo3Path . t3lib_extMgm::siteRelPath($this->registeredPlugins[$pluginId]->getExtensionKey()) . $pathToSkin . '" />';
-                               }
-                       }
-               }
-               
-                       // Loading CSS, JavaScript files and code
-               $TSFE->additionalHeaderData['htmlArea'] = $additionalCode_loadCSS;
+               $GLOBALS['TSFE']->additionalHeaderData['rtehtmlarea-contentCSS'] = $this->getPageStyle();
+                       // Loading RTE skin style sheets
+               $GLOBALS['TSFE']->additionalHeaderData['rtehtmlarea-skin'] = $this->getSkin();
+                       // Loading JavaScript files and code
                $this->TCEform->additionalJS_initial = $this->loadJSfiles($this->TCEform->RTEcounter);
-               $this->TCEform->additionalJS_pre[] = $this->loadJScode($this->TCEform->RTEcounter);
+               $this->TCEform->additionalJS_pre['rtehtmlarea-loadJScode'] = $this->loadJScode($this->TCEform->RTEcounter);
 
                /* =======================================
                 * DRAW THE EDITOR