mirror of
https://github.com/phpbb/phpbb.git
synced 2025-06-04 05:25:01 +02:00
Try this version of include ...
git-svn-id: file:///svn/phpbb/trunk@3810 89ea8834-ac86-4346-8a33-228a782c2dd0
This commit is contained in:
parent
a702dc6683
commit
9c8c50cdb7
@ -243,27 +243,10 @@ class Template {
|
|||||||
$this->compiled_code[$handle] = $this->compile($this->uncompiled_code[$handle]);
|
$this->compiled_code[$handle] = $this->compile($this->uncompiled_code[$handle]);
|
||||||
$this->compile_write($handle, $this->compiled_code[$handle]);
|
$this->compile_write($handle, $this->compiled_code[$handle]);
|
||||||
|
|
||||||
eval($this->compiled_code[$handle]);
|
return $handle;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function merge_from_include($filename)
|
|
||||||
{
|
|
||||||
$handle = 'include_' . $this->include_counter++;
|
|
||||||
|
|
||||||
$this->filename[$handle] = $filename;
|
|
||||||
$this->files[$handle] = $this->make_filename($filename);
|
|
||||||
|
|
||||||
if (!file_exists($this->files[$handle]))
|
|
||||||
{
|
|
||||||
trigger_error("Template->pparse(): Couldn't load template file for handle $handle", E_USER_ERROR);
|
|
||||||
}
|
|
||||||
|
|
||||||
$content = implode('', @file($this->files[$handle]));
|
|
||||||
|
|
||||||
return ($content);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Root-level variable assignment. Adds to current assignments, overriding
|
* Root-level variable assignment. Adds to current assignments, overriding
|
||||||
* any existing variable assignment with the same name.
|
* any existing variable assignment with the same name.
|
||||||
@ -340,20 +323,16 @@ class Template {
|
|||||||
*/
|
*/
|
||||||
function compile($code, $do_not_echo = false, $retvar = '')
|
function compile($code, $do_not_echo = false, $retvar = '')
|
||||||
{
|
{
|
||||||
// Pull out all merging includes, to let them parse with the code
|
|
||||||
preg_match_all('#<!-- MERGE_INCLUDE(.*?)-->#s', $code, $matches);
|
|
||||||
$merge_blocks = $matches[1];
|
|
||||||
foreach($merge_blocks as $filename)
|
|
||||||
{
|
|
||||||
$code = preg_replace('#<!-- MERGE_INCLUDE ' . preg_quote(trim($filename)) . ' -->#s', $this->merge_from_include(trim($filename)), $code);
|
|
||||||
}
|
|
||||||
|
|
||||||
// Pull out all block/statement level elements and seperate
|
// Pull out all block/statement level elements and seperate
|
||||||
// plain text
|
// plain text
|
||||||
preg_match_all('#<!-- PHP -->(.*?)<!-- ENDPHP -->#s', $code, $matches);
|
preg_match_all('#<!-- PHP -->(.*?)<!-- ENDPHP -->#s', $code, $matches);
|
||||||
$php_blocks = $matches[1];
|
$php_blocks = $matches[1];
|
||||||
$code = preg_replace('#<!-- PHP -->(.*?)<!-- ENDPHP -->#s', '<!-- PHP -->', $code);
|
$code = preg_replace('#<!-- PHP -->(.*?)<!-- ENDPHP -->#s', '<!-- PHP -->', $code);
|
||||||
|
|
||||||
|
preg_match_all('#<!-- INCLUDE (.*?) -->#s', $code, $matches);
|
||||||
|
$include_blocks = $matches[1];
|
||||||
|
$code = preg_replace('#<!-- INCLUDE (.*?) -->#s', '<!-- INCLUDE -->', $code);
|
||||||
|
|
||||||
preg_match_all('#<!-- (.*?) (.*?)?[ ]?-->#s', $code, $blocks);
|
preg_match_all('#<!-- (.*?) (.*?)?[ ]?-->#s', $code, $blocks);
|
||||||
$text_blocks = preg_split('#<!-- (.*?) (.*?)?[ ]?-->#s', $code);
|
$text_blocks = preg_split('#<!-- (.*?) (.*?)?[ ]?-->#s', $code);
|
||||||
for($i = 0; $i < count($text_blocks); $i++)
|
for($i = 0; $i < count($text_blocks); $i++)
|
||||||
@ -391,16 +370,19 @@ class Template {
|
|||||||
$compile_blocks[] = "// ENDIF\n}\n";
|
$compile_blocks[] = "// ENDIF\n}\n";
|
||||||
break;
|
break;
|
||||||
case 'INCLUDE':
|
case 'INCLUDE':
|
||||||
$compile_blocks[] = '// INCLUDE ' . $blocks[2][$curr_tb] . "\n" . $this->compile_tag_include($blocks[2][$curr_tb]);
|
$temp = '';
|
||||||
|
list(, $temp) = each($include_blocks);
|
||||||
|
$compile_blocks[] = "// INCLUDE $temp\ninclude('" . $this->cachedir . $temp . ".' . \$phpEx);\n";
|
||||||
|
$this->assign_from_include($temp);
|
||||||
break;
|
break;
|
||||||
case 'INCLUDEPHP':
|
/* case 'INCLUDEPHP':
|
||||||
$compile_blocks[] = '// INCLUDEPHP ' . $blocks[2][$curr_tb] . "\n" . $this->compile_tag_include_php($blocks[2][$curr_tb]);
|
$compile_blocks[] = '// INCLUDEPHP ' . $blocks[2][$curr_tb] . "\n" . $this->compile_tag_include_php($blocks[2][$curr_tb]);
|
||||||
break;
|
break;
|
||||||
case 'PHP':
|
case 'PHP':
|
||||||
$temp = '';
|
$temp = '';
|
||||||
list(, $temp) = each($php_blocks);
|
list(, $temp) = each($php_blocks);
|
||||||
$compile_blocks[] = "// PHP START\n" . $temp . "\n// PHP END\n";
|
$compile_blocks[] = "// PHP START\n" . $temp . "\n// PHP END\n";
|
||||||
break;
|
break;*/
|
||||||
default:
|
default:
|
||||||
$this->compile_var_tags($blocks[0][$curr_tb]);
|
$this->compile_var_tags($blocks[0][$curr_tb]);
|
||||||
$trim_check = trim($blocks[0][$curr_tb]);
|
$trim_check = trim($blocks[0][$curr_tb]);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user