/**
  * Checks if config-array exists already but if not, gets it
  *
  * @return void
  * @todo Define visibility
  */
 public function getConfigArray()
 {
     $setStatPageName = FALSE;
     // If config is not set by the cache (which would be a major mistake somewhere) OR if INTincScripts-include-scripts have been registered, then we must parse the template in order to get it
     if (!is_array($this->config) || is_array($this->config['INTincScript']) || $this->forceTemplateParsing) {
         $GLOBALS['TT']->push('Parse template', '');
         // Force parsing, if set?:
         $this->tmpl->forceTemplateParsing = $this->forceTemplateParsing;
         // Start parsing the TS template. Might return cached version.
         $this->tmpl->start($this->rootLine);
         $GLOBALS['TT']->pull();
         if ($this->tmpl->loaded) {
             $GLOBALS['TT']->push('Setting the config-array', '');
             // toplevel - objArrayName
             $this->sPre = $this->tmpl->setup['types.'][$this->type];
             $this->pSetup = $this->tmpl->setup[$this->sPre . '.'];
             if (!is_array($this->pSetup)) {
                 $message = 'The page is not configured! [type=' . $this->type . '][' . $this->sPre . '].';
                 if ($this->checkPageUnavailableHandler()) {
                     $this->pageUnavailableAndExit($message);
                 } else {
                     $explanation = 'This means that there is no TypoScript object of type PAGE with typeNum=' . $this->type . ' configured.';
                     \TYPO3\CMS\Core\Utility\GeneralUtility::sysLog($message, 'cms', \TYPO3\CMS\Core\Utility\GeneralUtility::SYSLOG_SEVERITY_ERROR);
                     throw new \TYPO3\CMS\Core\Error\Http\ServiceUnavailableException($message . ' ' . $explanation, 1294587217);
                 }
             } else {
                 $this->config['config'] = array();
                 // Filling the config-array, first with the main "config." part
                 if (is_array($this->tmpl->setup['config.'])) {
                     $this->config['config'] = $this->tmpl->setup['config.'];
                 }
                 // override it with the page/type-specific "config."
                 if (is_array($this->pSetup['config.'])) {
                     $this->config['config'] = \TYPO3\CMS\Core\Utility\GeneralUtility::array_merge_recursive_overrule($this->config['config'], $this->pSetup['config.']);
                 }
                 if ($this->config['config']['typolinkEnableLinksAcrossDomains']) {
                     $this->config['config']['typolinkCheckRootline'] = TRUE;
                 }
                 // Set default values for removeDefaultJS and inlineStyle2TempFile so CSS and JS are externalized if compatversion is higher than 4.0
                 if (\TYPO3\CMS\Core\Utility\GeneralUtility::compat_version('4.0')) {
                     if (!isset($this->config['config']['removeDefaultJS'])) {
                         $this->config['config']['removeDefaultJS'] = 'external';
                     }
                     if (!isset($this->config['config']['inlineStyle2TempFile'])) {
                         $this->config['config']['inlineStyle2TempFile'] = 1;
                     }
                 }
                 if (!isset($this->config['config']['compressJs'])) {
                     $this->config['config']['compressJs'] = 0;
                 }
                 // Processing for the config_array:
                 $this->config['rootLine'] = $this->tmpl->rootLine;
                 $this->config['mainScript'] = trim($this->config['config']['mainScript']) ? trim($this->config['config']['mainScript']) : 'index.php';
                 // Class for render Header and Footer parts
                 $template = '';
                 if ($this->pSetup['pageHeaderFooterTemplateFile']) {
                     $file = $this->tmpl->getFileName($this->pSetup['pageHeaderFooterTemplateFile']);
                     if ($file) {
                         $this->setTemplateFile($file);
                     }
                 }
             }
             $GLOBALS['TT']->pull();
         } else {
             if ($this->checkPageUnavailableHandler()) {
                 $this->pageUnavailableAndExit('No TypoScript template found!');
             } else {
                 $message = 'No TypoScript template found!';
                 \TYPO3\CMS\Core\Utility\GeneralUtility::sysLog($message, 'cms', \TYPO3\CMS\Core\Utility\GeneralUtility::SYSLOG_SEVERITY_ERROR);
                 throw new \TYPO3\CMS\Core\Error\Http\ServiceUnavailableException($message, 1294587218);
             }
         }
     }
     // Initialize charset settings etc.
     $this->initLLvars();
     // No cache
     // Set $this->no_cache TRUE if the config.no_cache value is set!
     if ($this->config['config']['no_cache']) {
         $this->set_no_cache();
     }
     // Merge GET with defaultGetVars
     if (!empty($this->config['config']['defaultGetVars.'])) {
         $modifiedGetVars = \TYPO3\CMS\Core\Utility\GeneralUtility::array_merge_recursive_overrule(\TYPO3\CMS\Core\Utility\GeneralUtility::removeDotsFromTS($this->config['config']['defaultGetVars.']), \TYPO3\CMS\Core\Utility\GeneralUtility::_GET());
         \TYPO3\CMS\Core\Utility\GeneralUtility::_GETset($modifiedGetVars);
     }
     // Hook for postProcessing the configuration array
     if (is_array($this->TYPO3_CONF_VARS['SC_OPTIONS']['tslib/class.tslib_fe.php']['configArrayPostProc'])) {
         $params = array('config' => &$this->config['config']);
         foreach ($this->TYPO3_CONF_VARS['SC_OPTIONS']['tslib/class.tslib_fe.php']['configArrayPostProc'] as $funcRef) {
             \TYPO3\CMS\Core\Utility\GeneralUtility::callUserFunction($funcRef, $params, $this);
         }
     }
 }
Ejemplo n.º 2
0
 /**
  * Checks if config-array exists already but if not, gets it
  *
  * @throws ServiceUnavailableException
  * @return void
  */
 public function getConfigArray()
 {
     // If config is not set by the cache (which would be a major mistake somewhere) OR if INTincScripts-include-scripts have been registered, then we must parse the template in order to get it
     if (!is_array($this->config) || is_array($this->config['INTincScript']) || $this->forceTemplateParsing) {
         $timeTracker = $this->getTimeTracker();
         $timeTracker->push('Parse template', '');
         // Force parsing, if set?:
         $this->tmpl->forceTemplateParsing = $this->forceTemplateParsing;
         // Start parsing the TS template. Might return cached version.
         $this->tmpl->start($this->rootLine);
         $timeTracker->pull();
         if ($this->tmpl->loaded) {
             $timeTracker->push('Setting the config-array', '');
             // toplevel - objArrayName
             $this->sPre = $this->tmpl->setup['types.'][$this->type];
             $this->pSetup = $this->tmpl->setup[$this->sPre . '.'];
             if (!is_array($this->pSetup)) {
                 $message = 'The page is not configured! [type=' . $this->type . '][' . $this->sPre . '].';
                 if ($this->checkPageUnavailableHandler()) {
                     $this->pageUnavailableAndExit($message);
                 } else {
                     $explanation = 'This means that there is no TypoScript object of type PAGE with typeNum=' . $this->type . ' configured.';
                     GeneralUtility::sysLog($message, 'cms', GeneralUtility::SYSLOG_SEVERITY_ERROR);
                     throw new ServiceUnavailableException($message . ' ' . $explanation, 1294587217);
                 }
             } else {
                 if (!isset($this->config['config'])) {
                     $this->config['config'] = [];
                 }
                 // Filling the config-array, first with the main "config." part
                 if (is_array($this->tmpl->setup['config.'])) {
                     ArrayUtility::mergeRecursiveWithOverrule($this->tmpl->setup['config.'], $this->config['config']);
                     $this->config['config'] = $this->tmpl->setup['config.'];
                 }
                 // override it with the page/type-specific "config."
                 if (is_array($this->pSetup['config.'])) {
                     ArrayUtility::mergeRecursiveWithOverrule($this->config['config'], $this->pSetup['config.']);
                 }
                 if ($this->config['config']['typolinkEnableLinksAcrossDomains']) {
                     $this->config['config']['typolinkCheckRootline'] = true;
                 }
                 // Set default values for removeDefaultJS and inlineStyle2TempFile so CSS and JS are externalized if compatversion is higher than 4.0
                 if (!isset($this->config['config']['removeDefaultJS'])) {
                     $this->config['config']['removeDefaultJS'] = 'external';
                 }
                 if (!isset($this->config['config']['inlineStyle2TempFile'])) {
                     $this->config['config']['inlineStyle2TempFile'] = 1;
                 }
                 if (!isset($this->config['config']['compressJs'])) {
                     $this->config['config']['compressJs'] = 0;
                 }
                 // Processing for the config_array:
                 $this->config['rootLine'] = $this->tmpl->rootLine;
                 $this->config['mainScript'] = trim($this->config['config']['mainScript']) ?: 'index.php';
                 if (isset($this->config['config']['mainScript']) || $this->config['mainScript'] !== 'index.php') {
                     $this->logDeprecatedTyposcript('config.mainScript', 'Setting the frontend script to something else than index.php is deprecated as of TYPO3 v8, and will not be possible in TYPO3 v9 without a custom extension');
                 }
                 // Class for render Header and Footer parts
                 if ($this->pSetup['pageHeaderFooterTemplateFile']) {
                     $file = $this->tmpl->getFileName($this->pSetup['pageHeaderFooterTemplateFile']);
                     if ($file) {
                         $this->pageRenderer->setTemplateFile($file);
                     }
                 }
             }
             $timeTracker->pull();
         } else {
             if ($this->checkPageUnavailableHandler()) {
                 $this->pageUnavailableAndExit('No TypoScript template found!');
             } else {
                 $message = 'No TypoScript template found!';
                 GeneralUtility::sysLog($message, 'cms', GeneralUtility::SYSLOG_SEVERITY_ERROR);
                 throw new ServiceUnavailableException($message, 1294587218);
             }
         }
     }
     // No cache
     // Set $this->no_cache TRUE if the config.no_cache value is set!
     if ($this->config['config']['no_cache']) {
         $this->set_no_cache('config.no_cache is set');
     }
     // Merge GET with defaultGetVars
     if (!empty($this->config['config']['defaultGetVars.'])) {
         $modifiedGetVars = GeneralUtility::removeDotsFromTS($this->config['config']['defaultGetVars.']);
         ArrayUtility::mergeRecursiveWithOverrule($modifiedGetVars, GeneralUtility::_GET());
         GeneralUtility::_GETset($modifiedGetVars);
     }
     // Hook for postProcessing the configuration array
     if (is_array($GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['tslib/class.tslib_fe.php']['configArrayPostProc'])) {
         $params = ['config' => &$this->config['config']];
         foreach ($GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['tslib/class.tslib_fe.php']['configArrayPostProc'] as $funcRef) {
             GeneralUtility::callUserFunction($funcRef, $params, $this);
         }
     }
 }