PageRenderTime 56ms CodeModel.GetById 22ms RepoModel.GetById 0ms app.codeStats 0ms

/system/libs/Smarty.class.php

http://asplite.googlecode.com/
PHP | 1953 lines | 1068 code | 178 blank | 707 comment | 138 complexity | f88bdea65c4b532c6e6c97a5f236a86b MD5 | raw file

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

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

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