Documentation TYPO3 par Ameos |
00001 <?php 00002 /*************************************************************** 00003 * Copyright notice 00004 * 00005 * (c) 1999-2005 Kasper Skaarhoj (kasperYYYY@typo3.com) 00006 * All rights reserved 00007 * 00008 * This script is part of the TYPO3 project. The TYPO3 project is 00009 * free software; you can redistribute it and/or modify 00010 * it under the terms of the GNU General Public License as published by 00011 * the Free Software Foundation; either version 2 of the License, or 00012 * (at your option) any later version. 00013 * 00014 * The GNU General Public License can be found at 00015 * http://www.gnu.org/copyleft/gpl.html. 00016 * A copy is found in the textfile GPL.txt and important notices to the license 00017 * from the author is found in LICENSE.txt distributed with these scripts. 00018 * 00019 * 00020 * This script is distributed in the hope that it will be useful, 00021 * but WITHOUT ANY WARRANTY; without even the implied warranty of 00022 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00023 * GNU General Public License for more details. 00024 * 00025 * This copyright notice MUST APPEAR in all copies of the script! 00026 ***************************************************************/ 00081 require_once (PATH_t3lib.'class.t3lib_tsparser.php'); 00082 require_once (PATH_t3lib.'class.t3lib_matchcondition.php'); 00083 00084 00085 00086 00087 00088 00089 00090 00091 00092 00093 00094 00095 00096 00097 00098 00107 class t3lib_TStemplate { 00108 00109 // Debugging, analysis: 00110 var $tt_track = 1; // If set, the global tt-timeobject is used to log the performance. 00111 var $forceTemplateParsing=0; // If set, the template is always rendered. Used from Admin Panel. 00112 00113 // Backend Analysis modules settings: 00114 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! 00115 var $matchAll=0; // If set, the match-class matches everything! Used for backend modules only. Never frontend! 00116 var $parseEditorCfgField=0; // If set, the Backend Editor Configuration TypoScript is also parsed (this is not needed for the frontend) 00117 var $backend_info = 0; 00118 var $getFileName_backPath=''; // Set from the backend - used to set an absolute path (PATH_site) so that relative resources are properly found with getFileName() 00119 00120 // Externally set breakpoints (used by Backend Modules) 00121 var $ext_constants_BRP=0; 00122 var $ext_config_BRP=0; 00123 var $ext_editorcfg_BRP=0; 00124 var $ext_regLinenumbers=FALSE; 00125 00126 // Constants: 00127 var $uplPath = 'uploads/tf/'; 00128 var $tempPath = 'typo3temp/'; 00129 var $menuclasses = 'gmenu,tmenu,imgmenu,jsmenu'; 00130 00131 // Set Internally: 00132 var $whereClause = ''; // This MUST be initialized by the init() function 00133 var $debug = 0; 00134 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. 00135 var $currentPageData = ''; // Contains "currentPageData" when rendered/fetched from cache. See getCurrentPageData() 00136 var $simulationHiddenOrTime=0; // See init(); Set if preview of some kind is enabled. 00137 00138 var $loaded = 0; // Set, if the TypoScript template structure is loaded and OK, see ->start() 00139 var $setup = Array( // Default TypoScript Setup code 00140 'styles.' => Array ( 00141 'insertContent' => 'CONTENT', 00142 'insertContent.' => Array ( 00143 'table' => 'tt_content', 00144 'select.' => Array ( 00145 'orderBy' => 'sorting', 00146 'where' => 'colPos=0', 00147 'languageField' => 'sys_language_uid' 00148 ) 00149 ) 00150 ), 00151 'config.' => Array ( 00152 'extTarget' => '_top', 00153 'stat' => 1, 00154 'stat_typeNumList' => '0,1' 00155 ) 00156 ); 00157 var $flatSetup = Array ( 00158 ); 00159 var $const = Array ( // Default TypoScript Constants code: 00160 '_clear' => '<img src="clear.gif" width="1" height="1" alt="" />', 00161 '_blackBorderWrap' => '<table border="0" bgcolor="black" cellspacing="0" cellpadding="1"><tr><td> | </td></tr></table>', 00162 '_tableWrap' => '<table border="0" cellspacing="0" cellpadding="0"> | </table>', 00163 '_tableWrap_DEBUG' => '<table border="1" cellspacing="0" cellpadding="0"> | </table>', 00164 '_stdFrameParams' => 'frameborder="no" marginheight="0" marginwidth="0" noresize="noresize"', 00165 '_stdFramesetParams' => 'border="0" framespacing="0" frameborder="no"' 00166 ); 00167 00168 00169 // For fetching TypoScript code from template hierarchy before parsing it. Each array contains code field values from template records/files: 00170 var $config = array(); // Setup field 00171 var $constants = array(); // Constant field 00172 var $editorcfg = array(); // Backend Editor Configuration field 00173 00174 var $hierarchyInfo = array(); // For Template Analyser in backend 00175 var $hierarchyInfoToRoot = array(); // For Template Analyser in backend (setup content only) 00176 var $nextLevel=0; // Next-level flag (see runThroughTemplates()) 00177 var $rootId; // The Page UID of the root page 00178 var $rootLine; // The rootline from current page to the root page 00179 var $absoluteRootLine; // Rootline all the way to the root. Set but runThroughTemplates 00180 var $outermostRootlineIndexWithTemplate=0; // A pointer to the last entry in the rootline where a template was found. 00181 var $rowSum; // Array of arrays with title/uid of templates in hierarchy 00182 var $resources=''; // Resources for the template hierarchy in a comma list 00183 var $sitetitle=''; // The current site title field. 00184 var $sections; // Tracking all conditions found during parsing of TypoScript. Used for the "all" key in currentPageData 00185 var $sectionsMatch; // Tracking all matching conditions found 00186 00187 // Backend: ts_analyzer 00188 var $clearList_const=array(); 00189 var $clearList_setup=array(); 00190 var $clearList_editorcfg=array(); 00191 var $parserErrors=array(); 00192 var $setup_constants = array(); 00193 00194 // Other: 00195 var $fileCache = Array(); // Used by getFileName for caching of references to file resources 00196 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. 00197 var $MPmap = ''; // Contains mapping of Page id numbers to MP variables. 00198 00199 00200 00201 00209 function init() { 00210 // $this->whereClause is used only to select templates from sys_template. 00211 // $GLOBALS['SIM_EXEC_TIME'] is used so that we're able to simulate a later time as a test... 00212 $this->whereClause='AND deleted=0 '; 00213 if (!$GLOBALS['TSFE']->showHiddenRecords) { 00214 $this->whereClause.='AND hidden=0 '; 00215 } 00216 if ($GLOBALS['TSFE']->showHiddenRecords || $GLOBALS['SIM_EXEC_TIME']!=$GLOBALS['EXEC_TIME']) { // Set the simulation flag, if simulation is detected! 00217 $this->simulationHiddenOrTime=1; 00218 } 00219 $this->whereClause.= 'AND (starttime<='.$GLOBALS['SIM_EXEC_TIME'].') AND (endtime=0 OR endtime>'.$GLOBALS['SIM_EXEC_TIME'].')'; 00220 if (!$GLOBALS['TYPO3_CONF_VARS']['GFX']['gdlib']) { 00221 $this->menuclasses='tmenu,jsmenu,gmenu'; 00222 } 00223 00224 // Sets the paths from where TypoScript resources are allowed to be used: 00225 $this->allowedPaths = Array ('media/','fileadmin/','uploads/','typo3temp/','t3lib/fonts/',TYPO3_mainDir.'ext/',TYPO3_mainDir.'sysext/','typo3conf/ext/'); 00226 if ($GLOBALS['TYPO3_CONF_VARS']['FE']['addAllowedPaths']) { 00227 $pathArr = t3lib_div::trimExplode(',',$GLOBALS['TYPO3_CONF_VARS']['FE']['addAllowedPaths'],1); 00228 while(list(,$p)=each($pathArr)) { 00229 // 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. 00230 $this->allowedPaths[] = $p; 00231 } 00232 } 00233 } 00234 00247 function getCurrentPageData() { 00248 $res = $GLOBALS['TYPO3_DB']->exec_SELECTquery('content', 'cache_pagesection', 'page_id='.intval($GLOBALS['TSFE']->id).' AND mpvar_hash='.t3lib_div::md5int($GLOBALS['TSFE']->MP)); 00249 if ($row = $GLOBALS['TYPO3_DB']->sql_fetch_assoc($res)) { 00250 $this->currentPageData = unserialize($row['content']); 00251 } else { 00252 $this->currentPageData = 'none'; 00253 } 00254 return $this->currentPageData; 00255 } 00256 00264 function matching($cc) { 00265 if (is_array($cc['all'])) { 00266 reset($cc['all']); 00267 $matchObj = t3lib_div::makeInstance('t3lib_matchCondition'); 00268 $matchObj->altRootLine=$cc['rootLine']; 00269 while(list($key,$pre)=each($cc['all'])) { 00270 if ($matchObj->match($pre)) { 00271 $sectionsMatch[$key]=$pre; 00272 } 00273 } 00274 $cc['match']=$sectionsMatch; 00275 } 00276 return $cc; 00277 } 00278 00288 function start($theRootLine) { 00289 if (is_array($theRootLine)) { 00290 $setupData=''; 00291 $cc=Array(); 00292 $hash=''; 00293 $this->runThroughTemplates($theRootLine); 00294 00295 // Getting the currentPageData if not already found 00296 if (!$this->currentPageData) { 00297 $this->getCurrentPageData(); 00298 } 00299 00300 // This is about getting the hash string which is used to fetch the cached TypoScript template. 00301 // If there was some cached currentPageData that's good (it gives us the hash), 00302 // However if the actual rowSum and the rowSum of currentPageData is different from each other, thats a problem, and we should re-make the current page data. 00303 if (is_array($this->currentPageData) && 00304 !strcmp(serialize($this->rowSum), serialize($this->currentPageData['rowSum'])) // The two ROWsums must NOT be different from each other - which they will be if start/endtime or hidden has changed! 00305 ) { 00306 // If currentPageData was actually there, we match the result... 00307 $cc['all'] = $this->currentPageData['all']; 00308 $cc['rowSum'] = $this->currentPageData['rowSum']; 00309 $cc = $this->matching($cc); 00310 $hash = md5(serialize($cc)); 00311 } else { 00312 // If currentPageData was not there, we first find $rowSum (freshly generated). After that we try to see, if rowSum is stored with a list of all matching-parameters. If so we match the result 00313 $rowSumHash = md5('ROWSUM:'.serialize($this->rowSum)); 00314 $result = t3lib_pageSelect::getHash($rowSumHash, 0); 00315 if ($result) { 00316 $cc['all'] = unserialize($result); 00317 $cc['rowSum'] = $this->rowSum; 00318 $cc = $this->matching($cc); 00319 $hash = md5(serialize($cc)); 00320 } 00321 } 00322 00323 if ($hash) { 00324 // Get TypoScript setup array 00325 $setupData = t3lib_pageSelect::getHash($hash, 0); 00326 } 00327 00328 if ($hash && $setupData && !$this->forceTemplateParsing) { 00329 // If TypoScript setup structure was cached we unserialize it here: 00330 $this->setup = unserialize($setupData); 00331 } else { 00332 // Make configuration 00333 $this->generateConfig(); 00334 00335 // This stores the template hash thing 00336 $cc=Array(); 00337 $cc['all']=$this->sections; // All sections in the template at this point is found 00338 $cc['rowSum']=$this->rowSum; // The line of templates is collected 00339 $cc = $this->matching($cc); 00340 00341 $hash = md5(serialize($cc)); 00342 00343 // This stores the data. 00344 t3lib_pageSelect::storeHash($hash, serialize($this->setup), 'TS TEMPLATE'); 00345 00346 if ($this->tt_track) $GLOBALS['TT']->setTSlogMessage('TS template size, serialized: '.strlen(serialize($this->setup)).' bytes'); 00347 00348 $rowSumHash = md5('ROWSUM:'.serialize($this->rowSum)); 00349 t3lib_pageSelect::storeHash($rowSumHash, serialize($cc['all']), 'TMPL CONDITIONS - AL'); 00350 } 00351 // Add rootLine 00352 $cc['rootLine'] = $this->rootLine; 00353 // Make global and save. 00354 $GLOBALS['TSFE']->all=$cc; 00355 00356 if (!$this->simulationHiddenOrTime) { // Only save currentPageData, if we're not simulating by hidden/starttime/endtime 00357 $insertFields = array( 00358 'page_id' => intval($GLOBALS['TSFE']->id), 00359 'mpvar_hash' => t3lib_div::md5int($GLOBALS['TSFE']->MP), 00360 'content' => serialize($cc), 00361 'tstamp' => $GLOBALS['EXEC_TIME'] 00362 ); 00363 $GLOBALS['TYPO3_DB']->exec_DELETEquery('cache_pagesection', 'page_id='.intval($GLOBALS['TSFE']->id).' AND mpvar_hash='.t3lib_div::md5int($GLOBALS['TSFE']->MP)); 00364 00365 $GLOBALS['TYPO3_DB']->exec_INSERTquery('cache_pagesection', $insertFields); 00366 } 00367 // If everything OK. 00368 if ($this->rootId && $this->rootLine && $this->setup) { 00369 $this->loaded = 1; 00370 } 00371 } 00372 } 00373 00374 00375 00376 00377 00378 00379 00380 00381 00382 00383 00384 00385 00386 00387 00388 /******************************************************************* 00389 * 00390 * Fetching TypoScript code text for the Template Hierarchy 00391 * 00392 *******************************************************************/ 00393 00404 function runThroughTemplates($theRootLine,$start_template_uid=0) { 00405 $this->constants = Array(); 00406 $this->config = Array(); 00407 $this->editorcfg = Array(); 00408 $this->rowSum = Array(); 00409 $this->hierarchyInfoToRoot = Array(); 00410 $this->absoluteRootLine=$theRootLine; // Is the TOTAL rootline 00411 00412 reset ($this->absoluteRootLine); 00413 $c=count($this->absoluteRootLine); 00414 for ($a=0;$a<$c;$a++) { 00415 if ($this->nextLevel) { // If some template loaded before has set a template-id for the next level, then load this template first! 00416 $res = $GLOBALS['TYPO3_DB']->exec_SELECTquery('*', 'sys_template', 'uid='.intval($this->nextLevel).' '.$this->whereClause); 00417 $this->nextLevel = 0; 00418 if ($row = $GLOBALS['TYPO3_DB']->sql_fetch_assoc($res)) { 00419 $this->processTemplate($row,'sys_'.$row['uid'],$this->absoluteRootLine[$a]['uid'],'sys_'.$row['uid']); 00420 $this->outermostRootlineIndexWithTemplate=$a; 00421 } 00422 $GLOBALS['TYPO3_DB']->sql_free_result($res); 00423 } 00424 $addC=''; 00425 if ($a==($c-1) && $start_template_uid) { // If first loop AND there is set an alternative template uid, use that 00426 $addC=' AND uid='.intval($start_template_uid); 00427 } 00428 00429 $res = $GLOBALS['TYPO3_DB']->exec_SELECTquery('*', 'sys_template', 'pid='.intval($this->absoluteRootLine[$a]['uid']).$addC.' '.$this->whereClause,'','sorting',1); 00430 if ($row = $GLOBALS['TYPO3_DB']->sql_fetch_assoc($res)) { 00431 $this->processTemplate($row,'sys_'.$row['uid'],$this->absoluteRootLine[$a]['uid'],'sys_'.$row['uid']); 00432 $this->outermostRootlineIndexWithTemplate=$a; 00433 } 00434 $GLOBALS['TYPO3_DB']->sql_free_result($res); 00435 $this->rootLine[] = $this->absoluteRootLine[$a]; 00436 } 00437 } 00438 00451 function processTemplate($row, $idList,$pid,$templateID='',$templateParent='') { 00452 // Adding basic template record information to rowSum array 00453 $this->rowSum[]=Array($row['uid'],$row['title'],$row['tstamp']); 00454 00455 // Processing "Clear"-flags 00456 if ($row['clear']) { 00457 $clConst = $row['clear']&1; 00458 $clConf = $row['clear']&2; 00459 if ($clConst) { 00460 $this->constants = Array(); 00461 $this->clearList_const=array(); 00462 } 00463 if ($clConf) { 00464 $this->config = Array(); 00465 $this->hierarchyInfoToRoot = Array(); 00466 $this->clearList_setup=array(); 00467 00468 $this->editorcfg = Array(); 00469 $this->clearList_editorcfg=array(); 00470 } 00471 } 00472 00473 // Include static records (static_template) or files (from extensions) (#1/2) 00474 if (!$row['includeStaticAfterBasedOn']) { // NORMAL inclusion, The EXACT same code is found below the basedOn inclusion!!! 00475 $this->includeStaticTypoScriptSources($idList,$templateID,$pid,$row); 00476 } 00477 00478 // Include "Based On" sys_templates: 00479 if (trim($row['basedOn'])) { // 'basedOn' is a list of templates to include 00480 // Manually you can put this value in the field and then the based_on ID will be taken from the $_GET var defined by '=....'. 00481 // 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! 00482 // 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. 00483 $basedOn_hackFeature = explode('=',$row['basedOn']); 00484 if ($basedOn_hackFeature[0]=='EXTERNAL_BASED_ON_TEMPLATE_ID' && $basedOn_hackFeature[1]) { 00485 $id = intval(t3lib_div::_GET($basedOn_hackFeature[1])); 00486 if ($id && !t3lib_div::inList($idList,'sys_'.$id)) { // if $id is not allready included ... 00487 $res = $GLOBALS['TYPO3_DB']->exec_SELECTquery('*', 'sys_template', 'uid='.$id.' '.$this->whereClause); 00488 if ($subrow = $GLOBALS['TYPO3_DB']->sql_fetch_assoc($res)) { // there was a template, then we fetch that 00489 $this->processTemplate($subrow,$idList.',sys_'.$id,$pid, 'sys_'.$id,$templateID); 00490 } 00491 $GLOBALS['TYPO3_DB']->sql_free_result($res); 00492 } 00493 } else { // NORMAL OPERATION: 00494 $basedOnArr = t3lib_div::intExplode(',',$row['basedOn']); 00495 while(list(,$id)=each($basedOnArr)) { // traversing list 00496 if (!t3lib_div::inList($idList,'sys_'.$id)) { // if $id is not allready included ... 00497 $res = $GLOBALS['TYPO3_DB']->exec_SELECTquery('*', 'sys_template', 'uid='.intval($id).' '.$this->whereClause); 00498 if ($subrow = $GLOBALS['TYPO3_DB']->sql_fetch_assoc($res)) { // there was a template, then we fetch that 00499 $this->processTemplate($subrow,$idList.',sys_'.$id,$pid, 'sys_'.$id,$templateID); 00500 } 00501 $GLOBALS['TYPO3_DB']->sql_free_result($res); 00502 } 00503 } 00504 } 00505 } 00506 00507 // Include static records (static_template) or files (from extensions) (#2/2) 00508 if ($row['includeStaticAfterBasedOn']) { 00509 $this->includeStaticTypoScriptSources($idList,$templateID,$pid,$row); 00510 } 00511 00512 // Creating hierarchy information; Used by backend analysis tools 00513 $this->hierarchyInfo[] = $this->hierarchyInfoToRoot[] = array( 00514 'root'=>trim($row['root']), 00515 'next'=>$row['nextLevel'], 00516 'clConst'=>$clConst, 00517 'clConf'=>$clConf, 00518 'templateID'=>$templateID, 00519 'templateParent'=>$templateParent, 00520 'title'=>$row['title'], 00521 'uid'=>$row['uid'], 00522 'pid'=>$row['pid'], 00523 'configLines' => substr_count($row['config'], chr(10))+1 00524 ); 00525 00526 // Adding the content of the fields constants (Constants), config (Setup) and editorcfg (Backend Editor Configuration) to the internal arrays. 00527 $this->constants[] = $row['constants']; 00528 $this->config[] = $row['config']; 00529 if ($this->parseEditorCfgField) $this->editorcfg[] = $row['editorcfg']; 00530 00531 // For backend analysis (Template Analyser) provide the order of added constants/config/editorcfg template IDs 00532 $this->clearList_const[]=$templateID; 00533 $this->clearList_setup[]=$templateID; 00534 if ($this->parseEditorCfgField) $this->clearList_editorcfg[]=$templateID; 00535 00536 // Add resources and sitetitle if found: 00537 if (trim($row['resources'])) { 00538 $this->resources = $row['resources'].','.$this->resources; 00539 } 00540 if (trim($row['sitetitle'])) { 00541 $this->sitetitle = $row['sitetitle']; 00542 } 00543 // If the template record is a Rootlevel record, set the flag and clear the template rootLine (so it starts over from this point) 00544 if (trim($row['root'])) { 00545 $this->rootId = $pid; 00546 $this->rootLine = Array(); 00547 } 00548 // If a template is set to be active on the next level set this internal value to point to this UID. (See runThroughTemplates()) 00549 if ($row['nextLevel']) { 00550 $this->nextLevel = $row['nextLevel']; 00551 } else { 00552 $this->nextLevel = 0; 00553 } 00554 } 00555 00566 function includeStaticTypoScriptSources($idList,$templateID,$pid,$row) { 00567 // Static Template Records (static_template): include_static is a list of static templates to include 00568 if (trim($row['include_static'])) { 00569 $include_staticArr = t3lib_div::intExplode(',',$row['include_static']); 00570 reset($include_staticArr); 00571 while(list(,$id)=each($include_staticArr)) { // traversing list 00572 if (!t3lib_div::inList($idList,'static_'.$id)) { // if $id is not allready included ... 00573 $res = $GLOBALS['TYPO3_DB']->exec_SELECTquery('*', 'static_template', 'uid='.intval($id)); 00574 if ($subrow = $GLOBALS['TYPO3_DB']->sql_fetch_assoc($res)) { // there was a template, then we fetch that 00575 $subrow = $this->prependStaticExtra($subrow); 00576 $this->processTemplate($subrow,$idList.',static_'.$id,$pid,'static_'.$id,$templateID); 00577 } 00578 $GLOBALS['TYPO3_DB']->sql_free_result($res); 00579 } 00580 } 00581 } 00582 00583 // Static Template Files (Text files from extensions): include_static_file is a list of static files to include (from extensions) 00584 if (trim($row['include_static_file'])) { 00585 $include_static_fileArr = t3lib_div::trimExplode(',',$row['include_static_file'],1); 00586 reset($include_static_fileArr); 00587 while(list(,$ISF_file)=each($include_static_fileArr)) { // traversing list 00588 $ISF_file = trim($ISF_file); 00589 if (substr($ISF_file,0,4)=='EXT:') { 00590 list($ISF_extKey,$ISF_localPath) = explode('/',substr($ISF_file,4),2); 00591 if (strcmp($ISF_extKey,'') && t3lib_extMgm::isLoaded($ISF_extKey) && strcmp($ISF_localPath,'')) { 00592 $ISF_localPath = ereg_replace('\/$','',$ISF_localPath).'/'; 00593 $ISF_filePath = t3lib_extMgm::extPath($ISF_extKey).$ISF_localPath; 00594 if (@is_dir($ISF_filePath)) { 00595 $mExtKey = str_replace('_','',$ISF_extKey.'/'.$ISF_localPath); 00596 $subrow=array( 00597 'constants'=> @is_file($ISF_filePath.'constants.txt') ?t3lib_div::getUrl($ISF_filePath.'constants.txt'):'', 00598 'config'=> @is_file($ISF_filePath.'setup.txt') ?t3lib_div::getUrl($ISF_filePath.'setup.txt'):'', 00599 'editorcfg'=> @is_file($ISF_filePath.'editorcfg.txt') ?t3lib_div::getUrl($ISF_filePath.'editorcfg.txt'):'', 00600 'include_static'=> @is_file($ISF_filePath.'include_static.txt')?implode(',',array_unique(t3lib_div::intExplode(',',t3lib_div::getUrl($ISF_filePath.'include_static.txt')))):'', 00601 'include_static_file'=> @is_file($ISF_filePath.'include_static_file.txt')?implode(',',array_unique(explode(',',t3lib_div::getUrl($ISF_filePath.'include_static_file.txt')))):'', 00602 'title' => $ISF_file, 00603 'uid' => $mExtKey 00604 ); 00605 $subrow = $this->prependStaticExtra($subrow); 00606 00607 $this->processTemplate($subrow,$idList.',ext_'.$mExtKey,$pid, 'ext_'.$mExtKey,$templateID); 00608 } 00609 } 00610 } 00611 } 00612 } 00613 00614 $this->addExtensionStatics($idList,$templateID,$pid,$row); 00615 } 00616 00628 function addExtensionStatics($idList,$templateID,$pid,$row) { 00629 global $TYPO3_LOADED_EXT; 00630 00631 if ($row['static_file_mode']==1 || ($row['static_file_mode']==0 && substr($templateID,0,4)=='sys_' && $row['root'])) { 00632 reset($TYPO3_LOADED_EXT); 00633 while(list($extKey,$files)=each($TYPO3_LOADED_EXT)) { 00634 if (is_array($files) && ($files['ext_typoscript_constants.txt'] || $files['ext_typoscript_setup.txt'] || $files['ext_typoscript_editorcfg.txt'])) { 00635 $mExtKey = str_replace('_','',$extKey); 00636 $subrow=array( 00637 'constants'=> $files['ext_typoscript_constants.txt']?t3lib_div::getUrl($files['ext_typoscript_constants.txt']):'', 00638 'config'=> $files['ext_typoscript_setup.txt']?t3lib_div::getUrl($files['ext_typoscript_setup.txt']):'', 00639 'editorcfg'=> $files['ext_typoscript_editorcfg.txt']?t3lib_div::getUrl($files['ext_typoscript_editorcfg.txt']):'', 00640 'title' => $extKey, 00641 'uid' => $mExtKey 00642 ); 00643 $subrow = $this->prependStaticExtra($subrow); 00644 00645 $this->processTemplate($subrow,$idList.',ext_'.$mExtKey,$pid, 'ext_'.$mExtKey,$templateID); 00646 } 00647 } 00648 } 00649 } 00650 00661 function prependStaticExtra($subrow) { 00662 $subrow['config'].=$GLOBALS['TYPO3_CONF_VARS']['FE']['defaultTypoScript_setup.'][$subrow['uid']]; 00663 $subrow['editorcfg'].=$GLOBALS['TYPO3_CONF_VARS']['FE']['defaultTypoScript_editorcfg.'][$subrow['uid']]; 00664 $subrow['constants'].=$GLOBALS['TYPO3_CONF_VARS']['FE']['defaultTypoScript_constants.'][$subrow['uid']]; 00665 return $subrow; 00666 } 00667 00668 00669 00670 00671 00672 00673 00674 00675 00676 00677 00678 00679 00680 00681 00682 00683 00684 /******************************************************************* 00685 * 00686 * Parsing TypoScript code text from Template Records into PHP array 00687 * 00688 *******************************************************************/ 00689 00697 function generateConfig() { 00698 // Add default TS for all three code types: 00699 array_unshift($this->constants,''.$GLOBALS['TYPO3_CONF_VARS']['FE']['defaultTypoScript_constants']); // Adding default TS/constants 00700 array_unshift($this->config,''.$GLOBALS['TYPO3_CONF_VARS']['FE']['defaultTypoScript_setup']); // Adding default TS/setup 00701 array_unshift($this->editorcfg,''.$GLOBALS['TYPO3_CONF_VARS']['FE']['defaultTypoScript_editorcfg']); // Adding default TS/editorcfg 00702 00703 // Parse the TypoScript code text for include-instructions! 00704 $this->procesIncludes(); 00705 00706 // These vars are also set lateron... 00707 $this->setup['resources']= $this->resources; 00708 $this->setup['sitetitle']= $this->sitetitle; 00709 00710 00711 00712 // **************************** 00713 // Parse TypoScript Constants 00714 // **************************** 00715 00716 // Initialize parser and match-condition classes: 00717 $constants = t3lib_div::makeInstance('t3lib_TSparser'); 00718 $constants->breakPointLN=intval($this->ext_constants_BRP); 00719 $constants->setup = $this->const; 00720 $constants->setup = $this->mergeConstantsFromPageTSconfig($constants->setup); 00721 $matchObj = t3lib_div::makeInstance('t3lib_matchCondition'); 00722 $matchObj->matchAlternative = $this->matchAlternative; 00723 $matchObj->matchAll = $this->matchAll; // Matches ALL conditions in TypoScript 00724 00725 // Traverse constants text fields and parse them 00726 foreach($this->constants as $str) { 00727 $constants->parse($str,$matchObj); 00728 } 00729 00730 // Read out parse errors if any 00731 $this->parserErrors['constants']=$constants->errors; 00732 00733 // 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) 00734 $this->flatSetup = Array(); 00735 $this->flattenSetup($constants->setup,'',''); 00736 00737 00738 00739 // *********************************************** 00740 // Parse TypoScript Setup (here called "config") 00741 // *********************************************** 00742 // Initialize parser and match-condition classes: 00743 $config = t3lib_div::makeInstance('t3lib_TSparser'); 00744 $config->breakPointLN = intval($this->ext_config_BRP); 00745 $config->regLinenumbers = $this->ext_regLinenumbers; 00746 $config->setup = $this->setup; 00747 00748 // Transfer information about conditions found in "Constants" and which of them returned true. 00749 $config->sections = $constants->sections; 00750 $config->sectionsMatch = $constants->sectionsMatch; 00751 00752 // Traverse setup text fields and concatenate them into one, single string separated by a [GLOBAL] condition 00753 $all=''; 00754 foreach($this->config as $str) { 00755 $all.="\n[GLOBAL]\n".$str; 00756 } 00757 00758 // Substitute constants in the Setup code: 00759 if ($this->tt_track) $GLOBALS['TT']->push('Substitute Constants ('.count($this->flatSetup).')'); 00760 $all = $this->substituteConstants($all); 00761 if ($this->tt_track) $GLOBALS['TT']->pull(); 00762 00763 // Searching for possible unsubstituted constants left (only for information) 00764 if (strstr($all,'{$')) { 00765 $findConst = explode('{$',$all); 00766 $theConstList=Array(); 00767 next($findConst); 00768 while(list(,$constVal)=each($findConst)) { 00769 $constLen=t3lib_div::intInRange(strcspn($constVal,'}'),0,50); 00770 $theConstList[]='{$'.substr($constVal,0,$constLen+1); 00771 } 00772 if ($this->tt_track) $GLOBALS['TT']->setTSlogMessage(implode(',',$theConstList).': Constants may remain un-substituted!!',2); 00773 } 00774 00775 // Logging the textual size of the TypoScript Setup field text with all constants substituted: 00776 if ($this->tt_track) $GLOBALS['TT']->setTSlogMessage('TypoScript template size as textfile: '.strlen($all).' bytes'); 00777 00778 // Finally parse the Setup field TypoScript code (where constants are now substituted) 00779 $config->parse($all,$matchObj); 00780 00781 // Read out parse errors if any 00782 $this->parserErrors['config']=$config->errors; 00783 00784 // Transfer the TypoScript array from the parser object to the internal $this->setup array: 00785 $this->setup = $config->setup; 00786 if ($this->backend_info) { 00787 $this->setup_constants = $constants->setup; // Used for backend purposes only 00788 } 00789 00790 00791 00792 00793 // ************************************************** 00794 // Parse Backend Editor Configuration (backend only) 00795 // ************************************************** 00796 if ($this->parseEditorCfgField) { 00797 $editorcfg = t3lib_div::makeInstance('t3lib_TSparser'); 00798 $editorcfg->breakPointLN=intval($this->ext_editorcfg_BRP); 00799 $editorcfg->setup = array(); // Empty as a start... 00800 00801 $all = implode("\n[GLOBAL]\n",$this->editorcfg); 00802 00803 // substitute constants in config 00804 $all = $this->substituteConstants($all); 00805 00806 // parse Config 00807 $matchObj->matchAll=1; // This should make sure that conditions are disabled. For now they are NOT active for the backend. 00808 $editorcfg->parse($all,$matchObj); 00809 $this->parserErrors['editorcfg']=$editorcfg->errors; 00810 $this->setup_editorcfg = $editorcfg->setup; 00811 } 00812 00813 00814 00815 00816 00817 // **************************************************************** 00818 // Final processing of the $this->setup TypoScript Template array 00819 // Basically: This is unsetting/setting of certain reserved keys. 00820 // **************************************************************** 00821 00822 // 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! 00823 unset($this->setup['resources']); 00824 unset($this->setup['resources.']); 00825 $this->setup['resources']= implode(',',t3lib_div::trimExplode(',',$this->resources,1)); 00826 00827 unset($this->setup['sitetitle']); 00828 unset($this->setup['sitetitle.']); 00829 $this->setup['sitetitle']= $this->sitetitle; 00830 00831 // Unsetting some vars... 00832 unset($this->setup['types.']); 00833 unset($this->setup['types']); 00834 if (is_array($this->setup)) { 00835 reset ($this->setup); 00836 while(list($theKey,)=each($this->setup)) { 00837 if ($this->setup[$theKey]=='PAGE') { 00838 $tN = $this->setup[$theKey.'.']['typeNum']; 00839 if (isset($tN)) { 00840 $this->setup['types.'][$tN] = $theKey; 00841 } elseif(!$this->setup['types.'][0]) { // If there is no type 0 yet and typeNum was not set, we use the current object as the default 00842 $this->setup['types.'][0] = $theKey; 00843 } 00844 } 00845 } 00846 } 00847 unset($this->setup['styles.']); 00848 unset($this->setup['temp.']); 00849 unset($constants); 00850 00851 // Storing the conditions found/matched information: 00852 $this->sections = $config->sections; 00853 $this->sectionsMatch = $config->sectionsMatch; 00854 } 00855 00863 function procesIncludes() { 00864 reset($this->constants); 00865 while(list($k)=each($this->constants)) { 00866 $this->constants[$k]=t3lib_TSparser::checkIncludeLines($this->constants[$k]); 00867 } 00868 00869 reset($this->config); 00870 while(list($k)=each($this->config)) { 00871 $this->config[$k]=t3lib_TSparser::checkIncludeLines($this->config[$k]); 00872 } 00873 00874 reset($this->editorcfg); 00875 while(list($k)=each($this->editorcfg)) { 00876 $this->editorcfg[$k]=t3lib_TSparser::checkIncludeLines($this->editorcfg[$k]); 00877 } 00878 } 00879 00887 function mergeConstantsFromPageTSconfig($constArray) { 00888 $TSdataArray = array(); 00889 $TSdataArray[]=$GLOBALS['TYPO3_CONF_VARS']['BE']['defaultPageTSconfig']; // Setting default configuration: 00890 00891 for ($a=0;$a<=$this->outermostRootlineIndexWithTemplate;$a++) { 00892 $TSdataArray[]=$this->absoluteRootLine[$a]['TSconfig']; 00893 } 00894 // Parsing the user TS (or getting from cache) 00895 $TSdataArray = t3lib_TSparser::checkIncludeLines_array($TSdataArray); 00896 $userTS = implode(chr(10).'[GLOBAL]'.chr(10),$TSdataArray); 00897 00898 $parseObj = t3lib_div::makeInstance('t3lib_TSparser'); 00899 $parseObj->parse($userTS); 00900 00901 if (is_array($parseObj->setup['TSFE.']['constants.'])) { 00902 $constArray = t3lib_div::array_merge_recursive_overrule($constArray,$parseObj->setup['TSFE.']['constants.']); 00903 } 00904 return $constArray; 00905 } 00906 00916 function flattenSetup($setupArray, $prefix, $resourceFlag) { 00917 if (is_array($setupArray)) { 00918 reset($setupArray); 00919 while(list($key,$val)=each($setupArray)) { 00920 if ($prefix || substr($key,0,16)!='TSConstantEditor') { // We don't want 'TSConstantEditor' in the flattend setup on the first level (190201) 00921 if (is_array($val)) { 00922 $this->flattenSetup($val,$prefix.$key, ($key=='file.')); 00923 } elseif ($resourceFlag) { 00924 $this->flatSetup[$prefix.$key] = $this->getFileName($val); 00925 } else { 00926 $this->flatSetup[$prefix.$key] = $val; 00927 } 00928 } 00929 } 00930 } 00931 } 00932 00940 function substituteConstants($all) { 00941 if ($this->tt_track) $GLOBALS['TT']->setTSlogMessage('Constants to substitute: '.count($this->flatSetup)); 00942 reset($this->flatSetup); 00943 while (list($const,$val)=each($this->flatSetup)) { 00944 if (!is_array($val)) { 00945 $all = str_replace('{$'.$const.'}',$val,$all); 00946 } 00947 } 00948 return $all; 00949 } 00950 00951 00952 00953 00954 00955 00956 00957 00958 00959 00960 00961 /******************************************************************* 00962 * 00963 * Various API functions, used from elsewhere in the frontend classes 00964 * 00965 *******************************************************************/ 00966 00978 function splitConfArray($conf,$splitCount) { 00979 00980 // Initialize variables: 00981 $splitCount = intval($splitCount); 00982 $conf2 = Array(); 00983 00984 if ($splitCount && is_array($conf)) { 00985 00986 // Initialize output to carry at least the keys: 00987 for ($aKey=0;$aKey<$splitCount;$aKey++) { 00988 $conf2[$aKey] = array(); 00989 } 00990 00991 // Recursive processing of array keys: 00992 foreach($conf as $cKey => $val) { 00993 if (is_array($val)) { 00994 $tempConf = $this->splitConfArray($val,$splitCount); 00995 foreach($tempConf as $aKey => $val) { 00996 $conf2[$aKey][$cKey] = $val; 00997 } 00998 } 00999 } 01000 01001 // Splitting of all values on this level of the TypoScript object tree: 01002 foreach($conf as $cKey => $val) { 01003 if (!is_array($val)) { 01004 if (!strstr($val,'|*|') && !strstr($val,'||')) { 01005 for ($aKey=0;$aKey<$splitCount;$aKey++) { 01006 $conf2[$aKey][$cKey] = $val; 01007 } 01008 } else { 01009 $main = explode ('|*|',$val); 01010 $mainCount = count($main); 01011 01012 $lastC = 0; 01013 $middleC = 0; 01014 $firstC = 0; 01015 01016 if ($main[0]) { 01017 $first = explode('||',$main[0]); 01018 $firstC = count($first); 01019 } 01020 if ($main[1]) { 01021 $middle = explode('||',$main[1]); 01022 $middleC = count($middle); 01023 } 01024 if ($main[2]) { 01025 $last = explode('||',$main[2]); 01026 $lastC = count($last); 01027 $value = $last[0]; 01028 } 01029 01030 for ($aKey=0;$aKey<$splitCount;$aKey++) { 01031 if ($firstC && isset($first[$aKey])) { 01032 $value = $first[$aKey]; 01033 } elseif ($middleC) { 01034 $value = $middle[($aKey-$firstC)%$middleC]; 01035 } 01036 if ($lastC && $lastC>=($splitCount-$aKey)) { 01037 $value = $last[$lastC-($splitCount-$aKey)]; 01038 } 01039 $conf2[$aKey][$cKey] = trim($value); 01040 } 01041 } 01042 } 01043 } 01044 } 01045 return $conf2; 01046 } 01047 01055 function getFileName($fileFromSetup) { 01056 $file = trim($fileFromSetup); 01057 if (!$file) return; 01058 // cache 01059 $hash = md5($file); 01060 if (isset($this->fileCache[$hash])) { 01061 return $this->fileCache[$hash]; 01062 } 01063 01064 if (!strcmp(substr($file,0,4),'EXT:')) { 01065 $newFile=''; 01066 list($extKey,$script)=explode('/',substr($file,4),2); 01067 if ($extKey && t3lib_extMgm::isLoaded($extKey)) { 01068 $extPath=t3lib_extMgm::extPath($extKey); 01069 $newFile=substr($extPath,strlen(PATH_site)).$script; 01070 } 01071 if (!@is_file(PATH_site.$newFile)) { 01072 if ($this->tt_track) $GLOBALS['TT']->setTSlogMessage('Extension media file "'.$newFile.'" was not found!',3); 01073 return; 01074 } else $file=$newFile; 01075 } 01076 01077 // find 01078 if (strstr($file,'/')) { // here it is manual media 01079 if (@is_file($this->getFileName_backPath.$file)) { 01080 $outFile = $file; 01081 $fileInfo = t3lib_div::split_fileref($outFile); 01082 reset($this->allowedPaths); 01083 $OK=0; 01084 while(list(,$val)=each($this->allowedPaths)) { 01085 if (substr($fileInfo['path'],0,strlen($val))==$val){$OK=1; break;} 01086 } 01087 if ($OK) { 01088 $this->fileCache[$hash]=$outFile; 01089 return $outFile; 01090 } elseif ($this->tt_track) $GLOBALS['TT']->setTSlogMessage('"'.$file.'" was not located in the allowed paths: ('.implode(',',$this->allowedPaths).')',3); 01091 } elseif ($this->tt_track) $GLOBALS['TT']->setTSlogMessage('"'.$this->getFileName_backPath.$file.'" is not a file (non-uploads/.. resource, did not exist).',3); 01092 } else { // Here it is uploaded media: 01093 $outFile = $this->extractFromResources($this->setup['resources'],$file); 01094 if ($outFile) { 01095 if (@is_file($this->uplPath.$outFile)) { 01096 $this->fileCache[$hash] = $this->uplPath.$outFile; 01097 return $this->uplPath.$outFile; 01098 } elseif ($this->tt_track) $GLOBALS['TT']->setTSlogMessage('"'.$this->uplPath.$outFile.'" is not a file (did not exist).',3); 01099 } elseif ($this->tt_track) $GLOBALS['TT']->setTSlogMessage('"'.$file.'" is not a file (uploads/.. resource).',3); 01100 } 01101 } 01102 01112 function extractFromResources($res,$file) { 01113 if (t3lib_div::inList($res,$file)) { 01114 $outFile = $file; 01115 } elseif (strstr($file,'*')) { 01116 $fileparts=explode('*',$file); 01117 $c=count($fileparts); 01118 $files = explode(',',$res); 01119 while(list(,$val)=each($files)) { 01120 $test = trim($val); 01121 if (ereg('^'.quotemeta($fileparts[0]).'.*'.quotemeta($fileparts[$c-1]).'$', $test)) { 01122 $outFile = $test; 01123 break; 01124 } 01125 } 01126 } 01127 return $outFile; 01128 } 01129 01140 function checkFile($name,$menuArr) { 01141 reset ($menuArr); 01142 while (list($aKey,)=each($menuArr)) { 01143 $menuArr[$aKey][$name] = $this->getFileName($menuArr[$aKey][$name]); 01144 } 01145 return $menuArr; 01146 } 01147 01157 function printTitle($title,$no_title=0,$titleFirst=0) { 01158 $st = trim($this->setup['sitetitle']) ? $this->setup['sitetitle']:''; 01159 $title = $no_title ? '' : $title; 01160 if ($titleFirst) { 01161 $temp=$st; 01162 $st=$title; 01163 $title=$temp; 01164 } 01165 if ($title && $st) { 01166 return $st.': '.$title; 01167 } else { 01168 return $st.$title; 01169 } 01170 } 01171 01180 function fileContent($fName) { 01181 $incFile = $this->getFileName($fName); 01182 if ($incFile && $fd=fopen($incFile,'rb')) { 01183 $content = ''; 01184 while (!feof($fd)) { 01185 $content.=fread($fd, 5000); 01186 } 01187 fclose( $fd ); 01188 return $content; 01189 } 01190 } 01191 01200 function wrap($content,$wrap) { 01201 if ($wrap) { 01202 $wrapArr = explode('|', $wrap); 01203 return trim($wrapArr[0]).$content.trim($wrapArr[1]); 01204 } else return $content; 01205 } 01206 01214 function removeQueryString($url) { 01215 if (substr($url,-1)=='?') { 01216 return substr($url,0,-1); 01217 } else { 01218 return $url; 01219 } 01220 } 01221 01231 function sortedKeyList($setupArr, $acceptOnlyProperties=FALSE) { 01232 $keyArr = Array(); 01233 01234 reset($setupArr); 01235 while(list($key,)=each($setupArr)) { 01236 $ikey = intval($key); 01237 if (!strcmp($ikey,$key) || $acceptOnlyProperties) { 01238 $keyArr[] = $ikey; 01239 } 01240 } 01241 01242 $keyArr = array_unique($keyArr); 01243 sort($keyArr); 01244 return $keyArr; 01245 } 01246 01247 01248 01249 01250 01251 01252 01253 01254 01255 01256 /******************************************************************* 01257 * 01258 * Functions for creating links 01259 * 01260 *******************************************************************/ 01261 01278 function linkData($page,$oTarget,$no_cache,$script,$overrideArray='',$addParams='',$typeOverride='') { 01279 global $TYPO3_CONF_VARS; 01280 01281 $LD = Array(); 01282 01283 // Overriding some fields in the page record and still preserves the values by adding them as parameters. Little strange function. 01284 if (is_array($overrideArray)) { 01285 foreach($overrideArray as $theKey => $theNewVal) { 01286 $addParams.= '&real_'.$theKey.'='.rawurlencode($page[$theKey]); 01287 $page[$theKey] = $theNewVal; 01288 } 01289 } 01290 01291 // Adding Mount Points, "&MP=", parameter for the current page if any is set: 01292 if (!strstr($addParams,'&MP=')) { 01293 if (trim($GLOBALS['TSFE']->MP_defaults[$page['uid']])) { // Looking for hardcoded defaults: 01294 $addParams.= '&MP='.rawurlencode(trim($GLOBALS['TSFE']->MP_defaults[$page['uid']])); 01295 } elseif ($GLOBALS['TSFE']->config['config']['MP_mapRootPoints']) { // Else look in automatically created map: 01296 $m = $this->getFromMPmap($page['uid']); 01297 if ($m) { 01298 $addParams.= '&MP='.rawurlencode($m); 01299 } 01300 } 01301 } 01302 01303 // Setting ID/alias: 01304 if (!$script) {$script = $GLOBALS['TSFE']->config['mainScript'];} 01305 if ($page['alias']) { 01306 $LD['url'] = $script.'?id='.rawurlencode($page['alias']); 01307 } else { 01308 $LD['url'] = $script.'?id='.$page['uid']; 01309 } 01310 // Setting target 01311 $LD['target'] = trim($page['target']) ? trim($page['target']) : $oTarget; 01312 01313 // typeNum 01314 $typeNum = $this->setup[$LD['target'].'.']['typeNum']; 01315 if (!$typeOverride && intval($GLOBALS['TSFE']->config['config']['forceTypeValue'])) { 01316 $typeOverride = intval($GLOBALS['TSFE']->config['config']['forceTypeValue']); 01317 } 01318 if (strcmp($typeOverride,'')) { $typeNum = $typeOverride; } // Override... 01319 if ($typeNum) { 01320 $LD['type'] = '&type='.intval($typeNum); 01321 } else { 01322 $LD['type'] = ''; 01323 } 01324 $LD['orig_type'] = $LD['type']; // Preserving the type number. Will not be cleared if simulateStaticDocuments. 01325 01326 // noCache 01327 $LD['no_cache'] = (trim($page['no_cache']) || $no_cache) ? '&no_cache=1' : ''; 01328 01329 // linkVars 01330 if ($GLOBALS['TSFE']->config['config']['uniqueLinkVars']) { 01331 if ($addParams) { 01332 $LD['linkVars'] = t3lib_div::implodeArrayForUrl('',t3lib_div::explodeUrl2Array($GLOBALS['TSFE']->linkVars.$addParams)); 01333 } else { 01334 $LD['linkVars'] = $GLOBALS['TSFE']->linkVars; 01335 } 01336 } else { 01337 $LD['linkVars'] = $GLOBALS['TSFE']->linkVars.$addParams; 01338 } 01339 01340 // If simulateStaticDocuments is enabled: 01341 if ($GLOBALS['TSFE']->config['config']['simulateStaticDocuments']) { 01342 $LD['type'] = ''; 01343 $LD['url'] = ''; 01344 01345 // MD5/base64 method limitation: 01346 $remainLinkVars=''; 01347 $flag_simulateStaticDocuments_pEnc = t3lib_div::inList('md5,base64',$GLOBALS['TSFE']->config['config']['simulateStaticDocuments_pEnc']) && !$LD['no_cache']; 01348 if ($flag_simulateStaticDocuments_pEnc) { 01349 list($LD['linkVars'], $remainLinkVars) = $GLOBALS['TSFE']->simulateStaticDocuments_pEnc_onlyP_proc($LD['linkVars']); 01350 } 01351 01352 $LD['url'].=$GLOBALS['TSFE']->makeSimulFileName( 01353 $page['title'], 01354 $page['alias'] ? $page['alias'] : $page['uid'], 01355 intval($typeNum), 01356 $LD['linkVars'], 01357 $LD['no_cache']?1:0 01358 ); 01359 01360 if ($flag_simulateStaticDocuments_pEnc) { 01361 $LD['linkVars']=$remainLinkVars; 01362 } 01363 if ($GLOBALS['TSFE']->config['config']['simulateStaticDocuments']=='PATH_INFO') { 01364 $LD['url'] = str_replace('.','/',$LD['url']); 01365 $LD['url'] = 'index.php/'.$LD['url'].'/?'; 01366 } else { 01367 $LD['url'].= '.html?'; 01368 } 01369 } 01370 01371 // Add absRefPrefix if exists. 01372 $LD['url'] = $GLOBALS['TSFE']->absRefPrefix.$LD['url']; 01373 01374 // 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. 01375 $LD['sectionIndex'] = $page['sectionIndex_uid'] ? '#'.$page['sectionIndex_uid'] : ''; 01376 01377 // Compile the normal total url 01378 $LD['totalURL']= $this->removeQueryString($LD['url'].$LD['type'].$LD['no_cache'].$LD['linkVars'].$GLOBALS['TSFE']->getMethodUrlIdToken).$LD['sectionIndex']; 01379 01380 // Call post processing function for link rendering: 01381 if (is_array($TYPO3_CONF_VARS['SC_OPTIONS']['t3lib/class.t3lib_tstemplate.php']['linkData-PostProc'])) { 01382 $_params = array( 01383 'LD' => &$LD, 01384 'args' => array('page'=>$page, 'oTarget'=>$oTarget, 'no_cache'=>$no_cache, 'script'=>$script, 'overrideArray'=>$overrideArray, 'addParams'=>$addParams, 'typeOverride'=>$typeOverride), 01385 'typeNum' => $typeNum 01386 ); 01387 foreach($TYPO3_CONF_VARS['SC_OPTIONS']['t3lib/class.t3lib_tstemplate.php']['linkData-PostProc'] as $_funcRef) { 01388 t3lib_div::callUserFunction($_funcRef,$_params,$this); 01389 } 01390 } 01391 01392 // Return the LD-array 01393 return $LD; 01394 } 01395 01405 function getFromMPmap($pageId=0) { 01406 01407 // Create map if not found already: 01408 if (!is_array($this->MPmap)) { 01409 $this->MPmap = array(); 01410 01411 $rootPoints = t3lib_div::trimExplode(',', strtolower($GLOBALS['TSFE']->config['config']['MP_mapRootPoints']),1); 01412 foreach($rootPoints as $p) { // Traverse rootpoints: 01413 if ($p == 'root') { 01414 $p = $this->rootLine[0]['uid']; 01415 $initMParray = array(); 01416 if ($this->rootLine[0]['_MOUNT_OL'] && $this->rootLine[0]['_MP_PARAM']) { 01417 $initMParray[] = $this->rootLine[0]['_MP_PARAM']; 01418 } 01419 } 01420 $this->initMPmap_create($p,$initMParray); 01421 } 01422 } 01423 01424 // Finding MP var for Page ID: 01425 if ($pageId) { 01426 if (is_array($this->MPmap[$pageId]) && count($this->MPmap[$pageId])) { 01427 return implode(',',$this->MPmap[$pageId]); 01428 } 01429 } 01430 } 01431 01441 function initMPmap_create($id,$MP_array=array(),$level=0) { 01442 01443 $id = intval($id); 01444 if($id<=0) return; 01445 01446 // First level, check id 01447 if (!$level) { 01448 01449 // Find mount point if any: 01450 $mount_info = $GLOBALS['TSFE']->sys_page->getMountPointInfo($id); 01451 01452 // Overlay mode: 01453 if (is_array($mount_info) && $mount_info['overlay']) { 01454 $MP_array[] = $mount_info['MPvar']; 01455 $id = $mount_info['mount_pid']; 01456 } 01457 01458 // Set mapping information for this level: 01459 $this->MPmap[$id] = $MP_array; 01460 01461 // Normal mode: 01462 if (is_array($mount_info) && !$mount_info['overlay']) { 01463 $MP_array[] = $mount_info['MPvar']; 01464 $id = $mount_info['mount_pid']; 01465 } 01466 } 01467 01468 if ($id && $level<20) { 01469 01470 $nextLevelAcc = array(); 01471 01472 // Select and traverse current level pages: 01473 $res = $GLOBALS['TYPO3_DB']->exec_SELECTquery( 01474 'uid,pid,doktype,mount_pid,mount_pid_ol', 01475 'pages', 01476 'pid='.intval($id).' AND deleted=0 AND doktype!=255 AND doktype!=6' // 255 = Garbage bin, 6 = Backend User Section 01477 ); 01478 while ($row = $GLOBALS['TYPO3_DB']->sql_fetch_assoc($res)) { 01479 01480 // Find mount point if any: 01481 $next_id = $row['uid']; 01482 $next_MP_array = $MP_array; 01483 $mount_info = $GLOBALS['TSFE']->sys_page->getMountPointInfo($next_id, $row); 01484 01485 // Overlay mode: 01486 if (is_array($mount_info) && $mount_info['overlay']) { 01487 $next_MP_array[] = $mount_info['MPvar']; 01488 $next_id = $mount_info['mount_pid']; 01489 } 01490 01491 if (!isset($this->MPmap[$next_id])) { 01492 01493 // Set mapping information for this level: 01494 $this->MPmap[$next_id] = $next_MP_array; 01495 01496 // Normal mode: 01497 if (is_array($mount_info) && !$mount_info['overlay']) { 01498 $next_MP_array[] = $mount_info['MPvar']; 01499 $next_id = $mount_info['mount_pid']; 01500 } 01501 01502 // Register recursive call 01503 // (have to do it this way since ALL of the current level should be registered BEFORE the sublevel at any time) 01504 $nextLevelAcc[] = array($next_id,$next_MP_array); 01505 } 01506 } 01507 01508 // Call recursively, if any: 01509 foreach($nextLevelAcc as $pSet) { 01510 $this->initMPmap_create($pSet[0],$pSet[1],$level+1); 01511 } 01512 } 01513 } 01514 } 01515 01516 01517 if (defined('TYPO3_MODE') && $TYPO3_CONF_VARS[TYPO3_MODE]['XCLASS']['t3lib/class.t3lib_tstemplate.php']) { 01518 include_once($TYPO3_CONF_VARS[TYPO3_MODE]['XCLASS']['t3lib/class.t3lib_tstemplate.php']); 01519 } 01520 ?>