PageRenderTime 62ms CodeModel.GetById 25ms RepoModel.GetById 0ms app.codeStats 0ms

/poll/smarty/Smarty.class.php

http://flaimo-php.googlecode.com/
PHP | 1932 lines | 1031 code | 176 blank | 725 comment | 132 complexity | c06ad394a40f538de0e16c99e7e7fc80 MD5 | raw file

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

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

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