mirror of
https://github.com/smarty-php/smarty.git
synced 2025-08-04 18:34:27 +02:00
update cache_lifetime logic: -1 = never expire, 0 = always expire
This commit is contained in:
@@ -95,7 +95,8 @@ class Smarty
|
|||||||
var $caching = false; // enable caching. true/false default false.
|
var $caching = false; // enable caching. true/false default false.
|
||||||
var $cache_dir = 'cache'; // name of directory for template cache files
|
var $cache_dir = 'cache'; // name of directory for template cache files
|
||||||
var $cache_lifetime = 3600; // number of seconds cached content will persist.
|
var $cache_lifetime = 3600; // number of seconds cached content will persist.
|
||||||
// 0 = never expires. default is one hour (3600)
|
// 0 = always regenerate cache,
|
||||||
|
// -1 = never expires. default is one hour (3600)
|
||||||
var $cache_handler_func = null; // function used for cached content. this is
|
var $cache_handler_func = null; // function used for cached content. this is
|
||||||
// an alternative to using the built-in file
|
// an alternative to using the built-in file
|
||||||
// based caching.
|
// based caching.
|
||||||
@@ -1478,7 +1479,7 @@ function _run_insert_handler($args)
|
|||||||
|
|
||||||
$this->_cache_info = unserialize($cache_header);
|
$this->_cache_info = unserialize($cache_header);
|
||||||
|
|
||||||
if ($this->cache_lifetime < 0 && (time() - $this->_cache_info['timestamp'] > $this->cache_lifetime)) {
|
if ($this->cache_lifetime > -1 && (time() - $this->_cache_info['timestamp'] > $this->cache_lifetime)) {
|
||||||
// cache expired, regenerate
|
// cache expired, regenerate
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
@@ -95,7 +95,8 @@ class Smarty
|
|||||||
var $caching = false; // enable caching. true/false default false.
|
var $caching = false; // enable caching. true/false default false.
|
||||||
var $cache_dir = 'cache'; // name of directory for template cache files
|
var $cache_dir = 'cache'; // name of directory for template cache files
|
||||||
var $cache_lifetime = 3600; // number of seconds cached content will persist.
|
var $cache_lifetime = 3600; // number of seconds cached content will persist.
|
||||||
// 0 = never expires. default is one hour (3600)
|
// 0 = always regenerate cache,
|
||||||
|
// -1 = never expires. default is one hour (3600)
|
||||||
var $cache_handler_func = null; // function used for cached content. this is
|
var $cache_handler_func = null; // function used for cached content. this is
|
||||||
// an alternative to using the built-in file
|
// an alternative to using the built-in file
|
||||||
// based caching.
|
// based caching.
|
||||||
@@ -1478,7 +1479,7 @@ function _run_insert_handler($args)
|
|||||||
|
|
||||||
$this->_cache_info = unserialize($cache_header);
|
$this->_cache_info = unserialize($cache_header);
|
||||||
|
|
||||||
if ($this->cache_lifetime < 0 && (time() - $this->_cache_info['timestamp'] > $this->cache_lifetime)) {
|
if ($this->cache_lifetime > -1 && (time() - $this->_cache_info['timestamp'] > $this->cache_lifetime)) {
|
||||||
// cache expired, regenerate
|
// cache expired, regenerate
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
@@ -8,12 +8,12 @@
|
|||||||
* Purpose: strip html tags from text
|
* Purpose: strip html tags from text
|
||||||
* -------------------------------------------------------------
|
* -------------------------------------------------------------
|
||||||
*/
|
*/
|
||||||
function smarty_modifier_strip_tags($string, $replace_with_space = true)
|
function smarty_modifier_strip_tags($string, $replace_with_space = true, $allowed = "<i><b><br>")
|
||||||
{
|
{
|
||||||
if ($replace_with_space)
|
if ($replace_with_space)
|
||||||
return preg_replace('!<[^>]*?>!', ' ', $string);
|
return preg_replace('!<[^>]*?>!', ' ', $string);
|
||||||
else
|
else
|
||||||
return strip_tags($string);
|
return strip_tags($string, $allowed);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* vim: set expandtab: */
|
/* vim: set expandtab: */
|
||||||
|
@@ -8,12 +8,12 @@
|
|||||||
* Purpose: strip html tags from text
|
* Purpose: strip html tags from text
|
||||||
* -------------------------------------------------------------
|
* -------------------------------------------------------------
|
||||||
*/
|
*/
|
||||||
function smarty_modifier_strip_tags($string, $replace_with_space = true)
|
function smarty_modifier_strip_tags($string, $replace_with_space = true, $allowed = "<i><b><br>")
|
||||||
{
|
{
|
||||||
if ($replace_with_space)
|
if ($replace_with_space)
|
||||||
return preg_replace('!<[^>]*?>!', ' ', $string);
|
return preg_replace('!<[^>]*?>!', ' ', $string);
|
||||||
else
|
else
|
||||||
return strip_tags($string);
|
return strip_tags($string, $allowed);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* vim: set expandtab: */
|
/* vim: set expandtab: */
|
||||||
|
Reference in New Issue
Block a user