From cc01941ed97f6c8f6790931bfc167ba45c5a8f91 Mon Sep 17 00:00:00 2001 From: rvelices Date: Tue, 17 Jan 2012 21:58:18 +0000 Subject: feature 2548 multisize - code cleanup + better usage in category_cats + i.php logs memory usage peak git-svn-id: http://piwigo.org/svn/trunk@12920 68402e56-0260-453c-a942-63ccdbb3a9ee --- include/template.class.php | 26 ++++++++++++++++++++------ 1 file changed, 20 insertions(+), 6 deletions(-) (limited to 'include/template.class.php') diff --git a/include/template.class.php b/include/template.class.php index 7bcab1150..90d7d58b8 100644 --- a/include/template.class.php +++ b/include/template.class.php @@ -22,9 +22,6 @@ // +-----------------------------------------------------------------------+ -require_once(PHPWG_ROOT_PATH.'include/smarty/libs/Smarty.class.php'); - - class Template { var $smarty; @@ -42,6 +39,7 @@ class Template { // used by html_head smarty block to add content before var $html_head_elements = array(); + private $html_style = ''; const COMBINED_SCRIPTS_TAG = ''; var $scriptLoader; @@ -112,6 +110,7 @@ class Template { $this->smarty->register_modifier( 'explode', array('Template', 'mod_explode') ); $this->smarty->register_modifier( 'get_extent', array(&$this, 'get_extent') ); $this->smarty->register_block('html_head', array(&$this, 'block_html_head') ); + $this->smarty->register_block('html_style', array(&$this, 'block_html_style') ); $this->smarty->register_function('combine_script', array(&$this, 'func_combine_script') ); $this->smarty->register_function('get_combined_scripts', array(&$this, 'func_get_combined_scripts') ); $this->smarty->register_function('combine_css', array(&$this, 'func_combine_css') ); @@ -466,15 +465,21 @@ class Template { $this->css_by_priority = array(); } - if ( count($this->html_head_elements) ) + if ( count($this->html_head_elements) || strlen($this->html_style) ) { $search = "\n"; $pos = strpos( $this->output, $search ); if ($pos !== false) { - $this->output = substr_replace( $this->output, "\n".implode( "\n", $this->html_head_elements ), $pos, 0 ); + $rep = "\n".implode( "\n", $this->html_head_elements ); + if (strlen($this->html_style)) + { + $rep=''; + } + $this->output = substr_replace( $this->output, $rep, $pos, 0 ); } //else maybe error or warning ? $this->html_head_elements = array(); + $this->html_style = ''; } echo $this->output; @@ -532,6 +537,15 @@ class Template { } } + function block_html_style($params, $content, &$smarty, &$repeat) + { + $content = trim($content); + if ( !empty($content) ) + { // second call + $this->html_style .= $content; + } + } + /** * combine_script smarty function allows inclusion of a javascript file in the current page. * The engine will combine several js files into a single one in order to reduce the number of @@ -842,7 +856,7 @@ class PwgTemplateAdapter $args = func_get_args(); return call_user_func_array('sprintf', $args ); } - + function derivative_url($type, $img) { return DerivativeImage::url($type, $img); -- cgit v1.2.3