⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 smarty.class.php

📁 Smarty class which may explain many things that you need. This class is very often use to start.
💻 PHP
📖 第 1 页 / 共 5 页
字号:
        $this->_plugins['modifier'][$modifier] =            array($modifier_impl, null, null, false);    }    /**     * 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($functions, false);        } 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 callback $function     */    function register_prefilter($function)    {        $this->_plugins['prefilter'][$this->_get_filter_name($function)]            = array($function, null, null, false);    }    /**     * Unregisters a prefilter function     *     * @param callback $function     */    function unregister_prefilter($function)    {        unset($this->_plugins['prefilter'][$this->_get_filter_name($function)]);    }    /**     * Registers a postfilter function to apply     * to a compiled template after compilation     *     * @param callback $function     */    function register_postfilter($function)    {        $this->_plugins['postfilter'][$this->_get_filter_name($function)]            = array($function, null, null, false);    }    /**     * Unregisters a postfilter function     *     * @param callback $function     */    function unregister_postfilter($function)    {        unset($this->_plugins['postfilter'][$this->_get_filter_name($function)]);    }    /**     * Registers an output filter function to apply     * to a template output     *     * @param callback $function     */    function register_outputfilter($function)    {        $this->_plugins['outputfilter'][$this->_get_filter_name($function)]            = array($function, null, null, false);    }    /**     * Unregisters an outputfilter function     *     * @param callback $function     */    function unregister_outputfilter($function)    {        unset($this->_plugins['outputfilter'][$this->_get_filter_name($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', $name, null, null, false)));                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);        }    }    /**     * clear the entire contents of cache (all templates)     *     * @param string $exp_time expire time     * @return boolean results of {@link smarty_core_rm_auto()}     */    function clear_all_cache($exp_time = null)    {        return $this->clear_cache(null, null, null, $exp_time);    }    /**     * test to see if valid cache exists for this template     *     * @param string $tpl_file name of template file     * @param string $cache_id     * @param string $compile_id     * @return string|false results of {@link _read_cache_file()}     */    function is_cached($tpl_file, $cache_id = null, $compile_id = null)    {        if (!$this->caching)            return false;        if (!isset($compile_id))            $compile_id = $this->compile_id;        $_params = array(            'tpl_file' => $tpl_file,            'cache_id' => $cache_id,            'compile_id' => $compile_id        );        require_once(SMARTY_CORE_DIR . 'core.read_cache_file.php');        return smarty_core_read_cache_file($_params, $this);    }    /**     * clear all the assigned template variables.     *     */    function clear_all_assign()    {        $this->_tpl_vars = array();    }    /**     * clears compiled version of specified template resource,     * or all compiled template files if one is not specified.     * This function is for advanced use only, not normally needed.     *     * @param string $tpl_file     * @param string $compile_id     * @param string $exp_time     * @return boolean results of {@link smarty_core_rm_auto()}     */    function clear_compiled_tpl($tpl_file = null, $compile_id = null, $exp_time = null)    {        if (!isset($compile_id)) {            $compile_id = $this->compile_id;        }        $_params = array('auto_base' => $this->compile_dir,                        'auto_source' => $tpl_file,                        'auto_id' => $compile_id,                        'exp_time' => $exp_time,                        'extensions' => array('.inc', '.php'));        require_once(SMARTY_CORE_DIR . 'core.rm_auto.php');        return smarty_core_rm_auto($_params, $this);    }    /**     * Checks whether requested template exists.     *     * @param string $tpl_file     * @return boolean     */    function template_exists($tpl_file)    {        $_params = array('resource_name' => $tpl_file, 'quiet'=>true, 'get_source'=>false);        return $this->_fetch_resource_info($_params);    }    /**     * Returns an array containing template variables     *     * @param string $name     * @param string $type     * @return array     */    function &get_template_vars($name=null)    {        if(!isset($name)) {            return $this->_tpl_vars;        } elseif(isset($this->_tpl_vars[$name])) {            return $this->_tpl_vars[$name];        } else {            // var non-existant, return valid reference            $_tmp = null;            return $_tmp;           }    }    /**     * Returns an array containing config variables     *     * @param string $name     * @param string $type     * @return array     */    function &get_config_vars($name=null)    {        if(!isset($name) && is_array($this->_config[0])) {            return $this->_config[0]['vars'];        } else if(isset($this->_config[0]['vars'][$name])) {            return $this->_config[0]['vars'][$name];        } else {            // var non-existant, return valid reference            $_tmp = null;            return $_tmp;        }    }    /**     * trigger Smarty error     *     * @param string $error_msg     * @param integer $error_type     */    function trigger_error($error_msg, $error_type = E_USER_WARNING)    {        trigger_error("Smarty error: $error_msg", $error_type);    }    /**     * executes & displays the template results     *     * @param string $resource_name     * @param string $cache_id     * @param string $compile_id     */    function display($resource_name, $cache_id = null, $compile_id = null)    {        $this->fetch($resource_name, $cache_id, $compile_id, true);    }    /**     * executes & returns or displays the template results     *     * @param string $resource_name     * @param string $cache_id     * @param string $compile_id     * @param boolean $display     */    function fetch($resource_name, $cache_id = null, $compile_id = null, $display = false)    {        static $_cache_info = array();                $_smarty_old_error_level = $this->debugging ? error_reporting() : error_reporting(isset($this->error_reporting)               ? $this->error_reporting : error_reporting() & ~E_NOTICE);        if (!$this->debugging && $this->debugging_ctrl == 'URL') {            $_query_string = $this->request_use_auto_globals ? $_SERVER['QUERY_STRING'] : $GLOBALS['HTTP_SERVER_VARS']['QUERY_STRING'];            if (@strstr($_query_string, $this->_smarty_debug_id)) {                if (@strstr($_query_string, $this->_smarty_debug_id . '=on')) {                    // enable debugging for this browser session                    @setcookie('SMARTY_DEBUG', true);                    $this->debugging = true;                } elseif (@strstr($_query_string, $this->_smarty_debug_id . '=off')) {                    // disable debugging for this browser session                    @setcookie('SMARTY_DEBUG', false);                    $this->debugging = false;                } else {                    // enable debugging for this page                    $this->debugging = true;                }            } else {                $this->debugging = (bool)($this->request_use_auto_globals ? @$_COOKIE['SMARTY_DEBUG'] : @$GLOBALS['HTTP_COOKIE_VARS']['SMARTY_DEBUG']);            }        }        if ($this->debugging) {            // capture time for debugging info            $_params = array();            require_once(SMARTY_CORE_DIR . 'core.get_microtime.php');            $_debug_start_time = smarty_core_get_microtime($_params, $this);            $this->_smarty_debug_info[] = array('type'      => 'template',                                                'filename'  => $resource_name,                                                'depth'     => 0);            $_included_tpls_idx = count($this->_smarty_debug_info) - 1;        }        if (!isset($compile_id)) {            $compile_id = $this->compile_id;        }        $this->_compile_id = $compile_id;        $this->_inclusion_depth = 0;        if ($this->caching) {            // save old cache_info, initialize cache_info            array_push($_cache_info, $this->_cache_info);            $this->_cache_info = array();            $_params = array(                'tpl_file' => $resource_name,                'cache_id' => $cache_id,                'compile_id' => $compile_id,                'results' => null            );            require_once(SMARTY_CORE_DIR . 'core.read_cache_file.php');            if (smarty_core_read_cache_file($_params, $this)) {                $_smarty_results = $_params['results'];                if (!empty($this->_cache_info['insert_tags'])) {                    $_params = array('plugins' => $this->_cache_info['insert_tags']);                    require_once(SMARTY_CORE_DIR . 'core.load_plugins.php');                    smarty_core_load_plugins($_params, $this);                    $_params = array('results' => $_smarty_results);                    require_once(SMARTY_CORE_DIR . 'core.process_cached_inserts.php');

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -