Cmscout1.00rc2 > Includes / Internals / Core.write Cache File.php

Questions? Need Help? Want to share? » PHP Forum
Script Name:
Cmscout1.00rc2

Download:
cmscout1.00rc2.zip

Category:
Content Management

Archive Content:

Content:

Admin

Content:

Avatars

Cache

Calendar

Calendar > Lang

Content:

Docs

Content:

Downloads

Content:

Forums

Content:

Images

Includes

Includes > Internals

Includes > Plugins

Includes

Content:

Install

Install > Templates C

Install

Content:

Photos

Pm

Content:

Sidebox

Content:

Templates > Admin

Templates > Admin > Images

Templates > Admin

Templates > CMScout

Templates > CMScout > Images

Templates > CMScout

Templates

Templates C

Content:

Tiny Mce

Tiny Mce > Langs

Tiny Mce > Plugins > Advhr

Tiny Mce > Plugins > Advhr > Images

Tiny Mce > Plugins > Advhr > Jscripts

Tiny Mce > Plugins > Advhr > Langs

Tiny Mce > Plugins > Advhr

Tiny Mce > Plugins > Advimage > Css

Tiny Mce > Plugins > Advimage

Tiny Mce > Plugins > Advimage > Images

Tiny Mce > Plugins > Advimage > Jscripts

Tiny Mce > Plugins > Advimage > Langs

Tiny Mce > Plugins > Advlink > Css

Tiny Mce > Plugins > Advlink

Tiny Mce > Plugins > Advlink > Jscripts

Tiny Mce > Plugins > Advlink > Langs

Tiny Mce > Plugins > Advlink

Tiny Mce > Plugins > Autosave

Tiny Mce > Plugins > Autosave > Langs

Tiny Mce > Plugins > Contextmenu > Css

Tiny Mce > Plugins > Contextmenu

Tiny Mce > Plugins > Contextmenu > Images

Tiny Mce > Plugins > Directionality

Tiny Mce > Plugins > Directionality > Images

Tiny Mce > Plugins > Directionality > Langs

Tiny Mce > Plugins > Emotions

Tiny Mce > Plugins > Emotions > Images

Tiny Mce > Plugins > Emotions > Jscripts

Tiny Mce > Plugins > Emotions > Langs

Tiny Mce > Plugins > Fullscreen

Tiny Mce > Plugins > Fullscreen > Images

Tiny Mce > Plugins > Fullscreen > Langs

Tiny Mce > Plugins > Ibrowser > Config

Tiny Mce > Plugins > Ibrowser > Css

Tiny Mce > Plugins > Ibrowser

Tiny Mce > Plugins > Ibrowser > Images

Tiny Mce > Plugins > Ibrowser

Tiny Mce > Plugins > Ibrowser > Interface

Tiny Mce > Plugins > Ibrowser > Interface > Images > TinyMCE

Tiny Mce > Plugins > Ibrowser > Interface

Tiny Mce > Plugins > Ibrowser > Langs

Tiny Mce > Plugins > Ibrowser > Scripts

Tiny Mce > Plugins > Ibrowser > Scripts > PhpThumb > Cache

Tiny Mce > Plugins > Ibrowser > Scripts > PhpThumb > Cache > Source

Tiny Mce > Plugins > Ibrowser > Scripts > PhpThumb > Demo

Tiny Mce > Plugins > Ibrowser > Scripts > PhpThumb > Docs

Tiny Mce > Plugins > Ibrowser > Scripts > PhpThumb > Fonts

Tiny Mce > Plugins > Ibrowser > Scripts > PhpThumb

Tiny Mce > Plugins > Ibrowser > Scripts

Tiny Mce > Plugins > Ibrowser > Temp

Tiny Mce > Plugins

Tiny Mce > Plugins > Inlinepopups > Css

Tiny Mce > Plugins > Inlinepopups

Tiny Mce > Plugins > Inlinepopups > Images

Tiny Mce > Plugins > Inlinepopups > Jscripts

Tiny Mce > Plugins > Insertdatetime

Tiny Mce > Plugins > Insertdatetime > Images

Tiny Mce > Plugins > Insertdatetime > Langs

Tiny Mce > Plugins > Paste

Tiny Mce > Plugins > Paste > Css

Tiny Mce > Plugins > Paste

Tiny Mce > Plugins > Paste > Images

Tiny Mce > Plugins > Paste > Jscripts

Tiny Mce > Plugins > Paste > Langs

Tiny Mce > Plugins > Paste

Tiny Mce > Plugins > Preview

Tiny Mce > Plugins > Preview > Images

Tiny Mce > Plugins > Preview > Langs

Tiny Mce > Plugins > Print

Tiny Mce > Plugins > Print > Images

Tiny Mce > Plugins > Print > Langs

Tiny Mce > Plugins > Searchreplace

Tiny Mce > Plugins > Searchreplace > Images

Tiny Mce > Plugins > Searchreplace > Jscripts

Tiny Mce > Plugins > Searchreplace > Langs

Tiny Mce > Plugins > Searchreplace

Tiny Mce > Plugins > Table

Tiny Mce > Plugins > Table > Css

Tiny Mce > Plugins > Table

Tiny Mce > Plugins > Table > Images

Tiny Mce > Plugins > Table > Jscripts

Tiny Mce > Plugins > Table > Langs

Tiny Mce > Plugins > Table

Tiny Mce > Themes > Advanced

Tiny Mce > Themes > Advanced > Css

Tiny Mce > Themes > Advanced > Docs > En

Tiny Mce > Themes > Advanced > Docs > En > Images

Tiny Mce > Themes > Advanced > Docs > En

Tiny Mce > Themes > Advanced > Docs > Images

Tiny Mce > Themes > Advanced

Tiny Mce > Themes > Advanced > Images

Tiny Mce > Themes > Advanced > Images > Xp

Tiny Mce > Themes > Advanced > Jscripts

Tiny Mce > Themes > Advanced > Langs

Tiny Mce > Themes > Advanced

Tiny Mce

Tiny Mce > Utils

Content:

Core.write Cache File.php:


<?php
/**
 * Smarty plugin
 * @package Smarty
 * @subpackage plugins
 */

/**
 * Prepend the cache information to the cache file
 * and write it
 *
 * @param string $tpl_file
 * @param string $cache_id
 * @param string $compile_id
 * @param string $results
 * @return true|null
 */

 // $tpl_file,  $cache_id,  $compile_id,  $results

function smarty_core_write_cache_file($params,  &$smarty)
{

    
// put timestamp in cache header
    
$smarty->_cache_info['timestamp'] = time();
    if (
$smarty->cache_lifetime > -1){
        
// expiration set
        
$smarty->_cache_info['expires'] = $smarty->_cache_info['timestamp'] + $smarty->cache_lifetime;
    } else {
        
// cache will never expire
        
$smarty->_cache_info['expires'] = -1;
    }

    
// collapse nocache.../nocache-tags
    
if (preg_match_all('!\{(/?)nocache\:[0-9a-f]{32}#\d+\}!',  $params['results'],  $match,  PREG_PATTERN_ORDER)) {
        
// remove everything between every pair of outermost noache.../nocache-tags
        // and replace it by a single nocache-tag
        // this new nocache-tag will be replaced by dynamic contents in
        // smarty_core_process_compiled_includes() on a cache-read
        
        
$match_count count($match[0]);
        
$results preg_split('!(\{/?nocache\:[0-9a-f]{32}#\d+\})!',  $params['results'],  -1,  PREG_SPLIT_DELIM_CAPTURE);
        
        
$level 0;
        
$j 0;
        for (
$i=0,  $results_count count($results); $i $results_count && $j $match_count$i++) {
            if (
$results[$i] == $match[0][$j]) {
                
// nocache tag
                
if ($match[1][$j]) { // closing tag
                    
$level--;
                    unset(
$results[$i]);
                } else { 
// opening tag
                    
if ($level++ > 0) unset($results[$i]);
                }
                
$j++;
            } elseif (
$level 0) {
                unset(
$results[$i]);
            }
        }
        
$params['results'] = implode('',  $results);
    }
    
$smarty->_cache_info['cache_serials'] = $smarty->_cache_serials;

    
// prepend the cache header info into cache file
    
$_cache_info serialize($smarty->_cache_info);
    
$params['results'] = strlen($_cache_info) . "\n" $_cache_info $params['results'];

    if (!empty(
$smarty->cache_handler_func)) {
        
// use cache_handler function
        
call_user_func_array($smarty->cache_handler_func,
                             array(
'write',  &$smarty,  &$params['results'],  $params['tpl_file'],  $params['cache_id'],  $params['compile_id'],  null));
    } else {
        
// use local cache file

        
if(!@is_writable($smarty->cache_dir)) {
            
// cache_dir not writable,  see if it exists
            
if(!@is_dir($smarty->cache_dir)) {
                
$smarty->trigger_error('the $cache_dir \'' $smarty->cache_dir '\' does not exist,  or is not a directory.',  E_USER_ERROR);
                return 
false;
            }
            
$smarty->trigger_error('unable to write to $cache_dir \'' realpath($smarty->cache_dir) . '\'. Be sure $cache_dir is writable by the web server user.',  E_USER_ERROR);
            return 
false;
        }

        
$_auto_id $smarty->_get_auto_id($params['cache_id'],  $params['compile_id']);
        
$_cache_file $smarty->_get_auto_filename($smarty->cache_dir,  $params['tpl_file'],  $_auto_id);
        
$_params = array('filename' => $_cache_file,  'contents' => $params['results'],  'create_dirs' => true);
        require_once(
SMARTY_CORE_DIR 'core.write_file.php');
        
smarty_core_write_file($_params,  $smarty);
        return 
true;
    }
}

/* vim: set expandtab: */

?>



Other Content Management Scripts:

WebMaster Resources Home

©RingsWorld.com