* 413: function getVal($string,$setup)
* 439: function setVal($string,&$setup,$value,$wipeOut=0)
* 485: function error($err,$num=2)
- * 497: function checkIncludeLines($string)
+ * 497: function checkIncludeLines($string, $cycle_counter=1, $returnFiles=false)
* 541: function checkIncludeLines_array($array)
*
* SECTION: Syntax highlighting
*
* @param string Unparsed TypoScript
* @param integer Counter for detecting endless loops
+ * @param boolean When set an array containing the resulting typoscript and all included files will get returned
* @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);
}
}
} else $newString.=$splitStr.$v;
}
$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;
}
include_once($TYPO3_CONF_VARS[TYPO3_MODE]['XCLASS']['t3lib/class.t3lib_tsparser.php']);
}
-?>
\ No newline at end of file
+?>
* @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));
+ }
}
}