Chris PeBenito 696b41
Chris PeBenito 696b41
Chris PeBenito 696b41
/**
Chris PeBenito 696b41
 * Project:     Smarty: the PHP compiling template engine
Chris PeBenito 696b41
 * File:        Smarty.class.php
Chris PeBenito 696b41
 *
Chris PeBenito 696b41
 * This library is free software; you can redistribute it and/or
Chris PeBenito 696b41
 * modify it under the terms of the GNU Lesser General Public
Chris PeBenito 696b41
 * License as published by the Free Software Foundation; either
Chris PeBenito 696b41
 * version 2.1 of the License, or (at your option) any later version.
Chris PeBenito 696b41
 *
Chris PeBenito 696b41
 * This library is distributed in the hope that it will be useful,
Chris PeBenito 696b41
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
Chris PeBenito 696b41
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
Chris PeBenito 696b41
 * Lesser General Public License for more details.
Chris PeBenito 696b41
 *
Chris PeBenito 696b41
 * You should have received a copy of the GNU Lesser General Public
Chris PeBenito 696b41
 * License along with this library; if not, write to the Free Software
Chris PeBenito 696b41
 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
Chris PeBenito 696b41
 *
Chris PeBenito 696b41
 * For questions, help, comments, discussion, etc., please join the
Chris PeBenito 696b41
 * Smarty mailing list. Send a blank e-mail to
Chris PeBenito 696b41
 * smarty-general-subscribe@lists.php.net
Chris PeBenito 696b41
 *
Chris PeBenito 696b41
 * @link http://smarty.php.net/
Chris PeBenito 696b41
 * @copyright 2001-2005 New Digital Group, Inc.
Chris PeBenito 696b41
 * @author Monte Ohrt <monte at ohrt dot com>
Chris PeBenito 696b41
 * @author Andrei Zmievski <andrei@php.net>
Chris PeBenito 696b41
 * @package Smarty
Chris PeBenito 696b41
 * @version 2.6.9
Chris PeBenito 696b41
 */
Chris PeBenito 696b41
Chris PeBenito 696b41
/* $Id$ */
Chris PeBenito 696b41
Chris PeBenito 696b41
/**
Chris PeBenito 696b41
 * DIR_SEP isn't used anymore, but third party apps might
Chris PeBenito 696b41
 */
Chris PeBenito 696b41
if(!defined('DIR_SEP')) {
Chris PeBenito 696b41
    define('DIR_SEP', DIRECTORY_SEPARATOR);
Chris PeBenito 696b41
}
Chris PeBenito 696b41
Chris PeBenito 696b41
/**
Chris PeBenito 696b41
 * set SMARTY_DIR to absolute path to Smarty library files.
Chris PeBenito 696b41
 * if not defined, include_path will be used. Sets SMARTY_DIR only if user
Chris PeBenito 696b41
 * application has not already defined it.
Chris PeBenito 696b41
 */
Chris PeBenito 696b41
Chris PeBenito 696b41
if (!defined('SMARTY_DIR')) {
Chris PeBenito 696b41
    define('SMARTY_DIR', dirname(__FILE__) . DIRECTORY_SEPARATOR);
Chris PeBenito 696b41
}
Chris PeBenito 696b41
Chris PeBenito 696b41
if (!defined('SMARTY_CORE_DIR')) {
Chris PeBenito 696b41
    define('SMARTY_CORE_DIR', SMARTY_DIR . 'internals' . DIRECTORY_SEPARATOR);
Chris PeBenito 696b41
}
Chris PeBenito 696b41
Chris PeBenito 696b41
define('SMARTY_PHP_PASSTHRU',   0);
Chris PeBenito 696b41
define('SMARTY_PHP_QUOTE',      1);
Chris PeBenito 696b41
define('SMARTY_PHP_REMOVE',     2);
Chris PeBenito 696b41
define('SMARTY_PHP_ALLOW',      3);
Chris PeBenito 696b41
Chris PeBenito 696b41
/**
Chris PeBenito 696b41
 * @package Smarty
Chris PeBenito 696b41
 */
Chris PeBenito 696b41
class Smarty
Chris PeBenito 696b41
{
Chris PeBenito 696b41
    /**#@+
Chris PeBenito 696b41
     * Smarty Configuration Section
Chris PeBenito 696b41
     */
Chris PeBenito 696b41
Chris PeBenito 696b41
    /**
Chris PeBenito 696b41
     * The name of the directory where templates are located.
Chris PeBenito 696b41
     *
Chris PeBenito 696b41
     * @var string
Chris PeBenito 696b41
     */
Chris PeBenito 696b41
    var $template_dir    =  'templates';
Chris PeBenito 696b41
Chris PeBenito 696b41
    /**
Chris PeBenito 696b41
     * The directory where compiled templates are located.
Chris PeBenito 696b41
     *
Chris PeBenito 696b41
     * @var string
Chris PeBenito 696b41
     */
Chris PeBenito 696b41
    var $compile_dir     =  'templates_c';
Chris PeBenito 696b41
Chris PeBenito 696b41
    /**
Chris PeBenito 696b41
     * The directory where config files are located.
Chris PeBenito 696b41
     *
Chris PeBenito 696b41
     * @var string
Chris PeBenito 696b41
     */
Chris PeBenito 696b41
    var $config_dir      =  'configs';
Chris PeBenito 696b41
Chris PeBenito 696b41
    /**
Chris PeBenito 696b41
     * An array of directories searched for plugins.
Chris PeBenito 696b41
     *
Chris PeBenito 696b41
     * @var array
Chris PeBenito 696b41
     */
Chris PeBenito 696b41
    var $plugins_dir     =  array('plugins');
Chris PeBenito 696b41
Chris PeBenito 696b41
    /**
Chris PeBenito 696b41
     * If debugging is enabled, a debug console window will display
Chris PeBenito 696b41
     * when the page loads (make sure your browser allows unrequested
Chris PeBenito 696b41
     * popup windows)
Chris PeBenito 696b41
     *
Chris PeBenito 696b41
     * @var boolean
Chris PeBenito 696b41
     */
Chris PeBenito 696b41
    var $debugging       =  false;
Chris PeBenito 696b41
Chris PeBenito 696b41
    /**
Chris PeBenito 696b41
     * When set, smarty does uses this value as error_reporting-level.
Chris PeBenito 696b41
     *
Chris PeBenito 696b41
     * @var boolean
Chris PeBenito 696b41
     */
Chris PeBenito 696b41
    var $error_reporting  =  null;
Chris PeBenito 696b41
Chris PeBenito 696b41
    /**
Chris PeBenito 696b41
     * This is the path to the debug console template. If not set,
Chris PeBenito 696b41
     * the default one will be used.
Chris PeBenito 696b41
     *
Chris PeBenito 696b41
     * @var string
Chris PeBenito 696b41
     */
Chris PeBenito 696b41
    var $debug_tpl       =  '';
Chris PeBenito 696b41
Chris PeBenito 696b41
    /**
Chris PeBenito 696b41
     * This determines if debugging is enable-able from the browser.
Chris PeBenito 696b41
     * 
    Chris PeBenito 696b41
         *  
  • NONE => no debugging control allowed
  • Chris PeBenito 696b41
         *  
  • URL => enable debugging when SMARTY_DEBUG is found in the URL.
  • Chris PeBenito 696b41
         * 
    Chris PeBenito 696b41
         * @link http://www.foo.dom/index.php?SMARTY_DEBUG
    Chris PeBenito 696b41
         * @var string
    Chris PeBenito 696b41
         */
    Chris PeBenito 696b41
        var $debugging_ctrl  =  'NONE';
    Chris PeBenito 696b41
    Chris PeBenito 696b41
        /**
    Chris PeBenito 696b41
         * This tells Smarty whether to check for recompiling or not. Recompiling
    Chris PeBenito 696b41
         * does not need to happen unless a template or config file is changed.
    Chris PeBenito 696b41
         * Typically you enable this during development, and disable for
    Chris PeBenito 696b41
         * production.
    Chris PeBenito 696b41
         *
    Chris PeBenito 696b41
         * @var boolean
    Chris PeBenito 696b41
         */
    Chris PeBenito 696b41
        var $compile_check   =  true;
    Chris PeBenito 696b41
    Chris PeBenito 696b41
        /**
    Chris PeBenito 696b41
         * This forces templates to compile every time. Useful for development
    Chris PeBenito 696b41
         * or debugging.
    Chris PeBenito 696b41
         *
    Chris PeBenito 696b41
         * @var boolean
    Chris PeBenito 696b41
         */
    Chris PeBenito 696b41
        var $force_compile   =  false;
    Chris PeBenito 696b41
    Chris PeBenito 696b41
        /**
    Chris PeBenito 696b41
         * This enables template caching.
    Chris PeBenito 696b41
         * 
      Chris PeBenito 696b41
           *  
    • 0 = no caching
    • Chris PeBenito 696b41
           *  
    • 1 = use class cache_lifetime value
    • Chris PeBenito 696b41
           *  
    • 2 = use cache_lifetime in cache file
    • Chris PeBenito 696b41
           * 
      Chris PeBenito 696b41
           * @var integer
      Chris PeBenito 696b41
           */
      Chris PeBenito 696b41
          var $caching         =  0;
      Chris PeBenito 696b41
      Chris PeBenito 696b41
          /**
      Chris PeBenito 696b41
           * The name of the directory for cache files.
      Chris PeBenito 696b41
           *
      Chris PeBenito 696b41
           * @var string
      Chris PeBenito 696b41
           */
      Chris PeBenito 696b41
          var $cache_dir       =  'cache';
      Chris PeBenito 696b41
      Chris PeBenito 696b41
          /**
      Chris PeBenito 696b41
           * This is the number of seconds cached content will persist.
      Chris PeBenito 696b41
           * 
        Chris PeBenito 696b41
             *  
      • 0 = always regenerate cache
      • Chris PeBenito 696b41
             *  
      • -1 = never expires
      • Chris PeBenito 696b41
             * 
        Chris PeBenito 696b41
             *
        Chris PeBenito 696b41
             * @var integer
        Chris PeBenito 696b41
             */
        Chris PeBenito 696b41
            var $cache_lifetime  =  3600;
        Chris PeBenito 696b41
        Chris PeBenito 696b41
            /**
        Chris PeBenito 696b41
             * Only used when $caching is enabled. If true, then If-Modified-Since headers
        Chris PeBenito 696b41
             * are respected with cached content, and appropriate HTTP headers are sent.
        Chris PeBenito 696b41
             * This way repeated hits to a cached page do not send the entire page to the
        Chris PeBenito 696b41
             * client every time.
        Chris PeBenito 696b41
             *
        Chris PeBenito 696b41
             * @var boolean
        Chris PeBenito 696b41
             */
        Chris PeBenito 696b41
            var $cache_modified_check = false;
        Chris PeBenito 696b41
        Chris PeBenito 696b41
            /**
        Chris PeBenito 696b41
             * This determines how Smarty handles "" tags in templates.
        Chris PeBenito 696b41
             * possible values:
        Chris PeBenito 696b41
             * 
          Chris PeBenito 696b41
               *  
        • SMARTY_PHP_PASSTHRU -> print tags as plain text
        • Chris PeBenito 696b41
               *  
        • SMARTY_PHP_QUOTE -> escape tags as entities
        • Chris PeBenito 696b41
               *  
        • SMARTY_PHP_REMOVE -> remove php tags
        • Chris PeBenito 696b41
               *  
        • SMARTY_PHP_ALLOW -> execute php tags
        • Chris PeBenito 696b41
               * 
          Chris PeBenito 696b41
               *
          Chris PeBenito 696b41
               * @var integer
          Chris PeBenito 696b41
               */
          Chris PeBenito 696b41
              var $php_handling    =  SMARTY_PHP_PASSTHRU;
          Chris PeBenito 696b41
          Chris PeBenito 696b41
              /**
          Chris PeBenito 696b41
               * This enables template security. When enabled, many things are restricted
          Chris PeBenito 696b41
               * in the templates that normally would go unchecked. This is useful when
          Chris PeBenito 696b41
               * untrusted parties are editing templates and you want a reasonable level
          Chris PeBenito 696b41
               * of security. (no direct execution of PHP in templates for example)
          Chris PeBenito 696b41
               *
          Chris PeBenito 696b41
               * @var boolean
          Chris PeBenito 696b41
               */
          Chris PeBenito 696b41
              var $security       =   false;
          Chris PeBenito 696b41
          Chris PeBenito 696b41
              /**
          Chris PeBenito 696b41
               * This is the list of template directories that are considered secure. This
          Chris PeBenito 696b41
               * is used only if {@link $security} is enabled. One directory per array
          Chris PeBenito 696b41
               * element.  {@link $template_dir} is in this list implicitly.
          Chris PeBenito 696b41
               *
          Chris PeBenito 696b41
               * @var array
          Chris PeBenito 696b41
               */
          Chris PeBenito 696b41
              var $secure_dir     =   array();
          Chris PeBenito 696b41
          Chris PeBenito 696b41
              /**
          Chris PeBenito 696b41
               * These are the security settings for Smarty. They are used only when
          Chris PeBenito 696b41
               * {@link $security} is enabled.
          Chris PeBenito 696b41
               *
          Chris PeBenito 696b41
               * @var array
          Chris PeBenito 696b41
               */
          Chris PeBenito 696b41
              var $security_settings  = array(
          Chris PeBenito 696b41
                                              'PHP_HANDLING'    => false,
          Chris PeBenito 696b41
                                              'IF_FUNCS'        => array('array', 'list',
          Chris PeBenito 696b41
                                                                         'isset', 'empty',
          Chris PeBenito 696b41
                                                                         'count', 'sizeof',
          Chris PeBenito 696b41
                                                                         'in_array', 'is_array',
          Chris PeBenito 696b41
                                                                         'true', 'false', 'null'),
          Chris PeBenito 696b41
                                              'INCLUDE_ANY'     => false,
          Chris PeBenito 696b41
                                              'PHP_TAGS'        => false,
          Chris PeBenito 696b41
                                              'MODIFIER_FUNCS'  => array('count'),
          Chris PeBenito 696b41
                                              'ALLOW_CONSTANTS'  => false
          Chris PeBenito 696b41
                                             );
          Chris PeBenito 696b41
          Chris PeBenito 696b41
              /**
          Chris PeBenito 696b41
               * This is an array of directories where trusted php scripts reside.
          Chris PeBenito 696b41
               * {@link $security} is disabled during their inclusion/execution.
          Chris PeBenito 696b41
               *
          Chris PeBenito 696b41
               * @var array
          Chris PeBenito 696b41
               */
          Chris PeBenito 696b41
              var $trusted_dir        = array();
          Chris PeBenito 696b41
          Chris PeBenito 696b41
              /**
          Chris PeBenito 696b41
               * The left delimiter used for the template tags.
          Chris PeBenito 696b41
               *
          Chris PeBenito 696b41
               * @var string
          Chris PeBenito 696b41
               */
          Chris PeBenito 696b41
              var $left_delimiter  =  '{';
          Chris PeBenito 696b41
          Chris PeBenito 696b41
              /**
          Chris PeBenito 696b41
               * The right delimiter used for the template tags.
          Chris PeBenito 696b41
               *
          Chris PeBenito 696b41
               * @var string
          Chris PeBenito 696b41
               */
          Chris PeBenito 696b41
              var $right_delimiter =  '}';
          Chris PeBenito 696b41
          Chris PeBenito 696b41
              /**
          Chris PeBenito 696b41
               * The order in which request variables are registered, similar to
          Chris PeBenito 696b41
               * variables_order in php.ini E = Environment, G = GET, P = POST,
          Chris PeBenito 696b41
               * C = Cookies, S = Server
          Chris PeBenito 696b41
               *
          Chris PeBenito 696b41
               * @var string
          Chris PeBenito 696b41
               */
          Chris PeBenito 696b41
              var $request_vars_order    = 'EGPCS';
          Chris PeBenito 696b41
          Chris PeBenito 696b41
              /**
          Chris PeBenito 696b41
               * Indicates wether $HTTP_*_VARS[] (request_use_auto_globals=false)
          Chris PeBenito 696b41
               * are uses as request-vars or $_*[]-vars. note: if
          Chris PeBenito 696b41
               * request_use_auto_globals is true, then $request_vars_order has
          Chris PeBenito 696b41
               * no effect, but the php-ini-value "gpc_order"
          Chris PeBenito 696b41
               *
          Chris PeBenito 696b41
               * @var boolean
          Chris PeBenito 696b41
               */
          Chris PeBenito 696b41
              var $request_use_auto_globals      = true;
          Chris PeBenito 696b41
          Chris PeBenito 696b41
              /**
          Chris PeBenito 696b41
               * Set this if you want different sets of compiled files for the same
          Chris PeBenito 696b41
               * templates. This is useful for things like different languages.
          Chris PeBenito 696b41
               * Instead of creating separate sets of templates per language, you
          Chris PeBenito 696b41
               * set different compile_ids like 'en' and 'de'.
          Chris PeBenito 696b41
               *
          Chris PeBenito 696b41
               * @var string
          Chris PeBenito 696b41
               */
          Chris PeBenito 696b41
              var $compile_id            = null;
          Chris PeBenito 696b41
          Chris PeBenito 696b41
              /**
          Chris PeBenito 696b41
               * This tells Smarty whether or not to use sub dirs in the cache/ and
          Chris PeBenito 696b41
               * templates_c/ directories. sub directories better organized, but
          Chris PeBenito 696b41
               * may not work well with PHP safe mode enabled.
          Chris PeBenito 696b41
               *
          Chris PeBenito 696b41
               * @var boolean
          Chris PeBenito 696b41
               *
          Chris PeBenito 696b41
               */
          Chris PeBenito 696b41
              var $use_sub_dirs          = false;
          Chris PeBenito 696b41
          Chris PeBenito 696b41
              /**
          Chris PeBenito 696b41
               * This is a list of the modifiers to apply to all template variables.
          Chris PeBenito 696b41
               * Put each modifier in a separate array element in the order you want
          Chris PeBenito 696b41
               * them applied. example: array('escape:"htmlall"');
          Chris PeBenito 696b41
               *
          Chris PeBenito 696b41
               * @var array
          Chris PeBenito 696b41
               */
          Chris PeBenito 696b41
              var $default_modifiers        = array();
          Chris PeBenito 696b41
          Chris PeBenito 696b41
              /**
          Chris PeBenito 696b41
               * This is the resource type to be used when not specified
          Chris PeBenito 696b41
               * at the beginning of the resource path. examples:
          Chris PeBenito 696b41
               * $smarty->display('file:index.tpl');
          Chris PeBenito 696b41
               * $smarty->display('db:index.tpl');
          Chris PeBenito 696b41
               * $smarty->display('index.tpl'); // will use default resource type
          Chris PeBenito 696b41
               * {include file="file:index.tpl"}
          Chris PeBenito 696b41
               * {include file="db:index.tpl"}
          Chris PeBenito 696b41
               * {include file="index.tpl"} {* will use default resource type *}
          Chris PeBenito 696b41
               *
          Chris PeBenito 696b41
               * @var array
          Chris PeBenito 696b41
               */
          Chris PeBenito 696b41
              var $default_resource_type    = 'file';
          Chris PeBenito 696b41
          Chris PeBenito 696b41
              /**
          Chris PeBenito 696b41
               * The function used for cache file handling. If not set, built-in caching is used.
          Chris PeBenito 696b41
               *
          Chris PeBenito 696b41
               * @var null|string function name
          Chris PeBenito 696b41
               */
          Chris PeBenito 696b41
              var $cache_handler_func   = null;
          Chris PeBenito 696b41
          Chris PeBenito 696b41
              /**
          Chris PeBenito 696b41
               * This indicates which filters are automatically loaded into Smarty.
          Chris PeBenito 696b41
               *
          Chris PeBenito 696b41
               * @var array array of filter names
          Chris PeBenito 696b41
               */
          Chris PeBenito 696b41
              var $autoload_filters = array();
          Chris PeBenito 696b41
          Chris PeBenito 696b41
              /**#@+
          Chris PeBenito 696b41
               * @var boolean
          Chris PeBenito 696b41
               */
          Chris PeBenito 696b41
              /**
          Chris PeBenito 696b41
               * This tells if config file vars of the same name overwrite each other or not.
          Chris PeBenito 696b41
               * if disabled, same name variables are accumulated in an array.
          Chris PeBenito 696b41
               */
          Chris PeBenito 696b41
              var $config_overwrite = true;
          Chris PeBenito 696b41
          Chris PeBenito 696b41
              /**
          Chris PeBenito 696b41
               * This tells whether or not to automatically booleanize config file variables.
          Chris PeBenito 696b41
               * If enabled, then the strings "on", "true", and "yes" are treated as boolean
          Chris PeBenito 696b41
               * true, and "off", "false" and "no" are treated as boolean false.
          Chris PeBenito 696b41
               */
          Chris PeBenito 696b41
              var $config_booleanize = true;
          Chris PeBenito 696b41
          Chris PeBenito 696b41
              /**
          Chris PeBenito 696b41
               * This tells whether hidden sections [.foobar] are readable from the
          Chris PeBenito 696b41
               * tempalates or not. Normally you would never allow this since that is
          Chris PeBenito 696b41
               * the point behind hidden sections: the application can access them, but
          Chris PeBenito 696b41
               * the templates cannot.
          Chris PeBenito 696b41
               */
          Chris PeBenito 696b41
              var $config_read_hidden = false;
          Chris PeBenito 696b41
          Chris PeBenito 696b41
              /**
          Chris PeBenito 696b41
               * This tells whether or not automatically fix newlines in config files.
          Chris PeBenito 696b41
               * It basically converts \r (mac) or \r\n (dos) to \n
          Chris PeBenito 696b41
               */
          Chris PeBenito 696b41
              var $config_fix_newlines = true;
          Chris PeBenito 696b41
              /**#@-*/
          Chris PeBenito 696b41
          Chris PeBenito 696b41
              /**
          Chris PeBenito 696b41
               * If a template cannot be found, this PHP function will be executed.
          Chris PeBenito 696b41
               * Useful for creating templates on-the-fly or other special action.
          Chris PeBenito 696b41
               *
          Chris PeBenito 696b41
               * @var string function name
          Chris PeBenito 696b41
               */
          Chris PeBenito 696b41
              var $default_template_handler_func = '';
          Chris PeBenito 696b41
          Chris PeBenito 696b41
              /**
          Chris PeBenito 696b41
               * The file that contains the compiler class. This can a full
          Chris PeBenito 696b41
               * pathname, or relative to the php_include path.
          Chris PeBenito 696b41
               *
          Chris PeBenito 696b41
               * @var string
          Chris PeBenito 696b41
               */
          Chris PeBenito 696b41
              var $compiler_file        =    'Smarty_Compiler.class.php';
          Chris PeBenito 696b41
          Chris PeBenito 696b41
              /**
          Chris PeBenito 696b41
               * The class used for compiling templates.
          Chris PeBenito 696b41
               *
          Chris PeBenito 696b41
               * @var string
          Chris PeBenito 696b41
               */
          Chris PeBenito 696b41
              var $compiler_class        =   'Smarty_Compiler';
          Chris PeBenito 696b41
          Chris PeBenito 696b41
              /**
          Chris PeBenito 696b41
               * The class used to load config vars.
          Chris PeBenito 696b41
               *
          Chris PeBenito 696b41
               * @var string
          Chris PeBenito 696b41
               */
          Chris PeBenito 696b41
              var $config_class          =   'Config_File';
          Chris PeBenito 696b41
          Chris PeBenito 696b41
          /**#@+
          Chris PeBenito 696b41
           * END Smarty Configuration Section
          Chris PeBenito 696b41
           * There should be no need to touch anything below this line.
          Chris PeBenito 696b41
           * @access private
          Chris PeBenito 696b41
           */
          Chris PeBenito 696b41
              /**
          Chris PeBenito 696b41
               * where assigned template vars are kept
          Chris PeBenito 696b41
               *
          Chris PeBenito 696b41
               * @var array
          Chris PeBenito 696b41
               */
          Chris PeBenito 696b41
              var $_tpl_vars             = array();
          Chris PeBenito 696b41
          Chris PeBenito 696b41
              /**
          Chris PeBenito 696b41
               * stores run-time $smarty.* vars
          Chris PeBenito 696b41
               *
          Chris PeBenito 696b41
               * @var null|array
          Chris PeBenito 696b41
               */
          Chris PeBenito 696b41
              var $_smarty_vars          = null;
          Chris PeBenito 696b41
          Chris PeBenito 696b41
              /**
          Chris PeBenito 696b41
               * keeps track of sections
          Chris PeBenito 696b41
               *
          Chris PeBenito 696b41
               * @var array
          Chris PeBenito 696b41
               */
          Chris PeBenito 696b41
              var $_sections             = array();
          Chris PeBenito 696b41
          Chris PeBenito 696b41
              /**
          Chris PeBenito 696b41
               * keeps track of foreach blocks
          Chris PeBenito 696b41
               *
          Chris PeBenito 696b41
               * @var array
          Chris PeBenito 696b41
               */
          Chris PeBenito 696b41
              var $_foreach              = array();
          Chris PeBenito 696b41
          Chris PeBenito 696b41
              /**
          Chris PeBenito 696b41
               * keeps track of tag hierarchy
          Chris PeBenito 696b41
               *
          Chris PeBenito 696b41
               * @var array
          Chris PeBenito 696b41
               */
          Chris PeBenito 696b41
              var $_tag_stack            = array();
          Chris PeBenito 696b41
          Chris PeBenito 696b41
              /**
          Chris PeBenito 696b41
               * configuration object
          Chris PeBenito 696b41
               *
          Chris PeBenito 696b41
               * @var Config_file
          Chris PeBenito 696b41
               */
          Chris PeBenito 696b41
              var $_conf_obj             = null;
          Chris PeBenito 696b41
          Chris PeBenito 696b41
              /**
          Chris PeBenito 696b41
               * loaded configuration settings
          Chris PeBenito 696b41
               *
          Chris PeBenito 696b41
               * @var array
          Chris PeBenito 696b41
               */
          Chris PeBenito 696b41
              var $_config               = array(array('vars'  => array(), 'files' => array()));
          Chris PeBenito 696b41
          Chris PeBenito 696b41
              /**
          Chris PeBenito 696b41
               * md5 checksum of the string 'Smarty'
          Chris PeBenito 696b41
               *
          Chris PeBenito 696b41
               * @var string
          Chris PeBenito 696b41
               */
          Chris PeBenito 696b41
              var $_smarty_md5           = 'f8d698aea36fcbead2b9d5359ffca76f';
          Chris PeBenito 696b41
          Chris PeBenito 696b41
              /**
          Chris PeBenito 696b41
               * Smarty version number
          Chris PeBenito 696b41
               *
          Chris PeBenito 696b41
               * @var string
          Chris PeBenito 696b41
               */
          Chris PeBenito 696b41
              var $_version              = '2.6.9';
          Chris PeBenito 696b41
          Chris PeBenito 696b41
              /**
          Chris PeBenito 696b41
               * current template inclusion depth
          Chris PeBenito 696b41
               *
          Chris PeBenito 696b41
               * @var integer
          Chris PeBenito 696b41
               */
          Chris PeBenito 696b41
              var $_inclusion_depth      = 0;
          Chris PeBenito 696b41
          Chris PeBenito 696b41
              /**
          Chris PeBenito 696b41
               * for different compiled templates
          Chris PeBenito 696b41
               *
          Chris PeBenito 696b41
               * @var string
          Chris PeBenito 696b41
               */
          Chris PeBenito 696b41
              var $_compile_id           = null;
          Chris PeBenito 696b41
          Chris PeBenito 696b41
              /**
          Chris PeBenito 696b41
               * text in URL to enable debug mode
          Chris PeBenito 696b41
               *
          Chris PeBenito 696b41
               * @var string
          Chris PeBenito 696b41
               */
          Chris PeBenito 696b41
              var $_smarty_debug_id      = 'SMARTY_DEBUG';
          Chris PeBenito 696b41
          Chris PeBenito 696b41
              /**
          Chris PeBenito 696b41
               * debugging information for debug console
          Chris PeBenito 696b41
               *
          Chris PeBenito 696b41
               * @var array
          Chris PeBenito 696b41
               */
          Chris PeBenito 696b41
              var $_smarty_debug_info    = array();
          Chris PeBenito 696b41
          Chris PeBenito 696b41
              /**
          Chris PeBenito 696b41
               * info that makes up a cache file
          Chris PeBenito 696b41
               *
          Chris PeBenito 696b41
               * @var array
          Chris PeBenito 696b41
               */
          Chris PeBenito 696b41
              var $_cache_info           = array();
          Chris PeBenito 696b41
          Chris PeBenito 696b41
              /**
          Chris PeBenito 696b41
               * default file permissions
          Chris PeBenito 696b41
               *
          Chris PeBenito 696b41
               * @var integer
          Chris PeBenito 696b41
               */
          Chris PeBenito 696b41
              var $_file_perms           = 0644;
          Chris PeBenito 696b41
          Chris PeBenito 696b41
              /**
          Chris PeBenito 696b41
               * default dir permissions
          Chris PeBenito 696b41
               *
          Chris PeBenito 696b41
               * @var integer
          Chris PeBenito 696b41
               */
          Chris PeBenito 696b41
              var $_dir_perms               = 0771;
          Chris PeBenito 696b41
          Chris PeBenito 696b41
              /**
          Chris PeBenito 696b41
               * registered objects
          Chris PeBenito 696b41
               *
          Chris PeBenito 696b41
               * @var array
          Chris PeBenito 696b41
               */
          Chris PeBenito 696b41
              var $_reg_objects           = array();
          Chris PeBenito 696b41
          Chris PeBenito 696b41
              /**
          Chris PeBenito 696b41
               * table keeping track of plugins
          Chris PeBenito 696b41
               *
          Chris PeBenito 696b41
               * @var array
          Chris PeBenito 696b41
               */
          Chris PeBenito 696b41
              var $_plugins              = array(
          Chris PeBenito 696b41
                                                 'modifier'      => array(),
          Chris PeBenito 696b41
                                                 'function'      => array(),
          Chris PeBenito 696b41
                                                 'block'         => array(),
          Chris PeBenito 696b41
                                                 'compiler'      => array(),
          Chris PeBenito 696b41
                                                 'prefilter'     => array(),
          Chris PeBenito 696b41
                                                 'postfilter'    => array(),
          Chris PeBenito 696b41
                                                 'outputfilter'  => array(),
          Chris PeBenito 696b41
                                                 'resource'      => array(),
          Chris PeBenito 696b41
                                                 'insert'        => array());
          Chris PeBenito 696b41
          Chris PeBenito 696b41
          Chris PeBenito 696b41
              /**
          Chris PeBenito 696b41
               * cache serials
          Chris PeBenito 696b41
               *
          Chris PeBenito 696b41
               * @var array
          Chris PeBenito 696b41
               */
          Chris PeBenito 696b41
              var $_cache_serials = array();
          Chris PeBenito 696b41
          Chris PeBenito 696b41
              /**
          Chris PeBenito 696b41
               * name of optional cache include file
          Chris PeBenito 696b41
               *
          Chris PeBenito 696b41
               * @var string
          Chris PeBenito 696b41
               */
          Chris PeBenito 696b41
              var $_cache_include = null;
          Chris PeBenito 696b41
          Chris PeBenito 696b41
              /**
          Chris PeBenito 696b41
               * indicate if the current code is used in a compiled
          Chris PeBenito 696b41
               * include
          Chris PeBenito 696b41
               *
          Chris PeBenito 696b41
               * @var string
          Chris PeBenito 696b41
               */
          Chris PeBenito 696b41
              var $_cache_including = false;
          Chris PeBenito 696b41
          Chris PeBenito 696b41
              /**#@-*/
          Chris PeBenito 696b41
              /**
          Chris PeBenito 696b41
               * The class constructor.
          Chris PeBenito 696b41
               */
          Chris PeBenito 696b41
              function Smarty()
          Chris PeBenito 696b41
              {
          Chris PeBenito 696b41
                $this->assign('SCRIPT_NAME', isset($_SERVER['SCRIPT_NAME']) ? $_SERVER['SCRIPT_NAME']
          Chris PeBenito 696b41
                              : @$GLOBALS['HTTP_SERVER_VARS']['SCRIPT_NAME']);
          Chris PeBenito 696b41
              }
          Chris PeBenito 696b41
          Chris PeBenito 696b41
              /**
          Chris PeBenito 696b41
               * assigns values to template variables
          Chris PeBenito 696b41
               *
          Chris PeBenito 696b41
               * @param array|string $tpl_var the template variable name(s)
          Chris PeBenito 696b41
               * @param mixed $value the value to assign
          Chris PeBenito 696b41
               */
          Chris PeBenito 696b41
              function assign($tpl_var, $value = null)
          Chris PeBenito 696b41
              {
          Chris PeBenito 696b41
                  if (is_array($tpl_var)){
          Chris PeBenito 696b41
                      foreach ($tpl_var as $key => $val) {
          Chris PeBenito 696b41
                          if ($key != '') {
          Chris PeBenito 696b41
                              $this->_tpl_vars[$key] = $val;
          Chris PeBenito 696b41
                          }
          Chris PeBenito 696b41
                      }
          Chris PeBenito 696b41
                  } else {
          Chris PeBenito 696b41
                      if ($tpl_var != '')
          Chris PeBenito 696b41
                          $this->_tpl_vars[$tpl_var] = $value;
          Chris PeBenito 696b41
                  }
          Chris PeBenito 696b41
              }
          Chris PeBenito 696b41
          Chris PeBenito 696b41
              /**
          Chris PeBenito 696b41
               * assigns values to template variables by reference
          Chris PeBenito 696b41
               *
          Chris PeBenito 696b41
               * @param string $tpl_var the template variable name
          Chris PeBenito 696b41
               * @param mixed $value the referenced value to assign
          Chris PeBenito 696b41
               */
          Chris PeBenito 696b41
              function assign_by_ref($tpl_var, &$value)
          Chris PeBenito 696b41
              {
          Chris PeBenito 696b41
                  if ($tpl_var != '')
          Chris PeBenito 696b41
                      $this->_tpl_vars[$tpl_var] = &$value;
          Chris PeBenito 696b41
              }
          Chris PeBenito 696b41
          Chris PeBenito 696b41
              /**
          Chris PeBenito 696b41
               * appends values to template variables
          Chris PeBenito 696b41
               *
          Chris PeBenito 696b41
               * @param array|string $tpl_var the template variable name(s)
          Chris PeBenito 696b41
               * @param mixed $value the value to append
          Chris PeBenito 696b41
               */
          Chris PeBenito 696b41
              function append($tpl_var, $value=null, $merge=false)
          Chris PeBenito 696b41
              {
          Chris PeBenito 696b41
                  if (is_array($tpl_var)) {
          Chris PeBenito 696b41
                      // $tpl_var is an array, ignore $value
          Chris PeBenito 696b41
                      foreach ($tpl_var as $_key => $_val) {
          Chris PeBenito 696b41
                          if ($_key != '') {
          Chris PeBenito 696b41
                              if(!@is_array($this->_tpl_vars[$_key])) {
          Chris PeBenito 696b41
                                  settype($this->_tpl_vars[$_key],'array');
          Chris PeBenito 696b41
                              }
          Chris PeBenito 696b41
                              if($merge && is_array($_val)) {
          Chris PeBenito 696b41
                                  foreach($_val as $_mkey => $_mval) {
          Chris PeBenito 696b41
                                      $this->_tpl_vars[$_key][$_mkey] = $_mval;
          Chris PeBenito 696b41
                                  }
          Chris PeBenito 696b41
                              } else {
          Chris PeBenito 696b41
                                  $this->_tpl_vars[$_key][] = $_val;
          Chris PeBenito 696b41
                              }
          Chris PeBenito 696b41
                          }
          Chris PeBenito 696b41
                      }
          Chris PeBenito 696b41
                  } else {
          Chris PeBenito 696b41
                      if ($tpl_var != '' && isset($value)) {
          Chris PeBenito 696b41
                          if(!@is_array($this->_tpl_vars[$tpl_var])) {
          Chris PeBenito 696b41
                              settype($this->_tpl_vars[$tpl_var],'array');
          Chris PeBenito 696b41
                          }
          Chris PeBenito 696b41
                          if($merge && is_array($value)) {
          Chris PeBenito 696b41
                              foreach($value as $_mkey => $_mval) {
          Chris PeBenito 696b41
                                  $this->_tpl_vars[$tpl_var][$_mkey] = $_mval;
          Chris PeBenito 696b41
                              }
          Chris PeBenito 696b41
                          } else {
          Chris PeBenito 696b41
                              $this->_tpl_vars[$tpl_var][] = $value;
          Chris PeBenito 696b41
                          }
          Chris PeBenito 696b41
                      }
          Chris PeBenito 696b41
                  }
          Chris PeBenito 696b41
              }
          Chris PeBenito 696b41
          Chris PeBenito 696b41
              /**
          Chris PeBenito 696b41
               * appends values to template variables by reference
          Chris PeBenito 696b41
               *
          Chris PeBenito 696b41
               * @param string $tpl_var the template variable name
          Chris PeBenito 696b41
               * @param mixed $value the referenced value to append
          Chris PeBenito 696b41
               */
          Chris PeBenito 696b41
              function append_by_ref($tpl_var, &$value, $merge=false)
          Chris PeBenito 696b41
              {
          Chris PeBenito 696b41
                  if ($tpl_var != '' && isset($value)) {
          Chris PeBenito 696b41
                      if(!@is_array($this->_tpl_vars[$tpl_var])) {
          Chris PeBenito 696b41
                       settype($this->_tpl_vars[$tpl_var],'array');
          Chris PeBenito 696b41
                      }
          Chris PeBenito 696b41
                      if ($merge && is_array($value)) {
          Chris PeBenito 696b41
                          foreach($value as $_key => $_val) {
          Chris PeBenito 696b41
                              $this->_tpl_vars[$tpl_var][$_key] = &$value[$_key];
          Chris PeBenito 696b41
                          }
          Chris PeBenito 696b41
                      } else {
          Chris PeBenito 696b41
                          $this->_tpl_vars[$tpl_var][] = &$value;
          Chris PeBenito 696b41
                      }
          Chris PeBenito 696b41
                  }
          Chris PeBenito 696b41
              }
          Chris PeBenito 696b41
          Chris PeBenito 696b41
          Chris PeBenito 696b41
              /**
          Chris PeBenito 696b41
               * clear the given assigned template variable.
          Chris PeBenito 696b41
               *
          Chris PeBenito 696b41
               * @param string $tpl_var the template variable to clear
          Chris PeBenito 696b41
               */
          Chris PeBenito 696b41
              function clear_assign($tpl_var)
          Chris PeBenito 696b41
              {
          Chris PeBenito 696b41
                  if (is_array($tpl_var))
          Chris PeBenito 696b41
                      foreach ($tpl_var as $curr_var)
          Chris PeBenito 696b41
                          unset($this->_tpl_vars[$curr_var]);
          Chris PeBenito 696b41
                  else
          Chris PeBenito 696b41
                      unset($this->_tpl_vars[$tpl_var]);
          Chris PeBenito 696b41
              }
          Chris PeBenito 696b41
          Chris PeBenito 696b41
          Chris PeBenito 696b41
              /**
          Chris PeBenito 696b41
               * Registers custom function to be used in templates
          Chris PeBenito 696b41
               *
          Chris PeBenito 696b41
               * @param string $function the name of the template function
          Chris PeBenito 696b41
               * @param string $function_impl the name of the PHP function to register
          Chris PeBenito 696b41
               */
          Chris PeBenito 696b41
              function register_function($function, $function_impl, $cacheable=true, $cache_attrs=null)
          Chris PeBenito 696b41
              {
          Chris PeBenito 696b41
                  $this->_plugins['function'][$function] =
          Chris PeBenito 696b41
                      array($function_impl, null, null, false, $cacheable, $cache_attrs);
          Chris PeBenito 696b41
          Chris PeBenito 696b41
              }
          Chris PeBenito 696b41
          Chris PeBenito 696b41
              /**
          Chris PeBenito 696b41
               * Unregisters custom function
          Chris PeBenito 696b41
               *
          Chris PeBenito 696b41
               * @param string $function name of template function
          Chris PeBenito 696b41
               */
          Chris PeBenito 696b41
              function unregister_function($function)
          Chris PeBenito 696b41
              {
          Chris PeBenito 696b41
                  unset($this->_plugins['function'][$function]);
          Chris PeBenito 696b41
              }
          Chris PeBenito 696b41
          Chris PeBenito 696b41
              /**
          Chris PeBenito 696b41
               * Registers object to be used in templates
          Chris PeBenito 696b41
               *
          Chris PeBenito 696b41
               * @param string $object name of template object
          Chris PeBenito 696b41
               * @param object &$object_impl the referenced PHP object to register
          Chris PeBenito 696b41
               * @param null|array $allowed list of allowed methods (empty = all)
          Chris PeBenito 696b41
               * @param boolean $smarty_args smarty argument format, else traditional
          Chris PeBenito 696b41
               * @param null|array $block_functs list of methods that are block format
          Chris PeBenito 696b41
               */
          Chris PeBenito 696b41
              function register_object($object, &$object_impl, $allowed = array(), $smarty_args = true, $block_methods = array())
          Chris PeBenito 696b41
              {
          Chris PeBenito 696b41
                  settype($allowed, 'array');
          Chris PeBenito 696b41
                  settype($smarty_args, 'boolean');
          Chris PeBenito 696b41
                  $this->_reg_objects[$object] =
          Chris PeBenito 696b41
                      array(&$object_impl, $allowed, $smarty_args, $block_methods);
          Chris PeBenito 696b41
              }
          Chris PeBenito 696b41
          Chris PeBenito 696b41
              /**
          Chris PeBenito 696b41
               * Unregisters object
          Chris PeBenito 696b41
               *
          Chris PeBenito 696b41
               * @param string $object name of template object
          Chris PeBenito 696b41
               */
          Chris PeBenito 696b41
              function unregister_object($object)
          Chris PeBenito 696b41
              {
          Chris PeBenito 696b41
                  unset($this->_reg_objects[$object]);
          Chris PeBenito 696b41
              }
          Chris PeBenito 696b41
          Chris PeBenito 696b41
          Chris PeBenito 696b41
              /**
          Chris PeBenito 696b41
               * Registers block function to be used in templates
          Chris PeBenito 696b41
               *
          Chris PeBenito 696b41
               * @param string $block name of template block
          Chris PeBenito 696b41
               * @param string $block_impl PHP function to register
          Chris PeBenito 696b41
               */
          Chris PeBenito 696b41
              function register_block($block, $block_impl, $cacheable=true, $cache_attrs=null)
          Chris PeBenito 696b41
              {
          Chris PeBenito 696b41
                  $this->_plugins['block'][$block] =
          Chris PeBenito 696b41
                      array($block_impl, null, null, false, $cacheable, $cache_attrs);
          Chris PeBenito 696b41
              }
          Chris PeBenito 696b41
          Chris PeBenito 696b41
              /**
          Chris PeBenito 696b41
               * Unregisters block function
          Chris PeBenito 696b41
               *
          Chris PeBenito 696b41
               * @param string $block name of template function
          Chris PeBenito 696b41
               */
          Chris PeBenito 696b41
              function unregister_block($block)
          Chris PeBenito 696b41
              {
          Chris PeBenito 696b41
                  unset($this->_plugins['block'][$block]);
          Chris PeBenito 696b41
              }
          Chris PeBenito 696b41
          Chris PeBenito 696b41
              /**
          Chris PeBenito 696b41
               * Registers compiler function
          Chris PeBenito 696b41
               *
          Chris PeBenito 696b41
               * @param string $function name of template function
          Chris PeBenito 696b41
               * @param string $function_impl name of PHP function to register
          Chris PeBenito 696b41
               */
          Chris PeBenito 696b41
              function register_compiler_function($function, $function_impl, $cacheable=true)
          Chris PeBenito 696b41
              {
          Chris PeBenito 696b41
                  $this->_plugins['compiler'][$function] =
          Chris PeBenito 696b41
                      array($function_impl, null, null, false, $cacheable);
          Chris PeBenito 696b41
              }
          Chris PeBenito 696b41
          Chris PeBenito 696b41
              /**
          Chris PeBenito 696b41
               * Unregisters compiler function
          Chris PeBenito 696b41
               *
          Chris PeBenito 696b41
               * @param string $function name of template function
          Chris PeBenito 696b41
               */
          Chris PeBenito 696b41
              function unregister_compiler_function($function)
          Chris PeBenito 696b41
              {
          Chris PeBenito 696b41
                  unset($this->_plugins['compiler'][$function]);
          Chris PeBenito 696b41
              }
          Chris PeBenito 696b41
          Chris PeBenito 696b41
              /**
          Chris PeBenito 696b41
               * Registers modifier to be used in templates
          Chris PeBenito 696b41
               *
          Chris PeBenito 696b41
               * @param string $modifier name of template modifier
          Chris PeBenito 696b41
               * @param string $modifier_impl name of PHP function to register
          Chris PeBenito 696b41
               */
          Chris PeBenito 696b41
              function register_modifier($modifier, $modifier_impl)
          Chris PeBenito 696b41
              {
          Chris PeBenito 696b41
                  $this->_plugins['modifier'][$modifier] =
          Chris PeBenito 696b41
                      array($modifier_impl, null, null, false);
          Chris PeBenito 696b41
              }
          Chris PeBenito 696b41
          Chris PeBenito 696b41
              /**
          Chris PeBenito 696b41
               * Unregisters modifier
          Chris PeBenito 696b41
               *
          Chris PeBenito 696b41
               * @param string $modifier name of template modifier
          Chris PeBenito 696b41
               */
          Chris PeBenito 696b41
              function unregister_modifier($modifier)
          Chris PeBenito 696b41
              {
          Chris PeBenito 696b41
                  unset($this->_plugins['modifier'][$modifier]);
          Chris PeBenito 696b41
              }
          Chris PeBenito 696b41
          Chris PeBenito 696b41
              /**
          Chris PeBenito 696b41
               * Registers a resource to fetch a template
          Chris PeBenito 696b41
               *
          Chris PeBenito 696b41
               * @param string $type name of resource
          Chris PeBenito 696b41
               * @param array $functions array of functions to handle resource
          Chris PeBenito 696b41
               */
          Chris PeBenito 696b41
              function register_resource($type, $functions)
          Chris PeBenito 696b41
              {
          Chris PeBenito 696b41
                  if (count($functions)==4) {
          Chris PeBenito 696b41
                      $this->_plugins['resource'][$type] =
          Chris PeBenito 696b41
                          array($functions, false);
          Chris PeBenito 696b41
          Chris PeBenito 696b41
                  } elseif (count($functions)==5) {
          Chris PeBenito 696b41
                      $this->_plugins['resource'][$type] =
          Chris PeBenito 696b41
                          array(array(array(&$functions[0], $functions[1])
          Chris PeBenito 696b41
                                      ,array(&$functions[0], $functions[2])
          Chris PeBenito 696b41
                                      ,array(&$functions[0], $functions[3])
          Chris PeBenito 696b41
                                      ,array(&$functions[0], $functions[4]))
          Chris PeBenito 696b41
                                ,false);
          Chris PeBenito 696b41
          Chris PeBenito 696b41
                  } else {
          Chris PeBenito 696b41
                      $this->trigger_error("malformed function-list for '$type' in register_resource");
          Chris PeBenito 696b41
          Chris PeBenito 696b41
                  }
          Chris PeBenito 696b41
              }
          Chris PeBenito 696b41
          Chris PeBenito 696b41
              /**
          Chris PeBenito 696b41
               * Unregisters a resource
          Chris PeBenito 696b41
               *
          Chris PeBenito 696b41
               * @param string $type name of resource
          Chris PeBenito 696b41
               */
          Chris PeBenito 696b41
              function unregister_resource($type)
          Chris PeBenito 696b41
              {
          Chris PeBenito 696b41
                  unset($this->_plugins['resource'][$type]);
          Chris PeBenito 696b41
              }
          Chris PeBenito 696b41
          Chris PeBenito 696b41
              /**
          Chris PeBenito 696b41
               * Registers a prefilter function to apply
          Chris PeBenito 696b41
               * to a template before compiling
          Chris PeBenito 696b41
               *
          Chris PeBenito 696b41
               * @param string $function name of PHP function to register
          Chris PeBenito 696b41
               */
          Chris PeBenito 696b41
              function register_prefilter($function)
          Chris PeBenito 696b41
              {
          Chris PeBenito 696b41
              $_name = (is_array($function)) ? $function[1] : $function;
          Chris PeBenito 696b41
                  $this->_plugins['prefilter'][$_name]
          Chris PeBenito 696b41
                      = array($function, null, null, false);
          Chris PeBenito 696b41
              }
          Chris PeBenito 696b41
          Chris PeBenito 696b41
              /**
          Chris PeBenito 696b41
               * Unregisters a prefilter function
          Chris PeBenito 696b41
               *
          Chris PeBenito 696b41
               * @param string $function name of PHP function
          Chris PeBenito 696b41
               */
          Chris PeBenito 696b41
              function unregister_prefilter($function)
          Chris PeBenito 696b41
              {
          Chris PeBenito 696b41
                  unset($this->_plugins['prefilter'][$function]);
          Chris PeBenito 696b41
              }
          Chris PeBenito 696b41
          Chris PeBenito 696b41
              /**
          Chris PeBenito 696b41
               * Registers a postfilter function to apply
          Chris PeBenito 696b41
               * to a compiled template after compilation
          Chris PeBenito 696b41
               *
          Chris PeBenito 696b41
               * @param string $function name of PHP function to register
          Chris PeBenito 696b41
               */
          Chris PeBenito 696b41
              function register_postfilter($function)
          Chris PeBenito 696b41
              {
          Chris PeBenito 696b41
              $_name = (is_array($function)) ? $function[1] : $function;
          Chris PeBenito 696b41
                  $this->_plugins['postfilter'][$_name]
          Chris PeBenito 696b41
                      = array($function, null, null, false);
          Chris PeBenito 696b41
              }
          Chris PeBenito 696b41
          Chris PeBenito 696b41
              /**
          Chris PeBenito 696b41
               * Unregisters a postfilter function
          Chris PeBenito 696b41
               *
          Chris PeBenito 696b41
               * @param string $function name of PHP function
          Chris PeBenito 696b41
               */
          Chris PeBenito 696b41
              function unregister_postfilter($function)
          Chris PeBenito 696b41
              {
          Chris PeBenito 696b41
                  unset($this->_plugins['postfilter'][$function]);
          Chris PeBenito 696b41
              }
          Chris PeBenito 696b41
          Chris PeBenito 696b41
              /**
          Chris PeBenito 696b41
               * Registers an output filter function to apply
          Chris PeBenito 696b41
               * to a template output
          Chris PeBenito 696b41
               *
          Chris PeBenito 696b41
               * @param string $function name of PHP function
          Chris PeBenito 696b41
               */
          Chris PeBenito 696b41
              function register_outputfilter($function)
          Chris PeBenito 696b41
              {
          Chris PeBenito 696b41
              $_name = (is_array($function)) ? $function[1] : $function;
          Chris PeBenito 696b41
                  $this->_plugins['outputfilter'][$_name]
          Chris PeBenito 696b41
                      = array($function, null, null, false);
          Chris PeBenito 696b41
              }
          Chris PeBenito 696b41
          Chris PeBenito 696b41
              /**
          Chris PeBenito 696b41
               * Unregisters an outputfilter function
          Chris PeBenito 696b41
               *
          Chris PeBenito 696b41
               * @param string $function name of PHP function
          Chris PeBenito 696b41
               */
          Chris PeBenito 696b41
              function unregister_outputfilter($function)
          Chris PeBenito 696b41
              {
          Chris PeBenito 696b41
                  unset($this->_plugins['outputfilter'][$function]);
          Chris PeBenito 696b41
              }
          Chris PeBenito 696b41
          Chris PeBenito 696b41
              /**
          Chris PeBenito 696b41
               * load a filter of specified type and name
          Chris PeBenito 696b41
               *
          Chris PeBenito 696b41
               * @param string $type filter type
          Chris PeBenito 696b41
               * @param string $name filter name
          Chris PeBenito 696b41
               */
          Chris PeBenito 696b41
              function load_filter($type, $name)
          Chris PeBenito 696b41
              {
          Chris PeBenito 696b41
                  switch ($type) {
          Chris PeBenito 696b41
                      case 'output':
          Chris PeBenito 696b41
                          $_params = array('plugins' => array(array($type . 'filter', $name, null, null, false)));
          Chris PeBenito 696b41
                          require_once(SMARTY_CORE_DIR . 'core.load_plugins.php');
          Chris PeBenito 696b41
                          smarty_core_load_plugins($_params, $this);
          Chris PeBenito 696b41
                          break;
          Chris PeBenito 696b41
          Chris PeBenito 696b41
                      case 'pre':
          Chris PeBenito 696b41
                      case 'post':
          Chris PeBenito 696b41
                          if (!isset($this->_plugins[$type . 'filter'][$name]))
          Chris PeBenito 696b41
                              $this->_plugins[$type . 'filter'][$name] = false;
          Chris PeBenito 696b41
                          break;
          Chris PeBenito 696b41
                  }
          Chris PeBenito 696b41
              }
          Chris PeBenito 696b41
          Chris PeBenito 696b41
              /**
          Chris PeBenito 696b41
               * clear cached content for the given template and cache id
          Chris PeBenito 696b41
               *
          Chris PeBenito 696b41
               * @param string $tpl_file name of template file
          Chris PeBenito 696b41
               * @param string $cache_id name of cache_id
          Chris PeBenito 696b41
               * @param string $compile_id name of compile_id
          Chris PeBenito 696b41
               * @param string $exp_time expiration time
          Chris PeBenito 696b41
               * @return boolean
          Chris PeBenito 696b41
               */
          Chris PeBenito 696b41
              function clear_cache($tpl_file = null, $cache_id = null, $compile_id = null, $exp_time = null)
          Chris PeBenito 696b41
              {
          Chris PeBenito 696b41
          Chris PeBenito 696b41
                  if (!isset($compile_id))
          Chris PeBenito 696b41
                      $compile_id = $this->compile_id;
          Chris PeBenito 696b41
          Chris PeBenito 696b41
                  if (!isset($tpl_file))
          Chris PeBenito 696b41
                      $compile_id = null;
          Chris PeBenito 696b41
          Chris PeBenito 696b41
                  $_auto_id = $this->_get_auto_id($cache_id, $compile_id);
          Chris PeBenito 696b41
          Chris PeBenito 696b41
                  if (!empty($this->cache_handler_func)) {
          Chris PeBenito 696b41
                      return call_user_func_array($this->cache_handler_func,
          Chris PeBenito 696b41
                                            array('clear', &$this, &$dummy, $tpl_file, $cache_id, $compile_id, $exp_time));
          Chris PeBenito 696b41
                  } else {
          Chris PeBenito 696b41
                      $_params = array('auto_base' => $this->cache_dir,
          Chris PeBenito 696b41
                                      'auto_source' => $tpl_file,
          Chris PeBenito 696b41
                                      'auto_id' => $_auto_id,
          Chris PeBenito 696b41
                                      'exp_time' => $exp_time);
          Chris PeBenito 696b41
                      require_once(SMARTY_CORE_DIR . 'core.rm_auto.php');
          Chris PeBenito 696b41
                      return smarty_core_rm_auto($_params, $this);
          Chris PeBenito 696b41
                  }
          Chris PeBenito 696b41
          Chris PeBenito 696b41
              }
          Chris PeBenito 696b41
          Chris PeBenito 696b41
          Chris PeBenito 696b41
              /**
          Chris PeBenito 696b41
               * clear the entire contents of cache (all templates)
          Chris PeBenito 696b41
               *
          Chris PeBenito 696b41
               * @param string $exp_time expire time
          Chris PeBenito 696b41
               * @return boolean results of {@link smarty_core_rm_auto()}
          Chris PeBenito 696b41
               */
          Chris PeBenito 696b41
              function clear_all_cache($exp_time = null)
          Chris PeBenito 696b41
              {
          Chris PeBenito 696b41
                  return $this->clear_cache(null, null, null, $exp_time);
          Chris PeBenito 696b41
              }
          Chris PeBenito 696b41
          Chris PeBenito 696b41
          Chris PeBenito 696b41
              /**
          Chris PeBenito 696b41
               * test to see if valid cache exists for this template
          Chris PeBenito 696b41
               *
          Chris PeBenito 696b41
               * @param string $tpl_file name of template file
          Chris PeBenito 696b41
               * @param string $cache_id
          Chris PeBenito 696b41
               * @param string $compile_id
          Chris PeBenito 696b41
               * @return string|false results of {@link _read_cache_file()}
          Chris PeBenito 696b41
               */
          Chris PeBenito 696b41
              function is_cached($tpl_file, $cache_id = null, $compile_id = null)
          Chris PeBenito 696b41
              {
          Chris PeBenito 696b41
                  if (!$this->caching)
          Chris PeBenito 696b41
                      return false;
          Chris PeBenito 696b41
          Chris PeBenito 696b41
                  if (!isset($compile_id))
          Chris PeBenito 696b41
                      $compile_id = $this->compile_id;
          Chris PeBenito 696b41
          Chris PeBenito 696b41
                  $_params = array(
          Chris PeBenito 696b41
                      'tpl_file' => $tpl_file,
          Chris PeBenito 696b41
                      'cache_id' => $cache_id,
          Chris PeBenito 696b41
                      'compile_id' => $compile_id
          Chris PeBenito 696b41
                  );
          Chris PeBenito 696b41
                  require_once(SMARTY_CORE_DIR . 'core.read_cache_file.php');
          Chris PeBenito 696b41
                  return smarty_core_read_cache_file($_params, $this);
          Chris PeBenito 696b41
              }
          Chris PeBenito 696b41
          Chris PeBenito 696b41
          Chris PeBenito 696b41
              /**
          Chris PeBenito 696b41
               * clear all the assigned template variables.
          Chris PeBenito 696b41
               *
          Chris PeBenito 696b41
               */
          Chris PeBenito 696b41
              function clear_all_assign()
          Chris PeBenito 696b41
              {
          Chris PeBenito 696b41
                  $this->_tpl_vars = array();
          Chris PeBenito 696b41
              }
          Chris PeBenito 696b41
          Chris PeBenito 696b41
              /**
          Chris PeBenito 696b41
               * clears compiled version of specified template resource,
          Chris PeBenito 696b41
               * or all compiled template files if one is not specified.
          Chris PeBenito 696b41
               * This function is for advanced use only, not normally needed.
          Chris PeBenito 696b41
               *
          Chris PeBenito 696b41
               * @param string $tpl_file
          Chris PeBenito 696b41
               * @param string $compile_id
          Chris PeBenito 696b41
               * @param string $exp_time
          Chris PeBenito 696b41
               * @return boolean results of {@link smarty_core_rm_auto()}
          Chris PeBenito 696b41
               */
          Chris PeBenito 696b41
              function clear_compiled_tpl($tpl_file = null, $compile_id = null, $exp_time = null)
          Chris PeBenito 696b41
              {
          Chris PeBenito 696b41
                  if (!isset($compile_id)) {
          Chris PeBenito 696b41
                      $compile_id = $this->compile_id;
          Chris PeBenito 696b41
                  }
          Chris PeBenito 696b41
                  $_params = array('auto_base' => $this->compile_dir,
          Chris PeBenito 696b41
                                  'auto_source' => $tpl_file,
          Chris PeBenito 696b41
                                  'auto_id' => $compile_id,
          Chris PeBenito 696b41
                                  'exp_time' => $exp_time,
          Chris PeBenito 696b41
                                  'extensions' => array('.inc', '.php'));
          Chris PeBenito 696b41
                  require_once(SMARTY_CORE_DIR . 'core.rm_auto.php');
          Chris PeBenito 696b41
                  return smarty_core_rm_auto($_params, $this);
          Chris PeBenito 696b41
              }
          Chris PeBenito 696b41
          Chris PeBenito 696b41
              /**
          Chris PeBenito 696b41
               * Checks whether requested template exists.
          Chris PeBenito 696b41
               *
          Chris PeBenito 696b41
               * @param string $tpl_file
          Chris PeBenito 696b41
               * @return boolean
          Chris PeBenito 696b41
               */
          Chris PeBenito 696b41
              function template_exists($tpl_file)
          Chris PeBenito 696b41
              {
          Chris PeBenito 696b41
                  $_params = array('resource_name' => $tpl_file, 'quiet'=>true, 'get_source'=>false);
          Chris PeBenito 696b41
                  return $this->_fetch_resource_info($_params);
          Chris PeBenito 696b41
              }
          Chris PeBenito 696b41
          Chris PeBenito 696b41
              /**
          Chris PeBenito 696b41
               * Returns an array containing template variables
          Chris PeBenito 696b41
               *
          Chris PeBenito 696b41
               * @param string $name
          Chris PeBenito 696b41
               * @param string $type
          Chris PeBenito 696b41
               * @return array
          Chris PeBenito 696b41
               */
          Chris PeBenito 696b41
              function &get_template_vars($name=null)
          Chris PeBenito 696b41
              {
          Chris PeBenito 696b41
                  if(!isset($name)) {
          Chris PeBenito 696b41
                      return $this->_tpl_vars;
          Chris PeBenito 696b41
                  }
          Chris PeBenito 696b41
                  if(isset($this->_tpl_vars[$name])) {
          Chris PeBenito 696b41
                      return $this->_tpl_vars[$name];
          Chris PeBenito 696b41
                  }
          Chris PeBenito 696b41
              }
          Chris PeBenito 696b41
          Chris PeBenito 696b41
              /**
          Chris PeBenito 696b41
               * Returns an array containing config variables
          Chris PeBenito 696b41
               *
          Chris PeBenito 696b41
               * @param string $name
          Chris PeBenito 696b41
               * @param string $type
          Chris PeBenito 696b41
               * @return array
          Chris PeBenito 696b41
               */
          Chris PeBenito 696b41
              function &get_config_vars($name=null)
          Chris PeBenito 696b41
              {
          Chris PeBenito 696b41
                  if(!isset($name) && is_array($this->_config[0])) {
          Chris PeBenito 696b41
                      return $this->_config[0]['vars'];
          Chris PeBenito 696b41
                  } else if(isset($this->_config[0]['vars'][$name])) {
          Chris PeBenito 696b41
                      return $this->_config[0]['vars'][$name];
          Chris PeBenito 696b41
                  }
          Chris PeBenito 696b41
              }
          Chris PeBenito 696b41
          Chris PeBenito 696b41
              /**
          Chris PeBenito 696b41
               * trigger Smarty error
          Chris PeBenito 696b41
               *
          Chris PeBenito 696b41
               * @param string $error_msg
          Chris PeBenito 696b41
               * @param integer $error_type
          Chris PeBenito 696b41
               */
          Chris PeBenito 696b41
              function trigger_error($error_msg, $error_type = E_USER_WARNING)
          Chris PeBenito 696b41
              {
          Chris PeBenito 696b41
                  trigger_error("Smarty error: $error_msg", $error_type);
          Chris PeBenito 696b41
              }
          Chris PeBenito 696b41
          Chris PeBenito 696b41
          Chris PeBenito 696b41
              /**
          Chris PeBenito 696b41
               * executes & displays the template results
          Chris PeBenito 696b41
               *
          Chris PeBenito 696b41
               * @param string $resource_name
          Chris PeBenito 696b41
               * @param string $cache_id
          Chris PeBenito 696b41
               * @param string $compile_id
          Chris PeBenito 696b41
               */
          Chris PeBenito 696b41
              function display($resource_name, $cache_id = null, $compile_id = null)
          Chris PeBenito 696b41
              {
          Chris PeBenito 696b41
                  $this->fetch($resource_name, $cache_id, $compile_id, true);
          Chris PeBenito 696b41
              }
          Chris PeBenito 696b41
          Chris PeBenito 696b41
              /**
          Chris PeBenito 696b41
               * executes & returns or displays the template results
          Chris PeBenito 696b41
               *
          Chris PeBenito 696b41
               * @param string $resource_name
          Chris PeBenito 696b41
               * @param string $cache_id
          Chris PeBenito 696b41
               * @param string $compile_id
          Chris PeBenito 696b41
               * @param boolean $display
          Chris PeBenito 696b41
               */
          Chris PeBenito 696b41
              function fetch($resource_name, $cache_id = null, $compile_id = null, $display = false)
          Chris PeBenito 696b41
              {
          Chris PeBenito 696b41
                  static $_cache_info = array();
          Chris PeBenito 696b41
                  
          Chris PeBenito 696b41
                  $_smarty_old_error_level = $this->debugging ? error_reporting() : error_reporting(isset($this->error_reporting)
          Chris PeBenito 696b41
                         ? $this->error_reporting : error_reporting() & ~E_NOTICE);
          Chris PeBenito 696b41
          Chris PeBenito 696b41
                  if (!$this->debugging && $this->debugging_ctrl == 'URL') {
          Chris PeBenito 696b41
                      $_query_string = $this->request_use_auto_globals ? $_SERVER['QUERY_STRING'] : $GLOBALS['HTTP_SERVER_VARS']['QUERY_STRING'];
          Chris PeBenito 696b41
                      if (@strstr($_query_string, $this->_smarty_debug_id)) {
          Chris PeBenito 696b41
                          if (@strstr($_query_string, $this->_smarty_debug_id . '=on')) {
          Chris PeBenito 696b41
                              // enable debugging for this browser session
          Chris PeBenito 696b41
                              @setcookie('SMARTY_DEBUG', true);
          Chris PeBenito 696b41
                              $this->debugging = true;
          Chris PeBenito 696b41
                          } elseif (@strstr($_query_string, $this->_smarty_debug_id . '=off')) {
          Chris PeBenito 696b41
                              // disable debugging for this browser session
          Chris PeBenito 696b41
                              @setcookie('SMARTY_DEBUG', false);
          Chris PeBenito 696b41
                              $this->debugging = false;
          Chris PeBenito 696b41
                          } else {
          Chris PeBenito 696b41
                              // enable debugging for this page
          Chris PeBenito 696b41
                              $this->debugging = true;
          Chris PeBenito 696b41
                          }
          Chris PeBenito 696b41
                      } else {
          Chris PeBenito 696b41
                          $this->debugging = (bool)($this->request_use_auto_globals ? @$_COOKIE['SMARTY_DEBUG'] : @$GLOBALS['HTTP_COOKIE_VARS']['SMARTY_DEBUG']);
          Chris PeBenito 696b41
                      }
          Chris PeBenito 696b41
                  }
          Chris PeBenito 696b41
          Chris PeBenito 696b41
                  if ($this->debugging) {
          Chris PeBenito 696b41
                      // capture time for debugging info
          Chris PeBenito 696b41
                      $_params = array();
          Chris PeBenito 696b41
                      require_once(SMARTY_CORE_DIR . 'core.get_microtime.php');
          Chris PeBenito 696b41
                      $_debug_start_time = smarty_core_get_microtime($_params, $this);
          Chris PeBenito 696b41
                      $this->_smarty_debug_info[] = array('type'      => 'template',
          Chris PeBenito 696b41
                                                          'filename'  => $resource_name,
          Chris PeBenito 696b41
                                                          'depth'     => 0);
          Chris PeBenito 696b41
                      $_included_tpls_idx = count($this->_smarty_debug_info) - 1;
          Chris PeBenito 696b41
                  }
          Chris PeBenito 696b41
          Chris PeBenito 696b41
                  if (!isset($compile_id)) {
          Chris PeBenito 696b41
                      $compile_id = $this->compile_id;
          Chris PeBenito 696b41
                  }
          Chris PeBenito 696b41
          Chris PeBenito 696b41
                  $this->_compile_id = $compile_id;
          Chris PeBenito 696b41
                  $this->_inclusion_depth = 0;
          Chris PeBenito 696b41
          Chris PeBenito 696b41
                  if ($this->caching) {
          Chris PeBenito 696b41
                      // save old cache_info, initialize cache_info
          Chris PeBenito 696b41
                      array_push($_cache_info, $this->_cache_info);
          Chris PeBenito 696b41
                      $this->_cache_info = array();
          Chris PeBenito 696b41
                      $_params = array(
          Chris PeBenito 696b41
                          'tpl_file' => $resource_name,
          Chris PeBenito 696b41
                          'cache_id' => $cache_id,
          Chris PeBenito 696b41
                          'compile_id' => $compile_id,
          Chris PeBenito 696b41
                          'results' => null
          Chris PeBenito 696b41
                      );
          Chris PeBenito 696b41
                      require_once(SMARTY_CORE_DIR . 'core.read_cache_file.php');
          Chris PeBenito 696b41
                      if (smarty_core_read_cache_file($_params, $this)) {
          Chris PeBenito 696b41
                          $_smarty_results = $_params['results'];
          Chris PeBenito 696b41
                          if (!empty($this->_cache_info['insert_tags'])) {
          Chris PeBenito 696b41
                              $_params = array('plugins' => $this->_cache_info['insert_tags']);
          Chris PeBenito 696b41
                              require_once(SMARTY_CORE_DIR . 'core.load_plugins.php');
          Chris PeBenito 696b41
                              smarty_core_load_plugins($_params, $this);
          Chris PeBenito 696b41
                              $_params = array('results' => $_smarty_results);
          Chris PeBenito 696b41
                              require_once(SMARTY_CORE_DIR . 'core.process_cached_inserts.php');
          Chris PeBenito 696b41
                              $_smarty_results = smarty_core_process_cached_inserts($_params, $this);
          Chris PeBenito 696b41
                          }
          Chris PeBenito 696b41
                          if (!empty($this->_cache_info['cache_serials'])) {
          Chris PeBenito 696b41
                              $_params = array('results' => $_smarty_results);
          Chris PeBenito 696b41
                              require_once(SMARTY_CORE_DIR . 'core.process_compiled_include.php');
          Chris PeBenito 696b41
                              $_smarty_results = smarty_core_process_compiled_include($_params, $this);
          Chris PeBenito 696b41
                          }
          Chris PeBenito 696b41
          Chris PeBenito 696b41
          Chris PeBenito 696b41
                          if ($display) {
          Chris PeBenito 696b41
                              if ($this->debugging)
          Chris PeBenito 696b41
                              {
          Chris PeBenito 696b41
                                  // capture time for debugging info
          Chris PeBenito 696b41
                                  $_params = array();
          Chris PeBenito 696b41
                                  require_once(SMARTY_CORE_DIR . 'core.get_microtime.php');
          Chris PeBenito 696b41
                                  $this->_smarty_debug_info[$_included_tpls_idx]['exec_time'] = smarty_core_get_microtime($_params, $this) - $_debug_start_time;
          Chris PeBenito 696b41
                                  require_once(SMARTY_CORE_DIR . 'core.display_debug_console.php');
          Chris PeBenito 696b41
                                  $_smarty_results .= smarty_core_display_debug_console($_params, $this);
          Chris PeBenito 696b41
                              }
          Chris PeBenito 696b41
                              if ($this->cache_modified_check) {
          Chris PeBenito 696b41
                                  $_server_vars = ($this->request_use_auto_globals) ? $_SERVER : $GLOBALS['HTTP_SERVER_VARS'];
          Chris PeBenito 696b41
                                  $_last_modified_date = @substr($_server_vars['HTTP_IF_MODIFIED_SINCE'], 0, strpos($_server_vars['HTTP_IF_MODIFIED_SINCE'], 'GMT') + 3);
          Chris PeBenito 696b41
                                  $_gmt_mtime = gmdate('D, d M Y H:i:s', $this->_cache_info['timestamp']).' GMT';
          Chris PeBenito 696b41
                                  if (@count($this->_cache_info['insert_tags']) == 0
          Chris PeBenito 696b41
                                      && !$this->_cache_serials
          Chris PeBenito 696b41
                                      && $_gmt_mtime == $_last_modified_date) {
          Chris PeBenito 696b41
                                      if (php_sapi_name()=='cgi')
          Chris PeBenito 696b41
                                          header('Status: 304 Not Modified');
          Chris PeBenito 696b41
                                      else
          Chris PeBenito 696b41
                                          header('HTTP/1.1 304 Not Modified');
          Chris PeBenito 696b41
          Chris PeBenito 696b41
                                  } else {
          Chris PeBenito 696b41
                                      header('Last-Modified: '.$_gmt_mtime);
          Chris PeBenito 696b41
                                      echo $_smarty_results;
          Chris PeBenito 696b41
                                  }
          Chris PeBenito 696b41
                              } else {
          Chris PeBenito 696b41
                                      echo $_smarty_results;
          Chris PeBenito 696b41
                              }
          Chris PeBenito 696b41
                              error_reporting($_smarty_old_error_level);
          Chris PeBenito 696b41
                              // restore initial cache_info
          Chris PeBenito 696b41
                              $this->_cache_info = array_pop($_cache_info);
          Chris PeBenito 696b41
                              return true;
          Chris PeBenito 696b41
                          } else {
          Chris PeBenito 696b41
                              error_reporting($_smarty_old_error_level);
          Chris PeBenito 696b41
                              // restore initial cache_info
          Chris PeBenito 696b41
                              $this->_cache_info = array_pop($_cache_info);
          Chris PeBenito 696b41
                              return $_smarty_results;
          Chris PeBenito 696b41
                          }
          Chris PeBenito 696b41
                      } else {
          Chris PeBenito 696b41
                          $this->_cache_info['template'][$resource_name] = true;
          Chris PeBenito 696b41
                          if ($this->cache_modified_check && $display) {
          Chris PeBenito 696b41
                              header('Last-Modified: '.gmdate('D, d M Y H:i:s', time()).' GMT');
          Chris PeBenito 696b41
                          }
          Chris PeBenito 696b41
                      }
          Chris PeBenito 696b41
                  }
          Chris PeBenito 696b41
          Chris PeBenito 696b41
                  // load filters that are marked as autoload
          Chris PeBenito 696b41
                  if (count($this->autoload_filters)) {
          Chris PeBenito 696b41
                      foreach ($this->autoload_filters as $_filter_type => $_filters) {
          Chris PeBenito 696b41
                          foreach ($_filters as $_filter) {
          Chris PeBenito 696b41
                              $this->load_filter($_filter_type, $_filter);
          Chris PeBenito 696b41
                          }
          Chris PeBenito 696b41
                      }
          Chris PeBenito 696b41
                  }
          Chris PeBenito 696b41
          Chris PeBenito 696b41
                  $_smarty_compile_path = $this->_get_compile_path($resource_name);
          Chris PeBenito 696b41
          Chris PeBenito 696b41
                  // if we just need to display the results, don't perform output
          Chris PeBenito 696b41
                  // buffering - for speed
          Chris PeBenito 696b41
                  $_cache_including = $this->_cache_including;
          Chris PeBenito 696b41
                  $this->_cache_including = false;
          Chris PeBenito 696b41
                  if ($display && !$this->caching && count($this->_plugins['outputfilter']) == 0) {
          Chris PeBenito 696b41
                      if ($this->_is_compiled($resource_name, $_smarty_compile_path)
          Chris PeBenito 696b41
                              || $this->_compile_resource($resource_name, $_smarty_compile_path))
          Chris PeBenito 696b41
                      {
          Chris PeBenito 696b41
                          include($_smarty_compile_path);
          Chris PeBenito 696b41
                      }
          Chris PeBenito 696b41
                  } else {
          Chris PeBenito 696b41
                      ob_start();
          Chris PeBenito 696b41
                      if ($this->_is_compiled($resource_name, $_smarty_compile_path)
          Chris PeBenito 696b41
                              || $this->_compile_resource($resource_name, $_smarty_compile_path))
          Chris PeBenito 696b41
                      {
          Chris PeBenito 696b41
                          include($_smarty_compile_path);
          Chris PeBenito 696b41
                      }
          Chris PeBenito 696b41
                      $_smarty_results = ob_get_contents();
          Chris PeBenito 696b41
                      ob_end_clean();
          Chris PeBenito 696b41
          Chris PeBenito 696b41
                      foreach ((array)$this->_plugins['outputfilter'] as $_output_filter) {
          Chris PeBenito 696b41
                          $_smarty_results = call_user_func_array($_output_filter[0], array($_smarty_results, &$this));
          Chris PeBenito 696b41
                      }
          Chris PeBenito 696b41
                  }
          Chris PeBenito 696b41
          Chris PeBenito 696b41
                  if ($this->caching) {
          Chris PeBenito 696b41
                      $_params = array('tpl_file' => $resource_name,
          Chris PeBenito 696b41
                                  'cache_id' => $cache_id,
          Chris PeBenito 696b41
                                  'compile_id' => $compile_id,
          Chris PeBenito 696b41
                                  'results' => $_smarty_results);
          Chris PeBenito 696b41
                      require_once(SMARTY_CORE_DIR . 'core.write_cache_file.php');
          Chris PeBenito 696b41
                      smarty_core_write_cache_file($_params, $this);
          Chris PeBenito 696b41
                      require_once(SMARTY_CORE_DIR . 'core.process_cached_inserts.php');
          Chris PeBenito 696b41
                      $_smarty_results = smarty_core_process_cached_inserts($_params, $this);
          Chris PeBenito 696b41
          Chris PeBenito 696b41
                      if ($this->_cache_serials) {
          Chris PeBenito 696b41
                          // strip nocache-tags from output
          Chris PeBenito 696b41
                          $_smarty_results = preg_replace('!(\{/?nocache\:[0-9a-f]{32}#\d+\})!s'
          Chris PeBenito 696b41
                                                          ,''
          Chris PeBenito 696b41
                                                          ,$_smarty_results);
          Chris PeBenito 696b41
                      }
          Chris PeBenito 696b41
                      // restore initial cache_info
          Chris PeBenito 696b41
                      $this->_cache_info = array_pop($_cache_info);
          Chris PeBenito 696b41
                  }
          Chris PeBenito 696b41
                  $this->_cache_including = $_cache_including;
          Chris PeBenito 696b41
          Chris PeBenito 696b41
                  if ($display) {
          Chris PeBenito 696b41
                      if (isset($_smarty_results)) { echo $_smarty_results; }
          Chris PeBenito 696b41
                      if ($this->debugging) {
          Chris PeBenito 696b41
                          // capture time for debugging info
          Chris PeBenito 696b41
                          $_params = array();
          Chris PeBenito 696b41
                          require_once(SMARTY_CORE_DIR . 'core.get_microtime.php');
          Chris PeBenito 696b41
                          $this->_smarty_debug_info[$_included_tpls_idx]['exec_time'] = (smarty_core_get_microtime($_params, $this) - $_debug_start_time);
          Chris PeBenito 696b41
                          require_once(SMARTY_CORE_DIR . 'core.display_debug_console.php');
          Chris PeBenito 696b41
                          echo smarty_core_display_debug_console($_params, $this);
          Chris PeBenito 696b41
                      }
          Chris PeBenito 696b41
                      error_reporting($_smarty_old_error_level);
          Chris PeBenito 696b41
                      return;
          Chris PeBenito 696b41
                  } else {
          Chris PeBenito 696b41
                      error_reporting($_smarty_old_error_level);
          Chris PeBenito 696b41
                      if (isset($_smarty_results)) { return $_smarty_results; }
          Chris PeBenito 696b41
                  }
          Chris PeBenito 696b41
              }
          Chris PeBenito 696b41
          Chris PeBenito 696b41
              /**
          Chris PeBenito 696b41
               * load configuration values
          Chris PeBenito 696b41
               *
          Chris PeBenito 696b41
               * @param string $file
          Chris PeBenito 696b41
               * @param string $section
          Chris PeBenito 696b41
               * @param string $scope
          Chris PeBenito 696b41
               */
          Chris PeBenito 696b41
              function config_load($file, $section = null, $scope = 'global')
          Chris PeBenito 696b41
              {
          Chris PeBenito 696b41
                  require_once($this->_get_plugin_filepath('function', 'config_load'));
          Chris PeBenito 696b41
                  smarty_function_config_load(array('file' => $file, 'section' => $section, 'scope' => $scope), $this);
          Chris PeBenito 696b41
              }
          Chris PeBenito 696b41
          Chris PeBenito 696b41
              /**
          Chris PeBenito 696b41
               * return a reference to a registered object
          Chris PeBenito 696b41
               *
          Chris PeBenito 696b41
               * @param string $name
          Chris PeBenito 696b41
               * @return object
          Chris PeBenito 696b41
               */
          Chris PeBenito 696b41
              function &get_registered_object($name) {
          Chris PeBenito 696b41
                  if (!isset($this->_reg_objects[$name]))
          Chris PeBenito 696b41
                  $this->_trigger_fatal_error("'$name' is not a registered object");
          Chris PeBenito 696b41
          Chris PeBenito 696b41
                  if (!is_object($this->_reg_objects[$name][0]))
          Chris PeBenito 696b41
                  $this->_trigger_fatal_error("registered '$name' is not an object");
          Chris PeBenito 696b41
          Chris PeBenito 696b41
                  return $this->_reg_objects[$name][0];
          Chris PeBenito 696b41
              }
          Chris PeBenito 696b41
          Chris PeBenito 696b41
              /**
          Chris PeBenito 696b41
               * clear configuration values
          Chris PeBenito 696b41
               *
          Chris PeBenito 696b41
               * @param string $var
          Chris PeBenito 696b41
               */
          Chris PeBenito 696b41
              function clear_config($var = null)
          Chris PeBenito 696b41
              {
          Chris PeBenito 696b41
                  if(!isset($var)) {
          Chris PeBenito 696b41
                      // clear all values
          Chris PeBenito 696b41
                      $this->_config = array(array('vars'  => array(),
          Chris PeBenito 696b41
                                                   'files' => array()));
          Chris PeBenito 696b41
                  } else {
          Chris PeBenito 696b41
                      unset($this->_config[0]['vars'][$var]);
          Chris PeBenito 696b41
                  }
          Chris PeBenito 696b41
              }
          Chris PeBenito 696b41
          Chris PeBenito 696b41
              /**
          Chris PeBenito 696b41
               * get filepath of requested plugin
          Chris PeBenito 696b41
               *
          Chris PeBenito 696b41
               * @param string $type
          Chris PeBenito 696b41
               * @param string $name
          Chris PeBenito 696b41
               * @return string|false
          Chris PeBenito 696b41
               */
          Chris PeBenito 696b41
              function _get_plugin_filepath($type, $name)
          Chris PeBenito 696b41
              {
          Chris PeBenito 696b41
                  $_params = array('type' => $type, 'name' => $name);
          Chris PeBenito 696b41
                  require_once(SMARTY_CORE_DIR . 'core.assemble_plugin_filepath.php');
          Chris PeBenito 696b41
                  return smarty_core_assemble_plugin_filepath($_params, $this);
          Chris PeBenito 696b41
              }
          Chris PeBenito 696b41
          Chris PeBenito 696b41
             /**
          Chris PeBenito 696b41
               * test if resource needs compiling
          Chris PeBenito 696b41
               *
          Chris PeBenito 696b41
               * @param string $resource_name
          Chris PeBenito 696b41
               * @param string $compile_path
          Chris PeBenito 696b41
               * @return boolean
          Chris PeBenito 696b41
               */
          Chris PeBenito 696b41
              function _is_compiled($resource_name, $compile_path)
          Chris PeBenito 696b41
              {
          Chris PeBenito 696b41
                  if (!$this->force_compile && file_exists($compile_path)) {
          Chris PeBenito 696b41
                      if (!$this->compile_check) {
          Chris PeBenito 696b41
                          // no need to check compiled file
          Chris PeBenito 696b41
                          return true;
          Chris PeBenito 696b41
                      } else {
          Chris PeBenito 696b41
                          // get file source and timestamp
          Chris PeBenito 696b41
                          $_params = array('resource_name' => $resource_name, 'get_source'=>false);
          Chris PeBenito 696b41
                          if (!$this->_fetch_resource_info($_params)) {
          Chris PeBenito 696b41
                              return false;
          Chris PeBenito 696b41
                          }
          Chris PeBenito 696b41
                          if ($_params['resource_timestamp'] <= filemtime($compile_path)) {
          Chris PeBenito 696b41
                              // template not expired, no recompile
          Chris PeBenito 696b41
                              return true;
          Chris PeBenito 696b41
                          } else {
          Chris PeBenito 696b41
                              // compile template
          Chris PeBenito 696b41
                              return false;
          Chris PeBenito 696b41
                          }
          Chris PeBenito 696b41
                      }
          Chris PeBenito 696b41
                  } else {
          Chris PeBenito 696b41
                      // compiled template does not exist, or forced compile
          Chris PeBenito 696b41
                      return false;
          Chris PeBenito 696b41
                  }
          Chris PeBenito 696b41
              }
          Chris PeBenito 696b41
          Chris PeBenito 696b41
             /**
          Chris PeBenito 696b41
               * compile the template
          Chris PeBenito 696b41
               *
          Chris PeBenito 696b41
               * @param string $resource_name
          Chris PeBenito 696b41
               * @param string $compile_path
          Chris PeBenito 696b41
               * @return boolean
          Chris PeBenito 696b41
               */
          Chris PeBenito 696b41
              function _compile_resource($resource_name, $compile_path)
          Chris PeBenito 696b41
              {
          Chris PeBenito 696b41
          Chris PeBenito 696b41
                  $_params = array('resource_name' => $resource_name);
          Chris PeBenito 696b41
                  if (!$this->_fetch_resource_info($_params)) {
          Chris PeBenito 696b41
                      return false;
          Chris PeBenito 696b41
                  }
          Chris PeBenito 696b41
          Chris PeBenito 696b41
                  $_source_content = $_params['source_content'];
          Chris PeBenito 696b41
                  $_cache_include    = substr($compile_path, 0, -4).'.inc';
          Chris PeBenito 696b41
          Chris PeBenito 696b41
                  if ($this->_compile_source($resource_name, $_source_content, $_compiled_content, $_cache_include)) {
          Chris PeBenito 696b41
                      // if a _cache_serial was set, we also have to write an include-file:
          Chris PeBenito 696b41
                      if ($this->_cache_include_info) {
          Chris PeBenito 696b41
                          require_once(SMARTY_CORE_DIR . 'core.write_compiled_include.php');
          Chris PeBenito 696b41
                          smarty_core_write_compiled_include(array_merge($this->_cache_include_info, array('compiled_content'=>$_compiled_content, 'resource_name'=>$resource_name)),  $this);
          Chris PeBenito 696b41
                      }
          Chris PeBenito 696b41
          Chris PeBenito 696b41
                      $_params = array('compile_path'=>$compile_path, 'compiled_content' => $_compiled_content);
          Chris PeBenito 696b41
                      require_once(SMARTY_CORE_DIR . 'core.write_compiled_resource.php');
          Chris PeBenito 696b41
                      smarty_core_write_compiled_resource($_params, $this);
          Chris PeBenito 696b41
          Chris PeBenito 696b41
                      return true;
          Chris PeBenito 696b41
                  } else {
          Chris PeBenito 696b41
                      return false;
          Chris PeBenito 696b41
                  }
          Chris PeBenito 696b41
          Chris PeBenito 696b41
              }
          Chris PeBenito 696b41
          Chris PeBenito 696b41
             /**
          Chris PeBenito 696b41
               * compile the given source
          Chris PeBenito 696b41
               *
          Chris PeBenito 696b41
               * @param string $resource_name
          Chris PeBenito 696b41
               * @param string $source_content
          Chris PeBenito 696b41
               * @param string $compiled_content
          Chris PeBenito 696b41
               * @return boolean
          Chris PeBenito 696b41
               */
          Chris PeBenito 696b41
              function _compile_source($resource_name, &$source_content, &$compiled_content, $cache_include_path=null)
          Chris PeBenito 696b41
              {
          Chris PeBenito 696b41
                  if (file_exists(SMARTY_DIR . $this->compiler_file)) {
          Chris PeBenito 696b41
                      require_once(SMARTY_DIR . $this->compiler_file);
          Chris PeBenito 696b41
                  } else {
          Chris PeBenito 696b41
                      // use include_path
          Chris PeBenito 696b41
                      require_once($this->compiler_file);
          Chris PeBenito 696b41
                  }
          Chris PeBenito 696b41
          Chris PeBenito 696b41
          Chris PeBenito 696b41
                  $smarty_compiler = new $this->compiler_class;
          Chris PeBenito 696b41
          Chris PeBenito 696b41
                  $smarty_compiler->template_dir      = $this->template_dir;
          Chris PeBenito 696b41
                  $smarty_compiler->compile_dir       = $this->compile_dir;
          Chris PeBenito 696b41
                  $smarty_compiler->plugins_dir       = $this->plugins_dir;
          Chris PeBenito 696b41
                  $smarty_compiler->config_dir        = $this->config_dir;
          Chris PeBenito 696b41
                  $smarty_compiler->force_compile     = $this->force_compile;
          Chris PeBenito 696b41
                  $smarty_compiler->caching           = $this->caching;
          Chris PeBenito 696b41
                  $smarty_compiler->php_handling      = $this->php_handling;
          Chris PeBenito 696b41
                  $smarty_compiler->left_delimiter    = $this->left_delimiter;
          Chris PeBenito 696b41
                  $smarty_compiler->right_delimiter   = $this->right_delimiter;
          Chris PeBenito 696b41
                  $smarty_compiler->_version          = $this->_version;
          Chris PeBenito 696b41
                  $smarty_compiler->security          = $this->security;
          Chris PeBenito 696b41
                  $smarty_compiler->secure_dir        = $this->secure_dir;
          Chris PeBenito 696b41
                  $smarty_compiler->security_settings = $this->security_settings;
          Chris PeBenito 696b41
                  $smarty_compiler->trusted_dir       = $this->trusted_dir;
          Chris PeBenito 696b41
                  $smarty_compiler->use_sub_dirs      = $this->use_sub_dirs;
          Chris PeBenito 696b41
                  $smarty_compiler->_reg_objects      = &$this->_reg_objects;
          Chris PeBenito 696b41
                  $smarty_compiler->_plugins          = &$this->_plugins;
          Chris PeBenito 696b41
                  $smarty_compiler->_tpl_vars         = &$this->_tpl_vars;
          Chris PeBenito 696b41
                  $smarty_compiler->default_modifiers = $this->default_modifiers;
          Chris PeBenito 696b41
                  $smarty_compiler->compile_id        = $this->_compile_id;
          Chris PeBenito 696b41
                  $smarty_compiler->_config            = $this->_config;
          Chris PeBenito 696b41
                  $smarty_compiler->request_use_auto_globals  = $this->request_use_auto_globals;
          Chris PeBenito 696b41
          Chris PeBenito 696b41
                  if (isset($cache_include_path) && isset($this->_cache_serials[$cache_include_path])) {
          Chris PeBenito 696b41
                      $smarty_compiler->_cache_serial = $this->_cache_serials[$cache_include_path];
          Chris PeBenito 696b41
                  }
          Chris PeBenito 696b41
                  $smarty_compiler->_cache_include = $cache_include_path;
          Chris PeBenito 696b41
          Chris PeBenito 696b41
          Chris PeBenito 696b41
                  $_results = $smarty_compiler->_compile_file($resource_name, $source_content, $compiled_content);
          Chris PeBenito 696b41
          Chris PeBenito 696b41
                  if ($smarty_compiler->_cache_serial) {
          Chris PeBenito 696b41
                      $this->_cache_include_info = array(
          Chris PeBenito 696b41
                          'cache_serial'=>$smarty_compiler->_cache_serial
          Chris PeBenito 696b41
                          ,'plugins_code'=>$smarty_compiler->_plugins_code
          Chris PeBenito 696b41
                          ,'include_file_path' => $cache_include_path);
          Chris PeBenito 696b41
          Chris PeBenito 696b41
                  } else {
          Chris PeBenito 696b41
                      $this->_cache_include_info = null;
          Chris PeBenito 696b41
          Chris PeBenito 696b41
                  }
          Chris PeBenito 696b41
          Chris PeBenito 696b41
                  return $_results;
          Chris PeBenito 696b41
              }
          Chris PeBenito 696b41
          Chris PeBenito 696b41
              /**
          Chris PeBenito 696b41
               * Get the compile path for this resource
          Chris PeBenito 696b41
               *
          Chris PeBenito 696b41
               * @param string $resource_name
          Chris PeBenito 696b41
               * @return string results of {@link _get_auto_filename()}
          Chris PeBenito 696b41
               */
          Chris PeBenito 696b41
              function _get_compile_path($resource_name)
          Chris PeBenito 696b41
              {
          Chris PeBenito 696b41
                  return $this->_get_auto_filename($this->compile_dir, $resource_name,
          Chris PeBenito 696b41
                                                   $this->_compile_id) . '.php';
          Chris PeBenito 696b41
              }
          Chris PeBenito 696b41
          Chris PeBenito 696b41
              /**
          Chris PeBenito 696b41
               * fetch the template info. Gets timestamp, and source
          Chris PeBenito 696b41
               * if get_source is true
          Chris PeBenito 696b41
               *
          Chris PeBenito 696b41
               * sets $source_content to the source of the template, and
          Chris PeBenito 696b41
               * $resource_timestamp to its time stamp
          Chris PeBenito 696b41
               * @param string $resource_name
          Chris PeBenito 696b41
               * @param string $source_content
          Chris PeBenito 696b41
               * @param integer $resource_timestamp
          Chris PeBenito 696b41
               * @param boolean $get_source
          Chris PeBenito 696b41
               * @param boolean $quiet
          Chris PeBenito 696b41
               * @return boolean
          Chris PeBenito 696b41
               */
          Chris PeBenito 696b41
          Chris PeBenito 696b41
              function _fetch_resource_info(&$params)
          Chris PeBenito 696b41
              {
          Chris PeBenito 696b41
                  if(!isset($params['get_source'])) { $params['get_source'] = true; }
          Chris PeBenito 696b41
                  if(!isset($params['quiet'])) { $params['quiet'] = false; }
          Chris PeBenito 696b41
          Chris PeBenito 696b41
                  $_return = false;
          Chris PeBenito 696b41
                  $_params = array('resource_name' => $params['resource_name']) ;
          Chris PeBenito 696b41
                  if (isset($params['resource_base_path']))
          Chris PeBenito 696b41
                      $_params['resource_base_path'] = $params['resource_base_path'];
          Chris PeBenito 696b41
                  else
          Chris PeBenito 696b41
                      $_params['resource_base_path'] = $this->template_dir;
          Chris PeBenito 696b41
          Chris PeBenito 696b41
                  if ($this->_parse_resource_name($_params)) {
          Chris PeBenito 696b41
                      $_resource_type = $_params['resource_type'];
          Chris PeBenito 696b41
                      $_resource_name = $_params['resource_name'];
          Chris PeBenito 696b41
                      switch ($_resource_type) {
          Chris PeBenito 696b41
                          case 'file':
          Chris PeBenito 696b41
                              if ($params['get_source']) {
          Chris PeBenito 696b41
                                  $params['source_content'] = $this->_read_file($_resource_name);
          Chris PeBenito 696b41
                              }
          Chris PeBenito 696b41
                              $params['resource_timestamp'] = filemtime($_resource_name);
          Chris PeBenito 696b41
                              $_return = is_file($_resource_name);
          Chris PeBenito 696b41
                              break;
          Chris PeBenito 696b41
          Chris PeBenito 696b41
                          default:
          Chris PeBenito 696b41
                              // call resource functions to fetch the template source and timestamp
          Chris PeBenito 696b41
                              if ($params['get_source']) {
          Chris PeBenito 696b41
                                  $_source_return = isset($this->_plugins['resource'][$_resource_type]) &&
          Chris PeBenito 696b41
                                      call_user_func_array($this->_plugins['resource'][$_resource_type][0][0],
          Chris PeBenito 696b41
                                                           array($_resource_name, &$params['source_content'], &$this));
          Chris PeBenito 696b41
                              } else {
          Chris PeBenito 696b41
                                  $_source_return = true;
          Chris PeBenito 696b41
                              }
          Chris PeBenito 696b41
          Chris PeBenito 696b41
                              $_timestamp_return = isset($this->_plugins['resource'][$_resource_type]) &&
          Chris PeBenito 696b41
                                  call_user_func_array($this->_plugins['resource'][$_resource_type][0][1],
          Chris PeBenito 696b41
                                                       array($_resource_name, &$params['resource_timestamp'], &$this));
          Chris PeBenito 696b41
          Chris PeBenito 696b41
                              $_return = $_source_return && $_timestamp_return;
          Chris PeBenito 696b41
                              break;
          Chris PeBenito 696b41
                      }
          Chris PeBenito 696b41
                  }
          Chris PeBenito 696b41
          Chris PeBenito 696b41
                  if (!$_return) {
          Chris PeBenito 696b41
                      // see if we can get a template with the default template handler
          Chris PeBenito 696b41
                      if (!empty($this->default_template_handler_func)) {
          Chris PeBenito 696b41
                          if (!is_callable($this->default_template_handler_func)) {
          Chris PeBenito 696b41
                              $this->trigger_error("default template handler function \"$this->default_template_handler_func\" doesn't exist.");
          Chris PeBenito 696b41
                          } else {
          Chris PeBenito 696b41
                              $_return = call_user_func_array(
          Chris PeBenito 696b41
                                  $this->default_template_handler_func,
          Chris PeBenito 696b41
                                  array($_params['resource_type'], $_params['resource_name'], &$params['source_content'], &$params['resource_timestamp'], &$this));
          Chris PeBenito 696b41
                          }
          Chris PeBenito 696b41
                      }
          Chris PeBenito 696b41
                  }
          Chris PeBenito 696b41
          Chris PeBenito 696b41
                  if (!$_return) {
          Chris PeBenito 696b41
                      if (!$params['quiet']) {
          Chris PeBenito 696b41
                          $this->trigger_error('unable to read resource: "' . $params['resource_name'] . '"');
          Chris PeBenito 696b41
                      }
          Chris PeBenito 696b41
                  } else if ($_return && $this->security) {
          Chris PeBenito 696b41
                      require_once(SMARTY_CORE_DIR . 'core.is_secure.php');
          Chris PeBenito 696b41
                      if (!smarty_core_is_secure($_params, $this)) {
          Chris PeBenito 696b41
                          if (!$params['quiet'])
          Chris PeBenito 696b41
                              $this->trigger_error('(secure mode) accessing "' . $params['resource_name'] . '" is not allowed');
          Chris PeBenito 696b41
                          $params['source_content'] = null;
          Chris PeBenito 696b41
                          $params['resource_timestamp'] = null;
          Chris PeBenito 696b41
                          return false;
          Chris PeBenito 696b41
                      }
          Chris PeBenito 696b41
                  }
          Chris PeBenito 696b41
                  return $_return;
          Chris PeBenito 696b41
              }
          Chris PeBenito 696b41
          Chris PeBenito 696b41
          Chris PeBenito 696b41
              /**
          Chris PeBenito 696b41
               * parse out the type and name from the resource
          Chris PeBenito 696b41
               *
          Chris PeBenito 696b41
               * @param string $resource_base_path
          Chris PeBenito 696b41
               * @param string $resource_name
          Chris PeBenito 696b41
               * @param string $resource_type
          Chris PeBenito 696b41
               * @param string $resource_name
          Chris PeBenito 696b41
               * @return boolean
          Chris PeBenito 696b41
               */
          Chris PeBenito 696b41
          Chris PeBenito 696b41
              function _parse_resource_name(&$params)
          Chris PeBenito 696b41
              {
          Chris PeBenito 696b41
          Chris PeBenito 696b41
                  // split tpl_path by the first colon
          Chris PeBenito 696b41
                  $_resource_name_parts = explode(':', $params['resource_name'], 2);
          Chris PeBenito 696b41
          Chris PeBenito 696b41
                  if (count($_resource_name_parts) == 1) {
          Chris PeBenito 696b41
                      // no resource type given
          Chris PeBenito 696b41
                      $params['resource_type'] = $this->default_resource_type;
          Chris PeBenito 696b41
                      $params['resource_name'] = $_resource_name_parts[0];
          Chris PeBenito 696b41
                  } else {
          Chris PeBenito 696b41
                      if(strlen($_resource_name_parts[0]) == 1) {
          Chris PeBenito 696b41
                          // 1 char is not resource type, but part of filepath
          Chris PeBenito 696b41
                          $params['resource_type'] = $this->default_resource_type;
          Chris PeBenito 696b41
                          $params['resource_name'] = $params['resource_name'];
          Chris PeBenito 696b41
                      } else {
          Chris PeBenito 696b41
                          $params['resource_type'] = $_resource_name_parts[0];
          Chris PeBenito 696b41
                          $params['resource_name'] = $_resource_name_parts[1];
          Chris PeBenito 696b41
                      }
          Chris PeBenito 696b41
                  }
          Chris PeBenito 696b41
          Chris PeBenito 696b41
                  if ($params['resource_type'] == 'file') {
          Chris PeBenito 696b41
                      if (!preg_match('/^([\/\\\\]|[a-zA-Z]:[\/\\\\])/', $params['resource_name'])) {
          Chris PeBenito 696b41
                          // relative pathname to $params['resource_base_path']
          Chris PeBenito 696b41
                          // use the first directory where the file is found
          Chris PeBenito 696b41
                          foreach ((array)$params['resource_base_path'] as $_curr_path) {
          Chris PeBenito 696b41
                              $_fullpath = $_curr_path . DIRECTORY_SEPARATOR . $params['resource_name'];
          Chris PeBenito 696b41
                              if (file_exists($_fullpath) && is_file($_fullpath)) {
          Chris PeBenito 696b41
                                  $params['resource_name'] = $_fullpath;
          Chris PeBenito 696b41
                                  return true;
          Chris PeBenito 696b41
                              }
          Chris PeBenito 696b41
                              // didn't find the file, try include_path
          Chris PeBenito 696b41
                              $_params = array('file_path' => $_fullpath);
          Chris PeBenito 696b41
                              require_once(SMARTY_CORE_DIR . 'core.get_include_path.php');
          Chris PeBenito 696b41
                              if(smarty_core_get_include_path($_params, $this)) {
          Chris PeBenito 696b41
                                  $params['resource_name'] = $_params['new_file_path'];
          Chris PeBenito 696b41
                                  return true;
          Chris PeBenito 696b41
                              }
          Chris PeBenito 696b41
                          }
          Chris PeBenito 696b41
                          return false;
          Chris PeBenito 696b41
                      } else {
          Chris PeBenito 696b41
                          /* absolute path */
          Chris PeBenito 696b41
                          return file_exists($params['resource_name']);
          Chris PeBenito 696b41
                      }
          Chris PeBenito 696b41
                  } elseif (empty($this->_plugins['resource'][$params['resource_type']])) {
          Chris PeBenito 696b41
                      $_params = array('type' => $params['resource_type']);
          Chris PeBenito 696b41
                      require_once(SMARTY_CORE_DIR . 'core.load_resource_plugin.php');
          Chris PeBenito 696b41
                      smarty_core_load_resource_plugin($_params, $this);
          Chris PeBenito 696b41
                  }
          Chris PeBenito 696b41
          Chris PeBenito 696b41
                  return true;
          Chris PeBenito 696b41
              }
          Chris PeBenito 696b41
          Chris PeBenito 696b41
          Chris PeBenito 696b41
              /**
          Chris PeBenito 696b41
               * Handle modifiers
          Chris PeBenito 696b41
               *
          Chris PeBenito 696b41
               * @param string|null $modifier_name
          Chris PeBenito 696b41
               * @param array|null $map_array
          Chris PeBenito 696b41
               * @return string result of modifiers
          Chris PeBenito 696b41
               */
          Chris PeBenito 696b41
              function _run_mod_handler()
          Chris PeBenito 696b41
              {
          Chris PeBenito 696b41
                  $_args = func_get_args();
          Chris PeBenito 696b41
                  list($_modifier_name, $_map_array) = array_splice($_args, 0, 2);
          Chris PeBenito 696b41
                  list($_func_name, $_tpl_file, $_tpl_line) =
          Chris PeBenito 696b41
                      $this->_plugins['modifier'][$_modifier_name];
          Chris PeBenito 696b41
          Chris PeBenito 696b41
                  $_var = $_args[0];
          Chris PeBenito 696b41
                  foreach ($_var as $_key => $_val) {
          Chris PeBenito 696b41
                      $_args[0] = $_val;
          Chris PeBenito 696b41
                      $_var[$_key] = call_user_func_array($_func_name, $_args);
          Chris PeBenito 696b41
                  }
          Chris PeBenito 696b41
                  return $_var;
          Chris PeBenito 696b41
              }
          Chris PeBenito 696b41
          Chris PeBenito 696b41
              /**
          Chris PeBenito 696b41
               * Remove starting and ending quotes from the string
          Chris PeBenito 696b41
               *
          Chris PeBenito 696b41
               * @param string $string
          Chris PeBenito 696b41
               * @return string
          Chris PeBenito 696b41
               */
          Chris PeBenito 696b41
              function _dequote($string)
          Chris PeBenito 696b41
              {
          Chris PeBenito 696b41
                  if (($string{0} == "'" || $string{0} == '"') &&
          Chris PeBenito 696b41
                      $string{strlen($string)-1} == $string{0})
          Chris PeBenito 696b41
                      return substr($string, 1, -1);
          Chris PeBenito 696b41
                  else
          Chris PeBenito 696b41
                      return $string;
          Chris PeBenito 696b41
              }
          Chris PeBenito 696b41
          Chris PeBenito 696b41
          Chris PeBenito 696b41
              /**
          Chris PeBenito 696b41
               * read in a file
          Chris PeBenito 696b41
               *
          Chris PeBenito 696b41
               * @param string $filename
          Chris PeBenito 696b41
               * @return string
          Chris PeBenito 696b41
               */
          Chris PeBenito 696b41
              function _read_file($filename)
          Chris PeBenito 696b41
              {
          Chris PeBenito 696b41
                  if ( file_exists($filename) && ($fd = @fopen($filename, 'rb')) ) {
          Chris PeBenito 696b41
                      $contents = ($size = filesize($filename)) ? fread($fd, $size) : '';
          Chris PeBenito 696b41
                      fclose($fd);
          Chris PeBenito 696b41
                      return $contents;
          Chris PeBenito 696b41
                  } else {
          Chris PeBenito 696b41
                      return false;
          Chris PeBenito 696b41
                  }
          Chris PeBenito 696b41
              }
          Chris PeBenito 696b41
          Chris PeBenito 696b41
              /**
          Chris PeBenito 696b41
               * get a concrete filename for automagically created content
          Chris PeBenito 696b41
               *
          Chris PeBenito 696b41
               * @param string $auto_base
          Chris PeBenito 696b41
               * @param string $auto_source
          Chris PeBenito 696b41
               * @param string $auto_id
          Chris PeBenito 696b41
               * @return string
          Chris PeBenito 696b41
               * @staticvar string|null
          Chris PeBenito 696b41
               * @staticvar string|null
          Chris PeBenito 696b41
               */
          Chris PeBenito 696b41
              function _get_auto_filename($auto_base, $auto_source = null, $auto_id = null)
          Chris PeBenito 696b41
              {
          Chris PeBenito 696b41
                  $_compile_dir_sep =  $this->use_sub_dirs ? DIRECTORY_SEPARATOR : '^';
          Chris PeBenito 696b41
                  $_return = $auto_base . DIRECTORY_SEPARATOR;
          Chris PeBenito 696b41
          Chris PeBenito 696b41
                  if(isset($auto_id)) {
          Chris PeBenito 696b41
                      // make auto_id safe for directory names
          Chris PeBenito 696b41
                      $auto_id = str_replace('%7C',$_compile_dir_sep,(urlencode($auto_id)));
          Chris PeBenito 696b41
                      // split into separate directories
          Chris PeBenito 696b41
                      $_return .= $auto_id . $_compile_dir_sep;
          Chris PeBenito 696b41
                  }
          Chris PeBenito 696b41
          Chris PeBenito 696b41
                  if(isset($auto_source)) {
          Chris PeBenito 696b41
                      // make source name safe for filename
          Chris PeBenito 696b41
                      $_filename = urlencode(basename($auto_source));
          Chris PeBenito 696b41
                      $_crc32 = sprintf('%08X', crc32($auto_source));
          Chris PeBenito 696b41
                      // prepend %% to avoid name conflicts with
          Chris PeBenito 696b41
                      // with $params['auto_id'] names
          Chris PeBenito 696b41
                      $_crc32 = substr($_crc32, 0, 2) . $_compile_dir_sep .
          Chris PeBenito 696b41
                                substr($_crc32, 0, 3) . $_compile_dir_sep . $_crc32;
          Chris PeBenito 696b41
                      $_return .= '%%' . $_crc32 . '%%' . $_filename;
          Chris PeBenito 696b41
                  }
          Chris PeBenito 696b41
          Chris PeBenito 696b41
                  return $_return;
          Chris PeBenito 696b41
              }
          Chris PeBenito 696b41
          Chris PeBenito 696b41
              /**
          Chris PeBenito 696b41
               * unlink a file, possibly using expiration time
          Chris PeBenito 696b41
               *
          Chris PeBenito 696b41
               * @param string $resource
          Chris PeBenito 696b41
               * @param integer $exp_time
          Chris PeBenito 696b41
               */
          Chris PeBenito 696b41
              function _unlink($resource, $exp_time = null)
          Chris PeBenito 696b41
              {
          Chris PeBenito 696b41
                  if(isset($exp_time)) {
          Chris PeBenito 696b41
                      if(time() - @filemtime($resource) >= $exp_time) {
          Chris PeBenito 696b41
                          return @unlink($resource);
          Chris PeBenito 696b41
                      }
          Chris PeBenito 696b41
                  } else {
          Chris PeBenito 696b41
                      return @unlink($resource);
          Chris PeBenito 696b41
                  }
          Chris PeBenito 696b41
              }
          Chris PeBenito 696b41
          Chris PeBenito 696b41
              /**
          Chris PeBenito 696b41
               * returns an auto_id for auto-file-functions
          Chris PeBenito 696b41
               *
          Chris PeBenito 696b41
               * @param string $cache_id
          Chris PeBenito 696b41
               * @param string $compile_id
          Chris PeBenito 696b41
               * @return string|null
          Chris PeBenito 696b41
               */
          Chris PeBenito 696b41
              function _get_auto_id($cache_id=null, $compile_id=null) {
          Chris PeBenito 696b41
              if (isset($cache_id))
          Chris PeBenito 696b41
                  return (isset($compile_id)) ? $cache_id . '|' . $compile_id  : $cache_id;
          Chris PeBenito 696b41
              elseif(isset($compile_id))
          Chris PeBenito 696b41
                  return $compile_id;
          Chris PeBenito 696b41
              else
          Chris PeBenito 696b41
                  return null;
          Chris PeBenito 696b41
              }
          Chris PeBenito 696b41
          Chris PeBenito 696b41
              /**
          Chris PeBenito 696b41
               * trigger Smarty plugin error
          Chris PeBenito 696b41
               *
          Chris PeBenito 696b41
               * @param string $error_msg
          Chris PeBenito 696b41
               * @param string $tpl_file
          Chris PeBenito 696b41
               * @param integer $tpl_line
          Chris PeBenito 696b41
               * @param string $file
          Chris PeBenito 696b41
               * @param integer $line
          Chris PeBenito 696b41
               * @param integer $error_type
          Chris PeBenito 696b41
               */
          Chris PeBenito 696b41
              function _trigger_fatal_error($error_msg, $tpl_file = null, $tpl_line = null,
          Chris PeBenito 696b41
                      $file = null, $line = null, $error_type = E_USER_ERROR)
          Chris PeBenito 696b41
              {
          Chris PeBenito 696b41
                  if(isset($file) && isset($line)) {
          Chris PeBenito 696b41
                      $info = ' ('.basename($file).", line $line)";
          Chris PeBenito 696b41
                  } else {
          Chris PeBenito 696b41
                      $info = '';
          Chris PeBenito 696b41
                  }
          Chris PeBenito 696b41
                  if (isset($tpl_line) && isset($tpl_file)) {
          Chris PeBenito 696b41
                      $this->trigger_error('[in ' . $tpl_file . ' line ' . $tpl_line . "]: $error_msg$info", $error_type);
          Chris PeBenito 696b41
                  } else {
          Chris PeBenito 696b41
                      $this->trigger_error($error_msg . $info, $error_type);
          Chris PeBenito 696b41
                  }
          Chris PeBenito 696b41
              }
          Chris PeBenito 696b41
          Chris PeBenito 696b41
          Chris PeBenito 696b41
              /**
          Chris PeBenito 696b41
               * callback function for preg_replace, to call a non-cacheable block
          Chris PeBenito 696b41
               * @return string
          Chris PeBenito 696b41
               */
          Chris PeBenito 696b41
              function _process_compiled_include_callback($match) {
          Chris PeBenito 696b41
                  $_func = '_smarty_tplfunc_'.$match[2].'_'.$match[3];
          Chris PeBenito 696b41
                  ob_start();
          Chris PeBenito 696b41
                  $_func($this);
          Chris PeBenito 696b41
                  $_ret = ob_get_contents();
          Chris PeBenito 696b41
                  ob_end_clean();
          Chris PeBenito 696b41
                  return $_ret;
          Chris PeBenito 696b41
              }
          Chris PeBenito 696b41
          Chris PeBenito 696b41
          Chris PeBenito 696b41
              /**
          Chris PeBenito 696b41
               * called for included templates
          Chris PeBenito 696b41
               *
          Chris PeBenito 696b41
               * @param string $_smarty_include_tpl_file
          Chris PeBenito 696b41
               * @param string $_smarty_include_vars
          Chris PeBenito 696b41
               */
          Chris PeBenito 696b41
          Chris PeBenito 696b41
              // $_smarty_include_tpl_file, $_smarty_include_vars
          Chris PeBenito 696b41
          Chris PeBenito 696b41
              function _smarty_include($params)
          Chris PeBenito 696b41
              {
          Chris PeBenito 696b41
                  if ($this->debugging) {
          Chris PeBenito 696b41
                      $_params = array();
          Chris PeBenito 696b41
                      require_once(SMARTY_CORE_DIR . 'core.get_microtime.php');
          Chris PeBenito 696b41
                      $debug_start_time = smarty_core_get_microtime($_params, $this);
          Chris PeBenito 696b41
                      $this->_smarty_debug_info[] = array('type'      => 'template',
          Chris PeBenito 696b41
                                                            'filename'  => $params['smarty_include_tpl_file'],
          Chris PeBenito 696b41
                                                            'depth'     => ++$this->_inclusion_depth);
          Chris PeBenito 696b41
                      $included_tpls_idx = count($this->_smarty_debug_info) - 1;
          Chris PeBenito 696b41
                  }
          Chris PeBenito 696b41
          Chris PeBenito 696b41
                  $this->_tpl_vars = array_merge($this->_tpl_vars, $params['smarty_include_vars']);
          Chris PeBenito 696b41
          Chris PeBenito 696b41
                  // config vars are treated as local, so push a copy of the
          Chris PeBenito 696b41
                  // current ones onto the front of the stack
          Chris PeBenito 696b41
                  array_unshift($this->_config, $this->_config[0]);
          Chris PeBenito 696b41
          Chris PeBenito 696b41
                  $_smarty_compile_path = $this->_get_compile_path($params['smarty_include_tpl_file']);
          Chris PeBenito 696b41
          Chris PeBenito 696b41
          Chris PeBenito 696b41
                  if ($this->_is_compiled($params['smarty_include_tpl_file'], $_smarty_compile_path)
          Chris PeBenito 696b41
                      || $this->_compile_resource($params['smarty_include_tpl_file'], $_smarty_compile_path))
          Chris PeBenito 696b41
                  {
          Chris PeBenito 696b41
                      include($_smarty_compile_path);
          Chris PeBenito 696b41
                  }
          Chris PeBenito 696b41
          Chris PeBenito 696b41
                  // pop the local vars off the front of the stack
          Chris PeBenito 696b41
                  array_shift($this->_config);
          Chris PeBenito 696b41
          Chris PeBenito 696b41
                  $this->_inclusion_depth--;
          Chris PeBenito 696b41
          Chris PeBenito 696b41
                  if ($this->debugging) {
          Chris PeBenito 696b41
                      // capture time for debugging info
          Chris PeBenito 696b41
                      $_params = array();
          Chris PeBenito 696b41
                      require_once(SMARTY_CORE_DIR . 'core.get_microtime.php');
          Chris PeBenito 696b41
                      $this->_smarty_debug_info[$included_tpls_idx]['exec_time'] = smarty_core_get_microtime($_params, $this) - $debug_start_time;
          Chris PeBenito 696b41
                  }
          Chris PeBenito 696b41
          Chris PeBenito 696b41
                  if ($this->caching) {
          Chris PeBenito 696b41
                      $this->_cache_info['template'][$params['smarty_include_tpl_file']] = true;
          Chris PeBenito 696b41
                  }
          Chris PeBenito 696b41
              }
          Chris PeBenito 696b41
          Chris PeBenito 696b41
          Chris PeBenito 696b41
              /**
          Chris PeBenito 696b41
               * get or set an array of cached attributes for function that is
          Chris PeBenito 696b41
               * not cacheable
          Chris PeBenito 696b41
               * @return array
          Chris PeBenito 696b41
               */
          Chris PeBenito 696b41
              function &_smarty_cache_attrs($cache_serial, $count) {
          Chris PeBenito 696b41
                  $_cache_attrs =& $this->_cache_info['cache_attrs'][$cache_serial][$count];
          Chris PeBenito 696b41
          Chris PeBenito 696b41
                  if ($this->_cache_including) {
          Chris PeBenito 696b41
                      /* return next set of cache_attrs */
          Chris PeBenito 696b41
                      $_return =& current($_cache_attrs);
          Chris PeBenito 696b41
                      next($_cache_attrs);
          Chris PeBenito 696b41
                      return $_return;
          Chris PeBenito 696b41
          Chris PeBenito 696b41
                  } else {
          Chris PeBenito 696b41
                      /* add a reference to a new set of cache_attrs */
          Chris PeBenito 696b41
                      $_cache_attrs[] = array();
          Chris PeBenito 696b41
                      return $_cache_attrs[count($_cache_attrs)-1];
          Chris PeBenito 696b41
          Chris PeBenito 696b41
                  }
          Chris PeBenito 696b41
          Chris PeBenito 696b41
              }
          Chris PeBenito 696b41
          Chris PeBenito 696b41
          Chris PeBenito 696b41
              /**
          Chris PeBenito 696b41
               * wrapper for include() retaining $this
          Chris PeBenito 696b41
               * @return mixed
          Chris PeBenito 696b41
               */
          Chris PeBenito 696b41
              function _include($filename, $once=false, $params=null)
          Chris PeBenito 696b41
              {
          Chris PeBenito 696b41
                  if ($once) {
          Chris PeBenito 696b41
                      return include_once($filename);
          Chris PeBenito 696b41
                  } else {
          Chris PeBenito 696b41
                      return include($filename);
          Chris PeBenito 696b41
                  }
          Chris PeBenito 696b41
              }
          Chris PeBenito 696b41
          Chris PeBenito 696b41
          Chris PeBenito 696b41
              /**
          Chris PeBenito 696b41
               * wrapper for eval() retaining $this
          Chris PeBenito 696b41
               * @return mixed
          Chris PeBenito 696b41
               */
          Chris PeBenito 696b41
              function _eval($code, $params=null)
          Chris PeBenito 696b41
              {
          Chris PeBenito 696b41
                  return eval($code);
          Chris PeBenito 696b41
              }
          Chris PeBenito 696b41
              /**#@-*/
          Chris PeBenito 696b41
          Chris PeBenito 696b41
          }
          Chris PeBenito 696b41
          Chris PeBenito 696b41
          /* vim: set expandtab: */
          Chris PeBenito 696b41
          Chris PeBenito 696b41
          ?>