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