Codice PHP:
    /**#@-*/
    /**
     * The class constructor.
     */
    
function Smarty()
    {
      
$this->assign('SCRIPT_NAME', isset($_SERVER['SCRIPT_NAME']) ? $_SERVER['SCRIPT_NAME']
                    : @
$GLOBALS['HTTP_SERVER_VARS']['SCRIPT_NAME']);
    }

    
/**
     * assigns values to template variables
     *
     * @param array|string $tpl_var the template variable name(s)
     * @param mixed $value the value to assign
     */
    
function assign($tpl_var$value null)
    {
        if (
is_array($tpl_var)){
            foreach (
$tpl_var as $key => $val) {
                if (
$key != '') {
                    
$this->_tpl_vars[$key] = $val;
                }
            }
        } else {
            if (
$tpl_var != '')
                
$this->_tpl_vars[$tpl_var] = $value;
        }
    }

    
/**
     * assigns values to template variables by reference
     *
     * @param string $tpl_var the template variable name
     * @param mixed $value the referenced value to assign
     */
    
function assign_by_ref($tpl_var, &$value)
    {
        if (
$tpl_var != '')
            
$this->_tpl_vars[$tpl_var] = &$value;
    }

    
/**
     * appends values to template variables
     *
     * @param array|string $tpl_var the template variable name(s)
     * @param mixed $value the value to append
     */
    
function append($tpl_var$value=null$merge=false)
    {
        if (
is_array($tpl_var)) {
            
// $tpl_var is an array, ignore $value
            
foreach ($tpl_var as $_key => $_val) {
                if (
$_key != '') {
                    if(!@
is_array($this->_tpl_vars[$_key])) {
                        
settype($this->_tpl_vars[$_key],'array');
                    }
                    if(
$merge && is_array($_val)) {
                        foreach(
$_val as $_mkey => $_mval) {
                            
$this->_tpl_vars[$_key][$_mkey] = $_mval;
                        }
                    } else {
                        
$this->_tpl_vars[$_key][] = $_val;
                    }
                }
            }
        } else {
            if (
$tpl_var != '' && isset($value)) {
                if(!@
is_array($this->_tpl_vars[$tpl_var])) {
                    
settype($this->_tpl_vars[$tpl_var],'array');
                }
                if(
$merge && is_array($value)) {
                    foreach(
$value as $_mkey => $_mval) {
                        
$this->_tpl_vars[$tpl_var][$_mkey] = $_mval;
                    }
                } else {
                    
$this->_tpl_vars[$tpl_var][] = $value;
                }
            }
        }
    }

    
/**
     * appends values to template variables by reference
     *
     * @param string $tpl_var the template variable name
     * @param mixed $value the referenced value to append
     */
    
function append_by_ref($tpl_var, &$value$merge=false)
    {
        if (
$tpl_var != '' && isset($value)) {
            if(!@
is_array($this->_tpl_vars[$tpl_var])) {
             
settype($this->_tpl_vars[$tpl_var],'array');
            }
            if (
$merge && is_array($value)) {
                foreach(
$value as $_key => $_val) {
                    
$this->_tpl_vars[$tpl_var][$_key] = &$value[$_key];
                }
            } else {
                
$this->_tpl_vars[$tpl_var][] = &$value;
            }
        }
    }


    
/**
     * clear the given assigned template variable.
     *
     * @param string $tpl_var the template variable to clear
     */
    
function clear_assign($tpl_var)
    {
        if (
is_array($tpl_var))
            foreach (
$tpl_var as $curr_var)
                unset(
$this->_tpl_vars[$curr_var]);
        else
            unset(
$this->_tpl_vars[$tpl_var]);
    }


    
/**
     * Registers custom function to be used in templates
     *
     * @param string $function the name of the template function
     * @param string $function_impl the name of the PHP function to register
     */
    
function register_function($function$function_impl$cacheable=true$cache_attrs=null)
    {
        
$this->_plugins['function'][$function] =
            array(
$function_implnullnullfalse$cacheable$cache_attrs);

    }

    
/**
     * Unregisters custom function
     *
     * @param string $function name of template function
     */
    
function unregister_function($function)
    {
        unset(
$this->_plugins['function'][$function]);
    }

    
/**
     * Registers object to be used in templates
     *
     * @param string $object name of template object
     * @param object &$object_impl the referenced PHP object to register
     * @param null|array $allowed list of allowed methods (empty = all)
     * @param boolean $smarty_args smarty argument format, else traditional
     * @param null|array $block_functs list of methods that are block format
     */
    
function register_object($object, &$object_impl$allowed = array(), $smarty_args true$block_methods = array())
    {
        
settype($allowed'array');
        
settype($smarty_args'boolean');
        
$this->_reg_objects[$object] =
            array(&
$object_impl$allowed$smarty_args$block_methods);
    }

    
/**
     * Unregisters object
     *
     * @param string $object name of template object
     */
    
function unregister_object($object)
    {
        unset(
$this->_reg_objects[$object]);
    }


    
/**
     * Registers block function to be used in templates
     *
     * @param string $block name of template block
     * @param string $block_impl PHP function to register
     */
    
function register_block($block$block_impl$cacheable=true$cache_attrs=null)
    {
        
$this->_plugins['block'][$block] =
            array(
$block_implnullnullfalse$cacheable$cache_attrs);
    }

    
/**
     * Unregisters block function
     *
     * @param string $block name of template function
     */
    
function unregister_block($block)
    {
        unset(
$this->_plugins['block'][$block]);
    }

    
/**
     * Registers compiler function
     *
     * @param string $function name of template function
     * @param string $function_impl name of PHP function to register
     */
    
function register_compiler_function($function$function_impl$cacheable=true)
    {
        
$this->_plugins['compiler'][$function] =
            array(
$function_implnullnullfalse$cacheable);
    }

    
/**
     * Unregisters compiler function
     *
     * @param string $function name of template function
     */
    
function unregister_compiler_function($function)
    {
        unset(
$this->_plugins['compiler'][$function]);
    }

    
/**
     * Registers modifier to be used in templates
     *
     * @param string $modifier name of template modifier
     * @param string $modifier_impl name of PHP function to register
     */
    
function register_modifier($modifier$modifier_impl)
    {
        
$this->_plugins['modifier'][$modifier] =
            array(
$modifier_implnullnullfalse);
    }

    
/**
     * Unregisters modifier
     *
     * @param string $modifier name of template modifier
     */
    
function unregister_modifier($modifier)
    {
        unset(
$this->_plugins['modifier'][$modifier]);
    }

    
/**
     * Registers a resource to fetch a template
     *
     * @param string $type name of resource
     * @param array $functions array of functions to handle resource
     */
    
function register_resource($type$functions)
    {
        if (
count($functions)==4) {
            
$this->_plugins['resource'][$type] =
                array(
$functionsfalse);

        } elseif (
count($functions)==5) {
            
$this->_plugins['resource'][$type] =
                array(array(array(&
$functions[0], $functions[1])
                            ,array(&
$functions[0], $functions[2])
                            ,array(&
$functions[0], $functions[3])
                            ,array(&
$functions[0], $functions[4]))
                      ,
false);

        } else {
            
$this->trigger_error("malformed function-list for '$type' in register_resource");

        }
    }

    
/**
     * Unregisters a resource
     *
     * @param string $type name of resource
     */
    
function unregister_resource($type)
    {
        unset(
$this->_plugins['resource'][$type]);
    }

    
/**
     * Registers a prefilter function to apply
     * to a template before compiling
     *
     * @param string $function name of PHP function to register
     */
    
function register_prefilter($function)
    {
    
$_name = (is_array($function)) ? $function[1] : $function;
        
$this->_plugins['prefilter'][$_name]
            = array(
$functionnullnullfalse);
    }

    
/**
     * Unregisters a prefilter function
     *
     * @param string $function name of PHP function
     */
    
function unregister_prefilter($function)
    {
        unset(
$this->_plugins['prefilter'][$function]);
    }

    
/**
     * Registers a postfilter function to apply
     * to a compiled template after compilation
     *
     * @param string $function name of PHP function to register
     */
    
function register_postfilter($function)
    {
    
$_name = (is_array($function)) ? $function[1] : $function;
        
$this->_plugins['postfilter'][$_name]
            = array(
$functionnullnullfalse);
    }

    
/**
     * Unregisters a postfilter function
     *
     * @param string $function name of PHP function
     */
    
function unregister_postfilter($function)
    {
        unset(
$this->_plugins['postfilter'][$function]);
    }

    
/**
     * Registers an output filter function to apply
     * to a template output
     *
     * @param string $function name of PHP function
     */
    
function register_outputfilter($function)
    {
    
$_name = (is_array($function)) ? $function[1] : $function;
        
$this->_plugins['outputfilter'][$_name]
            = array(
$functionnullnullfalse);
    }

    
/**
     * Unregisters an outputfilter function
     *
     * @param string $function name of PHP function
     */
    
function unregister_outputfilter($function)
    {
        unset(
$this->_plugins['outputfilter'][$function]);
    }

    
/**
     * load a filter of specified type and name
     *
     * @param string $type filter type
     * @param string $name filter name
     */
    
function load_filter($type$name)
    {
        switch (
$type) {
            case 
'output':
                
$_params = array('plugins' => array(array($type 'filter'$namenullnullfalse)));
                require_once(
SMARTY_CORE_DIR 'core.load_plugins.php');
                
smarty_core_load_plugins($_params$this);
                break;

            case 
'pre':
            case 
'post':
                if (!isset(
$this->_plugins[$type 'filter'][$name]))
                    
$this->_plugins[$type 'filter'][$name] = false;
                break;
        }
    }

    
/**
     * clear cached content for the given template and cache id
     *
     * @param string $tpl_file name of template file
     * @param string $cache_id name of cache_id
     * @param string $compile_id name of compile_id
     * @param string $exp_time expiration time
     * @return boolean
     */
    
function clear_cache($tpl_file null$cache_id null$compile_id null$exp_time null)
    {

        if (!isset(
$compile_id))
            
$compile_id $this->compile_id;

        if (!isset(
$tpl_file))
            
$compile_id null;

        
$_auto_id $this->_get_auto_id($cache_id$compile_id);

        if (!empty(
$this->cache_handler_func)) {
            return 
call_user_func_array($this->cache_handler_func,
                                  array(
'clear', &$this, &$dummy$tpl_file$cache_id$compile_id$exp_time));
        } else {
            
$_params = array('auto_base' => $this->cache_dir,
                            
'auto_source' => $tpl_file,
                            
'auto_id' => $_auto_id,
                            
'exp_time' => $exp_time);
            require_once(
SMARTY_CORE_DIR 'core.rm_auto.php');
            return 
smarty_core_rm_auto($_params$this);
        }

    }