From bb07324f762708142f2158da1a8060f9f812c28b Mon Sep 17 00:00:00 2001 From: rvelices Date: Wed, 19 Sep 2007 03:06:16 +0000 Subject: - fix: quick search error if the query term contained " or ' - optimized sql query in sync_users (called every time on admin page) - a lot faster when #user_cache_categories is big - added function Template->delete_block_vars (opposite of assign_block_vars) git-svn-id: http://piwigo.org/svn/branches/branch-1_7@2094 68402e56-0260-453c-a942-63ccdbb3a9ee --- include/template.php | 37 +++++++++++++++++++++++++++++++++++++ 1 file changed, 37 insertions(+) (limited to 'include/template.php') diff --git a/include/template.php b/include/template.php index 0e8f626f0..7d93237e6 100644 --- a/include/template.php +++ b/include/template.php @@ -295,6 +295,43 @@ class Template { return true; } + /** + * Block-level variable deletion. Deletes the last block iteration. + * if all is true - all blocks are removed + * return true if a deletion occured + */ + function delete_block_vars($blockname, $all=false) + { + $blocks = explode('.', $blockname); + $blockcount = count($blocks); + $str = '$this->_tpldata'; + for ($i = 0; $i < $blockcount; $i++) + { + $str .= '[\'' . $blocks[$i] . '.\']'; + eval('$lastiteration = isset('.$str.') ? sizeof('.$str.')-1:-1;'); + if ($lastiteration==-1) + { + return false; + } + if ($i==$blockcount-1) + { + break; + } + $str .= '[' . $lastiteration . ']'; + } + + if ($all==true or $lastiteration==0) + { + $str ='unset('.$str.');'; + } + else + { + $str ='unset('.$str.'['.$lastiteration.']);'; + } + eval($str); + return true; + } + /** * Root-level variable assignment. Adds to current assignments, overriding * any existing variable assignment with the same name. -- cgit v1.2.3