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