\Smarty_Internal_Template

Main class with template data structures and methods

Summary

Methods
Properties
Constants
fetch()
display()
isCached()
registerPlugin()
loadFilter()
registerFilter()
registerObject()
setCaching()
setCacheLifetime()
setCompileId()
setCacheId()
__construct()
assign()
append()
assignGlobal()
appendByRef()
assignByRef()
getTemplateVars()
getVariable()
_mergeVars()
_isDataObj()
_isTplObj()
_isSmartyObj()
_getSmartyObj()
__call()
render()
_subTemplateRender()
_subTemplateRegister()
_isSubTpl()
_assignInScope()
_decodeProperties()
compileTemplateSource()
writeCachedContent()
_getTemplateId()
capture_error()
loadCompiled()
loadCached()
_loadInheritance()
_cleanUp()
loadCompiler()
__set()
__get()
__destruct()
mustCompile()
addAutoloadFilters()
addDefaultModifier()
createData()
getAutoloadFilters()
getDebugTemplate()
getDefaultModifier()
getTags()
getRegisteredObject()
registerCacheResource()
registerClass()
registerDefaultConfigHandler()
registerDefaultPluginHandler()
registerDefaultTemplateHandler()
registerResource()
setAutoloadFilters()
setDebugTemplate()
setDefaultModifier()
unloadFilter()
unregisterCacheResource()
unregisterObject()
unregisterPlugin()
unregisterFilter()
unregisterResource()
_getSmartyObj()
getConfigVariable()
getConfigVars()
getGlobal()
getStreamVariable()
clearAssign()
clearAllAssign()
clearConfig()
configLoad()
$cache_id
$compile_id
$caching
$cache_lifetime
$tplFunctions
$_cache
$_objType
$template_class
$tpl_vars
$parent
$config_vars
$ext
$smarty
$source
$inheritance
$template_resource
$mustCompile
$templateId
$scope
$isRenderingCache
$startRenderCallbacks
$endRenderCallbacks
$tplObjCache
$isCacheTplObj
$subTplInfo
$compiled
$cached
$compiler
$_objType
$scope
$smarty
No constants found
No protected methods found
No protected properties found
N/A
_execute()
No private properties found
N/A

Properties

$cache_id

$cache_id : string

Set this if you want different sets of cache files for the same templates.

Type

string

$compile_id

$compile_id : string

Set this if you want different sets of compiled files for the same templates.

Type

string

$caching

$caching : boolean

caching enabled

Type

boolean

$cache_lifetime

$cache_lifetime : integer

cache lifetime in seconds

Type

integer

$tplFunctions

$tplFunctions : array

Array of source information for known template functions

Type

array

$_cache

$_cache : \array()

universal cache

Type

\array()

$_objType

$_objType : integer

This object type (Smarty = 1, template = 2, data = 4)

Type

integer

$template_class

$template_class : string

name of class used for templates

Type

string

$tpl_vars

$tpl_vars : array<mixed,\Smarty_Variable>

template variables

Type

array<mixed,\Smarty_Variable>

$config_vars

$config_vars : array<mixed,string>

configuration settings

Type

array<mixed,string>

$smarty

$smarty : \Smarty

Global smarty instance

Type

\Smarty

$template_resource

$template_resource : string

Template resource

Type

string

$mustCompile

$mustCompile : boolean

flag if compiled template is invalid and must be (re)compiled

Type

boolean

$templateId

$templateId : null|string

Template Id

Type

null|string

$scope

$scope : integer

Scope in which variables shall be assigned

Type

integer

$isRenderingCache

$isRenderingCache : boolean

Flag which is set while rending a cache file

Type

boolean

$startRenderCallbacks

$startRenderCallbacks : array<mixed,callback>

Callbacks called before rendering template

Type

array<mixed,callback>

$endRenderCallbacks

$endRenderCallbacks : array<mixed,callback>

Callbacks called after rendering template

Type

array<mixed,callback>

$tplObjCache

$tplObjCache : array<mixed,\Smarty_Internal_Template>

Template object cache

Type

array<mixed,\Smarty_Internal_Template>

$isCacheTplObj

$isCacheTplObj : array<mixed,\Smarty_Internal_Template>

Template object cache for Smarty::isCached() == true

Type

array<mixed,\Smarty_Internal_Template>

$subTplInfo

$subTplInfo : array<mixed,\string[]int>

Subtemplate Info Cache

Type

array<mixed,\string[]int>

$compiled

$compiled : \Smarty_Template_Compiled

Type

\Smarty_Template_Compiled

$cached

$cached : \Smarty_Template_Cached

Type

\Smarty_Template_Cached

$compiler

$compiler : \Smarty_Internal_TemplateCompilerBase

The following methods will be dynamically loaded by the extension handler when they are called. They are located in a corresponding Smarty_Internal_Method_xxxx class

Type

\Smarty_Internal_TemplateCompilerBase

$_objType

$_objType : integer

This object type (Smarty = 1, template = 2, data = 4)

The following methods will be dynamically loaded by the extension handler when they are called. They are located in a corresponding Smarty_Internal_Method_xxxx class

Type

integer

$scope

$scope : integer

Type

integer

$smarty

$smarty : \Smarty

The following methods will be dynamically loaded by the extension handler when they are called. They are located in a corresponding Smarty_Internal_Method_xxxx class

Type

\Smarty

Methods

fetch()

fetch(string  $template = null, mixed  $cache_id = null, mixed  $compile_id = null, object  $parent = null) : string

fetches a rendered Smarty template

Parameters

string $template

the resource handle of the template file or template object

mixed $cache_id

cache id to be used with this template

mixed $compile_id

compile id to be used with this template

object $parent

next higher level of Smarty variables

Throws

\Exception
\SmartyException

Returns

string —

rendered template output

display()

display(string  $template = null, mixed  $cache_id = null, mixed  $compile_id = null, object  $parent = null) 

displays a Smarty template

Parameters

string $template

the resource handle of the template file or template object

mixed $cache_id

cache id to be used with this template

mixed $compile_id

compile id to be used with this template

object $parent

next higher level of Smarty variables

isCached()

isCached(null|string|\Smarty_Internal_Template  $template = null, mixed  $cache_id = null, mixed  $compile_id = null, object  $parent = null) : boolean

test if cache is valid

Parameters

null|string|\Smarty_Internal_Template $template

the resource handle of the template file or template object

mixed $cache_id

cache id to be used with this template

mixed $compile_id

compile id to be used with this template

object $parent

next higher level of Smarty variables

Returns

boolean —

cache status

registerPlugin()

registerPlugin(string  $type, string  $name, callback  $callback, boolean  $cacheable = true, mixed  $cache_attr = null) : \Smarty|\Smarty_Internal_Template

Registers plugin to be used in templates

Parameters

string $type

plugin type

string $name

name of template tag

callback $callback

PHP callback to register

boolean $cacheable

if true (default) this function is cache able

mixed $cache_attr

caching attributes if any

Throws

\SmartyException

when the plugin tag is invalid

Returns

\Smarty|\Smarty_Internal_Template

loadFilter()

loadFilter(string  $type, string  $name) : boolean

load a filter of specified type and name

Parameters

string $type

filter type

string $name

filter name

Throws

\SmartyException

if filter could not be loaded

Returns

boolean

registerFilter()

registerFilter(string  $type, callback  $callback, string|null  $name = null) : \Smarty|\Smarty_Internal_Template

Registers a filter function

Parameters

string $type

filter type

callback $callback
string|null $name

optional filter name

Throws

\SmartyException

Returns

\Smarty|\Smarty_Internal_Template

registerObject()

registerObject(string  $object_name, object  $object, array  $allowed_methods_properties = array(), boolean  $format = true, array  $block_methods = array()) : \Smarty|\Smarty_Internal_Template

Registers object to be used in templates

Parameters

string $object_name
object $object

the referenced PHP object to register

array $allowed_methods_properties

list of allowed methods (empty = all)

boolean $format

smarty argument format, else traditional

array $block_methods

list of block-methods

Throws

\SmartyException

Returns

\Smarty|\Smarty_Internal_Template

setCaching()

setCaching(boolean  $caching) 

Parameters

boolean $caching

setCacheLifetime()

setCacheLifetime(integer  $cache_lifetime) 

Parameters

integer $cache_lifetime

setCompileId()

setCompileId(string  $compile_id) 

Parameters

string $compile_id

setCacheId()

setCacheId(string  $cache_id) 

Parameters

string $cache_id

__construct()

__construct(string  $template_resource, \Smarty  $smarty, null|\Smarty_Internal_Template|\Smarty|\Smarty_Internal_Data  $_parent = null, mixed  $_cache_id = null, mixed  $_compile_id = null, boolean|integer|null  $_caching = null, integer|null  $_cache_lifetime = null, boolean  $_isConfig = false) 

Create template data object Some of the global Smarty settings copied to template scope It load the required template resources and caching plugins

Parameters

string $template_resource

template resource string

\Smarty $smarty

Smarty instance

null|\Smarty_Internal_Template|\Smarty|\Smarty_Internal_Data $_parent

back pointer to parent object with variables or null

mixed $_cache_id

cache id or null

mixed $_compile_id

compile id or null

boolean|integer|null $_caching

use caching?

integer|null $_cache_lifetime

cache life-time in seconds

boolean $_isConfig

Throws

\SmartyException

assign()

assign(array|string  $tpl_var, mixed  $value = null, boolean  $nocache = false) : \Smarty_Internal_Data

assigns a Smarty variable

Parameters

array|string $tpl_var

the template variable name(s)

mixed $value

the value to assign

boolean $nocache

if true any output of this variable will be not cached

Returns

\Smarty_Internal_Data

current Smarty_Internal_Data (or Smarty or Smarty_Internal_Template) instance for chaining

append()

append(array|string  $tpl_var, mixed  $value = null, boolean  $merge = false, boolean  $nocache = false) : \Smarty_Internal_Data|\Smarty_Internal_Template|\Smarty

appends values to template variables

Parameters

array|string $tpl_var

the template variable name(s)

mixed $value

the value to append

boolean $merge

flag if array elements shall be merged

boolean $nocache

if true any output of this variable will be not cached

Returns

\Smarty_Internal_Data|\Smarty_Internal_Template|\Smarty

assignGlobal()

assignGlobal(string  $varName, mixed  $value = null, boolean  $nocache = false) : \Smarty_Internal_Data|\Smarty_Internal_Template|\Smarty

assigns a global Smarty variable

Parameters

string $varName

the global variable name

mixed $value

the value to assign

boolean $nocache

if true any output of this variable will be not cached

Returns

\Smarty_Internal_Data|\Smarty_Internal_Template|\Smarty

appendByRef()

appendByRef(string  $tpl_var,   $value, boolean  $merge = false) : \Smarty_Internal_Data|\Smarty_Internal_Template|\Smarty

appends values to template variables by reference

Parameters

string $tpl_var

the template variable name

$value
boolean $merge

flag if array elements shall be merged

Returns

\Smarty_Internal_Data|\Smarty_Internal_Template|\Smarty

assignByRef()

assignByRef(string  $tpl_var,   $value, boolean  $nocache = false) : \Smarty_Internal_Data|\Smarty_Internal_Template|\Smarty

assigns values to template variables by reference

Parameters

string $tpl_var

the template variable name

$value
boolean $nocache

if true any output of this variable will be not cached

Returns

\Smarty_Internal_Data|\Smarty_Internal_Template|\Smarty

getTemplateVars()

getTemplateVars(string  $varName = null, \Smarty_Internal_Data|\Smarty_Internal_Template|\Smarty  $_ptr = null, boolean  $searchParents = true) : mixed

Returns a single or all template variables

Parameters

string $varName

variable name or null

\Smarty_Internal_Data|\Smarty_Internal_Template|\Smarty $_ptr

optional pointer to data object

boolean $searchParents

include parent templates?

Returns

mixed —

variable value or or array of variables

getVariable()

getVariable(string  $variable = null, \Smarty_Internal_Data  $_ptr = null, boolean  $searchParents = true, boolean  $error_enable = true) : \Smarty_Variable|\Smarty_Undefined_Variable

gets the object of a Smarty variable

Parameters

string $variable

the name of the Smarty variable

\Smarty_Internal_Data $_ptr

optional pointer to data object

boolean $searchParents

search also in parent data

boolean $error_enable

Returns

\Smarty_Variable|\Smarty_Undefined_Variable

the object of the variable

_mergeVars()

_mergeVars(\Smarty_Internal_Data|null  $data = null) 

Follow the parent chain an merge template and config variables

Parameters

\Smarty_Internal_Data|null $data

_isDataObj()

_isDataObj() : boolean

Return true if this instance is a Data obj

Returns

boolean

_isTplObj()

_isTplObj() : boolean

Return true if this instance is a template obj

Returns

boolean

_isSmartyObj()

_isSmartyObj() : boolean

Return true if this instance is a Smarty obj

Returns

boolean

_getSmartyObj()

_getSmartyObj() : \Smarty

Get Smarty object

Returns

\Smarty

__call()

__call(string  $name, array  $args) : mixed

Handle unknown class methods

Parameters

string $name

unknown method-name

array $args

argument array

Throws

\SmartyException

Returns

mixed

render()

render(boolean  $no_output_filter = true, null|boolean  $display = null) : string

render template

Parameters

boolean $no_output_filter

if true do not run output filter

null|boolean $display

true: display, false: fetch null: sub-template

Throws

\SmartyException

Returns

string

_subTemplateRender()

_subTemplateRender(string  $template, mixed  $cache_id, mixed  $compile_id, integer  $caching, integer  $cache_lifetime, array  $data, integer  $scope, boolean  $forceTplCache, string  $uid = null, string  $content_func = null) 

Runtime function to render sub-template

Parameters

string $template

template name

mixed $cache_id

cache id

mixed $compile_id

compile id

integer $caching

cache mode

integer $cache_lifetime

life time of cache data

array $data

passed parameter template variables

integer $scope

scope in which {include} should execute

boolean $forceTplCache

cache template object

string $uid

file dependency uid

string $content_func

function name

_subTemplateRegister()

_subTemplateRegister() 

Get called sub-templates and save call count

_isSubTpl()

_isSubTpl() : boolean

Check if this is a sub template

Returns

boolean —

true is sub template

_assignInScope()

_assignInScope(string  $varName, mixed  $value, boolean  $nocache = false, integer  $scope) 

Assign variable in scope

Parameters

string $varName

variable name

mixed $value

value

boolean $nocache

nocache flag

integer $scope

scope into which variable shall be assigned

_decodeProperties()

_decodeProperties(\Smarty_Internal_Template  $tpl, array  $properties, boolean  $cache = false) : boolean

This function is executed automatically when a compiled or cached template file is included - Decode saved properties from compiled template and cache files - Check if compiled or cache file is valid

Parameters

\Smarty_Internal_Template $tpl
array $properties

special template properties

boolean $cache

flag if called from cache file

Throws

\SmartyException

Returns

boolean —

flag if compiled or cache file is valid

compileTemplateSource()

compileTemplateSource() 

Compiles the template If the template is not evaluated the compiled template is saved on disk

writeCachedContent()

writeCachedContent(string  $content) : boolean

Writes the content to cache resource

Parameters

string $content

Returns

boolean

_getTemplateId()

_getTemplateId() : string

Get unique template id

Returns

string

capture_error()

capture_error() 

runtime error not matching capture tags

loadCompiled()

loadCompiled(boolean  $force = false) 

Load compiled object

Parameters

boolean $force

force new compiled object

loadCached()

loadCached(boolean  $force = false) 

Load cached object

Parameters

boolean $force

force new cached object

_loadInheritance()

_loadInheritance() 

Load inheritance object

_cleanUp()

_cleanUp() 

Unload inheritance object

loadCompiler()

loadCompiler() 

Load compiler object

Throws

\SmartyException

__set()

__set(string  $property_name, mixed  $value) 

set Smarty property in template context

Parameters

string $property_name

property name

mixed $value

value

Throws

\SmartyException

__get()

__get(string  $property_name) : mixed|\Smarty_Template_Cached

get Smarty property in template context

Parameters

string $property_name

property name

Throws

\SmartyException

Returns

mixed|\Smarty_Template_Cached

__destruct()

__destruct() 

Template data object destructor

mustCompile()

mustCompile() : boolean

Returns

boolean

addAutoloadFilters()

addAutoloadFilters(mixed  $filters, string  $type = null) : \Smarty_Internal_TemplateBase

Parameters

mixed $filters
string $type

Returns

\Smarty_Internal_TemplateBase

addDefaultModifier()

addDefaultModifier(mixed  $modifiers) : \Smarty_Internal_TemplateBase

Parameters

mixed $modifiers

Returns

\Smarty_Internal_TemplateBase

createData()

createData(\Smarty_Internal_Data  $parent = null, string  $name = null) : \Smarty_Internal_TemplateBase

Parameters

\Smarty_Internal_Data $parent
string $name

Returns

\Smarty_Internal_TemplateBase

getAutoloadFilters()

getAutoloadFilters(string  $type = null) : array

Parameters

string $type

Returns

array

getDebugTemplate()

getDebugTemplate() : string

Returns

string

getDefaultModifier()

getDefaultModifier() : array

Returns

array

getTags()

getTags(mixed  $template = null) : array

Parameters

mixed $template

Returns

array

getRegisteredObject()

getRegisteredObject(string  $object_name) : object

Parameters

string $object_name

Returns

object

registerCacheResource()

registerCacheResource(string  $name, \Smarty_CacheResource  $resource_handler) : \Smarty_Internal_TemplateBase

Parameters

string $name
\Smarty_CacheResource $resource_handler

Returns

\Smarty_Internal_TemplateBase

registerClass()

registerClass(string  $class_name, string  $class_impl) : \Smarty_Internal_TemplateBase

Parameters

string $class_name
string $class_impl

Returns

\Smarty_Internal_TemplateBase

registerDefaultConfigHandler()

registerDefaultConfigHandler(callback  $callback) : \Smarty_Internal_TemplateBase

Parameters

callback $callback

Returns

\Smarty_Internal_TemplateBase

registerDefaultPluginHandler()

registerDefaultPluginHandler(callback  $callback) : \Smarty_Internal_TemplateBase

Parameters

callback $callback

Returns

\Smarty_Internal_TemplateBase

registerDefaultTemplateHandler()

registerDefaultTemplateHandler(callback  $callback) : \Smarty_Internal_TemplateBase

Parameters

callback $callback

Returns

\Smarty_Internal_TemplateBase

registerResource()

registerResource(string  $name, mixed  $resource_handler) : \Smarty_Internal_TemplateBase

Parameters

string $name
mixed $resource_handler

Returns

\Smarty_Internal_TemplateBase

setAutoloadFilters()

setAutoloadFilters(mixed  $filters, string  $type = null) : \Smarty_Internal_TemplateBase

Parameters

mixed $filters
string $type

Returns

\Smarty_Internal_TemplateBase

setDebugTemplate()

setDebugTemplate(string  $tpl_name) : \Smarty_Internal_TemplateBase

Parameters

string $tpl_name

Returns

\Smarty_Internal_TemplateBase

setDefaultModifier()

setDefaultModifier(mixed  $modifiers) : \Smarty_Internal_TemplateBase

Parameters

mixed $modifiers

Returns

\Smarty_Internal_TemplateBase

unloadFilter()

unloadFilter(string  $type, string  $name) : \Smarty_Internal_TemplateBase

Parameters

string $type
string $name

Returns

\Smarty_Internal_TemplateBase

unregisterCacheResource()

unregisterCacheResource(string  $name) : \Smarty_Internal_TemplateBase

Parameters

string $name

Returns

\Smarty_Internal_TemplateBase

unregisterObject()

unregisterObject(string  $object_name) : \Smarty_Internal_TemplateBase

Parameters

string $object_name

Returns

\Smarty_Internal_TemplateBase

unregisterPlugin()

unregisterPlugin(string  $type, string  $name) : \Smarty_Internal_TemplateBase

Parameters

string $type
string $name

Returns

\Smarty_Internal_TemplateBase

unregisterFilter()

unregisterFilter(string  $type, mixed  $callback) : \Smarty_Internal_TemplateBase

Parameters

string $type
mixed $callback

Returns

\Smarty_Internal_TemplateBase

unregisterResource()

unregisterResource(string  $name) : \Smarty_Internal_TemplateBase

Parameters

string $name

Returns

\Smarty_Internal_TemplateBase

_getSmartyObj()

_getSmartyObj() : \Smarty

Get Smarty object

Returns

\Smarty

getConfigVariable()

getConfigVariable(string  $varName, boolean  $errorEnable = true) : mixed

Parameters

string $varName
boolean $errorEnable

Returns

mixed

getConfigVars()

getConfigVars(string  $varName = null, boolean  $searchParents = true) : mixed

Parameters

string $varName
boolean $searchParents

Returns

mixed

getGlobal()

getGlobal(string  $varName = null) : mixed

Parameters

string $varName

Returns

mixed

getStreamVariable()

getStreamVariable(string  $variable) : mixed

Parameters

string $variable

Returns

mixed

clearAssign()

clearAssign(mixed  $tpl_var) : \Smarty_Internal_Data

Parameters

mixed $tpl_var

Returns

\Smarty_Internal_Data

clearAllAssign()

clearAllAssign() : \Smarty_Internal_Data

Returns

\Smarty_Internal_Data

clearConfig()

clearConfig(string  $varName = null) : \Smarty_Internal_Data

Parameters

string $varName

Returns

\Smarty_Internal_Data

configLoad()

configLoad(string  $config_file, mixed  $sections = null, string  $scope = 'local') : \Smarty_Internal_Data

Parameters

string $config_file
mixed $sections
string $scope

Returns

\Smarty_Internal_Data

_execute()

_execute(string  $template, mixed  $cache_id, mixed  $compile_id, object  $parent, string  $function) : mixed

fetches a rendered Smarty template

Parameters

string $template

the resource handle of the template file or template object

mixed $cache_id

cache id to be used with this template

mixed $compile_id

compile id to be used with this template

object $parent

next higher level of Smarty variables

string $function

function type 0 = fetch, 1 = display, 2 = isCache

Throws

\Exception
\SmartyException

Returns

mixed