23 static $content_cache = array();
25 if ($smarty->force_compile) {
30 if (isset($content_cache[$params[
'tpl_file'].
','.$params[
'cache_id'].
','.$params[
'compile_id']])) {
31 list($params[
'results'], $smarty->_cache_info) = $content_cache[$params[
'tpl_file'].
','.$params[
'cache_id'].
','.$params[
'compile_id']];
35 if (!empty($smarty->cache_handler_func)) {
37 call_user_func_array($smarty->cache_handler_func,
38 array(
'read', &$smarty, &$params[
'results'], $params[
'tpl_file'], $params[
'cache_id'], $params[
'compile_id'], null));
41 $_auto_id = $smarty->_get_auto_id($params[
'cache_id'], $params[
'compile_id']);
42 $_cache_file = $smarty->_get_auto_filename($smarty->cache_dir, $params[
'tpl_file'], $_auto_id);
43 $params[
'results'] = $smarty->_read_file($_cache_file);
46 if (empty($params[
'results'])) {
51 $_contents = $params[
'results'];
52 $_info_start = strpos($_contents,
"\n") + 1;
53 $_info_len = (int)substr($_contents, 0, $_info_start - 1);
54 $_cache_info = unserialize(substr($_contents, $_info_start, $_info_len));
55 $params[
'results'] = substr($_contents, $_info_start + $_info_len);
57 if ($smarty->caching == 2 && isset ($_cache_info[
'expires'])){
59 if ($_cache_info[
'expires'] > -1 && (time() > $_cache_info[
'expires'])) {
65 if ($smarty->cache_lifetime > -1 && (time() - $_cache_info[
'timestamp'] > $smarty->cache_lifetime)) {
71 if ($smarty->compile_check) {
72 $_params = array(
'get_source' =>
false,
'quiet'=>
true);
73 foreach (array_keys($_cache_info[
'template']) as $_template_dep) {
74 $_params[
'resource_name'] = $_template_dep;
75 if (!$smarty->_fetch_resource_info($_params) || $_cache_info[
'timestamp'] < $_params[
'resource_timestamp']) {
81 if (isset($_cache_info[
'config'])) {
82 $_params = array(
'resource_base_path' => $smarty->config_dir,
'get_source' =>
false,
'quiet'=>
true);
83 foreach (array_keys($_cache_info[
'config']) as $_config_dep) {
84 $_params[
'resource_name'] = $_config_dep;
85 if (!$smarty->_fetch_resource_info($_params) || $_cache_info[
'timestamp'] < $_params[
'resource_timestamp']) {
93 $content_cache[$params[
'tpl_file'].
','.$params[
'cache_id'].
','.$params[
'compile_id']] = array($params[
'results'], $_cache_info);
95 $smarty->_cache_info = $_cache_info;