php封装的smarty类实例是怎样

* @link http://www.smarty.net/
* @copyright 2008 New Digital Group, Inc.
* @author Monte Ohrt <monte at ohrt dot com>
* @author Uwe Tews
* @author Rodney Rehm
* @package Smarty
* @version 3.1.19
*/
/**
* define shorthand directory separator constant
*/
if (!defined(‘DS‘)) {
define(‘DS‘, DIRECTORY_SEPARATOR);
}
/**
* set SMARTY_DIR to absolute path to Smarty library files.
* Sets SMARTY_DIR only if user application has not already defined it.
*/
if (!defined(‘SMARTY_DIR‘)) {
define(‘SMARTY_DIR‘, dirname(__FILE__) . DS);
}
/**
* set SMARTY_SYSPLUGINS_DIR to absolute path to Smarty internal plugins.
* Sets SMARTY_SYSPLUGINS_DIR only if user application has not already defined it.
*/
if (!defined(‘SMARTY_SYSPLUGINS_DIR‘)) {
define(‘SMARTY_SYSPLUGINS_DIR‘, SMARTY_DIR . ‘sysplugins‘ . DS);
}
if (!defined(‘SMARTY_PLUGINS_DIR‘)) {
define(‘SMARTY_PLUGINS_DIR‘, SMARTY_DIR . ‘plugins‘ . DS);
}
if (!defined(‘SMARTY_MBSTRING‘)) {
define(‘SMARTY_MBSTRING‘, function_exists(‘mb_split‘));
}
if (!defined(‘SMARTY_RESOURCE_CHAR_SET‘)) {
// UTF-8 can only be done properly when mbstring is available!
/**
* @deprecated in favor of Smarty::$_CHARSET
*/
define(‘SMARTY_RESOURCE_CHAR_SET‘, SMARTY_MBSTRING ? ‘UTF-8‘ : ‘ISO-8859-1‘);
}
if (!defined(‘SMARTY_RESOURCE_DATE_FORMAT‘)) {
/**
* @deprecated in favor of Smarty::$_DATE_FORMAT
*/
define(‘SMARTY_RESOURCE_DATE_FORMAT‘, ‘%b %e, %Y‘);
}
/**
* register the class autoloader
*/
if (!defined(‘SMARTY_SPL_AUTOLOAD‘)) {
define(‘SMARTY_SPL_AUTOLOAD‘, 0);
}
if (SMARTY_SPL_AUTOLOAD && set_include_path(get_include_path() . PATH_SEPARATOR . SMARTY_SYSPLUGINS_DIR) !== false) {
$registeredAutoLoadFunctions = spl_autoload_functions();
if (!isset($registeredAutoLoadFunctions[‘spl_autoload‘])) {
spl_autoload_register();
}
} else {
spl_autoload_register(‘smartyAutoload‘);
}
/**
* Load always needed external class files
*/
include_once SMARTY_SYSPLUGINS_DIR . ‘smarty_internal_data.php‘;
include_once SMARTY_SYSPLUGINS_DIR . ‘smarty_internal_templatebase.php‘;
include_once SMARTY_SYSPLUGINS_DIR . ‘smarty_internal_template.php‘;
include_once SMARTY_SYSPLUGINS_DIR . ‘smarty_resource.php‘;
include_once SMARTY_SYSPLUGINS_DIR . ‘smarty_internal_resource_file.php‘;
include_once SMARTY_SYSPLUGINS_DIR . ‘smarty_cacheresource.php‘;
include_once SMARTY_SYSPLUGINS_DIR . ‘smarty_internal_cacheresource_file.php‘;
/**
* This is the main Smarty class
*
* @package Smarty
*/
class Smarty extends Smarty_Internal_TemplateBase
{
/**#@+
* constant definitions
*/
/**
* smarty version
*/
const SMARTY_VERSION = ‘Smarty-3.1.19‘;
/**
* define variable scopes
*/
const SCOPE_LOCAL = 0;
const SCOPE_PARENT = 1;
const SCOPE_ROOT = 2;
const SCOPE_GLOBAL = 3;
/**
* define caching modes
*/
const CACHING_OFF = 0;
const CACHING_LIFETIME_CURRENT = 1;
const CACHING_LIFETIME_SAVED = 2;
/**
* define constant for clearing cache files be saved expiration datees
*/
const CLEAR_EXPIRED = - 1;
/**
* define compile check modes
*/
const COMPILECHECK_OFF = 0;
const COMPILECHECK_ON = 1;
const COMPILECHECK_CACHEMISS = 2;
/**
* modes for handling of "<?php ... ?>" tags in templates.
*/
const PHP_PASSTHRU = 0; //-> print tags as plain text
const PHP_QUOTE = 1; //-> escape tags as entities
const PHP_REMOVE = 2; //-> escape tags as entities
const PHP_ALLOW = 3; //-> escape tags as entities
/**
* filter types
*/
const FILTER_POST = ‘post‘;
const FILTER_PRE = ‘pre‘;
const FILTER_OUTPUT = ‘output‘;
const FILTER_VARIABLE = ‘variable‘;
/**
* plugin types
*/
const PLUGIN_FUNCTION = ‘function‘;
const PLUGIN_BLOCK = ‘block‘;
const PLUGIN_COMPILER = ‘compiler‘;
const PLUGIN_MODIFIER = ‘modifier‘;
const PLUGIN_MODIFIERCOMPILER = ‘modifiercompiler‘;
/**#@-*/
/**
* assigned global tpl vars
*/
public static $global_tpl_vars = array();
/**
* error handler returned by set_error_hanlder() in Smarty::muteExpectedErrors()
*/
public static $_previous_error_handler = null;
/**
* contains directories outside of SMARTY_DIR that are to be muted by muteExpectedErrors()
*/
public static $_muted_directories = array();
/**
* Flag denoting if Multibyte String functions are available
*/
public static $_MBSTRING = SMARTY_MBSTRING;
/**
* The character set to adhere to (e.g. "UTF-8")
*/
public static $_CHARSET = SMARTY_RESOURCE_CHAR_SET;
/**
* The date format to be used internally
* (accepts date() and strftime())
*/
public static $_DATE_FORMAT = SMARTY_RESOURCE_DATE_FORMAT;
/**
* Flag denoting if PCRE should run in UTF-8 mode
*/
public static $_UTF8_MODIFIER = ‘u‘;
/**
* Flag denoting if operating system is windows
*/
public static $_IS_WINDOWS = false;
/**#@+
* variables
*/
/**
* auto literal on delimiters with whitspace
*
* @var boolean
*/
public $auto_literal = true;
/**
* display error on not assigned variables
*
* @var boolean
*/
public $error_unassigned = false;
/**
* look up relative filepaths in include_path
*
* @var boolean
*/
public $use_include_path = false;
/**
* template directory
*
* @var array
*/
private $template_dir = array();
/**
* joined template directory string used in cache keys
*
* @var string
*/
public $joined_template_dir = null;
/**
* joined config directory string used in cache keys
*
* @var string
*/
public $joined_config_dir = null;
/**
* default template handler
*
* @var callable
*/
public $default_template_handler_func = null;
/**
* default config handler
*
* @var callable
*/
public $default_config_handler_func = null;
/**
* default plugin handler
*
* @var callable
*/
public $default_plugin_handler_func = null;
/**
* compile directory
*
* @var string
*/
private $compile_dir = null;
/**
* plugins directory
*
* @var array
*/
private $plugins_dir = array();
/**
* cache directory
*
* @var string
*/
private $cache_dir = null;
/**
* config directory
*
* @var array
*/
private $config_dir = array();
/**
* force template compiling?
*
* @var boolean
*/
public $force_compile = false;
/**
* check template for modifications?
*
* @var boolean
*/
public $compile_check = true;
/**
* use sub dirs for compiled/cached files?
*
* @var boolean
*/
public $use_sub_dirs = false;
/**
* allow ambiguous resources (that are made unique by the resource handler)
*
* @var boolean
*/
public $allow_ambiguous_resources = false;
/**
* caching enabled
*
* @var boolean
*/
public $caching = false;
/**
* merge compiled includes
*
* @var boolean
*/
public $merge_compiled_includes = false;
/**
* template inheritance merge compiled includes
*
* @var boolean
*/
public $inheritance_merge_compiled_includes = true;
/**
* cache lifetime in seconds
*
* @var integer
*/
public $cache_lifetime = 3600;
/**
* force cache file creation
*
* @var boolean
*/
public $force_cache = false;
/**
* Set this if you want different sets of cache files for the same
* templates.
*
* @var string
*/
public $cache_id = null;
/**
* Set this if you want different sets of compiled files for the same
* templates.
*
* @var string
*/
public $compile_id = null;
/**
* template left-delimiter
*
* @var string
*/
public $left_delimiter = "{";
/**
* template right-delimiter
*
* @var string
*/
public $right_delimiter = "}";
/**#@+
* security
*/
/**
* class name
* This should be instance of Smarty_Security.
*
* @var string
* @see Smarty_Security
*/
public $security_class = ‘Smarty_Security‘;
/**
* implementation of security class
*
* @var Smarty_Security
*/
public $security_policy = null;
/**
* controls handling of PHP-blocks
*
* @var integer
*/
public $php_handling = self::PHP_PASSTHRU;
/**
* controls if the php template file resource is allowed
*
* @var bool
*/
public $allow_php_templates = false;
/**
* Should compiled-templates be prevented from being called directly?
* {@internal
* Currently used by Smarty_Internal_Template only.
* }}
*
* @var boolean
*/
public $direct_access_security = true;
/**#@-*/
/**
* debug mode
* Setting this to true enables the debug-console.
*
* @var boolean
*/
public $debugging = false;
/**
* This determines if debugging is enable-able from the browser.
* <ul>
* <li>NONE => no debugging control allowed</li>
* <li>URL => enable debugging when SMARTY_DEBUG is found in the URL.</li>
* </ul>
*
* @var string
*/
public $debugging_ctrl = ‘NONE‘;
/**
* Name of debugging URL-param.
* Only used when $debugging_ctrl is set to ‘URL‘.
* The name of the URL-parameter that activates debugging.
*
* @var type
*/
public $smarty_debug_id = ‘SMARTY_DEBUG‘;
/**
* Path of debug template.
*
* @var string
*/
public $debug_tpl = null;
/**
* When set, smarty uses this value as error_reporting-level.
*
* @var int
*/
public $error_reporting = null;
/**
* Internal flag for getTags()
*
* @var boolean
*/
public $get_used_tags = false;
/**#@+
* config var settings
*/
/**
* Controls whether variables with the same name overwrite each other.
*
* @var boolean
*/
public $config_overwrite = true;
/**
* Controls whether config values of on/true/yes and off/false/no get converted to boolean.
*
* @var boolean
*/
public $config_booleanize = true;
/**
* Controls whether hidden config sections/vars are read from the file.
*
* @var boolean
*/
public $config_read_hidden = false;
/**#@-*/
/**#@+
* resource locking

时间: 2024-10-11 06:25:25

php封装的smarty类实例是怎样的相关文章

C#封装的常用文件操作类实例

本文实例讲述了C#封装的常用文件操作类.分享给大家供大家参考.具体如下: 这个C#类封装了我们经常能用到的文件操作方法,包括读写文件.获取文件扩展名.复制文件.追加内容到文件.删除文件.移动文件.创建目录.递归删除文件及目录.列目录.列文件等,不可多得. using System; using System.Text; using System.Web; using System.IO; namespace DotNet.Utilities { public class FileOperate

C#使用iTextSharp封装的PDF文件操作类实例

本文实例讲述了C#使用iTextSharp封装的PDF文件操作类.分享给大家供大家参考.具体分析如下: 这个C#代码主要讲iTextSharp中用于操作PDF文件的方法进行了再次封装,可以更加方便的访问PDF文档,可以动态生成PDF文件.添加内容.设置段落.设置字体等. using System.IO; using iTextSharp.text; using iTextSharp.text.pdf; namespace DotNet.Utilities { /// <summary> ///

php封装的mysqli类完整实例

本文实例讲述了php封装的mysqli类.分享给大家供大家参考,具体如下:类: <?php header('content-type:text/html;charset=utf-8'); /* 掌握满足单例模式的必要条件 (1)私有的构造方法-为了防止在类外使用new关键字实例化对象 (2)私有的成员属性-为了防止在类外引入这个存放对象的属性 (3)私有的克隆方法-为了防止在类外通过clone成生另一个对象 (4)公有的静态方法-为了让用户进行实例化对象的操作 */ class ConnectM

Java JUC之Atomic系列12大类实例讲解和原理分解

Java JUC之Atomic系列12大类实例讲解和原理分解 2013-02-21      0个评论       作者:xieyuooo 收藏    我要投稿 在java6以后我们不但接触到了Lock相关的锁,也接触到了很多更加乐观的原子修改操作,也就是在修改时我们只需要保证它的那个瞬间是安全的即可,经过相应的包装后可以再处理对象的并发修改,以及并发中的ABA问题,本文讲述Atomic系列的类的实现以及使用方法,其中包含: 基本类:AtomicInteger.AtomicLong.Atomic

编辑一个小的smarty类

首先先建立两个文件夹,一个temp,存储编译前的文件,一个comp,存储编译后的文件,编译前的文件使用{$title}代替<?php echo $title; ?>,然后将前者编译成后者再解析,解析后存储在comp文件夹中 定义一个解析类smarty.class.php <?php //定义一个简单的smarty类,来编译html文件 class mini{ public $temp_uri='';//模板文件所在的位置 public $comp_uri='';//模板编译后存放的位置

轻松把玩HttpClient之封装HttpClient工具类(二),插件式配置HttpClient对象

上一篇文章中,简单分享一下封装HttpClient工具类的思路及部分代码,本文将分享如何实现插件式配置HttpClient对象. 如果你看过我前面的几篇关于HttpClient的文章或者官网示例,应该都知道HttpClient对象在创建时,都可以设置各种参数,但是却没有简单的进行封装,比如对我来说比较重要的3个:代理.ssl(包含绕过证书验证和自定义证书验证).超时.还需要自己写.所以这里我就简单封装了一下,顺便还封装了一个连接池的配置. 其实说是插件式配置,那是高大上的说法,说白了,就是采用了

C#实现的JS操作类实例

本文实例讲述了C#实现的JS操作类.分享给大家供大家参考.具体如下: 这个C#类封装了常用的JS客户端代码操作,包括弹出对话框.返回上一页,通过JS转向,弹出警告框并转向等. using System.Web; namespace DotNet.Utilities { /// <summary> /// 客户端脚本输出 /// </summary> public class JsHelper { /// <summary> /// 弹出信息,并跳转指定页面. /// &

C#操作session的类实例

本文实例讲述了C#操作session的类.分享给大家供大家参考.具体分析如下: 这个C#类对session操作进行了再次封装,可以大大简化session的常用操作,同时这个类可以将session值设置为数组,也可以将值读取为数组列表,如果你有这方面的需要可以使用这个类,扩这自己对这个C#类进行扩展. using System.Web; namespace DotNet.Utilities { public static class SessionHelper2 { /// <summary>

C#获取哈希加密生成随机安全码的类实例

本文实例讲述了C#获取哈希加密生成随机安全码的类.分享给大家供大家参考.具体分析如下: 这个C#类封装了一些hash加密的功能,可以用于得到随机哈希加密字符串使用非常方便 using System; using System.Text; using System.Security.Cryptography; namespace DotNet.Utilities { /// <summary> /// 得到随机安全码(哈希加密). /// </summary> public clas