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

📄 smarty.class.php

📁 转载中国源码下载站 1) 基于PHP语言开发,MYSQL数据库驱动的多用户留言本 2) 采用PHP官方提供的编译模板引擎smarty 3) 代码、页面分离
💻 PHP
📖 第 1 页 / 共 5 页
字号:
     * 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_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 string $function name of PHP function to register     */        function register_prefilter($function)    {	$_name = (is_array($function)) ? $function[1] : $function;        $this->_plugins['prefilter'][$_name]            = array($function, null, null, false);    }    /**     * 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($function, null, null, false);    }    /**     * 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($function, null, null, false);    }    /**     * 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', $name, null, null, false)));				require_once(SMARTY_DIR . 'core' . DIRECTORY_SEPARATOR . '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));        } else {			$_params = array('auto_base' => $this->cache_dir,							'auto_source' => $tpl_file,							'auto_id' => $_auto_id,							'exp_time' => $exp_time);			require_once(SMARTY_DIR . 'core' . DIRECTORY_SEPARATOR . '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)    {        if (!empty($this->cache_handler_func)) {            call_user_func_array($this->cache_handler_func,                           array('clear', &$this, &$dummy));        } else {			$_params = array('auto_base' => $this->cache_dir,							'auto_source' => null,							'auto_id' => null,							'exp_time' => $exp_time);			require_once(SMARTY_DIR . 'core' . DIRECTORY_SEPARATOR . 'core.rm_auto.php');			return smarty_core_rm_auto($_params, $this);        }    }    /**     * 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_DIR . 'core' . DIRECTORY_SEPARATOR . '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_DIR . 'core' . DIRECTORY_SEPARATOR . '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;		}		if(isset($this->_tpl_vars[$name])) {			return $this->_tpl_vars[$name];		}    }    /**     * 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];		}    }    /**     * 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(error_reporting() & ~E_NOTICE);        if($this->security && !in_array($this->template_dir, $this->secure_dir)) {            // add template_dir to secure_dir array            array_unshift($this->secure_dir, $this->template_dir);        }        if (!$this->debugging && $this->debugging_ctrl == 'URL'               && @strstr($GLOBALS['HTTP_SERVER_VARS']['QUERY_STRING'], $this->_smarty_debug_id)) {            // enable debugging from URL            $this->debugging = true;        }		        if ($this->debugging) {            // capture time for debugging info			$_params = array();			require_once(SMARTY_DIR . 'core' . DIRECTORY_SEPARATOR . '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_DIR . 'core' . DIRECTORY_SEPARATOR . 'core.read_cache_file.php');			            if (smarty_core_read_cache_file($_params, $this)) {				$_smarty_results = $_params['results'];                if (@count($this->_cache_info['insert_tags'])) {					$_params = array('plugins' => $this->_cache_info['insert_tags']);					require_once(SMARTY_DIR . 'core' . DIRECTORY_SEPARATOR . 'core.load_plugins.php');                	smarty_core_load_plugins($_params, $this);					$_params = array('results' => $_smarty_results);					require_once(SMARTY_DIR . 'core' . DIRECTORY_SEPARATOR . 'core.process_cached_inserts.php');                    $_smarty_results = smarty_core_process_cached_inserts($_params, $this);

⌨️ 快捷键说明

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