Class Smarty

Description

Located in /legacy/smarty/Smarty.class.php (line 64)


	
			
Direct descendents
Class Description
view Contains methods to handle emails appropriate.
Smarty_Compiler Template compiling class
Variable Summary
Method Summary
Smarty Smarty ()
void append (array|string $tpl_var, [mixed $value = null], [ $merge = false])
void append_by_ref (string $tpl_var,  &$value, [ $merge = false], mixed $value)
void assign (array|string $tpl_var, [mixed $value = null])
void assign_by_ref (string $tpl_var,  &$value, mixed $value)
boolean clear_all_cache ([string $exp_time = null])
void clear_assign (string $tpl_var)
boolean clear_cache ([string $tpl_file = null], [string $cache_id = null], [string $compile_id = null], [string $exp_time = null])
boolean clear_compiled_tpl ([string $tpl_file = null], [string $compile_id = null], [string $exp_time = null])
void clear_config ([string $var = null])
void config_load (string $file, [string $section = null], [string $scope = 'global'])
void display (string $resource_name, [string $cache_id = null], [string $compile_id = null])
void fetch (string $resource_name, [string $cache_id = null], [string $compile_id = null], [boolean $display = false])
array &get_config_vars ([string $name = null], string $type)
object &get_registered_object (string $name)
array &get_template_vars ([string $name = null], string $type)
string|false is_cached (string $tpl_file, [string $cache_id = null], [string $compile_id = null])
void load_filter (string $type, string $name)
void register_block (string $block, string $block_impl, [ $cacheable = true], [ $cache_attrs = null])
void register_compiler_function (string $function, string $function_impl, [ $cacheable = true])
void register_function (string $function, string $function_impl, [ $cacheable = true], [ $cache_attrs = null])
void register_modifier (string $modifier, string $modifier_impl)
void register_object (string $object, object &$object_impl, [null|array $allowed = array()], [boolean $smarty_args = true], [ $block_methods = array()], null|array $block_functs)
void register_outputfilter (callback $function)
void register_postfilter (callback $function)
void register_prefilter (callback $function)
void register_resource (string $type, array $functions)
boolean template_exists (string $tpl_file)
void trigger_error (string $error_msg, [integer $error_type = E_USER_WARNING])
void unregister_block (string $block)
void unregister_compiler_function (string $function)
void unregister_function (string $function)
void unregister_modifier (string $modifier)
void unregister_object (string $object)
void unregister_outputfilter (callback $function)
void unregister_postfilter (callback $function)
void unregister_prefilter (callback $function)
void unregister_resource (string $type)
boolean _compile_resource (string $resource_name, string $compile_path)
boolean _compile_source (string $resource_name,  &$source_content,  &$compiled_content, [ $cache_include_path = null], string $source_content, string $compiled_content)
string _dequote (string $string)
mixed _eval ( $code, [ $params = null])
boolean _fetch_resource_info ( &$params, string $resource_name, string $source_content, integer $resource_timestamp, boolean $get_source, boolean $quiet)
string _get_auto_filename (string $auto_base, [string $auto_source = null], [string $auto_id = null])
string|null _get_auto_id ([string $cache_id = null], [string $compile_id = null])
string _get_compile_path (string $resource_name)
string _get_filter_name (callback $function)
string|false _get_plugin_filepath (string $type, string $name)
mixed _include ( $filename, [ $once = false], [ $params = null])
boolean _is_compiled (string $resource_name, string $compile_path)
boolean _parse_resource_name ( &$params, string $resource_base_path, string $resource_name, string $resource_type)
string _read_file (string $filename)
string _run_mod_handler (string|null $modifier_name, array|null $map_array)
array &_smarty_cache_attrs ( $cache_serial,  $count)
void _smarty_include ( $params, string $_smarty_include_tpl_file, string $_smarty_include_vars)
void _trigger_fatal_error (string $error_msg, [string $tpl_file = null], [integer $tpl_line = null], [string $file = null], [integer $line = null], [integer $error_type = E_USER_ERROR])
void _unlink (string $resource, [integer $exp_time = null])
Variables
array $autoload_filters = array() (line 339)

This indicates which filters are automatically loaded into Smarty.

Smarty Configuration Section

  • var: array of filter names
string $cache_dir = 'cache' (line 167)

The name of the directory for cache files.

Smarty Configuration Section


Redefined in descendants as:
null|string $cache_handler_func = null (line 332)

The function used for cache file handling. If not set, built-in caching is used.

Smarty Configuration Section

  • var: function name
integer $cache_lifetime = 3600 (line 178)

This is the number of seconds cached content will persist.

Smarty Configuration Section

  • 0 = always regenerate cache
  • -1 = never expires

boolean $cache_modified_check = false (line 188)

Only used when $caching is enabled. If true, then If-Modified-Since headers are respected with cached content, and appropriate HTTP headers are sent.

Smarty Configuration Section This way repeated hits to a cached page do not send the entire page to the client every time.

integer $caching = 0 (line 160)

This enables template caching.

Smarty Configuration Section

  • 0 = no caching
  • 1 = use class cache_lifetime value
  • 2 = use cache_lifetime in cache file

string $compiler_class = 'Smarty_Compiler' (line 393)

The class used for compiling templates.

string $compiler_file = 'Smarty_Compiler.class.php' (line 386)

The file that contains the compiler class. This can a full pathname, or relative to the php_include path.

boolean $compile_check = true (line 141)

This tells Smarty whether to check for recompiling or not. Recompiling does not need to happen unless a template or config file is changed.

Smarty Configuration Section Typically you enable this during development, and disable for production.

string $compile_dir = 'templates_c' (line 82)

The directory where compiled templates are located.

Smarty Configuration Section


Redefined in descendants as:
string $compile_id = null (line 292)

Set this if you want different sets of compiled files for the same templates. This is useful for things like different languages.

Smarty Configuration Section Instead of creating separate sets of templates per language, you set different compile_ids like 'en' and 'de'.

boolean $config_booleanize = true (line 355)

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.

string $config_class = 'Config_File' (line 400)

The class used to load config vars.

string $config_dir = 'configs' (line 89)

The directory where config files are located.

Smarty Configuration Section


Redefined in descendants as:
boolean $config_fix_newlines = true (line 369)

This tells whether or not automatically fix newlines in config files.

It basically converts \r (mac) or \r\n (dos) to \n

boolean $config_overwrite = true (line 348)

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.

boolean $config_read_hidden = false (line 363)

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.

boolean $debugging = false (line 105)

If debugging is enabled, a debug console window will display when the page loads (make sure your browser allows unrequested popup windows)

Smarty Configuration Section

string $debugging_ctrl = 'NONE' (line 131)

This determines if debugging is enable-able from the browser.

Smarty Configuration Section

  • NONE => no debugging control allowed
  • URL => enable debugging when SMARTY_DEBUG is found in the URL.

string $debug_tpl = '' (line 120)

This is the path to the debug console template. If not set, the default one will be used.

Smarty Configuration Section

array $default_modifiers = array() (line 311)

This is a list of the modifiers to apply to all template variables.

Smarty Configuration Section Put each modifier in a separate array element in the order you want them applied. example:

  1. array('escape:"htmlall"');

array $default_resource_type = 'file' (line 325)

This is the resource type to be used when not specified

Smarty Configuration Section at the beginning of the resource path. examples: $smarty->display('file:index.tpl'); $smarty->display('db:index.tpl'); $smarty->display('index.tpl'); // will use default resource type {include file="file:index.tpl"} {include file="db:index.tpl"} {include file="index.tpl"} {* will use default resource type *}

string $default_template_handler_func = '' (line 378)

If a template cannot be found, this PHP function will be executed.

Useful for creating templates on-the-fly or other special action.

  • var: function name
integer $error_reporting = null (line 112)

When set, smarty does uses this value as error_reporting-level.

Smarty Configuration Section

boolean $force_compile = false (line 149)

This forces templates to compile every time. Useful for development or debugging.

Smarty Configuration Section

string $left_delimiter = '{' (line 256)

The left delimiter used for the template tags.

Smarty Configuration Section

integer $php_handling = SMARTY_PHP_PASSTHRU (line 202)

This determines how Smarty handles "<?php ... ?>" tags in templates.

Smarty Configuration Section possible values:

  • SMARTY_PHP_PASSTHRU -> print tags as plain text
  • SMARTY_PHP_QUOTE -> escape tags as entities
  • SMARTY_PHP_REMOVE -> remove php tags
  • SMARTY_PHP_ALLOW -> execute php tags

array $plugins_dir = array('plugins') (line 96)

An array of directories searched for plugins.

Smarty Configuration Section

boolean $request_use_auto_globals = true (line 282)

Indicates wether $HTTP_*_VARS[] (request_use_auto_globals=false)

Smarty Configuration Section are uses as request-vars or $_*[]-vars. note: if request_use_auto_globals is true, then $request_vars_order has no effect, but the php-ini-value "gpc_order"

string $request_vars_order = 'EGPCS' (line 272)

The order in which request variables are registered, similar to variables_order in php.ini E = Environment, G = GET, P = POST, C = Cookies, S = Server

Smarty Configuration Section

string $right_delimiter = '}' (line 263)

The right delimiter used for the template tags.

Smarty Configuration Section

array $secure_dir = array() (line 221)

This is the list of template directories that are considered secure. This is used only if $security is enabled. One directory per array element. $template_dir is in this list implicitly.

Smarty Configuration Section

boolean $security = false (line 212)

This enables template security. When enabled, many things are restricted

Smarty Configuration Section in the templates that normally would go unchecked. This is useful when untrusted parties are editing templates and you want a reasonable level of security. (no direct execution of PHP in templates for example)

array $security_settings = 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,'ALLOW_SUPER_GLOBALS'=>true)
(line 229)

These are the security settings for Smarty. They are used only when $security is enabled.

Smarty Configuration Section

string $template_dir = 'templates' (line 75)

The name of the directory where templates are located.

Smarty Configuration Section

array $trusted_dir = array() (line 249)

This is an array of directories where trusted php scripts reside.

Smarty Configuration Section $security is disabled during their inclusion/execution.

boolean $use_sub_dirs = false (line 302)

This tells Smarty whether or not to use sub dirs in the cache/ and templates_c/ directories. sub directories better organized, but may not work well with PHP safe mode enabled.

Smarty Configuration Section

Methods
Constructor Smarty (line 569)

The class constructor.

Smarty Smarty ()
append (line 613)

appends values to template variables

void append (array|string $tpl_var, [mixed $value = null], [ $merge = false])
  • array|string $tpl_var: the template variable name(s)
  • mixed $value: the value to append
  • $merge
append_by_ref (line 653)

appends values to template variables by reference

void append_by_ref (string $tpl_var,  &$value, [ $merge = false], mixed $value)
  • string $tpl_var: the template variable name
  • mixed $value: the referenced value to append
  • &$value
  • $merge
assign (line 581)

assigns values to template variables

void assign (array|string $tpl_var, [mixed $value = null])
  • array|string $tpl_var: the template variable name(s)
  • mixed $value: the value to assign
assign_by_ref (line 601)

assigns values to template variables by reference

void assign_by_ref (string $tpl_var,  &$value, mixed $value)
  • string $tpl_var: the template variable name
  • mixed $value: the referenced value to assign
  • &$value
clear_all_assign (line 1004)

clear all the assigned template variables.

void clear_all_assign ()
clear_all_cache (line 968)

clear the entire contents of cache (all templates)

boolean clear_all_cache ([string $exp_time = null])
  • string $exp_time: expire time
clear_assign (line 675)

clear the given assigned template variable.

void clear_assign (string $tpl_var)
  • string $tpl_var: the template variable to clear
clear_cache (line 936)

clear cached content for the given template and cache id

boolean clear_cache ([string $tpl_file = null], [string $cache_id = null], [string $compile_id = null], [string $exp_time = null])
  • 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
clear_compiled_tpl (line 1019)

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.

boolean clear_compiled_tpl ([string $tpl_file = null], [string $compile_id = null], [string $exp_time = null])
  • string $tpl_file
  • string $compile_id
  • string $exp_time
clear_config (line 1346)

clear configuration values

void clear_config ([string $var = null])
  • string $var
config_load (line 1319)

load configuration values

void config_load (string $file, [string $section = null], [string $scope = 'global'])
  • string $file
  • string $section
  • string $scope
display (line 1104)

executes & displays the template results

void display (string $resource_name, [string $cache_id = null], [string $compile_id = null])
  • string $resource_name
  • string $cache_id
  • string $compile_id
fetch (line 1117)

executes & returns or displays the template results

void fetch (string $resource_name, [string $cache_id = null], [string $compile_id = null], [boolean $display = false])
  • string $resource_name
  • string $cache_id
  • string $compile_id
  • boolean $display
get_config_vars (line 1072)

Returns an array containing config variables

array &get_config_vars ([string $name = null], string $type)
  • string $name
  • string $type
get_registered_object (line 1331)

return a reference to a registered object

object &get_registered_object (string $name)
  • string $name
get_template_vars (line 1052)

Returns an array containing template variables

array &get_template_vars ([string $name = null], string $type)
  • string $name
  • string $type
is_cached (line 982)

test to see if valid cache exists for this template

  • return: results of _read_cache_file()
string|false is_cached (string $tpl_file, [string $cache_id = null], [string $compile_id = null])
  • string $tpl_file: name of template file
  • string $cache_id
  • string $compile_id
load_filter (line 910)

load a filter of specified type and name

void load_filter (string $type, string $name)
  • string $type: filter type
  • string $name: filter name
register_block (line 742)

Registers block function to be used in templates

void register_block (string $block, string $block_impl, [ $cacheable = true], [ $cache_attrs = null])
  • string $block: name of template block
  • string $block_impl: PHP function to register
  • $cacheable
  • $cache_attrs
register_compiler_function (line 764)

Registers compiler function

void register_compiler_function (string $function, string $function_impl, [ $cacheable = true])
  • string $function: name of template function
  • string $function_impl: name of PHP function to register
  • $cacheable
register_function (line 691)

Registers custom function to be used in templates

void register_function (string $function, string $function_impl, [ $cacheable = true], [ $cache_attrs = null])
  • string $function: the name of the template function
  • string $function_impl: the name of the PHP function to register
  • $cacheable
  • $cache_attrs
register_modifier (line 786)

Registers modifier to be used in templates

void register_modifier (string $modifier, string $modifier_impl)
  • string $modifier: name of template modifier
  • string $modifier_impl: name of PHP function to register
register_object (line 717)

Registers object to be used in templates

void register_object (string $object, object &$object_impl, [null|array $allowed = array()], [boolean $smarty_args = true], [ $block_methods = array()], null|array $block_functs)
  • 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
  • $block_methods
register_outputfilter (line 888)

Registers an output filter function to apply to a template output

void register_outputfilter (callback $function)
  • callback $function
register_postfilter (line 866)

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

void register_postfilter (callback $function)
  • callback $function
register_prefilter (line 844)

Registers a prefilter function to apply to a template before compiling

void register_prefilter (callback $function)
  • callback $function
register_resource (line 808)

Registers a resource to fetch a template

void register_resource (string $type, array $functions)
  • string $type: name of resource
  • array $functions: array of functions to handle resource
template_exists (line 1039)

Checks whether requested template exists.

boolean template_exists (string $tpl_file)
  • string $tpl_file
trigger_error (line 1091)

trigger Smarty error

void trigger_error (string $error_msg, [integer $error_type = E_USER_WARNING])
  • string $error_msg
  • integer $error_type
unregister_block (line 753)

Unregisters block function

void unregister_block (string $block)
  • string $block: name of template function
unregister_compiler_function (line 775)

Unregisters compiler function

void unregister_compiler_function (string $function)
  • string $function: name of template function
unregister_function (line 703)

Unregisters custom function

void unregister_function (string $function)
  • string $function: name of template function
unregister_modifier (line 797)

Unregisters modifier

void unregister_modifier (string $modifier)
  • string $modifier: name of template modifier
unregister_object (line 730)

Unregisters object

void unregister_object (string $object)
  • string $object: name of template object
unregister_outputfilter (line 899)

Unregisters an outputfilter function

void unregister_outputfilter (callback $function)
  • callback $function
unregister_postfilter (line 877)

Unregisters a postfilter function

void unregister_postfilter (callback $function)
  • callback $function
unregister_prefilter (line 855)

Unregisters a prefilter function

void unregister_prefilter (callback $function)
  • callback $function
unregister_resource (line 833)

Unregisters a resource

void unregister_resource (string $type)
  • string $type: name of resource
_compile_resource (line 1411)

compile the template

boolean _compile_resource (string $resource_name, string $compile_path)
  • string $resource_name
  • string $compile_path
_compile_source (line 1448)

compile the given source

boolean _compile_source (string $resource_name,  &$source_content,  &$compiled_content, [ $cache_include_path = null], string $source_content, string $compiled_content)
  • string $resource_name
  • string $source_content
  • string $compiled_content
  • &$source_content
  • &$compiled_content
  • $cache_include_path
_dequote (line 1697)

Remove starting and ending quotes from the string

string _dequote (string $string)
  • string $string
_eval (line 1932)

wrapper for eval() retaining $this

mixed _eval ( $code, [ $params = null])
  • $code
  • $params
_fetch_resource_info (line 1531)

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

boolean _fetch_resource_info ( &$params, string $resource_name, string $source_content, integer $resource_timestamp, boolean $get_source, boolean $quiet)
  • string $resource_name
  • string $source_content
  • integer $resource_timestamp
  • boolean $get_source
  • boolean $quiet
  • &$params
_get_auto_filename (line 1737)

get a concrete filename for automagically created content

  • staticvar: string|null 1:
  • staticvar: string|null $_cache_info:
string _get_auto_filename (string $auto_base, [string $auto_source = null], [string $auto_id = null])
  • string $auto_base
  • string $auto_source
  • string $auto_id
_get_auto_id (line 1787)

returns an auto_id for auto-file-functions

string|null _get_auto_id ([string $cache_id = null], [string $compile_id = null])
  • string $cache_id
  • string $compile_id
_get_compile_path (line 1511)

Get the compile path for this resource

string _get_compile_path (string $resource_name)
  • string $resource_name
_get_filter_name (line 1943)

Extracts the filter name from the given callback

string _get_filter_name (callback $function)
  • callback $function
_get_plugin_filepath (line 1364)

get filepath of requested plugin

string|false _get_plugin_filepath (string $type, string $name)
  • string $type
  • string $name
_include (line 1918)

wrapper for include() retaining $this

mixed _include ( $filename, [ $once = false], [ $params = null])
  • $filename
  • $once
  • $params
_is_compiled (line 1378)

test if resource needs compiling

boolean _is_compiled (string $resource_name, string $compile_path)
  • string $resource_name
  • string $compile_path
_parse_resource_name (line 1615)

parse out the type and name from the resource

boolean _parse_resource_name ( &$params, string $resource_base_path, string $resource_name, string $resource_type)
  • string $resource_base_path
  • string $resource_name
  • string $resource_type
  • &$params
_process_compiled_include_callback (line 1826)

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

string _process_compiled_include_callback ( $match)
  • $match
_read_file (line 1713)

read in a file

string _read_file (string $filename)
  • string $filename
_run_mod_handler (line 1676)

Handle modifiers

  • return: result of modifiers
string _run_mod_handler (string|null $modifier_name, array|null $map_array)
  • string|null $modifier_name
  • array|null $map_array
_smarty_cache_attrs (line 1895)

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

not cacheable

array &_smarty_cache_attrs ( $cache_serial,  $count)
  • $cache_serial
  • $count
_smarty_include (line 1845)

called for included templates

void _smarty_include ( $params, string $_smarty_include_tpl_file, string $_smarty_include_vars)
  • string $_smarty_include_tpl_file
  • string $_smarty_include_vars
  • $params
_trigger_fatal_error (line 1806)

trigger Smarty plugin error

void _trigger_fatal_error (string $error_msg, [string $tpl_file = null], [integer $tpl_line = null], [string $file = null], [integer $line = null], [integer $error_type = E_USER_ERROR])
  • string $error_msg
  • string $tpl_file
  • integer $tpl_line
  • string $file
  • integer $line
  • integer $error_type
_unlink (line 1769)

unlink a file, possibly using expiration time

void _unlink (string $resource, [integer $exp_time = null])
  • string $resource
  • integer $exp_time

Documentation generated on Tue, 09 Aug 2011 09:05:34 +0200 by phpDocumentor 1.4.3