diff options
author | Paul S. Owen <psotfx@users.sourceforge.net> | 2002-08-22 21:40:51 +0000 |
---|---|---|
committer | Paul S. Owen <psotfx@users.sourceforge.net> | 2002-08-22 21:40:51 +0000 |
commit | 0226e8602ae10797786e521d9b60e2803610cca1 (patch) | |
tree | 2bc03f8aa7c7f2241de7aebbb4004c8689e0944f /phpBB/includes/template.php | |
parent | eca02e139ca7d19c4dc0e57b07350243fd99d87b (diff) | |
download | forums-0226e8602ae10797786e521d9b60e2803610cca1.tar forums-0226e8602ae10797786e521d9b60e2803610cca1.tar.gz forums-0226e8602ae10797786e521d9b60e2803610cca1.tar.bz2 forums-0226e8602ae10797786e521d9b60e2803610cca1.tar.xz forums-0226e8602ae10797786e521d9b60e2803610cca1.zip |
Instantiate template and set template path from seperate method
git-svn-id: file:///svn/phpbb/trunk@2882 89ea8834-ac86-4346-8a33-228a782c2dd0
Diffstat (limited to 'phpBB/includes/template.php')
-rw-r--r-- | phpBB/includes/template.php | 59 |
1 files changed, 27 insertions, 32 deletions
diff --git a/phpBB/includes/template.php b/phpBB/includes/template.php index b2cbfada87..70d6053517 100644 --- a/phpBB/includes/template.php +++ b/phpBB/includes/template.php @@ -20,13 +20,13 @@ ***************************************************************************/ /* - Template class. - + Template class. + Nathan Codding - Original version design and implementation Crimsonbane - Initial caching proposal and work - psoTFX - Completion of file caching, decompilation routines and implementation of + psoTFX - Completion of file caching, decompilation routines and implementation of conditionals/keywords and associated changes - + The interface was inspired by PHPLib templates, and the template file (formats are quite similar) @@ -62,14 +62,9 @@ class Template { var $include_counter = 1; var $block_nesting_level = 0; - /** - * Constructor. Simply sets the root dir. - * - */ - function Template($template = '') + function set_template($template = '') { global $phpbb_root_path; - $this->root = $phpbb_root_path . 'templates/' . $template; $this->cachedir = $phpbb_root_path . 'templates/cache/' . $template . '/'; @@ -154,7 +149,7 @@ class Template { return true; } - + /** * Destroys this template object. Should be called when you're done with it, in order * to clear out the template data so you can load/parse a new template set. @@ -178,7 +173,7 @@ class Template { { $_str = ''; - if ( !($this->compile_load($_str, $handle, true)) ) + if ( !($this->compile_load($_str, $handle, true)) ) { if ( !$this->loadfile($handle) ) { @@ -209,7 +204,7 @@ class Template { { $_str = ''; - if ( !($this->compile_load($_str, $handle, false)) ) + if ( !($this->compile_load($_str, $handle, false)) ) { if ( !$this->loadfile($handle) ) { @@ -237,7 +232,7 @@ class Template { $this->files[$handle] = $this->make_filename($filename); $_str = ''; - if ( !($this->compile_load($_str, $handle, false)) ) + if ( !($this->compile_load($_str, $handle, false)) ) { if ( !$this->loadfile($handle) ) { @@ -275,7 +270,7 @@ class Template { return true; } - + /** * Block-level variable assignment. Adds a new block iteration with the given * variable assignments. Note that this should only be called once per block @@ -355,7 +350,7 @@ class Template { $compile_blocks[] = "// BEGINELSE\n}} else {\n"; break; case 'END': - $compile_blocks[] = ( ( array_pop($this->block_else_level) ) ? "}\n" : "}}\n" ) . '// END ' . array_pop($this->block_names) . "\n"; + $compile_blocks[] = ( ( array_pop($this->block_else_level) ) ? "}\n" : "}}\n" ) . '// END ' . array_pop($this->block_names) . "\n"; break; case 'IF': $compile_blocks[] = '// IF ' . $blocks[2][$curr_tb] . "\n" . $this->compile_tag_if($blocks[2][$curr_tb], false); @@ -378,7 +373,7 @@ class Template { case 'PHP': $temp = ''; 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; default: $this->compile_var_tags($blocks[0][$curr_tb]); @@ -467,9 +462,9 @@ class Template { { /* Tokenize args for 'if' tag. */ preg_match_all('/(?: - "[^"\\\\]*(?:\\\\.[^"\\\\]*)*" | - \'[^\'\\\\]*(?:\\\\.[^\'\\\\]*)*\' | - [(),] | + "[^"\\\\]*(?:\\\\.[^"\\\\]*)*" | + \'[^\'\\\\]*(?:\\\\.[^\'\\\\]*)*\' | + [(),] | [^\s(),]+)/x', $tag_args, $match); $tokens = $match[0]; @@ -546,7 +541,7 @@ class Template { break; } } - + return ( ( $elseif ) ? '} elseif (' : 'if (' ) . ( implode(' ', $tokens) . ') { ' . "\n" ); } @@ -562,7 +557,7 @@ class Template { // // This is from Smarty - // + // function _parse_is_expr($is_arg, $tokens) { $expr_end = 0; @@ -755,7 +750,7 @@ class Template { } closedir($dp); } - + return; } @@ -774,7 +769,7 @@ class Template { } } closedir($dp); - + return; } @@ -783,12 +778,12 @@ class Template { $match_tags = array( "#(<\?php\nif \( .?this\->security\(\) \) \{\n)|(\n\}\n\?".">)#", - "#echo '(.*?)';#s", - "#\/\/ (INCLUDEPHP .*?)\n.?this\->assign_from_include_php\('.*?'\);\n#s", - "#\/\/ (INCLUDE .*?)\n.?this\->assign_from_include\('.*?'\);\n#s", + "#echo '(.*?)';#s", + "#\/\/ (INCLUDEPHP .*?)\n.?this\->assign_from_include_php\('.*?'\);\n#s", + "#\/\/ (INCLUDE .*?)\n.?this\->assign_from_include\('.*?'\);\n#s", "#\/\/ (IF .*?)\nif \(.*?\) \{[ ]?\n#", "#\/\/ (ELSEIF .*?)\n\} elseif \(.*?\) \{[ ]?\n#", - "#\/\/ (ELSE)\n\} else \{\n#", + "#\/\/ (ELSE)\n\} else \{\n#", "#\/\/ (ENDIF)\n}\n#", "#\/\/ (BEGIN .*?)\n.?_.*? = \(.*?\) : 0;\nif \(.*?\) \{\nfor \(.*?\)\n\{\n#", "#\}\}?\n\/\/ (END .*?)\n#", @@ -800,9 +795,9 @@ class Template { ); $replace_tags = array( - '', - "\\1", - "\\1", + '', + "\\1", + "\\1", "<!-- \\1 -->", "<!-- \\1 -->", "<!-- \\1 -->", @@ -811,7 +806,7 @@ class Template { "<!-- \\1 -->", "<!-- \\1 -->", "<!-- \\1 -->", - "{\\1}", + "{\\1}", "{\\1\\2}", "{\\1\\2\\3}", "{\\1\\2\\3\\4}" |