smarty_internal_template.php 24 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692
  1. <?php
  2. /**
  3. * Smarty Internal Plugin Template
  4. * This file contains the Smarty template engine
  5. *
  6. * @package Smarty
  7. * @subpackage Template
  8. * @author Uwe Tews
  9. */
  10. /**
  11. * Main class with template data structures and methods
  12. *
  13. * @package Smarty
  14. * @subpackage Template
  15. *
  16. * @property Smarty_Template_Compiled $compiled
  17. * @property Smarty_Template_Cached $cached
  18. * @property Smarty_Internal_TemplateCompilerBase $compiler
  19. *
  20. * The following methods will be dynamically loaded by the extension handler when they are called.
  21. * They are located in a corresponding Smarty_Internal_Method_xxxx class
  22. *
  23. * @method bool mustCompile()
  24. */
  25. class Smarty_Internal_Template extends Smarty_Internal_TemplateBase
  26. {
  27. /**
  28. * This object type (Smarty = 1, template = 2, data = 4)
  29. *
  30. * @var int
  31. */
  32. public $_objType = 2;
  33. /**
  34. * Global smarty instance
  35. *
  36. * @var Smarty
  37. */
  38. public $smarty = null;
  39. /**
  40. * Source instance
  41. *
  42. * @var Smarty_Template_Source|Smarty_Template_Config
  43. */
  44. public $source = null;
  45. /**
  46. * Inheritance runtime extension
  47. *
  48. * @var Smarty_Internal_Runtime_Inheritance
  49. */
  50. public $inheritance = null;
  51. /**
  52. * Template resource
  53. *
  54. * @var string
  55. */
  56. public $template_resource = null;
  57. /**
  58. * flag if compiled template is invalid and must be (re)compiled
  59. *
  60. * @var bool
  61. */
  62. public $mustCompile = null;
  63. /**
  64. * Template Id
  65. *
  66. * @var null|string
  67. */
  68. public $templateId = null;
  69. /**
  70. * Scope in which variables shall be assigned
  71. *
  72. * @var int
  73. */
  74. public $scope = 0;
  75. /**
  76. * Flag which is set while rending a cache file
  77. *
  78. * @var bool
  79. */
  80. public $isRenderingCache = false;
  81. /**
  82. * Callbacks called before rendering template
  83. *
  84. * @var callback[]
  85. */
  86. public $startRenderCallbacks = array();
  87. /**
  88. * Callbacks called after rendering template
  89. *
  90. * @var callback[]
  91. */
  92. public $endRenderCallbacks = array();
  93. /**
  94. * Template object cache
  95. *
  96. * @var Smarty_Internal_Template[]
  97. */
  98. public static $tplObjCache = array();
  99. /**
  100. * Template object cache for Smarty::isCached() == true
  101. *
  102. * @var Smarty_Internal_Template[]
  103. */
  104. public static $isCacheTplObj = array();
  105. /**
  106. * Subtemplate Info Cache
  107. *
  108. * @var string[]int[]
  109. */
  110. public static $subTplInfo = array();
  111. /**
  112. * Create template data object
  113. * Some of the global Smarty settings copied to template scope
  114. * It load the required template resources and caching plugins
  115. *
  116. * @param string $template_resource template resource string
  117. * @param Smarty $smarty Smarty instance
  118. * @param null|\Smarty_Internal_Template|\Smarty|\Smarty_Internal_Data $_parent back pointer to parent object
  119. * with variables or null
  120. * @param mixed $_cache_id cache id or null
  121. * @param mixed $_compile_id compile id or null
  122. * @param bool|int|null $_caching use caching?
  123. * @param int|null $_cache_lifetime cache life-time in seconds
  124. * @param bool $_isConfig
  125. *
  126. * @throws \SmartyException
  127. */
  128. public function __construct($template_resource, Smarty $smarty, Smarty_Internal_Data $_parent = null,
  129. $_cache_id = null, $_compile_id = null, $_caching = null, $_cache_lifetime = null,
  130. $_isConfig = false)
  131. {
  132. $this->smarty = $smarty;
  133. // Smarty parameter
  134. $this->cache_id = $_cache_id === null ? $this->smarty->cache_id : $_cache_id;
  135. $this->compile_id = $_compile_id === null ? $this->smarty->compile_id : $_compile_id;
  136. $this->caching = $_caching === null ? $this->smarty->caching : $_caching;
  137. if ($this->caching === true) {
  138. $this->caching = Smarty::CACHING_LIFETIME_CURRENT;
  139. }
  140. $this->cache_lifetime = $_cache_lifetime === null ? $this->smarty->cache_lifetime : $_cache_lifetime;
  141. $this->parent = $_parent;
  142. // Template resource
  143. $this->template_resource = $template_resource;
  144. $this->source = $_isConfig ? Smarty_Template_Config::load($this) : Smarty_Template_Source::load($this);
  145. parent::__construct();
  146. if ($smarty->security_policy && method_exists($smarty->security_policy, 'registerCallBacks')) {
  147. $smarty->security_policy->registerCallBacks($this);
  148. }
  149. }
  150. /**
  151. * render template
  152. *
  153. * @param bool $no_output_filter if true do not run output filter
  154. * @param null|bool $display true: display, false: fetch null: sub-template
  155. *
  156. * @return string
  157. * @throws \SmartyException
  158. */
  159. public function render($no_output_filter = true, $display = null)
  160. {
  161. if ($this->smarty->debugging) {
  162. if (!isset($this->smarty->_debug)) {
  163. $this->smarty->_debug = new Smarty_Internal_Debug();
  164. }
  165. $this->smarty->_debug->start_template($this, $display);
  166. }
  167. // checks if template exists
  168. if (!$this->source->exists) {
  169. throw new SmartyException("Unable to load template '{$this->source->type}:{$this->source->name}'" .
  170. ($this->_isSubTpl() ? " in '{$this->parent->template_resource}'" : ''));
  171. }
  172. // disable caching for evaluated code
  173. if ($this->source->handler->recompiled) {
  174. $this->caching = false;
  175. }
  176. // read from cache or render
  177. $isCacheTpl =
  178. $this->caching == Smarty::CACHING_LIFETIME_CURRENT || $this->caching == Smarty::CACHING_LIFETIME_SAVED;
  179. if ($isCacheTpl) {
  180. if (!isset($this->cached) || $this->cached->cache_id !== $this->cache_id ||
  181. $this->cached->compile_id !== $this->compile_id
  182. ) {
  183. $this->loadCached(true);
  184. }
  185. $this->cached->render($this, $no_output_filter);
  186. } else {
  187. if (!isset($this->compiled) || $this->compiled->compile_id !== $this->compile_id) {
  188. $this->loadCompiled(true);
  189. }
  190. $this->compiled->render($this);
  191. }
  192. // display or fetch
  193. if ($display) {
  194. if ($this->caching && $this->smarty->cache_modified_check) {
  195. $this->smarty->ext->_cacheModify->cacheModifiedCheck($this->cached, $this,
  196. isset($content) ? $content : ob_get_clean());
  197. } else {
  198. if ((!$this->caching || $this->cached->has_nocache_code || $this->source->handler->recompiled) &&
  199. !$no_output_filter && (isset($this->smarty->autoload_filters[ 'output' ]) ||
  200. isset($this->smarty->registered_filters[ 'output' ]))
  201. ) {
  202. echo $this->smarty->ext->_filterHandler->runFilter('output', ob_get_clean(), $this);
  203. } else {
  204. echo ob_get_clean();
  205. }
  206. }
  207. if ($this->smarty->debugging) {
  208. $this->smarty->_debug->end_template($this);
  209. // debug output
  210. $this->smarty->_debug->display_debug($this, true);
  211. }
  212. return '';
  213. } else {
  214. if ($this->smarty->debugging) {
  215. $this->smarty->_debug->end_template($this);
  216. if ($this->smarty->debugging === 2 && $display === false) {
  217. $this->smarty->_debug->display_debug($this, true);
  218. }
  219. }
  220. if ($this->_isSubTpl()) {
  221. foreach ($this->compiled->required_plugins as $code => $tmp1) {
  222. foreach ($tmp1 as $name => $tmp) {
  223. foreach ($tmp as $type => $data) {
  224. $this->parent->compiled->required_plugins[ $code ][ $name ][ $type ] = $data;
  225. }
  226. }
  227. }
  228. }
  229. if (!$no_output_filter &&
  230. (!$this->caching || $this->cached->has_nocache_code || $this->source->handler->recompiled) &&
  231. (isset($this->smarty->autoload_filters[ 'output' ]) ||
  232. isset($this->smarty->registered_filters[ 'output' ]))
  233. ) {
  234. return $this->smarty->ext->_filterHandler->runFilter('output', ob_get_clean(), $this);
  235. }
  236. // return cache content
  237. return null;
  238. }
  239. }
  240. /**
  241. * Runtime function to render sub-template
  242. *
  243. * @param string $template template name
  244. * @param mixed $cache_id cache id
  245. * @param mixed $compile_id compile id
  246. * @param integer $caching cache mode
  247. * @param integer $cache_lifetime life time of cache data
  248. * @param array $data passed parameter template variables
  249. * @param int $scope scope in which {include} should execute
  250. * @param bool $forceTplCache cache template object
  251. * @param string $uid file dependency uid
  252. * @param string $content_func function name
  253. *
  254. */
  255. public function _subTemplateRender($template, $cache_id, $compile_id, $caching, $cache_lifetime, $data, $scope,
  256. $forceTplCache, $uid = null, $content_func = null)
  257. {
  258. $tpl = clone $this;
  259. $tpl->parent = $this;
  260. $smarty = &$this->smarty;
  261. $_templateId = $smarty->_getTemplateId($template, $cache_id, $compile_id, $caching, $tpl);
  262. // recursive call ?
  263. if (isset($tpl->templateId) ? $tpl->templateId : $tpl->_getTemplateId() != $_templateId) {
  264. // already in template cache?
  265. if (isset(self::$tplObjCache[ $_templateId ])) {
  266. // copy data from cached object
  267. $cachedTpl = &self::$tplObjCache[ $_templateId ];
  268. $tpl->templateId = $cachedTpl->templateId;
  269. $tpl->template_resource = $cachedTpl->template_resource;
  270. $tpl->cache_id = $cachedTpl->cache_id;
  271. $tpl->compile_id = $cachedTpl->compile_id;
  272. $tpl->source = $cachedTpl->source;
  273. if (isset($cachedTpl->compiled)) {
  274. $tpl->compiled = $cachedTpl->compiled;
  275. } else {
  276. unset($tpl->compiled);
  277. }
  278. if ($caching != 9999 && isset($cachedTpl->cached)) {
  279. $tpl->cached = $cachedTpl->cached;
  280. } else {
  281. unset($tpl->cached);
  282. }
  283. } else {
  284. $tpl->templateId = $_templateId;
  285. $tpl->template_resource = $template;
  286. $tpl->cache_id = $cache_id;
  287. $tpl->compile_id = $compile_id;
  288. if (isset($uid)) {
  289. // for inline templates we can get all resource information from file dependency
  290. list($filepath, $timestamp, $type) = $tpl->compiled->file_dependency[ $uid ];
  291. $tpl->source = new Smarty_Template_Source($smarty, $filepath, $type, $filepath);
  292. $tpl->source->filepath = $filepath;
  293. $tpl->source->timestamp = $timestamp;
  294. $tpl->source->exists = true;
  295. $tpl->source->uid = $uid;
  296. } else {
  297. $tpl->source = Smarty_Template_Source::load($tpl);
  298. unset($tpl->compiled);
  299. }
  300. if ($caching != 9999) {
  301. unset($tpl->cached);
  302. }
  303. }
  304. } else {
  305. // on recursive calls force caching
  306. $forceTplCache = true;
  307. }
  308. $tpl->caching = $caching;
  309. $tpl->cache_lifetime = $cache_lifetime;
  310. // set template scope
  311. $tpl->scope = $scope;
  312. if (!isset(self::$tplObjCache[ $tpl->templateId ]) && !$tpl->source->handler->recompiled) {
  313. // check if template object should be cached
  314. if ($forceTplCache || (isset(self::$subTplInfo[ $tpl->template_resource ]) &&
  315. self::$subTplInfo[ $tpl->template_resource ] > 1) ||
  316. ($tpl->_isSubTpl() && isset(self::$tplObjCache[ $tpl->parent->templateId ]))
  317. ) {
  318. self::$tplObjCache[ $tpl->templateId ] = $tpl;
  319. }
  320. }
  321. if (!empty($data)) {
  322. // set up variable values
  323. foreach ($data as $_key => $_val) {
  324. $tpl->tpl_vars[ $_key ] = new Smarty_Variable($_val, $this->isRenderingCache);
  325. }
  326. }
  327. if ($tpl->caching == 9999) {
  328. if (!isset($tpl->compiled)) {
  329. $this->loadCompiled(true);
  330. }
  331. if ($tpl->compiled->has_nocache_code) {
  332. $this->cached->hashes[ $tpl->compiled->nocache_hash ] = true;
  333. }
  334. }
  335. $tpl->_cache = array();
  336. if (isset($uid)) {
  337. if ($smarty->debugging) {
  338. if (!isset($smarty->_debug)) {
  339. $smarty->_debug = new Smarty_Internal_Debug();
  340. }
  341. $smarty->_debug->start_template($tpl);
  342. $smarty->_debug->start_render($tpl);
  343. }
  344. $tpl->compiled->getRenderedTemplateCode($tpl, $content_func);
  345. if ($smarty->debugging) {
  346. $smarty->_debug->end_template($tpl);
  347. $smarty->_debug->end_render($tpl);
  348. }
  349. } else {
  350. if (isset($tpl->compiled)) {
  351. $tpl->compiled->render($tpl);
  352. } else {
  353. $tpl->render();
  354. }
  355. }
  356. }
  357. /**
  358. * Get called sub-templates and save call count
  359. *
  360. */
  361. public function _subTemplateRegister()
  362. {
  363. foreach ($this->compiled->includes as $name => $count) {
  364. if (isset(self::$subTplInfo[ $name ])) {
  365. self::$subTplInfo[ $name ] += $count;
  366. } else {
  367. self::$subTplInfo[ $name ] = $count;
  368. }
  369. }
  370. }
  371. /**
  372. * Check if this is a sub template
  373. *
  374. * @return bool true is sub template
  375. */
  376. public function _isSubTpl()
  377. {
  378. return isset($this->parent) && $this->parent->_isTplObj();
  379. }
  380. /**
  381. * Assign variable in scope
  382. *
  383. * @param string $varName variable name
  384. * @param mixed $value value
  385. * @param bool $nocache nocache flag
  386. * @param int $scope scope into which variable shall be assigned
  387. *
  388. */
  389. public function _assignInScope($varName, $value, $nocache = false, $scope = 0)
  390. {
  391. if (isset($this->tpl_vars[ $varName ])) {
  392. $this->tpl_vars[ $varName ] = clone $this->tpl_vars[ $varName ];
  393. $this->tpl_vars[ $varName ]->value = $value;
  394. if ($nocache || $this->isRenderingCache) {
  395. $this->tpl_vars[ $varName ]->nocache = true;
  396. }
  397. } else {
  398. $this->tpl_vars[ $varName ] = new Smarty_Variable($value, $nocache || $this->isRenderingCache);
  399. }
  400. if ($scope >= 0) {
  401. if ($scope > 0 || $this->scope > 0) {
  402. $this->smarty->ext->_updateScope->_updateScope($this, $varName, $scope);
  403. }
  404. }
  405. }
  406. /**
  407. * This function is executed automatically when a compiled or cached template file is included
  408. * - Decode saved properties from compiled template and cache files
  409. * - Check if compiled or cache file is valid
  410. *
  411. * @param \Smarty_Internal_Template $tpl
  412. * @param array $properties special template properties
  413. * @param bool $cache flag if called from cache file
  414. *
  415. * @return bool flag if compiled or cache file is valid
  416. * @throws \SmartyException
  417. */
  418. public function _decodeProperties(Smarty_Internal_Template $tpl, $properties, $cache = false)
  419. {
  420. // on cache resources other than file check version stored in cache code
  421. if (!isset($properties[ 'version' ]) || Smarty::SMARTY_VERSION !== $properties[ 'version' ]) {
  422. if ($cache) {
  423. $tpl->smarty->clearAllCache();
  424. } else {
  425. $tpl->smarty->clearCompiledTemplate();
  426. }
  427. return false;
  428. }
  429. $is_valid = true;
  430. if (!empty($properties[ 'file_dependency' ]) &&
  431. ((!$cache && $tpl->smarty->compile_check) || $tpl->smarty->compile_check == 1)
  432. ) {
  433. // check file dependencies at compiled code
  434. foreach ($properties[ 'file_dependency' ] as $_file_to_check) {
  435. if ($_file_to_check[ 2 ] == 'file' || $_file_to_check[ 2 ] == 'php') {
  436. if ($tpl->source->filepath == $_file_to_check[ 0 ]) {
  437. // do not recheck current template
  438. continue;
  439. //$mtime = $tpl->source->getTimeStamp();
  440. } else {
  441. // file and php types can be checked without loading the respective resource handlers
  442. $mtime = is_file($_file_to_check[ 0 ]) ? filemtime($_file_to_check[ 0 ]) : false;
  443. }
  444. } else {
  445. $handler = Smarty_Resource::load($tpl->smarty, $_file_to_check[ 2 ]);
  446. if ($handler->checkTimestamps()) {
  447. $source = Smarty_Template_Source::load($tpl, $tpl->smarty, $_file_to_check[ 0 ]);
  448. $mtime = $source->getTimeStamp();
  449. } else {
  450. continue;
  451. }
  452. }
  453. if ($mtime === false || $mtime > $_file_to_check[ 1 ]) {
  454. $is_valid = false;
  455. break;
  456. }
  457. }
  458. }
  459. if ($cache) {
  460. // CACHING_LIFETIME_SAVED cache expiry has to be validated here since otherwise we'd define the unifunc
  461. if ($tpl->caching === Smarty::CACHING_LIFETIME_SAVED && $properties[ 'cache_lifetime' ] >= 0 &&
  462. (time() > ($tpl->cached->timestamp + $properties[ 'cache_lifetime' ]))
  463. ) {
  464. $is_valid = false;
  465. }
  466. $tpl->cached->cache_lifetime = $properties[ 'cache_lifetime' ];
  467. $tpl->cached->valid = $is_valid;
  468. $resource = $tpl->cached;
  469. } else {
  470. $tpl->mustCompile = !$is_valid;
  471. $resource = $tpl->compiled;
  472. $resource->includes = isset($properties[ 'includes' ]) ? $properties[ 'includes' ] : array();
  473. }
  474. if ($is_valid) {
  475. $resource->unifunc = $properties[ 'unifunc' ];
  476. $resource->has_nocache_code = $properties[ 'has_nocache_code' ];
  477. // $tpl->compiled->nocache_hash = $properties['nocache_hash'];
  478. $resource->file_dependency = $properties[ 'file_dependency' ];
  479. }
  480. return $is_valid && !function_exists($properties[ 'unifunc' ]);
  481. }
  482. /**
  483. * Compiles the template
  484. * If the template is not evaluated the compiled template is saved on disk
  485. */
  486. public function compileTemplateSource()
  487. {
  488. return $this->compiled->compileTemplateSource($this);
  489. }
  490. /**
  491. * Writes the content to cache resource
  492. *
  493. * @param string $content
  494. *
  495. * @return bool
  496. */
  497. public function writeCachedContent($content)
  498. {
  499. return $this->smarty->ext->_updateCache->writeCachedContent($this->cached, $this, $content);
  500. }
  501. /**
  502. * Get unique template id
  503. *
  504. * @return string
  505. */
  506. public function _getTemplateId()
  507. {
  508. return isset($this->templateId) ? $this->templateId : $this->templateId =
  509. $this->smarty->_getTemplateId($this->template_resource, $this->cache_id, $this->compile_id);
  510. }
  511. /**
  512. * runtime error not matching capture tags
  513. */
  514. public function capture_error()
  515. {
  516. throw new SmartyException("Not matching {capture} open/close in \"{$this->template_resource}\"");
  517. }
  518. /**
  519. * Load compiled object
  520. *
  521. * @param bool $force force new compiled object
  522. */
  523. public function loadCompiled($force = false)
  524. {
  525. if ($force || !isset($this->compiled)) {
  526. $this->compiled = Smarty_Template_Compiled::load($this);
  527. }
  528. }
  529. /**
  530. * Load cached object
  531. *
  532. * @param bool $force force new cached object
  533. */
  534. public function loadCached($force = false)
  535. {
  536. if ($force || !isset($this->cached)) {
  537. $this->cached = Smarty_Template_Cached::load($this);
  538. }
  539. }
  540. /**
  541. * Load inheritance object
  542. *
  543. */
  544. public function _loadInheritance()
  545. {
  546. if (!isset($this->inheritance)) {
  547. $this->inheritance = new Smarty_Internal_Runtime_Inheritance();
  548. }
  549. }
  550. /**
  551. * Unload inheritance object
  552. *
  553. */
  554. public function _cleanUp()
  555. {
  556. $this->startRenderCallbacks = array();
  557. $this->endRenderCallbacks = array();
  558. $this->inheritance = null;
  559. }
  560. /**
  561. * Load compiler object
  562. *
  563. * @throws \SmartyException
  564. */
  565. public function loadCompiler()
  566. {
  567. if (!class_exists($this->source->compiler_class)) {
  568. $this->smarty->loadPlugin($this->source->compiler_class);
  569. }
  570. $this->compiler =
  571. new $this->source->compiler_class($this->source->template_lexer_class, $this->source->template_parser_class,
  572. $this->smarty);
  573. }
  574. /**
  575. * Handle unknown class methods
  576. *
  577. * @param string $name unknown method-name
  578. * @param array $args argument array
  579. *
  580. * @return mixed
  581. * @throws SmartyException
  582. */
  583. public function __call($name, $args)
  584. {
  585. // method of Smarty object?
  586. if (method_exists($this->smarty, $name)) {
  587. return call_user_func_array(array($this->smarty, $name), $args);
  588. }
  589. // parent
  590. return parent::__call($name, $args);
  591. }
  592. /**
  593. * set Smarty property in template context
  594. *
  595. * @param string $property_name property name
  596. * @param mixed $value value
  597. *
  598. * @throws SmartyException
  599. */
  600. public function __set($property_name, $value)
  601. {
  602. switch ($property_name) {
  603. case 'compiled':
  604. case 'cached':
  605. case 'compiler':
  606. $this->$property_name = $value;
  607. return;
  608. default:
  609. // Smarty property ?
  610. if (property_exists($this->smarty, $property_name)) {
  611. $this->smarty->$property_name = $value;
  612. return;
  613. }
  614. }
  615. throw new SmartyException("invalid template property '$property_name'.");
  616. }
  617. /**
  618. * get Smarty property in template context
  619. *
  620. * @param string $property_name property name
  621. *
  622. * @return mixed|Smarty_Template_Cached
  623. * @throws SmartyException
  624. */
  625. public function __get($property_name)
  626. {
  627. switch ($property_name) {
  628. case 'compiled':
  629. $this->loadCompiled();
  630. return $this->compiled;
  631. case 'cached':
  632. $this->loadCached();
  633. return $this->cached;
  634. case 'compiler':
  635. $this->loadCompiler();
  636. return $this->compiler;
  637. default:
  638. // Smarty property ?
  639. if (property_exists($this->smarty, $property_name)) {
  640. return $this->smarty->$property_name;
  641. }
  642. }
  643. throw new SmartyException("template property '$property_name' does not exist.");
  644. }
  645. /**
  646. * Template data object destructor
  647. */
  648. public function __destruct()
  649. {
  650. if ($this->smarty->cache_locking && isset($this->cached) && $this->cached->is_locked) {
  651. $this->cached->handler->releaseLock($this->smarty, $this->cached);
  652. }
  653. }
  654. }