PHP Classes
elePHPant
Icontem

File: smarty/block.cache.php

Recommend this page to a friend!
Stumble It! Stumble It! Bookmark in del.icio.us Bookmark in del.icio.us
  Classes of n/a  >  Cache output and objects  >  smarty/block.cache.php  >  Download  
File: smarty/block.cache.php
Role: Auxiliary script
Content type: text/plain
Description: Smarty plugin
Class: Cache output and objects
Cache the output of PHP scripts in files
Author: By
Last change:
Date: 7 years ago
Size: 758 bytes
 

Contents

Class file image Download
<?php

function smarty_block_cache($params, $content, &$smarty, &$repeat)
{
   
    if(
$content===null)
    {
        if(!isset(
$smarty->cache)) trigger_error("smarty_block_cache error: \$smarty->cache object not set!", E_USER_ERROR);
        if(!isset(
$params['file'])) trigger_error("smarty_block_cache error: parameter 'file' not specified!", E_USER_ERROR);
        if(!isset(
$params['time'])) trigger_error("smarty_block_cache error: parameter 'time' not specified!", E_USER_ERROR);
       
       
ob_start();
           
$finish = !$smarty->cache->save($params['file'],$params['time']);
       
$r = ob_get_contents();
       
ob_end_clean();
       
        if(
$finish)
        {
           
$repeat=false;
            echo(
$r);
        }
   
    }
    else
    {
        echo
$content;
       
$smarty->cache->save($params['file'],$params['time']);
    }

    return
"";

}

?>