PageRenderTime 58ms CodeModel.GetById 23ms RepoModel.GetById 0ms app.codeStats 0ms

/inc/smarty/Smarty.class.php

http://github.com/cosmocode/contagged
PHP | 1968 lines | 1059 code | 177 blank | 732 comment | 137 complexity | 8831a463a8165a9e118005d4a77bc05f MD5 | raw file
Possible License(s): GPL-2.0

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

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

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