Location: PHPKode > scripts > Ja2BU > libs/plugins/core.read_cache_file.php
<?php
/**
 * Smarty plugin
 * @package Smarty
 * @subpackage plugins
 */

/**
 * read a cache file, determine if it needs to be
 * regenerated or not
 *
 * @param string $tpl_file
 * @param string $cache_id
 * @param string $compile_id
 * @param string $results
 * @return boolean
 */    
 
//  $tpl_file, $cache_id, $compile_id, &$results
 
function smarty_core_read_cache_file(&$params, &$this)
{
    static  $content_cache = array();

    if ($this->force_compile) {
        // force compile enabled, always regenerate
        return false;
    }

    if (isset($content_cache[$params['tpl_file'].','.$params['cache_id'].','.$params['compile_id']])) {
        list($params['results'], $this->_cache_info) = $content_cache[$params['tpl_file'].','.$params['cache_id'].','.$params['compile_id']];
        return true;
    }

    if (!$this->is_cached($params['tpl_file'], $params['cache_id'], $params['compile_id'])) {
        // cache is out of date, regenerate
        return false;
    }

    if (!empty($this->cache_handler_func)) {
        // use cache_handler function
        call_user_func_array($this->cache_handler_func,
                             array('read', &$this, &$params['results'], $params['tpl_file'], $params['cache_id'], $params['compile_id']));
    } else {
        // use local cache file
        $_auto_id = $this->_get_auto_id($params['cache_id'], $params['compile_id']);
        $_cache_file = $this->_get_auto_filename($this->cache_dir, $params['tpl_file'], $_auto_id);
        $params['results'] = $this->_read_file($_cache_file);
    }

    $cache_split = explode("\n", $params['results'], 2);

    ob_start();
    if (!empty($this->cache_handler_func)) {
        eval('?>' . $cache_split[1]);
    }
    else {
        include($_cache_file);
    }
    $results = ob_get_contents();
    ob_end_clean();
    $params['results'] = $results;
    $content_cache[$params['tpl_file'].','.$params['cache_id'].','.$params['compile_id']] = array($params['results'], $this->_cache_info);

    return true;
}

/* vim: set expandtab: */

?>
Return current item: Ja2BU