[TASK] Move vendor/ directory out of contrib/
[Packages/TYPO3.CMS.git] / typo3 / sysext / core / Classes / TypoScript / TemplateService.php
1 <?php
2 namespace TYPO3\CMS\Core\TypoScript;
3
4 /*
5 * This file is part of the TYPO3 CMS project.
6 *
7 * It is free software; you can redistribute it and/or modify it under
8 * the terms of the GNU General Public License, either version 2
9 * of the License, or any later version.
10 *
11 * For the full copyright and license information, please read the
12 * LICENSE.txt file that was distributed with this source code.
13 *
14 * The TYPO3 project - inspiring people to share!
15 */
16
17 use TYPO3\CMS\Backend\Utility\BackendUtility;
18 use TYPO3\CMS\Core\Cache\CacheManager;
19 use TYPO3\CMS\Core\Database\DatabaseConnection;
20 use TYPO3\CMS\Core\TimeTracker\TimeTracker;
21 use TYPO3\CMS\Core\Utility\ArrayUtility;
22 use TYPO3\CMS\Core\Utility\ExtensionManagementUtility;
23 use TYPO3\CMS\Core\Utility\GeneralUtility;
24 use TYPO3\CMS\Core\Utility\MathUtility;
25 use TYPO3\CMS\Core\Utility\PathUtility;
26 use TYPO3\CMS\Core\Utility\StringUtility;
27 use TYPO3\CMS\Frontend\Configuration\TypoScript\ConditionMatching\ConditionMatcher;
28 use TYPO3\CMS\Frontend\Controller\TypoScriptFrontendController;
29 use TYPO3\CMS\Frontend\Page\PageRepository;
30
31 /**
32 * Template object that is responsible for generating the TypoScript template based on template records.
33 * @see \TYPO3\CMS\Core\TypoScript\Parser\TypoScriptParser
34 * @see \TYPO3\CMS\Core\Configuration\TypoScript\ConditionMatching\AbstractConditionMatcher
35 */
36 class TemplateService {
37
38 /**
39 * option to enable logging, time-tracking (FE-only)
40 * usually, this is only done when
41 * - in FE a BE_USER is logged-in
42 * - in BE when the BE_USER needs information about the template (TypoScript module)
43 * @var bool
44 */
45 protected $verbose = FALSE;
46
47 /**
48 * If set, the global tt-timeobject is used to log the performance.
49 *
50 * @var bool
51 */
52 public $tt_track = TRUE;
53
54 /**
55 * If set, the template is always rendered. Used from Admin Panel.
56 *
57 * @var bool
58 */
59 public $forceTemplateParsing = FALSE;
60
61 /**
62 * This array is passed on to matchObj by generateConfig().
63 * If it holds elements, they are used for matching instead. See commment at the match-class.
64 * Used for backend modules only. Never frontend!
65 *
66 * @var array
67 */
68 public $matchAlternative = array();
69
70 /**
71 * If set, the match-class matches everything! Used for backend modules only. Never frontend!
72 *
73 * @var bool
74 */
75 public $matchAll = FALSE;
76
77 /**
78 * @var bool
79 */
80 public $backend_info = FALSE;
81
82 /**
83 * Externally set breakpoints (used by Backend Modules)
84 *
85 * @var int
86 */
87 public $ext_constants_BRP = 0;
88
89 /**
90 * @var int
91 */
92 public $ext_config_BRP = 0;
93
94 /**
95 * @var bool
96 */
97 public $ext_regLinenumbers = FALSE;
98
99 /**
100 * @var bool
101 */
102 public $ext_regComments = FALSE;
103
104 /**
105 * @var string
106 */
107 public $tempPath = 'typo3temp/';
108
109 /**
110 * This MUST be initialized by the init() function
111 *
112 * @var string
113 */
114 public $whereClause = '';
115
116 /**
117 * @var bool
118 */
119 public $debug = FALSE;
120
121 /**
122 * This is the only paths (relative!!) that are allowed for resources in TypoScript.
123 * Should all be appended with '/'. You can extend these by the global array TYPO3_CONF_VARS. See init() function.
124 *
125 * @var array
126 */
127 public $allowedPaths = array();
128
129 /**
130 * See init(); Set if preview of some kind is enabled.
131 *
132 * @var int
133 */
134 public $simulationHiddenOrTime = 0;
135
136 /**
137 * Set, if the TypoScript template structure is loaded and OK, see ->start()
138 *
139 * @var bool
140 */
141 public $loaded = FALSE;
142
143 /**
144 * @var array Contains TypoScript setup part after parsing
145 */
146 public $setup = array();
147
148 /**
149 * @var array
150 */
151 public $flatSetup = array();
152
153 /**
154 * For fetching TypoScript code from template hierarchy before parsing it.
155 * Each array contains code field values from template records/files:
156 * Setup field
157 *
158 * @var array
159 */
160 public $config = array();
161
162 /**
163 * Constant field
164 *
165 * @var array
166 */
167 public $constants = array();
168
169 /**
170 * Holds the include paths of the templates (empty if from database)
171 *
172 * @var array
173 */
174 protected $templateIncludePaths = array();
175
176 /**
177 * For Template Analyser in backend
178 *
179 * @var array
180 */
181 public $hierarchyInfo = array();
182
183 /**
184 * For Template Analyser in backend (setup content only)
185 *
186 * @var array
187 */
188 public $hierarchyInfoToRoot = array();
189
190 /**
191 * Next-level flag (see runThroughTemplates())
192 *
193 * @var int
194 */
195 public $nextLevel = 0;
196
197 /**
198 * The Page UID of the root page
199 *
200 * @var int
201 */
202 public $rootId;
203
204 /**
205 * The rootline from current page to the root page
206 *
207 * @var array
208 */
209 public $rootLine;
210
211 /**
212 * Rootline all the way to the root. Set but runThroughTemplates
213 *
214 * @var array
215 */
216 public $absoluteRootLine;
217
218 /**
219 * A pointer to the last entry in the rootline where a template was found.
220 *
221 * @var int
222 */
223 public $outermostRootlineIndexWithTemplate = 0;
224
225 /**
226 * Array of arrays with title/uid of templates in hierarchy
227 *
228 * @var array
229 */
230 public $rowSum;
231
232 /**
233 * The current site title field.
234 *
235 * @var string
236 */
237 public $sitetitle = '';
238
239 /**
240 * Tracking all conditions found during parsing of TypoScript. Used for the "all" key in currentPageData
241 *
242 * @var string
243 */
244 public $sections;
245
246 /**
247 * Tracking all matching conditions found
248 *
249 * @var array
250 */
251 public $sectionsMatch;
252
253 /**
254 * Used by Backend only (Typoscript Template Analyzer)
255 *
256 */
257 public $clearList_const = array();
258
259 /**
260 * Used by Backend only (Typoscript Template Analyzer)
261 *
262 * @var array
263 */
264 public $clearList_setup = array();
265
266 /**
267 * @var array
268 */
269 public $parserErrors = array();
270
271 /**
272 * @var array
273 */
274 public $setup_constants = array();
275
276 /**
277 * Used by getFileName for caching of references to file resources
278 *
279 * @var array
280 */
281 public $fileCache = array();
282
283 /**
284 * Keys are frame names and values are type-values, which must be used to refer correctly to the content of the frames.
285 *
286 * @var array
287 */
288 public $frames = array();
289
290 /**
291 * Contains mapping of Page id numbers to MP variables.
292 *
293 * @var string
294 */
295 public $MPmap = '';
296
297 /**
298 * Indicator that extension statics are processed.
299 *
300 * These files are considered if either a root template
301 * has been processed or the $processExtensionStatics
302 * property has been set to TRUE.
303 *
304 * @var bool
305 */
306 protected $extensionStaticsProcessed = FALSE;
307
308 /**
309 * Trigger value, to ensure that extension statics are processed.
310 *
311 * @var bool
312 */
313 protected $processExtensionStatics = FALSE;
314
315 /**
316 * Set to TRUE after the default TypoScript was added during parsing.
317 * This prevents double inclusion of the same TypoScript code.
318 *
319 * @see addDefaultTypoScript()
320 * @var bool
321 */
322 protected $isDefaultTypoScriptAdded = FALSE;
323
324 /**
325 * Set to TRUE after $this->config and $this->constants have processed all <INCLUDE_TYPOSCRIPT:> instructions.
326 *
327 * This prevents double processing of INCLUDES.
328 *
329 * @see processIncludes()
330 * @var bool
331 */
332 protected $processIncludesHasBeenRun = FALSE;
333
334 /**
335 * @return bool
336 */
337 public function getProcessExtensionStatics() {
338 return $this->processExtensionStatics;
339 }
340
341 /**
342 * @param bool $processExtensionStatics
343 */
344 public function setProcessExtensionStatics($processExtensionStatics) {
345 $this->processExtensionStatics = (bool)$processExtensionStatics;
346 }
347
348 /**
349 * sets the verbose parameter
350 * @param bool $verbose
351 */
352 public function setVerbose($verbose) {
353 $this->verbose = (bool)$verbose;
354 }
355
356 /**
357 * Initialize
358 * MUST be called directly after creating a new template-object
359 *
360 * @return void
361 * @see \TYPO3\CMS\Frontend\Controller\TypoScriptFrontendController::initTemplate()
362 */
363 public function init() {
364 // $this->whereClause is used only to select templates from sys_template.
365 // $GLOBALS['SIM_ACCESS_TIME'] is used so that we're able to simulate a later time as a test...
366 $this->whereClause = 'AND deleted=0 ';
367 if (!$this->getTypoScriptFrontendController()->showHiddenRecords) {
368 $this->whereClause .= 'AND hidden=0 ';
369 }
370 if ($this->getTypoScriptFrontendController()->showHiddenRecords || $GLOBALS['SIM_ACCESS_TIME'] != $GLOBALS['ACCESS_TIME']) {
371 // Set the simulation flag, if simulation is detected!
372 $this->simulationHiddenOrTime = 1;
373 }
374 $this->whereClause .= 'AND (starttime<=' . $GLOBALS['SIM_ACCESS_TIME'] . ') AND (endtime=0 OR endtime>' . $GLOBALS['SIM_ACCESS_TIME'] . ')';
375 // Sets the paths from where TypoScript resources are allowed to be used:
376 $this->allowedPaths = array(
377 $GLOBALS['TYPO3_CONF_VARS']['BE']['fileadminDir'],
378 // fileadmin/ path
379 'uploads/',
380 'typo3temp/',
381 TYPO3_mainDir . 'ext/',
382 TYPO3_mainDir . 'sysext/',
383 'typo3conf/ext/'
384 );
385 if ($GLOBALS['TYPO3_CONF_VARS']['FE']['addAllowedPaths']) {
386 $pathArr = GeneralUtility::trimExplode(',', $GLOBALS['TYPO3_CONF_VARS']['FE']['addAllowedPaths'], TRUE);
387 foreach ($pathArr as $p) {
388 // Once checked for path, but as this may run from typo3/mod/web/ts/ dir, that'll not work!! So the paths ar uncritically included here.
389 $this->allowedPaths[] = $p;
390 }
391 }
392 }
393
394 /**
395 * Fetches the "currentPageData" array from cache
396 *
397 * NOTE about currentPageData:
398 * It holds information about the TypoScript conditions along with the list
399 * of template uid's which is used on the page. In the getFromCache() function
400 * in TSFE, currentPageData is used to evaluate if there is a template and
401 * if the matching conditions are alright. Unfortunately this does not take
402 * into account if the templates in the rowSum of currentPageData has
403 * changed composition, eg. due to hidden fields or start/end time. So if a
404 * template is hidden or times out, it'll not be discovered unless the page
405 * is regenerated - at least the this->start function must be called,
406 * because this will make a new portion of data in currentPageData string.
407 *
408 * @return array Returns the unmatched array $currentPageData if found cached in "cache_pagesection". Otherwise FALSE is returned which means that the array must be generated and stored in the cache
409 */
410 public function getCurrentPageData() {
411 return GeneralUtility::makeInstance(CacheManager::class)->getCache('cache_pagesection')->get((int)$this->getTypoScriptFrontendController()->id . '_' . GeneralUtility::md5int($this->getTypoScriptFrontendController()->MP));
412 }
413
414 /**
415 * Fetches data about which TypoScript-matches there are at this page. Then it performs a matchingtest.
416 *
417 * @param array $cc An array with three keys, "all", "rowSum" and "rootLine" - all coming from the "currentPageData" array
418 * @return array The input array but with a new key added, "match" which contains the items from the "all" key which when passed to tslib_matchCondition returned TRUE.
419 */
420 public function matching($cc) {
421 if (is_array($cc['all'])) {
422 /** @var $matchObj ConditionMatcher */
423 $matchObj = GeneralUtility::makeInstance(ConditionMatcher::class);
424 $matchObj->setRootline((array)$cc['rootLine']);
425 $sectionsMatch = array();
426 foreach ($cc['all'] as $key => $pre) {
427 if ($matchObj->match($pre)) {
428 $sectionsMatch[$key] = $pre;
429 }
430 }
431 $cc['match'] = $sectionsMatch;
432 }
433 return $cc;
434 }
435
436 /**
437 * This is all about fetching the right TypoScript template structure. If it's not cached then it must be generated and cached!
438 * The method traverses the rootline structure from out to in, fetches the hierarchy of template records and based on this either finds the cached TypoScript template structure or parses the template and caches it for next time.
439 * Sets $this->setup to the parsed TypoScript template array
440 *
441 * @param array $theRootLine The rootline of the current page (going ALL the way to tree root)
442 * @return void
443 * @see \TYPO3\CMS\Frontend\Controller\TypoScriptFrontendController::getConfigArray()
444 */
445 public function start($theRootLine) {
446 if (is_array($theRootLine)) {
447 $setupData = '';
448 $hash = '';
449 // Flag that indicates that the existing data in cache_pagesection
450 // could be used (this is the case if $TSFE->all is set, and the
451 // rowSum still matches). Based on this we decide if cache_pagesection
452 // needs to be updated...
453 $isCached = FALSE;
454 $this->runThroughTemplates($theRootLine);
455 if ($this->getTypoScriptFrontendController()->all) {
456 $cc = $this->getTypoScriptFrontendController()->all;
457 // The two rowSums must NOT be different from each other - which they will be if start/endtime or hidden has changed!
458 if (serialize($this->rowSum) !== serialize($cc['rowSum'])) {
459 unset($cc);
460 } else {
461 // If $TSFE->all contains valid data, we don't need to update cache_pagesection (because this data was fetched from there already)
462 if (serialize($this->rootLine) === serialize($cc['rootLine'])) {
463 $isCached = TRUE;
464 }
465 // When the data is serialized below (ROWSUM hash), it must not contain the rootline by concept. So this must be removed (and added again later)...
466 unset($cc['rootLine']);
467 }
468 }
469 // This is about getting the hash string which is used to fetch the cached TypoScript template.
470 // If there was some cached currentPageData ($cc) then that's good (it gives us the hash).
471 if (isset($cc) && is_array($cc)) {
472 // If currentPageData was actually there, we match the result (if this wasn't done already in $TSFE->getFromCache()...)
473 if (!$cc['match']) {
474 // @todo check if this can ever be the case - otherwise remove
475 $cc = $this->matching($cc);
476 ksort($cc);
477 }
478 $hash = md5(serialize($cc));
479 } else {
480 // If currentPageData was not there, we first find $rowSum (freshly generated). After that we try to see, if it is stored with a list of all conditions. If so we match the result.
481 $rowSumHash = md5('ROWSUM:' . serialize($this->rowSum));
482 $result = PageRepository::getHash($rowSumHash);
483 if (is_array($result)) {
484 $cc = array();
485 $cc['all'] = $result;
486 $cc['rowSum'] = $this->rowSum;
487 $cc = $this->matching($cc);
488 ksort($cc);
489 $hash = md5(serialize($cc));
490 }
491 }
492 if ($hash) {
493 // Get TypoScript setup array
494 $setupData = PageRepository::getHash($hash);
495 }
496 if (is_array($setupData) && !$this->forceTemplateParsing) {
497 // If TypoScript setup structure was cached we unserialize it here:
498 $this->setup = $setupData;
499 if ($this->tt_track) {
500 $this->getTimeTracker()->setTSLogMessage('Using cached TS template data');
501 }
502 } else {
503 if ($this->tt_track) {
504 $this->getTimeTracker()->setTSLogMessage('Not using any cached TS data');
505 }
506
507 // Make configuration
508 $this->generateConfig();
509 // This stores the template hash thing
510 $cc = array();
511 // All sections in the template at this point is found
512 $cc['all'] = $this->sections;
513 // The line of templates is collected
514 $cc['rowSum'] = $this->rowSum;
515 $cc = $this->matching($cc);
516 ksort($cc);
517 $hash = md5(serialize($cc));
518 // This stores the data.
519 PageRepository::storeHash($hash, $this->setup, 'TS_TEMPLATE');
520 if ($this->tt_track) {
521 $this->getTimeTracker()->setTSlogMessage('TS template size, serialized: ' . strlen(serialize($this->setup)) . ' bytes');
522 }
523 $rowSumHash = md5('ROWSUM:' . serialize($this->rowSum));
524 PageRepository::storeHash($rowSumHash, $cc['all'], 'TMPL_CONDITIONS_ALL');
525 }
526 // Add rootLine
527 $cc['rootLine'] = $this->rootLine;
528 ksort($cc);
529 // Make global and save
530 $this->getTypoScriptFrontendController()->all = $cc;
531 // Matching must be executed for every request, so this must never be part of the pagesection cache!
532 unset($cc['match']);
533 if (!$isCached && !$this->simulationHiddenOrTime && !$this->getTypoScriptFrontendController()->no_cache) {
534 // Only save the data if we're not simulating by hidden/starttime/endtime
535 $mpvarHash = GeneralUtility::md5int($this->getTypoScriptFrontendController()->MP);
536 /** @var $pageSectionCache \TYPO3\CMS\Core\Cache\Frontend\FrontendInterface */
537 $pageSectionCache = GeneralUtility::makeInstance(CacheManager::class)->getCache('cache_pagesection');
538 $pageSectionCache->set((int)$this->getTypoScriptFrontendController()->id . '_' . $mpvarHash, $cc, array(
539 'pageId_' . (int)$this->getTypoScriptFrontendController()->id,
540 'mpvarHash_' . $mpvarHash
541 ));
542 }
543 // If everything OK.
544 if ($this->rootId && $this->rootLine && $this->setup) {
545 $this->loaded = TRUE;
546 }
547 }
548 }
549
550 /*******************************************************************
551 *
552 * Fetching TypoScript code text for the Template Hierarchy
553 *
554 *******************************************************************/
555 /**
556 * Traverses the rootLine from the root and out. For each page it checks if there is a template record. If there is a template record, $this->processTemplate() is called.
557 * Resets and affects internal variables like $this->constants, $this->config and $this->rowSum
558 * Also creates $this->rootLine which is a root line stopping at the root template (contrary to $this->getTypoScriptFrontendController()->rootLine which goes all the way to the root of the tree
559 *
560 * @param array $theRootLine The rootline of the current page (going ALL the way to tree root)
561 * @param int $start_template_uid Set specific template record UID to select; this is only for debugging/development/analysis use in backend modules like "Web > Template". For parsing TypoScript templates in the frontend it should be 0 (zero)
562 * @return void
563 * @see start()
564 */
565 public function runThroughTemplates($theRootLine, $start_template_uid = 0) {
566 $this->constants = array();
567 $this->config = array();
568 $this->rowSum = array();
569 $this->hierarchyInfoToRoot = array();
570 $this->absoluteRootLine = $theRootLine;
571 $this->isDefaultTypoScriptAdded = FALSE;
572
573 reset($this->absoluteRootLine);
574 $c = count($this->absoluteRootLine);
575 for ($a = 0; $a < $c; $a++) {
576 // If some template loaded before has set a template-id for the next level, then load this template first!
577 if ($this->nextLevel) {
578 $res = $this->getDatabaseConnection()->exec_SELECTquery('*', 'sys_template', 'uid=' . (int)$this->nextLevel . ' ' . $this->whereClause);
579 $this->nextLevel = 0;
580 if ($row = $this->getDatabaseConnection()->sql_fetch_assoc($res)) {
581 $this->versionOL($row);
582 if (is_array($row)) {
583 $this->processTemplate($row, 'sys_' . $row['uid'], $this->absoluteRootLine[$a]['uid'], 'sys_' . $row['uid']);
584 $this->outermostRootlineIndexWithTemplate = $a;
585 }
586 }
587 $this->getDatabaseConnection()->sql_free_result($res);
588 }
589 $addC = '';
590 // If first loop AND there is set an alternative template uid, use that
591 if ($a == $c - 1 && $start_template_uid) {
592 $addC = ' AND uid=' . (int)$start_template_uid;
593 }
594 $res = $this->getDatabaseConnection()->exec_SELECTquery('*', 'sys_template', 'pid=' . (int)$this->absoluteRootLine[$a]['uid'] . $addC . ' ' . $this->whereClause, '', 'root DESC, sorting', 1);
595 if ($row = $this->getDatabaseConnection()->sql_fetch_assoc($res)) {
596 $this->versionOL($row);
597 if (is_array($row)) {
598 $this->processTemplate($row, 'sys_' . $row['uid'], $this->absoluteRootLine[$a]['uid'], 'sys_' . $row['uid']);
599 $this->outermostRootlineIndexWithTemplate = $a;
600 }
601 }
602 $this->getDatabaseConnection()->sql_free_result($res);
603 $this->rootLine[] = $this->absoluteRootLine[$a];
604 }
605
606 // Process extension static files if not done yet, but explicitly requested
607 if (!$this->extensionStaticsProcessed && $this->processExtensionStatics) {
608 $this->addExtensionStatics('sys_0', 'sys_0', 0, array());
609 }
610
611 // Add the global default TypoScript from the TYPO3_CONF_VARS
612 $this->addDefaultTypoScript();
613
614 $this->processIncludes();
615 }
616
617 /**
618 * Checks if the template ($row) has some included templates and after including them it fills the arrays with the setup
619 * Builds up $this->rowSum
620 *
621 * @param array $row A full TypoScript template record (sys_template/static_template/forged "dummy" record made from static template file)
622 * @param string $idList A list of already processed template ids including the current; The list is on the form "[prefix]_[uid]" where [prefix] is "sys" for "sys_template" records, "static" for "static_template" records and "ext_" for static include files (from extensions). The list is used to check that the recursive inclusion of templates does not go into circles: Simply it is used to NOT include a template record/file which has already BEEN included somewhere in the recursion.
623 * @param int $pid The PID of the input template record
624 * @param string $templateID The id of the current template. Same syntax as $idList ids, eg. "sys_123
625 * @param string $templateParent Parent template id (during recursive call); Same syntax as $idList ids, eg. "sys_123
626 * @param string $includePath Specifies the path from which the template was included (used with static_includes)
627 * @return void
628 * @see runThroughTemplates()
629 */
630 public function processTemplate($row, $idList, $pid, $templateID = '', $templateParent = '', $includePath = '') {
631 // Adding basic template record information to rowSum array
632 $this->rowSum[] = array($row['uid'], $row['title'], $row['tstamp']);
633 // Processing "Clear"-flags
634 $clConst = 0;
635 $clConf = 0;
636 if ($row['clear']) {
637 $clConst = $row['clear'] & 1;
638 $clConf = $row['clear'] & 2;
639 if ($clConst) {
640 $this->constants = array();
641 $this->clearList_const = array();
642 }
643 if ($clConf) {
644 $this->config = array();
645 $this->hierarchyInfoToRoot = array();
646 $this->clearList_setup = array();
647 }
648 }
649 // Include static records (static_template) or files (from extensions) (#1/2)
650 // NORMAL inclusion, The EXACT same code is found below the basedOn inclusion!!!
651 if (!$row['includeStaticAfterBasedOn']) {
652 $this->includeStaticTypoScriptSources($idList, $templateID, $pid, $row);
653 }
654 // Include "Based On" sys_templates:
655 // 'basedOn' is a list of templates to include
656 if (trim($row['basedOn'])) {
657 // Normal Operation, which is to include the "based-on" sys_templates,
658 // if they are not already included, and maintaining the sorting of the templates
659 $basedOnIds = GeneralUtility::intExplode(',', $row['basedOn'], TRUE);
660 // skip template if it's already included
661 foreach ($basedOnIds as $key => $basedOnId) {
662 if (GeneralUtility::inList($idList, 'sys_' . $basedOnId)) {
663 unset($basedOnIds[$key]);
664 }
665 }
666 if (!empty($basedOnIds)) {
667 $subTemplates = $this->getDatabaseConnection()->exec_SELECTgetRows('*', 'sys_template', 'uid IN (' . implode(',', $basedOnIds) . ') ' . $this->whereClause, '', '', '', 'uid');
668 // Traversing list again to ensure the sorting of the templates
669 foreach ($basedOnIds as $id) {
670 if (is_array($subTemplates[$id])) {
671 $this->versionOL($subTemplates[$id]);
672 $this->processTemplate($subTemplates[$id], $idList . ',sys_' . $id, $pid, 'sys_' . $id, $templateID);
673 }
674 }
675 }
676 }
677 // Include static records (static_template) or files (from extensions) (#2/2)
678 if ($row['includeStaticAfterBasedOn']) {
679 $this->includeStaticTypoScriptSources($idList, $templateID, $pid, $row);
680 }
681 // Creating hierarchy information; Used by backend analysis tools
682 $this->hierarchyInfo[] = ($this->hierarchyInfoToRoot[] = array(
683 'root' => trim($row['root']),
684 'next' => $row['nextLevel'],
685 'clConst' => $clConst,
686 'clConf' => $clConf,
687 'templateID' => $templateID,
688 'templateParent' => $templateParent,
689 'title' => $row['title'],
690 'uid' => $row['uid'],
691 'pid' => $row['pid'],
692 'configLines' => substr_count($row['config'], LF) + 1
693 ));
694 // Adding the content of the fields constants (Constants) and config (Setup)
695 $this->constants[] = $row['constants'];
696 $this->config[] = $row['config'];
697 $this->templateIncludePaths[] = $includePath;
698 // For backend analysis (Template Analyser) provide the order of added constants/config template IDs
699 $this->clearList_const[] = $templateID;
700 $this->clearList_setup[] = $templateID;
701 if (trim($row['sitetitle'])) {
702 $this->sitetitle = $row['sitetitle'];
703 }
704 // If the template record is a Rootlevel record, set the flag and clear the template rootLine (so it starts over from this point)
705 if (trim($row['root'])) {
706 $this->rootId = $pid;
707 $this->rootLine = array();
708 }
709 // If a template is set to be active on the next level set this internal value to point to this UID. (See runThroughTemplates())
710 if ($row['nextLevel']) {
711 $this->nextLevel = $row['nextLevel'];
712 } else {
713 $this->nextLevel = 0;
714 }
715 }
716
717 /**
718 * This function can be used to update the data of the current rootLine
719 * e.g. when a different language is used.
720 *
721 * This function must not be used if there are different pages in the
722 * rootline as before!
723 *
724 * @param array $fullRootLine Array containing the FULL rootline (up to the TYPO3 root)
725 * @return void
726 * @throws \RuntimeException If the given $fullRootLine does not contain all pages that are in the current template rootline
727 */
728 public function updateRootlineData($fullRootLine) {
729 if (!is_array($this->rootLine) || empty($this->rootLine)) {
730 return;
731 }
732
733 $fullRootLineByUid = array();
734 foreach ($fullRootLine as $rootLineData) {
735 $fullRootLineByUid[$rootLineData['uid']] = $rootLineData;
736 }
737
738 foreach ($this->rootLine as $level => $dataArray) {
739 $currentUid = $dataArray['uid'];
740
741 if (!array_key_exists($currentUid, $fullRootLineByUid)) {
742 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);
743 }
744
745 $this->rootLine[$level] = $fullRootLineByUid[$currentUid];
746 }
747 }
748
749 /**
750 * Includes static template records (from static_template table, loaded through a hook) and static template files (from extensions) for the input template record row.
751 *
752 * @param string $idList A list of already processed template ids including the current; The list is on the form "[prefix]_[uid]" where [prefix] is "sys" for "sys_template" records, "static" for "static_template" records and "ext_" for static include files (from extensions). The list is used to check that the recursive inclusion of templates does not go into circles: Simply it is used to NOT include a template record/file which has already BEEN included somewhere in the recursion.
753 * @param string $templateID The id of the current template. Same syntax as $idList ids, eg. "sys_123
754 * @param int $pid The PID of the input template record
755 * @param array $row A full TypoScript template record
756 * @return void
757 * @see processTemplate()
758 */
759 public function includeStaticTypoScriptSources($idList, $templateID, $pid, $row) {
760 // Static Template Records (static_template): include_static is a list of static templates to include
761 // Call function for link rendering:
762 if (is_array($GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['t3lib/class.t3lib_tstemplate.php']['includeStaticTypoScriptSources'])) {
763 $_params = array(
764 'idList' => &$idList,
765 'templateId' => &$templateID,
766 'pid' => &$pid,
767 'row' => &$row
768 );
769 foreach ($GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['t3lib/class.t3lib_tstemplate.php']['includeStaticTypoScriptSources'] as $_funcRef) {
770 GeneralUtility::callUserFunction($_funcRef, $_params, $this);
771 }
772 }
773 // If "Include before all static templates if root-flag is set" is set:
774 if ($row['static_file_mode'] == 3 && substr($templateID, 0, 4) == 'sys_' && $row['root']) {
775 $this->addExtensionStatics($idList, $templateID, $pid, $row);
776 }
777 // Static Template Files (Text files from extensions): include_static_file is a list of static files to include (from extensions)
778 if (trim($row['include_static_file'])) {
779 $include_static_fileArr = GeneralUtility::trimExplode(',', $row['include_static_file'], TRUE);
780 // Traversing list
781 foreach ($include_static_fileArr as $ISF_file) {
782 if (substr($ISF_file, 0, 4) == 'EXT:') {
783 list($ISF_extKey, $ISF_localPath) = explode('/', substr($ISF_file, 4), 2);
784 if ((string)$ISF_extKey !== '' && ExtensionManagementUtility::isLoaded($ISF_extKey) && (string)$ISF_localPath !== '') {
785 $ISF_localPath = rtrim($ISF_localPath, '/') . '/';
786 $ISF_filePath = ExtensionManagementUtility::extPath($ISF_extKey) . $ISF_localPath;
787 if (@is_dir($ISF_filePath)) {
788 $mExtKey = str_replace('_', '', $ISF_extKey . '/' . $ISF_localPath);
789 $subrow = array(
790 'constants' => $this->getTypoScriptSourceFileContent($ISF_filePath, 'constants'),
791 'config' => $this->getTypoScriptSourceFileContent($ISF_filePath, 'setup'),
792 'include_static' => @file_exists(($ISF_filePath . 'include_static.txt')) ? implode(',', array_unique(GeneralUtility::intExplode(',', GeneralUtility::getUrl($ISF_filePath . 'include_static.txt')))) : '',
793 'include_static_file' => @file_exists(($ISF_filePath . 'include_static_file.txt')) ? implode(',', array_unique(explode(',', GeneralUtility::getUrl($ISF_filePath . 'include_static_file.txt')))) : '',
794 'title' => $ISF_file,
795 'uid' => $mExtKey
796 );
797 $subrow = $this->prependStaticExtra($subrow);
798 $this->processTemplate($subrow, $idList . ',ext_' . $mExtKey, $pid, 'ext_' . $mExtKey, $templateID, $ISF_filePath);
799 }
800 }
801 }
802 }
803 }
804 // If "Default (include before if root flag is set)" is set OR
805 // "Always include before this template record" AND root-flag are set
806 if ($row['static_file_mode'] == 1 || $row['static_file_mode'] == 0 && substr($templateID, 0, 4) == 'sys_' && $row['root']) {
807 $this->addExtensionStatics($idList, $templateID, $pid, $row);
808 }
809 // Include Static Template Records after all other TypoScript has been included.
810 if (is_array($GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['t3lib/class.t3lib_tstemplate.php']['includeStaticTypoScriptSourcesAtEnd'])) {
811 $_params = array(
812 'idList' => &$idList,
813 'templateId' => &$templateID,
814 'pid' => &$pid,
815 'row' => &$row
816 );
817 foreach ($GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['t3lib/class.t3lib_tstemplate.php']['includeStaticTypoScriptSourcesAtEnd'] as $_funcRef) {
818 GeneralUtility::callUserFunction($_funcRef, $_params, $this);
819 }
820 }
821 }
822
823 /**
824 * Retrieves the content of the first existing file by extension order.
825 * Returns the empty string if no file is found.
826 *
827 * @param string $filePath The location of the file.
828 * @param string $baseName The base file name. "constants" or "setup".
829 * @return string
830 */
831 protected function getTypoScriptSourceFileContent($filePath, $baseName) {
832 $extensions = array('.ts', '.txt');
833 foreach ($extensions as $extension) {
834 $fileName = $filePath . $baseName . $extension;
835 if (@file_exists($fileName)) {
836 return GeneralUtility::getUrl($fileName);
837 }
838 }
839 return '';
840 }
841
842 /**
843 * Adds the default TypoScript files for extensions if any.
844 *
845 * @param string $idList A list of already processed template ids including the current; The list is on the form "[prefix]_[uid]" where [prefix] is "sys" for "sys_template" records, "static" for "static_template" records and "ext_" for static include files (from extensions). The list is used to check that the recursive inclusion of templates does not go into circles: Simply it is used to NOT include a template record/file which has already BEEN included somewhere in the recursion.
846 * @param string $templateID The id of the current template. Same syntax as $idList ids, eg. "sys_123
847 * @param int $pid The PID of the input template record
848 * @param array $row A full TypoScript template record
849 * @return void
850 * @access private
851 * @see includeStaticTypoScriptSources()
852 */
853 public function addExtensionStatics($idList, $templateID, $pid, $row) {
854 $this->extensionStaticsProcessed = TRUE;
855
856 // @todo Change to use new API
857 foreach ($GLOBALS['TYPO3_LOADED_EXT'] as $extKey => $files) {
858 if ((is_array($files) || $files instanceof \ArrayAccess) && ($files['ext_typoscript_constants.txt'] || $files['ext_typoscript_setup.txt'])) {
859 $mExtKey = str_replace('_', '', $extKey);
860 $subrow = array(
861 'constants' => $files['ext_typoscript_constants.txt'] ? GeneralUtility::getUrl($files['ext_typoscript_constants.txt']) : '',
862 'config' => $files['ext_typoscript_setup.txt'] ? GeneralUtility::getUrl($files['ext_typoscript_setup.txt']) : '',
863 'title' => $extKey,
864 'uid' => $mExtKey
865 );
866 $subrow = $this->prependStaticExtra($subrow);
867 $extPath = ExtensionManagementUtility::extPath($extKey);
868 $this->processTemplate($subrow, $idList . ',ext_' . $mExtKey, $pid, 'ext_' . $mExtKey, $templateID, $extPath);
869 }
870 }
871 }
872
873 /**
874 * Appends (not prepends) additional TypoScript code to static template records/files as set in TYPO3_CONF_VARS
875 * For DB records the "uid" value is the integer of the "static_template" record.
876 * For files the "uid" value is the extension key but with any underscores removed. Possibly with a path if its a static file selected in the template record
877 *
878 * @param array $subrow Static template record/file
879 * @return array Returns the input array where the values for keys "config" and "constants" may have been modified with prepended code.
880 * @access private
881 * @see addExtensionStatics(), includeStaticTypoScriptSources()
882 */
883 public function prependStaticExtra($subrow) {
884 // the identifier can be "43" if coming from "static template" extension or a path like "cssstyledcontent/static/"
885 $identifier = $subrow['uid'];
886 $subrow['config'] .= $GLOBALS['TYPO3_CONF_VARS']['FE']['defaultTypoScript_setup.'][$identifier];
887 $subrow['constants'] .= $GLOBALS['TYPO3_CONF_VARS']['FE']['defaultTypoScript_constants.'][$identifier];
888 // if this is a template of type "default content rendering", also see if other extensions have added their TypoScript that should be included after the content definitions
889 if (in_array($identifier, $GLOBALS['TYPO3_CONF_VARS']['FE']['contentRenderingTemplates'], TRUE)) {
890 $subrow['config'] .= $GLOBALS['TYPO3_CONF_VARS']['FE']['defaultTypoScript_setup.']['defaultContentRendering'];
891 $subrow['constants'] .= $GLOBALS['TYPO3_CONF_VARS']['FE']['defaultTypoScript_constants.']['defaultContentRendering'];
892 }
893 return $subrow;
894 }
895
896 /**
897 * Creating versioning overlay of a sys_template record.
898 * This will use either frontend or backend overlay functionality depending on environment.
899 *
900 * @param array $row Row to overlay (passed by reference)
901 * @return void
902 */
903 public function versionOL(&$row) {
904 // Distinguish frontend and backend call:
905 // To do the fronted call a full frontend is required, just checking for
906 // TYPO3_MODE === 'FE' is not enough. This could otherwise lead to fatals in
907 // eId scripts that run in frontend scope, but do not have a full blown frontend.
908 if (is_object($this->getTypoScriptFrontendController()) && property_exists($this->getTypoScriptFrontendController(), 'sys_page') && method_exists($this->getTypoScriptFrontendController()->sys_page, 'versionOL')) {
909 // Frontend
910 $this->getTypoScriptFrontendController()->sys_page->versionOL('sys_template', $row);
911 } else {
912 // Backend
913 BackendUtility::workspaceOL('sys_template', $row);
914 }
915 }
916
917 /*******************************************************************
918 *
919 * Parsing TypoScript code text from Template Records into PHP array
920 *
921 *******************************************************************/
922 /**
923 * Generates the configuration array by replacing constants and parsing the whole thing.
924 * Depends on $this->config and $this->constants to be set prior to this! (done by processTemplate/runThroughTemplates)
925 *
926 * @return void
927 * @see \TYPO3\CMS\Core\TypoScript\Parser\TypoScriptParser, start()
928 */
929 public function generateConfig() {
930 // Add default TS for all code types
931 $this->addDefaultTypoScript();
932
933 // Parse the TypoScript code text for include-instructions!
934 $this->processIncludes();
935 // These vars are also set lateron...
936 $this->setup['sitetitle'] = $this->sitetitle;
937 // ****************************
938 // Parse TypoScript Constants
939 // ****************************
940 // Initialize parser and match-condition classes:
941 /** @var $constants Parser\TypoScriptParser */
942 $constants = GeneralUtility::makeInstance(Parser\TypoScriptParser::class);
943 $constants->breakPointLN = (int)$this->ext_constants_BRP;
944 $constants->setup = $this->mergeConstantsFromPageTSconfig(array());
945 /** @var $matchObj ConditionMatcher */
946 $matchObj = GeneralUtility::makeInstance(ConditionMatcher::class);
947 $matchObj->setSimulateMatchConditions($this->matchAlternative);
948 $matchObj->setSimulateMatchResult((bool)$this->matchAll);
949 // Traverse constants text fields and parse them
950 foreach ($this->constants as $str) {
951 $constants->parse($str, $matchObj);
952 }
953 // Read out parse errors if any
954 $this->parserErrors['constants'] = $constants->errors;
955 // Then flatten the structure from a multi-dim array to a single dim array with all constants listed as key/value pairs (ready for substitution)
956 $this->flatSetup = array();
957 $this->flattenSetup($constants->setup, '', '');
958 // ***********************************************
959 // Parse TypoScript Setup (here called "config")
960 // ***********************************************
961 // Initialize parser and match-condition classes:
962 /** @var $config Parser\TypoScriptParser */
963 $config = GeneralUtility::makeInstance(Parser\TypoScriptParser::class);
964 $config->breakPointLN = (int)$this->ext_config_BRP;
965 $config->regLinenumbers = $this->ext_regLinenumbers;
966 $config->regComments = $this->ext_regComments;
967 $config->setup = $this->setup;
968 // Transfer information about conditions found in "Constants" and which of them returned TRUE.
969 $config->sections = $constants->sections;
970 $config->sectionsMatch = $constants->sectionsMatch;
971 // Traverse setup text fields and concatenate them into one, single string separated by a [GLOBAL] condition
972 $all = '';
973 foreach ($this->config as $str) {
974 $all .= '
975 [GLOBAL]
976 ' . $str;
977 }
978 // Substitute constants in the Setup code:
979 if ($this->tt_track) {
980 $this->getTimeTracker()->push('Substitute Constants (' . count($this->flatSetup) . ')');
981 }
982 $all = $this->substituteConstants($all);
983 if ($this->tt_track) {
984 $this->getTimeTracker()->pull();
985 }
986
987 // Searching for possible unsubstituted constants left (only for information)
988 if ($this->verbose) {
989 if (strstr($all, '{$')) {
990 $theConstList = array();
991 $findConst = explode('{$', $all);
992 array_shift($findConst);
993 foreach ($findConst as $constVal) {
994 $constLen = MathUtility::forceIntegerInRange(strcspn($constVal, '}'), 0, 50);
995 $theConstList[] = '{$' . substr($constVal, 0, ($constLen + 1));
996 }
997 if ($this->tt_track) {
998 $this->getTimeTracker()->setTSlogMessage(implode(', ', $theConstList) . ': Constants may remain un-substituted!!', 2);
999 }
1000 }
1001
1002 }
1003
1004 // Logging the textual size of the TypoScript Setup field text with all constants substituted:
1005 if ($this->tt_track) {
1006 $this->getTimeTracker()->setTSlogMessage('TypoScript template size as textfile: ' . strlen($all) . ' bytes');
1007 }
1008 // Finally parse the Setup field TypoScript code (where constants are now substituted)
1009 $config->parse($all, $matchObj);
1010 // Read out parse errors if any
1011 $this->parserErrors['config'] = $config->errors;
1012 // Transfer the TypoScript array from the parser object to the internal $this->setup array:
1013 $this->setup = $config->setup;
1014 if ($this->backend_info) {
1015 // Used for backend purposes only
1016 $this->setup_constants = $constants->setup;
1017 }
1018 // ****************************************************************
1019 // Final processing of the $this->setup TypoScript Template array
1020 // Basically: This is unsetting/setting of certain reserved keys.
1021 // ****************************************************************
1022 // These vars are allready set after 'processTemplate', but because $config->setup overrides them (in the line above!), we set them again. They are not changed compared to the value they had in the top of the page!
1023 unset($this->setup['sitetitle']);
1024 unset($this->setup['sitetitle.']);
1025 $this->setup['sitetitle'] = $this->sitetitle;
1026 // Unsetting some vars...
1027 unset($this->setup['types.']);
1028 unset($this->setup['types']);
1029 if (is_array($this->setup)) {
1030 foreach ($this->setup as $key => $value) {
1031 if ($value == 'PAGE') {
1032 // Set the typeNum of the current page object:
1033 if (isset($this->setup[$key . '.']['typeNum'])) {
1034 $typeNum = $this->setup[$key . '.']['typeNum'];
1035 $this->setup['types.'][$typeNum] = $key;
1036 } elseif (!isset($this->setup['types.'][0]) || !$this->setup['types.'][0]) {
1037 $this->setup['types.'][0] = $key;
1038 }
1039 }
1040 }
1041 }
1042 unset($this->setup['temp.']);
1043 unset($constants);
1044 // Storing the conditions found/matched information:
1045 $this->sections = $config->sections;
1046 $this->sectionsMatch = $config->sectionsMatch;
1047 }
1048
1049 /**
1050 * Searching TypoScript code text (for constants and config (Setup))
1051 * for include instructions and does the inclusion of external TypoScript files
1052 * if needed.
1053 *
1054 * @return void
1055 * @see \TYPO3\CMS\Core\TypoScript\Parser\TypoScriptParser, generateConfig()
1056 */
1057 public function processIncludes() {
1058 if ($this->processIncludesHasBeenRun) {
1059 return;
1060 }
1061
1062 $paths = $this->templateIncludePaths;
1063 $files = array();
1064 foreach ($this->constants as &$value) {
1065 $includeData = Parser\TypoScriptParser::checkIncludeLines($value, 1, TRUE, array_shift($paths));
1066 $files = array_merge($files, $includeData['files']);
1067 $value = $includeData['typoscript'];
1068 }
1069 unset($value);
1070 $paths = $this->templateIncludePaths;
1071 foreach ($this->config as &$value) {
1072 $includeData = Parser\TypoScriptParser::checkIncludeLines($value, 1, TRUE, array_shift($paths));
1073 $files = array_merge($files, $includeData['files']);
1074 $value = $includeData['typoscript'];
1075 }
1076 unset($value);
1077
1078 if (!empty($files)) {
1079 $files = array_unique($files);
1080 foreach ($files as $file) {
1081 $this->rowSum[] = array($file, filemtime($file));
1082 }
1083 }
1084
1085 $this->processIncludesHasBeenRun = TRUE;
1086 }
1087
1088 /**
1089 * Loads Page TSconfig until the outermost template record and parses the configuration - if TSFE.constants object path is found it is merged with the default data in here!
1090 *
1091 * @param array $constArray Constants array, default input.
1092 * @return array Constants array, modified
1093 * @todo Apply caching to the parsed Page TSconfig. This is done in the other similar functions for both frontend and backend. However, since this functions works for BOTH frontend and backend we will have to either write our own local caching function or (more likely) detect if we are in FE or BE and use caching functions accordingly. Not having caching affects mostly the backend modules inside the "Template" module since the overhead in the frontend is only seen when TypoScript templates are parsed anyways (after which point they are cached anyways...)
1094 */
1095 public function mergeConstantsFromPageTSconfig($constArray) {
1096 $TSdataArray = array();
1097 // Setting default configuration:
1098 $TSdataArray[] = $GLOBALS['TYPO3_CONF_VARS']['BE']['defaultPageTSconfig'];
1099 for ($a = 0; $a <= $this->outermostRootlineIndexWithTemplate; $a++) {
1100 $TSdataArray[] = $this->absoluteRootLine[$a]['TSconfig'];
1101 }
1102 // Parsing the user TS (or getting from cache)
1103 $TSdataArray = Parser\TypoScriptParser::checkIncludeLines_array($TSdataArray);
1104 $userTS = implode(LF . '[GLOBAL]' . LF, $TSdataArray);
1105 /** @var $parseObj Parser\TypoScriptParser */
1106 $parseObj = GeneralUtility::makeInstance(Parser\TypoScriptParser::class);
1107 $parseObj->parse($userTS);
1108 if (is_array($parseObj->setup['TSFE.']['constants.'])) {
1109 ArrayUtility::mergeRecursiveWithOverrule($constArray, $parseObj->setup['TSFE.']['constants.']);
1110 }
1111 return $constArray;
1112 }
1113
1114 /**
1115 * This flattens a hierarchical TypoScript array to $this->flatSetup
1116 *
1117 * @param array $setupArray TypoScript array
1118 * @param string $prefix Prefix to the object path. Used for recursive calls to this function.
1119 * @return void
1120 * @see generateConfig()
1121 */
1122 public function flattenSetup($setupArray, $prefix) {
1123 if (is_array($setupArray)) {
1124 foreach ($setupArray as $key => $val) {
1125 if ($prefix || !StringUtility::beginsWith($key, 'TSConstantEditor')) {
1126 // We don't want 'TSConstantEditor' in the flattend setup on the first level (190201)
1127 if (is_array($val)) {
1128 $this->flattenSetup($val, $prefix . $key);
1129 } else {
1130 $this->flatSetup[$prefix . $key] = $val;
1131 }
1132 }
1133 }
1134 }
1135 }
1136
1137 /**
1138 * Substitutes the constants from $this->flatSetup in the text string $all
1139 *
1140 * @param string $all TypoScript code text string
1141 * @return string The processed string with all constants found in $this->flatSetup as key/value pairs substituted.
1142 * @see generateConfig(), flattenSetup()
1143 */
1144 public function substituteConstants($all) {
1145 if ($this->tt_track) {
1146 $this->getTimeTracker()->setTSlogMessage('Constants to substitute: ' . count($this->flatSetup));
1147 }
1148 $noChange = FALSE;
1149 // Recursive substitution of constants (up to 10 nested levels)
1150 for ($i = 0; $i < 10 && !$noChange; $i++) {
1151 $old_all = $all;
1152 $all = preg_replace_callback('/\\{\\$(.[^}]*)\\}/', array($this, 'substituteConstantsCallBack'), $all);
1153 if ($old_all == $all) {
1154 $noChange = TRUE;
1155 }
1156 }
1157 return $all;
1158 }
1159
1160 /**
1161 * Call back method for preg_replace_callback in substituteConstants
1162 *
1163 * @param array $matches Regular expression matches
1164 * @return string Replacement
1165 * @see substituteConstants()
1166 */
1167 public function substituteConstantsCallBack($matches) {
1168 // Replace {$CONST} if found in $this->flatSetup, else leave unchanged
1169 return isset($this->flatSetup[$matches[1]]) && !is_array($this->flatSetup[$matches[1]]) ? $this->flatSetup[$matches[1]] : $matches[0];
1170 }
1171
1172 /*******************************************************************
1173 *
1174 * Various API functions, used from elsewhere in the frontend classes
1175 *
1176 *******************************************************************/
1177 /**
1178 * Implementation of the "optionSplit" feature in TypoScript (used eg. for MENU objects)
1179 * What it does is to split the incoming TypoScript array so that the values are exploded by certain strings ("||" and "|*|") and each part distributed into individual TypoScript arrays with a similar structure, but individualized values.
1180 * The concept is known as "optionSplit" and is rather advanced to handle but quite powerful, in particular for creating menus in TYPO3.
1181 *
1182 * @param array $conf A TypoScript array
1183 * @param int $splitCount The number of items for which to generated individual TypoScript arrays
1184 * @return array The individualized TypoScript array.
1185 * @see \TYPO3\CMS\Frontend\ContentObject\ContentObjectRenderer::IMGTEXT(), \TYPO3\CMS\Frontend\ContentObject\Menu\AbstractMenuContentObject::procesItemStates()
1186 */
1187 public function splitConfArray($conf, $splitCount) {
1188 // Initialize variables:
1189 $splitCount = (int)$splitCount;
1190 $conf2 = array();
1191 if ($splitCount && is_array($conf)) {
1192 // Initialize output to carry at least the keys:
1193 for ($aKey = 0; $aKey < $splitCount; $aKey++) {
1194 $conf2[$aKey] = array();
1195 }
1196 // Recursive processing of array keys:
1197 foreach ($conf as $cKey => $val) {
1198 if (is_array($val)) {
1199 $tempConf = $this->splitConfArray($val, $splitCount);
1200 foreach ($tempConf as $aKey => $val2) {
1201 $conf2[$aKey][$cKey] = $val2;
1202 }
1203 } else {
1204 // Splitting of all values on this level of the TypoScript object tree:
1205 if ($cKey === 'noTrimWrap' || (!strstr($val, '|*|') && !strstr($val, '||'))) {
1206 for ($aKey = 0; $aKey < $splitCount; $aKey++) {
1207 $conf2[$aKey][$cKey] = $val;
1208 }
1209 } else {
1210 $main = explode('|*|', $val);
1211 $lastC = 0;
1212 $middleC = 0;
1213 $firstC = 0;
1214 if ($main[0]) {
1215 $first = explode('||', $main[0]);
1216 $firstC = count($first);
1217 }
1218 $middle = array();
1219 if ($main[1]) {
1220 $middle = explode('||', $main[1]);
1221 $middleC = count($middle);
1222 }
1223 $last = array();
1224 $value = '';
1225 if ($main[2]) {
1226 $last = explode('||', $main[2]);
1227 $lastC = count($last);
1228 $value = $last[0];
1229 }
1230 for ($aKey = 0; $aKey < $splitCount; $aKey++) {
1231 if ($firstC && isset($first[$aKey])) {
1232 $value = $first[$aKey];
1233 } elseif ($middleC) {
1234 $value = $middle[($aKey - $firstC) % $middleC];
1235 }
1236 if ($lastC && $lastC >= $splitCount - $aKey) {
1237 $value = $last[$lastC - ($splitCount - $aKey)];
1238 }
1239 $conf2[$aKey][$cKey] = trim($value);
1240 }
1241 }
1242 }
1243 }
1244 }
1245 return $conf2;
1246 }
1247
1248 /**
1249 * Returns the reference used for the frontend inclusion, checks against allowed paths for inclusion.
1250 *
1251 * @param string $fileFromSetup TypoScript "resource" data type value.
1252 * @return string|NULL Resulting filename, is either a full absolute URL or a relative path. Returns NULL if invalid filename or a directory is given
1253 */
1254 public function getFileName($fileFromSetup) {
1255 $file = trim($fileFromSetup);
1256 if (!$file) {
1257 return NULL;
1258 } elseif (strpos($file, '../') !== FALSE) {
1259 if ($this->tt_track) {
1260 $this->getTimeTracker()->setTSlogMessage('File path "' . $file . '" contained illegal string "../"!', 3);
1261 }
1262 return NULL;
1263 }
1264 // Cache
1265 $hash = md5($file);
1266 if (isset($this->fileCache[$hash])) {
1267 return $this->fileCache[$hash];
1268 }
1269
1270 // if this is an URL, it can be returned directly
1271 $urlScheme = parse_url($file, PHP_URL_SCHEME);
1272 if ($urlScheme === 'https' || $urlScheme === 'http' || is_file(PATH_site . $file)) {
1273 return $file;
1274 }
1275
1276 // this call also resolves EXT:myext/ files
1277 $file = GeneralUtility::getFileAbsFileName($file);
1278 if (!$file) {
1279 if ($this->tt_track) {
1280 $this->getTimeTracker()->setTSlogMessage('File "' . $fileFromSetup . '" was not found!', 3);
1281 }
1282 return NULL;
1283 }
1284
1285 $file = PathUtility::stripPathSitePrefix($file);
1286
1287 // Check if the found file is in the allowed paths
1288 foreach ($this->allowedPaths as $val) {
1289 if (GeneralUtility::isFirstPartOfStr($file, $val)) {
1290 $this->fileCache[$hash] = $file;
1291 return $file;
1292 }
1293 }
1294
1295 if ($this->tt_track) {
1296 $this->getTimeTracker()->setTSlogMessage('"' . $file . '" was not located in the allowed paths: (' . implode(',', $this->allowedPaths) . ')', 3);
1297 }
1298 return NULL;
1299 }
1300
1301 /**
1302 * Compiles the content for the page <title> tag.
1303 *
1304 * @param string $pageTitle The input title string, typically the "title" field of a page's record.
1305 * @param bool $noTitle If set, then only the site title is outputted (from $this->setup['sitetitle'])
1306 * @param bool $showTitleFirst If set, then "sitetitle" and $title is swapped
1307 * @param string $pageTitleSeparator an alternative to the ": " as the separator between site title and page title
1308 * @return string The page title on the form "[sitetitle]: [input-title]". Not htmlspecialchar()'ed.
1309 * @see \TYPO3\CMS\Frontend\Controller\TypoScriptFrontendController::tempPageCacheContent(), \TYPO3\CMS\Frontend\Page\PageGenerator::renderContentWithHeader()
1310 */
1311 public function printTitle($pageTitle, $noTitle = FALSE, $showTitleFirst = FALSE, $pageTitleSeparator = '') {
1312 $siteTitle = trim($this->setup['sitetitle']);
1313 $pageTitle = $noTitle ? '' : $pageTitle;
1314 if ($showTitleFirst) {
1315 $temp = $siteTitle;
1316 $siteTitle = $pageTitle;
1317 $pageTitle = $temp;
1318 }
1319 // only show a separator if there are both site title and page title
1320 if ($pageTitle === '' || $siteTitle === '') {
1321 $pageTitleSeparator = '';
1322 // use the default separator if non given
1323 } elseif (empty($pageTitleSeparator)) {
1324 $pageTitleSeparator = ': ';
1325 }
1326 return $siteTitle . $pageTitleSeparator . $pageTitle;
1327 }
1328
1329 /**
1330 * Reads the fileContent of $fileName and returns it.
1331 * Similar to GeneralUtility::getUrl() but with an additional check if the path is allowed
1332 *
1333 * @param string $fileName Absolute filepath to record
1334 * @return NULL|string The content returned
1335 * @see \TYPO3\CMS\Frontend\ContentObject\ContentObjectRenderer::fileResource(), \TYPO3\CMS\Frontend\ContentObject\ContentObjectRenderer::MULTIMEDIA(), GeneralUtility::getUrl()
1336 */
1337 public function fileContent($fileName) {
1338 $fileName = $this->getFileName($fileName);
1339 if ($fileName) {
1340 return GeneralUtility::getUrl($fileName);
1341 }
1342 return NULL;
1343 }
1344
1345 /**
1346 * Ordinary "wrapping" function. Used in the AbstractMenuContentObject class and extension classes instead of the similar function in ContentObjectRenderer
1347 *
1348 * @param string $content The content to wrap
1349 * @param string $wrap The wrap value, eg. "<strong> | </strong>
1350 * @return string Wrapped input string
1351 * @deprecated since TYPO3 CMS 7, will be removed in TYPO3 CMS 8, use \TYPO3\CMS\Frontend\ContentObject\ContentObjectRenderer::wrap() instead
1352 * @see \TYPO3\CMS\Frontend\ContentObject\Menu\AbstractMenuContentObject, \TYPO3\CMS\Frontend\ContentObject\ContentObjectRenderer::wrap()
1353 */
1354 public function wrap($content, $wrap) {
1355 GeneralUtility::logDeprecatedFunction();
1356 if ($wrap) {
1357 $wrapArr = explode('|', $wrap);
1358 return trim($wrapArr[0]) . $content . trim($wrapArr[1]);
1359 } else {
1360 return $content;
1361 }
1362 }
1363
1364 /**
1365 * Removes the "?" of input string IF the "?" is the last character.
1366 *
1367 * @param string $url Input string
1368 * @return string Output string, free of "?" in the end, if any such character.
1369 * @see linkData(), \TYPO3\CMS\Frontend\Page\FramesetRenderer::frameParams()
1370 */
1371 public function removeQueryString($url) {
1372 if (substr($url, -1) == '?') {
1373 return substr($url, 0, -1);
1374 } else {
1375 return $url;
1376 }
1377 }
1378
1379 /**
1380 * Takes a TypoScript array as input and returns an array which contains all integer properties found which had a value (not only properties). The output array will be sorted numerically.
1381 * Call it like \TYPO3\CMS\Core\TypoScript\TemplateService::sortedKeyList()
1382 *
1383 * @param array $setupArr TypoScript array with numerical array in
1384 * @param bool $acceptOnlyProperties If set, then a value is not required - the properties alone will be enough.
1385 * @return array An array with all integer properties listed in numeric order.
1386 * @see \TYPO3\CMS\Frontend\ContentObject\ContentObjectRenderer::cObjGet(), \TYPO3\CMS\Frontend\Imaging\GifBuilder, \TYPO3\CMS\Frontend\ContentObject\Menu\ImageMenuContentObject::makeImageMap()
1387 */
1388 static public function sortedKeyList($setupArr, $acceptOnlyProperties = FALSE) {
1389 $keyArr = array();
1390 $setupArrKeys = array_keys($setupArr);
1391 foreach ($setupArrKeys as $key) {
1392 if ($acceptOnlyProperties || MathUtility::canBeInterpretedAsInteger($key)) {
1393 $keyArr[] = (int)$key;
1394 }
1395 }
1396 $keyArr = array_unique($keyArr);
1397 sort($keyArr);
1398 return $keyArr;
1399 }
1400
1401 /**
1402 * Returns the level of the given page in the rootline - Multiple pages can be given by separating the UIDs by comma.
1403 *
1404 * @param string $list A list of UIDs for which the rootline-level should get returned
1405 * @return int The level in the rootline. If more than one page was given the lowest level will get returned.
1406 */
1407 public function getRootlineLevel($list) {
1408 $idx = 0;
1409 foreach ($this->rootLine as $page) {
1410 if (GeneralUtility::inList($list, $page['uid'])) {
1411 return $idx;
1412 }
1413 $idx++;
1414 }
1415 return FALSE;
1416 }
1417
1418 /*******************************************************************
1419 *
1420 * Functions for creating links
1421 *
1422 *******************************************************************/
1423 /**
1424 * The mother of all functions creating links/URLs etc in a TypoScript environment.
1425 * See the references below.
1426 * Basically this function takes care of issues such as type,id,alias and Mount Points, URL rewriting (through hooks), M5/B6 encoded parameters etc.
1427 * It is important to pass all links created through this function since this is the guarantee that globally configured settings for link creating are observed and that your applications will conform to the various/many configuration options in TypoScript Templates regarding this.
1428 *
1429 * @param array $page The page record of the page to which we are creating a link. Needed due to fields like uid, alias, target, no_cache, title and sectionIndex_uid.
1430 * @param string $oTarget Default target string to use IF not $page['target'] is set.
1431 * @param bool $no_cache If set, then the "&no_cache=1" parameter is included in the URL.
1432 * @param string $script Alternative script name if you don't want to use $this->getTypoScriptFrontendController()->config['mainScript'] (normally set to "index.php")
1433 * @param array $overrideArray Array with overriding values for the $page array.
1434 * @param string $addParams Additional URL parameters to set in the URL. Syntax is "&foo=bar&foo2=bar2" etc. Also used internally to add parameters if needed.
1435 * @param string $typeOverride If you set this value to something else than a blank string, then the typeNumber used in the link will be forced to this value. Normally the typeNum is based on the target set OR on $this->getTypoScriptFrontendController()->config['config']['forceTypeValue'] if found.
1436 * @param string $targetDomain The target Doamin, if any was detected in typolink
1437 * @return array Contains keys like "totalURL", "url", "sectionIndex", "linkVars", "no_cache", "type", "target" of which "totalURL" is normally the value you would use while the other keys contains various parts that was used to construct "totalURL
1438 * @see \TYPO3\CMS\Frontend\Page\FramesetRenderer::frameParams(), \TYPO3\CMS\Frontend\ContentObject\ContentObjectRenderer::typoLink(), \TYPO3\CMS\Frontend\Page\PageGenerator::pagegenInit(), \TYPO3\CMS\Frontend\ContentObject\Menu\AbstractMenuContentObject::link()
1439 */
1440 public function linkData($page, $oTarget, $no_cache, $script, $overrideArray = NULL, $addParams = '', $typeOverride = '', $targetDomain = '') {
1441 $LD = array();
1442 // Overriding some fields in the page record and still preserves the values by adding them as parameters. Little strange function.
1443 if (is_array($overrideArray)) {
1444 foreach ($overrideArray as $theKey => $theNewVal) {
1445 $addParams .= '&real_' . $theKey . '=' . rawurlencode($page[$theKey]);
1446 $page[$theKey] = $theNewVal;
1447 }
1448 }
1449 // Adding Mount Points, "&MP=", parameter for the current page if any is set:
1450 if (!strstr($addParams, '&MP=')) {
1451 // Looking for hardcoded defaults:
1452 if (trim($this->getTypoScriptFrontendController()->MP_defaults[$page['uid']])) {
1453 $addParams .= '&MP=' . rawurlencode(trim($this->getTypoScriptFrontendController()->MP_defaults[$page['uid']]));
1454 } elseif ($this->getTypoScriptFrontendController()->config['config']['MP_mapRootPoints']) {
1455 // Else look in automatically created map:
1456 $m = $this->getFromMPmap($page['uid']);
1457 if ($m) {
1458 $addParams .= '&MP=' . rawurlencode($m);
1459 }
1460 }
1461 }
1462 // Setting ID/alias:
1463 if (!$script) {
1464 $script = $this->getTypoScriptFrontendController()->config['mainScript'];
1465 }
1466 if ($page['alias']) {
1467 $LD['url'] = $script . '?id=' . rawurlencode($page['alias']);
1468 } else {
1469 $LD['url'] = $script . '?id=' . $page['uid'];
1470 }
1471 // Setting target
1472 $LD['target'] = trim($page['target']) ?: $oTarget;
1473 // typeNum
1474 $typeNum = $this->setup[$LD['target'] . '.']['typeNum'];
1475 if (!MathUtility::canBeInterpretedAsInteger($typeOverride) && (int)$this->getTypoScriptFrontendController()->config['config']['forceTypeValue']) {
1476 $typeOverride = (int)$this->getTypoScriptFrontendController()->config['config']['forceTypeValue'];
1477 }
1478 if ((string)$typeOverride !== '') {
1479 $typeNum = $typeOverride;
1480 }
1481 // Override...
1482 if ($typeNum) {
1483 $LD['type'] = '&type=' . (int)$typeNum;
1484 } else {
1485 $LD['type'] = '';
1486 }
1487 // Preserving the type number.
1488 $LD['orig_type'] = $LD['type'];
1489 // noCache
1490 $LD['no_cache'] = trim($page['no_cache']) || $no_cache ? '&no_cache=1' : '';
1491 // linkVars
1492 if ($addParams) {
1493 $LD['linkVars'] = GeneralUtility::implodeArrayForUrl('', GeneralUtility::explodeUrl2Array($this->getTypoScriptFrontendController()->linkVars . $addParams), '', FALSE, TRUE);
1494 } else {
1495 $LD['linkVars'] = $this->getTypoScriptFrontendController()->linkVars;
1496 }
1497 // Add absRefPrefix if exists.
1498 $LD['url'] = $this->getTypoScriptFrontendController()->absRefPrefix . $LD['url'];
1499 // If the special key 'sectionIndex_uid' (added 'manually' in tslib/menu.php to the page-record) is set, then the link jumps directly to a section on the page.
1500 $LD['sectionIndex'] = $page['sectionIndex_uid'] ? '#c' . $page['sectionIndex_uid'] : '';
1501 // Compile the normal total url
1502 $LD['totalURL'] = $this->removeQueryString(($LD['url'] . $LD['type'] . $LD['no_cache'] . $LD['linkVars'] . $this->getTypoScriptFrontendController()->getMethodUrlIdToken)) . $LD['sectionIndex'];
1503 // Call post processing function for link rendering:
1504 if (is_array($GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['t3lib/class.t3lib_tstemplate.php']['linkData-PostProc'])) {
1505 $_params = array(
1506 'LD' => &$LD,
1507 'args' => array('page' => $page, 'oTarget' => $oTarget, 'no_cache' => $no_cache, 'script' => $script, 'overrideArray' => $overrideArray, 'addParams' => $addParams, 'typeOverride' => $typeOverride, 'targetDomain' => $targetDomain),
1508 'typeNum' => $typeNum
1509 );
1510 foreach ($GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['t3lib/class.t3lib_tstemplate.php']['linkData-PostProc'] as $_funcRef) {
1511 GeneralUtility::callUserFunction($_funcRef, $_params, $this);
1512 }
1513 }
1514 // Return the LD-array
1515 return $LD;
1516 }
1517
1518 /**
1519 * Initializes the automatically created MPmap coming from the "config.MP_mapRootPoints" setting
1520 * Can be called many times with overhead only the first time since then the map is generated and cached in memory.
1521 *
1522 * @param int $pageId Page id to return MPvar value for.
1523 * @return string
1524 * @see initMPmap_create()
1525 * @todo Implement some caching of the result between hits. (more than just the memory caching used here)
1526 */
1527 public function getFromMPmap($pageId = 0) {
1528 // Create map if not found already:
1529 if (!is_array($this->MPmap)) {
1530 $this->MPmap = array();
1531 $rootPoints = GeneralUtility::trimExplode(',', strtolower($this->getTypoScriptFrontendController()->config['config']['MP_mapRootPoints']), TRUE);
1532 // Traverse rootpoints:
1533 foreach ($rootPoints as $p) {
1534 $initMParray = array();
1535 if ($p == 'root') {
1536 $p = $this->rootLine[0]['uid'];
1537 if ($this->rootLine[0]['_MOUNT_OL'] && $this->rootLine[0]['_MP_PARAM']) {
1538 $initMParray[] = $this->rootLine[0]['_MP_PARAM'];
1539 }
1540 }
1541 $this->initMPmap_create($p, $initMParray);
1542 }
1543 }
1544 // Finding MP var for Page ID:
1545 if ($pageId) {
1546 if (is_array($this->MPmap[$pageId]) && !empty($this->MPmap[$pageId])) {
1547 return implode(',', $this->MPmap[$pageId]);
1548 }
1549 }
1550 return '';
1551 }
1552
1553 /**
1554 * Creating MPmap for a certain ID root point.
1555 *
1556 * @param int $id Root id from which to start map creation.
1557 * @param array $MP_array MP_array passed from root page.
1558 * @param int $level Recursion brake. Incremented for each recursive call. 20 is the limit.
1559 * @return void
1560 * @see getFromMPvar()
1561 */
1562 public function initMPmap_create($id, $MP_array = array(), $level = 0) {
1563 $id = (int)$id;
1564 if ($id <= 0) {
1565 return;
1566 }
1567 // First level, check id
1568 if (!$level) {
1569 // Find mount point if any:
1570 $mount_info = $this->getTypoScriptFrontendController()->sys_page->getMountPointInfo($id);
1571 // Overlay mode:
1572 if (is_array($mount_info) && $mount_info['overlay']) {
1573 $MP_array[] = $mount_info['MPvar'];
1574 $id = $mount_info['mount_pid'];
1575 }
1576 // Set mapping information for this level:
1577 $this->MPmap[$id] = $MP_array;
1578 // Normal mode:
1579 if (is_array($mount_info) && !$mount_info['overlay']) {
1580 $MP_array[] = $mount_info['MPvar'];
1581 $id = $mount_info['mount_pid'];
1582 }
1583 }
1584 if ($id && $level < 20) {
1585 $nextLevelAcc = array();
1586 // Select and traverse current level pages:
1587 $res = $this->getDatabaseConnection()->exec_SELECTquery('uid,pid,doktype,mount_pid,mount_pid_ol', 'pages', 'pid=' . (int)$id . ' AND deleted=0 AND doktype<>' . PageRepository::DOKTYPE_RECYCLER . ' AND doktype<>' . PageRepository::DOKTYPE_BE_USER_SECTION);
1588 while ($row = $this->getDatabaseConnection()->sql_fetch_assoc($res)) {
1589 // Find mount point if any:
1590 $next_id = $row['uid'];
1591 $next_MP_array = $MP_array;
1592 $mount_info = $this->getTypoScriptFrontendController()->sys_page->getMountPointInfo($next_id, $row);
1593 // Overlay mode:
1594 if (is_array($mount_info) && $mount_info['overlay']) {
1595 $next_MP_array[] = $mount_info['MPvar'];
1596 $next_id = $mount_info['mount_pid'];
1597 }
1598 if (!isset($this->MPmap[$next_id])) {
1599 // Set mapping information for this level:
1600 $this->MPmap[$next_id] = $next_MP_array;
1601 // Normal mode:
1602 if (is_array($mount_info) && !$mount_info['overlay']) {
1603 $next_MP_array[] = $mount_info['MPvar'];
1604 $next_id = $mount_info['mount_pid'];
1605 }
1606 // Register recursive call
1607 // (have to do it this way since ALL of the current level should be registered BEFORE the sublevel at any time)
1608 $nextLevelAcc[] = array($next_id, $next_MP_array);
1609 }
1610 }
1611 $this->getDatabaseConnection()->sql_free_result($res);
1612 // Call recursively, if any:
1613 foreach ($nextLevelAcc as $pSet) {
1614 $this->initMPmap_create($pSet[0], $pSet[1], $level + 1);
1615 }
1616 }
1617 }
1618
1619 /**
1620 * Adds the TypoScript from the global array.
1621 * The class property isDefaultTypoScriptAdded ensures
1622 * that the adding only happens once.
1623 *
1624 * @return void
1625 * @see isDefaultTypoScriptAdded
1626 */
1627 protected function addDefaultTypoScript() {
1628 // Add default TS for all code types, if not done already
1629 if (!$this->isDefaultTypoScriptAdded) {
1630 // adding default setup and constants
1631 // defaultTypoScript_setup is *very* unlikely to be empty
1632 // the count of elements in ->constants, ->config and ->templateIncludePaths have to be in sync
1633 array_unshift($this->constants, (string)$GLOBALS['TYPO3_CONF_VARS']['FE']['defaultTypoScript_constants']);
1634 array_unshift($this->config, (string)$GLOBALS['TYPO3_CONF_VARS']['FE']['defaultTypoScript_setup']);
1635 array_unshift($this->templateIncludePaths, '');
1636 // prepare a proper entry to hierachyInfo (used by TemplateAnalyzer in BE)
1637 $rootTemplateId = $this->hierarchyInfo[count($this->hierarchyInfo)-1]['templateID'];
1638 $defaultTemplateInfo = array(
1639 'root' => '',
1640 'next' => '',
1641 'clConst' => '',
1642 'clConf' => '',
1643 'templateID' => '_defaultTypoScript_',
1644 'templateParent' => $rootTemplateId,
1645 'title' => 'SYS:TYPO3_CONF_VARS:FE:defaultTypoScript',
1646 'uid' => '_defaultTypoScript_',
1647 'pid' => '',
1648 'configLines' => substr_count((string)$GLOBALS['TYPO3_CONF_VARS']['FE']['defaultTypoScript_setup'], LF) + 1
1649 );
1650 // push info to information arrays used in BE by TemplateTools (Analyzer)
1651 array_unshift($this->clearList_const, $defaultTemplateInfo['uid']);
1652 array_unshift($this->clearList_setup, $defaultTemplateInfo['uid']);
1653 array_unshift($this->hierarchyInfo, $defaultTemplateInfo);
1654 $this->isDefaultTypoScriptAdded = TRUE;
1655 }
1656 }
1657
1658 /**
1659 * @return DatabaseConnection
1660 */
1661 protected function getDatabaseConnection() {
1662 return $GLOBALS['TYPO3_DB'];
1663 }
1664
1665 /**
1666 * @return TypoScriptFrontendController
1667 */
1668 protected function getTypoScriptFrontendController() {
1669 return $GLOBALS['TSFE'];
1670 }
1671
1672 /**
1673 * @return TimeTracker
1674 */
1675 protected function getTimeTracker() {
1676 return $GLOBALS['TT'];
1677 }
1678
1679 }