[BUGFIX] RTE not loading in IE when content css file does not exist
authorStanislas Rolland <typo3@sjbr.ca>
Sun, 13 Nov 2011 02:05:08 +0000 (21:05 -0500)
committerStanislas Rolland <typo3@sjbr.ca>
Fri, 16 Dec 2011 03:16:03 +0000 (04:16 +0100)
Solution: Fallback to the default contentCSS file when the file
specified in Page TS Config does not exist or has zero file size.

Change-Id: I7377daaee8443b0cbf8e2515d34316a278c8ec06
Resolves: #29899
Releases: 4.5, 4.6, 4.7
Reviewed-on: http://review.typo3.org/6652
Reviewed-by: Stanislas Rolland
Tested-by: Stanislas Rolland
typo3/sysext/rtehtmlarea/class.tx_rtehtmlarea_base.php

index bcd3c03..a80dba1 100644 (file)
@@ -434,14 +434,29 @@ class tx_rtehtmlarea_base extends t3lib_rteapi {
         * @return      void
         */
        protected function addPageStyle() {
-                       // 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';
                $this->addStyleSheet(
                        'rtehtmlarea-page-style',
-                       $this->getFullFileName($filename),
+                       $this->getContentCssFileName(),
                        'htmlArea RTE Content CSS',
                        'alternate stylesheet'
-                       );
+               );
+       }
+
+       /**
+        * Get the name of the contentCSS file to use
+        *
+        * @return      the full file name of the content css file to use
+        */
+       protected function getContentCssFileName() {
+                       // Get stylesheet file name from Page TSConfig if any
+               $fileName = trim($this->thisConfig['contentCSS']);
+               if ($fileName) {
+                       $filename = $this->getFullFileName($fileName);
+               }
+               if (!$fileName || !file_exists(PATH_site . $fileName) || !filesize(PATH_site . $fileName)) {
+                       $fileName = $this->getFullFileName('EXT:' . $this->ID . '/res/contentcss/default.css');
+               }
+               return $fileName;
        }
 
        /**
@@ -902,9 +917,8 @@ class tx_rtehtmlarea_base extends t3lib_rteapi {
                $configureRTEInJavascriptString .= '
                        RTEarea[editornumber].defaultPageStyle = "' . $this->writeTemporaryFile('', 'defaultPageStyle', 'css', $this->buildStyleSheet()) . '";';
                        // Setting the pageStyle
-               $filename = trim($this->thisConfig['contentCSS']) ? trim($this->thisConfig['contentCSS']) : 'EXT:' . $this->ID . '/res/contentcss/default.css';
                $configureRTEInJavascriptString .= '
-                       RTEarea[editornumber].pageStyle = "' . t3lib_div::createVersionNumberedFilename($this->getFullFileName($filename)) .'";';
+                       RTEarea[editornumber].pageStyle = "' . t3lib_div::createVersionNumberedFilename($this->getContentCssFileName()) .'";';
                        // Process classes configuration
                $classesConfigurationRequired = false;
                foreach ($this->registeredPlugins as $pluginId => $plugin) {