Smarty


Smarty.Smarty
/Smarty.class.php at line 64

Class Smarty

Smarty

public class Smarty


Field Summary
array array of filter names

$autoload_filters

This indicates which filters are automatically loaded into Smarty.

string

$cache_dir

The name of the directory for cache files.

null|string function name

$cache_handler_func

The function used for cache file handling.

integer

$cache_lifetime

This is the number of seconds cached content will persist.

boolean

$cache_modified_check

Only used when $caching is enabled.

integer

$caching

This enables template caching.

boolean

$compile_check

This tells Smarty whether to check for recompiling or not.

string

$compile_dir

The directory where compiled templates are located.

string

$compile_id

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

string

$compiler_class

The class used for compiling templates.

string

$compiler_file

The file that contains the compiler class.

mixed

$config_booleanize

This tells whether or not to automatically booleanize config file variables.

string

$config_class

The class used to load config vars.

string

$config_dir

The directory where config files are located.

mixed

$config_fix_newlines

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

mixed

$config_overwrite

This tells if config file vars of the same name overwrite each other or not.

mixed

$config_read_hidden

This tells whether hidden sections [.foobar] are readable from the tempalates or not.

string

$debug_tpl

This is the path to the debug console template.

boolean

$debugging

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

string

$debugging_ctrl

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

array

$default_modifiers

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

array

$default_resource_type

This is the resource type to be used when not specified at the beginning of the resource path.

string function name

$default_template_handler_func

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

boolean

$error_reporting

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

boolean

$force_compile

This forces templates to compile every time.

string

$left_delimiter

The left delimiter used for the template tags.

integer

$php_handling

This determines how Smarty handles "

array

$plugins_dir

An array of directories searched for plugins.

boolean

$request_use_auto_globals

Indicates wether $HTTP_*_VARS[] (request_use_auto_globals=false) are uses as request-vars or $_*[]-vars.

string

$request_vars_order

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

string

$right_delimiter

The right delimiter used for the template tags.

array

$secure_dir

This is the list of template directories that are considered secure.

boolean

$security

This enables template security.

array

$security_settings

These are the security settings for Smarty.

string

$template_dir

The name of the directory where templates are located.

array

$trusted_dir

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

boolean

$use_sub_dirs

This tells Smarty whether or not to use sub dirs in the cache/ and templates_c/ directories.

Constructor Summary

Smarty()

The class constructor.

Method Summary
void

append(array|string tpl_var, mixed value, mixed merge)

appends values to template variables

void

append_by_ref(string tpl_var, mixed value, mixed merge)

appends values to template variables by reference

void

assign(array|string tpl_var, mixed value)

assigns values to template variables

void

assign_by_ref(string tpl_var, mixed value)

assigns values to template variables by reference

void

clear_all_assign()

clear all the assigned template variables.

boolean

clear_all_cache(string exp_time)

clear the entire contents of cache (all templates)

void

clear_assign(string tpl_var)

clear the given assigned template variable.

boolean

clear_cache(string tpl_file, string cache_id, string compile_id, string exp_time)

clear cached content for the given template and cache id

boolean

clear_compiled_tpl(string tpl_file, string compile_id, string exp_time)

clears compiled version of specified template resource, or all compiled template files if one is not specified.

void

clear_config(string var)

clear configuration values

void

config_load(string file, string section, string scope)

load configuration values

void

display(string resource_name, string cache_id, string compile_id)

executes & displays the template results

void

fetch(string resource_name, string cache_id, string compile_id, boolean display)

executes & returns or displays the template results

array

get_config_vars(string name, string type)

Returns an array containing config variables

object

get_registered_object(string name)

return a reference to a registered object

array

get_template_vars(string name, string type)

Returns an array containing template variables

string|false

is_cached(string tpl_file, string cache_id, string compile_id)

test to see if valid cache exists for this template

void

load_filter(string type, string name)

load a filter of specified type and name

void

register_block(string block, string block_impl, mixed cacheable, mixed cache_attrs)

Registers block function to be used in templates

void

register_compiler_function(string function, string function_impl, mixed cacheable)

Registers compiler function

void

register_function(string function, string function_impl, mixed cacheable, mixed cache_attrs)

Registers custom function to be used in templates

void

register_modifier(string modifier, string modifier_impl)

Registers modifier to be used in templates

void

register_object(string object, mixed object_impl, null|array allowed, mixed block_methods, object &$object_impl, boolean smarty_args, null|array block_functs)

Registers object to be used in templates

void

register_outputfilter(string function)

Registers an output filter function to apply to a template output

void

register_postfilter(string function)

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

void

register_prefilter(string function)

Registers a prefilter function to apply to a template before compiling

void

register_resource(string type, array functions)

Registers a resource to fetch a template

boolean

template_exists(string tpl_file)

Checks whether requested template exists.

void

trigger_error(string error_msg, integer error_type)

trigger Smarty error

void

unregister_block(string block)

Unregisters block function

void

unregister_compiler_function(string function)

Unregisters compiler function

void

unregister_function(string function)

Unregisters custom function

void

unregister_modifier(string modifier)

Unregisters modifier

void

unregister_object(string object)

Unregisters object

void

unregister_outputfilter(string function)

Unregisters an outputfilter function

void

unregister_postfilter(string function)

Unregisters a postfilter function

void

unregister_prefilter(string function)

Unregisters a prefilter function

void

unregister_resource(string type)

Unregisters a resource

Field Detail

/Smarty.class.php at line 338

autoload_filters

public array array of filter names $autoload_filters = array()

This indicates which filters are automatically loaded into Smarty.


/Smarty.class.php at line 167

cache_dir

public string $cache_dir = 'cache'

The name of the directory for cache files.


/Smarty.class.php at line 331

cache_handler_func

public null|string function name $cache_handler_func = null

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


/Smarty.class.php at line 178

cache_lifetime

public integer $cache_lifetime = 3600

This is the number of seconds cached content will persist.


/Smarty.class.php at line 188

cache_modified_check

public boolean $cache_modified_check = false

Only used when $caching is enabled. If true, then If-Modified-Since headers are respected with cached content, and appropriate HTTP headers are sent. This way repeated hits to a cached page do not send the entire page to the client every time.


/Smarty.class.php at line 160

caching

public integer $caching

This enables template caching.


/Smarty.class.php at line 141

compile_check

public boolean $compile_check = true

This tells Smarty whether to check for recompiling or not. Recompiling does not need to happen unless a template or config file is changed. Typically you enable this during development, and disable for production.


/Smarty.class.php at line 82

compile_dir

public string $compile_dir = 'templates_c'

The directory where compiled templates are located.


/Smarty.class.php at line 291

compile_id

public string $compile_id = null

Set this if you want different sets of compiled files for the same templates. This is useful for things like different languages. Instead of creating separate sets of templates per language, you set different compile_ids like 'en' and 'de'.


/Smarty.class.php at line 392

compiler_class

public string $compiler_class = 'Smarty_Compiler'

The class used for compiling templates.


/Smarty.class.php at line 385

compiler_file

public string $compiler_file = 'Smarty_Compiler.class.php'

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


/Smarty.class.php at line 354

config_booleanize

public mixed $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.


/Smarty.class.php at line 399

config_class

public string $config_class = 'Config_File'

The class used to load config vars.


/Smarty.class.php at line 89

config_dir

public string $config_dir = 'configs'

The directory where config files are located.


/Smarty.class.php at line 368

config_fix_newlines

public mixed $config_fix_newlines = true

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


/Smarty.class.php at line 347

config_overwrite

public mixed $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.


/Smarty.class.php at line 362

config_read_hidden

public mixed $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.


/Smarty.class.php at line 120

debug_tpl

public string $debug_tpl = ''

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


/Smarty.class.php at line 105

debugging

public boolean $debugging = false

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


/Smarty.class.php at line 131

debugging_ctrl

public string $debugging_ctrl = 'NONE'

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

See Also:
http://www.foo.dom/index.php?SMARTY_DEBUG

/Smarty.class.php at line 310

default_modifiers

public array $default_modifiers = array()

This is a list of the modifiers to apply to all template variables. Put each modifier in a separate array element in the order you want them applied. example: array('escape:"htmlall"');


/Smarty.class.php at line 324

default_resource_type

public array $default_resource_type = 'file'

This is the resource type to be used when not specified 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 *}


/Smarty.class.php at line 377

default_template_handler_func

public string function name $default_template_handler_func = ''

If a template cannot be found, this PHP function will be executed. Useful for creating templates on-the-fly or other special action.


/Smarty.class.php at line 112

error_reporting

public boolean $error_reporting = null

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


/Smarty.class.php at line 149

force_compile

public boolean $force_compile = false

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


/Smarty.class.php at line 255

left_delimiter

public string $left_delimiter = '{'

The left delimiter used for the template tags.


/Smarty.class.php at line 202

php_handling

public integer $php_handling = SMARTY_PHP_PASSTHRU

This determines how Smarty handles "" tags in templates. possible values:


/Smarty.class.php at line 96

plugins_dir

public array $plugins_dir = array('plugins')

An array of directories searched for plugins.


/Smarty.class.php at line 281

request_use_auto_globals

public boolean $request_use_auto_globals = true

Indicates wether $HTTP_*_VARS[] (request_use_auto_globals=false) 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"


/Smarty.class.php at line 271

request_vars_order

public string $request_vars_order = 'EGPCS'

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.class.php at line 262

right_delimiter

public string $right_delimiter = '}'

The right delimiter used for the template tags.


/Smarty.class.php at line 221

secure_dir

public array $secure_dir = array()

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.class.php at line 212

security

public boolean $security = false

This enables template security. When enabled, many things are restricted 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)


/Smarty.class.php at line 229

security_settings

public array $security_settings = array(...)

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

$security

is enabled.


/Smarty.class.php at line 75

template_dir

public string $template_dir = 'templates'

The name of the directory where templates are located.


/Smarty.class.php at line 248

trusted_dir

public array $trusted_dir = array()

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

$security

is disabled during their inclusion/execution.


/Smarty.class.php at line 301

use_sub_dirs

public boolean $use_sub_dirs = false

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.


Constructor Detail

/Smarty.class.php at line 568

Smarty

public Smarty()

The class constructor.


Method Detail

/Smarty.class.php at line 612

append

public void append(array|string tpl_var, mixed value, mixed merge)

appends values to template variables

Parameters:
tpl_var - the template variable name(s)
value - the value to append

/Smarty.class.php at line 652

append_by_ref

public void append_by_ref(string tpl_var, mixed value, mixed merge)

appends values to template variables by reference

Parameters:
tpl_var - the template variable name
value - the referenced value to append

/Smarty.class.php at line 580

assign

public void assign(array|string tpl_var, mixed value)

assigns values to template variables

Parameters:
tpl_var - the template variable name(s)
value - the value to assign

/Smarty.class.php at line 600

assign_by_ref

public void assign_by_ref(string tpl_var, mixed value)

assigns values to template variables by reference

Parameters:
tpl_var - the template variable name
value - the referenced value to assign

/Smarty.class.php at line 1006

clear_all_assign

public void clear_all_assign()

clear all the assigned template variables.


/Smarty.class.php at line 970

clear_all_cache

public boolean clear_all_cache(string exp_time)

clear the entire contents of cache (all templates)

Parameters:
exp_time - expire time
Returns:
results of {@link smarty_core_rm_auto()}

/Smarty.class.php at line 674

clear_assign

public void clear_assign(string tpl_var)

clear the given assigned template variable.

Parameters:
tpl_var - the template variable to clear

/Smarty.class.php at line 938

clear_cache

public boolean clear_cache(string tpl_file, string cache_id, string compile_id, string exp_time)

clear cached content for the given template and cache id

Parameters:
tpl_file - name of template file
cache_id - name of cache_id
compile_id - name of compile_id
exp_time - expiration time

/Smarty.class.php at line 1021

clear_compiled_tpl

public boolean clear_compiled_tpl(string tpl_file, string compile_id, string exp_time)

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.

Returns:
results of {@link smarty_core_rm_auto()}

/Smarty.class.php at line 1348

clear_config

public void clear_config(string var)

clear configuration values


/Smarty.class.php at line 1321

config_load

public void config_load(string file, string section, string scope)

load configuration values


/Smarty.class.php at line 1106

display

public void display(string resource_name, string cache_id, string compile_id)

executes & displays the template results


/Smarty.class.php at line 1119

fetch

public void fetch(string resource_name, string cache_id, string compile_id, boolean display)

executes & returns or displays the template results


/Smarty.class.php at line 1074

get_config_vars

public array get_config_vars(string name, string type)

Returns an array containing config variables


/Smarty.class.php at line 1333

get_registered_object

public object get_registered_object(string name)

return a reference to a registered object


/Smarty.class.php at line 1054

get_template_vars

public array get_template_vars(string name, string type)

Returns an array containing template variables


/Smarty.class.php at line 984

is_cached

public string|false is_cached(string tpl_file, string cache_id, string compile_id)

test to see if valid cache exists for this template

Parameters:
tpl_file - name of template file
Returns:
results of {@link _read_cache_file()}

/Smarty.class.php at line 912

load_filter

public void load_filter(string type, string name)

load a filter of specified type and name

Parameters:
type - filter type
name - filter name

/Smarty.class.php at line 741

register_block

public void register_block(string block, string block_impl, mixed cacheable, mixed cache_attrs)

Registers block function to be used in templates

Parameters:
block - name of template block
block_impl - PHP function to register

/Smarty.class.php at line 763

register_compiler_function

public void register_compiler_function(string function, string function_impl, mixed cacheable)

Registers compiler function

Parameters:
function - name of template function
function_impl - name of PHP function to register

/Smarty.class.php at line 690

register_function

public void register_function(string function, string function_impl, mixed cacheable, mixed cache_attrs)

Registers custom function to be used in templates

Parameters:
function - the name of the template function
function_impl - the name of the PHP function to register

/Smarty.class.php at line 785

register_modifier

public void register_modifier(string modifier, string modifier_impl)

Registers modifier to be used in templates

Parameters:
modifier - name of template modifier
modifier_impl - name of PHP function to register

/Smarty.class.php at line 716

register_object

public void register_object(string object, mixed object_impl, null|array allowed, mixed block_methods, object &$object_impl, boolean smarty_args, null|array block_functs)

Registers object to be used in templates

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

/Smarty.class.php at line 889

register_outputfilter

public void register_outputfilter(string function)

Registers an output filter function to apply to a template output

Parameters:
function - name of PHP function

/Smarty.class.php at line 866

register_postfilter

public void register_postfilter(string function)

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

Parameters:
function - name of PHP function to register

/Smarty.class.php at line 843

register_prefilter

public void register_prefilter(string function)

Registers a prefilter function to apply to a template before compiling

Parameters:
function - name of PHP function to register

/Smarty.class.php at line 807

register_resource

public void register_resource(string type, array functions)

Registers a resource to fetch a template

Parameters:
type - name of resource
functions - array of functions to handle resource

/Smarty.class.php at line 1041

template_exists

public boolean template_exists(string tpl_file)

Checks whether requested template exists.


/Smarty.class.php at line 1093

trigger_error

public void trigger_error(string error_msg, integer error_type)

trigger Smarty error


/Smarty.class.php at line 752

unregister_block

public void unregister_block(string block)

Unregisters block function

Parameters:
block - name of template function

/Smarty.class.php at line 774

unregister_compiler_function

public void unregister_compiler_function(string function)

Unregisters compiler function

Parameters:
function - name of template function

/Smarty.class.php at line 702

unregister_function

public void unregister_function(string function)

Unregisters custom function

Parameters:
function - name of template function

/Smarty.class.php at line 796

unregister_modifier

public void unregister_modifier(string modifier)

Unregisters modifier

Parameters:
modifier - name of template modifier

/Smarty.class.php at line 729

unregister_object

public void unregister_object(string object)

Unregisters object

Parameters:
object - name of template object

/Smarty.class.php at line 901

unregister_outputfilter

public void unregister_outputfilter(string function)

Unregisters an outputfilter function

Parameters:
function - name of PHP function

/Smarty.class.php at line 878

unregister_postfilter

public void unregister_postfilter(string function)

Unregisters a postfilter function

Parameters:
function - name of PHP function

/Smarty.class.php at line 855

unregister_prefilter

public void unregister_prefilter(string function)

Unregisters a prefilter function

Parameters:
function - name of PHP function

/Smarty.class.php at line 832

unregister_resource

public void unregister_resource(string type)

Unregisters a resource

Parameters:
type - name of resource

Smarty