Project

General

Profile

Bug #17627 » patch_6395__v2.diff

Administrator Admin, 2009-04-21 22:11

View differences:

t3lib/class.t3lib_tstemplate.php (Arbeitskopie)
* @see t3lib_TSparser, generateConfig()
*/
function procesIncludes() {
$files = array();
foreach ($this->constants as &$value) {
$value = t3lib_TSparser::checkIncludeLines($value);
$includeData = t3lib_TSparser::checkIncludeLines($value, 1, true);
$files = array_merge($files, $includeData['files']);
$value = $includeData['typoscript'];
}
foreach ($this->config as &$value) {
$value = t3lib_TSparser::checkIncludeLines($value);
$includeData = t3lib_TSparser::checkIncludeLines($value, 1, true);
$files = array_merge($files, $includeData['files']);
$value = $includeData['typoscript'];
}
foreach ($this->editorcfg as &$value) {
$value = t3lib_TSparser::checkIncludeLines($value);
$includeData = t3lib_TSparser::checkIncludeLines($value, 1, true);
$files = array_merge($files, $includeData['files']);
$value = $includeData['typoscript'];
}
if (count($files)) {
$files = array_unique($files);
foreach ($files as $file) {
$this->rowSum[] = Array($file, filemtime($file));
}
}
}
/**
t3lib/class.t3lib_tsparser.php (Arbeitskopie)
* @return string Complete TypoScript with includes added.
* @static
*/
function checkIncludeLines($string, $cycle_counter=1) {
function checkIncludeLines($string, $cycle_counter=1, $returnFiles=false) {
$includedFiles = array();
if ($cycle_counter>100) {
t3lib_div::sysLog('It appears like TypoScript code is looping over itself. Check your templates for "<INCLUDE_TYPOSCRIPT: ..." tags','Core',2);
if ($returnFiles) {
return array(
'typoscript' => '',
'files' => $includedFiles,
);
}
return '';
}
$splitStr='<INCLUDE_TYPOSCRIPT:';
......
if (strcmp($filename,'')) { // Must exist and must not contain '..' and must be relative
if (@is_file($filename) && filesize($filename)<100000) { // Max. 100 KB include files!
// check for includes in included text
$included_text = self::checkIncludeLines(t3lib_div::getUrl($filename),$cycle_counter+1);
$includedFiles[] = $filename;
$included_text = self::checkIncludeLines(t3lib_div::getUrl($filename),$cycle_counter+1, $returnFiles);
// If the method also has to return all included files, merge currently included
// files with files included by recursively calling itself
if ($returnFiles && is_array($included_text)) {
$includedFiles = array_merge($includedFiles, $included_text['files']);
$included_text = $included_text['typoscript'];
}
$newString.= $included_text.chr(10);
}
}
......
}
$string=substr($newString,1,-1); // not the first/last linebreak char.
}
// When all included files should get returned, simply return an compound array containing
// the TypoScript with all "includes" processed and the files which got included
if ($returnFiles) {
return array(
'typoscript' => $string,
'files' => $includedFiles,
);
}
return $string;
}
(2-2/2)