[BUGFIX] DocumentTemplate class inserts inDocStyles twice 49/27149/2
authorStefan Neufeind <typo3.neufeind@speedpartner.de>
Thu, 30 Jan 2014 13:56:34 +0000 (14:56 +0100)
committerStefan Neufeind <typo3.neufeind@speedpartner.de>
Thu, 30 Jan 2014 14:00:42 +0000 (15:00 +0100)
Change-Id: I252da74973c3dc4157717139c95ad0605e16fce1
Releases: 6.2, 6.1, 4.5
Resolves: #55458
Reviewed-on: https://review.typo3.org/27149
Reviewed-by: Stefan Neufeind
Tested-by: Stefan Neufeind
typo3/sysext/backend/Classes/Template/DocumentTemplate.php

index 8557789..8eb8525 100644 (file)
@@ -1159,6 +1159,12 @@ class DocumentTemplate {
                $this->inDocStylesArray[] = $this->inDocStyles_TBEstyle;
                // Implode it all:
                $inDocStyles = implode(LF, $this->inDocStylesArray);
+
+               // Reset styles so they won't be added again in insertStylesAndJS()
+               $this->inDocStylesArray = array();
+               $this->inDocStyles = '';
+               $this->inDocStyles_TBEstyle = '';
+
                if ($this->styleSheetFile) {
                        $this->pageRenderer->addCssFile($this->backPath . $this->styleSheetFile);
                }
@@ -1220,9 +1226,12 @@ class DocumentTemplate {
         */
        public function insertStylesAndJS($content) {
                // Insert accumulated CSS
-               $this->inDocStylesArray[] = $this->inDocStyles;
+               if (!empty($this->inDocStyles)) {
+                       $this->inDocStylesArray[] = $this->inDocStyles;
+               }
                $styles = LF . implode(LF, $this->inDocStylesArray);
                $content = str_replace('/*###POSTCSSMARKER###*/', $styles, $content);
+
                // Insert accumulated JS
                $jscode = $this->JScode . LF . $this->wrapScriptTags(implode(LF, $this->JScodeArray));
                $content = str_replace('<!--###POSTJSMARKER###-->', $jscode, $content);