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

/smarty/Smarty.class.php

http://github.com/Upliner/gitphp-glip
PHP | 1961 lines | 1057 code | 177 blank | 727 comment | 137 complexity | 4f280d0817540872d15dca8b10fa5df6 MD5 | raw file
Possible License(s): GPL-2.0

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

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