Класс Smarty

Шаблонизатор Smarty. Подробнее...

Граф наследования:Smarty:

A_Block A_Component A_Form A_Frame A_Grid A_Mail A_MainFrame A_Navigation A_Pager A_Statistic

Полный список членов класса

Открытые члены

Открытые атрибуты

Защищенные члены


Подробное описание

Шаблонизатор Smarty.

Конструктор(ы)

__construct (  ) 


Методы

_compile_resource ( resource_name,
compile_path 
) [protected]

compile the template

Аргументы:
string $resource_name
string $compile_path
Возвращает:
boolean

_compile_source ( resource_name,
&$  source_content,
&$  compiled_content,
cache_include_path = null 
) [protected]

compile the given source

Аргументы:
string $resource_name
string $source_content
string $compiled_content
Возвращает:
boolean

_dequote ( string  )  [protected]

Remove starting and ending quotes from the string.

Аргументы:
string $string
Возвращает:
string

_eval ( code,
params = null 
) [protected]

wrapper for eval() retaining $this

Возвращает:
mixed

_fetch_resource_info ( &$  params  )  [protected]

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

Аргументы:
string $resource_name
string $source_content
integer $resource_timestamp
boolean $get_source
boolean $quiet
Возвращает:
boolean

_get_auto_filename ( auto_base,
auto_source = null,
auto_id = null 
) [protected]

get a concrete filename for automagically created content

Аргументы:
string $auto_base
string $auto_source
string $auto_id
Возвращает:
string string|null string|null

_get_auto_id ( cache_id = null,
compile_id = null 
) [protected]

returns an auto_id for auto-file-functions

Аргументы:
string $cache_id
string $compile_id
Возвращает:
string|null

_get_compile_path ( resource_name  )  [protected]

Get the compile path for this resource.

Аргументы:
string $resource_name
Возвращает:
string results of _get_auto_filename()

_get_filter_name ( function  )  [protected]

Extracts the filter name from the given callback.

Аргументы:
callback $function
Возвращает:
string

_get_plugin_filepath ( type,
name 
)

get filepath of requested plugin

Аргументы:
string $type
string $name
Возвращает:
string|false

_include ( filename,
once = false,
params = null 
) [protected]

wrapper for include() retaining $this

Возвращает:
mixed

_is_compiled ( resource_name,
compile_path 
) [protected]

test if resource needs compiling

Аргументы:
string $resource_name
string $compile_path
Возвращает:
boolean

_parse_resource_name ( &$  params  )  [protected]

parse out the type and name from the resource

Аргументы:
string $resource_base_path
string $resource_name
string $resource_type
string $resource_name
Возвращает:
boolean

_process_compiled_include_callback ( match  )  [protected]

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

Возвращает:
string

_read_file ( filename  )  [protected]

read in a file

Аргументы:
string $filename
Возвращает:
string

_run_mod_handler (  )  [protected]

Handle modifiers.

Аргументы:
string|null $modifier_name
array|null $map_array
Возвращает:
string result of modifiers

& _smarty_cache_attrs ( cache_serial,
count 
) [protected]

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

Возвращает:
array

_smarty_include ( params  )  [protected]

called for included templates

Аргументы:
string $_smarty_include_tpl_file
string $_smarty_include_vars

_trigger_fatal_error ( error_msg,
tpl_file = null,
tpl_line = null,
file = null,
line = null,
error_type = E_USER_ERROR 
) [protected]

trigger Smarty plugin error

Аргументы:
string $error_msg
string $tpl_file
integer $tpl_line
string $file
integer $line
integer $error_type

_unlink ( resource,
exp_time = null 
) [protected]

unlink a file, possibly using expiration time

Аргументы:
string $resource
integer $exp_time

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

appends values to template variables

Аргументы:
array|string $tpl_var the template variable name(s)
mixed $value the value to append

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

appends values to template variables by reference

Аргументы:
string $tpl_var the template variable name
mixed $value the referenced value to append

assign ( tpl_var,
value = null 
)

assigns values to template variables

Аргументы:
array|string $tpl_var the template variable name(s)
mixed $value the value to assign

assign_by_ref ( tpl_var,
&$  value 
)

assigns values to template variables by reference

Аргументы:
string $tpl_var the template variable name
mixed $value the referenced value to assign

clear_all_assign (  ) 

clear all the assigned template variables.

clear_all_cache ( exp_time = null  ) 

clear the entire contents of cache (all templates)

Аргументы:
string $exp_time expire time
Возвращает:
boolean results of smarty_core_rm_auto()

clear_assign ( tpl_var  ) 

clear the given assigned template variable.

Аргументы:
string $tpl_var the template variable to clear

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

clear cached content for the given template and cache id

Аргументы:
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
Возвращает:
boolean

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.

Аргументы:
string $tpl_file
string $compile_id
string $exp_time
Возвращает:
boolean results of smarty_core_rm_auto()

clear_config ( var = null  ) 

clear configuration values

Аргументы:
string $var

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

load configuration values

Аргументы:
string $file
string $section
string $scope

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

executes & displays the template results

Аргументы:
string $resource_name
string $cache_id
string $compile_id

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

executes & returns or displays the template results

Аргументы:
string $resource_name
string $cache_id
string $compile_id
boolean $display

& get_config_vars ( name = null  ) 

Returns an array containing config variables.

Аргументы:
string $name
string $type
Возвращает:
array

& get_registered_object ( name  ) 

return a reference to a registered object

Аргументы:
string $name
Возвращает:
object

& get_template_vars ( name = null  ) 

Returns an array containing template variables.

Аргументы:
string $name
string $type
Возвращает:
array

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

test to see if valid cache exists for this template

Аргументы:
string $tpl_file name of template file
string $cache_id
string $compile_id
Возвращает:
string|false results of _read_cache_file()

load_filter ( type,
name 
)

load a filter of specified type and name

Аргументы:
string $type filter type
string $name filter name

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

Registers block function to be used in templates.

Аргументы:
string $block name of template block
string $block_impl PHP function to register

register_compiler_function ( function,
function_impl,
cacheable = true 
)

Registers compiler function.

Аргументы:
string $function name of template function
string $function_impl name of PHP function to register

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

Registers custom function to be used in templates.

Аргументы:
string $function the name of the template function
string $function_impl the name of the PHP function to register

register_modifier ( modifier,
modifier_impl 
)

Registers modifier to be used in templates.

Аргументы:
string $modifier name of template modifier
string $modifier_impl name of PHP function to register

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

Registers object to be used in templates.

Аргументы:
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

register_outputfilter ( function  ) 

Registers an output filter function to apply to a template output.

Аргументы:
callback $function

register_postfilter ( function  ) 

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

Аргументы:
callback $function

register_prefilter ( function  ) 

Registers a prefilter function to apply to a template before compiling.

Аргументы:
callback $function

register_resource ( type,
functions 
)

Registers a resource to fetch a template.

Аргументы:
string $type name of resource
array $functions array of functions to handle resource

template_exists ( tpl_file  ) 

Checks whether requested template exists.

Аргументы:
string $tpl_file
Возвращает:
boolean

trigger_error ( error_msg,
error_type = E_USER_WARNING 
)

trigger Smarty error

Аргументы:
string $error_msg
integer $error_type

unregister_block ( block  ) 

Unregisters block function.

Аргументы:
string $block name of template function

unregister_compiler_function ( function  ) 

Unregisters compiler function.

Аргументы:
string $function name of template function

unregister_function ( function  ) 

Unregisters custom function.

Аргументы:
string $function name of template function

unregister_modifier ( modifier  ) 

Unregisters modifier.

Аргументы:
string $modifier name of template modifier

unregister_object ( object  ) 

Unregisters object.

Аргументы:
string $object name of template object

unregister_outputfilter ( function  ) 

Unregisters an outputfilter function.

Аргументы:
callback $function

unregister_postfilter ( function  ) 

Unregisters a postfilter function.

Аргументы:
callback $function

unregister_prefilter ( function  ) 

Unregisters a prefilter function.

Аргументы:
callback $function

unregister_resource ( type  ) 

Unregisters a resource.

Аргументы:
string $type name of resource


Данные класса

$_cache_include

name of optional cache include file

$_cache_including

indicate if the current code is used in a compiled include

$_cache_info

info that makes up a cache file

$_cache_serials

cache serials

$_compile_id

for different compiled templates

$_conf_obj

configuration object

$_config

loaded configuration settings

$_dir_perms

default dir permissions

$_file_perms

default file permissions

$_foreach

keeps track of foreach blocks

$_inclusion_depth

current template inclusion depth

$_plugins

table keeping track of plugins

$_reg_objects

registered objects

$_sections

keeps track of sections

$_smarty_debug_id

text in URL to enable debug mode

$_smarty_debug_info

debugging information for debug console

$_smarty_md5

md5 checksum of the string 'Smarty'

$_smarty_vars

stores run-time $smarty.

* vars

$_tag_stack

keeps track of tag hierarchy

$_tpl_vars

where assigned template vars are kept

$_version

Smarty version number.

$autoload_filters

This indicates which filters are automatically loaded into Smarty.

array of filter names

$cache_dir

The name of the directory for cache files.

$cache_handler_func

The function used for cache file handling.

If not set, built-in caching is used.

$cache_lifetime

This is the number of seconds cached content will persist.

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

$cache_modified_check

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.

$caching

This enables template caching.

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

$compile_check

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.

$compile_dir

The directory where compiled templates are located.

$compile_id

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'.

$compiler_class

The class used for compiling templates.

$compiler_file

The file that contains the compiler class.

This can a full pathname, or relative to the php_include path.

$config_booleanize

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.

$config_class

The class used to load config vars.

$config_dir

The directory where config files are located.

$config_fix_newlines

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

It basically converts (mac) or
(dos) to

$config_overwrite

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.

$config_read_hidden

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.

$debug_tpl

This is the path to the debug console template.

If not set, the default one will be used.

$debugging

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

$debugging_ctrl

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

  • NONE => no debugging control allowed
  • URL => enable debugging when SMARTY_DEBUG is found in the URL.
http://www.foo.dom/index.php?SMARTY_DEBUG

$default_modifiers

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"');

$default_resource_type

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 *}

$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. function name

$error_reporting

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

$force_compile

This forces templates to compile every time.

Useful for development or debugging.

$left_delimiter

The left delimiter used for the template tags.

$php_handling

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

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

$plugins_dir

An array of directories searched for plugins.

$request_use_auto_globals

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"

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

$right_delimiter

The right delimiter used for the template tags.

$secure_dir

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.

$security

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)

$security_settings

These are the security settings for Smarty.

They are used only when $security is enabled.

$template_dir

The name of the directory where templates are located.

$trusted_dir

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

$security is disabled during their inclusion/execution.

$use_sub_dirs

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.


Объявления и описания членов класса находятся в файле: