PageRenderTime 65ms CodeModel.GetById 29ms RepoModel.GetById 0ms app.codeStats 1ms

/dotproject/lib/smarty/Smarty.class.php

http://github.com/BigBlueHat/dotproject
PHP | 1941 lines | 1040 code | 176 blank | 725 comment | 132 complexity | 031cbba2aff5bc80ed9bc9b58ef65bdd MD5 | raw file
Possible License(s): GPL-2.0, LGPL-2.1

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

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