Smarty Class Reference

Inheritance diagram for Smarty:

CmsSmarty Smarty_Compiler CMS_Compiler List of all members.

Public Member Functions

 Smarty ()
 assign ($tpl_var, $value=null)
 assign_by_ref ($tpl_var, &$value)
 append ($tpl_var, $value=null, $merge=false)
 append_by_ref ($tpl_var, &$value, $merge=false)
 clear_assign ($tpl_var)
 register_function ($function, $function_impl, $cacheable=true, $cache_attrs=null)
 unregister_function ($function)
 register_object ($object, &$object_impl, $allowed=array(), $smarty_args=true, $block_methods=array())
 unregister_object ($object)
 register_block ($block, $block_impl, $cacheable=true, $cache_attrs=null)
 unregister_block ($block)
 register_compiler_function ($function, $function_impl, $cacheable=true)
 unregister_compiler_function ($function)
 register_modifier ($modifier, $modifier_impl)
 unregister_modifier ($modifier)
 register_resource ($type, $functions)
 unregister_resource ($type)
 register_prefilter ($function)
 unregister_prefilter ($function)
 register_postfilter ($function)
 unregister_postfilter ($function)
 register_outputfilter ($function)
 unregister_outputfilter ($function)
 load_filter ($type, $name)
 clear_cache ($tpl_file=null, $cache_id=null, $compile_id=null, $exp_time=null)
 clear_all_cache ($exp_time=null)
 is_cached ($tpl_file, $cache_id=null, $compile_id=null)
 clear_all_assign ()
 clear_compiled_tpl ($tpl_file=null, $compile_id=null, $exp_time=null)
 template_exists ($tpl_file)
get_template_vars ($name=null)
get_config_vars ($name=null)
 trigger_error ($error_msg, $error_type=E_USER_WARNING)
 display ($resource_name, $cache_id=null, $compile_id=null)
 fetch ($resource_name, $cache_id=null, $compile_id=null, $display=false)
 config_load ($file, $section=null, $scope= 'global')
get_registered_object ($name)
 clear_config ($var=null)
 _get_plugin_filepath ($type, $name)
 _is_compiled ($resource_name, $compile_path)
 _compile_resource ($resource_name, $compile_path)
 _compile_source ($resource_name, &$source_content, &$compiled_content, $cache_include_path=null)
 _get_compile_path ($resource_name)
 _fetch_resource_info (&$params)
 _parse_resource_name (&$params)
 _run_mod_handler ()
 _dequote ($string)
 _read_file ($filename)
 _get_auto_filename ($auto_base, $auto_source=null, $auto_id=null)
 _unlink ($resource, $exp_time=null)
 _get_auto_id ($cache_id=null, $compile_id=null)
 _trigger_fatal_error ($error_msg, $tpl_file=null, $tpl_line=null, $file=null, $line=null, $error_type=E_USER_ERROR)
 _process_compiled_include_callback ($match)
 _smarty_include ($params)
_smarty_cache_attrs ($cache_serial, $count)
 _include ($filename, $once=false, $params=null)
 _eval ($code, $params=null)

Public Attributes

 $template_dir = 'templates'
 $compile_dir = 'templates_c'
 $config_dir = 'configs'
 $plugins_dir = array('plugins')
 $debugging = false
 $error_reporting = null
 $debug_tpl = ''
 $debugging_ctrl = 'NONE'
 $compile_check = true
 $force_compile = false
 $caching = 0
 $cache_dir = 'cache'
 $cache_lifetime = 3600
 $cache_modified_check = false
 $php_handling = SMARTY_PHP_PASSTHRU
 $security = false
 $secure_dir = array()
 $security_settings
 $trusted_dir = array()
 $left_delimiter = '{'
 $right_delimiter = '}'
 $request_vars_order = 'EGPCS'
 $request_use_auto_globals = true
 $compile_id = null
 $use_sub_dirs = false
 $default_modifiers = array()
 $default_resource_type = 'file'
 $cache_handler_func = null
 $autoload_filters = array()
 $config_overwrite = true
 $config_booleanize = true
 $config_read_hidden = false
 $config_fix_newlines = true
 $default_template_handler_func = ''
 $compiler_file = 'Smarty_Compiler.class.php'
 $compiler_class = 'Smarty_Compiler'
 $config_class = 'Config_File'
 $_tpl_vars = array()
 $_smarty_vars = null
 $_sections = array()
 $_foreach = array()
 $_tag_stack = array()
 $_conf_obj = null
 $_config = array(array('vars' => array(), 'files' => array()))
 $_smarty_md5 = 'f8d698aea36fcbead2b9d5359ffca76f'
 $_version = '2.6.18'
 $_inclusion_depth = 0
 $_compile_id = null
 $_smarty_debug_id = 'SMARTY_DEBUG'
 $_smarty_debug_info = array()
 $_cache_info = array()
 $_file_perms = 0644
 $_dir_perms = 0771
 $_reg_objects = array()
 $_plugins
 $_cache_serials = array()
 $_cache_include = null
 $_cache_including = false

Detailed Description

Definition at line 64 of file Smarty.class.php.


Member Function Documentation

Smarty::Smarty (  ) 

The class constructor.

Definition at line 568 of file Smarty.class.php.

References assign().

Smarty::assign ( tpl_var,
value = null 
)

assigns values to template variables

Parameters:
array|string $tpl_var the template variable name(s)
mixed $value the value to assign

Definition at line 580 of file Smarty.class.php.

Referenced by CmsSmarty::__construct(), Smarty_Compiler::_compile_capture_tag(), Smarty_Compiler::_compile_include_php_tag(), Smarty_Compiler::_compile_include_tag(), Smarty_Compiler::_compile_registered_object_tag(), and Smarty().

Smarty::assign_by_ref ( tpl_var,
&$  value 
)

assigns values to template variables by reference

Parameters:
string $tpl_var the template variable name
mixed $value the referenced value to assign

Definition at line 600 of file Smarty.class.php.

Smarty::append ( tpl_var,
value = null,
merge = false 
)

appends values to template variables

Parameters:
array|string $tpl_var the template variable name(s)
mixed $value the value to append

Definition at line 612 of file Smarty.class.php.

Smarty::append_by_ref ( tpl_var,
&$  value,
merge = false 
)

appends values to template variables by reference

Parameters:
string $tpl_var the template variable name
mixed $value the referenced value to append

Definition at line 652 of file Smarty.class.php.

Smarty::clear_assign ( tpl_var  ) 

clear the given assigned template variable.

Parameters:
string $tpl_var the template variable to clear

Definition at line 674 of file Smarty.class.php.

Smarty::register_function ( function,
function_impl,
cacheable = true,
cache_attrs = null 
)

Registers custom function to be used in templates

Parameters:
string $function the name of the template function
string $function_impl the name of the PHP function to register

Definition at line 690 of file Smarty.class.php.

Referenced by CmsSmarty::load_plugins(), and CmsSmarty::search_plugins().

Smarty::unregister_function ( function  ) 

Unregisters custom function

Parameters:
string $function name of template function

Definition at line 702 of file Smarty.class.php.

Smarty::register_object ( object,
&$  object_impl,
allowed = array(),
smarty_args = true,
block_methods = array() 
)

Registers object to be used in templates

Parameters:
string $object name of template object
object &$object_impl the referenced PHP object to register
null|array $allowed list of allowed methods (empty = all)
boolean $smarty_args smarty argument format, else traditional
null|array $block_functs list of methods that are block format

Definition at line 716 of file Smarty.class.php.

Smarty::unregister_object ( object  ) 

Unregisters object

Parameters:
string $object name of template object

Definition at line 729 of file Smarty.class.php.

Smarty::register_block ( block,
block_impl,
cacheable = true,
cache_attrs = null 
)

Registers block function to be used in templates

Parameters:
string $block name of template block
string $block_impl PHP function to register

Definition at line 741 of file Smarty.class.php.

Referenced by CmsSmarty::search_plugins().

Smarty::unregister_block ( block  ) 

Unregisters block function

Parameters:
string $block name of template function

Definition at line 752 of file Smarty.class.php.

Smarty::register_compiler_function ( function,
function_impl,
cacheable = true 
)

Registers compiler function

Parameters:
string $function name of template function
string $function_impl name of PHP function to register

Definition at line 763 of file Smarty.class.php.

Referenced by CmsSmarty::search_plugins().

Smarty::unregister_compiler_function ( function  ) 

Unregisters compiler function

Parameters:
string $function name of template function

Definition at line 774 of file Smarty.class.php.

Smarty::register_modifier ( modifier,
modifier_impl 
)

Registers modifier to be used in templates

Parameters:
string $modifier name of template modifier
string $modifier_impl name of PHP function to register

Definition at line 785 of file Smarty.class.php.

Referenced by CmsSmarty::search_plugins().

Smarty::unregister_modifier ( modifier  ) 

Unregisters modifier

Parameters:
string $modifier name of template modifier

Definition at line 796 of file Smarty.class.php.

Smarty::register_resource ( type,
functions 
)

Registers a resource to fetch a template

Parameters:
string $type name of resource
array $functions array of functions to handle resource

Definition at line 807 of file Smarty.class.php.

References trigger_error().

Referenced by CmsSmarty::__construct().

Smarty::unregister_resource ( type  ) 

Unregisters a resource

Parameters:
string $type name of resource

Definition at line 832 of file Smarty.class.php.

Smarty::register_prefilter ( function  ) 

Registers a prefilter function to apply to a template before compiling

Parameters:
string $function name of PHP function to register

Definition at line 843 of file Smarty.class.php.

Referenced by CmsSmarty::search_plugins().

Smarty::unregister_prefilter ( function  ) 

Unregisters a prefilter function

Parameters:
string $function name of PHP function

Definition at line 855 of file Smarty.class.php.

Smarty::register_postfilter ( function  ) 

Registers a postfilter function to apply to a compiled template after compilation

Parameters:
string $function name of PHP function to register

Definition at line 866 of file Smarty.class.php.

Referenced by CmsSmarty::search_plugins().

Smarty::unregister_postfilter ( function  ) 

Unregisters a postfilter function

Parameters:
string $function name of PHP function

Definition at line 878 of file Smarty.class.php.

Smarty::register_outputfilter ( function  ) 

Registers an output filter function to apply to a template output

Parameters:
string $function name of PHP function

Definition at line 889 of file Smarty.class.php.

Referenced by CmsSmarty::search_plugins().

Smarty::unregister_outputfilter ( function  ) 

Unregisters an outputfilter function

Parameters:
string $function name of PHP function

Definition at line 901 of file Smarty.class.php.

Smarty::load_filter ( type,
name 
)

load a filter of specified type and name

Parameters:
string $type filter type
string $name filter name

Definition at line 912 of file Smarty.class.php.

Referenced by fetch().

Smarty::clear_cache ( tpl_file = null,
cache_id = null,
compile_id = null,
exp_time = null 
)

clear cached content for the given template and cache id

Parameters:
string $tpl_file name of template file
string $cache_id name of cache_id
string $compile_id name of compile_id
string $exp_time expiration time
Returns:
boolean

Definition at line 938 of file Smarty.class.php.

References $compile_id, and _get_auto_id().

Referenced by clear_all_cache().

Smarty::clear_all_cache ( exp_time = null  ) 

clear the entire contents of cache (all templates)

Parameters:
string $exp_time expire time
Returns:
boolean results of smarty_core_rm_auto()

Definition at line 970 of file Smarty.class.php.

References clear_cache().

Smarty::is_cached ( tpl_file,
cache_id = null,
compile_id = null 
)

test to see if valid cache exists for this template

Parameters:
string $tpl_file name of template file
string $cache_id
string $compile_id
Returns:
string|false results of _read_cache_file()

Definition at line 984 of file Smarty.class.php.

References $compile_id.

Smarty::clear_all_assign (  ) 

clear all the assigned template variables.

Definition at line 1006 of file Smarty.class.php.

Smarty::clear_compiled_tpl ( tpl_file = null,
compile_id = null,
exp_time = null 
)

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.

Parameters:
string $tpl_file
string $compile_id
string $exp_time
Returns:
boolean results of smarty_core_rm_auto()

Definition at line 1021 of file Smarty.class.php.

References $compile_id.

Smarty::template_exists ( tpl_file  ) 

Checks whether requested template exists.

Parameters:
string $tpl_file
Returns:
boolean

Definition at line 1041 of file Smarty.class.php.

References _fetch_resource_info().

& Smarty::get_template_vars ( name = null  ) 

Returns an array containing template variables

Parameters:
string $name
string $type
Returns:
array

Definition at line 1054 of file Smarty.class.php.

& Smarty::get_config_vars ( name = null  ) 

Returns an array containing config variables

Parameters:
string $name
string $type
Returns:
array

Definition at line 1074 of file Smarty.class.php.

Smarty::trigger_error ( error_msg,
error_type = E_USER_WARNING 
)

trigger Smarty error

Parameters:
string $error_msg
integer $error_type

Reimplemented in CmsSmarty, and CMS_Compiler.

Definition at line 1093 of file Smarty.class.php.

Referenced by _fetch_resource_info(), Smarty_Compiler::_parse_var(), _trigger_fatal_error(), and register_resource().

Smarty::display ( resource_name,
cache_id = null,
compile_id = null 
)

executes & displays the template results

Parameters:
string $resource_name
string $cache_id
string $compile_id

Definition at line 1106 of file Smarty.class.php.

References $compile_id, and fetch().

Smarty::fetch ( resource_name,
cache_id = null,
compile_id = null,
display = false 
)

executes & returns or displays the template results

Parameters:
string $resource_name
string $cache_id
string $compile_id
boolean $display

Definition at line 1119 of file Smarty.class.php.

References $_cache_including, $_cache_info, $compile_id, _compile_resource(), _get_compile_path(), _is_compiled(), and load_filter().

Referenced by display().

Smarty::config_load ( file,
section = null,
scope = 'global' 
)

load configuration values

Parameters:
string $file
string $section
string $scope

Definition at line 1321 of file Smarty.class.php.

References _get_plugin_filepath().

& Smarty::get_registered_object ( name  ) 

return a reference to a registered object

Parameters:
string $name
Returns:
object

Definition at line 1333 of file Smarty.class.php.

References _trigger_fatal_error().

Smarty::clear_config ( var = null  ) 

clear configuration values

Parameters:
string $var

Definition at line 1348 of file Smarty.class.php.

Smarty::_get_plugin_filepath ( type,
name 
)

get filepath of requested plugin

Parameters:
string $type
string $name
Returns:
string|false

Definition at line 1366 of file Smarty.class.php.

Referenced by Smarty_Compiler::_compile_block_tag(), Smarty_Compiler::_compile_compiler_tag(), Smarty_Compiler::_compile_custom_tag(), CMS_Compiler::_compile_custom_tag(), and config_load().

Smarty::_is_compiled ( resource_name,
compile_path 
)

test if resource needs compiling

Parameters:
string $resource_name
string $compile_path
Returns:
boolean

Definition at line 1380 of file Smarty.class.php.

References _fetch_resource_info().

Referenced by _smarty_include(), and fetch().

Smarty::_compile_resource ( resource_name,
compile_path 
)

compile the template

Parameters:
string $resource_name
string $compile_path
Returns:
boolean

Definition at line 1413 of file Smarty.class.php.

References $_cache_include, _compile_source(), and _fetch_resource_info().

Referenced by _smarty_include(), and fetch().

Smarty::_compile_source ( resource_name,
&$  source_content,
&$  compiled_content,
cache_include_path = null 
)

compile the given source

Parameters:
string $resource_name
string $source_content
string $compiled_content
Returns:
boolean

Definition at line 1449 of file Smarty.class.php.

Referenced by _compile_resource().

Smarty::_get_compile_path ( resource_name  ) 

Get the compile path for this resource

Parameters:
string $resource_name
Returns:
string results of _get_auto_filename()

Definition at line 1512 of file Smarty.class.php.

References _get_auto_filename().

Referenced by _smarty_include(), and fetch().

Smarty::_fetch_resource_info ( &$  params  ) 

fetch the template info. Gets timestamp, and source if get_source is true

sets $source_content to the source of the template, and $resource_timestamp to its time stamp

Parameters:
string $resource_name
string $source_content
integer $resource_timestamp
boolean $get_source
boolean $quiet
Returns:
boolean

Definition at line 1532 of file Smarty.class.php.

References _parse_resource_name(), _read_file(), and trigger_error().

Referenced by _compile_resource(), _is_compiled(), and template_exists().

Smarty::_parse_resource_name ( &$  params  ) 

parse out the type and name from the resource

Parameters:
string $resource_base_path
string $resource_name
string $resource_type
string $resource_name
Returns:
boolean

Definition at line 1616 of file Smarty.class.php.

Referenced by _fetch_resource_info().

Smarty::_run_mod_handler (  ) 

Handle modifiers

Parameters:
string|null $modifier_name
array|null $map_array
Returns:
string result of modifiers

Definition at line 1677 of file Smarty.class.php.

Smarty::_dequote ( string  ) 

Remove starting and ending quotes from the string

Parameters:
string $string
Returns:
string

Definition at line 1698 of file Smarty.class.php.

Referenced by Smarty_Compiler::_compile_foreach_start(), Smarty_Compiler::_compile_include_php_tag(), Smarty_Compiler::_compile_insert_tag(), and Smarty_Compiler::_compile_registered_object_tag().

Smarty::_read_file ( filename  ) 

read in a file

Parameters:
string $filename
Returns:
string

Definition at line 1714 of file Smarty.class.php.

Referenced by _fetch_resource_info().

Smarty::_get_auto_filename ( auto_base,
auto_source = null,
auto_id = null 
)

get a concrete filename for automagically created content

Parameters:
string $auto_base
string $auto_source
string $auto_id
Returns:
string string|null string|null

Definition at line 1738 of file Smarty.class.php.

Referenced by _get_compile_path().

Smarty::_unlink ( resource,
exp_time = null 
)

unlink a file, possibly using expiration time

Parameters:
string $resource
integer $exp_time

Definition at line 1770 of file Smarty.class.php.

Smarty::_get_auto_id ( cache_id = null,
compile_id = null 
)

returns an auto_id for auto-file-functions

Parameters:
string $cache_id
string $compile_id
Returns:
string|null

Definition at line 1788 of file Smarty.class.php.

References $compile_id.

Referenced by clear_cache().

Smarty::_trigger_fatal_error ( error_msg,
tpl_file = null,
tpl_line = null,
file = null,
line = null,
error_type = E_USER_ERROR 
)

trigger Smarty plugin error

Parameters:
string $error_msg
string $tpl_file
integer $tpl_line
string $file
integer $line
integer $error_type

Definition at line 1807 of file Smarty.class.php.

References trigger_error().

Referenced by Smarty_Compiler::_compile_file(), Smarty_Compiler::_compile_registered_object_tag(), CMS_Compiler::_syntax_error(), and get_registered_object().

Smarty::_process_compiled_include_callback ( match  ) 

callback function for preg_replace, to call a non-cacheable block

Returns:
string

Definition at line 1827 of file Smarty.class.php.

Smarty::_smarty_include ( params  ) 

called for included templates

Parameters:
string $_smarty_include_tpl_file
string $_smarty_include_vars

Definition at line 1846 of file Smarty.class.php.

References _compile_resource(), _get_compile_path(), and _is_compiled().

& Smarty::_smarty_cache_attrs ( cache_serial,
count 
)

get or set an array of cached attributes for function that is not cacheable

Returns:
array

Definition at line 1896 of file Smarty.class.php.

Smarty::_include ( filename,
once = false,
params = null 
)

wrapper for include() retaining $this

Returns:
mixed

Reimplemented in CmsSmarty.

Definition at line 1919 of file Smarty.class.php.

Smarty::_eval ( code,
params = null 
)

wrapper for eval() retaining $this

Returns:
mixed

Definition at line 1933 of file Smarty.class.php.


Member Data Documentation

Smarty::$security_settings

Initial value:

 array(
                                    'PHP_HANDLING'    => false,
                                    'IF_FUNCS'        => array('array', 'list',
                                                               'isset', 'empty',
                                                               'count', 'sizeof',
                                                               'in_array', 'is_array',
                                                               'true', 'false', 'null'),
                                    'INCLUDE_ANY'     => false,
                                    'PHP_TAGS'        => false,
                                    'MODIFIER_FUNCS'  => array('count'),
                                    'ALLOW_CONSTANTS'  => false
                                   )

Definition at line 229 of file Smarty.class.php.

Smarty::$config_overwrite = true

This tells if config file vars of the same name overwrite each other or not. if disabled, same name variables are accumulated in an array.

Definition at line 347 of file Smarty.class.php.

Smarty::$config_booleanize = true

This tells whether or not to automatically booleanize config file variables. If enabled, then the strings "on", "true", and "yes" are treated as boolean true, and "off", "false" and "no" are treated as boolean false.

Definition at line 354 of file Smarty.class.php.

Smarty::$config_read_hidden = false

This tells whether hidden sections [.foobar] are readable from the tempalates or not. Normally you would never allow this since that is the point behind hidden sections: the application can access them, but the templates cannot.

Definition at line 362 of file Smarty.class.php.

Smarty::$config_fix_newlines = true

This tells whether or not automatically fix newlines in config files. It basically converts (mac) or
(dos) to

Definition at line 368 of file Smarty.class.php.

Smarty::$_plugins

Initial value:

 array(
                                       'modifier'      => array(),
                                       'function'      => array(),
                                       'block'         => array(),
                                       'compiler'      => array(),
                                       'prefilter'     => array(),
                                       'postfilter'    => array(),
                                       'outputfilter'  => array(),
                                       'resource'      => array(),
                                       'insert'        => array())

Definition at line 530 of file Smarty.class.php.


The documentation for this class was generated from the following file:
Generated on Sun Dec 14 14:20:27 2008 for CMSMS by  doxygen 1.5.1