php封装的smarty类完整实例
本文实例讲述了php封装的smarty类。分享给大家供大家参考,具体如下:
<?php /** *Project:Smarty:thePHPcompilingtemplateengine *File:Smarty.class.php *SVN:$Id:Smarty.class.php48482014-06-0818:12:09ZUwe.Tews@googlemail.com$ *Thislibraryisfreesoftware;youcanredistributeitand/or *modifyitunderthetermsoftheGNULesserGeneralPublic *LicenseaspublishedbytheFreeSoftwareFoundation;either *version2.1oftheLicense,or(atyouroption)anylaterversion. *Thislibraryisdistributedinthehopethatitwillbeuseful, *butWITHOUTANYWARRANTY;withouteventheimpliedwarrantyof *MERCHANTABILITYorFITNESSFORAPARTICULARPURPOSE.SeetheGNU *LesserGeneralPublicLicenseformoredetails. *YoushouldhavereceivedacopyoftheGNULesserGeneralPublic *Licensealongwiththislibrary;ifnot,writetotheFreeSoftware *Foundation,Inc.,59TemplePlace,Suite330,Boston,MA02111-1307USA *Forquestions,help,comments,discussion,etc.,pleasejointhe *Smartymailinglist.Sendablanke-mailto *smarty-discussion-subscribe@googlegroups.com * *@linkhttp://www.smarty.net/ *@copyright2008NewDigitalGroup,Inc. *@authorMonteOhrt<monteatohrtdotcom> *@authorUweTews *@authorRodneyRehm *@packageSmarty *@version3.1.19 */ /** *defineshorthanddirectoryseparatorconstant */ if(!defined('DS')){ define('DS',DIRECTORY_SEPARATOR); } /** *setSMARTY_DIRtoabsolutepathtoSmartylibraryfiles. *SetsSMARTY_DIRonlyifuserapplicationhasnotalreadydefinedit. */ if(!defined('SMARTY_DIR')){ define('SMARTY_DIR',dirname(__FILE__).DS); } /** *setSMARTY_SYSPLUGINS_DIRtoabsolutepathtoSmartyinternalplugins. *SetsSMARTY_SYSPLUGINS_DIRonlyifuserapplicationhasnotalreadydefinedit. */ 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-8canonlybedoneproperlywhenmbstringisavailable! /** *@deprecatedinfavorofSmarty::$_CHARSET */ define('SMARTY_RESOURCE_CHAR_SET',SMARTY_MBSTRING?'UTF-8':'ISO-8859-1'); } if(!defined('SMARTY_RESOURCE_DATE_FORMAT')){ /** *@deprecatedinfavorofSmarty::$_DATE_FORMAT */ define('SMARTY_RESOURCE_DATE_FORMAT','%b%e,%Y'); } /** *registertheclassautoloader */ 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'); } /** *Loadalwaysneededexternalclassfiles */ include_onceSMARTY_SYSPLUGINS_DIR.'smarty_internal_data.php'; include_onceSMARTY_SYSPLUGINS_DIR.'smarty_internal_templatebase.php'; include_onceSMARTY_SYSPLUGINS_DIR.'smarty_internal_template.php'; include_onceSMARTY_SYSPLUGINS_DIR.'smarty_resource.php'; include_onceSMARTY_SYSPLUGINS_DIR.'smarty_internal_resource_file.php'; include_onceSMARTY_SYSPLUGINS_DIR.'smarty_cacheresource.php'; include_onceSMARTY_SYSPLUGINS_DIR.'smarty_internal_cacheresource_file.php'; /** *ThisisthemainSmartyclass * *@packageSmarty */ classSmartyextendsSmarty_Internal_TemplateBase { /**#@+ *constantdefinitions */ /** *smartyversion */ constSMARTY_VERSION='Smarty-3.1.19'; /** *definevariablescopes */ constSCOPE_LOCAL=0; constSCOPE_PARENT=1; constSCOPE_ROOT=2; constSCOPE_GLOBAL=3; /** *definecachingmodes */ constCACHING_OFF=0; constCACHING_LIFETIME_CURRENT=1; constCACHING_LIFETIME_SAVED=2; /** *defineconstantforclearingcachefilesbesavedexpirationdatees */ constCLEAR_EXPIRED=-1; /** *definecompilecheckmodes */ constCOMPILECHECK_OFF=0; constCOMPILECHECK_ON=1; constCOMPILECHECK_CACHEMISS=2; /** *modesforhandlingof"<?php...?>"tagsintemplates. */ constPHP_PASSTHRU=0;//->printtagsasplaintext constPHP_QUOTE=1;//->escapetagsasentities constPHP_REMOVE=2;//->escapetagsasentities constPHP_ALLOW=3;//->escapetagsasentities /** *filtertypes */ constFILTER_POST='post'; constFILTER_PRE='pre'; constFILTER_OUTPUT='output'; constFILTER_VARIABLE='variable'; /** *plugintypes */ constPLUGIN_FUNCTION='function'; constPLUGIN_BLOCK='block'; constPLUGIN_COMPILER='compiler'; constPLUGIN_MODIFIER='modifier'; constPLUGIN_MODIFIERCOMPILER='modifiercompiler'; /**#@-*/ /** *assignedglobaltplvars */ publicstatic$global_tpl_vars=array(); /** *errorhandlerreturnedbyset_error_hanlder()inSmarty::muteExpectedErrors() */ publicstatic$_previous_error_handler=null; /** *containsdirectoriesoutsideofSMARTY_DIRthataretobemutedbymuteExpectedErrors() */ publicstatic$_muted_directories=array(); /** *FlagdenotingifMultibyteStringfunctionsareavailable */ publicstatic$_MBSTRING=SMARTY_MBSTRING; /** *Thecharactersettoadhereto(e.g."UTF-8") */ publicstatic$_CHARSET=SMARTY_RESOURCE_CHAR_SET; /** *Thedateformattobeusedinternally *(acceptsdate()andstrftime()) */ publicstatic$_DATE_FORMAT=SMARTY_RESOURCE_DATE_FORMAT; /** *FlagdenotingifPCREshouldruninUTF-8mode */ publicstatic$_UTF8_MODIFIER='u'; /** *Flagdenotingifoperatingsystemiswindows */ publicstatic$_IS_WINDOWS=false; /**#@+ *variables */ /** *autoliteralondelimiterswithwhitspace * *@varboolean */ public$auto_literal=true; /** *displayerroronnotassignedvariables * *@varboolean */ public$error_unassigned=false; /** *lookuprelativefilepathsininclude_path * *@varboolean */ public$use_include_path=false; /** *templatedirectory * *@vararray */ private$template_dir=array(); /** *joinedtemplatedirectorystringusedincachekeys * *@varstring */ public$joined_template_dir=null; /** *joinedconfigdirectorystringusedincachekeys * *@varstring */ public$joined_config_dir=null; /** *defaulttemplatehandler * *@varcallable */ public$default_template_handler_func=null; /** *defaultconfighandler * *@varcallable */ public$default_config_handler_func=null; /** *defaultpluginhandler * *@varcallable */ public$default_plugin_handler_func=null; /** *compiledirectory * *@varstring */ private$compile_dir=null; /** *pluginsdirectory * *@vararray */ private$plugins_dir=array(); /** *cachedirectory * *@varstring */ private$cache_dir=null; /** *configdirectory * *@vararray */ private$config_dir=array(); /** *forcetemplatecompiling? * *@varboolean */ public$force_compile=false; /** *checktemplateformodifications? * *@varboolean */ public$compile_check=true; /** *usesubdirsforcompiled/cachedfiles? * *@varboolean */ public$use_sub_dirs=false; /** *allowambiguousresources(thataremadeuniquebytheresourcehandler) * *@varboolean */ public$allow_ambiguous_resources=false; /** *cachingenabled * *@varboolean */ public$caching=false; /** *mergecompiledincludes * *@varboolean */ public$merge_compiled_includes=false; /** *templateinheritancemergecompiledincludes * *@varboolean */ public$inheritance_merge_compiled_includes=true; /** *cachelifetimeinseconds * *@varinteger */ public$cache_lifetime=3600; /** *forcecachefilecreation * *@varboolean */ public$force_cache=false; /** *Setthisifyouwantdifferentsetsofcachefilesforthesame *templates. * *@varstring */ public$cache_id=null; /** *Setthisifyouwantdifferentsetsofcompiledfilesforthesame *templates. * *@varstring */ public$compile_id=null; /** *templateleft-delimiter * *@varstring */ public$left_delimiter="{"; /** *templateright-delimiter * *@varstring */ public$right_delimiter="}"; /**#@+ *security */ /** *classname *ThisshouldbeinstanceofSmarty_Security. * *@varstring *@seeSmarty_Security */ public$security_class='Smarty_Security'; /** *implementationofsecurityclass * *@varSmarty_Security */ public$security_policy=null; /** *controlshandlingofPHP-blocks * *@varinteger */ public$php_handling=self::PHP_PASSTHRU; /** *controlsifthephptemplatefileresourceisallowed * *@varbool */ public$allow_php_templates=false; /** *Shouldcompiled-templatesbepreventedfrombeingcalleddirectly? *{@internal *CurrentlyusedbySmarty_Internal_Templateonly. *}} * *@varboolean */ public$direct_access_security=true; /**#@-*/ /** *debugmode *Settingthistotrueenablesthedebug-console. * *@varboolean */ public$debugging=false; /** *Thisdeterminesifdebuggingisenable-ablefromthebrowser. *<ul> *<li>NONE=>nodebuggingcontrolallowed</li> *<li>URL=>enabledebuggingwhenSMARTY_DEBUGisfoundintheURL.</li> *</ul> * *@varstring */ public$debugging_ctrl='NONE'; /** *NameofdebuggingURL-param. *Onlyusedwhen$debugging_ctrlissetto'URL'. *ThenameoftheURL-parameterthatactivatesdebugging. * *@vartype */ public$smarty_debug_id='SMARTY_DEBUG'; /** *Pathofdebugtemplate. * *@varstring */ public$debug_tpl=null; /** *Whenset,smartyusesthisvalueaserror_reporting-level. * *@varint */ public$error_reporting=null; /** *InternalflagforgetTags() * *@varboolean */ public$get_used_tags=false; /**#@+ *configvarsettings */ /** *Controlswhethervariableswiththesamenameoverwriteeachother. * *@varboolean */ public$config_overwrite=true; /** *Controlswhetherconfigvaluesofon/true/yesandoff/false/nogetconvertedtoboolean. * *@varboolean */ public$config_booleanize=true; /** *Controlswhetherhiddenconfigsections/varsarereadfromthefile. * *@varboolean */ public$config_read_hidden=false; /**#@-*/ /**#@+ *resourcelocking */ /** *lockingconcurrentcompiles * *@varboolean */ public$compile_locking=true; /** *Controlswhethercacheresourcesshouldemplylockingmechanism * *@varboolean */ public$cache_locking=false; /** *secondstowaitforacquiringalockbeforeignoringthewritelock * *@varfloat */ public$locking_timeout=10; /**#@-*/ /** *globaltemplatefunctions * *@vararray */ public$template_functions=array(); /** *resourcetypeusedifnonegiven *Mustbeanvalidkeyof$registered_resources. * *@varstring */ public$default_resource_type='file'; /** *cachingtype *Mustbeanelementof$cache_resource_types. * *@varstring */ public$caching_type='file'; /** *internalconfigproperties * *@vararray */ public$properties=array(); /** *configtype * *@varstring */ public$default_config_type='file'; /** *cachedtemplateobjects * *@vararray */ public$template_objects=array(); /** *checkIf-Modified-Sinceheaders * *@varboolean */ public$cache_modified_check=false; /** *registeredplugins * *@vararray */ public$registered_plugins=array(); /** *pluginsearchorder * *@vararray */ public$plugin_search_order=array('function','block','compiler','class'); /** *registeredobjects * *@vararray */ public$registered_objects=array(); /** *registeredclasses * *@vararray */ public$registered_classes=array(); /** *registeredfilters * *@vararray */ public$registered_filters=array(); /** *registeredresources * *@vararray */ public$registered_resources=array(); /** *resourcehandlercache * *@vararray */ public$_resource_handlers=array(); /** *registeredcacheresources * *@vararray */ public$registered_cache_resources=array(); /** *cacheresourcehandlercache * *@vararray */ public$_cacheresource_handlers=array(); /** *autoloadfilter * *@vararray */ public$autoload_filters=array(); /** *defaultmodifier * *@vararray */ public$default_modifiers=array(); /** *autoescapevariableoutput * *@varboolean */ public$escape_html=false; /** *globalinternalsmartyvars * *@vararray */ publicstatic$_smarty_vars=array(); /** *starttimeforexecutiontimecalculation * *@varint */ public$start_time=0; /** *defaultfilepermissions * *@varint */ public$_file_perms=0644; /** *defaultdirpermissions * *@varint */ public$_dir_perms=0771; /** *blocktaghierarchy * *@vararray */ public$_tag_stack=array(); /** *selfpointertoSmartyobject * *@varSmarty */ public$smarty; /** *requiredbythecompilerforBC * *@varstring */ public$_current_file=null; /** *internalflagtoenableparserdebugging * *@varbool */ public$_parserdebug=false; /** *Savedparameterofmergedtemplatesduringcompilation * *@vararray */ public$merged_templates_func=array(); /**#@-*/ /** *InitializenewSmartyobject */ publicfunction__construct() { //selfpointerneededbysomeotherclassmethods $this->smarty=$this; if(is_callable('mb_internal_encoding')){ mb_internal_encoding(Smarty::$_CHARSET); } $this->start_time=microtime(true); //setdefaultdirs $this->setTemplateDir('.'.DS.'templates'.DS) ->setCompileDir('.'.DS.'templates_c'.DS) ->setPluginsDir(SMARTY_PLUGINS_DIR) ->setCacheDir('.'.DS.'cache'.DS) ->setConfigDir('.'.DS.'configs'.DS); $this->debug_tpl='file:'.dirname(__FILE__).'/debug.tpl'; if(isset($_SERVER['SCRIPT_NAME'])){ $this->assignGlobal('SCRIPT_NAME',$_SERVER['SCRIPT_NAME']); } } /** *Classdestructor */ publicfunction__destruct() { //intentionallyleftblank } /** *<<magic>>setselfpointeronclonedobject */ publicfunction__clone() { $this->smarty=$this; } /** *<<magic>>Genericgetter. *Callstheappropriategetterfunction. *IssuesanE_USER_NOTICEifnovalidgetterisfound. * *@paramstring$namepropertyname * *@returnmixed */ publicfunction__get($name) { $allowed=array( 'template_dir'=>'getTemplateDir', 'config_dir'=>'getConfigDir', 'plugins_dir'=>'getPluginsDir', 'compile_dir'=>'getCompileDir', 'cache_dir'=>'getCacheDir', ); if(isset($allowed[$name])){ return$this->{$allowed[$name]}(); }else{ trigger_error('Undefinedproperty:'.get_class($this).'::$'.$name,E_USER_NOTICE); } } /** *<<magic>>Genericsetter. *Callstheappropriatesetterfunction. *IssuesanE_USER_NOTICEifnovalidsetterisfound. * *@paramstring$namepropertyname *@parammixed$valueparameterpassedtosetter */ publicfunction__set($name,$value) { $allowed=array( 'template_dir'=>'setTemplateDir', 'config_dir'=>'setConfigDir', 'plugins_dir'=>'setPluginsDir', 'compile_dir'=>'setCompileDir', 'cache_dir'=>'setCacheDir', ); if(isset($allowed[$name])){ $this->{$allowed[$name]}($value); }else{ trigger_error('Undefinedproperty:'.get_class($this).'::$'.$name,E_USER_NOTICE); } } /** *Checkifatemplateresourceexists * *@paramstring$resource_nametemplatename * *@returnbooleanstatus */ publicfunctiontemplateExists($resource_name) { //createtemplateobject $save=$this->template_objects; $tpl=new$this->template_class($resource_name,$this); //checkifitdoesexists $result=$tpl->source->exists; $this->template_objects=$save; return$result; } /** *Returnsasingleorallglobalvariables * *@paramstring$varnamevariablenameornull * *@returnstringvariablevalueororarrayofvariables */ publicfunctiongetGlobal($varname=null) { if(isset($varname)){ if(isset(self::$global_tpl_vars[$varname])){ returnself::$global_tpl_vars[$varname]->value; }else{ return''; } }else{ $_result=array(); foreach(self::$global_tpl_varsAS$key=>$var){ $_result[$key]=$var->value; } return$_result; } } /** *Emptycachefolder * *@paraminteger$exp_timeexpirationtime *@paramstring$typeresourcetype * *@returnintegernumberofcachefilesdeleted */ publicfunctionclearAllCache($exp_time=null,$type=null) { //loadcacheresourceandcallclearAll $_cache_resource=Smarty_CacheResource::load($this,$type); Smarty_CacheResource::invalidLoadedCache($this); return$_cache_resource->clearAll($this,$exp_time); } /** *Emptycacheforaspecifictemplate * *@paramstring$template_nametemplatename *@paramstring$cache_idcacheid *@paramstring$compile_idcompileid *@paraminteger$exp_timeexpirationtime *@paramstring$typeresourcetype * *@returnintegernumberofcachefilesdeleted */ publicfunctionclearCache($template_name,$cache_id=null,$compile_id=null,$exp_time=null,$type=null) { //loadcacheresourceandcallclear $_cache_resource=Smarty_CacheResource::load($this,$type); Smarty_CacheResource::invalidLoadedCache($this); return$_cache_resource->clear($this,$template_name,$cache_id,$compile_id,$exp_time); } /** *Loadssecurityclassandenablessecurity * *@paramstring|Smarty_Security$security_classifastringisused,itmustbeclass-name * *@returnSmartycurrentSmartyinstanceforchaining *@throwsSmartyExceptionwhenaninvalidclassnameisprovided */ publicfunctionenableSecurity($security_class=null) { if($security_classinstanceofSmarty_Security){ $this->security_policy=$security_class; return$this; }elseif(is_object($security_class)){ thrownewSmartyException("Class'".get_class($security_class)."'mustextendSmarty_Security."); } if($security_class==null){ $security_class=$this->security_class; } if(!class_exists($security_class)){ thrownewSmartyException("Securityclass'$security_class'isnotdefined"); }elseif($security_class!=='Smarty_Security'&&!is_subclass_of($security_class,'Smarty_Security')){ thrownewSmartyException("Class'$security_class'mustextendSmarty_Security."); }else{ $this->security_policy=new$security_class($this); } return$this; } /** *Disablesecurity * *@returnSmartycurrentSmartyinstanceforchaining */ publicfunctiondisableSecurity() { $this->security_policy=null; return$this; } /** *Settemplatedirectory * *@paramstring|array$template_dirdirectory(s)oftemplatesources * *@returnSmartycurrentSmartyinstanceforchaining */ publicfunctionsetTemplateDir($template_dir) { $this->template_dir=array(); foreach((array)$template_diras$k=>$v){ $this->template_dir[$k]=preg_replace('#(\w+)(/|\\\\){1,}#','$1$2',rtrim($v,'/\\')).DS; } $this->joined_template_dir=join(DIRECTORY_SEPARATOR,$this->template_dir); return$this; } /** *Addtemplatedirectory(s) * *@paramstring|array$template_dirdirectory(s)oftemplatesources *@paramstring$keyofthearrayelementtoassignthetemplatedirto * *@returnSmartycurrentSmartyinstanceforchaining *@throwsSmartyExceptionwhenthegiventemplatedirectoryisnotvalid */ publicfunctionaddTemplateDir($template_dir,$key=null) { //makesurewe'redealingwithanarray $this->template_dir=(array)$this->template_dir; if(is_array($template_dir)){ foreach($template_diras$k=>$v){ $v=preg_replace('#(\w+)(/|\\\\){1,}#','$1$2',rtrim($v,'/\\')).DS; if(is_int($k)){ //indexesarenotmergedbutappended $this->template_dir[]=$v; }else{ //stringindexesareoverridden $this->template_dir[$k]=$v; } } }else{ $v=preg_replace('#(\w+)(/|\\\\){1,}#','$1$2',rtrim($template_dir,'/\\')).DS; if($key!==null){ //overridedirectoryatspecifiedindex $this->template_dir[$key]=$v; }else{ //appendnewdirectory $this->template_dir[]=$v; } } $this->joined_template_dir=join(DIRECTORY_SEPARATOR,$this->template_dir); return$this; } /** *Gettemplatedirectories * *@parammixed$indexindexofdirectorytoget,nulltogetall * *@returnarray|stringlistoftemplatedirectories,ordirectoryof$index */ publicfunctiongetTemplateDir($index=null) { if($index!==null){ returnisset($this->template_dir[$index])?$this->template_dir[$index]:null; } return(array)$this->template_dir; } /** *Setconfigdirectory * *@param$config_dir * *@returnSmartycurrentSmartyinstanceforchaining */ publicfunctionsetConfigDir($config_dir) { $this->config_dir=array(); foreach((array)$config_diras$k=>$v){ $this->config_dir[$k]=preg_replace('#(\w+)(/|\\\\){1,}#','$1$2',rtrim($v,'/\\')).DS; } $this->joined_config_dir=join(DIRECTORY_SEPARATOR,$this->config_dir); return$this; } /** *Addconfigdirectory(s) * *@paramstring|array$config_dirdirectory(s)ofconfigsources *@parammixed$keykeyofthearrayelementtoassigntheconfigdirto * *@returnSmartycurrentSmartyinstanceforchaining */ publicfunctionaddConfigDir($config_dir,$key=null) { //makesurewe'redealingwithanarray $this->config_dir=(array)$this->config_dir; if(is_array($config_dir)){ foreach($config_diras$k=>$v){ $v=preg_replace('#(\w+)(/|\\\\){1,}#','$1$2',rtrim($v,'/\\')).DS; if(is_int($k)){ //indexesarenotmergedbutappended $this->config_dir[]=$v; }else{ //stringindexesareoverridden $this->config_dir[$k]=$v; } } }else{ $v=preg_replace('#(\w+)(/|\\\\){1,}#','$1$2',rtrim($config_dir,'/\\')).DS; if($key!==null){ //overridedirectoryatspecifiedindex $this->config_dir[$key]=rtrim($v,'/\\').DS; }else{ //appendnewdirectory $this->config_dir[]=rtrim($v,'/\\').DS; } } $this->joined_config_dir=join(DIRECTORY_SEPARATOR,$this->config_dir); return$this; } /** *Getconfigdirectory * *@parammixed$indexindexofdirectorytoget,nulltogetall * *@returnarray|stringconfigurationdirectory */ publicfunctiongetConfigDir($index=null) { if($index!==null){ returnisset($this->config_dir[$index])?$this->config_dir[$index]:null; } return(array)$this->config_dir; } /** *Setpluginsdirectory * *@paramstring|array$plugins_dirdirectory(s)ofplugins * *@returnSmartycurrentSmartyinstanceforchaining */ publicfunctionsetPluginsDir($plugins_dir) { $this->plugins_dir=array(); foreach((array)$plugins_diras$k=>$v){ $this->plugins_dir[$k]=rtrim($v,'/\\').DS; } return$this; } /** *Addsdirectoryofpluginfiles * *@param$plugins_dir * *@returnSmartycurrentSmartyinstanceforchaining */ publicfunctionaddPluginsDir($plugins_dir) { //makesurewe'redealingwithanarray $this->plugins_dir=(array)$this->plugins_dir; if(is_array($plugins_dir)){ foreach($plugins_diras$k=>$v){ if(is_int($k)){ //indexesarenotmergedbutappended $this->plugins_dir[]=rtrim($v,'/\\').DS; }else{ //stringindexesareoverridden $this->plugins_dir[$k]=rtrim($v,'/\\').DS; } } }else{ //appendnewdirectory $this->plugins_dir[]=rtrim($plugins_dir,'/\\').DS; } $this->plugins_dir=array_unique($this->plugins_dir); return$this; } /** *Getplugindirectories * *@returnarraylistofplugindirectories */ publicfunctiongetPluginsDir() { return(array)$this->plugins_dir; } /** *Setcompiledirectory * *@paramstring$compile_dirdirectorytostorecompiledtemplatesin * *@returnSmartycurrentSmartyinstanceforchaining */ publicfunctionsetCompileDir($compile_dir) { $this->compile_dir=rtrim($compile_dir,'/\\').DS; if(!isset(Smarty::$_muted_directories[$this->compile_dir])){ Smarty::$_muted_directories[$this->compile_dir]=null; } return$this; } /** *Getcompileddirectory * *@returnstringpathtocompiledtemplates */ publicfunctiongetCompileDir() { return$this->compile_dir; } /** *Setcachedirectory * *@paramstring$cache_dirdirectorytostorecachedtemplatesin * *@returnSmartycurrentSmartyinstanceforchaining */ publicfunctionsetCacheDir($cache_dir) { $this->cache_dir=rtrim($cache_dir,'/\\').DS; if(!isset(Smarty::$_muted_directories[$this->cache_dir])){ Smarty::$_muted_directories[$this->cache_dir]=null; } return$this; } /** *Getcachedirectory * *@returnstringpathofcachedirectory */ publicfunctiongetCacheDir() { return$this->cache_dir; } /** *Setdefaultmodifiers * *@paramarray|string$modifiersmodifierorlistofmodifierstoset * *@returnSmartycurrentSmartyinstanceforchaining */ publicfunctionsetDefaultModifiers($modifiers) { $this->default_modifiers=(array)$modifiers; return$this; } /** *Adddefaultmodifiers * *@paramarray|string$modifiersmodifierorlistofmodifierstoadd * *@returnSmartycurrentSmartyinstanceforchaining */ publicfunctionaddDefaultModifiers($modifiers) { if(is_array($modifiers)){ $this->default_modifiers=array_merge($this->default_modifiers,$modifiers); }else{ $this->default_modifiers[]=$modifiers; } return$this; } /** *Getdefaultmodifiers * *@returnarraylistofdefaultmodifiers */ publicfunctiongetDefaultModifiers() { return$this->default_modifiers; } /** *Setautoloadfilters * *@paramarray$filtersfilterstoloadautomatically *@paramstring$type"pre","output",…specifythefiltertypetoset.Defaultstononetreating$filters'keysastheappropriatetypes * *@returnSmartycurrentSmartyinstanceforchaining */ publicfunctionsetAutoloadFilters($filters,$type=null) { if($type!==null){ $this->autoload_filters[$type]=(array)$filters; }else{ $this->autoload_filters=(array)$filters; } return$this; } /** *Addautoloadfilters * *@paramarray$filtersfilterstoloadautomatically *@paramstring$type"pre","output",…specifythefiltertypetoset.Defaultstononetreating$filters'keysastheappropriatetypes * *@returnSmartycurrentSmartyinstanceforchaining */ publicfunctionaddAutoloadFilters($filters,$type=null) { if($type!==null){ if(!empty($this->autoload_filters[$type])){ $this->autoload_filters[$type]=array_merge($this->autoload_filters[$type],(array)$filters); }else{ $this->autoload_filters[$type]=(array)$filters; } }else{ foreach((array)$filtersas$key=>$value){ if(!empty($this->autoload_filters[$key])){ $this->autoload_filters[$key]=array_merge($this->autoload_filters[$key],(array)$value); }else{ $this->autoload_filters[$key]=(array)$value; } } } return$this; } /** *Getautoloadfilters * *@paramstring$typetypeoffiltertogetautoloadsfor.Defaultstoallautoloadfilters * *@returnarrayarray('type1'=>array('filter1','filter2',…))orarray('filter1','filter2',…)if$typewasspecified */ publicfunctiongetAutoloadFilters($type=null) { if($type!==null){ returnisset($this->autoload_filters[$type])?$this->autoload_filters[$type]:array(); } return$this->autoload_filters; } /** *returnnameofdebuggingtemplate * *@returnstring */ publicfunctiongetDebugTemplate() { return$this->debug_tpl; } /** *setthedebugtemplate * *@paramstring$tpl_name * *@returnSmartycurrentSmartyinstanceforchaining *@throwsSmartyExceptioniffileisnotreadable */ publicfunctionsetDebugTemplate($tpl_name) { if(!is_readable($tpl_name)){ thrownewSmartyException("Unknownfile'{$tpl_name}'"); } $this->debug_tpl=$tpl_name; return$this; } /** *createsatemplateobject * *@paramstring$templatetheresourcehandleofthetemplatefile *@parammixed$cache_idcacheidtobeusedwiththistemplate *@parammixed$compile_idcompileidtobeusedwiththistemplate *@paramobject$parentnexthigherlevelofSmartyvariables *@paramboolean$do_cloneflagisSmartyobjectshallbecloned * *@returnobjecttemplateobject */ publicfunctioncreateTemplate($template,$cache_id=null,$compile_id=null,$parent=null,$do_clone=true) { if($cache_id!==null&&(is_object($cache_id)||is_array($cache_id))){ $parent=$cache_id; $cache_id=null; } if($parent!==null&&is_array($parent)){ $data=$parent; $parent=null; }else{ $data=null; } //defaulttocache_idandcompile_idofSmartyobject $cache_id=$cache_id===null?$this->cache_id:$cache_id; $compile_id=$compile_id===null?$this->compile_id:$compile_id; //alreadyintemplatecache? if($this->allow_ambiguous_resources){ $_templateId=Smarty_Resource::getUniqueTemplateName($this,$template).$cache_id.$compile_id; }else{ $_templateId=$this->joined_template_dir.'#'.$template.$cache_id.$compile_id; } if(isset($_templateId[150])){ $_templateId=sha1($_templateId); } if($do_clone){ if(isset($this->template_objects[$_templateId])){ //returncachedtemplateobject $tpl=clone$this->template_objects[$_templateId]; $tpl->smarty=clone$tpl->smarty; $tpl->parent=$parent; $tpl->tpl_vars=array(); $tpl->config_vars=array(); }else{ $tpl=new$this->template_class($template,clone$this,$parent,$cache_id,$compile_id); } }else{ if(isset($this->template_objects[$_templateId])){ //returncachedtemplateobject $tpl=$this->template_objects[$_templateId]; $tpl->parent=$parent; $tpl->tpl_vars=array(); $tpl->config_vars=array(); }else{ $tpl=new$this->template_class($template,$this,$parent,$cache_id,$compile_id); } } //filldataifpresent if(!empty($data)&&is_array($data)){ //setupvariablevalues foreach($dataas$_key=>$_val){ $tpl->tpl_vars[$_key]=newSmarty_variable($_val); } } return$tpl; } /** *Takesunknownclassesandloadspluginfilesforthem *classnameformat:Smarty_PluginType_PluginName *pluginfilenameformat:plugintype.pluginname.php * *@paramstring$plugin_nameclasspluginnametoload *@parambool$checkcheckifalreadyloaded * *@throwsSmartyException *@returnstring|booleanfilepathofloadedfileorfalse */ publicfunctionloadPlugin($plugin_name,$check=true) { //iffunctionorclassexists,exitsilently(alreadyloaded) if($check&&(is_callable($plugin_name)||class_exists($plugin_name,false))){ returntrue; } //Pluginnameisexpectedtobe:Smarty_[Type]_[Name] $_name_parts=explode('_',$plugin_name,3); //classnamemusthavethreepartstobevalidplugin //count($_name_parts)<3===!isset($_name_parts[2]) if(!isset($_name_parts[2])||strtolower($_name_parts[0])!=='smarty'){ thrownewSmartyException("plugin{$plugin_name}isnotavalidnameformat"); } //iftypeis"internal",getpluginfromsysplugins if(strtolower($_name_parts[1])=='internal'){ $file=SMARTY_SYSPLUGINS_DIR.strtolower($plugin_name).'.php'; if(file_exists($file)){ require_once($file); return$file; }else{ returnfalse; } } //pluginfilenameisexpectedtobe:[type].[name].php $_plugin_filename="{$_name_parts[1]}.{$_name_parts[2]}.php"; $_stream_resolve_include_path=function_exists('stream_resolve_include_path'); //loopthroughplugindirsandfindtheplugin foreach($this->getPluginsDir()as$_plugin_dir){ $names=array( $_plugin_dir.$_plugin_filename, $_plugin_dir.strtolower($_plugin_filename), ); foreach($namesas$file){ if(file_exists($file)){ require_once($file); return$file; } if($this->use_include_path&&!preg_match('/^([\/\\\\]|[a-zA-Z]:[\/\\\\])/',$_plugin_dir)){ //tryPHPinclude_path if($_stream_resolve_include_path){ $file=stream_resolve_include_path($file); }else{ $file=Smarty_Internal_Get_Include_Path::getIncludePath($file); } if($file!==false){ require_once($file); return$file; } } } } //nopluginloaded returnfalse; } /** *Compilealltemplatefiles * *@paramstring$extensionfileextension *@parambool$force_compileforcealltorecompile *@paramint$time_limit *@paramint$max_errors * *@returnintegernumberoftemplatefilesrecompiled */ publicfunctioncompileAllTemplates($extension='.tpl',$force_compile=false,$time_limit=0,$max_errors=null) { returnSmarty_Internal_Utility::compileAllTemplates($extension,$force_compile,$time_limit,$max_errors,$this); } /** *Compileallconfigfiles * *@paramstring$extensionfileextension *@parambool$force_compileforcealltorecompile *@paramint$time_limit *@paramint$max_errors * *@returnintegernumberoftemplatefilesrecompiled */ publicfunctioncompileAllConfig($extension='.conf',$force_compile=false,$time_limit=0,$max_errors=null) { returnSmarty_Internal_Utility::compileAllConfig($extension,$force_compile,$time_limit,$max_errors,$this); } /** *Deletecompiledtemplatefile * *@paramstring$resource_nametemplatename *@paramstring$compile_idcompileid *@paraminteger$exp_timeexpirationtime * *@returnintegernumberoftemplatefilesdeleted */ publicfunctionclearCompiledTemplate($resource_name=null,$compile_id=null,$exp_time=null) { returnSmarty_Internal_Utility::clearCompiledTemplate($resource_name,$compile_id,$exp_time,$this); } /** *Returnarrayoftag/attributesofalltagsusedbyantemplate * *@paramSmarty_Internal_Template$template * *@returnarrayoftag/attributes */ publicfunctiongetTags(Smarty_Internal_Template$template) { returnSmarty_Internal_Utility::getTags($template); } /** *Runinstallationtest * *@paramarray$errorsArraytowriteerrorsinto,ratherthanoutputtingthem * *@returnbooleantrueifsetupisfine,falseifsomethingiswrong */ publicfunctiontestInstall(&$errors=null) { returnSmarty_Internal_Utility::testInstall($this,$errors); } /** *ErrorHandlertomuteexpectedmessages * *@linkhttp://php.net/set_error_handler * *@paraminteger$errnoErrorlevel *@param$errstr *@param$errfile *@param$errline *@param$errcontext * *@returnboolean */ publicstaticfunctionmutingErrorHandler($errno,$errstr,$errfile,$errline,$errcontext) { $_is_muted_directory=false; //addtheSMARTY_DIRtothelistofmuteddirectories if(!isset(Smarty::$_muted_directories[SMARTY_DIR])){ $smarty_dir=realpath(SMARTY_DIR); if($smarty_dir!==false){ Smarty::$_muted_directories[SMARTY_DIR]=array( 'file'=>$smarty_dir, 'length'=>strlen($smarty_dir), ); } } //walkthemuteddirectoriesandtestagainst$errfile foreach(Smarty::$_muted_directoriesas$key=>&$dir){ if(!$dir){ //resolvedirectoryandlengthforspeedycomparisons $file=realpath($key); if($file===false){ //thisdirectorydoesnotexist,removeandskipit unset(Smarty::$_muted_directories[$key]); continue; } $dir=array( 'file'=>$file, 'length'=>strlen($file), ); } if(!strncmp($errfile,$dir['file'],$dir['length'])){ $_is_muted_directory=true; break; } } //passtonexterrorhandlerifthiserrordidnotoccurinsideSMARTY_DIR //ortheerrorwaswithinsmartybutmaskedtobeignored if(!$_is_muted_directory||($errno&&$errno&error_reporting())){ if(Smarty::$_previous_error_handler){ returncall_user_func(Smarty::$_previous_error_handler,$errno,$errstr,$errfile,$errline,$errcontext); }else{ returnfalse; } } } /** *Enableerrorhandlertomuteexpectedmessages * *@returnvoid */ publicstaticfunctionmuteExpectedErrors() { /* errormutingisdonebecausesomepeopleimplementedcustomerror_handlersusing http://php.net/set_error_handlerandforsomereasondidnotunderstandthefollowingparagraph: ItisimportanttorememberthatthestandardPHPerrorhandleriscompletelybypassedforthe errortypesspecifiedbyerror_typesunlessthecallbackfunctionreturnsFALSE. error_reporting()settingswillhavenoeffectandyourerrorhandlerwillbecalledregardless- howeveryouarestillabletoreadthecurrentvalueoferror_reportingandactappropriately. Ofparticularnoteisthatthisvaluewillbe0ifthestatementthatcausedtheerrorwas prependedbythe@error-controloperator. Smartydeliberatelyuses@filemtime()overfile_exists()andfilemtime()insomeplaces.Reasonsinclude -@filemtime()isalmosttwiceasfastasusinganadditionalfile_exists() -betweenfile_exists()andfilemtime()apossibleraceconditionisopened, whichdoesnotexistusingthesimple@filemtime()approach. */ $error_handler=array('Smarty','mutingErrorHandler'); $previous=set_error_handler($error_handler); //avoiddeadloops if($previous!==$error_handler){ Smarty::$_previous_error_handler=$previous; } } /** *Disableerrorhandlermutingexpectedmessages * *@returnvoid */ publicstaticfunctionunmuteExpectedErrors() { restore_error_handler(); } } //Checkifwe'rerunningonwindows Smarty::$_IS_WINDOWS=strtoupper(substr(PHP_OS,0,3))==='WIN'; //letPCRE(preg_*)treatstringsasISO-8859-1ifwe'renotdealingwithUTF-8 if(Smarty::$_CHARSET!=='UTF-8'){ Smarty::$_UTF8_MODIFIER=''; } /** *Smartyexceptionclass * *@packageSmarty */ classSmartyExceptionextendsException { publicstatic$escape=false; publicfunction__toString() { return'-->Smarty:'.(self::$escape?htmlentities($this->message):$this->message).'<--'; } } /** *Smartycompilerexceptionclass * *@packageSmarty */ classSmartyCompilerExceptionextendsSmartyException { publicfunction__toString() { return'-->SmartyCompiler:'.$this->message.'<--'; } /** *Thelinenumberofthetemplateerror * *@typeint|null */ public$line=null; /** *Thetemplatesourcesnippetrelatingtotheerror * *@typestring|null */ public$source=null; /** *Therawtextoftheerrormessage * *@typestring|null */ public$desc=null; /** *Theresourceidentifierortemplatename * *@typestring|null */ public$template=null; } /** *Autoloader */ functionsmartyAutoload($class) { $_class=strtolower($class); static$_classes=array( 'smarty_config_source'=>true, 'smarty_config_compiled'=>true, 'smarty_security'=>true, 'smarty_cacheresource'=>true, 'smarty_cacheresource_custom'=>true, 'smarty_cacheresource_keyvaluestore'=>true, 'smarty_resource'=>true, 'smarty_resource_custom'=>true, 'smarty_resource_uncompiled'=>true, 'smarty_resource_recompiled'=>true, ); if(!strncmp($_class,'smarty_internal_',16)||isset($_classes[$_class])){ includeSMARTY_SYSPLUGINS_DIR.$_class.'.php'; } } <?php /** *Project:Smarty:thePHPcompilingtemplateengine *File:Smarty.class.php *SVN:$Id:Smarty.class.php48482014-06-0818:12:09ZUwe.Tews@googlemail.com$ *Thislibraryisfreesoftware;youcanredistributeitand/or *modifyitunderthetermsoftheGNULesserGeneralPublic *LicenseaspublishedbytheFreeSoftwareFoundation;either *version2.1oftheLicense,or(atyouroption)anylaterversion. *Thislibraryisdistributedinthehopethatitwillbeuseful, *butWITHOUTANYWARRANTY;withouteventheimpliedwarrantyof *MERCHANTABILITYorFITNESSFORAPARTICULARPURPOSE.SeetheGNU *LesserGeneralPublicLicenseformoredetails. *YoushouldhavereceivedacopyoftheGNULesserGeneralPublic *Licensealongwiththislibrary;ifnot,writetotheFreeSoftware *Foundation,Inc.,59TemplePlace,Suite330,Boston,MA02111-1307USA *Forquestions,help,comments,discussion,etc.,pleasejointhe *Smartymailinglist.Sendablanke-mailto *smarty-discussion-subscribe@googlegroups.com * *@linkhttp://www.smarty.net/ *@copyright2008NewDigitalGroup,Inc. *@authorMonteOhrt<monteatohrtdotcom> *@authorUweTews *@authorRodneyRehm *@packageSmarty *@version3.1.19 */ /** *defineshorthanddirectoryseparatorconstant */ if(!defined('DS')){ define('DS',DIRECTORY_SEPARATOR); } /** *setSMARTY_DIRtoabsolutepathtoSmartylibraryfiles. *SetsSMARTY_DIRonlyifuserapplicationhasnotalreadydefinedit. */ if(!defined('SMARTY_DIR')){ define('SMARTY_DIR',dirname(__FILE__).DS); } /** *setSMARTY_SYSPLUGINS_DIRtoabsolutepathtoSmartyinternalplugins. *SetsSMARTY_SYSPLUGINS_DIRonlyifuserapplicationhasnotalreadydefinedit. */ 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-8canonlybedoneproperlywhenmbstringisavailable! /** *@deprecatedinfavorofSmarty::$_CHARSET */ define('SMARTY_RESOURCE_CHAR_SET',SMARTY_MBSTRING?'UTF-8':'ISO-8859-1'); } if(!defined('SMARTY_RESOURCE_DATE_FORMAT')){ /** *@deprecatedinfavorofSmarty::$_DATE_FORMAT */ define('SMARTY_RESOURCE_DATE_FORMAT','%b%e,%Y'); } /** *registertheclassautoloader */ 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'); } /** *Loadalwaysneededexternalclassfiles */ include_onceSMARTY_SYSPLUGINS_DIR.'smarty_internal_data.php'; include_onceSMARTY_SYSPLUGINS_DIR.'smarty_internal_templatebase.php'; include_onceSMARTY_SYSPLUGINS_DIR.'smarty_internal_template.php'; include_onceSMARTY_SYSPLUGINS_DIR.'smarty_resource.php'; include_onceSMARTY_SYSPLUGINS_DIR.'smarty_internal_resource_file.php'; include_onceSMARTY_SYSPLUGINS_DIR.'smarty_cacheresource.php'; include_onceSMARTY_SYSPLUGINS_DIR.'smarty_internal_cacheresource_file.php'; /** *ThisisthemainSmartyclass * *@packageSmarty */ classSmartyextendsSmarty_Internal_TemplateBase { /**#@+ *constantdefinitions */ /** *smartyversion */ constSMARTY_VERSION='Smarty-3.1.19'; /** *definevariablescopes */ constSCOPE_LOCAL=0; constSCOPE_PARENT=1; constSCOPE_ROOT=2; constSCOPE_GLOBAL=3; /** *definecachingmodes */ constCACHING_OFF=0; constCACHING_LIFETIME_CURRENT=1; constCACHING_LIFETIME_SAVED=2; /** *defineconstantforclearingcachefilesbesavedexpirationdatees */ constCLEAR_EXPIRED=-1; /** *definecompilecheckmodes */ constCOMPILECHECK_OFF=0; constCOMPILECHECK_ON=1; constCOMPILECHECK_CACHEMISS=2; /** *modesforhandlingof"<?php...?>"tagsintemplates. */ constPHP_PASSTHRU=0;//->printtagsasplaintext constPHP_QUOTE=1;//->escapetagsasentities constPHP_REMOVE=2;//->escapetagsasentities constPHP_ALLOW=3;//->escapetagsasentities /** *filtertypes */ constFILTER_POST='post'; constFILTER_PRE='pre'; constFILTER_OUTPUT='output'; constFILTER_VARIABLE='variable'; /** *plugintypes */ constPLUGIN_FUNCTION='function'; constPLUGIN_BLOCK='block'; constPLUGIN_COMPILER='compiler'; constPLUGIN_MODIFIER='modifier'; constPLUGIN_MODIFIERCOMPILER='modifiercompiler'; /**#@-*/ /** *assignedglobaltplvars */ publicstatic$global_tpl_vars=array(); /** *errorhandlerreturnedbyset_error_hanlder()inSmarty::muteExpectedErrors() */ publicstatic$_previous_error_handler=null; /** *containsdirectoriesoutsideofSMARTY_DIRthataretobemutedbymuteExpectedErrors() */ publicstatic$_muted_directories=array(); /** *FlagdenotingifMultibyteStringfunctionsareavailable */ publicstatic$_MBSTRING=SMARTY_MBSTRING; /** *Thecharactersettoadhereto(e.g."UTF-8") */ publicstatic$_CHARSET=SMARTY_RESOURCE_CHAR_SET; /** *Thedateformattobeusedinternally *(acceptsdate()andstrftime()) */ publicstatic$_DATE_FORMAT=SMARTY_RESOURCE_DATE_FORMAT; /** *FlagdenotingifPCREshouldruninUTF-8mode */ publicstatic$_UTF8_MODIFIER='u'; /** *Flagdenotingifoperatingsystemiswindows */ publicstatic$_IS_WINDOWS=false; /**#@+ *variables */ /** *autoliteralondelimiterswithwhitspace * *@varboolean */ public$auto_literal=true; /** *displayerroronnotassignedvariables * *@varboolean */ public$error_unassigned=false; /** *lookuprelativefilepathsininclude_path * *@varboolean */ public$use_include_path=false; /** *templatedirectory * *@vararray */ private$template_dir=array(); /** *joinedtemplatedirectorystringusedincachekeys * *@varstring */ public$joined_template_dir=null; /** *joinedconfigdirectorystringusedincachekeys * *@varstring */ public$joined_config_dir=null; /** *defaulttemplatehandler * *@varcallable */ public$default_template_handler_func=null; /** *defaultconfighandler * *@varcallable */ public$default_config_handler_func=null; /** *defaultpluginhandler * *@varcallable */ public$default_plugin_handler_func=null; /** *compiledirectory * *@varstring */ private$compile_dir=null; /** *pluginsdirectory * *@vararray */ private$plugins_dir=array(); /** *cachedirectory * *@varstring */ private$cache_dir=null; /** *configdirectory * *@vararray */ private$config_dir=array(); /** *forcetemplatecompiling? * *@varboolean */ public$force_compile=false; /** *checktemplateformodifications? * *@varboolean */ public$compile_check=true; /** *usesubdirsforcompiled/cachedfiles? * *@varboolean */ public$use_sub_dirs=false; /** *allowambiguousresources(thataremadeuniquebytheresourcehandler) * *@varboolean */ public$allow_ambiguous_resources=false; /** *cachingenabled * *@varboolean */ public$caching=false; /** *mergecompiledincludes * *@varboolean */ public$merge_compiled_includes=false; /** *templateinheritancemergecompiledincludes * *@varboolean */ public$inheritance_merge_compiled_includes=true; /** *cachelifetimeinseconds * *@varinteger */ public$cache_lifetime=3600; /** *forcecachefilecreation * *@varboolean */ public$force_cache=false; /** *Setthisifyouwantdifferentsetsofcachefilesforthesame *templates. * *@varstring */ public$cache_id=null; /** *Setthisifyouwantdifferentsetsofcompiledfilesforthesame *templates. * *@varstring */ public$compile_id=null; /** *templateleft-delimiter * *@varstring */ public$left_delimiter="{"; /** *templateright-delimiter * *@varstring */ public$right_delimiter="}"; /**#@+ *security */ /** *classname *ThisshouldbeinstanceofSmarty_Security. * *@varstring *@seeSmarty_Security */ public$security_class='Smarty_Security'; /** *implementationofsecurityclass * *@varSmarty_Security */ public$security_policy=null; /** *controlshandlingofPHP-blocks * *@varinteger */ public$php_handling=self::PHP_PASSTHRU; /** *controlsifthephptemplatefileresourceisallowed * *@varbool */ public$allow_php_templates=false; /** *Shouldcompiled-templatesbepreventedfrombeingcalleddirectly? *{@internal *CurrentlyusedbySmarty_Internal_Templateonly. *}} * *@varboolean */ public$direct_access_security=true; /**#@-*/ /** *debugmode *Settingthistotrueenablesthedebug-console. * *@varboolean */ public$debugging=false; /** *Thisdeterminesifdebuggingisenable-ablefromthebrowser. *<ul> *<li>NONE=>nodebuggingcontrolallowed</li> *<li>URL=>enabledebuggingwhenSMARTY_DEBUGisfoundintheURL.</li> *</ul> * *@varstring */ public$debugging_ctrl='NONE'; /** *NameofdebuggingURL-param. *Onlyusedwhen$debugging_ctrlissetto'URL'. *ThenameoftheURL-parameterthatactivatesdebugging. * *@vartype */ public$smarty_debug_id='SMARTY_DEBUG'; /** *Pathofdebugtemplate. * *@varstring */ public$debug_tpl=null; /** *Whenset,smartyusesthisvalueaserror_reporting-level. * *@varint */ public$error_reporting=null; /** *InternalflagforgetTags() * *@varboolean */ public$get_used_tags=false; /**#@+ *configvarsettings */ /** *Controlswhethervariableswiththesamenameoverwriteeachother. * *@varboolean */ public$config_overwrite=true; /** *Controlswhetherconfigvaluesofon/true/yesandoff/false/nogetconvertedtoboolean. * *@varboolean */ public$config_booleanize=true; /** *Controlswhetherhiddenconfigsections/varsarereadfromthefile. * *@varboolean */ public$config_read_hidden=false; /**#@-*/ /**#@+ *resourcelocking */ /** *lockingconcurrentcompiles * *@varboolean */ public$compile_locking=true; /** *Controlswhethercacheresourcesshouldemplylockingmechanism * *@varboolean */ public$cache_locking=false; /** *secondstowaitforacquiringalockbeforeignoringthewritelock * *@varfloat */ public$locking_timeout=10; /**#@-*/ /** *globaltemplatefunctions * *@vararray */ public$template_functions=array(); /** *resourcetypeusedifnonegiven *Mustbeanvalidkeyof$registered_resources. * *@varstring */ public$default_resource_type='file'; /** *cachingtype *Mustbeanelementof$cache_resource_types. * *@varstring */ public$caching_type='file'; /** *internalconfigproperties * *@vararray */ public$properties=array(); /** *configtype * *@varstring */ public$default_config_type='file'; /** *cachedtemplateobjects * *@vararray */ public$template_objects=array(); /** *checkIf-Modified-Sinceheaders * *@varboolean */ public$cache_modified_check=false; /** *registeredplugins * *@vararray */ public$registered_plugins=array(); /** *pluginsearchorder * *@vararray */ public$plugin_search_order=array('function','block','compiler','class'); /** *registeredobjects * *@vararray */ public$registered_objects=array(); /** *registeredclasses * *@vararray */ public$registered_classes=array(); /** *registeredfilters * *@vararray */ public$registered_filters=array(); /** *registeredresources * *@vararray */ public$registered_resources=array(); /** *resourcehandlercache * *@vararray */ public$_resource_handlers=array(); /** *registeredcacheresources * *@vararray */ public$registered_cache_resources=array(); /** *cacheresourcehandlercache * *@vararray */ public$_cacheresource_handlers=array(); /** *autoloadfilter * *@vararray */ public$autoload_filters=array(); /** *defaultmodifier * *@vararray */ public$default_modifiers=array(); /** *autoescapevariableoutput * *@varboolean */ public$escape_html=false; /** *globalinternalsmartyvars * *@vararray */ publicstatic$_smarty_vars=array(); /** *starttimeforexecutiontimecalculation * *@varint */ public$start_time=0; /** *defaultfilepermissions * *@varint */ public$_file_perms=0644; /** *defaultdirpermissions * *@varint */ public$_dir_perms=0771; /** *blocktaghierarchy * *@vararray */ public$_tag_stack=array(); /** *selfpointertoSmartyobject * *@varSmarty */ public$smarty; /** *requiredbythecompilerforBC * *@varstring */ public$_current_file=null; /** *internalflagtoenableparserdebugging * *@varbool */ public$_parserdebug=false; /** *Savedparameterofmergedtemplatesduringcompilation * *@vararray */ public$merged_templates_func=array(); /**#@-*/ /** *InitializenewSmartyobject */ publicfunction__construct() { //selfpointerneededbysomeotherclassmethods $this->smarty=$this; if(is_callable('mb_internal_encoding')){ mb_internal_encoding(Smarty::$_CHARSET); } $this->start_time=microtime(true); //setdefaultdirs $this->setTemplateDir('.'.DS.'templates'.DS) ->setCompileDir('.'.DS.'templates_c'.DS) ->setPluginsDir(SMARTY_PLUGINS_DIR) ->setCacheDir('.'.DS.'cache'.DS) ->setConfigDir('.'.DS.'configs'.DS); $this->debug_tpl='file:'.dirname(__FILE__).'/debug.tpl'; if(isset($_SERVER['SCRIPT_NAME'])){ $this->assignGlobal('SCRIPT_NAME',$_SERVER['SCRIPT_NAME']); } } /** *Classdestructor */ publicfunction__destruct() { //intentionallyleftblank } /** *<<magic>>setselfpointeronclonedobject */ publicfunction__clone() { $this->smarty=$this; } /** *<<magic>>Genericgetter. *Callstheappropriategetterfunction. *IssuesanE_USER_NOTICEifnovalidgetterisfound. * *@paramstring$namepropertyname * *@returnmixed */ publicfunction__get($name) { $allowed=array( 'template_dir'=>'getTemplateDir', 'config_dir'=>'getConfigDir', 'plugins_dir'=>'getPluginsDir', 'compile_dir'=>'getCompileDir', 'cache_dir'=>'getCacheDir', ); if(isset($allowed[$name])){ return$this->{$allowed[$name]}(); }else{ trigger_error('Undefinedproperty:'.get_class($this).'::$'.$name,E_USER_NOTICE); } } /** *<<magic>>Genericsetter. *Callstheappropriatesetterfunction. *IssuesanE_USER_NOTICEifnovalidsetterisfound. * *@paramstring$namepropertyname *@parammixed$valueparameterpassedtosetter */ publicfunction__set($name,$value) { $allowed=array( 'template_dir'=>'setTemplateDir', 'config_dir'=>'setConfigDir', 'plugins_dir'=>'setPluginsDir', 'compile_dir'=>'setCompileDir', 'cache_dir'=>'setCacheDir', ); if(isset($allowed[$name])){ $this->{$allowed[$name]}($value); }else{ trigger_error('Undefinedproperty:'.get_class($this).'::$'.$name,E_USER_NOTICE); } } /** *Checkifatemplateresourceexists * *@paramstring$resource_nametemplatename * *@returnbooleanstatus */ publicfunctiontemplateExists($resource_name) { //createtemplateobject $save=$this->template_objects; $tpl=new$this->template_class($resource_name,$this); //checkifitdoesexists $result=$tpl->source->exists; $this->template_objects=$save; return$result; } /** *Returnsasingleorallglobalvariables * *@paramstring$varnamevariablenameornull * *@returnstringvariablevalueororarrayofvariables */ publicfunctiongetGlobal($varname=null) { if(isset($varname)){ if(isset(self::$global_tpl_vars[$varname])){ returnself::$global_tpl_vars[$varname]->value; }else{ return''; } }else{ $_result=array(); foreach(self::$global_tpl_varsAS$key=>$var){ $_result[$key]=$var->value; } return$_result; } } /** *Emptycachefolder * *@paraminteger$exp_timeexpirationtime *@paramstring$typeresourcetype * *@returnintegernumberofcachefilesdeleted */ publicfunctionclearAllCache($exp_time=null,$type=null) { //loadcacheresourceandcallclearAll $_cache_resource=Smarty_CacheResource::load($this,$type); Smarty_CacheResource::invalidLoadedCache($this); return$_cache_resource->clearAll($this,$exp_time); } /** *Emptycacheforaspecifictemplate * *@paramstring$template_nametemplatename *@paramstring$cache_idcacheid *@paramstring$compile_idcompileid *@paraminteger$exp_timeexpirationtime *@paramstring$typeresourcetype * *@returnintegernumberofcachefilesdeleted */ publicfunctionclearCache($template_name,$cache_id=null,$compile_id=null,$exp_time=null,$type=null) { //loadcacheresourceandcallclear $_cache_resource=Smarty_CacheResour