PageRenderTime 56ms CodeModel.GetById 19ms RepoModel.GetById 0ms app.codeStats 1ms

/application/smarty/Smarty.class.php

https://bitbucket.org/Libertus/food-journal
PHP | 1960 lines | 1056 code | 177 blank | 727 comment | 136 complexity | 01f2ff17fbf1075b88e1d733f2b67101 MD5 | raw file

Large files files are truncated, but you can click here to view the full file

  1. <?php
  2. /**
  3. * Project: Smarty: the PHP compiling template engine
  4. * File: Smarty.class.php
  5. *
  6. * This library is free software; you can redistribute it and/or
  7. * modify it under the terms of the GNU Lesser General Public
  8. * License as published by the Free Software Foundation; either
  9. * version 2.1 of the License, or (at your option) any later version.
  10. *
  11. * This library is distributed in the hope that it will be useful,
  12. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  13. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  14. * Lesser General Public License for more details.
  15. *
  16. * You should have received a copy of the GNU Lesser General Public
  17. * License along with this library; if not, write to the Free Software
  18. * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
  19. *
  20. * For questions, help, comments, discussion, etc., please join the
  21. * Smarty mailing list. Send a blank e-mail to
  22. * smarty-general-subscribe@lists.php.net
  23. *
  24. * @link http://smarty.php.net/
  25. * @copyright 2001-2005 New Digital Group, Inc.
  26. * @author Monte Ohrt <monte at ohrt dot com>
  27. * @author Andrei Zmievski <andrei@php.net>
  28. * @package Smarty
  29. * @version 2.6.19
  30. */
  31. /* $Id: Smarty.class.php 2722 2007-06-18 14:29:00Z danilo $ */
  32. /**
  33. * DIR_SEP isn't used anymore, but third party apps might
  34. */
  35. if(!defined('DIR_SEP')) {
  36. define('DIR_SEP', DIRECTORY_SEPARATOR);
  37. }
  38. /**
  39. * set SMARTY_DIR to absolute path to Smarty library files.
  40. * if not defined, include_path will be used. Sets SMARTY_DIR only if user
  41. * application has not already defined it.
  42. */
  43. if (!defined('SMARTY_DIR')) {
  44. define('SMARTY_DIR', dirname(__FILE__) . DIRECTORY_SEPARATOR);
  45. }
  46. if (!defined('SMARTY_CORE_DIR')) {
  47. define('SMARTY_CORE_DIR', SMARTY_DIR . 'internals' . DIRECTORY_SEPARATOR);
  48. }
  49. define('SMARTY_PHP_PASSTHRU', 0);
  50. define('SMARTY_PHP_QUOTE', 1);
  51. define('SMARTY_PHP_REMOVE', 2);
  52. define('SMARTY_PHP_ALLOW', 3);
  53. /**
  54. * @package Smarty
  55. */
  56. class Smarty
  57. {
  58. /**#@+
  59. * Smarty Configuration Section
  60. */
  61. /**
  62. * The name of the directory where templates are located.
  63. *
  64. * @var string
  65. */
  66. var $template_dir = 'templates';
  67. /**
  68. * The directory where compiled templates are located.
  69. *
  70. * @var string
  71. */
  72. var $compile_dir = 'templates_c';
  73. /**
  74. * The directory where config files are located.
  75. *
  76. * @var string
  77. */
  78. var $config_dir = 'configs';
  79. /**
  80. * An array of directories searched for plugins.
  81. *
  82. * @var array
  83. */
  84. var $plugins_dir = array('plugins');
  85. /**
  86. * If debugging is enabled, a debug console window will display
  87. * when the page loads (make sure your browser allows unrequested
  88. * popup windows)
  89. *
  90. * @var boolean
  91. */
  92. var $debugging = false;
  93. /**
  94. * When set, smarty does uses this value as error_reporting-level.
  95. *
  96. * @var boolean
  97. */
  98. var $error_reporting = null;
  99. /**
  100. * This is the path to the debug console template. If not set,
  101. * the default one will be used.
  102. *
  103. * @var string
  104. */
  105. var $debug_tpl = '';
  106. /**
  107. * This determines if debugging is enable-able from the browser.
  108. * <ul>
  109. * <li>NONE => no debugging control allowed</li>
  110. * <li>URL => enable debugging when SMARTY_DEBUG is found in the URL.</li>
  111. * </ul>
  112. * @link http://www.foo.dom/index.php?SMARTY_DEBUG
  113. * @var string
  114. */
  115. var $debugging_ctrl = 'NONE';
  116. /**
  117. * This tells Smarty whether to check for recompiling or not. Recompiling
  118. * does not need to happen unless a template or config file is changed.
  119. * Typically you enable this during development, and disable for
  120. * production.
  121. *
  122. * @var boolean
  123. */
  124. var $compile_check = true;
  125. /**
  126. * This forces templates to compile every time. Useful for development
  127. * or debugging.
  128. *
  129. * @var boolean
  130. */
  131. var $force_compile = false;
  132. /**
  133. * This enables template caching.
  134. * <ul>
  135. * <li>0 = no caching</li>
  136. * <li>1 = use class cache_lifetime value</li>
  137. * <li>2 = use cache_lifetime in cache file</li>
  138. * </ul>
  139. * @var integer
  140. */
  141. var $caching = 0;
  142. /**
  143. * The name of the directory for cache files.
  144. *
  145. * @var string
  146. */
  147. var $cache_dir = 'cache';
  148. /**
  149. * This is the number of seconds cached content will persist.
  150. * <ul>
  151. * <li>0 = always regenerate cache</li>
  152. * <li>-1 = never expires</li>
  153. * </ul>
  154. *
  155. * @var integer
  156. */
  157. var $cache_lifetime = 3600;
  158. /**
  159. * Only used when $caching is enabled. If true, then If-Modified-Since headers
  160. * are respected with cached content, and appropriate HTTP headers are sent.
  161. * This way repeated hits to a cached page do not send the entire page to the
  162. * client every time.
  163. *
  164. * @var boolean
  165. */
  166. var $cache_modified_check = false;
  167. /**
  168. * This determines how Smarty handles "<?php ... ?>" tags in templates.
  169. * possible values:
  170. * <ul>
  171. * <li>SMARTY_PHP_PASSTHRU -> print tags as plain text</li>
  172. * <li>SMARTY_PHP_QUOTE -> escape tags as entities</li>
  173. * <li>SMARTY_PHP_REMOVE -> remove php tags</li>
  174. * <li>SMARTY_PHP_ALLOW -> execute php tags</li>
  175. * </ul>
  176. *
  177. * @var integer
  178. */
  179. var $php_handling = SMARTY_PHP_PASSTHRU;
  180. /**
  181. * This enables template security. When enabled, many things are restricted
  182. * in the templates that normally would go unchecked. This is useful when
  183. * untrusted parties are editing templates and you want a reasonable level
  184. * of security. (no direct execution of PHP in templates for example)
  185. *
  186. * @var boolean
  187. */
  188. var $security = false;
  189. /**
  190. * This is the list of template directories that are considered secure. This
  191. * is used only if {@link $security} is enabled. One directory per array
  192. * element. {@link $template_dir} is in this list implicitly.
  193. *
  194. * @var array
  195. */
  196. var $secure_dir = array();
  197. /**
  198. * These are the security settings for Smarty. They are used only when
  199. * {@link $security} is enabled.
  200. *
  201. * @var array
  202. */
  203. var $security_settings = array(
  204. 'PHP_HANDLING' => false,
  205. 'IF_FUNCS' => array('array', 'list',
  206. 'isset', 'empty',
  207. 'count', 'sizeof',
  208. 'in_array', 'is_array',
  209. 'true', 'false', 'null'),
  210. 'INCLUDE_ANY' => false,
  211. 'PHP_TAGS' => false,
  212. 'MODIFIER_FUNCS' => array('count'),
  213. 'ALLOW_CONSTANTS' => false
  214. );
  215. /**
  216. * This is an array of directories where trusted php scripts reside.
  217. * {@link $security} is disabled during their inclusion/execution.
  218. *
  219. * @var array
  220. */
  221. var $trusted_dir = array();
  222. /**
  223. * The left delimiter used for the template tags.
  224. *
  225. * @var string
  226. */
  227. var $left_delimiter = '{';
  228. /**
  229. * The right delimiter used for the template tags.
  230. *
  231. * @var string
  232. */
  233. var $right_delimiter = '}';
  234. /**
  235. * The order in which request variables are registered, similar to
  236. * variables_order in php.ini E = Environment, G = GET, P = POST,
  237. * C = Cookies, S = Server
  238. *
  239. * @var string
  240. */
  241. var $request_vars_order = 'EGPCS';
  242. /**
  243. * Indicates wether $HTTP_*_VARS[] (request_use_auto_globals=false)
  244. * are uses as request-vars or $_*[]-vars. note: if
  245. * request_use_auto_globals is true, then $request_vars_order has
  246. * no effect, but the php-ini-value "gpc_order"
  247. *
  248. * @var boolean
  249. */
  250. var $request_use_auto_globals = true;
  251. /**
  252. * Set this if you want different sets of compiled files for the same
  253. * templates. This is useful for things like different languages.
  254. * Instead of creating separate sets of templates per language, you
  255. * set different compile_ids like 'en' and 'de'.
  256. *
  257. * @var string
  258. */
  259. var $compile_id = null;
  260. /**
  261. * This tells Smarty whether or not to use sub dirs in the cache/ and
  262. * templates_c/ directories. sub directories better organized, but
  263. * may not work well with PHP safe mode enabled.
  264. *
  265. * @var boolean
  266. *
  267. */
  268. var $use_sub_dirs = false;
  269. /**
  270. * This is a list of the modifiers to apply to all template variables.
  271. * Put each modifier in a separate array element in the order you want
  272. * them applied. example: <code>array('escape:"htmlall"');</code>
  273. *
  274. * @var array
  275. */
  276. var $default_modifiers = array();
  277. /**
  278. * This is the resource type to be used when not specified
  279. * at the beginning of the resource path. examples:
  280. * $smarty->display('file:index.tpl');
  281. * $smarty->display('db:index.tpl');
  282. * $smarty->display('index.tpl'); // will use default resource type
  283. * {include file="file:index.tpl"}
  284. * {include file="db:index.tpl"}
  285. * {include file="index.tpl"} {* will use default resource type *}
  286. *
  287. * @var array
  288. */
  289. var $default_resource_type = 'file';
  290. /**
  291. * The function used for cache file handling. If not set, built-in caching is used.
  292. *
  293. * @var null|string function name
  294. */
  295. var $cache_handler_func = null;
  296. /**
  297. * This indicates which filters are automatically loaded into Smarty.
  298. *
  299. * @var array array of filter names
  300. */
  301. var $autoload_filters = array();
  302. /**#@+
  303. * @var boolean
  304. */
  305. /**
  306. * This tells if config file vars of the same name overwrite each other or not.
  307. * if disabled, same name variables are accumulated in an array.
  308. */
  309. var $config_overwrite = true;
  310. /**
  311. * This tells whether or not to automatically booleanize config file variables.
  312. * If enabled, then the strings "on", "true", and "yes" are treated as boolean
  313. * true, and "off", "false" and "no" are treated as boolean false.
  314. */
  315. var $config_booleanize = true;
  316. /**
  317. * This tells whether hidden sections [.foobar] are readable from the
  318. * tempalates or not. Normally you would never allow this since that is
  319. * the point behind hidden sections: the application can access them, but
  320. * the templates cannot.
  321. */
  322. var $config_read_hidden = false;
  323. /**
  324. * This tells whether or not automatically fix newlines in config files.
  325. * It basically converts \r (mac) or \r\n (dos) to \n
  326. */
  327. var $config_fix_newlines = true;
  328. /**#@-*/
  329. /**
  330. * If a template cannot be found, this PHP function will be executed.
  331. * Useful for creating templates on-the-fly or other special action.
  332. *
  333. * @var string function name
  334. */
  335. var $default_template_handler_func = '';
  336. /**
  337. * The file that contains the compiler class. This can a full
  338. * pathname, or relative to the php_include path.
  339. *
  340. * @var string
  341. */
  342. var $compiler_file = 'Smarty_Compiler.class.php';
  343. /**
  344. * The class used for compiling templates.
  345. *
  346. * @var string
  347. */
  348. var $compiler_class = 'Smarty_Compiler';
  349. /**
  350. * The class used to load config vars.
  351. *
  352. * @var string
  353. */
  354. var $config_class = 'Config_File';
  355. /**#@+
  356. * END Smarty Configuration Section
  357. * There should be no need to touch anything below this line.
  358. * @access private
  359. */
  360. /**
  361. * where assigned template vars are kept
  362. *
  363. * @var array
  364. */
  365. var $_tpl_vars = array();
  366. /**
  367. * stores run-time $smarty.* vars
  368. *
  369. * @var null|array
  370. */
  371. var $_smarty_vars = null;
  372. /**
  373. * keeps track of sections
  374. *
  375. * @var array
  376. */
  377. var $_sections = array();
  378. /**
  379. * keeps track of foreach blocks
  380. *
  381. * @var array
  382. */
  383. var $_foreach = array();
  384. /**
  385. * keeps track of tag hierarchy
  386. *
  387. * @var array
  388. */
  389. var $_tag_stack = array();
  390. /**
  391. * configuration object
  392. *
  393. * @var Config_file
  394. */
  395. var $_conf_obj = null;
  396. /**
  397. * loaded configuration settings
  398. *
  399. * @var array
  400. */
  401. var $_config = array(array('vars' => array(), 'files' => array()));
  402. /**
  403. * md5 checksum of the string 'Smarty'
  404. *
  405. * @var string
  406. */
  407. var $_smarty_md5 = 'f8d698aea36fcbead2b9d5359ffca76f';
  408. /**
  409. * Smarty version number
  410. *
  411. * @var string
  412. */
  413. var $_version = '2.6.19';
  414. /**
  415. * current template inclusion depth
  416. *
  417. * @var integer
  418. */
  419. var $_inclusion_depth = 0;
  420. /**
  421. * for different compiled templates
  422. *
  423. * @var string
  424. */
  425. var $_compile_id = null;
  426. /**
  427. * text in URL to enable debug mode
  428. *
  429. * @var string
  430. */
  431. var $_smarty_debug_id = 'SMARTY_DEBUG';
  432. /**
  433. * debugging information for debug console
  434. *
  435. * @var array
  436. */
  437. var $_smarty_debug_info = array();
  438. /**
  439. * info that makes up a cache file
  440. *
  441. * @var array
  442. */
  443. var $_cache_info = array();
  444. /**
  445. * default file permissions
  446. *
  447. * @var integer
  448. */
  449. var $_file_perms = 0644;
  450. /**
  451. * default dir permissions
  452. *
  453. * @var integer
  454. */
  455. var $_dir_perms = 0771;
  456. /**
  457. * registered objects
  458. *
  459. * @var array
  460. */
  461. var $_reg_objects = array();
  462. /**
  463. * table keeping track of plugins
  464. *
  465. * @var array
  466. */
  467. var $_plugins = array(
  468. 'modifier' => array(),
  469. 'function' => array(),
  470. 'block' => array(),
  471. 'compiler' => array(),
  472. 'prefilter' => array(),
  473. 'postfilter' => array(),
  474. 'outputfilter' => array(),
  475. 'resource' => array(),
  476. 'insert' => array());
  477. /**
  478. * cache serials
  479. *
  480. * @var array
  481. */
  482. var $_cache_serials = array();
  483. /**
  484. * name of optional cache include file
  485. *
  486. * @var string
  487. */
  488. var $_cache_include = null;
  489. /**
  490. * indicate if the current code is used in a compiled
  491. * include
  492. *
  493. * @var string
  494. */
  495. var $_cache_including = false;
  496. /**#@-*/
  497. /**
  498. * The class constructor.
  499. */
  500. function Smarty()
  501. {
  502. $this->assign('SCRIPT_NAME', isset($_SERVER['SCRIPT_NAME']) ? $_SERVER['SCRIPT_NAME']
  503. : @$GLOBALS['HTTP_SERVER_VARS']['SCRIPT_NAME']);
  504. }
  505. /**
  506. * assigns values to template variables
  507. *
  508. * @param array|string $tpl_var the template variable name(s)
  509. * @param mixed $value the value to assign
  510. */
  511. function assign($tpl_var, $value = null)
  512. {
  513. if (is_array($tpl_var)){
  514. foreach ($tpl_var as $key => $val) {
  515. if ($key != '') {
  516. $this->_tpl_vars[$key] = $val;
  517. }
  518. }
  519. } else {
  520. if ($tpl_var != '')
  521. $this->_tpl_vars[$tpl_var] = $value;
  522. }
  523. }
  524. /**
  525. * assigns values to template variables by reference
  526. *
  527. * @param string $tpl_var the template variable name
  528. * @param mixed $value the referenced value to assign
  529. */
  530. function assign_by_ref($tpl_var, &$value)
  531. {
  532. if ($tpl_var != '')
  533. $this->_tpl_vars[$tpl_var] = &$value;
  534. }
  535. /**
  536. * appends values to template variables
  537. *
  538. * @param array|string $tpl_var the template variable name(s)
  539. * @param mixed $value the value to append
  540. */
  541. function append($tpl_var, $value=null, $merge=false)
  542. {
  543. if (is_array($tpl_var)) {
  544. // $tpl_var is an array, ignore $value
  545. foreach ($tpl_var as $_key => $_val) {
  546. if ($_key != '') {
  547. if(!@is_array($this->_tpl_vars[$_key])) {
  548. settype($this->_tpl_vars[$_key],'array');
  549. }
  550. if($merge && is_array($_val)) {
  551. foreach($_val as $_mkey => $_mval) {
  552. $this->_tpl_vars[$_key][$_mkey] = $_mval;
  553. }
  554. } else {
  555. $this->_tpl_vars[$_key][] = $_val;
  556. }
  557. }
  558. }
  559. } else {
  560. if ($tpl_var != '' && isset($value)) {
  561. if(!@is_array($this->_tpl_vars[$tpl_var])) {
  562. settype($this->_tpl_vars[$tpl_var],'array');
  563. }
  564. if($merge && is_array($value)) {
  565. foreach($value as $_mkey => $_mval) {
  566. $this->_tpl_vars[$tpl_var][$_mkey] = $_mval;
  567. }
  568. } else {
  569. $this->_tpl_vars[$tpl_var][] = $value;
  570. }
  571. }
  572. }
  573. }
  574. /**
  575. * appends values to template variables by reference
  576. *
  577. * @param string $tpl_var the template variable name
  578. * @param mixed $value the referenced value to append
  579. */
  580. function append_by_ref($tpl_var, &$value, $merge=false)
  581. {
  582. if ($tpl_var != '' && isset($value)) {
  583. if(!@is_array($this->_tpl_vars[$tpl_var])) {
  584. settype($this->_tpl_vars[$tpl_var],'array');
  585. }
  586. if ($merge && is_array($value)) {
  587. foreach($value as $_key => $_val) {
  588. $this->_tpl_vars[$tpl_var][$_key] = &$value[$_key];
  589. }
  590. } else {
  591. $this->_tpl_vars[$tpl_var][] = &$value;
  592. }
  593. }
  594. }
  595. /**
  596. * clear the given assigned template variable.
  597. *
  598. * @param string $tpl_var the template variable to clear
  599. */
  600. function clear_assign($tpl_var)
  601. {
  602. if (is_array($tpl_var))
  603. foreach ($tpl_var as $curr_var)
  604. unset($this->_tpl_vars[$curr_var]);
  605. else
  606. unset($this->_tpl_vars[$tpl_var]);
  607. }
  608. /**
  609. * Registers custom function to be used in templates
  610. *
  611. * @param string $function the name of the template function
  612. * @param string $function_impl the name of the PHP function to register
  613. */
  614. function register_function($function, $function_impl, $cacheable=true, $cache_attrs=null)
  615. {
  616. $this->_plugins['function'][$function] =
  617. array($function_impl, null, null, false, $cacheable, $cache_attrs);
  618. }
  619. /**
  620. * Unregisters custom function
  621. *
  622. * @param string $function name of template function
  623. */
  624. function unregister_function($function)
  625. {
  626. unset($this->_plugins['function'][$function]);
  627. }
  628. /**
  629. * Registers object to be used in templates
  630. *
  631. * @param string $object name of template object
  632. * @param object &$object_impl the referenced PHP object to register
  633. * @param null|array $allowed list of allowed methods (empty = all)
  634. * @param boolean $smarty_args smarty argument format, else traditional
  635. * @param null|array $block_functs list of methods that are block format
  636. */
  637. function register_object($object, &$object_impl, $allowed = array(), $smarty_args = true, $block_methods = array())
  638. {
  639. settype($allowed, 'array');
  640. settype($smarty_args, 'boolean');
  641. $this->_reg_objects[$object] =
  642. array(&$object_impl, $allowed, $smarty_args, $block_methods);
  643. }
  644. /**
  645. * Unregisters object
  646. *
  647. * @param string $object name of template object
  648. */
  649. function unregister_object($object)
  650. {
  651. unset($this->_reg_objects[$object]);
  652. }
  653. /**
  654. * Registers block function to be used in templates
  655. *
  656. * @param string $block name of template block
  657. * @param string $block_impl PHP function to register
  658. */
  659. function register_block($block, $block_impl, $cacheable=true, $cache_attrs=null)
  660. {
  661. $this->_plugins['block'][$block] =
  662. array($block_impl, null, null, false, $cacheable, $cache_attrs);
  663. }
  664. /**
  665. * Unregisters block function
  666. *
  667. * @param string $block name of template function
  668. */
  669. function unregister_block($block)
  670. {
  671. unset($this->_plugins['block'][$block]);
  672. }
  673. /**
  674. * Registers compiler function
  675. *
  676. * @param string $function name of template function
  677. * @param string $function_impl name of PHP function to register
  678. */
  679. function register_compiler_function($function, $function_impl, $cacheable=true)
  680. {
  681. $this->_plugins['compiler'][$function] =
  682. array($function_impl, null, null, false, $cacheable);
  683. }
  684. /**
  685. * Unregisters compiler function
  686. *
  687. * @param string $function name of template function
  688. */
  689. function unregister_compiler_function($function)
  690. {
  691. unset($this->_plugins['compiler'][$function]);
  692. }
  693. /**
  694. * Registers modifier to be used in templates
  695. *
  696. * @param string $modifier name of template modifier
  697. * @param string $modifier_impl name of PHP function to register
  698. */
  699. function register_modifier($modifier, $modifier_impl)
  700. {
  701. $this->_plugins['modifier'][$modifier] =
  702. array($modifier_impl, null, null, false);
  703. }
  704. /**
  705. * Unregisters modifier
  706. *
  707. * @param string $modifier name of template modifier
  708. */
  709. function unregister_modifier($modifier)
  710. {
  711. unset($this->_plugins['modifier'][$modifier]);
  712. }
  713. /**
  714. * Registers a resource to fetch a template
  715. *
  716. * @param string $type name of resource
  717. * @param array $functions array of functions to handle resource
  718. */
  719. function register_resource($type, $functions)
  720. {
  721. if (count($functions)==4) {
  722. $this->_plugins['resource'][$type] =
  723. array($functions, false);
  724. } elseif (count($functions)==5) {
  725. $this->_plugins['resource'][$type] =
  726. array(array(array(&$functions[0], $functions[1])
  727. ,array(&$functions[0], $functions[2])
  728. ,array(&$functions[0], $functions[3])
  729. ,array(&$functions[0], $functions[4]))
  730. ,false);
  731. } else {
  732. $this->trigger_error("malformed function-list for '$type' in register_resource");
  733. }
  734. }
  735. /**
  736. * Unregisters a resource
  737. *
  738. * @param string $type name of resource
  739. */
  740. function unregister_resource($type)
  741. {
  742. unset($this->_plugins['resource'][$type]);
  743. }
  744. /**
  745. * Registers a prefilter function to apply
  746. * to a template before compiling
  747. *
  748. * @param callback $function
  749. */
  750. function register_prefilter($function)
  751. {
  752. $this->_plugins['prefilter'][$this->_get_filter_name($function)]
  753. = array($function, null, null, false);
  754. }
  755. /**
  756. * Unregisters a prefilter function
  757. *
  758. * @param callback $function
  759. */
  760. function unregister_prefilter($function)
  761. {
  762. unset($this->_plugins['prefilter'][$this->_get_filter_name($function)]);
  763. }
  764. /**
  765. * Registers a postfilter function to apply
  766. * to a compiled template after compilation
  767. *
  768. * @param callback $function
  769. */
  770. function register_postfilter($function)
  771. {
  772. $this->_plugins['postfilter'][$this->_get_filter_name($function)]
  773. = array($function, null, null, false);
  774. }
  775. /**
  776. * Unregisters a postfilter function
  777. *
  778. * @param callback $function
  779. */
  780. function unregister_postfilter($function)
  781. {
  782. unset($this->_plugins['postfilter'][$this->_get_filter_name($function)]);
  783. }
  784. /**
  785. * Registers an output filter function to apply
  786. * to a template output
  787. *
  788. * @param callback $function
  789. */
  790. function register_outputfilter($function)
  791. {
  792. $this->_plugins['outputfilter'][$this->_get_filter_name($function)]
  793. = array($function, null, null, false);
  794. }
  795. /**
  796. * Unregisters an outputfilter function
  797. *
  798. * @param callback $function
  799. */
  800. function unregister_outputfilter($function)
  801. {
  802. unset($this->_plugins['outputfilter'][$this->_get_filter_name($function)]);
  803. }
  804. /**
  805. * load a filter of specified type and name
  806. *
  807. * @param string $type filter type
  808. * @param string $name filter name
  809. */
  810. function load_filter($type, $name)
  811. {
  812. switch ($type) {
  813. case 'output':
  814. $_params = array('plugins' => array(array($type . 'filter', $name, null, null, false)));
  815. require_once(SMARTY_CORE_DIR . 'core.load_plugins.php');
  816. smarty_core_load_plugins($_params, $this);
  817. break;
  818. case 'pre':
  819. case 'post':
  820. if (!isset($this->_plugins[$type . 'filter'][$name]))
  821. $this->_plugins[$type . 'filter'][$name] = false;
  822. break;
  823. }
  824. }
  825. /**
  826. * clear cached content for the given template and cache id
  827. *
  828. * @param string $tpl_file name of template file
  829. * @param string $cache_id name of cache_id
  830. * @param string $compile_id name of compile_id
  831. * @param string $exp_time expiration time
  832. * @return boolean
  833. */
  834. function clear_cache($tpl_file = null, $cache_id = null, $compile_id = null, $exp_time = null)
  835. {
  836. if (!isset($compile_id))
  837. $compile_id = $this->compile_id;
  838. if (!isset($tpl_file))
  839. $compile_id = null;
  840. $_auto_id = $this->_get_auto_id($cache_id, $compile_id);
  841. if (!empty($this->cache_handler_func)) {
  842. return call_user_func_array($this->cache_handler_func,
  843. array('clear', &$this, &$dummy, $tpl_file, $cache_id, $compile_id, $exp_time));
  844. } else {
  845. $_params = array('auto_base' => $this->cache_dir,
  846. 'auto_source' => $tpl_file,
  847. 'auto_id' => $_auto_id,
  848. 'exp_time' => $exp_time);
  849. require_once(SMARTY_CORE_DIR . 'core.rm_auto.php');
  850. return smarty_core_rm_auto($_params, $this);
  851. }
  852. }
  853. /**
  854. * clear the entire contents of cache (all templates)
  855. *
  856. * @param string $exp_time expire time
  857. * @return boolean results of {@link smarty_core_rm_auto()}
  858. */
  859. function clear_all_cache($exp_time = null)
  860. {
  861. return $this->clear_cache(null, null, null, $exp_time);
  862. }
  863. /**
  864. * test to see if valid cache exists for this template
  865. *
  866. * @param string $tpl_file name of template file
  867. * @param string $cache_id
  868. * @param string $compile_id
  869. * @return string|false results of {@link _read_cache_file()}
  870. */
  871. function is_cached($tpl_file, $cache_id = null, $compile_id = null)
  872. {
  873. if (!$this->caching)
  874. return false;
  875. if (!isset($compile_id))
  876. $compile_id = $this->compile_id;
  877. $_params = array(
  878. 'tpl_file' => $tpl_file,
  879. 'cache_id' => $cache_id,
  880. 'compile_id' => $compile_id
  881. );
  882. require_once(SMARTY_CORE_DIR . 'core.read_cache_file.php');
  883. return smarty_core_read_cache_file($_params, $this);
  884. }
  885. /**
  886. * clear all the assigned template variables.
  887. *
  888. */
  889. function clear_all_assign()
  890. {
  891. $this->_tpl_vars = array();
  892. }
  893. /**
  894. * clears compiled version of specified template resource,
  895. * or all compiled template files if one is not specified.
  896. * This function is for advanced use only, not normally needed.
  897. *
  898. * @param string $tpl_file
  899. * @param string $compile_id
  900. * @param string $exp_time
  901. * @return boolean results of {@link smarty_core_rm_auto()}
  902. */
  903. function clear_compiled_tpl($tpl_file = null, $compile_id = null, $exp_time = null)
  904. {
  905. if (!isset($compile_id)) {
  906. $compile_id = $this->compile_id;
  907. }
  908. $_params = array('auto_base' => $this->compile_dir,
  909. 'auto_source' => $tpl_file,
  910. 'auto_id' => $compile_id,
  911. 'exp_time' => $exp_time,
  912. 'extensions' => array('.inc', '.php'));
  913. require_once(SMARTY_CORE_DIR . 'core.rm_auto.php');
  914. return smarty_core_rm_auto($_params, $this);
  915. }
  916. /**
  917. * Checks whether requested template exists.
  918. *
  919. * @param string $tpl_file
  920. * @return boolean
  921. */
  922. function template_exists($tpl_file)
  923. {
  924. $_params = array('resource_name' => $tpl_file, 'quiet'=>true, 'get_source'=>false);
  925. return $this->_fetch_resource_info($_params);
  926. }
  927. /**
  928. * Returns an array containing template variables
  929. *
  930. * @param string $name
  931. * @param string $type
  932. * @return array
  933. */
  934. function &get_template_vars($name=null)
  935. {
  936. if(!isset($name)) {
  937. return $this->_tpl_vars;
  938. } elseif(isset($this->_tpl_vars[$name])) {
  939. return $this->_tpl_vars[$name];
  940. } else {
  941. // var non-existant, return valid reference
  942. $_tmp = null;
  943. return $_tmp;
  944. }
  945. }
  946. /**
  947. * Returns an array containing config variables
  948. *
  949. * @param string $name
  950. * @param string $type
  951. * @return array
  952. */
  953. function &get_config_vars($name=null)
  954. {
  955. if(!isset($name) && is_array($this->_config[0])) {
  956. return $this->_config[0]['vars'];
  957. } else if(isset($this->_config[0]['vars'][$name])) {
  958. return $this->_config[0]['vars'][$name];
  959. } else {
  960. // var non-existant, return valid reference
  961. $_tmp = null;
  962. return $_tmp;
  963. }
  964. }
  965. /**
  966. * trigger Smarty error
  967. *
  968. * @param string $error_msg
  969. * @param integer $error_type
  970. */
  971. function trigger_error($error_msg, $error_type = E_USER_WARNING)
  972. {
  973. trigger_error("Smarty error: $error_msg", $error_type);
  974. }
  975. /**
  976. * executes & displays the template results
  977. *
  978. * @param string $resource_name
  979. * @param string $cache_id
  980. * @param string $compile_id
  981. */
  982. function display($resource_name, $cache_id = null, $compile_id = null)
  983. {
  984. $this->fetch($resource_name, $cache_id, $compile_id, true);
  985. }
  986. /**
  987. * executes & returns or displays the template results
  988. *
  989. * @param string $resource_name
  990. * @param string $cache_id
  991. * @param string $compile_id
  992. * @param boolean $display
  993. */
  994. function fetch($resource_name, $cache_id = null, $compile_id = null, $display = false)
  995. {
  996. static $_cache_info = array();
  997. $_smarty_old_error_level = $this->debugging ? error_reporting() : error_reporting(isset($this->error_reporting)
  998. ? $this->error_reporting : error_reporting() & ~E_NOTICE);
  999. if (!$this->debugging && $this->debugging_ctrl == 'URL') {
  1000. $_query_string = $this->request_use_auto_globals ? $_SERVER['QUERY_STRING'] : $GLOBALS['HTTP_SERVER_VARS']['QUERY_STRING'];
  1001. if (@strstr($_query_string, $this->_smarty_debug_id)) {
  1002. if (@strstr($_query_string, $this->_smarty_debug_id . '=on')) {
  1003. // enable debugging for this browser session
  1004. @setcookie('SMARTY_DEBUG', true);
  1005. $this->debugging = true;
  1006. } elseif (@strstr($_query_string, $this->_smarty_debug_id . '=off')) {
  1007. // disable debugging for this browser session
  1008. @setcookie('SMARTY_DEBUG', false);
  1009. $this->debugging = false;
  1010. } else {
  1011. // enable debugging for this page
  1012. $this->debugging = true;
  1013. }
  1014. } else {
  1015. $this->debugging = (bool)($this->request_use_auto_globals ? @$_COOKIE['SMARTY_DEBUG'] : @$GLOBALS['HTTP_COOKIE_VARS']['SMARTY_DEBUG']);
  1016. }
  1017. }
  1018. if ($this->debugging) {
  1019. // capture time for debugging info
  1020. $_params = array();
  1021. require_once(SMARTY_CORE_DIR . 'core.get_microtime.php');
  1022. $_debug_start_time = smarty_core_get_microtime($_params, $this);
  1023. $this->_smarty_debug_info[] = array('type' => 'template',
  1024. 'filename' => $resource_name,
  1025. 'depth' => 0);
  1026. $_included_tpls_idx = count($this->_smarty_debug_info) - 1;
  1027. }
  1028. if (!isset($compile_id)) {
  1029. $compile_id = $this->compile_id;
  1030. }
  1031. $this->_compile_id = $compile_id;
  1032. $this->_inclusion_depth = 0;
  1033. if ($this->caching) {
  1034. // save old cache_info, initialize cache_info
  1035. array_push($_cache_info, $this->_cache_info);
  1036. $this->_cache_info = array();
  1037. $_params = array(
  1038. 'tpl_file' => $resource_name,
  1039. 'cache_id' => $cache_id,
  1040. 'compile_id' => $compile_id,
  1041. 'results' => null
  1042. );
  1043. require_once(SMARTY_CORE_DIR . 'core.read_cache_file.php');
  1044. if (smarty_core_read_cache_file($_params, $this)) {
  1045. $_smarty_results = $_params['results'];
  1046. if (!empty($this->_cache_info['insert_tags'])) {
  1047. $_params = array('plugins' => $this->_cache_info['insert_tags']);
  1048. require_once(SMARTY_CORE_DIR . 'core.load_plugins.php');
  1049. smarty_core_load_plugins($_params, $this);
  1050. $_params = array('results' => $_smarty_results);
  1051. require_once(SMARTY_CORE_DIR . 'core.process_cached_inserts.php');
  1052. $_smarty_results = smarty_core_process_cached_inserts($_params, $this);
  1053. }
  1054. if (!empty($this->_cache_info['cache_serials'])) {
  1055. $_params = array('results' => $_smarty_results);
  1056. require_once(SMARTY_CORE_DIR . 'core.process_compiled_include.php');
  1057. $_smarty_results = smarty_core_process_compiled_include($_params, $this);
  1058. }
  1059. if ($display) {
  1060. if ($this->debugging)
  1061. {
  1062. // capture time for debugging info
  1063. $_params = array();
  1064. require_once(SMARTY_CORE_DIR . 'core.get_microtime.php');
  1065. $this->_smarty_debug_info[$_included_tpls_idx]['exec_time'] = smarty_core_get_microtime($_params, $this) - $_debug_start_time;
  1066. require_once(SMARTY_CORE_DIR . 'core.display_debug_console.php');
  1067. $_smarty_results .= smarty_core_display_debug_console($_params, $this);
  1068. }
  1069. if ($this->cache_modified_check) {
  1070. $_server_vars = ($this->request_use_auto_globals) ? $_SERVER : $GLOBALS['HTTP_SERVER_VARS'];
  1071. $_last_modified_date = @substr($_server_vars['HTTP_IF_MODIFIED_SINCE'], 0, strpos($_server_vars['HTTP_IF_MODIFIED_SINCE'], 'GMT') + 3);
  1072. $_gmt_mtime = gmdate('D, d M Y H:i:s', $this->_cache_info['timestamp']).' GMT';
  1073. if (@count($this->_cache_info['insert_tags']) == 0
  1074. && !$this->_cache_serials
  1075. && $_gmt_mtime == $_last_modified_date) {
  1076. if (php_sapi_name()=='cgi')
  1077. header('Status: 304 Not Modified');
  1078. else
  1079. header('HTTP/1.1 304 Not Modified');
  1080. } else {
  1081. header('Last-Modified: '.$_gmt_mtime);
  1082. echo $_smarty_results;
  1083. }
  1084. } else {
  1085. echo $_smarty_results;
  1086. }
  1087. error_reporting($_smarty_old_error_level);
  1088. // restore initial cache_info
  1089. $this->_cache_info = array_pop($_cache_info);
  1090. return true;
  1091. } else {
  1092. error_reporting($_smarty_old_error_level);
  1093. // restore initial cache_info
  1094. $this->_cache_info = array_pop($_cache_info);
  1095. return $_smarty_results;
  1096. }
  1097. } else {
  1098. $this->_cache_info['template'][$resource_name] = true;
  1099. if ($this->cache_modified_check && $display) {
  1100. header('Last-Modified: '.gmdate('D, d M Y H:i:s', time()).' GMT');
  1101. }
  1102. }
  1103. }
  1104. // load filters that are marked as autoload
  1105. if (count($this->autoload_filters)) {
  1106. foreach ($this->autoload_filters as $_filter_type => $_filters) {
  1107. foreach ($_filters as $_filter) {
  1108. $this->load_filter($_filter_type, $_filter);
  1109. }
  1110. }
  1111. }
  1112. $_smarty_compile_path = $this->_get_compile_path($resource_name);
  1113. // if we just need to display the results, don't perform output
  1114. // buffering - for speed
  1115. $_cache_including = $this->_cache_including;
  1116. $this->_cache_including = false;
  1117. if ($display && !$this->caching && count($this->_plugins['outputfilter']) == 0) {
  1118. if ($this->_is_compiled($resource_name, $_smarty_compile_path)
  1119. || $this->_compile_resource($resource_name, $_smarty_compile_path))
  1120. {
  1121. include($_smarty_compile_path);
  1122. }
  1123. } else {
  1124. ob_start();
  1125. if ($this->_is_compiled($resource_name, $_smarty_compile_path)
  1126. || $this->_compile_resource($resource_name, $_smarty_compile_path))
  1127. {
  1128. include($_smarty_compile_path);
  1129. }
  1130. $_smarty_results = ob_get_contents();
  1131. ob_end_clean();
  1132. foreach ((array)$this->_plugins['outputfilter'] as $_output_filter) {
  1133. $_smarty_results = call_user_func_array($_output_filter[0], array($_smarty_results, &$this));
  1134. }
  1135. }
  1136. if ($this->caching) {
  1137. $_params = array('tpl_file' => $resource_name,
  1138. 'cache_id' => $cache_id,
  1139. 'compile_id' => $compile_id,
  1140. 'results' => $_smarty_results);
  1141. require_once(SMARTY_CORE_DIR . 'core.write_cache_file.php');
  1142. smarty_core_write_cache_file($_params, $this);
  1143. require_once(SMARTY_CORE_DIR . 'core.process_cached_inserts.php');
  1144. $_smarty_results = smarty_core_process_cached_inserts($_params, $this);
  1145. if ($this->_cache_serials) {
  1146. // strip nocache-tags from output
  1147. $_smarty_results = preg_replace('!(\{/?nocache\:[0-9a-f]{32}#\d+\})!s'
  1148. ,''
  1149. ,$_smarty_results);
  1150. }
  1151. // restore initial cache_info
  1152. $this->_cache_info = array_pop($_cache_info);
  1153. }
  1154. $this->_cache_including = $_cache_including;
  1155. if ($display) {
  1156. if (isset($_smarty_results)) { echo $_smarty_results; }
  1157. if ($this->debugging) {
  1158. // capture time for debugging info
  1159. $_params = array();
  1160. require_once(SMARTY_CORE_DIR . 'core.get_microtime.php');
  1161. $this->_smarty_debug_info[$_included_tpls_idx]['exec_time'] = (smarty_core_get_microtime($_params, $this) - $_debug_start_time);
  1162. require_once(SMARTY_CORE_DIR . 'core.display_debug_console.php');
  1163. echo smarty_core_display_debug_console($_params, $this);
  1164. }
  1165. error_reporting($_smarty_old_error_level);
  1166. return;
  1167. } else {
  1168. error_reporting($_smarty_old_error_level);
  1169. if (isset($_smarty_results)) { return $_smarty_results; }
  1170. }
  1171. }
  1172. /**
  1173. * load configuration values
  1174. *
  1175. * @param string $file
  1176. * @param string $section
  1177. * @param string $scope
  1178. */
  1179. function config_load($file, $section = null, $scope = 'global')
  1180. {
  1181. require_once($this->_get_plugin_filepath('function', 'config_load'));
  1182. smarty_function_config_load(array('file' => $file, 'section' => $section, 'scope' => $scope), $this);
  1183. }
  1184. /**
  1185. * return a reference to a registered object
  1186. *
  1187. * @param string $name
  1188. * @return object
  1189. */
  1190. function &get_registered_object($name) {
  1191. if (!isset($this->_reg_objects[$name]))
  1192. $this->_trigger_fatal_error("'$name' is not a registered object");
  1193. if (!is_object($this->_reg_objects[$name][0]))
  1194. $this->_trigger_fatal_error("registered '$name' is not an object");
  1195. return $this->_reg_objects[$name][0];
  1196. }
  1197. /**
  1198. * clear configuration values
  1199. *
  1200. * @param string $var
  1201. */
  1202. function clear_config($var = null)
  1203. {
  1204. if(!isset($var)) {
  1205. // clear all values
  1206. $this->_config = array(array('vars' => array(),
  1207. 'files' => array()));
  1208. } else {
  1209. unset($this->_config[0]['vars'][$var]);
  1210. }
  1211. }
  1212. /**
  1213. * get filepath of requested plugin
  1214. *
  1215. * @param string $type
  1216. * @param string $name
  1217. * @return string|false
  1218. */
  1219. function _get_plugin_filepath($type, $name)
  1220. {
  1221. $_params = array('type' => $type, 'name' => $name);
  1222. require_once(SMARTY_CORE_DIR . 'core.assemble_plugin_filepath.php');
  1223. return smarty_core_assemble_plugin_filepath($_params, $this);
  1224. }
  1225. /**
  1226. * test if resource needs compiling
  1227. *
  1228. * @param string $resource_name
  1229. * @param string $compile_path
  1230. * @return boolean
  1231. */
  1232. function _is_compiled($resource_name, $compile_path)
  1233. {
  1234. if (!$this->force_compile && file_exists($compile_path)) {
  1235. if (!$this->compile_check) {
  1236. // no need to check compiled file
  1237. return true;
  1238. } else {
  1239. // get file source and timestamp
  1240. $_params = array('resource_name' => $resource_name, 'get_source'=>false);
  1241. if (!$this->_fetch_resource_info($_params)) {
  1242. return false;
  1243. }
  1244. if ($_params['resource_timestamp'] <= filemtime($compile_path)) {
  1245. // template not expired, no recompile
  1246. return true;
  1247. } else {
  1248. // compile template
  1249. return false;
  1250. }
  1251. }
  1252. } else {
  1253. // compiled template does not exist, or forced compile
  1254. return false;
  1255. }
  1256. }
  1257. /**
  1258. * compile the template
  1259. *
  1260. * @param string $resource_name
  1261. * @param string $compile_path
  1262. * @return boolean
  1263. */
  1264. function _compile_resource($resource_name, $compile_path)
  1265. {
  1266. $_params = array('resource_name' => $resource_name);
  1267. if (!$this->_fetch_resource_info($_params)) {
  1268. return false;
  1269. }
  1270. $_source_content = $_params['source_content'];
  1271. $_cache_include = substr($compile_path, 0, -4).'.inc';
  1272. if ($this->_compile_source($resource_name, $_source_content, $_compiled_content, $_cache_include)) {
  1273. // if a _cache_serial was set, we also have to write an include-file:
  1274. if ($this->_cache_include_info) {
  1275. require_once(SMARTY_CORE_DIR . 'core.write_compiled_include.php');
  1276. smarty_core_write_compiled_include(array_merge($this->_cache_include_info, array('compiled_content'=>$_compiled_content, 'resource_name'=>$resource_name)), $this);
  1277. }
  1278. $_params = array('compile_path'=>$compile_path, 'compiled_content' => $_compiled_content);
  1279. require_once(SMARTY_CORE_DIR . 'core.write_compiled_resource.php');
  1280. smarty_core_write_compiled_resource($_params, $this);
  1281. return true;
  1282. } else {
  1283. return false;
  1284. }
  1285. }
  1286. /**
  1287. * compile the given source
  1288. *
  1289. * @param string $resource_name
  1290. * @param string $source_content
  1291. * @param string $compiled_content
  1292. * @return boolean
  1293. */
  1294. function _compile_source($resource_name, &$source_content, &$compiled_content, $cache_include_path=null)
  1295. {
  1296. if (file_exists(SMARTY_DIR . $this->compiler_file)) {
  1297. require_once(SMARTY_DIR . $this->compiler_file);
  1298. } else {
  1299. // use include_path
  1300. require_once($this->compiler_file);
  1301. }
  1302. $smarty_compiler = new $this->compiler_class;
  1303. $smarty_compiler->template_dir = $this->template_dir;
  1304. $smarty_compiler->compile_dir = $this->compile_dir;
  1305. $smarty_compiler->plugins_dir = $this->plugins_dir;
  1306. $smarty_compiler->config_dir = $this->config_dir;
  1307. $smarty_compiler->force_compile = $this->force_compile;
  1308. $smarty_compiler->caching = $this->caching;
  1309. $smarty_compiler->php_handling = $this->php_handling;
  1310. $smarty_compiler->left_delimiter = $this->left_delimiter;
  1311. $smarty_compiler->right_delimiter = $this->right_delimiter;
  1312. $smarty_compiler->_version = $this->_version;
  1313. $smarty_compiler->security = $this->security;
  1314. $smarty_compiler->secure_dir = $this->secure_dir;
  1315. $smarty_compiler->security_settings = $this->security_settings;
  1316. $smarty_compiler->trusted_dir = $this->trusted_dir;
  1317. $smarty_compiler->use_sub_dirs = $this->use_sub_dirs;
  1318. $smarty_compiler->_reg_objects = &$this->_reg_objects;
  1319. $smarty_compiler->_plugins = &$this->_plugins;
  1320. $smarty_compiler->_tpl_vars = &$this->_tpl_vars;
  1321. $smarty_compiler->default_modifiers = $this->default_modifiers;
  1322. $smarty_compiler->compile_id = $this->_compile_id;
  1323. $smarty_compiler->_config = $this->_config;
  1324. $smarty_compiler->request_use_auto_globals = $this->request_use_auto_globals;
  1325. if (isset($cache_include_path) && isset($this->_cache_serials[$cache_include_path])) {
  1326. $smarty_compiler->_cache_serial = $this->_cache_serials[$cache_include_path];
  1327. }
  1328. $smarty_compiler->_cache_include = $cache_include_path;
  1329. $_results = $smarty_compiler->_compile_file($resource_name, $source_content, $compiled_content);
  1330. if ($smarty_compiler->_cache_serial) {
  1331. $this->_cache_include_info = array(
  1332. 'cache_serial'=>$smarty_compiler->_cache_serial
  1333. ,'plugins_code'=>$smarty_compiler->_plugins_code
  1334. ,'include_file_path' => $cache_include_path);
  1335. } else {
  1336. $this->_cache_include_info = null;
  1337. }
  1338. return $_results;
  1339. }
  1340. /**
  1341. * Get the compile path for this resource
  1342. *
  1343. * @param string $resource_name
  1344. * @return string results of {@link _get_auto_filename()}
  1345. */
  1346. function _get_compile_path($resource_name)
  1347. {
  1348. return $this->_get_auto_filename($this->compile_dir, $resource_name,
  1349. $this->_compile_id) . '.php';
  1350. }
  1351. /**
  1352. * fetch the template info. Gets timestamp, and source
  1353. * if get_source is true
  1354. *
  1355. * sets $source_content to the source of the template, and
  1356. * $resource_timestamp to its time stamp
  1357. * @param string $resource_name
  1358. * @param string $source_content
  1359. * @param integer $resource_timestamp
  1360. * @param boolean $get_source
  1361. * @param boolean $quiet
  1362. * @return boolean
  1363. */
  1364. function _fetch_resource_info(&$params)
  1365. {
  1366. if(!isset($params['get_source'])) { $params['get_source'] = true; }
  1367. if(!isset($params['quiet'])) { $params['quiet'] = false; }
  1368. $_return = false;
  1369. $_params = array('resource_name' => $params['resource_name']) ;
  1370. if (isset($params['resource_base_path']))
  1371. $_params['resource_base_path'] = $params['resource_base_path'];
  1372. else
  1373. $_params['resource_base_path'] = $this->template_dir;
  1374. if ($this->_parse_resource_name($_params)) {
  1375. $_resource_type = $_params['resource_type'];
  1376. $_resource_name = $_params['resource_name'];
  1377. switch ($_resource_type) {
  1378. case 'file':
  1379. if ($params['get_source']) {
  1380. $params['source_content'] = $this->_read_file($_resource_name);
  1381. }
  1382. $params['resource_timestamp'] = filemtime($_resource_name);
  1383. $_return = is_file($_resource_name);
  1384. break;
  1385. default:

Large files files are truncated, but you can click here to view the full file