From 35076ee1b9e32618d3c92bdd8aee20f2c4abb694 Mon Sep 17 00:00:00 2001 From: rvelices Date: Sat, 1 Mar 2008 13:12:07 +0000 Subject: - index.tpl, menubar.tpl, mainpage_categories.tpl and month_calendar.tpl go smarty - better template debugging tweak (the smarty console is shown only once at the end) git-svn-id: http://piwigo.org/svn/trunk@2231 68402e56-0260-453c-a942-63ccdbb3a9ee --- include/template.class.php | 64 ++++++++++++++++++++++++++++------------------ 1 file changed, 39 insertions(+), 25 deletions(-) (limited to 'include/template.class.php') diff --git a/include/template.class.php b/include/template.class.php index da4b69034..1afdb655c 100644 --- a/include/template.class.php +++ b/include/template.class.php @@ -222,21 +222,6 @@ class Template { * is true. */ function parse($handle, $return=false) - { - return $this->_pparse_or_parse($handle, $return, false); - } - - /** - * Load the file for the handle, eventually compile the file and run the compiled - * code. This will print out the results of executing the template. - */ - function pparse($handle) - { - $this->_pparse_or_parse($handle, false, true); - } - - - /*private*/ function _pparse_or_parse($handle, $return, $immediate_display) { if ( !isset($this->files[$handle]) ) { @@ -253,31 +238,54 @@ class Template { if ($is_new) { - $this->smarty->assign( 'pwg_root', get_root_url() ); //deprecated $this->smarty->assign( 'ROOT_URL', get_root_url() ); - if ($immediate_display) - $this->p(); - $v = $this->smarty->fetch($this->files[$handle], null, null, $immediate_display ? true : false); - if ($immediate_display) - return; + $v = $this->smarty->fetch($this->files[$handle], null, null, false); } else { $this->_old->set_filename( $handle, $this->files[$handle] ); $v = $this->_old->parse($handle, true); } - if ($return==false) + if ($return) { - $this->output .= $v; + return $v; } - return $v; + $this->output .= $v; } - /** flushes current output */ + /** + * Load the file for the handle, eventually compile the file and run the compiled + * code. This will print out the results of executing the template. + */ + function pparse($handle) + { + $this->parse($handle, false); + echo $this->output; + $this->output=''; + + } + + + /** flushes the output */ function p() { + $start = get_moment(); + echo $this->output; $this->output=''; + + if ($this->smarty->debugging) + { + global $t2; + $this->smarty->assign( + array( + 'AAAA_DEBUG_OUTPUT_TIME__' => get_elapsed_time($start, get_moment()), + 'AAAA_DEBUG_TOTAL_TIME__' => get_elapsed_time($t2, get_moment()) + ) + ); + require_once(SMARTY_CORE_DIR . 'core.display_debug_console.php'); + echo smarty_core_display_debug_console(null, $this->smarty); + } } /** @@ -315,6 +323,12 @@ class Template { $this->smarty->append( $tpl_var, $value, $merge ); } + /** see smarty get_template_vars http://www.smarty.net/manual/en/api.get_template_vars.php */ + function &get_template_vars($name=null) + { + return $this->smarty->get_template_vars( $name ); + } + /** see smarty append http://www.smarty.net/manual/en/api.clear_assign.php */ function clear_assign($tpl_var) { -- cgit v1.2.3