28 use TYPO3\CMS\Core\Package\PackageManager;
59 'matchAll' =>
'Using $matchAll of class TemplateService from the outside is discouraged, as this variable is only used for internal storage.',
60 'whereClause' =>
'Using $whereClause of class TemplateService is discouraged, as this has been superseded by Doctrine DBAL API.',
61 'debug' =>
'Using $debug of class TemplateService is discouraged, as this option has no effect anymore.',
62 'allowedPaths' =>
'Using $allowedPaths of class TemplateService from the outside is discouraged, as this variable is only used for internal storage.',
63 'simulationHiddenOrTime' =>
'Using $simulationHiddenOrTime of class TemplateService is discouraged, as this has been superseeded by Doctrine DBAL API.',
64 'nextLevel' =>
'Using $nextLevel of class TemplateService from the outside is discouraged, as this variable is only used for internal storage.',
65 'rootId' =>
'Using $rootId of class TemplateService from the outside is discouraged, use TemplateService->getRootId() instead.',
66 'absoluteRootLine' =>
'Using $absoluteRootLine of class TemplateService from the outside is discouraged, as this variable is only used for internal storage.',
67 'outermostRootlineIndexWithTemplate' =>
'Using $outermostRootlineIndexWithTemplate of class TemplateService from the outside is discouraged, as this variable is only used for internal storage.',
68 'rowSum' =>
'Using $rowSum of class TemplateService from the outside is discouraged, as this variable is only used for internal storage.',
69 'sitetitle' =>
'Using $sitetitle of class TemplateService from the outside is discouraged, as this variable is only used for internal storage.',
70 'sectionsMatch' =>
'Using $sectionsMatch of class TemplateService from the outside is discouraged, as this variable is only used for internal storage.',
71 'frames' =>
'Using $frames of class TemplateService from the outside is discouraged, as this variable is only used for internal storage.',
72 'MPmap' =>
'Using $MPmap of class TemplateService from the outside is discouraged, as this variable is only used for internal storage.',
73 'fileCache' =>
'Using $fileCache of class TemplateService from the outside is discouraged, the property will be removed in TYPO3 v10.0.',
81 'prependStaticExtra' =>
'Using prependStaticExtra() of class TemplateService from the outside is discouraged, as this method is only meant to be used internally.',
82 'versionOL' =>
'Using versionOL() of class TemplateService from the outside is discouraged, as this method is only meant to be used internally.',
83 'processIncludes' =>
'Using processIncludes() of class TemplateService from the outside is discouraged, as this method is only meant to be used internally.',
84 'mergeConstantsFromPageTSconfig' =>
'Using mergeConstantsFromPageTSconfig() of class TemplateService from the outside is discouraged, as this method is only meant to be used internally.',
85 'flattenSetup' =>
'Using flattenSetup() of class TemplateService from the outside is discouraged, as this method is only meant to be used internally.',
86 'substituteConstants' =>
'Using substituteConstants() of class TemplateService from the outside is discouraged, as this method is only meant to be used internally.',
399 $this->context =
$context ?? GeneralUtility::makeInstance(Context::class);
400 $this->packageManager =
$packageManager ?? GeneralUtility::makeInstance(PackageManager::class);
402 if ($this->context->getPropertyFromAspect(
'visibility',
'includeHiddenContent',
false) ||
$GLOBALS[
'SIM_ACCESS_TIME'] !==
$GLOBALS[
'ACCESS_TIME']) {
404 $this->simulationHiddenOrTime = 1;
408 $this->allowedPaths = [
409 $GLOBALS[
'TYPO3_CONF_VARS'][
'BE'][
'fileadminDir'],
413 TYPO3_mainDir .
'ext/',
414 TYPO3_mainDir .
'sysext/',
417 if (
$GLOBALS[
'TYPO3_CONF_VARS'][
'FE'][
'addAllowedPaths']) {
418 $pathArr = GeneralUtility::trimExplode(
',',
$GLOBALS[
'TYPO3_CONF_VARS'][
'FE'][
'addAllowedPaths'],
true);
419 foreach ($pathArr as $p) {
421 $this->allowedPaths[] = $p;
425 $this->tt_track = $this->verbose = (bool)$this->context->getPropertyFromAspect(
'backend.user',
'isLoggedIn',
false);
458 public function init()
460 trigger_error(
'TemplateService->init() will be removed in TYPO3 v10.0, __construct() does the job.', E_USER_DEPRECATED);
462 if ($this->context->getPropertyFromAspect(
'visibility',
'includeHiddenContent',
false) ||
$GLOBALS[
'SIM_ACCESS_TIME'] !==
$GLOBALS[
'ACCESS_TIME']) {
464 $this->simulationHiddenOrTime = 1;
468 $this->allowedPaths = [
469 $GLOBALS[
'TYPO3_CONF_VARS'][
'BE'][
'fileadminDir'],
473 TYPO3_mainDir .
'ext/',
474 TYPO3_mainDir .
'sysext/',
477 if (
$GLOBALS[
'TYPO3_CONF_VARS'][
'FE'][
'addAllowedPaths']) {
478 $pathArr = GeneralUtility::trimExplode(
',',
$GLOBALS[
'TYPO3_CONF_VARS'][
'FE'][
'addAllowedPaths'],
true);
479 foreach ($pathArr as $p) {
481 $this->allowedPaths[] = $p;
491 $includeHiddenRecords = $this->context->getPropertyFromAspect(
'visibility',
'includeHiddenContent',
false);
494 $this->whereClause =
'AND deleted=0 ';
495 if (!$includeHiddenRecords) {
496 $this->whereClause .=
'AND hidden=0 ';
498 $this->whereClause .=
'AND (starttime<=' .
$GLOBALS[
'SIM_ACCESS_TIME'] .
') AND (endtime=0 OR endtime>' .
$GLOBALS[
'SIM_ACCESS_TIME'] .
')';
501 $this->queryBuilderRestrictions = GeneralUtility::makeInstance(DefaultRestrictionContainer::class);
503 if ($includeHiddenRecords) {
504 $this->queryBuilderRestrictions->removeByType(HiddenRestriction::class);
538 if (is_array($cc[
'all'])) {
540 $matchObj = GeneralUtility::makeInstance(ConditionMatcher::class);
541 $matchObj->setRootline((array)$cc[
'rootLine']);
543 foreach ($cc[
'all'] as $key => $pre) {
544 if ($matchObj->match($pre)) {
561 public function start($theRootLine)
563 if (is_array($theRootLine)) {
566 $cacheIdentifier =
'';
576 if (serialize($this->rowSum) !== serialize($cc[
'rowSum'])) {
580 if (serialize($this->rootLine) === serialize($cc[
'rootLine'])) {
584 unset($cc[
'rootLine']);
589 if (isset($cc) && is_array($cc)) {
596 $cacheIdentifier = md5(serialize($cc));
599 $rowSumHash = md5(
'ROWSUM:' . serialize($this->rowSum));
601 if (is_array($result)) {
603 $cc[
'all'] = $result;
607 $cacheIdentifier = md5(serialize($cc));
610 if ($cacheIdentifier) {
613 if (is_array($cachedData)) {
614 $constantsData = $cachedData[
'constants'];
615 $setupData = $cachedData[
'setup'];
618 if (!empty($setupData) && !$this->forceTemplateParsing) {
620 $this->setup_constants = $constantsData;
621 $this->setup = $setupData;
622 if ($this->tt_track) {
626 if ($this->tt_track) {
640 $cacheIdentifier = md5(serialize($cc));
642 $this->
setCacheEntry($cacheIdentifier, [
'constants' => $this->setup_constants,
'setup' => $this->setup],
'TS_TEMPLATE');
643 if ($this->tt_track) {
646 $rowSumHash = md5(
'ROWSUM:' . serialize($this->rowSum));
647 $this->
setCacheEntry($rowSumHash, $cc[
'all'],
'TMPL_CONDITIONS_ALL');
660 $pageSectionCache = GeneralUtility::makeInstance(CacheManager::class)->getCache(
'cache_pagesection');
663 'mpvarHash_' . $mpvarHash
667 if ($this->rootId && $this->rootLine && $this->setup) {
668 $this->loaded =
true;
689 $this->constants = [];
692 $this->hierarchyInfoToRoot = [];
693 $this->absoluteRootLine = $theRootLine;
694 $this->isDefaultTypoScriptAdded =
false;
696 reset($this->absoluteRootLine);
697 $c = count($this->absoluteRootLine);
698 $queryBuilder = GeneralUtility::makeInstance(ConnectionPool::class)->getQueryBuilderForTable(
'sys_template');
699 for ($a = 0; $a < $c; $a++) {
701 if ($this->nextLevel) {
702 $queryBuilder->setRestrictions($this->queryBuilderRestrictions);
703 $queryResult = $queryBuilder
705 ->from(
'sys_template')
707 $queryBuilder->expr()->eq(
709 $queryBuilder->createNamedParameter($this->nextLevel, \PDO::PARAM_INT)
713 $this->nextLevel = 0;
714 if ($row = $queryResult->fetch()) {
716 if (is_array($row)) {
717 $this->
processTemplate($row,
'sys_' . $row[
'uid'], $this->absoluteRootLine[$a][
'uid'],
'sys_' . $row[
'uid']);
718 $this->outermostRootlineIndexWithTemplate = $a;
724 $queryBuilder->expr()->eq(
726 $queryBuilder->createNamedParameter($this->absoluteRootLine[$a][
'uid'], \PDO::PARAM_INT)
730 if ($a === $c - 1 && $start_template_uid) {
731 $where[] = $queryBuilder->expr()->eq(
733 $queryBuilder->createNamedParameter($start_template_uid, \PDO::PARAM_INT)
736 $queryBuilder->setRestrictions($this->queryBuilderRestrictions);
737 $queryResult = $queryBuilder
739 ->from(
'sys_template')
741 ->orderBy(
'root',
'DESC')
742 ->addOrderBy(
'sorting')
745 if ($row = $queryResult->fetch()) {
747 if (is_array($row)) {
748 $this->
processTemplate($row,
'sys_' . $row[
'uid'], $this->absoluteRootLine[$a][
'uid'],
'sys_' . $row[
'uid']);
749 $this->outermostRootlineIndexWithTemplate = $a;
752 $this->rootLine[] = $this->absoluteRootLine[$a];
761 'startTemplateUid' => $start_template_uid,
763 foreach (
$GLOBALS[
'TYPO3_CONF_VARS'][
'SC_OPTIONS'][
'Core/TypoScript/TemplateService'][
'runThroughTemplatesPostProcessing'] ?? [] as $listener) {
764 GeneralUtility::callUserFunction($listener, $hookParameters, $this);
768 if (!$this->extensionStaticsProcessed && $this->processExtensionStatics) {
790 public function processTemplate($row, $idList, $pid, $templateID =
'', $templateParent =
'', $includePath =
'')
793 $this->rowSum[] = [$row[
'uid'] ??
null, $row[
'title'] ??
null, $row[
'tstamp'] ??
null];
797 if (!empty($row[
'clear'])) {
798 $clConst = $row[
'clear'] & 1;
799 $clConf = $row[
'clear'] & 2;
802 foreach ($this->constants as &$constantConfiguration) {
803 $constantConfiguration =
'';
805 unset($constantConfiguration);
806 $this->clearList_const = [];
810 foreach ($this->config as &$configConfiguration) {
811 $configConfiguration =
'';
813 unset($configConfiguration);
814 $this->hierarchyInfoToRoot = [];
815 $this->clearList_setup = [];
820 if (!isset($row[
'includeStaticAfterBasedOn']) || !$row[
'includeStaticAfterBasedOn']) {
825 if (trim($row[
'basedOn'] ??
'')) {
828 $basedOnIds = GeneralUtility::intExplode(
',', $row[
'basedOn'],
true);
830 foreach ($basedOnIds as $key => $basedOnId) {
831 if (GeneralUtility::inList($idList,
'sys_' . $basedOnId)) {
832 unset($basedOnIds[$key]);
835 if (!empty($basedOnIds)) {
836 $queryBuilder = GeneralUtility::makeInstance(ConnectionPool::class)->getQueryBuilderForTable(
'sys_template');
837 $queryBuilder->setRestrictions($this->queryBuilderRestrictions);
838 $queryResult = $queryBuilder
840 ->from(
'sys_template')
842 $queryBuilder->expr()->in(
844 $queryBuilder->createNamedParameter($basedOnIds, Connection::PARAM_INT_ARRAY)
850 while ($rowItem = $queryResult->fetch()) {
851 $subTemplates[(int)$rowItem[
'uid']] = $rowItem;
854 foreach ($basedOnIds as $id) {
855 if (is_array($subTemplates[$id])) {
857 $this->
processTemplate($subTemplates[$id], $idList .
',sys_' . $id, $pid,
'sys_' . $id, $templateID);
863 if (!empty($row[
'includeStaticAfterBasedOn'])) {
867 $this->hierarchyInfo[] = ($this->hierarchyInfoToRoot[] = [
868 'root' => trim($row[
'root'] ??
''),
869 'next' => $row[
'nextLevel'] ??
null,
870 'clConst' => $clConst,
872 'templateID' => $templateID,
873 'templateParent' => $templateParent,
874 'title' => $row[
'title'],
875 'uid' => $row[
'uid'],
876 'pid' => $row[
'pid'] ??
null,
877 'configLines' => substr_count($row[
'config'], LF) + 1
880 $this->constants[] = $row[
'constants'];
881 $this->config[] = $row[
'config'];
882 $this->templateIncludePaths[] = $includePath;
884 $this->clearList_const[] = $templateID;
885 $this->clearList_setup[] = $templateID;
886 if (trim($row[
'sitetitle'] ??
null)) {
887 $this->sitetitle = $row[
'sitetitle'];
890 if (trim($row[
'root'] ??
null)) {
891 $this->rootId = $pid;
892 $this->rootLine = [];
895 if ($row[
'nextLevel'] ??
null) {
896 $this->nextLevel = $row[
'nextLevel'];
898 $this->nextLevel = 0;
914 if (!is_array($this->rootLine) || empty($this->rootLine)) {
918 $fullRootLineByUid = [];
919 foreach ($fullRootLine as $rootLineData) {
920 $fullRootLineByUid[$rootLineData[
'uid']] = $rootLineData;
923 foreach ($this->rootLine as $level => $dataArray) {
924 $currentUid = $dataArray[
'uid'];
926 if (!array_key_exists($currentUid, $fullRootLineByUid)) {
927 throw new \RuntimeException(sprintf(
'The full rootLine does not contain data for the page with the uid %d that is contained in the template rootline.', $currentUid), 1370419654);
930 $this->rootLine[$level] = $fullRootLineByUid[$currentUid];
948 'idList' => &$idList,
949 'templateId' => &$templateID,
953 foreach (
$GLOBALS[
'TYPO3_CONF_VARS'][
'SC_OPTIONS'][
't3lib/class.t3lib_tstemplate.php'][
'includeStaticTypoScriptSources'] ?? [] as $_funcRef) {
954 GeneralUtility::callUserFunction($_funcRef, $_params, $this);
957 $staticFileMode = $row[
'static_file_mode'] ??
null;
958 if ($staticFileMode == 3 && strpos($templateID,
'sys_') === 0 && $row[
'root']) {
962 if (trim($row[
'include_static_file'] ??
'')) {
963 $include_static_fileArr = GeneralUtility::trimExplode(
',', $row[
'include_static_file'],
true);
965 foreach ($include_static_fileArr as $ISF_file) {
966 if (strpos($ISF_file,
'EXT:') === 0) {
967 list($ISF_extKey, $ISF_localPath) = explode(
'/', substr($ISF_file, 4), 2);
969 $ISF_localPath = rtrim($ISF_localPath,
'/') .
'/';
971 if (@is_dir($ISF_filePath)) {
972 $mExtKey = str_replace(
'_',
'', $ISF_extKey .
'/' . $ISF_localPath);
976 'include_static' => @file_exists($ISF_filePath .
'include_static.txt') ? implode(
',', array_unique(GeneralUtility::intExplode(
',', file_get_contents($ISF_filePath .
'include_static.txt')))) :
'',
977 'include_static_file' => @file_exists($ISF_filePath .
'include_static_file.txt') ? implode(
',', array_unique(explode(
',', file_get_contents($ISF_filePath .
'include_static_file.txt')))) :
'',
978 'title' => $ISF_file,
982 $this->
processTemplate($subrow, $idList .
',ext_' . $mExtKey, $pid,
'ext_' . $mExtKey, $templateID, $ISF_filePath);
990 if ($staticFileMode == 1 || $staticFileMode == 0 && strpos($templateID,
'sys_') === 0 && $row[
'root']) {
995 'idList' => &$idList,
996 'templateId' => &$templateID,
1000 foreach (
$GLOBALS[
'TYPO3_CONF_VARS'][
'SC_OPTIONS'][
't3lib/class.t3lib_tstemplate.php'][
'includeStaticTypoScriptSourcesAtEnd'] ?? [] as $_funcRef) {
1001 GeneralUtility::callUserFunction($_funcRef, $_params, $this);
1015 $extensions = [
'.typoscript',
'.ts',
'.txt'];
1016 foreach ($extensions as $extension) {
1017 $fileName = $filePath . $baseName . $extension;
1018 if (@file_exists($fileName)) {
1019 return file_get_contents($fileName);
1036 $this->extensionStaticsProcessed =
true;
1038 foreach ($this->packageManager->getActivePackages() as $package) {
1039 $extKey = $package->getPackageKey();
1040 $packagePath = $package->getPackagePath();
1042 'ext_typoscript_constants.txt',
1043 'ext_typoscript_constants.typoscript',
1044 'ext_typoscript_setup.txt',
1045 'ext_typoscript_setup.typoscript',
1048 $hasExtensionStatics =
false;
1049 foreach ($filesToCheck as $file) {
1050 $path = $packagePath . $file;
1051 if (@file_exists($path)) {
1052 $files[$file] = $path;
1053 $hasExtensionStatics =
true;
1055 $files[$file] =
null;
1059 if ($hasExtensionStatics) {
1060 $mExtKey = str_replace(
'_',
'', $extKey);
1064 if (!empty($files[
'ext_typoscript_constants.typoscript'])) {
1065 $constants = @file_get_contents($files[
'ext_typoscript_constants.typoscript']);
1066 } elseif (!empty($files[
'ext_typoscript_constants.txt'])) {
1067 $constants = @file_get_contents($files[
'ext_typoscript_constants.txt']);
1070 if (!empty($files[
'ext_typoscript_setup.typoscript'])) {
1071 $config = @file_get_contents($files[
'ext_typoscript_setup.typoscript']);
1072 } elseif (!empty($files[
'ext_typoscript_setup.txt'])) {
1073 $config = @file_get_contents($files[
'ext_typoscript_setup.txt']);
1083 $idList .
',ext_' . $mExtKey,
1104 $identifier = $subrow[
'uid'];
1105 $subrow[
'config'] .=
$GLOBALS[
'TYPO3_CONF_VARS'][
'FE'][
'defaultTypoScript_setup.'][$identifier] ??
null;
1106 $subrow[
'constants'] .=
$GLOBALS[
'TYPO3_CONF_VARS'][
'FE'][
'defaultTypoScript_constants.'][$identifier] ??
null;
1108 if (in_array($identifier,
$GLOBALS[
'TYPO3_CONF_VARS'][
'FE'][
'contentRenderingTemplates'],
true)) {
1109 $subrow[
'config'] .=
$GLOBALS[
'TYPO3_CONF_VARS'][
'FE'][
'defaultTypoScript_setup.'][
'defaultContentRendering'];
1110 $subrow[
'constants'] .=
$GLOBALS[
'TYPO3_CONF_VARS'][
'FE'][
'defaultTypoScript_constants.'][
'defaultContentRendering'];
1161 $constants = GeneralUtility::makeInstance(Parser\TypoScriptParser::class);
1162 $constants->breakPointLN = (int)$this->ext_constants_BRP;
1165 $matchObj = GeneralUtility::makeInstance(ConditionMatcher::class);
1166 $matchObj->setSimulateMatchConditions($this->matchAlternative);
1167 $matchObj->setSimulateMatchResult((
bool)$this->matchAll);
1169 foreach ($this->constants as $str) {
1173 $this->parserErrors[
'constants'] =
$constants->errors;
1175 $this->flatSetup = [];
1182 $config = GeneralUtility::makeInstance(Parser\TypoScriptParser::class);
1183 $config->breakPointLN = (int)$this->ext_config_BRP;
1192 foreach ($this->config as $str) {
1198 if ($this->tt_track) {
1202 if ($this->tt_track) {
1207 if ($this->verbose) {
1208 if (preg_match_all(
'/\\{\\$.[^}]*\\}/', $all, $constantList) > 0) {
1209 if ($this->tt_track) {
1216 if ($this->tt_track) {
1222 $this->parserErrors[
'config'] =
$config->errors;
1232 unset($this->setup[
'sitetitle']);
1233 unset($this->setup[
'sitetitle.']);
1236 unset($this->setup[
'types.']);
1237 unset($this->setup[
'types']);
1238 if (is_array($this->setup)) {
1239 foreach ($this->setup as $key => $value) {
1240 if ($value ===
'PAGE') {
1242 if (isset($this->setup[$key .
'.'][
'typeNum'])) {
1243 $typeNum = $this->setup[$key .
'.'][
'typeNum'];
1244 $this->setup[
'types.'][$typeNum] = $key;
1245 } elseif (!isset($this->setup[
'types.'][0]) || !$this->setup[
'types.'][0]) {
1246 $this->setup[
'types.'][0] = $key;
1251 unset($this->setup[
'temp.']);
1254 $this->sections =
$config->sections;
1255 $this->sectionsMatch =
$config->sectionsMatch;
1267 if ($this->processIncludesHasBeenRun) {
1273 foreach ($this->constants as &$value) {
1275 $files = array_merge($files, $includeData[
'files']);
1276 $value = $includeData[
'typoscript'];
1280 foreach ($this->config as &$value) {
1282 $files = array_merge($files, $includeData[
'files']);
1283 $value = $includeData[
'typoscript'];
1287 if (!empty($files)) {
1288 $files = array_unique($files);
1289 foreach ($files as $file) {
1290 $this->rowSum[] = [$file, filemtime($file)];
1294 $this->processIncludesHasBeenRun =
true;
1308 $TSdataArray[] =
$GLOBALS[
'TYPO3_CONF_VARS'][
'BE'][
'defaultPageTSconfig'];
1310 if (trim($this->absoluteRootLine[$a][
'tsconfig_includes'])) {
1311 $includeTsConfigFileList = GeneralUtility::trimExplode(
1313 $this->absoluteRootLine[$a][
'tsconfig_includes'],
1319 $TSdataArray[] = $this->absoluteRootLine[$a][
'TSconfig'];
1323 $userTS = implode(LF .
'[GLOBAL]' . LF, $TSdataArray);
1325 $parseObj = GeneralUtility::makeInstance(Parser\TypoScriptParser::class);
1326 $parseObj->parse($userTS);
1327 if (is_array($parseObj->setup[
'TSFE.'][
'constants.'])) {
1343 foreach ($filesToInclude as $key => $file) {
1344 if (strpos($file,
'EXT:') !== 0) {
1348 list($extensionKey, $filePath) = explode(
'/', substr($file, 4), 2);
1353 if ((
string)$filePath ==
'') {
1358 if (file_exists($tsConfigFile)) {
1359 $TSdataArray[] = file_get_contents($tsConfigFile);
1363 return $TSdataArray;
1375 if (is_array($setupArray)) {
1376 foreach ($setupArray as $key => $val) {
1377 if (is_array($val)) {
1380 $this->flatSetup[$prefix . $key] = $val;
1395 if ($this->tt_track) {
1400 for ($i = 0; $i < 10 && !$noChange; $i++) {
1402 $all = preg_replace_callback(
'/\\{\\$(.[^}]*)\\}/', [$this,
'substituteConstantsCallBack'], $all);
1403 if ($old_all == $all) {
1421 return isset($this->flatSetup[$matches[1]]) && !is_array($this->flatSetup[$matches[1]]) ? $this->flatSetup[$matches[1]] : $matches[0];
1439 trigger_error(
'TemplateService->getFileName() will be removed in TYPO3 v10.0. Use FilePathSanitizer->sanitize() of EXT:frontend instead.', E_USER_DEPRECATED);
1441 $file = GeneralUtility::makeInstance(FilePathSanitizer::class)->sanitize((
string)$fileFromSetup);
1443 if (!isset($this->fileCache[$hash])) {
1444 $this->fileCache[$hash] = $file;
1450 if ($this->tt_track) {
1454 if ($this->tt_track) {
1457 }
catch (InvalidFileException $e) {
1458 if ($this->tt_track) {
1459 $this->
getTimeTracker()->
setTSlogMessage(
'"' . $fileFromSetup .
'" was not located in the allowed paths: (' . implode(
',', $this->allowedPaths) .
')', 3);
1476 public function printTitle($pageTitle, $noTitle =
false, $showTitleFirst =
false, $pageTitleSeparator =
'')
1478 trigger_error(
'TemplateService->printTitle() will be removed in TYPO3 v10.0. Title tag generation has been moved into $TSFE itself, re-implement this method if you need to, otherwise use TSFE->generatePageTitle() for full usage.', E_USER_DEPRECATED);
1479 $siteTitle = trim($this->setup[
'sitetitle']);
1480 $pageTitle = $noTitle ?
'' : $pageTitle;
1481 if ($showTitleFirst) {
1483 $siteTitle = $pageTitle;
1487 if ($pageTitle ===
'' || $siteTitle ===
'') {
1488 $pageTitleSeparator =
'';
1489 } elseif (empty($pageTitleSeparator)) {
1491 $pageTitleSeparator =
': ';
1493 return $siteTitle . $pageTitleSeparator . $pageTitle;
1505 foreach ($this->rootLine as $page) {
1506 if (GeneralUtility::inList($list, $page[
'uid'])) {
1547 public function linkData($page, $oTarget, $no_cache, $_ =
null, $overrideArray =
null, $addParams =
'', $typeOverride =
'', $targetDomain =
'')
1549 trigger_error(
'Creating URLs to pages is now encapsulated into PageLinkBuilder, and should be used in the future. TemplateService->linkData() will be removed in TYPO3 v10.0.', E_USER_DEPRECATED);
1552 if (is_array($overrideArray)) {
1553 foreach ($overrideArray as $theKey => $theNewVal) {
1554 $addParams .=
'&real_' . $theKey .
'=' . rawurlencode($page[$theKey]);
1555 $page[$theKey] = $theNewVal;
1559 if (!strstr($addParams,
'&MP=')) {
1567 $addParams .=
'&MP=' . rawurlencode($m);
1572 $script =
'index.php';
1573 if ($page[
'alias']) {
1574 $LD[
'url'] = $script .
'?id=' . rawurlencode($page[
'alias']);
1576 $LD[
'url'] = $script .
'?id=' . $page[
'uid'];
1579 $LD[
'target'] = trim($page[
'target']) ?: $oTarget;
1581 $typeNum = $this->setup[$LD[
'target'] .
'.'][
'typeNum'];
1585 if ((
string)$typeOverride !==
'') {
1586 $typeNum = $typeOverride;
1590 $LD[
'type'] =
'&type=' . (int)$typeNum;
1595 $LD[
'orig_type'] = $LD[
'type'];
1597 $LD[
'no_cache'] = $no_cache ?
'&no_cache=1' :
'';
1607 $LD[
'sectionIndex'] = $page[
'sectionIndex_uid'] ?
'#c' . $page[
'sectionIndex_uid'] :
'';
1609 $LD[
'totalURL'] = rtrim($LD[
'url'] . $LD[
'type'] . $LD[
'no_cache'] . $LD[
'linkVars'] . $this->
getTypoScriptFrontendController()->getMethodUrlIdToken,
'?') . $LD[
'sectionIndex'];
1613 'args' => [
'page' => $page,
'oTarget' => $oTarget,
'no_cache' => $no_cache,
'script' => $script,
'overrideArray' => $overrideArray,
'addParams' => $addParams,
'typeOverride' => $typeOverride,
'targetDomain' => $targetDomain],
1614 'typeNum' => $typeNum
1616 foreach (
$GLOBALS[
'TYPO3_CONF_VARS'][
'SC_OPTIONS'][
't3lib/class.t3lib_tstemplate.php'][
'linkData-PostProc'] ?? [] as $_funcRef) {
1617 GeneralUtility::callUserFunction($_funcRef, $_params, $this);
1635 trigger_error(
'Getting a mount point parameter for a page is now built into PageLinkBuilder, and should be used in the future. TemplateService->getFromMPmap() will be removed in TYPO3 v10.0.', E_USER_DEPRECATED);
1637 if (!is_array($this->MPmap)) {
1641 foreach ($rootPoints as $p) {
1643 if ($p ===
'root') {
1644 $p = $this->rootLine[0][
'uid'];
1645 if ($this->rootLine[0][
'_MOUNT_OL'] && $this->rootLine[0][
'_MP_PARAM']) {
1646 $initMParray[] = $this->rootLine[0][
'_MP_PARAM'];
1654 if (is_array($this->MPmap[$pageId]) && !empty($this->MPmap[$pageId])) {
1655 return implode(
',', $this->MPmap[$pageId]);
1672 trigger_error(
'Building a mount point parameter map is now built into PageLinkBuilder, and should be used in the future. TemplateService->initMPmap_creat() will be removed in TYPO3 v10.0.', E_USER_DEPRECATED);
1682 if (is_array($mount_info) && $mount_info[
'overlay']) {
1683 $MP_array[] = $mount_info[
'MPvar'];
1684 $id = $mount_info[
'mount_pid'];
1687 $this->MPmap[$id] = $MP_array;
1689 if (is_array($mount_info) && !$mount_info[
'overlay']) {
1690 $MP_array[] = $mount_info[
'MPvar'];
1691 $id = $mount_info[
'mount_pid'];
1694 if ($id && $level < 20) {
1697 $queryBuilder = GeneralUtility::makeInstance(ConnectionPool::class)->getQueryBuilderForTable(
'pages');
1698 $queryBuilder->getRestrictions()
1700 ->add(GeneralUtility::makeInstance(DeletedRestriction::class));
1701 $queryResult = $queryBuilder
1702 ->select(
'uid',
'pid',
'doktype',
'mount_pid',
'mount_pid_ol')
1705 $queryBuilder->expr()->eq(
1707 $queryBuilder->createNamedParameter($id, \PDO::PARAM_INT)
1709 $queryBuilder->expr()->neq(
1713 $queryBuilder->expr()->neq(
1718 while ($row = $queryResult->fetch()) {
1720 $next_id = $row[
'uid'];
1721 $next_MP_array = $MP_array;
1724 if (is_array($mount_info) && $mount_info[
'overlay']) {
1725 $next_MP_array[] = $mount_info[
'MPvar'];
1726 $next_id = $mount_info[
'mount_pid'];
1728 if (!isset($this->MPmap[$next_id])) {
1730 $this->MPmap[$next_id] = $next_MP_array;
1732 if (is_array($mount_info) && !$mount_info[
'overlay']) {
1733 $next_MP_array[] = $mount_info[
'MPvar'];
1734 $next_id = $mount_info[
'mount_pid'];
1738 $nextLevelAcc[] = [$next_id, $next_MP_array];
1742 foreach ($nextLevelAcc as $pSet) {
1758 if (!$this->isDefaultTypoScriptAdded) {
1762 array_unshift($this->constants, (
string)
$GLOBALS[
'TYPO3_CONF_VARS'][
'FE'][
'defaultTypoScript_constants']);
1763 array_unshift($this->config, (
string)
$GLOBALS[
'TYPO3_CONF_VARS'][
'FE'][
'defaultTypoScript_setup']);
1764 array_unshift($this->templateIncludePaths,
'');
1766 $rootTemplateId = $this->hierarchyInfo[count($this->hierarchyInfo) - 1][
'templateID'] ??
null;
1767 $defaultTemplateInfo = [
1772 'templateID' =>
'_defaultTypoScript_',
1773 'templateParent' => $rootTemplateId,
1774 'title' =>
'SYS:TYPO3_CONF_VARS:FE:defaultTypoScript',
1775 'uid' =>
'_defaultTypoScript_',
1777 'configLines' => substr_count((
string)
$GLOBALS[
'TYPO3_CONF_VARS'][
'FE'][
'defaultTypoScript_setup'], LF) + 1
1780 array_unshift($this->clearList_const, $defaultTemplateInfo[
'uid']);
1781 array_unshift($this->clearList_setup, $defaultTemplateInfo[
'uid']);
1782 array_unshift($this->hierarchyInfo, $defaultTemplateInfo);
1783 $this->isDefaultTypoScriptAdded =
true;
1800 return GeneralUtility::makeInstance(TimeTracker::class);
1812 return GeneralUtility::makeInstance(CacheManager::class)->getCache(
'cache_hash')->get($identifier);
1824 GeneralUtility::makeInstance(CacheManager::class)->getCache(
'cache_hash')->set($identifier, $data, [
'ident_' . $tag], 0);