From 9c8c50cdb735f5555ee8a647b9a87603d9ffc0d2 Mon Sep 17 00:00:00 2001 From: "Paul S. Owen" Date: Thu, 10 Apr 2003 23:58:30 +0000 Subject: [PATCH] Try this version of include ... git-svn-id: file:///svn/phpbb/trunk@3810 89ea8834-ac86-4346-8a33-228a782c2dd0 --- phpBB/includes/template.php | 40 ++++++++++--------------------------- 1 file changed, 11 insertions(+), 29 deletions(-) diff --git a/phpBB/includes/template.php b/phpBB/includes/template.php index 079a40c0fe..c016c2740e 100644 --- a/phpBB/includes/template.php +++ b/phpBB/includes/template.php @@ -243,27 +243,10 @@ class Template { $this->compiled_code[$handle] = $this->compile($this->uncompiled_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 * any existing variable assignment with the same name. @@ -340,20 +323,16 @@ class Template { */ function compile($code, $do_not_echo = false, $retvar = '') { - // Pull out all merging includes, to let them parse with the code - preg_match_all('##s', $code, $matches); - $merge_blocks = $matches[1]; - foreach($merge_blocks as $filename) - { - $code = preg_replace('##s', $this->merge_from_include(trim($filename)), $code); - } - // Pull out all block/statement level elements and seperate // plain text preg_match_all('#(.*?)#s', $code, $matches); $php_blocks = $matches[1]; $code = preg_replace('#(.*?)#s', '', $code); + preg_match_all('##s', $code, $matches); + $include_blocks = $matches[1]; + $code = preg_replace('##s', '', $code); + preg_match_all('##s', $code, $blocks); $text_blocks = preg_split('##s', $code); for($i = 0; $i < count($text_blocks); $i++) @@ -391,16 +370,19 @@ class Template { $compile_blocks[] = "// ENDIF\n}\n"; break; 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; - case 'INCLUDEPHP': +/* case 'INCLUDEPHP': $compile_blocks[] = '// INCLUDEPHP ' . $blocks[2][$curr_tb] . "\n" . $this->compile_tag_include_php($blocks[2][$curr_tb]); break; case 'PHP': $temp = ''; list(, $temp) = each($php_blocks); $compile_blocks[] = "// PHP START\n" . $temp . "\n// PHP END\n"; - break; + break;*/ default: $this->compile_var_tags($blocks[0][$curr_tb]); $trim_check = trim($blocks[0][$curr_tb]);