Project

General

Profile

Feature #17527 » bug_6138.diff

Administrator Admin, 2007-08-13 23:37

View differences:

t3lib/class.t3lib_tsparser.php (Arbeitskopie)
* Use: t3lib_TSparser::checkIncludeLines()
*
* @param string Unparsed TypoScript
* @param integer Counter for detecting endless loops
* @return string Complete TypoScript with includes added.
*/
function checkIncludeLines($string) {
function checkIncludeLines($string, $cycle_counter=1) {
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);
return '';
}
$splitStr='<INCLUDE_TYPOSCRIPT:';
if (strstr($string,$splitStr)) {
$newString='';
......
$filename = t3lib_div::getFileAbsFileName(trim($sourceParts[1]));
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!
$newString.=t3lib_div::getUrl($filename).chr(10);
// check for includes in included text
$included_text = t3lib_TSparser::checkIncludeLines(t3lib_div::getUrl($filename),$cycle_counter+1);
$newString.= $included_text.chr(10);
}
}
break;
t3lib/class.t3lib_tsparser_ext.php (Arbeitskopie)
}
if ($this->ext_regComments && isset($arr[$key.'..'])) {
$comment = $arr[$key.'..'];
$comment = preg_replace('/[\r\n]/', ' ', $comment); // Remove linebreaks, replace with " "
$comment = preg_replace('/[#\*]{2,}/', '', $comment); // Remove # and * if more than twice in a row
$comment = preg_replace('/^[#\*\s]+/', '# ', $comment); // Replace leading # (just if it exists) and add it again. Result: Every comment should be prefixed by a "#".
$HTML.= ' <span class="comment">'.trim($comment).'</span>';
if (!preg_match('/### <INCLUDE_TYPOSCRIPT:.*/', $comment)) { // Skip INCLUDE_TYPOSCRIPT comments, they are almost useless
$comment = preg_replace('/[\r\n]/', ' ', $comment); // Remove linebreaks, replace with " "
$comment = preg_replace('/[#\*]{2,}/', '', $comment); // Remove # and * if more than twice in a row
$comment = preg_replace('/^[#\*\s]+/', '# ', $comment); // Replace leading # (just if it exists) and add it again. Result: Every comment should be prefixed by a "#".
$HTML.= ' <span class="comment">'.trim($comment).'</span>';
}
}
}
$HTML.="<br />";
(2-2/2)