[BUGFIX] Add defaultTypoScript to hierachyInfo 04/26804/3
authorPeter Niederlag <netservice@niekom.de>
Fri, 10 Jan 2014 13:16:53 +0000 (14:16 +0100)
committerBenjamin Mack <benni@typo3.org>
Tue, 14 Jan 2014 13:26:10 +0000 (14:26 +0100)
Fixes a problem with the TemplateAnalyzer introduced by #43540

- Always add both defaultTypoScript_setup and defaultTypoScript_constants.
- Add information for defaultTypoScript into hierarchyInfo.

Resolves: #53352
Releases: 6.2, 6.1, 6.0, 4.7, 4.5
Change-Id: I5d76bd092b1a8f509c90849774e916c7fd83b438
Reviewed-on: https://review.typo3.org/26804
Reviewed-by: Benjamin Mack
Tested-by: Benjamin Mack
typo3/sysext/core/Classes/TypoScript/TemplateService.php

index 7cc71ed..8981080 100644 (file)
@@ -1631,14 +1631,31 @@ class TemplateService {
         * @see isDefaultTypoScriptAdded
         */
        protected function addDefaultTypoScript() {
-                       // Add default TS for all code types, if not done already
+               // Add default TS for all code types, if not done already
                if (!$this->isDefaultTypoScriptAdded) {
-                       if (!empty($GLOBALS['TYPO3_CONF_VARS']['FE']['defaultTypoScript_constants'])) {
-                               array_unshift($this->constants, (string)$GLOBALS['TYPO3_CONF_VARS']['FE']['defaultTypoScript_constants']);
-                       }
-                       if (!empty($GLOBALS['TYPO3_CONF_VARS']['FE']['defaultTypoScript_setup'])) {
-                               array_unshift($this->config, (string)$GLOBALS['TYPO3_CONF_VARS']['FE']['defaultTypoScript_setup']);
-                       }
+                       // adding default setup and constants
+                       // defaultTypoScript_setup is *very* unlikely to be empty
+                       // the count of elements in ->constants and ->config have to be in sync so we always add *both*
+                       array_unshift($this->constants, (string)$GLOBALS['TYPO3_CONF_VARS']['FE']['defaultTypoScript_constants']);
+                       array_unshift($this->config, (string)$GLOBALS['TYPO3_CONF_VARS']['FE']['defaultTypoScript_setup']);
+                       // prepare a proper entry to hierachyInfo (used by TemplateAnalyzer in BE)
+                       $rootTemplateId = $this->hierarchyInfo[count($this->hierarchyInfo)-1]['templateID'];
+                       $defaultTemplateInfo = array(
+                               'root' => '',
+                               'next' => '',
+                               'clConst' => '',
+                               'clConf' => '',
+                               'templateID' => '_defaultTypoScript_',
+                               'templateParent' => $rootTemplateId,
+                               'title' => 'SYS:TYPO3_CONF_VARS:FE:defaultTypoScript',
+                               'uid' => '_defaultTypoScript_',
+                               'pid' => '',
+                               'configLines' => substr_count((string)$GLOBALS['TYPO3_CONF_VARS']['FE']['defaultTypoScript_setup'], LF) + 1
+                       );
+                       // push info to information arrays used in BE by TemplateTools (Analyzer)
+                       array_unshift($this->clearList_const, $defaultTemplateInfo['uid']);
+                       array_unshift($this->clearList_setup, $defaultTemplateInfo['uid']);
+                       array_unshift($this->hierarchyInfo, $defaultTemplateInfo);
                        $this->isDefaultTypoScriptAdded = TRUE;
                }
        }