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

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

index 76b1820..5c8d4c5 100644 (file)
@@ -433,14 +433,30 @@ 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);
+               }
+                       // Fallback to default content css file if configured file does not exists or is of zero size
+               if (!$fileName || !file_exists(PATH_site . $fileName) || !filesize(PATH_site . $fileName)) {
+                       $fileName = $this->getFullFileName('EXT:' . $this->ID . '/res/contentcss/default.css');
+               }
+               return $fileName;
        }
 
        /**
@@ -910,9 +926,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) {