diff --git a/.gitattributes b/.gitattributes new file mode 100644 index 00000000..412eeda7 --- /dev/null +++ b/.gitattributes @@ -0,0 +1,22 @@ +# Auto detect text files and perform LF normalization +* text=auto + +# Custom for Visual Studio +*.cs diff=csharp +*.sln merge=union +*.csproj merge=union +*.vbproj merge=union +*.fsproj merge=union +*.dbproj merge=union + +# Standard to msysgit +*.doc diff=astextplain +*.DOC diff=astextplain +*.docx diff=astextplain +*.DOCX diff=astextplain +*.dot diff=astextplain +*.DOT diff=astextplain +*.pdf diff=astextplain +*.PDF diff=astextplain +*.rtf diff=astextplain +*.RTF diff=astextplain diff --git a/.gitignore b/.gitignore new file mode 100644 index 00000000..2f29c7f0 --- /dev/null +++ b/.gitignore @@ -0,0 +1,218 @@ +################# +## Eclipse +################# + +*.pydevproject +.project +.metadata +bin/ +tmp/ +*.tmp +*.bak +*.swp +*~.nib +local.properties +.classpath +.settings/ +.loadpath + +# External tool builders +.externalToolBuilders/ + +# Locally stored "Eclipse launch configurations" +*.launch + +# CDT-specific +.cproject + +# PDT-specific +.buildpath + + +################# +## Visual Studio +################# + +## Ignore Visual Studio temporary files, build results, and +## files generated by popular Visual Studio add-ons. + +# User-specific files +*.suo +*.user +*.sln.docstates + +# Build results + +[Dd]ebug/ +[Rr]elease/ +x64/ +build/ +[Bb]in/ +[Oo]bj/ + +# MSTest test Results +[Tt]est[Rr]esult*/ +[Bb]uild[Ll]og.* + +*_i.c +*_p.c +*.ilk +*.meta +*.obj +*.pch +*.pdb +*.pgc +*.pgd +*.rsp +*.sbr +*.tlb +*.tli +*.tlh +*.tmp +*.tmp_proj +*.log +*.vspscc +*.vssscc +.builds +*.pidb +*.log +*.scc + +# Visual C++ cache files +ipch/ +*.aps +*.ncb +*.opensdf +*.sdf +*.cachefile + +# Visual Studio profiler +*.psess +*.vsp +*.vspx + +# Guidance Automation Toolkit +*.gpState + +# ReSharper is a .NET coding add-in +_ReSharper*/ +*.[Rr]e[Ss]harper + +# TeamCity is a build add-in +_TeamCity* + +# DotCover is a Code Coverage Tool +*.dotCover + +# NCrunch +*.ncrunch* +.*crunch*.local.xml + +# Installshield output folder +[Ee]xpress/ + +# DocProject is a documentation generator add-in +DocProject/buildhelp/ +DocProject/Help/*.HxT +DocProject/Help/*.HxC +DocProject/Help/*.hhc +DocProject/Help/*.hhk +DocProject/Help/*.hhp +DocProject/Help/Html2 +DocProject/Help/html + +# Click-Once directory +publish/ + +# Publish Web Output +*.Publish.xml +*.pubxml + +# NuGet Packages Directory +## TODO: If you have NuGet Package Restore enabled, uncomment the next line +#packages/ + +# Windows Azure Build Output +csx +*.build.csdef + +# Windows Store app package directory +AppPackages/ + +# Others +sql/ +*.Cache +ClientBin/ +[Ss]tyle[Cc]op.* +~$* +*~ +*.dbmdl +*.[Pp]ublish.xml +*.pfx +*.publishsettings + +# RIA/Silverlight projects +Generated_Code/ + +# Backup & report files from converting an old project file to a newer +# Visual Studio version. Backup files are not needed, because we have git ;-) +_UpgradeReport_Files/ +Backup*/ +UpgradeLog*.XML +UpgradeLog*.htm + +# SQL Server files +App_Data/*.mdf +App_Data/*.ldf + +############# +## Windows detritus +############# + +# Windows image file caches +Thumbs.db +ehthumbs.db + +# Folder config file +Desktop.ini + +# Recycle Bin used on file shares +$RECYCLE.BIN/ + +# Mac crap +.DS_Store + + +############# +## Python +############# + +*.py[co] + +# Packages +*.egg +*.egg-info +dist/ +build/ +eggs/ +parts/ +var/ +sdist/ +develop-eggs/ +.installed.cfg + +# Installer logs +pip-log.txt + +# Unit test / coverage reports +.coverage +.tox + +#Translations +*.mo + +#Mr Developer +.mr.developer.cfg + +.idea/ +.idea\ diff --git a/COMPOSER_RELEASE_NOTES.txt b/COMPOSER_RELEASE_NOTES.txt new file mode 100644 index 00000000..c943d9f2 --- /dev/null +++ b/COMPOSER_RELEASE_NOTES.txt @@ -0,0 +1,29 @@ + + +Starting with Smarty 3.1.21 Composer has been configured to load the packages from github. + +******************************************************************************* +* * +* NOTE: Because of this change you must clear your local composer cache with * +* the "composer clearcache" command * +* * +******************************************************************************* + +To get the latest stable version use + "require": { + "smarty/smarty": "~3.1" + } +in your composer.json file. + +To get the trunk version use + "require": { + "smarty/smarty": "~3.1@dev" + } + +The "smarty/smarty" package will start at libs/.... subfolder. + +To retrieve the development and documentation folders add + "require-dev": { + "smarty/smarty-dev": "~3.1@dev" + } + diff --git a/change_log.txt b/change_log.txt index e66bb9fc..2bcfde27 100644 --- a/change_log.txt +++ b/change_log.txt @@ -1,10 +1,21 @@ + ===== 3.1.22-dev ===== (xx.xx.2014) + 30.10.2014 + - bugfix access to class constant by object like {$object::CONST} or variable class name {$class::CONST} did not work (forum 25301) + + 26.10.2014 + - bugfix E_NOTICE message was created during compilation when ASP tags '<%' or '%>' are in template source text + - bugfix merge_compiled_includes option failed when caching enables and same subtemplate was included cached and not cached + ===== 3.1.21 ===== (18.10.2014) + 18.10.2014 + - composer moved to github + 17.10.2014 - bugfix on $php_handling security and optimization of smarty_internal_parsetree (Thue Kristensen) - + 16.10.2014 - bugfix composer.json update - + 15.10.2014 - bugfix calling a new created cache file with fetch() and Smarty::CACHING_LIFETIME_SAVED multiple times did fail (forum 22350) diff --git a/demo/plugins/cacheresource.pdo.php b/demo/plugins/cacheresource.pdo.php new file mode 100644 index 00000000..569193aa --- /dev/null +++ b/demo/plugins/cacheresource.pdo.php @@ -0,0 +1,322 @@ +setCachingType('pdo'); + * $smarty->loadPlugin('Smarty_CacheResource_Pdo'); + * $smarty->registerCacheResource('pdo', new Smarty_CacheResource_Pdo($cnx, 'smarty_cache')); + * + * @author Beno!t POLASZEK - 2014 + */ +class Smarty_CacheResource_Pdo extends Smarty_CacheResource_Custom +{ + + protected $fetchStatements = Array('default' => 'SELECT %2$s + FROM %1$s + WHERE 1 + AND id = :id + AND cache_id IS NULL + AND compile_id IS NULL', + + 'withCacheId' => 'SELECT %2$s + FROM %1$s + WHERE 1 + AND id = :id + AND cache_id = :cache_id + AND compile_id IS NULL', + + 'withCompileId' => 'SELECT %2$s + FROM %1$s + WHERE 1 + AND id = :id + AND compile_id = :compile_id + AND cache_id IS NULL', + + 'withCacheIdAndCompileId' => 'SELECT %2$s + FROM %1$s + WHERE 1 + AND id = :id + AND cache_id = :cache_id + AND compile_id = :compile_id'); + protected $insertStatement = 'INSERT INTO %s + + SET id = :id, + name = :name, + cache_id = :cache_id, + compile_id = :compile_id, + modified = CURRENT_TIMESTAMP, + expire = DATE_ADD(CURRENT_TIMESTAMP, INTERVAL :expire SECOND), + content = :content + + ON DUPLICATE KEY UPDATE + name = :name, + cache_id = :cache_id, + compile_id = :compile_id, + modified = CURRENT_TIMESTAMP, + expire = DATE_ADD(CURRENT_TIMESTAMP, INTERVAL :expire SECOND), + content = :content'; + + protected $deleteStatement = 'DELETE FROM %1$s WHERE %2$s'; + protected $truncateStatement = 'TRUNCATE TABLE %s'; + + protected $fetchColumns = 'modified, content'; + protected $fetchTimestampColumns = 'modified'; + + protected $pdo, $table, $database; + + /* + * Constructor + * + * @param PDO $pdo PDO : active connection + * @param string $table : table (or view) name + * @param string $database : optionnal - if table is located in another db + */ + public function __construct(PDO $pdo, $table, $database = null) + { + + if (is_null($table)) { + throw new SmartyException("Table name for caching can't be null"); + } + + $this->pdo = $pdo; + $this->table = $table; + $this->database = $database; + + $this->fillStatementsWithTableName(); + } + + /* + * Fills the table name into the statements. + * + * @return Current Instance + * @access protected + */ + protected function fillStatementsWithTableName() + { + + foreach ($this->fetchStatements AS &$statement) { + $statement = sprintf($statement, $this->getTableName(), '%s'); + } + + $this->insertStatement = sprintf($this->insertStatement, $this->getTableName()); + $this->deleteStatement = sprintf($this->deleteStatement, $this->getTableName(), '%s'); + $this->truncateStatement = sprintf($this->truncateStatement, $this->getTableName()); + + return $this; + } + + /* + * Gets the fetch statement, depending on what you specify + * + * @param string $columns : the column(s) name(s) you want to retrieve from the database + * @param string $id unique cache content identifier + * @param string|null $cache_id cache id + * @param string|null $compile_id compile id + * @access protected + */ + protected function getFetchStatement($columns, $id, $cache_id = null, $compile_id = null) + { + + if (!is_null($cache_id) && !is_null($compile_id)) { + $query = $this->fetchStatements['withCacheIdAndCompileId'] AND $args = Array('id' => $id, 'cache_id' => $cache_id, 'compile_id' => $compile_id); + } elseif (is_null($cache_id) && !is_null($compile_id)) { + $query = $this->fetchStatements['withCompileId'] AND $args = Array('id' => $id, 'compile_id' => $compile_id); + } elseif (!is_null($cache_id) && is_null($compile_id)) { + $query = $this->fetchStatements['withCacheId'] AND $args = Array('id' => $id, 'cache_id' => $cache_id); + } else { + $query = $this->fetchStatements['default'] AND $args = Array('id' => $id); + } + + $query = sprintf($query, $columns); + + $stmt = $this->pdo->prepare($query); + + foreach ($args AS $key => $value) { + $stmt->bindValue($key, $value); + } + + return $stmt; + } + + /** + * fetch cached content and its modification time from data source + * + * @param string $id unique cache content identifier + * @param string $name template name + * @param string|null $cache_id cache id + * @param string|null $compile_id compile id + * @param string $content cached content + * @param integer $mtime cache modification timestamp (epoch) + * + * @return void + * @access protected + */ + protected function fetch($id, $name, $cache_id = null, $compile_id = null, &$content, &$mtime) + { + + $stmt = $this->getFetchStatement($this->fetchColumns, $id, $cache_id, $compile_id); + $stmt ->execute(); + $row = $stmt->fetch(); + $stmt ->closeCursor(); + + if ($row) { + $content = $this->outputContent($row['content']); + $mtime = strtotime($row['modified']); + } else { + $content = null; + $mtime = null; + } + } + + /** + * Fetch cached content's modification timestamp from data source + * {@internal implementing this method is optional. + * Only implement it if modification times can be accessed faster than loading the complete cached content.}} + * + * @param string $id unique cache content identifier + * @param string $name template name + * @param string|null $cache_id cache id + * @param string|null $compile_id compile id + * + * @return integer|boolean timestamp (epoch) the template was modified, or false if not found + * @access protected + */ + // protected function fetchTimestamp($id, $name, $cache_id = null, $compile_id = null) { + // $stmt = $this->getFetchStatement($this->fetchTimestampColumns, $id, $cache_id, $compile_id); + // $stmt -> execute(); + // $mtime = strtotime($stmt->fetchColumn()); + // $stmt -> closeCursor(); + // return $mtime; + // } + + /** + * Save content to cache + * + * @param string $id unique cache content identifier + * @param string $name template name + * @param string|null $cache_id cache id + * @param string|null $compile_id compile id + * @param integer|null $exp_time seconds till expiration time in seconds or null + * @param string $content content to cache + * + * @return boolean success + * @access protected + */ + protected function save($id, $name, $cache_id = null, $compile_id = null, $exp_time, $content) + { + + $stmt = $this->pdo->prepare($this->insertStatement); + + $stmt ->bindValue('id', $id); + $stmt ->bindValue('name', $name); + $stmt ->bindValue('cache_id', $cache_id, (is_null($cache_id)) ? PDO::PARAM_NULL : PDO::PARAM_STR); + $stmt ->bindValue('compile_id', $compile_id, (is_null($compile_id)) ? PDO::PARAM_NULL : PDO::PARAM_STR); + $stmt ->bindValue('expire', (int) $exp_time, PDO::PARAM_INT); + $stmt ->bindValue('content', $this->inputContent($content)); + $stmt ->execute(); + + return !!$stmt->rowCount(); + } + + /* + * Encodes the content before saving to database + * + * @param string $content + * @return string $content + * @access protected + */ + protected function inputContent($content) + { + return $content; + } + + /* + * Decodes the content before saving to database + * + * @param string $content + * @return string $content + * @access protected + */ + protected function outputContent($content) + { + return $content; + } + + /** + * Delete content from cache + * + * @param string|null $name template name + * @param string|null $cache_id cache id + * @param string|null $compile_id compile id + * @param integer|null|-1 $exp_time seconds till expiration or null + * + * @return integer number of deleted caches + * @access protected + */ + protected function delete($name = null, $cache_id = null, $compile_id = null, $exp_time = null) + { + + // delete the whole cache + if ($name === null && $cache_id === null && $compile_id === null && $exp_time === null) { + // returning the number of deleted caches would require a second query to count them + $this->pdo->query($this->truncateStatement); + return - 1; + } + // build the filter + $where = array(); + // equal test name + if ($name !== null) { + $where[] = 'name = ' . $this->pdo->quote($name); + } + // equal test cache_id and match sub-groups + if ($cache_id !== null) { + $where[] = '(cache_id = ' . $this->pdo->quote($cache_id) + . ' OR cache_id LIKE ' . $this->pdo->quote($cache_id . '|%') . ')'; + } + // equal test compile_id + if ($compile_id !== null) { + $where[] = 'compile_id = ' . $this->pdo->quote($compile_id); + } + // for clearing expired caches + if ($exp_time === Smarty::CLEAR_EXPIRED) { + $where[] = 'expire < CURRENT_TIMESTAMP'; + } // range test expiration time + elseif ($exp_time !== null) { + $where[] = 'modified < DATE_SUB(NOW(), INTERVAL ' . intval($exp_time) . ' SECOND)'; + } + // run delete query + $query = $this->pdo->query(sprintf($this->deleteStatement, join(' AND ', $where))); + return $query->rowCount(); + } + + /** + * Gets the formatted table name + * + * @return string + * @access protected + */ + protected function getTableName() + { + return (is_null($this->database)) ? "`{$this->table}`" : "`{$this->database}`.`{$this->table}`"; + } +} + \ No newline at end of file diff --git a/demo/plugins/cacheresource.pdo_gzip.php b/demo/plugins/cacheresource.pdo_gzip.php new file mode 100644 index 00000000..8a9e0a5d --- /dev/null +++ b/demo/plugins/cacheresource.pdo_gzip.php @@ -0,0 +1,43 @@ +setCachingType('pdo_gzip'); + * $smarty->loadPlugin('Smarty_CacheResource_Pdo_Gzip'); + * $smarty->registerCacheResource('pdo_gzip', new Smarty_CacheResource_Pdo_Gzip($cnx, 'smarty_cache')); + * + * @require Smarty_CacheResource_Pdo class + * @author Beno!t POLASZEK - 2014 + */ +require_once 'cacheresource.pdo.php'; + +class Smarty_CacheResource_Pdo_Gzip extends Smarty_CacheResource_Pdo +{ + + /* + * Encodes the content before saving to database + * + * @param string $content + * @return string $content + * @access protected + */ + protected function inputContent($content) + { + return gzdeflate($content); + } + + /* + * Decodes the content before saving to database + * + * @param string $content + * @return string $content + * @access protected + */ + protected function outputContent($content) + { + return gzinflate($content); + } +} + \ No newline at end of file diff --git a/demo/templates/header.tpl b/demo/templates/header.tpl index 13fa6cb5..783210a1 100644 --- a/demo/templates/header.tpl +++ b/demo/templates/header.tpl @@ -1,5 +1,5 @@ - {$title} - {$Name} +{$title} - {$Name} diff --git a/libs/Smarty.class.php b/libs/Smarty.class.php index f17d6a80..463ff054 100644 --- a/libs/Smarty.class.php +++ b/libs/Smarty.class.php @@ -2,7 +2,10 @@ /** * Project: Smarty: the PHP compiling template engine * File: Smarty.class.php +<<<<<<< HEAD * SVN: $Id$ +======= +>>>>>>> trunk * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public * License as published by the Free Software Foundation; either @@ -24,7 +27,11 @@ * @author Uwe Tews * @author Rodney Rehm * @package Smarty +<<<<<<< HEAD * @version 3.1-DEV +======= + * @version 3.1.22-dev +>>>>>>> trunk */ /** @@ -110,7 +117,11 @@ class Smarty extends Smarty_Internal_TemplateBase /** * smarty version */ +<<<<<<< HEAD const SMARTY_VERSION = 'Smarty-3.1.21'; +======= + const SMARTY_VERSION = 'Smarty-3.1.22-dev/1'; +>>>>>>> trunk /** * define variable scopes diff --git a/libs/sysplugins/smarty_internal_compile_include.php b/libs/sysplugins/smarty_internal_compile_include.php index 4b7b09ce..35067f78 100644 --- a/libs/sysplugins/smarty_internal_compile_include.php +++ b/libs/sysplugins/smarty_internal_compile_include.php @@ -87,9 +87,13 @@ class Smarty_Internal_Compile_Include extends Smarty_Internal_CompileBase // flag if included template code should be merged into caller $merge_compiled_includes = ($compiler->smarty->merge_compiled_includes || ($compiler->inheritance && $compiler->smarty->inheritance_merge_compiled_includes) || $_attr['inline'] === true) && !$compiler->template->source->recompiled; + if ($_attr['nocache'] === true) { + $compiler->tag_nocache = true; + } + // set default when in nocache mode - // if ($compiler->template->caching && ($compiler->nocache || $compiler->tag_nocache || $compiler->forceNocache == 2)) { - if ($compiler->template->caching && ((!$compiler->inheritance && !$compiler->nocache && !$compiler->tag_nocache) || ($compiler->inheritance && ($compiler->nocache || $compiler->tag_nocache)))) { + if ($compiler->template->caching && !$compiler->nocache && !$compiler->tag_nocache) { + //if ($compiler->template->caching && ((!$compiler->inheritance && !$compiler->nocache && !$compiler->tag_nocache) || ($compiler->inheritance && ($compiler->nocache || $compiler->tag_nocache)))) { $_caching = self::CACHING_NOCACHE_CODE; } /* @@ -119,14 +123,6 @@ class Smarty_Internal_Compile_Include extends Smarty_Internal_CompileBase if ($_attr['caching'] === true) { $_caching = Smarty::CACHING_LIFETIME_CURRENT; } - if ($_attr['nocache'] === true) { - $compiler->tag_nocache = true; - if ($merge_compiled_includes) { - $_caching = self::CACHING_NOCACHE_CODE; - } else { - $_caching = Smarty::CACHING_OFF; - } - } $has_compiled_template = false; if ($merge_compiled_includes && $_attr['inline'] !== true) { @@ -153,33 +149,28 @@ class Smarty_Internal_Compile_Include extends Smarty_Internal_CompileBase } if ($merge_compiled_includes) { if ($compiler->template->caching && ($compiler->tag_nocache || $compiler->nocache) && $_caching != self::CACHING_NOCACHE_CODE) { - $merge_compiled_includes = false; +// $merge_compiled_includes = false; if ($compiler->inheritance && $compiler->smarty->inheritance_merge_compiled_includes) { $compiler->trigger_template_error(' invalid caching mode of subtemplate within {block} tags'); } } } if ($merge_compiled_includes) { - // we must observe different compile_id - $uid = sha1($_compile_id); + // we must observe different compile_id and caching + $uid = sha1($_compile_id . ($_caching ? '--caching' : '--nocaching')); $tpl_name = null; - $nocache = false; /** @var Smarty_Internal_Template $_smarty_tpl * used in evaluated code */ $_smarty_tpl = $compiler->template; eval("\$tpl_name = $include_file;"); if (!isset($compiler->smarty->merged_templates_func[$tpl_name][$uid])) { - $tpl = new $compiler->smarty->template_class ($tpl_name, $compiler->smarty, $compiler->template, $compiler->template->cache_id, $compiler->template->compile_id); + $tpl = new $compiler->smarty->template_class ($tpl_name, $compiler->smarty, $compiler->template, $compiler->template->cache_id, $compiler->template->compile_id, $_caching); // save unique function name $compiler->smarty->merged_templates_func[$tpl_name][$uid]['func'] = $tpl->properties['unifunc'] = 'content_' . str_replace(array('.', ','), '_', uniqid('', true)); // use current nocache hash for inlined code $compiler->smarty->merged_templates_func[$tpl_name][$uid]['nocache_hash'] = $tpl->properties['nocache_hash'] = $compiler->template->properties['nocache_hash']; - if ($compiler->template->caching && $_caching == self::CACHING_NOCACHE_CODE) { - // all code must be nocache - $nocache = true; - } - if ($compiler->inheritance) { + if ($compiler->inheritance) { $tpl->compiler->inheritance = true; } // make sure whole chain gets compiled @@ -187,7 +178,7 @@ class Smarty_Internal_Compile_Include extends Smarty_Internal_CompileBase if (!($tpl->source->uncompiled) && $tpl->source->exists) { // get compiled code - $compiled_code = $tpl->compiler->compileTemplate($tpl, $nocache); + $compiled_code = $tpl->compiler->compileTemplate($tpl); // release compiler object to free memory unset($tpl->compiler); // merge compiled code for {function} tags diff --git a/libs/sysplugins/smarty_internal_templatebase.php b/libs/sysplugins/smarty_internal_templatebase.php index f8f1c9e1..ec0c86ce 100644 --- a/libs/sysplugins/smarty_internal_templatebase.php +++ b/libs/sysplugins/smarty_internal_templatebase.php @@ -1,860 +1,1723 @@ -template_class) { - $template = $this; - } - if ($cache_id !== null && is_object($cache_id)) { - $parent = $cache_id; - $cache_id = null; - } - if ($parent === null && ($this instanceof Smarty || is_string($template))) { - $parent = $this; - } - // create template object if necessary - $_template = ($template instanceof $this->template_class) - ? $template - : $this->smarty->createTemplate($template, $cache_id, $compile_id, $parent, false); - // if called by Smarty object make sure we use current caching status - if ($this instanceof Smarty) { - $_template->caching = $this->caching; - } - // merge all variable scopes into template - if ($merge_tpl_vars) { - // save local variables - $save_tpl_vars = $_template->tpl_vars; - $save_config_vars = $_template->config_vars; - $ptr_array = array($_template); - $ptr = $_template; - while (isset($ptr->parent)) { - $ptr_array[] = $ptr = $ptr->parent; - } - $ptr_array = array_reverse($ptr_array); - $parent_ptr = reset($ptr_array); - $tpl_vars = $parent_ptr->tpl_vars; - $config_vars = $parent_ptr->config_vars; - while ($parent_ptr = next($ptr_array)) { - if (!empty($parent_ptr->tpl_vars)) { - $tpl_vars = array_merge($tpl_vars, $parent_ptr->tpl_vars); - } - if (!empty($parent_ptr->config_vars)) { - $config_vars = array_merge($config_vars, $parent_ptr->config_vars); - } - } - if (!empty(Smarty::$global_tpl_vars)) { - $tpl_vars = array_merge(Smarty::$global_tpl_vars, $tpl_vars); - } - $_template->tpl_vars = $tpl_vars; - $_template->config_vars = $config_vars; - } - // dummy local smarty variable - if (!isset($_template->tpl_vars['smarty'])) { - $_template->tpl_vars['smarty'] = new Smarty_Variable; - } - if (isset($this->smarty->error_reporting)) { - $_smarty_old_error_level = error_reporting($this->smarty->error_reporting); - } - // check URL debugging control - if (!$this->smarty->debugging && $this->smarty->debugging_ctrl == 'URL') { - if (isset($_SERVER['QUERY_STRING'])) { - $_query_string = $_SERVER['QUERY_STRING']; - } else { - $_query_string = ''; - } - if (false !== strpos($_query_string, $this->smarty->smarty_debug_id)) { - if (false !== strpos($_query_string, $this->smarty->smarty_debug_id . '=on')) { - // enable debugging for this browser session - setcookie('SMARTY_DEBUG', true); - $this->smarty->debugging = true; - } elseif (false !== strpos($_query_string, $this->smarty->smarty_debug_id . '=off')) { - // disable debugging for this browser session - setcookie('SMARTY_DEBUG', false); - $this->smarty->debugging = false; - } else { - // enable debugging for this page - $this->smarty->debugging = true; - } - } else { - if (isset($_COOKIE['SMARTY_DEBUG'])) { - $this->smarty->debugging = true; - } - } - } - // must reset merge template date - $_template->smarty->merged_templates_func = array(); - // get rendered template - // disable caching for evaluated code - if ($_template->source->recompiled) { - $_template->caching = false; - } - // checks if template exists - if (!$_template->source->exists) { - if ($_template->parent instanceof Smarty_Internal_Template) { - $parent_resource = " in '{$_template->parent->template_resource}'"; - } else { - $parent_resource = ''; - } - throw new SmartyException("Unable to load template {$_template->source->type} '{$_template->source->name}'{$parent_resource}"); - } - // read from cache or render - if (!($_template->caching == Smarty::CACHING_LIFETIME_CURRENT || $_template->caching == Smarty::CACHING_LIFETIME_SAVED) || !$_template->cached->valid) { - // render template (not loaded and not in cache) - if (!$_template->source->uncompiled) { - /** @var Smarty_Internal_Template $_smarty_tpl - * used in evaluated code - */ - $_smarty_tpl = $_template; - if ($_template->source->recompiled) { - $code = $_template->compiler->compileTemplate($_template); - if ($this->smarty->debugging) { - Smarty_Internal_Debug::start_render($_template); - } - try { - ob_start(); - eval("?>" . $code); - unset($code); - } - catch (Exception $e) { - ob_get_clean(); - throw $e; - } - } else { - if (!$_template->compiled->exists || ($_template->smarty->force_compile && !$_template->compiled->isCompiled)) { - $_template->compileTemplateSource(); - $code = file_get_contents($_template->compiled->filepath); - eval("?>" . $code); - unset($code); - $_template->compiled->loaded = true; - $_template->compiled->isCompiled = true; - } - if ($this->smarty->debugging) { - Smarty_Internal_Debug::start_render($_template); - } - if (!$_template->compiled->loaded) { - include($_template->compiled->filepath); - if ($_template->mustCompile) { - // recompile and load again - $_template->compileTemplateSource(); - $code = file_get_contents($_template->compiled->filepath); - eval("?>" . $code); - unset($code); - $_template->compiled->isCompiled = true; - } - $_template->compiled->loaded = true; - } else { - $_template->decodeProperties($_template->compiled->_properties, false); - } - try { - ob_start(); - if (empty($_template->properties['unifunc']) || !is_callable($_template->properties['unifunc'])) { - throw new SmartyException("Invalid compiled template for '{$_template->template_resource}'"); - } - array_unshift($_template->_capture_stack, array()); - // - // render compiled template - // - $_template->properties['unifunc']($_template); - // any unclosed {capture} tags ? - if (isset($_template->_capture_stack[0][0])) { - $_template->capture_error(); - } - array_shift($_template->_capture_stack); - } - catch (Exception $e) { - ob_get_clean(); - throw $e; - } - } - } else { - if ($_template->source->uncompiled) { - if ($this->smarty->debugging) { - Smarty_Internal_Debug::start_render($_template); - } - try { - ob_start(); - $_template->source->renderUncompiled($_template); - } - catch (Exception $e) { - ob_get_clean(); - throw $e; - } - } else { - throw new SmartyException("Resource '$_template->source->type' must have 'renderUncompiled' method"); - } - } - $_output = ob_get_clean(); - if (!$_template->source->recompiled && empty($_template->properties['file_dependency'][$_template->source->uid])) { - $_template->properties['file_dependency'][$_template->source->uid] = array($_template->source->filepath, $_template->source->timestamp, $_template->source->type); - } - if ($_template->parent instanceof Smarty_Internal_Template) { - $_template->parent->properties['file_dependency'] = array_merge($_template->parent->properties['file_dependency'], $_template->properties['file_dependency']); - foreach ($_template->required_plugins as $code => $tmp1) { - foreach ($tmp1 as $name => $tmp) { - foreach ($tmp as $type => $data) { - $_template->parent->required_plugins[$code][$name][$type] = $data; - } - } - } - } - if ($this->smarty->debugging) { - Smarty_Internal_Debug::end_render($_template); - } - // write to cache when nessecary - if (!$_template->source->recompiled && ($_template->caching == Smarty::CACHING_LIFETIME_SAVED || $_template->caching == Smarty::CACHING_LIFETIME_CURRENT)) { - if ($this->smarty->debugging) { - Smarty_Internal_Debug::start_cache($_template); - } - $_template->properties['has_nocache_code'] = false; - // get text between non-cached items - $cache_split = preg_split("!/\*%%SmartyNocache:{$_template->properties['nocache_hash']}%%\*\/(.+?)/\*/%%SmartyNocache:{$_template->properties['nocache_hash']}%%\*/!s", $_output); - // get non-cached items - preg_match_all("!/\*%%SmartyNocache:{$_template->properties['nocache_hash']}%%\*\/(.+?)/\*/%%SmartyNocache:{$_template->properties['nocache_hash']}%%\*/!s", $_output, $cache_parts); - $output = ''; - // loop over items, stitch back together - foreach ($cache_split as $curr_idx => $curr_split) { - // escape PHP tags in template content - $output .= preg_replace('/(<%|%>|<\?php|<\?|\?>|)/', "\n", $curr_split); - if (isset($cache_parts[0][$curr_idx])) { - $_template->properties['has_nocache_code'] = true; - // remove nocache tags from cache output - $output .= preg_replace("!/\*/?%%SmartyNocache:{$_template->properties['nocache_hash']}%%\*/!", '', $cache_parts[0][$curr_idx]); - } - } - if (!$no_output_filter && !$_template->has_nocache_code && (isset($this->smarty->autoload_filters['output']) || isset($this->smarty->registered_filters['output']))) { - $output = Smarty_Internal_Filter_Handler::runFilter('output', $output, $_template); - } - // rendering (must be done before writing cache file because of {function} nocache handling) - /** @var Smarty_Internal_Template $_smarty_tpl - * used in evaluated code - */ - $_smarty_tpl = $_template; - try { - ob_start(); - eval("?>" . $output); - $_output = ob_get_clean(); - } - catch (Exception $e) { - ob_get_clean(); - throw $e; - } - // write cache file content - $_template->writeCachedContent($output); - if ($this->smarty->debugging) { - Smarty_Internal_Debug::end_cache($_template); - } - } else { - // var_dump('renderTemplate', $_template->has_nocache_code, $_template->template_resource, $_template->properties['nocache_hash'], $_template->parent->properties['nocache_hash'], $_output); - if (!empty($_template->properties['nocache_hash']) && !empty($_template->parent->properties['nocache_hash'])) { - // replace nocache_hash - $_output = str_replace("{$_template->properties['nocache_hash']}", $_template->parent->properties['nocache_hash'], $_output); - $_template->parent->has_nocache_code = $_template->parent->has_nocache_code || $_template->has_nocache_code; - } - } - } else { - if ($this->smarty->debugging) { - Smarty_Internal_Debug::start_cache($_template); - } - try { - ob_start(); - array_unshift($_template->_capture_stack, array()); - // - // render cached template - // - $_template->properties['unifunc']($_template); - // any unclosed {capture} tags ? - if (isset($_template->_capture_stack[0][0])) { - $_template->capture_error(); - } - array_shift($_template->_capture_stack); - $_output = ob_get_clean(); - } - catch (Exception $e) { - ob_get_clean(); - throw $e; - } - if ($this->smarty->debugging) { - Smarty_Internal_Debug::end_cache($_template); - } - } - if ((!$this->caching || $_template->has_nocache_code || $_template->source->recompiled) && !$no_output_filter && (isset($this->smarty->autoload_filters['output']) || isset($this->smarty->registered_filters['output']))) { - $_output = Smarty_Internal_Filter_Handler::runFilter('output', $_output, $_template); - } - if (isset($this->error_reporting)) { - error_reporting($_smarty_old_error_level); - } - // display or fetch - if ($display) { - if ($this->caching && $this->cache_modified_check) { - $_isCached = $_template->isCached() && !$_template->has_nocache_code; - $_last_modified_date = @substr($_SERVER['HTTP_IF_MODIFIED_SINCE'], 0, strpos($_SERVER['HTTP_IF_MODIFIED_SINCE'], 'GMT') + 3); - if ($_isCached && $_template->cached->timestamp <= strtotime($_last_modified_date)) { - switch (PHP_SAPI) { - case 'cgi': // php-cgi < 5.3 - case 'cgi-fcgi': // php-cgi >= 5.3 - case 'fpm-fcgi': // php-fpm >= 5.3.3 - header('Status: 304 Not Modified'); - break; - - case 'cli': - if ( /* ^phpunit */ - !empty($_SERVER['SMARTY_PHPUNIT_DISABLE_HEADERS']) /* phpunit$ */ - ) { - $_SERVER['SMARTY_PHPUNIT_HEADERS'][] = '304 Not Modified'; - } - break; - - default: - header($_SERVER['SERVER_PROTOCOL'] . ' 304 Not Modified'); - break; - } - } else { - switch (PHP_SAPI) { - case 'cli': - if ( /* ^phpunit */ - !empty($_SERVER['SMARTY_PHPUNIT_DISABLE_HEADERS']) /* phpunit$ */ - ) { - $_SERVER['SMARTY_PHPUNIT_HEADERS'][] = 'Last-Modified: ' . gmdate('D, d M Y H:i:s', $_template->cached->timestamp) . ' GMT'; - } - break; - - default: - header('Last-Modified: ' . gmdate('D, d M Y H:i:s', $_template->cached->timestamp) . ' GMT'); - break; - } - echo $_output; - } - } else { - echo $_output; - } - // debug output - if ($this->smarty->debugging) { - Smarty_Internal_Debug::display_debug($_template); - } - if ($merge_tpl_vars) { - // restore local variables - $_template->tpl_vars = $save_tpl_vars; - $_template->config_vars = $save_config_vars; - } - - return; - } else { - if ($merge_tpl_vars) { - // restore local variables - $_template->tpl_vars = $save_tpl_vars; - $_template->config_vars = $save_config_vars; - } - // return fetched content - return $_output; - } - } - - /** - * displays a Smarty template - * - * @param string $template the resource handle of the template file or template object - * @param mixed $cache_id cache id to be used with this template - * @param mixed $compile_id compile id to be used with this template - * @param object $parent next higher level of Smarty variables - */ - public function display($template = null, $cache_id = null, $compile_id = null, $parent = null) - { - // display template - $this->fetch($template, $cache_id, $compile_id, $parent, true); - } - - /** - * test if cache is valid - * - * @param string|object $template the resource handle of the template file or template object - * @param mixed $cache_id cache id to be used with this template - * @param mixed $compile_id compile id to be used with this template - * @param object $parent next higher level of Smarty variables - * - * @return boolean cache status - */ - public function isCached($template = null, $cache_id = null, $compile_id = null, $parent = null) - { - if ($template === null && $this instanceof $this->template_class) { - return $this->cached->valid; - } - if (!($template instanceof $this->template_class)) { - if ($parent === null) { - $parent = $this; - } - $template = $this->smarty->createTemplate($template, $cache_id, $compile_id, $parent, false); - } - // return cache status of template - return $template->cached->valid; - } - - /** - * creates a data object - * - * @param object $parent next higher level of Smarty variables - * - * @returns Smarty_Data data object - */ - public function createData($parent = null) - { - return new Smarty_Data($parent, $this); - } - - /** - * Registers plugin to be used in templates - * - * @param string $type plugin type - * @param string $tag name of template tag - * @param callback $callback PHP callback to register - * @param boolean $cacheable if true (default) this fuction is cachable - * @param array $cache_attr caching attributes if any - * - * @return Smarty_Internal_Templatebase current Smarty_Internal_Templatebase (or Smarty or Smarty_Internal_Template) instance for chaining - * @throws SmartyException when the plugin tag is invalid - */ - public function registerPlugin($type, $tag, $callback, $cacheable = true, $cache_attr = null) - { - if (isset($this->smarty->registered_plugins[$type][$tag])) { - throw new SmartyException("Plugin tag \"{$tag}\" already registered"); - } elseif (!is_callable($callback)) { - throw new SmartyException("Plugin \"{$tag}\" not callable"); - } else { - $this->smarty->registered_plugins[$type][$tag] = array($callback, (bool) $cacheable, (array) $cache_attr); - } - - return $this; - } - - /** - * Unregister Plugin - * - * @param string $type of plugin - * @param string $tag name of plugin - * - * @return Smarty_Internal_Templatebase current Smarty_Internal_Templatebase (or Smarty or Smarty_Internal_Template) instance for chaining - */ - public function unregisterPlugin($type, $tag) - { - if (isset($this->smarty->registered_plugins[$type][$tag])) { - unset($this->smarty->registered_plugins[$type][$tag]); - } - - return $this; - } - - /** - * Registers a resource to fetch a template - * - * @param string $type name of resource type - * @param Smarty_Resource|array $callback or instance of Smarty_Resource, or array of callbacks to handle resource (deprecated) - * - * @return Smarty_Internal_Templatebase current Smarty_Internal_Templatebase (or Smarty or Smarty_Internal_Template) instance for chaining - */ - public function registerResource($type, $callback) - { - $this->smarty->registered_resources[$type] = $callback instanceof Smarty_Resource ? $callback : array($callback, false); - - return $this; - } - - /** - * Unregisters a resource - * - * @param string $type name of resource type - * - * @return Smarty_Internal_Templatebase current Smarty_Internal_Templatebase (or Smarty or Smarty_Internal_Template) instance for chaining - */ - public function unregisterResource($type) - { - if (isset($this->smarty->registered_resources[$type])) { - unset($this->smarty->registered_resources[$type]); - } - - return $this; - } - - /** - * Registers a cache resource to cache a template's output - * - * @param string $type name of cache resource type - * @param Smarty_CacheResource $callback instance of Smarty_CacheResource to handle output caching - * - * @return Smarty_Internal_Templatebase current Smarty_Internal_Templatebase (or Smarty or Smarty_Internal_Template) instance for chaining - */ - public function registerCacheResource($type, Smarty_CacheResource $callback) - { - $this->smarty->registered_cache_resources[$type] = $callback; - - return $this; - } - - /** - * Unregisters a cache resource - * - * @param string $type name of cache resource type - * - * @return Smarty_Internal_Templatebase current Smarty_Internal_Templatebase (or Smarty or Smarty_Internal_Template) instance for chaining - */ - public function unregisterCacheResource($type) - { - if (isset($this->smarty->registered_cache_resources[$type])) { - unset($this->smarty->registered_cache_resources[$type]); - } - - return $this; - } - - /** - * Registers object to be used in templates - * - * @param $object_name - * @param object $object_impl the referenced PHP object to register - * @param array $allowed list of allowed methods (empty = all) - * @param boolean $smarty_args smarty argument format, else traditional - * @param array $block_methods list of block-methods - * - * @throws SmartyException - * @return Smarty_Internal_Templatebase current Smarty_Internal_Templatebase (or Smarty or Smarty_Internal_Template) instance for chaining - */ - public function registerObject($object_name, $object_impl, $allowed = array(), $smarty_args = true, $block_methods = array()) - { - // test if allowed methods callable - if (!empty($allowed)) { - foreach ((array) $allowed as $method) { - if (!is_callable(array($object_impl, $method)) && !property_exists($object_impl, $method)) { - throw new SmartyException("Undefined method or property '$method' in registered object"); - } - } - } - // test if block methods callable - if (!empty($block_methods)) { - foreach ((array) $block_methods as $method) { - if (!is_callable(array($object_impl, $method))) { - throw new SmartyException("Undefined method '$method' in registered object"); - } - } - } - // register the object - $this->smarty->registered_objects[$object_name] = - array($object_impl, (array) $allowed, (boolean) $smarty_args, (array) $block_methods); - - return $this; - } - - /** - * return a reference to a registered object - * - * @param string $name object name - * - * @return object - * @throws SmartyException if no such object is found - */ - public function getRegisteredObject($name) - { - if (!isset($this->smarty->registered_objects[$name])) { - throw new SmartyException("'$name' is not a registered object"); - } - if (!is_object($this->smarty->registered_objects[$name][0])) { - throw new SmartyException("registered '$name' is not an object"); - } - - return $this->smarty->registered_objects[$name][0]; - } - - /** - * unregister an object - * - * @param string $name object name - * - * @return Smarty_Internal_Templatebase current Smarty_Internal_Templatebase (or Smarty or Smarty_Internal_Template) instance for chaining - */ - public function unregisterObject($name) - { - if (isset($this->smarty->registered_objects[$name])) { - unset($this->smarty->registered_objects[$name]); - } - - return $this; - } - - /** - * Registers static classes to be used in templates - * - * @param $class_name - * @param string $class_impl the referenced PHP class to register - * - * @throws SmartyException - * @return Smarty_Internal_Templatebase current Smarty_Internal_Templatebase (or Smarty or Smarty_Internal_Template) instance for chaining - */ - public function registerClass($class_name, $class_impl) - { - // test if exists - if (!class_exists($class_impl)) { - throw new SmartyException("Undefined class '$class_impl' in register template class"); - } - // register the class - $this->smarty->registered_classes[$class_name] = $class_impl; - - return $this; - } - - /** - * Registers a default plugin handler - * - * @param callable $callback class/method name - * - * @return Smarty_Internal_Templatebase current Smarty_Internal_Templatebase (or Smarty or Smarty_Internal_Template) instance for chaining - * @throws SmartyException if $callback is not callable - */ - public function registerDefaultPluginHandler($callback) - { - if (is_callable($callback)) { - $this->smarty->default_plugin_handler_func = $callback; - } else { - throw new SmartyException("Default plugin handler '$callback' not callable"); - } - - return $this; - } - - /** - * Registers a default template handler - * - * @param callable $callback class/method name - * - * @return Smarty_Internal_Templatebase current Smarty_Internal_Templatebase (or Smarty or Smarty_Internal_Template) instance for chaining - * @throws SmartyException if $callback is not callable - */ - public function registerDefaultTemplateHandler($callback) - { - if (is_callable($callback)) { - $this->smarty->default_template_handler_func = $callback; - } else { - throw new SmartyException("Default template handler '$callback' not callable"); - } - - return $this; - } - - /** - * Registers a default template handler - * - * @param callable $callback class/method name - * - * @return Smarty_Internal_Templatebase current Smarty_Internal_Templatebase (or Smarty or Smarty_Internal_Template) instance for chaining - * @throws SmartyException if $callback is not callable - */ - public function registerDefaultConfigHandler($callback) - { - if (is_callable($callback)) { - $this->smarty->default_config_handler_func = $callback; - } else { - throw new SmartyException("Default config handler '$callback' not callable"); - } - - return $this; - } - - /** - * Registers a filter function - * - * @param string $type filter type - * @param callback $callback - * - * @return Smarty_Internal_Templatebase current Smarty_Internal_Templatebase (or Smarty or Smarty_Internal_Template) instance for chaining - */ - public function registerFilter($type, $callback) - { - $this->smarty->registered_filters[$type][$this->_get_filter_name($callback)] = $callback; - - return $this; - } - - /** - * Unregisters a filter function - * - * @param string $type filter type - * @param callback $callback - * - * @return Smarty_Internal_Templatebase current Smarty_Internal_Templatebase (or Smarty or Smarty_Internal_Template) instance for chaining - */ - public function unregisterFilter($type, $callback) - { - $name = $this->_get_filter_name($callback); - if (isset($this->smarty->registered_filters[$type][$name])) { - unset($this->smarty->registered_filters[$type][$name]); - } - - return $this; - } - - /** - * Return internal filter name - * - * @param callback $function_name - * - * @return string internal filter name - */ - public function _get_filter_name($function_name) - { - if (is_array($function_name)) { - $_class_name = (is_object($function_name[0]) ? - get_class($function_name[0]) : $function_name[0]); - - return $_class_name . '_' . $function_name[1]; - } else { - return $function_name; - } - } - - /** - * load a filter of specified type and name - * - * @param string $type filter type - * @param string $name filter name - * - * @throws SmartyException if filter could not be loaded - */ - public function loadFilter($type, $name) - { - $_plugin = "smarty_{$type}filter_{$name}"; - $_filter_name = $_plugin; - if ($this->smarty->loadPlugin($_plugin)) { - if (class_exists($_plugin, false)) { - $_plugin = array($_plugin, 'execute'); - } - if (is_callable($_plugin)) { - $this->smarty->registered_filters[$type][$_filter_name] = $_plugin; - - return true; - } - } - throw new SmartyException("{$type}filter \"{$name}\" not callable"); - } - - /** - * unload a filter of specified type and name - * - * @param string $type filter type - * @param string $name filter name - * - * @return Smarty_Internal_Templatebase current Smarty_Internal_Templatebase (or Smarty or Smarty_Internal_Template) instance for chaining - */ - public function unloadFilter($type, $name) - { - $_filter_name = "smarty_{$type}filter_{$name}"; - if (isset($this->smarty->registered_filters[$type][$_filter_name])) { - unset ($this->smarty->registered_filters[$type][$_filter_name]); - } - - return $this; - } - - /** - * preg_replace callback to convert camelcase getter/setter to underscore property names - * - * @param string $match match string - * - * @return string replacemant - */ - private function replaceCamelcase($match) - { - return "_" . strtolower($match[1]); - } - - /** - * Handle unknown class methods - * - * @param string $name unknown method-name - * @param array $args argument array - * - * @throws SmartyException - */ - public function __call($name, $args) - { - static $_prefixes = array('set' => true, 'get' => true); - static $_resolved_property_name = array(); - static $_resolved_property_source = array(); - - // method of Smarty object? - if (method_exists($this->smarty, $name)) { - return call_user_func_array(array($this->smarty, $name), $args); - } - // see if this is a set/get for a property - $first3 = strtolower(substr($name, 0, 3)); - if (isset($_prefixes[$first3]) && isset($name[3]) && $name[3] !== '_') { - if (isset($_resolved_property_name[$name])) { - $property_name = $_resolved_property_name[$name]; - } else { - // try to keep case correct for future PHP 6.0 case-sensitive class methods - // lcfirst() not available < PHP 5.3.0, so improvise - $property_name = strtolower(substr($name, 3, 1)) . substr($name, 4); - // convert camel case to underscored name - $property_name = preg_replace_callback('/([A-Z])/', array($this, 'replaceCamelcase'), $property_name); - $_resolved_property_name[$name] = $property_name; - } - if (isset($_resolved_property_source[$property_name])) { - $_is_this = $_resolved_property_source[$property_name]; - } else { - $_is_this = null; - if (property_exists($this, $property_name)) { - $_is_this = true; - } elseif (property_exists($this->smarty, $property_name)) { - $_is_this = false; - } - $_resolved_property_source[$property_name] = $_is_this; - } - if ($_is_this) { - if ($first3 == 'get') { - return $this->$property_name; - } else { - return $this->$property_name = $args[0]; - } - } elseif ($_is_this === false) { - if ($first3 == 'get') { - return $this->smarty->$property_name; - } else { - return $this->smarty->$property_name = $args[0]; - } - } else { - throw new SmartyException("property '$property_name' does not exist."); - } - } - if ($name == 'Smarty') { - throw new SmartyException("PHP5 requires you to call __construct() instead of Smarty()"); - } - // must be unknown - throw new SmartyException("Call of unknown method '$name'."); - } -} +<<<<<<< HEAD +template_class) { + $template = $this; + } + if ($cache_id !== null && is_object($cache_id)) { + $parent = $cache_id; + $cache_id = null; + } + if ($parent === null && ($this instanceof Smarty || is_string($template))) { + $parent = $this; + } + // create template object if necessary + $_template = ($template instanceof $this->template_class) + ? $template + : $this->smarty->createTemplate($template, $cache_id, $compile_id, $parent, false); + // if called by Smarty object make sure we use current caching status + if ($this instanceof Smarty) { + $_template->caching = $this->caching; + } + // merge all variable scopes into template + if ($merge_tpl_vars) { + // save local variables + $save_tpl_vars = $_template->tpl_vars; + $save_config_vars = $_template->config_vars; + $ptr_array = array($_template); + $ptr = $_template; + while (isset($ptr->parent)) { + $ptr_array[] = $ptr = $ptr->parent; + } + $ptr_array = array_reverse($ptr_array); + $parent_ptr = reset($ptr_array); + $tpl_vars = $parent_ptr->tpl_vars; + $config_vars = $parent_ptr->config_vars; + while ($parent_ptr = next($ptr_array)) { + if (!empty($parent_ptr->tpl_vars)) { + $tpl_vars = array_merge($tpl_vars, $parent_ptr->tpl_vars); + } + if (!empty($parent_ptr->config_vars)) { + $config_vars = array_merge($config_vars, $parent_ptr->config_vars); + } + } + if (!empty(Smarty::$global_tpl_vars)) { + $tpl_vars = array_merge(Smarty::$global_tpl_vars, $tpl_vars); + } + $_template->tpl_vars = $tpl_vars; + $_template->config_vars = $config_vars; + } + // dummy local smarty variable + if (!isset($_template->tpl_vars['smarty'])) { + $_template->tpl_vars['smarty'] = new Smarty_Variable; + } + if (isset($this->smarty->error_reporting)) { + $_smarty_old_error_level = error_reporting($this->smarty->error_reporting); + } + // check URL debugging control + if (!$this->smarty->debugging && $this->smarty->debugging_ctrl == 'URL') { + if (isset($_SERVER['QUERY_STRING'])) { + $_query_string = $_SERVER['QUERY_STRING']; + } else { + $_query_string = ''; + } + if (false !== strpos($_query_string, $this->smarty->smarty_debug_id)) { + if (false !== strpos($_query_string, $this->smarty->smarty_debug_id . '=on')) { + // enable debugging for this browser session + setcookie('SMARTY_DEBUG', true); + $this->smarty->debugging = true; + } elseif (false !== strpos($_query_string, $this->smarty->smarty_debug_id . '=off')) { + // disable debugging for this browser session + setcookie('SMARTY_DEBUG', false); + $this->smarty->debugging = false; + } else { + // enable debugging for this page + $this->smarty->debugging = true; + } + } else { + if (isset($_COOKIE['SMARTY_DEBUG'])) { + $this->smarty->debugging = true; + } + } + } + // must reset merge template date + $_template->smarty->merged_templates_func = array(); + // get rendered template + // disable caching for evaluated code + if ($_template->source->recompiled) { + $_template->caching = false; + } + // checks if template exists + if (!$_template->source->exists) { + if ($_template->parent instanceof Smarty_Internal_Template) { + $parent_resource = " in '{$_template->parent->template_resource}'"; + } else { + $parent_resource = ''; + } + throw new SmartyException("Unable to load template {$_template->source->type} '{$_template->source->name}'{$parent_resource}"); + } + // read from cache or render + if (!($_template->caching == Smarty::CACHING_LIFETIME_CURRENT || $_template->caching == Smarty::CACHING_LIFETIME_SAVED) || !$_template->cached->valid) { + // render template (not loaded and not in cache) + if (!$_template->source->uncompiled) { + /** @var Smarty_Internal_Template $_smarty_tpl + * used in evaluated code + */ + $_smarty_tpl = $_template; + if ($_template->source->recompiled) { + $code = $_template->compiler->compileTemplate($_template); + if ($this->smarty->debugging) { + Smarty_Internal_Debug::start_render($_template); + } + try { + ob_start(); + eval("?>" . $code); + unset($code); + } + catch (Exception $e) { + ob_get_clean(); + throw $e; + } + } else { + if (!$_template->compiled->exists || ($_template->smarty->force_compile && !$_template->compiled->isCompiled)) { + $_template->compileTemplateSource(); + $code = file_get_contents($_template->compiled->filepath); + eval("?>" . $code); + unset($code); + $_template->compiled->loaded = true; + $_template->compiled->isCompiled = true; + } + if ($this->smarty->debugging) { + Smarty_Internal_Debug::start_render($_template); + } + if (!$_template->compiled->loaded) { + include($_template->compiled->filepath); + if ($_template->mustCompile) { + // recompile and load again + $_template->compileTemplateSource(); + $code = file_get_contents($_template->compiled->filepath); + eval("?>" . $code); + unset($code); + $_template->compiled->isCompiled = true; + } + $_template->compiled->loaded = true; + } else { + $_template->decodeProperties($_template->compiled->_properties, false); + } + try { + ob_start(); + if (empty($_template->properties['unifunc']) || !is_callable($_template->properties['unifunc'])) { + throw new SmartyException("Invalid compiled template for '{$_template->template_resource}'"); + } + array_unshift($_template->_capture_stack, array()); + // + // render compiled template + // + $_template->properties['unifunc']($_template); + // any unclosed {capture} tags ? + if (isset($_template->_capture_stack[0][0])) { + $_template->capture_error(); + } + array_shift($_template->_capture_stack); + } + catch (Exception $e) { + ob_get_clean(); + throw $e; + } + } + } else { + if ($_template->source->uncompiled) { + if ($this->smarty->debugging) { + Smarty_Internal_Debug::start_render($_template); + } + try { + ob_start(); + $_template->source->renderUncompiled($_template); + } + catch (Exception $e) { + ob_get_clean(); + throw $e; + } + } else { + throw new SmartyException("Resource '$_template->source->type' must have 'renderUncompiled' method"); + } + } + $_output = ob_get_clean(); + if (!$_template->source->recompiled && empty($_template->properties['file_dependency'][$_template->source->uid])) { + $_template->properties['file_dependency'][$_template->source->uid] = array($_template->source->filepath, $_template->source->timestamp, $_template->source->type); + } + if ($_template->parent instanceof Smarty_Internal_Template) { + $_template->parent->properties['file_dependency'] = array_merge($_template->parent->properties['file_dependency'], $_template->properties['file_dependency']); + foreach ($_template->required_plugins as $code => $tmp1) { + foreach ($tmp1 as $name => $tmp) { + foreach ($tmp as $type => $data) { + $_template->parent->required_plugins[$code][$name][$type] = $data; + } + } + } + } + if ($this->smarty->debugging) { + Smarty_Internal_Debug::end_render($_template); + } + // write to cache when nessecary + if (!$_template->source->recompiled && ($_template->caching == Smarty::CACHING_LIFETIME_SAVED || $_template->caching == Smarty::CACHING_LIFETIME_CURRENT)) { + if ($this->smarty->debugging) { + Smarty_Internal_Debug::start_cache($_template); + } + $_template->properties['has_nocache_code'] = false; + // get text between non-cached items + $cache_split = preg_split("!/\*%%SmartyNocache:{$_template->properties['nocache_hash']}%%\*\/(.+?)/\*/%%SmartyNocache:{$_template->properties['nocache_hash']}%%\*/!s", $_output); + // get non-cached items + preg_match_all("!/\*%%SmartyNocache:{$_template->properties['nocache_hash']}%%\*\/(.+?)/\*/%%SmartyNocache:{$_template->properties['nocache_hash']}%%\*/!s", $_output, $cache_parts); + $output = ''; + // loop over items, stitch back together + foreach ($cache_split as $curr_idx => $curr_split) { + // escape PHP tags in template content + $output .= preg_replace('/(<%|%>|<\?php|<\?|\?>|)/', "\n", $curr_split); + if (isset($cache_parts[0][$curr_idx])) { + $_template->properties['has_nocache_code'] = true; + // remove nocache tags from cache output + $output .= preg_replace("!/\*/?%%SmartyNocache:{$_template->properties['nocache_hash']}%%\*/!", '', $cache_parts[0][$curr_idx]); + } + } + if (!$no_output_filter && !$_template->has_nocache_code && (isset($this->smarty->autoload_filters['output']) || isset($this->smarty->registered_filters['output']))) { + $output = Smarty_Internal_Filter_Handler::runFilter('output', $output, $_template); + } + // rendering (must be done before writing cache file because of {function} nocache handling) + /** @var Smarty_Internal_Template $_smarty_tpl + * used in evaluated code + */ + $_smarty_tpl = $_template; + try { + ob_start(); + eval("?>" . $output); + $_output = ob_get_clean(); + } + catch (Exception $e) { + ob_get_clean(); + throw $e; + } + // write cache file content + $_template->writeCachedContent($output); + if ($this->smarty->debugging) { + Smarty_Internal_Debug::end_cache($_template); + } + } else { + // var_dump('renderTemplate', $_template->has_nocache_code, $_template->template_resource, $_template->properties['nocache_hash'], $_template->parent->properties['nocache_hash'], $_output); + if (!empty($_template->properties['nocache_hash']) && !empty($_template->parent->properties['nocache_hash'])) { + // replace nocache_hash + $_output = str_replace("{$_template->properties['nocache_hash']}", $_template->parent->properties['nocache_hash'], $_output); + $_template->parent->has_nocache_code = $_template->parent->has_nocache_code || $_template->has_nocache_code; + } + } + } else { + if ($this->smarty->debugging) { + Smarty_Internal_Debug::start_cache($_template); + } + try { + ob_start(); + array_unshift($_template->_capture_stack, array()); + // + // render cached template + // + $_template->properties['unifunc']($_template); + // any unclosed {capture} tags ? + if (isset($_template->_capture_stack[0][0])) { + $_template->capture_error(); + } + array_shift($_template->_capture_stack); + $_output = ob_get_clean(); + } + catch (Exception $e) { + ob_get_clean(); + throw $e; + } + if ($this->smarty->debugging) { + Smarty_Internal_Debug::end_cache($_template); + } + } + if ((!$this->caching || $_template->has_nocache_code || $_template->source->recompiled) && !$no_output_filter && (isset($this->smarty->autoload_filters['output']) || isset($this->smarty->registered_filters['output']))) { + $_output = Smarty_Internal_Filter_Handler::runFilter('output', $_output, $_template); + } + if (isset($this->error_reporting)) { + error_reporting($_smarty_old_error_level); + } + // display or fetch + if ($display) { + if ($this->caching && $this->cache_modified_check) { + $_isCached = $_template->isCached() && !$_template->has_nocache_code; + $_last_modified_date = @substr($_SERVER['HTTP_IF_MODIFIED_SINCE'], 0, strpos($_SERVER['HTTP_IF_MODIFIED_SINCE'], 'GMT') + 3); + if ($_isCached && $_template->cached->timestamp <= strtotime($_last_modified_date)) { + switch (PHP_SAPI) { + case 'cgi': // php-cgi < 5.3 + case 'cgi-fcgi': // php-cgi >= 5.3 + case 'fpm-fcgi': // php-fpm >= 5.3.3 + header('Status: 304 Not Modified'); + break; + + case 'cli': + if ( /* ^phpunit */ + !empty($_SERVER['SMARTY_PHPUNIT_DISABLE_HEADERS']) /* phpunit$ */ + ) { + $_SERVER['SMARTY_PHPUNIT_HEADERS'][] = '304 Not Modified'; + } + break; + + default: + header($_SERVER['SERVER_PROTOCOL'] . ' 304 Not Modified'); + break; + } + } else { + switch (PHP_SAPI) { + case 'cli': + if ( /* ^phpunit */ + !empty($_SERVER['SMARTY_PHPUNIT_DISABLE_HEADERS']) /* phpunit$ */ + ) { + $_SERVER['SMARTY_PHPUNIT_HEADERS'][] = 'Last-Modified: ' . gmdate('D, d M Y H:i:s', $_template->cached->timestamp) . ' GMT'; + } + break; + + default: + header('Last-Modified: ' . gmdate('D, d M Y H:i:s', $_template->cached->timestamp) . ' GMT'); + break; + } + echo $_output; + } + } else { + echo $_output; + } + // debug output + if ($this->smarty->debugging) { + Smarty_Internal_Debug::display_debug($_template); + } + if ($merge_tpl_vars) { + // restore local variables + $_template->tpl_vars = $save_tpl_vars; + $_template->config_vars = $save_config_vars; + } + + return; + } else { + if ($merge_tpl_vars) { + // restore local variables + $_template->tpl_vars = $save_tpl_vars; + $_template->config_vars = $save_config_vars; + } + // return fetched content + return $_output; + } + } + + /** + * displays a Smarty template + * + * @param string $template the resource handle of the template file or template object + * @param mixed $cache_id cache id to be used with this template + * @param mixed $compile_id compile id to be used with this template + * @param object $parent next higher level of Smarty variables + */ + public function display($template = null, $cache_id = null, $compile_id = null, $parent = null) + { + // display template + $this->fetch($template, $cache_id, $compile_id, $parent, true); + } + + /** + * test if cache is valid + * + * @param string|object $template the resource handle of the template file or template object + * @param mixed $cache_id cache id to be used with this template + * @param mixed $compile_id compile id to be used with this template + * @param object $parent next higher level of Smarty variables + * + * @return boolean cache status + */ + public function isCached($template = null, $cache_id = null, $compile_id = null, $parent = null) + { + if ($template === null && $this instanceof $this->template_class) { + return $this->cached->valid; + } + if (!($template instanceof $this->template_class)) { + if ($parent === null) { + $parent = $this; + } + $template = $this->smarty->createTemplate($template, $cache_id, $compile_id, $parent, false); + } + // return cache status of template + return $template->cached->valid; + } + + /** + * creates a data object + * + * @param object $parent next higher level of Smarty variables + * + * @returns Smarty_Data data object + */ + public function createData($parent = null) + { + return new Smarty_Data($parent, $this); + } + + /** + * Registers plugin to be used in templates + * + * @param string $type plugin type + * @param string $tag name of template tag + * @param callback $callback PHP callback to register + * @param boolean $cacheable if true (default) this fuction is cachable + * @param array $cache_attr caching attributes if any + * + * @return Smarty_Internal_Templatebase current Smarty_Internal_Templatebase (or Smarty or Smarty_Internal_Template) instance for chaining + * @throws SmartyException when the plugin tag is invalid + */ + public function registerPlugin($type, $tag, $callback, $cacheable = true, $cache_attr = null) + { + if (isset($this->smarty->registered_plugins[$type][$tag])) { + throw new SmartyException("Plugin tag \"{$tag}\" already registered"); + } elseif (!is_callable($callback)) { + throw new SmartyException("Plugin \"{$tag}\" not callable"); + } else { + $this->smarty->registered_plugins[$type][$tag] = array($callback, (bool) $cacheable, (array) $cache_attr); + } + + return $this; + } + + /** + * Unregister Plugin + * + * @param string $type of plugin + * @param string $tag name of plugin + * + * @return Smarty_Internal_Templatebase current Smarty_Internal_Templatebase (or Smarty or Smarty_Internal_Template) instance for chaining + */ + public function unregisterPlugin($type, $tag) + { + if (isset($this->smarty->registered_plugins[$type][$tag])) { + unset($this->smarty->registered_plugins[$type][$tag]); + } + + return $this; + } + + /** + * Registers a resource to fetch a template + * + * @param string $type name of resource type + * @param Smarty_Resource|array $callback or instance of Smarty_Resource, or array of callbacks to handle resource (deprecated) + * + * @return Smarty_Internal_Templatebase current Smarty_Internal_Templatebase (or Smarty or Smarty_Internal_Template) instance for chaining + */ + public function registerResource($type, $callback) + { + $this->smarty->registered_resources[$type] = $callback instanceof Smarty_Resource ? $callback : array($callback, false); + + return $this; + } + + /** + * Unregisters a resource + * + * @param string $type name of resource type + * + * @return Smarty_Internal_Templatebase current Smarty_Internal_Templatebase (or Smarty or Smarty_Internal_Template) instance for chaining + */ + public function unregisterResource($type) + { + if (isset($this->smarty->registered_resources[$type])) { + unset($this->smarty->registered_resources[$type]); + } + + return $this; + } + + /** + * Registers a cache resource to cache a template's output + * + * @param string $type name of cache resource type + * @param Smarty_CacheResource $callback instance of Smarty_CacheResource to handle output caching + * + * @return Smarty_Internal_Templatebase current Smarty_Internal_Templatebase (or Smarty or Smarty_Internal_Template) instance for chaining + */ + public function registerCacheResource($type, Smarty_CacheResource $callback) + { + $this->smarty->registered_cache_resources[$type] = $callback; + + return $this; + } + + /** + * Unregisters a cache resource + * + * @param string $type name of cache resource type + * + * @return Smarty_Internal_Templatebase current Smarty_Internal_Templatebase (or Smarty or Smarty_Internal_Template) instance for chaining + */ + public function unregisterCacheResource($type) + { + if (isset($this->smarty->registered_cache_resources[$type])) { + unset($this->smarty->registered_cache_resources[$type]); + } + + return $this; + } + + /** + * Registers object to be used in templates + * + * @param $object_name + * @param object $object_impl the referenced PHP object to register + * @param array $allowed list of allowed methods (empty = all) + * @param boolean $smarty_args smarty argument format, else traditional + * @param array $block_methods list of block-methods + * + * @throws SmartyException + * @return Smarty_Internal_Templatebase current Smarty_Internal_Templatebase (or Smarty or Smarty_Internal_Template) instance for chaining + */ + public function registerObject($object_name, $object_impl, $allowed = array(), $smarty_args = true, $block_methods = array()) + { + // test if allowed methods callable + if (!empty($allowed)) { + foreach ((array) $allowed as $method) { + if (!is_callable(array($object_impl, $method)) && !property_exists($object_impl, $method)) { + throw new SmartyException("Undefined method or property '$method' in registered object"); + } + } + } + // test if block methods callable + if (!empty($block_methods)) { + foreach ((array) $block_methods as $method) { + if (!is_callable(array($object_impl, $method))) { + throw new SmartyException("Undefined method '$method' in registered object"); + } + } + } + // register the object + $this->smarty->registered_objects[$object_name] = + array($object_impl, (array) $allowed, (boolean) $smarty_args, (array) $block_methods); + + return $this; + } + + /** + * return a reference to a registered object + * + * @param string $name object name + * + * @return object + * @throws SmartyException if no such object is found + */ + public function getRegisteredObject($name) + { + if (!isset($this->smarty->registered_objects[$name])) { + throw new SmartyException("'$name' is not a registered object"); + } + if (!is_object($this->smarty->registered_objects[$name][0])) { + throw new SmartyException("registered '$name' is not an object"); + } + + return $this->smarty->registered_objects[$name][0]; + } + + /** + * unregister an object + * + * @param string $name object name + * + * @return Smarty_Internal_Templatebase current Smarty_Internal_Templatebase (or Smarty or Smarty_Internal_Template) instance for chaining + */ + public function unregisterObject($name) + { + if (isset($this->smarty->registered_objects[$name])) { + unset($this->smarty->registered_objects[$name]); + } + + return $this; + } + + /** + * Registers static classes to be used in templates + * + * @param $class_name + * @param string $class_impl the referenced PHP class to register + * + * @throws SmartyException + * @return Smarty_Internal_Templatebase current Smarty_Internal_Templatebase (or Smarty or Smarty_Internal_Template) instance for chaining + */ + public function registerClass($class_name, $class_impl) + { + // test if exists + if (!class_exists($class_impl)) { + throw new SmartyException("Undefined class '$class_impl' in register template class"); + } + // register the class + $this->smarty->registered_classes[$class_name] = $class_impl; + + return $this; + } + + /** + * Registers a default plugin handler + * + * @param callable $callback class/method name + * + * @return Smarty_Internal_Templatebase current Smarty_Internal_Templatebase (or Smarty or Smarty_Internal_Template) instance for chaining + * @throws SmartyException if $callback is not callable + */ + public function registerDefaultPluginHandler($callback) + { + if (is_callable($callback)) { + $this->smarty->default_plugin_handler_func = $callback; + } else { + throw new SmartyException("Default plugin handler '$callback' not callable"); + } + + return $this; + } + + /** + * Registers a default template handler + * + * @param callable $callback class/method name + * + * @return Smarty_Internal_Templatebase current Smarty_Internal_Templatebase (or Smarty or Smarty_Internal_Template) instance for chaining + * @throws SmartyException if $callback is not callable + */ + public function registerDefaultTemplateHandler($callback) + { + if (is_callable($callback)) { + $this->smarty->default_template_handler_func = $callback; + } else { + throw new SmartyException("Default template handler '$callback' not callable"); + } + + return $this; + } + + /** + * Registers a default template handler + * + * @param callable $callback class/method name + * + * @return Smarty_Internal_Templatebase current Smarty_Internal_Templatebase (or Smarty or Smarty_Internal_Template) instance for chaining + * @throws SmartyException if $callback is not callable + */ + public function registerDefaultConfigHandler($callback) + { + if (is_callable($callback)) { + $this->smarty->default_config_handler_func = $callback; + } else { + throw new SmartyException("Default config handler '$callback' not callable"); + } + + return $this; + } + + /** + * Registers a filter function + * + * @param string $type filter type + * @param callback $callback + * + * @return Smarty_Internal_Templatebase current Smarty_Internal_Templatebase (or Smarty or Smarty_Internal_Template) instance for chaining + */ + public function registerFilter($type, $callback) + { + $this->smarty->registered_filters[$type][$this->_get_filter_name($callback)] = $callback; + + return $this; + } + + /** + * Unregisters a filter function + * + * @param string $type filter type + * @param callback $callback + * + * @return Smarty_Internal_Templatebase current Smarty_Internal_Templatebase (or Smarty or Smarty_Internal_Template) instance for chaining + */ + public function unregisterFilter($type, $callback) + { + $name = $this->_get_filter_name($callback); + if (isset($this->smarty->registered_filters[$type][$name])) { + unset($this->smarty->registered_filters[$type][$name]); + } + + return $this; + } + + /** + * Return internal filter name + * + * @param callback $function_name + * + * @return string internal filter name + */ + public function _get_filter_name($function_name) + { + if (is_array($function_name)) { + $_class_name = (is_object($function_name[0]) ? + get_class($function_name[0]) : $function_name[0]); + + return $_class_name . '_' . $function_name[1]; + } else { + return $function_name; + } + } + + /** + * load a filter of specified type and name + * + * @param string $type filter type + * @param string $name filter name + * + * @throws SmartyException if filter could not be loaded + */ + public function loadFilter($type, $name) + { + $_plugin = "smarty_{$type}filter_{$name}"; + $_filter_name = $_plugin; + if ($this->smarty->loadPlugin($_plugin)) { + if (class_exists($_plugin, false)) { + $_plugin = array($_plugin, 'execute'); + } + if (is_callable($_plugin)) { + $this->smarty->registered_filters[$type][$_filter_name] = $_plugin; + + return true; + } + } + throw new SmartyException("{$type}filter \"{$name}\" not callable"); + } + + /** + * unload a filter of specified type and name + * + * @param string $type filter type + * @param string $name filter name + * + * @return Smarty_Internal_Templatebase current Smarty_Internal_Templatebase (or Smarty or Smarty_Internal_Template) instance for chaining + */ + public function unloadFilter($type, $name) + { + $_filter_name = "smarty_{$type}filter_{$name}"; + if (isset($this->smarty->registered_filters[$type][$_filter_name])) { + unset ($this->smarty->registered_filters[$type][$_filter_name]); + } + + return $this; + } + + /** + * preg_replace callback to convert camelcase getter/setter to underscore property names + * + * @param string $match match string + * + * @return string replacemant + */ + private function replaceCamelcase($match) + { + return "_" . strtolower($match[1]); + } + + /** + * Handle unknown class methods + * + * @param string $name unknown method-name + * @param array $args argument array + * + * @throws SmartyException + */ + public function __call($name, $args) + { + static $_prefixes = array('set' => true, 'get' => true); + static $_resolved_property_name = array(); + static $_resolved_property_source = array(); + + // method of Smarty object? + if (method_exists($this->smarty, $name)) { + return call_user_func_array(array($this->smarty, $name), $args); + } + // see if this is a set/get for a property + $first3 = strtolower(substr($name, 0, 3)); + if (isset($_prefixes[$first3]) && isset($name[3]) && $name[3] !== '_') { + if (isset($_resolved_property_name[$name])) { + $property_name = $_resolved_property_name[$name]; + } else { + // try to keep case correct for future PHP 6.0 case-sensitive class methods + // lcfirst() not available < PHP 5.3.0, so improvise + $property_name = strtolower(substr($name, 3, 1)) . substr($name, 4); + // convert camel case to underscored name + $property_name = preg_replace_callback('/([A-Z])/', array($this, 'replaceCamelcase'), $property_name); + $_resolved_property_name[$name] = $property_name; + } + if (isset($_resolved_property_source[$property_name])) { + $_is_this = $_resolved_property_source[$property_name]; + } else { + $_is_this = null; + if (property_exists($this, $property_name)) { + $_is_this = true; + } elseif (property_exists($this->smarty, $property_name)) { + $_is_this = false; + } + $_resolved_property_source[$property_name] = $_is_this; + } + if ($_is_this) { + if ($first3 == 'get') { + return $this->$property_name; + } else { + return $this->$property_name = $args[0]; + } + } elseif ($_is_this === false) { + if ($first3 == 'get') { + return $this->smarty->$property_name; + } else { + return $this->smarty->$property_name = $args[0]; + } + } else { + throw new SmartyException("property '$property_name' does not exist."); + } + } + if ($name == 'Smarty') { + throw new SmartyException("PHP5 requires you to call __construct() instead of Smarty()"); + } + // must be unknown + throw new SmartyException("Call of unknown method '$name'."); + } +} +======= +template_class) { + $template = $this; + } + if ($cache_id !== null && is_object($cache_id)) { + $parent = $cache_id; + $cache_id = null; + } + if ($parent === null && ($this instanceof Smarty || is_string($template))) { + $parent = $this; + } + // create template object if necessary + $_template = ($template instanceof $this->template_class) + ? $template + : $this->smarty->createTemplate($template, $cache_id, $compile_id, $parent, false); + // if called by Smarty object make sure we use current caching status + if ($this instanceof Smarty) { + $_template->caching = $this->caching; + } + // merge all variable scopes into template + if ($merge_tpl_vars) { + // save local variables + $save_tpl_vars = $_template->tpl_vars; + $save_config_vars = $_template->config_vars; + $ptr_array = array($_template); + $ptr = $_template; + while (isset($ptr->parent)) { + $ptr_array[] = $ptr = $ptr->parent; + } + $ptr_array = array_reverse($ptr_array); + $parent_ptr = reset($ptr_array); + $tpl_vars = $parent_ptr->tpl_vars; + $config_vars = $parent_ptr->config_vars; + while ($parent_ptr = next($ptr_array)) { + if (!empty($parent_ptr->tpl_vars)) { + $tpl_vars = array_merge($tpl_vars, $parent_ptr->tpl_vars); + } + if (!empty($parent_ptr->config_vars)) { + $config_vars = array_merge($config_vars, $parent_ptr->config_vars); + } + } + if (!empty(Smarty::$global_tpl_vars)) { + $tpl_vars = array_merge(Smarty::$global_tpl_vars, $tpl_vars); + } + $_template->tpl_vars = $tpl_vars; + $_template->config_vars = $config_vars; + } + // dummy local smarty variable + if (!isset($_template->tpl_vars['smarty'])) { + $_template->tpl_vars['smarty'] = new Smarty_Variable; + } + if (isset($this->smarty->error_reporting)) { + $_smarty_old_error_level = error_reporting($this->smarty->error_reporting); + } + // check URL debugging control + if (!$this->smarty->debugging && $this->smarty->debugging_ctrl == 'URL') { + if (isset($_SERVER['QUERY_STRING'])) { + $_query_string = $_SERVER['QUERY_STRING']; + } else { + $_query_string = ''; + } + if (false !== strpos($_query_string, $this->smarty->smarty_debug_id)) { + if (false !== strpos($_query_string, $this->smarty->smarty_debug_id . '=on')) { + // enable debugging for this browser session + setcookie('SMARTY_DEBUG', true); + $this->smarty->debugging = true; + } elseif (false !== strpos($_query_string, $this->smarty->smarty_debug_id . '=off')) { + // disable debugging for this browser session + setcookie('SMARTY_DEBUG', false); + $this->smarty->debugging = false; + } else { + // enable debugging for this page + $this->smarty->debugging = true; + } + } else { + if (isset($_COOKIE['SMARTY_DEBUG'])) { + $this->smarty->debugging = true; + } + } + } + // must reset merge template date + $_template->smarty->merged_templates_func = array(); + // get rendered template + // disable caching for evaluated code + if ($_template->source->recompiled) { + $_template->caching = false; + } + // checks if template exists + if (!$_template->source->exists) { + if ($_template->parent instanceof Smarty_Internal_Template) { + $parent_resource = " in '{$_template->parent->template_resource}'"; + } else { + $parent_resource = ''; + } + throw new SmartyException("Unable to load template {$_template->source->type} '{$_template->source->name}'{$parent_resource}"); + } + // read from cache or render + if (!($_template->caching == Smarty::CACHING_LIFETIME_CURRENT || $_template->caching == Smarty::CACHING_LIFETIME_SAVED) || !$_template->cached->valid) { + // render template (not loaded and not in cache) + if (!$_template->source->uncompiled) { + /** @var Smarty_Internal_Template $_smarty_tpl + * used in evaluated code + */ + $_smarty_tpl = $_template; + if ($_template->source->recompiled) { + $code = $_template->compiler->compileTemplate($_template); + if ($this->smarty->debugging) { + Smarty_Internal_Debug::start_render($_template); + } + try { + ob_start(); + eval("?>" . $code); + unset($code); + } + catch (Exception $e) { + ob_get_clean(); + throw $e; + } + } else { + if (!$_template->compiled->exists || ($_template->smarty->force_compile && !$_template->compiled->isCompiled)) { + $_template->compileTemplateSource(); + $code = file_get_contents($_template->compiled->filepath); + eval("?>" . $code); + unset($code); + $_template->compiled->loaded = true; + $_template->compiled->isCompiled = true; + } + if ($this->smarty->debugging) { + Smarty_Internal_Debug::start_render($_template); + } + if (!$_template->compiled->loaded) { + include($_template->compiled->filepath); + if ($_template->mustCompile) { + // recompile and load again + $_template->compileTemplateSource(); + $code = file_get_contents($_template->compiled->filepath); + eval("?>" . $code); + unset($code); + $_template->compiled->isCompiled = true; + } + $_template->compiled->loaded = true; + } else { + $_template->decodeProperties($_template->compiled->_properties, false); + } + try { + ob_start(); + if (empty($_template->properties['unifunc']) || !is_callable($_template->properties['unifunc'])) { + throw new SmartyException("Invalid compiled template for '{$_template->template_resource}'"); + } + array_unshift($_template->_capture_stack, array()); + // + // render compiled template + // + $_template->properties['unifunc']($_template); + // any unclosed {capture} tags ? + if (isset($_template->_capture_stack[0][0])) { + $_template->capture_error(); + } + array_shift($_template->_capture_stack); + } + catch (Exception $e) { + ob_get_clean(); + throw $e; + } + } + } else { + if ($_template->source->uncompiled) { + if ($this->smarty->debugging) { + Smarty_Internal_Debug::start_render($_template); + } + try { + ob_start(); + $_template->source->renderUncompiled($_template); + } + catch (Exception $e) { + ob_get_clean(); + throw $e; + } + } else { + throw new SmartyException("Resource '$_template->source->type' must have 'renderUncompiled' method"); + } + } + $_output = ob_get_clean(); + if (!$_template->source->recompiled && empty($_template->properties['file_dependency'][$_template->source->uid])) { + $_template->properties['file_dependency'][$_template->source->uid] = array($_template->source->filepath, $_template->source->timestamp, $_template->source->type); + } + if ($_template->parent instanceof Smarty_Internal_Template) { + $_template->parent->properties['file_dependency'] = array_merge($_template->parent->properties['file_dependency'], $_template->properties['file_dependency']); + foreach ($_template->required_plugins as $code => $tmp1) { + foreach ($tmp1 as $name => $tmp) { + foreach ($tmp as $type => $data) { + $_template->parent->required_plugins[$code][$name][$type] = $data; + } + } + } + } + if ($this->smarty->debugging) { + Smarty_Internal_Debug::end_render($_template); + } + // write to cache when nessecary + if (!$_template->source->recompiled && ($_template->caching == Smarty::CACHING_LIFETIME_SAVED || $_template->caching == Smarty::CACHING_LIFETIME_CURRENT)) { + if ($this->smarty->debugging) { + Smarty_Internal_Debug::start_cache($_template); + } + $_template->properties['has_nocache_code'] = false; + // get text between non-cached items + $cache_split = preg_split("!/\*%%SmartyNocache:{$_template->properties['nocache_hash']}%%\*\/(.+?)/\*/%%SmartyNocache:{$_template->properties['nocache_hash']}%%\*/!s", $_output); + // get non-cached items + preg_match_all("!/\*%%SmartyNocache:{$_template->properties['nocache_hash']}%%\*\/(.+?)/\*/%%SmartyNocache:{$_template->properties['nocache_hash']}%%\*/!s", $_output, $cache_parts); + $output = ''; + // loop over items, stitch back together + foreach ($cache_split as $curr_idx => $curr_split) { + // escape PHP tags in template content + $output .= preg_replace('/(<%|%>|<\?php|<\?|\?>|)/', "\n", $curr_split); + if (isset($cache_parts[0][$curr_idx])) { + $_template->properties['has_nocache_code'] = true; + // remove nocache tags from cache output + $output .= preg_replace("!/\*/?%%SmartyNocache:{$_template->properties['nocache_hash']}%%\*/!", '', $cache_parts[0][$curr_idx]); + } + } + if (!$no_output_filter && !$_template->has_nocache_code && (isset($this->smarty->autoload_filters['output']) || isset($this->smarty->registered_filters['output']))) { + $output = Smarty_Internal_Filter_Handler::runFilter('output', $output, $_template); + } + // rendering (must be done before writing cache file because of {function} nocache handling) + /** @var Smarty_Internal_Template $_smarty_tpl + * used in evaluated code + */ + $_smarty_tpl = $_template; + try { + ob_start(); + eval("?>" . $output); + $_output = ob_get_clean(); + } + catch (Exception $e) { + ob_get_clean(); + throw $e; + } + // write cache file content + $_template->writeCachedContent($output); + if ($this->smarty->debugging) { + Smarty_Internal_Debug::end_cache($_template); + } + } else { + // var_dump('renderTemplate', $_template->has_nocache_code, $_template->template_resource, $_template->properties['nocache_hash'], $_template->parent->properties['nocache_hash'], $_output); + if (!empty($_template->properties['nocache_hash']) && !empty($_template->parent->properties['nocache_hash'])) { + // replace nocache_hash + $_output = str_replace("{$_template->properties['nocache_hash']}", $_template->parent->properties['nocache_hash'], $_output); + $_template->parent->has_nocache_code = $_template->parent->has_nocache_code || $_template->has_nocache_code; + } + } + } else { + if ($this->smarty->debugging) { + Smarty_Internal_Debug::start_cache($_template); + } + try { + ob_start(); + array_unshift($_template->_capture_stack, array()); + // + // render cached template + // + $_template->properties['unifunc']($_template); + // any unclosed {capture} tags ? + if (isset($_template->_capture_stack[0][0])) { + $_template->capture_error(); + } + array_shift($_template->_capture_stack); + $_output = ob_get_clean(); + } + catch (Exception $e) { + ob_get_clean(); + throw $e; + } + if ($this->smarty->debugging) { + Smarty_Internal_Debug::end_cache($_template); + } + } + if ((!$this->caching || $_template->has_nocache_code || $_template->source->recompiled) && !$no_output_filter && (isset($this->smarty->autoload_filters['output']) || isset($this->smarty->registered_filters['output']))) { + $_output = Smarty_Internal_Filter_Handler::runFilter('output', $_output, $_template); + } + if (isset($this->error_reporting)) { + error_reporting($_smarty_old_error_level); + } + // display or fetch + if ($display) { + if ($this->caching && $this->cache_modified_check) { + $_isCached = $_template->isCached() && !$_template->has_nocache_code; + $_last_modified_date = @substr($_SERVER['HTTP_IF_MODIFIED_SINCE'], 0, strpos($_SERVER['HTTP_IF_MODIFIED_SINCE'], 'GMT') + 3); + if ($_isCached && $_template->cached->timestamp <= strtotime($_last_modified_date)) { + switch (PHP_SAPI) { + case 'cgi': // php-cgi < 5.3 + case 'cgi-fcgi': // php-cgi >= 5.3 + case 'fpm-fcgi': // php-fpm >= 5.3.3 + header('Status: 304 Not Modified'); + break; + + case 'cli': + if ( /* ^phpunit */ + !empty($_SERVER['SMARTY_PHPUNIT_DISABLE_HEADERS']) /* phpunit$ */ + ) { + $_SERVER['SMARTY_PHPUNIT_HEADERS'][] = '304 Not Modified'; + } + break; + + default: + header($_SERVER['SERVER_PROTOCOL'] . ' 304 Not Modified'); + break; + } + } else { + switch (PHP_SAPI) { + case 'cli': + if ( /* ^phpunit */ + !empty($_SERVER['SMARTY_PHPUNIT_DISABLE_HEADERS']) /* phpunit$ */ + ) { + $_SERVER['SMARTY_PHPUNIT_HEADERS'][] = 'Last-Modified: ' . gmdate('D, d M Y H:i:s', $_template->cached->timestamp) . ' GMT'; + } + break; + + default: + header('Last-Modified: ' . gmdate('D, d M Y H:i:s', $_template->cached->timestamp) . ' GMT'); + break; + } + echo $_output; + } + } else { + echo $_output; + } + // debug output + if ($this->smarty->debugging) { + Smarty_Internal_Debug::display_debug($_template); + } + if ($merge_tpl_vars) { + // restore local variables + $_template->tpl_vars = $save_tpl_vars; + $_template->config_vars = $save_config_vars; + } + + return; + } else { + if ($merge_tpl_vars) { + // restore local variables + $_template->tpl_vars = $save_tpl_vars; + $_template->config_vars = $save_config_vars; + } + // return fetched content + return $_output; + } + } + + /** + * displays a Smarty template + * + * @param string $template the resource handle of the template file or template object + * @param mixed $cache_id cache id to be used with this template + * @param mixed $compile_id compile id to be used with this template + * @param object $parent next higher level of Smarty variables + */ + public function display($template = null, $cache_id = null, $compile_id = null, $parent = null) + { + // display template + $this->fetch($template, $cache_id, $compile_id, $parent, true); + } + + /** + * test if cache is valid + * + * @param string|object $template the resource handle of the template file or template object + * @param mixed $cache_id cache id to be used with this template + * @param mixed $compile_id compile id to be used with this template + * @param object $parent next higher level of Smarty variables + * + * @return boolean cache status + */ + public function isCached($template = null, $cache_id = null, $compile_id = null, $parent = null) + { + if ($template === null && $this instanceof $this->template_class) { + return $this->cached->valid; + } + if (!($template instanceof $this->template_class)) { + if ($parent === null) { + $parent = $this; + } + $template = $this->smarty->createTemplate($template, $cache_id, $compile_id, $parent, false); + } + // return cache status of template + return $template->cached->valid; + } + + /** + * creates a data object + * + * @param object $parent next higher level of Smarty variables + * + * @returns Smarty_Data data object + */ + public function createData($parent = null) + { + return new Smarty_Data($parent, $this); + } + + /** + * Registers plugin to be used in templates + * + * @param string $type plugin type + * @param string $tag name of template tag + * @param callback $callback PHP callback to register + * @param boolean $cacheable if true (default) this fuction is cachable + * @param array $cache_attr caching attributes if any + * + * @return Smarty_Internal_Templatebase current Smarty_Internal_Templatebase (or Smarty or Smarty_Internal_Template) instance for chaining + * @throws SmartyException when the plugin tag is invalid + */ + public function registerPlugin($type, $tag, $callback, $cacheable = true, $cache_attr = null) + { + if (isset($this->smarty->registered_plugins[$type][$tag])) { + throw new SmartyException("Plugin tag \"{$tag}\" already registered"); + } elseif (!is_callable($callback)) { + throw new SmartyException("Plugin \"{$tag}\" not callable"); + } else { + $this->smarty->registered_plugins[$type][$tag] = array($callback, (bool) $cacheable, (array) $cache_attr); + } + + return $this; + } + + /** + * Unregister Plugin + * + * @param string $type of plugin + * @param string $tag name of plugin + * + * @return Smarty_Internal_Templatebase current Smarty_Internal_Templatebase (or Smarty or Smarty_Internal_Template) instance for chaining + */ + public function unregisterPlugin($type, $tag) + { + if (isset($this->smarty->registered_plugins[$type][$tag])) { + unset($this->smarty->registered_plugins[$type][$tag]); + } + + return $this; + } + + /** + * Registers a resource to fetch a template + * + * @param string $type name of resource type + * @param Smarty_Resource|array $callback or instance of Smarty_Resource, or array of callbacks to handle resource (deprecated) + * + * @return Smarty_Internal_Templatebase current Smarty_Internal_Templatebase (or Smarty or Smarty_Internal_Template) instance for chaining + */ + public function registerResource($type, $callback) + { + $this->smarty->registered_resources[$type] = $callback instanceof Smarty_Resource ? $callback : array($callback, false); + + return $this; + } + + /** + * Unregisters a resource + * + * @param string $type name of resource type + * + * @return Smarty_Internal_Templatebase current Smarty_Internal_Templatebase (or Smarty or Smarty_Internal_Template) instance for chaining + */ + public function unregisterResource($type) + { + if (isset($this->smarty->registered_resources[$type])) { + unset($this->smarty->registered_resources[$type]); + } + + return $this; + } + + /** + * Registers a cache resource to cache a template's output + * + * @param string $type name of cache resource type + * @param Smarty_CacheResource $callback instance of Smarty_CacheResource to handle output caching + * + * @return Smarty_Internal_Templatebase current Smarty_Internal_Templatebase (or Smarty or Smarty_Internal_Template) instance for chaining + */ + public function registerCacheResource($type, Smarty_CacheResource $callback) + { + $this->smarty->registered_cache_resources[$type] = $callback; + + return $this; + } + + /** + * Unregisters a cache resource + * + * @param string $type name of cache resource type + * + * @return Smarty_Internal_Templatebase current Smarty_Internal_Templatebase (or Smarty or Smarty_Internal_Template) instance for chaining + */ + public function unregisterCacheResource($type) + { + if (isset($this->smarty->registered_cache_resources[$type])) { + unset($this->smarty->registered_cache_resources[$type]); + } + + return $this; + } + + /** + * Registers object to be used in templates + * + * @param $object_name + * @param object $object_impl the referenced PHP object to register + * @param array $allowed list of allowed methods (empty = all) + * @param boolean $smarty_args smarty argument format, else traditional + * @param array $block_methods list of block-methods + * + * @throws SmartyException + * @return Smarty_Internal_Templatebase current Smarty_Internal_Templatebase (or Smarty or Smarty_Internal_Template) instance for chaining + */ + public function registerObject($object_name, $object_impl, $allowed = array(), $smarty_args = true, $block_methods = array()) + { + // test if allowed methods callable + if (!empty($allowed)) { + foreach ((array) $allowed as $method) { + if (!is_callable(array($object_impl, $method)) && !property_exists($object_impl, $method)) { + throw new SmartyException("Undefined method or property '$method' in registered object"); + } + } + } + // test if block methods callable + if (!empty($block_methods)) { + foreach ((array) $block_methods as $method) { + if (!is_callable(array($object_impl, $method))) { + throw new SmartyException("Undefined method '$method' in registered object"); + } + } + } + // register the object + $this->smarty->registered_objects[$object_name] = + array($object_impl, (array) $allowed, (boolean) $smarty_args, (array) $block_methods); + + return $this; + } + + /** + * return a reference to a registered object + * + * @param string $name object name + * + * @return object + * @throws SmartyException if no such object is found + */ + public function getRegisteredObject($name) + { + if (!isset($this->smarty->registered_objects[$name])) { + throw new SmartyException("'$name' is not a registered object"); + } + if (!is_object($this->smarty->registered_objects[$name][0])) { + throw new SmartyException("registered '$name' is not an object"); + } + + return $this->smarty->registered_objects[$name][0]; + } + + /** + * unregister an object + * + * @param string $name object name + * + * @return Smarty_Internal_Templatebase current Smarty_Internal_Templatebase (or Smarty or Smarty_Internal_Template) instance for chaining + */ + public function unregisterObject($name) + { + if (isset($this->smarty->registered_objects[$name])) { + unset($this->smarty->registered_objects[$name]); + } + + return $this; + } + + /** + * Registers static classes to be used in templates + * + * @param $class_name + * @param string $class_impl the referenced PHP class to register + * + * @throws SmartyException + * @return Smarty_Internal_Templatebase current Smarty_Internal_Templatebase (or Smarty or Smarty_Internal_Template) instance for chaining + */ + public function registerClass($class_name, $class_impl) + { + // test if exists + if (!class_exists($class_impl)) { + throw new SmartyException("Undefined class '$class_impl' in register template class"); + } + // register the class + $this->smarty->registered_classes[$class_name] = $class_impl; + + return $this; + } + + /** + * Registers a default plugin handler + * + * @param callable $callback class/method name + * + * @return Smarty_Internal_Templatebase current Smarty_Internal_Templatebase (or Smarty or Smarty_Internal_Template) instance for chaining + * @throws SmartyException if $callback is not callable + */ + public function registerDefaultPluginHandler($callback) + { + if (is_callable($callback)) { + $this->smarty->default_plugin_handler_func = $callback; + } else { + throw new SmartyException("Default plugin handler '$callback' not callable"); + } + + return $this; + } + + /** + * Registers a default template handler + * + * @param callable $callback class/method name + * + * @return Smarty_Internal_Templatebase current Smarty_Internal_Templatebase (or Smarty or Smarty_Internal_Template) instance for chaining + * @throws SmartyException if $callback is not callable + */ + public function registerDefaultTemplateHandler($callback) + { + if (is_callable($callback)) { + $this->smarty->default_template_handler_func = $callback; + } else { + throw new SmartyException("Default template handler '$callback' not callable"); + } + + return $this; + } + + /** + * Registers a default template handler + * + * @param callable $callback class/method name + * + * @return Smarty_Internal_Templatebase current Smarty_Internal_Templatebase (or Smarty or Smarty_Internal_Template) instance for chaining + * @throws SmartyException if $callback is not callable + */ + public function registerDefaultConfigHandler($callback) + { + if (is_callable($callback)) { + $this->smarty->default_config_handler_func = $callback; + } else { + throw new SmartyException("Default config handler '$callback' not callable"); + } + + return $this; + } + + /** + * Registers a filter function + * + * @param string $type filter type + * @param callback $callback + * + * @return Smarty_Internal_Templatebase current Smarty_Internal_Templatebase (or Smarty or Smarty_Internal_Template) instance for chaining + */ + public function registerFilter($type, $callback) + { + $this->smarty->registered_filters[$type][$this->_get_filter_name($callback)] = $callback; + + return $this; + } + + /** + * Unregisters a filter function + * + * @param string $type filter type + * @param callback $callback + * + * @return Smarty_Internal_Templatebase current Smarty_Internal_Templatebase (or Smarty or Smarty_Internal_Template) instance for chaining + */ + public function unregisterFilter($type, $callback) + { + $name = $this->_get_filter_name($callback); + if (isset($this->smarty->registered_filters[$type][$name])) { + unset($this->smarty->registered_filters[$type][$name]); + } + + return $this; + } + + /** + * Return internal filter name + * + * @param callback $function_name + * + * @return string internal filter name + */ + public function _get_filter_name($function_name) + { + if (is_array($function_name)) { + $_class_name = (is_object($function_name[0]) ? + get_class($function_name[0]) : $function_name[0]); + + return $_class_name . '_' . $function_name[1]; + } else { + return $function_name; + } + } + + /** + * load a filter of specified type and name + * + * @param string $type filter type + * @param string $name filter name + * + * @throws SmartyException if filter could not be loaded + */ + public function loadFilter($type, $name) + { + $_plugin = "smarty_{$type}filter_{$name}"; + $_filter_name = $_plugin; + if ($this->smarty->loadPlugin($_plugin)) { + if (class_exists($_plugin, false)) { + $_plugin = array($_plugin, 'execute'); + } + if (is_callable($_plugin)) { + $this->smarty->registered_filters[$type][$_filter_name] = $_plugin; + + return true; + } + } + throw new SmartyException("{$type}filter \"{$name}\" not callable"); + } + + /** + * unload a filter of specified type and name + * + * @param string $type filter type + * @param string $name filter name + * + * @return Smarty_Internal_Templatebase current Smarty_Internal_Templatebase (or Smarty or Smarty_Internal_Template) instance for chaining + */ + public function unloadFilter($type, $name) + { + $_filter_name = "smarty_{$type}filter_{$name}"; + if (isset($this->smarty->registered_filters[$type][$_filter_name])) { + unset ($this->smarty->registered_filters[$type][$_filter_name]); + } + + return $this; + } + + /** + * preg_replace callback to convert camelcase getter/setter to underscore property names + * + * @param string $match match string + * + * @return string replacemant + */ + private function replaceCamelcase($match) + { + return "_" . strtolower($match[1]); + } + + /** + * Handle unknown class methods + * + * @param string $name unknown method-name + * @param array $args argument array + * + * @throws SmartyException + */ + public function __call($name, $args) + { + static $_prefixes = array('set' => true, 'get' => true); + static $_resolved_property_name = array(); + static $_resolved_property_source = array(); + + // method of Smarty object? + if (method_exists($this->smarty, $name)) { + return call_user_func_array(array($this->smarty, $name), $args); + } + // see if this is a set/get for a property + $first3 = strtolower(substr($name, 0, 3)); + if (isset($_prefixes[$first3]) && isset($name[3]) && $name[3] !== '_') { + if (isset($_resolved_property_name[$name])) { + $property_name = $_resolved_property_name[$name]; + } else { + // try to keep case correct for future PHP 6.0 case-sensitive class methods + // lcfirst() not available < PHP 5.3.0, so improvise + $property_name = strtolower(substr($name, 3, 1)) . substr($name, 4); + // convert camel case to underscored name + $property_name = preg_replace_callback('/([A-Z])/', array($this, 'replaceCamelcase'), $property_name); + $_resolved_property_name[$name] = $property_name; + } + if (isset($_resolved_property_source[$property_name])) { + $_is_this = $_resolved_property_source[$property_name]; + } else { + $_is_this = null; + if (property_exists($this, $property_name)) { + $_is_this = true; + } elseif (property_exists($this->smarty, $property_name)) { + $_is_this = false; + } + $_resolved_property_source[$property_name] = $_is_this; + } + if ($_is_this) { + if ($first3 == 'get') { + return $this->$property_name; + } else { + return $this->$property_name = $args[0]; + } + } elseif ($_is_this === false) { + if ($first3 == 'get') { + return $this->smarty->$property_name; + } else { + return $this->smarty->$property_name = $args[0]; + } + } else { + throw new SmartyException("property '$property_name' does not exist."); + } + } + if ($name == 'Smarty') { + throw new SmartyException("PHP5 requires you to call __construct() instead of Smarty()"); + } + // must be unknown + throw new SmartyException("Call of unknown method '$name'."); + } +} +>>>>>>> trunk diff --git a/libs/sysplugins/smarty_internal_templateparser.php b/libs/sysplugins/smarty_internal_templateparser.php index 98b9fc7f..f94ca2f1 100644 --- a/libs/sysplugins/smarty_internal_templateparser.php +++ b/libs/sysplugins/smarty_internal_templateparser.php @@ -126,6 +126,14 @@ class Smarty_Internal_Templateparser#line 80 "smarty_internal_templateparser.php $this->current_buffer = $this->root_buffer = new _smarty_template_buffer($this); } +<<<<<<< HEAD +======= + public function insertPhpCode($code) + { + $this->current_buffer->append_subtree(new _smarty_tag($this, $code)); + } + +>>>>>>> trunk public function compileVariable($variable) { if (strpos($variable, '(') == 0) { @@ -138,7 +146,11 @@ class Smarty_Internal_Templateparser#line 80 "smarty_internal_templateparser.php return '$_smarty_tpl->tpl_vars[' . $variable . ']->value'; } +<<<<<<< HEAD #line 130 "smarty_internal_templateparser.php" +======= + #line 134 "smarty_internal_templateparser.php" +>>>>>>> trunk const TP_VERT = 1; const TP_COLON = 2; @@ -2878,11 +2890,19 @@ class Smarty_Internal_Templateparser#line 80 "smarty_internal_templateparser.php while ($this->yyidx >= 0) { $this->yy_pop_parser_stack(); } +<<<<<<< HEAD #line 82 "smarty_internal_templateparser.y" $this->internalError = true; $this->compiler->trigger_template_error("Stack overflow in template parser"); #line 1721 "smarty_internal_templateparser.php" +======= + #line 86 "smarty_internal_templateparser.y" + + $this->internalError = true; + $this->compiler->trigger_template_error("Stack overflow in template parser"); + #line 1725 "smarty_internal_templateparser.php" +>>>>>>> trunk return; } @@ -3308,21 +3328,35 @@ class Smarty_Internal_Templateparser#line 80 "smarty_internal_templateparser.php 197 => 197, ); +<<<<<<< HEAD #line 93 "smarty_internal_templateparser.y" +======= + #line 97 "smarty_internal_templateparser.y" +>>>>>>> trunk function yy_r0() { $this->_retvalue = $this->root_buffer->to_smarty_php(); } +<<<<<<< HEAD #line 2150 "smarty_internal_templateparser.php" #line 101 "smarty_internal_templateparser.y" +======= + #line 2154 "smarty_internal_templateparser.php" + #line 105 "smarty_internal_templateparser.y" +>>>>>>> trunk function yy_r1() { if ($this->yystack[$this->yyidx + 0]->minor != null) { $this->current_buffer->append_subtree($this->yystack[$this->yyidx + 0]->minor); } } +<<<<<<< HEAD #line 2157 "smarty_internal_templateparser.php" #line 108 "smarty_internal_templateparser.y" +======= + #line 2161 "smarty_internal_templateparser.php" + #line 112 "smarty_internal_templateparser.y" +>>>>>>> trunk function yy_r2() { if ($this->yystack[$this->yyidx + 0]->minor != null) { @@ -3330,8 +3364,13 @@ class Smarty_Internal_Templateparser#line 80 "smarty_internal_templateparser.php $this->current_buffer->append_subtree($this->yystack[$this->yyidx + 0]->minor); } } +<<<<<<< HEAD #line 2165 "smarty_internal_templateparser.php" #line 122 "smarty_internal_templateparser.y" +======= + #line 2169 "smarty_internal_templateparser.php" + #line 126 "smarty_internal_templateparser.y" +>>>>>>> trunk function yy_r4() { if ($this->compiler->has_code) { @@ -3347,20 +3386,35 @@ class Smarty_Internal_Templateparser#line 80 "smarty_internal_templateparser.php $this->compiler->has_variable_string = false; $this->block_nesting_level = count($this->compiler->_tag_stack); } +<<<<<<< HEAD #line 2177 "smarty_internal_templateparser.php" #line 134 "smarty_internal_templateparser.y" +======= + #line 2181 "smarty_internal_templateparser.php" + #line 138 "smarty_internal_templateparser.y" +>>>>>>> trunk function yy_r5() { $this->_retvalue = null; } +<<<<<<< HEAD #line 2182 "smarty_internal_templateparser.php" #line 139 "smarty_internal_templateparser.y" +======= + #line 2186 "smarty_internal_templateparser.php" + #line 143 "smarty_internal_templateparser.y" +>>>>>>> trunk function yy_r6() { $this->_retvalue = new _smarty_text($this, $this->yystack[$this->yyidx + 0]->minor); } +<<<<<<< HEAD #line 2187 "smarty_internal_templateparser.php" #line 144 "smarty_internal_templateparser.y" +======= + #line 2191 "smarty_internal_templateparser.php" + #line 148 "smarty_internal_templateparser.y" +>>>>>>> trunk function yy_r7() { if (strpos($this->yystack[$this->yyidx + 0]->minor, '_retvalue = null; } } +<<<<<<< HEAD #line 2211 "smarty_internal_templateparser.php" #line 168 "smarty_internal_templateparser.y" +======= + #line 2215 "smarty_internal_templateparser.php" + #line 172 "smarty_internal_templateparser.y" +>>>>>>> trunk function yy_r8() { if ($this->is_xml) { @@ -3404,8 +3463,13 @@ class Smarty_Internal_Templateparser#line 80 "smarty_internal_templateparser.php $this->_retvalue = null; } } +<<<<<<< HEAD #line 2230 "smarty_internal_templateparser.php" #line 186 "smarty_internal_templateparser.y" +======= + #line 2234 "smarty_internal_templateparser.php" + #line 190 "smarty_internal_templateparser.y" +>>>>>>> trunk function yy_r9() { if (!$this->lex->is_phpScript) { @@ -3423,8 +3487,13 @@ class Smarty_Internal_Templateparser#line 80 "smarty_internal_templateparser.php } } } +<<<<<<< HEAD #line 2248 "smarty_internal_templateparser.php" #line 204 "smarty_internal_templateparser.y" +======= + #line 2252 "smarty_internal_templateparser.php" + #line 208 "smarty_internal_templateparser.y" +>>>>>>> trunk function yy_r10() { if ($this->php_handling == Smarty::PHP_PASSTHRU) { @@ -3448,30 +3517,52 @@ class Smarty_Internal_Templateparser#line 80 "smarty_internal_templateparser.php } } } +<<<<<<< HEAD #line 2272 "smarty_internal_templateparser.php" #line 228 "smarty_internal_templateparser.y" function yy_r11() { if ($this->php_handling == Smarty::PHP_PASSTHRU) { $this->_retvalue = new _smarty_text($this, st); +======= + #line 2276 "smarty_internal_templateparser.php" + #line 232 "smarty_internal_templateparser.y" + function yy_r11() + { + if ($this->php_handling == Smarty::PHP_PASSTHRU) { + $this->_retvalue = new _smarty_text($this, $this->yystack[$this->yyidx + 0]->minor); +>>>>>>> trunk } elseif ($this->php_handling == Smarty::PHP_QUOTE) { $this->_retvalue = new _smarty_text($this, htmlspecialchars('%>', ENT_QUOTES)); } elseif ($this->php_handling == Smarty::PHP_ALLOW) { if ($this->asp_tags) { $this->_retvalue = new _smarty_tag($this, $this->compiler->processNocacheCode('%>', true)); } else { +<<<<<<< HEAD $this->_retvalue = new _smarty_text($this, st); +======= + $this->_retvalue = new _smarty_text($this, $this->yystack[$this->yyidx + 0]->minor); +>>>>>>> trunk } } elseif ($this->php_handling == Smarty::PHP_REMOVE) { if ($this->asp_tags) { $this->_retvalue = null; } else { +<<<<<<< HEAD $this->_retvalue = new _smarty_text($this, st); } } } #line 2293 "smarty_internal_templateparser.php" #line 250 "smarty_internal_templateparser.y" +======= + $this->_retvalue = new _smarty_text($this, $this->yystack[$this->yyidx + 0]->minor); + } + } + } + #line 2297 "smarty_internal_templateparser.php" + #line 254 "smarty_internal_templateparser.y" +>>>>>>> trunk function yy_r12() { $this->compiler->tag_nocache = true; @@ -3480,8 +3571,13 @@ class Smarty_Internal_Templateparser#line 80 "smarty_internal_templateparser.php $this->_retvalue = new _smarty_tag($this, $this->compiler->processNocacheCode("", $this->compiler, true)); $this->template->has_nocache_code = $save; } +<<<<<<< HEAD #line 2302 "smarty_internal_templateparser.php" #line 259 "smarty_internal_templateparser.y" +======= + #line 2306 "smarty_internal_templateparser.php" + #line 263 "smarty_internal_templateparser.y" +>>>>>>> trunk function yy_r13() { if ($this->strip) { @@ -3490,20 +3586,35 @@ class Smarty_Internal_Templateparser#line 80 "smarty_internal_templateparser.php $this->_retvalue = new _smarty_text($this, $this->yystack[$this->yyidx + 0]->minor); } } +<<<<<<< HEAD #line 2311 "smarty_internal_templateparser.php" #line 268 "smarty_internal_templateparser.y" +======= + #line 2315 "smarty_internal_templateparser.php" + #line 272 "smarty_internal_templateparser.y" +>>>>>>> trunk function yy_r14() { $this->strip = true; } +<<<<<<< HEAD #line 2316 "smarty_internal_templateparser.php" #line 272 "smarty_internal_templateparser.y" +======= + #line 2320 "smarty_internal_templateparser.php" + #line 276 "smarty_internal_templateparser.y" +>>>>>>> trunk function yy_r15() { $this->strip = false; } +<<<<<<< HEAD #line 2321 "smarty_internal_templateparser.php" #line 276 "smarty_internal_templateparser.y" +======= + #line 2325 "smarty_internal_templateparser.php" + #line 280 "smarty_internal_templateparser.y" +>>>>>>> trunk function yy_r16() { if ($this->strip) { @@ -3512,181 +3623,326 @@ class Smarty_Internal_Templateparser#line 80 "smarty_internal_templateparser.php SMARTY_INTERNAL_COMPILE_BLOCK::blockSource($this->compiler, $this->yystack[$this->yyidx + 0]->minor); } } +<<<<<<< HEAD #line 2330 "smarty_internal_templateparser.php" #line 285 "smarty_internal_templateparser.y" +======= + #line 2334 "smarty_internal_templateparser.php" + #line 289 "smarty_internal_templateparser.y" +>>>>>>> trunk function yy_r17() { $this->_retvalue = ''; } +<<<<<<< HEAD #line 2335 "smarty_internal_templateparser.php" #line 289 "smarty_internal_templateparser.y" +======= + #line 2339 "smarty_internal_templateparser.php" + #line 293 "smarty_internal_templateparser.y" +>>>>>>> trunk function yy_r18() { $this->_retvalue = $this->yystack[$this->yyidx + - 1]->minor; } +<<<<<<< HEAD #line 2340 "smarty_internal_templateparser.php" #line 293 "smarty_internal_templateparser.y" +======= + #line 2344 "smarty_internal_templateparser.php" + #line 297 "smarty_internal_templateparser.y" +>>>>>>> trunk function yy_r19() { $this->_retvalue = $this->yystack[$this->yyidx + - 1]->minor . $this->yystack[$this->yyidx + 0]->minor; } +<<<<<<< HEAD #line 2345 "smarty_internal_templateparser.php" #line 301 "smarty_internal_templateparser.y" +======= + #line 2349 "smarty_internal_templateparser.php" + #line 305 "smarty_internal_templateparser.y" +>>>>>>> trunk function yy_r21() { $this->_retvalue = $this->yystack[$this->yyidx + 0]->minor; } +<<<<<<< HEAD #line 2350 "smarty_internal_templateparser.php" #line 314 "smarty_internal_templateparser.y" +======= + #line 2354 "smarty_internal_templateparser.php" + #line 318 "smarty_internal_templateparser.y" +>>>>>>> trunk function yy_r23() { $this->_retvalue = $this->compiler->compileTag('private_print_expression', array(), array('value' => $this->yystack[$this->yyidx + 0]->minor)); } +<<<<<<< HEAD #line 2355 "smarty_internal_templateparser.php" #line 318 "smarty_internal_templateparser.y" +======= + #line 2359 "smarty_internal_templateparser.php" + #line 322 "smarty_internal_templateparser.y" +>>>>>>> trunk function yy_r24() { $this->_retvalue = $this->compiler->compileTag('private_print_expression', $this->yystack[$this->yyidx + 0]->minor, array('value' => $this->yystack[$this->yyidx + - 2]->minor, 'modifierlist' => $this->yystack[$this->yyidx + - 1]->minor)); } +<<<<<<< HEAD #line 2360 "smarty_internal_templateparser.php" #line 322 "smarty_internal_templateparser.y" +======= + #line 2364 "smarty_internal_templateparser.php" + #line 326 "smarty_internal_templateparser.y" +>>>>>>> trunk function yy_r25() { $this->_retvalue = $this->compiler->compileTag('private_print_expression', $this->yystack[$this->yyidx + 0]->minor, array('value' => $this->yystack[$this->yyidx + - 1]->minor)); } +<<<<<<< HEAD #line 2365 "smarty_internal_templateparser.php" #line 326 "smarty_internal_templateparser.y" +======= + #line 2369 "smarty_internal_templateparser.php" + #line 330 "smarty_internal_templateparser.y" +>>>>>>> trunk function yy_r26() { $this->_retvalue = $this->compiler->compileTag('private_print_expression', $this->yystack[$this->yyidx + 0]->minor, array('value' => $this->yystack[$this->yyidx + - 2]->minor, 'modifierlist' => $this->yystack[$this->yyidx + - 1]->minor)); } +<<<<<<< HEAD #line 2370 "smarty_internal_templateparser.php" #line 339 "smarty_internal_templateparser.y" +======= + #line 2374 "smarty_internal_templateparser.php" + #line 343 "smarty_internal_templateparser.y" +>>>>>>> trunk function yy_r28() { $this->_retvalue = $this->compiler->compileTag('assign', array(array('value' => $this->yystack[$this->yyidx + 0]->minor), array('var' => "'" . $this->yystack[$this->yyidx + - 2]->minor . "'"))); } +<<<<<<< HEAD #line 2375 "smarty_internal_templateparser.php" #line 347 "smarty_internal_templateparser.y" +======= + #line 2379 "smarty_internal_templateparser.php" + #line 351 "smarty_internal_templateparser.y" +>>>>>>> trunk function yy_r30() { $this->_retvalue = $this->compiler->compileTag('assign', array_merge(array(array('value' => $this->yystack[$this->yyidx + - 1]->minor), array('var' => "'" . $this->yystack[$this->yyidx + - 3]->minor . "'")), $this->yystack[$this->yyidx + 0]->minor)); } +<<<<<<< HEAD #line 2380 "smarty_internal_templateparser.php" #line 351 "smarty_internal_templateparser.y" +======= + #line 2384 "smarty_internal_templateparser.php" + #line 355 "smarty_internal_templateparser.y" +>>>>>>> trunk function yy_r31() { $this->_retvalue = $this->compiler->compileTag('assign', array_merge(array(array('value' => $this->yystack[$this->yyidx + - 1]->minor), array('var' => $this->yystack[$this->yyidx + - 3]->minor['var'])), $this->yystack[$this->yyidx + 0]->minor), array('smarty_internal_index' => $this->yystack[$this->yyidx + - 3]->minor['smarty_internal_index'])); } +<<<<<<< HEAD #line 2385 "smarty_internal_templateparser.php" #line 356 "smarty_internal_templateparser.y" +======= + #line 2389 "smarty_internal_templateparser.php" + #line 360 "smarty_internal_templateparser.y" +>>>>>>> trunk function yy_r32() { $this->_retvalue = $this->compiler->compileTag($this->yystack[$this->yyidx + - 1]->minor, $this->yystack[$this->yyidx + 0]->minor); } +<<<<<<< HEAD #line 2390 "smarty_internal_templateparser.php" #line 360 "smarty_internal_templateparser.y" +======= + #line 2394 "smarty_internal_templateparser.php" + #line 364 "smarty_internal_templateparser.y" +>>>>>>> trunk function yy_r33() { $this->_retvalue = $this->compiler->compileTag($this->yystack[$this->yyidx + 0]->minor, array()); } +<<<<<<< HEAD #line 2395 "smarty_internal_templateparser.php" #line 365 "smarty_internal_templateparser.y" +======= + #line 2399 "smarty_internal_templateparser.php" + #line 369 "smarty_internal_templateparser.y" +>>>>>>> trunk function yy_r34() { $this->_retvalue = $this->compiler->compileTag($this->yystack[$this->yyidx + - 3]->minor, $this->yystack[$this->yyidx + 0]->minor, array('object_method' => $this->yystack[$this->yyidx + - 1]->minor)); } +<<<<<<< HEAD #line 2400 "smarty_internal_templateparser.php" #line 370 "smarty_internal_templateparser.y" +======= + #line 2404 "smarty_internal_templateparser.php" + #line 374 "smarty_internal_templateparser.y" +>>>>>>> trunk function yy_r35() { $this->_retvalue = '' . $this->compiler->compileTag($this->yystack[$this->yyidx + - 2]->minor, $this->yystack[$this->yyidx + 0]->minor) . '_retvalue .= $this->compiler->compileTag('private_modifier', array(), array('modifierlist' => $this->yystack[$this->yyidx + - 1]->minor, 'value' => 'ob_get_clean()')) . '?>'; } +<<<<<<< HEAD #line 2406 "smarty_internal_templateparser.php" #line 376 "smarty_internal_templateparser.y" +======= + #line 2410 "smarty_internal_templateparser.php" + #line 380 "smarty_internal_templateparser.y" +>>>>>>> trunk function yy_r36() { $this->_retvalue = '' . $this->compiler->compileTag($this->yystack[$this->yyidx + - 4]->minor, $this->yystack[$this->yyidx + 0]->minor, array('object_method' => $this->yystack[$this->yyidx + - 2]->minor)) . '_retvalue .= $this->compiler->compileTag('private_modifier', array(), array('modifierlist' => $this->yystack[$this->yyidx + - 1]->minor, 'value' => 'ob_get_clean()')) . '?>'; } +<<<<<<< HEAD #line 2412 "smarty_internal_templateparser.php" #line 382 "smarty_internal_templateparser.y" +======= + #line 2416 "smarty_internal_templateparser.php" + #line 386 "smarty_internal_templateparser.y" +>>>>>>> trunk function yy_r37() { $tag = trim(substr($this->yystack[$this->yyidx + - 1]->minor, $this->lex->ldel_length)); $this->_retvalue = $this->compiler->compileTag(($tag == 'else if') ? 'elseif' : $tag, array(), array('if condition' => $this->yystack[$this->yyidx + 0]->minor)); } +<<<<<<< HEAD #line 2418 "smarty_internal_templateparser.php" #line 387 "smarty_internal_templateparser.y" +======= + #line 2422 "smarty_internal_templateparser.php" + #line 391 "smarty_internal_templateparser.y" +>>>>>>> trunk function yy_r38() { $tag = trim(substr($this->yystack[$this->yyidx + - 2]->minor, $this->lex->ldel_length)); $this->_retvalue = $this->compiler->compileTag(($tag == 'else if') ? 'elseif' : $tag, $this->yystack[$this->yyidx + 0]->minor, array('if condition' => $this->yystack[$this->yyidx + - 1]->minor)); } +<<<<<<< HEAD #line 2424 "smarty_internal_templateparser.php" #line 392 "smarty_internal_templateparser.y" +======= + #line 2428 "smarty_internal_templateparser.php" + #line 396 "smarty_internal_templateparser.y" +>>>>>>> trunk function yy_r39() { $tag = trim(substr($this->yystack[$this->yyidx + - 1]->minor, $this->lex->ldel_length)); $this->_retvalue = $this->compiler->compileTag(($tag == 'else if') ? 'elseif' : $tag, array(), array('if condition' => $this->yystack[$this->yyidx + 0]->minor)); } +<<<<<<< HEAD #line 2430 "smarty_internal_templateparser.php" #line 403 "smarty_internal_templateparser.y" +======= + #line 2434 "smarty_internal_templateparser.php" + #line 407 "smarty_internal_templateparser.y" +>>>>>>> trunk function yy_r41() { $this->_retvalue = $this->compiler->compileTag('for', array_merge($this->yystack[$this->yyidx + 0]->minor, array(array('start' => $this->yystack[$this->yyidx + - 9]->minor), array('ifexp' => $this->yystack[$this->yyidx + - 6]->minor), array('var' => $this->yystack[$this->yyidx + - 2]->minor), array('step' => $this->yystack[$this->yyidx + - 1]->minor))), 1); } +<<<<<<< HEAD #line 2435 "smarty_internal_templateparser.php" #line 407 "smarty_internal_templateparser.y" +======= + #line 2439 "smarty_internal_templateparser.php" + #line 411 "smarty_internal_templateparser.y" +>>>>>>> trunk function yy_r42() { $this->_retvalue = '=' . $this->yystack[$this->yyidx + 0]->minor; } +<<<<<<< HEAD #line 2440 "smarty_internal_templateparser.php" #line 415 "smarty_internal_templateparser.y" +======= + #line 2444 "smarty_internal_templateparser.php" + #line 419 "smarty_internal_templateparser.y" +>>>>>>> trunk function yy_r44() { $this->_retvalue = $this->compiler->compileTag('for', array_merge($this->yystack[$this->yyidx + 0]->minor, array(array('start' => $this->yystack[$this->yyidx + - 3]->minor), array('to' => $this->yystack[$this->yyidx + - 1]->minor))), 0); } +<<<<<<< HEAD #line 2445 "smarty_internal_templateparser.php" #line 419 "smarty_internal_templateparser.y" +======= + #line 2449 "smarty_internal_templateparser.php" + #line 423 "smarty_internal_templateparser.y" +>>>>>>> trunk function yy_r45() { $this->_retvalue = $this->compiler->compileTag('for', array_merge($this->yystack[$this->yyidx + 0]->minor, array(array('start' => $this->yystack[$this->yyidx + - 5]->minor), array('to' => $this->yystack[$this->yyidx + - 3]->minor), array('step' => $this->yystack[$this->yyidx + - 1]->minor))), 0); } +<<<<<<< HEAD #line 2450 "smarty_internal_templateparser.php" #line 424 "smarty_internal_templateparser.y" +======= + #line 2454 "smarty_internal_templateparser.php" + #line 428 "smarty_internal_templateparser.y" +>>>>>>> trunk function yy_r46() { $this->_retvalue = $this->compiler->compileTag('foreach', $this->yystack[$this->yyidx + 0]->minor); } +<<<<<<< HEAD #line 2455 "smarty_internal_templateparser.php" #line 429 "smarty_internal_templateparser.y" +======= + #line 2459 "smarty_internal_templateparser.php" + #line 433 "smarty_internal_templateparser.y" +>>>>>>> trunk function yy_r47() { $this->_retvalue = $this->compiler->compileTag('foreach', array_merge($this->yystack[$this->yyidx + 0]->minor, array(array('from' => $this->yystack[$this->yyidx + - 4]->minor), array('item' => $this->yystack[$this->yyidx + - 1]->minor)))); } +<<<<<<< HEAD #line 2460 "smarty_internal_templateparser.php" #line 433 "smarty_internal_templateparser.y" +======= + #line 2464 "smarty_internal_templateparser.php" + #line 437 "smarty_internal_templateparser.y" +>>>>>>> trunk function yy_r48() { $this->_retvalue = $this->compiler->compileTag('foreach', array_merge($this->yystack[$this->yyidx + 0]->minor, array(array('from' => $this->yystack[$this->yyidx + - 7]->minor), array('item' => $this->yystack[$this->yyidx + - 1]->minor), array('key' => $this->yystack[$this->yyidx + - 4]->minor)))); } +<<<<<<< HEAD #line 2465 "smarty_internal_templateparser.php" #line 446 "smarty_internal_templateparser.y" +======= + #line 2469 "smarty_internal_templateparser.php" + #line 450 "smarty_internal_templateparser.y" +>>>>>>> trunk function yy_r51() { $this->_retvalue = $this->compiler->compileTag('setfilter', array(), array('modifier_list' => array(array_merge(array($this->yystack[$this->yyidx + - 1]->minor), $this->yystack[$this->yyidx + 0]->minor)))); } +<<<<<<< HEAD #line 2470 "smarty_internal_templateparser.php" #line 450 "smarty_internal_templateparser.y" +======= + #line 2474 "smarty_internal_templateparser.php" + #line 454 "smarty_internal_templateparser.y" +>>>>>>> trunk function yy_r52() { $this->_retvalue = $this->compiler->compileTag('setfilter', array(), array('modifier_list' => array_merge(array(array_merge(array($this->yystack[$this->yyidx + - 2]->minor), $this->yystack[$this->yyidx + - 1]->minor)), $this->yystack[$this->yyidx + 0]->minor))); } +<<<<<<< HEAD #line 2475 "smarty_internal_templateparser.php" #line 455 "smarty_internal_templateparser.y" +======= + #line 2479 "smarty_internal_templateparser.php" + #line 459 "smarty_internal_templateparser.y" +>>>>>>> trunk function yy_r53() { $j = strrpos($this->yystack[$this->yyidx + 0]->minor, '.'); @@ -3698,51 +3954,91 @@ class Smarty_Internal_Templateparser#line 80 "smarty_internal_templateparser.php $this->_retvalue = SMARTY_INTERNAL_COMPILE_BLOCK::compileParentBlock($this->compiler); } } +<<<<<<< HEAD #line 2487 "smarty_internal_templateparser.php" #line 468 "smarty_internal_templateparser.y" +======= + #line 2491 "smarty_internal_templateparser.php" + #line 472 "smarty_internal_templateparser.y" +>>>>>>> trunk function yy_r54() { $this->_retvalue = $this->compiler->compileTag($this->yystack[$this->yyidx + 0]->minor . 'close', array()); } +<<<<<<< HEAD #line 2492 "smarty_internal_templateparser.php" #line 472 "smarty_internal_templateparser.y" +======= + #line 2496 "smarty_internal_templateparser.php" + #line 476 "smarty_internal_templateparser.y" +>>>>>>> trunk function yy_r55() { $this->_retvalue = $this->compiler->compileTag($this->yystack[$this->yyidx + - 1]->minor . 'close', array(), array('modifier_list' => $this->yystack[$this->yyidx + 0]->minor)); } +<<<<<<< HEAD #line 2497 "smarty_internal_templateparser.php" #line 477 "smarty_internal_templateparser.y" +======= + #line 2501 "smarty_internal_templateparser.php" + #line 481 "smarty_internal_templateparser.y" +>>>>>>> trunk function yy_r56() { $this->_retvalue = $this->compiler->compileTag($this->yystack[$this->yyidx + - 2]->minor . 'close', array(), array('object_method' => $this->yystack[$this->yyidx + 0]->minor)); } +<<<<<<< HEAD #line 2502 "smarty_internal_templateparser.php" #line 481 "smarty_internal_templateparser.y" +======= + #line 2506 "smarty_internal_templateparser.php" + #line 485 "smarty_internal_templateparser.y" +>>>>>>> trunk function yy_r57() { $this->_retvalue = $this->compiler->compileTag($this->yystack[$this->yyidx + - 3]->minor . 'close', array(), array('object_method' => $this->yystack[$this->yyidx + - 1]->minor, 'modifier_list' => $this->yystack[$this->yyidx + 0]->minor)); } +<<<<<<< HEAD #line 2507 "smarty_internal_templateparser.php" #line 489 "smarty_internal_templateparser.y" +======= + #line 2511 "smarty_internal_templateparser.php" + #line 493 "smarty_internal_templateparser.y" +>>>>>>> trunk function yy_r58() { $this->_retvalue = $this->yystack[$this->yyidx + - 1]->minor; $this->_retvalue[] = $this->yystack[$this->yyidx + 0]->minor; } +<<<<<<< HEAD #line 2513 "smarty_internal_templateparser.php" #line 495 "smarty_internal_templateparser.y" +======= + #line 2517 "smarty_internal_templateparser.php" + #line 499 "smarty_internal_templateparser.y" +>>>>>>> trunk function yy_r59() { $this->_retvalue = array($this->yystack[$this->yyidx + 0]->minor); } +<<<<<<< HEAD #line 2518 "smarty_internal_templateparser.php" #line 500 "smarty_internal_templateparser.y" +======= + #line 2522 "smarty_internal_templateparser.php" + #line 504 "smarty_internal_templateparser.y" +>>>>>>> trunk function yy_r60() { $this->_retvalue = array(); } +<<<<<<< HEAD #line 2523 "smarty_internal_templateparser.php" #line 505 "smarty_internal_templateparser.y" +======= + #line 2527 "smarty_internal_templateparser.php" + #line 509 "smarty_internal_templateparser.y" +>>>>>>> trunk function yy_r61() { if (preg_match('~^true$~i', $this->yystack[$this->yyidx + 0]->minor)) { @@ -3755,155 +4051,280 @@ class Smarty_Internal_Templateparser#line 80 "smarty_internal_templateparser.php $this->_retvalue = array($this->yystack[$this->yyidx + - 2]->minor => "'" . $this->yystack[$this->yyidx + 0]->minor . "'"); } } +<<<<<<< HEAD #line 2536 "smarty_internal_templateparser.php" #line 517 "smarty_internal_templateparser.y" +======= + #line 2540 "smarty_internal_templateparser.php" + #line 521 "smarty_internal_templateparser.y" +>>>>>>> trunk function yy_r62() { $this->_retvalue = array(trim($this->yystack[$this->yyidx + - 1]->minor, " =\n\r\t") => $this->yystack[$this->yyidx + 0]->minor); } +<<<<<<< HEAD #line 2541 "smarty_internal_templateparser.php" #line 525 "smarty_internal_templateparser.y" +======= + #line 2545 "smarty_internal_templateparser.php" + #line 529 "smarty_internal_templateparser.y" +>>>>>>> trunk function yy_r64() { $this->_retvalue = "'" . $this->yystack[$this->yyidx + 0]->minor . "'"; } +<<<<<<< HEAD #line 2546 "smarty_internal_templateparser.php" #line 537 "smarty_internal_templateparser.y" +======= + #line 2550 "smarty_internal_templateparser.php" + #line 541 "smarty_internal_templateparser.y" +>>>>>>> trunk function yy_r67() { $this->_retvalue = array($this->yystack[$this->yyidx + - 2]->minor => $this->yystack[$this->yyidx + 0]->minor); } +<<<<<<< HEAD #line 2551 "smarty_internal_templateparser.php" #line 550 "smarty_internal_templateparser.y" +======= + #line 2555 "smarty_internal_templateparser.php" + #line 554 "smarty_internal_templateparser.y" +>>>>>>> trunk function yy_r69() { $this->yystack[$this->yyidx + - 2]->minor[] = $this->yystack[$this->yyidx + 0]->minor; $this->_retvalue = $this->yystack[$this->yyidx + - 2]->minor; } +<<<<<<< HEAD #line 2557 "smarty_internal_templateparser.php" #line 555 "smarty_internal_templateparser.y" +======= + #line 2561 "smarty_internal_templateparser.php" + #line 559 "smarty_internal_templateparser.y" +>>>>>>> trunk function yy_r70() { $this->_retvalue = array('var' => $this->yystack[$this->yyidx + - 2]->minor, 'value' => $this->yystack[$this->yyidx + 0]->minor); } +<<<<<<< HEAD #line 2562 "smarty_internal_templateparser.php" #line 583 "smarty_internal_templateparser.y" +======= + #line 2566 "smarty_internal_templateparser.php" + #line 587 "smarty_internal_templateparser.y" +>>>>>>> trunk function yy_r75() { $this->_retvalue = '$_smarty_tpl->getStreamVariable(\'' . $this->yystack[$this->yyidx + - 2]->minor . '://' . $this->yystack[$this->yyidx + 0]->minor . '\')'; } +<<<<<<< HEAD #line 2567 "smarty_internal_templateparser.php" #line 588 "smarty_internal_templateparser.y" +======= + #line 2571 "smarty_internal_templateparser.php" + #line 592 "smarty_internal_templateparser.y" +>>>>>>> trunk function yy_r76() { $this->_retvalue = $this->yystack[$this->yyidx + - 2]->minor . trim($this->yystack[$this->yyidx + - 1]->minor) . $this->yystack[$this->yyidx + 0]->minor; } +<<<<<<< HEAD #line 2572 "smarty_internal_templateparser.php" #line 607 "smarty_internal_templateparser.y" +======= + #line 2576 "smarty_internal_templateparser.php" + #line 611 "smarty_internal_templateparser.y" +>>>>>>> trunk function yy_r80() { $this->_retvalue = $this->compiler->compileTag('private_modifier', array(), array('value' => $this->yystack[$this->yyidx + - 1]->minor, 'modifierlist' => $this->yystack[$this->yyidx + 0]->minor)); } +<<<<<<< HEAD #line 2577 "smarty_internal_templateparser.php" #line 613 "smarty_internal_templateparser.y" +======= + #line 2581 "smarty_internal_templateparser.php" + #line 617 "smarty_internal_templateparser.y" +>>>>>>> trunk function yy_r81() { $this->_retvalue = $this->yystack[$this->yyidx + - 2]->minor . $this->yystack[$this->yyidx + - 1]->minor . $this->yystack[$this->yyidx + 0]->minor; } +<<<<<<< HEAD #line 2582 "smarty_internal_templateparser.php" #line 617 "smarty_internal_templateparser.y" +======= + #line 2586 "smarty_internal_templateparser.php" + #line 621 "smarty_internal_templateparser.y" +>>>>>>> trunk function yy_r82() { $this->_retvalue = 'in_array(' . $this->yystack[$this->yyidx + - 2]->minor . ',' . $this->yystack[$this->yyidx + 0]->minor . ')'; } +<<<<<<< HEAD #line 2587 "smarty_internal_templateparser.php" #line 621 "smarty_internal_templateparser.y" +======= + #line 2591 "smarty_internal_templateparser.php" + #line 625 "smarty_internal_templateparser.y" +>>>>>>> trunk function yy_r83() { $this->_retvalue = 'in_array(' . $this->yystack[$this->yyidx + - 2]->minor . ',(array)' . $this->yystack[$this->yyidx + 0]->minor . ')'; } +<<<<<<< HEAD #line 2592 "smarty_internal_templateparser.php" #line 629 "smarty_internal_templateparser.y" +======= + #line 2596 "smarty_internal_templateparser.php" + #line 633 "smarty_internal_templateparser.y" +>>>>>>> trunk function yy_r85() { $this->_retvalue = '!(' . $this->yystack[$this->yyidx + - 2]->minor . ' % ' . $this->yystack[$this->yyidx + 0]->minor . ')'; } +<<<<<<< HEAD #line 2597 "smarty_internal_templateparser.php" #line 633 "smarty_internal_templateparser.y" +======= + #line 2601 "smarty_internal_templateparser.php" + #line 637 "smarty_internal_templateparser.y" +>>>>>>> trunk function yy_r86() { $this->_retvalue = '(' . $this->yystack[$this->yyidx + - 2]->minor . ' % ' . $this->yystack[$this->yyidx + 0]->minor . ')'; } +<<<<<<< HEAD #line 2602 "smarty_internal_templateparser.php" #line 637 "smarty_internal_templateparser.y" +======= + #line 2606 "smarty_internal_templateparser.php" + #line 641 "smarty_internal_templateparser.y" +>>>>>>> trunk function yy_r87() { $this->_retvalue = '!(1 & ' . $this->yystack[$this->yyidx + - 1]->minor . ')'; } +<<<<<<< HEAD #line 2607 "smarty_internal_templateparser.php" #line 641 "smarty_internal_templateparser.y" +======= + #line 2611 "smarty_internal_templateparser.php" + #line 645 "smarty_internal_templateparser.y" +>>>>>>> trunk function yy_r88() { $this->_retvalue = '(1 & ' . $this->yystack[$this->yyidx + - 1]->minor . ')'; } +<<<<<<< HEAD #line 2612 "smarty_internal_templateparser.php" #line 645 "smarty_internal_templateparser.y" +======= + #line 2616 "smarty_internal_templateparser.php" + #line 649 "smarty_internal_templateparser.y" +>>>>>>> trunk function yy_r89() { $this->_retvalue = '!(1 & ' . $this->yystack[$this->yyidx + - 2]->minor . ' / ' . $this->yystack[$this->yyidx + 0]->minor . ')'; } +<<<<<<< HEAD #line 2617 "smarty_internal_templateparser.php" #line 649 "smarty_internal_templateparser.y" +======= + #line 2621 "smarty_internal_templateparser.php" + #line 653 "smarty_internal_templateparser.y" +>>>>>>> trunk function yy_r90() { $this->_retvalue = '(1 & ' . $this->yystack[$this->yyidx + - 2]->minor . ' / ' . $this->yystack[$this->yyidx + 0]->minor . ')'; } +<<<<<<< HEAD #line 2622 "smarty_internal_templateparser.php" #line 673 "smarty_internal_templateparser.y" +======= + #line 2626 "smarty_internal_templateparser.php" + #line 677 "smarty_internal_templateparser.y" +>>>>>>> trunk function yy_r96() { self::$prefix_number ++; $this->compiler->prefix_code[] = 'yystack[$this->yyidx + 0]->minor . ';?>'; $this->_retvalue = $this->yystack[$this->yyidx + - 2]->minor . $this->yystack[$this->yyidx + - 1]->minor . '$_tmp' . self::$prefix_number; } +<<<<<<< HEAD #line 2629 "smarty_internal_templateparser.php" #line 682 "smarty_internal_templateparser.y" +======= + #line 2633 "smarty_internal_templateparser.php" + #line 686 "smarty_internal_templateparser.y" +>>>>>>> trunk function yy_r97() { $this->_retvalue = $this->yystack[$this->yyidx + - 6]->minor . ' ? ' . $this->compileVariable("'" . $this->yystack[$this->yyidx + - 2]->minor . "'") . ' : ' . $this->yystack[$this->yyidx + 0]->minor; } +<<<<<<< HEAD #line 2634 "smarty_internal_templateparser.php" #line 686 "smarty_internal_templateparser.y" +======= + #line 2638 "smarty_internal_templateparser.php" + #line 690 "smarty_internal_templateparser.y" +>>>>>>> trunk function yy_r98() { $this->_retvalue = $this->yystack[$this->yyidx + - 5]->minor . ' ? ' . $this->yystack[$this->yyidx + - 2]->minor . ' : ' . $this->yystack[$this->yyidx + 0]->minor; } +<<<<<<< HEAD #line 2639 "smarty_internal_templateparser.php" #line 701 "smarty_internal_templateparser.y" +======= + #line 2643 "smarty_internal_templateparser.php" + #line 705 "smarty_internal_templateparser.y" +>>>>>>> trunk function yy_r101() { $this->_retvalue = '!' . $this->yystack[$this->yyidx + 0]->minor; } +<<<<<<< HEAD #line 2644 "smarty_internal_templateparser.php" #line 722 "smarty_internal_templateparser.y" +======= + #line 2648 "smarty_internal_templateparser.php" + #line 726 "smarty_internal_templateparser.y" +>>>>>>> trunk function yy_r106() { $this->_retvalue = $this->yystack[$this->yyidx + - 2]->minor . '.' . $this->yystack[$this->yyidx + 0]->minor; } +<<<<<<< HEAD #line 2649 "smarty_internal_templateparser.php" #line 726 "smarty_internal_templateparser.y" +======= + #line 2653 "smarty_internal_templateparser.php" + #line 730 "smarty_internal_templateparser.y" +>>>>>>> trunk function yy_r107() { $this->_retvalue = $this->yystack[$this->yyidx + - 1]->minor . '.'; } +<<<<<<< HEAD #line 2654 "smarty_internal_templateparser.php" #line 730 "smarty_internal_templateparser.y" +======= + #line 2658 "smarty_internal_templateparser.php" + #line 734 "smarty_internal_templateparser.y" +>>>>>>> trunk function yy_r108() { $this->_retvalue = '.' . $this->yystack[$this->yyidx + 0]->minor; } +<<<<<<< HEAD #line 2659 "smarty_internal_templateparser.php" #line 735 "smarty_internal_templateparser.y" +======= + #line 2663 "smarty_internal_templateparser.php" + #line 739 "smarty_internal_templateparser.y" +>>>>>>> trunk function yy_r109() { if (preg_match('~^true$~i', $this->yystack[$this->yyidx + 0]->minor)) { @@ -3916,14 +4337,24 @@ class Smarty_Internal_Templateparser#line 80 "smarty_internal_templateparser.php $this->_retvalue = "'" . $this->yystack[$this->yyidx + 0]->minor . "'"; } } +<<<<<<< HEAD #line 2672 "smarty_internal_templateparser.php" #line 753 "smarty_internal_templateparser.y" +======= + #line 2676 "smarty_internal_templateparser.php" + #line 757 "smarty_internal_templateparser.y" +>>>>>>> trunk function yy_r111() { $this->_retvalue = "(" . $this->yystack[$this->yyidx + - 1]->minor . ")"; } +<<<<<<< HEAD #line 2677 "smarty_internal_templateparser.php" #line 768 "smarty_internal_templateparser.y" +======= + #line 2681 "smarty_internal_templateparser.php" + #line 772 "smarty_internal_templateparser.y" +>>>>>>> trunk function yy_r114() { if (!$this->security || isset($this->smarty->registered_classes[$this->yystack[$this->yyidx + - 2]->minor]) || $this->smarty->security_policy->isTrustedStaticClass($this->yystack[$this->yyidx + - 2]->minor, $this->compiler)) { @@ -3936,6 +4367,7 @@ class Smarty_Internal_Templateparser#line 80 "smarty_internal_templateparser.php $this->compiler->trigger_template_error("static class '" . $this->yystack[$this->yyidx + - 2]->minor . "' is undefined or not allowed by security setting"); } } +<<<<<<< HEAD #line 2690 "smarty_internal_templateparser.php" #line 780 "smarty_internal_templateparser.y" function yy_r115() @@ -3948,14 +4380,35 @@ class Smarty_Internal_Templateparser#line 80 "smarty_internal_templateparser.php } #line 2699 "smarty_internal_templateparser.php" #line 789 "smarty_internal_templateparser.y" +======= + #line 2694 "smarty_internal_templateparser.php" + #line 784 "smarty_internal_templateparser.y" + function yy_r115() + { + self::$prefix_number ++; + if ($this->yystack[$this->yyidx + - 2]->minor['var'] == '\'smarty\'') { + $this->compiler->prefix_code[] = 'compiler->compileTag('private_special_variable', array(), $this->yystack[$this->yyidx + - 2]->minor['smarty_internal_index']) . ';?>'; + } else { + $this->compiler->prefix_code[] = 'compileVariable($this->yystack[$this->yyidx + - 2]->minor['var']) . $this->yystack[$this->yyidx + - 2]->minor['smarty_internal_index'] . ';?>'; + } + $this->_retvalue = '$_tmp' . self::$prefix_number . '::' . $this->yystack[$this->yyidx + 0]->minor; + } + #line 2706 "smarty_internal_templateparser.php" + #line 796 "smarty_internal_templateparser.y" +>>>>>>> trunk function yy_r116() { self::$prefix_number ++; $this->compiler->prefix_code[] = '' . $this->yystack[$this->yyidx + - 1]->minor . ''; $this->_retvalue = '$_tmp' . self::$prefix_number; } +<<<<<<< HEAD #line 2706 "smarty_internal_templateparser.php" #line 804 "smarty_internal_templateparser.y" +======= + #line 2713 "smarty_internal_templateparser.php" + #line 811 "smarty_internal_templateparser.y" +>>>>>>> trunk function yy_r118() { if ($this->yystack[$this->yyidx + 0]->minor['var'] == '\'smarty\'') { @@ -3968,116 +4421,211 @@ class Smarty_Internal_Templateparser#line 80 "smarty_internal_templateparser.php $this->_retvalue = $this->compileVariable($this->yystack[$this->yyidx + 0]->minor['var']) . $this->yystack[$this->yyidx + 0]->minor['smarty_internal_index']; } } +<<<<<<< HEAD #line 2719 "smarty_internal_templateparser.php" #line 817 "smarty_internal_templateparser.y" +======= + #line 2726 "smarty_internal_templateparser.php" + #line 824 "smarty_internal_templateparser.y" +>>>>>>> trunk function yy_r119() { $this->_retvalue = '$_smarty_tpl->tpl_vars[' . $this->yystack[$this->yyidx + - 2]->minor . ']->' . $this->yystack[$this->yyidx + 0]->minor; } +<<<<<<< HEAD #line 2724 "smarty_internal_templateparser.php" #line 827 "smarty_internal_templateparser.y" +======= + #line 2731 "smarty_internal_templateparser.php" + #line 834 "smarty_internal_templateparser.y" +>>>>>>> trunk function yy_r121() { $this->_retvalue = '$_smarty_tpl->getConfigVariable(\'' . $this->yystack[$this->yyidx + - 1]->minor . '\')'; } +<<<<<<< HEAD #line 2729 "smarty_internal_templateparser.php" #line 831 "smarty_internal_templateparser.y" +======= + #line 2736 "smarty_internal_templateparser.php" + #line 838 "smarty_internal_templateparser.y" +>>>>>>> trunk function yy_r122() { $this->_retvalue = '(is_array($tmp = $_smarty_tpl->getConfigVariable(\'' . $this->yystack[$this->yyidx + - 2]->minor . '\')) ? $tmp' . $this->yystack[$this->yyidx + 0]->minor . ' :null)'; } +<<<<<<< HEAD #line 2734 "smarty_internal_templateparser.php" #line 835 "smarty_internal_templateparser.y" +======= + #line 2741 "smarty_internal_templateparser.php" + #line 842 "smarty_internal_templateparser.y" +>>>>>>> trunk function yy_r123() { $this->_retvalue = '$_smarty_tpl->getConfigVariable(' . $this->yystack[$this->yyidx + - 1]->minor . ')'; } +<<<<<<< HEAD #line 2739 "smarty_internal_templateparser.php" #line 839 "smarty_internal_templateparser.y" +======= + #line 2746 "smarty_internal_templateparser.php" + #line 846 "smarty_internal_templateparser.y" +>>>>>>> trunk function yy_r124() { $this->_retvalue = '(is_array($tmp = $_smarty_tpl->getConfigVariable(' . $this->yystack[$this->yyidx + - 2]->minor . ')) ? $tmp' . $this->yystack[$this->yyidx + 0]->minor . ' : null)'; } +<<<<<<< HEAD #line 2744 "smarty_internal_templateparser.php" #line 843 "smarty_internal_templateparser.y" +======= + #line 2751 "smarty_internal_templateparser.php" + #line 850 "smarty_internal_templateparser.y" +>>>>>>> trunk function yy_r125() { $this->_retvalue = array('var' => $this->yystack[$this->yyidx + - 1]->minor, 'smarty_internal_index' => $this->yystack[$this->yyidx + 0]->minor); } +<<<<<<< HEAD #line 2749 "smarty_internal_templateparser.php" #line 856 "smarty_internal_templateparser.y" +======= + #line 2756 "smarty_internal_templateparser.php" + #line 863 "smarty_internal_templateparser.y" +>>>>>>> trunk function yy_r127() { return; } +<<<<<<< HEAD #line 2754 "smarty_internal_templateparser.php" #line 862 "smarty_internal_templateparser.y" +======= + #line 2761 "smarty_internal_templateparser.php" + #line 869 "smarty_internal_templateparser.y" +>>>>>>> trunk function yy_r128() { $this->_retvalue = '[' . $this->compileVariable($this->yystack[$this->yyidx + 0]->minor) . ']'; } +<<<<<<< HEAD #line 2759 "smarty_internal_templateparser.php" #line 866 "smarty_internal_templateparser.y" +======= + #line 2766 "smarty_internal_templateparser.php" + #line 873 "smarty_internal_templateparser.y" +>>>>>>> trunk function yy_r129() { $this->_retvalue = '[' . $this->compileVariable($this->yystack[$this->yyidx + - 2]->minor) . '->' . $this->yystack[$this->yyidx + 0]->minor . ']'; } +<<<<<<< HEAD #line 2764 "smarty_internal_templateparser.php" #line 870 "smarty_internal_templateparser.y" +======= + #line 2771 "smarty_internal_templateparser.php" + #line 877 "smarty_internal_templateparser.y" +>>>>>>> trunk function yy_r130() { $this->_retvalue = "['" . $this->yystack[$this->yyidx + 0]->minor . "']"; } +<<<<<<< HEAD #line 2769 "smarty_internal_templateparser.php" #line 874 "smarty_internal_templateparser.y" +======= + #line 2776 "smarty_internal_templateparser.php" + #line 881 "smarty_internal_templateparser.y" +>>>>>>> trunk function yy_r131() { $this->_retvalue = "[" . $this->yystack[$this->yyidx + 0]->minor . "]"; } +<<<<<<< HEAD #line 2774 "smarty_internal_templateparser.php" #line 878 "smarty_internal_templateparser.y" +======= + #line 2781 "smarty_internal_templateparser.php" + #line 885 "smarty_internal_templateparser.y" +>>>>>>> trunk function yy_r132() { $this->_retvalue = "[" . $this->yystack[$this->yyidx + - 1]->minor . "]"; } +<<<<<<< HEAD #line 2779 "smarty_internal_templateparser.php" #line 883 "smarty_internal_templateparser.y" +======= + #line 2786 "smarty_internal_templateparser.php" + #line 890 "smarty_internal_templateparser.y" +>>>>>>> trunk function yy_r133() { $this->_retvalue = '[' . $this->compiler->compileTag('private_special_variable', array(), '[\'section\'][\'' . $this->yystack[$this->yyidx + - 1]->minor . '\'][\'index\']') . ']'; } +<<<<<<< HEAD #line 2784 "smarty_internal_templateparser.php" #line 887 "smarty_internal_templateparser.y" +======= + #line 2791 "smarty_internal_templateparser.php" + #line 894 "smarty_internal_templateparser.y" +>>>>>>> trunk function yy_r134() { $this->_retvalue = '[' . $this->compiler->compileTag('private_special_variable', array(), '[\'section\'][\'' . $this->yystack[$this->yyidx + - 3]->minor . '\'][\'' . $this->yystack[$this->yyidx + - 1]->minor . '\']') . ']'; } +<<<<<<< HEAD #line 2789 "smarty_internal_templateparser.php" #line 897 "smarty_internal_templateparser.y" +======= + #line 2796 "smarty_internal_templateparser.php" + #line 904 "smarty_internal_templateparser.y" +>>>>>>> trunk function yy_r136() { $this->_retvalue = '[]'; } +<<<<<<< HEAD #line 2794 "smarty_internal_templateparser.php" #line 910 "smarty_internal_templateparser.y" +======= + #line 2801 "smarty_internal_templateparser.php" + #line 917 "smarty_internal_templateparser.y" +>>>>>>> trunk function yy_r138() { $this->_retvalue = $this->yystack[$this->yyidx + - 1]->minor . '.' . $this->yystack[$this->yyidx + 0]->minor; } +<<<<<<< HEAD #line 2799 "smarty_internal_templateparser.php" #line 915 "smarty_internal_templateparser.y" +======= + #line 2806 "smarty_internal_templateparser.php" + #line 922 "smarty_internal_templateparser.y" +>>>>>>> trunk function yy_r139() { $this->_retvalue = '\'' . $this->yystack[$this->yyidx + 0]->minor . '\''; } +<<<<<<< HEAD #line 2804 "smarty_internal_templateparser.php" #line 920 "smarty_internal_templateparser.y" +======= + #line 2811 "smarty_internal_templateparser.php" + #line 927 "smarty_internal_templateparser.y" +>>>>>>> trunk function yy_r140() { $this->_retvalue = '(' . $this->yystack[$this->yyidx + - 1]->minor . ')'; } +<<<<<<< HEAD #line 2809 "smarty_internal_templateparser.php" #line 927 "smarty_internal_templateparser.y" +======= + #line 2816 "smarty_internal_templateparser.php" + #line 934 "smarty_internal_templateparser.y" +>>>>>>> trunk function yy_r141() { if ($this->yystack[$this->yyidx + - 1]->minor['var'] == '\'smarty\'') { @@ -4086,20 +4634,35 @@ class Smarty_Internal_Templateparser#line 80 "smarty_internal_templateparser.php $this->_retvalue = $this->compileVariable($this->yystack[$this->yyidx + - 1]->minor['var']) . $this->yystack[$this->yyidx + - 1]->minor['smarty_internal_index'] . $this->yystack[$this->yyidx + 0]->minor; } } +<<<<<<< HEAD #line 2818 "smarty_internal_templateparser.php" #line 936 "smarty_internal_templateparser.y" +======= + #line 2825 "smarty_internal_templateparser.php" + #line 943 "smarty_internal_templateparser.y" +>>>>>>> trunk function yy_r142() { $this->_retvalue = $this->yystack[$this->yyidx + 0]->minor; } +<<<<<<< HEAD #line 2823 "smarty_internal_templateparser.php" #line 941 "smarty_internal_templateparser.y" +======= + #line 2830 "smarty_internal_templateparser.php" + #line 948 "smarty_internal_templateparser.y" +>>>>>>> trunk function yy_r143() { $this->_retvalue = $this->yystack[$this->yyidx + - 1]->minor . $this->yystack[$this->yyidx + 0]->minor; } +<<<<<<< HEAD #line 2828 "smarty_internal_templateparser.php" #line 946 "smarty_internal_templateparser.y" +======= + #line 2835 "smarty_internal_templateparser.php" + #line 953 "smarty_internal_templateparser.y" +>>>>>>> trunk function yy_r144() { if ($this->security && substr($this->yystack[$this->yyidx + - 1]->minor, 0, 1) == '_') { @@ -4107,8 +4670,13 @@ class Smarty_Internal_Templateparser#line 80 "smarty_internal_templateparser.php } $this->_retvalue = '->' . $this->yystack[$this->yyidx + - 1]->minor . $this->yystack[$this->yyidx + 0]->minor; } +<<<<<<< HEAD #line 2836 "smarty_internal_templateparser.php" #line 953 "smarty_internal_templateparser.y" +======= + #line 2843 "smarty_internal_templateparser.php" + #line 960 "smarty_internal_templateparser.y" +>>>>>>> trunk function yy_r145() { if ($this->security) { @@ -4116,8 +4684,13 @@ class Smarty_Internal_Templateparser#line 80 "smarty_internal_templateparser.php } $this->_retvalue = '->{' . $this->compileVariable($this->yystack[$this->yyidx + - 1]->minor) . $this->yystack[$this->yyidx + 0]->minor . '}'; } +<<<<<<< HEAD #line 2844 "smarty_internal_templateparser.php" #line 960 "smarty_internal_templateparser.y" +======= + #line 2851 "smarty_internal_templateparser.php" + #line 967 "smarty_internal_templateparser.y" +>>>>>>> trunk function yy_r146() { if ($this->security) { @@ -4125,8 +4698,13 @@ class Smarty_Internal_Templateparser#line 80 "smarty_internal_templateparser.php } $this->_retvalue = '->{' . $this->yystack[$this->yyidx + - 2]->minor . $this->yystack[$this->yyidx + 0]->minor . '}'; } +<<<<<<< HEAD #line 2852 "smarty_internal_templateparser.php" #line 967 "smarty_internal_templateparser.y" +======= + #line 2859 "smarty_internal_templateparser.php" + #line 974 "smarty_internal_templateparser.y" +>>>>>>> trunk function yy_r147() { if ($this->security) { @@ -4134,14 +4712,24 @@ class Smarty_Internal_Templateparser#line 80 "smarty_internal_templateparser.php } $this->_retvalue = '->{\'' . $this->yystack[$this->yyidx + - 4]->minor . '\'.' . $this->yystack[$this->yyidx + - 2]->minor . $this->yystack[$this->yyidx + 0]->minor . '}'; } +<<<<<<< HEAD #line 2860 "smarty_internal_templateparser.php" #line 975 "smarty_internal_templateparser.y" +======= + #line 2867 "smarty_internal_templateparser.php" + #line 982 "smarty_internal_templateparser.y" +>>>>>>> trunk function yy_r148() { $this->_retvalue = '->' . $this->yystack[$this->yyidx + 0]->minor; } +<<<<<<< HEAD #line 2865 "smarty_internal_templateparser.php" #line 983 "smarty_internal_templateparser.y" +======= + #line 2872 "smarty_internal_templateparser.php" + #line 990 "smarty_internal_templateparser.y" +>>>>>>> trunk function yy_r149() { if (!$this->security || $this->smarty->security_policy->isTrustedPhpFunction($this->yystack[$this->yyidx + - 3]->minor, $this->compiler)) { @@ -4177,8 +4765,13 @@ class Smarty_Internal_Templateparser#line 80 "smarty_internal_templateparser.php } } } +<<<<<<< HEAD #line 2901 "smarty_internal_templateparser.php" #line 1021 "smarty_internal_templateparser.y" +======= + #line 2908 "smarty_internal_templateparser.php" + #line 1028 "smarty_internal_templateparser.y" +>>>>>>> trunk function yy_r150() { if ($this->security && substr($this->yystack[$this->yyidx + - 3]->minor, 0, 1) == '_') { @@ -4186,8 +4779,13 @@ class Smarty_Internal_Templateparser#line 80 "smarty_internal_templateparser.php } $this->_retvalue = $this->yystack[$this->yyidx + - 3]->minor . "(" . implode(',', $this->yystack[$this->yyidx + - 1]->minor) . ")"; } +<<<<<<< HEAD #line 2909 "smarty_internal_templateparser.php" #line 1028 "smarty_internal_templateparser.y" +======= + #line 2916 "smarty_internal_templateparser.php" + #line 1035 "smarty_internal_templateparser.y" +>>>>>>> trunk function yy_r151() { if ($this->security) { @@ -4197,201 +4795,365 @@ class Smarty_Internal_Templateparser#line 80 "smarty_internal_templateparser.php $this->compiler->prefix_code[] = 'compileVariable("'" . $this->yystack[$this->yyidx + - 3]->minor . "'") . ';?>'; $this->_retvalue = '$_tmp' . self::$prefix_number . '(' . implode(',', $this->yystack[$this->yyidx + - 1]->minor) . ')'; } +<<<<<<< HEAD #line 2919 "smarty_internal_templateparser.php" #line 1039 "smarty_internal_templateparser.y" +======= + #line 2926 "smarty_internal_templateparser.php" + #line 1046 "smarty_internal_templateparser.y" +>>>>>>> trunk function yy_r152() { $this->_retvalue = array_merge($this->yystack[$this->yyidx + - 2]->minor, array($this->yystack[$this->yyidx + 0]->minor)); } +<<<<<<< HEAD #line 2924 "smarty_internal_templateparser.php" #line 1056 "smarty_internal_templateparser.y" +======= + #line 2931 "smarty_internal_templateparser.php" + #line 1063 "smarty_internal_templateparser.y" +>>>>>>> trunk function yy_r155() { $this->_retvalue = array_merge($this->yystack[$this->yyidx + - 2]->minor, array(array_merge($this->yystack[$this->yyidx + - 1]->minor, $this->yystack[$this->yyidx + 0]->minor))); } +<<<<<<< HEAD #line 2929 "smarty_internal_templateparser.php" #line 1060 "smarty_internal_templateparser.y" +======= + #line 2936 "smarty_internal_templateparser.php" + #line 1067 "smarty_internal_templateparser.y" +>>>>>>> trunk function yy_r156() { $this->_retvalue = array(array_merge($this->yystack[$this->yyidx + - 1]->minor, $this->yystack[$this->yyidx + 0]->minor)); } +<<<<<<< HEAD #line 2934 "smarty_internal_templateparser.php" #line 1068 "smarty_internal_templateparser.y" +======= + #line 2941 "smarty_internal_templateparser.php" + #line 1075 "smarty_internal_templateparser.y" +>>>>>>> trunk function yy_r158() { $this->_retvalue = array($this->yystack[$this->yyidx + 0]->minor); } +<<<<<<< HEAD #line 2939 "smarty_internal_templateparser.php" #line 1076 "smarty_internal_templateparser.y" +======= + #line 2946 "smarty_internal_templateparser.php" + #line 1083 "smarty_internal_templateparser.y" +>>>>>>> trunk function yy_r159() { $this->_retvalue = array_merge($this->yystack[$this->yyidx + - 1]->minor, $this->yystack[$this->yyidx + 0]->minor); } +<<<<<<< HEAD #line 2944 "smarty_internal_templateparser.php" #line 1110 "smarty_internal_templateparser.y" +======= + #line 2951 "smarty_internal_templateparser.php" + #line 1117 "smarty_internal_templateparser.y" +>>>>>>> trunk function yy_r166() { $this->_retvalue = '$' . $this->yystack[$this->yyidx + - 1]->minor . $this->yystack[$this->yyidx + 0]->minor; } +<<<<<<< HEAD #line 2949 "smarty_internal_templateparser.php" #line 1115 "smarty_internal_templateparser.y" +======= + #line 2956 "smarty_internal_templateparser.php" + #line 1122 "smarty_internal_templateparser.y" +>>>>>>> trunk function yy_r167() { $this->_retvalue = '$' . $this->yystack[$this->yyidx + - 2]->minor . $this->yystack[$this->yyidx + - 1]->minor . $this->yystack[$this->yyidx + 0]->minor; } +<<<<<<< HEAD #line 2954 "smarty_internal_templateparser.php" #line 1121 "smarty_internal_templateparser.y" +======= + #line 2961 "smarty_internal_templateparser.php" + #line 1128 "smarty_internal_templateparser.y" +>>>>>>> trunk function yy_r168() { $this->_retvalue = '=='; } +<<<<<<< HEAD #line 2959 "smarty_internal_templateparser.php" #line 1125 "smarty_internal_templateparser.y" +======= + #line 2966 "smarty_internal_templateparser.php" + #line 1132 "smarty_internal_templateparser.y" +>>>>>>> trunk function yy_r169() { $this->_retvalue = '!='; } +<<<<<<< HEAD #line 2964 "smarty_internal_templateparser.php" #line 1129 "smarty_internal_templateparser.y" +======= + #line 2971 "smarty_internal_templateparser.php" + #line 1136 "smarty_internal_templateparser.y" +>>>>>>> trunk function yy_r170() { $this->_retvalue = '>'; } +<<<<<<< HEAD #line 2969 "smarty_internal_templateparser.php" #line 1133 "smarty_internal_templateparser.y" +======= + #line 2976 "smarty_internal_templateparser.php" + #line 1140 "smarty_internal_templateparser.y" +>>>>>>> trunk function yy_r171() { $this->_retvalue = '<'; } +<<<<<<< HEAD #line 2974 "smarty_internal_templateparser.php" #line 1137 "smarty_internal_templateparser.y" +======= + #line 2981 "smarty_internal_templateparser.php" + #line 1144 "smarty_internal_templateparser.y" +>>>>>>> trunk function yy_r172() { $this->_retvalue = '>='; } +<<<<<<< HEAD #line 2979 "smarty_internal_templateparser.php" #line 1141 "smarty_internal_templateparser.y" +======= + #line 2986 "smarty_internal_templateparser.php" + #line 1148 "smarty_internal_templateparser.y" +>>>>>>> trunk function yy_r173() { $this->_retvalue = '<='; } +<<<<<<< HEAD #line 2984 "smarty_internal_templateparser.php" #line 1145 "smarty_internal_templateparser.y" +======= + #line 2991 "smarty_internal_templateparser.php" + #line 1152 "smarty_internal_templateparser.y" +>>>>>>> trunk function yy_r174() { $this->_retvalue = '==='; } +<<<<<<< HEAD #line 2989 "smarty_internal_templateparser.php" #line 1149 "smarty_internal_templateparser.y" +======= + #line 2996 "smarty_internal_templateparser.php" + #line 1156 "smarty_internal_templateparser.y" +>>>>>>> trunk function yy_r175() { $this->_retvalue = '!=='; } +<<<<<<< HEAD #line 2994 "smarty_internal_templateparser.php" #line 1153 "smarty_internal_templateparser.y" +======= + #line 3001 "smarty_internal_templateparser.php" + #line 1160 "smarty_internal_templateparser.y" +>>>>>>> trunk function yy_r176() { $this->_retvalue = '%'; } +<<<<<<< HEAD #line 2999 "smarty_internal_templateparser.php" #line 1157 "smarty_internal_templateparser.y" +======= + #line 3006 "smarty_internal_templateparser.php" + #line 1164 "smarty_internal_templateparser.y" +>>>>>>> trunk function yy_r177() { $this->_retvalue = '&&'; } +<<<<<<< HEAD #line 3004 "smarty_internal_templateparser.php" #line 1161 "smarty_internal_templateparser.y" +======= + #line 3011 "smarty_internal_templateparser.php" + #line 1168 "smarty_internal_templateparser.y" +>>>>>>> trunk function yy_r178() { $this->_retvalue = '||'; } +<<<<<<< HEAD #line 3009 "smarty_internal_templateparser.php" #line 1165 "smarty_internal_templateparser.y" +======= + #line 3016 "smarty_internal_templateparser.php" + #line 1172 "smarty_internal_templateparser.y" +>>>>>>> trunk function yy_r179() { $this->_retvalue = ' XOR '; } +<<<<<<< HEAD #line 3014 "smarty_internal_templateparser.php" #line 1172 "smarty_internal_templateparser.y" +======= + #line 3021 "smarty_internal_templateparser.php" + #line 1179 "smarty_internal_templateparser.y" +>>>>>>> trunk function yy_r180() { $this->_retvalue = 'array(' . $this->yystack[$this->yyidx + - 1]->minor . ')'; } +<<<<<<< HEAD #line 3019 "smarty_internal_templateparser.php" #line 1180 "smarty_internal_templateparser.y" +======= + #line 3026 "smarty_internal_templateparser.php" + #line 1187 "smarty_internal_templateparser.y" +>>>>>>> trunk function yy_r182() { $this->_retvalue = $this->yystack[$this->yyidx + - 2]->minor . ',' . $this->yystack[$this->yyidx + 0]->minor; } +<<<<<<< HEAD #line 3024 "smarty_internal_templateparser.php" #line 1188 "smarty_internal_templateparser.y" +======= + #line 3031 "smarty_internal_templateparser.php" + #line 1195 "smarty_internal_templateparser.y" +>>>>>>> trunk function yy_r184() { $this->_retvalue = $this->yystack[$this->yyidx + - 2]->minor . '=>' . $this->yystack[$this->yyidx + 0]->minor; } +<<<<<<< HEAD #line 3029 "smarty_internal_templateparser.php" #line 1192 "smarty_internal_templateparser.y" +======= + #line 3036 "smarty_internal_templateparser.php" + #line 1199 "smarty_internal_templateparser.y" +>>>>>>> trunk function yy_r185() { $this->_retvalue = '\'' . $this->yystack[$this->yyidx + - 2]->minor . '\'=>' . $this->yystack[$this->yyidx + 0]->minor; } +<<<<<<< HEAD #line 3034 "smarty_internal_templateparser.php" #line 1204 "smarty_internal_templateparser.y" +======= + #line 3041 "smarty_internal_templateparser.php" + #line 1211 "smarty_internal_templateparser.y" +>>>>>>> trunk function yy_r187() { $this->_retvalue = "''"; } +<<<<<<< HEAD #line 3039 "smarty_internal_templateparser.php" #line 1208 "smarty_internal_templateparser.y" +======= + #line 3046 "smarty_internal_templateparser.php" + #line 1215 "smarty_internal_templateparser.y" +>>>>>>> trunk function yy_r188() { $this->_retvalue = $this->yystack[$this->yyidx + - 1]->minor->to_smarty_php(); } +<<<<<<< HEAD #line 3044 "smarty_internal_templateparser.php" #line 1213 "smarty_internal_templateparser.y" +======= + #line 3051 "smarty_internal_templateparser.php" + #line 1220 "smarty_internal_templateparser.y" +>>>>>>> trunk function yy_r189() { $this->yystack[$this->yyidx + - 1]->minor->append_subtree($this->yystack[$this->yyidx + 0]->minor); $this->_retvalue = $this->yystack[$this->yyidx + - 1]->minor; } +<<<<<<< HEAD #line 3050 "smarty_internal_templateparser.php" #line 1218 "smarty_internal_templateparser.y" +======= + #line 3057 "smarty_internal_templateparser.php" + #line 1225 "smarty_internal_templateparser.y" +>>>>>>> trunk function yy_r190() { $this->_retvalue = new _smarty_doublequoted($this, $this->yystack[$this->yyidx + 0]->minor); } +<<<<<<< HEAD #line 3055 "smarty_internal_templateparser.php" #line 1222 "smarty_internal_templateparser.y" +======= + #line 3062 "smarty_internal_templateparser.php" + #line 1229 "smarty_internal_templateparser.y" +>>>>>>> trunk function yy_r191() { $this->_retvalue = new _smarty_code($this, '(string)' . $this->yystack[$this->yyidx + - 1]->minor); } +<<<<<<< HEAD #line 3060 "smarty_internal_templateparser.php" #line 1230 "smarty_internal_templateparser.y" +======= + #line 3067 "smarty_internal_templateparser.php" + #line 1237 "smarty_internal_templateparser.y" +>>>>>>> trunk function yy_r193() { $this->_retvalue = new _smarty_code($this, '(string)$_smarty_tpl->tpl_vars[\'' . substr($this->yystack[$this->yyidx + 0]->minor, 1) . '\']->value'); } +<<<<<<< HEAD #line 3065 "smarty_internal_templateparser.php" #line 1238 "smarty_internal_templateparser.y" +======= + #line 3072 "smarty_internal_templateparser.php" + #line 1245 "smarty_internal_templateparser.y" +>>>>>>> trunk function yy_r195() { $this->_retvalue = new _smarty_code($this, '(string)(' . $this->yystack[$this->yyidx + - 1]->minor . ')'); } +<<<<<<< HEAD #line 3070 "smarty_internal_templateparser.php" #line 1242 "smarty_internal_templateparser.y" +======= + #line 3077 "smarty_internal_templateparser.php" + #line 1249 "smarty_internal_templateparser.y" +>>>>>>> trunk function yy_r196() { $this->_retvalue = new _smarty_tag($this, $this->yystack[$this->yyidx + - 1]->minor); } +<<<<<<< HEAD #line 3075 "smarty_internal_templateparser.php" #line 1246 "smarty_internal_templateparser.y" +======= + #line 3082 "smarty_internal_templateparser.php" + #line 1253 "smarty_internal_templateparser.y" +>>>>>>> trunk function yy_r197() { $this->_retvalue = new _smarty_dq_content($this, $this->yystack[$this->yyidx + 0]->minor); } +<<<<<<< HEAD #line 3080 "smarty_internal_templateparser.php" +======= + #line 3087 "smarty_internal_templateparser.php" +>>>>>>> trunk private $_retvalue; @@ -4449,12 +5211,20 @@ class Smarty_Internal_Templateparser#line 80 "smarty_internal_templateparser.php public function yy_syntax_error($yymajor, $TOKEN) { +<<<<<<< HEAD #line 75 "smarty_internal_templateparser.y" +======= + #line 79 "smarty_internal_templateparser.y" +>>>>>>> trunk $this->internalError = true; $this->yymajor = $yymajor; $this->compiler->trigger_template_error(); +<<<<<<< HEAD #line 3142 "smarty_internal_templateparser.php" +======= + #line 3149 "smarty_internal_templateparser.php" +>>>>>>> trunk } public function yy_accept() @@ -4465,14 +5235,22 @@ class Smarty_Internal_Templateparser#line 80 "smarty_internal_templateparser.php while ($this->yyidx >= 0) { $stack = $this->yy_pop_parser_stack(); } +<<<<<<< HEAD #line 66 "smarty_internal_templateparser.y" +======= + #line 70 "smarty_internal_templateparser.y" +>>>>>>> trunk $this->successful = !$this->internalError; $this->internalError = false; $this->retvalue = $this->_retvalue; //echo $this->retvalue."\n\n"; +<<<<<<< HEAD #line 3160 "smarty_internal_templateparser.php" +======= + #line 3167 "smarty_internal_templateparser.php" +>>>>>>> trunk } public function doParse($yymajor, $yytokenvalue)