From 1ca406366f96104fecf672f30011868a3298266d Mon Sep 17 00:00:00 2001 From: messju Date: Fri, 21 Mar 2003 15:39:29 +0000 Subject: [PATCH] renamed $localvars to $_localvars in cache-file-handling-functions, added _get_auto_id()-function --- NEWS | 2 ++ libs/Smarty.class.php | 56 +++++++++++++++++++------------------------ 2 files changed, 26 insertions(+), 32 deletions(-) diff --git a/NEWS b/NEWS index 2c611c12..23574ace 100644 --- a/NEWS +++ b/NEWS @@ -1,3 +1,5 @@ + - renamed $localvars to $_localvars in cache-file-handling-functions, + added _get_auto_id()-function (messju) - swapped compile_id and cache_id in read_cache_file and write_cache_file (messju) - reverted patch for cache-file-handling (messju) diff --git a/libs/Smarty.class.php b/libs/Smarty.class.php index a3577a3e..3c447850 100644 --- a/libs/Smarty.class.php +++ b/libs/Smarty.class.php @@ -911,18 +911,13 @@ class Smarty if (!isset($compile_id)) $compile_id = $this->compile_id; - if (isset($cache_id)) - $auto_id = (isset($compile_id)) ? $cache_id . '|' . $compile_id : $cache_id; - elseif(isset($compile_id)) - $auto_id = $compile_id; - else - $auto_id = null; + $_auto_id = $this->_get_auto_id($cache_id, $compile_id); if (!empty($this->cache_handler_func)) { - $funcname = $this->cache_handler_func; - return $funcname('clear', $this, $dummy, $tpl_file, $cache_id, $compile_id); + $_funcname = $this->cache_handler_func; + return $_funcname('clear', $this, $dummy, $tpl_file, $cache_id, $compile_id); } else { - return $this->_rm_auto($this->cache_dir, $tpl_file, $auto_id, $exp_time); + return $this->_rm_auto($this->cache_dir, $tpl_file, $_auto_id, $exp_time); } } @@ -2280,19 +2275,13 @@ class Smarty if (!empty($this->cache_handler_func)) { // use cache_handler function - $funcname = $this->cache_handler_func; - return $funcname('write', $this, $results, $tpl_file, $cache_id, $compile_id); + $_funcname = $this->cache_handler_func; + return $_funcname('write', $this, $results, $tpl_file, $cache_id, $compile_id); } else { // use local cache file - if (isset($cache_id)) - $auto_id = (isset($compile_id)) ? $cache_id . '|' . $compile_id : $cache_id; - elseif(isset($compile_id)) - $auto_id = $compile_id; - else - $auto_id = null; - - $cache_file = $this->_get_auto_filename($this->cache_dir, $tpl_file, $auto_id); - $this->_write_file($cache_file, $results, true); + $_auto_id = $this->_get_auto_id($cache_id, $compile_id); + $_cache_file = $this->_get_auto_filename($this->cache_dir, $tpl_file, $_auto_id); + $this->_write_file($_cache_file, $results, true); return true; } } @@ -2322,19 +2311,13 @@ class Smarty if (!empty($this->cache_handler_func)) { // use cache_handler function - $funcname = $this->cache_handler_func; - $funcname('read', $this, $results, $tpl_file, $cache_id, $compile_id); + $_funcname = $this->cache_handler_func; + $_funcname('read', $this, $results, $tpl_file, $cache_id, $compile_id); } else { // use local cache file - if (isset($cache_id)) - $auto_id = (isset($compile_id)) ? $cache_id . '|' . $compile_id : $cache_id; - elseif(isset($compile_id)) - $auto_id = $compile_id; - else - $auto_id = null; - - $cache_file = $this->_get_auto_filename($this->cache_dir, $tpl_file, $auto_id); - $results = $this->_read_file($cache_file); + $_auto_id = $this->_get_auto_id($cache_id, $compile_id); + $_cache_file = $this->_get_auto_filename($this->cache_dir, $tpl_file, $_auto_id); + $results = $this->_read_file($_cache_file); } if (empty($results)) { @@ -2385,7 +2368,16 @@ class Smarty return true; } - + + function _get_auto_id($cache_id=null, $compile_id=null) { + if (isset($cache_id)) + return (isset($compile_id)) ? $cache_id . '|' . $compile_id : $cache_id; + elseif(isset($compile_id)) + return $compile_id; + else + return null; + } + /** * get filepath of requested plugin *