5 Modification information for LGPL compliance
7 r56990 - 2010-06-16 13:05:36 -0700 (Wed, 16 Jun 2010) - kjing - snapshot "Mango" svn branch to a new one for GitHub sync
9 r56989 - 2010-06-16 13:01:33 -0700 (Wed, 16 Jun 2010) - kjing - defunt "Mango" svn dev branch before github cutover
11 r55980 - 2010-04-19 13:31:28 -0700 (Mon, 19 Apr 2010) - kjing - create Mango (6.1) based on windex
13 r51719 - 2009-10-22 10:18:00 -0700 (Thu, 22 Oct 2009) - mitani - Converted to Build 3 tags and updated the build system
15 r51634 - 2009-10-19 13:32:22 -0700 (Mon, 19 Oct 2009) - mitani - Windex is the branch for Sugar Sales 1.0 development
17 r50375 - 2009-08-24 18:07:43 -0700 (Mon, 24 Aug 2009) - dwong - branch kobe2 from tokyo r50372
19 r42807 - 2008-12-29 11:16:59 -0800 (Mon, 29 Dec 2008) - dwong - Branch from trunk/sugarcrm r42806 to branches/tokyo/sugarcrm
21 r8230 - 2005-10-03 17:47:19 -0700 (Mon, 03 Oct 2005) - majed - Added Sugar_Smarty to the code tree.
34 * read a cache file, determine if it needs to be
37 * @param string $tpl_file
38 * @param string $cache_id
39 * @param string $compile_id
40 * @param string $results
44 // $tpl_file, $cache_id, $compile_id, &$results
46 function smarty_core_read_cache_file(&$params, &$smarty)
48 static $content_cache = array();
50 if ($smarty->force_compile) {
51 // force compile enabled, always regenerate
55 if (isset($content_cache[$params['tpl_file'].','.$params['cache_id'].','.$params['compile_id']])) {
56 list($params['results'], $smarty->_cache_info) = $content_cache[$params['tpl_file'].','.$params['cache_id'].','.$params['compile_id']];
60 if (!empty($smarty->cache_handler_func)) {
61 // use cache_handler function
62 call_user_func_array($smarty->cache_handler_func,
63 array('read', &$smarty, &$params['results'], $params['tpl_file'], $params['cache_id'], $params['compile_id'], null));
65 // use local cache file
66 $_auto_id = $smarty->_get_auto_id($params['cache_id'], $params['compile_id']);
67 $_cache_file = $smarty->_get_auto_filename($smarty->cache_dir, $params['tpl_file'], $_auto_id);
68 $params['results'] = $smarty->_read_file($_cache_file);
71 if (empty($params['results'])) {
72 // nothing to parse (error?), regenerate cache
76 $_contents = $params['results'];
77 $_info_start = strpos($_contents, "\n") + 1;
78 $_info_len = (int)substr($_contents, 0, $_info_start - 1);
79 $_cache_info = unserialize(substr($_contents, $_info_start, $_info_len));
80 $params['results'] = substr($_contents, $_info_start + $_info_len);
82 if ($smarty->caching == 2 && isset ($_cache_info['expires'])){
83 // caching by expiration time
84 if ($_cache_info['expires'] > -1 && (time() > $_cache_info['expires'])) {
85 // cache expired, regenerate
89 // caching by lifetime
90 if ($smarty->cache_lifetime > -1 && (time() - $_cache_info['timestamp'] > $smarty->cache_lifetime)) {
91 // cache expired, regenerate
96 if ($smarty->compile_check) {
97 $_params = array('get_source' => false, 'quiet'=>true);
98 foreach (array_keys($_cache_info['template']) as $_template_dep) {
99 $_params['resource_name'] = $_template_dep;
100 if (!$smarty->_fetch_resource_info($_params) || $_cache_info['timestamp'] < $_params['resource_timestamp']) {
101 // template file has changed, regenerate cache
106 if (isset($_cache_info['config'])) {
107 $_params = array('resource_base_path' => $smarty->config_dir, 'get_source' => false, 'quiet'=>true);
108 foreach (array_keys($_cache_info['config']) as $_config_dep) {
109 $_params['resource_name'] = $_config_dep;
110 if (!$smarty->_fetch_resource_info($_params) || $_cache_info['timestamp'] < $_params['resource_timestamp']) {
111 // config file has changed, regenerate cache
118 $content_cache[$params['tpl_file'].','.$params['cache_id'].','.$params['compile_id']] = array($params['results'], $_cache_info);
120 $smarty->_cache_info = $_cache_info;
124 /* vim: set expandtab: */