4 * Project: Smarty: the PHP compiling template engine
5 * File: Smarty.class.php
7 * This library is free software; you can redistribute it and/or
8 * modify it under the terms of the GNU Lesser General Public
9 * License as published by the Free Software Foundation; either
10 * version 2.1 of the License, or (at your option) any later version.
12 * This library is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 * Lesser General Public License for more details.
17 * You should have received a copy of the GNU Lesser General Public
18 * License along with this library; if not, write to the Free Software
19 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
21 * For questions, help, comments, discussion, etc., please join the
22 * Smarty mailing list. Send a blank e-mail to
23 * smarty-general-subscribe@lists.php.net
25 * @link http://smarty.php.net/
26 * @copyright 2001-2004 ispi of Lincoln, Inc.
27 * @author Monte Ohrt <monte@ispi.net>
28 * @author Andrei Zmievski <andrei@php.net>
36 * DIR_SEP isn't used anymore, but third party apps might
38 if(!defined('DIR_SEP')) {
39 define('DIR_SEP', DIRECTORY_SEPARATOR
);
43 * set SMARTY_DIR to absolute path to Smarty library files.
44 * if not defined, include_path will be used. Sets SMARTY_DIR only if user
45 * application has not already defined it.
48 if (!defined('SMARTY_DIR')) {
49 define('SMARTY_DIR', dirname(__FILE__
) . DIRECTORY_SEPARATOR
);
52 define('SMARTY_PHP_PASSTHRU', 0);
53 define('SMARTY_PHP_QUOTE', 1);
54 define('SMARTY_PHP_REMOVE', 2);
55 define('SMARTY_PHP_ALLOW', 3);
63 * Smarty Configuration Section
67 * The name of the directory where templates are located.
71 var $template_dir = 'templates';
74 * The directory where compiled templates are located.
78 var $compile_dir = 'templates_c';
81 * The directory where config files are located.
85 var $config_dir = 'configs';
88 * An array of directories searched for plugins.
92 var $plugins_dir = array('plugins');
95 * If debugging is enabled, a debug console window will display
96 * when the page loads (make sure your browser allows unrequested
101 var $debugging = false;
104 * When set, smarty does uses this value as error_reporting-level.
108 var $error_reporting = null;
111 * This is the path to the debug console template. If not set,
112 * the default one will be used.
119 * This determines if debugging is enable-able from the browser.
121 * <li>NONE => no debugging control allowed</li>
122 * <li>URL => enable debugging when SMARTY_DEBUG is found in the URL.</li>
124 * @link http://www.foo.dom/index.php?SMARTY_DEBUG
127 var $debugging_ctrl = 'NONE';
130 * This tells Smarty whether to check for recompiling or not. Recompiling
131 * does not need to happen unless a template or config file is changed.
132 * Typically you enable this during development, and disable for
137 var $compile_check = true;
140 * This forces templates to compile every time. Useful for development
145 var $force_compile = false;
148 * This enables template caching.
150 * <li>0 = no caching</li>
151 * <li>1 = use class cache_lifetime value</li>
152 * <li>2 = use cache_lifetime in cache file</li>
159 * The name of the directory for cache files.
163 var $cache_dir = 'cache';
166 * This is the number of seconds cached content will persist.
168 * <li>0 = always regenerate cache</li>
169 * <li>-1 = never expires</li>
174 var $cache_lifetime = 3600;
177 * Only used when $caching is enabled. If true, then If-Modified-Since headers
178 * are respected with cached content, and appropriate HTTP headers are sent.
179 * This way repeated hits to a cached page do not send the entire page to the
184 var $cache_modified_check = false;
187 * This determines how Smarty handles "<?php ... ?>" tags in templates.
190 * <li>SMARTY_PHP_PASSTHRU -> print tags as plain text</li>
191 * <li>SMARTY_PHP_QUOTE -> escape tags as entities</li>
192 * <li>SMARTY_PHP_REMOVE -> remove php tags</li>
193 * <li>SMARTY_PHP_ALLOW -> execute php tags</li>
198 var $php_handling = SMARTY_PHP_PASSTHRU
;
201 * This enables template security. When enabled, many things are restricted
202 * in the templates that normally would go unchecked. This is useful when
203 * untrusted parties are editing templates and you want a reasonable level
204 * of security. (no direct execution of PHP in templates for example)
208 var $security = false;
211 * This is the list of template directories that are considered secure. This
212 * is used only if {@link $security} is enabled. One directory per array
213 * element. {@link $template_dir} is in this list implicitly.
217 var $secure_dir = array();
220 * These are the security settings for Smarty. They are used only when
221 * {@link $security} is enabled.
225 var $security_settings = array(
226 'PHP_HANDLING' => false,
227 'IF_FUNCS' => array('array', 'list',
230 'in_array', 'is_array',
232 'INCLUDE_ANY' => false,
234 'MODIFIER_FUNCS' => array('count'),
235 'ALLOW_CONSTANTS' => false
239 * This is an array of directories where trusted php scripts reside.
240 * {@link $security} is disabled during their inclusion/execution.
244 var $trusted_dir = array();
247 * The left delimiter used for the template tags.
251 var $left_delimiter = '{';
254 * The right delimiter used for the template tags.
258 var $right_delimiter = '}';
261 * The order in which request variables are registered, similar to
262 * variables_order in php.ini E = Environment, G = GET, P = POST,
263 * C = Cookies, S = Server
267 var $request_vars_order = "EGPCS";
270 * Indicates wether $HTTP_*_VARS[] (request_use_auto_globals=false)
271 * are uses as request-vars or $_*[]-vars. note: if
272 * request_use_auto_globals is true, then $request_vars_order has
273 * no effect, but the php-ini-value "gpc_order"
277 var $request_use_auto_globals = true;
280 * Set this if you want different sets of compiled files for the same
281 * templates. This is useful for things like different languages.
282 * Instead of creating separate sets of templates per language, you
283 * set different compile_ids like 'en' and 'de'.
287 var $compile_id = null;
290 * This tells Smarty whether or not to use sub dirs in the cache/ and
291 * templates_c/ directories. sub directories better organized, but
292 * may not work well with PHP safe mode enabled.
297 var $use_sub_dirs = false;
300 * This is a list of the modifiers to apply to all template variables.
301 * Put each modifier in a separate array element in the order you want
302 * them applied. example: <code>array('escape:"htmlall"');</code>
306 var $default_modifiers = array();
309 * This is the resource type to be used when not specified
310 * at the beginning of the resource path. examples:
311 * $smarty->display('file:index.tpl');
312 * $smarty->display('db:index.tpl');
313 * $smarty->display('index.tpl'); // will use default resource type
314 * {include file="file:index.tpl"}
315 * {include file="db:index.tpl"}
316 * {include file="index.tpl"} {* will use default resource type *}
320 var $default_resource_type = 'file';
323 * The function used for cache file handling. If not set, built-in caching is used.
325 * @var null|string function name
327 var $cache_handler_func = null;
330 * This indicates which filters are automatically loaded into Smarty.
332 * @var array array of filter names
334 var $autoload_filters = array();
340 * This tells if config file vars of the same name overwrite each other or not.
341 * if disabled, same name variables are accumulated in an array.
343 var $config_overwrite = true;
346 * This tells whether or not to automatically booleanize config file variables.
347 * If enabled, then the strings "on", "true", and "yes" are treated as boolean
348 * true, and "off", "false" and "no" are treated as boolean false.
350 var $config_booleanize = true;
353 * This tells whether hidden sections [.foobar] are readable from the
354 * tempalates or not. Normally you would never allow this since that is
355 * the point behind hidden sections: the application can access them, but
356 * the templates cannot.
358 var $config_read_hidden = false;
361 * This tells whether or not automatically fix newlines in config files.
362 * It basically converts \r (mac) or \r\n (dos) to \n
364 var $config_fix_newlines = true;
368 * If a template cannot be found, this PHP function will be executed.
369 * Useful for creating templates on-the-fly or other special action.
371 * @var string function name
373 var $default_template_handler_func = '';
376 * The file that contains the compiler class. This can a full
377 * pathname, or relative to the php_include path.
381 var $compiler_file = 'Smarty_Compiler.class.php';
384 * The class used for compiling templates.
388 var $compiler_class = 'Smarty_Compiler';
391 * The class used to load config vars.
395 var $config_class = 'Config_File';
398 * END Smarty Configuration Section
399 * There should be no need to touch anything below this line.
403 * error messages. true/false
407 var $_error_msg = false;
410 * where assigned template vars are kept
414 var $_tpl_vars = array();
417 * stores run-time $smarty.* vars
421 var $_smarty_vars = null;
424 * keeps track of sections
428 var $_sections = array();
431 * keeps track of foreach blocks
435 var $_foreach = array();
438 * keeps track of tag hierarchy
442 var $_tag_stack = array();
445 * configuration object
449 var $_conf_obj = null;
452 * loaded configuration settings
456 var $_config = array(array('vars' => array(), 'files' => array()));
459 * md5 checksum of the string 'Smarty'
463 var $_smarty_md5 = 'f8d698aea36fcbead2b9d5359ffca76f';
466 * Smarty version number
470 var $_version = '2.6.2';
473 * current template inclusion depth
477 var $_inclusion_depth = 0;
480 * for different compiled templates
484 var $_compile_id = null;
487 * text in URL to enable debug mode
491 var $_smarty_debug_id = 'SMARTY_DEBUG';
494 * debugging information for debug console
498 var $_smarty_debug_info = array();
501 * info that makes up a cache file
505 var $_cache_info = array();
508 * default file permissions
512 var $_file_perms = 0644;
515 * default dir permissions
519 var $_dir_perms = 0771;
526 var $_reg_objects = array();
529 * table keeping track of plugins
533 var $_plugins = array(
534 'modifier' => array(),
535 'function' => array(),
537 'compiler' => array(),
538 'prefilter' => array(),
539 'postfilter' => array(),
540 'outputfilter' => array(),
541 'resource' => array(),
542 'insert' => array());
550 var $_cache_serials = array();
553 * name of optional cache include file
557 var $_cache_include = null;
560 * indicate if the current code is used in a compiled
565 var $_cache_including = false;
569 * The class constructor.
573 $this->assign('SCRIPT_NAME', isset($_SERVER['SCRIPT_NAME']) ?
$_SERVER['SCRIPT_NAME']
574 : @$GLOBALS['HTTP_SERVER_VARS']['SCRIPT_NAME']);
578 * assigns values to template variables
580 * @param array|string $tpl_var the template variable name(s)
581 * @param mixed $value the value to assign
583 function assign($tpl_var, $value = null)
585 if (is_array($tpl_var)){
586 foreach ($tpl_var as $key => $val) {
588 $this->_tpl_vars
[$key] = $val;
593 $this->_tpl_vars
[$tpl_var] = $value;
598 * assigns values to template variables by reference
600 * @param string $tpl_var the template variable name
601 * @param mixed $value the referenced value to assign
603 function assign_by_ref($tpl_var, &$value)
606 $this->_tpl_vars
[$tpl_var] = &$value;
610 * appends values to template variables
612 * @param array|string $tpl_var the template variable name(s)
613 * @param mixed $value the value to append
615 function append($tpl_var, $value=null, $merge=false)
617 if (is_array($tpl_var)) {
618 // $tpl_var is an array, ignore $value
619 foreach ($tpl_var as $_key => $_val) {
621 if(!@is_array
($this->_tpl_vars
[$_key])) {
622 settype($this->_tpl_vars
[$_key],'array');
624 if($merge && is_array($_val)) {
625 foreach($_val as $_mkey => $_mval) {
626 $this->_tpl_vars
[$_key][$_mkey] = $_mval;
629 $this->_tpl_vars
[$_key][] = $_val;
634 if ($tpl_var != '' && isset($value)) {
635 if(!@is_array
($this->_tpl_vars
[$tpl_var])) {
636 settype($this->_tpl_vars
[$tpl_var],'array');
638 if($merge && is_array($value)) {
639 foreach($value as $_mkey => $_mval) {
640 $this->_tpl_vars
[$tpl_var][$_mkey] = $_mval;
643 $this->_tpl_vars
[$tpl_var][] = $value;
650 * appends values to template variables by reference
652 * @param string $tpl_var the template variable name
653 * @param mixed $value the referenced value to append
655 function append_by_ref($tpl_var, &$value, $merge=false)
657 if ($tpl_var != '' && isset($value)) {
658 if(!@is_array
($this->_tpl_vars
[$tpl_var])) {
659 settype($this->_tpl_vars
[$tpl_var],'array');
661 if ($merge && is_array($value)) {
662 foreach($value as $_key => $_val) {
663 $this->_tpl_vars
[$tpl_var][$_key] = &$value[$_key];
666 $this->_tpl_vars
[$tpl_var][] = &$value;
673 * clear the given assigned template variable.
675 * @param string $tpl_var the template variable to clear
677 function clear_assign($tpl_var)
679 if (is_array($tpl_var))
680 foreach ($tpl_var as $curr_var)
681 unset($this->_tpl_vars
[$curr_var]);
683 unset($this->_tpl_vars
[$tpl_var]);
688 * Registers custom function to be used in templates
690 * @param string $function the name of the template function
691 * @param string $function_impl the name of the PHP function to register
693 function register_function($function, $function_impl, $cacheable=true, $cache_attrs=null)
695 $this->_plugins
['function'][$function] =
696 array($function_impl, null, null, false, $cacheable, $cache_attrs);
701 * Unregisters custom function
703 * @param string $function name of template function
705 function unregister_function($function)
707 unset($this->_plugins
['function'][$function]);
711 * Registers object to be used in templates
713 * @param string $object name of template object
714 * @param object &$object_impl the referenced PHP object to register
715 * @param null|array $allowed list of allowed methods (empty = all)
716 * @param boolean $smarty_args smarty argument format, else traditional
717 * @param null|array $block_functs list of methods that are block format
719 function register_object($object, &$object_impl, $allowed = array(), $smarty_args = true, $block_methods = array())
721 settype($allowed, 'array');
722 settype($smarty_args, 'boolean');
723 $this->_reg_objects
[$object] =
724 array(&$object_impl, $allowed, $smarty_args, $block_methods);
730 * @param string $object name of template object
732 function unregister_object($object)
734 unset($this->_reg_objects
[$object]);
739 * Registers block function to be used in templates
741 * @param string $block name of template block
742 * @param string $block_impl PHP function to register
744 function register_block($block, $block_impl, $cacheable=true, $cache_attrs=null)
746 $this->_plugins
['block'][$block] =
747 array($block_impl, null, null, false, $cacheable, $cache_attrs);
751 * Unregisters block function
753 * @param string $block name of template function
755 function unregister_block($block)
757 unset($this->_plugins
['block'][$block]);
761 * Registers compiler function
763 * @param string $function name of template function
764 * @param string $function_impl name of PHP function to register
766 function register_compiler_function($function, $function_impl, $cacheable=true)
768 $this->_plugins
['compiler'][$function] =
769 array($function_impl, null, null, false, $cacheable);
773 * Unregisters compiler function
775 * @param string $function name of template function
777 function unregister_compiler_function($function)
779 unset($this->_plugins
['compiler'][$function]);
783 * Registers modifier to be used in templates
785 * @param string $modifier name of template modifier
786 * @param string $modifier_impl name of PHP function to register
788 function register_modifier($modifier, $modifier_impl)
790 $this->_plugins
['modifier'][$modifier] =
791 array($modifier_impl, null, null, false);
795 * Unregisters modifier
797 * @param string $modifier name of template modifier
799 function unregister_modifier($modifier)
801 unset($this->_plugins
['modifier'][$modifier]);
805 * Registers a resource to fetch a template
807 * @param string $type name of resource
808 * @param array $functions array of functions to handle resource
810 function register_resource($type, $functions)
812 if (count($functions)==4) {
813 $this->_plugins
['resource'][$type] =
814 array($functions, false);
816 } elseif (count($functions)==5) {
817 $this->_plugins
['resource'][$type] =
818 array(array(array(&$functions[0], $functions[1])
819 ,array(&$functions[0], $functions[2])
820 ,array(&$functions[0], $functions[3])
821 ,array(&$functions[0], $functions[4]))
825 $this->trigger_error("malformed function-list for '$type' in register_resource");
831 * Unregisters a resource
833 * @param string $type name of resource
835 function unregister_resource($type)
837 unset($this->_plugins
['resource'][$type]);
841 * Registers a prefilter function to apply
842 * to a template before compiling
844 * @param string $function name of PHP function to register
846 function register_prefilter($function)
848 $_name = (is_array($function)) ?
$function[1] : $function;
849 $this->_plugins
['prefilter'][$_name]
850 = array($function, null, null, false);
854 * Unregisters a prefilter function
856 * @param string $function name of PHP function
858 function unregister_prefilter($function)
860 unset($this->_plugins
['prefilter'][$function]);
864 * Registers a postfilter function to apply
865 * to a compiled template after compilation
867 * @param string $function name of PHP function to register
869 function register_postfilter($function)
871 $_name = (is_array($function)) ?
$function[1] : $function;
872 $this->_plugins
['postfilter'][$_name]
873 = array($function, null, null, false);
877 * Unregisters a postfilter function
879 * @param string $function name of PHP function
881 function unregister_postfilter($function)
883 unset($this->_plugins
['postfilter'][$function]);
887 * Registers an output filter function to apply
888 * to a template output
890 * @param string $function name of PHP function
892 function register_outputfilter($function)
894 $_name = (is_array($function)) ?
$function[1] : $function;
895 $this->_plugins
['outputfilter'][$_name]
896 = array($function, null, null, false);
900 * Unregisters an outputfilter function
902 * @param string $function name of PHP function
904 function unregister_outputfilter($function)
906 unset($this->_plugins
['outputfilter'][$function]);
910 * load a filter of specified type and name
912 * @param string $type filter type
913 * @param string $name filter name
915 function load_filter($type, $name)
919 $_params = array('plugins' => array(array($type . 'filter', $name, null, null, false)));
920 require_once(SMARTY_DIR
. 'core' . DIRECTORY_SEPARATOR
. 'core.load_plugins.php');
921 smarty_core_load_plugins($_params, $this);
926 if (!isset($this->_plugins
[$type . 'filter'][$name]))
927 $this->_plugins
[$type . 'filter'][$name] = false;
933 * clear cached content for the given template and cache id
935 * @param string $tpl_file name of template file
936 * @param string $cache_id name of cache_id
937 * @param string $compile_id name of compile_id
938 * @param string $exp_time expiration time
941 function clear_cache($tpl_file = null, $cache_id = null, $compile_id = null, $exp_time = null)
944 if (!isset($compile_id))
945 $compile_id = $this->compile_id
;
947 if (!isset($tpl_file))
950 $_auto_id = $this->_get_auto_id($cache_id, $compile_id);
952 if (!empty($this->cache_handler_func
)) {
953 return call_user_func_array($this->cache_handler_func
,
954 array('clear', &$this, &$dummy, $tpl_file, $cache_id, $compile_id, $exp_time));
956 $_params = array('auto_base' => $this->cache_dir
,
957 'auto_source' => $tpl_file,
958 'auto_id' => $_auto_id,
959 'exp_time' => $exp_time);
960 require_once(SMARTY_DIR
. 'core' . DIRECTORY_SEPARATOR
. 'core.rm_auto.php');
961 return smarty_core_rm_auto($_params, $this);
968 * clear the entire contents of cache (all templates)
970 * @param string $exp_time expire time
971 * @return boolean results of {@link smarty_core_rm_auto()}
973 function clear_all_cache($exp_time = null)
975 if (!empty($this->cache_handler_func
)) {
977 call_user_func_array($this->cache_handler_func
,
978 array('clear', &$this, &$dummy, null, null, null, $exp_time));
980 $_params = array('auto_base' => $this->cache_dir
,
981 'auto_source' => null,
983 'exp_time' => $exp_time);
984 require_once(SMARTY_DIR
. 'core' . DIRECTORY_SEPARATOR
. 'core.rm_auto.php');
985 return smarty_core_rm_auto($_params, $this);
991 * test to see if valid cache exists for this template
993 * @param string $tpl_file name of template file
994 * @param string $cache_id
995 * @param string $compile_id
996 * @return string|false results of {@link _read_cache_file()}
998 function is_cached($tpl_file, $cache_id = null, $compile_id = null)
1000 if (!$this->caching
)
1003 if (!isset($compile_id))
1004 $compile_id = $this->compile_id
;
1007 'tpl_file' => $tpl_file,
1008 'cache_id' => $cache_id,
1009 'compile_id' => $compile_id
1011 require_once(SMARTY_DIR
. 'core' . DIRECTORY_SEPARATOR
. 'core.read_cache_file.php');
1012 return smarty_core_read_cache_file($_params, $this);
1017 * clear all the assigned template variables.
1020 function clear_all_assign()
1022 $this->_tpl_vars
= array();
1026 * clears compiled version of specified template resource,
1027 * or all compiled template files if one is not specified.
1028 * This function is for advanced use only, not normally needed.
1030 * @param string $tpl_file
1031 * @param string $compile_id
1032 * @param string $exp_time
1033 * @return boolean results of {@link smarty_core_rm_auto()}
1035 function clear_compiled_tpl($tpl_file = null, $compile_id = null, $exp_time = null)
1037 if (!isset($compile_id)) {
1038 $compile_id = $this->compile_id
;
1040 $_params = array('auto_base' => $this->compile_dir
,
1041 'auto_source' => $tpl_file,
1042 'auto_id' => $compile_id,
1043 'exp_time' => $exp_time,
1044 'extensions' => array('.inc', '.php'));
1045 require_once(SMARTY_DIR
. 'core' . DIRECTORY_SEPARATOR
. 'core.rm_auto.php');
1046 return smarty_core_rm_auto($_params, $this);
1050 * Checks whether requested template exists.
1052 * @param string $tpl_file
1055 function template_exists($tpl_file)
1057 $_params = array('resource_name' => $tpl_file, 'quiet'=>true, 'get_source'=>false);
1058 return $this->_fetch_resource_info($_params);
1062 * Returns an array containing template variables
1064 * @param string $name
1065 * @param string $type
1068 function &get_template_vars($name=null)
1071 return $this->_tpl_vars
;
1073 if(isset($this->_tpl_vars
[$name])) {
1074 return $this->_tpl_vars
[$name];
1079 * Returns an array containing config variables
1081 * @param string $name
1082 * @param string $type
1085 function &get_config_vars($name=null)
1087 if(!isset($name) && is_array($this->_config
[0])) {
1088 return $this->_config
[0]['vars'];
1089 } else if(isset($this->_config
[0]['vars'][$name])) {
1090 return $this->_config
[0]['vars'][$name];
1095 * trigger Smarty error
1097 * @param string $error_msg
1098 * @param integer $error_type
1100 function trigger_error($error_msg, $error_type = E_USER_WARNING
)
1102 trigger_error("Smarty error: $error_msg", $error_type);
1107 * executes & displays the template results
1109 * @param string $resource_name
1110 * @param string $cache_id
1111 * @param string $compile_id
1113 function display($resource_name, $cache_id = null, $compile_id = null)
1115 $this->fetch($resource_name, $cache_id, $compile_id, true);
1119 * executes & returns or displays the template results
1121 * @param string $resource_name
1122 * @param string $cache_id
1123 * @param string $compile_id
1124 * @param boolean $display
1126 function fetch($resource_name, $cache_id = null, $compile_id = null, $display = false)
1128 static $_cache_info = array();
1130 $_smarty_old_error_level = $this->debugging ?
error_reporting() : error_reporting(isset($this->error_reporting
)
1131 ?
$this->error_reporting
: error_reporting() & ~E_NOTICE
);
1133 if (!$this->debugging
&& $this->debugging_ctrl
== 'URL') {
1134 $_query_string = $this->request_use_auto_globals ?
$_SERVER['QUERY_STRING'] : $GLOBALS['HTTP_SERVER_VARS']['QUERY_STRING'];
1135 if (@strstr
($_query_string, $this->_smarty_debug_id
)) {
1136 if (@strstr
($_query_string, $this->_smarty_debug_id
. '=on')) {
1137 // enable debugging for this browser session
1138 @setcookie
('SMARTY_DEBUG', true);
1139 $this->debugging
= true;
1140 } elseif (@strstr
($_query_string, $this->_smarty_debug_id
. '=off')) {
1141 // disable debugging for this browser session
1142 @setcookie
('SMARTY_DEBUG', false);
1143 $this->debugging
= false;
1145 // enable debugging for this page
1146 $this->debugging
= true;
1149 $_cookie_var = $this->request_use_auto_globals ?
$_COOKIE['SMARTY_DEBUG'] : $GLOBALS['HTTP_COOKIE_VARS']['SMARTY_DEBUG'];
1150 $this->debugging
= $_cookie_var ?
true : false;
1154 if ($this->debugging
) {
1155 // capture time for debugging info
1157 require_once(SMARTY_DIR
. 'core' . DIRECTORY_SEPARATOR
. 'core.get_microtime.php');
1158 $_debug_start_time = smarty_core_get_microtime($_params, $this);
1159 $this->_smarty_debug_info
[] = array('type' => 'template',
1160 'filename' => $resource_name,
1162 $_included_tpls_idx = count($this->_smarty_debug_info
) - 1;
1165 if (!isset($compile_id)) {
1166 $compile_id = $this->compile_id
;
1169 $this->_compile_id
= $compile_id;
1170 $this->_inclusion_depth
= 0;
1172 if ($this->caching
) {
1173 // save old cache_info, initialize cache_info
1174 array_push($_cache_info, $this->_cache_info
);
1175 $this->_cache_info
= array();
1177 'tpl_file' => $resource_name,
1178 'cache_id' => $cache_id,
1179 'compile_id' => $compile_id,
1182 require_once(SMARTY_DIR
. 'core' . DIRECTORY_SEPARATOR
. 'core.read_cache_file.php');
1183 if (smarty_core_read_cache_file($_params, $this)) {
1184 $_smarty_results = $_params['results'];
1185 if (@count
($this->_cache_info
['insert_tags'])) {
1186 $_params = array('plugins' => $this->_cache_info
['insert_tags']);
1187 require_once(SMARTY_DIR
. 'core' . DIRECTORY_SEPARATOR
. 'core.load_plugins.php');
1188 smarty_core_load_plugins($_params, $this);
1189 $_params = array('results' => $_smarty_results);
1190 require_once(SMARTY_DIR
. 'core' . DIRECTORY_SEPARATOR
. 'core.process_cached_inserts.php');
1191 $_smarty_results = smarty_core_process_cached_inserts($_params, $this);
1193 if (@count
($this->_cache_info
['cache_serials'])) {
1194 $_params = array('results' => $_smarty_results);
1195 require_once(SMARTY_DIR
. 'core' . DIRECTORY_SEPARATOR
. 'core.process_compiled_include.php');
1196 $_smarty_results = smarty_core_process_compiled_include($_params, $this);
1201 if ($this->debugging
)
1203 // capture time for debugging info
1205 require_once(SMARTY_DIR
. 'core' . DIRECTORY_SEPARATOR
. 'core.get_microtime.php');
1206 $this->_smarty_debug_info
[$_included_tpls_idx]['exec_time'] = smarty_core_get_microtime($_params, $this) - $_debug_start_time;
1207 require_once(SMARTY_DIR
. 'core' . DIRECTORY_SEPARATOR
. 'core.display_debug_console.php');
1208 $_smarty_results .= smarty_core_display_debug_console($_params, $this);
1210 if ($this->cache_modified_check
) {
1211 $_server_vars = ($this->request_use_auto_globals
) ?
$_SERVER : $GLOBALS['HTTP_SERVER_VARS'];
1212 $_last_modified_date = @substr
($_server_vars['HTTP_IF_MODIFIED_SINCE'], 0, strpos($_server_vars['HTTP_IF_MODIFIED_SINCE'], 'GMT') +
3);
1213 $_gmt_mtime = gmdate('D, d M Y H:i:s', $this->_cache_info
['timestamp']).' GMT';
1214 if (@count
($this->_cache_info
['insert_tags']) == 0
1215 && !$this->_cache_serials
1216 && $_gmt_mtime == $_last_modified_date) {
1217 if (php_sapi_name()=='cgi')
1218 header("Status: 304 Not Modified");
1220 header("HTTP/1.1 304 Not Modified");
1223 header("Last-Modified: ".$_gmt_mtime);
1224 echo $_smarty_results;
1227 echo $_smarty_results;
1229 error_reporting($_smarty_old_error_level);
1230 // restore initial cache_info
1231 $this->_cache_info
= array_pop($_cache_info);
1234 error_reporting($_smarty_old_error_level);
1235 // restore initial cache_info
1236 $this->_cache_info
= array_pop($_cache_info);
1237 return $_smarty_results;
1240 $this->_cache_info
['template'][$resource_name] = true;
1241 if ($this->cache_modified_check
&& $display) {
1242 header("Last-Modified: ".gmdate('D, d M Y H:i:s', time()).' GMT');
1247 // load filters that are marked as autoload
1248 if (count($this->autoload_filters
)) {
1249 foreach ($this->autoload_filters
as $_filter_type => $_filters) {
1250 foreach ($_filters as $_filter) {
1251 $this->load_filter($_filter_type, $_filter);
1256 $_smarty_compile_path = $this->_get_compile_path($resource_name);
1258 // if we just need to display the results, don't perform output
1259 // buffering - for speed
1260 $_cache_including = $this->_cache_including
;
1261 $this->_cache_including
= false;
1262 if ($display && !$this->caching
&& count($this->_plugins
['outputfilter']) == 0) {
1263 if ($this->_is_compiled($resource_name, $_smarty_compile_path)
1264 ||
$this->_compile_resource($resource_name, $_smarty_compile_path))
1266 include($_smarty_compile_path);
1270 if ($this->_is_compiled($resource_name, $_smarty_compile_path)
1271 ||
$this->_compile_resource($resource_name, $_smarty_compile_path))
1273 include($_smarty_compile_path);
1275 $_smarty_results = ob_get_contents();
1278 foreach ((array)$this->_plugins
['outputfilter'] as $_output_filter) {
1279 $_smarty_results = call_user_func_array($_output_filter[0], array($_smarty_results, &$this));
1283 if ($this->caching
) {
1284 $_params = array('tpl_file' => $resource_name,
1285 'cache_id' => $cache_id,
1286 'compile_id' => $compile_id,
1287 'results' => $_smarty_results);
1288 require_once(SMARTY_DIR
. 'core' . DIRECTORY_SEPARATOR
. 'core.write_cache_file.php');
1289 smarty_core_write_cache_file($_params, $this);
1290 require_once(SMARTY_DIR
. 'core' . DIRECTORY_SEPARATOR
. 'core.process_cached_inserts.php');
1291 $_smarty_results = smarty_core_process_cached_inserts($_params, $this);
1293 if ($this->_cache_serials
) {
1294 // strip nocache-tags from output
1295 $_smarty_results = preg_replace('!(\{/?nocache\:[0-9a-f]{32}#\d+\})!s'
1299 // restore initial cache_info
1300 $this->_cache_info
= array_pop($_cache_info);
1302 $this->_cache_including
= $_cache_including;
1305 if (isset($_smarty_results)) { echo $_smarty_results; }
1306 if ($this->debugging
) {
1307 // capture time for debugging info
1309 require_once(SMARTY_DIR
. 'core' . DIRECTORY_SEPARATOR
. 'core.get_microtime.php');
1310 $this->_smarty_debug_info
[$_included_tpls_idx]['exec_time'] = (smarty_core_get_microtime($_params, $this) - $_debug_start_time);
1311 require_once(SMARTY_DIR
. 'core' . DIRECTORY_SEPARATOR
. 'core.display_debug_console.php');
1312 echo smarty_core_display_debug_console($_params, $this);
1314 error_reporting($_smarty_old_error_level);
1317 error_reporting($_smarty_old_error_level);
1318 if (isset($_smarty_results)) { return $_smarty_results; }
1323 * load configuration values
1325 * @param string $file
1326 * @param string $section
1327 * @param string $scope
1329 function config_load($file, $section = null, $scope = 'global')
1331 require_once($this->_get_plugin_filepath('function', 'config_load'));
1332 smarty_function_config_load(array('file' => $file, 'section' => $section, 'scope' => $scope), $this);
1336 * return a reference to a registered object
1338 * @param string $name
1341 function &get_registered_object($name) {
1342 if (!isset($this->_reg_objects
[$name]))
1343 $this->_trigger_fatal_error("'$name' is not a registered object");
1345 if (!is_object($this->_reg_objects
[$name][0]))
1346 $this->_trigger_fatal_error("registered '$name' is not an object");
1348 return $this->_reg_objects
[$name][0];
1352 * clear configuration values
1354 * @param string $var
1356 function clear_config($var = null)
1360 $this->_config
= array(array('vars' => array(),
1361 'files' => array()));
1363 unset($this->_config
[0]['vars'][$var]);
1368 * get filepath of requested plugin
1370 * @param string $type
1371 * @param string $name
1372 * @return string|false
1374 function _get_plugin_filepath($type, $name)
1376 $_params = array('type' => $type, 'name' => $name);
1377 require_once(SMARTY_DIR
. 'core' . DIRECTORY_SEPARATOR
. 'core.assemble_plugin_filepath.php');
1378 return smarty_core_assemble_plugin_filepath($_params, $this);
1382 * test if resource needs compiling
1384 * @param string $resource_name
1385 * @param string $compile_path
1388 function _is_compiled($resource_name, $compile_path)
1390 if (!$this->force_compile
&& file_exists($compile_path)) {
1391 if (!$this->compile_check
) {
1392 // no need to check compiled file
1395 // get file source and timestamp
1396 $_params = array('resource_name' => $resource_name, 'get_source'=>false);
1397 if (!$this->_fetch_resource_info($_params)) {
1400 if ($_params['resource_timestamp'] <= filemtime($compile_path)) {
1401 // template not expired, no recompile
1409 // compiled template does not exist, or forced compile
1415 * compile the template
1417 * @param string $resource_name
1418 * @param string $compile_path
1421 function _compile_resource($resource_name, $compile_path)
1424 $_params = array('resource_name' => $resource_name);
1425 if (!$this->_fetch_resource_info($_params)) {
1429 $_source_content = $_params['source_content'];
1430 $_resource_timestamp = $_params['resource_timestamp'];
1431 $_cache_include = substr($compile_path, 0, -4).'.inc';
1433 if ($this->_compile_source($resource_name, $_source_content, $_compiled_content, $_cache_include)) {
1434 // if a _cache_serial was set, we also have to write an include-file:
1435 if ($this->_cache_include_info
) {
1436 require_once(SMARTY_DIR
. 'core' . DIRECTORY_SEPARATOR
. 'core.write_compiled_include.php');
1437 smarty_core_write_compiled_include(array_merge($this->_cache_include_info
, array('compiled_content'=>$_compiled_content)), $this);
1440 $_params = array('compile_path'=>$compile_path, 'compiled_content' => $_compiled_content, 'resource_timestamp' => $_resource_timestamp);
1441 require_once(SMARTY_DIR
. 'core' . DIRECTORY_SEPARATOR
. 'core.write_compiled_resource.php');
1442 smarty_core_write_compiled_resource($_params, $this);
1446 $this->trigger_error($smarty_compiler->_error_msg
);
1453 * compile the given source
1455 * @param string $resource_name
1456 * @param string $source_content
1457 * @param string $compiled_content
1460 function _compile_source($resource_name, &$source_content, &$compiled_content, $cache_include_path=null)
1462 if (file_exists(SMARTY_DIR
. $this->compiler_file
)) {
1463 require_once(SMARTY_DIR
. $this->compiler_file
);
1466 require_once($this->compiler_file
);
1470 $smarty_compiler = new $this->compiler_class
;
1472 $smarty_compiler->template_dir
= $this->template_dir
;
1473 $smarty_compiler->compile_dir
= $this->compile_dir
;
1474 $smarty_compiler->plugins_dir
= $this->plugins_dir
;
1475 $smarty_compiler->config_dir
= $this->config_dir
;
1476 $smarty_compiler->force_compile
= $this->force_compile
;
1477 $smarty_compiler->caching
= $this->caching
;
1478 $smarty_compiler->php_handling
= $this->php_handling
;
1479 $smarty_compiler->left_delimiter
= $this->left_delimiter
;
1480 $smarty_compiler->right_delimiter
= $this->right_delimiter
;
1481 $smarty_compiler->_version
= $this->_version
;
1482 $smarty_compiler->security
= $this->security
;
1483 $smarty_compiler->secure_dir
= $this->secure_dir
;
1484 $smarty_compiler->security_settings
= $this->security_settings
;
1485 $smarty_compiler->trusted_dir
= $this->trusted_dir
;
1486 $smarty_compiler->_reg_objects
= &$this->_reg_objects
;
1487 $smarty_compiler->_plugins
= &$this->_plugins
;
1488 $smarty_compiler->_tpl_vars
= &$this->_tpl_vars
;
1489 $smarty_compiler->default_modifiers
= $this->default_modifiers
;
1490 $smarty_compiler->compile_id
= $this->_compile_id
;
1491 $smarty_compiler->_config
= $this->_config
;
1492 $smarty_compiler->request_use_auto_globals
= $this->request_use_auto_globals
;
1494 $smarty_compiler->_cache_serial
= null;
1495 $smarty_compiler->_cache_include
= $cache_include_path;
1498 $_results = $smarty_compiler->_compile_file($resource_name, $source_content, $compiled_content);
1500 if ($smarty_compiler->_cache_serial
) {
1501 $this->_cache_include_info
= array(
1502 'cache_serial'=>$smarty_compiler->_cache_serial
1503 ,'plugins_code'=>$smarty_compiler->_plugins_code
1504 ,'include_file_path' => $cache_include_path);
1507 $this->_cache_include_info
= null;
1515 * Get the compile path for this resource
1517 * @param string $resource_name
1518 * @return string results of {@link _get_auto_filename()}
1520 function _get_compile_path($resource_name)
1522 return $this->_get_auto_filename($this->compile_dir
, $resource_name,
1523 $this->_compile_id
) . '.php';
1527 * fetch the template info. Gets timestamp, and source
1528 * if get_source is true
1530 * sets $source_content to the source of the template, and
1531 * $resource_timestamp to its time stamp
1532 * @param string $resource_name
1533 * @param string $source_content
1534 * @param integer $resource_timestamp
1535 * @param boolean $get_source
1536 * @param boolean $quiet
1540 function _fetch_resource_info(&$params)
1542 if(!isset($params['get_source'])) { $params['get_source'] = true; }
1543 if(!isset($params['quiet'])) { $params['quiet'] = false; }
1546 $_params = array('resource_name' => $params['resource_name']) ;
1547 if (isset($params['resource_base_path']))
1548 $_params['resource_base_path'] = $params['resource_base_path'];
1550 if ($this->_parse_resource_name($_params)) {
1551 $_resource_type = $_params['resource_type'];
1552 $_resource_name = $_params['resource_name'];
1553 switch ($_resource_type) {
1555 if ($params['get_source']) {
1556 $params['source_content'] = $this->_read_file($_resource_name);
1558 $params['resource_timestamp'] = filemtime($_resource_name);
1559 $_return = is_file($_resource_name);
1563 // call resource functions to fetch the template source and timestamp
1564 if ($params['get_source']) {
1565 $_source_return = isset($this->_plugins
['resource'][$_resource_type]) &&
1566 call_user_func_array($this->_plugins
['resource'][$_resource_type][0][0],
1567 array($_resource_name, &$params['source_content'], &$this));
1569 $_source_return = true;
1572 $_timestamp_return = isset($this->_plugins
['resource'][$_resource_type]) &&
1573 call_user_func_array($this->_plugins
['resource'][$_resource_type][0][1],
1574 array($_resource_name, &$params['resource_timestamp'], &$this));
1576 $_return = $_source_return && $_timestamp_return;
1582 // see if we can get a template with the default template handler
1583 if (!empty($this->default_template_handler_func
)) {
1584 if (!is_callable($this->default_template_handler_func
)) {
1585 $this->trigger_error("default template handler function \"$this->default_template_handler_func\" doesn't exist.");
1587 $_return = call_user_func_array(
1588 $this->default_template_handler_func
,
1589 array($_params['resource_type'], $_params['resource_name'], &$params['source_content'], &$params['resource_timestamp'], &$this));
1595 if (!$params['quiet']) {
1596 $this->trigger_error('unable to read resource: "' . $params['resource_name'] . '"');
1598 } else if ($_return && $this->security
) {
1599 require_once(SMARTY_DIR
. 'core' . DIRECTORY_SEPARATOR
. 'core.is_secure.php');
1600 if (!smarty_core_is_secure($_params, $this)) {
1601 if (!$params['quiet'])
1602 $this->trigger_error('(secure mode) accessing "' . $params['resource_name'] . '" is not allowed');
1603 $params['source_content'] = null;
1604 $params['resource_timestamp'] = null;
1613 * parse out the type and name from the resource
1615 * @param string $resource_base_path
1616 * @param string $resource_name
1617 * @param string $resource_type
1618 * @param string $resource_name
1622 function _parse_resource_name(&$params)
1625 // split tpl_path by the first colon
1626 $_resource_name_parts = explode(':', $params['resource_name'], 2);
1628 if (count($_resource_name_parts) == 1) {
1629 // no resource type given
1630 $params['resource_type'] = $this->default_resource_type
;
1631 $params['resource_name'] = $_resource_name_parts[0];
1633 if(strlen($_resource_name_parts[0]) == 1) {
1634 // 1 char is not resource type, but part of filepath
1635 $params['resource_type'] = $this->default_resource_type
;
1636 $params['resource_name'] = $params['resource_name'];
1638 $params['resource_type'] = $_resource_name_parts[0];
1639 $params['resource_name'] = $_resource_name_parts[1];
1643 if ($params['resource_type'] == 'file') {
1644 if (!preg_match("/^([\/\\\\]|[a-zA-Z]:[\/\\\\])/", $params['resource_name'])) {
1645 // relative pathname to $params['resource_base_path']
1646 // use the first directory where the file is found
1647 if (isset($params['resource_base_path'])) {
1648 $_resource_base_path = (array)$params['resource_base_path'];
1650 $_resource_base_path = (array)$this->template_dir
;
1651 $_resource_base_path[] = '.';
1653 foreach ($_resource_base_path as $_curr_path) {
1654 $_fullpath = $_curr_path . DIRECTORY_SEPARATOR
. $params['resource_name'];
1655 if (file_exists($_fullpath) && is_file($_fullpath)) {
1656 $params['resource_name'] = $_fullpath;
1659 // didn't find the file, try include_path
1660 $_params = array('file_path' => $_fullpath);
1661 require_once(SMARTY_DIR
. 'core' . DIRECTORY_SEPARATOR
. 'core.get_include_path.php');
1662 if(smarty_core_get_include_path($_params, $this)) {
1663 $params['resource_name'] = $_params['new_file_path'];
1669 } elseif (empty($this->_plugins
['resource'][$params['resource_type']])) {
1670 $_params = array('type' => $params['resource_type']);
1671 require_once(SMARTY_DIR
. 'core' . DIRECTORY_SEPARATOR
. 'core.load_resource_plugin.php');
1672 smarty_core_load_resource_plugin($_params, $this);
1682 * @param string|null $modifier_name
1683 * @param array|null $map_array
1684 * @return string result of modifiers
1686 function _run_mod_handler()
1688 $_args = func_get_args();
1689 list($_modifier_name, $_map_array) = array_splice($_args, 0, 2);
1690 list($_func_name, $_tpl_file, $_tpl_line) =
1691 $this->_plugins
['modifier'][$_modifier_name];
1694 foreach ($_var as $_key => $_val) {
1696 $_var[$_key] = call_user_func_array($_func_name, $_args);
1702 * Remove starting and ending quotes from the string
1704 * @param string $string
1707 function _dequote($string)
1709 if (($string{0} == "'" ||
$string{0} == '"') &&
1710 $string{strlen($string)-1} == $string{0})
1711 return substr($string, 1, -1);
1718 * read in a file from line $start for $lines.
1719 * read the entire file if $start and $lines are null.
1721 * @param string $filename
1722 * @param integer $start
1723 * @param integer $lines
1726 function _read_file($filename, $start=null, $lines=null)
1728 if (!($fd = @fopen
($filename, 'r'))) {
1731 flock($fd, LOCK_SH
);
1732 if ($start == null && $lines == null) {
1733 // read the entire file
1734 $contents = fread($fd, filesize($filename));
1737 // skip the first lines before $start
1738 for ($loop=1; $loop < $start; $loop++
) {
1742 if ( $lines == null ) {
1743 // read the rest of the file
1744 while (!feof($fd)) {
1745 $contents .= fgets($fd, 65536);
1748 // read up to $lines lines
1749 for ($loop=0; $loop < $lines; $loop++
) {
1750 $contents .= fgets($fd, 65536);
1762 * get a concrete filename for automagically created content
1764 * @param string $auto_base
1765 * @param string $auto_source
1766 * @param string $auto_id
1768 * @staticvar string|null
1769 * @staticvar string|null
1771 function _get_auto_filename($auto_base, $auto_source = null, $auto_id = null)
1773 $_compile_dir_sep = $this->use_sub_dirs ? DIRECTORY_SEPARATOR
: '^';
1775 if(@is_dir
($auto_base)) {
1776 $_return = $auto_base . DIRECTORY_SEPARATOR
;
1778 // auto_base not found, try include_path
1779 $_params = array('file_path' => $auto_base);
1780 require_once(SMARTY_DIR
. 'core' . DIRECTORY_SEPARATOR
. 'core.get_include_path.php');
1781 smarty_core_get_include_path($_params, $this);
1782 $_return = isset($_params['new_file_path']) ?
$_params['new_file_path'] . DIRECTORY_SEPARATOR
: null;
1785 if(isset($auto_id)) {
1786 // make auto_id safe for directory names
1787 $auto_id = str_replace('%7C',$_compile_dir_sep,(urlencode($auto_id)));
1788 // split into separate directories
1789 $_return .= $auto_id . $_compile_dir_sep;
1792 if(isset($auto_source)) {
1793 // make source name safe for filename
1794 $_filename = urlencode(basename($auto_source));
1795 $_crc32 = crc32($auto_source) . $_compile_dir_sep;
1796 // prepend %% to avoid name conflicts with
1797 // with $params['auto_id'] names
1798 $_crc32 = '%%' . substr($_crc32,0,3) . $_compile_dir_sep . '%%' . $_crc32;
1799 $_return .= $_crc32 . $_filename;
1806 * unlink a file, possibly using expiration time
1808 * @param string $resource
1809 * @param integer $exp_time
1811 function _unlink($resource, $exp_time = null)
1813 if(isset($exp_time)) {
1814 if(time() - @filemtime
($resource) >= $exp_time) {
1815 return @unlink
($resource);
1818 return @unlink
($resource);
1823 * returns an auto_id for auto-file-functions
1825 * @param string $cache_id
1826 * @param string $compile_id
1827 * @return string|null
1829 function _get_auto_id($cache_id=null, $compile_id=null) {
1830 if (isset($cache_id))
1831 return (isset($compile_id)) ?
$cache_id . '|' . $compile_id : $cache_id;
1832 elseif(isset($compile_id))
1839 * trigger Smarty plugin error
1841 * @param string $error_msg
1842 * @param string $tpl_file
1843 * @param integer $tpl_line
1844 * @param string $file
1845 * @param integer $line
1846 * @param integer $error_type
1848 function _trigger_fatal_error($error_msg, $tpl_file = null, $tpl_line = null,
1849 $file = null, $line = null, $error_type = E_USER_ERROR
)
1851 if(isset($file) && isset($line)) {
1852 $info = ' ('.basename($file).", line $line)";
1856 if (isset($tpl_line) && isset($tpl_file)) {
1857 $this->trigger_error('[in ' . $tpl_file . ' line ' . $tpl_line . "]: $error_msg$info", $error_type);
1859 $this->trigger_error($error_msg . $info, $error_type);
1865 * callback function for preg_replace, to call a non-cacheable block
1868 function _process_compiled_include_callback($match) {
1869 $_func = '_smarty_tplfunc_'.$match[2].'_'.$match[3];
1872 $_ret = ob_get_contents();
1879 * called for included templates
1881 * @param string $_smarty_include_tpl_file
1882 * @param string $_smarty_include_vars
1885 // $_smarty_include_tpl_file, $_smarty_include_vars
1887 function _smarty_include($params)
1889 if ($this->debugging
) {
1891 require_once(SMARTY_DIR
. 'core' . DIRECTORY_SEPARATOR
. 'core.get_microtime.php');
1892 $debug_start_time = smarty_core_get_microtime($_params, $this);
1893 $this->_smarty_debug_info
[] = array('type' => 'template',
1894 'filename' => $params['smarty_include_tpl_file'],
1895 'depth' => ++
$this->_inclusion_depth
);
1896 $included_tpls_idx = count($this->_smarty_debug_info
) - 1;
1899 $this->_tpl_vars
= array_merge($this->_tpl_vars
, $params['smarty_include_vars']);
1901 // config vars are treated as local, so push a copy of the
1902 // current ones onto the front of the stack
1903 array_unshift($this->_config
, $this->_config
[0]);
1905 $_smarty_compile_path = $this->_get_compile_path($params['smarty_include_tpl_file']);
1908 if ($this->_is_compiled($params['smarty_include_tpl_file'], $_smarty_compile_path)
1909 ||
$this->_compile_resource($params['smarty_include_tpl_file'], $_smarty_compile_path))
1911 include($_smarty_compile_path);
1914 // pop the local vars off the front of the stack
1915 array_shift($this->_config
);
1917 $this->_inclusion_depth
--;
1919 if ($this->debugging
) {
1920 // capture time for debugging info
1922 require_once(SMARTY_DIR
. 'core' . DIRECTORY_SEPARATOR
. 'core.get_microtime.php');
1923 $this->_smarty_debug_info
[$included_tpls_idx]['exec_time'] = smarty_core_get_microtime($_params, $this) - $debug_start_time;
1926 if ($this->caching
) {
1927 $this->_cache_info
['template'][$params['smarty_include_tpl_file']] = true;
1933 * get or set an array of cached attributes for function that is
1937 function &_smarty_cache_attrs($cache_serial, $count) {
1938 $_cache_attrs =& $this->_cache_info
['cache_attrs'][$cache_serial][$count];
1940 if ($this->_cache_including
) {
1941 /* return next set of cache_attrs */
1942 $_return =& current($_cache_attrs);
1943 next($_cache_attrs);
1947 /* add a reference to a new set of cache_attrs */
1948 $_cache_attrs[] = array();
1949 return $_cache_attrs[count($_cache_attrs)-1];
1957 * wrapper for include() retaining $this
1960 function _include($filename, $once=false, $params=null)
1963 return include_once($filename);
1965 return include($filename);
1971 * wrapper for eval() retaining $this
1974 function _eval($code, $params=null)
1982 /* vim: set expandtab: */