aboutsummaryrefslogtreecommitdiffstats
path: root/library/Smarty
diff options
context:
space:
mode:
Diffstat (limited to 'library/Smarty')
-rw-r--r--library/Smarty/README9
-rw-r--r--library/Smarty/change_log.txt183
-rw-r--r--library/Smarty/libs/Autoloader.php96
-rw-r--r--library/Smarty/libs/Smarty.class.php865
-rw-r--r--library/Smarty/libs/SmartyBC.class.php7
-rw-r--r--library/Smarty/libs/debug.tpl8
-rw-r--r--library/Smarty/libs/plugins/modifier.debug_print_var.php6
-rw-r--r--library/Smarty/libs/plugins/modifier.regex_replace.php5
-rw-r--r--library/Smarty/libs/plugins/modifiercompiler.escape.php8
-rw-r--r--library/Smarty/libs/plugins/modifiercompiler.wordwrap.php6
-rw-r--r--library/Smarty/libs/plugins/shared.make_timestamp.php4
-rw-r--r--library/Smarty/libs/sysplugins/smarty_cacheresource.php37
-rw-r--r--library/Smarty/libs/sysplugins/smarty_cacheresource_custom.php63
-rw-r--r--library/Smarty/libs/sysplugins/smarty_cacheresource_keyvaluestore.php63
-rw-r--r--library/Smarty/libs/sysplugins/smarty_data.php2
-rw-r--r--library/Smarty/libs/sysplugins/smarty_internal_cacheresource_file.php135
-rw-r--r--library/Smarty/libs/sysplugins/smarty_internal_compile_append.php8
-rw-r--r--library/Smarty/libs/sysplugins/smarty_internal_compile_assign.php66
-rw-r--r--library/Smarty/libs/sysplugins/smarty_internal_compile_block.php515
-rw-r--r--library/Smarty/libs/sysplugins/smarty_internal_compile_break.php16
-rw-r--r--library/Smarty/libs/sysplugins/smarty_internal_compile_call.php8
-rw-r--r--library/Smarty/libs/sysplugins/smarty_internal_compile_capture.php40
-rw-r--r--library/Smarty/libs/sysplugins/smarty_internal_compile_config_load.php49
-rw-r--r--library/Smarty/libs/sysplugins/smarty_internal_compile_continue.php16
-rw-r--r--library/Smarty/libs/sysplugins/smarty_internal_compile_debug.php4
-rw-r--r--library/Smarty/libs/sysplugins/smarty_internal_compile_extends.php117
-rw-r--r--library/Smarty/libs/sysplugins/smarty_internal_compile_for.php21
-rw-r--r--library/Smarty/libs/sysplugins/smarty_internal_compile_foreach.php345
-rw-r--r--library/Smarty/libs/sysplugins/smarty_internal_compile_function.php126
-rw-r--r--library/Smarty/libs/sysplugins/smarty_internal_compile_if.php95
-rw-r--r--library/Smarty/libs/sysplugins/smarty_internal_compile_include.php252
-rw-r--r--library/Smarty/libs/sysplugins/smarty_internal_compile_include_php.php28
-rw-r--r--library/Smarty/libs/sysplugins/smarty_internal_compile_insert.php21
-rw-r--r--library/Smarty/libs/sysplugins/smarty_internal_compile_ldelim.php9
-rw-r--r--library/Smarty/libs/sysplugins/smarty_internal_compile_nocache.php12
-rw-r--r--library/Smarty/libs/sysplugins/smarty_internal_compile_private_block_plugin.php22
-rw-r--r--library/Smarty/libs/sysplugins/smarty_internal_compile_private_function_plugin.php9
-rw-r--r--library/Smarty/libs/sysplugins/smarty_internal_compile_private_modifier.php42
-rw-r--r--library/Smarty/libs/sysplugins/smarty_internal_compile_private_object_block_function.php23
-rw-r--r--library/Smarty/libs/sysplugins/smarty_internal_compile_private_object_function.php12
-rw-r--r--library/Smarty/libs/sysplugins/smarty_internal_compile_private_php.php42
-rw-r--r--library/Smarty/libs/sysplugins/smarty_internal_compile_private_print_expression.php53
-rw-r--r--library/Smarty/libs/sysplugins/smarty_internal_compile_private_registered_block.php32
-rw-r--r--library/Smarty/libs/sysplugins/smarty_internal_compile_private_registered_function.php10
-rw-r--r--library/Smarty/libs/sysplugins/smarty_internal_compile_private_special_variable.php53
-rw-r--r--library/Smarty/libs/sysplugins/smarty_internal_compile_rdelim.php4
-rw-r--r--library/Smarty/libs/sysplugins/smarty_internal_compile_section.php382
-rw-r--r--library/Smarty/libs/sysplugins/smarty_internal_compile_setfilter.php12
-rw-r--r--library/Smarty/libs/sysplugins/smarty_internal_compile_while.php46
-rw-r--r--library/Smarty/libs/sysplugins/smarty_internal_compilebase.php16
-rw-r--r--library/Smarty/libs/sysplugins/smarty_internal_config_file_compiler.php26
-rw-r--r--library/Smarty/libs/sysplugins/smarty_internal_data.php381
-rw-r--r--library/Smarty/libs/sysplugins/smarty_internal_debug.php148
-rw-r--r--library/Smarty/libs/sysplugins/smarty_internal_extension_codeframe.php127
-rw-r--r--library/Smarty/libs/sysplugins/smarty_internal_extension_config.php160
-rw-r--r--library/Smarty/libs/sysplugins/smarty_internal_extension_defaulttemplatehandler.php85
-rw-r--r--library/Smarty/libs/sysplugins/smarty_internal_filter_handler.php67
-rw-r--r--library/Smarty/libs/sysplugins/smarty_internal_function_call_handler.php71
-rw-r--r--library/Smarty/libs/sysplugins/smarty_internal_get_include_path.php46
-rw-r--r--library/Smarty/libs/sysplugins/smarty_internal_nocache_insert.php4
-rw-r--r--library/Smarty/libs/sysplugins/smarty_internal_parsetree.php21
-rw-r--r--library/Smarty/libs/sysplugins/smarty_internal_parsetree_code.php10
-rw-r--r--library/Smarty/libs/sysplugins/smarty_internal_parsetree_dq.php28
-rw-r--r--library/Smarty/libs/sysplugins/smarty_internal_parsetree_dqcontent.php10
-rw-r--r--library/Smarty/libs/sysplugins/smarty_internal_parsetree_tag.php21
-rw-r--r--library/Smarty/libs/sysplugins/smarty_internal_parsetree_template.php58
-rw-r--r--library/Smarty/libs/sysplugins/smarty_internal_parsetree_text.php10
-rw-r--r--library/Smarty/libs/sysplugins/smarty_internal_resource_extends.php39
-rw-r--r--library/Smarty/libs/sysplugins/smarty_internal_resource_file.php159
-rw-r--r--library/Smarty/libs/sysplugins/smarty_internal_resource_php.php12
-rw-r--r--library/Smarty/libs/sysplugins/smarty_internal_resource_registered.php5
-rw-r--r--library/Smarty/libs/sysplugins/smarty_internal_smartytemplatecompiler.php109
-rw-r--r--library/Smarty/libs/sysplugins/smarty_internal_template.php746
-rw-r--r--library/Smarty/libs/sysplugins/smarty_internal_templatebase.php603
-rw-r--r--library/Smarty/libs/sysplugins/smarty_internal_templatecompilerbase.php641
-rw-r--r--library/Smarty/libs/sysplugins/smarty_internal_templatelexer.php597
-rw-r--r--library/Smarty/libs/sysplugins/smarty_internal_templateparser.php2308
-rw-r--r--library/Smarty/libs/sysplugins/smarty_internal_testinstall.php338
-rw-r--r--library/Smarty/libs/sysplugins/smarty_internal_utility.php303
-rw-r--r--library/Smarty/libs/sysplugins/smarty_internal_write_file.php88
-rw-r--r--library/Smarty/libs/sysplugins/smarty_resource.php108
-rw-r--r--library/Smarty/libs/sysplugins/smarty_resource_recompiled.php7
-rw-r--r--library/Smarty/libs/sysplugins/smarty_resource_uncompiled.php7
-rw-r--r--library/Smarty/libs/sysplugins/smarty_security.php309
-rw-r--r--library/Smarty/libs/sysplugins/smarty_template_cached.php285
-rw-r--r--library/Smarty/libs/sysplugins/smarty_template_compiled.php163
-rw-r--r--library/Smarty/libs/sysplugins/smarty_template_config.php45
-rw-r--r--library/Smarty/libs/sysplugins/smarty_template_source.php198
-rw-r--r--library/Smarty/libs/sysplugins/smarty_variable.php10
89 files changed, 5412 insertions, 6944 deletions
diff --git a/library/Smarty/README b/library/Smarty/README
index 9304219b4..08b397c3f 100644
--- a/library/Smarty/README
+++ b/library/Smarty/README
@@ -460,12 +460,13 @@ included template.
PLUGINS
=======
-Smarty3 are following the same coding rules as in Smarty2.
-The only difference is that the template object is passed as additional third parameter.
+Smarty 3 plugins follow the same coding rules as in Smarty 2.
+The main difference is that the template object is now passed in place of the smarty object.
+The smarty object can be still be accessed through $template->smarty.
-smarty_plugintype_name (array $params, object $smarty, object $template)
+smarty_plugintype_name (array $params, Smarty_Internal_Template $template)
-The Smarty 2 plugins are still compatible as long as they do not make use of specific Smarty2 internals.
+The Smarty 2 plugins are still compatible as long as they do not make use of specific Smarty 2 internals.
TEMPLATE INHERITANCE:
diff --git a/library/Smarty/change_log.txt b/library/Smarty/change_log.txt
index 5606b1d83..2bcdfd024 100644
--- a/library/Smarty/change_log.txt
+++ b/library/Smarty/change_log.txt
@@ -1,13 +1,178 @@
- ===== 3.1.27===== (18.06.2015)
-18.06.2015
- - bugfix another update on file path normalization failed on path containing something like "/.foo/" https://github.com/smarty-php/smarty/issues/56
+ ===== 3.1.28-dev===== (xx.xx.2015)
+ 05.12.2015
+ -bugfix {strip} should insert a single space https://github.com/smarty-php/smarty/issues/111
+
+ 25.11.2015
+ -bugfix a left delimter like '[%' did fail on [%$var_[%$variable%]%] (forum topic 25798)
+
+ 02.11.2015
+ - bugfix {include} with variable file name like {include file="foo_`$bar`.tpl"} did fail in 3.1.28-dev https://github.com/smarty-php/smarty/issues/102
+
+ 01.11.2015
+ - update config file processing
+
+ 31.10.2015
+ - bugfix add missing $trusted_dir property to SmartyBC class (forum topic 25751)
+
+ 29.10.2015
+ - improve template scope handling
+
+ 24.10.2015
+ - more optimizations of template processing
+ - bugfix Error when using {include} within {capture} https://github.com/smarty-php/smarty/issues/100
+
+ 21.10.2015
+ - move some code into runtime extensions
+
+ 18.10.2015
+ - optimize filepath normalization
+ - rework of template inheritance
+ - speed and size optimizations
+ - bugfix under HHVM temporary cache file must only be created when caches template was updated
+ - fix compiled code for new {block} assign attribute
+ - update code generated by template function call handler
+
+ 18.09.2015
+ - bugfix {if $foo instanceof $bar} failed to compile if 2nd value is a variable https://github.com/smarty-php/smarty/issues/92
+
+ 17.09.2015
+ - bugfix {foreach} first attribute was not correctly reset since commit 05a8fa2 of 02.08.2015 https://github.com/smarty-php/smarty/issues/90
+
+ 16.09.2015
+ - update compiler by moving no longer needed properties, code optimizations and other
+
+ 14.09.2015
+ - optimize autoloader
+ - optimize subtemplate handling
+ - update template inheritance processing
+ - move code of {call} processing back into Smarty_Internal_Template class
+ - improvement invalidate OPCACHE for cleared compiled and cached template files (forum topic 25557)
+ - bugfix unintended multiple debug windows (forum topic 25699)
+
+ 30.08.2015
+ - size optimization move some runtime functions into extension
+ - optimize inline template processing
+ - optimization merge inheritance child and parent templates into one compiled template file
+
+ 29.08.2015
+ - improvement convert template inheritance into runtime processing
+ - bugfix {$smarty.block.parent} did always reference the root parent block https://github.com/smarty-php/smarty/issues/68
+
+ 23.08.2015
+ - introduce Smarty::$resource_cache_mode and cache template object of {include} inside loop
+ - load seldom used Smarty API methods dynamically to reduce memory footprint
+ - cache template object of {include} if same template is included several times
+ - convert debug console processing to object
+ - use output buffers for better performance and less memory usage
+ - optimize nocache hash processing
+ - remove not really needed properties
+ - optimize rendering
+ - move caching to Smarty::_cache
+ - remove properties with redundant content
+ - optimize Smarty::templateExists()
+ - optimize use_include_path processing
+ - relocate properties for size optimization
+ - remove redundant code
+ - bugfix compiling super globals like {$smarty.get.foo} did fail in the master branch https://github.com/smarty-php/smarty/issues/77
+
+ 06.08.2015
+ - avoid possible circular object references caused by parser/lexer objects
+ - rewrite compileAll... utility methods
+ - commit several internal improvements
+ - bugfix Smarty failed when compile_id did contain "|"
+
+ 03.08.2015
+ - rework clear cache methods
+ - bugfix compileAllConfig() was broken since 3.1.22 because of the changes in config file processing
+ - improve getIncludePath() to return directory if no file was given
+
+ 02.08.2015
+ - optimization and code cleanup of {foreach} and {section} compiler
+ - rework {capture} compiler
+
+ 01.08.2015
+ - update DateTime object can be instance of DateTimeImmutable since PHP5.5 https://github.com/smarty-php/smarty/pull/75
+ - improvement show resource type and start of template source instead of uid on eval: and string: resource (forum topic 25630)
+
+ 31.07.2015
+ - optimize {foreach} and {section} compiler
+
+ 29.07.2015
+ - optimize {section} compiler for speed and size of compiled code
+
+ 28.07.2015
+ - update for PHP 7 compatibility
+
+ 26.07.2015
+ - improvement impement workaround for HHVM PHP incompatibillity https://github.com/facebook/hhvm/issues/4797
+
+ 25.07.2015
+ - bugfix parser did hang on text starting <?something https://github.com/smarty-php/smarty/issues/74
+
+ 20.07.2015
+ - bugfix config files got recompiled on each request
+ - improvement invalidate PHP 5.5 opcache for recompiled and cached templates https://github.com/smarty-php/smarty/issues/72
+
+ 12.07.2015
+ - optimize {extends} compilation
+
+ 10.07.2015
+ - bugfix force file: resource in demo resource.extendsall.php
+
+ 08.07.2015
+ - bugfix convert each word of class names to ucfirst in in compiler. (forum topic 25588)
+
+ 07.07.2015
+ - improvement allow fetch() or display() called on a template object to get output from other template
+ like $template->fetch('foo.tpl') https://github.com/smarty-php/smarty/issues/70
+ - improvement Added $limit parameter to regex_replace modifier #71
+ - new feature multiple indices on file: resource
+
+ 06.07.2015
+ - optimize {block} compilation
+ - optimization get rid of __get and __set in source object
+
+ 01.07.2015
+ - optimize compile check handling
+ - update {foreach} compiler
+ - bugfix debugging console did not display string values containing \n, \r or \t correctly https://github.com/smarty-php/smarty/issues/66
+ - optimize source resources
+
+ 28.06.2015
+ - move $smarty->enableSecurity() into Smarty_Security class
+ - optimize security isTrustedResourceDir()
+ - move auto load filter methods into extension
+ - move $smarty->getTemplateVars() into extension
+ - move getStreamVariable() into extension
+ - move $smarty->append() and $smarty->appendByRef() into extension
+ - optimize autoloader
+ - optimize file path normalization
+ - bugfix PATH_SEPARATOR was replaced by mistake in autoloader
+ - remove redundant code
+
+ 27.06.2015
+ - bugfix resolve naming conflict between custom Smarty delimiter '<%' and PHP ASP tags https://github.com/smarty-php/smarty/issues/64
+ - update $smarty->_realpath for relative path not starting with './'
+ - update Smarty security with new realpath handling
+ - update {include_php} with new realpath handling
+ - move $smarty->loadPlugin() into extension
+ - minor compiler optimizations
+ - bugfix allow function plugins with name ending with 'close' https://github.com/smarty-php/smarty/issues/52
+ - rework of $smarty->clearCompiledTemplate() and move it to its own extension
+
+ 19.06.2015
+ - improvement allow closures as callback at $smarty->registerFilter() https://github.com/smarty-php/smarty/issues/59
+
+ ===== 3.1.27===== (18.06.2015)
+ 18.06.2015
+ - bugfix another update on file path normalization failed on path containing something like "/.foo/" https://github.com/smarty-php/smarty/issues/56
===== 3.1.26===== (18.06.2015)
-18.06.2015
- - bugfix file path normalization failed on path containing something like "/.foo/" https://github.com/smarty-php/smarty/issues/56
+ 18.06.2015
+ - bugfix file path normalization failed on path containing something like "/.foo/" https://github.com/smarty-php/smarty/issues/56
-17.06.2015
- - bugfix calling a plugin with nocache option but no other attributes like {foo nocache} caused call to undefined function https://github.com/smarty-php/smarty/issues/55
+ 17.06.2015
+ - bugfix calling a plugin with nocache option but no other attributes like {foo nocache} caused call to undefined function https://github.com/smarty-php/smarty/issues/55
===== 3.1.25===== (15.06.2015)
15.06.2015
@@ -209,8 +374,8 @@
- bugfix Debug Console did not include all data from merged compiled subtemplates
04.11.2014
- - new feature $smarty->debug = true; => overwrite existing Debug Console window (old behaviour)
- $smarty->debug = 2; => individual Debug Console window by template name
+ - new feature $smarty->debugging = true; => overwrite existing Debug Console window (old behaviour)
+ $smarty->debugging = 2; => individual Debug Console window by template name
03.11.2014
- bugfix Debug Console did not show included subtemplates since 3.1.17 (forum 25301)
diff --git a/library/Smarty/libs/Autoloader.php b/library/Smarty/libs/Autoloader.php
index a24cad6f7..7d0c388a6 100644
--- a/library/Smarty/libs/Autoloader.php
+++ b/library/Smarty/libs/Autoloader.php
@@ -25,62 +25,20 @@ class Smarty_Autoloader
* @var string
*/
public static $SMARTY_DIR = '';
+
/**
* Filepath to Smarty internal plugins
*
* @var string
*/
public static $SMARTY_SYSPLUGINS_DIR = '';
- /**
- * Array of not existing classes to avoid is_file calls for already tested classes
- *
- * @var array
- */
- public static $unknown = array();
+
/**
* Array with Smarty core classes and their filename
*
* @var array
*/
- public static $rootClasses = array('Smarty' => 'Smarty.class.php',
- 'SmartyBC' => 'SmartyBC.class.php',
- );
-
- private static $syspluginsClasses = array(
- 'smarty_config_source' => true,
- 'smarty_security' => true,
- 'smarty_cacheresource' => true,
- 'smarty_compiledresource' => true,
- 'smarty_cacheresource_custom' => true,
- 'smarty_cacheresource_keyvaluestore' => true,
- 'smarty_resource' => true,
- 'smarty_resource_custom' => true,
- 'smarty_resource_uncompiled' => true,
- 'smarty_resource_recompiled' => true,
- 'smarty_template_source' => true,
- 'smarty_template_compiled' => true,
- 'smarty_template_cached' => true,
- 'smarty_template_config' => true,
- 'smarty_data' => true,
- 'smarty_variable' => true,
- 'smarty_undefined_variable' => true,
- 'smartyexception' => true,
- 'smartycompilerexception' => true,
- 'smarty_internal_data' => true,
- 'smarty_internal_template' => true,
- 'smarty_internal_templatebase' => true,
- 'smarty_internal_resource_file' => true,
- 'smarty_internal_resource_extends' => true,
- 'smarty_internal_resource_eval' => true,
- 'smarty_internal_resource_string' => true,
- 'smarty_internal_resource_registered' => true,
- 'smarty_internal_extension_codeframe' => true,
- 'smarty_internal_extension_config' => true,
- 'smarty_internal_filter_handler' => true,
- 'smarty_internal_function_call_handler' => true,
- 'smarty_internal_cacheresource_file' => true,
- 'smarty_internal_write_file' => true,
- );
+ public static $rootClasses = array('smarty' => 'Smarty.class.php', 'smartybc' => 'SmartyBC.class.php',);
/**
* Registers Smarty_Autoloader backward compatible to older installations.
@@ -95,7 +53,9 @@ class Smarty_Autoloader
if (!defined('SMARTY_SPL_AUTOLOAD')) {
define('SMARTY_SPL_AUTOLOAD', 0);
}
- if (SMARTY_SPL_AUTOLOAD && set_include_path(get_include_path() . PATH_SEPARATOR . SMARTY_SYSPLUGINS_DIR) !== false) {
+ if (SMARTY_SPL_AUTOLOAD &&
+ set_include_path(get_include_path() . PATH_SEPARATOR . SMARTY_SYSPLUGINS_DIR) !== false
+ ) {
$registeredAutoLoadFunctions = spl_autoload_functions();
if (!isset($registeredAutoLoadFunctions['spl_autoload'])) {
spl_autoload_register();
@@ -112,8 +72,9 @@ class Smarty_Autoloader
*/
public static function register($prepend = false)
{
- self::$SMARTY_DIR = defined('SMARTY_DIR') ? SMARTY_DIR : dirname(__FILE__) . '/';
- self::$SMARTY_SYSPLUGINS_DIR = defined('SMARTY_SYSPLUGINS_DIR') ? SMARTY_SYSPLUGINS_DIR : self::$SMARTY_DIR . 'sysplugins/';
+ self::$SMARTY_DIR = defined('SMARTY_DIR') ? SMARTY_DIR : dirname(__FILE__) . DIRECTORY_SEPARATOR;
+ self::$SMARTY_SYSPLUGINS_DIR = defined('SMARTY_SYSPLUGINS_DIR') ? SMARTY_SYSPLUGINS_DIR :
+ self::$SMARTY_DIR . 'sysplugins' . DIRECTORY_SEPARATOR;
if (version_compare(phpversion(), '5.3.0', '>=')) {
spl_autoload_register(array(__CLASS__, 'autoload'), true, $prepend);
} else {
@@ -122,37 +83,42 @@ class Smarty_Autoloader
}
/**
- * Handles autoloading of classes.
+ * Handles auto loading of classes.
*
* @param string $class A class name.
*/
public static function autoload($class)
{
- // Request for Smarty or already unknown class
- if (isset(self::$unknown[$class])) {
- return;
- }
$_class = strtolower($class);
- if (isset(self::$syspluginsClasses[$_class])) {
- $_class = (self::$syspluginsClasses[$_class] === true) ? $_class : self::$syspluginsClasses[$_class];
- $file = self::$SMARTY_SYSPLUGINS_DIR . $_class . '.php';
- require_once $file;
+ $file = self::$SMARTY_SYSPLUGINS_DIR . $_class . '.php';
+ if (strpos($_class, 'smarty_internal_') === 0) {
+ if (strpos($_class, 'smarty_internal_compile_') === 0) {
+ if (is_file($file)) {
+ require $file;
+ }
+ return;
+ }
+ @include $file;
return;
- } elseif (0 !== strpos($_class, 'smarty_internal_')) {
- if (isset(self::$rootClasses[$class])) {
- $file = self::$SMARTY_DIR . self::$rootClasses[$class];
- require_once $file;
+ }
+ if (preg_match('/^(smarty_(((template_(source|config|cache|compiled|resource_base))|((cached|compiled)?resource)|(variable|security)))|(smarty(bc)?)$)/',
+ $_class, $match)) {
+ if (!empty($match[3])) {
+ @include $file;
+ return;
+ } elseif (!empty($match[9]) && isset(self::$rootClasses[$_class])) {
+ $file = self::$rootClasses[$_class];
+ require $file;
return;
}
- self::$unknown[$class] = true;
+ }
+ if (0 !== strpos($_class, 'smarty')) {
return;
}
- $file = self::$SMARTY_SYSPLUGINS_DIR . $_class . '.php';
if (is_file($file)) {
- require_once $file;
+ require $file;
return;
}
- self::$unknown[$class] = true;
return;
}
}
diff --git a/library/Smarty/libs/Smarty.class.php b/library/Smarty/libs/Smarty.class.php
index 1f0f2634a..ac09d0a43 100644
--- a/library/Smarty/libs/Smarty.class.php
+++ b/library/Smarty/libs/Smarty.class.php
@@ -27,7 +27,7 @@
* @author Uwe Tews
* @author Rodney Rehm
* @package Smarty
- * @version 3.1.27
+ * @version 3.1.28-dev
*/
/**
@@ -79,7 +79,7 @@ if (!defined('SMARTY_RESOURCE_DATE_FORMAT')) {
*/
if (!class_exists('Smarty_Autoloader', false)) {
if (!class_exists('Smarty_Internal_Data', true)) {
- require_once 'Autoloader.php';
+ require_once dirname(__FILE__) . '/Autoloader.php';
Smarty_Autoloader::registerBC();
}
}
@@ -87,20 +87,27 @@ if (!class_exists('Smarty_Autoloader', false)) {
/**
* Load always needed external class files
*/
-
if (!class_exists('Smarty_Internal_Data', false)) {
require_once SMARTY_SYSPLUGINS_DIR . 'smarty_internal_data.php';
}
+require_once SMARTY_SYSPLUGINS_DIR . 'smarty_internal_extension_handler.php';
require_once SMARTY_SYSPLUGINS_DIR . 'smarty_internal_templatebase.php';
require_once SMARTY_SYSPLUGINS_DIR . 'smarty_internal_template.php';
require_once SMARTY_SYSPLUGINS_DIR . 'smarty_resource.php';
require_once SMARTY_SYSPLUGINS_DIR . 'smarty_variable.php';
require_once SMARTY_SYSPLUGINS_DIR . 'smarty_template_source.php';
+require_once SMARTY_SYSPLUGINS_DIR . 'smarty_template_resource_base.php';
/**
* This is the main Smarty class
*
* @package Smarty
+ *
+ * @method int clearAllCache(int $exp_time = null, string $type = null)
+ * @method int clearCache(string $template_name, string $cache_id = null, string $compile_id = null, int $exp_time = null, string $type = null)
+ * @method int compileAllTemplates(Smarty $smarty, string $extension = '.tpl', bool $force_compile = false, int $time_limit = 0, int $max_errors = null)
+ * @method int compileAllConfig(Smarty $smarty, string $extension = '.conf', bool $force_compile = false, int $time_limit = 0, int $max_errors = null)
+ *
*/
class Smarty extends Smarty_Internal_TemplateBase
{
@@ -111,18 +118,24 @@ class Smarty extends Smarty_Internal_TemplateBase
/**
* smarty version
*/
- const SMARTY_VERSION = '3.1.27';
+ const SMARTY_VERSION = '3.1.28-dev/77';
/**
* define variable scopes
*/
const SCOPE_LOCAL = 0;
- const SCOPE_PARENT = 1;
+ const SCOPE_PARENT = 2;
+
+ const SCOPE_TPL_ROOT = 4;
+
+ const SCOPE_ROOT = 8;
+
+ const SCOPE_SMARTY = 16;
- const SCOPE_ROOT = 2;
+ const SCOPE_GLOBAL = 32;
- const SCOPE_GLOBAL = 3;
+ const SCOPE_BUBBLE_UP = 64;
/**
* define caching modes
@@ -134,7 +147,7 @@ class Smarty extends Smarty_Internal_TemplateBase
const CACHING_LIFETIME_SAVED = 2;
/**
- * define constant for clearing cache files be saved expiration datees
+ * define constant for clearing cache files be saved expiration dates
*/
const CLEAR_EXPIRED = - 1;
@@ -191,6 +204,17 @@ class Smarty extends Smarty_Internal_TemplateBase
const PLUGIN_MODIFIERCOMPILER = 'modifiercompiler';
+ /**
+ * Resource caching modes
+ */
+ const RESOURCE_CACHE_OFF = 0;
+
+ const RESOURCE_CACHE_AUTOMATIC = 1; // cache template objects by rules
+
+ const RESOURCE_CACHE_TEMPLATE = 2; // cache all template objects
+
+ const RESOURCE_CACHE_ON = 4; // cache source and compiled resources
+
/**#@-*/
/**
@@ -199,14 +223,14 @@ class Smarty extends Smarty_Internal_TemplateBase
public static $global_tpl_vars = array();
/**
- * error handler returned by set_error_hanlder() in Smarty::muteExpectedErrors()
+ * error handler returned by set_error_handler() in Smarty::muteExpectedErrors()
*/
public static $_previous_error_handler = null;
/**
* contains directories outside of SMARTY_DIR that are to be muted by muteExpectedErrors()
*/
- public static $_muted_directories = array('./templates_c/' => null, './cache/' => null);
+ public static $_muted_directories = array();
/**
* Flag denoting if Multibyte String functions are available
@@ -239,7 +263,7 @@ class Smarty extends Smarty_Internal_TemplateBase
*/
/**
- * auto literal on delimiters with whitspace
+ * auto literal on delimiters with whitespace
*
* @var boolean
*/
@@ -253,7 +277,7 @@ class Smarty extends Smarty_Internal_TemplateBase
public $error_unassigned = false;
/**
- * look up relative filepaths in include_path
+ * look up relative file path in include_path
*
* @var boolean
*/
@@ -271,14 +295,14 @@ class Smarty extends Smarty_Internal_TemplateBase
*
* @var string
*/
- public $joined_template_dir = './templates/';
+ public $_joined_template_dir = null;
/**
* joined config directory string used in cache keys
*
* @var string
*/
- public $joined_config_dir = './configs/';
+ public $_joined_config_dir = null;
/**
* default template handler
@@ -365,13 +389,6 @@ class Smarty extends Smarty_Internal_TemplateBase
public $merge_compiled_includes = false;
/**
- * template inheritance merge compiled includes
- *
- * @var boolean
- */
- public $inheritance_merge_compiled_includes = true;
-
- /**
* force cache file creation
*
* @var boolean
@@ -425,16 +442,6 @@ class Smarty extends Smarty_Internal_TemplateBase
*/
public $allow_php_templates = false;
- /**
- * Should compiled-templates be prevented from being called directly?
- * {@internal
- * Currently used by Smarty_Internal_Template only.
- * }}
- *
- * @var boolean
- */
- public $direct_access_security = true;
-
/**#@-*/
/**
* debug mode
@@ -478,13 +485,6 @@ class Smarty extends Smarty_Internal_TemplateBase
*/
public $error_reporting = null;
- /**
- * Internal flag for getTags()
- *
- * @var boolean
- */
- public $get_used_tags = false;
-
/**#@+
* config var settings
*/
@@ -524,7 +524,7 @@ class Smarty extends Smarty_Internal_TemplateBase
public $compile_locking = true;
/**
- * Controls whether cache resources should emply locking mechanism
+ * Controls whether cache resources should use locking mechanism
*
* @var boolean
*/
@@ -556,13 +556,6 @@ class Smarty extends Smarty_Internal_TemplateBase
public $caching_type = 'file';
/**
- * internal config properties
- *
- * @var array
- */
- public $properties = array();
-
- /**
* config type
*
* @var string
@@ -570,32 +563,11 @@ class Smarty extends Smarty_Internal_TemplateBase
public $default_config_type = 'file';
/**
- * cached template objects
- *
- * @var array
- */
- public $source_objects = array();
-
- /**
- * cached template objects
- *
- * @var array
- */
- public $template_objects = array();
-
- /**
* enable resource caching
*
* @var bool
*/
- public $resource_caching = false;
-
- /**
- * enable template resource caching
- *
- * @var bool
- */
- public $template_resource_caching = true;
+ public $resource_cache_mode = 1;
/**
* check If-Modified-Since headers
@@ -612,13 +584,6 @@ class Smarty extends Smarty_Internal_TemplateBase
public $registered_plugins = array();
/**
- * plugin search order
- *
- * @var array
- */
- public $plugin_search_order = array('function', 'block', 'compiler', 'class');
-
- /**
* registered objects
*
* @var array
@@ -647,13 +612,6 @@ class Smarty extends Smarty_Internal_TemplateBase
public $registered_resources = array();
/**
- * resource handler cache
- *
- * @var array
- */
- public $_resource_handlers = array();
-
- /**
* registered cache resources
*
* @var array
@@ -661,13 +619,6 @@ class Smarty extends Smarty_Internal_TemplateBase
public $registered_cache_resources = array();
/**
- * cache resource handler cache
- *
- * @var array
- */
- public $_cacheresource_handlers = array();
-
- /**
* autoload filter
*
* @var array
@@ -689,13 +640,6 @@ class Smarty extends Smarty_Internal_TemplateBase
public $escape_html = false;
/**
- * global internal smarty vars
- *
- * @var array
- */
- public static $_smarty_vars = array();
-
- /**
* start time for execution time calculation
*
* @var int
@@ -703,46 +647,45 @@ class Smarty extends Smarty_Internal_TemplateBase
public $start_time = 0;
/**
- * default file permissions
- *
- * @var int
- */
- public $_file_perms = 0644;
-
- /**
- * default dir permissions
+ * required by the compiler for BC
*
- * @var int
+ * @var string
*/
- public $_dir_perms = 0771;
+ public $_current_file = null;
/**
- * block tag hierarchy
+ * internal flag to enable parser debugging
*
- * @var array
+ * @var bool
*/
- public $_tag_stack = array();
+ public $_parserdebug = false;
/**
- * required by the compiler for BC
+ * This object type (Smarty = 1, template = 2, data = 4)
*
- * @var string
+ * @var int
*/
- public $_current_file = null;
+ public $_objType = 1;
/**
- * internal flag to enable parser debugging
+ * Debug object
*
- * @var bool
+ * @var Smarty_Internal_Debug
*/
- public $_parserdebug = false;
+ public $_debug = null;
/**
- * Cache of is_file results of loadPlugin()
+ * removed properties
*
* @var array
*/
- public $_is_file_cache = array();
+ private static $obsoleteProperties = array('resource_caching', 'template_resource_caching',
+ 'direct_access_security', '_dir_perms', '_file_perms',
+ 'plugin_search_order', 'inheritance_merge_compiled_includes');
+
+ private static $accessMap = array('template_dir' => 'getTemplateDir', 'config_dir' => 'getConfigDir',
+ 'plugins_dir' => 'getPluginsDir', 'compile_dir' => 'getCompileDir',
+ 'cache_dir' => 'getCacheDir',);
/**#@-*/
@@ -751,30 +694,12 @@ class Smarty extends Smarty_Internal_TemplateBase
*/
public function __construct()
{
+ parent::__construct();
if (is_callable('mb_internal_encoding')) {
mb_internal_encoding(Smarty::$_CHARSET);
}
$this->start_time = microtime(true);
- // check default dirs for overloading
- if ($this->template_dir[0] !== './templates/' || isset($this->template_dir[1])) {
- $this->setTemplateDir($this->template_dir);
- }
- if ($this->config_dir[0] !== './configs/' || isset($this->config_dir[1])) {
- $this->setConfigDir($this->config_dir);
- }
- if ($this->compile_dir !== './templates_c/') {
- unset(self::$_muted_directories['./templates_c/']);
- $this->setCompileDir($this->compile_dir);
- }
- if ($this->cache_dir !== './cache/') {
- unset(self::$_muted_directories['./cache/']);
- $this->setCacheDir($this->cache_dir);
- }
- if (isset($this->plugins_dir)) {
- $this->setPluginsDir($this->plugins_dir);
- } else {
- $this->setPluginsDir(SMARTY_PLUGINS_DIR);
- }
+
if (isset($_SERVER['SCRIPT_NAME'])) {
Smarty::$global_tpl_vars['SCRIPT_NAME'] = new Smarty_Variable($_SERVER['SCRIPT_NAME']);
}
@@ -789,52 +714,6 @@ class Smarty extends Smarty_Internal_TemplateBase
}
/**
- * fetches a rendered 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
- * @param bool $display true: display, false: fetch
- * @param bool $merge_tpl_vars not used - left for BC
- * @param bool $no_output_filter not used - left for BC
- *
- * @throws Exception
- * @throws SmartyException
- * @return string rendered template output
- */
- public function fetch($template = null, $cache_id = null, $compile_id = null, $parent = null, $display = false, $merge_tpl_vars = true, $no_output_filter = false)
- {
- if ($cache_id !== null && is_object($cache_id)) {
- $parent = $cache_id;
- $cache_id = null;
- }
- if ($parent === null) {
- $parent = $this;
- }
- // get template object
- $_template = is_object($template) ? $template : $this->createTemplate($template, $cache_id, $compile_id, $parent, false);
- // set caching in template object
- $_template->caching = $this->caching;
- // fetch template content
- return $_template->render(true, false, $display);
- }
-
- /**
- * 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);
- }
-
- /**
* Check if a template resource exists
*
* @param string $resource_name template name
@@ -843,14 +722,9 @@ class Smarty extends Smarty_Internal_TemplateBase
*/
public function templateExists($resource_name)
{
- // create template object
- $save = $this->template_objects;
- $tpl = new $this->template_class($resource_name, $this);
- // check if it does exists
- $result = $tpl->source->exists;
- $this->template_objects = $save;
-
- return $result;
+ // create source object
+ $source = Smarty_Template_Source::load(null, $this, $resource_name);
+ return $source->exists;
}
/**
@@ -879,43 +753,6 @@ class Smarty extends Smarty_Internal_TemplateBase
}
/**
- * Empty cache folder
- *
- * @param integer $exp_time expiration time
- * @param string $type resource type
- *
- * @return integer number of cache files deleted
- */
- public function clearAllCache($exp_time = null, $type = null)
- {
- // load cache resource and call clearAll
- $_cache_resource = Smarty_CacheResource::load($this, $type);
- Smarty_CacheResource::invalidLoadedCache($this);
-
- return $_cache_resource->clearAll($this, $exp_time);
- }
-
- /**
- * Empty cache for a specific template
- *
- * @param string $template_name template name
- * @param string $cache_id cache id
- * @param string $compile_id compile id
- * @param integer $exp_time expiration time
- * @param string $type resource type
- *
- * @return integer number of cache files deleted
- */
- public function clearCache($template_name, $cache_id = null, $compile_id = null, $exp_time = null, $type = null)
- {
- // load cache resource and call clear
- $_cache_resource = Smarty_CacheResource::load($this, $type);
- Smarty_CacheResource::invalidLoadedCache($this);
-
- return $_cache_resource->clear($this, $template_name, $cache_id, $compile_id, $exp_time);
- }
-
- /**
* Loads security class and enables security
*
* @param string|Smarty_Security $security_class if a string is used, it must be class-name
@@ -925,24 +762,7 @@ class Smarty extends Smarty_Internal_TemplateBase
*/
public function enableSecurity($security_class = null)
{
- if ($security_class instanceof Smarty_Security) {
- $this->security_policy = $security_class;
-
- return $this;
- } elseif (is_object($security_class)) {
- throw new SmartyException("Class '" . get_class($security_class) . "' must extend Smarty_Security.");
- }
- if ($security_class == null) {
- $security_class = $this->security_class;
- }
- if (!class_exists($security_class)) {
- throw new SmartyException("Security class '$security_class' is not defined");
- } elseif ($security_class !== 'Smarty_Security' && !is_subclass_of($security_class, 'Smarty_Security')) {
- throw new SmartyException("Class '$security_class' must extend Smarty_Security.");
- } else {
- $this->security_policy = new $security_class($this);
- }
-
+ Smarty_Security::enableSecurity($this, $security_class);
return $this;
}
@@ -962,16 +782,18 @@ class Smarty extends Smarty_Internal_TemplateBase
* Set template directory
*
* @param string|array $template_dir directory(s) of template sources
+ * @param bool $isConfig true for config_dir
*
- * @return Smarty current Smarty instance for chaining
+ * @return \Smarty current Smarty instance for chaining
*/
- public function setTemplateDir($template_dir)
+ public function setTemplateDir($template_dir, $isConfig = false)
{
- $this->template_dir = array();
- foreach ((array) $template_dir as $k => $v) {
- $this->template_dir[$k] = rtrim($v, '/\\') . DS;
- }
- $this->joined_template_dir = join(' # ', $this->template_dir);
+ $type = $isConfig ? 'config_dir' : 'template_dir';
+ $joined = '_joined_' . $type;
+ $this->{$type} = (array) $template_dir;
+ $this->{$joined} = join(' # ', $this->{$type});
+ $this->_cache[$type . '_new'] = true;
+ $this->_cache[$type] = false;
return $this;
}
@@ -980,30 +802,53 @@ class Smarty extends Smarty_Internal_TemplateBase
*
* @param string|array $template_dir directory(s) of template sources
* @param string $key of the array element to assign the template dir to
+ * @param bool $isConfig true for config_dir
*
* @return Smarty current Smarty instance for chaining
- * @throws SmartyException when the given template directory is not valid
*/
- public function addTemplateDir($template_dir, $key = null)
+ public function addTemplateDir($template_dir, $key = null, $isConfig = false)
{
- $this->_addDir('template_dir', $template_dir, $key);
- $this->joined_template_dir = join(' # ', $this->template_dir);
+ $type = $isConfig ? 'config_dir' : 'template_dir';
+ $joined = '_joined_' . $type;
+ if (!isset($this->_cache[$type])) {
+ $this->{$type} = (array) $this->{$type};
+ $this->{$joined} = join(' # ', $this->{$type});
+ $this->_cache[$type . '_new'] = true;
+ $this->_cache[$type] = false;
+ }
+ $this->{$joined} .= ' # ' . join(' # ', (array) $template_dir);
+ $this->_addDir($type, $template_dir, $key);
return $this;
}
/**
* Get template directories
*
- * @param mixed $index index of directory to get, null to get all
+ * @param mixed $index index of directory to get, null to get all
+ * @param bool $isConfig true for config_dir
*
- * @return array|string list of template directories, or directory of $index
+ * @return array list of template directories, or directory of $index
*/
- public function getTemplateDir($index = null)
+ public function getTemplateDir($index = null, $isConfig = false)
{
+ $type = $isConfig ? 'config_dir' : 'template_dir';
+ if (!isset($this->_cache[$type])) {
+ $joined = '_joined_' . $type;
+ $this->{$type} = (array) $this->{$type};
+ $this->{$joined} = join(' # ', $this->{$type});
+ $this->_cache[$type] = false;
+ }
+ if ($this->_cache[$type] == false) {
+ foreach ($this->{$type} as $k => $v) {
+ $this->{$type}[$k] = $this->_realpath($v . DS, true);
+ }
+ $this->_cache[$type . '_new'] = true;
+ $this->_cache[$type] = true;
+ }
if ($index !== null) {
- return isset($this->template_dir[$index]) ? $this->template_dir[$index] : null;
+ return isset($this->{$type}[$index]) ? $this->{$type}[$index] : null;
}
- return (array) $this->template_dir;
+ return $this->{$type};
}
/**
@@ -1015,12 +860,7 @@ class Smarty extends Smarty_Internal_TemplateBase
*/
public function setConfigDir($config_dir)
{
- $this->config_dir = array();
- foreach ((array) $config_dir as $k => $v) {
- $this->config_dir[$k] = rtrim($v, '/\\') . DS;
- }
- $this->joined_config_dir = join(' # ', $this->config_dir);
- return $this;
+ return $this->setTemplateDir($config_dir, true);
}
/**
@@ -1033,9 +873,7 @@ class Smarty extends Smarty_Internal_TemplateBase
*/
public function addConfigDir($config_dir, $key = null)
{
- $this->_addDir('config_dir', $config_dir, $key);
- $this->joined_config_dir = join(' # ', $this->config_dir);
- return $this;
+ return $this->addTemplateDir($config_dir, $key, true);
}
/**
@@ -1043,14 +881,11 @@ class Smarty extends Smarty_Internal_TemplateBase
*
* @param mixed $index index of directory to get, null to get all
*
- * @return array|string configuration directory
+ * @return array configuration directory
*/
public function getConfigDir($index = null)
{
- if ($index !== null) {
- return isset($this->config_dir[$index]) ? $this->config_dir[$index] : null;
- }
- return (array) $this->config_dir;
+ return $this->getTemplateDir($index, true);
}
/**
@@ -1062,8 +897,10 @@ class Smarty extends Smarty_Internal_TemplateBase
*/
public function setPluginsDir($plugins_dir)
{
- $this->plugins_dir = array();
- $this->addPluginsDir($plugins_dir);
+ $this->plugins_dir = (array) $plugins_dir;
+ if (isset($this->_cache['plugins_dir'])) {
+ unset($this->_cache['plugins_dir']);
+ }
return $this;
}
@@ -1076,13 +913,13 @@ class Smarty extends Smarty_Internal_TemplateBase
*/
public function addPluginsDir($plugins_dir)
{
- // make sure we're dealing with an array
- $this->plugins_dir = (array) $this->plugins_dir;
- foreach ((array) $plugins_dir as $v) {
- $this->plugins_dir[] = rtrim($v, '/\\') . DS;
+ if (!isset($this->plugins_dir)) {
+ $this->plugins_dir = array(SMARTY_PLUGINS_DIR);
+ }
+ $this->plugins_dir = array_merge((array) $this->plugins_dir, (array) $plugins_dir);
+ if (isset($this->_cache['plugins_dir'])) {
+ unset($this->_cache['plugins_dir']);
}
- $this->plugins_dir = array_unique($this->plugins_dir);
- $this->_is_file_cache = array();
return $this;
}
@@ -1093,7 +930,21 @@ class Smarty extends Smarty_Internal_TemplateBase
*/
public function getPluginsDir()
{
- return (array) $this->plugins_dir;
+ if (!isset($this->_cache['plugins_dir'])) {
+ if (!isset($this->plugins_dir)) {
+ $this->plugins_dir = array(SMARTY_PLUGINS_DIR);
+ } else {
+ $plugins_dir = (array) $this->plugins_dir;
+ $this->plugins_dir = array();
+ foreach ($plugins_dir as $v) {
+ $this->plugins_dir[] = $this->_realpath($v . DS, true);
+ }
+ $this->plugins_dir = array_unique($this->plugins_dir);
+ }
+ $this->_cache['plugin_files'] = array();
+ $this->_cache['plugins_dir'] = true;
+ }
+ return $this->plugins_dir;
}
/**
@@ -1105,11 +956,11 @@ class Smarty extends Smarty_Internal_TemplateBase
*/
public function setCompileDir($compile_dir)
{
- $this->compile_dir = rtrim($compile_dir, '/\\') . DS;
+ $this->compile_dir = $this->_realpath($compile_dir . DS, true);
if (!isset(Smarty::$_muted_directories[$this->compile_dir])) {
Smarty::$_muted_directories[$this->compile_dir] = null;
}
-
+ $this->_cache['compile_dir'] = true;
return $this;
}
@@ -1120,6 +971,13 @@ class Smarty extends Smarty_Internal_TemplateBase
*/
public function getCompileDir()
{
+ if (!isset($this->_cache['compile_dir'])) {
+ $this->compile_dir = $this->_realpath($this->compile_dir . DS, true);
+ if (!isset(Smarty::$_muted_directories[$this->compile_dir])) {
+ Smarty::$_muted_directories[$this->compile_dir] = null;
+ }
+ $this->_cache['compile_dir'] = true;
+ }
return $this->compile_dir;
}
@@ -1132,10 +990,11 @@ class Smarty extends Smarty_Internal_TemplateBase
*/
public function setCacheDir($cache_dir)
{
- $this->cache_dir = rtrim($cache_dir, '/\\') . DS;
+ $this->cache_dir = $this->_realpath($cache_dir . DS, true);
if (!isset(Smarty::$_muted_directories[$this->cache_dir])) {
Smarty::$_muted_directories[$this->cache_dir] = null;
}
+ $this->_cache['cache_dir'] = true;
return $this;
}
@@ -1146,6 +1005,13 @@ class Smarty extends Smarty_Internal_TemplateBase
*/
public function getCacheDir()
{
+ if (!isset($this->_cache['cache_dir'])) {
+ $this->cache_dir = $this->_realpath($this->cache_dir . DS, true);
+ if (!isset(Smarty::$_muted_directories[$this->cache_dir])) {
+ Smarty::$_muted_directories[$this->cache_dir] = null;
+ }
+ $this->_cache['cache_dir'] = true;
+ }
return $this->cache_dir;
}
@@ -1158,165 +1024,28 @@ class Smarty extends Smarty_Internal_TemplateBase
*/
private function _addDir($dirName, $dir, $key = null)
{
- // make sure we're dealing with an array
- $this->$dirName = (array) $this->$dirName;
-
+ $rp = $this->_cache[$dirName];
if (is_array($dir)) {
foreach ($dir as $k => $v) {
+ $path = $rp ? $this->_realpath($v . DS, true) : $v;
if (is_int($k)) {
// indexes are not merged but appended
- $this->{$dirName}[] = rtrim($v, '/\\') . DS;
+ $this->{$dirName}[] = $path;
} else {
// string indexes are overridden
- $this->{$dirName}[$k] = rtrim($v, '/\\') . DS;
+ $this->{$dirName}[$k] = $path;
}
}
} else {
+ $path = $rp ? $this->_realpath($dir . DS, true) : $dir;
if ($key !== null) {
// override directory at specified index
- $this->{$dirName}[$key] = rtrim($dir, '/\\') . DS;
+ $this->{$dirName}[$key] = $path;
} else {
// append new directory
- $this->{$dirName}[] = rtrim($dir, '/\\') . DS;
- }
- }
- }
-
- /**
- * Set default modifiers
- *
- * @param array|string $modifiers modifier or list of modifiers to set
- *
- * @return Smarty current Smarty instance for chaining
- */
- public function setDefaultModifiers($modifiers)
- {
- $this->default_modifiers = (array) $modifiers;
-
- return $this;
- }
-
- /**
- * Add default modifiers
- *
- * @param array|string $modifiers modifier or list of modifiers to add
- *
- * @return Smarty current Smarty instance for chaining
- */
- public function addDefaultModifiers($modifiers)
- {
- if (is_array($modifiers)) {
- $this->default_modifiers = array_merge($this->default_modifiers, $modifiers);
- } else {
- $this->default_modifiers[] = $modifiers;
- }
-
- return $this;
- }
-
- /**
- * Get default modifiers
- *
- * @return array list of default modifiers
- */
- public function getDefaultModifiers()
- {
- return $this->default_modifiers;
- }
-
- /**
- * Set autoload filters
- *
- * @param array $filters filters to load automatically
- * @param string $type "pre", "output", … specify the filter type to set. Defaults to none treating $filters'
- * keys as the appropriate types
- *
- * @return Smarty current Smarty instance for chaining
- */
- public function setAutoloadFilters($filters, $type = null)
- {
- if ($type !== null) {
- $this->autoload_filters[$type] = (array) $filters;
- } else {
- $this->autoload_filters = (array) $filters;
- }
-
- return $this;
- }
-
- /**
- * Add autoload filters
- *
- * @param array $filters filters to load automatically
- * @param string $type "pre", "output", … specify the filter type to set. Defaults to none treating $filters'
- * keys as the appropriate types
- *
- * @return Smarty current Smarty instance for chaining
- */
- public function addAutoloadFilters($filters, $type = null)
- {
- if ($type !== null) {
- if (!empty($this->autoload_filters[$type])) {
- $this->autoload_filters[$type] = array_merge($this->autoload_filters[$type], (array) $filters);
- } else {
- $this->autoload_filters[$type] = (array) $filters;
- }
- } else {
- foreach ((array) $filters as $key => $value) {
- if (!empty($this->autoload_filters[$key])) {
- $this->autoload_filters[$key] = array_merge($this->autoload_filters[$key], (array) $value);
- } else {
- $this->autoload_filters[$key] = (array) $value;
- }
+ $this->{$dirName}[] = $path;
}
}
-
- return $this;
- }
-
- /**
- * Get autoload filters
- *
- * @param string $type type of filter to get autoloads for. Defaults to all autoload filters
- *
- * @return array array( 'type1' => array( 'filter1', 'filter2', … ) ) or array( 'filter1', 'filter2', …) if $type
- * was specified
- */
- public function getAutoloadFilters($type = null)
- {
- if ($type !== null) {
- return isset($this->autoload_filters[$type]) ? $this->autoload_filters[$type] : array();
- }
-
- return $this->autoload_filters;
- }
-
- /**
- * return name of debugging template
- *
- * @return string
- */
- public function getDebugTemplate()
- {
- return $this->debug_tpl;
- }
-
- /**
- * set the debug template
- *
- * @param string $tpl_name
- *
- * @return Smarty current Smarty instance for chaining
- * @throws SmartyException if file is not readable
- */
- public function setDebugTemplate($tpl_name)
- {
- if (!is_readable($tpl_name)) {
- throw new SmartyException("Unknown file '{$tpl_name}'");
- }
- $this->debug_tpl = $tpl_name;
-
- return $this;
}
/**
@@ -1342,23 +1071,21 @@ class Smarty extends Smarty_Internal_TemplateBase
} else {
$data = null;
}
- $_templateId = $this->getTemplateId($template, $cache_id, $compile_id);
- if (isset($this->template_objects[$_templateId])) {
- if ($do_clone) {
- $tpl = clone $this->template_objects[$_templateId];
- $tpl->smarty = clone $tpl->smarty;
- } else {
- $tpl = $this->template_objects[$_templateId];
- }
+ if ($this->caching &&
+ isset($this->_cache['isCached'][$_templateId = $this->_getTemplateId($template, $cache_id, $compile_id)])
+ ) {
+ $tpl = $do_clone ? clone $this->_cache['isCached'][$_templateId] : $this->_cache['isCached'][$_templateId];
$tpl->parent = $parent;
$tpl->tpl_vars = array();
$tpl->config_vars = array();
} else {
- $tpl = new $this->template_class($template, $this, $parent, $cache_id, $compile_id);
- if ($do_clone) {
- $tpl->smarty = clone $tpl->smarty;
- }
- $tpl->templateId = $_templateId;
+ /* @var Smarty_Internal_Template $tpl */
+ $tpl = new $this->template_class($template, $this, $parent, $cache_id, $compile_id, null, null);
+ }
+ if ($do_clone) {
+ $tpl->smarty = clone $tpl->smarty;
+ } elseif ($parent === null) {
+ $tpl->parent = $this;
}
// fill data if present
if (!empty($data) && is_array($data)) {
@@ -1368,7 +1095,7 @@ class Smarty extends Smarty_Internal_TemplateBase
}
}
if ($this->debugging) {
- Smarty_Internal_Debug::register_template($tpl);
+ $tpl->smarty->_debug = new Smarty_Internal_Debug();
}
return $tpl;
}
@@ -1386,126 +1113,72 @@ class Smarty extends Smarty_Internal_TemplateBase
*/
public function loadPlugin($plugin_name, $check = true)
{
- // if function or class exists, exit silently (already loaded)
- if ($check && (is_callable($plugin_name) || class_exists($plugin_name, false))) {
- return true;
- }
- // Plugin name is expected to be: Smarty_[Type]_[Name]
- $_name_parts = explode('_', $plugin_name, 3);
- // class name must have three parts to be valid plugin
- // count($_name_parts) < 3 === !isset($_name_parts[2])
- if (!isset($_name_parts[2]) || strtolower($_name_parts[0]) !== 'smarty') {
- throw new SmartyException("plugin {$plugin_name} is not a valid name format");
- }
- // if type is "internal", get plugin from sysplugins
- if (strtolower($_name_parts[1]) == 'internal') {
- $file = SMARTY_SYSPLUGINS_DIR . strtolower($plugin_name) . '.php';
- if (isset($this->_is_file_cache[$file]) ? $this->_is_file_cache[$file] : $this->_is_file_cache[$file] = is_file($file)) {
- require_once($file);
- return $file;
- } else {
- return false;
- }
- }
- // plugin filename is expected to be: [type].[name].php
- $_plugin_filename = "{$_name_parts[1]}.{$_name_parts[2]}.php";
-
- $_stream_resolve_include_path = function_exists('stream_resolve_include_path');
-
- // loop through plugin dirs and find the plugin
- foreach ($this->getPluginsDir() as $_plugin_dir) {
- $names = array($_plugin_dir . $_plugin_filename, $_plugin_dir . strtolower($_plugin_filename),);
- foreach ($names as $file) {
- if (isset($this->_is_file_cache[$file]) ? $this->_is_file_cache[$file] : $this->_is_file_cache[$file] = is_file($file)) {
- require_once($file);
- return $file;
- }
- if ($this->use_include_path && !preg_match('/^([\/\\\\]|[a-zA-Z]:[\/\\\\])/', $_plugin_dir)) {
- // try PHP include_path
- if ($_stream_resolve_include_path) {
- $file = stream_resolve_include_path($file);
- } else {
- $file = Smarty_Internal_Get_Include_Path::getIncludePath($file);
- }
-
- if ($file !== false) {
- require_once($file);
-
- return $file;
- }
- }
- }
- }
- // no plugin loaded
- return false;
+ return $this->ext->loadPlugin->loadPlugin($this, $plugin_name, $check);
}
/**
- * Compile all template files
+ * Get unique template id
*
- * @param string $extension file extension
- * @param bool $force_compile force all to recompile
- * @param int $time_limit
- * @param int $max_errors
+ * @param string $template_name
+ * @param null|mixed $cache_id
+ * @param null|mixed $compile_id
+ * @param null $caching
*
- * @return integer number of template files recompiled
- */
- public function compileAllTemplates($extension = '.tpl', $force_compile = false, $time_limit = 0, $max_errors = null)
- {
- return Smarty_Internal_Utility::compileAllTemplates($extension, $force_compile, $time_limit, $max_errors, $this);
- }
-
- /**
- * Compile all config files
- *
- * @param string $extension file extension
- * @param bool $force_compile force all to recompile
- * @param int $time_limit
- * @param int $max_errors
- *
- * @return integer number of template files recompiled
+ * @return string
*/
- public function compileAllConfig($extension = '.conf', $force_compile = false, $time_limit = 0, $max_errors = null)
+ public function _getTemplateId($template_name, $cache_id = null, $compile_id = null, $caching = null)
{
- return Smarty_Internal_Utility::compileAllConfig($extension, $force_compile, $time_limit, $max_errors, $this);
- }
+ $cache_id = $cache_id === null ? $this->cache_id : $cache_id;
+ $compile_id = $compile_id === null ? $this->compile_id : $compile_id;
+ $caching = (int) ($caching === null ? $this->caching : $caching);
- /**
- * Delete compiled template file
- *
- * @param string $resource_name template name
- * @param string $compile_id compile id
- * @param integer $exp_time expiration time
- *
- * @return integer number of template files deleted
- */
- public function clearCompiledTemplate($resource_name = null, $compile_id = null, $exp_time = null)
- {
- return Smarty_Internal_Utility::clearCompiledTemplate($resource_name, $compile_id, $exp_time, $this);
+ if ($this->allow_ambiguous_resources) {
+ $_templateId =
+ Smarty_Resource::getUniqueTemplateName($this, $template_name) . "#{$cache_id}#{$compile_id}#{$caching}";
+ } else {
+ $_templateId = $this->_joined_template_dir . "#{$template_name}#{$cache_id}#{$compile_id}#{$caching}";
+ }
+ if (isset($_templateId[150])) {
+ $_templateId = sha1($_templateId);
+ }
+ return $_templateId;
}
/**
- * Return array of tag/attributes of all tags used by an template
+ * Normalize path
+ * - remove /./ and /../
+ * - make it absolute if required
*
- * @param Smarty_Internal_Template $template
+ * @param string $path file path
+ * @param bool $realpath leave $path relative
*
- * @return array of tag/attributes
+ * @return string
*/
- public function getTags(Smarty_Internal_Template $template)
+ public function _realpath($path, $realpath = null)
{
- return Smarty_Internal_Utility::getTags($template);
- }
+ static $pattern = null;
+ static $nds = null;
+ if ($pattern == null) {
+ $nds = DS == '/' ? '\\' : '/';
+ $ds = '\\' . DS;
+ $pattern =
+ "#([{$ds}]+[^{$ds}]+[{$ds}]+[.]([{$ds}]+[.])*[.][{$ds}]+([.][{$ds}]+)*)|([{$ds}]+([.][{$ds}]+)+)|[{$ds}]{2,}#";
+ }
+ // normalize DS
+ if (strpos($path, $nds) !== false) {
+ $path = str_replace($nds, DS, $path);
+ }
- /**
- * Run installation test
- *
- * @param array $errors Array to write errors into, rather than outputting them
- *
- * @return boolean true if setup is fine, false if something is wrong
- */
- public function testInstall(&$errors = null)
- {
- return Smarty_Internal_TestInstall::testInstall($this, $errors);
+ if ($realpath === true && $path[0] !== '/' && $path[1] !== ':') {
+ $path = getcwd() . DS . $path;
+ }
+ while ((strpos($path, '.' . DS) !== false) || (strpos($path, DS . DS) !== false)) {
+ $path = preg_replace($pattern, DS, $path);
+ }
+ if ($realpath === false && ($path[0] == '/' || $path[1] == ':')) {
+ $path = str_ireplace(getcwd(), '.', $path);
+ }
+ return $path;
}
/**
@@ -1525,38 +1198,6 @@ class Smarty extends Smarty_Internal_TemplateBase
}
/**
- * @param boolean $caching
- */
- public function setCaching($caching)
- {
- $this->caching = $caching;
- }
-
- /**
- * @param int $cache_lifetime
- */
- public function setCacheLifetime($cache_lifetime)
- {
- $this->cache_lifetime = $cache_lifetime;
- }
-
- /**
- * @param string $compile_id
- */
- public function setCompileId($compile_id)
- {
- $this->compile_id = $compile_id;
- }
-
- /**
- * @param string $cache_id
- */
- public function setCacheId($cache_id)
- {
- $this->cache_id = $cache_id;
- }
-
- /**
* @param int $error_reporting
*/
public function setErrorReporting($error_reporting)
@@ -1653,11 +1294,37 @@ class Smarty extends Smarty_Internal_TemplateBase
}
/**
+ * @param string $default_resource_type
+ */
+ public function setDefaultResourceType($default_resource_type)
+ {
+ $this->default_resource_type = $default_resource_type;
+ }
+
+ /**
+ * @param string $caching_type
+ */
+ public function setCachingType($caching_type)
+ {
+ $this->caching_type = $caching_type;
+ }
+
+ /**
+ * Test install
+ *
+ * @param null $errors
+ */
+ public function testInstall(&$errors = null)
+ {
+ Smarty_Internal_TestInstall::testInstall($this, $errors);
+ }
+
+ /**
* Class destructor
*/
public function __destruct()
{
- // intentionally left blank
+ $i = 0;// intentionally left blank
}
/**
@@ -1671,12 +1338,11 @@ class Smarty extends Smarty_Internal_TemplateBase
*/
public function __get($name)
{
- $allowed = array('template_dir' => 'getTemplateDir', 'config_dir' => 'getConfigDir',
- 'plugins_dir' => 'getPluginsDir', 'compile_dir' => 'getCompileDir',
- 'cache_dir' => 'getCacheDir',);
- if (isset($allowed[$name])) {
- return $this->{$allowed[$name]}();
+ if (isset(self::$accessMap[$name])) {
+ return $this->{self::$accessMap[$name]}();
+ } elseif (in_array($name, self::$obsoleteProperties)) {
+ return null;
} else {
trigger_error('Undefined property: ' . get_class($this) . '::$' . $name, E_USER_NOTICE);
}
@@ -1692,14 +1358,16 @@ class Smarty extends Smarty_Internal_TemplateBase
*/
public function __set($name, $value)
{
- $allowed = array('template_dir' => 'setTemplateDir', 'config_dir' => 'setConfigDir',
- 'plugins_dir' => 'setPluginsDir', 'compile_dir' => 'setCompileDir',
- 'cache_dir' => 'setCacheDir',);
-
- if (isset($allowed[$name])) {
- $this->{$allowed[$name]}($value);
+ if (isset(self::$accessMap[$name])) {
+ $this->{self::$accessMap[$name]}($value);
+ } elseif (in_array($name, self::$obsoleteProperties)) {
+ return;
} else {
- trigger_error('Undefined property: ' . get_class($this) . '::$' . $name, E_USER_NOTICE);
+ if (is_object($value) && method_exists($value, $name)) {
+ $this->$name = $value;
+ } else {
+ trigger_error('Undefined property: ' . get_class($this) . '::$' . $name, E_USER_NOTICE);
+ }
}
}
@@ -1724,8 +1392,8 @@ class Smarty extends Smarty_Internal_TemplateBase
if (!isset(Smarty::$_muted_directories[SMARTY_DIR])) {
$smarty_dir = realpath(SMARTY_DIR);
if ($smarty_dir !== false) {
- Smarty::$_muted_directories[SMARTY_DIR] = array('file' => $smarty_dir,
- 'length' => strlen($smarty_dir),);
+ Smarty::$_muted_directories[SMARTY_DIR] =
+ array('file' => $smarty_dir, 'length' => strlen($smarty_dir),);
}
}
@@ -1751,7 +1419,8 @@ class Smarty extends Smarty_Internal_TemplateBase
// or the error was within smarty but masked to be ignored
if (!$_is_muted_directory || ($errno && $errno & error_reporting())) {
if (Smarty::$_previous_error_handler) {
- return call_user_func(Smarty::$_previous_error_handler, $errno, $errstr, $errfile, $errline, $errcontext);
+ return call_user_func(Smarty::$_previous_error_handler, $errno, $errstr, $errfile, $errline,
+ $errcontext);
} else {
return false;
}
diff --git a/library/Smarty/libs/SmartyBC.class.php b/library/Smarty/libs/SmartyBC.class.php
index 76dd8bd0f..1dd529c9c 100644
--- a/library/Smarty/libs/SmartyBC.class.php
+++ b/library/Smarty/libs/SmartyBC.class.php
@@ -45,6 +45,13 @@ class SmartyBC extends Smarty
public $_version = self::SMARTY_VERSION;
/**
+ * This is an array of directories where trusted php scripts reside.
+ *
+ * @var array
+ */
+ public $trusted_dir = array();
+
+ /**
* Initialize new SmartyBC object
*
* @param array $options options to set during initialization, e.g. array( 'forceCompile' => false )
diff --git a/library/Smarty/libs/debug.tpl b/library/Smarty/libs/debug.tpl
index 5b09c5bd2..5526cbca8 100644
--- a/library/Smarty/libs/debug.tpl
+++ b/library/Smarty/libs/debug.tpl
@@ -128,7 +128,7 @@
<tr class="{if $vars@iteration % 2 eq 0}odd{else}even{/if}">
<td><h3><font color=blue>${$vars@key}</font></h3>
{if isset($vars['nocache'])}<b>Nocache</b></br>{/if}
- {if isset($vars['scope'])}<b>Origin:</b> {$vars['scope']|debug_print_var:10:80 nofilter}{/if}
+ {if isset($vars['scope'])}<b>Origin:</b> {$vars['scope']|debug_print_var nofilter}{/if}
</td>
<td><h3>Value</h3>{$vars['value']|debug_print_var:10:80 nofilter}</td>
<td>{if isset($vars['attributes'])}<h3>Attributes</h3>{$vars['attributes']|debug_print_var nofilter} {/if}</td>
@@ -141,7 +141,7 @@
{foreach $config_vars as $vars}
<tr class="{if $vars@iteration % 2 eq 0}odd{else}even{/if}">
<td><h3><font color=blue>#{$vars@key}#</font></h3>
- {if isset($vars['scope'])}<b>Origin:</b> {$vars['scope']|debug_print_var:10:80 nofilter}{/if}
+ {if isset($vars['scope'])}<b>Origin:</b> {$vars['scope']|debug_print_var nofilter}{/if}
</td>
<td>{$vars['value']|debug_print_var:10:80 nofilter}</td>
</tr>
@@ -152,9 +152,9 @@
</html>
{/capture}
<script type="text/javascript">
- {$id = ''}
+ {$id = '__Smarty__'}
{if $display_mode}{$id = "$offset$template_name"|md5}{/if}
- _smarty_console = window.open("", "console{$id}", "width=680,height=600,left={$offset},top={$offset},resizable,scrollbars=yes");
+ _smarty_console = window.open("", "console{$id}", "width=1024,height=600,left={$offset},top={$offset},resizable,scrollbars=yes");
_smarty_console.document.write("{$debug_output|escape:'javascript' nofilter}");
_smarty_console.document.close();
</script>
diff --git a/library/Smarty/libs/plugins/modifier.debug_print_var.php b/library/Smarty/libs/plugins/modifier.debug_print_var.php
index e3971a046..4ff8213ce 100644
--- a/library/Smarty/libs/plugins/modifier.debug_print_var.php
+++ b/library/Smarty/libs/plugins/modifier.debug_print_var.php
@@ -24,9 +24,9 @@
*/
function smarty_modifier_debug_print_var($var, $max = 10, $length = 40, $depth = 0, $objects = array())
{
- $_replace = array("\n" => '<i>\n</i>',
- "\r" => '<i>\r</i>',
- "\t" => '<i>\t</i>'
+ $_replace = array("\n" => '\n',
+ "\r" => '\r',
+ "\t" => '\t'
);
switch (gettype($var)) {
case 'array' :
diff --git a/library/Smarty/libs/plugins/modifier.regex_replace.php b/library/Smarty/libs/plugins/modifier.regex_replace.php
index abb1ff548..ffea16755 100644
--- a/library/Smarty/libs/plugins/modifier.regex_replace.php
+++ b/library/Smarty/libs/plugins/modifier.regex_replace.php
@@ -19,10 +19,11 @@
* @param string $string input string
* @param string|array $search regular expression(s) to search for
* @param string|array $replace string(s) that should be replaced
+ * @param int $limit the maximum number of replacements
*
* @return string
*/
-function smarty_modifier_regex_replace($string, $search, $replace)
+function smarty_modifier_regex_replace($string, $search, $replace, $limit = -1)
{
if (is_array($search)) {
foreach ($search as $idx => $s) {
@@ -32,7 +33,7 @@ function smarty_modifier_regex_replace($string, $search, $replace)
$search = _smarty_regex_replace_check($search);
}
- return preg_replace($search, $replace, $string);
+ return preg_replace($search, $replace, $string, $limit);
}
/**
diff --git a/library/Smarty/libs/plugins/modifiercompiler.escape.php b/library/Smarty/libs/plugins/modifiercompiler.escape.php
index 7e848aaec..0b29220ef 100644
--- a/library/Smarty/libs/plugins/modifiercompiler.escape.php
+++ b/library/Smarty/libs/plugins/modifiercompiler.escape.php
@@ -115,11 +115,11 @@ function smarty_modifiercompiler_escape($params, $compiler)
// could not optimize |escape call, so fallback to regular plugin
if ($compiler->template->caching && ($compiler->tag_nocache | $compiler->nocache)) {
- $compiler->template->required_plugins['nocache']['escape']['modifier']['file'] = SMARTY_PLUGINS_DIR . 'modifier.escape.php';
- $compiler->template->required_plugins['nocache']['escape']['modifier']['function'] = 'smarty_modifier_escape';
+ $compiler->parent_compiler->template->compiled->required_plugins['nocache']['escape']['modifier']['file'] = SMARTY_PLUGINS_DIR . 'modifier.escape.php';
+ $compiler->parent_compiler->template->compiled->required_plugins['nocache']['escape']['modifier']['function'] = 'smarty_modifier_escape';
} else {
- $compiler->template->required_plugins['compiled']['escape']['modifier']['file'] = SMARTY_PLUGINS_DIR . 'modifier.escape.php';
- $compiler->template->required_plugins['compiled']['escape']['modifier']['function'] = 'smarty_modifier_escape';
+ $compiler->parent_compiler->template->compiled->required_plugins['compiled']['escape']['modifier']['file'] = SMARTY_PLUGINS_DIR . 'modifier.escape.php';
+ $compiler->parent_compiler->template->compiled->required_plugins['compiled']['escape']['modifier']['function'] = 'smarty_modifier_escape';
}
return 'smarty_modifier_escape(' . join(', ', $params) . ')';
diff --git a/library/Smarty/libs/plugins/modifiercompiler.wordwrap.php b/library/Smarty/libs/plugins/modifiercompiler.wordwrap.php
index 2ad928ea1..6bb63247d 100644
--- a/library/Smarty/libs/plugins/modifiercompiler.wordwrap.php
+++ b/library/Smarty/libs/plugins/modifiercompiler.wordwrap.php
@@ -34,11 +34,11 @@ function smarty_modifiercompiler_wordwrap($params, $compiler)
$function = 'wordwrap';
if (Smarty::$_MBSTRING) {
if ($compiler->template->caching && ($compiler->tag_nocache | $compiler->nocache)) {
- $compiler->template->required_plugins['nocache']['wordwrap']['modifier']['file'] = SMARTY_PLUGINS_DIR . 'shared.mb_wordwrap.php';
+ $compiler->parent_compiler->template->compiled->required_plugins['nocache']['wordwrap']['modifier']['file'] = SMARTY_PLUGINS_DIR . 'shared.mb_wordwrap.php';
$compiler->template->required_plugins['nocache']['wordwrap']['modifier']['function'] = 'smarty_mb_wordwrap';
} else {
- $compiler->template->required_plugins['compiled']['wordwrap']['modifier']['file'] = SMARTY_PLUGINS_DIR . 'shared.mb_wordwrap.php';
- $compiler->template->required_plugins['compiled']['wordwrap']['modifier']['function'] = 'smarty_mb_wordwrap';
+ $compiler->parent_compiler->template->compiled->required_plugins['compiled']['wordwrap']['modifier']['file'] = SMARTY_PLUGINS_DIR . 'shared.mb_wordwrap.php';
+ $compiler->parent_compiler->template->compiled->required_plugins['compiled']['wordwrap']['modifier']['function'] = 'smarty_mb_wordwrap';
}
$function = 'smarty_mb_wordwrap';
}
diff --git a/library/Smarty/libs/plugins/shared.make_timestamp.php b/library/Smarty/libs/plugins/shared.make_timestamp.php
index 7c94e5f59..f87d40c7e 100644
--- a/library/Smarty/libs/plugins/shared.make_timestamp.php
+++ b/library/Smarty/libs/plugins/shared.make_timestamp.php
@@ -21,8 +21,8 @@ function smarty_make_timestamp($string)
if (empty($string)) {
// use "now":
return time();
- } elseif ($string instanceof DateTime) {
- return $string->getTimestamp();
+ } elseif ($string instanceof DateTime || (interface_exists('DateTimeInterface', false) && $string instanceof DateTimeInterface)) {
+ return (int) $string->format('U'); // PHP 5.2 BC
} elseif (strlen($string) == 14 && ctype_digit($string)) {
// it is mysql timestamp format of YYYYMMDDHHMMSS?
return mktime(substr($string, 8, 2), substr($string, 10, 2), substr($string, 12, 2),
diff --git a/library/Smarty/libs/sysplugins/smarty_cacheresource.php b/library/Smarty/libs/sysplugins/smarty_cacheresource.php
index 622ab6fbc..8cd2805a5 100644
--- a/library/Smarty/libs/sysplugins/smarty_cacheresource.php
+++ b/library/Smarty/libs/sysplugins/smarty_cacheresource.php
@@ -20,9 +20,7 @@ abstract class Smarty_CacheResource
*
* @var array
*/
- protected static $sysplugins = array(
- 'file' => 'smarty_internal_cacheresource_file.php',
- );
+ protected static $sysplugins = array('file' => 'smarty_internal_cacheresource_file.php',);
/**
* populate Cached Object with meta data from Resource
@@ -48,10 +46,11 @@ abstract class Smarty_CacheResource
*
* @param Smarty_Internal_Template $_template template object
* @param Smarty_Template_Cached $cached cached object
+ * @param bool $update flag if called because cache update
*
- * @return boolean true or false if the cached content does not exist
+ * @return bool true or false if the cached content does not exist
*/
- abstract public function process(Smarty_Internal_Template $_template, Smarty_Template_Cached $cached = null);
+ abstract public function process(Smarty_Internal_Template $_template, Smarty_Template_Cached $cached = null, $update = false);
/**
* Write the rendered template output to cache
@@ -74,8 +73,8 @@ abstract class Smarty_CacheResource
{
if ($_template->cached->handler->process($_template)) {
ob_start();
- $_template->properties['unifunc']($_template);
-
+ $unifunc = $_template->cached->unifunc;
+ $unifunc($_template);
return ob_get_clean();
}
@@ -186,27 +185,24 @@ abstract class Smarty_CacheResource
}
// try smarty's cache
- if (isset($smarty->_cacheresource_handlers[$type])) {
- return $smarty->_cacheresource_handlers[$type];
+ if (isset($smarty->_cache['cacheresource_handlers'][$type])) {
+ return $smarty->_cache['cacheresource_handlers'][$type];
}
// try registered resource
if (isset($smarty->registered_cache_resources[$type])) {
// do not cache these instances as they may vary from instance to instance
- return $smarty->_cacheresource_handlers[$type] = $smarty->registered_cache_resources[$type];
+ return $smarty->_cache['cacheresource_handlers'][$type] = $smarty->registered_cache_resources[$type];
}
// try sysplugins dir
if (isset(self::$sysplugins[$type])) {
$cache_resource_class = 'Smarty_Internal_CacheResource_' . ucfirst($type);
- if (!class_exists($cache_resource_class, false)) {
- require SMARTY_SYSPLUGINS_DIR . self::$sysplugins[$type];
- }
- return $smarty->_cacheresource_handlers[$type] = new $cache_resource_class();
+ return $smarty->_cache['cacheresource_handlers'][$type] = new $cache_resource_class();
}
// try plugins dir
$cache_resource_class = 'Smarty_CacheResource_' . ucfirst($type);
if ($smarty->loadPlugin($cache_resource_class)) {
- return $smarty->_cacheresource_handlers[$type] = new $cache_resource_class();
+ return $smarty->_cache['cacheresource_handlers'][$type] = new $cache_resource_class();
}
// give up
throw new SmartyException("Unable to load cache resource '{$type}'");
@@ -217,12 +213,13 @@ abstract class Smarty_CacheResource
*
* @param Smarty $smarty Smarty object
*/
- public static function invalidLoadedCache(Smarty $smarty)
+ public function invalidLoadedCache(Smarty $smarty)
{
- foreach ($smarty->template_objects as $tpl) {
- if (isset($tpl->cached)) {
- $tpl->cached->valid = false;
- $tpl->cached->processed = false;
+ if (isset($smarty->_cache['template_objects'])) {
+ foreach ($smarty->_cache['template_objects'] as $key => $tpl) {
+ if (isset($tpl->cached)) {
+ unset ($smarty->_cache['template_objects'][$key]);
+ }
}
}
}
diff --git a/library/Smarty/libs/sysplugins/smarty_cacheresource_custom.php b/library/Smarty/libs/sysplugins/smarty_cacheresource_custom.php
index f496c1523..4e9606ef1 100644
--- a/library/Smarty/libs/sysplugins/smarty_cacheresource_custom.php
+++ b/library/Smarty/libs/sysplugins/smarty_cacheresource_custom.php
@@ -83,7 +83,7 @@ abstract class Smarty_CacheResource_Custom extends Smarty_CacheResource
public function populate(Smarty_Template_Cached $cached, Smarty_Internal_Template $_template)
{
$_cache_id = isset($cached->cache_id) ? preg_replace('![^\w\|]+!', '_', $cached->cache_id) : null;
- $_compile_id = isset($cached->compile_id) ? preg_replace('![^\w\|]+!', '_', $cached->compile_id) : null;
+ $_compile_id = isset($cached->compile_id) ? preg_replace('![^\w]+!', '_', $cached->compile_id) : null;
$path = $cached->source->filepath . $_cache_id . $_compile_id;
$cached->filepath = sha1($path);
if ($_template->smarty->cache_locking) {
@@ -119,10 +119,11 @@ abstract class Smarty_CacheResource_Custom extends Smarty_CacheResource
*
* @param Smarty_Internal_Template $_template template object
* @param Smarty_Template_Cached $cached cached object
+ * @param bool $update flag if called because cache update
*
* @return boolean true or false if the cached content does not exist
*/
- public function process(Smarty_Internal_Template $_template, Smarty_Template_Cached $cached = null)
+ public function process(Smarty_Internal_Template $_template, Smarty_Template_Cached $cached = null, $update = false)
{
if (!$cached) {
$cached = $_template->cached;
@@ -130,14 +131,7 @@ abstract class Smarty_CacheResource_Custom extends Smarty_CacheResource
$content = $cached->content ? $cached->content : null;
$timestamp = $cached->timestamp ? $cached->timestamp : null;
if ($content === null || !$timestamp) {
- $this->fetch(
- $_template->cached->filepath,
- $_template->source->name,
- $_template->cache_id,
- $_template->compile_id,
- $content,
- $timestamp
- );
+ $this->fetch($_template->cached->filepath, $_template->source->name, $_template->cache_id, $_template->compile_id, $content, $timestamp);
}
if (isset($content)) {
/** @var Smarty_Internal_Template $_smarty_tpl
@@ -145,7 +139,7 @@ abstract class Smarty_CacheResource_Custom extends Smarty_CacheResource
*/
$_smarty_tpl = $_template;
eval("?>" . $content);
-
+ $cached->content = null;
return true;
}
@@ -162,14 +156,7 @@ abstract class Smarty_CacheResource_Custom extends Smarty_CacheResource
*/
public function writeCachedContent(Smarty_Internal_Template $_template, $content)
{
- return $this->save(
- $_template->cached->filepath,
- $_template->source->name,
- $_template->cache_id,
- $_template->compile_id,
- $_template->properties['cache_lifetime'],
- $content
- );
+ return $this->save($_template->cached->filepath, $_template->source->name, $_template->cache_id, $_template->compile_id, $_template->cache_lifetime, $content);
}
/**
@@ -185,14 +172,7 @@ abstract class Smarty_CacheResource_Custom extends Smarty_CacheResource
$timestamp = null;
if ($content === null) {
$timestamp = null;
- $this->fetch(
- $_template->cached->filepath,
- $_template->source->name,
- $_template->cache_id,
- $_template->compile_id,
- $content,
- $timestamp
- );
+ $this->fetch($_template->cached->filepath, $_template->source->name, $_template->cache_id, $_template->compile_id, $content, $timestamp);
}
if (isset($content)) {
return $content;
@@ -210,8 +190,6 @@ abstract class Smarty_CacheResource_Custom extends Smarty_CacheResource
*/
public function clearAll(Smarty $smarty, $exp_time = null)
{
- $this->cache = array();
-
return $this->delete(null, null, null, $exp_time);
}
@@ -228,32 +206,23 @@ abstract class Smarty_CacheResource_Custom extends Smarty_CacheResource
*/
public function clear(Smarty $smarty, $resource_name, $cache_id, $compile_id, $exp_time)
{
- $this->cache = array();
$cache_name = null;
if (isset($resource_name)) {
- $_save_stat = $smarty->caching;
- $smarty->caching = true;
- $tpl = new $smarty->template_class($resource_name, $smarty);
- $smarty->caching = $_save_stat;
-
- if ($tpl->source->exists) {
- $cache_name = $tpl->source->name;
+ $source = Smarty_Template_Source::load(null, $smarty, $resource_name);
+ if ($source->exists) {
+ $cache_name = $source->name;
} else {
return 0;
}
// remove from template cache
- if ($smarty->allow_ambiguous_resources) {
- $_templateId = $tpl->source->unique_resource . $tpl->cache_id . $tpl->compile_id;
- } else {
- $_templateId = $smarty->joined_template_dir . '#' . $resource_name . $tpl->cache_id . $tpl->compile_id;
- }
- if (isset($_templateId[150])) {
- $_templateId = sha1($_templateId);
+ if (isset($smarty->_cache['template_objects'])) {
+ foreach ($smarty->_cache['template_objects'] as $key => $_tpl) {
+ if (isset($_tpl->cached) && $_tpl->source->uid == $source->uid) {
+ unset($smarty->_cache['template_objects'][$key]);
+ }
+ }
}
- unset($smarty->template_objects[$_templateId]);
- // template object no longer needed
- unset($tpl);
}
return $this->delete($cache_name, $cache_id, $compile_id, $exp_time);
diff --git a/library/Smarty/libs/sysplugins/smarty_cacheresource_keyvaluestore.php b/library/Smarty/libs/sysplugins/smarty_cacheresource_keyvaluestore.php
index 2fdc7e42f..ee4021a19 100644
--- a/library/Smarty/libs/sysplugins/smarty_cacheresource_keyvaluestore.php
+++ b/library/Smarty/libs/sysplugins/smarty_cacheresource_keyvaluestore.php
@@ -54,7 +54,8 @@ abstract class Smarty_CacheResource_KeyValueStore extends Smarty_CacheResource
*/
public function populate(Smarty_Template_Cached $cached, Smarty_Internal_Template $_template)
{
- $cached->filepath = $_template->source->uid . '#' . $this->sanitize($cached->source->resource) . '#' . $this->sanitize($cached->cache_id) . '#' . $this->sanitize($cached->compile_id);
+ $cached->filepath = $_template->source->uid . '#' . $this->sanitize($cached->source->resource) . '#' .
+ $this->sanitize($cached->cache_id) . '#' . $this->sanitize($cached->compile_id);
$this->populateTimestamp($cached);
}
@@ -81,10 +82,11 @@ abstract class Smarty_CacheResource_KeyValueStore extends Smarty_CacheResource
*
* @param Smarty_Internal_Template $_template template object
* @param Smarty_Template_Cached $cached cached object
+ * @param bool $update flag if called because cache update
*
* @return boolean true or false if the cached content does not exist
*/
- public function process(Smarty_Internal_Template $_template, Smarty_Template_Cached $cached = null)
+ public function process(Smarty_Internal_Template $_template, Smarty_Template_Cached $cached = null, $update = false)
{
if (!$cached) {
$cached = $_template->cached;
@@ -121,7 +123,7 @@ abstract class Smarty_CacheResource_KeyValueStore extends Smarty_CacheResource
{
$this->addMetaTimestamp($content);
- return $this->write(array($_template->cached->filepath => $content), $_template->properties['cache_lifetime']);
+ return $this->write(array($_template->cached->filepath => $content), $_template->cache_lifetime);
}
/**
@@ -162,7 +164,14 @@ abstract class Smarty_CacheResource_KeyValueStore extends Smarty_CacheResource
if (!$this->purge()) {
$this->invalidate(null);
}
-
+ // remove from template cache
+ if (isset($smarty->_cache['template_objects'])) {
+ foreach ($smarty->_cache['template_objects'] as $key => $tpl) {
+ if (isset($tpl->cached)) {
+ unset($smarty->_cache['template_objects'][$key]);
+ }
+ }
+ }
return - 1;
}
@@ -183,11 +192,21 @@ abstract class Smarty_CacheResource_KeyValueStore extends Smarty_CacheResource
*/
public function clear(Smarty $smarty, $resource_name, $cache_id, $compile_id, $exp_time)
{
- $uid = $this->getTemplateUid($smarty, $resource_name, $cache_id, $compile_id);
- $cid = $uid . '#' . $this->sanitize($resource_name) . '#' . $this->sanitize($cache_id) . '#' . $this->sanitize($compile_id);
+ $uid = $this->getTemplateUid($smarty, $resource_name);
+ $cid = $uid . '#' . $this->sanitize($resource_name) . '#' . $this->sanitize($cache_id) . '#' .
+ $this->sanitize($compile_id);
$this->delete(array($cid));
$this->invalidate($cid, $resource_name, $cache_id, $compile_id, $uid);
-
+ // remove from template cache
+ if (isset($resource_name) && isset($smarty->_cache['template_objects'])) {
+ if (isset($smarty->_cache['template_objects'])) {
+ foreach ($smarty->_cache['template_objects'] as $key => $tpl) {
+ if ($tpl->source->uid == $uid && isset($tpl->cached)) {
+ unset($smarty->_cache['template_objects'][$key]);
+ }
+ }
+ }
+ }
return - 1;
}
@@ -196,33 +215,20 @@ abstract class Smarty_CacheResource_KeyValueStore extends Smarty_CacheResource
*
* @param Smarty $smarty Smarty object
* @param string $resource_name template name
- * @param string $cache_id cache id
- * @param string $compile_id compile id
*
* @return string filepath of cache file
+ * @throws \SmartyException
+ *
*/
- protected function getTemplateUid(Smarty $smarty, $resource_name, $cache_id, $compile_id)
+ protected function getTemplateUid(Smarty $smarty, $resource_name)
{
- $uid = '';
if (isset($resource_name)) {
- $tpl = new $smarty->template_class($resource_name, $smarty);
- if ($tpl->source->exists) {
- $uid = $tpl->source->uid;
- }
-
- // remove from template cache
- if ($smarty->allow_ambiguous_resources) {
- $_templateId = $tpl->source->unique_resource . $tpl->cache_id . $tpl->compile_id;
- } else {
- $_templateId = $smarty->joined_template_dir . '#' . $resource_name . $tpl->cache_id . $tpl->compile_id;
- }
- if (isset($_templateId[150])) {
- $_templateId = sha1($_templateId);
+ $source = Smarty_Template_Source::load(null, $smarty, $resource_name);
+ if ($source->exists) {
+ return $source->uid;
}
- unset($smarty->template_objects[$_templateId]);
}
-
- return $uid;
+ return '';
}
/**
@@ -234,12 +240,10 @@ abstract class Smarty_CacheResource_KeyValueStore extends Smarty_CacheResource
*/
protected function sanitize($string)
{
- // some poeple smoke bad weed
$string = trim($string, '|');
if (!$string) {
return null;
}
-
return preg_replace('#[^\w\|]+#S', '_', $string);
}
@@ -397,7 +401,6 @@ abstract class Smarty_CacheResource_KeyValueStore extends Smarty_CacheResource
$t[] = 'IVK#COMPILE' . $_compile;
}
$_name .= '#';
- // some poeple smoke bad weed
$cid = trim($cache_id, '|');
if (!$cid) {
return $t;
diff --git a/library/Smarty/libs/sysplugins/smarty_data.php b/library/Smarty/libs/sysplugins/smarty_data.php
index 8074513d8..7cf18a43e 100644
--- a/library/Smarty/libs/sysplugins/smarty_data.php
+++ b/library/Smarty/libs/sysplugins/smarty_data.php
@@ -30,6 +30,7 @@ class Smarty_Data extends Smarty_Internal_Data
* @var string
*/
public $dataObjectName = '';
+
/**
* Smarty object
*
@@ -48,6 +49,7 @@ class Smarty_Data extends Smarty_Internal_Data
*/
public function __construct($_parent = null, $smarty = null, $name = null)
{
+ parent::__construct();
self::$count ++;
$this->dataObjectName = 'Data_object ' . (isset($name) ? "'{$name}'" : self::$count);
$this->smarty = $smarty;
diff --git a/library/Smarty/libs/sysplugins/smarty_internal_cacheresource_file.php b/library/Smarty/libs/sysplugins/smarty_internal_cacheresource_file.php
index de794517a..64d02dfe5 100644
--- a/library/Smarty/libs/sysplugins/smarty_internal_cacheresource_file.php
+++ b/library/Smarty/libs/sysplugins/smarty_internal_cacheresource_file.php
@@ -29,14 +29,12 @@ class Smarty_Internal_CacheResource_File extends Smarty_CacheResource
{
$_source_file_path = str_replace(':', '.', $_template->source->filepath);
$_cache_id = isset($_template->cache_id) ? preg_replace('![^\w\|]+!', '_', $_template->cache_id) : null;
- $_compile_id = isset($_template->compile_id) ? preg_replace('![^\w\|]+!', '_', $_template->compile_id) : null;
+ $_compile_id = isset($_template->compile_id) ? preg_replace('![^\w]+!', '_', $_template->compile_id) : null;
$_filepath = $_template->source->uid;
// if use_sub_dirs, break file into directories
if ($_template->smarty->use_sub_dirs) {
- $_filepath = substr($_filepath, 0, 2) . DS
- . substr($_filepath, 2, 2) . DS
- . substr($_filepath, 4, 2) . DS
- . $_filepath;
+ $_filepath = substr($_filepath, 0, 2) . DS . substr($_filepath, 2, 2) . DS . substr($_filepath, 4, 2) . DS .
+ $_filepath;
}
$_compile_dir_sep = $_template->smarty->use_sub_dirs ? DS : '^';
if (isset($_cache_id)) {
@@ -60,7 +58,8 @@ class Smarty_Internal_CacheResource_File extends Smarty_CacheResource
}
$cached->lock_id = $_lock_dir . sha1($_cache_id . $_compile_id . $_template->source->uid) . '.lock';
}
- $cached->filepath = $_cache_dir . $_cache_id . $_compile_id . $_filepath . '.' . basename($_source_file_path) . '.php';
+ $cached->filepath = $_cache_dir . $_cache_id . $_compile_id . $_filepath . '.' . basename($_source_file_path) .
+ '.php';
$cached->timestamp = $cached->exists = is_file($cached->filepath);
if ($cached->exists) {
$cached->timestamp = filemtime($cached->filepath);
@@ -87,17 +86,22 @@ class Smarty_Internal_CacheResource_File extends Smarty_CacheResource
*
* @param Smarty_Internal_Template $_template template object
* @param Smarty_Template_Cached $cached cached object
+ * @param bool $update flag if called because cache update
*
- * @return booleantrue or false if the cached content does not exist
+ * @return boolean true or false if the cached content does not exist
*/
- public function process(Smarty_Internal_Template $_template, Smarty_Template_Cached $cached = null)
+ public function process(Smarty_Internal_Template $_template, Smarty_Template_Cached $cached = null, $update = false)
{
/** @var Smarty_Internal_Template $_smarty_tpl
* used in included file
*/
$_smarty_tpl = $_template;
-
- return @include $_template->cached->filepath;
+ $_template->cached->valid = false;
+ if ($update && defined('HHVM_VERSION')) {
+ return $_template->smarty->ext->_hhvm->includeHhvm($_template, $_template->cached->filepath);
+ } else {
+ return @include $_template->cached->filepath;
+ }
}
/**
@@ -110,8 +114,10 @@ class Smarty_Internal_CacheResource_File extends Smarty_CacheResource
*/
public function writeCachedContent(Smarty_Internal_Template $_template, $content)
{
- $obj = new Smarty_Internal_Write_File();
- if ($obj->writeFile($_template->cached->filepath, $content, $_template->smarty) === true) {
+ if ($_template->smarty->ext->_writeFile->writeFile($_template->cached->filepath, $content, $_template->smarty) === true) {
+ if (function_exists('opcache_invalidate')) {
+ opcache_invalidate($_template->cached->filepath);
+ }
$cached = $_template->cached;
$cached->timestamp = $cached->exists = is_file($cached->filepath);
if ($cached->exists) {
@@ -147,7 +153,7 @@ class Smarty_Internal_CacheResource_File extends Smarty_CacheResource
*/
public function clearAll(Smarty $smarty, $exp_time = null)
{
- return $this->clear($smarty, null, null, null, $exp_time);
+ return Smarty_Internal_Extension_Clear::clear($smarty, null, null, null, $exp_time);
}
/**
@@ -163,108 +169,7 @@ class Smarty_Internal_CacheResource_File extends Smarty_CacheResource
*/
public function clear(Smarty $smarty, $resource_name, $cache_id, $compile_id, $exp_time)
{
- $_cache_id = isset($cache_id) ? preg_replace('![^\w\|]+!', '_', $cache_id) : null;
- $_compile_id = isset($compile_id) ? preg_replace('![^\w\|]+!', '_', $compile_id) : null;
- $_dir_sep = $smarty->use_sub_dirs ? '/' : '^';
- $_compile_id_offset = $smarty->use_sub_dirs ? 3 : 0;
- $_dir = realpath($smarty->getCacheDir()) . '/';
- if ($_dir == '/') { //We should never want to delete this!
- return 0;
- }
- $_dir_length = strlen($_dir);
- if (isset($_cache_id)) {
- $_cache_id_parts = explode('|', $_cache_id);
- $_cache_id_parts_count = count($_cache_id_parts);
- if ($smarty->use_sub_dirs) {
- foreach ($_cache_id_parts as $id_part) {
- $_dir .= $id_part . DS;
- }
- }
- }
- if (isset($resource_name)) {
- $_save_stat = $smarty->caching;
- $smarty->caching = true;
- $tpl = new $smarty->template_class($resource_name, $smarty);
- $smarty->caching = $_save_stat;
-
- // remove from template cache
- $tpl->source; // have the template registered before unset()
- if ($smarty->allow_ambiguous_resources) {
- $_templateId = $tpl->source->unique_resource . $tpl->cache_id . $tpl->compile_id;
- } else {
- $_templateId = $smarty->joined_template_dir . '#' . $resource_name . $tpl->cache_id . $tpl->compile_id;
- }
- if (isset($_templateId[150])) {
- $_templateId = sha1($_templateId);
- }
- unset($smarty->template_objects[$_templateId]);
-
- if ($tpl->source->exists) {
- $_resourcename_parts = basename(str_replace('^', '/', $tpl->cached->filepath));
- } else {
- return 0;
- }
- }
- $_count = 0;
- $_time = time();
- if (file_exists($_dir)) {
- $_cacheDirs = new RecursiveDirectoryIterator($_dir);
- $_cache = new RecursiveIteratorIterator($_cacheDirs, RecursiveIteratorIterator::CHILD_FIRST);
- foreach ($_cache as $_file) {
- if (substr(basename($_file->getPathname()), 0, 1) == '.' || strpos($_file, '.svn') !== false) {
- continue;
- }
- // directory ?
- if ($_file->isDir()) {
- if (!$_cache->isDot()) {
- // delete folder if empty
- @rmdir($_file->getPathname());
- }
- } else {
- $_parts = explode($_dir_sep, str_replace('\\', '/', substr((string) $_file, $_dir_length)));
- $_parts_count = count($_parts);
- // check name
- if (isset($resource_name)) {
- if ($_parts[$_parts_count - 1] != $_resourcename_parts) {
- continue;
- }
- }
- // check compile id
- if (isset($_compile_id) && (!isset($_parts[$_parts_count - 2 - $_compile_id_offset]) || $_parts[$_parts_count - 2 - $_compile_id_offset] != $_compile_id)) {
- continue;
- }
- // check cache id
- if (isset($_cache_id)) {
- // count of cache id parts
- $_parts_count = (isset($_compile_id)) ? $_parts_count - 2 - $_compile_id_offset : $_parts_count - 1 - $_compile_id_offset;
- if ($_parts_count < $_cache_id_parts_count) {
- continue;
- }
- for ($i = 0; $i < $_cache_id_parts_count; $i ++) {
- if ($_parts[$i] != $_cache_id_parts[$i]) {
- continue 2;
- }
- }
- }
- // expired ?
- if (isset($exp_time)) {
- if ($exp_time < 0) {
- preg_match('#\'cache_lifetime\' =>\s*(\d*)#', file_get_contents($_file), $match);
- if ($_time < (@filemtime($_file) + $match[1])) {
- continue;
- }
- } else {
- if ($_time - @filemtime($_file) < $exp_time) {
- continue;
- }
- }
- }
- $_count += @unlink((string) $_file) ? 1 : 0;
- }
- }
- }
-
- return $_count;
+ return Smarty_Internal_Extension_Clear::clear($smarty, $resource_name, $cache_id, $compile_id, $exp_time);
}
/**
diff --git a/library/Smarty/libs/sysplugins/smarty_internal_compile_append.php b/library/Smarty/libs/sysplugins/smarty_internal_compile_append.php
index cbf65685b..bd2ffe474 100644
--- a/library/Smarty/libs/sysplugins/smarty_internal_compile_append.php
+++ b/library/Smarty/libs/sysplugins/smarty_internal_compile_append.php
@@ -19,13 +19,13 @@ class Smarty_Internal_Compile_Append extends Smarty_Internal_Compile_Assign
/**
* Compiles code for the {append} tag
*
- * @param array $args array with attributes from parser
- * @param object $compiler compiler object
- * @param array $parameter array with compilation parameter
+ * @param array $args array with attributes from parser
+ * @param \Smarty_Internal_TemplateCompilerBase $compiler compiler object
+ * @param array $parameter array with compilation parameter
*
* @return string compiled code
*/
- public function compile($args, $compiler, $parameter)
+ public function compile($args, Smarty_Internal_TemplateCompilerBase $compiler, $parameter)
{
// the following must be assigned at runtime because it will be overwritten in parent class
$this->required_attributes = array('var', 'value');
diff --git a/library/Smarty/libs/sysplugins/smarty_internal_compile_assign.php b/library/Smarty/libs/sysplugins/smarty_internal_compile_assign.php
index bdce0c3f0..5e3fce3cc 100644
--- a/library/Smarty/libs/sysplugins/smarty_internal_compile_assign.php
+++ b/library/Smarty/libs/sysplugins/smarty_internal_compile_assign.php
@@ -17,22 +17,30 @@
class Smarty_Internal_Compile_Assign extends Smarty_Internal_CompileBase
{
/**
+ * Valid scope names
+ *
+ * @var array
+ */
+ public $valid_scopes = array('local' => true, 'parent' => true, 'root' => true, 'global' => true,
+ 'smarty' => true, 'tpl_root' => true);
+
+ /**
* Compiles code for the {assign} tag
*
- * @param array $args array with attributes from parser
- * @param object $compiler compiler object
- * @param array $parameter array with compilation parameter
+ * @param array $args array with attributes from parser
+ * @param \Smarty_Internal_TemplateCompilerBase $compiler compiler object
+ * @param array $parameter array with compilation parameter
*
* @return string compiled code
+ * @throws \SmartyCompilerException
*/
- public function compile($args, $compiler, $parameter)
+ public function compile($args, Smarty_Internal_TemplateCompilerBase $compiler, $parameter)
{
// the following must be assigned at runtime because it will be overwritten in Smarty_Internal_Compile_Append
$this->required_attributes = array('var', 'value');
$this->shorttag_order = array('var', 'value');
- $this->optional_attributes = array('scope');
+ $this->optional_attributes = array('scope', 'bubble_up');
$_nocache = 'null';
- $_scope = Smarty::SCOPE_LOCAL;
// check and get attributes
$_attr = $this->getAttributes($compiler, $args);
// nocache ?
@@ -46,39 +54,43 @@ class Smarty_Internal_Compile_Assign extends Smarty_Internal_CompileBase
}
}
// scope setup
+ $_scope = Smarty::SCOPE_LOCAL;
if (isset($_attr['scope'])) {
$_attr['scope'] = trim($_attr['scope'], "'\"");
- if ($_attr['scope'] == 'parent') {
- $_scope = Smarty::SCOPE_PARENT;
- } elseif ($_attr['scope'] == 'root') {
- $_scope = Smarty::SCOPE_ROOT;
- } elseif ($_attr['scope'] == 'global') {
- $_scope = Smarty::SCOPE_GLOBAL;
- } else {
- $compiler->trigger_template_error('illegal value for "scope" attribute', $compiler->lex->taglineno);
+ if (!isset($this->valid_scopes[$_attr['scope']])) {
+ $compiler->trigger_template_error("illegal value '{$_attr['scope']}' for \"scope\" attribute", null, true);
+ }
+ if ($_attr['scope'] != 'local') {
+ if ($_attr['scope'] == 'parent') {
+ $_scope = Smarty::SCOPE_PARENT;
+ } elseif ($_attr['scope'] == 'root') {
+ $_scope = Smarty::SCOPE_ROOT;
+ } elseif ($_attr['scope'] == 'global') {
+ $_scope = Smarty::SCOPE_GLOBAL;
+ } elseif ($_attr['scope'] == 'smarty') {
+ $_scope = Smarty::SCOPE_SMARTY;
+ } elseif ($_attr['scope'] == 'tpl_root') {
+ $_scope = Smarty::SCOPE_TPL_ROOT;
+ }
+ $_scope += (isset($_attr['bubble_up']) && $_attr['bubble_up'] == 'false') ? 0 : Smarty::SCOPE_BUBBLE_UP;
}
}
// compiled output
if (isset($parameter['smarty_internal_index'])) {
- $output = "<?php \$_smarty_tpl->createLocalArrayVariable($_attr[var], $_nocache, $_scope);\n\$_smarty_tpl->tpl_vars[$_attr[var]]->value$parameter[smarty_internal_index] = $_attr[value];";
+ $output =
+ "<?php \$_smarty_tpl->smarty->ext->_var->createLocalArrayVariable(\$_smarty_tpl, $_attr[var], $_nocache);\n\$_smarty_tpl->tpl_vars[$_attr[var]]->value$parameter[smarty_internal_index] = $_attr[value];";
} else {
// implement Smarty2's behaviour of variables assigned by reference
if ($compiler->template->smarty instanceof SmartyBC) {
- $output = "<?php if (isset(\$_smarty_tpl->tpl_vars[$_attr[var]])) {\$_smarty_tpl->tpl_vars[$_attr[var]] = clone \$_smarty_tpl->tpl_vars[$_attr[var]];";
- $output .= "\n\$_smarty_tpl->tpl_vars[$_attr[var]]->value = $_attr[value]; \$_smarty_tpl->tpl_vars[$_attr[var]]->nocache = $_nocache; \$_smarty_tpl->tpl_vars[$_attr[var]]->scope = $_scope;";
- $output .= "\n} else \$_smarty_tpl->tpl_vars[$_attr[var]] = new Smarty_Variable($_attr[value], $_nocache, $_scope);";
+ $output =
+ "<?php if (isset(\$_smarty_tpl->tpl_vars[$_attr[var]])) {\$_smarty_tpl->tpl_vars[$_attr[var]] = clone \$_smarty_tpl->tpl_vars[$_attr[var]];";
+ $output .= "\n\$_smarty_tpl->tpl_vars[$_attr[var]]->value = $_attr[value]; \$_smarty_tpl->tpl_vars[$_attr[var]]->nocache = $_nocache;";
+ $output .= "\n} else \$_smarty_tpl->tpl_vars[$_attr[var]] = new Smarty_Variable($_attr[value], $_nocache);";
} else {
- $output = "<?php \$_smarty_tpl->tpl_vars[$_attr[var]] = new Smarty_Variable($_attr[value], $_nocache, $_scope);";
+ $output = "<?php \$_smarty_tpl->tpl_vars[$_attr[var]] = new Smarty_Variable($_attr[value], $_nocache);";
}
}
- if ($_scope == Smarty::SCOPE_PARENT) {
- $output .= "\nif (\$_smarty_tpl->parent != null) \$_smarty_tpl->parent->tpl_vars[$_attr[var]] = clone \$_smarty_tpl->tpl_vars[$_attr[var]];";
- } elseif ($_scope == Smarty::SCOPE_ROOT || $_scope == Smarty::SCOPE_GLOBAL) {
- $output .= "\n\$_ptr = \$_smarty_tpl->parent; while (\$_ptr != null) {\$_ptr->tpl_vars[$_attr[var]] = clone \$_smarty_tpl->tpl_vars[$_attr[var]]; \$_ptr = \$_ptr->parent; }";
- }
- if ($_scope == Smarty::SCOPE_GLOBAL) {
- $output .= "\nSmarty::\$global_tpl_vars[$_attr[var]] = clone \$_smarty_tpl->tpl_vars[$_attr[var]];";
- }
+ $output .= "\n\$_smarty_tpl->ext->_updateScope->updateScope(\$_smarty_tpl, $_attr[var], $_scope);";
$output .= '?>';
return $output;
diff --git a/library/Smarty/libs/sysplugins/smarty_internal_compile_block.php b/library/Smarty/libs/sysplugins/smarty_internal_compile_block.php
index 93c90a91e..52a541ebd 100644
--- a/library/Smarty/libs/sysplugins/smarty_internal_compile_block.php
+++ b/library/Smarty/libs/sysplugins/smarty_internal_compile_block.php
@@ -1,24 +1,20 @@
<?php
-
-/**
- * Smarty Internal Plugin Compile Block
- * Compiles the {block}{/block} tags
+/*
+ * This file is part of Smarty.
*
- * @package Smarty
- * @subpackage Compiler
- * @author Uwe Tews
+ * (c) 2015 Uwe Tews
+ *
+ * For the full copyright and license information, please view the LICENSE
+ * file that was distributed with this source code.
*/
/**
* Smarty Internal Plugin Compile Block Class
*
- * @package Smarty
- * @subpackage Compiler
+ * @author Uwe Tews <uwe.tews@googlemail.com>
*/
-class Smarty_Internal_Compile_Block extends Smarty_Internal_CompileBase
+class Smarty_Internal_Compile_Block extends Smarty_Internal_Compile_Shared_Inheritance
{
-
- const parent = '____SMARTY_BLOCK_PARENT____';
/**
* Attribute definition: Overwrites base class.
*
@@ -41,7 +37,7 @@ class Smarty_Internal_Compile_Block extends Smarty_Internal_CompileBase
* @var array
* @see Smarty_Internal_CompileBase
*/
- public $option_flags = array('hide', 'append', 'prepend', 'nocache');
+ public $option_flags = array('hide', 'nocache');
/**
* Attribute definition: Overwrites base class.
@@ -49,395 +45,248 @@ class Smarty_Internal_Compile_Block extends Smarty_Internal_CompileBase
* @var array
* @see Smarty_Internal_CompileBase
*/
- public $optional_attributes = array('internal_file', 'internal_uid', 'internal_line');
+ public $optional_attributes = array('assign');
+
/**
- * nested child block names
+ * nesting level of block tags
*
- * @var array
+ * @var int
*/
- public static $nested_block_names = array();
+ public static $blockTagNestingLevel = 0;
/**
- * child block source buffer
+ * Saved compiler object
*
- * @var array
+ * @var Smarty_Internal_TemplateCompilerBase
*/
- public static $block_data = array();
+ public $compiler = null;
/**
* Compiles code for the {block} tag
*
- * @param array $args array with attributes from parser
- * @param object $compiler compiler object
+ * @param array $args array with attributes from parser
+ * @param \Smarty_Internal_TemplateCompilerBase $compiler compiler object
+ * @param array $parameter array with compilation parameter
*
- * @return boolean true
+ * @return bool true
*/
- public function compile($args, $compiler)
+ public function compile($args, Smarty_Internal_TemplateCompilerBase $compiler, $parameter)
{
- // check and get attributes
- $_attr = $this->getAttributes($compiler, $args);
- $_name = trim($_attr['name'], "\"'");
-
- // existing child must override parent settings
- if (isset($compiler->template->block_data[$_name]) && $compiler->template->block_data[$_name]['mode'] == 'replace') {
- $_attr['append'] = false;
- $_attr['prepend'] = false;
+ if (!isset($compiler->_cache['blockNesting'])) {
+ $compiler->_cache['blockNesting'] = 0;
}
-
- // check if we process an inheritance child template
- if ($compiler->inheritance_child) {
- array_unshift(self::$nested_block_names, $_name);
- // build {block} for child block
- self::$block_data[$_name]['source'] =
- "{$compiler->smarty->left_delimiter}private_child_block name={$_attr['name']} file='{$compiler->template->source->filepath}' type='{$compiler->template->source->type}' resource='{$compiler->template->template_resource}'" .
- " uid='{$compiler->template->source->uid}' line={$compiler->lex->line}";
- if ($_attr['nocache']) {
- self::$block_data[$_name]['source'] .= ' nocache';
- }
- self::$block_data[$_name]['source'] .= $compiler->smarty->right_delimiter;
-
- $save = array($_attr, $compiler->inheritance);
- $this->openTag($compiler, 'block', $save);
- // set flag for {block} tag
- $compiler->inheritance = true;
- $compiler->lex->yypushstate(Smarty_Internal_Templatelexer::CHILDBLOCK);
- $compiler->has_code = false;
- return;
+ if ($compiler->_cache['blockNesting'] == 0) {
+ // make sure that inheritance gets initialized in template code
+ $this->registerInit($compiler);
+ $this->option_flags = array('hide', 'nocache', 'append', 'prepend');
+ } else {
+ $this->option_flags = array('hide', 'nocache');
}
- // must merge includes
- if ($_attr['nocache'] == true) {
- $compiler->tag_nocache = true;
+ // check and get attributes
+ $_attr = $this->getAttributes($compiler, $args);
+ $compiler->_cache['blockNesting'] ++;
+ $compiler->_cache['blockName'][$compiler->_cache['blockNesting']] = $_attr['name'];
+ $compiler->_cache['blockParams'][$compiler->_cache['blockNesting']][0] = 'block_' . preg_replace('![^\w]+!', '_', uniqid(rand(), true));
+ $compiler->_cache['blockParams'][$compiler->_cache['blockNesting']][1] = false;
+ $this->openTag($compiler, 'block', array($_attr, $compiler->nocache, $compiler->parser->current_buffer,
+ $compiler->template->compiled->has_nocache_code,
+ $compiler->template->caching));
+ // must whole block be nocache ?
+ if ($compiler->tag_nocache) {
+ $i = 0;
}
- $save = array($_attr, $compiler->inheritance, $compiler->parser->current_buffer, $compiler->nocache);
- $this->openTag($compiler, 'block', $save);
- $compiler->inheritance = true;
$compiler->nocache = $compiler->nocache | $compiler->tag_nocache;
-
- $compiler->parser->current_buffer = new Smarty_Internal_ParseTree_Template($compiler->parser);
- $compiler->has_code = false;
-
- return true;
+ // $compiler->suppressNocacheProcessing = true;
+ if ($_attr['nocache'] === true) {
+ //$compiler->trigger_template_error('nocache option not allowed', $compiler->parser->lex->taglineno);
+ }
+ $compiler->parser->current_buffer = new Smarty_Internal_ParseTree_Template();
+ $compiler->template->compiled->has_nocache_code = false;
+ $compiler->suppressNocacheProcessing = true;
}
/**
* Compile saved child block source
*
- * @param object $compiler compiler object
- * @param string $_name optional name of child block
+ * @param \Smarty_Internal_TemplateCompilerBase compiler object
+ * @param string $_name optional name of child block
*
* @return string compiled code of child block
*/
- static function compileChildBlock($compiler, $_name = null)
+ static function compileChildBlock(Smarty_Internal_TemplateCompilerBase $compiler, $_name = null)
{
- if ($compiler->inheritance_child) {
- $name1 = Smarty_Internal_Compile_Block::$nested_block_names[0];
- if (isset($compiler->template->block_data[$name1])) {
- // replace inner block name with generic
- Smarty_Internal_Compile_Block::$block_data[$name1]['source'] .= $compiler->template->block_data[$name1]['source'];
- Smarty_Internal_Compile_Block::$block_data[$name1]['child'] = true;
- }
- $compiler->lex->yypushstate(Smarty_Internal_Templatelexer::CHILDBLOCK);
- $compiler->has_code = false;
- return;
- }
- // if called by {$smarty.block.child} we must search the name of enclosing {block}
- if ($_name == null) {
- $stack_count = count($compiler->_tag_stack);
- while (-- $stack_count >= 0) {
- if ($compiler->_tag_stack[$stack_count][0] == 'block') {
- $_name = trim($compiler->_tag_stack[$stack_count][1][0]['name'], "\"'");
- break;
- }
- }
- }
- if ($_name == null) {
- $compiler->trigger_template_error(' tag {$smarty.block.child} used outside {block} tags ', $compiler->lex->taglineno);
- }
- // undefined child?
- if (!isset($compiler->template->block_data[$_name]['source'])) {
- $compiler->popTrace();
- return '';
+ if (!isset($compiler->_cache['blockNesting'])) {
+ $compiler->trigger_template_error(' tag {$smarty.block.child} used outside {block} tags ',
+ $compiler->parser->lex->taglineno);
}
- // flag that child is already compile by {$smarty.block.child} inclusion
- $compiler->template->block_data[$_name]['compiled'] = true;
- $_tpl = new Smarty_Internal_template('string:' . $compiler->template->block_data[$_name]['source'], $compiler->smarty, $compiler->template, $compiler->template->cache_id,
- $compiler->template->compile_id, $compiler->template->caching, $compiler->template->cache_lifetime);
- if ($compiler->smarty->debugging) {
- Smarty_Internal_Debug::ignore($_tpl);
- }
- $_tpl->tpl_vars = $compiler->template->tpl_vars;
- $_tpl->variable_filters = $compiler->template->variable_filters;
- $_tpl->properties['nocache_hash'] = $compiler->template->properties['nocache_hash'];
- $_tpl->allow_relative_path = true;
- $_tpl->compiler->inheritance = true;
- $_tpl->compiler->suppressHeader = true;
- $_tpl->compiler->suppressFilter = true;
- $_tpl->compiler->suppressTemplatePropertyHeader = true;
- $nocache = $compiler->nocache || $compiler->tag_nocache;
- if (strpos($compiler->template->block_data[$_name]['source'], self::parent) !== false) {
- $_output = str_replace(self::parent, $compiler->parser->current_buffer->to_smarty_php(), $_tpl->compiler->compileTemplate($_tpl, $nocache, $compiler->parent_compiler));
- } elseif ($compiler->template->block_data[$_name]['mode'] == 'prepend') {
- $_output = $_tpl->compiler->compileTemplate($_tpl, $nocache, $compiler->parent_compiler) . $compiler->parser->current_buffer->to_smarty_php();
- } elseif ($compiler->template->block_data[$_name]['mode'] == 'append') {
- $_output = $compiler->parser->current_buffer->to_smarty_php() . $_tpl->compiler->compileTemplate($_tpl, $nocache, $compiler->parent_compiler);
- } elseif (!empty($compiler->template->block_data[$_name])) {
- $_output = $_tpl->compiler->compileTemplate($_tpl, $nocache, $compiler->parent_compiler);
- }
- $compiler->template->properties['file_dependency'] = array_merge($compiler->template->properties['file_dependency'], $_tpl->properties['file_dependency']);
- $compiler->template->properties['tpl_function'] = array_merge($compiler->template->properties['tpl_function'], $_tpl->properties['tpl_function']);
- $compiler->template->variable_filters = $_tpl->variable_filters;
- if ($_tpl->has_nocache_code) {
- $compiler->template->has_nocache_code = true;
- }
- foreach ($_tpl->required_plugins as $key => $tmp1) {
- if ($compiler->nocache && $compiler->template->caching) {
- $code = 'nocache';
- } else {
- $code = $key;
- }
- foreach ($tmp1 as $name => $tmp) {
- foreach ($tmp as $type => $data) {
- $compiler->template->required_plugins[$code][$name][$type] = $data;
- }
- }
- }
- unset($_tpl);
$compiler->has_code = true;
- return $_output;
+ $compiler->suppressNocacheProcessing = true;
+ $compiler->_cache['blockParams'][$compiler->_cache['blockNesting']][1] = true;
+ $output = "<?php \n\$_smarty_tpl->ext->_inheritance->processBlock(\$_smarty_tpl, 2, {$compiler->_cache['blockName'][$compiler->_cache['blockNesting']]}, null, \$_blockParentStack);\n?>\n";
+ return $output;
}
/**
* Compile $smarty.block.parent
*
- * @param object $compiler compiler object
- * @param string $_name optional name of child block
+ * @param \Smarty_Internal_TemplateCompilerBase $compiler compiler object
+ * @param string $_name optional name of child block
*
* @return string compiled code of child block
*/
- static function compileParentBlock($compiler, $_name = null)
+ static function compileParentBlock(Smarty_Internal_TemplateCompilerBase $compiler, $_name = null)
{
- // if called by {$smarty.block.parent} we must search the name of enclosing {block}
- if ($_name == null) {
- $stack_count = count($compiler->_tag_stack);
- while (-- $stack_count >= 0) {
- if ($compiler->_tag_stack[$stack_count][0] == 'block') {
- $_name = trim($compiler->_tag_stack[$stack_count][1][0]['name'], "\"'");
- break;
- }
- }
- }
- if ($_name == null) {
- $compiler->trigger_template_error(' tag {$smarty.block.parent} used outside {block} tags ', $compiler->lex->taglineno);
- }
- if (empty(Smarty_Internal_Compile_Block::$nested_block_names)) {
- $compiler->trigger_template_error(' illegal {$smarty.block.parent} in parent template ', $compiler->lex->taglineno);
+ if (!isset($compiler->_cache['blockNesting'])) {
+ $compiler->trigger_template_error(' tag {$smarty.block.parent} used outside {block} tags ',
+ $compiler->parser->lex->taglineno);
}
- Smarty_Internal_Compile_Block::$block_data[Smarty_Internal_Compile_Block::$nested_block_names[0]]['source'] .= Smarty_Internal_Compile_Block::parent;
- $compiler->lex->yypushstate(Smarty_Internal_Templatelexer::CHILDBLOCK);
- $compiler->has_code = false;
- return;
- }
-
- /**
- * Process block source
- *
- * @param $compiler
- * @param string $source source text
- */
- static function blockSource($compiler, $source)
- {
- Smarty_Internal_Compile_Block::$block_data[Smarty_Internal_Compile_Block::$nested_block_names[0]]['source'] .= $source;
+ $compiler->suppressNocacheProcessing = true;
+ $compiler->has_code = true;
+ $output = "<?php \n\$_smarty_tpl->ext->_inheritance->processBlock(\$_smarty_tpl, 3, {$compiler->_cache['blockName'][$compiler->_cache['blockNesting']]}, null, \$_blockParentStack);\n?>\n";
+ return $output;
}
}
/**
* Smarty Internal Plugin Compile BlockClose Class
*
- * @package Smarty
- * @subpackage Compiler
*/
-class Smarty_Internal_Compile_Blockclose extends Smarty_Internal_CompileBase
+class Smarty_Internal_Compile_Blockclose extends Smarty_Internal_Compile_Shared_Inheritance
{
/**
* Compiles code for the {/block} tag
*
- * @param array $args array with attributes from parser
- * @param object $compiler compiler object
+ * @param array $args array with attributes from parser
+ * @param \Smarty_Internal_TemplateCompilerBase $compiler compiler object
+ * @param array $parameter array with compilation parameter
*
- * @return string compiled code
+ * @return bool true
*/
- public function compile($args, $compiler)
+ public function compile($args, Smarty_Internal_TemplateCompilerBase $compiler, $parameter)
{
- $compiler->has_code = true;
- // check and get attributes
- $_attr = $this->getAttributes($compiler, $args);
- $saved_data = $this->closeTag($compiler, array('block'));
- $_name = trim($saved_data[0]['name'], "\"'");
- // reset flag for {block} tag
- $compiler->inheritance = $saved_data[1];
- // check if we process an inheritance child template
- if ($compiler->inheritance_child) {
- $name1 = Smarty_Internal_Compile_Block::$nested_block_names[0];
- Smarty_Internal_Compile_Block::$block_data[$name1]['source'] .= "{$compiler->smarty->left_delimiter}/private_child_block{$compiler->smarty->right_delimiter}";
- array_shift(Smarty_Internal_Compile_Block::$nested_block_names);
- if (!empty(Smarty_Internal_Compile_Block::$nested_block_names)) {
- $name2 = Smarty_Internal_Compile_Block::$nested_block_names[0];
- if (isset($compiler->template->block_data[$name1]) || !$saved_data[0]['hide']) {
- if (isset(Smarty_Internal_Compile_Block::$block_data[$name1]['child']) || !isset($compiler->template->block_data[$name1])) {
- Smarty_Internal_Compile_Block::$block_data[$name2]['source'] .= Smarty_Internal_Compile_Block::$block_data[$name1]['source'];
- } else {
- if ($compiler->template->block_data[$name1]['mode'] == 'append') {
- Smarty_Internal_Compile_Block::$block_data[$name2]['source'] .= Smarty_Internal_Compile_Block::$block_data[$name1]['source'] . $compiler->template->block_data[$name1]['source'];
- } elseif ($compiler->template->block_data[$name1]['mode'] == 'prepend') {
- Smarty_Internal_Compile_Block::$block_data[$name2]['source'] .= $compiler->template->block_data[$name1]['source'] . Smarty_Internal_Compile_Block::$block_data[$name1]['source'];
- } else {
- Smarty_Internal_Compile_Block::$block_data[$name2]['source'] .= $compiler->template->block_data[$name1]['source'];
- }
- }
- }
- unset(Smarty_Internal_Compile_Block::$block_data[$name1]);
- $compiler->lex->yypushstate(Smarty_Internal_Templatelexer::CHILDBLOCK);
- } else {
- if (isset($compiler->template->block_data[$name1]) || !$saved_data[0]['hide']) {
- if (isset($compiler->template->block_data[$name1]) && !isset(Smarty_Internal_Compile_Block::$block_data[$name1]['child'])) {
- if (strpos($compiler->template->block_data[$name1]['source'], Smarty_Internal_Compile_Block::parent) !== false) {
- $compiler->template->block_data[$name1]['source'] =
- str_replace(Smarty_Internal_Compile_Block::parent, Smarty_Internal_Compile_Block::$block_data[$name1]['source'], $compiler->template->block_data[$name1]['source']);
- } elseif ($compiler->template->block_data[$name1]['mode'] == 'prepend') {
- $compiler->template->block_data[$name1]['source'] .= Smarty_Internal_Compile_Block::$block_data[$name1]['source'];
- } elseif ($compiler->template->block_data[$name1]['mode'] == 'append') {
- $compiler->template->block_data[$name1]['source'] = Smarty_Internal_Compile_Block::$block_data[$name1]['source'] . $compiler->template->block_data[$name1]['source'];
- }
- } else {
- $compiler->template->block_data[$name1]['source'] = Smarty_Internal_Compile_Block::$block_data[$name1]['source'];
- }
- $compiler->template->block_data[$name1]['mode'] = 'replace';
- if ($saved_data[0]['append']) {
- $compiler->template->block_data[$name1]['mode'] = 'append';
- }
- if ($saved_data[0]['prepend']) {
- $compiler->template->block_data[$name1]['mode'] = 'prepend';
- }
- }
- unset(Smarty_Internal_Compile_Block::$block_data[$name1]);
- $compiler->lex->yypushstate(Smarty_Internal_Templatelexer::CHILDBODY);
+ list($_attr, $_nocache, $_buffer, $_has_nocache_code, $_caching) = $this->closeTag($compiler, array('block'));
+ // init block parameter
+ $_block = $compiler->_cache['blockParams'][$compiler->_cache['blockNesting']];
+ unset($compiler->_cache['blockParams'][$compiler->_cache['blockNesting']]);
+ $_block[2] = $_block[3] = 0;
+ $_name = trim($_attr['name'], "'\"");
+ $_assign = isset($_attr['assign']) ? $_attr['assign'] : null;
+ unset($_attr['assign'], $_attr['name']);
+ foreach ($_attr as $name => $stat) {
+ if ((is_bool($stat) && $stat !== false) || (!is_bool($stat) && $stat != 'false')) {
+ $_block[$name] = is_string($stat) ? trim($stat, "'\"") : $stat;
}
- $compiler->has_code = false;
- return;
}
- if (isset($compiler->template->block_data[$_name]) && !isset($compiler->template->block_data[$_name]['compiled'])) {
- $_output = Smarty_Internal_Compile_Block::compileChildBlock($compiler, $_name);
- } else {
- if ($saved_data[0]['hide'] && !isset($compiler->template->block_data[$_name]['source'])) {
- $_output = '';
- } else {
- $_output = $compiler->parser->current_buffer->to_smarty_php();
+ $_funcName = $_block[0];
+ // get compiled block code
+ $_functionCode = $compiler->parser->current_buffer;
+ // setup buffer for template function code
+ $compiler->parser->current_buffer = new Smarty_Internal_ParseTree_Template();
+
+ if ($compiler->template->compiled->has_nocache_code) {
+ // $compiler->parent_compiler->template->tpl_function[$_name]['call_name_caching'] = $_funcNameCaching;
+ $_block[6] = $_funcNameCaching = $_funcName . '_nocache';
+ $output = "<?php\n";
+ $output .= "/* {block '{$_name}'} {$compiler->template->source->type}:{$compiler->template->source->name} */\n";
+ $output .= "function {$_funcNameCaching} (\$_smarty_tpl, \$_blockParentStack) {\n";
+ $output .= "/*/%%SmartyNocache:{$compiler->template->compiled->nocache_hash}%%*/\n";
+ $output .= "\$_smarty_tpl->cached->hashes['{$compiler->template->compiled->nocache_hash}'] = true;\n";
+ if (isset($_assign)) {
+ $output .= "ob_start();\n";
+ }
+ $output .= "?>\n";
+ $compiler->parser->current_buffer->append_subtree($compiler->parser,
+ new Smarty_Internal_ParseTree_Tag($compiler->parser,
+ $output));
+ $compiler->parser->current_buffer->append_subtree($compiler->parser, $_functionCode);
+ $output = "<?php\n";
+ if (isset($_assign)) {
+ $output .= "\$_smarty_tpl->tpl_vars[{$_assign}] = new Smarty_Variable(ob_get_clean());\n";
}
+ $output .= "/*%%SmartyNocache:{$compiler->template->compiled->nocache_hash}%%*/\n";
+ $output .= "}\n";
+ $output .= "/* {/block '{$_name}'} */\n\n";
+ $output .= "?>\n";
+ $compiler->parser->current_buffer->append_subtree($compiler->parser,
+ new Smarty_Internal_ParseTree_Tag($compiler->parser,
+ $output));
+ $compiler->blockOrFunctionCode .= $f = $compiler->parser->current_buffer->to_smarty_php($compiler->parser);
+ $compiler->parser->current_buffer = new Smarty_Internal_ParseTree_Template();
+ $this->compiler = $compiler;
+ $_functionCode = new Smarty_Internal_ParseTree_Tag($compiler->parser,
+ preg_replace_callback("/((<\?php )?echo '\/\*%%SmartyNocache:{$compiler->template->compiled->nocache_hash}%%\*\/([\S\s]*?)\/\*\/%%SmartyNocache:{$compiler->template->compiled->nocache_hash}%%\*\/';(\?>\n)?)/",
+ array($this, 'removeNocache'),
+ $_functionCode->to_smarty_php($compiler->parser)));
+ $this->compiler = null;
}
- if (isset($compiler->template->block_data[$_name]['compiled'])) {
- unset($compiler->template->block_data[$_name]['compiled']);
+ $output = "<?php\n";
+ $output .= "/* {block '{$_name}'} {$compiler->template->source->type}:{$compiler->template->source->name} */\n";
+ $output .= "function {$_funcName}(\$_smarty_tpl, \$_blockParentStack) {\n";
+ if (isset($_assign)) {
+ $output .= "ob_start();\n";
}
- // reset flags
- $compiler->parser->current_buffer = $saved_data[2];
- if ($compiler->nocache) {
- $compiler->tag_nocache = true;
+ $output .= "?>\n";
+ $compiler->parser->current_buffer->append_subtree($compiler->parser,
+ new Smarty_Internal_ParseTree_Tag($compiler->parser,
+ $output));
+ $compiler->parser->current_buffer->append_subtree($compiler->parser, $_functionCode);
+ $output = "<?php\n";
+ if (isset($_assign)) {
+ $output .= "\$_smarty_tpl->tpl_vars[{$_assign}] = new Smarty_Variable(ob_get_clean());\n";
+ }
+ $output .= "}\n";
+ $output .= "/* {/block '{$_name}'} */\n\n";
+ $output .= "?>\n";
+ $compiler->parser->current_buffer->append_subtree($compiler->parser,
+ new Smarty_Internal_ParseTree_Tag($compiler->parser,
+ $output));
+ $compiler->blockOrFunctionCode .= $compiler->parser->current_buffer->to_smarty_php($compiler->parser);
+ // nocache plugins must be copied
+ if (!empty($compiler->template->compiled->required_plugins['nocache'])) {
+ foreach ($compiler->template->compiled->required_plugins['nocache'] as $plugin => $tmp) {
+ foreach ($tmp as $type => $data) {
+ $compiler->parent_compiler->template->compiled->required_plugins['compiled'][$plugin][$type] =
+ $data;
+ }
+ }
}
- $compiler->nocache = $saved_data[3];
- // $_output content has already nocache code processed
- $compiler->suppressNocacheProcessing = true;
-
- return $_output;
- }
-}
-
-/**
- * Smarty Internal Plugin Compile Child Block Class
- *
- * @package Smarty
- * @subpackage Compiler
- */
-class Smarty_Internal_Compile_Private_Child_Block extends Smarty_Internal_CompileBase
-{
- /**
- * Attribute definition: Overwrites base class.
- *
- * @var array
- * @see Smarty_Internal_CompileBase
- */
- public $required_attributes = array('name', 'file', 'uid', 'line', 'type', 'resource');
- /**
- * Compiles code for the {private_child_block} tag
- *
- * @param array $args array with attributes from parser
- * @param object $compiler compiler object
- *
- * @return boolean true
- */
- public function compile($args, $compiler)
- {
- // check and get attributes
- $_attr = $this->getAttributes($compiler, $args);
-
- // update template with original template resource of {block}
- if (trim($_attr['type'], "'") == 'file') {
- $compiler->template->template_resource = 'file:' . realpath(trim($_attr['file'], "'"));
+ // restore old status
+ $compiler->template->compiled->has_nocache_code = $_has_nocache_code;
+ $compiler->tag_nocache = $compiler->nocache;
+ $compiler->nocache = $_nocache;
+ $compiler->parser->current_buffer = $_buffer;
+ $output = "<?php \n";
+ if ($compiler->_cache['blockNesting'] == 1) {
+ $output .= "\$_smarty_tpl->ext->_inheritance->processBlock(\$_smarty_tpl, 0, {$compiler->_cache['blockName'][$compiler->_cache['blockNesting']]}, " .
+ var_export($_block, true) . ");\n";
} else {
- $compiler->template->template_resource = trim($_attr['resource'], "'");
- }
- // source object
- unset ($compiler->template->source);
- $exists = $compiler->template->source->exists;
+ $output .= "\$_smarty_tpl->ext->_inheritance->processBlock(\$_smarty_tpl, 0, {$compiler->_cache['blockName'][$compiler->_cache['blockNesting']]}, " .
+ var_export($_block, true) . ", \$_blockParentStack);\n";
- // must merge includes
- if ($_attr['nocache'] == true) {
- $compiler->tag_nocache = true;
}
- $save = array($_attr, $compiler->nocache);
-
- // set trace back to child block
- $compiler->pushTrace(trim($_attr['file'], "\"'"), trim($_attr['uid'], "\"'"), $_attr['line'] - $compiler->lex->line);
-
- $this->openTag($compiler, 'private_child_block', $save);
-
- $compiler->nocache = $compiler->nocache | $compiler->tag_nocache;
- $compiler->has_code = false;
-
- return true;
+ $output .= "?>\n";
+ $compiler->_cache['blockNesting'] --;
+ if ($compiler->_cache['blockNesting'] == 0) {
+ unset($compiler->_cache['blockNesting']);
+ }
+ $compiler->has_code = true;
+ $compiler->suppressNocacheProcessing = true;
+ return $output;
}
-}
-
-/**
- * Smarty Internal Plugin Compile Child Block Close Class
- *
- * @package Smarty
- * @subpackage Compiler
- */
-class Smarty_Internal_Compile_Private_Child_Blockclose extends Smarty_Internal_CompileBase
-{
/**
- * Compiles code for the {/private_child_block} tag
- *
- * @param array $args array with attributes from parser
- * @param object $compiler compiler object
+ * @param $match
*
- * @return boolean true
+ * @return mixed
*/
- public function compile($args, $compiler)
+ function removeNocache($match)
{
- // check and get attributes
- $_attr = $this->getAttributes($compiler, $args);
-
- $saved_data = $this->closeTag($compiler, array('private_child_block'));
-
- // end of child block
- $compiler->popTrace();
-
- $compiler->nocache = $saved_data[1];
- $compiler->has_code = false;
-
- return true;
+ $code =
+ preg_replace("/((<\?php )?echo '\/\*%%SmartyNocache:{$this->compiler->template->compiled->nocache_hash}%%\*\/)|(\/\*\/%%SmartyNocache:{$this->compiler->template->compiled->nocache_hash}%%\*\/';(\?>\n)?)/",
+ '', $match[0]);
+ $code = str_replace(array('\\\'', '\\\\\''), array('\'', '\\\''), $code);
+ return $code;
}
}
diff --git a/library/Smarty/libs/sysplugins/smarty_internal_compile_break.php b/library/Smarty/libs/sysplugins/smarty_internal_compile_break.php
index b51e9e8f3..cbc73d36a 100644
--- a/library/Smarty/libs/sysplugins/smarty_internal_compile_break.php
+++ b/library/Smarty/libs/sysplugins/smarty_internal_compile_break.php
@@ -23,6 +23,7 @@ class Smarty_Internal_Compile_Break extends Smarty_Internal_CompileBase
* @see Smarty_Internal_CompileBase
*/
public $optional_attributes = array('levels');
+
/**
* Attribute definition: Overwrites base class.
*
@@ -34,25 +35,26 @@ class Smarty_Internal_Compile_Break extends Smarty_Internal_CompileBase
/**
* Compiles code for the {break} tag
*
- * @param array $args array with attributes from parser
- * @param object $compiler compiler object
- * @param array $parameter array with compilation parameter
+ * @param array $args array with attributes from parser
+ * @param \Smarty_Internal_TemplateCompilerBase $compiler compiler object
+ * @param array $parameter array with compilation parameter
*
* @return string compiled code
+ * @throws \SmartyCompilerException
*/
- public function compile($args, $compiler, $parameter)
+ public function compile($args, Smarty_Internal_TemplateCompilerBase $compiler, $parameter)
{
static $_is_loopy = array('for' => true, 'foreach' => true, 'while' => true, 'section' => true);
// check and get attributes
$_attr = $this->getAttributes($compiler, $args);
if ($_attr['nocache'] === true) {
- $compiler->trigger_template_error('nocache option not allowed', $compiler->lex->taglineno);
+ $compiler->trigger_template_error('nocache option not allowed', null, true);
}
if (isset($_attr['levels'])) {
if (!is_numeric($_attr['levels'])) {
- $compiler->trigger_template_error('level attribute must be a numeric constant', $compiler->lex->taglineno);
+ $compiler->trigger_template_error('level attribute must be a numeric constant', null, true);
}
$_levels = $_attr['levels'];
} else {
@@ -67,7 +69,7 @@ class Smarty_Internal_Compile_Break extends Smarty_Internal_CompileBase
$stack_count --;
}
if ($level_count != 0) {
- $compiler->trigger_template_error("cannot break {$_levels} level(s)", $compiler->lex->taglineno);
+ $compiler->trigger_template_error("cannot break {$_levels} level(s)", null, true);
}
return "<?php break {$_levels};?>";
diff --git a/library/Smarty/libs/sysplugins/smarty_internal_compile_call.php b/library/Smarty/libs/sysplugins/smarty_internal_compile_call.php
index 05420fa5f..b7204bec0 100644
--- a/library/Smarty/libs/sysplugins/smarty_internal_compile_call.php
+++ b/library/Smarty/libs/sysplugins/smarty_internal_compile_call.php
@@ -23,6 +23,7 @@ class Smarty_Internal_Compile_Call extends Smarty_Internal_CompileBase
* @see Smarty_Internal_CompileBase
*/
public $required_attributes = array('name');
+
/**
* Attribute definition: Overwrites base class.
*
@@ -30,6 +31,7 @@ class Smarty_Internal_Compile_Call extends Smarty_Internal_CompileBase
* @see Smarty_Internal_CompileBase
*/
public $shorttag_order = array('name');
+
/**
* Attribute definition: Overwrites base class.
*
@@ -76,9 +78,11 @@ class Smarty_Internal_Compile_Call extends Smarty_Internal_CompileBase
//$compiler->suppressNocacheProcessing = true;
// was there an assign attribute
if (isset($_assign)) {
- $_output = "<?php ob_start();\$_smarty_tpl->callTemplateFunction ({$_name}, \$_smarty_tpl, {$_params}, {$_nocache}); \$_smarty_tpl->assign({$_assign}, ob_get_clean());?>\n";
+ $_output =
+ "<?php ob_start();\n\$_smarty_tpl->smarty->ext->_tplFunction->callTemplateFunction(\$_smarty_tpl, {$_name}, {$_params}, {$_nocache});\n\$_smarty_tpl->assign({$_assign}, ob_get_clean());?>\n";
} else {
- $_output = "<?php \$_smarty_tpl->callTemplateFunction ({$_name}, \$_smarty_tpl, {$_params}, {$_nocache});?>\n";
+ $_output =
+ "<?php \$_smarty_tpl->smarty->ext->_tplFunction->callTemplateFunction(\$_smarty_tpl, {$_name}, {$_params}, {$_nocache});?>\n";
}
return $_output;
}
diff --git a/library/Smarty/libs/sysplugins/smarty_internal_compile_capture.php b/library/Smarty/libs/sysplugins/smarty_internal_compile_capture.php
index 34728e47a..95c75a4b1 100644
--- a/library/Smarty/libs/sysplugins/smarty_internal_compile_capture.php
+++ b/library/Smarty/libs/sysplugins/smarty_internal_compile_capture.php
@@ -23,6 +23,7 @@ class Smarty_Internal_Compile_Capture extends Smarty_Internal_CompileBase
* @see Smarty_Internal_CompileBase
*/
public $shorttag_order = array('name');
+
/**
* Attribute definition: Overwrites base class.
*
@@ -34,12 +35,12 @@ class Smarty_Internal_Compile_Capture extends Smarty_Internal_CompileBase
/**
* Compiles code for the {capture} tag
*
- * @param array $args array with attributes from parser
- * @param object $compiler compiler object
+ * @param array $args array with attributes from parser
+ * @param \Smarty_Internal_TemplateCompilerBase $compiler compiler object
*
* @return string compiled code
*/
- public function compile($args, $compiler)
+ public function compile($args, Smarty_Internal_TemplateCompilerBase $compiler)
{
// check and get attributes
$_attr = $this->getAttributes($compiler, $args);
@@ -51,10 +52,31 @@ class Smarty_Internal_Compile_Capture extends Smarty_Internal_CompileBase
$compiler->_capture_stack[0][] = array($buffer, $assign, $append, $compiler->nocache);
// maybe nocache because of nocache variables
$compiler->nocache = $compiler->nocache | $compiler->tag_nocache;
- $_output = "<?php \$_smarty_tpl->_capture_stack[0][] = array($buffer, $assign, $append); ob_start(); ?>";
+ $_output = "<?php \$_smarty_tpl->_cache['capture_stack'][] = array($buffer, $assign, $append); ob_start(); ?>";
return $_output;
}
+
+ /**
+ * Compiles code for the {$smarty.capture.xxx}
+ *
+ * @param array $args array with attributes from parser
+ * @param \Smarty_Internal_TemplateCompilerBase $compiler compiler object
+ * @param array $parameter array with compilation parameter
+ *
+ * @return string compiled code
+ * @throws \SmartyCompilerException
+ */
+ public static function compileSpecialVariable($args, Smarty_Internal_TemplateCompilerBase $compiler, $parameter)
+ {
+ // make all lower case
+ $parameter = array_map('strtolower', $parameter);
+ $tag = trim($parameter[0], '"\'');
+ if (!isset($parameter[1]) || false === $name = $compiler->getId($parameter[1])) {
+ $compiler->trigger_template_error("missing or illegal \$smarty.{$tag} name attribute", null, true);
+ }
+ return "isset(\$_smarty_tpl->_cache['__smarty_capture']['{$name}']) ? \$_smarty_tpl->_cache['__smarty_capture']['{$name}'] : null";
+ }
}
/**
@@ -68,12 +90,12 @@ class Smarty_Internal_Compile_CaptureClose extends Smarty_Internal_CompileBase
/**
* Compiles code for the {/capture} tag
*
- * @param array $args array with attributes from parser
- * @param object $compiler compiler object
+ * @param array $args array with attributes from parser
+ * @param \Smarty_Internal_TemplateCompilerBase $compiler compiler object
*
* @return string compiled code
*/
- public function compile($args, $compiler)
+ public function compile($args, Smarty_Internal_TemplateCompilerBase $compiler)
{
// check and get attributes
$_attr = $this->getAttributes($compiler, $args);
@@ -84,11 +106,11 @@ class Smarty_Internal_Compile_CaptureClose extends Smarty_Internal_CompileBase
list($buffer, $assign, $append, $compiler->nocache) = array_pop($compiler->_capture_stack[0]);
- $_output = "<?php list(\$_capture_buffer, \$_capture_assign, \$_capture_append) = array_pop(\$_smarty_tpl->_capture_stack[0]);\n";
+ $_output = "<?php list(\$_capture_buffer, \$_capture_assign, \$_capture_append) = array_pop(\$_smarty_tpl->_cache['capture_stack']);\n";
$_output .= "if (!empty(\$_capture_buffer)) {\n";
$_output .= " if (isset(\$_capture_assign)) \$_smarty_tpl->assign(\$_capture_assign, ob_get_contents());\n";
$_output .= " if (isset( \$_capture_append)) \$_smarty_tpl->append( \$_capture_append, ob_get_contents());\n";
- $_output .= " Smarty::\$_smarty_vars['capture'][\$_capture_buffer]=ob_get_clean();\n";
+ $_output .= "\$_smarty_tpl->_cache['__smarty_capture'][\$_capture_buffer]=ob_get_clean();\n";
$_output .= "} else \$_smarty_tpl->capture_error();?>";
return $_output;
diff --git a/library/Smarty/libs/sysplugins/smarty_internal_compile_config_load.php b/library/Smarty/libs/sysplugins/smarty_internal_compile_config_load.php
index 5b291bed1..d2e50a08f 100644
--- a/library/Smarty/libs/sysplugins/smarty_internal_compile_config_load.php
+++ b/library/Smarty/libs/sysplugins/smarty_internal_compile_config_load.php
@@ -23,6 +23,7 @@ class Smarty_Internal_Compile_Config_Load extends Smarty_Internal_CompileBase
* @see Smarty_Internal_CompileBase
*/
public $required_attributes = array('file');
+
/**
* Attribute definition: Overwrites base class.
*
@@ -30,30 +31,39 @@ class Smarty_Internal_Compile_Config_Load extends Smarty_Internal_CompileBase
* @see Smarty_Internal_CompileBase
*/
public $shorttag_order = array('file', 'section');
+
/**
* Attribute definition: Overwrites base class.
*
* @var array
* @see Smarty_Internal_CompileBase
*/
- public $optional_attributes = array('section', 'scope');
+ public $optional_attributes = array('section', 'scope', 'bubble_up');
+
+ /**
+ * Valid scope names
+ *
+ * @var array
+ */
+ public $valid_scopes = array('local' => true, 'parent' => true, 'root' => true, 'global' => true,
+ 'smarty' => true, 'tpl_root' => true);
/**
* Compiles code for the {config_load} tag
*
- * @param array $args array with attributes from parser
- * @param object $compiler compiler object
+ * @param array $args array with attributes from parser
+ * @param \Smarty_Internal_TemplateCompilerBase $compiler compiler object
*
* @return string compiled code
+ * @throws \SmartyCompilerException
*/
- public function compile($args, $compiler)
+ public function compile($args, Smarty_Internal_TemplateCompilerBase $compiler)
{
- static $_is_legal_scope = array('local' => true, 'parent' => true, 'root' => true, 'global' => true);
// check and get attributes
$_attr = $this->getAttributes($compiler, $args);
if ($_attr['nocache'] === true) {
- $compiler->trigger_template_error('nocache option not allowed', $compiler->lex->taglineno);
+ $compiler->trigger_template_error('nocache option not allowed', null, true);
}
// save possible attributes
@@ -63,18 +73,31 @@ class Smarty_Internal_Compile_Config_Load extends Smarty_Internal_CompileBase
} else {
$section = 'null';
}
- $scope = 'local';
- // scope setup
+ $_scope = Smarty::SCOPE_LOCAL;
if (isset($_attr['scope'])) {
$_attr['scope'] = trim($_attr['scope'], "'\"");
- if (isset($_is_legal_scope[$_attr['scope']])) {
- $scope = $_attr['scope'];
- } else {
- $compiler->trigger_template_error('illegal value for "scope" attribute', $compiler->lex->taglineno);
+ if (!isset($this->valid_scopes[$_attr['scope']])) {
+ $compiler->trigger_template_error("illegal value '{$_attr['scope']}' for \"scope\" attribute", null, true);
+ }
+ if ($_attr['scope'] != 'local') {
+ if ($_attr['scope'] == 'parent') {
+ $_scope = Smarty::SCOPE_PARENT;
+ } elseif ($_attr['scope'] == 'root') {
+ $_scope = Smarty::SCOPE_ROOT;
+ } elseif ($_attr['scope'] == 'global') {
+ $_scope = Smarty::SCOPE_GLOBAL;
+ } elseif ($_attr['scope'] == 'smarty') {
+ $_scope = Smarty::SCOPE_SMARTY;
+ } elseif ($_attr['scope'] == 'tpl_root') {
+ $_scope = Smarty::SCOPE_TPL_ROOT;
+ }
+ $_scope += (isset($_attr['bubble_up']) && $_attr['bubble_up'] == 'false') ? 0 : Smarty::SCOPE_BUBBLE_UP;
}
}
+
// create config object
- $_output = "<?php Smarty_Internal_Extension_Config::configLoad(\$_smarty_tpl, $conf_file, $section, '$scope');?>";
+ $_output =
+ "<?php\n\$_smarty_tpl->smarty->ext->configLoad->_loadConfigFile(\$_smarty_tpl, {$conf_file}, {$section}, {$_scope});\n?>\n";
return $_output;
}
diff --git a/library/Smarty/libs/sysplugins/smarty_internal_compile_continue.php b/library/Smarty/libs/sysplugins/smarty_internal_compile_continue.php
index af3765128..2ee04c94e 100644
--- a/library/Smarty/libs/sysplugins/smarty_internal_compile_continue.php
+++ b/library/Smarty/libs/sysplugins/smarty_internal_compile_continue.php
@@ -23,6 +23,7 @@ class Smarty_Internal_Compile_Continue extends Smarty_Internal_CompileBase
* @see Smarty_Internal_CompileBase
*/
public $optional_attributes = array('levels');
+
/**
* Attribute definition: Overwrites base class.
*
@@ -34,25 +35,26 @@ class Smarty_Internal_Compile_Continue extends Smarty_Internal_CompileBase
/**
* Compiles code for the {continue} tag
*
- * @param array $args array with attributes from parser
- * @param object $compiler compiler object
- * @param array $parameter array with compilation parameter
+ * @param array $args array with attributes from parser
+ * @param \Smarty_Internal_TemplateCompilerBase $compiler compiler object
+ * @param array $parameter array with compilation parameter
*
* @return string compiled code
+ * @throws \SmartyCompilerException
*/
- public function compile($args, $compiler, $parameter)
+ public function compile($args, Smarty_Internal_TemplateCompilerBase $compiler, $parameter)
{
static $_is_loopy = array('for' => true, 'foreach' => true, 'while' => true, 'section' => true);
// check and get attributes
$_attr = $this->getAttributes($compiler, $args);
if ($_attr['nocache'] === true) {
- $compiler->trigger_template_error('nocache option not allowed', $compiler->lex->taglineno);
+ $compiler->trigger_template_error('nocache option not allowed', null, true);
}
if (isset($_attr['levels'])) {
if (!is_numeric($_attr['levels'])) {
- $compiler->trigger_template_error('level attribute must be a numeric constant', $compiler->lex->taglineno);
+ $compiler->trigger_template_error('level attribute must be a numeric constant', null, true);
}
$_levels = $_attr['levels'];
} else {
@@ -67,7 +69,7 @@ class Smarty_Internal_Compile_Continue extends Smarty_Internal_CompileBase
$stack_count --;
}
if ($level_count != 0) {
- $compiler->trigger_template_error("cannot continue {$_levels} level(s)", $compiler->lex->taglineno);
+ $compiler->trigger_template_error("cannot continue {$_levels} level(s)", null, true);
}
return "<?php continue {$_levels};?>";
diff --git a/library/Smarty/libs/sysplugins/smarty_internal_compile_debug.php b/library/Smarty/libs/sysplugins/smarty_internal_compile_debug.php
index b184a746b..d73c81a10 100644
--- a/library/Smarty/libs/sysplugins/smarty_internal_compile_debug.php
+++ b/library/Smarty/libs/sysplugins/smarty_internal_compile_debug.php
@@ -34,8 +34,8 @@ class Smarty_Internal_Compile_Debug extends Smarty_Internal_CompileBase
$compiler->tag_nocache = true;
// display debug template
- $_output = "<?php \$_smarty_tpl->smarty->loadPlugin('Smarty_Internal_Debug'); Smarty_Internal_Debug::display_debug(\$_smarty_tpl); ?>";
-
+ $_output = "<?php \$_smarty_debug = new Smarty_Internal_Debug;\n \$_smarty_debug->display_debug(\$_smarty_tpl);\n";
+ $_output .= "unset(\$_smarty_debug);\n?>";
return $_output;
}
}
diff --git a/library/Smarty/libs/sysplugins/smarty_internal_compile_extends.php b/library/Smarty/libs/sysplugins/smarty_internal_compile_extends.php
index 2b541f2e3..7ce3dcf6f 100644
--- a/library/Smarty/libs/sysplugins/smarty_internal_compile_extends.php
+++ b/library/Smarty/libs/sysplugins/smarty_internal_compile_extends.php
@@ -15,7 +15,7 @@
* @package Smarty
* @subpackage Compiler
*/
-class Smarty_Internal_Compile_Extends extends Smarty_Internal_CompileBase
+class Smarty_Internal_Compile_Extends extends Smarty_Internal_Compile_Shared_Inheritance
{
/**
* Attribute definition: Overwrites base class.
@@ -24,6 +24,15 @@ class Smarty_Internal_Compile_Extends extends Smarty_Internal_CompileBase
* @see Smarty_Internal_CompileBase
*/
public $required_attributes = array('file');
+
+ /**
+ * Array of names of optional attribute required by tag
+ * use array('_any') if there is no restriction of attributes names
+ *
+ * @var array
+ */
+ public $optional_attributes = array('extends_resource');
+
/**
* Attribute definition: Overwrites base class.
*
@@ -33,53 +42,93 @@ class Smarty_Internal_Compile_Extends extends Smarty_Internal_CompileBase
public $shorttag_order = array('file');
/**
- * Compiles code for the {extends} tag
+ * Compiles code for the {extends} tag extends: resource
*
- * @param array $args array with attributes from parser
- * @param object $compiler compiler object
+ * @param array $args array with attributes from parser
+ * @param \Smarty_Internal_TemplateCompilerBase $compiler compiler object
*
* @return string compiled code
+ * @throws \SmartyCompilerException
+ * @throws \SmartyException
*/
- public function compile($args, $compiler)
+ public function compile($args, Smarty_Internal_TemplateCompilerBase $compiler)
{
// check and get attributes
$_attr = $this->getAttributes($compiler, $args);
if ($_attr['nocache'] === true) {
- $compiler->trigger_template_error('nocache option not allowed', $compiler->lex->taglineno);
+ $compiler->trigger_template_error('nocache option not allowed', $compiler->parser->lex->line - 1);
}
if (strpos($_attr['file'], '$_tmp') !== false) {
- $compiler->trigger_template_error('illegal value for file attribute', $compiler->lex->taglineno);
- }
-
- $name = $_attr['file'];
- /** @var Smarty_Internal_Template $_smarty_tpl
- * used in evaluated code
- */
- $_smarty_tpl = $compiler->template;
- eval("\$tpl_name = $name;");
- // create template object
- $_template = new $compiler->smarty->template_class($tpl_name, $compiler->smarty, $compiler->template);
- // check for recursion
- $uid = $_template->source->uid;
- if (isset($compiler->extends_uid[$uid])) {
- $compiler->trigger_template_error("illegal recursive call of \"$include_file\"", $compiler->lex->line - 1);
+ $compiler->trigger_template_error('illegal value for file attribute', $compiler->parser->lex->line - 1);
}
- $compiler->extends_uid[$uid] = true;
- if (empty($_template->source->components)) {
- array_unshift($compiler->sources, $_template->source);
- } else {
- foreach ($_template->source->components as $source) {
- array_unshift($compiler->sources, $source);
- $uid = $source->uid;
- if (isset($compiler->extends_uid[$uid])) {
- $compiler->trigger_template_error("illegal recursive call of \"{$source->filepath}\"", $compiler->lex->line - 1);
+ // add code to initialize inheritance
+ $this->registerInit($compiler, true);
+ $file = trim($_attr['file'], '\'"');
+ if (strlen($file) > 8 && substr($file, 0, 8) == 'extends:') {
+ // generate code for each template
+ $files = array_reverse(explode('|', substr($file, 8)));
+ $i = 0;
+ foreach ($files as $file) {
+ if ($file[0] == '"') {
+ $file = trim($file, '".');
+ } else {
+ $file = "'{$file}'";
+ }
+ $i ++;
+ if ($i == count($files) && isset($_attr['extends_resource'])) {
+ $this->compileEndChild($compiler);
}
- $compiler->extends_uid[$uid] = true;
+ $this->compileInclude($compiler, $file);
}
+ if (!isset($_attr['extends_resource'])) {
+ $this->compileEndChild($compiler);
+ }
+ } else {
+ $this->compileEndChild($compiler);
+ $this->compileInclude($compiler, $_attr['file']);
}
- unset ($_template);
- $compiler->inheritance_child = true;
- $compiler->lex->yypushstate(Smarty_Internal_Templatelexer::CHILDBODY);
+ $compiler->has_code = false;
return '';
}
+
+ /**
+ * Add code for inheritance endChild() method to end of template
+ *
+ * @param \Smarty_Internal_TemplateCompilerBase $compiler
+ */
+ private function compileEndChild(Smarty_Internal_TemplateCompilerBase $compiler)
+ {
+ $compiler->parser->template_postfix[] = new Smarty_Internal_ParseTree_Tag($compiler->parser,
+ "<?php \$_smarty_tpl->ext->_inheritance->endChild(\$_smarty_tpl);\n?>\n");
+ }
+
+ /**
+ * Add code for including subtemplate to end of template
+ *
+ * @param \Smarty_Internal_TemplateCompilerBase $compiler
+ * @param string $file subtemplate name
+ */
+ private function compileInclude(Smarty_Internal_TemplateCompilerBase $compiler, $file)
+ {
+ $compiler->parser->template_postfix[] = new Smarty_Internal_ParseTree_Tag($compiler->parser,
+ $compiler->compileTag('include',
+ array($file,
+ array('scope' => 'parent'))));
+ }
+
+ /**
+ * Create source code for {extends} from source components array
+ *
+ * @param []\Smarty_Internal_Template_Source $components
+ *
+ * @return string
+ */
+ public static function extendsSourceArrayCode($components)
+ {
+ $resources = array();
+ foreach ($components as $source) {
+ $resources[] = $source->resource;
+ }
+ return '{extends file=\'extends:' . join('|', $resources) . '\' extends_resource=true}';
+ }
}
diff --git a/library/Smarty/libs/sysplugins/smarty_internal_compile_for.php b/library/Smarty/libs/sysplugins/smarty_internal_compile_for.php
index 5bac55011..7b86d4859 100644
--- a/library/Smarty/libs/sysplugins/smarty_internal_compile_for.php
+++ b/library/Smarty/libs/sysplugins/smarty_internal_compile_for.php
@@ -34,6 +34,7 @@ class Smarty_Internal_Compile_For extends Smarty_Internal_CompileBase
*/
public function compile($args, $compiler, $parameter)
{
+ $compiler->loopNesting++;
if ($parameter == 0) {
$this->required_attributes = array('start', 'to');
$this->optional_attributes = array('max', 'step');
@@ -44,7 +45,7 @@ class Smarty_Internal_Compile_For extends Smarty_Internal_CompileBase
// check and get attributes
$_attr = $this->getAttributes($compiler, $args);
- $output = "<?php ";
+ $output = "<?php\n";
if ($parameter == 1) {
foreach ($_attr['start'] as $_statement) {
if (is_array($_statement['var'])) {
@@ -54,8 +55,8 @@ class Smarty_Internal_Compile_For extends Smarty_Internal_CompileBase
$var = $_statement['var'];
$index = '';
}
- $output .= " \$_smarty_tpl->tpl_vars[$var] = new Smarty_Variable;";
- $output .= " \$_smarty_tpl->tpl_vars[$var]->value{$index} = $_statement[value];\n";
+ $output .= "\$_smarty_tpl->tpl_vars[$var] = new Smarty_Variable;\n";
+ $output .= "\$_smarty_tpl->tpl_vars[$var]->value{$index} = {$_statement['value']};\n";
}
if (is_array($_attr['var'])) {
$var = $_attr['var']['var'];
@@ -64,7 +65,7 @@ class Smarty_Internal_Compile_For extends Smarty_Internal_CompileBase
$var = $_attr['var'];
$index = '';
}
- $output .= " if ($_attr[ifexp]) { for (\$_foo=true;$_attr[ifexp]; \$_smarty_tpl->tpl_vars[$var]->value{$index}$_attr[step]) {\n";
+ $output .= "if ($_attr[ifexp]) {\nfor (\$_foo=true;$_attr[ifexp]; \$_smarty_tpl->tpl_vars[$var]->value{$index}$_attr[step]) {\n";
} else {
$_statement = $_attr['start'];
if (is_array($_statement['var'])) {
@@ -148,6 +149,7 @@ class Smarty_Internal_Compile_Forclose extends Smarty_Internal_CompileBase
*/
public function compile($args, $compiler, $parameter)
{
+ $compiler->loopNesting--;
// check and get attributes
$_attr = $this->getAttributes($compiler, $args);
// must endblock be nocache?
@@ -157,10 +159,11 @@ class Smarty_Internal_Compile_Forclose extends Smarty_Internal_CompileBase
list($openTag, $compiler->nocache) = $this->closeTag($compiler, array('for', 'forelse'));
- if ($openTag == 'forelse') {
- return "<?php } ?>";
- } else {
- return "<?php }} ?>";
- }
+ $output = "<?php }\n";
+ if ($openTag != 'forelse') {
+ $output .= "}\n";
+ }
+ $output .= "?>\n";
+ return $output;
}
}
diff --git a/library/Smarty/libs/sysplugins/smarty_internal_compile_foreach.php b/library/Smarty/libs/sysplugins/smarty_internal_compile_foreach.php
index 82ea49637..876ed026a 100644
--- a/library/Smarty/libs/sysplugins/smarty_internal_compile_foreach.php
+++ b/library/Smarty/libs/sysplugins/smarty_internal_compile_foreach.php
@@ -14,7 +14,7 @@
* @package Smarty
* @subpackage Compiler
*/
-class Smarty_Internal_Compile_Foreach extends Smarty_Internal_CompileBase
+class Smarty_Internal_Compile_Foreach extends Smarty_Internal_Compile_Private_ForeachSection
{
/**
* Attribute definition: Overwrites base class.
@@ -23,6 +23,7 @@ class Smarty_Internal_Compile_Foreach extends Smarty_Internal_CompileBase
* @see Smarty_Internal_CompileBase
*/
public $required_attributes = array('from', 'item');
+
/**
* Attribute definition: Overwrites base class.
*
@@ -30,6 +31,7 @@ class Smarty_Internal_Compile_Foreach extends Smarty_Internal_CompileBase
* @see Smarty_Internal_CompileBase
*/
public $optional_attributes = array('name', 'key');
+
/**
* Attribute definition: Overwrites base class.
*
@@ -39,177 +41,228 @@ class Smarty_Internal_Compile_Foreach extends Smarty_Internal_CompileBase
public $shorttag_order = array('from', 'item', 'key', 'name');
/**
+ * counter
+ *
+ * @var int
+ */
+ public $counter = 0;
+
+ /**
+ * Name of this tag
+ *
+ * @var string
+ */
+ public $tagName = 'foreach';
+
+ /**
+ * Valid properties of $smarty.foreach.name.xxx variable
+ *
+ * @var array
+ */
+ public static $nameProperties = array('first', 'last', 'index', 'iteration', 'show', 'total');
+
+ /**
+ * Valid properties of $item@xxx variable
+ *
+ * @var array
+ */
+ public $itemProperties = array('first', 'last', 'index', 'iteration', 'show', 'total', 'key');
+
+ /**
+ * Flag if tag had name attribute
+ *
+ * @var bool
+ */
+ public $isNamed = false;
+
+ /**
* Compiles code for the {foreach} tag
*
- * @param array $args array with attributes from parser
- * @param object $compiler compiler object
- * @param array $parameter array with compilation parameter
+ * @param array $args array with attributes from parser
+ * @param \Smarty_Internal_TemplateCompilerBase $compiler compiler object
+ * @param array $parameter array with compilation parameter
*
* @return string compiled code
+ * @throws \SmartyCompilerException
*/
- public function compile($args, $compiler, $parameter)
+ public function compile($args, Smarty_Internal_TemplateCompilerBase $compiler, $parameter)
{
+ $compiler->loopNesting ++;
+ // init
+ $this->isNamed = false;
// check and get attributes
$_attr = $this->getAttributes($compiler, $args);
-
$from = $_attr['from'];
- $item = $_attr['item'];
- if (!strncmp("\$_smarty_tpl->tpl_vars[$item]", $from, strlen($item) + 24)) {
- $compiler->trigger_template_error("item variable {$item} may not be the same variable as at 'from'", $compiler->lex->taglineno);
+ $item = $compiler->getId($_attr['item']);
+ if ($item === false) {
+ $item = $compiler->getVariableName($_attr['item']);
}
-
+ $attributes = array('item' => $item);
if (isset($_attr['key'])) {
- $key = $_attr['key'];
- } else {
- $key = null;
+ $key = $compiler->getId($_attr['key']);
+ if ($key === false) {
+ $key = $compiler->getVariableName($_attr['key']);
+ }
+ $attributes['key'] = $key;
}
-
- $this->openTag($compiler, 'foreach', array('foreach', $compiler->nocache, $item, $key, true));
- // maybe nocache because of nocache variables
- $compiler->nocache = $compiler->nocache | $compiler->tag_nocache;
-
if (isset($_attr['name'])) {
- $name = trim($_attr['name'], '\'"');
- $has_name = true;
- $SmartyVarName = "\$smarty.foreach.{$name}.";
- } else {
- $has_name = false;
- }
- $ItemVarName = '$' . trim($item, '\'"') . '@';
- // evaluates which Smarty variables and properties have to be computed
-
- if ($has_name) {
- $useSmartyForeach = $usesSmartyFirst = strpos($compiler->lex->data, $SmartyVarName . 'first') !== false;
- $useSmartyForeach = ($usesSmartyLast = strpos($compiler->lex->data, $SmartyVarName . 'last') !== false) || $useSmartyForeach;
- $useSmartyForeach = ($usesSmartyIndex = strpos($compiler->lex->data, $SmartyVarName . 'index') !== false) || $useSmartyForeach;
- $useSmartyForeach = ($usesSmartyIteration = (!$usesSmartyIndex && ($usesSmartyFirst || $usesSmartyLast)) || strpos($compiler->lex->data, $SmartyVarName . 'iteration') !== false) || $useSmartyForeach;
- $useSmartyForeach = ($usesSmartyShow = strpos($compiler->lex->data, $SmartyVarName . 'show') !== false) || $useSmartyForeach;
- $useSmartyForeach = ($usesSmartyTotal = $usesSmartyLast ||strpos($compiler->lex->data, $SmartyVarName . 'total') !== false) || $useSmartyForeach;
- } else {
- $usesSmartyFirst = false;
- $usesSmartyLast = false;
- $usesSmartyTotal = false;
- $usesSmartyShow = false;
- $useSmartyForeach = false;
+ $this->isNamed = true;
+ $attributes['name'] = $compiler->getId($_attr['name']);
+ }
+ foreach ($attributes as $a => $v) {
+ if ($v === false) {
+ $compiler->trigger_template_error("'{$a}' attribute/variable has illegal value", null, true);
+ }
+ }
+ $fromName = $compiler->getVariableName($_attr['from']);
+ if ($fromName) {
+ foreach (array('item', 'key') as $a) {
+ if (isset($attributes[$a]) && $attributes[$a] == $fromName) {
+ $compiler->trigger_template_error("'{$a}' and 'from' may not have same variable name '{$fromName}'",
+ null, true);
+ }
+ }
}
- $usesPropKey = strpos($compiler->lex->data, $ItemVarName . 'key') !== false;
- $usesPropFirst = strpos($compiler->lex->data, $ItemVarName . 'first') !== false;
- $usesPropLast = strpos($compiler->lex->data, $ItemVarName . 'last') !== false;
- $usesPropIndex = strpos($compiler->lex->data, $ItemVarName . 'index') !== false;
- $usesPropIteration = (!$usesPropIndex && ($usesPropFirst || $usesPropLast)) || strpos($compiler->lex->data, $ItemVarName . 'iteration') !== false;
- $usesPropShow = strpos($compiler->lex->data, $ItemVarName . 'show') !== false;
- $usesPropTotal = $usesPropLast || strpos($compiler->lex->data, $ItemVarName . 'total') !== false;
+ $itemVar = "\$_smarty_tpl->tpl_vars['{$item}']";
+ $local = '$__foreach_' . (isset($attributes['name']) ? $attributes['name'] : $attributes['item']) . '_' .
+ $this->counter ++ . '_';
+ $needIteration = false;
+ // search for used tag attributes
+ $itemAttr = array();
+ $namedAttr = array();
+ $this->scanForProperties($attributes, $compiler);
+ if (!empty($this->matchResults['item'])) {
+ $itemAttr = $this->matchResults['item'];
+ }
+ if (!empty($this->matchResults['named'])) {
+ $namedAttr = $this->matchResults['named'];
+ }
+ if (isset($itemAttr['last'])) {
+ $needIteration = true;
+ }
+ if (isset($namedAttr['last'])) {
+ $needIteration = true;
+ }
$keyTerm = '';
- if ($usesPropKey) {
- $keyTerm = "\$_smarty_tpl->tpl_vars[$item]->key => ";
- } elseif ($key != null) {
- $keyTerm = "\$_smarty_tpl->tpl_vars[$key]->value => ";
+ if (isset($itemAttr['key'])) {
+ $keyTerm = "{$itemVar}->key => ";
+ } elseif (isset($attributes['key'])) {
+ $keyTerm = "\$_smarty_tpl->tpl_vars['{$key}']->value => ";
}
+
+ $saveVars = array();
+ $restoreVars = array();
+ if ($this->isNamed) {
+ $foreachVar = "\$_smarty_tpl->tpl_vars['__smarty_foreach_{$attributes['name']}']";
+ if (!empty($namedAttr)) {
+ $saveVars['saved'] = "isset({$foreachVar}) ? {$foreachVar} : false;";
+ $restoreVars[] = "if ({$local}saved) {\n{$foreachVar} = {$local}saved;\n}\n";
+ }
+ }
+ foreach (array('item', 'key') as $a) {
+ if (isset($attributes[$a])) {
+ $saveVars['saved_' . $a] =
+ "isset(\$_smarty_tpl->tpl_vars['{$attributes[$a]}']) ? \$_smarty_tpl->tpl_vars['{$attributes[$a]}'] : false;";
+ $restoreVars[] =
+ "if ({$local}saved_{$a}) {\n\$_smarty_tpl->tpl_vars['{$attributes[$a]}'] = {$local}saved_{$a};\n}\n";
+ }
+ }
+ $this->openTag($compiler, 'foreach',
+ array('foreach', $compiler->nocache, $local, $restoreVars, $itemVar, true));
+ // maybe nocache because of nocache variables
+ $compiler->nocache = $compiler->nocache | $compiler->tag_nocache;
+
// generate output code
$output = "<?php\n";
$output .= "\$_from = $from;\n";
$output .= "if (!is_array(\$_from) && !is_object(\$_from)) {\n";
$output .= "settype(\$_from, 'array');\n";
$output .= "}\n";
- $output .= "\$_smarty_tpl->tpl_vars[$item] = new Smarty_Variable;\n";
- $output .= "\$_smarty_tpl->tpl_vars[$item]->_loop = false;\n";
- if ($key != null) {
- $output .= "\$_smarty_tpl->tpl_vars[$key] = new Smarty_Variable;\n";
+ foreach ($saveVars as $k => $code) {
+ $output .= "{$local}{$k} = {$code}\n";
}
- if ($usesPropTotal) {
- $output .= "\$_smarty_tpl->tpl_vars[$item]->total= \$_smarty_tpl->_count(\$_from);\n";
+ $output .= "{$itemVar} = new Smarty_Variable();\n";
+ $output .= "{$local}total = \$_smarty_tpl->smarty->ext->_foreach->count(\$_from);\n";
+ if (isset($itemAttr['show'])) {
+ $output .= "{$itemVar}->show = ({$local}total > 0);\n";
}
- if ($usesPropIteration) {
- $output .= "\$_smarty_tpl->tpl_vars[$item]->iteration=0;\n";
+ if (isset($itemAttr['total'])) {
+ $output .= "{$itemVar}->total= {$local}total;\n";
}
- if ($usesPropIndex) {
- $output .= "\$_smarty_tpl->tpl_vars[$item]->index=-1;\n";
- }
- if ($usesPropShow) {
- if ($usesPropTotal) {
- $output .= "\$_smarty_tpl->tpl_vars[$item]->show = (\$_smarty_tpl->tpl_vars[$item]->total > 0);\n";
- } else {
- $output .= "\$_smarty_tpl->tpl_vars[$item]->show = (\$_smarty_tpl->_count(\$_from) > 0);\n";
- }
- }
- if ($has_name) {
+ if ($this->isNamed) {
$prop = array();
- if ($usesSmartyTotal) {
- $prop['total'] = "'total' => ";
- $prop['total'] .= $usesSmartyShow ? '$total = ' : '';
- $prop['total'] .= '$_smarty_tpl->_count($_from)';
+ if (isset($namedAttr['total'])) {
+ $prop['total'] = "'total' => {$local}total";
}
- if ($usesSmartyIteration) {
+ if (isset($namedAttr['iteration'])) {
$prop['iteration'] = "'iteration' => 0";
}
- if ($usesSmartyIndex) {
+ if (isset($namedAttr['index'])) {
$prop['index'] = "'index' => -1";
}
- if ($usesSmartyShow) {
- $prop['show'] = "'show' => ";
- if ($usesSmartyTotal) {
- $prop['show'] .= "(\$total > 0)";
- } else {
- $prop['show'] .= "(\$_smarty_tpl->_count(\$_from) > 0)";
- }
+ if (isset($namedAttr['show'])) {
+ $prop['show'] = "'show' => ({$local}total > 0)";
}
- if ($useSmartyForeach) {
+ if (!empty($namedAttr)) {
$_vars = 'array(' . join(', ', $prop) . ')';
- $foreachVar = "'__foreach_{$name}'";
- $output .= "\$_smarty_tpl->tpl_vars[$foreachVar] = new Smarty_Variable({$_vars});\n";
+ $output .= "{$foreachVar} = new Smarty_Variable({$_vars});\n";
}
}
- $output .= "foreach (\$_from as {$keyTerm}\$_smarty_tpl->tpl_vars[$item]->value) {\n";
- $output .= "\$_smarty_tpl->tpl_vars[$item]->_loop = true;\n";
- if ($key != null && $usesPropKey) {
- $output .= "\$_smarty_tpl->tpl_vars[$key]->value = \$_smarty_tpl->tpl_vars[$item]->key;\n";
+ $output .= "if ({$local}total) {\n";
+ if (isset($attributes['key'])) {
+ $output .= "\$_smarty_tpl->tpl_vars['{$key}'] = new Smarty_Variable();\n";
}
- if ($usesPropIteration) {
- $output .= "\$_smarty_tpl->tpl_vars[$item]->iteration++;\n";
+ if (isset($namedAttr['first']) || isset($itemAttr['first'])) {
+ $output .= "{$local}first = true;\n";
}
- if ($usesPropIndex) {
- $output .= "\$_smarty_tpl->tpl_vars[$item]->index++;\n";
+ if (isset($itemAttr['iteration'])) {
+ $output .= "{$itemVar}->iteration=0;\n";
}
- if ($usesPropFirst) {
- if ($usesPropIndex) {
- $output .= "\$_smarty_tpl->tpl_vars[$item]->first = \$_smarty_tpl->tpl_vars[$item]->index == 0;\n";
- } else {
- $output .= "\$_smarty_tpl->tpl_vars[$item]->first = \$_smarty_tpl->tpl_vars[$item]->iteration == 1;\n";
- }
+ if (isset($itemAttr['index'])) {
+ $output .= "{$itemVar}->index=-1;\n";
}
- if ($usesPropLast) {
- if ($usesPropIndex) {
- $output .= "\$_smarty_tpl->tpl_vars[$item]->last = \$_smarty_tpl->tpl_vars[$item]->index + 1 == \$_smarty_tpl->tpl_vars[$item]->total;\n";
- } else {
- $output .= "\$_smarty_tpl->tpl_vars[$item]->last = \$_smarty_tpl->tpl_vars[$item]->iteration == \$_smarty_tpl->tpl_vars[$item]->total;\n";
- }
+ if ($needIteration) {
+ $output .= "{$local}iteration=0;\n";
+ }
+ $output .= "foreach (\$_from as {$keyTerm}{$itemVar}->value) {\n";
+ if (isset($attributes['key']) && isset($itemAttr['key'])) {
+ $output .= "\$_smarty_tpl->tpl_vars['{$key}']->value = {$itemVar}->key;\n";
+ }
+ if (isset($itemAttr['iteration'])) {
+ $output .= "{$itemVar}->iteration++;\n";
+ }
+ if (isset($itemAttr['index'])) {
+ $output .= "{$itemVar}->index++;\n";
}
- if ($has_name) {
- if ($usesSmartyIteration) {
- $output .= "\$_smarty_tpl->tpl_vars[$foreachVar]->value['iteration']++;\n";
+ if ($needIteration) {
+ $output .= "{$local}iteration++;\n";
+ }
+ if (isset($itemAttr['first'])) {
+ $output .= "{$itemVar}->first = {$local}first;\n";
+ }
+ if (isset($itemAttr['last'])) {
+ $output .= "{$itemVar}->last = {$local}iteration == {$local}total;\n";
+ }
+ if ($this->isNamed) {
+ if (isset($namedAttr['iteration'])) {
+ $output .= "{$foreachVar}->value['iteration']++;\n";
}
- if ($usesSmartyIndex) {
- $output .= "\$_smarty_tpl->tpl_vars[$foreachVar]->value['index']++;\n";
+ if (isset($namedAttr['index'])) {
+ $output .= "{$foreachVar}->value['index']++;\n";
}
- if ($usesSmartyFirst) {
- if ($usesSmartyIndex) {
- $output .= "\$_smarty_tpl->tpl_vars[$foreachVar]->value['first'] = \$_smarty_tpl->tpl_vars[$foreachVar]->value['index'] == 0;\n";
- } else {
- $output .= "\$_smarty_tpl->tpl_vars[$foreachVar]->value['first'] = \$_smarty_tpl->tpl_vars[$foreachVar]->value['iteration'] == 1;\n";
- }
+ if (isset($namedAttr['first'])) {
+ $output .= "{$foreachVar}->value['first'] = {$local}first;\n";
}
- if ($usesSmartyLast) {
- if ($usesSmartyIndex) {
- $output .= "\$_smarty_tpl->tpl_vars[$foreachVar]->value['last'] = \$_smarty_tpl->tpl_vars[$foreachVar]->value['index'] + 1 == \$_smarty_tpl->tpl_vars[$foreachVar]->value['total'];\n";
- } else {
- $output .= "\$_smarty_tpl->tpl_vars[$foreachVar]->value['last'] = \$_smarty_tpl->tpl_vars[$foreachVar]->value['iteration'] == \$_smarty_tpl->tpl_vars[$foreachVar]->value['total'];\n";
- }
+ if (isset($namedAttr['last'])) {
+ $output .= "{$foreachVar}->value['last'] = {$local}iteration == {$local}total;\n";
}
}
- $itemName = trim($item,"'\"");
- $output .= "\$foreach_{$itemName}_Sav = \$_smarty_tpl->tpl_vars[$item];\n";
+ if (isset($namedAttr['first']) || isset($itemAttr['first'])) {
+ $output .= "{$local}first = false;\n";
+ }
+ $output .= "{$local}saved_local_item = {$itemVar};\n";
$output .= "?>";
return $output;
@@ -227,24 +280,23 @@ class Smarty_Internal_Compile_Foreachelse extends Smarty_Internal_CompileBase
/**
* Compiles code for the {foreachelse} tag
*
- * @param array $args array with attributes from parser
- * @param object $compiler compiler object
- * @param array $parameter array with compilation parameter
+ * @param array $args array with attributes from parser
+ * @param \Smarty_Internal_TemplateCompilerBase $compiler compiler object
+ * @param array $parameter array with compilation parameter
*
* @return string compiled code
*/
- public function compile($args, $compiler, $parameter)
+ public function compile($args, Smarty_Internal_TemplateCompilerBase $compiler, $parameter)
{
// check and get attributes
$_attr = $this->getAttributes($compiler, $args);
- list($openTag, $nocache, $item, $key, $foo) = $this->closeTag($compiler, array('foreach'));
- $this->openTag($compiler, 'foreachelse', array('foreachelse', $nocache, $item, $key, false));
- $itemName = trim($item,"'\"");
+ list($openTag, $nocache, $local, $restoreVars, $itemVar, $foo) = $this->closeTag($compiler, array('foreach'));
+ $this->openTag($compiler, 'foreachelse', array('foreachelse', $nocache, $local, $restoreVars, $itemVar, false));
$output = "<?php\n";
- $output .= "\$_smarty_tpl->tpl_vars[$item] = \$foreach_{$itemName}_Sav;\n";
+ $output .= "{$itemVar} = {$local}saved_local_item;\n";
$output .= "}\n";
- $output .= "if (!\$_smarty_tpl->tpl_vars[$item]->_loop) {\n?>";
+ $output .= "} else {\n?>";
return $output;
}
}
@@ -260,28 +312,33 @@ class Smarty_Internal_Compile_Foreachclose extends Smarty_Internal_CompileBase
/**
* Compiles code for the {/foreach} tag
*
- * @param array $args array with attributes from parser
- * @param object $compiler compiler object
- * @param array $parameter array with compilation parameter
+ * @param array $args array with attributes from parser
+ * @param \Smarty_Internal_TemplateCompilerBase $compiler compiler object
+ * @param array $parameter array with compilation parameter
*
* @return string compiled code
*/
- public function compile($args, $compiler, $parameter)
+ public function compile($args, Smarty_Internal_TemplateCompilerBase $compiler, $parameter)
{
- // check and get attributes
- $_attr = $this->getAttributes($compiler, $args);
+ $compiler->loopNesting --;
// must endblock be nocache?
if ($compiler->nocache) {
$compiler->tag_nocache = true;
}
- list($openTag, $compiler->nocache, $item, $key, $restore) = $this->closeTag($compiler, array('foreach', 'foreachelse'));
- $itemName = trim($item,"'\"");
+ list($openTag, $compiler->nocache, $local, $restoreVars, $itemVar, $restore) =
+ $this->closeTag($compiler, array('foreach', 'foreachelse'));
$output = "<?php\n";
+
if ($restore) {
- $output .= "\$_smarty_tpl->tpl_vars[$item] = \$foreach_{$itemName}_Sav;\n";
+ $output .= "{$itemVar} = {$local}saved_local_item;\n";
+ $output .= "}\n";
+ }
+ $output .= "}\n";
+ foreach ($restoreVars as $restore) {
+ $output .= $restore;
}
- $output .= "}\n?>";
+ $output .= "?>";
return $output;
}
diff --git a/library/Smarty/libs/sysplugins/smarty_internal_compile_function.php b/library/Smarty/libs/sysplugins/smarty_internal_compile_function.php
index 35408bcbe..26804b6ac 100644
--- a/library/Smarty/libs/sysplugins/smarty_internal_compile_function.php
+++ b/library/Smarty/libs/sysplugins/smarty_internal_compile_function.php
@@ -44,32 +44,31 @@ class Smarty_Internal_Compile_Function extends Smarty_Internal_CompileBase
/**
* Compiles code for the {function} tag
*
- * @param array $args array with attributes from parser
- * @param object $compiler compiler object
- * @param array $parameter array with compilation parameter
+ * @param array $args array with attributes from parser
+ * @param \Smarty_Internal_TemplateCompilerBase $compiler compiler object
+ * @param array $parameter array with compilation parameter
*
- * @return boolean true
+ * @return bool true
+ * @throws \SmartyCompilerException
*/
- public function compile($args, $compiler, $parameter)
+ public function compile($args, Smarty_Internal_TemplateCompilerBase $compiler, $parameter)
{
+ $compiler->loopNesting++;
// check and get attributes
$_attr = $this->getAttributes($compiler, $args);
if ($_attr['nocache'] === true) {
- $compiler->trigger_template_error('nocache option not allowed', $compiler->lex->taglineno);
+ $compiler->trigger_template_error('nocache option not allowed', null, true);
}
unset($_attr['nocache']);
$_name = trim($_attr['name'], "'\"");
- $compiler->parent_compiler->templateProperties['tpl_function'][$_name] = array();
- $save = array($_attr, $compiler->parser->current_buffer, $compiler->template->has_nocache_code, $compiler->template->required_plugins, $compiler->template->caching);
+ $compiler->parent_compiler->template->tpl_function[$_name] = array();
+ $save = array($_attr, $compiler->parser->current_buffer, $compiler->template->compiled->has_nocache_code,
+ $compiler->template->caching);
$this->openTag($compiler, 'function', $save);
- // set flag that we are compiling a template function
- $compiler->compiles_template_function = true;
// Init temporary context
- $compiler->template->required_plugins = array('compiled' => array(), 'nocache' => array());
- $compiler->parser->current_buffer = new Smarty_Internal_ParseTree_Template($compiler->parser);
- $compiler->template->has_nocache_code = false;
- $compiler->template->caching = true;
+ $compiler->parser->current_buffer = new Smarty_Internal_ParseTree_Template();
+ $compiler->template->compiled->has_nocache_code = false;
return true;
}
}
@@ -101,15 +100,14 @@ class Smarty_Internal_Compile_Functionclose extends Smarty_Internal_CompileBase
*/
public function compile($args, Smarty_Internal_TemplateCompilerBase $compiler, $parameter)
{
+ $compiler->loopNesting--;
$this->compiler = $compiler;
$saved_data = $this->closeTag($compiler, array('function'));
$_attr = $saved_data[0];
$_name = trim($_attr['name'], "'\"");
- // reset flag that we are compiling a template function
- $compiler->compiles_template_function = false;
- $compiler->parent_compiler->templateProperties['tpl_function'][$_name]['called_functions'] = $compiler->called_functions;
- $compiler->parent_compiler->templateProperties['tpl_function'][$_name]['compiled_filepath'] = $compiler->parent_compiler->template->compiled->filepath;
- $compiler->parent_compiler->templateProperties['tpl_function'][$_name]['uid'] = $compiler->template->source->uid;
+ $compiler->parent_compiler->template->tpl_function[$_name]['called_functions'] = $compiler->called_functions;
+ $compiler->parent_compiler->template->tpl_function[$_name]['compiled_filepath'] = $compiler->parent_compiler->template->compiled->filepath;
+ $compiler->parent_compiler->template->tpl_function[$_name]['uid'] = $compiler->template->source->uid;
$compiler->called_functions = array();
$_parameter = $_attr;
unset($_parameter['name']);
@@ -130,89 +128,71 @@ class Smarty_Internal_Compile_Functionclose extends Smarty_Internal_CompileBase
}
$_functionCode = $compiler->parser->current_buffer;
// setup buffer for template function code
- $compiler->parser->current_buffer = new Smarty_Internal_ParseTree_Template($compiler->parser);
+ $compiler->parser->current_buffer = new Smarty_Internal_ParseTree_Template();
- $_funcName = "smarty_template_function_{$_name}_{$compiler->template->properties['nocache_hash']}";
+ $_funcName = "smarty_template_function_{$_name}_{$compiler->template->compiled->nocache_hash}";
$_funcNameCaching = $_funcName . '_nocache';
- if ($compiler->template->has_nocache_code) {
- $compiler->parent_compiler->templateProperties['tpl_function'][$_name]['call_name_caching'] = $_funcNameCaching;
+ if ($compiler->template->compiled->has_nocache_code) {
+ $compiler->parent_compiler->template->tpl_function[$_name]['call_name_caching'] = $_funcNameCaching;
$output = "<?php\n";
$output .= "/* {$_funcNameCaching} */\n";
$output .= "if (!function_exists('{$_funcNameCaching}')) {\n";
$output .= "function {$_funcNameCaching} (\$_smarty_tpl,\$params) {\n";
- // build plugin include code
- if (!empty($compiler->template->required_plugins['compiled'])) {
- foreach ($compiler->template->required_plugins['compiled'] as $tmp) {
- foreach ($tmp as $data) {
- $output .= "if (!is_callable('{$data['function']}')) require_once '{$data['file']}';\n";
- }
- }
- }
- if (!empty($compiler->template->required_plugins['nocache'])) {
- $output .= "echo '/*%%SmartyNocache:{$compiler->template->properties['nocache_hash']}%%*/<?php ";
- foreach ($compiler->template->required_plugins['nocache'] as $tmp) {
- foreach ($tmp as $data) {
- $output .= "if (!is_callable(\'{$data['function']}\')) require_once \'{$data['file']}\';\n";
- }
- }
- $output .= "?>/*/%%SmartyNocache:{$compiler->template->properties['nocache_hash']}%%*/';\n";
- }
$output .= "ob_start();\n";
+ $output .= "\$_smarty_tpl->compiled->has_nocache_code = true;\n";
$output .= $_paramsCode;
- $output .= "\$_smarty_tpl->properties['saved_tpl_vars'][] = \$_smarty_tpl->tpl_vars;\n";
+ $output .= "\$_smarty_tpl->_cache['saved_tpl_vars'][] = \$_smarty_tpl->tpl_vars;\n";
$output .= "foreach (\$params as \$key => \$value) {\n\$_smarty_tpl->tpl_vars[\$key] = new Smarty_Variable(\$value);\n}";
$output .= "\$params = var_export(\$params, true);\n";
- $output .= "echo \"/*%%SmartyNocache:{$compiler->template->properties['nocache_hash']}%%*/<?php ";
+ $output .= "echo \"/*%%SmartyNocache:{$compiler->template->compiled->nocache_hash}%%*/<?php ";
$output .= "\\\$saved_tpl_vars = \\\$_smarty_tpl->tpl_vars;\nforeach (\$params as \\\$key => \\\$value) {\n\\\$_smarty_tpl->tpl_vars[\\\$key] = new Smarty_Variable(\\\$value);\n}\n?>";
- $output .= "/*/%%SmartyNocache:{$compiler->template->properties['nocache_hash']}%%*/\n\";?>";
- $compiler->parser->current_buffer->append_subtree(new Smarty_Internal_ParseTree_Tag($compiler->parser, $output));
- $compiler->parser->current_buffer->append_subtree($_functionCode);
- $output = "<?php echo \"/*%%SmartyNocache:{$compiler->template->properties['nocache_hash']}%%*/<?php ";
+ $output .= "/*/%%SmartyNocache:{$compiler->template->compiled->nocache_hash}%%*/\n\";?>";
+ $compiler->parser->current_buffer->append_subtree($compiler->parser, new Smarty_Internal_ParseTree_Tag($compiler->parser, $output));
+ $compiler->parser->current_buffer->append_subtree($compiler->parser, $_functionCode);
+ $output = "<?php echo \"/*%%SmartyNocache:{$compiler->template->compiled->nocache_hash}%%*/<?php ";
$output .= "foreach (Smarty::\\\$global_tpl_vars as \\\$key => \\\$value){\n";
- $output .= "if (\\\$_smarty_tpl->tpl_vars[\\\$key] === \\\$value) \\\$saved_tpl_vars[\\\$key] = \\\$value;\n}\n";
+ $output .= "if (!isset(\\\$_smarty_tpl->tpl_vars[\\\$key]) || \\\$_smarty_tpl->tpl_vars[\\\$key] === \\\$value) \\\$saved_tpl_vars[\\\$key] = \\\$value;\n}\n";
$output .= "\\\$_smarty_tpl->tpl_vars = \\\$saved_tpl_vars;?>\n";
- $output .= "/*/%%SmartyNocache:{$compiler->template->properties['nocache_hash']}%%*/\";\n?>";
- $output .= "<?php echo str_replace('{$compiler->template->properties['nocache_hash']}', \$_smarty_tpl->properties['nocache_hash'], ob_get_clean());\n";
- $output .= "\$_smarty_tpl->tpl_vars = array_pop(\$_smarty_tpl->properties['saved_tpl_vars']);\n}\n}\n";
+ $output .= "/*/%%SmartyNocache:{$compiler->template->compiled->nocache_hash}%%*/\";\n?>";
+ $output .= "<?php echo str_replace('{$compiler->template->compiled->nocache_hash}', \$_smarty_tpl->compiled->nocache_hash, ob_get_clean());\n";
+ $output .= "\$_smarty_tpl->tpl_vars = array_pop(\$_smarty_tpl->_cache['saved_tpl_vars']);\n}\n}\n";
$output .= "/*/ {$_funcName}_nocache */\n\n";
$output .= "?>\n";
- $compiler->parser->current_buffer->append_subtree(new Smarty_Internal_ParseTree_Tag($compiler->parser, $output));
- $_functionCode = new Smarty_Internal_ParseTree_Tag($compiler->parser, preg_replace_callback("/((<\?php )?echo '\/\*%%SmartyNocache:{$compiler->template->properties['nocache_hash']}%%\*\/([\S\s]*?)\/\*\/%%SmartyNocache:{$compiler->template->properties['nocache_hash']}%%\*\/';(\?>\n)?)/", array($this, 'removeNocache'), $_functionCode->to_smarty_php()));
+ $compiler->parser->current_buffer->append_subtree($compiler->parser, new Smarty_Internal_ParseTree_Tag($compiler->parser, $output));
+ $_functionCode = new Smarty_Internal_ParseTree_Tag($compiler->parser, preg_replace_callback("/((<\?php )?echo '\/\*%%SmartyNocache:{$compiler->template->compiled->nocache_hash}%%\*\/([\S\s]*?)\/\*\/%%SmartyNocache:{$compiler->template->compiled->nocache_hash}%%\*\/';(\?>\n)?)/", array($this,
+ 'removeNocache'), $_functionCode->to_smarty_php($compiler->parser)));
}
- $compiler->parent_compiler->templateProperties['tpl_function'][$_name]['call_name'] = $_funcName;
+ $compiler->parent_compiler->template->tpl_function[$_name]['call_name'] = $_funcName;
$output = "<?php\n";
$output .= "/* {$_funcName} */\n";
$output .= "if (!function_exists('{$_funcName}')) {\n";
$output .= "function {$_funcName}(\$_smarty_tpl,\$params) {\n";
- // build plugin include code
- if (!empty($compiler->template->required_plugins['nocache'])) {
- $compiler->template->required_plugins['compiled'] = array_merge($compiler->template->required_plugins['compiled'], $compiler->template->required_plugins['nocache']);
- }
- if (!empty($compiler->template->required_plugins['compiled'])) {
- foreach ($compiler->template->required_plugins['compiled'] as $tmp) {
- foreach ($tmp as $data) {
- $output .= "if (!is_callable('{$data['function']}')) require_once '{$data['file']}';\n";
- }
- }
- }
$output .= "\$saved_tpl_vars = \$_smarty_tpl->tpl_vars;\n";
$output .= $_paramsCode;
$output .= "foreach (\$params as \$key => \$value) {\n\$_smarty_tpl->tpl_vars[\$key] = new Smarty_Variable(\$value);\n}?>";
- $compiler->parser->current_buffer->append_subtree(new Smarty_Internal_ParseTree_Tag($compiler->parser, $output));
- $compiler->parser->current_buffer->append_subtree($_functionCode);
+ $compiler->parser->current_buffer->append_subtree($compiler->parser, new Smarty_Internal_ParseTree_Tag($compiler->parser, $output));
+ $compiler->parser->current_buffer->append_subtree($compiler->parser, $_functionCode);
$output = "<?php foreach (Smarty::\$global_tpl_vars as \$key => \$value){\n";
- $output .= "if (\$_smarty_tpl->tpl_vars[\$key] === \$value) \$saved_tpl_vars[\$key] = \$value;\n}\n";
+ $output .= "if (!isset(\$_smarty_tpl->tpl_vars[\$key]) || \$_smarty_tpl->tpl_vars[\$key] === \$value) \$saved_tpl_vars[\$key] = \$value;\n}\n";
$output .= "\$_smarty_tpl->tpl_vars = \$saved_tpl_vars;\n}\n}\n";
$output .= "/*/ {$_funcName} */\n\n";
$output .= "?>\n";
- $compiler->parser->current_buffer->append_subtree(new Smarty_Internal_ParseTree_Tag($compiler->parser, $output));
- $compiler->parent_compiler->templateFunctionCode .= $compiler->parser->current_buffer->to_smarty_php();
+ $compiler->parser->current_buffer->append_subtree($compiler->parser, new Smarty_Internal_ParseTree_Tag($compiler->parser, $output));
+ $compiler->parent_compiler->blockOrFunctionCode .= $compiler->parser->current_buffer->to_smarty_php($compiler->parser);
+ // nocache plugins must be copied
+ if (!empty($compiler->template->compiled->required_plugins['nocache'])) {
+ foreach ($compiler->template->compiled->required_plugins['nocache'] as $plugin => $tmp) {
+ foreach ($tmp as $type => $data) {
+ $compiler->parent_compiler->template->compiled->required_plugins['compiled'][$plugin][$type] = $data;
+ }
+ }
+ }
// restore old buffer
+
$compiler->parser->current_buffer = $saved_data[1];
// restore old status
- $compiler->template->has_nocache_code = $saved_data[2];
- $compiler->template->required_plugins = $saved_data[3];
- $compiler->template->caching = $saved_data[4];
+ $compiler->template->compiled->has_nocache_code = $saved_data[2];
+ $compiler->template->caching = $saved_data[3];
return true;
}
@@ -223,7 +203,7 @@ class Smarty_Internal_Compile_Functionclose extends Smarty_Internal_CompileBase
*/
function removeNocache($match)
{
- $code = preg_replace("/((<\?php )?echo '\/\*%%SmartyNocache:{$this->compiler->template->properties['nocache_hash']}%%\*\/)|(\/\*\/%%SmartyNocache:{$this->compiler->template->properties['nocache_hash']}%%\*\/';(\?>\n)?)/", '', $match[0]);
+ $code = preg_replace("/((<\?php )?echo '\/\*%%SmartyNocache:{$this->compiler->template->compiled->nocache_hash}%%\*\/)|(\/\*\/%%SmartyNocache:{$this->compiler->template->compiled->nocache_hash}%%\*\/';(\?>\n)?)/", '', $match[0]);
$code = str_replace(array('\\\'', '\\\\\''), array('\'', '\\\''), $code);
return $code;
}
diff --git a/library/Smarty/libs/sysplugins/smarty_internal_compile_if.php b/library/Smarty/libs/sysplugins/smarty_internal_compile_if.php
index d4fd30e9f..541e21816 100644
--- a/library/Smarty/libs/sysplugins/smarty_internal_compile_if.php
+++ b/library/Smarty/libs/sysplugins/smarty_internal_compile_if.php
@@ -19,13 +19,14 @@ class Smarty_Internal_Compile_If extends Smarty_Internal_CompileBase
/**
* Compiles code for the {if} tag
*
- * @param array $args array with attributes from parser
- * @param object $compiler compiler object
- * @param array $parameter array with compilation parameter
+ * @param array $args array with attributes from parser
+ * @param \Smarty_Internal_TemplateCompilerBase $compiler compiler object
+ * @param array $parameter array with compilation parameter
*
* @return string compiled code
+ * @throws \SmartyCompilerException
*/
- public function compile($args, $compiler, $parameter)
+ public function compile($args, Smarty_Internal_TemplateCompilerBase $compiler, $parameter)
{
// check and get attributes
$_attr = $this->getAttributes($compiler, $args);
@@ -34,7 +35,7 @@ class Smarty_Internal_Compile_If extends Smarty_Internal_CompileBase
$compiler->nocache = $compiler->nocache | $compiler->tag_nocache;
if (!array_key_exists("if condition", $parameter)) {
- $compiler->trigger_template_error("missing if condition", $compiler->lex->taglineno);
+ $compiler->trigger_template_error("missing if condition", null, true);
}
if (is_array($parameter['if condition'])) {
@@ -45,7 +46,7 @@ class Smarty_Internal_Compile_If extends Smarty_Internal_CompileBase
$var = trim($parameter['if condition']['var']['var'], "'");
} else {
$var = trim($parameter['if condition']['var'], "'");
- }
+ }
if (isset($compiler->template->tpl_vars[$var])) {
$compiler->template->tpl_vars[$var]->nocache = true;
} else {
@@ -55,11 +56,19 @@ class Smarty_Internal_Compile_If extends Smarty_Internal_CompileBase
$_nocache = '';
}
if (is_array($parameter['if condition']['var'])) {
- $_output = "<?php if (!isset(\$_smarty_tpl->tpl_vars[" . $parameter['if condition']['var']['var'] . "]) || !is_array(\$_smarty_tpl->tpl_vars[" . $parameter['if condition']['var']['var'] . "]->value)) \$_smarty_tpl->createLocalArrayVariable(" . $parameter['if condition']['var']['var'] . "$_nocache);\n";
- $_output .= "if (\$_smarty_tpl->tpl_vars[" . $parameter['if condition']['var']['var'] . "]->value" . $parameter['if condition']['var']['smarty_internal_index'] . " = " . $parameter['if condition']['value'] . ") {?>";
+ $_output = "<?php if (!isset(\$_smarty_tpl->tpl_vars[" . $parameter['if condition']['var']['var'] .
+ "]) || !is_array(\$_smarty_tpl->tpl_vars[" . $parameter['if condition']['var']['var'] .
+ "]->value)) \$_smarty_tpl->smarty->ext->_var->createLocalArrayVariable(\$_smarty_tpl, " . $parameter['if condition']['var']['var'] .
+ "$_nocache);\n";
+ $_output .= "if (\$_smarty_tpl->tpl_vars[" . $parameter['if condition']['var']['var'] . "]->value" .
+ $parameter['if condition']['var']['smarty_internal_index'] . " = " .
+ $parameter['if condition']['value'] . ") {?>";
} else {
- $_output = "<?php if (!isset(\$_smarty_tpl->tpl_vars[" . $parameter['if condition']['var'] . "])) \$_smarty_tpl->tpl_vars[" . $parameter['if condition']['var'] . "] = new Smarty_Variable(null{$_nocache});";
- $_output .= "if (\$_smarty_tpl->tpl_vars[" . $parameter['if condition']['var'] . "]->value = " . $parameter['if condition']['value'] . ") {?>";
+ $_output = "<?php if (!isset(\$_smarty_tpl->tpl_vars[" . $parameter['if condition']['var'] .
+ "])) \$_smarty_tpl->tpl_vars[" . $parameter['if condition']['var'] .
+ "] = new Smarty_Variable(null{$_nocache});";
+ $_output .= "if (\$_smarty_tpl->tpl_vars[" . $parameter['if condition']['var'] . "]->value = " .
+ $parameter['if condition']['value'] . ") {?>";
}
return $_output;
@@ -80,13 +89,13 @@ class Smarty_Internal_Compile_Else extends Smarty_Internal_CompileBase
/**
* Compiles code for the {else} tag
*
- * @param array $args array with attributes from parser
- * @param object $compiler compiler object
- * @param array $parameter array with compilation parameter
+ * @param array $args array with attributes from parser
+ * @param \Smarty_Internal_TemplateCompilerBase $compiler compiler object
+ * @param array $parameter array with compilation parameter
*
* @return string compiled code
*/
- public function compile($args, $compiler, $parameter)
+ public function compile($args, Smarty_Internal_TemplateCompilerBase $compiler, $parameter)
{
list($nesting, $compiler->tag_nocache) = $this->closeTag($compiler, array('if', 'elseif'));
$this->openTag($compiler, 'else', array($nesting, $compiler->tag_nocache));
@@ -106,13 +115,14 @@ class Smarty_Internal_Compile_Elseif extends Smarty_Internal_CompileBase
/**
* Compiles code for the {elseif} tag
*
- * @param array $args array with attributes from parser
- * @param object $compiler compiler object
- * @param array $parameter array with compilation parameter
+ * @param array $args array with attributes from parser
+ * @param \Smarty_Internal_TemplateCompilerBase $compiler compiler object
+ * @param array $parameter array with compilation parameter
*
* @return string compiled code
+ * @throws \SmartyCompilerException
*/
- public function compile($args, $compiler, $parameter)
+ public function compile($args, Smarty_Internal_TemplateCompilerBase $compiler, $parameter)
{
// check and get attributes
$_attr = $this->getAttributes($compiler, $args);
@@ -120,7 +130,7 @@ class Smarty_Internal_Compile_Elseif extends Smarty_Internal_CompileBase
list($nesting, $compiler->tag_nocache) = $this->closeTag($compiler, array('if', 'elseif'));
if (!array_key_exists("if condition", $parameter)) {
- $compiler->trigger_template_error("missing elseif condition", $compiler->lex->taglineno);
+ $compiler->trigger_template_error("missing elseif condition", null, true);
}
if (is_array($parameter['if condition'])) {
@@ -149,11 +159,20 @@ class Smarty_Internal_Compile_Elseif extends Smarty_Internal_CompileBase
if ($condition_by_assign) {
$this->openTag($compiler, 'elseif', array($nesting + 1, $compiler->tag_nocache));
if (is_array($parameter['if condition']['var'])) {
- $_output = "<?php } else { if (!isset(\$_smarty_tpl->tpl_vars[" . $parameter['if condition']['var']['var'] . "]) || !is_array(\$_smarty_tpl->tpl_vars[" . $parameter['if condition']['var']['var'] . "]->value)) \$_smarty_tpl->createLocalArrayVariable(" . $parameter['if condition']['var']['var'] . "$_nocache);\n";
- $_output .= "if (\$_smarty_tpl->tpl_vars[" . $parameter['if condition']['var']['var'] . "]->value" . $parameter['if condition']['var']['smarty_internal_index'] . " = " . $parameter['if condition']['value'] . ") {?>";
+ $_output = "<?php } else { if (!isset(\$_smarty_tpl->tpl_vars[" .
+ $parameter['if condition']['var']['var'] . "]) || !is_array(\$_smarty_tpl->tpl_vars[" .
+ $parameter['if condition']['var']['var'] .
+ "]->value)) \$_smarty_tpl->smarty->ext->_var->createLocalArrayVariable(\$_smarty_tpl, " .
+ $parameter['if condition']['var']['var'] . "$_nocache);\n";
+ $_output .= "if (\$_smarty_tpl->tpl_vars[" . $parameter['if condition']['var']['var'] . "]->value" .
+ $parameter['if condition']['var']['smarty_internal_index'] . " = " .
+ $parameter['if condition']['value'] . ") {?>";
} else {
- $_output = "<?php } else { if (!isset(\$_smarty_tpl->tpl_vars[" . $parameter['if condition']['var'] . "])) \$_smarty_tpl->tpl_vars[" . $parameter['if condition']['var'] . "] = new Smarty_Variable(null{$_nocache});";
- $_output .= "if (\$_smarty_tpl->tpl_vars[" . $parameter['if condition']['var'] . "]->value = " . $parameter['if condition']['value'] . ") {?>";
+ $_output = "<?php } else { if (!isset(\$_smarty_tpl->tpl_vars[" .
+ $parameter['if condition']['var'] . "])) \$_smarty_tpl->tpl_vars[" .
+ $parameter['if condition']['var'] . "] = new Smarty_Variable(null{$_nocache});";
+ $_output .= "if (\$_smarty_tpl->tpl_vars[" . $parameter['if condition']['var'] . "]->value = " .
+ $parameter['if condition']['value'] . ") {?>";
}
return $_output;
@@ -166,17 +185,29 @@ class Smarty_Internal_Compile_Elseif extends Smarty_Internal_CompileBase
$tmp = '';
foreach ($compiler->prefix_code as $code) {
$tmp = $compiler->appendCode($tmp, $code);
- }
+ }
$compiler->prefix_code = array();
$tmp = $compiler->appendCode("<?php } else {?>", $tmp);
$this->openTag($compiler, 'elseif', array($nesting + 1, $compiler->tag_nocache));
if ($condition_by_assign) {
if (is_array($parameter['if condition']['var'])) {
- $_output = $compiler->appendCode($tmp, "<?php if (!isset(\$_smarty_tpl->tpl_vars[" . $parameter['if condition']['var']['var'] . "]) || !is_array(\$_smarty_tpl->tpl_vars[" . $parameter['if condition']['var']['var'] . "]->value)) \$_smarty_tpl->createLocalArrayVariable(" . $parameter['if condition']['var']['var'] . "$_nocache);\n");
- $_output .= "if (\$_smarty_tpl->tpl_vars[" . $parameter['if condition']['var']['var'] . "]->value" . $parameter['if condition']['var']['smarty_internal_index'] . " = " . $parameter['if condition']['value'] . ") {?>";
+ $_output = $compiler->appendCode($tmp, "<?php if (!isset(\$_smarty_tpl->tpl_vars[" .
+ $parameter['if condition']['var']['var'] .
+ "]) || !is_array(\$_smarty_tpl->tpl_vars[" .
+ $parameter['if condition']['var']['var'] .
+ "]->value)) \$_smarty_tpl->smarty->ext->_var->createLocalArrayVariable(\$_smarty_tpl, " .
+ $parameter['if condition']['var']['var'] . "$_nocache);\n");
+ $_output .= "if (\$_smarty_tpl->tpl_vars[" . $parameter['if condition']['var']['var'] . "]->value" .
+ $parameter['if condition']['var']['smarty_internal_index'] . " = " .
+ $parameter['if condition']['value'] . ") {?>";
} else {
- $_output = $compiler->appendCode($tmp, "<?php if (!isset(\$_smarty_tpl->tpl_vars[" . $parameter['if condition']['var'] . "])) \$_smarty_tpl->tpl_vars[" . $parameter['if condition']['var'] . "] = new Smarty_Variable(null{$_nocache});");
- $_output .= "if (\$_smarty_tpl->tpl_vars[" . $parameter['if condition']['var'] . "]->value = " . $parameter['if condition']['value'] . ") {?>";
+ $_output = $compiler->appendCode($tmp, "<?php if (!isset(\$_smarty_tpl->tpl_vars[" .
+ $parameter['if condition']['var'] .
+ "])) \$_smarty_tpl->tpl_vars[" .
+ $parameter['if condition']['var'] .
+ "] = new Smarty_Variable(null{$_nocache});");
+ $_output .= "if (\$_smarty_tpl->tpl_vars[" . $parameter['if condition']['var'] . "]->value = " .
+ $parameter['if condition']['value'] . ") {?>";
}
return $_output;
@@ -198,13 +229,13 @@ class Smarty_Internal_Compile_Ifclose extends Smarty_Internal_CompileBase
/**
* Compiles code for the {/if} tag
*
- * @param array $args array with attributes from parser
- * @param object $compiler compiler object
- * @param array $parameter array with compilation parameter
+ * @param array $args array with attributes from parser
+ * @param \Smarty_Internal_TemplateCompilerBase $compiler compiler object
+ * @param array $parameter array with compilation parameter
*
* @return string compiled code
*/
- public function compile($args, $compiler, $parameter)
+ public function compile($args, Smarty_Internal_TemplateCompilerBase $compiler, $parameter)
{
// must endblock be nocache?
if ($compiler->nocache) {
diff --git a/library/Smarty/libs/sysplugins/smarty_internal_compile_include.php b/library/Smarty/libs/sysplugins/smarty_internal_compile_include.php
index b0720a29b..09fa11d6c 100644
--- a/library/Smarty/libs/sysplugins/smarty_internal_compile_include.php
+++ b/library/Smarty/libs/sysplugins/smarty_internal_compile_include.php
@@ -20,6 +20,7 @@ class Smarty_Internal_Compile_Include extends Smarty_Internal_CompileBase
* caching mode to create nocache code but no cache file
*/
const CACHING_NOCACHE_CODE = 9999;
+
/**
* Attribute definition: Overwrites base class.
*
@@ -27,6 +28,7 @@ class Smarty_Internal_Compile_Include extends Smarty_Internal_CompileBase
* @see Smarty_Internal_CompileBase
*/
public $required_attributes = array('file');
+
/**
* Attribute definition: Overwrites base class.
*
@@ -34,13 +36,15 @@ class Smarty_Internal_Compile_Include extends Smarty_Internal_CompileBase
* @see Smarty_Internal_CompileBase
*/
public $shorttag_order = array('file');
+
/**
* Attribute definition: Overwrites base class.
*
* @var array
* @see Smarty_Internal_CompileBase
*/
- public $option_flags = array('nocache', 'inline', 'caching');
+ public $option_flags = array('nocache', 'inline', 'caching', 'bubble_up');
+
/**
* Attribute definition: Overwrites base class.
*
@@ -50,6 +54,14 @@ class Smarty_Internal_Compile_Include extends Smarty_Internal_CompileBase
public $optional_attributes = array('_any');
/**
+ * Valid scope names
+ *
+ * @var array
+ */
+ public $valid_scopes = array('local' => true, 'parent' => true, 'root' => true, 'global' => true,
+ 'smarty' => true, 'tpl_root' => true);
+
+ /**
* Compiles code for the {include} tag
*
* @param array $args array with attributes from parser
@@ -64,26 +76,73 @@ class Smarty_Internal_Compile_Include extends Smarty_Internal_CompileBase
// check and get attributes
$_attr = $this->getAttributes($compiler, $args);
- // save possible attributes
- $include_file = $_attr['file'];
+ $hashResourceName = $fullResourceName = $source_resource = $_attr['file'];
+ $variable_template = false;
+ $cache_tpl = false;
+ // parse resource_name
+ if (preg_match('/^([\'"])(([A-Za-z0-9_\-]{2,})[:])?(([^$()]+)|(.+))\1$/', $source_resource, $match)) {
+ $type = !empty($match[3]) ? $match[3] : $compiler->template->smarty->default_resource_type;
+ $name = !empty($match[5]) ? $match[5] : $match[6];
+ $handler = Smarty_Resource::load($compiler->smarty, $type);
+ if ($handler->recompiled || $handler->uncompiled) {
+ $variable_template = true;
+ }
+ if (!$variable_template) {
+ if ($type != 'string') {
+ $fullResourceName = "{$type}:{$name}";
+ $compiled = $compiler->parent_compiler->template->compiled;
+ if (isset($compiled->includes[$fullResourceName])) {
+ $compiled->includes[$fullResourceName] ++;
+ $cache_tpl = true;
+ } else {
+ $compiled->includes[$fullResourceName] = 1;
+ }
+ $fullResourceName = '"' . $fullResourceName . '"';
+ }
+ }
+ if (empty($match[5])) {
+ $variable_template = true;
+ }
+ } else {
+ $variable_template = true;
+ }
if (isset($_attr['assign'])) {
// output will be stored in a smarty variable instead of being displayed
$_assign = $_attr['assign'];
}
- $_parent_scope = Smarty::SCOPE_LOCAL;
+ // scope setup
+ $_scope = Smarty::SCOPE_LOCAL;
if (isset($_attr['scope'])) {
$_attr['scope'] = trim($_attr['scope'], "'\"");
- if ($_attr['scope'] == 'parent') {
- $_parent_scope = Smarty::SCOPE_PARENT;
- } elseif ($_attr['scope'] == 'root') {
- $_parent_scope = Smarty::SCOPE_ROOT;
- } elseif ($_attr['scope'] == 'global') {
- $_parent_scope = Smarty::SCOPE_GLOBAL;
+ if (!isset($this->valid_scopes[$_attr['scope']])) {
+ $compiler->trigger_template_error("illegal value '{$_attr['scope']}' for \"scope\" attribute", null, true);
+ }
+ if ($_attr['scope'] != 'local') {
+ if ($_attr['scope'] == 'parent') {
+ $_scope = Smarty::SCOPE_PARENT;
+ } elseif ($_attr['scope'] == 'root') {
+ $_scope = Smarty::SCOPE_ROOT;
+ } elseif ($_attr['scope'] == 'global') {
+ $_scope = Smarty::SCOPE_GLOBAL;
+ } elseif ($_attr['scope'] == 'smarty') {
+ $_scope = Smarty::SCOPE_SMARTY;
+ } elseif ($_attr['scope'] == 'tpl_root') {
+ $_scope = Smarty::SCOPE_TPL_ROOT;
+ }
+ if ($_attr['bubble_up'] === true) {
+ $_scope = $_scope + Smarty::SCOPE_BUBBLE_UP;
+ }
}
}
+ // set flag to cache subtemplate object when called within loop or template name is variable.
+ if ($cache_tpl || $variable_template || $compiler->loopNesting > 0) {
+ $_cache_tpl = 'true';
+ } else {
+ $_cache_tpl = 'false';
+ }
// assume caching is off
$_caching = Smarty::CACHING_OFF;
@@ -99,31 +158,29 @@ 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;
+ $merge_compiled_includes = ($compiler->smarty->merge_compiled_includes || $_attr['inline'] === true) &&
+ !$compiler->template->source->handler->recompiled;
if ($merge_compiled_includes && $_attr['inline'] !== true) {
// variable template name ?
- if ($compiler->has_variable_string || !((substr_count($include_file, '"') == 2 || substr_count($include_file, "'") == 2)) || substr_count($include_file, '(') != 0 || substr_count($include_file, '$_smarty_tpl->') != 0) {
+ if ($variable_template) {
$merge_compiled_includes = false;
if ($compiler->template->caching) {
// must use individual cache file
//$_attr['caching'] = 1;
}
- if ($compiler->inheritance && $compiler->smarty->inheritance_merge_compiled_includes && $_attr['inline'] !== true) {
- $compiler->trigger_template_error(' variable template file names not allow within {block} tags');
- }
}
// variable compile_id?
if (isset($_attr['compile_id'])) {
- if (!((substr_count($_attr['compile_id'], '"') == 2 || substr_count($_attr['compile_id'], "'") == 2 || is_numeric($_attr['compile_id']))) || substr_count($_attr['compile_id'], '(') != 0 || substr_count($_attr['compile_id'], '$_smarty_tpl->') != 0) {
+ if (!((substr_count($_attr['compile_id'], '"') == 2 || substr_count($_attr['compile_id'], "'") == 2 ||
+ is_numeric($_attr['compile_id']))) || substr_count($_attr['compile_id'], '(') != 0 ||
+ substr_count($_attr['compile_id'], '$_smarty_tpl->') != 0
+ ) {
$merge_compiled_includes = false;
if ($compiler->template->caching) {
// must use individual cache file
//$_attr['caching'] = 1;
}
- if ($compiler->inheritance && $compiler->smarty->inheritance_merge_compiled_includes && $_attr['inline'] !== true) {
- $compiler->trigger_template_error(' variable compile_id not allow within {block} tags');
- }
}
}
}
@@ -167,74 +224,23 @@ class Smarty_Internal_Compile_Include extends Smarty_Internal_CompileBase
$has_compiled_template = false;
if ($merge_compiled_includes) {
- if ($compiler->template->caching && ($compiler->tag_nocache || $compiler->nocache) && $_caching != self::CACHING_NOCACHE_CODE) {
- // $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');
- }
- }
$c_id = isset($_attr['compile_id']) ? $_attr['compile_id'] : $compiler->template->compile_id;
// we must observe different compile_id and caching
- $uid = sha1($c_id . ($_caching ? '--caching' : '--nocaching'));
- $tpl_name = null;
-
- /** @var Smarty_Internal_Template $_smarty_tpl
- * used in evaluated code
- */
- $_smarty_tpl = $compiler->template;
- eval("\$tpl_name = $include_file;");
- if (!isset($compiler->parent_compiler->mergedSubTemplatesData[$tpl_name][$uid])) {
- $compiler->smarty->allow_ambiguous_resources = true;
- $tpl = new $compiler->smarty->template_class ($tpl_name, $compiler->smarty, $compiler->template, $compiler->template->cache_id, $c_id, $_caching);
- // save unique function name
- $compiler->parent_compiler->mergedSubTemplatesData[$tpl_name][$uid]['func'] = $tpl->properties['unifunc'] = 'content_' . str_replace(array('.', ','), '_', uniqid('', true));
- if ($compiler->inheritance) {
- $tpl->compiler->inheritance = true;
- }
- // make sure whole chain gets compiled
- $tpl->mustCompile = true;
- if (!($tpl->source->uncompiled) && $tpl->source->exists) {
- $tpl->compiler->suppressTemplatePropertyHeader = true;
- $compiler->parent_compiler->mergedSubTemplatesData[$tpl_name][$uid]['nocache_hash'] = $tpl->properties['nocache_hash'] = str_replace(array('.', ','), '_', uniqid(rand(), true));
- // get compiled code
- $compiled_code = Smarty_Internal_Extension_CodeFrame::createFunctionFrame($tpl, $tpl->compiler->compileTemplate($tpl, null, $compiler->parent_compiler));
- unset($tpl->compiler);
-
- // remove header code
- $compiled_code = preg_replace("/(<\?php \/\*%%SmartyHeaderCode:{$tpl->properties['nocache_hash']}%%\*\/(.+?)\/\*\/%%SmartyHeaderCode%%\*\/\?>\n)/s", '', $compiled_code);
- if ($tpl->has_nocache_code) {
- // replace nocache_hash
- $compiled_code = str_replace("{$tpl->properties['nocache_hash']}", $compiler->template->properties['nocache_hash'], $compiled_code);
- $compiler->template->has_nocache_code = true;
- }
- $compiler->parent_compiler->mergedSubTemplatesCode[$tpl->properties['unifunc']] = $compiled_code;
- $has_compiled_template = true;
- if (!empty($tpl->required_plugins['compiled'])) {
- foreach ($tpl->required_plugins['compiled'] as $name => $callBack) {
- if (!isset($compiler->template->required_plugins['compiled'][$name])) {
- $compiler->template->required_plugins['compiled'][$name] = $callBack;
- }
- }
- }
- if (!empty($tpl->required_plugins['nocache'])) {
- foreach ($tpl->required_plugins['nocache'] as $name => $callBack) {
- if (!isset($compiler->template->required_plugins['nocache'][$name])) {
- $compiler->template->required_plugins['nocache'][$name] = $callBack;
- }
- }
- }
- unset ($tpl);
- }
+ $t_hash = sha1($c_id . ($_caching ? '--caching' : '--nocaching'));
+ if (!isset($compiler->parent_compiler->mergedSubTemplatesData[$hashResourceName][$t_hash])) {
+ $has_compiled_template =
+ $this->compileInlineTemplate($compiler, $fullResourceName, $_caching, $hashResourceName, $t_hash,
+ $c_id);
} else {
$has_compiled_template = true;
}
}
// delete {include} standard attributes
- unset($_attr['file'], $_attr['assign'], $_attr['cache_id'], $_attr['compile_id'], $_attr['cache_lifetime'], $_attr['nocache'], $_attr['caching'], $_attr['scope'], $_attr['inline']);
+ unset($_attr['file'], $_attr['assign'], $_attr['cache_id'], $_attr['compile_id'], $_attr['cache_lifetime'], $_attr['nocache'], $_attr['caching'], $_attr['scope'], $_attr['inline'], $_attr['bubble_up']);
// remaining attributes must be assigned as smarty variable
$_vars_nc = '';
if (!empty($_attr)) {
- if ($_parent_scope == Smarty::SCOPE_LOCAL) {
+ if ($_scope == Smarty::SCOPE_LOCAL) {
$_pairs = array();
// create variables
foreach ($_attr as $key => $value) {
@@ -243,35 +249,34 @@ class Smarty_Internal_Compile_Include extends Smarty_Internal_CompileBase
}
$_vars = 'array(' . join(',', $_pairs) . ')';
} else {
- $compiler->trigger_template_error('variable passing not allowed in parent/global scope', $compiler->lex->taglineno);
+ $compiler->trigger_template_error('variable passing not allowed in parent/global scope', null, true);
}
} else {
$_vars = 'array()';
}
- $update_compile_id = $compiler->template->caching && !$compiler->tag_nocache && !$compiler->nocache && $_compile_id != '$_smarty_tpl->compile_id';
+ $update_compile_id = $compiler->template->caching && !$compiler->tag_nocache && !$compiler->nocache &&
+ $_compile_id != '$_smarty_tpl->compile_id';
if ($has_compiled_template && !$call_nocache) {
- // if ($has_compiled_template && !$compiler->tag_nocache && !$compiler->nocache) {
- // never call inline templates in nocache mode
- //$compiler->suppressNocacheProcessing = true;
- $_hash = $compiler->parent_compiler->mergedSubTemplatesData[$tpl_name][$uid]['nocache_hash'];
- $_output = "<?php /* Call merged included template \"" . $tpl_name . "\" */\n";
+ $_output = "<?php\n";
if ($update_compile_id) {
$_output .= $compiler->makeNocacheCode("\$_compile_id_save[] = \$_smarty_tpl->compile_id;\n\$_smarty_tpl->compile_id = {$_compile_id};\n");
}
- if (!empty($_vars_nc) && $_caching == 9999 && $_smarty_tpl->caching) {
+ if (!empty($_vars_nc) && $_caching == 9999 && $compiler->template->caching) {
//$compiler->suppressNocacheProcessing = false;
$_output .= substr($compiler->processNocacheCode('<?php ' . $_vars_nc . "?>\n", true), 6, - 3);
//$compiler->suppressNocacheProcessing = true;
}
if (isset($_assign)) {
- $_output .= " \$_smarty_tpl->tpl_vars[$_assign] = new Smarty_Variable(\$_smarty_tpl->getInlineSubTemplate({$include_file}, {$_cache_id}, {$_compile_id}, {$_caching}, {$_cache_lifetime}, {$_vars}, {$_parent_scope}, '{$_hash}', '{$compiler->parent_compiler->mergedSubTemplatesData[$tpl_name][$uid]['func']}'));\n";
- } else {
- $_output .= "echo \$_smarty_tpl->getInlineSubTemplate({$include_file}, {$_cache_id}, {$_compile_id}, {$_caching}, {$_cache_lifetime}, {$_vars}, {$_parent_scope}, '{$_hash}', '{$compiler->parent_compiler->mergedSubTemplatesData[$tpl_name][$uid]['func']}');\n";
+ $_output .= "ob_start();\n";
+ }
+ $_output .= "\$_smarty_tpl->smarty->ext->_subtemplate->render(\$_smarty_tpl, {$fullResourceName}, {$_cache_id}, {$_compile_id}, {$_caching}, {$_cache_lifetime}, {$_vars}, {$_scope}, {$_cache_tpl}, '{$compiler->parent_compiler->mergedSubTemplatesData[$hashResourceName][$t_hash]['uid']}', '{$compiler->parent_compiler->mergedSubTemplatesData[$hashResourceName][$t_hash]['func']}');\n";
+ if (isset($_assign)) {
+ $_output .= "\$_smarty_tpl->assign({$_assign}, ob_get_clean());\n";
}
if ($update_compile_id) {
$_output .= $compiler->makeNocacheCode("\$_smarty_tpl->compile_id = array_pop(\$_compile_id_save);\n");
}
- $_output .= "/* End of included template \"" . $tpl_name . "\" */?>\n";
+ $_output .= "?>\n";
return $_output;
}
@@ -285,9 +290,11 @@ class Smarty_Internal_Compile_Include extends Smarty_Internal_CompileBase
}
// was there an assign attribute
if (isset($_assign)) {
- $_output .= "\$_smarty_tpl->tpl_vars[$_assign] = new Smarty_Variable(\$_smarty_tpl->getSubTemplate ($include_file, $_cache_id, $_compile_id, $_caching, $_cache_lifetime, $_vars, $_parent_scope));\n";
- } else {
- $_output .= "echo \$_smarty_tpl->getSubTemplate ($include_file, $_cache_id, $_compile_id, $_caching, $_cache_lifetime, $_vars, $_parent_scope);\n";
+ $_output .= "ob_start();\n";
+ }
+ $_output .= "\$_smarty_tpl->smarty->ext->_subtemplate->render(\$_smarty_tpl, {$fullResourceName}, $_cache_id, $_compile_id, $_caching, $_cache_lifetime, $_vars, $_scope, {$_cache_tpl});\n";
+ if (isset($_assign)) {
+ $_output .= "\$_smarty_tpl->assign({$_assign}, ob_get_clean());\n";
}
if ($update_compile_id) {
$_output .= "\$_smarty_tpl->compile_id = array_pop(\$_compile_id_save);\n";
@@ -295,4 +302,65 @@ class Smarty_Internal_Compile_Include extends Smarty_Internal_CompileBase
$_output .= "?>\n";
return $_output;
}
+
+ /**
+ * Compile inline sub template
+ *
+ * @param \Smarty_Internal_SmartyTemplateCompiler $compiler
+ * @param $fullResourceName
+ * @param $_caching
+ * @param $hashResourceName
+ * @param $t_hash
+ * @param $c_id
+ *
+ * @return bool
+ */
+ public function compileInlineTemplate(Smarty_Internal_SmartyTemplateCompiler $compiler, $fullResourceName,
+ $_caching, $hashResourceName, $t_hash, $c_id)
+ {
+ $compiler->smarty->allow_ambiguous_resources = true;
+ /* @var Smarty_Internal_Template $tpl */
+ $tpl =
+ new $compiler->smarty->template_class (trim($fullResourceName, '"\''), $compiler->smarty, $compiler->template,
+ $compiler->template->cache_id, $c_id, $_caching);
+ if (!($tpl->source->handler->uncompiled) && $tpl->source->exists) {
+ $compiler->parent_compiler->mergedSubTemplatesData[$hashResourceName][$t_hash]['uid'] = $tpl->source->uid;
+ if (isset($compiler->template->_inheritance)) {
+ $tpl->_inheritance = clone $compiler->template->_inheritance;
+ }
+ $tpl->compiled = new Smarty_Template_Compiled();
+ $tpl->compiled->nocache_hash = $compiler->parent_compiler->template->compiled->nocache_hash;
+ $tpl->loadCompiler();
+ // save unique function name
+ $compiler->parent_compiler->mergedSubTemplatesData[$hashResourceName][$t_hash]['func'] =
+ $tpl->compiled->unifunc = 'content_' . str_replace(array('.', ','), '_', uniqid('', true));
+ // make sure whole chain gets compiled
+ $tpl->mustCompile = true;
+ $compiler->parent_compiler->mergedSubTemplatesData[$hashResourceName][$t_hash]['nocache_hash'] =
+ $tpl->compiled->nocache_hash;
+ // get compiled code
+ $compiled_code = "<?php\n\n";
+ $compiled_code .= "/* Start inline template \"{$tpl->source->type}:{$tpl->source->name}\" =============================*/\n";
+ $compiled_code .= "function {$tpl->compiled->unifunc} (\$_smarty_tpl) {\n";
+ $compiled_code .= "?>\n" . $tpl->compiler->compileTemplateSource($tpl, null, $compiler->parent_compiler);
+ $compiled_code .= "<?php\n";
+ $compiled_code .= "}\n?>\n";
+ $compiled_code .= $tpl->compiler->postFilter($tpl->compiler->blockOrFunctionCode);
+ $compiled_code .= "<?php\n\n";
+ $compiled_code .= "/* End inline template \"{$tpl->source->type}:{$tpl->source->name}\" =============================*/\n";
+ $compiled_code .= "?>";
+ unset($tpl->compiler);
+ if ($tpl->compiled->has_nocache_code) {
+ // replace nocache_hash
+ $compiled_code =
+ str_replace("{$tpl->compiled->nocache_hash}", $compiler->template->compiled->nocache_hash,
+ $compiled_code);
+ $compiler->template->compiled->has_nocache_code = true;
+ }
+ $compiler->parent_compiler->mergedSubTemplatesCode[$tpl->compiled->unifunc] = $compiled_code;
+ return true;
+ } else {
+ return false;
+ }
+ }
}
diff --git a/library/Smarty/libs/sysplugins/smarty_internal_compile_include_php.php b/library/Smarty/libs/sysplugins/smarty_internal_compile_include_php.php
index 76f506c52..e7e62997c 100644
--- a/library/Smarty/libs/sysplugins/smarty_internal_compile_include_php.php
+++ b/library/Smarty/libs/sysplugins/smarty_internal_compile_include_php.php
@@ -23,6 +23,7 @@ class Smarty_Internal_Compile_Include_Php extends Smarty_Internal_CompileBase
* @see Smarty_Internal_CompileBase
*/
public $required_attributes = array('file');
+
/**
* Attribute definition: Overwrites base class.
*
@@ -30,6 +31,7 @@ class Smarty_Internal_Compile_Include_Php extends Smarty_Internal_CompileBase
* @see Smarty_Internal_CompileBase
*/
public $shorttag_order = array('file');
+
/**
* Attribute definition: Overwrites base class.
*
@@ -41,13 +43,14 @@ class Smarty_Internal_Compile_Include_Php extends Smarty_Internal_CompileBase
/**
* Compiles code for the {include_php} tag
*
- * @param array $args array with attributes from parser
- * @param object $compiler compiler object
+ * @param array $args array with attributes from parser
+ * @param \Smarty_Internal_TemplateCompilerBase $compiler compiler object
*
- * @throws SmartyException
- * @return string compiled code
+ * @return string
+ * @throws \SmartyCompilerException
+ * @throws \SmartyException
*/
- public function compile($args, $compiler)
+ public function compile($args, Smarty_Internal_TemplateCompilerBase $compiler)
{
if (!($compiler->smarty instanceof SmartyBC)) {
throw new SmartyException("{include_php} is deprecated, use SmartyBC class to enable");
@@ -60,9 +63,10 @@ class Smarty_Internal_Compile_Include_Php extends Smarty_Internal_CompileBase
*/
$_smarty_tpl = $compiler->template;
$_filepath = false;
- eval('$_file = ' . $_attr['file'] . ';');
+ $_file = null;
+ eval('$_file = @' . $_attr['file'] . ';');
if (!isset($compiler->smarty->security_policy) && file_exists($_file)) {
- $_filepath = $_file;
+ $_filepath = $compiler->smarty->_realpath($_file, true);
} else {
if (isset($compiler->smarty->security_policy)) {
$_dir = $compiler->smarty->security_policy->trusted_dir;
@@ -71,16 +75,16 @@ class Smarty_Internal_Compile_Include_Php extends Smarty_Internal_CompileBase
}
if (!empty($_dir)) {
foreach ((array) $_dir as $_script_dir) {
- $_script_dir = rtrim($_script_dir, '/\\') . DS;
- if (file_exists($_script_dir . $_file)) {
- $_filepath = $_script_dir . $_file;
+ $_path = $compiler->smarty->_realpath($_script_dir . DS . $_file, true);
+ if (file_exists($_path)) {
+ $_filepath = $_path;
break;
}
}
}
}
if ($_filepath == false) {
- $compiler->trigger_template_error("{include_php} file '{$_file}' is not readable", $compiler->lex->taglineno);
+ $compiler->trigger_template_error("{include_php} file '{$_file}' is not readable", null, true);
}
if (isset($compiler->smarty->security_policy)) {
@@ -99,7 +103,7 @@ class Smarty_Internal_Compile_Include_Php extends Smarty_Internal_CompileBase
}
if (isset($_assign)) {
- return "<?php ob_start(); include{$_once} ('{$_filepath}'); \$_smarty_tpl->assign({$_assign},ob_get_contents()); ob_end_clean();?>";
+ return "<?php ob_start();\ninclude{$_once} ('{$_filepath}');\n\$_smarty_tpl->assign({$_assign},ob_get_clean());\n?>";
} else {
return "<?php include{$_once} ('{$_filepath}');?>\n";
}
diff --git a/library/Smarty/libs/sysplugins/smarty_internal_compile_insert.php b/library/Smarty/libs/sysplugins/smarty_internal_compile_insert.php
index 57f273506..2ebde1661 100644
--- a/library/Smarty/libs/sysplugins/smarty_internal_compile_insert.php
+++ b/library/Smarty/libs/sysplugins/smarty_internal_compile_insert.php
@@ -24,6 +24,7 @@ class Smarty_Internal_Compile_Insert extends Smarty_Internal_CompileBase
* @see Smarty_Internal_CompileBase
*/
public $required_attributes = array('name');
+
/**
* Attribute definition: Overwrites base class.
*
@@ -31,6 +32,7 @@ class Smarty_Internal_Compile_Insert extends Smarty_Internal_CompileBase
* @see Smarty_Internal_CompileBase
*/
public $shorttag_order = array('name');
+
/**
* Attribute definition: Overwrites base class.
*
@@ -42,12 +44,13 @@ class Smarty_Internal_Compile_Insert extends Smarty_Internal_CompileBase
/**
* Compiles code for the {insert} tag
*
- * @param array $args array with attributes from parser
- * @param object $compiler compiler object
+ * @param array $args array with attributes from parser
+ * @param \Smarty_Internal_TemplateCompilerBase $compiler compiler object
*
* @return string compiled code
+ * @throws \SmartyCompilerException
*/
- public function compile($args, $compiler)
+ public function compile($args, Smarty_Internal_TemplateCompilerBase $compiler)
{
// check and get attributes
$_attr = $this->getAttributes($compiler, $args);
@@ -63,7 +66,7 @@ class Smarty_Internal_Compile_Insert extends Smarty_Internal_CompileBase
$_output = '<?php ';
// save possible attributes
- eval('$_name = ' . $_attr['name'] . ';');
+ eval('$_name = @' . $_attr['name'] . ';');
if (isset($_attr['assign'])) {
// output will be stored in a smarty variable instead of being displayed
$_assign = $_attr['assign'];
@@ -80,7 +83,7 @@ class Smarty_Internal_Compile_Insert extends Smarty_Internal_CompileBase
$_function = "smarty_insert_{$_name}";
$_smarty_tpl = $compiler->template;
$_filepath = false;
- eval('$_script = ' . $_attr['script'] . ';');
+ eval('$_script = @' . $_attr['script'] . ';');
if (!isset($compiler->smarty->security_policy) && file_exists($_script)) {
$_filepath = $_script;
} else {
@@ -100,13 +103,13 @@ class Smarty_Internal_Compile_Insert extends Smarty_Internal_CompileBase
}
}
if ($_filepath == false) {
- $compiler->trigger_template_error("{insert} missing script file '{$_script}'", $compiler->lex->taglineno);
+ $compiler->trigger_template_error("{insert} missing script file '{$_script}'", null, true);
}
// code for script file loading
$_output .= "require_once '{$_filepath}' ;";
require_once $_filepath;
if (!is_callable($_function)) {
- $compiler->trigger_template_error(" {insert} function '{$_function}' is not callable in script file '{$_script}'", $compiler->lex->taglineno);
+ $compiler->trigger_template_error(" {insert} function '{$_function}' is not callable in script file '{$_script}'", null, true);
}
} else {
$_filepath = 'null';
@@ -115,7 +118,7 @@ class Smarty_Internal_Compile_Insert extends Smarty_Internal_CompileBase
if (!is_callable($_function)) {
// try plugin
if (!$_function = $compiler->getPlugin($_name, 'insert')) {
- $compiler->trigger_template_error("{insert} no function or plugin found for '{$_name}'", $compiler->lex->taglineno);
+ $compiler->trigger_template_error("{insert} no function or plugin found for '{$_name}'", null, true);
}
}
}
@@ -124,7 +127,7 @@ class Smarty_Internal_Compile_Insert extends Smarty_Internal_CompileBase
// convert attributes into parameter array string
$_paramsArray = array();
foreach ($_attr as $_key => $_value) {
- $_paramsArray[] = "'$_key' => $_value";
+ $_paramsArray[] = "'$_key' => $_value";
}
$_params = 'array(' . implode(", ", $_paramsArray) . ')';
// call insert
diff --git a/library/Smarty/libs/sysplugins/smarty_internal_compile_ldelim.php b/library/Smarty/libs/sysplugins/smarty_internal_compile_ldelim.php
index 91b44881e..8c6b701e1 100644
--- a/library/Smarty/libs/sysplugins/smarty_internal_compile_ldelim.php
+++ b/library/Smarty/libs/sysplugins/smarty_internal_compile_ldelim.php
@@ -20,16 +20,17 @@ class Smarty_Internal_Compile_Ldelim extends Smarty_Internal_CompileBase
* Compiles code for the {ldelim} tag
* This tag does output the left delimiter
*
- * @param array $args array with attributes from parser
- * @param object $compiler compiler object
+ * @param array $args array with attributes from parser
+ * @param \Smarty_Internal_TemplateCompilerBase $compiler compiler object
*
* @return string compiled code
+ * @throws \SmartyCompilerException
*/
- public function compile($args, $compiler)
+ public function compile($args, Smarty_Internal_TemplateCompilerBase $compiler)
{
$_attr = $this->getAttributes($compiler, $args);
if ($_attr['nocache'] === true) {
- $compiler->trigger_template_error('nocache option not allowed', $compiler->lex->taglineno);
+ $compiler->trigger_template_error('nocache option not allowed', null, true);
}
// this tag does not return compiled code
$compiler->has_code = true;
diff --git a/library/Smarty/libs/sysplugins/smarty_internal_compile_nocache.php b/library/Smarty/libs/sysplugins/smarty_internal_compile_nocache.php
index 6f63dcb17..b29a993aa 100644
--- a/library/Smarty/libs/sysplugins/smarty_internal_compile_nocache.php
+++ b/library/Smarty/libs/sysplugins/smarty_internal_compile_nocache.php
@@ -27,12 +27,12 @@ class Smarty_Internal_Compile_Nocache extends Smarty_Internal_CompileBase
* Compiles code for the {nocache} tag
* This tag does not generate compiled output. It only sets a compiler flag.
*
- * @param array $args array with attributes from parser
- * @param object $compiler compiler object
+ * @param array $args array with attributes from parser
+ * @param \Smarty_Internal_TemplateCompilerBase $compiler compiler object
*
* @return bool
*/
- public function compile($args, $compiler)
+ public function compile($args, Smarty_Internal_TemplateCompilerBase $compiler)
{
$_attr = $this->getAttributes($compiler, $args);
$this->openTag($compiler, 'nocache', array($compiler->nocache));
@@ -57,12 +57,12 @@ class Smarty_Internal_Compile_Nocacheclose extends Smarty_Internal_CompileBase
* Compiles code for the {/nocache} tag
* This tag does not generate compiled output. It only sets a compiler flag.
*
- * @param array $args array with attributes from parser
- * @param object $compiler compiler object
+ * @param array $args array with attributes from parser
+ * @param \Smarty_Internal_TemplateCompilerBase $compiler compiler object
*
* @return bool
*/
- public function compile($args, $compiler)
+ public function compile($args, Smarty_Internal_TemplateCompilerBase $compiler)
{
$_attr = $this->getAttributes($compiler, $args);
// leave nocache mode
diff --git a/library/Smarty/libs/sysplugins/smarty_internal_compile_private_block_plugin.php b/library/Smarty/libs/sysplugins/smarty_internal_compile_private_block_plugin.php
index 3dff8538e..9e2eea233 100644
--- a/library/Smarty/libs/sysplugins/smarty_internal_compile_private_block_plugin.php
+++ b/library/Smarty/libs/sysplugins/smarty_internal_compile_private_block_plugin.php
@@ -27,15 +27,15 @@ class Smarty_Internal_Compile_Private_Block_Plugin extends Smarty_Internal_Compi
/**
* Compiles code for the execution of block plugin
*
- * @param array $args array with attributes from parser
- * @param object $compiler compiler object
- * @param array $parameter array with compilation parameter
- * @param string $tag name of block plugin
- * @param string $function PHP function name
+ * @param array $args array with attributes from parser
+ * @param \Smarty_Internal_TemplateCompilerBase $compiler compiler object
+ * @param array $parameter array with compilation parameter
+ * @param string $tag name of block plugin
+ * @param string $function PHP function name
*
* @return string compiled code
*/
- public function compile($args, $compiler, $parameter, $tag, $function)
+ public function compile($args, Smarty_Internal_TemplateCompilerBase $compiler, $parameter, $tag, $function)
{
if (!isset($tag[5]) || substr($tag, - 5) != 'close') {
// opening tag of block plugin
@@ -60,7 +60,7 @@ class Smarty_Internal_Compile_Private_Block_Plugin extends Smarty_Internal_Compi
// maybe nocache because of nocache variables or nocache plugin
$compiler->nocache = $compiler->nocache | $compiler->tag_nocache;
// compile code
- $output = "<?php \$_smarty_tpl->smarty->_tag_stack[] = array('{$tag}', {$_params}); \$_block_repeat=true; echo {$function}({$_params}, null, \$_smarty_tpl, \$_block_repeat);while (\$_block_repeat) { ob_start();?>";
+ $output = "<?php \$_smarty_tpl->smarty->_cache['tag_stack'][] = array('{$tag}', {$_params}); \$_block_repeat=true; echo {$function}({$_params}, null, \$_smarty_tpl, \$_block_repeat);while (\$_block_repeat) { ob_start();?>";
} else {
// must endblock be nocache?
if ($compiler->nocache) {
@@ -75,9 +75,13 @@ class Smarty_Internal_Compile_Private_Block_Plugin extends Smarty_Internal_Compi
$mod_pre = $mod_post = '';
} else {
$mod_pre = ' ob_start(); ';
- $mod_post = 'echo ' . $compiler->compileTag('private_modifier', array(), array('modifierlist' => $parameter['modifier_list'], 'value' => 'ob_get_clean()')) . ';';
+ $mod_post = 'echo ' .
+ $compiler->compileTag('private_modifier', array(), array('modifierlist' => $parameter['modifier_list'],
+ 'value' => 'ob_get_clean()')) . ';';
}
- $output = "<?php \$_block_content = ob_get_clean(); \$_block_repeat=false;" . $mod_pre . " echo {$function}({$_params}, \$_block_content, \$_smarty_tpl, \$_block_repeat); " . $mod_post . " } array_pop(\$_smarty_tpl->smarty->_tag_stack);?>";
+ $output = "<?php \$_block_content = ob_get_clean(); \$_block_repeat=false;" . $mod_pre .
+ " echo {$function}({$_params}, \$_block_content, \$_smarty_tpl, \$_block_repeat); " . $mod_post .
+ " } array_pop(\$_smarty_tpl->smarty->_cache['tag_stack']);?>";
}
return $output . "\n";
diff --git a/library/Smarty/libs/sysplugins/smarty_internal_compile_private_function_plugin.php b/library/Smarty/libs/sysplugins/smarty_internal_compile_private_function_plugin.php
index 4fbd4dc18..0d0ab8138 100644
--- a/library/Smarty/libs/sysplugins/smarty_internal_compile_private_function_plugin.php
+++ b/library/Smarty/libs/sysplugins/smarty_internal_compile_private_function_plugin.php
@@ -23,6 +23,7 @@ class Smarty_Internal_Compile_Private_Function_Plugin extends Smarty_Internal_Co
* @see Smarty_Internal_CompileBase
*/
public $required_attributes = array();
+
/**
* Attribute definition: Overwrites base class.
*
@@ -34,15 +35,15 @@ class Smarty_Internal_Compile_Private_Function_Plugin extends Smarty_Internal_Co
/**
* Compiles code for the execution of function plugin
*
- * @param array $args array with attributes from parser
- * @param object $compiler compiler object
+ * @param array $args array with attributes from parser
+ * @param \Smarty_Internal_TemplateCompilerBase $compiler compiler object
* @param array $parameter array with compilation parameter
* @param string $tag name of function plugin
- * @param string $function PHP function name
+ * @param string $function PHP function name
*
* @return string compiled code
*/
- public function compile($args, $compiler, $parameter, $tag, $function)
+ public function compile($args, Smarty_Internal_TemplateCompilerBase $compiler, $parameter, $tag, $function)
{
// This tag does create output
$compiler->has_output = true;
diff --git a/library/Smarty/libs/sysplugins/smarty_internal_compile_private_modifier.php b/library/Smarty/libs/sysplugins/smarty_internal_compile_private_modifier.php
index ba03bfcfa..9594d2ae7 100644
--- a/library/Smarty/libs/sysplugins/smarty_internal_compile_private_modifier.php
+++ b/library/Smarty/libs/sysplugins/smarty_internal_compile_private_modifier.php
@@ -20,13 +20,14 @@ class Smarty_Internal_Compile_Private_Modifier extends Smarty_Internal_CompileBa
/**
* Compiles code for modifier execution
*
- * @param array $args array with attributes from parser
- * @param object $compiler compiler object
- * @param array $parameter array with compilation parameter
+ * @param array $args array with attributes from parser
+ * @param \Smarty_Internal_TemplateCompilerBase $compiler compiler object
+ * @param array $parameter array with compilation parameter
*
* @return string compiled code
+ * @throws \SmartyCompilerException
*/
- public function compile($args, $compiler, $parameter)
+ public function compile($args, Smarty_Internal_TemplateCompilerBase $compiler, $parameter)
{
// check and get attributes
$_attr = $this->getAttributes($compiler, $args);
@@ -52,7 +53,8 @@ class Smarty_Internal_Compile_Private_Modifier extends Smarty_Internal_CompileBa
$output = "{$function}({$params})";
} else {
if (is_object($function[0])) {
- $output = '$_smarty_tpl->smarty->registered_plugins[Smarty::PLUGIN_MODIFIER][\'' . $modifier . '\'][0][0]->' . $function[1] . '(' . $params . ')';
+ $output = '$_smarty_tpl->smarty->registered_plugins[Smarty::PLUGIN_MODIFIER][\'' .
+ $modifier . '\'][0][0]->' . $function[1] . '(' . $params . ')';
} else {
$output = $function[0] . '::' . $function[1] . '(' . $params . ')';
}
@@ -73,7 +75,9 @@ class Smarty_Internal_Compile_Private_Modifier extends Smarty_Internal_CompileBa
// modifiercompiler plugin
if ($compiler->smarty->loadPlugin('smarty_modifiercompiler_' . $modifier)) {
// check if modifier allowed
- if (!is_object($compiler->smarty->security_policy) || $compiler->smarty->security_policy->isTrustedModifier($modifier, $compiler)) {
+ if (!is_object($compiler->smarty->security_policy) ||
+ $compiler->smarty->security_policy->isTrustedModifier($modifier, $compiler)
+ ) {
$plugin = 'smarty_modifiercompiler_' . $modifier;
$output = $plugin($single_modifier, $compiler);
}
@@ -85,7 +89,9 @@ class Smarty_Internal_Compile_Private_Modifier extends Smarty_Internal_CompileBa
// modifier plugin
if ($function = $compiler->getPlugin($modifier, Smarty::PLUGIN_MODIFIER)) {
// check if modifier allowed
- if (!is_object($compiler->smarty->security_policy) || $compiler->smarty->security_policy->isTrustedModifier($modifier, $compiler)) {
+ if (!is_object($compiler->smarty->security_policy) ||
+ $compiler->smarty->security_policy->isTrustedModifier($modifier, $compiler)
+ ) {
$output = "{$function}({$params})";
}
$compiler->known_modifier_type[$modifier] = $type;
@@ -96,7 +102,9 @@ class Smarty_Internal_Compile_Private_Modifier extends Smarty_Internal_CompileBa
// PHP function
if (is_callable($modifier)) {
// check if modifier allowed
- if (!is_object($compiler->smarty->security_policy) || $compiler->smarty->security_policy->isTrustedPhpModifier($modifier, $compiler)) {
+ if (!is_object($compiler->smarty->security_policy) ||
+ $compiler->smarty->security_policy->isTrustedPhpModifier($modifier, $compiler)
+ ) {
$output = "{$modifier}({$params})";
}
$compiler->known_modifier_type[$modifier] = $type;
@@ -105,21 +113,29 @@ class Smarty_Internal_Compile_Private_Modifier extends Smarty_Internal_CompileBa
break;
case 6:
// default plugin handler
- if (isset($compiler->default_handler_plugins[Smarty::PLUGIN_MODIFIER][$modifier]) || (is_callable($compiler->smarty->default_plugin_handler_func) && $compiler->getPluginFromDefaultHandler($modifier, Smarty::PLUGIN_MODIFIER))) {
+ if (isset($compiler->default_handler_plugins[Smarty::PLUGIN_MODIFIER][$modifier]) ||
+ (is_callable($compiler->smarty->default_plugin_handler_func) &&
+ $compiler->getPluginFromDefaultHandler($modifier, Smarty::PLUGIN_MODIFIER))
+ ) {
$function = $compiler->default_handler_plugins[Smarty::PLUGIN_MODIFIER][$modifier][0];
// check if modifier allowed
- if (!is_object($compiler->smarty->security_policy) || $compiler->smarty->security_policy->isTrustedModifier($modifier, $compiler)) {
+ if (!is_object($compiler->smarty->security_policy) ||
+ $compiler->smarty->security_policy->isTrustedModifier($modifier, $compiler)
+ ) {
if (!is_array($function)) {
$output = "{$function}({$params})";
} else {
if (is_object($function[0])) {
- $output = '$_smarty_tpl->smarty->registered_plugins[Smarty::PLUGIN_MODIFIER][\'' . $modifier . '\'][0][0]->' . $function[1] . '(' . $params . ')';
+ $output = '$_smarty_tpl->smarty->registered_plugins[Smarty::PLUGIN_MODIFIER][\'' .
+ $modifier . '\'][0][0]->' . $function[1] . '(' . $params . ')';
} else {
$output = $function[0] . '::' . $function[1] . '(' . $params . ')';
}
}
}
- if (isset($compiler->template->required_plugins['nocache'][$modifier][Smarty::PLUGIN_MODIFIER]['file']) || isset($compiler->template->required_plugins['compiled'][$modifier][Smarty::PLUGIN_MODIFIER]['file'])) {
+ if (isset($compiler->parent_compiler->template->compiled->required_plugins['nocache'][$modifier][Smarty::PLUGIN_MODIFIER]['file']) ||
+ isset($compiler->parent_compiler->template->compiled->required_plugins['compiled'][$modifier][Smarty::PLUGIN_MODIFIER]['file'])
+ ) {
// was a plugin
$compiler->known_modifier_type[$modifier] = 4;
} else {
@@ -130,7 +146,7 @@ class Smarty_Internal_Compile_Private_Modifier extends Smarty_Internal_CompileBa
}
}
if (!isset($compiler->known_modifier_type[$modifier])) {
- $compiler->trigger_template_error("unknown modifier \"" . $modifier . "\"", $compiler->lex->taglineno);
+ $compiler->trigger_template_error("unknown modifier \"" . $modifier . "\"", null, true);
}
}
diff --git a/library/Smarty/libs/sysplugins/smarty_internal_compile_private_object_block_function.php b/library/Smarty/libs/sysplugins/smarty_internal_compile_private_object_block_function.php
index 5418fefff..d2bc5d60c 100644
--- a/library/Smarty/libs/sysplugins/smarty_internal_compile_private_object_block_function.php
+++ b/library/Smarty/libs/sysplugins/smarty_internal_compile_private_object_block_function.php
@@ -27,15 +27,15 @@ class Smarty_Internal_Compile_Private_Object_Block_Function extends Smarty_Inter
/**
* Compiles code for the execution of block plugin
*
- * @param array $args array with attributes from parser
- * @param object $compiler compiler object
- * @param array $parameter array with compilation parameter
- * @param string $tag name of block object
- * @param string $method name of method to call
+ * @param array $args array with attributes from parser
+ * @param \Smarty_Internal_TemplateCompilerBase $compiler compiler object
+ * @param array $parameter array with compilation parameter
+ * @param string $tag name of block object
+ * @param string $method name of method to call
*
* @return string compiled code
*/
- public function compile($args, $compiler, $parameter, $tag, $method)
+ public function compile($args, Smarty_Internal_TemplateCompilerBase $compiler, $parameter, $tag, $method)
{
if (!isset($tag[5]) || substr($tag, - 5) != 'close') {
// opening tag of block plugin
@@ -60,7 +60,8 @@ class Smarty_Internal_Compile_Private_Object_Block_Function extends Smarty_Inter
// maybe nocache because of nocache variables or nocache plugin
$compiler->nocache = $compiler->nocache | $compiler->tag_nocache;
// compile code
- $output = "<?php \$_smarty_tpl->smarty->_tag_stack[] = array('{$tag}->{$method}', {$_params}); \$_block_repeat=true; echo \$_smarty_tpl->smarty->registered_objects['{$tag}'][0]->{$method}({$_params}, null, \$_smarty_tpl, \$_block_repeat);while (\$_block_repeat) { ob_start();?>";
+ $output =
+ "<?php \$_smarty_tpl->smarty->_cache['tag_stack'][] = array('{$tag}->{$method}', {$_params}); \$_block_repeat=true; echo \$_smarty_tpl->smarty->registered_objects['{$tag}'][0]->{$method}({$_params}, null, \$_smarty_tpl, \$_block_repeat);while (\$_block_repeat) { ob_start();?>";
} else {
$base_tag = substr($tag, 0, - 5);
// must endblock be nocache?
@@ -76,9 +77,13 @@ class Smarty_Internal_Compile_Private_Object_Block_Function extends Smarty_Inter
$mod_pre = $mod_post = '';
} else {
$mod_pre = ' ob_start(); ';
- $mod_post = 'echo ' . $compiler->compileTag('private_modifier', array(), array('modifierlist' => $parameter['modifier_list'], 'value' => 'ob_get_clean()')) . ';';
+ $mod_post = 'echo ' . $compiler->compileTag('private_modifier', array(),
+ array('modifierlist' => $parameter['modifier_list'],
+ 'value' => 'ob_get_clean()')) . ';';
}
- $output = "<?php \$_block_content = ob_get_contents(); ob_end_clean(); \$_block_repeat=false;" . $mod_pre . " echo \$_smarty_tpl->smarty->registered_objects['{$base_tag}'][0]->{$method}({$_params}, \$_block_content, \$_smarty_tpl, \$_block_repeat); " . $mod_post . " } array_pop(\$_smarty_tpl->smarty->_tag_stack);?>";
+ $output = "<?php \$_block_content = ob_get_clean(); \$_block_repeat=false;" . $mod_pre .
+ " echo \$_smarty_tpl->smarty->registered_objects['{$base_tag}'][0]->{$method}({$_params}, \$_block_content, \$_smarty_tpl, \$_block_repeat); " .
+ $mod_post . " } array_pop(\$_smarty_tpl->smarty->_cache['tag_stack']);?>";
}
return $output . "\n";
diff --git a/library/Smarty/libs/sysplugins/smarty_internal_compile_private_object_function.php b/library/Smarty/libs/sysplugins/smarty_internal_compile_private_object_function.php
index d6eb47ab3..e306e0f6d 100644
--- a/library/Smarty/libs/sysplugins/smarty_internal_compile_private_object_function.php
+++ b/library/Smarty/libs/sysplugins/smarty_internal_compile_private_object_function.php
@@ -27,15 +27,15 @@ class Smarty_Internal_Compile_Private_Object_Function extends Smarty_Internal_Co
/**
* Compiles code for the execution of function plugin
*
- * @param array $args array with attributes from parser
- * @param object $compiler compiler object
- * @param array $parameter array with compilation parameter
- * @param string $tag name of function
- * @param string $method name of method to call
+ * @param array $args array with attributes from parser
+ * @param \Smarty_Internal_TemplateCompilerBase $compiler compiler object
+ * @param array $parameter array with compilation parameter
+ * @param string $tag name of function
+ * @param string $method name of method to call
*
* @return string compiled code
*/
- public function compile($args, $compiler, $parameter, $tag, $method)
+ public function compile($args, Smarty_Internal_TemplateCompilerBase $compiler, $parameter, $tag, $method)
{
// check and get attributes
$_attr = $this->getAttributes($compiler, $args);
diff --git a/library/Smarty/libs/sysplugins/smarty_internal_compile_private_php.php b/library/Smarty/libs/sysplugins/smarty_internal_compile_private_php.php
index 0b7958197..584f70b0e 100644
--- a/library/Smarty/libs/sysplugins/smarty_internal_compile_private_php.php
+++ b/library/Smarty/libs/sysplugins/smarty_internal_compile_private_php.php
@@ -42,10 +42,12 @@ class Smarty_Internal_Compile_Private_Php extends Smarty_Internal_CompileBase
$compiler->has_code = false;
if ($_attr['type'] == 'xml') {
$compiler->tag_nocache = true;
- $save = $compiler->template->has_nocache_code;
+ $save = $compiler->template->compiled->has_nocache_code;
$output = addcslashes($_attr['code'], "'\\");
- $compiler->parser->current_buffer->append_subtree(new Smarty_Internal_ParseTree_Tag($compiler->parser, $compiler->processNocacheCode("<?php echo '" . $output . "';?>", $compiler, true)));
- $compiler->template->has_nocache_code = $save;
+ $compiler->parser->current_buffer->append_subtree($compiler->parser, new Smarty_Internal_ParseTree_Tag($compiler->parser, $compiler->processNocacheCode("<?php echo '" .
+ $output .
+ "';?>", $compiler, true)));
+ $compiler->template->compiled->has_nocache_code = $save;
return '';
}
if ($_attr['type'] != 'tag') {
@@ -53,29 +55,31 @@ class Smarty_Internal_Compile_Private_Php extends Smarty_Internal_CompileBase
return '';
} elseif ($compiler->php_handling == Smarty::PHP_QUOTE) {
$output = preg_replace_callback('#(<\?(?:php|=)?)|(<%)|(<script\s+language\s*=\s*["\']?\s*php\s*["\']?\s*>)|(\?>)|(%>)|(<\/script>)#i', array($this,
- 'quote'), $_attr['code']);
- $compiler->parser->current_buffer->append_subtree(new Smarty_Internal_ParseTree_Text($compiler->parser, $output));
+ 'quote'), $_attr['code']);
+ $compiler->parser->current_buffer->append_subtree($compiler->parser, new Smarty_Internal_ParseTree_Text($output));
return '';
} elseif ($compiler->php_handling == Smarty::PHP_PASSTHRU || $_attr['type'] == 'unmatched') {
$compiler->tag_nocache = true;
- $save = $compiler->template->has_nocache_code;
+ $save = $compiler->template->compiled->has_nocache_code;
$output = addcslashes($_attr['code'], "'\\");
- $compiler->parser->current_buffer->append_subtree(new Smarty_Internal_ParseTree_Tag($compiler->parser, $compiler->processNocacheCode("<?php echo '" . $output . "';?>", $compiler, true)));
- $compiler->template->has_nocache_code = $save;
+ $compiler->parser->current_buffer->append_subtree($compiler->parser, new Smarty_Internal_ParseTree_Tag($compiler->parser, $compiler->processNocacheCode("<?php echo '" .
+ $output .
+ "';?>", $compiler, true)));
+ $compiler->template->compiled->has_nocache_code = $save;
return '';
} elseif ($compiler->php_handling == Smarty::PHP_ALLOW) {
if (!($compiler->smarty instanceof SmartyBC)) {
- $compiler->trigger_template_error('$smarty->php_handling PHP_ALLOW not allowed. Use SmartyBC to enable it', $compiler->lex->taglineno);
+ $compiler->trigger_template_error('$smarty->php_handling PHP_ALLOW not allowed. Use SmartyBC to enable it', null, true);
}
$compiler->has_code = true;
return $_attr['code'];
} else {
- $compiler->trigger_template_error('Illegal $smarty->php_handling value', $compiler->lex->taglineno);
+ $compiler->trigger_template_error('Illegal $smarty->php_handling value', null, true);
}
} else {
$compiler->has_code = true;
if (!($compiler->smarty instanceof SmartyBC)) {
- $compiler->trigger_template_error('{php}[/php} tags not allowed. Use SmartyBC to enable them', $compiler->lex->taglineno);
+ $compiler->trigger_template_error('{php}[/php} tags not allowed. Use SmartyBC to enable them', null, true);
}
$ldel = preg_quote($compiler->smarty->left_delimiter, '#');
$rdel = preg_quote($compiler->smarty->right_delimiter, '#');
@@ -84,11 +88,11 @@ class Smarty_Internal_Compile_Private_Php extends Smarty_Internal_CompileBase
if ('nocache' == trim($match[2])) {
$compiler->tag_nocache = true;
} else {
- $compiler->trigger_template_error("illegal value of option flag \"{$match[2]}\"", $compiler->lex->taglineno);
+ $compiler->trigger_template_error("illegal value of option flag \"{$match[2]}\"", null, true);
}
}
return preg_replace(array("#^{$ldel}\\s*php\\s*(.)*?{$rdel}#",
- "#{$ldel}\\s*/\\s*php\\s*{$rdel}$#"), array('<?php ', '?>'), $_attr['code']);
+ "#{$ldel}\\s*/\\s*php\\s*{$rdel}$#"), array('<?php ', '?>'), $_attr['code']);
}
}
@@ -140,7 +144,9 @@ class Smarty_Internal_Compile_Private_Php extends Smarty_Internal_CompileBase
if ($lex->phpType == 'unmatched') {
return;
}
- if (($lex->phpType == 'php' || $lex->phpType == 'asp') && ($lex->compiler->php_handling == Smarty::PHP_PASSTHRU || $lex->compiler->php_handling == Smarty::PHP_QUOTE)) {
+ if (($lex->phpType == 'php' || $lex->phpType == 'asp') &&
+ ($lex->compiler->php_handling == Smarty::PHP_PASSTHRU || $lex->compiler->php_handling == Smarty::PHP_QUOTE)
+ ) {
return;
}
$start = $lex->counter + strlen($lex->value);
@@ -167,7 +173,8 @@ class Smarty_Internal_Compile_Private_Php extends Smarty_Internal_CompileBase
}
}
while ($close > $pos && $close < $start) {
- if (preg_match('~' . preg_quote($closeTag, '~') . '~i', $lex->data, $match, PREG_OFFSET_CAPTURE, $from)) {
+ if (preg_match('~' . preg_quote($closeTag, '~') .
+ '~i', $lex->data, $match, PREG_OFFSET_CAPTURE, $from)) {
$close = $match[0][1];
$from = $close + strlen($match[0][0]);
} else {
@@ -190,6 +197,11 @@ class Smarty_Internal_Compile_Private_Php extends Smarty_Internal_CompileBase
* Call back function for $php_handling = PHP_QUOTE
*
*/
+ /**
+ * @param $match
+ *
+ * @return string
+ */
private function quote($match)
{
return htmlspecialchars($match[0], ENT_QUOTES);
diff --git a/library/Smarty/libs/sysplugins/smarty_internal_compile_private_print_expression.php b/library/Smarty/libs/sysplugins/smarty_internal_compile_private_print_expression.php
index 188bbe77a..c0c089bff 100644
--- a/library/Smarty/libs/sysplugins/smarty_internal_compile_private_print_expression.php
+++ b/library/Smarty/libs/sysplugins/smarty_internal_compile_private_print_expression.php
@@ -23,6 +23,7 @@ class Smarty_Internal_Compile_Private_Print_Expression extends Smarty_Internal_C
* @see Smarty_Internal_CompileBase
*/
public $optional_attributes = array('assign');
+
/**
* Attribute definition: Overwrites base class.
*
@@ -34,14 +35,14 @@ class Smarty_Internal_Compile_Private_Print_Expression extends Smarty_Internal_C
/**
* Compiles code for generating output from any expression
*
- * @param array $args array with attributes from parser
- * @param object $compiler compiler object
- * @param array $parameter array with compilation parameter
+ * @param array $args array with attributes from parser
+ * @param \Smarty_Internal_TemplateCompilerBase $compiler compiler object
+ * @param array $parameter array with compilation parameter
*
- * @throws SmartyException
- * @return string compiled code
+ * @return string
+ * @throws \SmartyException
*/
- public function compile($args, $compiler, $parameter)
+ public function compile($args, Smarty_Internal_TemplateCompilerBase $compiler, $parameter)
{
// check and get attributes
$_attr = $this->getAttributes($compiler, $args);
@@ -57,7 +58,8 @@ class Smarty_Internal_Compile_Private_Print_Expression extends Smarty_Internal_C
$output = $parameter['value'];
// tag modifier
if (!empty($parameter['modifierlist'])) {
- $output = $compiler->compileTag('private_modifier', array(), array('modifierlist' => $parameter['modifierlist'], 'value' => $output));
+ $output = $compiler->compileTag('private_modifier', array(), array('modifierlist' => $parameter['modifierlist'],
+ 'value' => $output));
}
if (!$_attr['nofilter']) {
// default modifier
@@ -74,7 +76,8 @@ class Smarty_Internal_Compile_Private_Print_Expression extends Smarty_Internal_C
}
$compiler->default_modifier_list = $modifierlist;
}
- $output = $compiler->compileTag('private_modifier', array(), array('modifierlist' => $compiler->default_modifier_list, 'value' => $output));
+ $output = $compiler->compileTag('private_modifier', array(), array('modifierlist' => $compiler->default_modifier_list,
+ 'value' => $output));
}
// autoescape html
if ($compiler->template->smarty->escape_html) {
@@ -82,7 +85,8 @@ class Smarty_Internal_Compile_Private_Print_Expression extends Smarty_Internal_C
}
// loop over registered filters
if (!empty($compiler->template->smarty->registered_filters[Smarty::FILTER_VARIABLE])) {
- foreach ($compiler->template->smarty->registered_filters[Smarty::FILTER_VARIABLE] as $key => $function) {
+ foreach ($compiler->template->smarty->registered_filters[Smarty::FILTER_VARIABLE] as $key =>
+ $function) {
if (!is_array($function)) {
$output = "{$function}({$output},\$_smarty_tpl)";
} elseif (is_object($function[0])) {
@@ -104,13 +108,14 @@ class Smarty_Internal_Compile_Private_Print_Expression extends Smarty_Internal_C
}
}
}
- if (isset($compiler->template->variable_filters)) {
- foreach ($compiler->template->variable_filters as $filter) {
- if (count($filter) == 1 && ($result = $this->compile_output_filter($compiler, $filter[0], $output)) !== false) {
- $output = $result;
- } else {
- $output = $compiler->compileTag('private_modifier', array(), array('modifierlist' => array($filter), 'value' => $output));
- }
+ foreach ($compiler->variable_filters as $filter) {
+ if (count($filter) == 1 &&
+ ($result = $this->compile_output_filter($compiler, $filter[0], $output)) !== false
+ ) {
+ $output = $result;
+ } else {
+ $output = $compiler->compileTag('private_modifier', array(), array('modifierlist' => array($filter),
+ 'value' => $output));
}
}
}
@@ -123,23 +128,23 @@ class Smarty_Internal_Compile_Private_Print_Expression extends Smarty_Internal_C
}
/**
- * @param object $compiler compiler object
- * @param string $name name of variable filter
- * @param string $output embedded output
+ * @param \Smarty_Internal_TemplateCompilerBase $compiler compiler object
+ * @param string $name name of variable filter
+ * @param string $output embedded output
*
* @return string
*/
- private function compile_output_filter($compiler, $name, $output)
+ private function compile_output_filter(Smarty_Internal_TemplateCompilerBase $compiler, $name, $output)
{
$plugin_name = "smarty_variablefilter_{$name}";
$path = $compiler->smarty->loadPlugin($plugin_name, false);
if ($path) {
if ($compiler->template->caching) {
- $compiler->template->required_plugins['nocache'][$name][Smarty::FILTER_VARIABLE]['file'] = $path;
- $compiler->template->required_plugins['nocache'][$name][Smarty::FILTER_VARIABLE]['function'] = $plugin_name;
+ $compiler->parent_compiler->template->compiled->required_plugins['nocache'][$name][Smarty::FILTER_VARIABLE]['file'] = $path;
+ $compiler->parent_compiler->template->compiled->required_plugins['nocache'][$name][Smarty::FILTER_VARIABLE]['function'] = $plugin_name;
} else {
- $compiler->template->required_plugins['compiled'][$name][Smarty::FILTER_VARIABLE]['file'] = $path;
- $compiler->template->required_plugins['compiled'][$name][Smarty::FILTER_VARIABLE]['function'] = $plugin_name;
+ $compiler->parent_compiler->template->compiled->required_plugins['compiled'][$name][Smarty::FILTER_VARIABLE]['file'] = $path;
+ $compiler->parent_compiler->template->compiled->required_plugins['compiled'][$name][Smarty::FILTER_VARIABLE]['function'] = $plugin_name;
}
} else {
// not found
diff --git a/library/Smarty/libs/sysplugins/smarty_internal_compile_private_registered_block.php b/library/Smarty/libs/sysplugins/smarty_internal_compile_private_registered_block.php
index 68ab644fc..78d95f720 100644
--- a/library/Smarty/libs/sysplugins/smarty_internal_compile_private_registered_block.php
+++ b/library/Smarty/libs/sysplugins/smarty_internal_compile_private_registered_block.php
@@ -27,14 +27,14 @@ class Smarty_Internal_Compile_Private_Registered_Block extends Smarty_Internal_C
/**
* Compiles code for the execution of a block function
*
- * @param array $args array with attributes from parser
- * @param object $compiler compiler object
- * @param array $parameter array with compilation parameter
- * @param string $tag name of block function
+ * @param array $args array with attributes from parser
+ * @param \Smarty_Internal_TemplateCompilerBase $compiler compiler object
+ * @param array $parameter array with compilation parameter
+ * @param string $tag name of block function
*
* @return string compiled code
*/
- public function compile($args, $compiler, $parameter, $tag)
+ public function compile($args, Smarty_Internal_TemplateCompilerBase $compiler, $parameter, $tag)
{
if (!isset($tag[5]) || substr($tag, - 5) != 'close') {
// opening tag of block plugin
@@ -69,11 +69,11 @@ class Smarty_Internal_Compile_Private_Registered_Block extends Smarty_Internal_C
$function = $tag_info[0];
// compile code
if (!is_array($function)) {
- $output = "<?php \$_smarty_tpl->smarty->_tag_stack[] = array('{$tag}', {$_params}); \$_block_repeat=true; echo {$function}({$_params}, null, \$_smarty_tpl, \$_block_repeat);while (\$_block_repeat) { ob_start();?>";
+ $output = "<?php \$_smarty_tpl->smarty->_cache['tag_stack'][] = array('{$tag}', {$_params}); \$_block_repeat=true; echo {$function}({$_params}, null, \$_smarty_tpl, \$_block_repeat);while (\$_block_repeat) { ob_start();?>";
} elseif (is_object($function[0])) {
- $output = "<?php \$_smarty_tpl->smarty->_tag_stack[] = array('{$tag}', {$_params}); \$_block_repeat=true; echo \$_smarty_tpl->smarty->registered_plugins['block']['{$tag}'][0][0]->{$function[1]}({$_params}, null, \$_smarty_tpl, \$_block_repeat);while (\$_block_repeat) { ob_start();?>";
+ $output = "<?php \$_smarty_tpl->smarty->_cache['tag_stack'][] = array('{$tag}', {$_params}); \$_block_repeat=true; echo \$_smarty_tpl->smarty->registered_plugins['block']['{$tag}'][0][0]->{$function[1]}({$_params}, null, \$_smarty_tpl, \$_block_repeat);while (\$_block_repeat) { ob_start();?>";
} else {
- $output = "<?php \$_smarty_tpl->smarty->_tag_stack[] = array('{$tag}', {$_params}); \$_block_repeat=true; echo {$function[0]}::{$function[1]}({$_params}, null, \$_smarty_tpl, \$_block_repeat);while (\$_block_repeat) { ob_start();?>";
+ $output = "<?php \$_smarty_tpl->smarty->_cache['tag_stack'][] = array('{$tag}', {$_params}); \$_block_repeat=true; echo {$function[0]}::{$function[1]}({$_params}, null, \$_smarty_tpl, \$_block_repeat);while (\$_block_repeat) { ob_start();?>";
}
} else {
// must endblock be nocache?
@@ -95,14 +95,22 @@ class Smarty_Internal_Compile_Private_Registered_Block extends Smarty_Internal_C
$mod_pre = $mod_post = '';
} else {
$mod_pre = ' ob_start(); ';
- $mod_post = 'echo ' . $compiler->compileTag('private_modifier', array(), array('modifierlist' => $parameter['modifier_list'], 'value' => 'ob_get_clean()')) . ';';
+ $mod_post = 'echo ' .
+ $compiler->compileTag('private_modifier', array(), array('modifierlist' => $parameter['modifier_list'],
+ 'value' => 'ob_get_clean()')) . ';';
}
if (!is_array($function)) {
- $output = "<?php \$_block_content = ob_get_clean(); \$_block_repeat=false;" . $mod_pre . " echo {$function}({$_params}, \$_block_content, \$_smarty_tpl, \$_block_repeat);" . $mod_post . " } array_pop(\$_smarty_tpl->smarty->_tag_stack);?>";
+ $output = "<?php \$_block_content = ob_get_clean(); \$_block_repeat=false;" . $mod_pre .
+ " echo {$function}({$_params}, \$_block_content, \$_smarty_tpl, \$_block_repeat);" . $mod_post .
+ " } array_pop(\$_smarty_tpl->smarty->_cache['tag_stack']);?>";
} elseif (is_object($function[0])) {
- $output = "<?php \$_block_content = ob_get_clean(); \$_block_repeat=false;" . $mod_pre . " echo \$_smarty_tpl->smarty->registered_plugins['block']['{$base_tag}'][0][0]->{$function[1]}({$_params}, \$_block_content, \$_smarty_tpl, \$_block_repeat); " . $mod_post . "} array_pop(\$_smarty_tpl->smarty->_tag_stack);?>";
+ $output = "<?php \$_block_content = ob_get_clean(); \$_block_repeat=false;" . $mod_pre .
+ " echo \$_smarty_tpl->smarty->registered_plugins['block']['{$base_tag}'][0][0]->{$function[1]}({$_params}, \$_block_content, \$_smarty_tpl, \$_block_repeat); " .
+ $mod_post . "} array_pop(\$_smarty_tpl->smarty->_cache['tag_stack']);?>";
} else {
- $output = "<?php \$_block_content = ob_get_clean(); \$_block_repeat=false;" . $mod_pre . " echo {$function[0]}::{$function[1]}({$_params}, \$_block_content, \$_smarty_tpl, \$_block_repeat); " . $mod_post . "} array_pop(\$_smarty_tpl->smarty->_tag_stack);?>";
+ $output = "<?php \$_block_content = ob_get_clean(); \$_block_repeat=false;" . $mod_pre .
+ " echo {$function[0]}::{$function[1]}({$_params}, \$_block_content, \$_smarty_tpl, \$_block_repeat); " .
+ $mod_post . "} array_pop(\$_smarty_tpl->smarty->_cache['tag_stack']);?>";
}
}
diff --git a/library/Smarty/libs/sysplugins/smarty_internal_compile_private_registered_function.php b/library/Smarty/libs/sysplugins/smarty_internal_compile_private_registered_function.php
index dfb4572f4..6bddc7529 100644
--- a/library/Smarty/libs/sysplugins/smarty_internal_compile_private_registered_function.php
+++ b/library/Smarty/libs/sysplugins/smarty_internal_compile_private_registered_function.php
@@ -27,14 +27,14 @@ class Smarty_Internal_Compile_Private_Registered_Function extends Smarty_Interna
/**
* Compiles code for the execution of a registered function
*
- * @param array $args array with attributes from parser
- * @param object $compiler compiler object
- * @param array $parameter array with compilation parameter
- * @param string $tag name of function
+ * @param array $args array with attributes from parser
+ * @param \Smarty_Internal_TemplateCompilerBase $compiler compiler object
+ * @param array $parameter array with compilation parameter
+ * @param string $tag name of function
*
* @return string compiled code
*/
- public function compile($args, $compiler, $parameter, $tag)
+ public function compile($args, Smarty_Internal_TemplateCompilerBase $compiler, $parameter, $tag)
{
// This tag does create output
$compiler->has_output = true;
diff --git a/library/Smarty/libs/sysplugins/smarty_internal_compile_private_special_variable.php b/library/Smarty/libs/sysplugins/smarty_internal_compile_private_special_variable.php
index 525bc0db7..5a8c54faa 100644
--- a/library/Smarty/libs/sysplugins/smarty_internal_compile_private_special_variable.php
+++ b/library/Smarty/libs/sysplugins/smarty_internal_compile_private_special_variable.php
@@ -19,44 +19,51 @@ class Smarty_Internal_Compile_Private_Special_Variable extends Smarty_Internal_C
/**
* Compiles code for the special $smarty variables
*
- * @param array $args array with attributes from parser
- * @param object $compiler compiler object
- * @param $parameter
+ * @param array $args array with attributes from parser
+ * @param \Smarty_Internal_TemplateCompilerBase $compiler compiler object
+ * @param $parameter
*
* @return string compiled code
+ * @throws \SmartyCompilerException
*/
- public function compile($args, $compiler, $parameter)
+ public function compile($args, Smarty_Internal_TemplateCompilerBase $compiler, $parameter)
{
$_index = preg_split("/\]\[/", substr($parameter, 1, strlen($parameter) - 2));
- $compiled_ref = ' ';
- $variable = trim($_index[0], "'");
- if (!isset($compiler->smarty->security_policy) || $compiler->smarty->security_policy->isTrustedSpecialSmartyVar($variable, $compiler)) {
+ $variable = strtolower($compiler->getId($_index[0]));
+ if ($variable === false) {
+ $compiler->trigger_template_error("special \$Smarty variable name index can not be variable", null, true);
+ }
+ if (!isset($compiler->smarty->security_policy) ||
+ $compiler->smarty->security_policy->isTrustedSpecialSmartyVar($variable, $compiler)
+ ) {
switch ($variable) {
case 'foreach':
- $name = trim($_index[1], "'");
- $foreachVar = "'__foreach_{$name}'";
- return "(isset(\$_smarty_tpl->tpl_vars[$foreachVar]->value[{$_index[2]}]) ? \$_smarty_tpl->tpl_vars[$foreachVar]->value[{$_index[2]}] : null)";
case 'section':
- return "\$_smarty_tpl->getVariable('smarty')->value$parameter";
+ return Smarty_Internal_Compile_Private_ForeachSection::compileSpecialVariable(array(), $compiler, $_index);
case 'capture':
- return "Smarty::\$_smarty_vars$parameter";
+ if (class_exists('Smarty_Internal_Compile_Capture')) {
+ return Smarty_Internal_Compile_Capture::compileSpecialVariable(array(), $compiler, $_index);
+ }
+ return '';
case 'now':
return 'time()';
case 'cookies':
- if (isset($compiler->smarty->security_policy) && !$compiler->smarty->security_policy->allow_super_globals) {
+ if (isset($compiler->smarty->security_policy) &&
+ !$compiler->smarty->security_policy->allow_super_globals
+ ) {
$compiler->trigger_template_error("(secure mode) super globals not permitted");
break;
}
- $compiled_ref = '$_COOKIE';
- break;
-
+ return '$_COOKIE';
case 'get':
case 'post':
case 'env':
case 'server':
case 'session':
case 'request':
- if (isset($compiler->smarty->security_policy) && !$compiler->smarty->security_policy->allow_super_globals) {
+ if (isset($compiler->smarty->security_policy) &&
+ !$compiler->smarty->security_policy->allow_super_globals
+ ) {
$compiler->trigger_template_error("(secure mode) super globals not permitted");
break;
}
@@ -78,11 +85,13 @@ class Smarty_Internal_Compile_Private_Special_Variable extends Smarty_Internal_C
return "'$_version'";
case 'const':
- if (isset($compiler->smarty->security_policy) && !$compiler->smarty->security_policy->allow_constants) {
+ if (isset($compiler->smarty->security_policy) &&
+ !$compiler->smarty->security_policy->allow_constants
+ ) {
$compiler->trigger_template_error("(secure mode) constants not permitted");
break;
}
- if (strpos($_index[1], '$') === false && strpos($_index[1], '\'') === false ) {
+ if (strpos($_index[1], '$') === false && strpos($_index[1], '\'') === false) {
return "@constant('{$_index[1]}')";
} else {
return "@constant({$_index[1]})";
@@ -90,9 +99,9 @@ class Smarty_Internal_Compile_Private_Special_Variable extends Smarty_Internal_C
case 'config':
if (isset($_index[2])) {
- return "(is_array(\$tmp = \$_smarty_tpl->getConfigVariable($_index[1])) ? \$tmp[$_index[2]] : null)";
+ return "(is_array(\$tmp = \$_smarty_tpl->smarty->ext->_config->_getConfigVariable(\$_smarty_tpl, $_index[1])) ? \$tmp[$_index[2]] : null)";
} else {
- return "\$_smarty_tpl->getConfigVariable($_index[1])";
+ return "\$_smarty_tpl->smarty->ext->_config->_getConfigVariable(\$_smarty_tpl, $_index[1])";
}
case 'ldelim':
$_ldelim = $compiler->smarty->left_delimiter;
@@ -114,7 +123,7 @@ class Smarty_Internal_Compile_Private_Special_Variable extends Smarty_Internal_C
$compiled_ref = $compiled_ref . "[$_ind]";
}
}
+ return $compiled_ref;
}
- return $compiled_ref;
}
}
diff --git a/library/Smarty/libs/sysplugins/smarty_internal_compile_rdelim.php b/library/Smarty/libs/sysplugins/smarty_internal_compile_rdelim.php
index dcff2ae41..22b33eaa2 100644
--- a/library/Smarty/libs/sysplugins/smarty_internal_compile_rdelim.php
+++ b/library/Smarty/libs/sysplugins/smarty_internal_compile_rdelim.php
@@ -25,11 +25,11 @@ class Smarty_Internal_Compile_Rdelim extends Smarty_Internal_CompileBase
*
* @return string compiled code
*/
- public function compile($args, $compiler)
+ public function compile($args, Smarty_Internal_TemplateCompilerBase $compiler)
{
$_attr = $this->getAttributes($compiler, $args);
if ($_attr['nocache'] === true) {
- $compiler->trigger_template_error('nocache option not allowed', $compiler->lex->taglineno);
+ $compiler->trigger_template_error('nocache option not allowed', null, true);
}
// this tag does not return compiled code
$compiler->has_code = true;
diff --git a/library/Smarty/libs/sysplugins/smarty_internal_compile_section.php b/library/Smarty/libs/sysplugins/smarty_internal_compile_section.php
index 5ac3fb067..079903c2b 100644
--- a/library/Smarty/libs/sysplugins/smarty_internal_compile_section.php
+++ b/library/Smarty/libs/sysplugins/smarty_internal_compile_section.php
@@ -14,7 +14,7 @@
* @package Smarty
* @subpackage Compiler
*/
-class Smarty_Internal_Compile_Section extends Smarty_Internal_CompileBase
+class Smarty_Internal_Compile_Section extends Smarty_Internal_Compile_Private_ForeachSection
{
/**
* Attribute definition: Overwrites base class.
@@ -23,6 +23,7 @@ class Smarty_Internal_Compile_Section extends Smarty_Internal_CompileBase
* @see Smarty_Internal_CompileBase
*/
public $required_attributes = array('name', 'loop');
+
/**
* Attribute definition: Overwrites base class.
*
@@ -30,6 +31,7 @@ class Smarty_Internal_Compile_Section extends Smarty_Internal_CompileBase
* @see Smarty_Internal_CompileBase
*/
public $shorttag_order = array('name', 'loop');
+
/**
* Attribute definition: Overwrites base class.
*
@@ -39,102 +41,342 @@ class Smarty_Internal_Compile_Section extends Smarty_Internal_CompileBase
public $optional_attributes = array('start', 'step', 'max', 'show');
/**
+ * counter
+ *
+ * @var int
+ */
+ public $counter = 0;
+
+ /**
+ * Name of this tag
+ *
+ * @var string
+ */
+ public $tagName = 'section';
+
+ /**
+ * Valid properties of $smarty.section.name.xxx variable
+ *
+ * @var array
+ */
+ public static $nameProperties = array('first', 'last', 'index', 'iteration', 'show', 'total', 'rownum',
+ 'index_prev', 'index_next');
+
+ /**
+ * {section} tag has no item properties
+ *
+ * @var array
+ */
+ public $itemProperties = null;
+
+ /**
+ * {section} tag has always name attribute
+ *
+ * @var bool
+ */
+ public $isNamed = true;
+
+ /**
* Compiles code for the {section} tag
*
- * @param array $args array with attributes from parser
- * @param object $compiler compiler object
+ * @param array $args array with attributes from parser
+ * @param \Smarty_Internal_TemplateCompilerBase $compiler compiler object
*
* @return string compiled code
+ * @throws \SmartyCompilerException
*/
- public function compile($args, $compiler)
+ public function compile($args, Smarty_Internal_TemplateCompilerBase $compiler)
{
+ $compiler->loopNesting++;
// check and get attributes
$_attr = $this->getAttributes($compiler, $args);
-
- $this->openTag($compiler, 'section', array('section', $compiler->nocache));
+ $attributes = array('name' => $compiler->getId($_attr['name']));
+ unset($_attr['name']);
+ foreach ($attributes as $a => $v) {
+ if ($v === false) {
+ $compiler->trigger_template_error("'{$a}' attribute/variable has illegal value", null, true);
+ }
+ }
+ $local = "\$__section_{$attributes['name']}_" . $this->counter ++ . '_';
+ $sectionVar = "\$_smarty_tpl->tpl_vars['__smarty_section_{$attributes['name']}']";
+ $this->openTag($compiler, 'section', array('section', $compiler->nocache, $local, $sectionVar));
// maybe nocache because of nocache variables
$compiler->nocache = $compiler->nocache | $compiler->tag_nocache;
- $output = "<?php ";
-
- $section_name = $_attr['name'];
-
- $output .= "if (isset(\$_smarty_tpl->tpl_vars['smarty']->value['section'][$section_name])) unset(\$_smarty_tpl->tpl_vars['smarty']->value['section'][$section_name]);\n";
- $section_props = "\$_smarty_tpl->tpl_vars['smarty']->value['section'][$section_name]";
+ $initLocal = array('saved' => "isset(\$_smarty_tpl->tpl_vars['__smarty_section_{$attributes['name']}']) ? \$_smarty_tpl->tpl_vars['__section_{$attributes['name']}'] : false",);
+ $initNamedProperty = array();
+ $initFor = array();
+ $incFor = array();
+ $cmpFor = array();
+ $propValue = array('index' => "{$sectionVar}->value['index']", 'show' => 'true', 'step' => 1,
+ 'iteration' => "{$local}iteration",
+ );
+ $propType = array('index' => 2, 'iteration' => 2, 'show' => 0, 'step' => 0,);
+ // search for used tag attributes
+ $this->scanForProperties($attributes, $compiler);
+ if (!empty($this->matchResults['named'])) {
+ $namedAttr = $this->matchResults['named'];
+ }
+ $namedAttr['index'] = true;
+ $output = "<?php\n";
foreach ($_attr as $attr_name => $attr_value) {
switch ($attr_name) {
case 'loop':
- $output .= "{$section_props}['loop'] = is_array(\$_loop=$attr_value) ? count(\$_loop) : max(0, (int) \$_loop); unset(\$_loop);\n";
+ if (is_numeric($attr_value)) {
+ $v = (int) $attr_value;
+ $t = 0;
+ } else {
+ $v = "(is_array(@\$_loop=$attr_value) ? count(\$_loop) : max(0, (int) \$_loop))";
+ $t = 1;
+ }
+ if (isset($namedAttr['loop'])) {
+ $initNamedProperty['loop'] = "'loop' => {$v}";
+ if ($t == 1) {
+ $v = "{$sectionVar}->value['loop']";
+ }
+ } elseif ($t == 1) {
+ $initLocal['loop'] = $v;
+ $v = "{$local}loop";
+ }
break;
-
case 'show':
if (is_bool($attr_value)) {
- $show_attr_value = $attr_value ? 'true' : 'false';
+ $v = $attr_value ? 'true' : 'false';
+ $t = 0;
} else {
- $show_attr_value = "(bool) $attr_value";
+ $v = "(bool) $attr_value";
+ $t = 3;
}
- $output .= "{$section_props}['show'] = $show_attr_value;\n";
break;
-
- case 'name':
- $output .= "{$section_props}['$attr_name'] = $attr_value;\n";
+ case 'step':
+ if (is_numeric($attr_value)) {
+ $v = (int) $attr_value;
+ $v = ($v == 0) ? 1 : $v;
+ $t = 0;
+ break;
+ }
+ $initLocal['step'] = "((int)@$attr_value) == 0 ? 1 : (int)@$attr_value";
+ $v = "{$local}step";
+ $t = 2;
break;
case 'max':
case 'start':
- $output .= "{$section_props}['$attr_name'] = (int) $attr_value;\n";
- break;
-
- case 'step':
- $output .= "{$section_props}['$attr_name'] = ((int) $attr_value) == 0 ? 1 : (int) $attr_value;\n";
+ if (is_numeric($attr_value)) {
+ $v = (int) $attr_value;
+ $t = 0;
+ break;
+ }
+ $v = "(int)@$attr_value";
+ $t = 3;
break;
}
+ if ($t == 3 && $compiler->getId($attr_value)) {
+ $t = 1;
+ }
+ $propValue[$attr_name] = $v;
+ $propType[$attr_name] = $t;
}
- if (!isset($_attr['show'])) {
- $output .= "{$section_props}['show'] = true;\n";
+ if (isset($namedAttr['step'])) {
+ $initNamedProperty['step'] = $propValue['step'];
}
-
- if (!isset($_attr['loop'])) {
- $output .= "{$section_props}['loop'] = 1;\n";
+ if (isset($namedAttr['iteration'])) {
+ $propValue['iteration'] = "{$sectionVar}->value['iteration']";
}
+ $incFor['iteration'] = "{$propValue['iteration']}++";
+ $initFor['iteration'] = "{$propValue['iteration']} = 1";
- if (!isset($_attr['max'])) {
- $output .= "{$section_props}['max'] = {$section_props}['loop'];\n";
+ if ($propType['step'] == 0) {
+ if ($propValue['step'] == 1) {
+ $incFor['index'] = "{$sectionVar}->value['index']++";
+ } elseif ($propValue['step'] > 1) {
+ $incFor['index'] = "{$sectionVar}->value['index'] += {$propValue['step']}";
+ } else {
+ $incFor['index'] = "{$sectionVar}->value['index'] -= " . - $propValue['step'];
+ }
} else {
- $output .= "if ({$section_props}['max'] < 0)\n" . " {$section_props}['max'] = {$section_props}['loop'];\n";
+ $incFor['index'] = "{$sectionVar}->value['index'] += {$propValue['step']}";
}
- if (!isset($_attr['step'])) {
- $output .= "{$section_props}['step'] = 1;\n";
+ if (!isset($propValue['max'])) {
+ $propValue['max'] = $propValue['loop'];
+ $propType['max'] = $propType['loop'];
+ } elseif ($propType['max'] != 0) {
+ $propValue['max'] = "{$propValue['max']} < 0 ? {$propValue['loop']} : {$propValue['max']}";
+ $propType['max'] = 1;
+ } else {
+ if ($propValue['max'] < 0) {
+ $propValue['max'] = $propValue['loop'];
+ $propType['max'] = $propType['loop'];
+ }
}
- if (!isset($_attr['start'])) {
- $output .= "{$section_props}['start'] = {$section_props}['step'] > 0 ? 0 : {$section_props}['loop']-1;\n";
+ if (!isset($propValue['start'])) {
+ $start_code = array(1 => "{$propValue['step']} > 0 ? ", 2 => '0', 3 => ' : ', 4 => $propValue['loop'],
+ 5 => ' - 1');
+ if ($propType['loop'] == 0) {
+ $start_code[5] = '';
+ $start_code[4] = $propValue['loop'] - 1;
+ }
+ if ($propType['step'] == 0) {
+ if ($propValue['step'] > 0) {
+ $start_code = array(1 => '0');
+ $propType['start'] = 0;
+ } else {
+ $start_code[1] = $start_code[2] = $start_code[3] = '';
+ $propType['start'] = $propType['loop'];
+ }
+ } else {
+ $propType['start'] = 1;
+ }
+ $propValue['start'] = join('', $start_code);
} else {
- $output .= "if ({$section_props}['start'] < 0)\n" . " {$section_props}['start'] = max({$section_props}['step'] > 0 ? 0 : -1, {$section_props}['loop'] + {$section_props}['start']);\n" . "else\n" . " {$section_props}['start'] = min({$section_props}['start'], {$section_props}['step'] > 0 ? {$section_props}['loop'] : {$section_props}['loop']-1);\n";
+ $start_code = array(1 => "{$propValue['start']} < 0 ? ", 2 => 'max(', 3 => "{$propValue['step']} > 0 ? ",
+ 4 => '0', 5 => ' : ', 6 => '-1', 7 => ', ',
+ 8 => "{$propValue['start']} + {$propValue['loop']}", 10 => ')', 11 => ' : ',
+ 12 => 'min(', 13 => $propValue['start'], 14 => ', ',
+ 15 => "{$propValue['step']} > 0 ? ", 16 => $propValue['loop'], 17 => ' : ',
+ 18 => $propType['loop'] == 0 ? $propValue['loop'] - 1 : "{$propValue['loop']} - 1",
+ 19 => ')');
+ if ($propType['step'] == 0) {
+ $start_code[3] = $start_code[5] = $start_code[15] = $start_code[17] = '';
+ if ($propValue['step'] > 0) {
+ $start_code[6] = $start_code[18] = '';
+ } else {
+ $start_code[4] = $start_code[16] = '';
+ }
+ }
+ if ($propType['start'] == 0) {
+ if ($propType['loop'] == 0) {
+ $start_code[8] = $propValue['start'] + $propValue['loop'];
+ }
+ $propType['start'] = $propType['step'] + $propType['loop'];
+ $start_code[1] = '';
+ if ($propValue['start'] < 0) {
+ for ($i = 11; $i <= 19; $i ++) {
+ $start_code[$i] = '';
+ }
+ if ($propType['start'] == 0) {
+ $start_code = array(max($propValue['step'] > 0 ? 0 : - 1, $propValue['start'] +
+ $propValue['loop']));
+ }
+ } else {
+ for ($i = 1; $i <= 11; $i ++) {
+ $start_code[$i] = '';
+ }
+ if ($propType['start'] == 0) {
+ $start_code = array(min($propValue['step'] > 0 ? $propValue['loop'] : $propValue['loop'] -
+ 1, $propValue['start']));
+ }
+ }
+ }
+ $propValue['start'] = join('', $start_code);
+ }
+ if ($propType['start'] != 0) {
+ $initLocal['start'] = $propValue['start'];
+ $propValue['start'] = "{$local}start";
}
- $output .= "if ({$section_props}['show']) {\n";
+ $initFor['index'] = "{$sectionVar}->value['index'] = {$propValue['start']}";
+
if (!isset($_attr['start']) && !isset($_attr['step']) && !isset($_attr['max'])) {
- $output .= " {$section_props}['total'] = {$section_props}['loop'];\n";
+ $propValue['total'] = $propValue['loop'];
+ $propType['total'] = $propType['loop'];
} else {
- $output .= " {$section_props}['total'] = min(ceil(({$section_props}['step'] > 0 ? {$section_props}['loop'] - {$section_props}['start'] : {$section_props}['start']+1)/abs({$section_props}['step'])), {$section_props}['max']);\n";
+ $propType['total'] = $propType['start'] + $propType['loop'] + $propType['step'] + $propType['max'];
+ if ($propType['total'] == 0) {
+ $propValue['total'] = min(ceil(($propValue['step'] > 0 ? $propValue['loop'] -
+ $propValue['start'] : (int) $propValue['start'] + 1) /
+ abs($propValue['step'])), $propValue['max']);
+ } else {
+ $total_code = array(1 => 'min(', 2 => 'ceil(', 3 => '(', 4 => "{$propValue['step']} > 0 ? ",
+ 5 => $propValue['loop'], 6 => ' - ', 7 => $propValue['start'], 8 => ' : ',
+ 9 => $propValue['start'], 10 => '+ 1', 11 => ')', 12 => '/ ', 13 => 'abs(',
+ 14 => $propValue['step'], 15 => ')', 16 => ')', 17 => ", {$propValue['max']})",);
+ if (!isset($propValue['max'])) {
+ $total_code[1] = $total_code[17] = '';
+ }
+ if ($propType['loop'] + $propType['start'] == 0) {
+ $total_code[5] = $propValue['loop'] - $propValue['start'];
+ $total_code[6] = $total_code[7] = '';
+ }
+ if ($propType['start'] == 0) {
+ $total_code[9] = (int) $propValue['start'] + 1;
+ $total_code[10] = '';
+ }
+ if ($propType['step'] == 0) {
+ $total_code[13] = $total_code[15] = '';
+ if ($propValue['step'] == 1 || $propValue['step'] == - 1) {
+ $total_code[2] = $total_code[12] = $total_code[14] = $total_code[16] = '';
+ } elseif ($propValue['step'] < 0) {
+ $total_code[14] = - $propValue['step'];
+ }
+ $total_code[4] = '';
+ if ($propValue['step'] > 0) {
+ $total_code[8] = $total_code[9] = $total_code[10] = '';
+ } else {
+ $total_code[5] = $total_code[6] = $total_code[7] = $total_code[8] = '';
+ }
+ }
+ $propValue['total'] = join('', $total_code);
+ }
}
- $output .= " if ({$section_props}['total'] == 0)\n" . " {$section_props}['show'] = false;\n" . "} else\n" . " {$section_props}['total'] = 0;\n";
- $output .= "if ({$section_props}['show']):\n";
- $output .= "
- for ({$section_props}['index'] = {$section_props}['start'], {$section_props}['iteration'] = 1;
- {$section_props}['iteration'] <= {$section_props}['total'];
- {$section_props}['index'] += {$section_props}['step'], {$section_props}['iteration']++):\n";
- $output .= "{$section_props}['rownum'] = {$section_props}['iteration'];\n";
- $output .= "{$section_props}['index_prev'] = {$section_props}['index'] - {$section_props}['step'];\n";
- $output .= "{$section_props}['index_next'] = {$section_props}['index'] + {$section_props}['step'];\n";
- $output .= "{$section_props}['first'] = ({$section_props}['iteration'] == 1);\n";
- $output .= "{$section_props}['last'] = ({$section_props}['iteration'] == {$section_props}['total']);\n";
+ if (isset($namedAttr['total'])) {
+ $initNamedProperty['total'] = "'total' => {$propValue['total']}";
+ if ($propType['total'] > 0) {
+ $propValue['total'] = "{$sectionVar}->value['total']";
+ }
+ } elseif ($propType['total'] > 0) {
+ $initLocal['total'] = $propValue['total'];
+ $propValue['total'] = "{$local}total";
+ }
+
+ $cmpFor['iteration'] = "{$propValue['iteration']} <= {$propValue['total']}";
+
+ foreach ($initLocal as $key => $code) {
+ $output .= "{$local}{$key} = {$code};\n";
+ }
+ $_vars = 'array(' . join(', ', $initNamedProperty) . ')';
+ $output .= "{$sectionVar} = new Smarty_Variable({$_vars});\n";
+ $cond_code = "{$propValue['total']} != 0";
+ if ($propType['total'] == 0) {
+ if ($propValue['total'] == 0) {
+ $cond_code = 'false';
+ } else {
+ $cond_code = 'true';
+ }
+ }
+ if ($propType['show'] > 0) {
+ $output .= "{$local}show = {$propValue['show']} ? {$cond_code} : false;\n";
+ $output .= "if ({$local}show) {\n";
+ } elseif ($propValue['show'] == 'true') {
+ $output .= "if ({$cond_code}) {\n";
+ } else {
+ $output .= "if (false) {\n";
+ }
+ $jinit = join(', ', $initFor);
+ $jcmp = join(', ', $cmpFor);
+ $jinc = join(', ', $incFor);
+ $output .= "for ({$jinit}; {$jcmp}; {$jinc}){\n";
+ if (isset($namedAttr['rownum'])) {
+ $output .= "{$sectionVar}->value['rownum'] = {$propValue['iteration']};\n";
+ }
+ if (isset($namedAttr['index_prev'])) {
+ $output .= "{$sectionVar}->value['index_prev'] = {$propValue['index']} - {$propValue['step']};\n";
+ }
+ if (isset($namedAttr['index_next'])) {
+ $output .= "{$sectionVar}->value['index_next'] = {$propValue['index']} + {$propValue['step']};\n";
+ }
+ if (isset($namedAttr['first'])) {
+ $output .= "{$sectionVar}->value['first'] = ({$propValue['iteration']} == 1);\n";
+ }
+ if (isset($namedAttr['last'])) {
+ $output .= "{$sectionVar}->value['last'] = ({$propValue['iteration']} == {$propValue['total']});\n";
+ }
$output .= "?>";
return $output;
@@ -152,20 +394,20 @@ class Smarty_Internal_Compile_Sectionelse extends Smarty_Internal_CompileBase
/**
* Compiles code for the {sectionelse} tag
*
- * @param array $args array with attributes from parser
- * @param object $compiler compiler object
+ * @param array $args array with attributes from parser
+ * @param \Smarty_Internal_TemplateCompilerBase $compiler compiler object
*
* @return string compiled code
*/
- public function compile($args, $compiler)
+ public function compile($args, Smarty_Internal_TemplateCompilerBase $compiler)
{
// check and get attributes
$_attr = $this->getAttributes($compiler, $args);
- list($openTag, $nocache) = $this->closeTag($compiler, array('section'));
- $this->openTag($compiler, 'sectionelse', array('sectionelse', $nocache));
+ list($openTag, $nocache, $local, $sectionVar) = $this->closeTag($compiler, array('section'));
+ $this->openTag($compiler, 'sectionelse', array('sectionelse', $nocache, $local, $sectionVar));
- return "<?php endfor; else: ?>";
+ return "<?php }} else {\n ?>";
}
}
@@ -180,27 +422,33 @@ class Smarty_Internal_Compile_Sectionclose extends Smarty_Internal_CompileBase
/**
* Compiles code for the {/section} tag
*
- * @param array $args array with attributes from parser
- * @param object $compiler compiler object
+ * @param array $args array with attributes from parser
+ * @param \Smarty_Internal_TemplateCompilerBase $compiler compiler object
*
* @return string compiled code
*/
- public function compile($args, $compiler)
+ public function compile($args, Smarty_Internal_TemplateCompilerBase $compiler)
{
- // check and get attributes
- $_attr = $this->getAttributes($compiler, $args);
-
+ $compiler->loopNesting--;
// must endblock be nocache?
if ($compiler->nocache) {
$compiler->tag_nocache = true;
}
- list($openTag, $compiler->nocache) = $this->closeTag($compiler, array('section', 'sectionelse'));
+ list($openTag, $compiler->nocache, $local, $sectionVar) = $this->closeTag($compiler, array('section',
+ 'sectionelse'));
+ $output = "<?php\n";
if ($openTag == 'sectionelse') {
- return "<?php endif; ?>";
+ $output .= "}\n";
} else {
- return "<?php endfor; endif; ?>";
+ $output .= "}\n}\n";
}
+ $output .= "if ({$local}saved) {\n";
+ $output .= "{$sectionVar} = {$local}saved;\n";
+ $output .= "}\n";
+ $output .= "?>";
+
+ return $output;
}
}
diff --git a/library/Smarty/libs/sysplugins/smarty_internal_compile_setfilter.php b/library/Smarty/libs/sysplugins/smarty_internal_compile_setfilter.php
index 8e91ba6d0..b4932c1e1 100644
--- a/library/Smarty/libs/sysplugins/smarty_internal_compile_setfilter.php
+++ b/library/Smarty/libs/sysplugins/smarty_internal_compile_setfilter.php
@@ -25,10 +25,10 @@ class Smarty_Internal_Compile_Setfilter extends Smarty_Internal_CompileBase
*
* @return string compiled code
*/
- public function compile($args, $compiler, $parameter)
+ public function compile($args, Smarty_Internal_TemplateCompilerBase $compiler, $parameter)
{
- $compiler->variable_filter_stack[] = $compiler->template->variable_filters;
- $compiler->template->variable_filters = $parameter['modifier_list'];
+ $compiler->variable_filter_stack[] = $compiler->variable_filters;
+ $compiler->variable_filters = $parameter['modifier_list'];
// this tag does not return compiled code
$compiler->has_code = false;
@@ -53,14 +53,14 @@ class Smarty_Internal_Compile_Setfilterclose extends Smarty_Internal_CompileBase
*
* @return string compiled code
*/
- public function compile($args, $compiler)
+ public function compile($args, Smarty_Internal_TemplateCompilerBase $compiler)
{
$_attr = $this->getAttributes($compiler, $args);
// reset variable filter to previous state
if (count($compiler->variable_filter_stack)) {
- $compiler->template->variable_filters = array_pop($compiler->variable_filter_stack);
+ $compiler->variable_filters = array_pop($compiler->variable_filter_stack);
} else {
- $compiler->template->variable_filters = array();
+ $compiler->variable_filters = array();
}
// this tag does not return compiled code
$compiler->has_code = false;
diff --git a/library/Smarty/libs/sysplugins/smarty_internal_compile_while.php b/library/Smarty/libs/sysplugins/smarty_internal_compile_while.php
index 6a6fb3ef1..bd31f6671 100644
--- a/library/Smarty/libs/sysplugins/smarty_internal_compile_while.php
+++ b/library/Smarty/libs/sysplugins/smarty_internal_compile_while.php
@@ -19,24 +19,27 @@ class Smarty_Internal_Compile_While extends Smarty_Internal_CompileBase
/**
* Compiles code for the {while} tag
*
- * @param array $args array with attributes from parser
- * @param object $compiler compiler object
- * @param array $parameter array with compilation parameter
+ * @param array $args array with attributes from parser
+ * @param \Smarty_Internal_TemplateCompilerBase $compiler compiler object
+ * @param array $parameter array with compilation parameter
*
* @return string compiled code
+ * @throws \SmartyCompilerException
*/
- public function compile($args, $compiler, $parameter)
+ public function compile($args, Smarty_Internal_TemplateCompilerBase $compiler, $parameter)
{
+ $compiler->loopNesting++;
// check and get attributes
$_attr = $this->getAttributes($compiler, $args);
$this->openTag($compiler, 'while', $compiler->nocache);
if (!array_key_exists("if condition", $parameter)) {
- $compiler->trigger_template_error("missing while condition", $compiler->lex->taglineno);
+ $compiler->trigger_template_error("missing while condition", null, true);
}
// maybe nocache because of nocache variables
$compiler->nocache = $compiler->nocache | $compiler->tag_nocache;
+ $_output = "<?php\n";
if (is_array($parameter['if condition'])) {
if ($compiler->nocache) {
$_nocache = ',true';
@@ -55,17 +58,24 @@ class Smarty_Internal_Compile_While extends Smarty_Internal_CompileBase
$_nocache = '';
}
if (is_array($parameter['if condition']['var'])) {
- $_output = "<?php if (!isset(\$_smarty_tpl->tpl_vars[" . $parameter['if condition']['var']['var'] . "]) || !is_array(\$_smarty_tpl->tpl_vars[" . $parameter['if condition']['var']['var'] . "]->value)) \$_smarty_tpl->createLocalArrayVariable(" . $parameter['if condition']['var']['var'] . "$_nocache);\n";
- $_output .= "while (\$_smarty_tpl->tpl_vars[" . $parameter['if condition']['var']['var'] . "]->value" . $parameter['if condition']['var']['smarty_internal_index'] . " = " . $parameter['if condition']['value'] . ") {?>";
+ $_output .= "if (!isset(\$_smarty_tpl->tpl_vars[" . $parameter['if condition']['var']['var'] .
+ "]) || !is_array(\$_smarty_tpl->tpl_vars[" . $parameter['if condition']['var']['var'] .
+ "]->value)) \$_smarty_tpl->smarty->ext->_var->createLocalArrayVariable(\$_smarty_tpl, " . $parameter['if condition']['var']['var'] .
+ "$_nocache);\n";
+ $_output .= "while (\$_smarty_tpl->tpl_vars[" . $parameter['if condition']['var']['var'] . "]->value" .
+ $parameter['if condition']['var']['smarty_internal_index'] . " = " .
+ $parameter['if condition']['value'] . ") {?>";
} else {
- $_output = "<?php if (!isset(\$_smarty_tpl->tpl_vars[" . $parameter['if condition']['var'] . "])) \$_smarty_tpl->tpl_vars[" . $parameter['if condition']['var'] . "] = new Smarty_Variable(null{$_nocache});";
- $_output .= "while (\$_smarty_tpl->tpl_vars[" . $parameter['if condition']['var'] . "]->value = " . $parameter['if condition']['value'] . ") {?>";
+ $_output .= "if (!isset(\$_smarty_tpl->tpl_vars[" . $parameter['if condition']['var'] .
+ "])) \$_smarty_tpl->tpl_vars[" . $parameter['if condition']['var'] .
+ "] = new Smarty_Variable(null{$_nocache});";
+ $_output .= "while (\$_smarty_tpl->tpl_vars[" . $parameter['if condition']['var'] . "]->value = " .
+ $parameter['if condition']['value'] . ") {?>";
}
-
- return $_output;
} else {
- return "<?php while ({$parameter['if condition']}) {?>";
- }
+ $_output .= "while ({$parameter['if condition']}) {?>";
+ }
+ return $_output;
}
}
@@ -80,19 +90,19 @@ class Smarty_Internal_Compile_Whileclose extends Smarty_Internal_CompileBase
/**
* Compiles code for the {/while} tag
*
- * @param array $args array with attributes from parser
- * @param object $compiler compiler object
+ * @param array $args array with attributes from parser
+ * @param \Smarty_Internal_TemplateCompilerBase $compiler compiler object
*
* @return string compiled code
*/
- public function compile($args, $compiler)
+ public function compile($args, Smarty_Internal_TemplateCompilerBase $compiler)
{
+ $compiler->loopNesting--;
// must endblock be nocache?
if ($compiler->nocache) {
$compiler->tag_nocache = true;
}
$compiler->nocache = $this->closeTag($compiler, array('while'));
-
- return "<?php }?>";
+ return "<?php }?>\n";
}
}
diff --git a/library/Smarty/libs/sysplugins/smarty_internal_compilebase.php b/library/Smarty/libs/sysplugins/smarty_internal_compilebase.php
index f78f15f40..0803f27a6 100644
--- a/library/Smarty/libs/sysplugins/smarty_internal_compilebase.php
+++ b/library/Smarty/libs/sysplugins/smarty_internal_compilebase.php
@@ -21,6 +21,7 @@ abstract class Smarty_Internal_CompileBase
* @var array
*/
public $required_attributes = array();
+
/**
* Array of names of optional attribute required by tag
* use array('_any') if there is no restriction of attributes names
@@ -28,12 +29,14 @@ abstract class Smarty_Internal_CompileBase
* @var array
*/
public $optional_attributes = array();
+
/**
* Shorttag attribute order defined by its names
*
* @var array
*/
public $shorttag_order = array();
+
/**
* Array of names of valid option flags
*
@@ -68,7 +71,7 @@ abstract class Smarty_Internal_CompileBase
$_indexed_attr[$this->shorttag_order[$key]] = $mixed;
} else {
// too many shorthands
- $compiler->trigger_template_error('too many shorthand attributes', $compiler->lex->taglineno);
+ $compiler->trigger_template_error('too many shorthand attributes', null, true);
}
// named attribute
} else {
@@ -90,7 +93,7 @@ abstract class Smarty_Internal_CompileBase
$_indexed_attr[$kv['key']] = false;
}
} else {
- $compiler->trigger_template_error("illegal value of option flag \"{$kv['key']}\"", $compiler->lex->taglineno);
+ $compiler->trigger_template_error("illegal value of option flag \"{$kv['key']}\"", null, true);
}
// must be named attribute
} else {
@@ -102,7 +105,7 @@ abstract class Smarty_Internal_CompileBase
// check if all required attributes present
foreach ($this->required_attributes as $attr) {
if (!array_key_exists($attr, $_indexed_attr)) {
- $compiler->trigger_template_error("missing \"" . $attr . "\" attribute", $compiler->lex->taglineno);
+ $compiler->trigger_template_error("missing \"" . $attr . "\" attribute", null, true);
}
}
// check for not allowed attributes
@@ -110,7 +113,7 @@ abstract class Smarty_Internal_CompileBase
$tmp_array = array_merge($this->required_attributes, $this->optional_attributes, $this->option_flags);
foreach ($_indexed_attr as $key => $dummy) {
if (!in_array($key, $tmp_array) && $key !== 0) {
- $compiler->trigger_template_error("unexpected \"" . $key . "\" attribute", $compiler->lex->taglineno);
+ $compiler->trigger_template_error("unexpected \"" . $key . "\" attribute", null, true);
}
}
}
@@ -162,12 +165,13 @@ abstract class Smarty_Internal_CompileBase
}
}
// wrong nesting of tags
- $compiler->trigger_template_error("unclosed {$compiler->smarty->left_delimiter}" . $_openTag . "{$compiler->smarty->right_delimiter} tag");
+ $compiler->trigger_template_error("unclosed {$compiler->smarty->left_delimiter}" . $_openTag .
+ "{$compiler->smarty->right_delimiter} tag");
return;
}
// wrong nesting of tags
- $compiler->trigger_template_error("unexpected closing tag", $compiler->lex->taglineno);
+ $compiler->trigger_template_error("unexpected closing tag", null, true);
return;
}
diff --git a/library/Smarty/libs/sysplugins/smarty_internal_config_file_compiler.php b/library/Smarty/libs/sysplugins/smarty_internal_config_file_compiler.php
index 50779c7b5..56d3b0665 100644
--- a/library/Smarty/libs/sysplugins/smarty_internal_config_file_compiler.php
+++ b/library/Smarty/libs/sysplugins/smarty_internal_config_file_compiler.php
@@ -30,6 +30,7 @@ class Smarty_Internal_Config_File_Compiler
* @var string
*/
public $parser_class;
+
/**
* Lexer object
*
@@ -100,16 +101,17 @@ class Smarty_Internal_Config_File_Compiler
public function compileTemplate(Smarty_Internal_Template $template)
{
$this->template = $template;
- $this->template->properties['file_dependency'][$this->template->source->uid] = array($this->template->source->name, $this->template->source->timestamp, $this->template->source->type);
- // on empty config just return
- if ($template->source->content == '') {
- return true;
- }
+ $this->template->compiled->file_dependency[$this->template->source->uid] = array($this->template->source->filepath,
+ $this->template->source->getTimeStamp(),
+ $this->template->source->type);
if ($this->smarty->debugging) {
- Smarty_Internal_Debug::start_compile($this->template);
+ $this->smarty->_debug->start_compile($this->template);
}
// init the lexer/parser to compile the config file
- $lex = new $this->lexer_class(str_replace(array("\r\n", "\r"), "\n", $template->source->content) . "\n", $this);
+ /* @var Smarty_Internal_ConfigFileLexer $lex */
+ $lex = new $this->lexer_class(str_replace(array("\r\n", "\r"), "\n", $template->source->getContent()) .
+ "\n", $this);
+ /* @var Smarty_Internal_ConfigFileParser $parser */
$parser = new $this->parser_class($lex, $this);
if (function_exists('mb_internal_encoding') && ((int) ini_get('mbstring.func_overload')) & 2) {
@@ -136,14 +138,16 @@ class Smarty_Internal_Config_File_Compiler
mb_internal_encoding($mbEncoding);
}
if ($this->smarty->debugging) {
- Smarty_Internal_Debug::end_compile($this->template);
+ $this->smarty->_debug->end_compile($this->template);
}
// template header code
- $template_header = "<?php /* Smarty version " . Smarty::SMARTY_VERSION . ", created on " . strftime("%Y-%m-%d %H:%M:%S") . "\n";
+ $template_header = "<?php /* Smarty version " . Smarty::SMARTY_VERSION . ", created on " .
+ strftime("%Y-%m-%d %H:%M:%S") . "\n";
$template_header .= " compiled from \"" . $this->template->source->filepath . "\" */ ?>\n";
- $code = '<?php Smarty_Internal_Extension_Config::loadConfigVars($_smarty_tpl, ' . var_export($this->config_data, true) . '); ?>';
- return $template_header . Smarty_Internal_Extension_CodeFrame::create($this->template, $code);
+ $code = '<?php $_smarty_tpl->smarty->ext->configLoad->_loadConfigVars($_smarty_tpl, ' .
+ var_export($this->config_data, true) . '); ?>';
+ return $template_header . $this->template->smarty->ext->_codeFrame->create($this->template, $code);
}
/**
diff --git a/library/Smarty/libs/sysplugins/smarty_internal_data.php b/library/Smarty/libs/sysplugins/smarty_internal_data.php
index 2ca0f31da..53f351b41 100644
--- a/library/Smarty/libs/sysplugins/smarty_internal_data.php
+++ b/library/Smarty/libs/sysplugins/smarty_internal_data.php
@@ -13,42 +13,79 @@
*
* @package Smarty
* @subpackage Template
+ *
+ * @method mixed getConfigVars(string $varName = null, bool $searchParents = true)
+ * @method mixed getStreamVariable(string $variable)
+ * @method Smarty_Internal_Data clearAssign(mixed $tpl_var)
+ * @method Smarty_Internal_Data clearAllAssign()
+ * @method Smarty_Internal_Data clearConfig(string $varName = null)
+ * @method Smarty_Internal_Data configLoad(string $config_file, mixed $sections = null, string $scope = 'local')
+ * @property int $scope
*/
class Smarty_Internal_Data
{
/**
+ * This object type (Smarty = 1, template = 2, data = 4)
+ *
+ * @var int
+ */
+ public $_objType = 4;
+
+ /**
* name of class used for templates
*
* @var string
*/
public $template_class = 'Smarty_Internal_Template';
+
/**
* template variables
*
- * @var array
+ * @var Smarty_Variable[]
*/
public $tpl_vars = array();
+
/**
* parent template (if any)
*
- * @var Smarty_Internal_Template
+ * @var Smarty|Smarty_Internal_Template|Smarty_Internal_Data
*/
public $parent = null;
+
/**
* configuration settings
*
- * @var array
+ * @var string[]
*/
public $config_vars = array();
/**
+ * extension handler
+ *
+ * @var Smarty_Internal_Extension_Handler
+ */
+ public $ext = null;
+
+ /**
+ * Smarty_Internal_Data constructor.
+ *
+ * Install extension handler
+ */
+ public function __construct()
+ {
+ $this->ext = new Smarty_Internal_Extension_Handler();
+ $this->ext->objType = $this->_objType;
+ }
+
+ /**
* assigns a Smarty variable
*
* @param array|string $tpl_var the template variable name(s)
* @param mixed $value the value to assign
* @param boolean $nocache if true any output of this variable will be not cached
*
- * @return Smarty_Internal_Data current Smarty_Internal_Data (or Smarty or Smarty_Internal_Template) instance for chaining
+ * @return Smarty_Internal_Data current Smarty_Internal_Data (or Smarty or Smarty_Internal_Template) instance for
+ * chaining
*/
public function assign($tpl_var, $value = null, $nocache = false)
{
@@ -56,119 +93,53 @@ class Smarty_Internal_Data
foreach ($tpl_var as $_key => $_val) {
if ($_key != '') {
$this->tpl_vars[$_key] = new Smarty_Variable($_val, $nocache);
+ if ($this->_objType == 2 && $this->scope) {
+ $this->ext->_updateScope->updateScope($this, $_key);
+ }
}
}
} else {
if ($tpl_var != '') {
$this->tpl_vars[$tpl_var] = new Smarty_Variable($value, $nocache);
+ if ($this->_objType == 2 && $this->scope) {
+ $this->ext->_updateScope->updateScope($this, $tpl_var);
+ }
}
}
-
return $this;
}
/**
- * assigns a global Smarty variable
- *
- * @param string $varname the global variable name
- * @param mixed $value the value to assign
- * @param boolean $nocache if true any output of this variable will be not cached
+ * appends values to template variables
*
- * @return Smarty_Internal_Data current Smarty_Internal_Data (or Smarty or Smarty_Internal_Template) instance for chaining
- */
- public function assignGlobal($varname, $value = null, $nocache = false)
- {
- if ($varname != '') {
- Smarty::$global_tpl_vars[$varname] = new Smarty_Variable($value, $nocache);
- $ptr = $this;
- while ($ptr instanceof Smarty_Internal_Template) {
- $ptr->tpl_vars[$varname] = clone Smarty::$global_tpl_vars[$varname];
- $ptr = $ptr->parent;
- }
- }
-
- return $this;
- }
-
- /**
- * assigns values to template variables by reference
+ * @api Smarty::append()
+ * @link http://www.smarty.net/docs/en/api.append.tpl
*
- * @param string $tpl_var the template variable name
- * @param $value
- * @param boolean $nocache if true any output of this variable will be not cached
+ * @param array|string $tpl_var the template variable name(s)
+ * @param mixed $value the value to append
+ * @param bool $merge flag if array elements shall be merged
+ * @param bool $nocache if true any output of this variable will
+ * be not cached
*
- * @return Smarty_Internal_Data current Smarty_Internal_Data (or Smarty or Smarty_Internal_Template) instance for chaining
+ * @return \Smarty_Internal_Data|\Smarty_Internal_Template|\Smarty
*/
- public function assignByRef($tpl_var, &$value, $nocache = false)
+ public function append($tpl_var, $value = null, $merge = false, $nocache = false)
{
- if ($tpl_var != '') {
- $this->tpl_vars[$tpl_var] = new Smarty_Variable(null, $nocache);
- $this->tpl_vars[$tpl_var]->value = &$value;
- }
-
- return $this;
+ return $this->ext->append->append($this, $tpl_var, $value, $merge, $nocache);
}
/**
- * appends values to template variables
+ * assigns a global Smarty variable
*
- * @param array|string $tpl_var the template variable name(s)
- * @param mixed $value the value to append
- * @param boolean $merge flag if array elements shall be merged
- * @param boolean $nocache if true any output of this variable will be not cached
+ * @param string $varName the global variable name
+ * @param mixed $value the value to assign
+ * @param boolean $nocache if true any output of this variable will be not cached
*
- * @return Smarty_Internal_Data current Smarty_Internal_Data (or Smarty or Smarty_Internal_Template) instance for chaining
+ * @return \Smarty_Internal_Data|\Smarty_Internal_Template|\Smarty
*/
- public function append($tpl_var, $value = null, $merge = false, $nocache = false)
+ public function assignGlobal($varName, $value = null, $nocache = false)
{
- if (is_array($tpl_var)) {
- // $tpl_var is an array, ignore $value
- foreach ($tpl_var as $_key => $_val) {
- if ($_key != '') {
- if (!isset($this->tpl_vars[$_key])) {
- $tpl_var_inst = $this->getVariable($_key, null, true, false);
- if ($tpl_var_inst instanceof Smarty_Undefined_Variable) {
- $this->tpl_vars[$_key] = new Smarty_Variable(null, $nocache);
- } else {
- $this->tpl_vars[$_key] = clone $tpl_var_inst;
- }
- }
- if (!(is_array($this->tpl_vars[$_key]->value) || $this->tpl_vars[$_key]->value instanceof ArrayAccess)) {
- settype($this->tpl_vars[$_key]->value, 'array');
- }
- if ($merge && is_array($_val)) {
- foreach ($_val as $_mkey => $_mval) {
- $this->tpl_vars[$_key]->value[$_mkey] = $_mval;
- }
- } else {
- $this->tpl_vars[$_key]->value[] = $_val;
- }
- }
- }
- } else {
- if ($tpl_var != '' && isset($value)) {
- if (!isset($this->tpl_vars[$tpl_var])) {
- $tpl_var_inst = $this->getVariable($tpl_var, null, true, false);
- if ($tpl_var_inst instanceof Smarty_Undefined_Variable) {
- $this->tpl_vars[$tpl_var] = new Smarty_Variable(null, $nocache);
- } else {
- $this->tpl_vars[$tpl_var] = clone $tpl_var_inst;
- }
- }
- if (!(is_array($this->tpl_vars[$tpl_var]->value) || $this->tpl_vars[$tpl_var]->value instanceof ArrayAccess)) {
- settype($this->tpl_vars[$tpl_var]->value, 'array');
- }
- if ($merge && is_array($value)) {
- foreach ($value as $_mkey => $_mval) {
- $this->tpl_vars[$tpl_var]->value[$_mkey] = $_mval;
- }
- } else {
- $this->tpl_vars[$tpl_var]->value[] = $value;
- }
- }
- }
-
- return $this;
+ return $this->ext->assignGlobal->assignGlobal($this, $varName, $value, $nocache);
}
/**
@@ -178,227 +149,77 @@ class Smarty_Internal_Data
* @param mixed &$value the referenced value to append
* @param boolean $merge flag if array elements shall be merged
*
- * @return Smarty_Internal_Data current Smarty_Internal_Data (or Smarty or Smarty_Internal_Template) instance for chaining
+ * @return \Smarty_Internal_Data|\Smarty_Internal_Template|\Smarty
*/
public function appendByRef($tpl_var, &$value, $merge = false)
{
- if ($tpl_var != '' && isset($value)) {
- if (!isset($this->tpl_vars[$tpl_var])) {
- $this->tpl_vars[$tpl_var] = new Smarty_Variable();
- }
- if (!is_array($this->tpl_vars[$tpl_var]->value)) {
- settype($this->tpl_vars[$tpl_var]->value, 'array');
- }
- if ($merge && is_array($value)) {
- foreach ($value as $_key => $_val) {
- $this->tpl_vars[$tpl_var]->value[$_key] = &$value[$_key];
- }
- } else {
- $this->tpl_vars[$tpl_var]->value[] = &$value;
- }
- }
-
- return $this;
+ return $this->ext->appendByRef->appendByRef($this, $tpl_var, $value, $merge);
}
/**
- * Returns a single or all template variables
+ * assigns values to template variables by reference
*
- * @param string $varname variable name or null
- * @param object $_ptr optional pointer to data object
- * @param boolean $search_parents include parent templates?
+ * @param string $tpl_var the template variable name
+ * @param $value
+ * @param boolean $nocache if true any output of this variable will be not cached
*
- * @return string variable value or or array of variables
+ * @return \Smarty_Internal_Data|\Smarty_Internal_Template|\Smarty
*/
- public function getTemplateVars($varname = null, $_ptr = null, $search_parents = true)
+ public function assignByRef($tpl_var, &$value, $nocache = false)
{
- if (isset($varname)) {
- $_var = $this->getVariable($varname, $_ptr, $search_parents, false);
- if (is_object($_var)) {
- return $_var->value;
- } else {
- return null;
- }
- } else {
- $_result = array();
- if ($_ptr === null) {
- $_ptr = $this;
- }
- while ($_ptr !== null) {
- foreach ($_ptr->tpl_vars AS $key => $var) {
- if (!array_key_exists($key, $_result)) {
- $_result[$key] = $var->value;
- }
- }
- // not found, try at parent
- if ($search_parents) {
- $_ptr = $_ptr->parent;
- } else {
- $_ptr = null;
- }
- }
- if ($search_parents && isset(Smarty::$global_tpl_vars)) {
- foreach (Smarty::$global_tpl_vars AS $key => $var) {
- if (!array_key_exists($key, $_result)) {
- $_result[$key] = $var->value;
- }
- }
- }
-
- return $_result;
- }
+ return $this->ext->assignByRef->assignByRef($this, $tpl_var, $value, $nocache);
}
/**
- * clear the given assigned template variable.
+ * Returns a single or all template variables
*
- * @param string|array $tpl_var the template variable(s) to clear
+ * @api Smarty::getTemplateVars()
+ * @link http://www.smarty.net/docs/en/api.get.template.vars.tpl
*
- * @return Smarty_Internal_Data current Smarty_Internal_Data (or Smarty or Smarty_Internal_Template) instance for chaining
- */
- public function clearAssign($tpl_var)
- {
- if (is_array($tpl_var)) {
- foreach ($tpl_var as $curr_var) {
- unset($this->tpl_vars[$curr_var]);
- }
- } else {
- unset($this->tpl_vars[$tpl_var]);
- }
-
- return $this;
- }
-
- /**
- * clear all the assigned template variables.
+ * @param string $varName variable name or null
+ * @param \Smarty_Internal_Data|\Smarty_Internal_Template|\Smarty $_ptr optional pointer to data object
+ * @param bool $searchParents include parent templates?
*
- * @return Smarty_Internal_Data current Smarty_Internal_Data (or Smarty or Smarty_Internal_Template) instance for chaining
+ * @return mixed variable value or or array of variables
*/
- public function clearAllAssign()
+ public function getTemplateVars($varName = null, Smarty_Internal_Data $_ptr = null, $searchParents = true)
{
- $this->tpl_vars = array();
-
- return $this;
+ return $this->ext->getTemplateVars->getTemplateVars($this, $varName, $_ptr, $searchParents);
}
/**
- * load a config file, optionally load just selected sections
- *
- * @param string $config_file filename
- * @param mixed $sections array of section names, single section or null
+ * Follow the parent chain an merge template and config variables
*
- * @return Smarty_Internal_Data current Smarty_Internal_Data (or Smarty or Smarty_Internal_Template) instance for chaining
+ * @param \Smarty_Internal_Data|null $data
*/
- public function configLoad($config_file, $sections = null)
+ public function _mergeVars(Smarty_Internal_Data $data = null)
{
- // load Config class
- Smarty_Internal_Extension_Config::configLoad($this, $config_file, $sections);
- return $this;
- }
-
- /**
- * gets the object of a Smarty variable
- *
- * @param string $variable the name of the Smarty variable
- * @param object $_ptr optional pointer to data object
- * @param boolean $search_parents search also in parent data
- * @param bool $error_enable
- *
- * @return object the object of the variable
- */
- public function getVariable($variable, $_ptr = null, $search_parents = true, $error_enable = true)
- {
- if ($_ptr === null) {
- $_ptr = $this;
- }
- while ($_ptr !== null) {
- if (isset($_ptr->tpl_vars[$variable])) {
- // found it, return it
- return $_ptr->tpl_vars[$variable];
+ if (isset($data)) {
+ if (!empty($this->tpl_vars)) {
+ $data->tpl_vars = array_merge($this->tpl_vars, $data->tpl_vars);
}
- // not found, try at parent
- if ($search_parents) {
- $_ptr = $_ptr->parent;
- } else {
- $_ptr = null;
+ if (!empty($this->config_vars)) {
+ $data->config_vars = array_merge($this->config_vars, $data->config_vars);
}
+ } else {
+ $data = $this;
}
- if (isset(Smarty::$global_tpl_vars[$variable])) {
- // found it, return it
- return Smarty::$global_tpl_vars[$variable];
- }
- $smarty = isset($this->smarty) ? $this->smarty : $this;
- if ($smarty->error_unassigned && $error_enable) {
- // force a notice
- $x = $$variable;
+ if (isset($this->parent)) {
+ $this->parent->_mergeVars($data);
}
-
- return new Smarty_Undefined_Variable;
- }
-
- /**
- * gets a config variable
- *
- * @param string $variable the name of the config variable
- * @param bool $error_enable
- *
- * @return mixed the value of the config variable
- */
- public function getConfigVariable($variable, $error_enable = true)
- {
- return Smarty_Internal_Extension_Config::getConfigVariable($this, $variable, $error_enable = true);
- }
-
- /**
- * Returns a single or all config variables
- *
- * @param string $varname variable name or null
- * @param bool $search_parents
- *
- * @return string variable value or or array of variables
- */
- public function getConfigVars($varname = null, $search_parents = true)
- {
- return Smarty_Internal_Extension_Config::getConfigVars($this, $varname, $search_parents);
- }
-
- /**
- * Deassigns a single or all config variables
- *
- * @param string $varname variable name or null
- *
- * @return Smarty_Internal_Data current Smarty_Internal_Data (or Smarty or Smarty_Internal_Template) instance for chaining
- */
- public function clearConfig($varname = null)
- {
- return Smarty_Internal_Extension_Config::clearConfig($this, $varname);
}
/**
- * gets a stream variable
+ * Handle unknown class methods
*
- * @param string $variable the stream of the variable
+ * @param string $name unknown method-name
+ * @param array $args argument array
*
+ * @return mixed
* @throws SmartyException
- * @return mixed the value of the stream variable
*/
- public function getStreamVariable($variable)
+ public function __call($name, $args)
{
- $_result = '';
- $fp = fopen($variable, 'r+');
- if ($fp) {
- while (!feof($fp) && ($current_line = fgets($fp)) !== false) {
- $_result .= $current_line;
- }
- fclose($fp);
-
- return $_result;
- }
- $smarty = isset($this->smarty) ? $this->smarty : $this;
- if ($smarty->error_unassigned) {
- throw new SmartyException('Undefined stream variable "' . $variable . '"');
- } else {
- return null;
- }
+ return $this->ext->_callExternalMethod($this, $name, $args);
}
}
diff --git a/library/Smarty/libs/sysplugins/smarty_internal_debug.php b/library/Smarty/libs/sysplugins/smarty_internal_debug.php
index 89eb9f3ab..e330a35c1 100644
--- a/library/Smarty/libs/sysplugins/smarty_internal_debug.php
+++ b/library/Smarty/libs/sysplugins/smarty_internal_debug.php
@@ -21,44 +21,44 @@ class Smarty_Internal_Debug extends Smarty_Internal_Data
*
* @var array
*/
- public static $template_data = array();
+ public $template_data = array();
/**
* List of uid's which shall be ignored
*
* @var array
*/
- public static $ignore_uid = array();
+ public $ignore_uid = array();
/**
* Index of display() and fetch() calls
*
* @var int
*/
- public static $index = 0;
+ public $index = 0;
/**
* Counter for window offset
*
* @var int
*/
- public static $offset = 0;
+ public $offset = 0;
/**
* Start logging template
*
* @param \Smarty_Internal_Template $template template
- * @param null $mode true: display false: fetch null: subtemolate
+ * @param null $mode true: display false: fetch null: subtemplate
*/
- public static function start_template(Smarty_Internal_Template $template, $mode = null)
+ public function start_template(Smarty_Internal_Template $template, $mode = null)
{
if (isset($mode)) {
- self::$index ++;
- self::$offset ++;
- self::$template_data[self::$index] = null;
+ $this->index ++;
+ $this->offset ++;
+ $this->template_data[$this->index] = null;
}
- $key = self::get_key($template);
- self::$template_data[self::$index][$key]['start_template_time'] = microtime(true);
+ $key = $this->get_key($template);
+ $this->template_data[$this->index][$key]['start_template_time'] = microtime(true);
}
/**
@@ -66,11 +66,12 @@ class Smarty_Internal_Debug extends Smarty_Internal_Data
*
* @param \Smarty_Internal_Template $template cached template
*/
- public static function end_template(Smarty_Internal_Template $template)
+ public function end_template(Smarty_Internal_Template $template)
{
- $key = self::get_key($template);
- self::$template_data[self::$index][$key]['total_time'] += microtime(true) - self::$template_data[self::$index][$key]['start_template_time'];
- self::$template_data[self::$index][$key]['properties'] = $template->properties;
+ $key = $this->get_key($template);
+ $this->template_data[$this->index][$key]['total_time'] +=
+ microtime(true) - $this->template_data[$this->index][$key]['start_template_time'];
+ //$this->template_data[$this->index][$key]['properties'] = $template->properties;
}
/**
@@ -78,28 +79,29 @@ class Smarty_Internal_Debug extends Smarty_Internal_Data
*
* @param \Smarty_Internal_Template $template
*/
- public static function start_compile(Smarty_Internal_Template $template)
+ public function start_compile(Smarty_Internal_Template $template)
{
static $_is_stringy = array('string' => true, 'eval' => true);
if (!empty($template->compiler->trace_uid)) {
$key = $template->compiler->trace_uid;
- if (!isset(self::$template_data[self::$index][$key])) {
+ if (!isset($this->template_data[$this->index][$key])) {
if (isset($_is_stringy[$template->source->type])) {
- self::$template_data[self::$index][$key]['name'] = '\'' . substr($template->source->name, 0, 25) . '...\'';
+ $this->template_data[$this->index][$key]['name'] =
+ '\'' . substr($template->source->name, 0, 25) . '...\'';
} else {
- self::$template_data[self::$index][$key]['name'] = $template->source->filepath;
+ $this->template_data[$this->index][$key]['name'] = $template->source->filepath;
}
- self::$template_data[self::$index][$key]['compile_time'] = 0;
- self::$template_data[self::$index][$key]['render_time'] = 0;
- self::$template_data[self::$index][$key]['cache_time'] = 0;
+ $this->template_data[$this->index][$key]['compile_time'] = 0;
+ $this->template_data[$this->index][$key]['render_time'] = 0;
+ $this->template_data[$this->index][$key]['cache_time'] = 0;
}
} else {
- if (isset(self::$ignore_uid[$template->source->uid])) {
+ if (isset($this->ignore_uid[$template->source->uid])) {
return;
}
- $key = self::get_key($template);
+ $key = $this->get_key($template);
}
- self::$template_data[self::$index][$key]['start_time'] = microtime(true);
+ $this->template_data[$this->index][$key]['start_time'] = microtime(true);
}
/**
@@ -107,18 +109,19 @@ class Smarty_Internal_Debug extends Smarty_Internal_Data
*
* @param \Smarty_Internal_Template $template
*/
- public static function end_compile(Smarty_Internal_Template $template)
+ public function end_compile(Smarty_Internal_Template $template)
{
if (!empty($template->compiler->trace_uid)) {
$key = $template->compiler->trace_uid;
} else {
- if (isset(self::$ignore_uid[$template->source->uid])) {
+ if (isset($this->ignore_uid[$template->source->uid])) {
return;
}
- $key = self::get_key($template);
+ $key = $this->get_key($template);
}
- self::$template_data[self::$index][$key]['compile_time'] += microtime(true) - self::$template_data[self::$index][$key]['start_time'];
+ $this->template_data[$this->index][$key]['compile_time'] +=
+ microtime(true) - $this->template_data[$this->index][$key]['start_time'];
}
/**
@@ -126,10 +129,10 @@ class Smarty_Internal_Debug extends Smarty_Internal_Data
*
* @param \Smarty_Internal_Template $template
*/
- public static function start_render(Smarty_Internal_Template $template)
+ public function start_render(Smarty_Internal_Template $template)
{
- $key = self::get_key($template);
- self::$template_data[self::$index][$key]['start_time'] = microtime(true);
+ $key = $this->get_key($template);
+ $this->template_data[$this->index][$key]['start_time'] = microtime(true);
}
/**
@@ -137,10 +140,11 @@ class Smarty_Internal_Debug extends Smarty_Internal_Data
*
* @param \Smarty_Internal_Template $template
*/
- public static function end_render(Smarty_Internal_Template $template)
+ public function end_render(Smarty_Internal_Template $template)
{
- $key = self::get_key($template);
- self::$template_data[self::$index][$key]['render_time'] += microtime(true) - self::$template_data[self::$index][$key]['start_time'];
+ $key = $this->get_key($template);
+ $this->template_data[$this->index][$key]['render_time'] +=
+ microtime(true) - $this->template_data[$this->index][$key]['start_time'];
}
/**
@@ -148,10 +152,10 @@ class Smarty_Internal_Debug extends Smarty_Internal_Data
*
* @param \Smarty_Internal_Template $template cached template
*/
- public static function start_cache(Smarty_Internal_Template $template)
+ public function start_cache(Smarty_Internal_Template $template)
{
- $key = self::get_key($template);
- self::$template_data[self::$index][$key]['start_time'] = microtime(true);
+ $key = $this->get_key($template);
+ $this->template_data[$this->index][$key]['start_time'] = microtime(true);
}
/**
@@ -159,10 +163,11 @@ class Smarty_Internal_Debug extends Smarty_Internal_Data
*
* @param \Smarty_Internal_Template $template cached template
*/
- public static function end_cache(Smarty_Internal_Template $template)
+ public function end_cache(Smarty_Internal_Template $template)
{
- $key = self::get_key($template);
- self::$template_data[self::$index][$key]['cache_time'] += microtime(true) - self::$template_data[self::$index][$key]['start_time'];
+ $key = $this->get_key($template);
+ $this->template_data[$this->index][$key]['cache_time'] +=
+ microtime(true) - $this->template_data[$this->index][$key]['start_time'];
}
/**
@@ -170,7 +175,7 @@ class Smarty_Internal_Debug extends Smarty_Internal_Data
*
* @param \Smarty_Internal_Template $template cached template
*/
- public static function register_template(Smarty_Internal_Template $template)
+ public function register_template(Smarty_Internal_Template $template)
{
}
@@ -189,14 +194,14 @@ class Smarty_Internal_Debug extends Smarty_Internal_Data
* @param Smarty_Internal_Template|Smarty $obj object to debug
* @param bool $full
*/
- public static function display_debug($obj, $full = false)
+ public function display_debug($obj, $full = false)
{
if (!$full) {
- self::$offset ++;
- $savedIndex = self::$index;
- self::$index = 9999;
+ $this->offset ++;
+ $savedIndex = $this->index;
+ $this->index = 9999;
}
- if ($obj instanceof Smarty) {
+ if ($obj->_objType == 1) {
$smarty = $obj;
} else {
$smarty = $obj->smarty;
@@ -227,7 +232,7 @@ class Smarty_Internal_Debug extends Smarty_Internal_Data
$debObj->compile_id = null;
$debObj->cache_id = null;
// prepare information of assigned variables
- $ptr = self::get_debug_vars($obj);
+ $ptr = $this->get_debug_vars($obj);
$_assigned_vars = $ptr->tpl_vars;
ksort($_assigned_vars);
$_config_vars = $ptr->config_vars;
@@ -235,11 +240,11 @@ class Smarty_Internal_Debug extends Smarty_Internal_Data
$debugging = $smarty->debugging;
$_template = new Smarty_Internal_Template($debObj->debug_tpl, $debObj);
- if ($obj instanceof Smarty_Internal_Template) {
+ if ($obj->_objType == 2) {
$_template->assign('template_name', $obj->source->type . ':' . $obj->source->name);
}
- if ($obj instanceof Smarty || $full) {
- $_template->assign('template_data', self::$template_data[self::$index]);
+ if ($obj->_objType == 1 || $full) {
+ $_template->assign('template_data', $this->template_data[$this->index]);
} else {
$_template->assign('template_data', null);
}
@@ -247,13 +252,13 @@ class Smarty_Internal_Debug extends Smarty_Internal_Data
$_template->assign('config_vars', $_config_vars);
$_template->assign('execution_time', microtime(true) - $smarty->start_time);
$_template->assign('display_mode', $debugging == 2 || !$full);
- $_template->assign('offset', self::$offset * 50);
+ $_template->assign('offset', $this->offset * 50);
echo $_template->fetch();
if (isset($full)) {
- self::$index --;
+ $this->index --;
}
if (!$full) {
- self::$index = $savedIndex;
+ $this->index = $savedIndex;
}
}
@@ -264,14 +269,14 @@ class Smarty_Internal_Debug extends Smarty_Internal_Data
*
* @return StdClass
*/
- public static function get_debug_vars($obj)
+ public function get_debug_vars($obj)
{
$config_vars = array();
foreach ($obj->config_vars as $key => $var) {
$config_vars[$key]['value'] = $var;
- if ($obj instanceof Smarty_Internal_Template) {
+ if ($obj->_objType == 2) {
$config_vars[$key]['scope'] = $obj->source->type . ':' . $obj->source->name;
- } elseif ($obj instanceof Smarty_Data) {
+ } elseif ($obj->_objType == 4) {
$tpl_vars[$key]['scope'] = $obj->dataObjectName;
} else {
$config_vars[$key]['scope'] = 'Smarty object';
@@ -294,9 +299,9 @@ class Smarty_Internal_Debug extends Smarty_Internal_Data
}
}
}
- if ($obj instanceof Smarty_Internal_Template) {
+ if ($obj->_objType == 2) {
$tpl_vars[$key]['scope'] = $obj->source->type . ':' . $obj->source->name;
- } elseif ($obj instanceof Smarty_Data) {
+ } elseif ($obj->_objType == 4) {
$tpl_vars[$key]['scope'] = $obj->dataObjectName;
} else {
$tpl_vars[$key]['scope'] = 'Smarty object';
@@ -304,7 +309,7 @@ class Smarty_Internal_Debug extends Smarty_Internal_Data
}
if (isset($obj->parent)) {
- $parent = self::get_debug_vars($obj->parent);
+ $parent = $this->get_debug_vars($obj->parent);
foreach ($parent->tpl_vars as $name => $pvar) {
if (isset($tpl_vars[$name]) && $tpl_vars[$name]['value'] === $pvar['value']) {
$tpl_vars[$name]['scope'] = $pvar['scope'];
@@ -351,7 +356,7 @@ class Smarty_Internal_Debug extends Smarty_Internal_Data
*
* @return string key into $template_data
*/
- private static function get_key(Smarty_Internal_Template $template)
+ private function get_key(Smarty_Internal_Template $template)
{
static $_is_stringy = array('string' => true, 'eval' => true);
// calculate Uid if not already done
@@ -359,18 +364,19 @@ class Smarty_Internal_Debug extends Smarty_Internal_Data
$template->source->filepath;
}
$key = $template->source->uid;
- if (isset(self::$template_data[self::$index][$key])) {
+ if (isset($this->template_data[$this->index][$key])) {
return $key;
} else {
if (isset($_is_stringy[$template->source->type])) {
- self::$template_data[self::$index][$key]['name'] = '\'' . substr($template->source->name, 0, 25) . '...\'';
+ $this->template_data[$this->index][$key]['name'] =
+ '\'' . substr($template->source->name, 0, 25) . '...\'';
} else {
- self::$template_data[self::$index][$key]['name'] = $template->source->filepath;
+ $this->template_data[$this->index][$key]['name'] = $template->source->filepath;
}
- self::$template_data[self::$index][$key]['compile_time'] = 0;
- self::$template_data[self::$index][$key]['render_time'] = 0;
- self::$template_data[self::$index][$key]['cache_time'] = 0;
- self::$template_data[self::$index][$key]['total_time'] = 0;
+ $this->template_data[$this->index][$key]['compile_time'] = 0;
+ $this->template_data[$this->index][$key]['render_time'] = 0;
+ $this->template_data[$this->index][$key]['cache_time'] = 0;
+ $this->template_data[$this->index][$key]['total_time'] = 0;
return $key;
}
@@ -381,13 +387,13 @@ class Smarty_Internal_Debug extends Smarty_Internal_Data
*
* @param \Smarty_Internal_Template $template
*/
- public static function ignore(Smarty_Internal_Template $template)
+ public function ignore(Smarty_Internal_Template $template)
{
// calculate Uid if not already done
if ($template->source->uid == '') {
$template->source->filepath;
}
- self::$ignore_uid[$template->source->uid] = true;
+ $this->ignore_uid[$template->source->uid] = true;
}
/**
@@ -395,7 +401,7 @@ class Smarty_Internal_Debug extends Smarty_Internal_Data
*
* @param Smarty_Internal_Template $_template
*/
- public static function debugUrl(Smarty_Internal_Template $_template)
+ public function debugUrl(Smarty_Internal_Template $_template)
{
if (isset($_SERVER['QUERY_STRING'])) {
$_query_string = $_SERVER['QUERY_STRING'];
diff --git a/library/Smarty/libs/sysplugins/smarty_internal_extension_codeframe.php b/library/Smarty/libs/sysplugins/smarty_internal_extension_codeframe.php
deleted file mode 100644
index 0474378ce..000000000
--- a/library/Smarty/libs/sysplugins/smarty_internal_extension_codeframe.php
+++ /dev/null
@@ -1,127 +0,0 @@
-<?php
-/**
- * Smarty Internal Extension
- * This file contains the Smarty template extension to create a code frame
- *
- * @package Smarty
- * @subpackage Template
- * @author Uwe Tews
- */
-
-/**
- * Class Smarty_Internal_Extension_CodeFrame
- * Create code frame for compiled and cached templates
- */
-class Smarty_Internal_Extension_CodeFrame
-{
- /**
- * Create code frame for compiled and cached templates
- *
- * @param Smarty_Internal_Template $_template
- * @param string $content optional template content
- * @param bool $cache flag for cache file
- *
- * @return string
- */
- public static function create(Smarty_Internal_Template $_template, $content = '', $cache = false)
- {
- // build property code
- $_template->properties['has_nocache_code'] = $_template->has_nocache_code || !empty($_template->required_plugins['nocache']);
- $_template->properties['version'] = Smarty::SMARTY_VERSION;
- if (!isset($_template->properties['unifunc'])) {
- $_template->properties['unifunc'] = 'content_' . str_replace(array('.', ','), '_', uniqid('', true));
- }
- $properties = $_template->properties;
- if (!$cache) {
- unset($properties['tpl_function']);
- if (!empty($_template->compiler->templateProperties)) {
- $properties['tpl_function'] = $_template->compiler->templateProperties['tpl_function'];
- }
- }
- $output = "<?php\n";
- $output .= "/*%%SmartyHeaderCode:{$_template->properties['nocache_hash']}%%*/\n";
- if ($_template->smarty->direct_access_security) {
- $output .= "if(!defined('SMARTY_DIR')) exit('no direct access allowed');\n";
- }
- $output .= "\$_valid = \$_smarty_tpl->decodeProperties(" . var_export($properties, true) . ',' . ($cache ? 'true' : 'false') . ");\n";
- $output .= "/*/%%SmartyHeaderCode%%*/\n";
- $output .= "if (\$_valid && !is_callable('{$_template->properties['unifunc']}')) {\n";
- $output .= "function {$_template->properties['unifunc']} (\$_smarty_tpl) {\n";
- // include code for plugins
- if (!$cache) {
- if (!empty($_template->required_plugins['compiled'])) {
- foreach ($_template->required_plugins['compiled'] as $tmp) {
- foreach ($tmp as $data) {
- $file = addslashes($data['file']);
- if (is_Array($data['function'])) {
- $output .= "if (!is_callable(array('{$data['function'][0]}','{$data['function'][1]}'))) require_once '{$file}';\n";
- } else {
- $output .= "if (!is_callable('{$data['function']}')) require_once '{$file}';\n";
- }
- }
- }
- }
- if (!empty($_template->required_plugins['nocache'])) {
- $_template->has_nocache_code = true;
- $output .= "echo '/*%%SmartyNocache:{$_template->properties['nocache_hash']}%%*/<?php \$_smarty = \$_smarty_tpl->smarty; ";
- foreach ($_template->required_plugins['nocache'] as $tmp) {
- foreach ($tmp as $data) {
- $file = addslashes($data['file']);
- if (is_Array($data['function'])) {
- $output .= addslashes("if (!is_callable(array('{$data['function'][0]}','{$data['function'][1]}'))) require_once '{$file}';\n");
- } else {
- $output .= addslashes("if (!is_callable('{$data['function']}')) require_once '{$file}';\n");
- }
- }
- }
- $output .= "?>/*/%%SmartyNocache:{$_template->properties['nocache_hash']}%%*/';\n";
- }
- }
- $output .= "?>\n";
- $output = self::appendCode($output, $content);
- return self::appendCode($output, "<?php }\n}\n?>");
- }
-
- /**
- * Create code frame of compiled template function
- *
- * @param \Smarty_Internal_Template $_template
- * @param string $content
- *
- * @return string
- */
- public static function createFunctionFrame(Smarty_Internal_Template $_template, $content = '')
- {
- if (!isset($_template->properties['unifunc'])) {
- $_template->properties['unifunc'] = 'content_' . str_replace(array('.', ','), '_', uniqid('', true));
- }
- $output = "<?php\n";
- $output .= "/*%%SmartyHeaderCode:{$_template->properties['nocache_hash']}%%*/\n";
- $output .= "if (\$_valid && !is_callable('{$_template->properties['unifunc']}')) {\n";
- $output .= "function {$_template->properties['unifunc']} (\$_smarty_tpl) {\n";
- $output .= "?>\n" . $content;
- $output .= "<?php\n";
- $output .= "/*/%%SmartyNocache:{$_template->properties['nocache_hash']}%%*/\n";
- $output .= "}\n}\n?>";
- return $output;
- }
-
- /**
- * Append code segments and remove unneeded ?> <?php transitions
- *
- * @param string $left
- * @param string $right
- *
- * @return string
- */
- public static function appendCode($left, $right)
- {
- if (preg_match('/\s*\?>$/', $left) && preg_match('/^<\?php\s+/', $right)) {
- $left = preg_replace('/\s*\?>$/', "\n", $left);
- $left .= preg_replace('/^<\?php\s+/', '', $right);
- } else {
- $left .= $right;
- }
- return $left;
- }
-} \ No newline at end of file
diff --git a/library/Smarty/libs/sysplugins/smarty_internal_extension_config.php b/library/Smarty/libs/sysplugins/smarty_internal_extension_config.php
deleted file mode 100644
index a30bb22da..000000000
--- a/library/Smarty/libs/sysplugins/smarty_internal_extension_config.php
+++ /dev/null
@@ -1,160 +0,0 @@
-<?php
-
-/**
- * @package Smarty
- * @subpackage PluginsInternal
- */
-class Smarty_Internal_Extension_Config
-{
- /**
- * @param $obj
- * @param $config_file
- * @param null $sections
- * @param string $scope
- */
- static function configLoad($obj, $config_file, $sections = null, $scope = 'local')
- {
- $smarty = isset($obj->smarty) ? $obj->smarty : $obj;
- $confObj = new $smarty->template_class($config_file, $smarty, $obj);
- $confObj->caching = Smarty::CACHING_OFF;
- $confObj->source = Smarty_Template_Config::load($confObj);
- $confObj->source->config_sections = $sections;
- $confObj->source->scope = $scope;
- $confObj->compiled = Smarty_Template_Compiled::load($confObj);
- if ($confObj->smarty->debugging) {
- Smarty_Internal_Debug::start_render($confObj);
- }
- $confObj->compiled->render($confObj);
- if ($confObj->smarty->debugging) {
- Smarty_Internal_Debug::end_render($confObj);
- }
- if ($obj instanceof Smarty_Internal_Template) {
- $obj->properties['file_dependency'][$confObj->source->uid] = array($confObj->source->filepath, $confObj->source->timestamp, $confObj->source->type);
- }
- }
-
- /**
- * load config variables
- *
- * @param mixed $sections array of section names, single section or null
- * @param string $scope global,parent or local
- *
- * @throws Exception
- */
- static function loadConfigVars($_template, $_config_vars)
- {
- $scope = $_template->source->scope;
- // pointer to scope (local scope is parent of template object
- $scope_ptr = $_template->parent;
- if ($scope == 'parent') {
- if (isset($_template->parent->parent)) {
- $scope_ptr = $_template->parent->parent;
- }
- } elseif ($scope == 'root' || $scope == 'global') {
- while (isset($scope_ptr->parent)) {
- $scope_ptr = $scope_ptr->parent;
- }
- }
- // copy global config vars
- foreach ($_config_vars['vars'] as $variable => $value) {
- if ($_template->smarty->config_overwrite || !isset($scope_ptr->config_vars[$variable])) {
- $scope_ptr->config_vars[$variable] = $value;
- } else {
- $scope_ptr->config_vars[$variable] = array_merge((array) $scope_ptr->config_vars[$variable], (array) $value);
- }
- }
- // scan sections
- $sections = $_template->source->config_sections;
- if (!empty($sections)) {
- foreach ((array) $sections as $_template_section) {
- if (isset($_config_vars['sections'][$_template_section])) {
- foreach ($_config_vars['sections'][$_template_section]['vars'] as $variable => $value) {
- if ($_template->smarty->config_overwrite || !isset($scope_ptr->config_vars[$variable])) {
- $scope_ptr->config_vars[$variable] = $value;
- } else {
- $scope_ptr->config_vars[$variable] = array_merge((array) $scope_ptr->config_vars[$variable], (array) $value);
- }
- }
- }
- }
- }
- }
-
- /**
- * Returns a single or all config variables
- *
- * @param string $varname variable name or null
- * @param bool $search_parents
- *
- * @return string variable value or or array of variables
- */
- static function getConfigVars($obj, $varname = null, $search_parents = true)
- {
- $_ptr = $obj;
- $var_array = array();
- while ($_ptr !== null) {
- if (isset($varname)) {
- if (isset($_ptr->config_vars[$varname])) {
- return $_ptr->config_vars[$varname];
- }
- } else {
- $var_array = array_merge($_ptr->config_vars, $var_array);
- }
- // not found, try at parent
- if ($search_parents) {
- $_ptr = $_ptr->parent;
- } else {
- $_ptr = null;
- }
- }
- if (isset($varname)) {
- return '';
- } else {
- return $var_array;
- }
- }
-
- /**
- * gets a config variable
- *
- * @param string $variable the name of the config variable
- * @param bool $error_enable
- *
- * @return mixed the value of the config variable
- */
- static function getConfigVariable($obj, $variable, $error_enable = true)
- {
- $_ptr = $obj;
- while ($_ptr !== null) {
- if (isset($_ptr->config_vars[$variable])) {
- // found it, return it
- return $_ptr->config_vars[$variable];
- }
- // not found, try at parent
- $_ptr = $_ptr->parent;
- }
- if ($obj->error_unassigned && $error_enable) {
- // force a notice
- $x = $$variable;
- }
-
- return null;
- }
-
- /**
- * remove a single or all config variables
- *
- * @param string $name variable name or null
- *
- * @return Smarty_Internal_Data current Smarty_Internal_Data (or Smarty or Smarty_Internal_Template) instance for chaining
- */
- static function clearConfig($obj, $name = null)
- {
- if (isset($name)) {
- unset($obj->config_vars[$name]);
- } else {
- $obj->config_vars = array();
- }
- return $obj;
- }
-}
diff --git a/library/Smarty/libs/sysplugins/smarty_internal_extension_defaulttemplatehandler.php b/library/Smarty/libs/sysplugins/smarty_internal_extension_defaulttemplatehandler.php
deleted file mode 100644
index ed6029204..000000000
--- a/library/Smarty/libs/sysplugins/smarty_internal_extension_defaulttemplatehandler.php
+++ /dev/null
@@ -1,85 +0,0 @@
-<?php
-/**
- * Smarty Resource Extension
- *
- * @package Smarty
- * @subpackage TemplateResources
- * @author Uwe Tews
- */
-
-/**
- * Smarty Resource Extension
- * Default template and config file handling
- *
- * @package Smarty
- * @subpackage TemplateResources
- */
-class Smarty_Internal_Extension_DefaultTemplateHandler
-{
-
- /**
- * get default content from template of config resource handler
- *
- * @param Smarty_Internal_Template $_template
- * @param Smarty_Internal_Template_Source $source
- * @param Smarty_Resource $resObj
- */
- static function _getDefault(Smarty_Internal_Template $_template, &$source, &$resObj)
- {
- if ($source->isConfig) {
- $default_handler = $_template->smarty->default_config_handler_func;
- } else {
- $default_handler = $_template->smarty->default_template_handler_func;
- }
- $_content = $_timestamp = null;
- $_return = call_user_func_array($default_handler,
- array($source->type, $source->name, &$_content, &$_timestamp, $source->smarty));
- if (is_string($_return)) {
- $source->exists = is_file($_return);
- if ($source->exists) {
- $source->timestamp = filemtime($_return);
- }
- $source->filepath = $_return;
- } elseif ($_return === true) {
- $source->content = $_content;
- $source->timestamp = $_timestamp;
- $source->exists = true;
- $source->recompiled = true;
- $source->filepath = false;
- }
- }
-
- /**
- * register template default handler
- *
- * @param Smarty $smarty
- * @param mixed $callback
- *
- * @throws SmartyException
- */
- static function registerDefaultTemplateHandler(Smarty $smarty, $callback)
- {
- if (is_callable($callback)) {
- $smarty->default_template_handler_func = $callback;
- } else {
- throw new SmartyException("Default template handler not callable");
- }
- }
-
- /**
- * register config default handler
- *
- * @param Smarty $smarty
- * @param mixed $callback
- *
- * @throws SmartyException
- */
- static function registerDefaultConfigHandler(Smarty $smarty, $callback)
- {
- if (is_callable($callback)) {
- $smarty->default_config_handler_func = $callback;
- } else {
- throw new SmartyException("Default config handler not callable");
- }
- }
-} \ No newline at end of file
diff --git a/library/Smarty/libs/sysplugins/smarty_internal_filter_handler.php b/library/Smarty/libs/sysplugins/smarty_internal_filter_handler.php
deleted file mode 100644
index 4f0f3981c..000000000
--- a/library/Smarty/libs/sysplugins/smarty_internal_filter_handler.php
+++ /dev/null
@@ -1,67 +0,0 @@
-<?php
-/**
- * Smarty Internal Plugin Filter Handler
- * Smarty filter handler class
- *
- * @package Smarty
- * @subpackage PluginsInternal
- * @author Uwe Tews
- */
-
-/**
- * Class for filter processing
- *
- * @package Smarty
- * @subpackage PluginsInternal
- */
-class Smarty_Internal_Filter_Handler
-{
- /**
- * Run filters over content
- * The filters will be lazy loaded if required
- * class name format: Smarty_FilterType_FilterName
- * plugin filename format: filtertype.filtername.php
- * Smarty2 filter plugins could be used
- *
- * @param string $type the type of filter ('pre','post','output') which shall run
- * @param string $content the content which shall be processed by the filters
- * @param Smarty_Internal_Template $template template object
- *
- * @throws SmartyException
- * @return string the filtered content
- */
- public static function runFilter($type, $content, Smarty_Internal_Template $template)
- {
- $output = $content;
- // loop over autoload filters of specified type
- if (!empty($template->smarty->autoload_filters[$type])) {
- foreach ((array) $template->smarty->autoload_filters[$type] as $name) {
- $plugin_name = "Smarty_{$type}filter_{$name}";
- if ($template->smarty->loadPlugin($plugin_name)) {
- if (function_exists($plugin_name)) {
- // use loaded Smarty2 style plugin
- $output = $plugin_name($output, $template);
- } elseif (class_exists($plugin_name, false)) {
- // loaded class of filter plugin
- $output = call_user_func(array($plugin_name, 'execute'), $output, $template);
- }
- } else {
- // nothing found, throw exception
- throw new SmartyException("Unable to load filter {$plugin_name}");
- }
- }
- }
- // loop over registerd filters of specified type
- if (!empty($template->smarty->registered_filters[$type])) {
- foreach ($template->smarty->registered_filters[$type] as $key => $name) {
- if (is_array($template->smarty->registered_filters[$type][$key])) {
- $output = call_user_func($template->smarty->registered_filters[$type][$key], $output, $template);
- } else {
- $output = $template->smarty->registered_filters[$type][$key]($output, $template);
- }
- }
- }
- // return filtered output
- return $output;
- }
-}
diff --git a/library/Smarty/libs/sysplugins/smarty_internal_function_call_handler.php b/library/Smarty/libs/sysplugins/smarty_internal_function_call_handler.php
deleted file mode 100644
index 6cf4188a2..000000000
--- a/library/Smarty/libs/sysplugins/smarty_internal_function_call_handler.php
+++ /dev/null
@@ -1,71 +0,0 @@
-<?php
-/**
- * Smarty Internal Plugin Function Call Handler
- *
- * @package Smarty
- * @subpackage PluginsInternal
- * @author Uwe Tews
- */
-
-/**
- * This class does handles template functions defined with the {function} tag missing in cache file.
- * It can happen when the template function was called with the nocache option or within a nocache section.
- * The template function will be loaded from it's compiled template file, executed and added to the cache file
- * for later use.
- *
- * @package Smarty
- * @subpackage PluginsInternal
- */
-class Smarty_Internal_Function_Call_Handler
-{
- /**
- * This function handles calls to template functions defined by {function}
- * It does create a PHP function at the first call
- *
- * @param string $_name template function name
- * @param Smarty_Internal_Template $_smarty_tpl
- * @param string $_function PHP function name
- * @param array $_params Smarty variables passed as call parameter
- * @param bool $_nocache nocache flag
- *
- * @return bool
- */
- public static function call($_name, Smarty_Internal_Template $_smarty_tpl, $_function, $_params, $_nocache)
- {
- $funcParam = $_smarty_tpl->properties['tpl_function'][$_name];
- if (is_file($funcParam['compiled_filepath'])) {
- // read compiled file
- $code = file_get_contents($funcParam['compiled_filepath']);
- // grab template function
- if (preg_match("/\/\* {$_function} \*\/([\S\s]*?)\/\*\/ {$_function} \*\//", $code, $match)) {
- // grab source info from file dependency
- preg_match("/\s*'{$funcParam['uid']}'([\S\s]*?)\),/", $code, $match1);
- unset($code);
- $output = '';
- // make PHP function known
- eval($match[0]);
- if (function_exists($_function)) {
- // search cache file template
- $tplPtr = $_smarty_tpl;
- while (!isset($tplPtr->cached) && isset($tplPtr->parent)) {
- $tplPtr = $tplPtr->parent;
- }
- // add template function code to cache file
- if (isset($tplPtr->cached)) {
- $cache = $tplPtr->cached;
- $content = $cache->read($tplPtr);
- if ($content) {
- // check if we must update file dependency
- if (!preg_match("/'{$funcParam['uid']}'([\S\s]*?)'nocache_hash'/", $content, $match2)) {
- $content = preg_replace("/('file_dependency'([\S\s]*?)\()/", "\\1{$match1[0]}", $content);
- }
- $cache->write($tplPtr, $content . "<?php " . $match[0] . "?>\n");
- }
- }
- return true;
- }
- }
- }
- return false;
- }
-}
diff --git a/library/Smarty/libs/sysplugins/smarty_internal_get_include_path.php b/library/Smarty/libs/sysplugins/smarty_internal_get_include_path.php
deleted file mode 100644
index d46ca7029..000000000
--- a/library/Smarty/libs/sysplugins/smarty_internal_get_include_path.php
+++ /dev/null
@@ -1,46 +0,0 @@
-<?php
-/**
- * Smarty read include path plugin
- *
- * @package Smarty
- * @subpackage PluginsInternal
- * @author Monte Ohrt
- */
-
-/**
- * Smarty Internal Read Include Path Class
- *
- * @package Smarty
- * @subpackage PluginsInternal
- */
-class Smarty_Internal_Get_Include_Path
-{
- /**
- * Return full file path from PHP include_path
- *
- * @param string $filepath filepath
- *
- * @return string|boolean full filepath or false
- */
- public static function getIncludePath($filepath)
- {
- static $_include_path = null;
-
- if (function_exists('stream_resolve_include_path')) {
- // available since PHP 5.3.2
- return stream_resolve_include_path($filepath);
- }
-
- if ($_include_path === null) {
- $_include_path = explode(PATH_SEPARATOR, get_include_path());
- }
-
- foreach ($_include_path as $_path) {
- if (file_exists($_path . DS . $filepath)) {
- return $_path . DS . $filepath;
- }
- }
-
- return false;
- }
-}
diff --git a/library/Smarty/libs/sysplugins/smarty_internal_nocache_insert.php b/library/Smarty/libs/sysplugins/smarty_internal_nocache_insert.php
index 0d2facfe9..b3d5fa86a 100644
--- a/library/Smarty/libs/sysplugins/smarty_internal_nocache_insert.php
+++ b/library/Smarty/libs/sysplugins/smarty_internal_nocache_insert.php
@@ -42,10 +42,10 @@ class Smarty_Internal_Nocache_Insert
$_output .= "echo {$_function}(" . var_export($_attr, true) . ",\$_smarty_tpl);?>";
}
$_tpl = $_template;
- while ($_tpl->parent instanceof Smarty_Internal_Template) {
+ while (isset($_tpl->parent) && $_tpl->parent->_objType == 2) {
$_tpl = $_tpl->parent;
}
- return "/*%%SmartyNocache:{$_tpl->properties['nocache_hash']}%%*/" . $_output . "/*/%%SmartyNocache:{$_tpl->properties['nocache_hash']}%%*/";
+ return "/*%%SmartyNocache:{$_tpl->compiled->nocache_hash}%%*/" . $_output . "/*/%%SmartyNocache:{$_tpl->compiled->nocache_hash}%%*/";
}
}
diff --git a/library/Smarty/libs/sysplugins/smarty_internal_parsetree.php b/library/Smarty/libs/sysplugins/smarty_internal_parsetree.php
index c96731ed9..32c9df094 100644
--- a/library/Smarty/libs/sysplugins/smarty_internal_parsetree.php
+++ b/library/Smarty/libs/sysplugins/smarty_internal_parsetree.php
@@ -18,13 +18,6 @@ abstract class Smarty_Internal_ParseTree
{
/**
- * Parser object
- *
- * @var object
- */
- public $parser;
-
- /**
* Buffer content
*
* @var mixed
@@ -41,9 +34,21 @@ abstract class Smarty_Internal_ParseTree
/**
* Return buffer
*
+ * @param \Smarty_Internal_Templateparser $parser
+ *
* @return string buffer content
*/
- abstract public function to_smarty_php();
+ abstract public function to_smarty_php(Smarty_Internal_Templateparser $parser);
+
+ /**
+ * Template data object destructor
+ */
+ public function __destruct()
+ {
+ $this->data = null;
+ $this->subtrees = null;
+ }
+
}
diff --git a/library/Smarty/libs/sysplugins/smarty_internal_parsetree_code.php b/library/Smarty/libs/sysplugins/smarty_internal_parsetree_code.php
index a44ae499c..d0f0b3fd9 100644
--- a/library/Smarty/libs/sysplugins/smarty_internal_parsetree_code.php
+++ b/library/Smarty/libs/sysplugins/smarty_internal_parsetree_code.php
@@ -21,21 +21,21 @@ class Smarty_Internal_ParseTree_Code extends Smarty_Internal_ParseTree
/**
* Create parse tree buffer for code fragment
*
- * @param object $parser parser object
- * @param string $data content
+ * @param string $data content
*/
- public function __construct($parser, $data)
+ public function __construct($data)
{
- $this->parser = $parser;
$this->data = $data;
}
/**
* Return buffer content in parentheses
*
+ * @param \Smarty_Internal_Templateparser $parser
+ *
* @return string content
*/
- public function to_smarty_php()
+ public function to_smarty_php(Smarty_Internal_Templateparser $parser)
{
return sprintf("(%s)", $this->data);
}
diff --git a/library/Smarty/libs/sysplugins/smarty_internal_parsetree_dq.php b/library/Smarty/libs/sysplugins/smarty_internal_parsetree_dq.php
index bdfa4c48f..607389cb5 100644
--- a/library/Smarty/libs/sysplugins/smarty_internal_parsetree_dq.php
+++ b/library/Smarty/libs/sysplugins/smarty_internal_parsetree_dq.php
@@ -25,43 +25,45 @@ class Smarty_Internal_ParseTree_Dq extends Smarty_Internal_ParseTree
*/
public function __construct($parser, Smarty_Internal_ParseTree $subtree)
{
- $this->parser = $parser;
$this->subtrees[] = $subtree;
if ($subtree instanceof Smarty_Internal_ParseTree_Tag) {
- $this->parser->block_nesting_level = count($this->parser->compiler->_tag_stack);
+ $parser->block_nesting_level = count($parser->compiler->_tag_stack);
}
}
/**
* Append buffer to subtree
*
- * @param Smarty_Internal_ParseTree $subtree parse tree buffer
+ * @param \Smarty_Internal_Templateparser $parser
+ * @param Smarty_Internal_ParseTree $subtree parse tree buffer
*/
- public function append_subtree(Smarty_Internal_ParseTree $subtree)
+ public function append_subtree(Smarty_Internal_Templateparser $parser, Smarty_Internal_ParseTree $subtree)
{
$last_subtree = count($this->subtrees) - 1;
- if ($last_subtree >= 0 && $this->subtrees[$last_subtree] instanceof Smarty_Internal_ParseTree_Tag && $this->subtrees[$last_subtree]->saved_block_nesting < $this->parser->block_nesting_level) {
+ if ($last_subtree >= 0 && $this->subtrees[$last_subtree] instanceof Smarty_Internal_ParseTree_Tag && $this->subtrees[$last_subtree]->saved_block_nesting < $parser->block_nesting_level) {
if ($subtree instanceof Smarty_Internal_ParseTree_Code) {
- $this->subtrees[$last_subtree]->data = $this->parser->compiler->appendCode($this->subtrees[$last_subtree]->data, '<?php echo ' . $subtree->data . ';?>');
+ $this->subtrees[$last_subtree]->data = $parser->compiler->appendCode($this->subtrees[$last_subtree]->data, '<?php echo ' . $subtree->data . ';?>');
} elseif ($subtree instanceof Smarty_Internal_ParseTree_DqContent) {
- $this->subtrees[$last_subtree]->data = $this->parser->compiler->appendCode($this->subtrees[$last_subtree]->data, '<?php echo "' . $subtree->data . '";?>');
+ $this->subtrees[$last_subtree]->data = $parser->compiler->appendCode($this->subtrees[$last_subtree]->data, '<?php echo "' . $subtree->data . '";?>');
} else {
- $this->subtrees[$last_subtree]->data = $this->parser->compiler->appendCode($this->subtrees[$last_subtree]->data, $subtree->data);
+ $this->subtrees[$last_subtree]->data = $parser->compiler->appendCode($this->subtrees[$last_subtree]->data, $subtree->data);
}
} else {
$this->subtrees[] = $subtree;
}
if ($subtree instanceof Smarty_Internal_ParseTree_Tag) {
- $this->parser->block_nesting_level = count($this->parser->compiler->_tag_stack);
+ $parser->block_nesting_level = count($parser->compiler->_tag_stack);
}
}
/**
* Merge subtree buffer content together
*
+ * @param \Smarty_Internal_Templateparser $parser
+ *
* @return string compiled template code
*/
- public function to_smarty_php()
+ public function to_smarty_php(Smarty_Internal_Templateparser $parser)
{
$code = '';
foreach ($this->subtrees as $subtree) {
@@ -69,15 +71,15 @@ class Smarty_Internal_ParseTree_Dq extends Smarty_Internal_ParseTree
$code .= ".";
}
if ($subtree instanceof Smarty_Internal_ParseTree_Tag) {
- $more_php = $subtree->assign_to_var();
+ $more_php = $subtree->assign_to_var($parser);
} else {
- $more_php = $subtree->to_smarty_php();
+ $more_php = $subtree->to_smarty_php($parser);
}
$code .= $more_php;
if (!$subtree instanceof Smarty_Internal_ParseTree_DqContent) {
- $this->parser->compiler->has_variable_string = true;
+ $parser->compiler->has_variable_string = true;
}
}
diff --git a/library/Smarty/libs/sysplugins/smarty_internal_parsetree_dqcontent.php b/library/Smarty/libs/sysplugins/smarty_internal_parsetree_dqcontent.php
index 3197772d1..a8ca389d9 100644
--- a/library/Smarty/libs/sysplugins/smarty_internal_parsetree_dqcontent.php
+++ b/library/Smarty/libs/sysplugins/smarty_internal_parsetree_dqcontent.php
@@ -21,21 +21,21 @@ class Smarty_Internal_ParseTree_DqContent extends Smarty_Internal_ParseTree
/**
* Create parse tree buffer with string content
*
- * @param object $parser parser object
- * @param string $data string section
+ * @param string $data string section
*/
- public function __construct($parser, $data)
+ public function __construct($data)
{
- $this->parser = $parser;
$this->data = $data;
}
/**
* Return content as double quoted string
*
+ * @param \Smarty_Internal_Templateparser $parser
+ *
* @return string doubled quoted string
*/
- public function to_smarty_php()
+ public function to_smarty_php(Smarty_Internal_Templateparser $parser)
{
return '"' . $this->data . '"';
}
diff --git a/library/Smarty/libs/sysplugins/smarty_internal_parsetree_tag.php b/library/Smarty/libs/sysplugins/smarty_internal_parsetree_tag.php
index 81475b5f0..575c8c9e8 100644
--- a/library/Smarty/libs/sysplugins/smarty_internal_parsetree_tag.php
+++ b/library/Smarty/libs/sysplugins/smarty_internal_parsetree_tag.php
@@ -29,12 +29,11 @@ class Smarty_Internal_ParseTree_Tag extends Smarty_Internal_ParseTree
/**
* Create parse tree buffer for Smarty tag
*
- * @param object $parser parser object
- * @param string $data content
+ * @param \Smarty_Internal_Templateparser $parser parser object
+ * @param string $data content
*/
- public function __construct($parser, $data)
+ public function __construct(Smarty_Internal_Templateparser $parser, $data)
{
- $this->parser = $parser;
$this->data = $data;
$this->saved_block_nesting = $parser->block_nesting_level;
}
@@ -42,9 +41,11 @@ class Smarty_Internal_ParseTree_Tag extends Smarty_Internal_ParseTree
/**
* Return buffer content
*
+ * @param \Smarty_Internal_Templateparser $parser
+ *
* @return string content
*/
- public function to_smarty_php()
+ public function to_smarty_php(Smarty_Internal_Templateparser $parser)
{
return $this->data;
}
@@ -52,14 +53,16 @@ class Smarty_Internal_ParseTree_Tag extends Smarty_Internal_ParseTree
/**
* Return complied code that loads the evaluated output of buffer content into a temporary variable
*
+ * @param \Smarty_Internal_Templateparser $parser
+ *
* @return string template code
*/
- public function assign_to_var()
+ public function assign_to_var(Smarty_Internal_Templateparser $parser)
{
$var = sprintf('$_tmp%d', ++ Smarty_Internal_Templateparser::$prefix_number);
- $tmp = $this->parser->compiler->appendCode('<?php ob_start();?>', $this->data);
- $tmp = $this->parser->compiler->appendCode($tmp, "<?php {$var}=ob_get_clean();?>");
- $this->parser->compiler->prefix_code[] = sprintf("%s", $tmp);
+ $tmp = $parser->compiler->appendCode('<?php ob_start();?>', $this->data);
+ $tmp = $parser->compiler->appendCode($tmp, "<?php {$var}=ob_get_clean();?>");
+ $parser->compiler->prefix_code[] = sprintf("%s", $tmp);
return $var;
}
diff --git a/library/Smarty/libs/sysplugins/smarty_internal_parsetree_template.php b/library/Smarty/libs/sysplugins/smarty_internal_parsetree_template.php
index 7d814edaa..623ae51a3 100644
--- a/library/Smarty/libs/sysplugins/smarty_internal_parsetree_template.php
+++ b/library/Smarty/libs/sysplugins/smarty_internal_parsetree_template.php
@@ -29,19 +29,18 @@ class Smarty_Internal_ParseTree_Template extends Smarty_Internal_ParseTree
/**
* Create root of parse tree for template elements
*
- * @param object $parser parse object
*/
- public function __construct($parser)
+ public function __construct()
{
- $this->parser = $parser;
}
/**
* Append buffer to subtree
*
- * @param Smarty_Internal_ParseTree $subtree
+ * @param \Smarty_Internal_Templateparser $parser
+ * @param Smarty_Internal_ParseTree $subtree
*/
- public function append_subtree(Smarty_Internal_ParseTree $subtree)
+ public function append_subtree(Smarty_Internal_Templateparser $parser, Smarty_Internal_ParseTree $subtree)
{
if (!empty($subtree->subtrees)) {
$this->subtrees = array_merge($this->subtrees, $subtree->subtrees);
@@ -53,37 +52,68 @@ class Smarty_Internal_ParseTree_Template extends Smarty_Internal_ParseTree
}
/**
+ * Append array to subtree
+ *
+ * @param \Smarty_Internal_Templateparser $parser
+ * @param \Smarty_Internal_ParseTree[] $array
+ */
+ public function append_array(Smarty_Internal_Templateparser $parser, $array = array())
+ {
+ if (!empty($array)) {
+ $this->subtrees = array_merge($this->subtrees, (array) $array);
+ }
+ }
+
+ /**
+ * Prepend array to subtree
+ *
+ * @param \Smarty_Internal_Templateparser $parser
+ * @param \Smarty_Internal_ParseTree[] $array
+ */
+ public function prepend_array(Smarty_Internal_Templateparser $parser, $array = array())
+ {
+ if (!empty($array)) {
+ $this->subtrees = array_merge((array) $array, $this->subtrees);
+ }
+ }
+
+ /**
* Sanitize and merge subtree buffers together
*
+ * @param \Smarty_Internal_Templateparser $parser
+ *
* @return string template code content
*/
- public function to_smarty_php()
+ public function to_smarty_php(Smarty_Internal_Templateparser $parser)
{
$code = '';
for ($key = 0, $cnt = count($this->subtrees); $key < $cnt; $key ++) {
if ($this->subtrees[$key] instanceof Smarty_Internal_ParseTree_Text) {
- $subtree = $this->subtrees[$key]->to_smarty_php();
- while ($key + 1 < $cnt && ($this->subtrees[$key + 1] instanceof Smarty_Internal_ParseTree_Text || $this->subtrees[$key + 1]->data == '')) {
+ $subtree = $this->subtrees[$key]->to_smarty_php($parser);
+ while ($key + 1 < $cnt && ($this->subtrees[$key + 1] instanceof Smarty_Internal_ParseTree_Text ||
+ $this->subtrees[$key + 1]->data == '')) {
$key ++;
if ($this->subtrees[$key]->data == '') {
continue;
}
- $subtree .= $this->subtrees[$key]->to_smarty_php();
+ $subtree .= $this->subtrees[$key]->to_smarty_php($parser);
}
if ($subtree == '') {
continue;
}
- $code .= preg_replace('/((<%)|(%>)|(<\?php)|(<\?)|(\?>)|(<\/?script))/', "<?php echo '\$1'; ?>\n", $subtree);
+ $code .= preg_replace('/((<%)|(%>)|(<\?php)|(<\?)|(\?>)|(<\/?script))/', "<?php echo '\$1'; ?>\n",
+ $subtree);
continue;
}
if ($this->subtrees[$key] instanceof Smarty_Internal_ParseTree_Tag) {
- $subtree = $this->subtrees[$key]->to_smarty_php();
- while ($key + 1 < $cnt && ($this->subtrees[$key + 1] instanceof Smarty_Internal_ParseTree_Tag || $this->subtrees[$key + 1]->data == '')) {
+ $subtree = $this->subtrees[$key]->to_smarty_php($parser);
+ while ($key + 1 < $cnt && ($this->subtrees[$key + 1] instanceof Smarty_Internal_ParseTree_Tag ||
+ $this->subtrees[$key + 1]->data == '')) {
$key ++;
if ($this->subtrees[$key]->data == '') {
continue;
}
- $subtree = $this->parser->compiler->appendCode($subtree, $this->subtrees[$key]->to_smarty_php());
+ $subtree = $parser->compiler->appendCode($subtree, $this->subtrees[$key]->to_smarty_php($parser));
}
if ($subtree == '') {
continue;
@@ -91,7 +121,7 @@ class Smarty_Internal_ParseTree_Template extends Smarty_Internal_ParseTree
$code .= $subtree;
continue;
}
- $code .= $this->subtrees[$key]->to_smarty_php();
+ $code .= $this->subtrees[$key]->to_smarty_php($parser);
}
return $code;
}
diff --git a/library/Smarty/libs/sysplugins/smarty_internal_parsetree_text.php b/library/Smarty/libs/sysplugins/smarty_internal_parsetree_text.php
index 42d5bd299..b3100fa09 100644
--- a/library/Smarty/libs/sysplugins/smarty_internal_parsetree_text.php
+++ b/library/Smarty/libs/sysplugins/smarty_internal_parsetree_text.php
@@ -19,21 +19,21 @@ class Smarty_Internal_ParseTree_Text extends Smarty_Internal_ParseTree
/**
* Create template text buffer
*
- * @param object $parser parser object
- * @param string $data text
+ * @param string $data text
*/
- public function __construct($parser, $data)
+ public function __construct($data)
{
- $this->parser = $parser;
$this->data = $data;
}
/**
* Return buffer content
*
+ * @param \Smarty_Internal_Templateparser $parser
+ *
* @return string text
*/
- public function to_smarty_php()
+ public function to_smarty_php(Smarty_Internal_Templateparser $parser)
{
return $this->data;
}
diff --git a/library/Smarty/libs/sysplugins/smarty_internal_resource_extends.php b/library/Smarty/libs/sysplugins/smarty_internal_resource_extends.php
index 16974ef29..0c0802d62 100644
--- a/library/Smarty/libs/sysplugins/smarty_internal_resource_extends.php
+++ b/library/Smarty/libs/sysplugins/smarty_internal_resource_extends.php
@@ -34,30 +34,29 @@ class Smarty_Internal_Resource_Extends extends Smarty_Resource
*/
public function populate(Smarty_Template_Source $source, Smarty_Internal_Template $_template = null)
{
- $uid = sha1(getcwd());
+ $uid = '';
$sources = array();
$components = explode('|', $source->name);
$exists = true;
foreach ($components as $component) {
- $s = Smarty_Resource::source(null, $source->smarty, $component);
- if ($s->type == 'php') {
- throw new SmartyException("Resource type {$s->type} cannot be used with the extends resource type");
+ /* @var \Smarty_Template_Source $_s */
+ $_s = Smarty_Template_Source::load(null, $source->smarty, $component);
+ if ($_s->type == 'php') {
+ throw new SmartyException("Resource type {$_s->type} cannot be used with the extends resource type");
}
- $sources[$s->uid] = $s;
- $uid .= realpath($s->filepath);
- if ($_template && $_template->smarty->compile_check) {
- $exists = $exists && $s->exists;
+ $sources[$_s->uid] = $_s;
+ $uid .= $_s->filepath;
+ if ($_template) {
+ $exists = $exists && $_s->exists;
}
}
$source->components = $sources;
- $source->filepath = $s->filepath;
+ $source->filepath = $_s->filepath;
$source->uid = sha1($uid);
- if ($_template && $_template->smarty->compile_check) {
- $source->timestamp = $s->timestamp;
- $source->exists = $exists;
+ $source->exists = $exists;
+ if ($_template) {
+ $source->timestamp = $_s->timestamp;
}
- // need the template at getContent()
- $source->template = $_template;
}
/**
@@ -68,10 +67,11 @@ class Smarty_Internal_Resource_Extends extends Smarty_Resource
public function populateTimestamp(Smarty_Template_Source $source)
{
$source->exists = true;
- foreach ($source->components as $s) {
- $source->exists = $source->exists && $s->exists;
+ /* @var \Smarty_Template_Source $_s */
+ foreach ($source->components as $_s) {
+ $source->exists = $source->exists && $_s->exists;
}
- $source->timestamp = $s->timestamp;
+ $source->timestamp = $source->exists ? $_s->getTimeStamp() : false;
}
/**
@@ -91,9 +91,10 @@ class Smarty_Internal_Resource_Extends extends Smarty_Resource
$_components = array_reverse($source->components);
$_content = '';
- foreach ($_components as $_component) {
+ /* @var \Smarty_Template_Source $_s */
+ foreach ($_components as $_s) {
// read content
- $_content .= $_component->content;
+ $_content .= $_s->getContent();
}
return $_content;
}
diff --git a/library/Smarty/libs/sysplugins/smarty_internal_resource_file.php b/library/Smarty/libs/sysplugins/smarty_internal_resource_file.php
index b34033dd8..b15e3cc6a 100644
--- a/library/Smarty/libs/sysplugins/smarty_internal_resource_file.php
+++ b/library/Smarty/libs/sysplugins/smarty_internal_resource_file.php
@@ -29,120 +29,83 @@ class Smarty_Internal_Resource_File extends Smarty_Resource
protected function buildFilepath(Smarty_Template_Source $source, Smarty_Internal_Template $_template = null)
{
$file = $source->name;
- preg_match('#^(?P<absolute>[\\\/]|[a-zA-Z]:[\\\/])|(\[(?P<index>[^\]]+)\])|(?P<rel>\.[\\\/])#', $file, $fileMatch);
- // save basename
- if (!empty($fileMatch['absolute'])) {
- $file = $this->normalizePath($file);
+ // absolute file ?
+ if ($file[0] == '/' || $file[1] == ':') {
+ $file = $source->smarty->_realpath($file, true);
return is_file($file) ? $file : false;
}
// go relative to a given template?
- if (!empty($fileMatch['rel']) && $_template && $_template->parent instanceof Smarty_Internal_Template) {
- if ($_template->parent->source->type != 'file' && $_template->parent->source->type != 'extends' && !$_template->parent->allow_relative_path) {
+ if ($file[0] == '.' && $_template && isset($_template->parent) && $_template->parent->_objType == 2 &&
+ preg_match('#^[.]{1,2}[\\\/]#', $file)
+ ) {
+ if ($_template->parent->source->type != 'file' && $_template->parent->source->type != 'extends' &&
+ !isset($_template->parent->_cache['allow_relative_path'])
+ ) {
throw new SmartyException("Template '{$file}' cannot be relative to template of resource type '{$_template->parent->source->type}'");
}
$path = dirname($_template->parent->source->filepath) . DS . $file;
// normalize path
- $path = $this->normalizePath($path);
+ $path = $source->smarty->_realpath($path);
// files relative to a template only get one shot
return is_file($path) ? $path : false;
}
-
- if ($source->isConfig) {
- $_directories = $source->smarty->getConfigDir();
- } else {
- $_directories = $source->smarty->getTemplateDir();
+ // normalize DS
+ if (strpos($file, DS == '/' ? '\\' : '/') !== false) {
+ $file = str_replace(DS == '/' ? '\\' : '/', DS, $file);
}
+
+ $_directories = $source->smarty->getTemplateDir(null, $source->isConfig);
// template_dir index?
- if (!empty($fileMatch['index'])) {
- $index = $fileMatch['index'];
- $_directory = null;
- // try string indexes
- if (isset($_directories[$index])) {
- $_directory = $_directories[$index];
- } elseif (is_numeric($index)) {
- // try numeric index
- $index = (int) $index;
+ if ($file[0] == '[' && preg_match('#^\[([^\]]+)\](.+)$#', $file, $fileMatch)) {
+ $file = $fileMatch[2];
+ $_indices = explode(',', $fileMatch[1]);
+ $_index_dirs = array();
+ foreach ($_indices as $index) {
+ $index = trim($index);
+ // try string indexes
if (isset($_directories[$index])) {
- $_directory = $_directories[$index];
- } else {
- // try at location index
- $keys = array_keys($_directories);
- $_directory = $_directories[$keys[$index]];
+ $_index_dirs[] = $_directories[$index];
+ } elseif (is_numeric($index)) {
+ // try numeric index
+ $index = (int) $index;
+ if (isset($_directories[$index])) {
+ $_index_dirs[] = $_directories[$index];
+ } else {
+ // try at location index
+ $keys = array_keys($_directories);
+ if (isset($_directories[$keys[$index]])) {
+ $_index_dirs[] = $_directories[$keys[$index]];
+ }
+ }
}
}
- if ($_directory) {
- preg_match('#\](.+)$#', $file, $fileMatch);
- $path = $_directory . $fileMatch[1];
- $path = $this->normalizePath($path);
- if (is_file($path)) {
- return $path;
- }
- } else {
+ if (empty($_index_dirs)) {
// index not found
return false;
+ } else {
+ $_directories = $_index_dirs;
}
}
// relative file name?
foreach ($_directories as $_directory) {
- $_filepath = $_directory . $file;
- $path = $this->normalizePath($_filepath);
+ $path = $_directory . $file;
if (is_file($path)) {
- return $path;
- }
- if ($source->smarty->use_include_path && !preg_match('/^([\/\\\\]|[a-zA-Z]:[\/\\\\])/', $_directory)) {
- // try PHP include_path
- if (function_exists('stream_resolve_include_path')) {
- $_filepath = stream_resolve_include_path($_filepath);
- } else {
- $_filepath = Smarty_Internal_Get_Include_Path::getIncludePath($_filepath);
- }
- if ($_filepath !== false) {
- $path = $this->normalizePath($_filepath);
- if (is_file($path)) {
- return $path;
- }
- }
+ return (strpos($path, '.' . DS) !== false) ? $source->smarty->_realpath($path) : $path;
}
}
- // Could be relative to cwd
- $path = $this->normalizePath(getcwd() . DS . $file);
- return is_file($path) ? $path : false;
- }
-
- /**
- * Normalize path
- * - remove /./ and /../
- * - make it absolute
- *
- * @param string $path file path
- *
- * @return string
- */
- public function normalizePath($path)
- {
- if ($path[0] == '.') {
- $path = getcwd() . DS . $path;
+ if (!isset($_index_dirs)) {
+ // Could be relative to cwd
+ $path = $source->smarty->_realpath($file, true);
+ if (is_file($path)) {
+ return $path;
+ }
}
- $path = preg_replace('#[\\\/]+([.][\\\/]+)*#', DS, $path);
- while (strrpos($path, '.' . DS) !== false) {
- $path = preg_replace('#([\\\/]([^\\\/]+[\\\/]){2}([.][.][\\\/]){2})|([\\\/][^\\\/]+[\\\/][.][.][\\\/])#', DS, $path);
+ // Use include path ?
+ if ($source->smarty->use_include_path) {
+ return $source->smarty->ext->_getIncludePath->getIncludePath($_directories, $file, $source->smarty);
}
- return $path;
- }
-
- /**
- * test is file exists and save timestamp
- *
- * @param Smarty_Template_Source $source source object
- * @param string $file file name
- *
- * @return bool true if file exists
- */
- protected function fileExists(Smarty_Template_Source $source, $file)
- {
- $source->timestamp = is_file($file) ? @filemtime($file) : false;
- return $source->exists = !!$source->timestamp;
+ return false;
}
/**
@@ -156,13 +119,13 @@ class Smarty_Internal_Resource_File extends Smarty_Resource
$source->filepath = $this->buildFilepath($source, $_template);
if ($source->filepath !== false) {
- if (is_object($source->smarty->security_policy)) {
- $source->smarty->security_policy->isTrustedResourceDir($source->filepath);
+ if (isset($source->smarty->security_policy) && is_object($source->smarty->security_policy)) {
+ $source->smarty->security_policy->isTrustedResourceDir($source->filepath, $source->isConfig);
}
$source->exists = true;
$source->uid = sha1($source->filepath);
- if ($source->smarty->compile_check && !isset($source->timestamp)) {
- $source->timestamp = @filemtime($source->filepath);
+ if ($source->smarty->compile_check == 1) {
+ $source->timestamp = filemtime($source->filepath);
}
} else {
$source->timestamp = false;
@@ -177,9 +140,11 @@ class Smarty_Internal_Resource_File extends Smarty_Resource
*/
public function populateTimestamp(Smarty_Template_Source $source)
{
- $source->timestamp = $source->exists = is_file($source->filepath);
+ if (!$source->exists) {
+ $source->timestamp = $source->exists = is_file($source->filepath);
+ }
if ($source->exists) {
- $source->timestamp = @filemtime($source->filepath);
+ $source->timestamp = filemtime($source->filepath);
}
}
@@ -193,13 +158,11 @@ class Smarty_Internal_Resource_File extends Smarty_Resource
*/
public function getContent(Smarty_Template_Source $source)
{
- if ($source->timestamp) {
+ if ($source->exists) {
return file_get_contents($source->filepath);
}
- if ($source instanceof Smarty_Config_Source) {
- throw new SmartyException("Unable to read config {$source->type} '{$source->name}'");
- }
- throw new SmartyException("Unable to read template {$source->type} '{$source->name}'");
+ throw new SmartyException('Unable to read ' . ($source->isConfig ? 'config' : 'template') .
+ " {$source->type} '{$source->name}'");
}
/**
diff --git a/library/Smarty/libs/sysplugins/smarty_internal_resource_php.php b/library/Smarty/libs/sysplugins/smarty_internal_resource_php.php
index c836d1b26..62680625c 100644
--- a/library/Smarty/libs/sysplugins/smarty_internal_resource_php.php
+++ b/library/Smarty/libs/sysplugins/smarty_internal_resource_php.php
@@ -25,6 +25,14 @@ class Smarty_Internal_Resource_Php extends Smarty_Internal_Resource_File
protected $short_open_tag;
/**
+ * Resource does implement populateCompiledFilepath() method
+ *
+ * @var bool
+ */
+ public $hasCompiledHandler = true;
+
+
+ /**
* Create a new PHP Resource
*/
@@ -43,7 +51,7 @@ class Smarty_Internal_Resource_Php extends Smarty_Internal_Resource_File
*/
public function getContent(Smarty_Template_Source $source)
{
- if ($source->timestamp) {
+ if ($source->exists) {
return '';
}
throw new SmartyException("Unable to read template {$source->type} '{$source->name}'");
@@ -64,7 +72,7 @@ class Smarty_Internal_Resource_Php extends Smarty_Internal_Resource_File
throw new SmartyException("PHP templates are disabled");
}
if (!$source->exists) {
- if ($_template->parent instanceof Smarty_Internal_Template) {
+ if (isset($_template->parent) && $_template->parent->_objType == 2) {
$parent_resource = " in '{$_template->parent->template_resource}'";
} else {
$parent_resource = '';
diff --git a/library/Smarty/libs/sysplugins/smarty_internal_resource_registered.php b/library/Smarty/libs/sysplugins/smarty_internal_resource_registered.php
index f7175dd93..69b396b6a 100644
--- a/library/Smarty/libs/sysplugins/smarty_internal_resource_registered.php
+++ b/library/Smarty/libs/sysplugins/smarty_internal_resource_registered.php
@@ -76,12 +76,13 @@ class Smarty_Internal_Resource_Registered extends Smarty_Resource
public function getContent(Smarty_Template_Source $source)
{
// return template string
- $t = call_user_func_array($source->smarty->registered_resources[$source->type][0][0], array($source->name, &$source->content, $source->smarty));
+ $content = null;
+ $t = call_user_func_array($source->smarty->registered_resources[$source->type][0][0], array($source->name, &$content, $source->smarty));
if (is_bool($t) && !$t) {
throw new SmartyException("Unable to read template {$source->type} '{$source->name}'");
}
- return $source->content;
+ return $content;
}
/**
diff --git a/library/Smarty/libs/sysplugins/smarty_internal_smartytemplatecompiler.php b/library/Smarty/libs/sysplugins/smarty_internal_smartytemplatecompiler.php
index ca9bc669b..116bbea7b 100644
--- a/library/Smarty/libs/sysplugins/smarty_internal_smartytemplatecompiler.php
+++ b/library/Smarty/libs/sysplugins/smarty_internal_smartytemplatecompiler.php
@@ -9,11 +9,6 @@
*/
/**
- * @ignore
- */
-//include 'smarty_internal_parsetree.php';
-
-/**
* Class SmartyTemplateCompiler
*
* @package Smarty
@@ -36,25 +31,32 @@ class Smarty_Internal_SmartyTemplateCompiler extends Smarty_Internal_TemplateCom
public $parser_class;
/**
- * Lexer object
+ * array of vars which can be compiled in local scope
*
- * @var object
+ * @var array
*/
- public $lex;
+ public $local_var = array();
/**
- * Parser object
+ * array of callbacks called when the normal compile process of template is finished
*
- * @var object
+ * @var array
*/
- public $parser;
+ public $postCompileCallbacks = array();
/**
- * array of vars which can be compiled in local scope
+ * prefix code
*
- * @var array
+ * @var string
*/
- public $local_var = array();
+ public $prefixCompiledCode = '';
+
+ /**
+ * postfix code
+ *
+ * @var string
+ */
+ public $postfixCompiledCode = '';
/**
* Initialize compiler
@@ -63,10 +65,9 @@ class Smarty_Internal_SmartyTemplateCompiler extends Smarty_Internal_TemplateCom
* @param string $parser_class class name
* @param Smarty $smarty global instance
*/
- public function __construct($lexer_class, $parser_class, $smarty)
+ public function __construct($lexer_class, $parser_class, Smarty $smarty)
{
- $this->smarty = $smarty;
- parent::__construct();
+ parent::__construct($smarty);
// get required plugins
$this->lexer_class = $lexer_class;
$this->parser_class = $parser_class;
@@ -76,8 +77,10 @@ class Smarty_Internal_SmartyTemplateCompiler extends Smarty_Internal_TemplateCom
* method to compile a Smarty template
*
* @param mixed $_content template source
+ * @param bool $isTemplateSource
*
- * @return bool true if compiling succeeded, false if it failed
+ * @return bool true if compiling succeeded, false if it failed
+ * @throws \SmartyCompilerException
*/
protected function doCompile($_content, $isTemplateSource = false)
{
@@ -85,14 +88,11 @@ class Smarty_Internal_SmartyTemplateCompiler extends Smarty_Internal_TemplateCom
tags in the templates are replaces with PHP code,
then written to compiled files. */
// init the lexer/parser to compile the template
- $this->lex = new $this->lexer_class(str_replace(array("\r\n", "\r"), "\n", $_content), $this);
- $this->parser = new $this->parser_class($this->lex, $this);
- if ($isTemplateSource) {
- $this->parser->insertPhpCode("<?php\n\$_smarty_tpl->properties['nocache_hash'] = '{$this->nocache_hash}';\n?>\n");
- }
- if ($this->inheritance_child) {
- // start state on child templates
- $this->lex->yypushstate(Smarty_Internal_Templatelexer::CHILDBODY);
+ $this->parser =
+ new $this->parser_class(new $this->lexer_class(str_replace(array("\r\n", "\r"), "\n", $_content), $this),
+ $this);
+ if ($isTemplateSource && $this->template->caching) {
+ $this->parser->insertPhpCode("<?php\n\$_smarty_tpl->compiled->nocache_hash = '{$this->nocache_hash}';\n?>\n");
}
if (function_exists('mb_internal_encoding') && ((int) ini_get('mbstring.func_overload')) & 2) {
$mbEncoding = mb_internal_encoding();
@@ -103,21 +103,17 @@ class Smarty_Internal_SmartyTemplateCompiler extends Smarty_Internal_TemplateCom
if ($this->smarty->_parserdebug) {
$this->parser->PrintTrace();
- $this->lex->PrintTrace();
+ $this->parser->lex->PrintTrace();
}
// get tokens from lexer and parse them
- while ($this->lex->yylex() && !$this->abort_and_recompile) {
+ while ($this->parser->lex->yylex()) {
if ($this->smarty->_parserdebug) {
- echo "<pre>Line {$this->lex->line} Parsing {$this->parser->yyTokenName[$this->lex->token]} Token " .
- htmlentities($this->lex->value) . "</pre>";
+ echo "<pre>Line {$this->parser->lex->line} Parsing {$this->parser->yyTokenName[$this->parser->lex->token]} Token " .
+ htmlentities($this->parser->lex->value) . "</pre>";
}
- $this->parser->doParse($this->lex->token, $this->lex->value);
+ $this->parser->doParse($this->parser->lex->token, $this->parser->lex->value);
}
- if ($this->abort_and_recompile) {
- // exit here on abort
- return false;
- }
// finish parsing process
$this->parser->doParse(0, 0);
if ($mbEncoding) {
@@ -127,10 +123,47 @@ class Smarty_Internal_SmartyTemplateCompiler extends Smarty_Internal_TemplateCom
if (count($this->_tag_stack) > 0) {
// get stacked info
list($openTag, $_data) = array_pop($this->_tag_stack);
- $this->trigger_template_error("unclosed {$this->smarty->left_delimiter}" . $openTag . "{$this->smarty->right_delimiter} tag");
+ $this->trigger_template_error("unclosed {$this->smarty->left_delimiter}" . $openTag .
+ "{$this->smarty->right_delimiter} tag");
+ }
+ // call post compile callbacks
+ foreach ($this->postCompileCallbacks as $cb) {
+ $parameter = $cb;
+ $parameter[0] = $this;
+ call_user_func_array($cb[0], $parameter);
}
// return compiled code
- // return str_replace(array("? >\n<?php","? ><?php"), array('',''), $this->parser->retvalue);
- return $this->parser->retvalue;
+ return $this->prefixCompiledCode . $this->parser->retvalue . $this->postfixCompiledCode;
+ }
+
+ /**
+ * Register a post compile callback
+ * - when the callback is called after template compiling the compiler object will be inserted as first parameter
+ *
+ * @param callback $callback
+ * @param array $parameter optional parameter array
+ * @param string $key optional key for callback
+ * @param bool $replace if true replace existing keyed callback
+ */
+ public function registerPostCompileCallback($callback, $parameter = array(), $key = null, $replace = false)
+ {
+ array_unshift($parameter, $callback);
+ if (isset($key)) {
+ if ($replace || !isset($this->postCompileCallbacks[$key])) {
+ $this->postCompileCallbacks[$key] = $parameter;
+ }
+ } else {
+ $this->postCompileCallbacks[] = $parameter;
+ }
+ }
+
+ /**
+ * Remove a post compile callback
+ *
+ * @param string $key callback key
+ */
+ public function unregisterPostCompileCallback($key)
+ {
+ unset($this->postCompileCallbacks[$key]);
}
}
diff --git a/library/Smarty/libs/sysplugins/smarty_internal_template.php b/library/Smarty/libs/sysplugins/smarty_internal_template.php
index 4721f3086..52c7391b1 100644
--- a/library/Smarty/libs/sysplugins/smarty_internal_template.php
+++ b/library/Smarty/libs/sysplugins/smarty_internal_template.php
@@ -14,13 +14,21 @@
* @package Smarty
* @subpackage Template
*
- * @property Smarty_Template_Source $source
- * @property Smarty_Template_Compiled $compiled
- * @property Smarty_Template_Cached $cached
+ * @property Smarty_Template_Source|Smarty_Template_Config $source
+ * @property Smarty_Template_Compiled $compiled
+ * @property Smarty_Template_Cached $cached
+ * @method bool mustCompile()
*/
class Smarty_Internal_Template extends Smarty_Internal_TemplateBase
{
/**
+ * This object type (Smarty = 1, template = 2, data = 4)
+ *
+ * @var int
+ */
+ public $_objType = 2;
+
+ /**
* Global smarty instance
*
* @var Smarty
@@ -28,89 +36,65 @@ class Smarty_Internal_Template extends Smarty_Internal_TemplateBase
public $smarty = null;
/**
- * Template resource
+ * Source instance
*
- * @var string
+ * @var Smarty_Template_Source|Smarty_Template_Config
*/
- public $template_resource = null;
+ public $source = null;
+
/**
- * Saved template Id
+ * Template resource
*
- * @var null|string
+ * @var string
*/
- public $templateId = null;
+ public $template_resource = null;
+
/**
* flag if compiled template is invalid and must be (re)compiled
*
* @var bool
*/
public $mustCompile = null;
+
/**
- * flag if template does contain nocache code sections
- *
- * @var bool
- */
- public $has_nocache_code = false;
- /**
- * special compiled and cached template properties
- *
- * @var array
- */
- public $properties = array('file_dependency' => array(),
- 'nocache_hash' => '',
- 'tpl_function' => array(),
- );
- /**
- * required plugins
- *
- * @var array
- */
- public $required_plugins = array('compiled' => array(), 'nocache' => array());
- /**
- * blocks for template inheritance
- *
- * @var array
- */
- public $block_data = array();
- /**
- * variable filters
+ * Template Id
*
- * @var array
+ * @var null|string
*/
- public $variable_filters = array();
+ public $templateId = null;
+
/**
- * optional log of tag/attributes
+ * Known template functions
*
* @var array
*/
- public $used_tags = array();
- /**
- * internal flag to allow relative path in child template blocks
- *
- * @var bool
- */
- public $allow_relative_path = false;
+ public $tpl_function = array();
+
/**
- * internal capture runtime stack
+ * Scope in which template is rendered
*
- * @var array
+ * @var int
*/
- public $_capture_stack = array(0 => array());
+ public $scope = 0;
/**
* Create template data object
* Some of the global Smarty settings copied to template scope
* It load the required template resources and caching plugins
*
- * @param string $template_resource template resource string
- * @param Smarty $smarty Smarty instance
- * @param Smarty_Internal_Template $_parent back pointer to parent object with variables or null
- * @param mixed $_cache_id cache id or null
- * @param mixed $_compile_id compile id or null
- * @param bool $_caching use caching?
- * @param int $_cache_lifetime cache life-time in seconds
+ * @param string $template_resource template resource string
+ * @param Smarty $smarty Smarty instance
+ * @param \Smarty_Internal_Template|\Smarty|\Smarty_Internal_Data $_parent back pointer to parent object
+ * with variables or null
+ * @param mixed $_cache_id cache id or null
+ * @param mixed $_compile_id compile id or null
+ * @param bool $_caching use caching?
+ * @param int $_cache_lifetime cache life-time in seconds
+ *
+ * @throws \SmartyException
*/
- public function __construct($template_resource, $smarty, $_parent = null, $_cache_id = null, $_compile_id = null, $_caching = null, $_cache_lifetime = null)
+ public function __construct($template_resource, Smarty $smarty, Smarty_Internal_Data $_parent = null,
+ $_cache_id = null, $_compile_id = null, $_caching = null, $_cache_lifetime = null)
{
$this->smarty = &$smarty;
// Smarty parameter
@@ -124,30 +108,8 @@ class Smarty_Internal_Template extends Smarty_Internal_TemplateBase
$this->parent = $_parent;
// Template resource
$this->template_resource = $template_resource;
- // copy block data of template inheritance
- if ($this->parent instanceof Smarty_Internal_Template) {
- $this->block_data = $this->parent->block_data;
- }
- }
-
- /**
- * fetches rendered template
- *
- * @throws Exception
- * @throws SmartyException
- * @return string rendered template output
- */
- public function fetch()
- {
- return $this->render(true, false, false);
- }
-
- /**
- * displays a Smarty template
- */
- public function display()
- {
- $this->render(true, false, true);
+ $this->source = Smarty_Template_Source::load($this);
+ parent::__construct();
}
/**
@@ -161,53 +123,11 @@ class Smarty_Internal_Template extends Smarty_Internal_TemplateBase
* @throws SmartyException
* @return string rendered template output
*/
- public function render($merge_tpl_vars = false, $no_output_filter = true, $display = null)
+ public function render($no_output_filter = true, $display = null)
{
- $parentIsTpl = $this->parent instanceof Smarty_Internal_Template;
+ $parentIsTpl = isset($this->parent) && $this->parent->_objType == 2;
if ($this->smarty->debugging) {
- Smarty_Internal_Debug::start_template($this, $display);
- }
- $save_tpl_vars = null;
- $save_config_vars = null;
- // merge all variable scopes into template
- if ($merge_tpl_vars) {
- // save local variables
- $save_tpl_vars = $this->tpl_vars;
- $save_config_vars = $this->config_vars;
- $ptr_array = array($this);
- $ptr = $this;
- 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);
- }
- $this->tpl_vars = $tpl_vars;
- $this->config_vars = $config_vars;
- }
- // dummy local smarty variable
- if (!isset($this->tpl_vars['smarty'])) {
- $this->tpl_vars['smarty'] = new Smarty_Variable;
- }
- $_smarty_old_error_level = isset($this->smarty->error_reporting) ? error_reporting($this->smarty->error_reporting) : null;
- // check URL debugging control
- if (!$this->smarty->debugging && $this->smarty->debugging_ctrl == 'URL') {
- Smarty_Internal_Debug::debugUrl($this);
- }
- if (!isset($this->source)) {
- $this->loadSource();
+ $this->smarty->_debug->start_template($this, $display);
}
// checks if template exists
if (!$this->source->exists) {
@@ -218,199 +138,81 @@ class Smarty_Internal_Template extends Smarty_Internal_TemplateBase
}
throw new SmartyException("Unable to load template {$this->source->type} '{$this->source->name}'{$parent_resource}");
}
+ // check URL debugging control
+ if (!$this->smarty->debugging && $this->smarty->debugging_ctrl == 'URL') {
+ $this->smarty->_debug->debugUrl($this);
+ }
// disable caching for evaluated code
- if ($this->source->recompiled) {
+ if ($this->source->handler->recompiled) {
$this->caching = false;
}
// read from cache or render
- $isCacheTpl = $this->caching == Smarty::CACHING_LIFETIME_CURRENT || $this->caching == Smarty::CACHING_LIFETIME_SAVED;
+ $isCacheTpl =
+ $this->caching == Smarty::CACHING_LIFETIME_CURRENT || $this->caching == Smarty::CACHING_LIFETIME_SAVED;
if ($isCacheTpl) {
if (!isset($this->cached)) {
$this->loadCached();
}
- $this->cached->isCached($this);
- }
- if (!($isCacheTpl) || !$this->cached->valid) {
- if ($isCacheTpl) {
- $this->properties['tpl_function'] = array();
- }
- // render template (not loaded and not in cache)
- if ($this->smarty->debugging) {
- Smarty_Internal_Debug::start_render($this);
- }
- if (!$this->source->uncompiled) {
- // render compiled code
- if (!isset($this->compiled)) {
- $this->loadCompiled();
- }
- $content = $this->compiled->render($this);
- } else {
- $content = $this->source->renderUncompiled($this);
- }
- if (!$this->source->recompiled && empty($this->properties['file_dependency'][$this->source->uid])) {
- $this->properties['file_dependency'][$this->source->uid] = array($this->source->filepath, $this->source->timestamp, $this->source->type);
- }
- if ($parentIsTpl) {
- $this->parent->properties['file_dependency'] = array_merge($this->parent->properties['file_dependency'], $this->properties['file_dependency']);
- //$this->parent->properties['tpl_function'] = array_merge($this->parent->properties['tpl_function'], $this->properties['tpl_function']);
- }
- if ($this->smarty->debugging) {
- Smarty_Internal_Debug::end_render($this);
- }
- // write to cache when necessary
- if (!$this->source->recompiled && $isCacheTpl) {
- if ($this->smarty->debugging) {
- Smarty_Internal_Debug::start_cache($this);
- }
- $this->cached->updateCache($this, $content, $no_output_filter);
- $compile_check = $this->smarty->compile_check;
- $this->smarty->compile_check = false;
- if ($parentIsTpl) {
- $this->properties['tpl_function'] = $this->parent->properties['tpl_function'];
- }
- if (!$this->cached->processed) {
- $this->cached->process($this);
- }
- $this->smarty->compile_check = $compile_check;
- $content = $this->getRenderedTemplateCode();
- if ($this->smarty->debugging) {
- Smarty_Internal_Debug::end_cache($this);
- }
- } else {
- if (!empty($this->properties['nocache_hash']) && !empty($this->parent->properties['nocache_hash'])) {
- // replace nocache_hash
- $content = str_replace("{$this->properties['nocache_hash']}", $this->parent->properties['nocache_hash'], $content);
- $this->parent->has_nocache_code = $this->parent->has_nocache_code || $this->has_nocache_code;
- }
- }
+ $this->cached->render($this, $no_output_filter);
+ } elseif ($this->source->handler->uncompiled) {
+ $this->source->render($this);
} else {
- if ($this->smarty->debugging) {
- Smarty_Internal_Debug::start_cache($this);
- }
- $content = $this->cached->render($this);
- if ($this->smarty->debugging) {
- Smarty_Internal_Debug::end_cache($this);
+ if (!isset($this->compiled)) {
+ $this->loadCompiled();
}
+ $this->compiled->render($this);
}
- if ((!$this->caching || $this->has_nocache_code || $this->source->recompiled) && !$no_output_filter && (isset($this->smarty->autoload_filters['output']) || isset($this->smarty->registered_filters['output']))) {
- $content = Smarty_Internal_Filter_Handler::runFilter('output', $content, $this);
- }
- if (isset($_smarty_old_error_level)) {
- error_reporting($_smarty_old_error_level);
- }
+
// display or fetch
if ($display) {
if ($this->caching && $this->smarty->cache_modified_check) {
- $this->cached->cacheModifiedCheck($this, $content);
+ $this->smarty->ext->_cachemodify->cacheModifiedCheck($this->cached, $this,
+ isset($content) ? $content : ob_get_clean());
} else {
- echo $content;
- }
- if ($this->smarty->debugging) {
- Smarty_Internal_Debug::end_template($this);
+ if ((!$this->caching || $this->cached->has_nocache_code || $this->source->handler->recompiled) &&
+ !$no_output_filter && (isset($this->smarty->autoload_filters['output']) ||
+ isset($this->smarty->registered_filters['output']))
+ ) {
+ echo $this->smarty->ext->_filterHandler->runFilter('output', ob_get_clean(), $this);
+ } else {
+ ob_end_flush();
+ flush();
+ }
}
- // debug output
if ($this->smarty->debugging) {
- Smarty_Internal_Debug::display_debug($this, true);
- }
- if ($merge_tpl_vars) {
- // restore local variables
- $this->tpl_vars = $save_tpl_vars;
- $this->config_vars = $save_config_vars;
+ $this->smarty->_debug->end_template($this);
+ // debug output
+ $this->smarty->_debug->display_debug($this, true);
}
return '';
} else {
- if ($merge_tpl_vars) {
- // restore local variables
- $this->tpl_vars = $save_tpl_vars;
- $this->config_vars = $save_config_vars;
- }
if ($this->smarty->debugging) {
- Smarty_Internal_Debug::end_template($this);
- }
- if ($this->smarty->debugging == 2 and $display === false) {
- if ($this->smarty->debugging) {
- Smarty_Internal_Debug::display_debug($this, true);
+ $this->smarty->_debug->end_template($this);
+ if ($this->smarty->debugging == 2 and !$display) {
+ $this->smarty->_debug->display_debug($this, true);
}
}
if ($parentIsTpl) {
- $this->parent->properties['tpl_function'] = array_merge($this->parent->properties['tpl_function'], $this->properties['tpl_function']);
- foreach ($this->required_plugins as $code => $tmp1) {
+ if (!empty($this->tpl_function)) {
+ $this->parent->tpl_function = array_merge($this->parent->tpl_function, $this->tpl_function);
+ }
+ foreach ($this->compiled->required_plugins as $code => $tmp1) {
foreach ($tmp1 as $name => $tmp) {
foreach ($tmp as $type => $data) {
- $this->parent->required_plugins[$code][$name][$type] = $data;
+ $this->parent->compiled->required_plugins[$code][$name][$type] = $data;
}
}
}
}
- // return cache content
- return $content;
- }
- }
-
- /**
- * get rendered template content by calling compiled or cached template code
- *
- * @return string
- * @throws Exception
- */
- public function getRenderedTemplateCode()
- {
- $level = ob_get_level();
- try {
- ob_start();
- if (empty($this->properties['unifunc']) || !is_callable($this->properties['unifunc'])) {
- throw new SmartyException("Invalid compiled template for '{$this->template_resource}'");
- }
- if (isset($this->smarty->security_policy)) {
- $this->smarty->security_policy->startTemplate($this);
- }
- array_unshift($this->_capture_stack, array());
- //
- // render compiled or saved template code
- //
- $this->properties['unifunc']($this);
- // any unclosed {capture} tags ?
- if (isset($this->_capture_stack[0][0])) {
- $this->capture_error();
- }
- array_shift($this->_capture_stack);
- if (isset($this->smarty->security_policy)) {
- $this->smarty->security_policy->exitTemplate($this);
- }
- return ob_get_clean();
- }
- catch (Exception $e) {
- while (ob_get_level() > $level) {
- ob_end_clean();
- }
- throw $e;
- }
- }
-
- /**
- * Returns if the current template must be compiled by the Smarty compiler
- * It does compare the timestamps of template source and the compiled templates and checks the force compile
- * configuration
- *
- * @throws SmartyException
- * @return boolean true if the template must be compiled
- */
- public function mustCompile()
- {
- if (!$this->source->exists) {
- if ($this->parent instanceof Smarty_Internal_Template) {
- $parent_resource = " in '$this->parent->template_resource}'";
- } else {
- $parent_resource = '';
+ if (!$no_output_filter &&
+ (!$this->caching || $this->cached->has_nocache_code || $this->source->handler->recompiled) &&
+ (isset($this->smarty->autoload_filters['output']) || isset($this->smarty->registered_filters['output']))
+ ) {
+ return $this->smarty->ext->_filterHandler->runFilter('output', ob_get_clean(), $this);
}
- throw new SmartyException("Unable to load template {$this->source->type} '{$this->source->name}'{$parent_resource}");
- }
- if ($this->mustCompile === null) {
- $this->mustCompile = (!$this->source->uncompiled && ($this->smarty->force_compile || $this->source->recompiled || $this->compiled->timestamp === false ||
- ($this->smarty->compile_check && $this->compiled->timestamp < $this->source->timestamp)));
+ // return cache content
+ return null;
}
-
- return $this->mustCompile;
}
/**
@@ -431,328 +233,18 @@ class Smarty_Internal_Template extends Smarty_Internal_TemplateBase
*/
public function writeCachedContent($content)
{
- return $this->cached->writeCachedContent($this, $content);
- }
-
- /**
- * Template code runtime function to get subtemplate content
- *
- * @param string $template the resource handle of the template file
- * @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 integer $caching cache mode
- * @param integer $cache_lifetime life time of cache data
- * @param $data
- * @param int $parent_scope scope in which {include} should execute
- *
- * @returns string template content
- */
- public function getSubTemplate($template, $cache_id, $compile_id, $caching, $cache_lifetime, $data, $parent_scope)
- {
- $tpl = $this->setupSubTemplate($template, $cache_id, $compile_id, $caching, $cache_lifetime, $data, $parent_scope);
- return $tpl->render();
- }
-
- /**
- * Template code runtime function to set up an inline subtemplate
- *
- * @param string $template the resource handle of the template file
- * @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 integer $caching cache mode
- * @param integer $cache_lifetime life time of cache data
- * @param array $data passed parameter template variables
- * @param int $parent_scope scope in which {include} should execute
- *
- * @returns object template object
- */
- public function setupSubTemplate($template, $cache_id, $compile_id, $caching, $cache_lifetime, $data, $parent_scope)
- {
- $_templateId = $this->getTemplateId($template, $cache_id, $compile_id);
- // already in template cache?
- if (isset($this->smarty->template_objects[$_templateId])) {
- // clone cached template object because of possible recursive call
- $tpl = clone $this->smarty->template_objects[$_templateId];
- $tpl->parent = $this;
- if ((bool) $tpl->caching !== (bool) $caching) {
- unset($tpl->compiled);
- }
- $tpl->caching = $caching;
- $tpl->cache_lifetime = $cache_lifetime;
- } else {
- $tpl = new $this->smarty->template_class($template, $this->smarty, $this, $cache_id, $compile_id, $caching, $cache_lifetime);
- $tpl->templateId = $_templateId;
- }
- // get variables from calling scope
- if ($parent_scope == Smarty::SCOPE_LOCAL) {
- $tpl->tpl_vars = $this->tpl_vars;
- $tpl->tpl_vars['smarty'] = clone $this->tpl_vars['smarty'];
- } elseif ($parent_scope == Smarty::SCOPE_PARENT) {
- $tpl->tpl_vars = &$this->tpl_vars;
- } elseif ($parent_scope == Smarty::SCOPE_GLOBAL) {
- $tpl->tpl_vars = &Smarty::$global_tpl_vars;
- } elseif (($scope_ptr = $this->getScopePointer($parent_scope)) == null) {
- $tpl->tpl_vars = &$this->tpl_vars;
- } else {
- $tpl->tpl_vars = &$scope_ptr->tpl_vars;
- }
- $tpl->config_vars = $this->config_vars;
- if (!empty($data)) {
- // set up variable values
- foreach ($data as $_key => $_val) {
- $tpl->tpl_vars[$_key] = new Smarty_Variable($_val);
- }
- }
- $tpl->properties['tpl_function'] = $this->properties['tpl_function'];
- return $tpl;
- }
-
- /**
- * Template code runtime function to set up an inline subtemplate
- *
- * @param string $template the resource handle of the template file
- * @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 integer $caching cache mode
- * @param integer $cache_lifetime life time of cache data
- * @param array $data passed parameter template variables
- * @param int $parent_scope scope in which {include} should execute
- * @param string $hash nocache hash code
- * @param string $content_func name of content function
- *
- * @returns object template content
- */
- public function getInlineSubTemplate($template, $cache_id, $compile_id, $caching, $cache_lifetime, $data, $parent_scope, $hash, $content_func)
- {
- $tpl = $this->setupSubTemplate($template, $cache_id, $compile_id, $caching, $cache_lifetime, $data, $parent_scope);
- $tpl->properties['nocache_hash'] = $hash;
- if (!isset($this->smarty->template_objects[$tpl->templateId])) {
- $this->smarty->template_objects[$tpl->templateId] = $tpl;
- }
- if ($this->smarty->debugging) {
- Smarty_Internal_Debug::start_template($tpl);
- Smarty_Internal_Debug::start_render($tpl);
- }
- $tpl->properties['unifunc'] = $content_func;
- $output = $tpl->getRenderedTemplateCode();
- if ($this->smarty->debugging) {
- Smarty_Internal_Debug::end_template($tpl);
- Smarty_Internal_Debug::end_render($tpl);
- }
- if (!empty($tpl->properties['file_dependency'])) {
- $this->properties['file_dependency'] = array_merge($this->properties['file_dependency'], $tpl->properties['file_dependency']);
- }
- $this->properties['tpl_function'] = $tpl->properties['tpl_function'];
- return str_replace($tpl->properties['nocache_hash'], $this->properties['nocache_hash'], $output);
- }
-
- /**
- * Call template function
- *
- * @param string $name template function name
- * @param object|\Smarty_Internal_Template $_smarty_tpl template object
- * @param array $params parameter array
- * @param bool $nocache true if called nocache
- *
- * @throws \SmartyException
- */
- public function callTemplateFunction($name, Smarty_Internal_Template $_smarty_tpl, $params, $nocache)
- {
- if (isset($_smarty_tpl->properties['tpl_function'][$name])) {
- if (!$_smarty_tpl->caching || ($_smarty_tpl->caching && $nocache)) {
- $function = $_smarty_tpl->properties['tpl_function'][$name]['call_name'];
- } else {
- if (isset($_smarty_tpl->properties['tpl_function'][$name]['call_name_caching'])) {
- $function = $_smarty_tpl->properties['tpl_function'][$name]['call_name_caching'];
- } else {
- $function = $_smarty_tpl->properties['tpl_function'][$name]['call_name'];
- }
- }
- if (function_exists($function)) {
- $function ($_smarty_tpl, $params);
- return;
- }
- // try to load template function dynamically
- if (Smarty_Internal_Function_Call_Handler::call($name, $_smarty_tpl, $function, $params, $nocache)) {
- $function ($_smarty_tpl, $params);
- return;
- }
- }
- throw new SmartyException("Unable to find template function '{$name}'");
- }
-
- /**
- * This function is executed automatically when a compiled or cached template file is included
- * - Decode saved properties from compiled template and cache files
- * - Check if compiled or cache file is valid
- *
- * @param array $properties special template properties
- * @param bool $cache flag if called from cache file
- *
- * @return bool flag if compiled or cache file is valid
- */
- public function decodeProperties($properties, $cache = false)
- {
- $properties['version'] = (isset($properties['version'])) ? $properties['version'] : '';
- $is_valid = true;
- if (Smarty::SMARTY_VERSION != $properties['version']) {
- // new version must rebuild
- $is_valid = false;
- } elseif ((!$cache && $this->smarty->compile_check || $cache && ($this->smarty->compile_check === true || $this->smarty->compile_check === Smarty::COMPILECHECK_ON)) && !empty($properties['file_dependency'])) {
- // check file dependencies at compiled code
- foreach ($properties['file_dependency'] as $_file_to_check) {
- if ($_file_to_check[2] == 'file' || $_file_to_check[2] == 'php') {
- if ($this->source->filepath == $_file_to_check[0] && isset($this->source->timestamp)) {
- // do not recheck current template
- $mtime = $this->source->timestamp;
- } else {
- // file and php types can be checked without loading the respective resource handlers
- $mtime = is_file($_file_to_check[0]) ? @filemtime($_file_to_check[0]) : false;
- }
- } elseif ($_file_to_check[2] == 'string') {
- continue;
- } else {
- $source = Smarty_Resource::source(null, $this->smarty, $_file_to_check[0]);
- $mtime = $source->timestamp;
- }
- if (!$mtime || $mtime > $_file_to_check[1]) {
- $is_valid = false;
- break;
- }
- }
- }
- if ($cache) {
- // CACHING_LIFETIME_SAVED cache expiry has to be validated here since otherwise we'd define the unifunc
- if ($this->caching === Smarty::CACHING_LIFETIME_SAVED &&
- $properties['cache_lifetime'] >= 0 &&
- (time() > ($this->cached->timestamp + $properties['cache_lifetime']))
- ) {
- $is_valid = false;
- }
- $this->cached->valid = $is_valid;
- } else {
- $this->mustCompile = !$is_valid;
- }
- if ($is_valid) {
- $this->has_nocache_code = $properties['has_nocache_code'];
- // $this->properties['nocache_hash'] = $properties['nocache_hash'];
- if (isset($properties['cache_lifetime'])) {
- $this->properties['cache_lifetime'] = $properties['cache_lifetime'];
- }
- if (isset($properties['file_dependency'])) {
- $this->properties['file_dependency'] = array_merge($this->properties['file_dependency'], $properties['file_dependency']);
- }
- if (isset($properties['tpl_function'])) {
- $this->properties['tpl_function'] = array_merge($this->properties['tpl_function'], $properties['tpl_function']);
- }
- $this->properties['version'] = $properties['version'];
- $this->properties['unifunc'] = $properties['unifunc'];
- }
- return $is_valid;
- }
-
- /**
- * Template code runtime function to create a local Smarty variable for array assignments
- *
- * @param string $tpl_var template variable name
- * @param bool $nocache cache mode of variable
- * @param int $scope scope of variable
- */
- public function createLocalArrayVariable($tpl_var, $nocache = false, $scope = Smarty::SCOPE_LOCAL)
- {
- if (!isset($this->tpl_vars[$tpl_var])) {
- $this->tpl_vars[$tpl_var] = new Smarty_Variable(array(), $nocache, $scope);
- } else {
- $this->tpl_vars[$tpl_var] = clone $this->tpl_vars[$tpl_var];
- if ($scope != Smarty::SCOPE_LOCAL) {
- $this->tpl_vars[$tpl_var]->scope = $scope;
- }
- if (!(is_array($this->tpl_vars[$tpl_var]->value) || $this->tpl_vars[$tpl_var]->value instanceof ArrayAccess)) {
- settype($this->tpl_vars[$tpl_var]->value, 'array');
- }
- }
- }
-
- /**
- * Template code runtime function to get pointer to template variable array of requested scope
- *
- * @param int $scope requested variable scope
- *
- * @return array array of template variables
- */
- public function &getScope($scope)
- {
- if ($scope == Smarty::SCOPE_PARENT && !empty($this->parent)) {
- return $this->parent->tpl_vars;
- } elseif ($scope == Smarty::SCOPE_ROOT && !empty($this->parent)) {
- $ptr = $this->parent;
- while (!empty($ptr->parent)) {
- $ptr = $ptr->parent;
- }
-
- return $ptr->tpl_vars;
- } elseif ($scope == Smarty::SCOPE_GLOBAL) {
- return Smarty::$global_tpl_vars;
- }
- $null = null;
-
- return $null;
+ return $this->smarty->ext->_updateCache->writeCachedContent($this->cached, $this, $content);
}
/**
- * Get parent or root of template parent chain
+ * Get unique template id
*
- * @param int $scope parent or root scope
- *
- * @return mixed object
- */
- public function getScopePointer($scope)
- {
- if ($scope == Smarty::SCOPE_PARENT && !empty($this->parent)) {
- return $this->parent;
- } elseif ($scope == Smarty::SCOPE_ROOT && !empty($this->parent)) {
- $ptr = $this->parent;
- while (!empty($ptr->parent)) {
- $ptr = $ptr->parent;
- }
-
- return $ptr;
- }
-
- return null;
- }
-
- /**
- * [util function] counts an array, arrayAccess/traversable or PDOStatement object
- *
- * @param mixed $value
- *
- * @return int the count for arrays and objects that implement countable, 1 for other objects that don't, and 0
- * for empty elements
+ * @return string
*/
- public function _count($value)
+ public function _getTemplateId()
{
- if (is_array($value) === true || $value instanceof Countable) {
- return count($value);
- } elseif ($value instanceof IteratorAggregate) {
- // Note: getIterator() returns a Traversable, not an Iterator
- // thus rewind() and valid() methods may not be present
- return iterator_count($value->getIterator());
- } elseif ($value instanceof Iterator) {
- return iterator_count($value);
- } elseif ($value instanceof PDOStatement) {
- return $value->rowCount();
- } elseif ($value instanceof Traversable) {
- return iterator_count($value);
- } elseif ($value instanceof ArrayAccess) {
- if ($value->offsetExists(0)) {
- return 1;
- }
- } elseif (is_object($value)) {
- return count($value);
- }
-
- return 0;
+ return isset($this->templateId) ? $this->templateId : $this->templateId =
+ $this->smarty->_getTemplateId($this->template_resource, $this->cache_id, $this->compile_id);
}
/**
@@ -764,42 +256,12 @@ class Smarty_Internal_Template extends Smarty_Internal_TemplateBase
}
/**
- * Empty cache for this template
- *
- * @param integer $exp_time expiration time
- *
- * @return integer number of cache files deleted
- */
- public function clearCache($exp_time = null)
- {
- Smarty_CacheResource::invalidLoadedCache($this->smarty);
-
- return $this->cached->handler->clear($this->smarty, $this->template_resource, $this->cache_id, $this->compile_id, $exp_time);
- }
-
- /**
- * Load source resource
- *
- * @throws SmartyException
- */
- public function loadSource()
- {
- $this->source = Smarty_Template_Source::load($this);
- if ($this->smarty->template_resource_caching && !$this->source->recompiled && isset($this->templateId)) {
- $this->smarty->template_objects[$this->templateId] = $this;
- }
- }
-
- /**
* Load compiled object
*
*/
public function loadCompiled()
{
if (!isset($this->compiled)) {
- if (!class_exists('Smarty_Template_Compiled', false)) {
- require SMARTY_SYSPLUGINS_DIR . 'smarty_template_compiled.php';
- }
$this->compiled = Smarty_Template_Compiled::load($this);
}
}
@@ -811,9 +273,6 @@ class Smarty_Internal_Template extends Smarty_Internal_TemplateBase
public function loadCached()
{
if (!isset($this->cached)) {
- if (!class_exists('Smarty_Template_Cached', false)) {
- require SMARTY_SYSPLUGINS_DIR . 'smarty_template_cached.php';
- }
$this->cached = Smarty_Template_Cached::load($this);
}
}
@@ -825,8 +284,12 @@ class Smarty_Internal_Template extends Smarty_Internal_TemplateBase
*/
public function loadCompiler()
{
- $this->smarty->loadPlugin($this->source->compiler_class);
- $this->compiler = new $this->source->compiler_class($this->source->template_lexer_class, $this->source->template_parser_class, $this->smarty);
+ if (!class_exists($this->source->handler->compiler_class)) {
+ $this->smarty->loadPlugin($this->source->handler->compiler_class);
+ }
+ $this->compiler = new $this->source->handler->compiler_class($this->source->handler->template_lexer_class,
+ $this->source->handler->template_parser_class,
+ $this->smarty);
}
/**
@@ -859,7 +322,6 @@ class Smarty_Internal_Template extends Smarty_Internal_TemplateBase
public function __set($property_name, $value)
{
switch ($property_name) {
- case 'source':
case 'compiled':
case 'cached':
case 'compiler':
@@ -886,10 +348,6 @@ class Smarty_Internal_Template extends Smarty_Internal_TemplateBase
public function __get($property_name)
{
switch ($property_name) {
- case 'source':
- $this->loadSource();
- return $this->source;
-
case 'compiled':
$this->loadCompiled();
return $this->compiled;
diff --git a/library/Smarty/libs/sysplugins/smarty_internal_templatebase.php b/library/Smarty/libs/sysplugins/smarty_internal_templatebase.php
index 68fd4be2e..9b4953dee 100644
--- a/library/Smarty/libs/sysplugins/smarty_internal_templatebase.php
+++ b/library/Smarty/libs/sysplugins/smarty_internal_templatebase.php
@@ -11,8 +11,32 @@
/**
* Class with shared template methods
*
- * @package Smarty
- * @subpackage Template
+ * @package Smarty
+ * @subpackage Template
+ *
+ * @property Smarty $smarty
+ * @method Smarty_Internal_TemplateBase setAutoloadFilters(mixed $filters, string $type = null)
+ * @method Smarty_Internal_TemplateBase addAutoloadFilters(mixed $filters, string $type = null)
+ * @method array getAutoloadFilters(string $type = null)
+ * @local_method Smarty_Internal_TemplateBase registerFilter(string $type, callback $callback, string $name = null)
+ * @method Smarty_Internal_TemplateBase unregisterFilter(string $type, mixed $callback)
+ * @method Smarty_Internal_TemplateBase unloadFilter(string $type, string $name)
+ * @method string getDebugTemplate()
+ * @method Smarty_Internal_TemplateBase setDebugTemplate(string $tpl_name)
+ * @method Smarty_Internal_TemplateBase setDefaultModifier(mixed $modifiers)
+ * @method Smarty_Internal_TemplateBase addDefaultModifier(mixed $modifiers)
+ * @method array getDefaultModifier()
+ * @method Smarty_Internal_TemplateBase registerDefaultPluginHandler(callback $callback)
+ * @method Smarty_Internal_TemplateBase registerResource(string $name, Smarty_Resource $resource_handler)
+ * @method Smarty_Internal_TemplateBase unregisterResource(string $name)
+ * @method Smarty_Internal_TemplateBase registerCacheResource(string $name, Smarty_CacheResource $resource_handler)
+ * @method Smarty_Internal_TemplateBase unregisterCacheResource(string $name)
+ * @method Smarty_Internal_TemplateBase unregisterPlugin(string $type, string $name)
+ * @method Smarty_Internal_TemplateBase unregisterObject(string $object_name)
+ * @method object getRegisteredObject(string $object_name)
+ * @method Smarty_Internal_TemplateBase registerClass(string $class_name, string $class_impl)
+ * @method Smarty_Internal_TemplateBase createData(Smarty_Internal_Data $parent = null, string $name = null)
+ * @method array getTags(mixed $template = null)
*/
abstract class Smarty_Internal_TemplateBase extends Smarty_Internal_Data
{
@@ -23,6 +47,7 @@ abstract class Smarty_Internal_TemplateBase extends Smarty_Internal_Data
* @var string
*/
public $cache_id = null;
+
/**
* Set this if you want different sets of compiled files for the same
* templates.
@@ -30,12 +55,14 @@ abstract class Smarty_Internal_TemplateBase extends Smarty_Internal_Data
* @var string
*/
public $compile_id = null;
+
/**
* caching enabled
*
* @var boolean
*/
public $caching = false;
+
/**
* cache lifetime in seconds
*
@@ -44,514 +71,246 @@ abstract class Smarty_Internal_TemplateBase extends Smarty_Internal_Data
public $cache_lifetime = 3600;
/**
- * 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
+ * universal cache
*
- * @return boolean cache status
+ * @var array()
*/
- public function isCached($template = null, $cache_id = null, $compile_id = null, $parent = null)
- {
- if ($template === null && $this instanceof $this->template_class) {
- $template = $this;
- } else {
- if (!($template instanceof $this->template_class)) {
- if ($parent === null) {
- $parent = $this;
- }
- $smarty = isset($this->smarty) ? $this->smarty : $this;
- $template = $smarty->createTemplate($template, $cache_id, $compile_id, $parent, false);
- }
- }
- // return cache status of template
- if (!isset($template->cached)) {
- $template->loadCached();
- }
- return $template->cached->isCached($template);
- }
-
- /**
- * creates a data object
- *
- * @param object $parent next higher level of Smarty variables
- * @param string $name optional data block name
- *
- * @returns Smarty_Data data object
- */
- public function createData($parent = null, $name = null)
- {
- $dataObj = new Smarty_Data($parent, $this, $name);
- if ($this->debugging) {
- Smarty_Internal_Debug::register_data($dataObj);
- }
- return $dataObj;
- }
-
- /**
- * Get unique template id
- *
- * @param string $template_name
- * @param null|mixed $cache_id
- * @param null|mixed $compile_id
- *
- * @return string
- */
- public function getTemplateId($template_name, $cache_id = null, $compile_id = null)
- {
- $cache_id = isset($cache_id) ? $cache_id : $this->cache_id;
- $compile_id = isset($compile_id) ? $compile_id : $this->compile_id;
- $smarty = isset($this->smarty) ? $this->smarty : $this;
- if ($smarty->allow_ambiguous_resources) {
- $_templateId = Smarty_Resource::getUniqueTemplateName($this, $template_name) . "#{$cache_id}#{$compile_id}";
- } else {
- $_templateId = $smarty->joined_template_dir . "#{$template_name}#{$cache_id}#{$compile_id}";
- }
- if (isset($_templateId[150])) {
- $_templateId = sha1($_templateId);
- }
- return $_templateId;
- }
-
- /**
- * 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)
- {
- $smarty = isset($this->smarty) ? $this->smarty : $this;
- if (isset($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 {
- $smarty->registered_plugins[$type][$tag] = array($callback, (bool) $cacheable, (array) $cache_attr);
- }
-
- return $this;
- }
+ public $_cache = array();
/**
- * Unregister Plugin
+ * fetches a rendered Smarty template
*
- * @param string $type of plugin
- * @param string $tag name of plugin
+ * @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
*
- * @return Smarty_Internal_Templatebase current Smarty_Internal_Templatebase (or Smarty or
- * Smarty_Internal_Template) instance for chaining
+ * @throws Exception
+ * @throws SmartyException
+ * @return string rendered template output
*/
- public function unregisterPlugin($type, $tag)
+ public function fetch($template = null, $cache_id = null, $compile_id = null, $parent = null)
{
- $smarty = isset($this->smarty) ? $this->smarty : $this;
- if (isset($smarty->registered_plugins[$type][$tag])) {
- unset($smarty->registered_plugins[$type][$tag]);
- }
-
- return $this;
+ $result = $this->_execute($template, $cache_id, $compile_id, $parent, 0);
+ return $result === null ? ob_get_clean() : $result;
}
/**
- * 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)
+ * displays a Smarty template
*
- * @return Smarty_Internal_Templatebase current Smarty_Internal_Templatebase (or Smarty or
- * Smarty_Internal_Template) instance for chaining
+ * @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 registerResource($type, $callback)
+ public function display($template = null, $cache_id = null, $compile_id = null, $parent = null)
{
- $smarty = isset($this->smarty) ? $this->smarty : $this;
- $smarty->registered_resources[$type] = $callback instanceof Smarty_Resource ? $callback : array($callback, false);
-
- return $this;
+ // display template
+ $this->_execute($template, $cache_id, $compile_id, $parent, 1);
}
/**
- * Unregisters a resource
+ * test if cache is valid
*
- * @param string $type name of resource type
+ * @api Smarty::isCached()
+ * @link http://www.smarty.net/docs/en/api.is.cached.tpl
*
- * @return Smarty_Internal_Templatebase current Smarty_Internal_Templatebase (or Smarty or
- * Smarty_Internal_Template) instance for chaining
- */
- public function unregisterResource($type)
- {
- $smarty = isset($this->smarty) ? $this->smarty : $this;
- if (isset($smarty->registered_resources[$type])) {
- unset($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
+ * @param null|string|\Smarty_Internal_Template $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 Smarty_Internal_Templatebase current Smarty_Internal_Templatebase (or Smarty or
- * Smarty_Internal_Template) instance for chaining
+ * @return boolean cache status
*/
- public function registerCacheResource($type, Smarty_CacheResource $callback)
+ public function isCached($template = null, $cache_id = null, $compile_id = null, $parent = null)
{
- $smarty = isset($this->smarty) ? $this->smarty : $this;
- $smarty->registered_cache_resources[$type] = $callback;
-
- return $this;
+ return $this->_execute($template, $cache_id, $compile_id, $parent, 2);
}
/**
- * Unregisters a cache resource
+ * fetches a rendered Smarty template
*
- * @param string $type name of cache resource type
+ * @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
+ * @param string $function function type 0 = fetch, 1 = display, 2 = isCache
*
- * @return Smarty_Internal_Templatebase current Smarty_Internal_Templatebase (or Smarty or
- * Smarty_Internal_Template) instance for chaining
+ * @return mixed
+ * @throws \Exception
+ * @throws \SmartyException
*/
- public function unregisterCacheResource($type)
+ private function _execute($template, $cache_id, $compile_id, $parent, $function)
{
- $smarty = isset($this->smarty) ? $this->smarty : $this;
- if (isset($smarty->registered_cache_resources[$type])) {
- unset($smarty->registered_cache_resources[$type]);
+ $smarty = $this->_objType == 1 ? $this : $this->smarty;
+ if ($template === null) {
+ if ($this->_objType != 2) {
+ throw new SmartyException($function . '():Missing \'$template\' parameter');
+ } else {
+ $template = clone $this;
+ }
+ } elseif (is_object($template)) {
+ if (!isset($template->_objType) || $template->_objType != 2) {
+ throw new SmartyException($function . '():Template object expected');
+ } else {
+ /* @var Smarty_Internal_Template $template */
+ $template = clone $template;
+ }
+ } else {
+ // get template object
+ /* @var Smarty_Internal_Template $template */
+ $template = $smarty->createTemplate($template, $cache_id, $compile_id, $parent, false);
+ if ($this->_objType == 1) {
+ // set caching in template object
+ $template->caching = $this->caching;
+ }
}
-
- 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");
+ // fetch template content
+ $level = ob_get_level();
+ try {
+ $_smarty_old_error_level =
+ ($this->_objType == 1 && isset($smarty->error_reporting)) ? error_reporting($smarty->error_reporting) :
+ null;
+ if ($function == 2) {
+ if ($template->caching) {
+ // return cache status of template
+ if (!isset($template->cached)) {
+ $template->loadCached();
+ }
+ $result = $template->cached->isCached($template);
+ $template->smarty->_cache['isCached'][$template->_getTemplateId()] = $template;
+ } else {
+ return false;
+ }
+ } else {
+ ob_start();
+ $template->_mergeVars();
+ if (!empty(Smarty::$global_tpl_vars)) {
+ $template->tpl_vars = array_merge(Smarty::$global_tpl_vars, $template->tpl_vars);
}
+ $result = $template->render(false, $function);
}
+ if (isset($_smarty_old_error_level)) {
+ error_reporting($_smarty_old_error_level);
+ }
+ return $result;
}
- // 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");
- }
+ catch (Exception $e) {
+ while (ob_get_level() > $level) {
+ ob_end_clean();
}
+ throw $e;
}
- // register the object
- $smarty = isset($this->smarty) ? $this->smarty : $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
+ * Registers plugin to be used in templates
*
- * @return object
- * @throws SmartyException if no such object is found
- */
- public function getRegisteredObject($name)
- {
- $smarty = isset($this->smarty) ? $this->smarty : $this;
- if (!isset($smarty->registered_objects[$name])) {
- throw new SmartyException("'$name' is not a registered object");
- }
- if (!is_object($smarty->registered_objects[$name][0])) {
- throw new SmartyException("registered '$name' is not an object");
- }
-
- return $smarty->registered_objects[$name][0];
- }
-
- /**
- * unregister an object
+ * @api Smarty::registerPlugin()
+ * @link http://www.smarty.net/docs/en/api.register.plugin.tpl
*
- * @param string $name object name
+ * @param string $type plugin type
+ * @param string $name name of template tag
+ * @param callback $callback PHP callback to register
+ * @param bool $cacheable if true (default) this function is cache able
+ * @param mixed $cache_attr caching attributes if any
*
- * @return Smarty_Internal_Templatebase current Smarty_Internal_Templatebase (or Smarty or
- * Smarty_Internal_Template) instance for chaining
+ * @return \Smarty|\Smarty_Internal_Template
+ * @throws SmartyException when the plugin tag is invalid
*/
- public function unregisterObject($name)
+ public function registerPlugin($type, $name, $callback, $cacheable = true, $cache_attr = null)
{
- $smarty = isset($this->smarty) ? $this->smarty : $this;
- if (isset($smarty->registered_objects[$name])) {
- unset($smarty->registered_objects[$name]);
- }
-
- return $this;
+ return $this->ext->registerPlugin->registerPlugin($this, $type, $name, $callback, $cacheable, $cache_attr);
}
/**
- * Registers static classes to be used in templates
- *
- * @param $class_name
- * @param string $class_impl the referenced PHP class to register
+ * load a filter of specified type and name
*
- * @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
- $smarty = isset($this->smarty) ? $this->smarty : $this;
- $smarty->registered_classes[$class_name] = $class_impl;
-
- return $this;
- }
-
- /**
- * Registers a default plugin handler
+ * @api Smarty::loadFilter()
+ * @link http://www.smarty.net/docs/en/api.load.filter.tpl
*
- * @param callable $callback class/method 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
- * @throws SmartyException if $callback is not callable
+ * @return bool
+ * @throws SmartyException if filter could not be loaded
*/
- public function registerDefaultPluginHandler($callback)
+ public function loadFilter($type, $name)
{
- $smarty = isset($this->smarty) ? $this->smarty : $this;
- if (is_callable($callback)) {
- $smarty->default_plugin_handler_func = $callback;
- } else {
- throw new SmartyException("Default plugin handler '$callback' not callable");
- }
-
- return $this;
+ return $this->ext->loadFilter->loadFilter($this, $type, $name);
}
/**
- * Registers a default template handler
- *
- * @param callable $callback class/method name
+ * Registers a filter function
*
- * @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)
- {
- Smarty_Internal_Extension_DefaultTemplateHandler::registerDefaultTemplateHandler($this, $callback);
- return $this;
- }
-
- /**
- * Registers a default template handler
+ * @api Smarty::registerFilter()
+ * @link http://www.smarty.net/docs/en/api.register.filter.tpl
*
- * @param callable $callback class/method name
+ * @param string $type filter type
+ * @param callback $callback
+ * @param string|null $name optional filter 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
+ * @return \Smarty|\Smarty_Internal_Template
+ * @throws \SmartyException
*/
- public function registerDefaultConfigHandler($callback)
+ public function registerFilter($type, $callback, $name = null)
{
- Smarty_Internal_Extension_DefaultTemplateHandler::registerDefaultConfigHandler($this, $callback);
- return $this;
+ return $this->ext->registerFilter->registerFilter($this, $type, $callback, $name);
}
/**
- * Registers a filter function
- *
- * @param string $type filter type
- * @param callback $callback
+ * Registers object to be used in templates
*
- * @return Smarty_Internal_Templatebase current Smarty_Internal_Templatebase (or Smarty or
- * Smarty_Internal_Template) instance for chaining
- */
- public function registerFilter($type, $callback)
- {
- $smarty = isset($this->smarty) ? $this->smarty : $this;
- $smarty->registered_filters[$type][$this->_get_filter_name($callback)] = $callback;
-
- return $this;
- }
-
- /**
- * Unregisters a filter function
+ * @api Smarty::registerObject()
+ * @link http://www.smarty.net/docs/en/api.register.object.tpl
*
- * @param string $type filter type
- * @param callback $callback
+ * @param string $object_name
+ * @param object $object the referenced PHP object to register
+ * @param array $allowed_methods_properties list of allowed methods (empty = all)
+ * @param bool $format smarty argument format, else traditional
+ * @param array $block_methods list of block-methods
*
- * @return Smarty_Internal_Templatebase current Smarty_Internal_Templatebase (or Smarty or
- * Smarty_Internal_Template) instance for chaining
+ * @return \Smarty|\Smarty_Internal_Template
+ * @throws \SmartyException
*/
- public function unregisterFilter($type, $callback)
+ public function registerObject($object_name, $object, $allowed_methods_properties = array(), $format = true,
+ $block_methods = array())
{
- $name = $this->_get_filter_name($callback);
- $smarty = isset($this->smarty) ? $this->smarty : $this;
- if (isset($smarty->registered_filters[$type][$name])) {
- unset($smarty->registered_filters[$type][$name]);
- }
-
- return $this;
+ return $this->ext->registerObject->registerObject($this, $object_name, $object, $allowed_methods_properties,
+ $format, $block_methods);
}
/**
- * Return internal filter name
- *
- * @param callback $function_name
- *
- * @return string internal filter name
+ * @param boolean $caching
*/
- public function _get_filter_name($function_name)
+ public function setCaching($caching)
{
- 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;
- }
+ $this->caching = $caching;
}
/**
- * 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
+ * @param int $cache_lifetime
*/
- public function loadFilter($type, $name)
+ public function setCacheLifetime($cache_lifetime)
{
- $smarty = isset($this->smarty) ? $this->smarty : $this;
- $_plugin = "smarty_{$type}filter_{$name}";
- $_filter_name = $_plugin;
- if ($smarty->loadPlugin($_plugin)) {
- if (class_exists($_plugin, false)) {
- $_plugin = array($_plugin, 'execute');
- }
- if (is_callable($_plugin)) {
- $smarty->registered_filters[$type][$_filter_name] = $_plugin;
-
- return true;
- }
- }
- throw new SmartyException("{$type}filter \"{$name}\" not callable");
+ $this->cache_lifetime = $cache_lifetime;
}
/**
- * 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
+ * @param string $compile_id
*/
- public function unloadFilter($type, $name)
+ public function setCompileId($compile_id)
{
- $smarty = isset($this->smarty) ? $this->smarty : $this;
- $_filter_name = "smarty_{$type}filter_{$name}";
- if (isset($smarty->registered_filters[$type][$_filter_name])) {
- unset ($smarty->registered_filters[$type][$_filter_name]);
- }
-
- return $this;
+ $this->compile_id = $compile_id;
}
/**
- * preg_replace callback to convert camelcase getter/setter to underscore property names
- *
- * @param string $match match string
- *
- * @return string replacemant
+ * @param string $cache_id
*/
- private function replaceCamelcase($match)
+ public function setCacheId($cache_id)
{
- return "_" . strtolower($match[1]);
+ $this->cache_id = $cache_id;
}
- /**
- * 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();
-
- // 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])) {
- $status = $_resolved_property_source[$property_name];
- } else {
- $status = null;
- if (property_exists($this, $property_name)) {
- $status = true;
- } elseif (property_exists($this->smarty, $property_name)) {
- $status = false;
- }
- $_resolved_property_source[$property_name] = $status;
- }
- $smarty = null;
- if ($status === true) {
- $smarty = $this;
- } elseif ($status === false) {
- $smarty = $this->smarty;
- }
- if ($smarty) {
- if ($first3 == 'get') {
- return $smarty->$property_name;
- } else {
- return $smarty->$property_name = $args[0];
- }
- }
- throw new SmartyException("property '$property_name' does not exist.");
- }
- throw new SmartyException("Call of unknown method '$name'.");
- }
}
diff --git a/library/Smarty/libs/sysplugins/smarty_internal_templatecompilerbase.php b/library/Smarty/libs/sysplugins/smarty_internal_templatecompilerbase.php
index 7fc6c3252..9487c3454 100644
--- a/library/Smarty/libs/sysplugins/smarty_internal_templatecompilerbase.php
+++ b/library/Smarty/libs/sysplugins/smarty_internal_templatecompilerbase.php
@@ -14,6 +14,11 @@
*
* @package Smarty
* @subpackage Compiler
+ *
+ * @property Smarty_Internal_SmartyTemplateCompiler $prefixCompiledCode = ''
+ * @property Smarty_Internal_SmartyTemplateCompiler $postfixCompiledCode = ''
+ * @method Smarty_Internal_SmartyTemplateCompiler registerPostCompileCallback($callback, $parameter = array(), $key = null, $replace = false)
+ * @method Smarty_Internal_SmartyTemplateCompiler unregisterPostCompileCallback($key)
*/
abstract class Smarty_Internal_TemplateCompilerBase
{
@@ -26,6 +31,13 @@ abstract class Smarty_Internal_TemplateCompilerBase
public $smarty = null;
/**
+ * Parser object
+ *
+ * @var Smarty_Internal_Templateparser
+ */
+ public $parser = null;
+
+ /**
* hash for nocache sections
*
* @var mixed
@@ -40,11 +52,11 @@ abstract class Smarty_Internal_TemplateCompilerBase
public $suppressNocacheProcessing = false;
/**
- * compile tag objects
+ * compile tag objects cache
*
* @var array
*/
- public static $_tag_objects = array();
+ public $_tag_objects = array();
/**
* tag stack
@@ -82,34 +94,6 @@ abstract class Smarty_Internal_TemplateCompilerBase
public $templateProperties = array();
/**
- * sources which must be compiled
- *
- * @var array
- */
- public $sources = array();
-
- /**
- * flag that we are inside {block}
- *
- * @var bool
- */
- public $inheritance = false;
-
- /**
- * flag when compiling inheritance child template
- *
- * @var bool
- */
- public $inheritance_child = false;
-
- /**
- * uid of templates called by {extends} for recursion check
- *
- * @var array
- */
- public $extends_uid = array();
-
- /**
* source line offset for error messages
*
* @var int
@@ -159,27 +143,6 @@ abstract class Smarty_Internal_TemplateCompilerBase
public $forceNocache = false;
/**
- * suppress Smarty header code in compiled template
- *
- * @var bool
- */
- public $suppressHeader = false;
-
- /**
- * suppress template property header code in compiled template
- *
- * @var bool
- */
- public $suppressTemplatePropertyHeader = false;
-
- /**
- * suppress pre and post filter
- *
- * @var bool
- */
- public $suppressFilter = false;
-
- /**
* flag if compiled template file shall we written
*
* @var bool
@@ -187,13 +150,6 @@ abstract class Smarty_Internal_TemplateCompilerBase
public $write_compiled_code = true;
/**
- * flag if currently a template function is compiled
- *
- * @var bool
- */
- public $compiles_template_function = false;
-
- /**
* called sub functions from template function
*
* @var array
@@ -201,11 +157,11 @@ abstract class Smarty_Internal_TemplateCompilerBase
public $called_functions = array();
/**
- * compiled template function code
+ * compiled template or block function code
*
* @var string
*/
- public $templateFunctionCode = '';
+ public $blockOrFunctionCode = '';
/**
* php_handling setting either from Smarty or security
@@ -250,13 +206,6 @@ abstract class Smarty_Internal_TemplateCompilerBase
public $tag_nocache = false;
/**
- * Flag to restart parsing
- *
- * @var bool
- */
- public $abort_and_recompile = false;
-
- /**
* Compiled tag prefix code
*
* @var array
@@ -292,6 +241,27 @@ abstract class Smarty_Internal_TemplateCompilerBase
public $has_output = false;
/**
+ * Stack for {setfilter} {/setfilter}
+ *
+ * @var array
+ */
+ public $variable_filter_stack = array();
+
+ /**
+ * variable filters for {setfilter} {/setfilter}
+ *
+ * @var array
+ */
+ public $variable_filters = array();
+
+ /**
+ * Nesting count of looping tags like {foreach}, {for}, {section}, {while}
+ *
+ * @var int
+ */
+ public $loopNesting = 0;
+
+ /**
* Strip preg pattern
*
* @var string
@@ -299,19 +269,37 @@ abstract class Smarty_Internal_TemplateCompilerBase
public $stripRegEx = '![\t ]*[\r\n]+[\t ]*!';
/**
+ * plugin search order
+ *
+ * @var array
+ */
+ public $plugin_search_order = array('function', 'block', 'compiler', 'class');
+
+ /**
+ * General storage area for tag compiler plugins
+ *
+ * @var array
+ */
+ public $_cache = array();
+
+ /**
* method to compile a Smarty template
*
- * @param mixed $_content template source
+ * @param mixed $_content template source
+ * @param bool $isTemplateSource
*
- * @return bool true if compiling succeeded, false if it failed
+ * @return bool true if compiling succeeded, false if it failed
*/
- abstract protected function doCompile($_content);
+ abstract protected function doCompile($_content, $isTemplateSource = false);
/**
* Initialize compiler
+ *
+ * @param Smarty $smarty global instance
*/
- public function __construct()
+ public function __construct(Smarty $smarty)
{
+ $this->smarty = $smarty;
$this->nocache_hash = str_replace(array('.', ','), '_', uniqid(rand(), true));
}
@@ -323,117 +311,140 @@ abstract class Smarty_Internal_TemplateCompilerBase
* @param null|Smarty_Internal_TemplateCompilerBase $parent_compiler
*
* @return bool true if compiling succeeded, false if it failed
+ * @throws \Exception
*/
- public function compileTemplate(Smarty_Internal_Template $template, $nocache = null, $parent_compiler = null)
+ public function compileTemplate(Smarty_Internal_Template $template, $nocache = null,
+ Smarty_Internal_TemplateCompilerBase $parent_compiler = null)
{
- // save template object in compiler class
- $this->template = $template;
- if (isset($this->template->smarty->security_policy)) {
- $this->php_handling = $this->template->smarty->security_policy->php_handling;
- } else {
- $this->php_handling = $this->template->smarty->php_handling;
- }
- $this->parent_compiler = $parent_compiler ? $parent_compiler : $this;
- $nocache = isset($nocache) ? $nocache : false;
- if (empty($template->properties['nocache_hash'])) {
- $template->properties['nocache_hash'] = $this->nocache_hash;
- } else {
- $this->nocache_hash = $template->properties['nocache_hash'];
- }
- $save_source = $this->template->source;
- // template header code
- $template_header = '';
- if (!$this->suppressHeader) {
- $template_header .= "<?php /* Smarty version " . Smarty::SMARTY_VERSION . ", created on " . strftime("%Y-%m-%d %H:%M:%S") . "\n";
- $template_header .= " compiled from \"" . $this->template->source->filepath . "\" */ ?>\n";
- }
+ // get code frame of compiled template
+ $_compiled_code = $template->smarty->ext->_codeFrame->create($template,
+ $this->compileTemplateSource($template, $nocache,
+ $parent_compiler),
+ $this->postFilter($this->blockOrFunctionCode) .
+ join('', $this->mergedSubTemplatesCode));
+ return $_compiled_code;
+ }
- if (empty($this->template->source->components)) {
- $this->sources = array($template->source);
- } else {
- // we have array of inheritance templates by extends: resource
- $this->sources = array_reverse($template->source->components);
- }
- $loop = 0;
- // the $this->sources array can get additional elements while compiling by the {extends} tag
- while ($this->template->source = array_shift($this->sources)) {
- $this->smarty->_current_file = $this->template->source->filepath;
+ /**
+ * Compile template source and run optional post filter
+ *
+ * @param \Smarty_Internal_Template $template
+ * @param null|bool $nocache flag if template must be compiled in nocache mode
+ * @param \Smarty_Internal_TemplateCompilerBase $parent_compiler
+ *
+ * @return string
+ * @throws \Exception
+ */
+ public function compileTemplateSource(Smarty_Internal_Template $template, $nocache = null,
+ Smarty_Internal_TemplateCompilerBase $parent_compiler = null)
+ {
+ try {
+ // save template object in compiler class
+ $this->template = $template;
+ if (property_exists($this->template->smarty, 'plugin_search_order')) {
+ $this->plugin_search_order = $this->template->smarty->plugin_search_order;
+ }
if ($this->smarty->debugging) {
- Smarty_Internal_Debug::start_compile($this->template);
+ $this->smarty->_debug->start_compile($this->template);
+ }
+ if (isset($this->template->smarty->security_policy)) {
+ $this->php_handling = $this->template->smarty->security_policy->php_handling;
+ } else {
+ $this->php_handling = $this->template->smarty->php_handling;
}
- $no_sources = count($this->sources);
- $this->parent_compiler->template->properties['file_dependency'][$this->template->source->uid] = array($this->template->source->filepath, $this->template->source->timestamp, $this->template->source->type);
- $loop ++;
- if ($no_sources) {
- $this->inheritance_child = true;
+ $this->parent_compiler = $parent_compiler ? $parent_compiler : $this;
+ $nocache = isset($nocache) ? $nocache : false;
+ if (empty($template->compiled->nocache_hash)) {
+ $template->compiled->nocache_hash = $this->nocache_hash;
} else {
- $this->inheritance_child = false;
+ $this->nocache_hash = $template->compiled->nocache_hash;
}
- do {
- // flag for nochache sections
- $this->nocache = $nocache;
- $this->tag_nocache = false;
- // reset has nocache code flag
- $this->template->has_nocache_code = false;
- $this->has_variable_string = false;
- $this->prefix_code = array();
- $_compiled_code = '';
- // flag for aborting current and start recompile
- $this->abort_and_recompile = false;
+ // flag for nocache sections
+ $this->nocache = $nocache;
+ $this->tag_nocache = false;
+ // reset has nocache code flag
+ $this->template->compiled->has_nocache_code = false;
+ $this->has_variable_string = false;
+ $this->prefix_code = array();
+ // add file dependency
+ $this->parent_compiler->template->compiled->file_dependency[$this->template->source->uid] =
+ array($this->template->source->filepath, $this->template->source->getTimeStamp(),
+ $this->template->source->type);
+ $this->smarty->_current_file = $this->template->source->filepath;
+ // get template source
+ if (!empty($this->template->source->components)) {
+ // we have array of inheritance templates by extends: resource
+ // generate corresponding source code sequence
+ $_content =
+ Smarty_Internal_Compile_Extends::extendsSourceArrayCode($this->template->source->components);
+ } else {
// get template source
- $_content = $this->template->source->content;
- if ($_content != '') {
- // run prefilter if required
- if ((isset($this->smarty->autoload_filters['pre']) || isset($this->smarty->registered_filters['pre'])) && !$this->suppressFilter) {
- $_content = Smarty_Internal_Filter_Handler::runFilter('pre', $_content, $template);
- }
- // call compiler
- $_compiled_code = $this->doCompile($_content, true);
- }
- } while ($this->abort_and_recompile);
- if ($this->smarty->debugging) {
- Smarty_Internal_Debug::end_compile($this->template);
+ $_content = $this->template->source->getContent();
}
+ $_compiled_code = $this->postFilter($this->doCompile($this->preFilter($_content), true));
}
- // restore source
- $this->template->source = $save_source;
- unset($save_source);
- $this->smarty->_current_file = $this->template->source->filepath;
- // free memory
- unset($this->parser->root_buffer, $this->parser->current_buffer, $this->parser, $this->lex);
- self::$_tag_objects = array();
- // return compiled code to template object
- $merged_code = '';
- if (!empty($this->mergedSubTemplatesCode)) {
- foreach ($this->mergedSubTemplatesCode as $code) {
- $merged_code .= $code;
+ catch (Exception $e) {
+ if ($this->smarty->debugging) {
+ $this->smarty->_debug->end_compile($this->template);
}
+ $this->_tag_stack = array();
+ $this->_tag_objects = array();
+ // free memory
+ $this->parent_compiler = null;
+ $this->template = null;
+ $this->parser = null;
+ throw $e;
}
- // run postfilter if required on compiled template code
- if ((isset($this->smarty->autoload_filters['post']) || isset($this->smarty->registered_filters['post'])) && !$this->suppressFilter && $_compiled_code != '') {
- $_compiled_code = Smarty_Internal_Filter_Handler::runFilter('post', $_compiled_code, $template);
- }
- if ($this->suppressTemplatePropertyHeader) {
- $_compiled_code .= $merged_code;
- } else {
- $_compiled_code = $template_header . Smarty_Internal_Extension_CodeFrame::create($template, $_compiled_code) . $merged_code;
- }
- if (!empty($this->templateFunctionCode)) {
- // run postfilter if required on compiled template code
- if ((isset($this->smarty->autoload_filters['post']) || isset($this->smarty->registered_filters['post'])) && !$this->suppressFilter) {
- $_compiled_code .= Smarty_Internal_Filter_Handler::runFilter('post', $this->templateFunctionCode, $template);
- } else {
- $_compiled_code .= $this->templateFunctionCode;
- }
+ if ($this->smarty->debugging) {
+ $this->smarty->_debug->end_compile($this->template);
}
- // unset content because template inheritance could have replace source with parent code
- unset ($template->source->content);
$this->parent_compiler = null;
$this->template = null;
+ $this->parser = null;
return $_compiled_code;
}
/**
+ * Optionally process compiled code by post filter
+ *
+ * @param string $code compiled code
+ *
+ * @return string
+ * @throws \SmartyException
+ */
+ public function postFilter($code)
+ {
+ // run post filter if on code
+ if (!empty($code) &&
+ (isset($this->smarty->autoload_filters['post']) || isset($this->smarty->registered_filters['post']))
+ ) {
+ return $this->smarty->ext->_filterHandler->runFilter('post', $code, $this->template);
+ } else {
+ return $code;
+ }
+ }
+
+ /**
+ * Run optional prefilter
+ *
+ * @param string $_content template source
+ *
+ * @return string
+ * @throws \SmartyException
+ */
+ public function preFilter($_content)
+ {
+ // run pre filter if required
+ if ($_content != '' &&
+ ((isset($this->smarty->autoload_filters['pre']) || isset($this->smarty->registered_filters['pre'])))
+ ) {
+ return $this->smarty->ext->_filterHandler->runFilter('pre', $_content, $this->template);
+ } else {
+ return $_content;
+ }
+ }
+
+ /**
* Compile Tag
* This is a call back from the lexer/parser
*
@@ -478,17 +489,18 @@ abstract class Smarty_Internal_TemplateCompilerBase
$this->has_code = true;
$this->has_output = false;
// log tag/attributes
- if (isset($this->smarty->get_used_tags) && $this->smarty->get_used_tags) {
- $this->template->used_tags[] = array($tag, $args);
+ if (isset($this->smarty->_cache['get_used_tags'])) {
+ $this->template->_cache['used_tags'][] = array($tag, $args);
}
// check nocache option flag
- if (in_array("'nocache'", $args) || in_array(array('nocache' => 'true'), $args) || in_array(array('nocache' => '"true"'), $args) || in_array(array('nocache' => "'true'"), $args)
+ if (in_array("'nocache'", $args) || in_array(array('nocache' => 'true'), $args) ||
+ in_array(array('nocache' => '"true"'), $args) || in_array(array('nocache' => "'true'"), $args)
) {
$this->tag_nocache = true;
}
- // compile the smarty tag (required compile classes to compile the tag are autoloaded)
+ // compile the smarty tag (required compile classes to compile the tag are auto loaded)
if (($_output = $this->callTagCompiler($tag, $args, $parameter)) === false) {
- if (isset($this->parent_compiler->templateProperties['tpl_function'][$tag])) {
+ if (isset($this->parent_compiler->template->tpl_function[$tag])) {
// template defined by {template} tag
$args['_attr']['name'] = "'" . $tag . "'";
$_output = $this->callTagCompiler('call', $args, $parameter);
@@ -522,18 +534,23 @@ abstract class Smarty_Internal_TemplateCompilerBase
// check if tag is a registered object
if (isset($this->smarty->registered_objects[$tag]) && isset($parameter['object_method'])) {
$method = $parameter['object_method'];
- if (!in_array($method, $this->smarty->registered_objects[$tag][3]) && (empty($this->smarty->registered_objects[$tag][1]) || in_array($method, $this->smarty->registered_objects[$tag][1]))
+ if (!in_array($method, $this->smarty->registered_objects[$tag][3]) &&
+ (empty($this->smarty->registered_objects[$tag][1]) ||
+ in_array($method, $this->smarty->registered_objects[$tag][1]))
) {
return $this->callTagCompiler('private_object_function', $args, $parameter, $tag, $method);
} elseif (in_array($method, $this->smarty->registered_objects[$tag][3])) {
- return $this->callTagCompiler('private_object_block_function', $args, $parameter, $tag, $method);
+ return $this->callTagCompiler('private_object_block_function', $args, $parameter, $tag,
+ $method);
} else {
// throw exception
- $this->trigger_template_error('not allowed method "' . $method . '" in registered object "' . $tag . '"', $this->lex->taglineno);
+ $this->trigger_template_error('not allowed method "' . $method . '" in registered object "' .
+ $tag . '"', null, true);
}
}
// check if tag is registered
- foreach (array(Smarty::PLUGIN_COMPILER, Smarty::PLUGIN_FUNCTION, Smarty::PLUGIN_BLOCK) as $plugin_type) {
+ foreach (array(Smarty::PLUGIN_COMPILER, Smarty::PLUGIN_FUNCTION, Smarty::PLUGIN_BLOCK) as $plugin_type)
+ {
if (isset($this->smarty->registered_plugins[$plugin_type][$tag])) {
// if compiler function plugin call it now
if ($plugin_type == Smarty::PLUGIN_COMPILER) {
@@ -552,20 +569,26 @@ abstract class Smarty_Internal_TemplateCompilerBase
if (!is_array($function)) {
return $function($new_args, $this);
} elseif (is_object($function[0])) {
- return $this->smarty->registered_plugins[$plugin_type][$tag][0][0]->$function[1]($new_args, $this);
+ return $this->smarty->registered_plugins[$plugin_type][$tag][0][0]->{$function[1]}($new_args,
+ $this);
} else {
return call_user_func_array($function, array($new_args, $this));
}
}
// compile registered function or block function
if ($plugin_type == Smarty::PLUGIN_FUNCTION || $plugin_type == Smarty::PLUGIN_BLOCK) {
- return $this->callTagCompiler('private_registered_' . $plugin_type, $args, $parameter, $tag);
+ return $this->callTagCompiler('private_registered_' . $plugin_type, $args, $parameter,
+ $tag);
}
}
}
// check plugins from plugins folder
- foreach ($this->smarty->plugin_search_order as $plugin_type) {
- if ($plugin_type == Smarty::PLUGIN_COMPILER && $this->smarty->loadPlugin('smarty_compiler_' . $tag) && (!isset($this->smarty->security_policy) || $this->smarty->security_policy->isTrustedTag($tag, $this))) {
+ foreach ($this->plugin_search_order as $plugin_type) {
+ if ($plugin_type == Smarty::PLUGIN_COMPILER &&
+ $this->smarty->loadPlugin('smarty_compiler_' . $tag) &&
+ (!isset($this->smarty->security_policy) ||
+ $this->smarty->security_policy->isTrustedTag($tag, $this))
+ ) {
$plugin = 'smarty_compiler_' . $tag;
if (is_callable($plugin)) {
// convert arguments format for old compiler plugins
@@ -589,8 +612,11 @@ abstract class Smarty_Internal_TemplateCompilerBase
throw new SmartyException("Plugin \"{$tag}\" not callable");
} else {
if ($function = $this->getPlugin($tag, $plugin_type)) {
- if (!isset($this->smarty->security_policy) || $this->smarty->security_policy->isTrustedTag($tag, $this)) {
- return $this->callTagCompiler('private_' . $plugin_type . '_plugin', $args, $parameter, $tag, $function);
+ if (!isset($this->smarty->security_policy) ||
+ $this->smarty->security_policy->isTrustedTag($tag, $this)
+ ) {
+ return $this->callTagCompiler('private_' . $plugin_type . '_plugin', $args, $parameter,
+ $tag, $function);
}
}
}
@@ -598,7 +624,7 @@ abstract class Smarty_Internal_TemplateCompilerBase
if (is_callable($this->smarty->default_plugin_handler_func)) {
$found = false;
// look for already resolved tags
- foreach ($this->smarty->plugin_search_order as $plugin_type) {
+ foreach ($this->plugin_search_order as $plugin_type) {
if (isset($this->default_handler_plugins[$plugin_type][$tag])) {
$found = true;
break;
@@ -606,7 +632,7 @@ abstract class Smarty_Internal_TemplateCompilerBase
}
if (!$found) {
// call default handler
- foreach ($this->smarty->plugin_search_order as $plugin_type) {
+ foreach ($this->plugin_search_order as $plugin_type) {
if ($this->getPluginFromDefaultHandler($tag, $plugin_type)) {
$found = true;
break;
@@ -624,12 +650,14 @@ abstract class Smarty_Internal_TemplateCompilerBase
if (!is_array($function)) {
return $function($new_args, $this);
} elseif (is_object($function[0])) {
- return $this->default_handler_plugins[$plugin_type][$tag][0][0]->$function[1]($new_args, $this);
+ return $this->default_handler_plugins[$plugin_type][$tag][0][0]->$function[1]($new_args,
+ $this);
} else {
return call_user_func_array($function, array($new_args, $this));
}
} else {
- return $this->callTagCompiler('private_registered_' . $plugin_type, $args, $parameter, $tag);
+ return $this->callTagCompiler('private_registered_' . $plugin_type, $args, $parameter,
+ $tag);
}
}
}
@@ -640,20 +668,36 @@ abstract class Smarty_Internal_TemplateCompilerBase
if (isset($this->smarty->registered_objects[$base_tag]) && isset($parameter['object_method'])) {
$method = $parameter['object_method'];
if (in_array($method, $this->smarty->registered_objects[$base_tag][3])) {
- return $this->callTagCompiler('private_object_block_function', $args, $parameter, $tag, $method);
+ return $this->callTagCompiler('private_object_block_function', $args, $parameter, $tag,
+ $method);
} else {
// throw exception
- $this->trigger_template_error('not allowed closing tag method "' . $method . '" in registered object "' . $base_tag . '"', $this->lex->taglineno);
+ $this->trigger_template_error('not allowed closing tag method "' . $method .
+ '" in registered object "' . $base_tag . '"', null, true);
}
}
// registered block tag ?
- if (isset($this->smarty->registered_plugins[Smarty::PLUGIN_BLOCK][$base_tag]) || isset($this->default_handler_plugins[Smarty::PLUGIN_BLOCK][$base_tag])) {
+ if (isset($this->smarty->registered_plugins[Smarty::PLUGIN_BLOCK][$base_tag]) ||
+ isset($this->default_handler_plugins[Smarty::PLUGIN_BLOCK][$base_tag])
+ ) {
return $this->callTagCompiler('private_registered_block', $args, $parameter, $tag);
}
+ // registered function tag ?
+ if (isset($this->smarty->registered_plugins[Smarty::PLUGIN_FUNCTION][$tag])) {
+ return $this->callTagCompiler('private_registered_function', $args, $parameter, $tag);
+ }
// block plugin?
if ($function = $this->getPlugin($base_tag, Smarty::PLUGIN_BLOCK)) {
return $this->callTagCompiler('private_block_plugin', $args, $parameter, $tag, $function);
}
+ // function plugin?
+ if ($function = $this->getPlugin($tag, Smarty::PLUGIN_FUNCTION)) {
+ if (!isset($this->smarty->security_policy) ||
+ $this->smarty->security_policy->isTrustedTag($tag, $this)
+ ) {
+ return $this->callTagCompiler('private_function_plugin', $args, $parameter, $tag, $function);
+ }
+ }
// registered compiler plugin ?
if (isset($this->smarty->registered_plugins[Smarty::PLUGIN_COMPILER][$tag])) {
// if compiler function plugin call it now
@@ -665,7 +709,8 @@ abstract class Smarty_Internal_TemplateCompilerBase
if (!is_array($function)) {
return $function($args, $this);
} elseif (is_object($function[0])) {
- return $this->smarty->registered_plugins[Smarty::PLUGIN_COMPILER][$tag][0][0]->$function[1]($args, $this);
+ return $this->smarty->registered_plugins[Smarty::PLUGIN_COMPILER][$tag][0][0]->$function[1]($args,
+ $this);
} else {
return call_user_func_array($function, array($args, $this));
}
@@ -684,7 +729,7 @@ abstract class Smarty_Internal_TemplateCompilerBase
throw new SmartyException("Plugin \"{$tag}\" not callable");
}
}
- $this->trigger_template_error("unknown tag \"" . $tag . "\"", $this->lex->taglineno);
+ $this->trigger_template_error("unknown tag \"" . $tag . "\"", null, true);
}
}
@@ -700,13 +745,27 @@ abstract class Smarty_Internal_TemplateCompilerBase
if (strpos($variable, '(') == 0) {
// not a variable variable
$var = trim($variable, '\'');
- $this->tag_nocache = $this->tag_nocache | $this->template->getVariable($var, null, true, false)->nocache;
- $this->template->properties['variables'][$var] = $this->tag_nocache | $this->nocache;
+ $this->tag_nocache = $this->tag_nocache |
+ $this->template->ext->getTemplateVars->_getVariable($this->template, $var, null, true, false)->nocache;
+ // todo $this->template->compiled->properties['variables'][$var] = $this->tag_nocache | $this->nocache;
}
return '$_smarty_tpl->tpl_vars[' . $variable . ']->value';
}
/**
+ * compile config variable
+ *
+ * @param string $variable
+ *
+ * @return string
+ */
+ public function compileConfigVariable($variable)
+ {
+ // return '$_smarty_tpl->config_vars[' . $variable . ']';
+ return '$_smarty_tpl->smarty->ext->configLoad->_getConfigVariable($_smarty_tpl, ' . $variable . ')';
+ }
+
+ /**
* This method is called from parser to process a text content section
* - remove text from inheritance child templates as they may generate output
* - strip text if strip is enabled
@@ -718,9 +777,9 @@ abstract class Smarty_Internal_TemplateCompilerBase
public function processText($text)
{
if ($this->parser->strip) {
- return new Smarty_Internal_ParseTree_Text($this->parser, preg_replace($this->stripRegEx, '', $text));
+ return new Smarty_Internal_ParseTree_Text(preg_replace($this->stripRegEx, ' ', $text));
} else {
- return new Smarty_Internal_ParseTree_Text($this->parser, $text);
+ return new Smarty_Internal_ParseTree_Text($text);
}
}
@@ -728,7 +787,7 @@ abstract class Smarty_Internal_TemplateCompilerBase
* lazy loads internal compile plugin for tag and calls the compile method
* compile objects cached for reuse.
* class name format: Smarty_Internal_Compile_TagName
- * plugin filename format: Smarty_Internal_Tagname.php
+ * plugin filename format: Smarty_Internal_TagName.php
*
* @param string $tag tag name
* @param array $args list of tag attributes
@@ -740,23 +799,24 @@ abstract class Smarty_Internal_TemplateCompilerBase
*/
public function callTagCompiler($tag, $args, $param1 = null, $param2 = null, $param3 = null)
{
- // check if tag allowed by security
- if (!isset($this->smarty->security_policy) || $this->smarty->security_policy->isTrustedTag($tag, $this)) {
- // re-use object if already exists
- if (!isset(self::$_tag_objects[$tag])) {
- // lazy load internal compiler plugin
- $class_name = 'Smarty_Internal_Compile_' . $tag;
- if ($this->smarty->loadPlugin($class_name)) {
- self::$_tag_objects[$tag] = new $class_name;
- } else {
- return false;
- }
+ // re-use object if already exists
+ if (!isset($this->_tag_objects[$tag])) {
+ // lazy load internal compiler plugin
+ $_tag = explode('_', $tag);
+ $_tag = array_map('ucfirst', $_tag);
+ $class_name = 'Smarty_Internal_Compile_' . implode('_', $_tag);
+ if (class_exists($class_name) &&
+ (!isset($this->smarty->security_policy) || $this->smarty->security_policy->isTrustedTag($tag, $this))
+ ) {
+ $this->_tag_objects[$tag] = new $class_name;
+ } else {
+ $this->_tag_objects[$tag] = false;
+ return false;
}
- // compile this tag
- return self::$_tag_objects[$tag]->compile($args, $this, $param1, $param2, $param3);
}
- // no internal compile plugin for this tag
- return false;
+ // compile this tag
+ return $this->_tag_objects[$tag] === false ? false :
+ $this->_tag_objects[$tag]->compile($args, $this, $param1, $param2, $param3);
}
/**
@@ -771,18 +831,24 @@ abstract class Smarty_Internal_TemplateCompilerBase
{
$function = null;
if ($this->template->caching && ($this->nocache || $this->tag_nocache)) {
- if (isset($this->template->required_plugins['nocache'][$plugin_name][$plugin_type])) {
- $function = $this->template->required_plugins['nocache'][$plugin_name][$plugin_type]['function'];
- } elseif (isset($this->template->required_plugins['compiled'][$plugin_name][$plugin_type])) {
- $this->template->required_plugins['nocache'][$plugin_name][$plugin_type] = $this->template->required_plugins['compiled'][$plugin_name][$plugin_type];
- $function = $this->template->required_plugins['nocache'][$plugin_name][$plugin_type]['function'];
+ if (isset($this->parent_compiler->template->compiled->required_plugins['nocache'][$plugin_name][$plugin_type])) {
+ $function =
+ $this->parent_compiler->template->compiled->required_plugins['nocache'][$plugin_name][$plugin_type]['function'];
+ } elseif (isset($this->parent_compiler->template->compiled->required_plugins['compiled'][$plugin_name][$plugin_type])) {
+ $this->parent_compiler->template->compiled->required_plugins['nocache'][$plugin_name][$plugin_type] =
+ $this->parent_compiler->template->compiled->required_plugins['compiled'][$plugin_name][$plugin_type];
+ $function =
+ $this->parent_compiler->template->compiled->required_plugins['nocache'][$plugin_name][$plugin_type]['function'];
}
} else {
- if (isset($this->template->required_plugins['compiled'][$plugin_name][$plugin_type])) {
- $function = $this->template->required_plugins['compiled'][$plugin_name][$plugin_type]['function'];
- } elseif (isset($this->template->required_plugins['nocache'][$plugin_name][$plugin_type])) {
- $this->template->required_plugins['compiled'][$plugin_name][$plugin_type] = $this->template->required_plugins['nocache'][$plugin_name][$plugin_type];
- $function = $this->template->required_plugins['compiled'][$plugin_name][$plugin_type]['function'];
+ if (isset($this->parent_compiler->template->compiled->required_plugins['compiled'][$plugin_name][$plugin_type])) {
+ $function =
+ $this->parent_compiler->template->compiled->required_plugins['compiled'][$plugin_name][$plugin_type]['function'];
+ } elseif (isset($this->parent_compiler->template->compiled->required_plugins['nocache'][$plugin_name][$plugin_type])) {
+ $this->parent_compiler->template->compiled->required_plugins['compiled'][$plugin_name][$plugin_type] =
+ $this->parent_compiler->template->compiled->required_plugins['nocache'][$plugin_name][$plugin_type];
+ $function =
+ $this->parent_compiler->template->compiled->required_plugins['compiled'][$plugin_name][$plugin_type]['function'];
}
}
if (isset($function)) {
@@ -798,11 +864,15 @@ abstract class Smarty_Internal_TemplateCompilerBase
if (is_string($file)) {
if ($this->template->caching && ($this->nocache || $this->tag_nocache)) {
- $this->template->required_plugins['nocache'][$plugin_name][$plugin_type]['file'] = $file;
- $this->template->required_plugins['nocache'][$plugin_name][$plugin_type]['function'] = $function;
+ $this->parent_compiler->template->compiled->required_plugins['nocache'][$plugin_name][$plugin_type]['file'] =
+ $file;
+ $this->parent_compiler->template->compiled->required_plugins['nocache'][$plugin_name][$plugin_type]['function'] =
+ $function;
} else {
- $this->template->required_plugins['compiled'][$plugin_name][$plugin_type]['file'] = $file;
- $this->template->required_plugins['compiled'][$plugin_name][$plugin_type]['function'] = $function;
+ $this->parent_compiler->template->compiled->required_plugins['compiled'][$plugin_name][$plugin_type]['file'] =
+ $file;
+ $this->parent_compiler->template->compiled->required_plugins['compiled'][$plugin_name][$plugin_type]['function'] =
+ $function;
}
if ($plugin_type == 'modifier') {
$this->modifier_plugins[$plugin_name] = true;
@@ -831,17 +901,22 @@ abstract class Smarty_Internal_TemplateCompilerBase
$callback = null;
$script = null;
$cacheable = true;
- $result = call_user_func_array($this->smarty->default_plugin_handler_func, array($tag, $plugin_type, $this->template, &$callback, &$script, &$cacheable));
+ $result = call_user_func_array($this->smarty->default_plugin_handler_func,
+ array($tag, $plugin_type, $this->template, &$callback, &$script, &$cacheable));
if ($result) {
$this->tag_nocache = $this->tag_nocache || !$cacheable;
if ($script !== null) {
if (is_file($script)) {
if ($this->template->caching && ($this->nocache || $this->tag_nocache)) {
- $this->template->required_plugins['nocache'][$tag][$plugin_type]['file'] = $script;
- $this->template->required_plugins['nocache'][$tag][$plugin_type]['function'] = $callback;
+ $this->parent_compiler->template->compiled->required_plugins['nocache'][$tag][$plugin_type]['file'] =
+ $script;
+ $this->parent_compiler->template->compiled->required_plugins['nocache'][$tag][$plugin_type]['function'] =
+ $callback;
} else {
- $this->template->required_plugins['compiled'][$tag][$plugin_type]['file'] = $script;
- $this->template->required_plugins['compiled'][$tag][$plugin_type]['function'] = $callback;
+ $this->parent_compiler->template->compiled->required_plugins['compiled'][$tag][$plugin_type]['file'] =
+ $script;
+ $this->parent_compiler->template->compiled->required_plugins['compiled'][$tag][$plugin_type]['function'] =
+ $callback;
}
require_once $script;
} else {
@@ -898,16 +973,19 @@ abstract class Smarty_Internal_TemplateCompilerBase
// If the template is not evaluated and we have a nocache section and or a nocache tag
if ($is_code && !empty($content)) {
// generate replacement code
- if ((!($this->template->source->recompiled) || $this->forceNocache) && $this->template->caching && !$this->suppressNocacheProcessing && ($this->nocache || $this->tag_nocache)
+ if ((!($this->template->source->handler->recompiled) || $this->forceNocache) && $this->template->caching &&
+ !$this->suppressNocacheProcessing && ($this->nocache || $this->tag_nocache)
) {
- $this->template->has_nocache_code = true;
+ $this->template->compiled->has_nocache_code = true;
$_output = addcslashes($content, '\'\\');
$_output = str_replace("^#^", "'", $_output);
- $_output = "<?php echo '/*%%SmartyNocache:{$this->nocache_hash}%%*/" . $_output . "/*/%%SmartyNocache:{$this->nocache_hash}%%*/';?>\n";
+ $_output = "<?php echo '/*%%SmartyNocache:{$this->nocache_hash}%%*/" . $_output .
+ "/*/%%SmartyNocache:{$this->nocache_hash}%%*/';?>\n";
// make sure we include modifier plugins for nocache code
foreach ($this->modifier_plugins as $plugin_name => $dummy) {
- if (isset($this->template->required_plugins['compiled'][$plugin_name]['modifier'])) {
- $this->template->required_plugins['nocache'][$plugin_name]['modifier'] = $this->template->required_plugins['compiled'][$plugin_name]['modifier'];
+ if (isset($this->parent_compiler->template->compiled->required_plugins['compiled'][$plugin_name]['modifier'])) {
+ $this->parent_compiler->template->compiled->required_plugins['nocache'][$plugin_name]['modifier'] =
+ $this->parent_compiler->template->compiled->required_plugins['compiled'][$plugin_name]['modifier'];
}
}
} else {
@@ -924,55 +1002,46 @@ abstract class Smarty_Internal_TemplateCompilerBase
}
/**
- * Generate nocache code string
+ * Get Id
*
- * @param string $code PHP code
+ * @param string $input
*
- * @return string
+ * @return bool|string
*/
- public function makeNocacheCode($code)
+ public function getId($input)
{
- return "echo '/*%%SmartyNocache:{$this->nocache_hash}%%*/<?php " . str_replace("^#^", "'", addcslashes($code, '\'\\')) . "?>/*/%%SmartyNocache:{$this->nocache_hash}%%*/';\n";
+ if (preg_match('~^[\'"]*([0-9]*[a-zA-Z_]\w*)[\'"]*$~', $input, $match)) {
+ return $match[1];
+ }
+ return false;
}
/**
- * push current file and line offset on stack for tracing {block} source lines
+ * Get variable name from string
+ *
+ * @param string $input
*
- * @param string $file new filename
- * @param string $uid uid of file
- * @param int $line line offset to source
- * @param bool $debug false debug end_compile shall not be called
+ * @return bool|string
*/
- public function pushTrace($file, $uid, $line, $debug = true)
+ public function getVariableName($input)
{
- if ($this->smarty->debugging && $debug) {
- Smarty_Internal_Debug::end_compile($this->template);
- }
- array_push($this->trace_stack, array($this->smarty->_current_file, $this->trace_filepath, $this->trace_uid, $this->trace_line_offset));
- $this->trace_filepath = $this->smarty->_current_file = $file;
- $this->trace_uid = $uid;
- $this->trace_line_offset = $line;
- if ($this->smarty->debugging) {
- Smarty_Internal_Debug::start_compile($this->template);
+ if (preg_match('~^[$]_smarty_tpl->tpl_vars\[[\'"]*([0-9]*[a-zA-Z_]\w*)[\'"]*\]->value$~', $input, $match)) {
+ return $match[1];
}
+ return false;
}
/**
- * restore file and line offset
+ * Generate nocache code string
+ *
+ * @param string $code PHP code
+ *
+ * @return string
*/
- public function popTrace()
+ public function makeNocacheCode($code)
{
- if ($this->smarty->debugging) {
- Smarty_Internal_Debug::end_compile($this->template);
- }
- $r = array_pop($this->trace_stack);
- $this->smarty->_current_file = $r[0];
- $this->trace_filepath = $r[1];
- $this->trace_uid = $r[2];
- $this->trace_line_offset = $r[3];
- if ($this->smarty->debugging) {
- Smarty_Internal_Debug::start_compile($this->template);
- }
+ return "echo '/*%%SmartyNocache:{$this->nocache_hash}%%*/<?php " .
+ str_replace("^#^", "'", addcslashes($code, '\'\\')) . "?>/*/%%SmartyNocache:{$this->nocache_hash}%%*/';\n";
}
/**
@@ -981,33 +1050,53 @@ abstract class Smarty_Internal_TemplateCompilerBase
* In this case the parser is called to obtain information about expected tokens.
* If parameter $args contains a string this is used as error message
*
- * @param string $args individual error message or null
- * @param string $line line-number
+ * @param string $args individual error message or null
+ * @param string $line line-number
+ * @param null|bool $tagline if true the line number of last tag
*
- * @throws SmartyCompilerException when an unexpected token is found
+ * @throws \SmartyCompilerException when an unexpected token is found
*/
- public function trigger_template_error($args = null, $line = null)
+ public function trigger_template_error($args = null, $line = null, $tagline = null)
{
- // get template source line which has error
- if (!isset($line)) {
- $line = $this->lex->line;
+ $lex = $this->parser->lex;
+ if ($tagline === true) {
+ // get line number of Tag
+ $line = $lex->taglineno;
+ } elseif (!isset($line)) {
+ // get template source line which has error
+ $line = $lex->line;
+ } else {
+ $line = (int) $line;
}
+
+ if (in_array($this->template->source->type, array('eval', 'string'))) {
+ $templateName = $this->template->source->type . ':' . trim(preg_replace('![\t\r\n]+!', ' ',
+ strlen($lex->data) > 40 ?
+ substr($lex->data, 0, 40) .
+ '...' : $lex->data));
+ } else {
+ $templateName = $this->template->source->type . ':' . $this->template->source->filepath;
+ }
+
// $line += $this->trace_line_offset;
- $match = preg_split("/\n/", $this->lex->data);
- $error_text = 'Syntax error in template "' . (empty($this->trace_filepath) ? $this->template->source->filepath : $this->trace_filepath) . '" on line ' . ($line + $this->trace_line_offset) . ' "' . trim(preg_replace('![\t\r\n]+!', ' ', $match[$line - 1])) . '" ';
+ $match = preg_split("/\n/", $lex->data);
+ $error_text =
+ 'Syntax error in template "' . (empty($this->trace_filepath) ? $templateName : $this->trace_filepath) .
+ '" on line ' . ($line + $this->trace_line_offset) . ' "' .
+ trim(preg_replace('![\t\r\n]+!', ' ', $match[$line - 1])) . '" ';
if (isset($args)) {
// individual error message
$error_text .= $args;
} else {
$expect = array();
// expected token from parser
- $error_text .= ' - Unexpected "' . $this->lex->value . '"';
+ $error_text .= ' - Unexpected "' . $lex->value . '"';
if (count($this->parser->yy_get_expected_tokens($this->parser->yymajor)) <= 4) {
foreach ($this->parser->yy_get_expected_tokens($this->parser->yymajor) as $token) {
$exp_token = $this->parser->yyTokenName[$token];
- if (isset($this->lex->smarty_token_names[$exp_token])) {
+ if (isset($lex->smarty_token_names[$exp_token])) {
// token type from lexer
- $expect[] = '"' . $this->lex->smarty_token_names[$exp_token] . '"';
+ $expect[] = '"' . $lex->smarty_token_names[$exp_token] . '"';
} else {
// otherwise internal token name
$expect[] = $this->parser->yyTokenName[$token];
diff --git a/library/Smarty/libs/sysplugins/smarty_internal_templatelexer.php b/library/Smarty/libs/sysplugins/smarty_internal_templatelexer.php
index abf81d087..993b7be62 100644
--- a/library/Smarty/libs/sysplugins/smarty_internal_templatelexer.php
+++ b/library/Smarty/libs/sysplugins/smarty_internal_templatelexer.php
@@ -1,11 +1,11 @@
<?php
-/**
- * Smarty Internal Plugin Templatelexer
- * This is the lexer to break the template source into tokens
+/*
+ * This file is part of Smarty.
+ *
+ * (c) 2015 Uwe Tews
*
- * @package Smarty
- * @subpackage Compiler
- * @author Uwe Tews
+ * For the full copyright and license information, please view the LICENSE
+ * file that was distributed with this source code.
*/
/**
@@ -13,9 +13,8 @@
* This is the template file lexer.
* It is generated from the smarty_internal_templatelexer.plex file
*
- * @package Smarty
- * @subpackage Compiler
- * @author Uwe Tews
+ *
+ * @author Uwe Tews <uwe.tews@googlemail.com>
*/
class Smarty_Internal_Templatelexer
{
@@ -156,8 +155,7 @@ class Smarty_Internal_Templatelexer
*
* @var array
*/
- public $state_name = array(1 => 'TEXT', 2 => 'TAG', 3 => 'TAGBODY', 4 => 'LITERAL', 5 => 'DOUBLEQUOTEDSTRING',
- 6 => 'CHILDBODY', 7 => 'CHILDBLOCK', 8 => 'CHILDLITERAL');
+ public $state_name = array(1 => 'TEXT', 2 => 'TAG', 3 => 'TAGBODY', 4 => 'LITERAL', 5 => 'DOUBLEQUOTEDSTRING',);
/**
* storage for assembled token patterns
@@ -174,27 +172,27 @@ class Smarty_Internal_Templatelexer
private $yy_global_pattern5 = null;
- private $yy_global_pattern6 = null;
-
- private $yy_global_pattern7 = null;
-
- private $yy_global_pattern8 = null;
-
/**
* token names
*
* @var array
*/
public $smarty_token_names = array( // Text for parser error messages
- 'NOT' => '(!,not)', 'OPENP' => '(', 'CLOSEP' => ')', 'OPENB' => '[', 'CLOSEB' => ']', 'PTR' => '->',
- 'APTR' => '=>', 'EQUAL' => '=', 'NUMBER' => 'number', 'UNIMATH' => '+" , "-', 'MATH' => '*" , "/" , "%',
- 'INCDEC' => '++" , "--', 'SPACE' => ' ', 'DOLLAR' => '$', 'SEMICOLON' => ';', 'COLON' => ':',
- 'DOUBLECOLON' => '::', 'AT' => '@', 'HATCH' => '#', 'QUOTE' => '"', 'BACKTICK' => '`', 'VERT' => '"|" modifier',
- 'DOT' => '.', 'COMMA' => '","', 'QMARK' => '"?"', 'ID' => 'id, name', 'TEXT' => 'text',
- 'LDELSLASH' => '{/..} closing tag', 'LDEL' => '{...} Smarty tag', 'COMMENT' => 'comment', 'AS' => 'as',
- 'TO' => 'to', 'PHP' => '"<?php", "<%", "{php}" tag', 'LOGOP' => '"<", "==" ... logical operator',
- 'TLOGOP' => '"lt", "eq" ... logical operator; "is div by" ... if condition',
- 'SCOND' => '"is even" ... if condition',);
+ 'NOT' => '(!,not)', 'OPENP' => '(', 'CLOSEP' => ')',
+ 'OPENB' => '[', 'CLOSEB' => ']', 'PTR' => '->', 'APTR' => '=>',
+ 'EQUAL' => '=', 'NUMBER' => 'number', 'UNIMATH' => '+" , "-',
+ 'MATH' => '*" , "/" , "%', 'INCDEC' => '++" , "--',
+ 'SPACE' => ' ', 'DOLLAR' => '$', 'SEMICOLON' => ';',
+ 'COLON' => ':', 'DOUBLECOLON' => '::', 'AT' => '@', 'HATCH' => '#',
+ 'QUOTE' => '"', 'BACKTICK' => '`', 'VERT' => '"|" modifier',
+ 'DOT' => '.', 'COMMA' => '","', 'QMARK' => '"?"',
+ 'ID' => 'id, name', 'TEXT' => 'text',
+ 'LDELSLASH' => '{/..} closing tag', 'LDEL' => '{...} Smarty tag',
+ 'COMMENT' => 'comment', 'AS' => 'as', 'TO' => 'to',
+ 'PHP' => '"<?php", "<%", "{php}" tag',
+ 'LOGOP' => '"<", "==" ... logical operator',
+ 'TLOGOP' => '"lt", "eq" ... logical operator; "is div by" ... if condition',
+ 'SCOND' => '"is even" ... if condition',);
/**
* constructor
@@ -207,7 +205,7 @@ class Smarty_Internal_Templatelexer
$this->data = $data;
$this->counter = 0;
if (preg_match('~^\xEF\xBB\xBF~i', $this->data, $match)) {
- $this->counter += strlen($match[0]);
+ $this->counter += strlen($match[ 0 ]);
}
$this->line = 1;
$this->smarty = $compiler->smarty;
@@ -216,8 +214,8 @@ class Smarty_Internal_Templatelexer
$this->ldel_length = strlen($this->smarty->left_delimiter);
$this->rdel = preg_quote($this->smarty->right_delimiter, '~');
$this->rdel_length = strlen($this->smarty->right_delimiter);
- $this->smarty_token_names['LDEL'] = $this->smarty->left_delimiter;
- $this->smarty_token_names['RDEL'] = $this->smarty->right_delimiter;
+ $this->smarty_token_names[ 'LDEL' ] = $this->smarty->left_delimiter;
+ $this->smarty_token_names[ 'RDEL' ] = $this->smarty->right_delimiter;
}
public function PrintTrace()
@@ -231,7 +229,8 @@ class Smarty_Internal_Templatelexer
*/
public function isAutoLiteral()
{
- return $this->smarty->auto_literal && isset($this->value[$this->ldel_length]) ? strpos(" \n\t\r", $this->value[$this->ldel_length]) !== false : false;
+ return $this->smarty->auto_literal && isset($this->value[ $this->ldel_length ]) ?
+ strpos(" \n\t\r", $this->value[ $this->ldel_length ]) !== false : false;
}
private $_yy_state = 1;
@@ -246,23 +245,31 @@ class Smarty_Internal_Templatelexer
public function yypushstate($state)
{
if ($this->yyTraceFILE) {
- fprintf($this->yyTraceFILE, "%sState push %s\n", $this->yyTracePrompt, isset($this->state_name[$this->_yy_state]) ? $this->state_name[$this->_yy_state] : $this->_yy_state);
+ fprintf($this->yyTraceFILE, "%sState push %s\n", $this->yyTracePrompt,
+ isset($this->state_name[ $this->_yy_state ]) ? $this->state_name[ $this->_yy_state ] :
+ $this->_yy_state);
}
array_push($this->_yy_stack, $this->_yy_state);
$this->_yy_state = $state;
if ($this->yyTraceFILE) {
- fprintf($this->yyTraceFILE, "%snew State %s\n", $this->yyTracePrompt, isset($this->state_name[$this->_yy_state]) ? $this->state_name[$this->_yy_state] : $this->_yy_state);
+ fprintf($this->yyTraceFILE, "%snew State %s\n", $this->yyTracePrompt,
+ isset($this->state_name[ $this->_yy_state ]) ? $this->state_name[ $this->_yy_state ] :
+ $this->_yy_state);
}
}
public function yypopstate()
{
if ($this->yyTraceFILE) {
- fprintf($this->yyTraceFILE, "%sState pop %s\n", $this->yyTracePrompt, isset($this->state_name[$this->_yy_state]) ? $this->state_name[$this->_yy_state] : $this->_yy_state);
+ fprintf($this->yyTraceFILE, "%sState pop %s\n", $this->yyTracePrompt,
+ isset($this->state_name[ $this->_yy_state ]) ? $this->state_name[ $this->_yy_state ] :
+ $this->_yy_state);
}
$this->_yy_state = array_pop($this->_yy_stack);
if ($this->yyTraceFILE) {
- fprintf($this->yyTraceFILE, "%snew State %s\n", $this->yyTracePrompt, isset($this->state_name[$this->_yy_state]) ? $this->state_name[$this->_yy_state] : $this->_yy_state);
+ fprintf($this->yyTraceFILE, "%snew State %s\n", $this->yyTracePrompt,
+ isset($this->state_name[ $this->_yy_state ]) ? $this->state_name[ $this->_yy_state ] :
+ $this->_yy_state);
}
}
@@ -270,14 +277,20 @@ class Smarty_Internal_Templatelexer
{
$this->_yy_state = $state;
if ($this->yyTraceFILE) {
- fprintf($this->yyTraceFILE, "%sState set %s\n", $this->yyTracePrompt, isset($this->state_name[$this->_yy_state]) ? $this->state_name[$this->_yy_state] : $this->_yy_state);
+ fprintf($this->yyTraceFILE, "%sState set %s\n", $this->yyTracePrompt,
+ isset($this->state_name[ $this->_yy_state ]) ? $this->state_name[ $this->_yy_state ] :
+ $this->_yy_state);
}
}
public function yylex1()
{
if (!isset($this->yy_global_pattern1)) {
- $this->yy_global_pattern1 = "/\G([{][}])|\G(" . $this->ldel . "[*])|\G((<[?]((php\\s+|=)|\\s+))|(<[%])|(<[?]xml\\s+)|(<script\\s+language\\s*=\\s*[\"']?\\s*php\\s*[\"']?\\s*>)|([?][>])|([%][>])|(" . $this->ldel . "\\s*php(.*?)" . $this->rdel . ")|(" . $this->ldel . "\\s*[\/]php" . $this->rdel . "))|\G(" . $this->ldel . "\\s*literal\\s*" . $this->rdel . ")|\G(" . $this->ldel . "\\s*)|\G(\\s*" . $this->rdel . ")|\G([\S\s])/isS";
+ $this->yy_global_pattern1 =
+ "/\G([{][}])|\G(" . $this->ldel . "[*])|\G((" . $this->ldel . "\\s*php(.*?)" . $this->rdel . ")|(" .
+ $this->ldel . "\\s*[\/]php" . $this->rdel . "))|\G(" . $this->ldel . "\\s*literal\\s*" . $this->rdel .
+ ")|\G(" . $this->ldel . "\\s*)|\G(\\s*" . $this->rdel .
+ ")|\G((<[?]((php\\s+|=)|\\s+))|(<[%])|(<[?]xml\\s+)|(<script\\s+language\\s*=\\s*[\"']?\\s*php\\s*[\"']?\\s*>)|([?][>])|([%][>]))|\G([\S\s])/isS";
}
if ($this->counter >= strlen($this->data)) {
return false; // end of input
@@ -286,13 +299,14 @@ class Smarty_Internal_Templatelexer
do {
if (preg_match($this->yy_global_pattern1, $this->data, $yymatches, null, $this->counter)) {
$yysubmatches = $yymatches;
- if (strlen($yysubmatches[0]) < 200) {
+ if (strlen($yysubmatches[ 0 ]) < 200) {
$yymatches = preg_grep("/(.|\s)+/", $yysubmatches);
} else {
$yymatches = array_filter($yymatches, 'strlen');
}
if (empty($yymatches)) {
- throw new Exception('Error: lexing failed because a rule matched' . ' an empty string. Input "' . substr($this->data, $this->counter, 5) . '... state TEXT');
+ throw new Exception('Error: lexing failed because a rule matched' . ' an empty string. Input "' .
+ substr($this->data, $this->counter, 5) . '... state TEXT');
}
next($yymatches); // skip global match
$this->token = key($yymatches); // token number
@@ -317,7 +331,7 @@ class Smarty_Internal_Templatelexer
continue;
}
} else {
- throw new Exception('Unexpected input at line' . $this->line . ': ' . $this->data[$this->counter]);
+ throw new Exception('Unexpected input at line' . $this->line . ': ' . $this->data[ $this->counter ]);
}
break;
} while (true);
@@ -335,8 +349,8 @@ class Smarty_Internal_Templatelexer
{
preg_match("~[*]{$this->rdel}~", $this->data, $match, PREG_OFFSET_CAPTURE, $this->counter);
- if (isset($match[0][1])) {
- $to = $match[0][1] + strlen($match[0][0]);
+ if (isset($match[ 0 ][ 1 ])) {
+ $to = $match[ 0 ][ 1 ] + strlen($match[ 0 ][ 0 ]);
} else {
$this->compiler->trigger_template_error("missing or misspelled comment closing tag '*{$this->smarty->right_delimiter}'");
}
@@ -351,10 +365,12 @@ class Smarty_Internal_Templatelexer
$obj->parsePhp($this);
}
- function yy_r1_15()
+ function yy_r1_7()
{
- if ($this->smarty->auto_literal && isset($this->value[$this->ldel_length]) ? strpos(" \n\t\r", $this->value[$this->ldel_length]) !== false : false) {
+ if ($this->smarty->auto_literal && isset($this->value[ $this->ldel_length ]) ?
+ strpos(" \n\t\r", $this->value[ $this->ldel_length ]) !== false : false
+ ) {
$this->token = Smarty_Internal_Templateparser::TP_TEXT;
} else {
$this->token = Smarty_Internal_Templateparser::TP_LITERALSTART;
@@ -362,10 +378,12 @@ class Smarty_Internal_Templatelexer
}
}
- function yy_r1_16()
+ function yy_r1_8()
{
- if ($this->smarty->auto_literal && isset($this->value[$this->ldel_length]) ? strpos(" \n\t\r", $this->value[$this->ldel_length]) !== false : false) {
+ if ($this->smarty->auto_literal && isset($this->value[ $this->ldel_length ]) ?
+ strpos(" \n\t\r", $this->value[ $this->ldel_length ]) !== false : false
+ ) {
$this->token = Smarty_Internal_Templateparser::TP_TEXT;
} else {
$this->yypushstate(self::TAG);
@@ -373,19 +391,27 @@ class Smarty_Internal_Templatelexer
}
}
- function yy_r1_17()
+ function yy_r1_9()
{
$this->token = Smarty_Internal_Templateparser::TP_TEXT;
}
- function yy_r1_18()
+ function yy_r1_10()
+ {
+
+ $obj = new Smarty_Internal_Compile_Private_Php();
+ $obj->parsePhp($this);
+ }
+
+ function yy_r1_19()
{
$to = strlen($this->data);
- preg_match("~($this->ldel)|([<]script\s+language\s*=\s*[\"\']?\s*php\s*[\"\']?\s*[>])|([<][?])|([<][%])|([?][>])|([%][>])~i", $this->data, $match, PREG_OFFSET_CAPTURE, $this->counter);
- if (isset($match[0][1])) {
- $to = $match[0][1];
+ preg_match("~($this->ldel)|(<[?]((php\s+|=)|\s+))|(<[%])|(<[?]xml\s+)|(<script\s+language\s*=\s*[\"']?\s*php\s*[\"']?\s*>)|([?][>])|([%][>])~i",
+ $this->data, $match, PREG_OFFSET_CAPTURE, $this->counter);
+ if (isset($match[ 0 ][ 1 ])) {
+ $to = $match[ 0 ][ 1 ];
}
$this->value = substr($this->data, $this->counter, $to - $this->counter);
$this->token = Smarty_Internal_Templateparser::TP_TEXT;
@@ -394,7 +420,13 @@ class Smarty_Internal_Templatelexer
public function yylex2()
{
if (!isset($this->yy_global_pattern2)) {
- $this->yy_global_pattern2 = "/\G(" . $this->ldel . "\\s*(if|elseif|else if|while)\\s+)|\G(" . $this->ldel . "\\s*for\\s+)|\G(" . $this->ldel . "\\s*foreach(?![^\s]))|\G(" . $this->ldel . "\\s*setfilter\\s+)|\G(" . $this->ldel . "\\s*[0-9]*[a-zA-Z_]\\w*(\\s+nocache)?\\s*" . $this->rdel . ")|\G(" . $this->ldel . "\\s*[\/](?:(?!block)[0-9]*[a-zA-Z_]\\w*)\\s*" . $this->rdel . ")|\G(" . $this->ldel . "\\s*[$][0-9]*[a-zA-Z_]\\w*(\\s+nocache)?\\s*" . $this->rdel . ")|\G(" . $this->ldel . "\\s*[\/])|\G(" . $this->ldel . "\\s*)/isS";
+ $this->yy_global_pattern2 =
+ "/\G(" . $this->ldel . "\\s*(if|elseif|else if|while)\\s+)|\G(" . $this->ldel . "\\s*for\\s+)|\G(" .
+ $this->ldel . "\\s*foreach(?![^\s]))|\G(" . $this->ldel . "\\s*setfilter\\s+)|\G(" . $this->ldel .
+ "\\s*[0-9]*[a-zA-Z_]\\w*(\\s+nocache)?\\s*" . $this->rdel . ")|\G(" . $this->ldel .
+ "\\s*[\/](?:(?!block)[0-9]*[a-zA-Z_]\\w*)\\s*" . $this->rdel . ")|\G(" . $this->ldel .
+ "\\s*[$][0-9]*[a-zA-Z_]\\w*(\\s+nocache)?\\s*" . $this->rdel . ")|\G(" . $this->ldel . "\\s*[\/])|\G(" .
+ $this->ldel . "\\s*)/isS";
}
if ($this->counter >= strlen($this->data)) {
return false; // end of input
@@ -403,13 +435,14 @@ class Smarty_Internal_Templatelexer
do {
if (preg_match($this->yy_global_pattern2, $this->data, $yymatches, null, $this->counter)) {
$yysubmatches = $yymatches;
- if (strlen($yysubmatches[0]) < 200) {
+ if (strlen($yysubmatches[ 0 ]) < 200) {
$yymatches = preg_grep("/(.|\s)+/", $yysubmatches);
} else {
$yymatches = array_filter($yymatches, 'strlen');
}
if (empty($yymatches)) {
- throw new Exception('Error: lexing failed because a rule matched' . ' an empty string. Input "' . substr($this->data, $this->counter, 5) . '... state TAG');
+ throw new Exception('Error: lexing failed because a rule matched' . ' an empty string. Input "' .
+ substr($this->data, $this->counter, 5) . '... state TAG');
}
next($yymatches); // skip global match
$this->token = key($yymatches); // token number
@@ -434,7 +467,7 @@ class Smarty_Internal_Templatelexer
continue;
}
} else {
- throw new Exception('Unexpected input at line' . $this->line . ': ' . $this->data[$this->counter]);
+ throw new Exception('Unexpected input at line' . $this->line . ': ' . $this->data[ $this->counter ]);
}
break;
} while (true);
@@ -493,9 +526,9 @@ class Smarty_Internal_Templatelexer
function yy_r2_9()
{
- if ($this->_yy_stack[count($this->_yy_stack) - 1] == self::TEXT) {
+ if ($this->_yy_stack[ count($this->_yy_stack) - 1 ] == self::TEXT) {
$this->yypopstate();
- $this->token = Smarty_Internal_Templateparser::TP_SIMPLEOUTPUT;
+ $this->token = Smarty_Internal_Templateparser::TP_SIMPELOUTPUT;
$this->taglineno = $this->line;
} else {
$this->value = $this->smarty->left_delimiter;
@@ -524,7 +557,8 @@ class Smarty_Internal_Templatelexer
public function yylex3()
{
if (!isset($this->yy_global_pattern3)) {
- $this->yy_global_pattern3 = "/\G(\\s*" . $this->rdel . ")|\G([\"])|\G('[^'\\\\]*(?:\\\\.[^'\\\\]*)*')|\G([$]smarty\\.block\\.(child|parent))|\G([$][0-9]*[a-zA-Z_]\\w*)|\G([$])|\G(\\s+is\\s+in\\s+)|\G(\\s+as\\s+)|\G(\\s+to\\s+)|\G(\\s+step\\s+)|\G(\\s+instanceof\\s+)|\G(\\s*(([!=][=]{1,2})|([<][=>]?)|([>][=]?)|[&|]{2})\\s*)|\G(\\s+(eq|ne|neq|gt|ge|gte|lt|le|lte|mod|and|or|xor|(is\\s+(not\\s+)?(odd|even|div)\\s+by))\\s+)|\G(\\s+is\\s+(not\\s+)?(odd|even))|\G(([!]\\s*)|(not\\s+))|\G([(](int(eger)?|bool(ean)?|float|double|real|string|binary|array|object)[)]\\s*)|\G(\\s*[(]\\s*)|\G(\\s*[)])|\G(\\[\\s*)|\G(\\s*\\])|\G(\\s*[-][>]\\s*)|\G(\\s*[=][>]\\s*)|\G(\\s*[=]\\s*)|\G(([+]|[-]){2})|\G(\\s*([+]|[-])\\s*)|\G(\\s*([*]{1,2}|[%\/^&]|[<>]{2})\\s*)|\G([@])|\G([#])|\G(\\s+[0-9]*[a-zA-Z_][a-zA-Z0-9_\-:]*\\s*[=]\\s*)|\G(([0-9]*[a-zA-Z_]\\w*)?(\\\\[0-9]*[a-zA-Z_]\\w*)+)|\G([0-9]*[a-zA-Z_]\\w*)|\G(\\d+)|\G([`])|\G([|])|\G([.])|\G(\\s*[,]\\s*)|\G(\\s*[;]\\s*)|\G([:]{2})|\G(\\s*[:]\\s*)|\G(\\s*[?]\\s*)|\G(0[xX][0-9a-fA-F]+)|\G(\\s+)|\G(" . $this->ldel . "\\s*)|\G([\S\s])/isS";
+ $this->yy_global_pattern3 = "/\G(\\s*" . $this->rdel . ")|\G(" . $this->ldel .
+ "\\s*)|\G([\"])|\G('[^'\\\\]*(?:\\\\.[^'\\\\]*)*')|\G([$]smarty\\.block\\.(child|parent))|\G([$][0-9]*[a-zA-Z_]\\w*)|\G([$])|\G(\\s+is\\s+in\\s+)|\G(\\s+as\\s+)|\G(\\s+to\\s+)|\G(\\s+step\\s+)|\G(\\s+instanceof\\s+)|\G(\\s*(([!=][=]{1,2})|([<][=>]?)|([>][=]?)|[&|]{2})\\s*)|\G(\\s+(eq|ne|neq|gt|ge|gte|lt|le|lte|mod|and|or|xor|(is\\s+(not\\s+)?(odd|even|div)\\s+by))\\s+)|\G(\\s+is\\s+(not\\s+)?(odd|even))|\G(([!]\\s*)|(not\\s+))|\G([(](int(eger)?|bool(ean)?|float|double|real|string|binary|array|object)[)]\\s*)|\G(\\s*[(]\\s*)|\G(\\s*[)])|\G(\\[\\s*)|\G(\\s*\\])|\G(\\s*[-][>]\\s*)|\G(\\s*[=][>]\\s*)|\G(\\s*[=]\\s*)|\G(([+]|[-]){2})|\G(\\s*([+]|[-])\\s*)|\G(\\s*([*]{1,2}|[%\/^&]|[<>]{2})\\s*)|\G([@])|\G([#])|\G(\\s+[0-9]*[a-zA-Z_][a-zA-Z0-9_\-:]*\\s*[=]\\s*)|\G(([0-9]*[a-zA-Z_]\\w*)?(\\\\[0-9]*[a-zA-Z_]\\w*)+)|\G([0-9]*[a-zA-Z_]\\w*)|\G(\\d+)|\G([`])|\G([|])|\G([.])|\G(\\s*[,]\\s*)|\G(\\s*[;]\\s*)|\G([:]{2})|\G(\\s*[:]\\s*)|\G(\\s*[?]\\s*)|\G(0[xX][0-9a-fA-F]+)|\G(\\s+)|\G([\S\s])/isS";
}
if ($this->counter >= strlen($this->data)) {
return false; // end of input
@@ -533,13 +567,14 @@ class Smarty_Internal_Templatelexer
do {
if (preg_match($this->yy_global_pattern3, $this->data, $yymatches, null, $this->counter)) {
$yysubmatches = $yymatches;
- if (strlen($yysubmatches[0]) < 200) {
+ if (strlen($yysubmatches[ 0 ]) < 200) {
$yymatches = preg_grep("/(.|\s)+/", $yysubmatches);
} else {
$yymatches = array_filter($yymatches, 'strlen');
}
if (empty($yymatches)) {
- throw new Exception('Error: lexing failed because a rule matched' . ' an empty string. Input "' . substr($this->data, $this->counter, 5) . '... state TAGBODY ');
+ throw new Exception('Error: lexing failed because a rule matched' . ' an empty string. Input "' .
+ substr($this->data, $this->counter, 5) . '... state TAGBODY');
}
next($yymatches); // skip global match
$this->token = key($yymatches); // token number
@@ -564,7 +599,7 @@ class Smarty_Internal_Templatelexer
continue;
}
} else {
- throw new Exception('Unexpected input at line' . $this->line . ': ' . $this->data[$this->counter]);
+ throw new Exception('Unexpected input at line' . $this->line . ': ' . $this->data[ $this->counter ]);
}
break;
} while (true);
@@ -582,268 +617,272 @@ class Smarty_Internal_Templatelexer
function yy_r3_2()
{
+ if ($this->smarty->auto_literal && isset($this->value[ $this->ldel_length ]) ?
+ strpos(" \n\t\r", $this->value[ $this->ldel_length ]) !== false : false
+ ) {
+ $this->token = Smarty_Internal_Templateparser::TP_TEXT;
+ } else {
+ $this->yypushstate(self::TAG);
+ return true;
+ }
+ }
+
+ function yy_r3_3()
+ {
+
$this->token = Smarty_Internal_Templateparser::TP_QUOTE;
$this->yypushstate(self::DOUBLEQUOTEDSTRING);
}
- function yy_r3_3()
+ function yy_r3_4()
{
$this->token = Smarty_Internal_Templateparser::TP_SINGLEQUOTESTRING;
}
- function yy_r3_4()
+ function yy_r3_5()
{
$this->token = Smarty_Internal_Templateparser::TP_SMARTYBLOCKCHILDPARENT;
$this->taglineno = $this->line;
}
- function yy_r3_6()
+ function yy_r3_7()
{
$this->token = Smarty_Internal_Templateparser::TP_DOLLARID;
}
- function yy_r3_7()
+ function yy_r3_8()
{
$this->token = Smarty_Internal_Templateparser::TP_DOLLAR;
}
- function yy_r3_8()
+ function yy_r3_9()
{
$this->token = Smarty_Internal_Templateparser::TP_ISIN;
}
- function yy_r3_9()
+ function yy_r3_10()
{
$this->token = Smarty_Internal_Templateparser::TP_AS;
}
- function yy_r3_10()
+ function yy_r3_11()
{
$this->token = Smarty_Internal_Templateparser::TP_TO;
}
- function yy_r3_11()
+ function yy_r3_12()
{
$this->token = Smarty_Internal_Templateparser::TP_STEP;
}
- function yy_r3_12()
+ function yy_r3_13()
{
$this->token = Smarty_Internal_Templateparser::TP_INSTANCEOF;
}
- function yy_r3_13()
+ function yy_r3_14()
{
$this->token = Smarty_Internal_Templateparser::TP_LOGOP;
}
- function yy_r3_18()
+ function yy_r3_19()
{
$this->token = Smarty_Internal_Templateparser::TP_TLOGOP;
}
- function yy_r3_23()
+ function yy_r3_24()
{
$this->token = Smarty_Internal_Templateparser::TP_SINGLECOND;
}
- function yy_r3_26()
+ function yy_r3_27()
{
$this->token = Smarty_Internal_Templateparser::TP_NOT;
}
- function yy_r3_29()
+ function yy_r3_30()
{
$this->token = Smarty_Internal_Templateparser::TP_TYPECAST;
}
- function yy_r3_33()
+ function yy_r3_34()
{
$this->token = Smarty_Internal_Templateparser::TP_OPENP;
}
- function yy_r3_34()
+ function yy_r3_35()
{
$this->token = Smarty_Internal_Templateparser::TP_CLOSEP;
}
- function yy_r3_35()
+ function yy_r3_36()
{
$this->token = Smarty_Internal_Templateparser::TP_OPENB;
}
- function yy_r3_36()
+ function yy_r3_37()
{
$this->token = Smarty_Internal_Templateparser::TP_CLOSEB;
}
- function yy_r3_37()
+ function yy_r3_38()
{
$this->token = Smarty_Internal_Templateparser::TP_PTR;
}
- function yy_r3_38()
+ function yy_r3_39()
{
$this->token = Smarty_Internal_Templateparser::TP_APTR;
}
- function yy_r3_39()
+ function yy_r3_40()
{
$this->token = Smarty_Internal_Templateparser::TP_EQUAL;
}
- function yy_r3_40()
+ function yy_r3_41()
{
$this->token = Smarty_Internal_Templateparser::TP_INCDEC;
}
- function yy_r3_42()
+ function yy_r3_43()
{
$this->token = Smarty_Internal_Templateparser::TP_UNIMATH;
}
- function yy_r3_44()
+ function yy_r3_45()
{
$this->token = Smarty_Internal_Templateparser::TP_MATH;
}
- function yy_r3_46()
+ function yy_r3_47()
{
$this->token = Smarty_Internal_Templateparser::TP_AT;
}
- function yy_r3_47()
+ function yy_r3_48()
{
$this->token = Smarty_Internal_Templateparser::TP_HATCH;
}
- function yy_r3_48()
+ function yy_r3_49()
{
// resolve conflicts with shorttag and right_delimiter starting with '='
- if (substr($this->data, $this->counter + strlen($this->value) - 1, $this->rdel_length) == $this->smarty->right_delimiter) {
+ if (substr($this->data, $this->counter + strlen($this->value) - 1, $this->rdel_length) ==
+ $this->smarty->right_delimiter
+ ) {
preg_match("~\s+~", $this->value, $match);
- $this->value = $match[0];
+ $this->value = $match[ 0 ];
$this->token = Smarty_Internal_Templateparser::TP_SPACE;
} else {
$this->token = Smarty_Internal_Templateparser::TP_ATTR;
}
}
- function yy_r3_49()
+ function yy_r3_50()
{
$this->token = Smarty_Internal_Templateparser::TP_NAMESPACE;
}
- function yy_r3_52()
+ function yy_r3_53()
{
$this->token = Smarty_Internal_Templateparser::TP_ID;
}
- function yy_r3_53()
+ function yy_r3_54()
{
$this->token = Smarty_Internal_Templateparser::TP_INTEGER;
}
- function yy_r3_54()
+ function yy_r3_55()
{
$this->token = Smarty_Internal_Templateparser::TP_BACKTICK;
$this->yypopstate();
}
- function yy_r3_55()
- {
-
- $this->token = Smarty_Internal_Templateparser::TP_VERT;
- }
-
function yy_r3_56()
{
- $this->token = Smarty_Internal_Templateparser::TP_DOT;
+ $this->token = Smarty_Internal_Templateparser::TP_VERT;
}
function yy_r3_57()
{
- $this->token = Smarty_Internal_Templateparser::TP_COMMA;
+ $this->token = Smarty_Internal_Templateparser::TP_DOT;
}
function yy_r3_58()
{
- $this->token = Smarty_Internal_Templateparser::TP_SEMICOLON;
+ $this->token = Smarty_Internal_Templateparser::TP_COMMA;
}
function yy_r3_59()
{
- $this->token = Smarty_Internal_Templateparser::TP_DOUBLECOLON;
+ $this->token = Smarty_Internal_Templateparser::TP_SEMICOLON;
}
function yy_r3_60()
{
- $this->token = Smarty_Internal_Templateparser::TP_COLON;
+ $this->token = Smarty_Internal_Templateparser::TP_DOUBLECOLON;
}
function yy_r3_61()
{
- $this->token = Smarty_Internal_Templateparser::TP_QMARK;
+ $this->token = Smarty_Internal_Templateparser::TP_COLON;
}
function yy_r3_62()
{
- $this->token = Smarty_Internal_Templateparser::TP_HEX;
+ $this->token = Smarty_Internal_Templateparser::TP_QMARK;
}
function yy_r3_63()
{
- $this->token = Smarty_Internal_Templateparser::TP_SPACE;
+ $this->token = Smarty_Internal_Templateparser::TP_HEX;
}
function yy_r3_64()
{
- if ($this->smarty->auto_literal && isset($this->value[$this->ldel_length]) ? strpos(" \n\t\r", $this->value[$this->ldel_length]) !== false : false) {
- $this->token = Smarty_Internal_Templateparser::TP_TEXT;
- } else {
- $this->yypushstate(self::TAG);
- return true;
- }
+ $this->token = Smarty_Internal_Templateparser::TP_SPACE;
}
function yy_r3_65()
@@ -855,7 +894,9 @@ class Smarty_Internal_Templatelexer
public function yylex4()
{
if (!isset($this->yy_global_pattern4)) {
- $this->yy_global_pattern4 = "/\G(" . $this->ldel . "\\s*literal\\s*" . $this->rdel . ")|\G(" . $this->ldel . "\\s*[\/]literal\\s*" . $this->rdel . ")|\G([\S\s])/isS";
+ $this->yy_global_pattern4 =
+ "/\G(" . $this->ldel . "\\s*literal\\s*" . $this->rdel . ")|\G(" . $this->ldel . "\\s*[\/]literal\\s*" .
+ $this->rdel . ")|\G([\S\s])/isS";
}
if ($this->counter >= strlen($this->data)) {
return false; // end of input
@@ -864,13 +905,14 @@ class Smarty_Internal_Templatelexer
do {
if (preg_match($this->yy_global_pattern4, $this->data, $yymatches, null, $this->counter)) {
$yysubmatches = $yymatches;
- if (strlen($yysubmatches[0]) < 200) {
+ if (strlen($yysubmatches[ 0 ]) < 200) {
$yymatches = preg_grep("/(.|\s)+/", $yysubmatches);
} else {
$yymatches = array_filter($yymatches, 'strlen');
}
if (empty($yymatches)) {
- throw new Exception('Error: lexing failed because a rule matched' . ' an empty string. Input "' . substr($this->data, $this->counter, 5) . '... state LITERAL');
+ throw new Exception('Error: lexing failed because a rule matched' . ' an empty string. Input "' .
+ substr($this->data, $this->counter, 5) . '... state LITERAL');
}
next($yymatches); // skip global match
$this->token = key($yymatches); // token number
@@ -895,7 +937,7 @@ class Smarty_Internal_Templatelexer
continue;
}
} else {
- throw new Exception('Unexpected input at line' . $this->line . ': ' . $this->data[$this->counter]);
+ throw new Exception('Unexpected input at line' . $this->line . ': ' . $this->data[ $this->counter ]);
}
break;
} while (true);
@@ -926,9 +968,10 @@ class Smarty_Internal_Templatelexer
{
$to = strlen($this->data);
- preg_match("~{$this->ldel}[/]?literal{$this->rdel}~i", $this->data, $match, PREG_OFFSET_CAPTURE, $this->counter);
- if (isset($match[0][1])) {
- $to = $match[0][1];
+ preg_match("~{$this->ldel}[/]?literal{$this->rdel}~i", $this->data, $match, PREG_OFFSET_CAPTURE,
+ $this->counter);
+ if (isset($match[ 0 ][ 1 ])) {
+ $to = $match[ 0 ][ 1 ];
} else {
$this->compiler->trigger_template_error("missing or misspelled literal closing tag");
}
@@ -939,7 +982,12 @@ class Smarty_Internal_Templatelexer
public function yylex5()
{
if (!isset($this->yy_global_pattern5)) {
- $this->yy_global_pattern5 = "/\G(" . $this->ldel . "\\s*literal\\s*" . $this->rdel . ")|\G(" . $this->ldel . "\\s*[\/]literal\\s*" . $this->rdel . ")|\G(" . $this->ldel . "\\s*[\/])|\G(" . $this->ldel . "\\s*[0-9]*[a-zA-Z_]\\w*)|\G(" . $this->ldel . "\\s*)|\G([\"])|\G([`][$])|\G([$][0-9]*[a-zA-Z_]\\w*)|\G([$])|\G(([^\"\\\\]*?)((?:\\\\.[^\"\\\\]*?)*?)(?=(" . $this->ldel . "|\\$|`\\$|\")))|\G([\S\s])/isS";
+ $this->yy_global_pattern5 =
+ "/\G(" . $this->ldel . "\\s*literal\\s*" . $this->rdel . ")|\G(" . $this->ldel . "\\s*[\/]literal\\s*" .
+ $this->rdel . ")|\G(" . $this->ldel . "\\s*[\/])|\G(" . $this->ldel . "\\s*[0-9]*[a-zA-Z_]\\w*)|\G(" .
+ $this->ldel .
+ "\\s*)|\G([\"])|\G([`][$])|\G([$][0-9]*[a-zA-Z_]\\w*)|\G([$])|\G(([^\"\\\\]*?)((?:\\\\.[^\"\\\\]*?)*?)(?=(" .
+ $this->ldel . "|\\$|`\\$|\")))|\G([\S\s])/isS";
}
if ($this->counter >= strlen($this->data)) {
return false; // end of input
@@ -948,13 +996,14 @@ class Smarty_Internal_Templatelexer
do {
if (preg_match($this->yy_global_pattern5, $this->data, $yymatches, null, $this->counter)) {
$yysubmatches = $yymatches;
- if (strlen($yysubmatches[0]) < 200) {
+ if (strlen($yysubmatches[ 0 ]) < 200) {
$yymatches = preg_grep("/(.|\s)+/", $yysubmatches);
} else {
$yymatches = array_filter($yymatches, 'strlen');
}
if (empty($yymatches)) {
- throw new Exception('Error: lexing failed because a rule matched' . ' an empty string. Input "' . substr($this->data, $this->counter, 5) . '... state DOUBLEQUOTEDSTRING');
+ throw new Exception('Error: lexing failed because a rule matched' . ' an empty string. Input "' .
+ substr($this->data, $this->counter, 5) . '... state DOUBLEQUOTEDSTRING');
}
next($yymatches); // skip global match
$this->token = key($yymatches); // token number
@@ -979,7 +1028,7 @@ class Smarty_Internal_Templatelexer
continue;
}
} else {
- throw new Exception('Unexpected input at line' . $this->line . ': ' . $this->data[$this->counter]);
+ throw new Exception('Unexpected input at line' . $this->line . ': ' . $this->data[ $this->counter ]);
}
break;
} while (true);
@@ -1002,7 +1051,9 @@ class Smarty_Internal_Templatelexer
function yy_r5_3()
{
- if ($this->smarty->auto_literal && isset($this->value[$this->ldel_length]) ? strpos(" \n\t\r", $this->value[$this->ldel_length]) !== false : false) {
+ if ($this->smarty->auto_literal && isset($this->value[ $this->ldel_length ]) ?
+ strpos(" \n\t\r", $this->value[ $this->ldel_length ]) !== false : false
+ ) {
$this->token = Smarty_Internal_Templateparser::TP_TEXT;
} else {
$this->yypushstate(self::TAG);
@@ -1013,7 +1064,9 @@ class Smarty_Internal_Templatelexer
function yy_r5_4()
{
- if ($this->smarty->auto_literal && isset($this->value[$this->ldel_length]) ? strpos(" \n\t\r", $this->value[$this->ldel_length]) !== false : false) {
+ if ($this->smarty->auto_literal && isset($this->value[ $this->ldel_length ]) ?
+ strpos(" \n\t\r", $this->value[ $this->ldel_length ]) !== false : false
+ ) {
$this->token = Smarty_Internal_Templateparser::TP_TEXT;
} else {
$this->yypushstate(self::TAG);
@@ -1024,7 +1077,9 @@ class Smarty_Internal_Templatelexer
function yy_r5_5()
{
- if ($this->smarty->auto_literal && isset($this->value[$this->ldel_length]) ? strpos(" \n\t\r", $this->value[$this->ldel_length]) !== false : false) {
+ if ($this->smarty->auto_literal && isset($this->value[ $this->ldel_length ]) ?
+ strpos(" \n\t\r", $this->value[ $this->ldel_length ]) !== false : false
+ ) {
$this->token = Smarty_Internal_Templateparser::TP_TEXT;
} else {
$this->token = Smarty_Internal_Templateparser::TP_LDEL;
@@ -1075,294 +1130,6 @@ class Smarty_Internal_Templatelexer
$this->token = Smarty_Internal_Templateparser::TP_TEXT;
}
- public function yylex6()
- {
- if (!isset($this->yy_global_pattern6)) {
- $this->yy_global_pattern6 = "/\G(" . $this->ldel . "\\s*strip\\s*" . $this->rdel . ")|\G(" . $this->ldel . "\\s*[\/]strip\\s*" . $this->rdel . ")|\G(" . $this->ldel . "\\s*block)|\G([\S\s])/isS";
- }
- if ($this->counter >= strlen($this->data)) {
- return false; // end of input
- }
-
- do {
- if (preg_match($this->yy_global_pattern6, $this->data, $yymatches, null, $this->counter)) {
- $yysubmatches = $yymatches;
- if (strlen($yysubmatches[0]) < 200) {
- $yymatches = preg_grep("/(.|\s)+/", $yysubmatches);
- } else {
- $yymatches = array_filter($yymatches, 'strlen');
- }
- if (empty($yymatches)) {
- throw new Exception('Error: lexing failed because a rule matched' . ' an empty string. Input "' . substr($this->data, $this->counter, 5) . '... state CHILDBODY');
- }
- next($yymatches); // skip global match
- $this->token = key($yymatches); // token number
- $this->value = current($yymatches); // token value
- $r = $this->{'yy_r6_' . $this->token}();
- if ($r === null) {
- $this->counter += strlen($this->value);
- $this->line += substr_count($this->value, "\n");
- // accept this token
- return true;
- } elseif ($r === true) {
- // we have changed state
- // process this token in the new state
- return $this->yylex();
- } elseif ($r === false) {
- $this->counter += strlen($this->value);
- $this->line += substr_count($this->value, "\n");
- if ($this->counter >= strlen($this->data)) {
- return false; // end of input
- }
- // skip this token
- continue;
- }
- } else {
- throw new Exception('Unexpected input at line' . $this->line . ': ' . $this->data[$this->counter]);
- }
- break;
- } while (true);
- } // end function
-
- const CHILDBODY = 6;
-
- function yy_r6_1()
- {
-
- if ($this->smarty->auto_literal && isset($this->value[$this->ldel_length]) ? strpos(" \n\t\r", $this->value[$this->ldel_length]) !== false : false) {
- return false;
- } else {
- $this->token = Smarty_Internal_Templateparser::TP_STRIPON;
- }
- }
-
- function yy_r6_2()
- {
-
- if ($this->smarty->auto_literal && isset($this->value[$this->ldel_length]) ? strpos(" \n\t\r", $this->value[$this->ldel_length]) !== false : false) {
- return false;
- } else {
- $this->token = Smarty_Internal_Templateparser::TP_STRIPOFF;
- }
- }
-
- function yy_r6_3()
- {
-
- if ($this->smarty->auto_literal && isset($this->value[$this->ldel_length]) ? strpos(" \n\t\r", $this->value[$this->ldel_length]) !== false : false) {
- return false;
- } else {
- $this->yypopstate();
- return true;
- }
- }
-
- function yy_r6_4()
- {
-
- $to = strlen($this->data);
- preg_match("~" . $this->ldel . "\s*(([/])?strip\s*" . $this->rdel . "|block\s+)~i", $this->data, $match, PREG_OFFSET_CAPTURE, $this->counter);
- if (isset($match[0][1])) {
- $to = $match[0][1];
- }
- $this->value = substr($this->data, $this->counter, $to - $this->counter);
- return false;
- }
-
- public function yylex7()
- {
- if (!isset($this->yy_global_pattern7)) {
- $this->yy_global_pattern7 = "/\G(" . $this->ldel . "\\s*literal\\s*" . $this->rdel . ")|\G(" . $this->ldel . "\\s*block)|\G(" . $this->ldel . "\\s*[\/]block)|\G(" . $this->ldel . "\\s*[$]smarty\\.block\\.(child|parent))|\G([\S\s])/isS";
- }
- if ($this->counter >= strlen($this->data)) {
- return false; // end of input
- }
-
- do {
- if (preg_match($this->yy_global_pattern7, $this->data, $yymatches, null, $this->counter)) {
- $yysubmatches = $yymatches;
- if (strlen($yysubmatches[0]) < 200) {
- $yymatches = preg_grep("/(.|\s)+/", $yysubmatches);
- } else {
- $yymatches = array_filter($yymatches, 'strlen');
- }
- if (empty($yymatches)) {
- throw new Exception('Error: lexing failed because a rule matched' . ' an empty string. Input "' . substr($this->data, $this->counter, 5) . '... state CHILDBLOCK');
- }
- next($yymatches); // skip global match
- $this->token = key($yymatches); // token number
- $this->value = current($yymatches); // token value
- $r = $this->{'yy_r7_' . $this->token}();
- if ($r === null) {
- $this->counter += strlen($this->value);
- $this->line += substr_count($this->value, "\n");
- // accept this token
- return true;
- } elseif ($r === true) {
- // we have changed state
- // process this token in the new state
- return $this->yylex();
- } elseif ($r === false) {
- $this->counter += strlen($this->value);
- $this->line += substr_count($this->value, "\n");
- if ($this->counter >= strlen($this->data)) {
- return false; // end of input
- }
- // skip this token
- continue;
- }
- } else {
- throw new Exception('Unexpected input at line' . $this->line . ': ' . $this->data[$this->counter]);
- }
- break;
- } while (true);
- } // end function
-
- const CHILDBLOCK = 7;
-
- function yy_r7_1()
- {
-
- if ($this->smarty->auto_literal && isset($this->value[$this->ldel_length]) ? strpos(" \n\t\r", $this->value[$this->ldel_length]) !== false : false) {
- $this->token = Smarty_Internal_Templateparser::TP_BLOCKSOURCE;
- } else {
- $this->token = Smarty_Internal_Templateparser::TP_BLOCKSOURCE;
- $this->yypushstate(self::CHILDLITERAL);
- }
- }
-
- function yy_r7_2()
- {
-
- if ($this->smarty->auto_literal && isset($this->value[$this->ldel_length]) ? strpos(" \n\t\r", $this->value[$this->ldel_length]) !== false : false) {
- $this->token = Smarty_Internal_Templateparser::TP_BLOCKSOURCE;
- } else {
- $this->yypopstate();
- return true;
- }
- }
-
- function yy_r7_3()
- {
-
- if ($this->smarty->auto_literal && isset($this->value[$this->ldel_length]) ? strpos(" \n\t\r", $this->value[$this->ldel_length]) !== false : false) {
- $this->token = Smarty_Internal_Templateparser::TP_BLOCKSOURCE;
- } else {
- $this->yypopstate();
- return true;
- }
- }
-
- function yy_r7_4()
- {
-
- if ($this->smarty->auto_literal && isset($this->value[$this->ldel_length]) ? strpos(" \n\t\r", $this->value[$this->ldel_length]) !== false : false) {
- $this->token = Smarty_Internal_Templateparser::TP_BLOCKSOURCE;
- } else {
- $this->yypopstate();
- return true;
- }
- }
-
- function yy_r7_6()
- {
-
- $to = strlen($this->data);
- preg_match("~" . $this->ldel . "\s*(literal\s*" . $this->rdel . "|([/])?block(\s|" . $this->rdel . ")|[\$]smarty\.block\.(child|parent))~i", $this->data, $match, PREG_OFFSET_CAPTURE, $this->counter);
- if (isset($match[0][1])) {
- $to = $match[0][1];
- }
- $this->value = substr($this->data, $this->counter, $to - $this->counter);
- $this->token = Smarty_Internal_Templateparser::TP_BLOCKSOURCE;
- }
-
- public function yylex8()
- {
- if (!isset($this->yy_global_pattern8)) {
- $this->yy_global_pattern8 = "/\G(" . $this->ldel . "\\s*literal\\s*" . $this->rdel . ")|\G(" . $this->ldel . "\\s*[\/]literal\\s*" . $this->rdel . ")|\G([\S\s])/isS";
- }
- if ($this->counter >= strlen($this->data)) {
- return false; // end of input
- }
-
- do {
- if (preg_match($this->yy_global_pattern8, $this->data, $yymatches, null, $this->counter)) {
- $yysubmatches = $yymatches;
- if (strlen($yysubmatches[0]) < 200) {
- $yymatches = preg_grep("/(.|\s)+/", $yysubmatches);
- } else {
- $yymatches = array_filter($yymatches, 'strlen');
- }
- if (empty($yymatches)) {
- throw new Exception('Error: lexing failed because a rule matched' . ' an empty string. Input "' . substr($this->data, $this->counter, 5) . '... state CHILDLITERAL');
- }
- next($yymatches); // skip global match
- $this->token = key($yymatches); // token number
- $this->value = current($yymatches); // token value
- $r = $this->{'yy_r8_' . $this->token}();
- if ($r === null) {
- $this->counter += strlen($this->value);
- $this->line += substr_count($this->value, "\n");
- // accept this token
- return true;
- } elseif ($r === true) {
- // we have changed state
- // process this token in the new state
- return $this->yylex();
- } elseif ($r === false) {
- $this->counter += strlen($this->value);
- $this->line += substr_count($this->value, "\n");
- if ($this->counter >= strlen($this->data)) {
- return false; // end of input
- }
- // skip this token
- continue;
- }
- } else {
- throw new Exception('Unexpected input at line' . $this->line . ': ' . $this->data[$this->counter]);
- }
- break;
- } while (true);
- } // end function
-
- const CHILDLITERAL = 8;
-
- function yy_r8_1()
- {
-
- if ($this->smarty->auto_literal && isset($this->value[$this->ldel_length]) ? strpos(" \n\t\r", $this->value[$this->ldel_length]) !== false : false) {
- $this->token = Smarty_Internal_Templateparser::TP_BLOCKSOURCE;
- } else {
- $this->token = Smarty_Internal_Templateparser::TP_BLOCKSOURCE;
- $this->yypushstate(self::CHILDLITERAL);
- }
- }
-
- function yy_r8_2()
- {
-
- if ($this->smarty->auto_literal && isset($this->value[$this->ldel_length]) ? strpos(" \n\t\r", $this->value[$this->ldel_length]) !== false : false) {
- $this->token = Smarty_Internal_Templateparser::TP_BLOCKSOURCE;
- } else {
- $this->token = Smarty_Internal_Templateparser::TP_BLOCKSOURCE;
- $this->yypopstate();
- }
- }
-
- function yy_r8_3()
- {
-
- $to = strlen($this->data);
- preg_match("~{$this->ldel}[/]?literal\s*{$this->rdel}~i", $this->data, $match, PREG_OFFSET_CAPTURE, $this->counter);
- if (isset($match[0][1])) {
- $to = $match[0][1];
- } else {
- $this->compiler->trigger_template_error("missing or misspelled literal closing tag");
- }
- $this->value = substr($this->data, $this->counter, $to - $this->counter);
- $this->token = Smarty_Internal_Templateparser::TP_BLOCKSOURCE;
- }
-
}
\ No newline at end of file
diff --git a/library/Smarty/libs/sysplugins/smarty_internal_templateparser.php b/library/Smarty/libs/sysplugins/smarty_internal_templateparser.php
index 871f7c0a7..57dbf61a3 100644
--- a/library/Smarty/libs/sysplugins/smarty_internal_templateparser.php
+++ b/library/Smarty/libs/sysplugins/smarty_internal_templateparser.php
@@ -76,21 +76,19 @@ class TP_yyStackEntry
;
-#line 13 "../smarty/lexer/smarty_internal_templateparser.y"
+#line 11 "../smarty/lexer/smarty_internal_templateparser.y"
/**
- * Smarty Internal Plugin Templateparser
+ * Smarty Template Parser Class
*
* This is the template parser.
* It is generated from the smarty_internal_templateparser.y file
*
- * @package Smarty
- * @subpackage Compiler
- * @author Uwe Tews
+ * @author Uwe Tews <uwe.tews@googlemail.com>
*/
class Smarty_Internal_Templateparser
{
- #line 26 "../smarty/lexer/smarty_internal_templateparser.y"
+ #line 23 "../smarty/lexer/smarty_internal_templateparser.y"
const Err1 = "Security error: Call to private object member not allowed";
@@ -157,7 +155,7 @@ class Smarty_Internal_Templateparser
*
* @var Smarty_Internal_Templatelexer
*/
- private $lex;
+ public $lex;
/**
* internal error flag
@@ -206,7 +204,21 @@ class Smarty_Internal_Templateparser
*
* @var Smarty_Security
*/
- private $security = null;
+ public $security = null;
+
+ /**
+ * template prefix array
+ *
+ * @var \Smarty_Internal_ParseTree[]
+ */
+ public $template_prefix = array();
+
+ /**
+ * security object
+ *
+ * @var \Smarty_Internal_ParseTree[]
+ */
+ public $template_postfix = array();
/**
* constructor
@@ -221,7 +233,7 @@ class Smarty_Internal_Templateparser
$this->template = $this->compiler->template;
$this->smarty = $this->template->smarty;
$this->security = isset($this->smarty->security_policy) ? $this->smarty->security_policy : false;
- $this->current_buffer = $this->root_buffer = new Smarty_Internal_ParseTree_Template($this);
+ $this->current_buffer = $this->root_buffer = new Smarty_Internal_ParseTree_Template();
}
/**
@@ -231,7 +243,7 @@ class Smarty_Internal_Templateparser
*/
public function insertPhpCode($code)
{
- $this->current_buffer->append_subtree(new Smarty_Internal_ParseTree_Tag($this, $code));
+ $this->current_buffer->append_subtree($this, new Smarty_Internal_ParseTree_Tag($this, $code));
}
/**
@@ -245,10 +257,10 @@ class Smarty_Internal_Templateparser
{
$tmp = '';
foreach ($this->compiler->prefix_code as $preCode) {
- $tmp = empty($tmp) ? $preCode : $this->compiler->appendCode($tmp, $preCode);
+ $tmp .= $preCode;
}
$this->compiler->prefix_code = array();
- $tmp = empty($tmp) ? $code : $this->compiler->appendCode($tmp, $code);
+ $tmp .= $code;
return new Smarty_Internal_ParseTree_Tag($this, $this->compiler->processNocacheCode($tmp, true));
}
@@ -266,430 +278,602 @@ class Smarty_Internal_Templateparser
const TP_STRIPOFF = 7;
- const TP_BLOCKSOURCE = 8;
-
- const TP_LITERALSTART = 9;
+ const TP_LITERALSTART = 8;
- const TP_LITERALEND = 10;
+ const TP_LITERALEND = 9;
- const TP_LITERAL = 11;
+ const TP_LITERAL = 10;
- const TP_RDEL = 12;
+ const TP_RDEL = 11;
- const TP_SIMPLEOUTPUT = 13;
+ const TP_SIMPELOUTPUT = 12;
- const TP_LDEL = 14;
+ const TP_LDEL = 13;
- const TP_DOLLARID = 15;
+ const TP_DOLLARID = 14;
- const TP_EQUAL = 16;
+ const TP_EQUAL = 15;
- const TP_SIMPLETAG = 17;
+ const TP_SIMPLETAG = 16;
- const TP_ID = 18;
+ const TP_ID = 17;
- const TP_PTR = 19;
+ const TP_PTR = 18;
- const TP_LDELIF = 20;
+ const TP_LDELIF = 19;
- const TP_LDELFOR = 21;
+ const TP_LDELFOR = 20;
- const TP_SEMICOLON = 22;
+ const TP_SEMICOLON = 21;
- const TP_INCDEC = 23;
+ const TP_INCDEC = 22;
- const TP_TO = 24;
+ const TP_TO = 23;
- const TP_STEP = 25;
+ const TP_STEP = 24;
- const TP_LDELFOREACH = 26;
+ const TP_LDELFOREACH = 25;
- const TP_SPACE = 27;
+ const TP_SPACE = 26;
- const TP_AS = 28;
+ const TP_AS = 27;
- const TP_APTR = 29;
+ const TP_APTR = 28;
- const TP_LDELSETFILTER = 30;
+ const TP_LDELSETFILTER = 29;
- const TP_SMARTYBLOCKCHILDPARENT = 31;
+ const TP_SMARTYBLOCKCHILDPARENT = 30;
- const TP_CLOSETAG = 32;
+ const TP_CLOSETAG = 31;
- const TP_LDELSLASH = 33;
+ const TP_LDELSLASH = 32;
- const TP_ATTR = 34;
+ const TP_ATTR = 33;
- const TP_INTEGER = 35;
+ const TP_INTEGER = 34;
- const TP_COMMA = 36;
+ const TP_COMMA = 35;
- const TP_OPENP = 37;
+ const TP_OPENP = 36;
- const TP_CLOSEP = 38;
+ const TP_CLOSEP = 37;
- const TP_MATH = 39;
+ const TP_MATH = 38;
- const TP_UNIMATH = 40;
+ const TP_UNIMATH = 39;
- const TP_ISIN = 41;
+ const TP_ISIN = 40;
- const TP_INSTANCEOF = 42;
+ const TP_INSTANCEOF = 41;
- const TP_QMARK = 43;
+ const TP_QMARK = 42;
- const TP_NOT = 44;
+ const TP_NOT = 43;
- const TP_TYPECAST = 45;
+ const TP_TYPECAST = 44;
- const TP_HEX = 46;
+ const TP_HEX = 45;
- const TP_DOT = 47;
+ const TP_DOT = 46;
- const TP_SINGLEQUOTESTRING = 48;
+ const TP_SINGLEQUOTESTRING = 47;
- const TP_DOUBLECOLON = 49;
+ const TP_DOUBLECOLON = 48;
- const TP_NAMESPACE = 50;
+ const TP_NAMESPACE = 49;
- const TP_AT = 51;
+ const TP_AT = 50;
- const TP_HATCH = 52;
+ const TP_HATCH = 51;
- const TP_OPENB = 53;
+ const TP_OPENB = 52;
- const TP_CLOSEB = 54;
+ const TP_CLOSEB = 53;
- const TP_DOLLAR = 55;
+ const TP_DOLLAR = 54;
- const TP_LOGOP = 56;
+ const TP_LOGOP = 55;
- const TP_TLOGOP = 57;
+ const TP_TLOGOP = 56;
- const TP_SINGLECOND = 58;
+ const TP_SINGLECOND = 57;
- const TP_QUOTE = 59;
+ const TP_QUOTE = 58;
- const TP_BACKTICK = 60;
+ const TP_BACKTICK = 59;
- const YY_NO_ACTION = 525;
+ const YY_NO_ACTION = 535;
- const YY_ACCEPT_ACTION = 524;
+ const YY_ACCEPT_ACTION = 534;
- const YY_ERROR_ACTION = 523;
+ const YY_ERROR_ACTION = 533;
- const YY_SZ_ACTTAB = 1908;
+ const YY_SZ_ACTTAB = 2082;
- static public $yy_action = array(287, 9, 129, 251, 273, 194, 441, 2, 82, 280, 281, 282, 216, 110, 353, 223, 212,
- 229, 441, 258, 217, 12, 199, 240, 32, 257, 257, 39, 17, 12, 25, 43, 42, 263, 224, 233, 17, 206, 441, 80, 1, 244,
- 311, 311, 172, 172, 52, 287, 9, 128, 441, 273, 65, 178, 2, 82, 268, 14, 184, 298, 110, 262, 13, 319, 229, 297,
- 258, 217, 31, 225, 12, 32, 170, 257, 39, 239, 189, 17, 43, 42, 263, 224, 292, 214, 206, 249, 80, 1, 113, 311,
- 164, 442, 172, 52, 287, 9, 132, 201, 273, 209, 260, 2, 82, 442, 14, 141, 256, 110, 262, 88, 303, 229, 261, 258,
- 217, 260, 225, 12, 32, 168, 36, 39, 241, 12, 17, 43, 42, 263, 224, 292, 17, 206, 189, 80, 1, 7, 311, 180, 257,
- 219, 52, 287, 9, 132, 134, 273, 193, 470, 2, 82, 10, 470, 156, 304, 110, 300, 89, 172, 229, 310, 258, 217, 260,
- 205, 223, 32, 257, 14, 39, 324, 12, 262, 43, 42, 263, 224, 292, 17, 206, 189, 80, 1, 470, 311, 470, 172, 470,
- 52, 287, 9, 131, 201, 273, 209, 257, 2, 82, 83, 307, 232, 201, 110, 399, 454, 230, 229, 237, 258, 217, 454, 225,
- 355, 32, 133, 201, 39, 215, 399, 144, 43, 42, 263, 224, 292, 399, 206, 12, 80, 1, 326, 311, 157, 236, 17, 52,
- 287, 9, 133, 201, 273, 209, 260, 2, 82, 214, 201, 235, 202, 110, 113, 80, 99, 229, 311, 258, 217, 396, 225, 187,
- 19, 14, 323, 39, 18, 262, 28, 43, 42, 263, 224, 292, 396, 206, 12, 80, 1, 143, 311, 396, 134, 17, 52, 287, 9,
- 132, 10, 273, 209, 4, 2, 82, 313, 14, 146, 454, 110, 262, 181, 158, 229, 454, 258, 217, 260, 192, 12, 32, 20,
- 260, 39, 99, 441, 17, 43, 42, 263, 224, 292, 243, 206, 189, 80, 1, 441, 311, 187, 182, 298, 52, 287, 9, 130,
- 201, 273, 209, 14, 2, 82, 93, 262, 104, 24, 110, 399, 99, 169, 229, 154, 258, 217, 220, 225, 113, 5, 124, 260,
- 39, 135, 399, 100, 43, 42, 263, 224, 292, 399, 206, 261, 80, 1, 325, 311, 228, 112, 104, 52, 287, 9, 132, 92,
- 273, 191, 173, 2, 82, 174, 291, 285, 16, 110, 330, 312, 260, 229, 310, 258, 217, 311, 225, 223, 32, 259, 90, 39,
- 261, 6, 264, 43, 42, 263, 224, 292, 181, 206, 175, 80, 1, 116, 311, 171, 201, 21, 52, 287, 9, 132, 37, 273, 195,
- 260, 2, 82, 36, 296, 238, 189, 110, 189, 259, 201, 229, 261, 258, 217, 214, 225, 218, 32, 35, 113, 39, 36, 232,
- 299, 43, 42, 263, 224, 292, 15, 206, 183, 80, 1, 211, 311, 17, 91, 226, 52, 287, 9, 133, 177, 273, 209, 179, 2,
- 82, 318, 470, 99, 18, 110, 470, 454, 121, 229, 288, 258, 217, 289, 225, 316, 19, 145, 189, 39, 187, 189, 121,
- 43, 42, 263, 224, 292, 161, 206, 261, 80, 99, 104, 311, 454, 14, 454, 52, 470, 262, 454, 279, 278, 276, 277,
- 283, 284, 174, 159, 470, 261, 287, 9, 470, 454, 273, 311, 317, 2, 82, 176, 298, 223, 204, 110, 115, 68, 107,
- 229, 117, 258, 217, 100, 3, 201, 272, 329, 138, 29, 210, 271, 293, 454, 325, 454, 359, 470, 260, 454, 254, 317,
- 139, 275, 200, 306, 223, 204, 111, 119, 72, 107, 260, 201, 37, 242, 100, 255, 151, 272, 329, 213, 4, 210, 271,
- 293, 150, 325, 245, 167, 20, 152, 317, 81, 208, 149, 260, 223, 204, 260, 119, 60, 102, 186, 218, 185, 265, 100,
- 269, 22, 272, 329, 286, 270, 210, 271, 293, 317, 325, 248, 147, 148, 223, 204, 178, 119, 72, 107, 153, 232, 260,
- 274, 100, 13, 319, 272, 329, 261, 397, 210, 271, 293, 231, 325, 268, 136, 317, 189, 165, 106, 207, 223, 204,
- 397, 115, 68, 107, 84, 327, 85, 397, 100, 103, 441, 272, 329, 290, 86, 210, 271, 293, 87, 325, 299, 299, 441,
- 317, 299, 155, 299, 299, 223, 204, 305, 119, 50, 102, 299, 108, 299, 299, 100, 299, 299, 272, 329, 299, 299,
- 210, 271, 293, 317, 325, 299, 299, 299, 223, 204, 299, 119, 72, 107, 299, 299, 299, 299, 100, 27, 227, 272, 329,
- 160, 299, 210, 271, 293, 299, 325, 299, 299, 317, 299, 299, 299, 203, 223, 204, 299, 109, 46, 107, 299, 299,
- 299, 299, 100, 299, 299, 272, 329, 299, 308, 210, 271, 293, 299, 325, 299, 311, 287, 8, 309, 299, 273, 299, 317,
- 2, 82, 299, 299, 223, 204, 110, 119, 49, 107, 229, 299, 258, 217, 100, 299, 142, 272, 329, 299, 178, 210, 271,
- 293, 299, 325, 260, 317, 299, 13, 319, 299, 223, 204, 299, 119, 70, 107, 299, 294, 23, 299, 100, 189, 299, 272,
- 329, 299, 299, 210, 271, 293, 317, 325, 299, 299, 299, 223, 204, 299, 119, 77, 107, 299, 299, 299, 299, 100,
- 299, 299, 272, 329, 299, 308, 210, 271, 293, 299, 325, 299, 299, 287, 8, 309, 299, 273, 299, 317, 2, 82, 299,
- 299, 223, 204, 110, 119, 71, 107, 229, 299, 258, 217, 100, 299, 299, 272, 329, 299, 299, 210, 271, 293, 299,
- 325, 299, 317, 299, 299, 299, 299, 223, 204, 299, 119, 60, 107, 299, 295, 23, 299, 100, 299, 299, 272, 329, 299,
- 299, 210, 271, 293, 317, 325, 299, 140, 299, 223, 204, 178, 119, 73, 107, 299, 299, 260, 299, 100, 13, 319, 272,
- 329, 299, 299, 210, 271, 293, 299, 325, 317, 201, 299, 189, 299, 223, 204, 299, 119, 62, 107, 299, 41, 40, 38,
- 100, 299, 299, 272, 329, 299, 299, 210, 271, 293, 299, 325, 317, 163, 321, 322, 328, 223, 204, 299, 119, 63,
- 107, 299, 41, 40, 38, 100, 299, 299, 272, 329, 299, 299, 210, 271, 293, 299, 325, 317, 201, 321, 322, 328, 223,
- 204, 299, 97, 69, 107, 299, 299, 299, 299, 100, 299, 299, 272, 329, 299, 299, 210, 271, 293, 299, 325, 317, 299,
- 299, 299, 299, 223, 204, 299, 119, 75, 107, 222, 41, 40, 38, 100, 299, 299, 272, 329, 299, 299, 210, 271, 293,
- 299, 325, 317, 201, 321, 322, 328, 223, 204, 299, 119, 64, 107, 299, 247, 299, 299, 100, 299, 299, 272, 329,
- 299, 299, 210, 271, 293, 299, 325, 317, 201, 26, 299, 299, 223, 204, 299, 98, 74, 107, 299, 41, 40, 38, 100,
- 299, 299, 272, 329, 299, 299, 210, 271, 293, 299, 325, 317, 201, 321, 322, 328, 223, 198, 299, 105, 59, 107,
- 299, 41, 40, 38, 100, 299, 299, 272, 329, 299, 299, 210, 271, 293, 299, 325, 317, 299, 321, 322, 328, 223, 204,
- 299, 119, 45, 107, 246, 41, 40, 38, 100, 299, 299, 272, 329, 299, 299, 210, 271, 293, 299, 325, 317, 201, 321,
- 322, 328, 223, 94, 299, 79, 48, 101, 299, 252, 299, 299, 100, 299, 299, 272, 329, 299, 299, 210, 271, 293, 299,
- 325, 317, 299, 299, 299, 299, 223, 204, 299, 119, 56, 107, 299, 41, 40, 38, 100, 299, 299, 272, 329, 299, 299,
- 210, 271, 293, 299, 325, 317, 201, 321, 322, 328, 223, 204, 299, 119, 61, 107, 299, 190, 299, 299, 100, 299,
- 299, 272, 329, 299, 299, 210, 271, 293, 299, 325, 317, 299, 299, 299, 299, 223, 204, 299, 96, 58, 107, 299, 41,
- 40, 38, 100, 299, 299, 272, 329, 299, 299, 210, 271, 293, 299, 325, 317, 201, 321, 322, 328, 223, 204, 299, 119,
- 66, 107, 299, 188, 299, 299, 100, 299, 299, 272, 329, 299, 299, 210, 271, 293, 299, 325, 317, 201, 299, 299,
- 299, 223, 204, 299, 119, 47, 107, 299, 41, 40, 38, 100, 299, 299, 272, 329, 299, 299, 210, 271, 293, 299, 325,
- 317, 299, 321, 322, 328, 223, 204, 299, 119, 78, 107, 299, 41, 40, 38, 100, 299, 299, 272, 329, 299, 299, 210,
- 271, 293, 299, 325, 317, 299, 321, 322, 328, 223, 204, 299, 119, 54, 107, 299, 299, 299, 299, 100, 299, 299,
- 272, 329, 299, 299, 210, 271, 293, 299, 325, 317, 299, 299, 299, 299, 223, 204, 299, 119, 53, 107, 299, 299,
- 299, 299, 100, 299, 299, 272, 329, 299, 299, 210, 271, 293, 299, 325, 317, 299, 299, 299, 299, 223, 95, 299, 79,
- 44, 101, 299, 299, 299, 299, 100, 299, 299, 272, 329, 299, 299, 210, 271, 293, 299, 325, 317, 299, 299, 299,
- 299, 223, 197, 299, 119, 57, 107, 299, 299, 299, 299, 100, 299, 299, 272, 329, 299, 299, 210, 271, 293, 299,
- 325, 317, 299, 299, 299, 299, 223, 204, 299, 119, 76, 107, 299, 299, 299, 299, 100, 299, 299, 272, 329, 299,
- 299, 210, 271, 293, 299, 325, 317, 299, 299, 299, 299, 223, 204, 299, 119, 55, 107, 299, 299, 299, 299, 100,
- 299, 299, 272, 329, 299, 299, 210, 271, 293, 299, 325, 317, 299, 299, 299, 299, 223, 204, 299, 119, 67, 107,
- 299, 299, 299, 299, 100, 299, 299, 272, 329, 299, 299, 210, 271, 293, 299, 325, 317, 299, 299, 299, 299, 223,
- 234, 299, 122, 299, 107, 299, 299, 299, 299, 100, 299, 299, 299, 320, 299, 299, 210, 271, 293, 299, 325, 317,
- 409, 409, 299, 299, 223, 234, 299, 127, 299, 107, 299, 299, 299, 299, 100, 299, 299, 299, 250, 299, 299, 210,
- 271, 293, 299, 325, 524, 51, 253, 281, 282, 216, 299, 299, 223, 299, 441, 317, 409, 409, 409, 201, 223, 234,
- 299, 126, 299, 107, 441, 299, 299, 299, 100, 299, 299, 409, 409, 409, 299, 210, 271, 293, 201, 325, 299, 33,
- 299, 12, 299, 299, 299, 299, 299, 301, 17, 299, 299, 299, 299, 41, 40, 38, 299, 299, 317, 299, 299, 299, 12,
- 223, 234, 299, 123, 299, 107, 17, 321, 322, 328, 100, 41, 40, 38, 299, 299, 299, 210, 271, 293, 299, 325, 299,
- 299, 403, 299, 299, 299, 321, 322, 328, 299, 317, 299, 403, 299, 403, 223, 234, 403, 118, 299, 107, 299, 299,
- 299, 403, 100, 403, 299, 403, 299, 299, 299, 210, 271, 293, 317, 325, 232, 299, 299, 223, 234, 299, 125, 299,
- 107, 299, 299, 226, 299, 100, 299, 201, 299, 299, 299, 299, 210, 271, 293, 470, 325, 317, 201, 470, 454, 226,
- 223, 234, 299, 120, 299, 107, 299, 299, 299, 299, 100, 470, 299, 30, 299, 470, 454, 210, 271, 293, 201, 325, 12,
- 41, 40, 38, 454, 299, 454, 17, 470, 299, 454, 314, 41, 40, 38, 299, 315, 299, 321, 322, 328, 201, 454, 34, 454,
- 299, 470, 299, 454, 321, 322, 328, 299, 299, 226, 470, 41, 40, 38, 470, 454, 299, 114, 299, 299, 299, 470, 299,
- 299, 299, 470, 454, 299, 321, 322, 328, 299, 302, 299, 41, 40, 38, 201, 299, 299, 299, 299, 299, 454, 299, 454,
- 299, 470, 365, 454, 299, 321, 322, 328, 454, 221, 454, 299, 470, 299, 454, 166, 299, 12, 299, 178, 299, 299,
- 299, 299, 17, 260, 299, 441, 13, 319, 162, 299, 11, 196, 178, 299, 266, 137, 299, 441, 260, 178, 189, 13, 319,
- 299, 299, 260, 299, 299, 13, 319, 299, 267, 299, 299, 299, 189, 299, 299, 299, 299, 299, 299, 189, 299, 299,
- 299, 299, 299, 299, 299, 299, 311,);
-
- static public $yy_lookahead = array(13, 14, 15, 15, 17, 18, 37, 20, 21, 64, 65, 66, 67, 26, 12, 70, 47, 30, 49, 32,
- 33, 27, 35, 54, 37, 23, 23, 40, 34, 27, 29, 44, 45, 46, 47, 48, 34, 50, 37, 52, 53, 54, 55, 55, 42, 42, 59, 13,
- 14, 15, 49, 17, 18, 76, 20, 21, 93, 14, 95, 96, 26, 18, 85, 86, 30, 31, 32, 33, 16, 35, 27, 37, 29, 23, 40, 23,
- 99, 34, 44, 45, 46, 47, 48, 75, 50, 77, 52, 53, 80, 55, 72, 37, 42, 59, 13, 14, 15, 1, 17, 18, 82, 20, 21, 49,
- 14, 72, 18, 26, 18, 76, 60, 30, 94, 32, 33, 82, 35, 27, 37, 29, 36, 40, 38, 27, 34, 44, 45, 46, 47, 48, 34, 50,
- 99, 52, 53, 36, 55, 81, 23, 51, 59, 13, 14, 15, 47, 17, 18, 14, 20, 21, 53, 18, 72, 54, 26, 12, 76, 42, 30, 65,
- 32, 33, 82, 35, 70, 37, 23, 14, 40, 54, 27, 18, 44, 45, 46, 47, 48, 34, 50, 99, 52, 53, 14, 55, 51, 42, 18, 59,
- 13, 14, 15, 1, 17, 18, 23, 20, 21, 103, 104, 47, 1, 26, 12, 47, 51, 30, 54, 32, 33, 53, 35, 12, 37, 15, 1, 40,
- 18, 27, 28, 44, 45, 46, 47, 48, 34, 50, 27, 52, 53, 18, 55, 72, 19, 34, 59, 13, 14, 15, 1, 17, 18, 82, 20, 21,
- 75, 1, 77, 78, 26, 80, 52, 19, 30, 55, 32, 33, 12, 35, 99, 37, 14, 50, 40, 16, 18, 14, 44, 45, 46, 47, 48, 27,
- 50, 27, 52, 53, 92, 55, 34, 47, 34, 59, 13, 14, 15, 53, 17, 18, 37, 20, 21, 54, 14, 72, 47, 26, 18, 76, 72, 30,
- 53, 32, 33, 82, 35, 27, 37, 16, 82, 40, 19, 37, 34, 44, 45, 46, 47, 48, 54, 50, 99, 52, 53, 49, 55, 99, 95, 96,
- 59, 13, 14, 15, 1, 17, 18, 14, 20, 21, 81, 18, 49, 16, 26, 12, 19, 72, 30, 75, 32, 33, 71, 35, 80, 37, 75, 82,
- 40, 15, 27, 80, 44, 45, 46, 47, 48, 34, 50, 94, 52, 53, 91, 55, 51, 80, 49, 59, 13, 14, 15, 37, 17, 18, 72, 20,
- 21, 9, 10, 11, 22, 26, 97, 96, 82, 30, 65, 32, 33, 55, 35, 70, 37, 100, 36, 40, 94, 37, 35, 44, 45, 46, 47, 48,
- 76, 50, 76, 52, 53, 49, 55, 72, 1, 16, 59, 13, 14, 15, 2, 17, 18, 82, 20, 21, 36, 104, 38, 99, 26, 99, 100, 1,
- 30, 94, 32, 33, 75, 35, 77, 37, 29, 80, 40, 36, 47, 38, 44, 45, 46, 47, 48, 27, 50, 15, 52, 53, 18, 55, 34, 92,
- 2, 59, 13, 14, 15, 76, 17, 18, 76, 20, 21, 90, 14, 19, 16, 26, 18, 19, 97, 30, 66, 32, 33, 69, 35, 90, 37, 15,
- 99, 40, 99, 99, 97, 44, 45, 46, 47, 48, 92, 50, 94, 52, 19, 49, 55, 47, 14, 49, 59, 51, 18, 53, 3, 4, 5, 6, 7,
- 8, 9, 92, 14, 94, 13, 14, 18, 19, 17, 55, 65, 20, 21, 95, 96, 70, 71, 26, 73, 74, 75, 30, 18, 32, 33, 80, 37, 1,
- 83, 84, 72, 24, 87, 88, 89, 47, 91, 49, 12, 51, 82, 53, 18, 65, 72, 5, 101, 102, 70, 71, 18, 73, 74, 75, 82, 1,
- 2, 38, 80, 18, 52, 83, 84, 18, 37, 87, 88, 89, 72, 91, 54, 72, 16, 52, 65, 18, 98, 92, 82, 70, 71, 82, 73, 74,
- 75, 18, 77, 81, 18, 80, 18, 43, 83, 84, 12, 35, 87, 88, 89, 65, 91, 18, 72, 92, 70, 71, 76, 73, 74, 75, 92, 47,
- 82, 82, 80, 85, 86, 83, 84, 94, 12, 87, 88, 89, 16, 91, 93, 80, 65, 99, 92, 79, 98, 70, 71, 27, 73, 74, 75, 80,
- 87, 80, 34, 80, 68, 37, 83, 84, 10, 80, 87, 88, 89, 80, 91, 105, 105, 49, 65, 105, 92, 105, 105, 70, 71, 102,
- 73, 74, 75, 105, 77, 105, 105, 80, 105, 105, 83, 84, 105, 105, 87, 88, 89, 65, 91, 105, 105, 105, 70, 71, 105,
- 73, 74, 75, 105, 105, 105, 105, 80, 14, 15, 83, 84, 18, 105, 87, 88, 89, 105, 91, 105, 105, 65, 105, 105, 105,
- 98, 70, 71, 105, 73, 74, 75, 105, 105, 105, 105, 80, 105, 105, 83, 84, 105, 5, 87, 88, 89, 105, 91, 105, 55, 13,
- 14, 15, 105, 17, 105, 65, 20, 21, 105, 105, 70, 71, 26, 73, 74, 75, 30, 105, 32, 33, 80, 105, 72, 83, 84, 105,
- 76, 87, 88, 89, 105, 91, 82, 65, 105, 85, 86, 105, 70, 71, 105, 73, 74, 75, 105, 59, 60, 105, 80, 99, 105, 83,
- 84, 105, 105, 87, 88, 89, 65, 91, 105, 105, 105, 70, 71, 105, 73, 74, 75, 105, 105, 105, 105, 80, 105, 105, 83,
- 84, 105, 5, 87, 88, 89, 105, 91, 105, 105, 13, 14, 15, 105, 17, 105, 65, 20, 21, 105, 105, 70, 71, 26, 73, 74,
- 75, 30, 105, 32, 33, 80, 105, 105, 83, 84, 105, 105, 87, 88, 89, 105, 91, 105, 65, 105, 105, 105, 105, 70, 71,
- 105, 73, 74, 75, 105, 59, 60, 105, 80, 105, 105, 83, 84, 105, 105, 87, 88, 89, 65, 91, 105, 72, 105, 70, 71, 76,
- 73, 74, 75, 105, 105, 82, 105, 80, 85, 86, 83, 84, 105, 105, 87, 88, 89, 105, 91, 65, 1, 105, 99, 105, 70, 71,
- 105, 73, 74, 75, 105, 39, 40, 41, 80, 105, 105, 83, 84, 105, 105, 87, 88, 89, 105, 91, 65, 28, 56, 57, 58, 70,
- 71, 105, 73, 74, 75, 105, 39, 40, 41, 80, 105, 105, 83, 84, 105, 105, 87, 88, 89, 105, 91, 65, 1, 56, 57, 58,
- 70, 71, 105, 73, 74, 75, 105, 105, 105, 105, 80, 105, 105, 83, 84, 105, 105, 87, 88, 89, 105, 91, 65, 105, 105,
- 105, 105, 70, 71, 105, 73, 74, 75, 38, 39, 40, 41, 80, 105, 105, 83, 84, 105, 105, 87, 88, 89, 105, 91, 65, 1,
- 56, 57, 58, 70, 71, 105, 73, 74, 75, 105, 12, 105, 105, 80, 105, 105, 83, 84, 105, 105, 87, 88, 89, 105, 91, 65,
- 1, 2, 105, 105, 70, 71, 105, 73, 74, 75, 105, 39, 40, 41, 80, 105, 105, 83, 84, 105, 105, 87, 88, 89, 105, 91,
- 65, 1, 56, 57, 58, 70, 71, 105, 73, 74, 75, 105, 39, 40, 41, 80, 105, 105, 83, 84, 105, 105, 87, 88, 89, 105,
- 91, 65, 105, 56, 57, 58, 70, 71, 105, 73, 74, 75, 38, 39, 40, 41, 80, 105, 105, 83, 84, 105, 105, 87, 88, 89,
- 105, 91, 65, 1, 56, 57, 58, 70, 71, 105, 73, 74, 75, 105, 12, 105, 105, 80, 105, 105, 83, 84, 105, 105, 87, 88,
- 89, 105, 91, 65, 105, 105, 105, 105, 70, 71, 105, 73, 74, 75, 105, 39, 40, 41, 80, 105, 105, 83, 84, 105, 105,
- 87, 88, 89, 105, 91, 65, 1, 56, 57, 58, 70, 71, 105, 73, 74, 75, 105, 12, 105, 105, 80, 105, 105, 83, 84, 105,
- 105, 87, 88, 89, 105, 91, 65, 105, 105, 105, 105, 70, 71, 105, 73, 74, 75, 105, 39, 40, 41, 80, 105, 105, 83,
- 84, 105, 105, 87, 88, 89, 105, 91, 65, 1, 56, 57, 58, 70, 71, 105, 73, 74, 75, 105, 12, 105, 105, 80, 105, 105,
- 83, 84, 105, 105, 87, 88, 89, 105, 91, 65, 1, 105, 105, 105, 70, 71, 105, 73, 74, 75, 105, 39, 40, 41, 80, 105,
- 105, 83, 84, 105, 105, 87, 88, 89, 105, 91, 65, 105, 56, 57, 58, 70, 71, 105, 73, 74, 75, 105, 39, 40, 41, 80,
- 105, 105, 83, 84, 105, 105, 87, 88, 89, 105, 91, 65, 105, 56, 57, 58, 70, 71, 105, 73, 74, 75, 105, 105, 105,
- 105, 80, 105, 105, 83, 84, 105, 105, 87, 88, 89, 105, 91, 65, 105, 105, 105, 105, 70, 71, 105, 73, 74, 75, 105,
- 105, 105, 105, 80, 105, 105, 83, 84, 105, 105, 87, 88, 89, 105, 91, 65, 105, 105, 105, 105, 70, 71, 105, 73, 74,
- 75, 105, 105, 105, 105, 80, 105, 105, 83, 84, 105, 105, 87, 88, 89, 105, 91, 65, 105, 105, 105, 105, 70, 71,
- 105, 73, 74, 75, 105, 105, 105, 105, 80, 105, 105, 83, 84, 105, 105, 87, 88, 89, 105, 91, 65, 105, 105, 105,
- 105, 70, 71, 105, 73, 74, 75, 105, 105, 105, 105, 80, 105, 105, 83, 84, 105, 105, 87, 88, 89, 105, 91, 65, 105,
- 105, 105, 105, 70, 71, 105, 73, 74, 75, 105, 105, 105, 105, 80, 105, 105, 83, 84, 105, 105, 87, 88, 89, 105, 91,
- 65, 105, 105, 105, 105, 70, 71, 105, 73, 74, 75, 105, 105, 105, 105, 80, 105, 105, 83, 84, 105, 105, 87, 88, 89,
- 105, 91, 65, 105, 105, 105, 105, 70, 71, 105, 73, 105, 75, 105, 105, 105, 105, 80, 105, 105, 105, 84, 105, 105,
- 87, 88, 89, 105, 91, 65, 1, 2, 105, 105, 70, 71, 105, 73, 105, 75, 105, 105, 105, 105, 80, 105, 105, 105, 84,
- 105, 105, 87, 88, 89, 105, 91, 62, 63, 64, 65, 66, 67, 105, 105, 70, 105, 37, 65, 39, 40, 41, 1, 70, 71, 105,
- 73, 105, 75, 49, 105, 105, 105, 80, 105, 105, 56, 57, 58, 105, 87, 88, 89, 1, 91, 105, 25, 105, 27, 105, 105,
- 105, 105, 105, 12, 34, 105, 105, 105, 105, 39, 40, 41, 105, 105, 65, 105, 105, 105, 27, 70, 71, 105, 73, 105,
- 75, 34, 56, 57, 58, 80, 39, 40, 41, 105, 105, 105, 87, 88, 89, 105, 91, 105, 105, 12, 105, 105, 105, 56, 57, 58,
- 105, 65, 105, 22, 105, 24, 70, 71, 27, 73, 105, 75, 105, 105, 105, 34, 80, 36, 105, 38, 105, 105, 105, 87, 88,
- 89, 65, 91, 47, 105, 105, 70, 71, 105, 73, 105, 75, 105, 105, 2, 105, 80, 105, 1, 105, 105, 105, 105, 87, 88,
- 89, 14, 91, 65, 1, 18, 19, 2, 70, 71, 105, 73, 105, 75, 105, 105, 105, 105, 80, 14, 105, 16, 105, 18, 19, 87,
- 88, 89, 1, 91, 27, 39, 40, 41, 47, 105, 49, 34, 51, 105, 53, 54, 39, 40, 41, 105, 54, 105, 56, 57, 58, 1, 47, 2,
- 49, 105, 51, 105, 53, 56, 57, 58, 105, 105, 2, 14, 39, 40, 41, 18, 19, 105, 22, 105, 105, 105, 14, 105, 105,
- 105, 18, 19, 105, 56, 57, 58, 105, 60, 105, 39, 40, 41, 1, 105, 105, 105, 105, 105, 47, 105, 49, 105, 51, 12,
- 53, 105, 56, 57, 58, 47, 19, 49, 105, 51, 105, 53, 72, 105, 27, 105, 76, 105, 105, 105, 105, 34, 82, 105, 37,
- 85, 86, 72, 105, 14, 15, 76, 105, 18, 72, 105, 49, 82, 76, 99, 85, 86, 105, 105, 82, 105, 105, 85, 86, 105, 35,
- 105, 105, 105, 99, 105, 105, 105, 105, 105, 105, 99, 105, 105, 105, 105, 105, 105, 105, 105, 55,);
-
- const YY_SHIFT_USE_DFLT = - 32;
-
- const YY_SHIFT_MAX = 236;
-
- static public $yy_shift_ofst = array(517, 410, 316, 81, 81, 316, 81, 410, 34, 34, - 13, 81, 128, 81, 81, 128, 81,
- 81, 269, 81, 81, 81, 175, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 81, 363, 81, 81, 222, 222, 457, 457, 457, 457,
- 457, 1624, 1603, 1736, 1736, 1736, 1736, 1736, 517, 754, 1211, 1265, 1076, 1157, 1760, 941, 1725, 995, 1103,
- 1049, 1783, 1292, 1824, 1292, 1292, 1292, 1292, 1292, 1292, 1292, 1292, 1292, 1292, 1292, 914, 914, 199, 198,
- 96, 342, 842, 90, 43, 278, 246, 96, 96, 342, 232, 342, 580, 2, 143, 190, 244, 331, 711, 321, 325, 291, 376, 446,
- 237, - 6, 462, - 6, 552, 432, 213, 500, 500, 480, 419, 446, 438, 438, 438, 438, 491, 438, 438, 491, 438, 438,
- - 32, 1738, 1720, 466, 1784, 1795, 514, 1852, 247, 153, - 6, - 6, - 6, - 6, - 6, - 6, 97, - 12, 168, - 6, - 6,
- 97, 97, - 6, 156, 156, 97, 52, 97, - 6, - 6, - 6, 97, 251, 97, - 6, - 12, - 6, 97, - 6, - 6, - 12, - 6, - 12,
- - 6, 211, - 6, 664, 438, 491, 438, 438, 438, 424, 438, 491, 515, 491, 424, - 32, - 32, - 32, - 32, - 32, 1562,
- 1664, 634, - 31, 1, 133, 50, 115, 152, 99, 88, 366, 84, 3, 405, 54, 415, 396, 274, 368, 553, 571, 542, 582, 534,
- 566, 558, 545, 567, 547, 583, 574, 608, 586, 590, 598, 515, 550, 593, 596, 609, 371, 264, 171, 533, 530,);
-
- const YY_REDUCE_USE_DFLT = - 56;
-
- const YY_REDUCE_MAX = 190;
-
- static public $yy_reduce_ofst = array(1527, 471, 619, 560, 644, 535, 504, 589, 1335, 1092, 1038, 1119, 1011, 984,
- 876, 1173, 903, 930, 957, 1146, 1200, 1443, 1416, 1362, 1227, 1389, 1254, 1281, 1308, 1065, 673, 849, 824, 708,
- 761, 736, 796, 1497, 1470, 1619, 1535, 1671, 1644, 1582, 1792, 1777, 1799, 845, 1792, 718, 556, - 55, 94, - 23,
- - 23, - 23, - 23, - 23, - 23, - 23, - 23, - 23, - 23, - 23, - 23, 33, - 23, - 23, - 23, - 23, - 23, - 23, - 23,
- - 23, - 23, - 23, - 23, - 23, - 23, 221, 279, 80, 169, 329, 347, 310, 18, 273, 159, 226, 8, - 37, 369, 338, 525,
- 525, 336, 336, 336, 293, 414, 231, 231, 422, 389, 336, 522, 231, 498, 336, 484, 400, 435, 414, 272, 336, 403,
- 397, 336, 336, 336, 444, 336, 336, 231, 336, 336, 336, 184, 184, 184, 184, 184, 184, 573, 184, 551, 557, 557,
- 557, 557, 557, 557, 559, 585, 184, 557, 557, 559, 559, 557, 544, 564, 559, 578, 559, 557, 557, 557, 559, 594,
- 559, 557, 587, 557, 559, 557, 557, 595, 557, 599, 557, 579, 557, 602, 399, 295, 399, 399, 399, 301, 399, 295,
- 375, 295, 301, 257, 56, 537, 532, 511,);
-
- static public $yyExpectedTokens = array(array(3, 4, 5, 6, 7, 8, 9, 13, 14, 17, 20, 21, 26, 30, 32, 33,),
- array(13, 14, 15, 17, 18, 20, 21, 26, 30, 32, 33, 35, 37, 40, 44, 45, 46, 47, 48, 50, 52, 53, 55, 59,),
- array(13, 14, 15, 17, 18, 20, 21, 26, 30, 32, 33, 35, 37, 40, 44, 45, 46, 47, 48, 50, 52, 53, 55, 59,),
- array(13, 14, 15, 17, 18, 20, 21, 26, 30, 32, 33, 35, 37, 40, 44, 45, 46, 47, 48, 50, 52, 53, 55, 59,),
- array(13, 14, 15, 17, 18, 20, 21, 26, 30, 32, 33, 35, 37, 40, 44, 45, 46, 47, 48, 50, 52, 53, 55, 59,),
- array(13, 14, 15, 17, 18, 20, 21, 26, 30, 32, 33, 35, 37, 40, 44, 45, 46, 47, 48, 50, 52, 53, 55, 59,),
- array(13, 14, 15, 17, 18, 20, 21, 26, 30, 32, 33, 35, 37, 40, 44, 45, 46, 47, 48, 50, 52, 53, 55, 59,),
- array(13, 14, 15, 17, 18, 20, 21, 26, 30, 32, 33, 35, 37, 40, 44, 45, 46, 47, 48, 50, 52, 53, 55, 59,),
- array(13, 14, 15, 17, 18, 20, 21, 26, 30, 31, 32, 33, 35, 37, 40, 44, 45, 46, 47, 48, 50, 52, 53, 55, 59,),
- array(13, 14, 15, 17, 18, 20, 21, 26, 30, 31, 32, 33, 35, 37, 40, 44, 45, 46, 47, 48, 50, 52, 53, 55, 59,),
- array(13, 14, 15, 17, 18, 20, 21, 26, 30, 32, 33, 35, 37, 40, 44, 45, 46, 47, 48, 50, 52, 53, 54, 55, 59,),
- array(13, 14, 15, 17, 18, 20, 21, 26, 30, 32, 33, 35, 37, 40, 44, 45, 46, 47, 48, 50, 52, 53, 55, 59,),
- array(13, 14, 15, 17, 18, 20, 21, 26, 30, 32, 33, 35, 37, 40, 44, 45, 46, 47, 48, 50, 52, 53, 55, 59,),
- array(13, 14, 15, 17, 18, 20, 21, 26, 30, 32, 33, 35, 37, 40, 44, 45, 46, 47, 48, 50, 52, 53, 55, 59,),
- array(13, 14, 15, 17, 18, 20, 21, 26, 30, 32, 33, 35, 37, 40, 44, 45, 46, 47, 48, 50, 52, 53, 55, 59,),
- array(13, 14, 15, 17, 18, 20, 21, 26, 30, 32, 33, 35, 37, 40, 44, 45, 46, 47, 48, 50, 52, 53, 55, 59,),
- array(13, 14, 15, 17, 18, 20, 21, 26, 30, 32, 33, 35, 37, 40, 44, 45, 46, 47, 48, 50, 52, 53, 55, 59,),
- array(13, 14, 15, 17, 18, 20, 21, 26, 30, 32, 33, 35, 37, 40, 44, 45, 46, 47, 48, 50, 52, 53, 55, 59,),
- array(13, 14, 15, 17, 18, 20, 21, 26, 30, 32, 33, 35, 37, 40, 44, 45, 46, 47, 48, 50, 52, 53, 55, 59,),
- array(13, 14, 15, 17, 18, 20, 21, 26, 30, 32, 33, 35, 37, 40, 44, 45, 46, 47, 48, 50, 52, 53, 55, 59,),
- array(13, 14, 15, 17, 18, 20, 21, 26, 30, 32, 33, 35, 37, 40, 44, 45, 46, 47, 48, 50, 52, 53, 55, 59,),
- array(13, 14, 15, 17, 18, 20, 21, 26, 30, 32, 33, 35, 37, 40, 44, 45, 46, 47, 48, 50, 52, 53, 55, 59,),
- array(13, 14, 15, 17, 18, 20, 21, 26, 30, 32, 33, 35, 37, 40, 44, 45, 46, 47, 48, 50, 52, 53, 55, 59,),
- array(13, 14, 15, 17, 18, 20, 21, 26, 30, 32, 33, 35, 37, 40, 44, 45, 46, 47, 48, 50, 52, 53, 55, 59,),
- array(13, 14, 15, 17, 18, 20, 21, 26, 30, 32, 33, 35, 37, 40, 44, 45, 46, 47, 48, 50, 52, 53, 55, 59,),
- array(13, 14, 15, 17, 18, 20, 21, 26, 30, 32, 33, 35, 37, 40, 44, 45, 46, 47, 48, 50, 52, 53, 55, 59,),
- array(13, 14, 15, 17, 18, 20, 21, 26, 30, 32, 33, 35, 37, 40, 44, 45, 46, 47, 48, 50, 52, 53, 55, 59,),
- array(13, 14, 15, 17, 18, 20, 21, 26, 30, 32, 33, 35, 37, 40, 44, 45, 46, 47, 48, 50, 52, 53, 55, 59,),
- array(13, 14, 15, 17, 18, 20, 21, 26, 30, 32, 33, 35, 37, 40, 44, 45, 46, 47, 48, 50, 52, 53, 55, 59,),
- array(13, 14, 15, 17, 18, 20, 21, 26, 30, 32, 33, 35, 37, 40, 44, 45, 46, 47, 48, 50, 52, 53, 55, 59,),
- array(13, 14, 15, 17, 18, 20, 21, 26, 30, 32, 33, 35, 37, 40, 44, 45, 46, 47, 48, 50, 52, 53, 55, 59,),
- array(13, 14, 15, 17, 18, 20, 21, 26, 30, 32, 33, 35, 37, 40, 44, 45, 46, 47, 48, 50, 52, 53, 55, 59,),
- array(13, 14, 15, 17, 18, 20, 21, 26, 30, 32, 33, 35, 37, 40, 44, 45, 46, 47, 48, 50, 52, 53, 55, 59,),
- array(13, 14, 15, 17, 18, 20, 21, 26, 30, 32, 33, 35, 37, 40, 44, 45, 46, 47, 48, 50, 52, 53, 55, 59,),
- array(13, 14, 15, 17, 18, 20, 21, 26, 30, 32, 33, 35, 37, 40, 44, 45, 46, 47, 48, 50, 52, 53, 55, 59,),
- array(13, 14, 15, 17, 18, 20, 21, 26, 30, 32, 33, 35, 37, 40, 44, 45, 46, 47, 48, 50, 52, 53, 55, 59,),
- array(13, 14, 15, 17, 18, 20, 21, 26, 30, 32, 33, 35, 37, 40, 44, 45, 46, 47, 48, 50, 52, 53, 55, 59,),
- array(13, 14, 15, 17, 18, 20, 21, 26, 30, 32, 33, 35, 37, 40, 44, 45, 46, 47, 48, 50, 52, 53, 55, 59,),
- array(13, 14, 15, 17, 18, 20, 21, 26, 30, 32, 33, 35, 37, 40, 44, 45, 46, 47, 48, 50, 52, 53, 55, 59,),
- array(13, 14, 15, 17, 18, 20, 21, 26, 30, 32, 33, 35, 37, 40, 44, 45, 46, 47, 48, 50, 52, 55, 59,),
- array(13, 14, 15, 17, 18, 20, 21, 26, 30, 32, 33, 35, 37, 40, 44, 45, 46, 47, 48, 50, 52, 55, 59,),
- array(13, 14, 15, 17, 18, 20, 21, 26, 30, 32, 33, 35, 37, 40, 44, 45, 46, 47, 48, 50, 52, 55, 59,),
- array(13, 14, 15, 17, 18, 20, 21, 26, 30, 32, 33, 35, 37, 40, 44, 45, 46, 47, 48, 50, 52, 55, 59,),
- array(13, 14, 15, 17, 18, 20, 21, 26, 30, 32, 33, 35, 37, 40, 44, 45, 46, 47, 48, 50, 52, 55, 59,),
- array(1, 12, 27, 34, 39, 40, 41, 56, 57, 58,), array(1, 25, 27, 34, 39, 40, 41, 56, 57, 58,),
- array(1, 27, 34, 39, 40, 41, 56, 57, 58,), array(1, 27, 34, 39, 40, 41, 56, 57, 58,),
- array(1, 27, 34, 39, 40, 41, 56, 57, 58,), array(1, 27, 34, 39, 40, 41, 56, 57, 58,),
- array(1, 27, 34, 39, 40, 41, 56, 57, 58,), array(3, 4, 5, 6, 7, 8, 9, 13, 14, 17, 20, 21, 26, 30, 32, 33,),
- array(5, 13, 14, 15, 17, 20, 21, 26, 30, 32, 33, 59, 60,), array(1, 12, 39, 40, 41, 56, 57, 58,),
- array(1, 12, 39, 40, 41, 56, 57, 58,), array(1, 2, 39, 40, 41, 56, 57, 58,),
- array(1, 12, 39, 40, 41, 56, 57, 58,), array(1, 39, 40, 41, 56, 57, 58, 60,),
- array(1, 28, 39, 40, 41, 56, 57, 58,), array(1, 39, 40, 41, 54, 56, 57, 58,),
- array(1, 38, 39, 40, 41, 56, 57, 58,), array(1, 38, 39, 40, 41, 56, 57, 58,),
- array(1, 12, 39, 40, 41, 56, 57, 58,), array(1, 22, 39, 40, 41, 56, 57, 58,), array(1, 39, 40, 41, 56, 57, 58,),
- array(1, 12, 19, 27, 34, 37, 49,), array(1, 39, 40, 41, 56, 57, 58,), array(1, 39, 40, 41, 56, 57, 58,),
- array(1, 39, 40, 41, 56, 57, 58,), array(1, 39, 40, 41, 56, 57, 58,), array(1, 39, 40, 41, 56, 57, 58,),
- array(1, 39, 40, 41, 56, 57, 58,), array(1, 39, 40, 41, 56, 57, 58,), array(1, 39, 40, 41, 56, 57, 58,),
- array(1, 39, 40, 41, 56, 57, 58,), array(1, 39, 40, 41, 56, 57, 58,), array(1, 39, 40, 41, 56, 57, 58,),
- array(39, 40, 41, 56, 57, 58,), array(39, 40, 41, 56, 57, 58,), array(1, 12, 27, 34,), array(15, 18, 52, 55,),
- array(1, 27, 34,), array(15, 37, 55,), array(5, 13, 14, 15, 17, 20, 21, 26, 30, 32, 33, 59, 60,),
- array(14, 18, 27, 29, 34,), array(14, 18, 27, 29, 34,), array(14, 18, 27, 34,), array(14, 18, 27, 34,),
- array(1, 27, 34,), array(1, 27, 34,), array(15, 37, 55,), array(19, 47, 53,), array(15, 37, 55,), array(1, 2,),
- array(12, 23, 27, 34, 42,), array(12, 23, 27, 34, 42,), array(1, 12, 27, 28, 34,), array(1, 12, 27, 34,),
- array(1, 12, 27, 34,), array(14, 15, 18, 55,), array(14, 18, 51,), array(16, 19, 49,), array(16, 19, 49,),
- array(9, 10, 11,), array(15, 18,), array(1, 54,), array(27, 34,), array(19, 49,), array(27, 34,), array(1, 12,),
- array(27, 34,), array(1, 19,), array(14, 18,), array(14, 18,), array(15, 55,), array(1, 29,), array(15, 18,),
- array(1,), array(1,), array(1,), array(1,), array(19,), array(1,), array(1,), array(19,), array(1,), array(1,),
- array(), array(2, 14, 16, 18, 19, 47, 49, 51, 53,), array(2, 14, 18, 19, 47, 49, 51, 53, 54,),
- array(2, 14, 16, 18, 19, 47, 49, 51, 53,), array(2, 14, 18, 19, 47, 49, 51, 53,),
- array(2, 14, 18, 19, 47, 49, 51, 53,), array(14, 18, 19, 47, 49, 51, 53,), array(14, 15, 18, 35, 55,),
- array(16, 47, 53,), array(14, 18, 51,), array(27, 34,), array(27, 34,), array(27, 34,), array(27, 34,),
- array(27, 34,), array(27, 34,), array(47, 53,), array(15, 55,), array(14, 18,), array(27, 34,), array(27, 34,),
- array(47, 53,), array(47, 53,), array(27, 34,), array(47, 53,), array(47, 53,), array(47, 53,), array(16, 23,),
- array(47, 53,), array(27, 34,), array(27, 34,), array(27, 34,), array(47, 53,), array(14, 37,), array(47, 53,),
- array(27, 34,), array(15, 55,), array(27, 34,), array(47, 53,), array(27, 34,), array(27, 34,), array(15, 55,),
- array(27, 34,), array(15, 55,), array(27, 34,), array(18, 50,), array(27, 34,), array(10,), array(1,),
- array(19,), array(1,), array(1,), array(1,), array(2,), array(1,), array(19,), array(37,), array(19,),
- array(2,), array(), array(), array(), array(), array(), array(1, 2, 37, 39, 40, 41, 49, 56, 57, 58,),
- array(12, 22, 24, 27, 34, 36, 38, 47,), array(12, 16, 27, 34, 37, 49,), array(37, 47, 49, 54,),
- array(29, 37, 49,), array(14, 18, 51,), array(23, 42, 60,), array(23, 42, 54,), array(47, 54,), array(36, 54,),
- array(18, 51,), array(22, 36,), array(36, 38,), array(23, 42,), array(16, 47,), array(37, 49,), array(36, 38,),
- array(36, 38,), array(37, 49,), array(37, 49,), array(37,), array(18,), array(54,), array(16,), array(52,),
- array(5,), array(18,), array(38,), array(18,), array(52,), array(18,), array(43,), array(12,), array(35,),
- array(47,), array(18,), array(37,), array(18,), array(18,), array(18,), array(18,), array(35,), array(54,),
- array(23,), array(24,), array(18,), array(), array(), array(), array(), array(), array(), array(), array(),
- array(), array(), array(), array(), array(), array(), array(), array(), array(), array(), array(), array(),
- array(), array(), array(), array(), array(), array(), array(), array(), array(), array(), array(), array(),
- array(), array(), array(), array(), array(), array(), array(), array(), array(), array(), array(), array(),
- array(), array(), array(), array(), array(), array(), array(), array(), array(), array(), array(), array(),
- array(), array(), array(), array(), array(), array(), array(), array(), array(), array(), array(), array(),
- array(), array(), array(), array(), array(), array(), array(), array(), array(), array(), array(), array(),
- array(), array(), array(), array(), array(), array(), array(), array(), array(), array(), array(), array(),
- array(), array(),);
-
- static public $yy_default = array(334, 508, 523, 488, 488, 523, 488, 523, 523, 523, 523, 523, 523, 523, 523, 523,
- 523, 523, 523, 523, 523, 523, 523, 523, 523, 523, 523, 523, 523, 523, 523, 523, 523, 523, 523, 523, 523, 523,
- 523, 523, 523, 523, 523, 523, 523, 393, 360, 393, 357, 393, 369, 331, 523, 523, 523, 523, 523, 523, 398, 523,
- 523, 523, 523, 523, 414, 431, 405, 400, 511, 395, 509, 486, 487, 374, 398, 404, 510, 419, 420, 407, 523, 393,
- 523, 523, 393, 393, 393, 393, 393, 393, 523, 500, 523, 383, 421, 421, 407, 407, 407, 523, 454, 444, 444, 523,
- 523, 407, 393, 444, 371, 407, 393, 387, 454, 454, 523, 407, 523, 389, 422, 407, 410, 497, 417, 423, 444, 424,
- 411, 495, 443, 443, 443, 443, 443, 443, 523, 470, 456, 361, 378, 372, 362, 364, 377, 451, 523, 454, 356, 370,
- 480, 481, 373, 447, 449, 448, 523, 478, 367, 366, 368, 479, 454, 452, 358, 523, 380, 450, 376, 354, 523, 382,
- 523, 379, 523, 381, 348, 384, 498, 390, 413, 388, 489, 438, 475, 454, 501, 490, 494, 494, 454, 494, 454, 431,
- 427, 431, 431, 431, 455, 421, 421, 427, 523, 523, 523, 523, 421, 427, 439, 523, 523, 431, 523, 499, 523, 523,
- 523, 523, 339, 523, 523, 523, 523, 523, 433, 523, 523, 427, 523, 470, 523, 523, 523, 523, 429, 434, 421, 401,
- 523, 464, 483, 375, 461, 484, 406, 463, 469, 462, 433, 474, 394, 402, 496, 470, 460, 332, 445, 491, 492, 425,
- 386, 493, 392, 472, 473, 426, 428, 457, 458, 459, 453, 409, 430, 432, 408, 363, 391, 341, 340, 342, 338, 337,
- 333, 335, 336, 343, 344, 350, 351, 352, 349, 347, 345, 346, 434, 435, 512, 513, 514, 385, 476, 485, 519, 520,
- 517, 516, 505, 507, 506, 515, 522, 518, 521, 471, 477, 467, 465, 468, 440, 437, 436, 415, 416, 502, 503, 442,
- 466, 446, 441, 418, 504, 412, 482,);
-
- const YYNOCODE = 106;
+ static public $yy_action = array(278, 8, 134, 451, 281, 68, 207, 7, 85, 248, 29, 98, 168, 114, 252, 451, 367, 230,
+ 315, 245, 235, 249, 233, 36, 28, 145, 38, 42, 140, 36, 27, 39, 41, 322, 222, 300,
+ 27, 213, 195, 82, 1, 31, 265, 92, 164, 181, 53, 278, 8, 133, 97, 281, 201, 249, 7,
+ 85, 35, 307, 35, 307, 114, 226, 227, 215, 230, 108, 245, 235, 265, 208, 195, 28,
+ 195, 5, 42, 184, 268, 277, 39, 41, 322, 222, 218, 258, 213, 120, 82, 1, 333, 265,
+ 181, 175, 3, 53, 278, 8, 135, 105, 281, 206, 249, 7, 85, 35, 307, 207, 24, 114, 16,
+ 103, 305, 230, 17, 245, 235, 404, 233, 195, 28, 288, 15, 42, 96, 265, 20, 39, 41,
+ 322, 222, 300, 404, 213, 450, 82, 1, 6, 265, 404, 52, 113, 53, 278, 8, 135, 450,
+ 281, 206, 289, 7, 85, 261, 463, 228, 244, 114, 122, 296, 463, 230, 102, 245, 235,
+ 236, 198, 182, 28, 262, 122, 42, 143, 274, 102, 39, 41, 322, 222, 300, 33, 213,
+ 314, 82, 1, 274, 265, 207, 86, 311, 53, 278, 8, 136, 195, 281, 206, 362, 7, 85,
+ 283, 285, 287, 229, 114, 33, 228, 309, 230, 326, 245, 235, 36, 233, 291, 28, 479,
+ 479, 42, 27, 147, 479, 39, 41, 322, 222, 300, 159, 213, 249, 82, 1, 193, 265, 94,
+ 169, 249, 53, 278, 8, 135, 251, 281, 197, 249, 7, 85, 248, 29, 91, 150, 114, 252,
+ 193, 479, 230, 207, 245, 235, 249, 233, 195, 28, 288, 191, 42, 407, 450, 207, 39,
+ 41, 322, 222, 300, 179, 213, 195, 82, 1, 450, 265, 407, 52, 249, 53, 278, 8, 135,
+ 407, 281, 204, 195, 7, 85, 313, 251, 93, 155, 114, 226, 225, 12, 230, 108, 245,
+ 235, 249, 233, 247, 28, 479, 479, 42, 282, 189, 479, 39, 41, 322, 222, 300, 161,
+ 213, 195, 82, 1, 25, 265, 103, 177, 249, 53, 278, 8, 132, 142, 281, 206, 249, 7,
+ 85, 195, 244, 34, 249, 114, 103, 193, 103, 230, 251, 245, 235, 207, 233, 289, 4,
+ 237, 113, 42, 228, 146, 138, 39, 41, 322, 222, 300, 10, 213, 249, 82, 1, 148, 265,
+ 251, 113, 99, 53, 278, 8, 137, 251, 281, 206, 288, 7, 85, 294, 103, 186, 246, 114,
+ 237, 335, 33, 230, 319, 245, 235, 329, 233, 255, 23, 52, 331, 42, 188, 246, 264,
+ 39, 41, 322, 222, 300, 167, 213, 138, 82, 1, 34, 265, 288, 10, 249, 53, 278, 8,
+ 135, 153, 281, 199, 207, 7, 85, 234, 226, 250, 249, 114, 108, 193, 190, 230, 308,
+ 245, 235, 337, 209, 232, 28, 128, 160, 42, 128, 193, 207, 39, 41, 322, 222, 300,
+ 11, 213, 463, 82, 1, 158, 265, 27, 463, 108, 53, 278, 8, 137, 176, 281, 206, 180,
+ 7, 85, 220, 14, 276, 249, 114, 269, 207, 172, 230, 251, 245, 235, 106, 233, 286,
+ 23, 407, 115, 42, 259, 193, 141, 39, 41, 322, 222, 300, 267, 213, 312, 82, 407,
+ 144, 265, 207, 207, 38, 53, 407, 187, 246, 272, 273, 271, 270, 266, 184, 318, 207,
+ 13, 278, 8, 22, 242, 281, 2, 173, 7, 85, 36, 84, 265, 19, 114, 6, 156, 27, 230,
+ 137, 245, 235, 223, 217, 304, 249, 237, 248, 29, 228, 214, 163, 252, 119, 66, 112,
+ 40, 43, 37, 102, 249, 126, 298, 260, 265, 192, 212, 297, 301, 284, 274, 295, 170,
+ 324, 257, 256, 82, 304, 185, 265, 211, 302, 228, 214, 336, 221, 123, 73, 112, 166,
+ 334, 183, 102, 248, 29, 298, 260, 253, 252, 212, 297, 301, 275, 274, 279, 195, 304,
+ 36, 294, 165, 205, 228, 214, 171, 27, 123, 58, 109, 225, 117, 251, 102, 139, 149,
+ 298, 260, 89, 151, 212, 297, 301, 304, 274, 301, 181, 157, 228, 214, 248, 29, 123,
+ 73, 112, 252, 249, 87, 102, 35, 307, 298, 260, 88, 36, 212, 297, 301, 174, 274, 90,
+ 27, 304, 195, 95, 301, 216, 228, 214, 301, 301, 123, 46, 109, 110, 301, 301, 102,
+ 301, 207, 298, 260, 450, 405, 212, 297, 301, 231, 274, 401, 301, 304, 238, 301,
+ 450, 301, 228, 214, 405, 327, 119, 66, 112, 301, 36, 405, 102, 301, 450, 298, 260,
+ 27, 301, 212, 297, 301, 304, 274, 301, 301, 450, 228, 214, 301, 301, 123, 73, 112,
+ 303, 301, 301, 102, 301, 301, 298, 260, 301, 301, 212, 297, 301, 137, 274, 301,
+ 254, 304, 301, 301, 301, 210, 228, 214, 248, 29, 123, 75, 112, 252, 301, 301, 102,
+ 301, 301, 298, 260, 301, 301, 212, 297, 301, 301, 274, 301, 301, 304, 301, 243,
+ 301, 82, 228, 214, 265, 301, 123, 60, 112, 301, 301, 301, 102, 241, 301, 298, 260,
+ 301, 301, 212, 297, 301, 304, 274, 301, 301, 301, 228, 214, 301, 301, 104, 71, 112,
+ 301, 301, 301, 102, 301, 301, 298, 260, 301, 301, 212, 297, 301, 301, 274, 301,
+ 301, 304, 301, 301, 301, 301, 228, 81, 301, 301, 83, 47, 107, 301, 301, 301, 102,
+ 301, 301, 298, 260, 301, 301, 212, 297, 301, 301, 274, 301, 301, 304, 301, 301,
+ 301, 301, 228, 214, 301, 301, 123, 76, 112, 301, 301, 301, 102, 301, 301, 298, 260,
+ 301, 301, 212, 297, 301, 304, 274, 301, 301, 301, 228, 214, 301, 301, 123, 67, 112,
+ 301, 301, 301, 102, 301, 301, 298, 260, 301, 301, 212, 297, 301, 301, 274, 301,
+ 301, 304, 301, 301, 301, 301, 228, 214, 301, 301, 123, 64, 112, 301, 301, 301, 102,
+ 301, 301, 298, 260, 301, 310, 212, 297, 301, 301, 274, 301, 278, 9, 299, 301, 281,
+ 301, 301, 7, 85, 301, 301, 301, 301, 114, 310, 301, 301, 230, 301, 245, 235, 278,
+ 9, 299, 301, 281, 301, 301, 7, 85, 301, 301, 301, 301, 114, 301, 301, 301, 230,
+ 301, 245, 235, 301, 301, 181, 154, 316, 21, 301, 181, 152, 301, 301, 301, 249, 304,
+ 301, 35, 307, 249, 228, 203, 35, 307, 123, 61, 112, 325, 21, 301, 102, 195, 301,
+ 298, 260, 301, 195, 212, 297, 301, 301, 274, 304, 301, 301, 181, 162, 228, 214,
+ 301, 301, 123, 62, 112, 301, 249, 301, 102, 35, 307, 298, 260, 301, 301, 212, 297,
+ 301, 301, 274, 301, 301, 304, 195, 207, 301, 301, 228, 214, 301, 301, 123, 65, 112,
+ 196, 301, 301, 102, 301, 301, 298, 260, 301, 301, 212, 297, 301, 301, 274, 304,
+ 301, 301, 301, 301, 228, 214, 301, 301, 123, 48, 112, 40, 43, 37, 102, 301, 301,
+ 298, 260, 301, 301, 212, 297, 301, 301, 274, 304, 301, 324, 257, 256, 228, 214,
+ 301, 301, 123, 63, 112, 301, 301, 301, 102, 18, 200, 298, 260, 292, 301, 212, 297,
+ 301, 301, 274, 301, 301, 304, 301, 207, 301, 301, 228, 202, 301, 293, 116, 59, 112,
+ 320, 301, 301, 102, 301, 301, 298, 260, 301, 301, 212, 297, 301, 301, 274, 304,
+ 265, 301, 301, 301, 228, 79, 301, 301, 83, 45, 107, 40, 43, 37, 102, 301, 301, 298,
+ 260, 301, 301, 212, 297, 301, 301, 274, 304, 301, 324, 257, 256, 228, 214, 301,
+ 301, 123, 58, 112, 301, 301, 301, 102, 301, 301, 298, 260, 301, 301, 212, 297, 301,
+ 301, 274, 301, 301, 304, 301, 207, 301, 301, 228, 214, 301, 301, 123, 72, 112, 40,
+ 43, 37, 102, 301, 301, 298, 260, 301, 301, 212, 297, 301, 301, 274, 304, 178, 324,
+ 257, 256, 228, 214, 301, 301, 123, 55, 112, 40, 43, 37, 102, 301, 301, 298, 260,
+ 301, 301, 212, 297, 301, 301, 274, 304, 301, 324, 257, 256, 228, 214, 301, 301,
+ 123, 54, 112, 301, 301, 301, 102, 301, 301, 298, 260, 301, 301, 212, 297, 301, 301,
+ 274, 301, 301, 304, 301, 207, 301, 301, 228, 214, 301, 301, 101, 77, 112, 280, 301,
+ 301, 102, 301, 301, 298, 260, 301, 301, 212, 297, 301, 301, 274, 304, 301, 301,
+ 301, 301, 228, 214, 301, 301, 123, 80, 112, 40, 43, 37, 102, 301, 301, 298, 260,
+ 301, 301, 212, 297, 301, 301, 274, 304, 301, 324, 257, 256, 228, 214, 301, 301,
+ 123, 56, 112, 301, 301, 301, 102, 301, 301, 298, 260, 301, 301, 212, 297, 301, 301,
+ 274, 301, 301, 304, 301, 207, 301, 301, 228, 214, 301, 301, 123, 70, 112, 194, 301,
+ 301, 102, 301, 301, 298, 260, 301, 301, 212, 297, 301, 301, 274, 304, 301, 301,
+ 301, 301, 228, 214, 301, 301, 123, 74, 112, 40, 43, 37, 102, 301, 301, 298, 260,
+ 301, 301, 212, 297, 301, 301, 274, 304, 301, 324, 257, 256, 228, 214, 301, 301,
+ 123, 49, 112, 301, 301, 301, 102, 301, 301, 298, 260, 301, 301, 212, 297, 301, 301,
+ 274, 301, 301, 304, 301, 207, 301, 301, 228, 214, 301, 301, 100, 57, 112, 301, 301,
+ 301, 102, 301, 301, 298, 260, 301, 301, 212, 297, 301, 301, 274, 304, 301, 301,
+ 301, 301, 228, 214, 301, 301, 123, 44, 112, 40, 43, 37, 102, 301, 301, 298, 260,
+ 301, 301, 212, 297, 301, 301, 274, 304, 301, 324, 257, 256, 228, 214, 301, 301,
+ 123, 69, 112, 301, 301, 301, 102, 301, 301, 298, 260, 301, 301, 212, 297, 301, 301,
+ 274, 301, 301, 304, 301, 301, 301, 301, 228, 214, 301, 301, 118, 50, 112, 301, 301,
+ 301, 102, 301, 301, 298, 260, 301, 301, 212, 297, 301, 301, 274, 304, 301, 301,
+ 301, 301, 228, 214, 301, 301, 123, 78, 112, 301, 301, 301, 102, 301, 301, 298, 260,
+ 207, 301, 212, 297, 301, 301, 274, 304, 301, 301, 359, 301, 228, 224, 301, 301,
+ 121, 301, 112, 301, 301, 288, 102, 301, 301, 36, 306, 301, 301, 212, 297, 301, 27,
+ 274, 301, 301, 304, 301, 301, 301, 52, 228, 224, 301, 301, 131, 301, 112, 301, 301,
+ 301, 102, 301, 301, 219, 321, 301, 301, 212, 297, 301, 301, 274, 219, 479, 479,
+ 301, 301, 301, 479, 463, 301, 301, 479, 479, 301, 30, 301, 479, 463, 417, 417, 301,
+ 301, 301, 301, 479, 479, 301, 207, 301, 479, 463, 301, 301, 301, 301, 301, 463,
+ 328, 463, 301, 479, 301, 463, 332, 207, 463, 301, 463, 288, 479, 301, 463, 36, 450,
+ 290, 417, 417, 417, 463, 27, 463, 301, 479, 301, 463, 450, 301, 52, 301, 36, 301,
+ 301, 417, 417, 417, 301, 27, 301, 301, 304, 301, 40, 43, 37, 228, 224, 301, 301,
+ 127, 301, 112, 301, 301, 301, 102, 301, 301, 301, 324, 257, 256, 212, 297, 301,
+ 301, 274, 301, 301, 304, 301, 301, 219, 301, 228, 224, 301, 301, 125, 301, 112,
+ 301, 479, 479, 102, 15, 301, 479, 463, 301, 301, 212, 297, 301, 301, 274, 534, 51,
+ 263, 285, 287, 229, 304, 301, 228, 301, 301, 228, 224, 207, 301, 124, 301, 112,
+ 301, 301, 463, 102, 463, 207, 479, 301, 463, 301, 212, 297, 301, 304, 274, 207,
+ 301, 301, 228, 224, 36, 301, 130, 301, 112, 301, 301, 27, 102, 301, 301, 301, 40,
+ 43, 37, 212, 297, 301, 32, 274, 36, 239, 40, 43, 37, 301, 301, 27, 301, 324, 257,
+ 256, 40, 43, 37, 301, 301, 301, 301, 324, 257, 256, 301, 301, 301, 301, 301, 304,
+ 301, 324, 257, 256, 228, 224, 301, 301, 129, 301, 112, 301, 301, 301, 102, 301,
+ 301, 26, 301, 301, 219, 212, 297, 301, 301, 274, 301, 479, 479, 301, 479, 479, 479,
+ 463, 207, 479, 463, 301, 301, 301, 301, 301, 301, 301, 301, 301, 301, 301, 301,
+ 301, 301, 301, 301, 301, 301, 301, 301, 301, 301, 301, 301, 463, 301, 463, 463,
+ 479, 463, 463, 479, 207, 463, 40, 43, 37, 301, 301, 301, 301, 301, 301, 301, 301,
+ 301, 301, 301, 301, 301, 301, 324, 257, 256, 301, 330, 301, 301, 301, 301, 301,
+ 301, 301, 301, 301, 301, 301, 411, 301, 40, 43, 37, 207, 301, 301, 301, 301, 411,
+ 301, 411, 301, 207, 411, 301, 317, 301, 324, 257, 256, 411, 301, 411, 301, 411,
+ 301, 301, 301, 301, 301, 301, 301, 111, 237, 301, 301, 301, 301, 301, 323, 40, 43,
+ 37, 301, 207, 301, 301, 301, 301, 40, 43, 37, 301, 301, 373, 301, 301, 324, 257,
+ 256, 301, 240, 301, 301, 301, 301, 324, 257, 256, 36, 301, 301, 301, 301, 301, 301,
+ 27, 301, 301, 450, 301, 301, 301, 301, 301, 301, 301, 301, 301, 301, 301, 450,);
+
+ static public $yy_lookahead = array(12, 13, 14, 36, 16, 17, 1, 19, 20, 12, 13, 71, 72, 25, 17, 48, 11, 29, 30, 31,
+ 32, 81, 34, 26, 36, 28, 2, 39, 14, 26, 33, 43, 44, 45, 46, 47, 33, 49, 98, 51,
+ 52, 23, 54, 71, 72, 71, 58, 12, 13, 14, 36, 16, 17, 81, 19, 20, 84, 85, 84, 85,
+ 25, 75, 76, 77, 29, 79, 31, 32, 54, 34, 98, 36, 98, 36, 39, 8, 9, 10, 43, 44,
+ 45, 46, 47, 14, 49, 48, 51, 52, 53, 54, 71, 72, 35, 58, 12, 13, 14, 67, 16, 17,
+ 81, 19, 20, 84, 85, 1, 15, 25, 21, 18, 53, 29, 13, 31, 32, 11, 34, 98, 36, 22,
+ 15, 39, 35, 54, 28, 43, 44, 45, 46, 47, 26, 49, 36, 51, 52, 36, 54, 33, 41, 48,
+ 58, 12, 13, 14, 48, 16, 17, 64, 19, 20, 70, 46, 69, 99, 25, 75, 59, 52, 29, 79,
+ 31, 32, 70, 34, 71, 36, 86, 75, 39, 51, 90, 79, 43, 44, 45, 46, 47, 35, 49, 37,
+ 51, 52, 90, 54, 1, 102, 103, 58, 12, 13, 14, 98, 16, 17, 11, 19, 20, 63, 64, 65,
+ 66, 25, 35, 69, 37, 29, 34, 31, 32, 26, 34, 17, 36, 12, 13, 39, 33, 72, 17, 43,
+ 44, 45, 46, 47, 72, 49, 81, 51, 52, 98, 54, 71, 72, 81, 58, 12, 13, 14, 93, 16,
+ 17, 81, 19, 20, 12, 13, 71, 72, 25, 17, 98, 50, 29, 1, 31, 32, 81, 34, 98, 36,
+ 22, 71, 39, 11, 36, 1, 43, 44, 45, 46, 47, 72, 49, 98, 51, 52, 48, 54, 26, 41,
+ 81, 58, 12, 13, 14, 33, 16, 17, 98, 19, 20, 53, 93, 71, 72, 25, 75, 76, 15, 29,
+ 79, 31, 32, 81, 34, 22, 36, 12, 13, 39, 11, 71, 17, 43, 44, 45, 46, 47, 72, 49,
+ 98, 51, 52, 15, 54, 18, 72, 81, 58, 12, 13, 14, 72, 16, 17, 81, 19, 20, 98, 99,
+ 15, 81, 25, 18, 98, 18, 29, 93, 31, 32, 1, 34, 64, 36, 46, 48, 39, 69, 72, 46,
+ 43, 44, 45, 46, 47, 52, 49, 81, 51, 52, 91, 54, 93, 48, 80, 58, 12, 13, 14, 93,
+ 16, 17, 22, 19, 20, 92, 18, 94, 95, 25, 46, 103, 35, 29, 37, 31, 32, 53, 34, 17,
+ 36, 41, 53, 39, 94, 95, 95, 43, 44, 45, 46, 47, 72, 49, 46, 51, 52, 15, 54, 22,
+ 52, 81, 58, 12, 13, 14, 72, 16, 17, 1, 19, 20, 50, 75, 76, 81, 25, 79, 98, 80,
+ 29, 89, 31, 32, 89, 34, 18, 36, 96, 51, 39, 96, 98, 1, 43, 44, 45, 46, 47, 26,
+ 49, 46, 51, 52, 75, 54, 33, 52, 79, 58, 12, 13, 14, 72, 16, 17, 14, 19, 20, 17,
+ 28, 65, 81, 25, 68, 1, 91, 29, 93, 31, 32, 79, 34, 37, 36, 11, 17, 39, 17, 98,
+ 14, 43, 44, 45, 46, 47, 9, 49, 96, 51, 26, 27, 54, 1, 1, 2, 58, 33, 94, 95, 3,
+ 4, 5, 6, 7, 8, 34, 1, 2, 12, 13, 13, 14, 16, 36, 17, 19, 20, 26, 17, 54, 42, 25,
+ 36, 72, 33, 29, 14, 31, 32, 17, 17, 64, 81, 46, 12, 13, 69, 70, 72, 17, 73, 74,
+ 75, 38, 39, 40, 79, 81, 17, 82, 83, 54, 17, 86, 87, 88, 17, 90, 17, 91, 55, 56,
+ 57, 51, 64, 71, 54, 100, 101, 69, 70, 53, 50, 73, 74, 75, 91, 53, 80, 79, 12,
+ 13, 82, 83, 17, 17, 86, 87, 88, 5, 90, 81, 98, 64, 26, 92, 28, 97, 69, 70, 91,
+ 33, 73, 74, 75, 76, 78, 93, 79, 79, 91, 82, 83, 79, 91, 86, 87, 88, 64, 90, 104,
+ 71, 72, 69, 70, 12, 13, 73, 74, 75, 17, 81, 79, 79, 84, 85, 82, 83, 79, 26, 86,
+ 87, 88, 91, 90, 79, 33, 64, 98, 91, 104, 97, 69, 70, 104, 104, 73, 74, 75, 76,
+ 104, 104, 79, 104, 1, 82, 83, 36, 11, 86, 87, 88, 15, 90, 11, 104, 64, 46, 104,
+ 48, 104, 69, 70, 26, 53, 73, 74, 75, 104, 26, 33, 79, 104, 36, 82, 83, 33, 104,
+ 86, 87, 88, 64, 90, 104, 104, 48, 69, 70, 104, 104, 73, 74, 75, 101, 104, 104,
+ 79, 104, 104, 82, 83, 104, 104, 86, 87, 88, 14, 90, 104, 17, 64, 104, 104, 104,
+ 97, 69, 70, 12, 13, 73, 74, 75, 17, 104, 104, 79, 104, 104, 82, 83, 104, 104,
+ 86, 87, 88, 104, 90, 104, 104, 64, 104, 49, 104, 51, 69, 70, 54, 104, 73, 74,
+ 75, 104, 104, 104, 79, 50, 104, 82, 83, 104, 104, 86, 87, 88, 64, 90, 104, 104,
+ 104, 69, 70, 104, 104, 73, 74, 75, 104, 104, 104, 79, 104, 104, 82, 83, 104,
+ 104, 86, 87, 88, 104, 90, 104, 104, 64, 104, 104, 104, 104, 69, 70, 104, 104,
+ 73, 74, 75, 104, 104, 104, 79, 104, 104, 82, 83, 104, 104, 86, 87, 88, 104, 90,
+ 104, 104, 64, 104, 104, 104, 104, 69, 70, 104, 104, 73, 74, 75, 104, 104, 104,
+ 79, 104, 104, 82, 83, 104, 104, 86, 87, 88, 64, 90, 104, 104, 104, 69, 70, 104,
+ 104, 73, 74, 75, 104, 104, 104, 79, 104, 104, 82, 83, 104, 104, 86, 87, 88, 104,
+ 90, 104, 104, 64, 104, 104, 104, 104, 69, 70, 104, 104, 73, 74, 75, 104, 104,
+ 104, 79, 104, 104, 82, 83, 104, 5, 86, 87, 88, 104, 90, 104, 12, 13, 14, 104,
+ 16, 104, 104, 19, 20, 104, 104, 104, 104, 25, 5, 104, 104, 29, 104, 31, 32, 12,
+ 13, 14, 104, 16, 104, 104, 19, 20, 104, 104, 104, 104, 25, 104, 104, 104, 29,
+ 104, 31, 32, 104, 104, 71, 72, 58, 59, 104, 71, 72, 104, 104, 104, 81, 64, 104,
+ 84, 85, 81, 69, 70, 84, 85, 73, 74, 75, 58, 59, 104, 79, 98, 104, 82, 83, 104,
+ 98, 86, 87, 88, 104, 90, 64, 104, 104, 71, 72, 69, 70, 104, 104, 73, 74, 75,
+ 104, 81, 104, 79, 84, 85, 82, 83, 104, 104, 86, 87, 88, 104, 90, 104, 104, 64,
+ 98, 1, 104, 104, 69, 70, 104, 104, 73, 74, 75, 11, 104, 104, 79, 104, 104, 82,
+ 83, 104, 104, 86, 87, 88, 104, 90, 64, 104, 104, 104, 104, 69, 70, 104, 104, 73,
+ 74, 75, 38, 39, 40, 79, 104, 104, 82, 83, 104, 104, 86, 87, 88, 104, 90, 64,
+ 104, 55, 56, 57, 69, 70, 104, 104, 73, 74, 75, 104, 104, 104, 79, 13, 14, 82,
+ 83, 17, 104, 86, 87, 88, 104, 90, 104, 104, 64, 104, 1, 104, 104, 69, 70, 104,
+ 34, 73, 74, 75, 11, 104, 104, 79, 104, 104, 82, 83, 104, 104, 86, 87, 88, 104,
+ 90, 64, 54, 104, 104, 104, 69, 70, 104, 104, 73, 74, 75, 38, 39, 40, 79, 104,
+ 104, 82, 83, 104, 104, 86, 87, 88, 104, 90, 64, 104, 55, 56, 57, 69, 70, 104,
+ 104, 73, 74, 75, 104, 104, 104, 79, 104, 104, 82, 83, 104, 104, 86, 87, 88, 104,
+ 90, 104, 104, 64, 104, 1, 104, 104, 69, 70, 104, 104, 73, 74, 75, 38, 39, 40,
+ 79, 104, 104, 82, 83, 104, 104, 86, 87, 88, 104, 90, 64, 27, 55, 56, 57, 69, 70,
+ 104, 104, 73, 74, 75, 38, 39, 40, 79, 104, 104, 82, 83, 104, 104, 86, 87, 88,
+ 104, 90, 64, 104, 55, 56, 57, 69, 70, 104, 104, 73, 74, 75, 104, 104, 104, 79,
+ 104, 104, 82, 83, 104, 104, 86, 87, 88, 104, 90, 104, 104, 64, 104, 1, 104, 104,
+ 69, 70, 104, 104, 73, 74, 75, 11, 104, 104, 79, 104, 104, 82, 83, 104, 104, 86,
+ 87, 88, 104, 90, 64, 104, 104, 104, 104, 69, 70, 104, 104, 73, 74, 75, 38, 39,
+ 40, 79, 104, 104, 82, 83, 104, 104, 86, 87, 88, 104, 90, 64, 104, 55, 56, 57,
+ 69, 70, 104, 104, 73, 74, 75, 104, 104, 104, 79, 104, 104, 82, 83, 104, 104, 86,
+ 87, 88, 104, 90, 104, 104, 64, 104, 1, 104, 104, 69, 70, 104, 104, 73, 74, 75,
+ 11, 104, 104, 79, 104, 104, 82, 83, 104, 104, 86, 87, 88, 104, 90, 64, 104, 104,
+ 104, 104, 69, 70, 104, 104, 73, 74, 75, 38, 39, 40, 79, 104, 104, 82, 83, 104,
+ 104, 86, 87, 88, 104, 90, 64, 104, 55, 56, 57, 69, 70, 104, 104, 73, 74, 75,
+ 104, 104, 104, 79, 104, 104, 82, 83, 104, 104, 86, 87, 88, 104, 90, 104, 104,
+ 64, 104, 1, 104, 104, 69, 70, 104, 104, 73, 74, 75, 104, 104, 104, 79, 104, 104,
+ 82, 83, 104, 104, 86, 87, 88, 104, 90, 64, 104, 104, 104, 104, 69, 70, 104, 104,
+ 73, 74, 75, 38, 39, 40, 79, 104, 104, 82, 83, 104, 104, 86, 87, 88, 104, 90, 64,
+ 104, 55, 56, 57, 69, 70, 104, 104, 73, 74, 75, 104, 104, 104, 79, 104, 104, 82,
+ 83, 104, 104, 86, 87, 88, 104, 90, 104, 104, 64, 104, 104, 104, 104, 69, 70,
+ 104, 104, 73, 74, 75, 104, 104, 104, 79, 104, 104, 82, 83, 104, 104, 86, 87, 88,
+ 104, 90, 64, 104, 104, 104, 104, 69, 70, 104, 104, 73, 74, 75, 104, 104, 104,
+ 79, 104, 104, 82, 83, 1, 104, 86, 87, 88, 104, 90, 64, 104, 104, 11, 104, 69,
+ 70, 104, 104, 73, 104, 75, 104, 104, 22, 79, 104, 104, 26, 83, 104, 104, 86, 87,
+ 88, 33, 90, 104, 104, 64, 104, 104, 104, 41, 69, 70, 104, 104, 73, 104, 75, 104,
+ 104, 104, 79, 104, 104, 2, 83, 104, 104, 86, 87, 88, 104, 90, 2, 12, 13, 104,
+ 104, 104, 17, 18, 104, 104, 12, 13, 104, 15, 104, 17, 18, 1, 2, 104, 104, 104,
+ 104, 12, 13, 104, 1, 104, 17, 18, 104, 104, 104, 104, 104, 46, 11, 48, 104, 50,
+ 104, 52, 53, 1, 46, 104, 48, 22, 50, 104, 52, 26, 36, 11, 38, 39, 40, 46, 33,
+ 48, 104, 50, 104, 52, 48, 104, 41, 104, 26, 104, 104, 55, 56, 57, 104, 33, 104,
+ 104, 64, 104, 38, 39, 40, 69, 70, 104, 104, 73, 104, 75, 104, 104, 104, 79, 104,
+ 104, 104, 55, 56, 57, 86, 87, 88, 104, 90, 104, 104, 64, 104, 104, 2, 104, 69,
+ 70, 104, 104, 73, 104, 75, 104, 12, 13, 79, 15, 104, 17, 18, 104, 104, 86, 87,
+ 88, 104, 90, 61, 62, 63, 64, 65, 66, 64, 104, 69, 104, 104, 69, 70, 1, 104, 73,
+ 104, 75, 104, 104, 46, 79, 48, 1, 50, 104, 52, 104, 86, 87, 88, 64, 90, 1, 104,
+ 104, 69, 70, 26, 104, 73, 104, 75, 104, 104, 33, 79, 104, 104, 104, 38, 39, 40,
+ 86, 87, 88, 24, 90, 26, 37, 38, 39, 40, 104, 104, 33, 104, 55, 56, 57, 38, 39,
+ 40, 104, 104, 104, 104, 55, 56, 57, 104, 104, 104, 104, 104, 64, 104, 55, 56,
+ 57, 69, 70, 104, 104, 73, 104, 75, 104, 104, 104, 79, 104, 104, 2, 104, 104, 2,
+ 86, 87, 88, 104, 90, 104, 12, 13, 104, 12, 13, 17, 18, 1, 17, 18, 104, 104, 104,
+ 104, 104, 104, 104, 104, 104, 104, 104, 104, 104, 104, 104, 104, 104, 104, 104,
+ 104, 104, 104, 104, 104, 46, 104, 48, 46, 50, 48, 52, 50, 1, 52, 38, 39, 40,
+ 104, 104, 104, 104, 104, 104, 104, 104, 104, 104, 104, 104, 104, 104, 55, 56,
+ 57, 104, 59, 104, 104, 104, 104, 104, 104, 104, 104, 104, 104, 104, 11, 104, 38,
+ 39, 40, 1, 104, 104, 104, 104, 21, 104, 23, 104, 1, 26, 104, 53, 104, 55, 56,
+ 57, 33, 104, 35, 104, 37, 104, 104, 104, 104, 104, 104, 104, 21, 46, 104, 104,
+ 104, 104, 104, 37, 38, 39, 40, 104, 1, 104, 104, 104, 104, 38, 39, 40, 104, 104,
+ 11, 104, 104, 55, 56, 57, 104, 18, 104, 104, 104, 104, 55, 56, 57, 26, 104, 104,
+ 104, 104, 104, 104, 33, 104, 104, 36, 104, 104, 104, 104, 104, 104, 104, 104,
+ 104, 104, 104, 48,);
+
+ const YY_SHIFT_USE_DFLT = - 34;
+
+ const YY_SHIFT_MAX = 242;
+
+ static public $yy_shift_ofst = array(517, 270, 82, 270, 317, 82, 82, 317, - 12, - 12, 35, 411, 82, 82, 82, 129, 82,
+ 82, 82, 176, 82, 82, 82, 82, 82, 82, 223, 82, 82, 82, 82, 82, 82, 82, 82, 82,
+ 411, 364, 364, 458, 458, 458, 458, 458, 1830, 1706, 1810, 1810, 1810, 1810,
+ 1810, 517, 733, 933, 2001, 1306, 1389, 1223, 1820, 1952, 526, 1917, 1992, 1140,
+ 1057, 1472, 1472, 1472, 2033, 1472, 1472, 1472, 1472, 1472, 1472, 1472, 1472,
+ 1472, 1196, 1689, 1196, 1600, 533, 183, 512, 14, 954, - 3, 589, 634, 634, 684,
+ 684, 512, 512, 368, 14, 14, 512, 513, 484, 104, 746, 518, 252, 67, 232, 91,
+ 232, 325, 3, 486, 307, 462, 433, 428, 349, 3, 5, 452, 462, 264, 327, 264, 264,
+ 264, 264, 264, 327, 264, 264, - 34, 1772, 1653, 1662, 1902, 1899, 1675, 1113,
+ 543, 105, 295, 3, 415, 69, 69, 3, 3, 313, 313, 3, 313, 3, 3, 3, 3, 3, 3, 283,
+ 3, 415, 3, 3, 3, 3, 69, 313, 3, 3, 3, 313, 313, 313, 99, 313, 3, 3, 3, 69, 3,
+ 498, 264, 264, 24, 497, 264, 327, 327, 327, 264, 24, 264, - 34, - 34, - 34,
+ - 34, - 34, 1680, 1977, 678, 201, 652, 238, 97, 96, 357, 228, 382, 344, 308,
+ 142, 57, 37, - 33, 360, 87, 167, 539, 545, 562, 507, 194, 172, 118, 397, 456,
+ 402, 18, 299, 605, 556, 588, 552, 508, 481, 479, 398, 492, 534, 499, 522, 560,
+ 498,);
+
+ const YY_REDUCE_USE_DFLT = - 61;
+
+ const YY_REDUCE_MAX = 196;
+
+ static public $yy_reduce_ofst = array(1737, 488, 575, 633, 550, 658, 521, 604, 770, 1102, 1075, 1407, 1461, 1517,
+ 1351, 1158, 1212, 1295, 1046, 716, 992, 936, 853, 963, 1019, 687, 1268, 1241,
+ 1129, 1185, 1490, 1434, 1378, 1324, 799, 824, 741, 1544, 1573, 1819, 1678,
+ 1740, 1707, 1765, 923, - 28, 571, - 28, 19, 918, 959, 134, 80, 83, - 26, - 26,
+ - 26, - 26, - 26, - 26, - 26, - 26, - 26, - 26, - 26, - 26, - 26, - 26, 160,
+ - 26, - 26, - 26, - 26, - 26, - 26, - 26, - 26, - 26, - 26, 222, - 26, 222,
+ 92, 175, - 60, - 14, 288, 145, 199, 286, 254, 152, 246, 354, 401, 293, 358,
+ 221, 340, 240, 190, 190, 279, 412, 190, 416, 395, 310, 279, 310, 472, 389,
+ 310, 352, 260, 93, 190, 487, 190, 190, 355, 190, 310, 190, 190, 190, 515, 190,
+ 424, 190, 190, 190, 530, 530, 530, 530, 530, 530, 551, 535, 530, 530, 531,
+ 540, 574, 555, 531, 531, 524, 524, 531, 524, 531, 531, 531, 531, 531, 531,
+ 549, 531, 544, 531, 531, 531, 531, 587, 524, 531, 531, 531, 524, 524, 524,
+ 573, 524, 531, 531, 531, 580, 531, 579, 131, 131, 54, 30, 131, 311, 311, 311,
+ 131, 54, 131, 294, 519, 489, 359, 506,);
+
+ static public $yyExpectedTokens = array(array(3, 4, 5, 6, 7, 8, 12, 13, 16, 19, 20, 25, 29, 31, 32,),
+ array(12, 13, 14, 16, 17, 19, 20, 25, 29, 31, 32, 34, 36, 39, 43, 44, 45,
+ 46, 47, 49, 51, 52, 54, 58,),
+ array(12, 13, 14, 16, 17, 19, 20, 25, 29, 31, 32, 34, 36, 39, 43, 44, 45,
+ 46, 47, 49, 51, 52, 54, 58,),
+ array(12, 13, 14, 16, 17, 19, 20, 25, 29, 31, 32, 34, 36, 39, 43, 44, 45,
+ 46, 47, 49, 51, 52, 54, 58,),
+ array(12, 13, 14, 16, 17, 19, 20, 25, 29, 31, 32, 34, 36, 39, 43, 44, 45,
+ 46, 47, 49, 51, 52, 54, 58,),
+ array(12, 13, 14, 16, 17, 19, 20, 25, 29, 31, 32, 34, 36, 39, 43, 44, 45,
+ 46, 47, 49, 51, 52, 54, 58,),
+ array(12, 13, 14, 16, 17, 19, 20, 25, 29, 31, 32, 34, 36, 39, 43, 44, 45,
+ 46, 47, 49, 51, 52, 54, 58,),
+ array(12, 13, 14, 16, 17, 19, 20, 25, 29, 31, 32, 34, 36, 39, 43, 44, 45,
+ 46, 47, 49, 51, 52, 54, 58,),
+ array(12, 13, 14, 16, 17, 19, 20, 25, 29, 30, 31, 32, 34, 36, 39, 43, 44,
+ 45, 46, 47, 49, 51, 52, 54, 58,),
+ array(12, 13, 14, 16, 17, 19, 20, 25, 29, 30, 31, 32, 34, 36, 39, 43, 44,
+ 45, 46, 47, 49, 51, 52, 54, 58,),
+ array(12, 13, 14, 16, 17, 19, 20, 25, 29, 31, 32, 34, 36, 39, 43, 44, 45,
+ 46, 47, 49, 51, 52, 53, 54, 58,),
+ array(12, 13, 14, 16, 17, 19, 20, 25, 29, 31, 32, 34, 36, 39, 43, 44, 45,
+ 46, 47, 49, 51, 52, 54, 58,),
+ array(12, 13, 14, 16, 17, 19, 20, 25, 29, 31, 32, 34, 36, 39, 43, 44, 45,
+ 46, 47, 49, 51, 52, 54, 58,),
+ array(12, 13, 14, 16, 17, 19, 20, 25, 29, 31, 32, 34, 36, 39, 43, 44, 45,
+ 46, 47, 49, 51, 52, 54, 58,),
+ array(12, 13, 14, 16, 17, 19, 20, 25, 29, 31, 32, 34, 36, 39, 43, 44, 45,
+ 46, 47, 49, 51, 52, 54, 58,),
+ array(12, 13, 14, 16, 17, 19, 20, 25, 29, 31, 32, 34, 36, 39, 43, 44, 45,
+ 46, 47, 49, 51, 52, 54, 58,),
+ array(12, 13, 14, 16, 17, 19, 20, 25, 29, 31, 32, 34, 36, 39, 43, 44, 45,
+ 46, 47, 49, 51, 52, 54, 58,),
+ array(12, 13, 14, 16, 17, 19, 20, 25, 29, 31, 32, 34, 36, 39, 43, 44, 45,
+ 46, 47, 49, 51, 52, 54, 58,),
+ array(12, 13, 14, 16, 17, 19, 20, 25, 29, 31, 32, 34, 36, 39, 43, 44, 45,
+ 46, 47, 49, 51, 52, 54, 58,),
+ array(12, 13, 14, 16, 17, 19, 20, 25, 29, 31, 32, 34, 36, 39, 43, 44, 45,
+ 46, 47, 49, 51, 52, 54, 58,),
+ array(12, 13, 14, 16, 17, 19, 20, 25, 29, 31, 32, 34, 36, 39, 43, 44, 45,
+ 46, 47, 49, 51, 52, 54, 58,),
+ array(12, 13, 14, 16, 17, 19, 20, 25, 29, 31, 32, 34, 36, 39, 43, 44, 45,
+ 46, 47, 49, 51, 52, 54, 58,),
+ array(12, 13, 14, 16, 17, 19, 20, 25, 29, 31, 32, 34, 36, 39, 43, 44, 45,
+ 46, 47, 49, 51, 52, 54, 58,),
+ array(12, 13, 14, 16, 17, 19, 20, 25, 29, 31, 32, 34, 36, 39, 43, 44, 45,
+ 46, 47, 49, 51, 52, 54, 58,),
+ array(12, 13, 14, 16, 17, 19, 20, 25, 29, 31, 32, 34, 36, 39, 43, 44, 45,
+ 46, 47, 49, 51, 52, 54, 58,),
+ array(12, 13, 14, 16, 17, 19, 20, 25, 29, 31, 32, 34, 36, 39, 43, 44, 45,
+ 46, 47, 49, 51, 52, 54, 58,),
+ array(12, 13, 14, 16, 17, 19, 20, 25, 29, 31, 32, 34, 36, 39, 43, 44, 45,
+ 46, 47, 49, 51, 52, 54, 58,),
+ array(12, 13, 14, 16, 17, 19, 20, 25, 29, 31, 32, 34, 36, 39, 43, 44, 45,
+ 46, 47, 49, 51, 52, 54, 58,),
+ array(12, 13, 14, 16, 17, 19, 20, 25, 29, 31, 32, 34, 36, 39, 43, 44, 45,
+ 46, 47, 49, 51, 52, 54, 58,),
+ array(12, 13, 14, 16, 17, 19, 20, 25, 29, 31, 32, 34, 36, 39, 43, 44, 45,
+ 46, 47, 49, 51, 52, 54, 58,),
+ array(12, 13, 14, 16, 17, 19, 20, 25, 29, 31, 32, 34, 36, 39, 43, 44, 45,
+ 46, 47, 49, 51, 52, 54, 58,),
+ array(12, 13, 14, 16, 17, 19, 20, 25, 29, 31, 32, 34, 36, 39, 43, 44, 45,
+ 46, 47, 49, 51, 52, 54, 58,),
+ array(12, 13, 14, 16, 17, 19, 20, 25, 29, 31, 32, 34, 36, 39, 43, 44, 45,
+ 46, 47, 49, 51, 52, 54, 58,),
+ array(12, 13, 14, 16, 17, 19, 20, 25, 29, 31, 32, 34, 36, 39, 43, 44, 45,
+ 46, 47, 49, 51, 52, 54, 58,),
+ array(12, 13, 14, 16, 17, 19, 20, 25, 29, 31, 32, 34, 36, 39, 43, 44, 45,
+ 46, 47, 49, 51, 52, 54, 58,),
+ array(12, 13, 14, 16, 17, 19, 20, 25, 29, 31, 32, 34, 36, 39, 43, 44, 45,
+ 46, 47, 49, 51, 52, 54, 58,),
+ array(12, 13, 14, 16, 17, 19, 20, 25, 29, 31, 32, 34, 36, 39, 43, 44, 45,
+ 46, 47, 49, 51, 52, 54, 58,),
+ array(12, 13, 14, 16, 17, 19, 20, 25, 29, 31, 32, 34, 36, 39, 43, 44, 45,
+ 46, 47, 49, 51, 52, 54, 58,),
+ array(12, 13, 14, 16, 17, 19, 20, 25, 29, 31, 32, 34, 36, 39, 43, 44, 45,
+ 46, 47, 49, 51, 52, 54, 58,),
+ array(12, 13, 14, 16, 17, 19, 20, 25, 29, 31, 32, 34, 36, 39, 43, 44, 45,
+ 46, 47, 49, 51, 54, 58,),
+ array(12, 13, 14, 16, 17, 19, 20, 25, 29, 31, 32, 34, 36, 39, 43, 44, 45,
+ 46, 47, 49, 51, 54, 58,),
+ array(12, 13, 14, 16, 17, 19, 20, 25, 29, 31, 32, 34, 36, 39, 43, 44, 45,
+ 46, 47, 49, 51, 54, 58,),
+ array(12, 13, 14, 16, 17, 19, 20, 25, 29, 31, 32, 34, 36, 39, 43, 44, 45,
+ 46, 47, 49, 51, 54, 58,),
+ array(12, 13, 14, 16, 17, 19, 20, 25, 29, 31, 32, 34, 36, 39, 43, 44, 45,
+ 46, 47, 49, 51, 54, 58,),
+ array(1, 24, 26, 33, 38, 39, 40, 55, 56, 57,),
+ array(1, 11, 26, 33, 38, 39, 40, 55, 56, 57,),
+ array(1, 26, 33, 38, 39, 40, 55, 56, 57,),
+ array(1, 26, 33, 38, 39, 40, 55, 56, 57,),
+ array(1, 26, 33, 38, 39, 40, 55, 56, 57,),
+ array(1, 26, 33, 38, 39, 40, 55, 56, 57,),
+ array(1, 26, 33, 38, 39, 40, 55, 56, 57,),
+ array(3, 4, 5, 6, 7, 8, 12, 13, 16, 19, 20, 25, 29, 31, 32,),
+ array(14, 17, 49, 51, 54,),
+ array(5, 12, 13, 14, 16, 19, 20, 25, 29, 31, 32, 58, 59,),
+ array(1, 21, 38, 39, 40, 55, 56, 57,),
+ array(1, 11, 38, 39, 40, 55, 56, 57,),
+ array(1, 11, 38, 39, 40, 55, 56, 57,),
+ array(1, 27, 38, 39, 40, 55, 56, 57,),
+ array(1, 37, 38, 39, 40, 55, 56, 57,),
+ array(1, 38, 39, 40, 53, 55, 56, 57,), array(1, 2, 38, 39, 40, 55, 56, 57,),
+ array(1, 38, 39, 40, 55, 56, 57, 59,),
+ array(1, 37, 38, 39, 40, 55, 56, 57,),
+ array(1, 11, 38, 39, 40, 55, 56, 57,),
+ array(1, 11, 38, 39, 40, 55, 56, 57,), array(1, 38, 39, 40, 55, 56, 57,),
+ array(1, 38, 39, 40, 55, 56, 57,), array(1, 38, 39, 40, 55, 56, 57,),
+ array(1, 11, 18, 26, 33, 36, 48,), array(1, 38, 39, 40, 55, 56, 57,),
+ array(1, 38, 39, 40, 55, 56, 57,), array(1, 38, 39, 40, 55, 56, 57,),
+ array(1, 38, 39, 40, 55, 56, 57,), array(1, 38, 39, 40, 55, 56, 57,),
+ array(1, 38, 39, 40, 55, 56, 57,), array(1, 38, 39, 40, 55, 56, 57,),
+ array(1, 38, 39, 40, 55, 56, 57,), array(1, 38, 39, 40, 55, 56, 57,),
+ array(38, 39, 40, 55, 56, 57,), array(1, 11, 22, 26, 33, 41,),
+ array(38, 39, 40, 55, 56, 57,), array(1, 11, 22, 26, 33, 41,),
+ array(14, 17, 51, 54,), array(1, 11, 26, 33,), array(1, 26, 33,),
+ array(14, 36, 54,),
+ array(5, 12, 13, 14, 16, 19, 20, 25, 29, 31, 32, 58, 59,),
+ array(12, 13, 17, 26, 28, 33,), array(12, 13, 17, 26, 28, 33,),
+ array(12, 13, 17, 26, 33,), array(12, 13, 17, 26, 33,),
+ array(1, 11, 26, 33,), array(1, 11, 26, 33,), array(1, 26, 33,),
+ array(1, 26, 33,), array(18, 46, 52,), array(14, 36, 54,),
+ array(14, 36, 54,), array(1, 26, 33,), array(1, 2,),
+ array(1, 11, 26, 27, 33,), array(1, 11, 26, 33,), array(12, 13, 17, 50,),
+ array(13, 14, 17, 54,), array(1, 11, 26, 33,), array(8, 9, 10,),
+ array(12, 13, 17,), array(15, 18, 48,), array(12, 13, 17,),
+ array(15, 18, 48,), array(26, 33,), array(14, 54,), array(18, 48,),
+ array(14, 17,), array(26, 33,), array(1, 18,), array(1, 53,),
+ array(26, 33,), array(1, 11,), array(1, 28,), array(14, 17,), array(1,),
+ array(18,), array(1,), array(1,), array(1,), array(1,), array(1,),
+ array(18,), array(1,), array(1,), array(),
+ array(2, 12, 13, 15, 17, 18, 46, 48, 50, 52,),
+ array(2, 12, 13, 17, 18, 46, 48, 50, 52, 53,),
+ array(2, 12, 13, 15, 17, 18, 46, 48, 50, 52,),
+ array(2, 12, 13, 17, 18, 46, 48, 50, 52,),
+ array(2, 12, 13, 17, 18, 46, 48, 50, 52,),
+ array(12, 13, 17, 18, 46, 48, 50, 52,), array(13, 14, 17, 34, 54,),
+ array(12, 13, 17, 50,), array(15, 46, 52,), array(12, 13, 17,),
+ array(26, 33,), array(46, 52,), array(14, 54,), array(14, 54,),
+ array(26, 33,), array(26, 33,), array(46, 52,), array(46, 52,),
+ array(26, 33,), array(46, 52,), array(26, 33,), array(26, 33,),
+ array(26, 33,), array(26, 33,), array(26, 33,), array(26, 33,),
+ array(15, 22,), array(26, 33,), array(46, 52,), array(26, 33,),
+ array(26, 33,), array(26, 33,), array(26, 33,), array(14, 54,),
+ array(46, 52,), array(26, 33,), array(26, 33,), array(26, 33,),
+ array(46, 52,), array(46, 52,), array(46, 52,), array(13, 36,),
+ array(46, 52,), array(26, 33,), array(26, 33,), array(26, 33,),
+ array(14, 54,), array(26, 33,), array(36,), array(1,), array(1,), array(2,),
+ array(9,), array(1,), array(18,), array(18,), array(18,), array(1,),
+ array(2,), array(1,), array(), array(), array(), array(), array(),
+ array(1, 2, 36, 38, 39, 40, 48, 55, 56, 57,),
+ array(11, 21, 23, 26, 33, 35, 37, 46,), array(11, 15, 26, 33, 36, 48,),
+ array(12, 13, 17, 50,), array(36, 46, 48, 53,), array(22, 41, 53,),
+ array(22, 41, 59,), array(28, 36, 48,), array(35, 37,), array(36, 48,),
+ array(17, 50,), array(46, 53,), array(15, 46,), array(35, 37,),
+ array(35, 53,), array(36, 48,), array(36, 48,), array(22, 41,),
+ array(21, 35,), array(35, 37,), array(53,), array(53,), array(17,),
+ array(36,), array(17,), array(34,), array(51,), array(22,), array(37,),
+ array(15,), array(23,), array(11,), array(5,), array(17,), array(17,),
+ array(17,), array(46,), array(17,), array(17,), array(51,), array(34,),
+ array(17,), array(42,), array(17,), array(17,), array(36,), array(),
+ array(), array(), array(), array(), array(), array(), array(), array(),
+ array(), array(), array(), array(), array(), array(), array(), array(),
+ array(), array(), array(), array(), array(), array(), array(), array(),
+ array(), array(), array(), array(), array(), array(), array(), array(),
+ array(), array(), array(), array(), array(), array(), array(), array(),
+ array(), array(), array(), array(), array(), array(), array(), array(),
+ array(), array(), array(), array(), array(), array(), array(), array(),
+ array(), array(), array(), array(), array(), array(), array(), array(),
+ array(), array(), array(), array(), array(), array(), array(), array(),
+ array(), array(), array(), array(), array(), array(), array(), array(),
+ array(), array(), array(), array(), array(), array(), array(), array(),
+ array(), array(), array(), array(), array(), array(),);
+
+ static public $yy_default = array(341, 518, 498, 533, 533, 498, 498, 533, 533, 533, 533, 533, 533, 533, 533, 533,
+ 533, 533, 533, 533, 533, 533, 533, 533, 533, 533, 533, 533, 533, 533, 533, 533,
+ 533, 533, 533, 533, 533, 533, 533, 533, 533, 533, 533, 533, 401, 533, 377, 401,
+ 401, 401, 368, 338, 533, 533, 533, 533, 533, 406, 533, 533, 533, 533, 533, 533,
+ 533, 520, 521, 422, 440, 382, 496, 406, 412, 497, 519, 408, 413, 403, 429, 430,
+ 428, 430, 533, 415, 401, 533, 533, 401, 401, 401, 401, 447, 421, 401, 401, 510,
+ 533, 533, 401, 391, 415, 415, 463, 533, 415, 533, 463, 453, 463, 453, 379, 533,
+ 453, 533, 401, 395, 415, 401, 415, 415, 533, 425, 453, 415, 433, 431, 397, 418,
+ 507, 432, 419, 505, 452, 452, 452, 452, 452, 452, 533, 465, 479, 463, 386, 456,
+ 533, 533, 388, 387, 461, 457, 364, 459, 384, 360, 385, 361, 380, 378, 533, 363,
+ 458, 365, 369, 381, 366, 533, 490, 376, 375, 372, 491, 460, 489, 463, 488, 370,
+ 374, 390, 533, 389, 463, 421, 396, 499, 354, 398, 511, 508, 485, 392, 500, 447,
+ 504, 504, 463, 504, 463, 440, 436, 440, 464, 440, 430, 430, 440, 533, 440, 533,
+ 436, 436, 533, 533, 533, 448, 430, 533, 533, 533, 443, 533, 509, 533, 533, 533,
+ 430, 533, 533, 409, 533, 346, 533, 533, 533, 436, 533, 533, 533, 438, 533, 442,
+ 533, 533, 479, 451, 503, 394, 486, 383, 483, 400, 410, 481, 482, 402, 450, 502,
+ 514, 513, 479, 501, 420, 427, 426, 339, 487, 480, 350, 351, 352, 353, 349, 347,
+ 344, 345, 455, 348, 355, 356, 358, 399, 484, 371, 357, 340, 454, 342, 414, 343,
+ 434, 531, 530, 466, 467, 468, 462, 417, 526, 441, 416, 528, 443, 444, 516, 517,
+ 446, 515, 424, 423, 445, 495, 532, 525, 492, 475, 493, 393, 522, 477, 437, 494,
+ 469, 506, 435, 442, 512, 523, 439, 470, 529, 473, 527, 476, 474, 478, 472, 524,
+ 471, 449,);
+
+ const YYNOCODE = 105;
const YYSTACKDEPTH = 500;
- const YYNSTATE = 331;
+ const YYNSTATE = 338;
- const YYNRULE = 192;
+ const YYNRULE = 195;
- const YYERRORSYMBOL = 61;
+ const YYERRORSYMBOL = 60;
const YYERRSYMDT = 'yy0';
@@ -722,90 +906,127 @@ class Smarty_Internal_Templateparser
public $yyerrcnt; /* Shifts left before out of the error */
public $yystack = array(); /* The parser's stack */
- public $yyTokenName = array('$', 'VERT', 'COLON', 'PHP', 'NOCACHE', 'TEXT', 'STRIPON', 'STRIPOFF', 'BLOCKSOURCE',
- 'LITERALSTART', 'LITERALEND', 'LITERAL', 'RDEL', 'SIMPLEOUTPUT', 'LDEL', 'DOLLARID', 'EQUAL', 'SIMPLETAG', 'ID',
- 'PTR', 'LDELIF', 'LDELFOR', 'SEMICOLON', 'INCDEC', 'TO', 'STEP', 'LDELFOREACH', 'SPACE', 'AS', 'APTR',
- 'LDELSETFILTER', 'SMARTYBLOCKCHILDPARENT', 'CLOSETAG', 'LDELSLASH', 'ATTR', 'INTEGER', 'COMMA', 'OPENP',
- 'CLOSEP', 'MATH', 'UNIMATH', 'ISIN', 'INSTANCEOF', 'QMARK', 'NOT', 'TYPECAST', 'HEX', 'DOT',
- 'SINGLEQUOTESTRING', 'DOUBLECOLON', 'NAMESPACE', 'AT', 'HATCH', 'OPENB', 'CLOSEB', 'DOLLAR', 'LOGOP', 'TLOGOP',
- 'SINGLECOND', 'QUOTE', 'BACKTICK', 'error', 'start', 'template', 'template_element', 'smartytag', 'literal',
- 'text_content', 'literal_elements', 'literal_element', 'tag', 'variable', 'attributes', 'value', 'expr',
- 'varindexed', 'modifierlist', 'statement', 'statements', 'foraction', 'varvar', 'modparameters', 'attribute',
- 'ternary', 'array', 'lop', 'scond', 'ns1', 'function', 'doublequoted_with_quotes', 'static_class_access',
- 'object', 'arrayindex', 'indexdef', 'varvarele', 'objectchain', 'objectelement', 'method', 'params', 'modifier',
- 'modparameter', 'arrayelements', 'arrayelement', 'doublequoted', 'doublequotedcontent',);
+ public $yyTokenName = array('$', 'VERT', 'COLON', 'PHP', 'NOCACHE', 'TEXT', 'STRIPON', 'STRIPOFF', 'LITERALSTART',
+ 'LITERALEND', 'LITERAL', 'RDEL', 'SIMPELOUTPUT', 'LDEL', 'DOLLARID', 'EQUAL',
+ 'SIMPLETAG', 'ID', 'PTR', 'LDELIF', 'LDELFOR', 'SEMICOLON', 'INCDEC', 'TO', 'STEP',
+ 'LDELFOREACH', 'SPACE', 'AS', 'APTR', 'LDELSETFILTER', 'SMARTYBLOCKCHILDPARENT',
+ 'CLOSETAG', 'LDELSLASH', 'ATTR', 'INTEGER', 'COMMA', 'OPENP', 'CLOSEP', 'MATH',
+ 'UNIMATH', 'ISIN', 'INSTANCEOF', 'QMARK', 'NOT', 'TYPECAST', 'HEX', 'DOT',
+ 'SINGLEQUOTESTRING', 'DOUBLECOLON', 'NAMESPACE', 'AT', 'HATCH', 'OPENB', 'CLOSEB',
+ 'DOLLAR', 'LOGOP', 'TLOGOP', 'SINGLECOND', 'QUOTE', 'BACKTICK', 'error', 'start',
+ 'template', 'template_element', 'smartytag', 'literal', 'text_content',
+ 'literal_elements', 'literal_element', 'tag', 'variable', 'modifierlist', 'attributes',
+ 'value', 'expr', 'varindexed', 'statement', 'statements', 'foraction', 'varvar',
+ 'modparameters', 'attribute', 'ternary', 'array', 'lop', 'scond', 'ns1', 'function',
+ 'doublequoted_with_quotes', 'static_class_access', 'object', 'arrayindex', 'indexdef',
+ 'varvarele', 'objectchain', 'objectelement', 'method', 'params', 'modifier',
+ 'modparameter', 'arrayelements', 'arrayelement', 'doublequoted',
+ 'doublequotedcontent',);
public static $yyRuleName = array('start ::= template', 'template ::= template_element',
- 'template ::= template template_element', 'template ::=', 'template_element ::= smartytag',
- 'template_element ::= literal', 'template_element ::= PHP', 'template_element ::= NOCACHE',
- 'template_element ::= text_content', 'text_content ::= TEXT', 'text_content ::= text_content TEXT',
- 'template_element ::= STRIPON', 'template_element ::= STRIPOFF', 'template_element ::= BLOCKSOURCE',
- 'literal ::= LITERALSTART LITERALEND', 'literal ::= LITERALSTART literal_elements LITERALEND',
- 'literal_elements ::= literal_elements literal_element', 'literal_elements ::=', 'literal_element ::= literal',
- 'literal_element ::= LITERAL', 'smartytag ::= tag RDEL', 'smartytag ::= SIMPLEOUTPUT', 'tag ::= LDEL variable',
- 'tag ::= LDEL variable attributes', 'tag ::= LDEL value', 'tag ::= LDEL value attributes', 'tag ::= LDEL expr',
- 'tag ::= LDEL expr attributes', 'tag ::= LDEL DOLLARID EQUAL value', 'tag ::= LDEL DOLLARID EQUAL expr',
- 'tag ::= LDEL DOLLARID EQUAL expr attributes', 'tag ::= LDEL varindexed EQUAL expr attributes',
- 'smartytag ::= SIMPLETAG', 'tag ::= LDEL ID attributes', 'tag ::= LDEL ID',
- 'tag ::= LDEL ID modifierlist attributes', 'tag ::= LDEL ID PTR ID attributes',
- 'tag ::= LDEL ID PTR ID modifierlist attributes', 'tag ::= LDELIF expr', 'tag ::= LDELIF expr attributes',
- 'tag ::= LDELIF statement', 'tag ::= LDELIF statement attributes',
- 'tag ::= LDELFOR statements SEMICOLON expr SEMICOLON varindexed foraction attributes',
- 'foraction ::= EQUAL expr', 'foraction ::= INCDEC', 'tag ::= LDELFOR statement TO expr attributes',
- 'tag ::= LDELFOR statement TO expr STEP expr attributes', 'tag ::= LDELFOREACH attributes',
- 'tag ::= LDELFOREACH SPACE value AS varvar attributes',
- 'tag ::= LDELFOREACH SPACE value AS varvar APTR varvar attributes',
- 'tag ::= LDELFOREACH SPACE expr AS varvar attributes',
- 'tag ::= LDELFOREACH SPACE expr AS varvar APTR varvar attributes', 'tag ::= LDELSETFILTER ID modparameters',
- 'tag ::= LDELSETFILTER ID modparameters modifierlist', 'tag ::= LDEL SMARTYBLOCKCHILDPARENT',
- 'smartytag ::= CLOSETAG', 'tag ::= LDELSLASH ID', 'tag ::= LDELSLASH ID modifierlist',
- 'tag ::= LDELSLASH ID PTR ID', 'tag ::= LDELSLASH ID PTR ID modifierlist',
- 'attributes ::= attributes attribute', 'attributes ::= attribute', 'attributes ::=',
- 'attribute ::= SPACE ID EQUAL ID', 'attribute ::= ATTR expr', 'attribute ::= ATTR value',
- 'attribute ::= SPACE ID', 'attribute ::= SPACE expr', 'attribute ::= SPACE value',
- 'attribute ::= SPACE INTEGER EQUAL expr', 'statements ::= statement',
- 'statements ::= statements COMMA statement', 'statement ::= DOLLARID EQUAL INTEGER',
- 'statement ::= DOLLARID EQUAL expr', 'statement ::= varindexed EQUAL expr',
- 'statement ::= OPENP statement CLOSEP', 'expr ::= value', 'expr ::= ternary', 'expr ::= DOLLARID COLON ID',
- 'expr ::= expr MATH value', 'expr ::= expr UNIMATH value', 'expr ::= array', 'expr ::= expr modifierlist',
- 'expr ::= expr lop expr', 'expr ::= expr scond', 'expr ::= expr ISIN array', 'expr ::= expr ISIN value',
- 'expr ::= variable INSTANCEOF ns1', 'ternary ::= OPENP expr CLOSEP QMARK DOLLARID COLON expr',
- 'ternary ::= OPENP expr CLOSEP QMARK expr COLON expr', 'value ::= variable', 'value ::= UNIMATH value',
- 'value ::= NOT value', 'value ::= TYPECAST value', 'value ::= variable INCDEC', 'value ::= HEX',
- 'value ::= INTEGER', 'value ::= INTEGER DOT INTEGER', 'value ::= INTEGER DOT', 'value ::= DOT INTEGER',
- 'value ::= ID', 'value ::= function', 'value ::= OPENP expr CLOSEP', 'value ::= SINGLEQUOTESTRING',
- 'value ::= doublequoted_with_quotes', 'value ::= varindexed DOUBLECOLON static_class_access',
- 'value ::= smartytag', 'value ::= value modifierlist', 'value ::= NAMESPACE',
- 'value ::= ns1 DOUBLECOLON static_class_access', 'ns1 ::= ID', 'ns1 ::= NAMESPACE', 'variable ::= DOLLARID',
- 'variable ::= varindexed', 'variable ::= varvar AT ID', 'variable ::= object', 'variable ::= HATCH ID HATCH',
- 'variable ::= HATCH ID HATCH arrayindex', 'variable ::= HATCH variable HATCH',
- 'variable ::= HATCH variable HATCH arrayindex', 'varindexed ::= DOLLARID arrayindex',
- 'varindexed ::= varvar arrayindex', 'arrayindex ::= arrayindex indexdef', 'arrayindex ::=',
- 'indexdef ::= DOT DOLLARID', 'indexdef ::= DOT varvar', 'indexdef ::= DOT varvar AT ID', 'indexdef ::= DOT ID',
- 'indexdef ::= DOT INTEGER', 'indexdef ::= DOT LDEL expr RDEL', 'indexdef ::= OPENB ID CLOSEB',
- 'indexdef ::= OPENB ID DOT ID CLOSEB', 'indexdef ::= OPENB SINGLEQUOTESTRING CLOSEB',
- 'indexdef ::= OPENB INTEGER CLOSEB', 'indexdef ::= OPENB DOLLARID CLOSEB', 'indexdef ::= OPENB variable CLOSEB',
- 'indexdef ::= OPENB value CLOSEB', 'indexdef ::= OPENB expr CLOSEB', 'indexdef ::= OPENB CLOSEB',
- 'varvar ::= DOLLARID', 'varvar ::= DOLLAR', 'varvar ::= varvar varvarele', 'varvarele ::= ID',
- 'varvarele ::= LDEL expr RDEL', 'object ::= varindexed objectchain', 'objectchain ::= objectelement',
- 'objectchain ::= objectchain objectelement', 'objectelement ::= PTR ID arrayindex',
- 'objectelement ::= PTR varvar arrayindex', 'objectelement ::= PTR LDEL expr RDEL arrayindex',
- 'objectelement ::= PTR ID LDEL expr RDEL arrayindex', 'objectelement ::= PTR method',
- 'function ::= ns1 OPENP params CLOSEP', 'method ::= ID OPENP params CLOSEP',
- 'method ::= DOLLARID OPENP params CLOSEP', 'params ::= params COMMA expr', 'params ::= expr', 'params ::=',
- 'modifierlist ::= modifierlist modifier modparameters', 'modifierlist ::= modifier modparameters',
- 'modifier ::= VERT AT ID', 'modifier ::= VERT ID', 'modparameters ::= modparameters modparameter',
- 'modparameters ::=', 'modparameter ::= COLON value', 'modparameter ::= COLON array',
- 'static_class_access ::= method', 'static_class_access ::= method objectchain', 'static_class_access ::= ID',
- 'static_class_access ::= DOLLARID arrayindex', 'static_class_access ::= DOLLARID arrayindex objectchain',
- 'lop ::= LOGOP', 'lop ::= TLOGOP', 'scond ::= SINGLECOND', 'array ::= OPENB arrayelements CLOSEB',
- 'arrayelements ::= arrayelement', 'arrayelements ::= arrayelements COMMA arrayelement', 'arrayelements ::=',
- 'arrayelement ::= value APTR expr', 'arrayelement ::= ID APTR expr', 'arrayelement ::= expr',
- 'doublequoted_with_quotes ::= QUOTE QUOTE', 'doublequoted_with_quotes ::= QUOTE doublequoted QUOTE',
- 'doublequoted ::= doublequoted doublequotedcontent', 'doublequoted ::= doublequotedcontent',
- 'doublequotedcontent ::= BACKTICK variable BACKTICK', 'doublequotedcontent ::= BACKTICK expr BACKTICK',
- 'doublequotedcontent ::= DOLLARID', 'doublequotedcontent ::= LDEL variable RDEL',
- 'doublequotedcontent ::= LDEL expr RDEL', 'doublequotedcontent ::= smartytag', 'doublequotedcontent ::= TEXT',);
+ 'template ::= template template_element', 'template ::=',
+ 'template_element ::= smartytag', 'template_element ::= literal',
+ 'template_element ::= PHP', 'template_element ::= NOCACHE',
+ 'template_element ::= text_content', 'text_content ::= TEXT',
+ 'text_content ::= text_content TEXT', 'template_element ::= STRIPON',
+ 'template_element ::= STRIPOFF', 'literal ::= LITERALSTART LITERALEND',
+ 'literal ::= LITERALSTART literal_elements LITERALEND',
+ 'literal_elements ::= literal_elements literal_element', 'literal_elements ::=',
+ 'literal_element ::= literal', 'literal_element ::= LITERAL',
+ 'smartytag ::= tag RDEL', 'smartytag ::= SIMPELOUTPUT', 'tag ::= LDEL variable',
+ 'tag ::= LDEL variable modifierlist attributes',
+ 'tag ::= LDEL variable attributes', 'tag ::= LDEL value',
+ 'tag ::= LDEL value modifierlist attributes', 'tag ::= LDEL value attributes',
+ 'tag ::= LDEL expr modifierlist attributes', 'tag ::= LDEL expr attributes',
+ 'tag ::= LDEL DOLLARID EQUAL value', 'tag ::= LDEL DOLLARID EQUAL expr',
+ 'tag ::= LDEL DOLLARID EQUAL expr attributes',
+ 'tag ::= LDEL varindexed EQUAL expr attributes', 'smartytag ::= SIMPLETAG',
+ 'tag ::= LDEL ID attributes', 'tag ::= LDEL ID',
+ 'tag ::= LDEL ID modifierlist attributes', 'tag ::= LDEL ID PTR ID attributes',
+ 'tag ::= LDEL ID PTR ID modifierlist attributes', 'tag ::= LDELIF expr',
+ 'tag ::= LDELIF expr attributes', 'tag ::= LDELIF statement',
+ 'tag ::= LDELIF statement attributes',
+ 'tag ::= LDELFOR statements SEMICOLON expr SEMICOLON varindexed foraction attributes',
+ 'foraction ::= EQUAL expr', 'foraction ::= INCDEC',
+ 'tag ::= LDELFOR statement TO expr attributes',
+ 'tag ::= LDELFOR statement TO expr STEP expr attributes',
+ 'tag ::= LDELFOREACH attributes',
+ 'tag ::= LDELFOREACH SPACE value AS varvar attributes',
+ 'tag ::= LDELFOREACH SPACE value AS varvar APTR varvar attributes',
+ 'tag ::= LDELFOREACH SPACE expr AS varvar attributes',
+ 'tag ::= LDELFOREACH SPACE expr AS varvar APTR varvar attributes',
+ 'tag ::= LDELSETFILTER ID modparameters',
+ 'tag ::= LDELSETFILTER ID modparameters modifierlist',
+ 'tag ::= LDEL SMARTYBLOCKCHILDPARENT', 'smartytag ::= CLOSETAG',
+ 'tag ::= LDELSLASH ID', 'tag ::= LDELSLASH ID modifierlist',
+ 'tag ::= LDELSLASH ID PTR ID', 'tag ::= LDELSLASH ID PTR ID modifierlist',
+ 'attributes ::= attributes attribute', 'attributes ::= attribute',
+ 'attributes ::=', 'attribute ::= SPACE ID EQUAL ID', 'attribute ::= ATTR expr',
+ 'attribute ::= ATTR value', 'attribute ::= SPACE ID', 'attribute ::= SPACE expr',
+ 'attribute ::= SPACE value', 'attribute ::= SPACE INTEGER EQUAL expr',
+ 'statements ::= statement', 'statements ::= statements COMMA statement',
+ 'statement ::= DOLLARID EQUAL INTEGER', 'statement ::= DOLLARID EQUAL expr',
+ 'statement ::= varindexed EQUAL expr', 'statement ::= OPENP statement CLOSEP',
+ 'expr ::= value', 'expr ::= ternary', 'expr ::= DOLLARID COLON ID',
+ 'expr ::= expr MATH value', 'expr ::= expr UNIMATH value', 'expr ::= array',
+ 'expr ::= expr modifierlist', 'expr ::= expr lop expr', 'expr ::= expr scond',
+ 'expr ::= expr ISIN array', 'expr ::= expr ISIN value',
+ 'expr ::= variable INSTANCEOF ns1', 'expr ::= variable INSTANCEOF variable',
+ 'ternary ::= OPENP expr CLOSEP QMARK DOLLARID COLON expr',
+ 'ternary ::= OPENP expr CLOSEP QMARK expr COLON expr', 'value ::= variable',
+ 'value ::= UNIMATH value', 'value ::= NOT value', 'value ::= TYPECAST value',
+ 'value ::= variable INCDEC', 'value ::= HEX', 'value ::= INTEGER',
+ 'value ::= INTEGER DOT INTEGER', 'value ::= INTEGER DOT', 'value ::= DOT INTEGER',
+ 'value ::= ID', 'value ::= function', 'value ::= OPENP expr CLOSEP',
+ 'value ::= SINGLEQUOTESTRING', 'value ::= doublequoted_with_quotes',
+ 'value ::= varindexed DOUBLECOLON static_class_access', 'value ::= smartytag',
+ 'value ::= value modifierlist', 'value ::= NAMESPACE',
+ 'value ::= ns1 DOUBLECOLON static_class_access', 'ns1 ::= ID',
+ 'ns1 ::= NAMESPACE', 'variable ::= DOLLARID', 'variable ::= varindexed',
+ 'variable ::= varvar AT ID', 'variable ::= object', 'variable ::= HATCH ID HATCH',
+ 'variable ::= HATCH ID HATCH arrayindex', 'variable ::= HATCH variable HATCH',
+ 'variable ::= HATCH variable HATCH arrayindex',
+ 'varindexed ::= DOLLARID arrayindex', 'varindexed ::= varvar arrayindex',
+ 'arrayindex ::= arrayindex indexdef', 'arrayindex ::=',
+ 'indexdef ::= DOT DOLLARID', 'indexdef ::= DOT varvar',
+ 'indexdef ::= DOT varvar AT ID', 'indexdef ::= DOT ID',
+ 'indexdef ::= DOT INTEGER', 'indexdef ::= DOT LDEL expr RDEL',
+ 'indexdef ::= OPENB ID CLOSEB', 'indexdef ::= OPENB ID DOT ID CLOSEB',
+ 'indexdef ::= OPENB SINGLEQUOTESTRING CLOSEB',
+ 'indexdef ::= OPENB INTEGER CLOSEB', 'indexdef ::= OPENB DOLLARID CLOSEB',
+ 'indexdef ::= OPENB variable CLOSEB', 'indexdef ::= OPENB value CLOSEB',
+ 'indexdef ::= OPENB expr CLOSEB', 'indexdef ::= OPENB CLOSEB',
+ 'varvar ::= DOLLARID', 'varvar ::= DOLLAR', 'varvar ::= varvar varvarele',
+ 'varvarele ::= ID', 'varvarele ::= SIMPELOUTPUT', 'varvarele ::= LDEL expr RDEL',
+ 'object ::= varindexed objectchain', 'objectchain ::= objectelement',
+ 'objectchain ::= objectchain objectelement',
+ 'objectelement ::= PTR ID arrayindex', 'objectelement ::= PTR varvar arrayindex',
+ 'objectelement ::= PTR LDEL expr RDEL arrayindex',
+ 'objectelement ::= PTR ID LDEL expr RDEL arrayindex',
+ 'objectelement ::= PTR method', 'function ::= ns1 OPENP params CLOSEP',
+ 'method ::= ID OPENP params CLOSEP', 'method ::= DOLLARID OPENP params CLOSEP',
+ 'params ::= params COMMA expr', 'params ::= expr', 'params ::=',
+ 'modifierlist ::= modifierlist modifier modparameters',
+ 'modifierlist ::= modifier modparameters', 'modifier ::= VERT AT ID',
+ 'modifier ::= VERT ID', 'modparameters ::= modparameters modparameter',
+ 'modparameters ::=', 'modparameter ::= COLON value',
+ 'modparameter ::= COLON array', 'static_class_access ::= method',
+ 'static_class_access ::= method objectchain', 'static_class_access ::= ID',
+ 'static_class_access ::= DOLLARID arrayindex',
+ 'static_class_access ::= DOLLARID arrayindex objectchain', 'lop ::= LOGOP',
+ 'lop ::= TLOGOP', 'scond ::= SINGLECOND', 'array ::= OPENB arrayelements CLOSEB',
+ 'arrayelements ::= arrayelement',
+ 'arrayelements ::= arrayelements COMMA arrayelement', 'arrayelements ::=',
+ 'arrayelement ::= value APTR expr', 'arrayelement ::= ID APTR expr',
+ 'arrayelement ::= expr', 'doublequoted_with_quotes ::= QUOTE QUOTE',
+ 'doublequoted_with_quotes ::= QUOTE doublequoted QUOTE',
+ 'doublequoted ::= doublequoted doublequotedcontent',
+ 'doublequoted ::= doublequotedcontent',
+ 'doublequotedcontent ::= BACKTICK variable BACKTICK',
+ 'doublequotedcontent ::= BACKTICK expr BACKTICK',
+ 'doublequotedcontent ::= DOLLARID', 'doublequotedcontent ::= LDEL variable RDEL',
+ 'doublequotedcontent ::= LDEL expr RDEL', 'doublequotedcontent ::= smartytag',
+ 'doublequotedcontent ::= TEXT',);
public function tokenName($tokenType)
{
@@ -885,7 +1106,8 @@ class Smarty_Internal_Templateparser
}
$yyruleno = $yyact - self::YYNSTATE;
$this->yyidx -= self::$yyRuleInfo[$yyruleno][1];
- $nextstate = $this->yy_find_reduce_action($this->yystack[$this->yyidx]->stateno, self::$yyRuleInfo[$yyruleno][0]);
+ $nextstate = $this->yy_find_reduce_action($this->yystack[$this->yyidx]->stateno,
+ self::$yyRuleInfo[$yyruleno][0]);
if (isset(self::$yyExpectedTokens[$nextstate])) {
$expected = array_merge($expected, self::$yyExpectedTokens[$nextstate]);
if (isset($res4[$nextstate][$token])) {
@@ -895,7 +1117,9 @@ class Smarty_Internal_Templateparser
return array_unique($expected);
}
} else {
- if ($res4[$nextstate][$token] = in_array($token, self::$yyExpectedTokens[$nextstate], true)) {
+ if ($res4[$nextstate][$token] =
+ in_array($token, self::$yyExpectedTokens[$nextstate], true)
+ ) {
$this->yyidx = $yyidx;
$this->yystack = $stack;
return array_unique($expected);
@@ -969,7 +1193,8 @@ class Smarty_Internal_Templateparser
}
$yyruleno = $yyact - self::YYNSTATE;
$this->yyidx -= self::$yyRuleInfo[$yyruleno][1];
- $nextstate = $this->yy_find_reduce_action($this->yystack[$this->yyidx]->stateno, self::$yyRuleInfo[$yyruleno][0]);
+ $nextstate = $this->yy_find_reduce_action($this->yystack[$this->yyidx]->stateno,
+ self::$yyRuleInfo[$yyruleno][0]);
if (isset($res2[$nextstate][$token])) {
if ($res2[$nextstate][$token]) {
$this->yyidx = $yyidx;
@@ -977,7 +1202,9 @@ class Smarty_Internal_Templateparser
return true;
}
} else {
- if ($res2[$nextstate][$token] = (isset(self::$yyExpectedTokens[$nextstate]) && in_array($token, self::$yyExpectedTokens[$nextstate], true))) {
+ if ($res2[$nextstate][$token] = (isset(self::$yyExpectedTokens[$nextstate]) &&
+ in_array($token, self::$yyExpectedTokens[$nextstate], true))
+ ) {
$this->yyidx = $yyidx;
$this->yystack = $stack;
return true;
@@ -1038,9 +1265,13 @@ class Smarty_Internal_Templateparser
}
$i += $iLookAhead;
if ($i < 0 || $i >= self::YY_SZ_ACTTAB || self::$yy_lookahead[$i] != $iLookAhead) {
- if (count(self::$yyFallback) && $iLookAhead < count(self::$yyFallback) && ($iFallback = self::$yyFallback[$iLookAhead]) != 0) {
+ if (count(self::$yyFallback) && $iLookAhead < count(self::$yyFallback) &&
+ ($iFallback = self::$yyFallback[$iLookAhead]) != 0
+ ) {
if ($this->yyTraceFILE) {
- fwrite($this->yyTraceFILE, $this->yyTracePrompt . "FALLBACK " . $this->yyTokenName[$iLookAhead] . " => " . $this->yyTokenName[$iFallback] . "\n");
+ fwrite($this->yyTraceFILE,
+ $this->yyTracePrompt . "FALLBACK " . $this->yyTokenName[$iLookAhead] . " => " .
+ $this->yyTokenName[$iFallback] . "\n");
}
return $this->yy_find_shift_action($iFallback);
@@ -1085,7 +1316,7 @@ class Smarty_Internal_Templateparser
while ($this->yyidx >= 0) {
$this->yy_pop_parser_stack();
}
- #line 190 "../smarty/lexer/smarty_internal_templateparser.y"
+ #line 214 "../smarty/lexer/smarty_internal_templateparser.y"
$this->internalError = true;
$this->compiler->trigger_template_error("Stack overflow in template parser");
@@ -1107,108 +1338,127 @@ class Smarty_Internal_Templateparser
}
}
- public static $yyRuleInfo = array(array(0 => 62, 1 => 1), array(0 => 63, 1 => 1), array(0 => 63, 1 => 2),
- array(0 => 63, 1 => 0), array(0 => 64, 1 => 1), array(0 => 64, 1 => 1), array(0 => 64, 1 => 1),
- array(0 => 64, 1 => 1), array(0 => 64, 1 => 1), array(0 => 67, 1 => 1), array(0 => 67, 1 => 2),
- array(0 => 64, 1 => 1), array(0 => 64, 1 => 1), array(0 => 64, 1 => 1), array(0 => 66, 1 => 2),
- array(0 => 66, 1 => 3), array(0 => 68, 1 => 2), array(0 => 68, 1 => 0), array(0 => 69, 1 => 1),
- array(0 => 69, 1 => 1), array(0 => 65, 1 => 2), array(0 => 65, 1 => 1), array(0 => 70, 1 => 2),
- array(0 => 70, 1 => 3), array(0 => 70, 1 => 2), array(0 => 70, 1 => 3), array(0 => 70, 1 => 2),
- array(0 => 70, 1 => 3), array(0 => 70, 1 => 4), array(0 => 70, 1 => 4), array(0 => 70, 1 => 5),
- array(0 => 70, 1 => 5), array(0 => 65, 1 => 1), array(0 => 70, 1 => 3), array(0 => 70, 1 => 2),
- array(0 => 70, 1 => 4), array(0 => 70, 1 => 5), array(0 => 70, 1 => 6), array(0 => 70, 1 => 2),
- array(0 => 70, 1 => 3), array(0 => 70, 1 => 2), array(0 => 70, 1 => 3), array(0 => 70, 1 => 8),
- array(0 => 79, 1 => 2), array(0 => 79, 1 => 1), array(0 => 70, 1 => 5), array(0 => 70, 1 => 7),
- array(0 => 70, 1 => 2), array(0 => 70, 1 => 6), array(0 => 70, 1 => 8), array(0 => 70, 1 => 6),
- array(0 => 70, 1 => 8), array(0 => 70, 1 => 3), array(0 => 70, 1 => 4), array(0 => 70, 1 => 2),
- array(0 => 65, 1 => 1), array(0 => 70, 1 => 2), array(0 => 70, 1 => 3), array(0 => 70, 1 => 4),
- array(0 => 70, 1 => 5), array(0 => 72, 1 => 2), array(0 => 72, 1 => 1), array(0 => 72, 1 => 0),
- array(0 => 82, 1 => 4), array(0 => 82, 1 => 2), array(0 => 82, 1 => 2), array(0 => 82, 1 => 2),
- array(0 => 82, 1 => 2), array(0 => 82, 1 => 2), array(0 => 82, 1 => 4), array(0 => 78, 1 => 1),
- array(0 => 78, 1 => 3), array(0 => 77, 1 => 3), array(0 => 77, 1 => 3), array(0 => 77, 1 => 3),
- array(0 => 77, 1 => 3), array(0 => 74, 1 => 1), array(0 => 74, 1 => 1), array(0 => 74, 1 => 3),
- array(0 => 74, 1 => 3), array(0 => 74, 1 => 3), array(0 => 74, 1 => 1), array(0 => 74, 1 => 2),
- array(0 => 74, 1 => 3), array(0 => 74, 1 => 2), array(0 => 74, 1 => 3), array(0 => 74, 1 => 3),
- array(0 => 74, 1 => 3), array(0 => 83, 1 => 7), array(0 => 83, 1 => 7), array(0 => 73, 1 => 1),
- array(0 => 73, 1 => 2), array(0 => 73, 1 => 2), array(0 => 73, 1 => 2), array(0 => 73, 1 => 2),
- array(0 => 73, 1 => 1), array(0 => 73, 1 => 1), array(0 => 73, 1 => 3), array(0 => 73, 1 => 2),
- array(0 => 73, 1 => 2), array(0 => 73, 1 => 1), array(0 => 73, 1 => 1), array(0 => 73, 1 => 3),
- array(0 => 73, 1 => 1), array(0 => 73, 1 => 1), array(0 => 73, 1 => 3), array(0 => 73, 1 => 1),
- array(0 => 73, 1 => 2), array(0 => 73, 1 => 1), array(0 => 73, 1 => 3), array(0 => 87, 1 => 1),
- array(0 => 87, 1 => 1), array(0 => 71, 1 => 1), array(0 => 71, 1 => 1), array(0 => 71, 1 => 3),
- array(0 => 71, 1 => 1), array(0 => 71, 1 => 3), array(0 => 71, 1 => 4), array(0 => 71, 1 => 3),
- array(0 => 71, 1 => 4), array(0 => 75, 1 => 2), array(0 => 75, 1 => 2), array(0 => 92, 1 => 2),
- array(0 => 92, 1 => 0), array(0 => 93, 1 => 2), array(0 => 93, 1 => 2), array(0 => 93, 1 => 4),
- array(0 => 93, 1 => 2), array(0 => 93, 1 => 2), array(0 => 93, 1 => 4), array(0 => 93, 1 => 3),
- array(0 => 93, 1 => 5), array(0 => 93, 1 => 3), array(0 => 93, 1 => 3), array(0 => 93, 1 => 3),
- array(0 => 93, 1 => 3), array(0 => 93, 1 => 3), array(0 => 93, 1 => 3), array(0 => 93, 1 => 2),
- array(0 => 80, 1 => 1), array(0 => 80, 1 => 1), array(0 => 80, 1 => 2), array(0 => 94, 1 => 1),
- array(0 => 94, 1 => 3), array(0 => 91, 1 => 2), array(0 => 95, 1 => 1), array(0 => 95, 1 => 2),
- array(0 => 96, 1 => 3), array(0 => 96, 1 => 3), array(0 => 96, 1 => 5), array(0 => 96, 1 => 6),
- array(0 => 96, 1 => 2), array(0 => 88, 1 => 4), array(0 => 97, 1 => 4), array(0 => 97, 1 => 4),
- array(0 => 98, 1 => 3), array(0 => 98, 1 => 1), array(0 => 98, 1 => 0), array(0 => 76, 1 => 3),
- array(0 => 76, 1 => 2), array(0 => 99, 1 => 3), array(0 => 99, 1 => 2), array(0 => 81, 1 => 2),
- array(0 => 81, 1 => 0), array(0 => 100, 1 => 2), array(0 => 100, 1 => 2), array(0 => 90, 1 => 1),
- array(0 => 90, 1 => 2), array(0 => 90, 1 => 1), array(0 => 90, 1 => 2), array(0 => 90, 1 => 3),
- array(0 => 85, 1 => 1), array(0 => 85, 1 => 1), array(0 => 86, 1 => 1), array(0 => 84, 1 => 3),
- array(0 => 101, 1 => 1), array(0 => 101, 1 => 3), array(0 => 101, 1 => 0), array(0 => 102, 1 => 3),
- array(0 => 102, 1 => 3), array(0 => 102, 1 => 1), array(0 => 89, 1 => 2), array(0 => 89, 1 => 3),
- array(0 => 103, 1 => 2), array(0 => 103, 1 => 1), array(0 => 104, 1 => 3), array(0 => 104, 1 => 3),
- array(0 => 104, 1 => 1), array(0 => 104, 1 => 3), array(0 => 104, 1 => 3), array(0 => 104, 1 => 1),
- array(0 => 104, 1 => 1),);
+ public static $yyRuleInfo = array(array(0 => 61, 1 => 1), array(0 => 62, 1 => 1), array(0 => 62, 1 => 2),
+ array(0 => 62, 1 => 0), array(0 => 63, 1 => 1), array(0 => 63, 1 => 1),
+ array(0 => 63, 1 => 1), array(0 => 63, 1 => 1), array(0 => 63, 1 => 1),
+ array(0 => 66, 1 => 1), array(0 => 66, 1 => 2), array(0 => 63, 1 => 1),
+ array(0 => 63, 1 => 1), array(0 => 65, 1 => 2), array(0 => 65, 1 => 3),
+ array(0 => 67, 1 => 2), array(0 => 67, 1 => 0), array(0 => 68, 1 => 1),
+ array(0 => 68, 1 => 1), array(0 => 64, 1 => 2), array(0 => 64, 1 => 1),
+ array(0 => 69, 1 => 2), array(0 => 69, 1 => 4), array(0 => 69, 1 => 3),
+ array(0 => 69, 1 => 2), array(0 => 69, 1 => 4), array(0 => 69, 1 => 3),
+ array(0 => 69, 1 => 4), array(0 => 69, 1 => 3), array(0 => 69, 1 => 4),
+ array(0 => 69, 1 => 4), array(0 => 69, 1 => 5), array(0 => 69, 1 => 5),
+ array(0 => 64, 1 => 1), array(0 => 69, 1 => 3), array(0 => 69, 1 => 2),
+ array(0 => 69, 1 => 4), array(0 => 69, 1 => 5), array(0 => 69, 1 => 6),
+ array(0 => 69, 1 => 2), array(0 => 69, 1 => 3), array(0 => 69, 1 => 2),
+ array(0 => 69, 1 => 3), array(0 => 69, 1 => 8), array(0 => 78, 1 => 2),
+ array(0 => 78, 1 => 1), array(0 => 69, 1 => 5), array(0 => 69, 1 => 7),
+ array(0 => 69, 1 => 2), array(0 => 69, 1 => 6), array(0 => 69, 1 => 8),
+ array(0 => 69, 1 => 6), array(0 => 69, 1 => 8), array(0 => 69, 1 => 3),
+ array(0 => 69, 1 => 4), array(0 => 69, 1 => 2), array(0 => 64, 1 => 1),
+ array(0 => 69, 1 => 2), array(0 => 69, 1 => 3), array(0 => 69, 1 => 4),
+ array(0 => 69, 1 => 5), array(0 => 72, 1 => 2), array(0 => 72, 1 => 1),
+ array(0 => 72, 1 => 0), array(0 => 81, 1 => 4), array(0 => 81, 1 => 2),
+ array(0 => 81, 1 => 2), array(0 => 81, 1 => 2), array(0 => 81, 1 => 2),
+ array(0 => 81, 1 => 2), array(0 => 81, 1 => 4), array(0 => 77, 1 => 1),
+ array(0 => 77, 1 => 3), array(0 => 76, 1 => 3), array(0 => 76, 1 => 3),
+ array(0 => 76, 1 => 3), array(0 => 76, 1 => 3), array(0 => 74, 1 => 1),
+ array(0 => 74, 1 => 1), array(0 => 74, 1 => 3), array(0 => 74, 1 => 3),
+ array(0 => 74, 1 => 3), array(0 => 74, 1 => 1), array(0 => 74, 1 => 2),
+ array(0 => 74, 1 => 3), array(0 => 74, 1 => 2), array(0 => 74, 1 => 3),
+ array(0 => 74, 1 => 3), array(0 => 74, 1 => 3), array(0 => 74, 1 => 3),
+ array(0 => 82, 1 => 7), array(0 => 82, 1 => 7), array(0 => 73, 1 => 1),
+ array(0 => 73, 1 => 2), array(0 => 73, 1 => 2), array(0 => 73, 1 => 2),
+ array(0 => 73, 1 => 2), array(0 => 73, 1 => 1), array(0 => 73, 1 => 1),
+ array(0 => 73, 1 => 3), array(0 => 73, 1 => 2), array(0 => 73, 1 => 2),
+ array(0 => 73, 1 => 1), array(0 => 73, 1 => 1), array(0 => 73, 1 => 3),
+ array(0 => 73, 1 => 1), array(0 => 73, 1 => 1), array(0 => 73, 1 => 3),
+ array(0 => 73, 1 => 1), array(0 => 73, 1 => 2), array(0 => 73, 1 => 1),
+ array(0 => 73, 1 => 3), array(0 => 86, 1 => 1), array(0 => 86, 1 => 1),
+ array(0 => 70, 1 => 1), array(0 => 70, 1 => 1), array(0 => 70, 1 => 3),
+ array(0 => 70, 1 => 1), array(0 => 70, 1 => 3), array(0 => 70, 1 => 4),
+ array(0 => 70, 1 => 3), array(0 => 70, 1 => 4), array(0 => 75, 1 => 2),
+ array(0 => 75, 1 => 2), array(0 => 91, 1 => 2), array(0 => 91, 1 => 0),
+ array(0 => 92, 1 => 2), array(0 => 92, 1 => 2), array(0 => 92, 1 => 4),
+ array(0 => 92, 1 => 2), array(0 => 92, 1 => 2), array(0 => 92, 1 => 4),
+ array(0 => 92, 1 => 3), array(0 => 92, 1 => 5), array(0 => 92, 1 => 3),
+ array(0 => 92, 1 => 3), array(0 => 92, 1 => 3), array(0 => 92, 1 => 3),
+ array(0 => 92, 1 => 3), array(0 => 92, 1 => 3), array(0 => 92, 1 => 2),
+ array(0 => 79, 1 => 1), array(0 => 79, 1 => 1), array(0 => 79, 1 => 2),
+ array(0 => 93, 1 => 1), array(0 => 93, 1 => 1), array(0 => 93, 1 => 3),
+ array(0 => 90, 1 => 2), array(0 => 94, 1 => 1), array(0 => 94, 1 => 2),
+ array(0 => 95, 1 => 3), array(0 => 95, 1 => 3), array(0 => 95, 1 => 5),
+ array(0 => 95, 1 => 6), array(0 => 95, 1 => 2), array(0 => 87, 1 => 4),
+ array(0 => 96, 1 => 4), array(0 => 96, 1 => 4), array(0 => 97, 1 => 3),
+ array(0 => 97, 1 => 1), array(0 => 97, 1 => 0), array(0 => 71, 1 => 3),
+ array(0 => 71, 1 => 2), array(0 => 98, 1 => 3), array(0 => 98, 1 => 2),
+ array(0 => 80, 1 => 2), array(0 => 80, 1 => 0), array(0 => 99, 1 => 2),
+ array(0 => 99, 1 => 2), array(0 => 89, 1 => 1), array(0 => 89, 1 => 2),
+ array(0 => 89, 1 => 1), array(0 => 89, 1 => 2), array(0 => 89, 1 => 3),
+ array(0 => 84, 1 => 1), array(0 => 84, 1 => 1), array(0 => 85, 1 => 1),
+ array(0 => 83, 1 => 3), array(0 => 100, 1 => 1), array(0 => 100, 1 => 3),
+ array(0 => 100, 1 => 0), array(0 => 101, 1 => 3), array(0 => 101, 1 => 3),
+ array(0 => 101, 1 => 1), array(0 => 88, 1 => 2), array(0 => 88, 1 => 3),
+ array(0 => 102, 1 => 2), array(0 => 102, 1 => 1), array(0 => 103, 1 => 3),
+ array(0 => 103, 1 => 3), array(0 => 103, 1 => 1), array(0 => 103, 1 => 3),
+ array(0 => 103, 1 => 3), array(0 => 103, 1 => 1), array(0 => 103, 1 => 1),);
public static $yyReduceMap = array(0 => 0, 1 => 1, 2 => 2, 4 => 4, 5 => 5, 6 => 6, 7 => 7, 8 => 8, 9 => 9,
- 18 => 9, 19 => 9, 44 => 9, 67 => 9, 68 => 9, 76 => 9, 77 => 9, 81 => 9, 90 => 9,
- 95 => 9, 96 => 9, 101 => 9, 103 => 9, 104 => 9, 108 => 9, 110 => 9, 111 => 9,
- 115 => 9, 175 => 9, 180 => 9, 10 => 10, 11 => 11, 12 => 12, 13 => 13, 14 => 14,
- 17 => 14, 15 => 15, 75 => 15, 16 => 16, 91 => 16, 93 => 16, 94 => 16, 122 => 16,
- 20 => 20, 21 => 21, 22 => 22, 24 => 22, 26 => 22, 23 => 23, 25 => 23, 27 => 23,
- 28 => 28, 29 => 28, 30 => 30, 31 => 31, 32 => 32, 33 => 33, 34 => 34, 35 => 35,
- 36 => 36, 37 => 37, 38 => 38, 39 => 39, 41 => 39, 40 => 40, 42 => 42, 43 => 43,
- 45 => 45, 46 => 46, 47 => 47, 48 => 48, 50 => 48, 49 => 49, 51 => 49, 52 => 52,
- 53 => 53, 54 => 54, 55 => 55, 56 => 56, 57 => 57, 58 => 58, 59 => 59, 60 => 60,
- 61 => 61, 70 => 61, 156 => 61, 160 => 61, 164 => 61, 165 => 61, 62 => 62,
- 157 => 62, 163 => 62, 63 => 63, 64 => 64, 65 => 64, 66 => 66, 142 => 66,
- 69 => 69, 71 => 71, 72 => 72, 73 => 72, 74 => 74, 78 => 78, 79 => 79, 80 => 79,
- 82 => 82, 107 => 82, 83 => 83, 84 => 84, 85 => 85, 86 => 86, 87 => 87, 88 => 88,
- 89 => 89, 92 => 92, 97 => 97, 98 => 98, 99 => 99, 100 => 100, 102 => 102,
- 105 => 105, 106 => 106, 109 => 109, 112 => 112, 113 => 113, 114 => 114,
- 116 => 116, 117 => 117, 118 => 118, 119 => 119, 120 => 120, 121 => 121,
- 123 => 123, 177 => 123, 124 => 124, 125 => 125, 126 => 126, 127 => 127,
- 128 => 128, 129 => 129, 137 => 129, 130 => 130, 131 => 131, 132 => 132,
- 133 => 132, 135 => 132, 136 => 132, 134 => 134, 138 => 138, 139 => 139,
- 140 => 140, 181 => 140, 141 => 141, 143 => 143, 144 => 144, 145 => 145,
+ 17 => 9, 18 => 9, 45 => 9, 68 => 9, 69 => 9, 77 => 9, 78 => 9, 82 => 9, 92 => 9,
+ 97 => 9, 98 => 9, 103 => 9, 105 => 9, 106 => 9, 110 => 9, 112 => 9, 117 => 9,
+ 178 => 9, 183 => 9, 10 => 10, 11 => 11, 12 => 12, 13 => 13, 16 => 13, 14 => 14,
+ 76 => 14, 15 => 15, 93 => 15, 95 => 15, 96 => 15, 124 => 15, 19 => 19, 20 => 20,
+ 21 => 21, 24 => 21, 22 => 22, 25 => 22, 23 => 23, 26 => 23, 28 => 23, 27 => 27,
+ 29 => 29, 30 => 29, 31 => 31, 32 => 32, 33 => 33, 34 => 34, 35 => 35, 36 => 36,
+ 37 => 37, 38 => 38, 39 => 39, 40 => 40, 42 => 40, 41 => 41, 43 => 43, 44 => 44,
+ 46 => 46, 47 => 47, 48 => 48, 49 => 49, 51 => 49, 50 => 50, 52 => 50, 53 => 53,
+ 54 => 54, 55 => 55, 56 => 56, 57 => 57, 58 => 58, 59 => 59, 60 => 60, 61 => 61,
+ 62 => 62, 71 => 62, 159 => 62, 163 => 62, 167 => 62, 168 => 62, 63 => 63,
+ 160 => 63, 166 => 63, 64 => 64, 65 => 65, 66 => 65, 67 => 67, 144 => 67,
+ 70 => 70, 72 => 72, 73 => 73, 74 => 73, 75 => 75, 79 => 79, 80 => 80, 81 => 80,
+ 83 => 83, 109 => 83, 84 => 84, 85 => 85, 86 => 86, 87 => 87, 88 => 88, 89 => 88,
+ 90 => 90, 91 => 91, 94 => 94, 99 => 99, 100 => 100, 101 => 101, 102 => 102,
+ 104 => 104, 107 => 107, 108 => 108, 111 => 111, 113 => 113, 114 => 114,
+ 115 => 115, 116 => 116, 118 => 118, 119 => 119, 120 => 120, 121 => 121,
+ 122 => 122, 123 => 123, 125 => 125, 180 => 125, 126 => 126, 127 => 127,
+ 128 => 128, 129 => 129, 130 => 130, 131 => 131, 139 => 131, 132 => 132,
+ 133 => 133, 134 => 134, 135 => 134, 137 => 134, 138 => 134, 136 => 136,
+ 140 => 140, 141 => 141, 142 => 142, 184 => 142, 143 => 143, 145 => 145,
146 => 146, 147 => 147, 148 => 148, 149 => 149, 150 => 150, 151 => 151,
- 152 => 152, 153 => 153, 154 => 154, 155 => 155, 158 => 158, 159 => 159,
- 161 => 161, 162 => 162, 166 => 166, 167 => 167, 168 => 168, 169 => 169,
- 170 => 170, 171 => 171, 172 => 172, 173 => 173, 174 => 174, 176 => 176,
- 178 => 178, 179 => 179, 182 => 182, 183 => 183, 184 => 184, 185 => 185,
- 186 => 185, 188 => 185, 187 => 187, 189 => 189, 190 => 190, 191 => 191,);
-
- #line 201 "../smarty/lexer/smarty_internal_templateparser.y"
+ 152 => 152, 153 => 153, 154 => 154, 155 => 155, 156 => 156, 157 => 157,
+ 158 => 158, 161 => 161, 162 => 162, 164 => 164, 165 => 165, 169 => 169,
+ 170 => 170, 171 => 171, 172 => 172, 173 => 173, 174 => 174, 175 => 175,
+ 176 => 176, 177 => 177, 179 => 179, 181 => 181, 182 => 182, 185 => 185,
+ 186 => 186, 187 => 187, 188 => 188, 189 => 188, 191 => 188, 190 => 190,
+ 192 => 192, 193 => 193, 194 => 194,);
+
+ #line 225 "../smarty/lexer/smarty_internal_templateparser.y"
function yy_r0()
{
- $this->_retvalue = $this->root_buffer->to_smarty_php();
+ $this->root_buffer->prepend_array($this, $this->template_prefix);
+ $this->root_buffer->append_array($this, $this->template_postfix);
+ $this->_retvalue = $this->root_buffer->to_smarty_php($this);
}
- #line 209 "../smarty/lexer/smarty_internal_templateparser.y"
+ #line 235 "../smarty/lexer/smarty_internal_templateparser.y"
function yy_r1()
{
if ($this->yystack[$this->yyidx + 0]->minor != null) {
- $this->current_buffer->append_subtree($this->yystack[$this->yyidx + 0]->minor);
+ $this->current_buffer->append_subtree($this, $this->yystack[$this->yyidx + 0]->minor);
}
}
- #line 216 "../smarty/lexer/smarty_internal_templateparser.y"
+ #line 242 "../smarty/lexer/smarty_internal_templateparser.y"
function yy_r2()
{
if ($this->yystack[$this->yyidx + 0]->minor != null) {
// because of possible code injection
- $this->current_buffer->append_subtree($this->yystack[$this->yyidx + 0]->minor);
+ $this->current_buffer->append_subtree($this, $this->yystack[$this->yyidx + 0]->minor);
}
}
- #line 230 "../smarty/lexer/smarty_internal_templateparser.y"
+ #line 256 "../smarty/lexer/smarty_internal_templateparser.y"
function yy_r4()
{
if ($this->compiler->has_code) {
@@ -1220,150 +1470,184 @@ class Smarty_Internal_Templateparser
$this->block_nesting_level = count($this->compiler->_tag_stack);
}
- #line 241 "../smarty/lexer/smarty_internal_templateparser.y"
+ #line 267 "../smarty/lexer/smarty_internal_templateparser.y"
function yy_r5()
{
- $this->_retvalue = new Smarty_Internal_ParseTree_Text($this, $this->yystack[$this->yyidx + 0]->minor);
+ $this->_retvalue = new Smarty_Internal_ParseTree_Text($this->yystack[$this->yyidx + 0]->minor);
}
- #line 245 "../smarty/lexer/smarty_internal_templateparser.y"
+ #line 271 "../smarty/lexer/smarty_internal_templateparser.y"
function yy_r6()
{
- $code = $this->compiler->compileTag('private_php', array(array('code' => $this->yystack[$this->yyidx + 0]->minor),
- array('type' => $this->lex->phpType)), array());
+ $code = $this->compiler->compileTag('private_php',
+ array(array('code' => $this->yystack[$this->yyidx + 0]->minor),
+ array('type' => $this->lex->phpType)), array());
if ($this->compiler->has_code && !empty($code)) {
$tmp = '';
foreach ($this->compiler->prefix_code as $code) {
$tmp .= $code;
}
$this->compiler->prefix_code = array();
- $this->_retvalue = new Smarty_Internal_ParseTree_Tag($this, $this->compiler->processNocacheCode($tmp . $code, true));
+ $this->_retvalue =
+ new Smarty_Internal_ParseTree_Tag($this, $this->compiler->processNocacheCode($tmp . $code, true));
} else {
$this->_retvalue = null;
}
}
- #line 256 "../smarty/lexer/smarty_internal_templateparser.y"
+ #line 282 "../smarty/lexer/smarty_internal_templateparser.y"
function yy_r7()
{
$this->compiler->tag_nocache = true;
- $save = $this->template->has_nocache_code;
- $this->_retvalue = new Smarty_Internal_ParseTree_Tag($this, $this->compiler->processNocacheCode("<?php echo '{$this->yystack[$this->yyidx + 0]->minor}';?>\n", $this->compiler, true));
- $this->template->has_nocache_code = $save;
+ $save = $this->template->compiled->has_nocache_code;
+ $this->_retvalue = new Smarty_Internal_ParseTree_Tag($this,
+ $this->compiler->processNocacheCode("<?php echo '{$this->yystack[$this->yyidx + 0]->minor}';?>\n",
+ $this->compiler,
+ true));
+ $this->template->compiled->has_nocache_code = $save;
}
- #line 263 "../smarty/lexer/smarty_internal_templateparser.y"
+ #line 289 "../smarty/lexer/smarty_internal_templateparser.y"
function yy_r8()
{
$this->_retvalue = $this->compiler->processText($this->yystack[$this->yyidx + 0]->minor);
}
- #line 267 "../smarty/lexer/smarty_internal_templateparser.y"
+ #line 293 "../smarty/lexer/smarty_internal_templateparser.y"
function yy_r9()
{
$this->_retvalue = $this->yystack[$this->yyidx + 0]->minor;
}
- #line 271 "../smarty/lexer/smarty_internal_templateparser.y"
+ #line 297 "../smarty/lexer/smarty_internal_templateparser.y"
function yy_r10()
{
$this->_retvalue = $this->yystack[$this->yyidx + - 1]->minor . $this->yystack[$this->yyidx + 0]->minor;
}
- #line 276 "../smarty/lexer/smarty_internal_templateparser.y"
+ #line 302 "../smarty/lexer/smarty_internal_templateparser.y"
function yy_r11()
{
$this->strip = true;
}
- #line 280 "../smarty/lexer/smarty_internal_templateparser.y"
+ #line 306 "../smarty/lexer/smarty_internal_templateparser.y"
function yy_r12()
{
$this->strip = false;
}
- #line 284 "../smarty/lexer/smarty_internal_templateparser.y"
+ #line 311 "../smarty/lexer/smarty_internal_templateparser.y"
function yy_r13()
{
- if ($this->strip) {
- SMARTY_INTERNAL_COMPILE_BLOCK::blockSource($this->compiler, preg_replace('![\t ]*[\r\n]+[\t ]*!', '', $this->yystack[$this->yyidx + 0]->minor));
- } else {
- SMARTY_INTERNAL_COMPILE_BLOCK::blockSource($this->compiler, $this->yystack[$this->yyidx + 0]->minor);
- }
- }
-
- #line 293 "../smarty/lexer/smarty_internal_templateparser.y"
- function yy_r14()
- {
$this->_retvalue = '';
}
- #line 297 "../smarty/lexer/smarty_internal_templateparser.y"
- function yy_r15()
+ #line 315 "../smarty/lexer/smarty_internal_templateparser.y"
+ function yy_r14()
{
$this->_retvalue = $this->yystack[$this->yyidx + - 1]->minor;
}
- #line 301 "../smarty/lexer/smarty_internal_templateparser.y"
- function yy_r16()
+ #line 319 "../smarty/lexer/smarty_internal_templateparser.y"
+ function yy_r15()
{
$this->_retvalue = $this->yystack[$this->yyidx + - 1]->minor . $this->yystack[$this->yyidx + 0]->minor;
}
- #line 317 "../smarty/lexer/smarty_internal_templateparser.y"
- function yy_r20()
+ #line 335 "../smarty/lexer/smarty_internal_templateparser.y"
+ function yy_r19()
{
$this->_retvalue = $this->yystack[$this->yyidx + - 1]->minor;
}
- #line 323 "../smarty/lexer/smarty_internal_templateparser.y"
- function yy_r21()
+ #line 341 "../smarty/lexer/smarty_internal_templateparser.y"
+ function yy_r20()
{
- $var = trim(substr($this->yystack[$this->yyidx + 0]->minor, $this->lex->ldel_length, - $this->lex->rdel_length), ' $');
+ $var = trim(substr($this->yystack[$this->yyidx + 0]->minor, $this->lex->ldel_length, - $this->lex->rdel_length),
+ ' $');
if (preg_match('/^(.*)(\s+nocache)$/', $var, $match)) {
- $this->_retvalue = $this->compiler->compileTag('private_print_expression', array('nocache'), array('value' => $this->compiler->compileVariable('\'' . $match[1] . '\'')));
+ $this->_retvalue = $this->compiler->compileTag('private_print_expression', array('nocache'),
+ array('value' => $this->compiler->compileVariable('\'' .
+ $match[1] .
+ '\'')));
} else {
- $this->_retvalue = $this->compiler->compileTag('private_print_expression', array(), array('value' => $this->compiler->compileVariable('\'' . $var . '\'')));
+ $this->_retvalue = $this->compiler->compileTag('private_print_expression', array(),
+ array('value' => $this->compiler->compileVariable('\'' .
+ $var .
+ '\'')));
}
}
- #line 333 "../smarty/lexer/smarty_internal_templateparser.y"
+ #line 351 "../smarty/lexer/smarty_internal_templateparser.y"
+ function yy_r21()
+ {
+ $this->_retvalue = $this->compiler->compileTag('private_print_expression', array(),
+ array('value' => $this->yystack[$this->yyidx + 0]->minor));
+ }
+
+ #line 355 "../smarty/lexer/smarty_internal_templateparser.y"
function yy_r22()
{
- $this->_retvalue = $this->compiler->compileTag('private_print_expression', array(), array('value' => $this->yystack[$this->yyidx + 0]->minor));
+ $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));
}
- #line 337 "../smarty/lexer/smarty_internal_templateparser.y"
+ #line 359 "../smarty/lexer/smarty_internal_templateparser.y"
function yy_r23()
{
- $this->_retvalue = $this->compiler->compileTag('private_print_expression', $this->yystack[$this->yyidx + 0]->minor, array('value' => $this->yystack[$this->yyidx + - 1]->minor));
+ $this->_retvalue =
+ $this->compiler->compileTag('private_print_expression', $this->yystack[$this->yyidx + 0]->minor,
+ array('value' => $this->yystack[$this->yyidx + - 1]->minor));
}
- #line 360 "../smarty/lexer/smarty_internal_templateparser.y"
- function yy_r28()
+ #line 373 "../smarty/lexer/smarty_internal_templateparser.y"
+ function yy_r27()
{
- $this->_retvalue = $this->compiler->compileTag('assign', array(array('value' => $this->yystack[$this->yyidx + 0]->minor),
- array('var' => '\'' . substr($this->yystack[$this->yyidx + - 2]->minor, 1) . '\'')));
+ $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));
}
- #line 368 "../smarty/lexer/smarty_internal_templateparser.y"
- function yy_r30()
+ #line 386 "../smarty/lexer/smarty_internal_templateparser.y"
+ function yy_r29()
{
- $this->_retvalue = $this->compiler->compileTag('assign', array_merge(array(array('value' => $this->yystack[$this->yyidx + - 1]->minor),
- array('var' => '\'' . substr($this->yystack[$this->yyidx + - 3]->minor, 1) . '\'')), $this->yystack[$this->yyidx + 0]->minor));
+ $this->_retvalue = $this->compiler->compileTag('assign',
+ array(array('value' => $this->yystack[$this->yyidx + 0]->minor),
+ array('var' => '\'' .
+ substr($this->yystack[$this->yyidx + - 2]->minor, 1) .
+ '\'')));
}
- #line 372 "../smarty/lexer/smarty_internal_templateparser.y"
+ #line 394 "../smarty/lexer/smarty_internal_templateparser.y"
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']));
+ $this->_retvalue = $this->compiler->compileTag('assign',
+ array_merge(array(array('value' => $this->yystack[$this->yyidx +
+ - 1]->minor), array('var' => '\'' .
+ substr($this->yystack[$this->yyidx + - 3]->minor, 1) .
+ '\'')), $this->yystack[$this->yyidx + 0]->minor));
}
- #line 377 "../smarty/lexer/smarty_internal_templateparser.y"
+ #line 398 "../smarty/lexer/smarty_internal_templateparser.y"
function yy_r32()
{
- $tag = trim(substr($this->yystack[$this->yyidx + 0]->minor, $this->lex->ldel_length, - $this->lex->rdel_length));
+ $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']));
+ }
+
+ #line 403 "../smarty/lexer/smarty_internal_templateparser.y"
+ function yy_r33()
+ {
+ $tag =
+ trim(substr($this->yystack[$this->yyidx + 0]->minor, $this->lex->ldel_length, - $this->lex->rdel_length));
if ($tag == 'strip') {
$this->strip = true;
$this->_retvalue = null;;
@@ -1372,7 +1656,8 @@ class Smarty_Internal_Templateparser
if ($this->security) {
$this->security->isTrustedConstant($tag, $this->compiler);
}
- $this->_retvalue = $this->compiler->compileTag('private_print_expression', array(), array('value' => $tag));
+ $this->_retvalue =
+ $this->compiler->compileTag('private_print_expression', array(), array('value' => $tag));
} else {
if (preg_match('/^(.*)(\s+nocache)$/', $tag, $match)) {
$this->_retvalue = $this->compiler->compileTag($match[1], array("'nocache'"));
@@ -1383,149 +1668,197 @@ class Smarty_Internal_Templateparser
}
}
- #line 399 "../smarty/lexer/smarty_internal_templateparser.y"
- function yy_r33()
+ #line 425 "../smarty/lexer/smarty_internal_templateparser.y"
+ function yy_r34()
{
if (defined($this->yystack[$this->yyidx + - 1]->minor)) {
if ($this->security) {
$this->security->isTrustedConstant($this->yystack[$this->yyidx + - 1]->minor, $this->compiler);
}
- $this->_retvalue = $this->compiler->compileTag('private_print_expression', $this->yystack[$this->yyidx + 0]->minor, array('value' => $this->yystack[$this->yyidx + - 1]->minor));
+ $this->_retvalue =
+ $this->compiler->compileTag('private_print_expression', $this->yystack[$this->yyidx + 0]->minor,
+ array('value' => $this->yystack[$this->yyidx + - 1]->minor));
} else {
- $this->_retvalue = $this->compiler->compileTag($this->yystack[$this->yyidx + - 1]->minor, $this->yystack[$this->yyidx + 0]->minor);
+ $this->_retvalue = $this->compiler->compileTag($this->yystack[$this->yyidx + - 1]->minor,
+ $this->yystack[$this->yyidx + 0]->minor);
}
}
- #line 409 "../smarty/lexer/smarty_internal_templateparser.y"
- function yy_r34()
+ #line 435 "../smarty/lexer/smarty_internal_templateparser.y"
+ function yy_r35()
{
if (defined($this->yystack[$this->yyidx + 0]->minor)) {
if ($this->security) {
$this->security->isTrustedConstant($this->yystack[$this->yyidx + 0]->minor, $this->compiler);
}
- $this->_retvalue = $this->compiler->compileTag('private_print_expression', array(), array('value' => $this->yystack[$this->yyidx + 0]->minor));
+ $this->_retvalue = $this->compiler->compileTag('private_print_expression', array(),
+ array('value' => $this->yystack[$this->yyidx + 0]->minor));
} else {
$this->_retvalue = $this->compiler->compileTag($this->yystack[$this->yyidx + 0]->minor, array());
}
}
- #line 422 "../smarty/lexer/smarty_internal_templateparser.y"
- function yy_r35()
+ #line 448 "../smarty/lexer/smarty_internal_templateparser.y"
+ function yy_r36()
{
if (defined($this->yystack[$this->yyidx + - 2]->minor)) {
if ($this->security) {
$this->security->isTrustedConstant($this->yystack[$this->yyidx + - 2]->minor, $this->compiler);
}
- $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));
+ $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));
} else {
- $this->_retvalue = '<?php ob_start();?>' . $this->compiler->compileTag($this->yystack[$this->yyidx + - 2]->minor, $this->yystack[$this->yyidx + 0]->minor) . '<?php echo ';
- $this->_retvalue .= $this->compiler->compileTag('private_modifier', array(), array('modifierlist' => $this->yystack[$this->yyidx + - 1]->minor,
- 'value' => 'ob_get_clean()')) . ';?>';
+ $this->_retvalue = '<?php ob_start();?>' .
+ $this->compiler->compileTag($this->yystack[$this->yyidx + - 2]->minor,
+ $this->yystack[$this->yyidx + 0]->minor) . '<?php echo ';
+ $this->_retvalue .= $this->compiler->compileTag('private_modifier', array(),
+ array('modifierlist' => $this->yystack[$this->yyidx +
+ - 1]->minor, 'value' => 'ob_get_clean()')) . ';?>';
}
}
- #line 435 "../smarty/lexer/smarty_internal_templateparser.y"
- function yy_r36()
- {
- $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));
- }
-
- #line 440 "../smarty/lexer/smarty_internal_templateparser.y"
+ #line 461 "../smarty/lexer/smarty_internal_templateparser.y"
function yy_r37()
{
- $this->_retvalue = '<?php ob_start();?>' . $this->compiler->compileTag($this->yystack[$this->yyidx + - 4]->minor, $this->yystack[$this->yyidx + 0]->minor, array('object_method' => $this->yystack[$this->yyidx + - 2]->minor)) . '<?php echo ';
- $this->_retvalue .= $this->compiler->compileTag('private_modifier', array(), array('modifierlist' => $this->yystack[$this->yyidx + - 1]->minor,
- 'value' => 'ob_get_clean()')) . ';?>';
+ $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));
}
- #line 446 "../smarty/lexer/smarty_internal_templateparser.y"
+ #line 466 "../smarty/lexer/smarty_internal_templateparser.y"
function yy_r38()
{
- $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));
+ $this->_retvalue = '<?php ob_start();?>' .
+ $this->compiler->compileTag($this->yystack[$this->yyidx + - 4]->minor,
+ $this->yystack[$this->yyidx + 0]->minor,
+ array('object_method' => $this->yystack[$this->yyidx + - 2]->minor)) .
+ '<?php echo ';
+ $this->_retvalue .= $this->compiler->compileTag('private_modifier', array(),
+ array('modifierlist' => $this->yystack[$this->yyidx +
+ - 1]->minor, 'value' => 'ob_get_clean()')) . ';?>';
}
- #line 451 "../smarty/lexer/smarty_internal_templateparser.y"
+ #line 472 "../smarty/lexer/smarty_internal_templateparser.y"
function yy_r39()
{
- $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));
+ $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));
}
- #line 456 "../smarty/lexer/smarty_internal_templateparser.y"
+ #line 477 "../smarty/lexer/smarty_internal_templateparser.y"
function yy_r40()
{
- $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));
+ $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));
}
- #line 467 "../smarty/lexer/smarty_internal_templateparser.y"
- function yy_r42()
+ #line 482 "../smarty/lexer/smarty_internal_templateparser.y"
+ function yy_r41()
{
- $this->_retvalue = $this->compiler->compileTag('for', array_merge($this->yystack[$this->yyidx + 0]->minor, array(array('start' => $this->yystack[$this->yyidx + - 6]->minor),
- array('ifexp' => $this->yystack[$this->yyidx + - 4]->minor),
- array('var' => $this->yystack[$this->yyidx + - 2]->minor),
- array('step' => $this->yystack[$this->yyidx + - 1]->minor))), 1);
+ $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));
}
- #line 471 "../smarty/lexer/smarty_internal_templateparser.y"
+ #line 493 "../smarty/lexer/smarty_internal_templateparser.y"
function yy_r43()
{
- $this->_retvalue = '=' . $this->yystack[$this->yyidx + 0]->minor;
+ $this->_retvalue = $this->compiler->compileTag('for', array_merge($this->yystack[$this->yyidx + 0]->minor,
+ array(array('start' => $this->yystack[$this->yyidx +
+ - 6]->minor),
+ array('ifexp' => $this->yystack[$this->yyidx +
+ - 4]->minor),
+ array('var' => $this->yystack[$this->yyidx +
+ - 2]->minor),
+ array('step' => $this->yystack[$this->yyidx +
+ - 1]->minor))), 1);
}
- #line 479 "../smarty/lexer/smarty_internal_templateparser.y"
- function yy_r45()
+ #line 497 "../smarty/lexer/smarty_internal_templateparser.y"
+ 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);
+ $this->_retvalue = '=' . $this->yystack[$this->yyidx + 0]->minor;
}
- #line 483 "../smarty/lexer/smarty_internal_templateparser.y"
+ #line 505 "../smarty/lexer/smarty_internal_templateparser.y"
function yy_r46()
{
- $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);
+ $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);
}
- #line 488 "../smarty/lexer/smarty_internal_templateparser.y"
+ #line 509 "../smarty/lexer/smarty_internal_templateparser.y"
function yy_r47()
{
- $this->_retvalue = $this->compiler->compileTag('foreach', $this->yystack[$this->yyidx + 0]->minor);
+ $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);
}
- #line 493 "../smarty/lexer/smarty_internal_templateparser.y"
+ #line 514 "../smarty/lexer/smarty_internal_templateparser.y"
function yy_r48()
{
- $this->_retvalue = $this->compiler->compileTag('foreach', array_merge($this->yystack[$this->yyidx + 0]->minor, array(array('from' => $this->yystack[$this->yyidx + - 3]->minor),
- array('item' => $this->yystack[$this->yyidx + - 1]->minor))));
+ $this->_retvalue = $this->compiler->compileTag('foreach', $this->yystack[$this->yyidx + 0]->minor);
}
- #line 497 "../smarty/lexer/smarty_internal_templateparser.y"
+ #line 519 "../smarty/lexer/smarty_internal_templateparser.y"
function yy_r49()
{
- $this->_retvalue = $this->compiler->compileTag('foreach', array_merge($this->yystack[$this->yyidx + 0]->minor, array(array('from' => $this->yystack[$this->yyidx + - 5]->minor),
- array('item' => $this->yystack[$this->yyidx + - 1]->minor),
- array('key' => $this->yystack[$this->yyidx + - 3]->minor))));
+ $this->_retvalue = $this->compiler->compileTag('foreach', array_merge($this->yystack[$this->yyidx + 0]->minor,
+ array(array('from' => $this->yystack[$this->yyidx +
+ - 3]->minor),
+ array('item' => $this->yystack[$this->yyidx +
+ - 1]->minor))));
}
- #line 510 "../smarty/lexer/smarty_internal_templateparser.y"
- function yy_r52()
+ #line 523 "../smarty/lexer/smarty_internal_templateparser.y"
+ function yy_r50()
{
- $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))));
+ $this->_retvalue = $this->compiler->compileTag('foreach', array_merge($this->yystack[$this->yyidx + 0]->minor,
+ array(array('from' => $this->yystack[$this->yyidx +
+ - 5]->minor),
+ array('item' => $this->yystack[$this->yyidx +
+ - 1]->minor),
+ array('key' => $this->yystack[$this->yyidx +
+ - 3]->minor))));
}
- #line 514 "../smarty/lexer/smarty_internal_templateparser.y"
+ #line 536 "../smarty/lexer/smarty_internal_templateparser.y"
function yy_r53()
{
- $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)));
+ $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))));
}
- #line 519 "../smarty/lexer/smarty_internal_templateparser.y"
+ #line 540 "../smarty/lexer/smarty_internal_templateparser.y"
function yy_r54()
{
+ $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)));
+ }
+
+ #line 545 "../smarty/lexer/smarty_internal_templateparser.y"
+ function yy_r55()
+ {
$j = strrpos($this->yystack[$this->yyidx + 0]->minor, '.');
if ($this->yystack[$this->yyidx + 0]->minor[$j + 1] == 'c') {
// {$smarty.block.child}
@@ -1536,10 +1869,11 @@ class Smarty_Internal_Templateparser
}
}
- #line 532 "../smarty/lexer/smarty_internal_templateparser.y"
- function yy_r55()
+ #line 558 "../smarty/lexer/smarty_internal_templateparser.y"
+ function yy_r56()
{
- $tag = trim(substr($this->yystack[$this->yyidx + 0]->minor, $this->lex->ldel_length, - $this->lex->rdel_length), ' /');
+ $tag = trim(substr($this->yystack[$this->yyidx + 0]->minor, $this->lex->ldel_length, - $this->lex->rdel_length),
+ ' /');
if ($tag == 'strip') {
$this->strip = false;
$this->_retvalue = null;
@@ -1548,189 +1882,216 @@ class Smarty_Internal_Templateparser
}
}
- #line 541 "../smarty/lexer/smarty_internal_templateparser.y"
- function yy_r56()
- {
- $this->_retvalue = $this->compiler->compileTag($this->yystack[$this->yyidx + 0]->minor . 'close', array());
- }
-
- #line 545 "../smarty/lexer/smarty_internal_templateparser.y"
+ #line 567 "../smarty/lexer/smarty_internal_templateparser.y"
function yy_r57()
{
- $this->_retvalue = $this->compiler->compileTag($this->yystack[$this->yyidx + - 1]->minor . 'close', array(), array('modifier_list' => $this->yystack[$this->yyidx + 0]->minor));
+ $this->_retvalue = $this->compiler->compileTag($this->yystack[$this->yyidx + 0]->minor . 'close', array());
}
- #line 550 "../smarty/lexer/smarty_internal_templateparser.y"
+ #line 571 "../smarty/lexer/smarty_internal_templateparser.y"
function yy_r58()
{
- $this->_retvalue = $this->compiler->compileTag($this->yystack[$this->yyidx + - 2]->minor . 'close', array(), array('object_method' => $this->yystack[$this->yyidx + 0]->minor));
+ $this->_retvalue = $this->compiler->compileTag($this->yystack[$this->yyidx + - 1]->minor . 'close', array(),
+ array('modifier_list' => $this->yystack[$this->yyidx +
+ 0]->minor));
}
- #line 554 "../smarty/lexer/smarty_internal_templateparser.y"
+ #line 576 "../smarty/lexer/smarty_internal_templateparser.y"
function yy_r59()
{
- $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));
+ $this->_retvalue = $this->compiler->compileTag($this->yystack[$this->yyidx + - 2]->minor . 'close', array(),
+ array('object_method' => $this->yystack[$this->yyidx +
+ 0]->minor));
}
- #line 562 "../smarty/lexer/smarty_internal_templateparser.y"
+ #line 580 "../smarty/lexer/smarty_internal_templateparser.y"
function yy_r60()
{
+ $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));
+ }
+
+ #line 588 "../smarty/lexer/smarty_internal_templateparser.y"
+ function yy_r61()
+ {
$this->_retvalue = $this->yystack[$this->yyidx + - 1]->minor;
$this->_retvalue[] = $this->yystack[$this->yyidx + 0]->minor;
}
- #line 568 "../smarty/lexer/smarty_internal_templateparser.y"
- function yy_r61()
+ #line 594 "../smarty/lexer/smarty_internal_templateparser.y"
+ function yy_r62()
{
$this->_retvalue = array($this->yystack[$this->yyidx + 0]->minor);
}
- #line 573 "../smarty/lexer/smarty_internal_templateparser.y"
- function yy_r62()
+ #line 599 "../smarty/lexer/smarty_internal_templateparser.y"
+ function yy_r63()
{
$this->_retvalue = array();
}
- #line 578 "../smarty/lexer/smarty_internal_templateparser.y"
- function yy_r63()
+ #line 604 "../smarty/lexer/smarty_internal_templateparser.y"
+ function yy_r64()
{
if (defined($this->yystack[$this->yyidx + 0]->minor)) {
if ($this->security) {
$this->security->isTrustedConstant($this->yystack[$this->yyidx + 0]->minor, $this->compiler);
}
- $this->_retvalue = array($this->yystack[$this->yyidx + - 2]->minor => $this->yystack[$this->yyidx + 0]->minor);
+ $this->_retvalue =
+ array($this->yystack[$this->yyidx + - 2]->minor => $this->yystack[$this->yyidx + 0]->minor);
} else {
- $this->_retvalue = array($this->yystack[$this->yyidx + - 2]->minor => '\'' . $this->yystack[$this->yyidx + 0]->minor . '\'');
+ $this->_retvalue =
+ array($this->yystack[$this->yyidx + - 2]->minor => '\'' . $this->yystack[$this->yyidx + 0]->minor .
+ '\'');
}
}
- #line 589 "../smarty/lexer/smarty_internal_templateparser.y"
- function yy_r64()
+ #line 615 "../smarty/lexer/smarty_internal_templateparser.y"
+ function yy_r65()
{
- $this->_retvalue = array(trim($this->yystack[$this->yyidx + - 1]->minor, " =\n\r\t") => $this->yystack[$this->yyidx + 0]->minor);
+ $this->_retvalue =
+ array(trim($this->yystack[$this->yyidx + - 1]->minor, " =\n\r\t") => $this->yystack[$this->yyidx +
+ 0]->minor);
}
- #line 597 "../smarty/lexer/smarty_internal_templateparser.y"
- function yy_r66()
+ #line 623 "../smarty/lexer/smarty_internal_templateparser.y"
+ function yy_r67()
{
$this->_retvalue = '\'' . $this->yystack[$this->yyidx + 0]->minor . '\'';
}
- #line 609 "../smarty/lexer/smarty_internal_templateparser.y"
- function yy_r69()
+ #line 635 "../smarty/lexer/smarty_internal_templateparser.y"
+ function yy_r70()
{
$this->_retvalue = array($this->yystack[$this->yyidx + - 2]->minor => $this->yystack[$this->yyidx + 0]->minor);
}
- #line 622 "../smarty/lexer/smarty_internal_templateparser.y"
- function yy_r71()
+ #line 648 "../smarty/lexer/smarty_internal_templateparser.y"
+ function yy_r72()
{
$this->yystack[$this->yyidx + - 2]->minor[] = $this->yystack[$this->yyidx + 0]->minor;
$this->_retvalue = $this->yystack[$this->yyidx + - 2]->minor;
}
- #line 627 "../smarty/lexer/smarty_internal_templateparser.y"
- function yy_r72()
+ #line 653 "../smarty/lexer/smarty_internal_templateparser.y"
+ function yy_r73()
{
$this->_retvalue = array('var' => '\'' . substr($this->yystack[$this->yyidx + - 2]->minor, 1) . '\'',
'value' => $this->yystack[$this->yyidx + 0]->minor);
}
- #line 634 "../smarty/lexer/smarty_internal_templateparser.y"
- function yy_r74()
+ #line 660 "../smarty/lexer/smarty_internal_templateparser.y"
+ function yy_r75()
{
$this->_retvalue = array('var' => $this->yystack[$this->yyidx + - 2]->minor,
'value' => $this->yystack[$this->yyidx + 0]->minor);
}
- #line 658 "../smarty/lexer/smarty_internal_templateparser.y"
- function yy_r78()
- {
- $this->_retvalue = '$_smarty_tpl->getStreamVariable(\'' . substr($this->yystack[$this->yyidx + - 2]->minor, 1) . '://' . $this->yystack[$this->yyidx + 0]->minor . '\')';
- }
-
- #line 663 "../smarty/lexer/smarty_internal_templateparser.y"
+ #line 684 "../smarty/lexer/smarty_internal_templateparser.y"
function yy_r79()
{
- $this->_retvalue = $this->yystack[$this->yyidx + - 2]->minor . trim($this->yystack[$this->yyidx + - 1]->minor) . $this->yystack[$this->yyidx + 0]->minor;
+ $this->_retvalue =
+ '$_smarty_tpl->getStreamVariable(\'' . substr($this->yystack[$this->yyidx + - 2]->minor, 1) . '://' .
+ $this->yystack[$this->yyidx + 0]->minor . '\')';
}
- #line 677 "../smarty/lexer/smarty_internal_templateparser.y"
- function yy_r82()
+ #line 689 "../smarty/lexer/smarty_internal_templateparser.y"
+ 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));
+ $this->_retvalue = $this->yystack[$this->yyidx + - 2]->minor . trim($this->yystack[$this->yyidx + - 1]->minor) .
+ $this->yystack[$this->yyidx + 0]->minor;
}
- #line 683 "../smarty/lexer/smarty_internal_templateparser.y"
+ #line 703 "../smarty/lexer/smarty_internal_templateparser.y"
function yy_r83()
{
- $this->_retvalue = (isset($this->yystack[$this->yyidx + - 1]->minor['pre']) ? $this->yystack[$this->yyidx + - 1]->minor['pre'] : '') . $this->yystack[$this->yyidx + - 2]->minor . $this->yystack[$this->yyidx + - 1]->minor['op'] . $this->yystack[$this->yyidx + 0]->minor . (isset($this->yystack[$this->yyidx + - 1]->minor['pre']) ? ')' : '');
+ $this->_retvalue = $this->compiler->compileTag('private_modifier', array(),
+ array('value' => $this->yystack[$this->yyidx + - 1]->minor,
+ 'modifierlist' => $this->yystack[$this->yyidx +
+ 0]->minor));
}
- #line 686 "../smarty/lexer/smarty_internal_templateparser.y"
+ #line 709 "../smarty/lexer/smarty_internal_templateparser.y"
function yy_r84()
{
- $this->_retvalue = $this->yystack[$this->yyidx + 0]->minor . $this->yystack[$this->yyidx + - 1]->minor . ')';
+ $this->_retvalue = (isset($this->yystack[$this->yyidx + - 1]->minor['pre']) ?
+ $this->yystack[$this->yyidx + - 1]->minor['pre'] : '') . $this->yystack[$this->yyidx + - 2]->minor .
+ $this->yystack[$this->yyidx + - 1]->minor['op'] . $this->yystack[$this->yyidx + 0]->minor .
+ (isset($this->yystack[$this->yyidx + - 1]->minor['pre']) ? ')' : '');
}
- #line 690 "../smarty/lexer/smarty_internal_templateparser.y"
+ #line 712 "../smarty/lexer/smarty_internal_templateparser.y"
function yy_r85()
{
- $this->_retvalue = 'in_array(' . $this->yystack[$this->yyidx + - 2]->minor . ',' . $this->yystack[$this->yyidx + 0]->minor . ')';
+ $this->_retvalue = $this->yystack[$this->yyidx + 0]->minor . $this->yystack[$this->yyidx + - 1]->minor . ')';
}
- #line 694 "../smarty/lexer/smarty_internal_templateparser.y"
+ #line 716 "../smarty/lexer/smarty_internal_templateparser.y"
function yy_r86()
{
- $this->_retvalue = 'in_array(' . $this->yystack[$this->yyidx + - 2]->minor . ',(array)' . $this->yystack[$this->yyidx + 0]->minor . ')';
+ $this->_retvalue =
+ 'in_array(' . $this->yystack[$this->yyidx + - 2]->minor . ',' . $this->yystack[$this->yyidx + 0]->minor .
+ ')';
}
- #line 698 "../smarty/lexer/smarty_internal_templateparser.y"
+ #line 720 "../smarty/lexer/smarty_internal_templateparser.y"
function yy_r87()
{
- $this->_retvalue = $this->yystack[$this->yyidx + - 2]->minor . $this->yystack[$this->yyidx + - 1]->minor . $this->yystack[$this->yyidx + 0]->minor;
+ $this->_retvalue = 'in_array(' . $this->yystack[$this->yyidx + - 2]->minor . ',(array)' .
+ $this->yystack[$this->yyidx + 0]->minor . ')';
}
- #line 706 "../smarty/lexer/smarty_internal_templateparser.y"
+ #line 724 "../smarty/lexer/smarty_internal_templateparser.y"
function yy_r88()
{
- $this->_retvalue = $this->yystack[$this->yyidx + - 5]->minor . ' ? ' . $this->compiler->compileVariable('\'' . substr($this->yystack[$this->yyidx + - 2]->minor, 1) . '\'') . ' : ' . $this->yystack[$this->yyidx + 0]->minor;
+ $this->_retvalue = $this->yystack[$this->yyidx + - 2]->minor . $this->yystack[$this->yyidx + - 1]->minor .
+ $this->yystack[$this->yyidx + 0]->minor;
+ }
+
+ #line 736 "../smarty/lexer/smarty_internal_templateparser.y"
+ function yy_r90()
+ {
+ $this->_retvalue = $this->yystack[$this->yyidx + - 5]->minor . ' ? ' .
+ $this->compiler->compileVariable('\'' . substr($this->yystack[$this->yyidx + - 2]->minor, 1) . '\'') .
+ ' : ' . $this->yystack[$this->yyidx + 0]->minor;
}
- #line 710 "../smarty/lexer/smarty_internal_templateparser.y"
- function yy_r89()
+ #line 740 "../smarty/lexer/smarty_internal_templateparser.y"
+ function yy_r91()
{
- $this->_retvalue = $this->yystack[$this->yyidx + - 5]->minor . ' ? ' . $this->yystack[$this->yyidx + - 2]->minor . ' : ' . $this->yystack[$this->yyidx + 0]->minor;
+ $this->_retvalue =
+ $this->yystack[$this->yyidx + - 5]->minor . ' ? ' . $this->yystack[$this->yyidx + - 2]->minor . ' : ' .
+ $this->yystack[$this->yyidx + 0]->minor;
}
- #line 725 "../smarty/lexer/smarty_internal_templateparser.y"
- function yy_r92()
+ #line 755 "../smarty/lexer/smarty_internal_templateparser.y"
+ function yy_r94()
{
$this->_retvalue = '!' . $this->yystack[$this->yyidx + 0]->minor;
}
- #line 746 "../smarty/lexer/smarty_internal_templateparser.y"
- function yy_r97()
+ #line 776 "../smarty/lexer/smarty_internal_templateparser.y"
+ function yy_r99()
{
$this->_retvalue = $this->yystack[$this->yyidx + - 2]->minor . '.' . $this->yystack[$this->yyidx + 0]->minor;
}
- #line 750 "../smarty/lexer/smarty_internal_templateparser.y"
- function yy_r98()
+ #line 780 "../smarty/lexer/smarty_internal_templateparser.y"
+ function yy_r100()
{
$this->_retvalue = $this->yystack[$this->yyidx + - 1]->minor . '.';
}
- #line 754 "../smarty/lexer/smarty_internal_templateparser.y"
- function yy_r99()
+ #line 784 "../smarty/lexer/smarty_internal_templateparser.y"
+ function yy_r101()
{
$this->_retvalue = '.' . $this->yystack[$this->yyidx + 0]->minor;
}
- #line 759 "../smarty/lexer/smarty_internal_templateparser.y"
- function yy_r100()
+ #line 789 "../smarty/lexer/smarty_internal_templateparser.y"
+ function yy_r102()
{
if (defined($this->yystack[$this->yyidx + 0]->minor)) {
if ($this->security) {
@@ -1742,139 +2103,169 @@ class Smarty_Internal_Templateparser
}
}
- #line 776 "../smarty/lexer/smarty_internal_templateparser.y"
- function yy_r102()
+ #line 806 "../smarty/lexer/smarty_internal_templateparser.y"
+ function yy_r104()
{
$this->_retvalue = "(" . $this->yystack[$this->yyidx + - 1]->minor . ")";
}
- #line 791 "../smarty/lexer/smarty_internal_templateparser.y"
- function yy_r105()
+ #line 821 "../smarty/lexer/smarty_internal_templateparser.y"
+ function yy_r107()
{
self::$prefix_number ++;
if ($this->yystack[$this->yyidx + - 2]->minor['var'] == '\'smarty\'') {
- $this->compiler->prefix_code[] = '<?php $_tmp' . self::$prefix_number . ' = ' . $this->compiler->compileTag('private_special_variable', array(), $this->yystack[$this->yyidx + - 2]->minor['smarty_internal_index']) . ';?>';
+ $this->compiler->prefix_code[] = '<?php $_tmp' . self::$prefix_number . ' = ' .
+ $this->compiler->compileTag('private_special_variable', array(),
+ $this->yystack[$this->yyidx + - 2]->minor['smarty_internal_index']) . ';?>';
} else {
- $this->compiler->prefix_code[] = '<?php $_tmp' . self::$prefix_number . ' = ' . $this->compiler->compileVariable($this->yystack[$this->yyidx + - 2]->minor['var']) . $this->yystack[$this->yyidx + - 2]->minor['smarty_internal_index'] . ';?>';
+ $this->compiler->prefix_code[] = '<?php $_tmp' . self::$prefix_number . ' = ' .
+ $this->compiler->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[0] . $this->yystack[$this->yyidx + 0]->minor[1];
+ $this->_retvalue = '$_tmp' . self::$prefix_number . '::' . $this->yystack[$this->yyidx + 0]->minor[0] .
+ $this->yystack[$this->yyidx + 0]->minor[1];
}
- #line 802 "../smarty/lexer/smarty_internal_templateparser.y"
- function yy_r106()
+ #line 832 "../smarty/lexer/smarty_internal_templateparser.y"
+ function yy_r108()
{
self::$prefix_number ++;
$tmp = $this->compiler->appendCode('<?php ob_start();?>', $this->yystack[$this->yyidx + 0]->minor);
- $this->compiler->prefix_code[] = $this->compiler->appendCode($tmp, '<?php $_tmp' . self::$prefix_number . '=ob_get_clean();?>');
+ $this->compiler->prefix_code[] =
+ $this->compiler->appendCode($tmp, '<?php $_tmp' . self::$prefix_number . '=ob_get_clean();?>');
$this->_retvalue = '$_tmp' . self::$prefix_number;
}
- #line 819 "../smarty/lexer/smarty_internal_templateparser.y"
- function yy_r109()
+ #line 849 "../smarty/lexer/smarty_internal_templateparser.y"
+ function yy_r111()
{
- if (!in_array(strtolower($this->yystack[$this->yyidx + - 2]->minor), array('self',
- 'parent')) && (!$this->security || $this->security->isTrustedStaticClassAccess($this->yystack[$this->yyidx + - 2]->minor, $this->yystack[$this->yyidx + 0]->minor, $this->compiler))
+ if (!in_array(strtolower($this->yystack[$this->yyidx + - 2]->minor), array('self', 'parent')) &&
+ (!$this->security || $this->security->isTrustedStaticClassAccess($this->yystack[$this->yyidx + - 2]->minor,
+ $this->yystack[$this->yyidx + 0]->minor,
+ $this->compiler))
) {
if (isset($this->smarty->registered_classes[$this->yystack[$this->yyidx + - 2]->minor])) {
- $this->_retvalue = $this->smarty->registered_classes[$this->yystack[$this->yyidx + - 2]->minor] . '::' . $this->yystack[$this->yyidx + 0]->minor[0] . $this->yystack[$this->yyidx + 0]->minor[1];
+ $this->_retvalue = $this->smarty->registered_classes[$this->yystack[$this->yyidx + - 2]->minor] . '::' .
+ $this->yystack[$this->yyidx + 0]->minor[0] . $this->yystack[$this->yyidx + 0]->minor[1];
} else {
- $this->_retvalue = $this->yystack[$this->yyidx + - 2]->minor . '::' . $this->yystack[$this->yyidx + 0]->minor[0] . $this->yystack[$this->yyidx + 0]->minor[1];
+ $this->_retvalue =
+ $this->yystack[$this->yyidx + - 2]->minor . '::' . $this->yystack[$this->yyidx + 0]->minor[0] .
+ $this->yystack[$this->yyidx + 0]->minor[1];
}
} else {
- $this->compiler->trigger_template_error("static class '" . $this->yystack[$this->yyidx + - 2]->minor . "' is undefined or not allowed by security setting");
+ $this->compiler->trigger_template_error("static class '" . $this->yystack[$this->yyidx + - 2]->minor .
+ "' is undefined or not allowed by security setting");
}
}
- #line 853 "../smarty/lexer/smarty_internal_templateparser.y"
- function yy_r112()
+ #line 868 "../smarty/lexer/smarty_internal_templateparser.y"
+ function yy_r113()
{
- $this->_retvalue = $this->compiler->compileVariable('\'' . substr($this->yystack[$this->yyidx + 0]->minor, 1) . '\'');
+ $this->_retvalue = $this->yystack[$this->yyidx + 0]->minor;
}
- #line 856 "../smarty/lexer/smarty_internal_templateparser.y"
- function yy_r113()
+ #line 879 "../smarty/lexer/smarty_internal_templateparser.y"
+ function yy_r114()
+ {
+ $this->_retvalue =
+ $this->compiler->compileVariable('\'' . substr($this->yystack[$this->yyidx + 0]->minor, 1) . '\'');
+ }
+
+ #line 882 "../smarty/lexer/smarty_internal_templateparser.y"
+ function yy_r115()
{
if ($this->yystack[$this->yyidx + 0]->minor['var'] == '\'smarty\'') {
- $smarty_var = $this->compiler->compileTag('private_special_variable', array(), $this->yystack[$this->yyidx + 0]->minor['smarty_internal_index']);
+ $smarty_var = $this->compiler->compileTag('private_special_variable', array(),
+ $this->yystack[$this->yyidx + 0]->minor['smarty_internal_index']);
$this->_retvalue = $smarty_var;
} else {
- // used for array reset,next,prev,end,current
+ // used for array reset,next,prev,end,current
$this->last_variable = $this->yystack[$this->yyidx + 0]->minor['var'];
$this->last_index = $this->yystack[$this->yyidx + 0]->minor['smarty_internal_index'];
- $this->_retvalue = $this->compiler->compileVariable($this->yystack[$this->yyidx + 0]->minor['var']) . $this->yystack[$this->yyidx + 0]->minor['smarty_internal_index'];
+ $this->_retvalue = $this->compiler->compileVariable($this->yystack[$this->yyidx + 0]->minor['var']) .
+ $this->yystack[$this->yyidx + 0]->minor['smarty_internal_index'];
}
}
- #line 869 "../smarty/lexer/smarty_internal_templateparser.y"
- function yy_r114()
+ #line 895 "../smarty/lexer/smarty_internal_templateparser.y"
+ function yy_r116()
{
- $this->_retvalue = '$_smarty_tpl->tpl_vars[' . $this->yystack[$this->yyidx + - 2]->minor . ']->' . $this->yystack[$this->yyidx + 0]->minor;
+ $this->_retvalue = '$_smarty_tpl->tpl_vars[' . $this->yystack[$this->yyidx + - 2]->minor . ']->' .
+ $this->yystack[$this->yyidx + 0]->minor;
}
- #line 879 "../smarty/lexer/smarty_internal_templateparser.y"
- function yy_r116()
+ #line 905 "../smarty/lexer/smarty_internal_templateparser.y"
+ function yy_r118()
{
- $this->_retvalue = '$_smarty_tpl->getConfigVariable( \'' . $this->yystack[$this->yyidx + - 1]->minor . '\')';
+ $this->_retvalue =
+ $this->compiler->compileConfigVariable("'" . $this->yystack[$this->yyidx + - 1]->minor . "'");
}
- #line 883 "../smarty/lexer/smarty_internal_templateparser.y"
- function yy_r117()
+ #line 909 "../smarty/lexer/smarty_internal_templateparser.y"
+ function yy_r119()
{
- $this->_retvalue = '(is_array($tmp = $_smarty_tpl->getConfigVariable( \'' . $this->yystack[$this->yyidx + - 2]->minor . '\')) ? $tmp' . $this->yystack[$this->yyidx + 0]->minor . ' :null)';
+ $this->_retvalue = '(is_array($tmp = ' .
+ $this->compiler->compileConfigVariable("'" . $this->yystack[$this->yyidx + - 2]->minor . "'") . ') ? $tmp' .
+ $this->yystack[$this->yyidx + 0]->minor . ' :null)';
}
- #line 887 "../smarty/lexer/smarty_internal_templateparser.y"
- function yy_r118()
+ #line 913 "../smarty/lexer/smarty_internal_templateparser.y"
+ function yy_r120()
{
- $this->_retvalue = '$_smarty_tpl->getConfigVariable( ' . $this->yystack[$this->yyidx + - 1]->minor . ')';
+ $this->_retvalue = $this->compiler->compileConfigVariable($this->yystack[$this->yyidx + - 1]->minor);
}
- #line 891 "../smarty/lexer/smarty_internal_templateparser.y"
- function yy_r119()
+ #line 917 "../smarty/lexer/smarty_internal_templateparser.y"
+ function yy_r121()
{
- $this->_retvalue = '(is_array($tmp = $_smarty_tpl->getConfigVariable( ' . $this->yystack[$this->yyidx + - 2]->minor . ')) ? $tmp' . $this->yystack[$this->yyidx + 0]->minor . ' : null)';
+ $this->_retvalue =
+ '(is_array($tmp = ' . $this->compiler->compileConfigVariable($this->yystack[$this->yyidx + - 2]->minor) .
+ ') ? $tmp' . $this->yystack[$this->yyidx + 0]->minor . ' : null)';
}
- #line 895 "../smarty/lexer/smarty_internal_templateparser.y"
- function yy_r120()
+ #line 921 "../smarty/lexer/smarty_internal_templateparser.y"
+ function yy_r122()
{
- $this->_retvalue = array('var' => '\'' . substr($this->yystack[$this->yyidx + - 1]->minor, 1) . '\'',
+ $this->_retvalue = array('var' => '\'' . substr($this->yystack[$this->yyidx + - 1]->minor, 1) . '\'',
'smarty_internal_index' => $this->yystack[$this->yyidx + 0]->minor);
}
- #line 898 "../smarty/lexer/smarty_internal_templateparser.y"
- function yy_r121()
+ #line 924 "../smarty/lexer/smarty_internal_templateparser.y"
+ function yy_r123()
{
$this->_retvalue = array('var' => $this->yystack[$this->yyidx + - 1]->minor,
'smarty_internal_index' => $this->yystack[$this->yyidx + 0]->minor);
}
- #line 911 "../smarty/lexer/smarty_internal_templateparser.y"
- function yy_r123()
+ #line 937 "../smarty/lexer/smarty_internal_templateparser.y"
+ function yy_r125()
{
return;
}
- #line 917 "../smarty/lexer/smarty_internal_templateparser.y"
- function yy_r124()
+ #line 943 "../smarty/lexer/smarty_internal_templateparser.y"
+ function yy_r126()
{
- $this->_retvalue = '[' . $this->compiler->compileVariable('\'' . substr($this->yystack[$this->yyidx + 0]->minor, 1) . '\'') . ']';
+ $this->_retvalue =
+ '[' . $this->compiler->compileVariable('\'' . substr($this->yystack[$this->yyidx + 0]->minor, 1) . '\'') .
+ ']';
}
- #line 920 "../smarty/lexer/smarty_internal_templateparser.y"
- function yy_r125()
+ #line 946 "../smarty/lexer/smarty_internal_templateparser.y"
+ function yy_r127()
{
$this->_retvalue = '[' . $this->compiler->compileVariable($this->yystack[$this->yyidx + 0]->minor) . ']';
}
- #line 924 "../smarty/lexer/smarty_internal_templateparser.y"
- function yy_r126()
+ #line 950 "../smarty/lexer/smarty_internal_templateparser.y"
+ function yy_r128()
{
- $this->_retvalue = '[' . $this->compiler->compileVariable($this->yystack[$this->yyidx + - 2]->minor) . '->' . $this->yystack[$this->yyidx + 0]->minor . ']';
+ $this->_retvalue = '[' . $this->compiler->compileVariable($this->yystack[$this->yyidx + - 2]->minor) . '->' .
+ $this->yystack[$this->yyidx + 0]->minor . ']';
}
- #line 928 "../smarty/lexer/smarty_internal_templateparser.y"
- function yy_r127()
+ #line 954 "../smarty/lexer/smarty_internal_templateparser.y"
+ function yy_r129()
{
if (defined($this->yystack[$this->yyidx + 0]->minor)) {
if ($this->security) {
@@ -1886,96 +2277,118 @@ class Smarty_Internal_Templateparser
}
}
- #line 939 "../smarty/lexer/smarty_internal_templateparser.y"
- function yy_r128()
+ #line 965 "../smarty/lexer/smarty_internal_templateparser.y"
+ function yy_r130()
{
$this->_retvalue = '[' . $this->yystack[$this->yyidx + 0]->minor . ']';
}
- #line 943 "../smarty/lexer/smarty_internal_templateparser.y"
- function yy_r129()
+ #line 970 "../smarty/lexer/smarty_internal_templateparser.y"
+ function yy_r131()
{
$this->_retvalue = '[' . $this->yystack[$this->yyidx + - 1]->minor . ']';
}
- #line 948 "../smarty/lexer/smarty_internal_templateparser.y"
- function yy_r130()
+ #line 975 "../smarty/lexer/smarty_internal_templateparser.y"
+ function yy_r132()
{
- $this->_retvalue = '[' . $this->compiler->compileTag('private_special_variable', array(), '[\'section\'][\'' . $this->yystack[$this->yyidx + - 1]->minor . '\'][\'index\']') . ']';
+ $this->_retvalue = '[' . $this->compiler->compileTag('private_special_variable', array(), '[\'section\'][\'' .
+ $this->yystack[$this->yyidx +
+ - 1]->minor . '\'][\'index\']') .
+ ']';
}
- #line 952 "../smarty/lexer/smarty_internal_templateparser.y"
- function yy_r131()
+ #line 979 "../smarty/lexer/smarty_internal_templateparser.y"
+ function yy_r133()
{
- $this->_retvalue = '[' . $this->compiler->compileTag('private_special_variable', array(), '[\'section\'][\'' . $this->yystack[$this->yyidx + - 3]->minor . '\'][\'' . $this->yystack[$this->yyidx + - 1]->minor . '\']') . ']';
+ $this->_retvalue = '[' . $this->compiler->compileTag('private_special_variable', array(), '[\'section\'][\'' .
+ $this->yystack[$this->yyidx +
+ - 3]->minor . '\'][\'' .
+ $this->yystack[$this->yyidx +
+ - 1]->minor . '\']') . ']';
}
- #line 955 "../smarty/lexer/smarty_internal_templateparser.y"
- function yy_r132()
+ #line 982 "../smarty/lexer/smarty_internal_templateparser.y"
+ function yy_r134()
{
$this->_retvalue = '[' . $this->yystack[$this->yyidx + - 1]->minor . ']';
}
- #line 961 "../smarty/lexer/smarty_internal_templateparser.y"
- function yy_r134()
+ #line 988 "../smarty/lexer/smarty_internal_templateparser.y"
+ function yy_r136()
{
- $this->_retvalue = '[' . $this->compiler->compileVariable('\'' . substr($this->yystack[$this->yyidx + - 1]->minor, 1) . '\'') . ']';;
+ $this->_retvalue =
+ '[' . $this->compiler->compileVariable('\'' . substr($this->yystack[$this->yyidx + - 1]->minor, 1) . '\'') .
+ ']';;
}
- #line 977 "../smarty/lexer/smarty_internal_templateparser.y"
- function yy_r138()
+ #line 1004 "../smarty/lexer/smarty_internal_templateparser.y"
+ function yy_r140()
{
$this->_retvalue = '[]';
}
- #line 987 "../smarty/lexer/smarty_internal_templateparser.y"
- function yy_r139()
+ #line 1014 "../smarty/lexer/smarty_internal_templateparser.y"
+ function yy_r141()
{
$this->_retvalue = '\'' . substr($this->yystack[$this->yyidx + 0]->minor, 1) . '\'';
}
- #line 991 "../smarty/lexer/smarty_internal_templateparser.y"
- function yy_r140()
+ #line 1018 "../smarty/lexer/smarty_internal_templateparser.y"
+ function yy_r142()
{
$this->_retvalue = "''";
}
- #line 996 "../smarty/lexer/smarty_internal_templateparser.y"
- function yy_r141()
+ #line 1023 "../smarty/lexer/smarty_internal_templateparser.y"
+ function yy_r143()
{
$this->_retvalue = $this->yystack[$this->yyidx + - 1]->minor . '.' . $this->yystack[$this->yyidx + 0]->minor;
}
- #line 1006 "../smarty/lexer/smarty_internal_templateparser.y"
- function yy_r143()
+ #line 1031 "../smarty/lexer/smarty_internal_templateparser.y"
+ function yy_r145()
+ {
+ $var = trim(substr($this->yystack[$this->yyidx + 0]->minor, $this->lex->ldel_length, - $this->lex->rdel_length),
+ ' $');
+ $this->_retvalue = $this->compiler->compileVariable('\'' . $var . '\'');
+ }
+
+ #line 1037 "../smarty/lexer/smarty_internal_templateparser.y"
+ function yy_r146()
{
$this->_retvalue = '(' . $this->yystack[$this->yyidx + - 1]->minor . ')';
}
- #line 1013 "../smarty/lexer/smarty_internal_templateparser.y"
- function yy_r144()
+ #line 1044 "../smarty/lexer/smarty_internal_templateparser.y"
+ function yy_r147()
{
if ($this->yystack[$this->yyidx + - 1]->minor['var'] == '\'smarty\'') {
- $this->_retvalue = $this->compiler->compileTag('private_special_variable', array(), $this->yystack[$this->yyidx + - 1]->minor['smarty_internal_index']) . $this->yystack[$this->yyidx + 0]->minor;
+ $this->_retvalue = $this->compiler->compileTag('private_special_variable', array(),
+ $this->yystack[$this->yyidx +
+ - 1]->minor['smarty_internal_index']) .
+ $this->yystack[$this->yyidx + 0]->minor;
} else {
- $this->_retvalue = $this->compiler->compileVariable($this->yystack[$this->yyidx + - 1]->minor['var']) . $this->yystack[$this->yyidx + - 1]->minor['smarty_internal_index'] . $this->yystack[$this->yyidx + 0]->minor;
+ $this->_retvalue = $this->compiler->compileVariable($this->yystack[$this->yyidx + - 1]->minor['var']) .
+ $this->yystack[$this->yyidx + - 1]->minor['smarty_internal_index'] .
+ $this->yystack[$this->yyidx + 0]->minor;
}
}
- #line 1022 "../smarty/lexer/smarty_internal_templateparser.y"
- function yy_r145()
+ #line 1053 "../smarty/lexer/smarty_internal_templateparser.y"
+ function yy_r148()
{
$this->_retvalue = $this->yystack[$this->yyidx + 0]->minor;
}
- #line 1027 "../smarty/lexer/smarty_internal_templateparser.y"
- function yy_r146()
+ #line 1058 "../smarty/lexer/smarty_internal_templateparser.y"
+ function yy_r149()
{
$this->_retvalue = $this->yystack[$this->yyidx + - 1]->minor . $this->yystack[$this->yyidx + 0]->minor;
}
- #line 1032 "../smarty/lexer/smarty_internal_templateparser.y"
- function yy_r147()
+ #line 1063 "../smarty/lexer/smarty_internal_templateparser.y"
+ function yy_r150()
{
if ($this->security && substr($this->yystack[$this->yyidx + - 1]->minor, 0, 1) == '_') {
$this->compiler->trigger_template_error(self::Err1);
@@ -1983,53 +2396,66 @@ class Smarty_Internal_Templateparser
$this->_retvalue = '->' . $this->yystack[$this->yyidx + - 1]->minor . $this->yystack[$this->yyidx + 0]->minor;
}
- #line 1039 "../smarty/lexer/smarty_internal_templateparser.y"
- function yy_r148()
+ #line 1070 "../smarty/lexer/smarty_internal_templateparser.y"
+ function yy_r151()
{
if ($this->security) {
$this->compiler->trigger_template_error(self::Err2);
}
- $this->_retvalue = '->{' . $this->compiler->compileVariable($this->yystack[$this->yyidx + - 1]->minor) . $this->yystack[$this->yyidx + 0]->minor . '}';
+ $this->_retvalue = '->{' . $this->compiler->compileVariable($this->yystack[$this->yyidx + - 1]->minor) .
+ $this->yystack[$this->yyidx + 0]->minor . '}';
}
- #line 1046 "../smarty/lexer/smarty_internal_templateparser.y"
- function yy_r149()
+ #line 1077 "../smarty/lexer/smarty_internal_templateparser.y"
+ function yy_r152()
{
if ($this->security) {
$this->compiler->trigger_template_error(self::Err2);
}
- $this->_retvalue = '->{' . $this->yystack[$this->yyidx + - 2]->minor . $this->yystack[$this->yyidx + 0]->minor . '}';
+ $this->_retvalue =
+ '->{' . $this->yystack[$this->yyidx + - 2]->minor . $this->yystack[$this->yyidx + 0]->minor . '}';
}
- #line 1053 "../smarty/lexer/smarty_internal_templateparser.y"
- function yy_r150()
+ #line 1084 "../smarty/lexer/smarty_internal_templateparser.y"
+ function yy_r153()
{
if ($this->security) {
$this->compiler->trigger_template_error(self::Err2);
}
- $this->_retvalue = '->{\'' . $this->yystack[$this->yyidx + - 4]->minor . '\'.' . $this->yystack[$this->yyidx + - 2]->minor . $this->yystack[$this->yyidx + 0]->minor . '}';
+ $this->_retvalue =
+ '->{\'' . $this->yystack[$this->yyidx + - 4]->minor . '\'.' . $this->yystack[$this->yyidx + - 2]->minor .
+ $this->yystack[$this->yyidx + 0]->minor . '}';
}
- #line 1061 "../smarty/lexer/smarty_internal_templateparser.y"
- function yy_r151()
+ #line 1092 "../smarty/lexer/smarty_internal_templateparser.y"
+ function yy_r154()
{
$this->_retvalue = '->' . $this->yystack[$this->yyidx + 0]->minor;
}
- #line 1069 "../smarty/lexer/smarty_internal_templateparser.y"
- function yy_r152()
+ #line 1100 "../smarty/lexer/smarty_internal_templateparser.y"
+ function yy_r155()
{
- if (!$this->security || $this->security->isTrustedPhpFunction($this->yystack[$this->yyidx + - 3]->minor, $this->compiler)) {
- if (strcasecmp($this->yystack[$this->yyidx + - 3]->minor, 'isset') === 0 || strcasecmp($this->yystack[$this->yyidx + - 3]->minor, 'empty') === 0 || strcasecmp($this->yystack[$this->yyidx + - 3]->minor, 'array') === 0 || is_callable($this->yystack[$this->yyidx + - 3]->minor)) {
+ if (!$this->security ||
+ $this->security->isTrustedPhpFunction($this->yystack[$this->yyidx + - 3]->minor, $this->compiler)
+ ) {
+ if (strcasecmp($this->yystack[$this->yyidx + - 3]->minor, 'isset') === 0 ||
+ strcasecmp($this->yystack[$this->yyidx + - 3]->minor, 'empty') === 0 ||
+ strcasecmp($this->yystack[$this->yyidx + - 3]->minor, 'array') === 0 ||
+ is_callable($this->yystack[$this->yyidx + - 3]->minor)
+ ) {
$func_name = strtolower($this->yystack[$this->yyidx + - 3]->minor);
if ($func_name == 'isset') {
if (count($this->yystack[$this->yyidx + - 1]->minor) == 0) {
$this->compiler->trigger_template_error('Illegal number of paramer in "isset()"');
}
$par = implode(',', $this->yystack[$this->yyidx + - 1]->minor);
- if (strncasecmp($par, '$_smarty_tpl->getConfigVariable', strlen('$_smarty_tpl->getConfigVariable')) === 0) {
+ if (strncasecmp($par, '$_smarty_tpl->smarty->ext->_config->_getConfigVariable',
+ strlen('$_smarty_tpl->smarty->ext->_config->_getConfigVariable')) === 0
+ ) {
self::$prefix_number ++;
- $this->compiler->prefix_code[] = '<?php $_tmp' . self::$prefix_number . '=' . str_replace(')', ', false)', $par) . ';?>';
+ $this->compiler->prefix_code[] =
+ '<?php $_tmp' . self::$prefix_number . '=' . str_replace(')', ', false)', $par) . ';?>';
$isset_par = '$_tmp' . self::$prefix_number;
} else {
$isset_par = str_replace("')->value", "',null,true,false)->value", $par);
@@ -2040,110 +2466,125 @@ class Smarty_Internal_Templateparser
$this->compiler->trigger_template_error('Illegal number of paramer in "empty()"');
}
if ($func_name == 'empty') {
- $this->_retvalue = $func_name . '(' . str_replace("')->value", "',null,true,false)->value", $this->yystack[$this->yyidx + - 1]->minor[0]) . ')';
+ $this->_retvalue = $func_name . '(' . str_replace("')->value", "',null,true,false)->value",
+ $this->yystack[$this->yyidx +
+ - 1]->minor[0]) . ')';
} else {
$this->_retvalue = $func_name . '(' . $this->yystack[$this->yyidx + - 1]->minor[0] . ')';
}
} else {
- $this->_retvalue = $this->yystack[$this->yyidx + - 3]->minor . "(" . implode(',', $this->yystack[$this->yyidx + - 1]->minor) . ")";
+ $this->_retvalue = $this->yystack[$this->yyidx + - 3]->minor . "(" .
+ implode(',', $this->yystack[$this->yyidx + - 1]->minor) . ")";
}
} else {
- $this->compiler->trigger_template_error("unknown function \"" . $this->yystack[$this->yyidx + - 3]->minor . "\"");
+ $this->compiler->trigger_template_error("unknown function \"" .
+ $this->yystack[$this->yyidx + - 3]->minor . "\"");
}
}
}
- #line 1108 "../smarty/lexer/smarty_internal_templateparser.y"
- function yy_r153()
+ #line 1139 "../smarty/lexer/smarty_internal_templateparser.y"
+ function yy_r156()
{
if ($this->security && substr($this->yystack[$this->yyidx + - 3]->minor, 0, 1) == '_') {
$this->compiler->trigger_template_error(self::Err1);
}
- $this->_retvalue = $this->yystack[$this->yyidx + - 3]->minor . "(" . implode(',', $this->yystack[$this->yyidx + - 1]->minor) . ")";
+ $this->_retvalue =
+ $this->yystack[$this->yyidx + - 3]->minor . "(" . implode(',', $this->yystack[$this->yyidx + - 1]->minor) .
+ ")";
}
- #line 1115 "../smarty/lexer/smarty_internal_templateparser.y"
- function yy_r154()
+ #line 1146 "../smarty/lexer/smarty_internal_templateparser.y"
+ function yy_r157()
{
if ($this->security) {
$this->compiler->trigger_template_error(self::Err2);
}
self::$prefix_number ++;
- $this->compiler->prefix_code[] = '<?php $_tmp' . self::$prefix_number . '=' . $this->compiler->compileVariable('\'' . substr($this->yystack[$this->yyidx + - 3]->minor, 1) . '\'') . ';?>';
- $this->_retvalue = '$_tmp' . self::$prefix_number . '(' . implode(',', $this->yystack[$this->yyidx + - 1]->minor) . ')';
+ $this->compiler->prefix_code[] = '<?php $_tmp' . self::$prefix_number . '=' .
+ $this->compiler->compileVariable('\'' . substr($this->yystack[$this->yyidx + - 3]->minor, 1) . '\'') .
+ ';?>';
+ $this->_retvalue =
+ '$_tmp' . self::$prefix_number . '(' . implode(',', $this->yystack[$this->yyidx + - 1]->minor) . ')';
}
- #line 1126 "../smarty/lexer/smarty_internal_templateparser.y"
- function yy_r155()
+ #line 1157 "../smarty/lexer/smarty_internal_templateparser.y"
+ function yy_r158()
{
- $this->_retvalue = array_merge($this->yystack[$this->yyidx + - 2]->minor, array($this->yystack[$this->yyidx + 0]->minor));
+ $this->_retvalue =
+ array_merge($this->yystack[$this->yyidx + - 2]->minor, array($this->yystack[$this->yyidx + 0]->minor));
}
- #line 1143 "../smarty/lexer/smarty_internal_templateparser.y"
- function yy_r158()
+ #line 1174 "../smarty/lexer/smarty_internal_templateparser.y"
+ function yy_r161()
{
- $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)));
+ $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)));
}
- #line 1147 "../smarty/lexer/smarty_internal_templateparser.y"
- function yy_r159()
+ #line 1178 "../smarty/lexer/smarty_internal_templateparser.y"
+ function yy_r162()
{
- $this->_retvalue = array(array_merge($this->yystack[$this->yyidx + - 1]->minor, $this->yystack[$this->yyidx + 0]->minor));
+ $this->_retvalue =
+ array(array_merge($this->yystack[$this->yyidx + - 1]->minor, $this->yystack[$this->yyidx + 0]->minor));
}
- #line 1155 "../smarty/lexer/smarty_internal_templateparser.y"
- function yy_r161()
+ #line 1186 "../smarty/lexer/smarty_internal_templateparser.y"
+ function yy_r164()
{
$this->_retvalue = array($this->yystack[$this->yyidx + 0]->minor);
}
- #line 1163 "../smarty/lexer/smarty_internal_templateparser.y"
- function yy_r162()
+ #line 1194 "../smarty/lexer/smarty_internal_templateparser.y"
+ function yy_r165()
{
- $this->_retvalue = array_merge($this->yystack[$this->yyidx + - 1]->minor, $this->yystack[$this->yyidx + 0]->minor);
+ $this->_retvalue =
+ array_merge($this->yystack[$this->yyidx + - 1]->minor, $this->yystack[$this->yyidx + 0]->minor);
}
- #line 1182 "../smarty/lexer/smarty_internal_templateparser.y"
- function yy_r166()
+ #line 1213 "../smarty/lexer/smarty_internal_templateparser.y"
+ function yy_r169()
{
$this->_retvalue = array($this->yystack[$this->yyidx + 0]->minor, '', 'method');
}
- #line 1187 "../smarty/lexer/smarty_internal_templateparser.y"
- function yy_r167()
+ #line 1218 "../smarty/lexer/smarty_internal_templateparser.y"
+ function yy_r170()
{
- $this->_retvalue = array($this->yystack[$this->yyidx + - 1]->minor, $this->yystack[$this->yyidx + 0]->minor,
- 'method');
+ $this->_retvalue =
+ array($this->yystack[$this->yyidx + - 1]->minor, $this->yystack[$this->yyidx + 0]->minor, 'method');
}
- #line 1192 "../smarty/lexer/smarty_internal_templateparser.y"
- function yy_r168()
+ #line 1223 "../smarty/lexer/smarty_internal_templateparser.y"
+ function yy_r171()
{
$this->_retvalue = array($this->yystack[$this->yyidx + 0]->minor, '');
}
- #line 1197 "../smarty/lexer/smarty_internal_templateparser.y"
- function yy_r169()
+ #line 1228 "../smarty/lexer/smarty_internal_templateparser.y"
+ function yy_r172()
{
- $this->_retvalue = array($this->yystack[$this->yyidx + - 1]->minor, $this->yystack[$this->yyidx + 0]->minor,
- 'property');
+ $this->_retvalue =
+ array($this->yystack[$this->yyidx + - 1]->minor, $this->yystack[$this->yyidx + 0]->minor, 'property');
}
- #line 1202 "../smarty/lexer/smarty_internal_templateparser.y"
- function yy_r170()
+ #line 1233 "../smarty/lexer/smarty_internal_templateparser.y"
+ function yy_r173()
{
$this->_retvalue = array($this->yystack[$this->yyidx + - 2]->minor,
- $this->yystack[$this->yyidx + - 1]->minor . $this->yystack[$this->yyidx + 0]->minor, 'property');
+ $this->yystack[$this->yyidx + - 1]->minor . $this->yystack[$this->yyidx + 0]->minor,
+ 'property');
}
- #line 1208 "../smarty/lexer/smarty_internal_templateparser.y"
- function yy_r171()
+ #line 1239 "../smarty/lexer/smarty_internal_templateparser.y"
+ function yy_r174()
{
$this->_retvalue['op'] = ' ' . trim($this->yystack[$this->yyidx + 0]->minor) . ' ';
}
- #line 1212 "../smarty/lexer/smarty_internal_templateparser.y"
- function yy_r172()
+ #line 1243 "../smarty/lexer/smarty_internal_templateparser.y"
+ function yy_r175()
{
static $lops = array('eq' => array('op' => ' == ', 'pre' => null),
'ne' => array('op' => ' != ', 'pre' => null),
@@ -2168,8 +2609,8 @@ class Smarty_Internal_Templateparser
$this->_retvalue = $lops[$op];
}
- #line 1238 "../smarty/lexer/smarty_internal_templateparser.y"
- function yy_r173()
+ #line 1269 "../smarty/lexer/smarty_internal_templateparser.y"
+ function yy_r176()
{
static $scond = array('iseven' => '!(1 & ', 'isnoteven' => '(1 & ', 'isodd' => '(1 & ',
'isnotodd' => '!(1 & ',);
@@ -2177,77 +2618,81 @@ class Smarty_Internal_Templateparser
$this->_retvalue = $scond[$op];
}
- #line 1252 "../smarty/lexer/smarty_internal_templateparser.y"
- function yy_r174()
+ #line 1283 "../smarty/lexer/smarty_internal_templateparser.y"
+ function yy_r177()
{
$this->_retvalue = 'array(' . $this->yystack[$this->yyidx + - 1]->minor . ')';
}
- #line 1260 "../smarty/lexer/smarty_internal_templateparser.y"
- function yy_r176()
+ #line 1291 "../smarty/lexer/smarty_internal_templateparser.y"
+ function yy_r179()
{
$this->_retvalue = $this->yystack[$this->yyidx + - 2]->minor . ',' . $this->yystack[$this->yyidx + 0]->minor;
}
- #line 1268 "../smarty/lexer/smarty_internal_templateparser.y"
- function yy_r178()
+ #line 1299 "../smarty/lexer/smarty_internal_templateparser.y"
+ function yy_r181()
{
$this->_retvalue = $this->yystack[$this->yyidx + - 2]->minor . '=>' . $this->yystack[$this->yyidx + 0]->minor;
}
- #line 1272 "../smarty/lexer/smarty_internal_templateparser.y"
- function yy_r179()
+ #line 1303 "../smarty/lexer/smarty_internal_templateparser.y"
+ function yy_r182()
{
- $this->_retvalue = '\'' . $this->yystack[$this->yyidx + - 2]->minor . '\'=>' . $this->yystack[$this->yyidx + 0]->minor;
+ $this->_retvalue =
+ '\'' . $this->yystack[$this->yyidx + - 2]->minor . '\'=>' . $this->yystack[$this->yyidx + 0]->minor;
}
- #line 1288 "../smarty/lexer/smarty_internal_templateparser.y"
- function yy_r182()
+ #line 1319 "../smarty/lexer/smarty_internal_templateparser.y"
+ function yy_r185()
{
- $this->_retvalue = $this->yystack[$this->yyidx + - 1]->minor->to_smarty_php();
+ $this->_retvalue = $this->yystack[$this->yyidx + - 1]->minor->to_smarty_php($this);
}
- #line 1293 "../smarty/lexer/smarty_internal_templateparser.y"
- function yy_r183()
+ #line 1324 "../smarty/lexer/smarty_internal_templateparser.y"
+ function yy_r186()
{
- $this->yystack[$this->yyidx + - 1]->minor->append_subtree($this->yystack[$this->yyidx + 0]->minor);
+ $this->yystack[$this->yyidx + - 1]->minor->append_subtree($this, $this->yystack[$this->yyidx + 0]->minor);
$this->_retvalue = $this->yystack[$this->yyidx + - 1]->minor;
}
- #line 1298 "../smarty/lexer/smarty_internal_templateparser.y"
- function yy_r184()
+ #line 1329 "../smarty/lexer/smarty_internal_templateparser.y"
+ function yy_r187()
{
$this->_retvalue = new Smarty_Internal_ParseTree_Dq($this, $this->yystack[$this->yyidx + 0]->minor);
}
- #line 1302 "../smarty/lexer/smarty_internal_templateparser.y"
- function yy_r185()
+ #line 1333 "../smarty/lexer/smarty_internal_templateparser.y"
+ function yy_r188()
{
- $this->_retvalue = new Smarty_Internal_ParseTree_Code($this, '(string)' . $this->yystack[$this->yyidx + - 1]->minor);
+ $this->_retvalue = new Smarty_Internal_ParseTree_Code('(string)' . $this->yystack[$this->yyidx + - 1]->minor);
}
- #line 1310 "../smarty/lexer/smarty_internal_templateparser.y"
- function yy_r187()
+ #line 1341 "../smarty/lexer/smarty_internal_templateparser.y"
+ function yy_r190()
{
- $this->_retvalue = new Smarty_Internal_ParseTree_Code($this, '(string)$_smarty_tpl->tpl_vars[\'' . substr($this->yystack[$this->yyidx + 0]->minor, 1) . '\']->value');
+ $this->_retvalue = new Smarty_Internal_ParseTree_Code('(string)$_smarty_tpl->tpl_vars[\'' .
+ substr($this->yystack[$this->yyidx + 0]->minor, 1) .
+ '\']->value');
}
- #line 1318 "../smarty/lexer/smarty_internal_templateparser.y"
- function yy_r189()
+ #line 1349 "../smarty/lexer/smarty_internal_templateparser.y"
+ function yy_r192()
{
- $this->_retvalue = new Smarty_Internal_ParseTree_Code($this, '(string)(' . $this->yystack[$this->yyidx + - 1]->minor . ')');
+ $this->_retvalue =
+ new Smarty_Internal_ParseTree_Code('(string)(' . $this->yystack[$this->yyidx + - 1]->minor . ')');
}
- #line 1322 "../smarty/lexer/smarty_internal_templateparser.y"
- function yy_r190()
+ #line 1353 "../smarty/lexer/smarty_internal_templateparser.y"
+ function yy_r193()
{
$this->_retvalue = new Smarty_Internal_ParseTree_Tag($this, $this->yystack[$this->yyidx + 0]->minor);
}
- #line 1326 "../smarty/lexer/smarty_internal_templateparser.y"
- function yy_r191()
+ #line 1357 "../smarty/lexer/smarty_internal_templateparser.y"
+ function yy_r194()
{
- $this->_retvalue = new Smarty_Internal_ParseTree_DqContent($this, $this->yystack[$this->yyidx + 0]->minor);
+ $this->_retvalue = new Smarty_Internal_ParseTree_DqContent($this->yystack[$this->yyidx + 0]->minor);
}
private $_retvalue;
@@ -2255,7 +2700,8 @@ class Smarty_Internal_Templateparser
public function yy_reduce($yyruleno)
{
if ($this->yyTraceFILE && $yyruleno >= 0 && $yyruleno < count(self::$yyRuleName)) {
- fprintf($this->yyTraceFILE, "%sReduce (%d) [%s].\n", $this->yyTracePrompt, $yyruleno, self::$yyRuleName[$yyruleno]);
+ fprintf($this->yyTraceFILE, "%sReduce (%d) [%s].\n", $this->yyTracePrompt, $yyruleno,
+ self::$yyRuleName[$yyruleno]);
}
$this->_retvalue = $yy_lefthand_side = null;
@@ -2301,7 +2747,7 @@ class Smarty_Internal_Templateparser
public function yy_syntax_error($yymajor, $TOKEN)
{
- #line 183 "../smarty/lexer/smarty_internal_templateparser.y"
+ #line 207 "../smarty/lexer/smarty_internal_templateparser.y"
$this->internalError = true;
$this->yymajor = $yymajor;
@@ -2316,7 +2762,7 @@ class Smarty_Internal_Templateparser
while ($this->yyidx >= 0) {
$this->yy_pop_parser_stack();
}
- #line 176 "../smarty/lexer/smarty_internal_templateparser.y"
+ #line 200 "../smarty/lexer/smarty_internal_templateparser.y"
$this->successful = !$this->internalError;
$this->internalError = false;
@@ -2369,12 +2815,14 @@ class Smarty_Internal_Templateparser
$yymx = $this->yystack[$this->yyidx]->major;
if ($yymx == self::YYERRORSYMBOL || $yyerrorhit) {
if ($this->yyTraceFILE) {
- fprintf($this->yyTraceFILE, "%sDiscard input token %s\n", $this->yyTracePrompt, $this->yyTokenName[$yymajor]);
+ fprintf($this->yyTraceFILE, "%sDiscard input token %s\n", $this->yyTracePrompt,
+ $this->yyTokenName[$yymajor]);
}
$this->yy_destructor($yymajor, $yytokenvalue);
$yymajor = self::YYNOCODE;
} else {
- while ($this->yyidx >= 0 && $yymx != self::YYERRORSYMBOL && ($yyact = $this->yy_find_shift_action(self::YYERRORSYMBOL)) >= self::YYNSTATE) {
+ while ($this->yyidx >= 0 && $yymx != self::YYERRORSYMBOL &&
+ ($yyact = $this->yy_find_shift_action(self::YYERRORSYMBOL)) >= self::YYNSTATE) {
$this->yy_pop_parser_stack();
}
if ($this->yyidx < 0 || $yymajor == 0) {
diff --git a/library/Smarty/libs/sysplugins/smarty_internal_testinstall.php b/library/Smarty/libs/sysplugins/smarty_internal_testinstall.php
index 1ba31638f..5b6475ccc 100644
--- a/library/Smarty/libs/sysplugins/smarty_internal_testinstall.php
+++ b/library/Smarty/libs/sysplugins/smarty_internal_testinstall.php
@@ -7,6 +7,7 @@
* @subpackage Utilities
* @author Uwe Tews
*/
+
/**
* TestInstall class
*
@@ -19,8 +20,7 @@ class Smarty_Internal_TestInstall
* diagnose Smarty setup
* If $errors is secified, the diagnostic report will be appended to the array, rather than being output.
*
- * @param Smarty $smarty Smarty instance to test
- * @param array $errors array to push results into rather than outputting them
+ * @param array $errors array to push results into rather than outputting them
*
* @return bool status, true if everything is fine, false else
*/
@@ -47,7 +47,7 @@ class Smarty_Internal_TestInstall
if ($_stream_resolve_include_path) {
$template_dir = stream_resolve_include_path($_template_dir);
} else {
- $template_dir = Smarty_Internal_Get_Include_Path::getIncludePath($_template_dir);
+ $template_dir = $smarty->ext->_getIncludePath->getIncludePath($_template_dir, null, $smarty);
}
if ($template_dir !== false) {
@@ -58,7 +58,8 @@ class Smarty_Internal_TestInstall
continue;
} else {
$status = false;
- $message = "FAILED: $_template_dir does not exist (and couldn't be found in include_path either)";
+ $message =
+ "FAILED: $_template_dir does not exist (and couldn't be found in include_path either)";
if ($errors === null) {
echo $message . ".\n";
} else {
@@ -166,7 +167,7 @@ class Smarty_Internal_TestInstall
if ($_stream_resolve_include_path) {
$plugin_dir = stream_resolve_include_path($_plugin_dir);
} else {
- $plugin_dir = Smarty_Internal_Get_Include_Path::getIncludePath($_plugin_dir);
+ $plugin_dir = $smarty->ext->_getIncludePath->getIncludePath($_plugin_dir, null, $smarty);
}
if ($plugin_dir !== false) {
@@ -288,7 +289,6 @@ class Smarty_Internal_TestInstall
// test if all registered config_dir are accessible
foreach ($smarty->getConfigDir() as $config_dir) {
$_config_dir = $config_dir;
- $config_dir = realpath($config_dir);
// resolve include_path or fail existence
if (!$config_dir) {
if ($smarty->use_include_path && !preg_match('/^([\/\\\\]|[a-zA-Z]:[\/\\\\])/', $_config_dir)) {
@@ -296,7 +296,7 @@ class Smarty_Internal_TestInstall
if ($_stream_resolve_include_path) {
$config_dir = stream_resolve_include_path($_config_dir);
} else {
- $config_dir = Smarty_Internal_Get_Include_Path::getIncludePath($_config_dir);
+ $config_dir = $smarty->ext->_getIncludePath->getIncludePath($_config_dir, null, $smarty);
}
if ($config_dir !== false) {
@@ -358,106 +358,164 @@ class Smarty_Internal_TestInstall
// test if sysplugins are available
$source = SMARTY_SYSPLUGINS_DIR;
if (is_dir($source)) {
- $expected = array(
- "smarty_cacheresource.php" => true,
- "smarty_cacheresource_custom.php" => true,
- "smarty_cacheresource_keyvaluestore.php" => true,
- "smarty_data.php" => true,
- "smarty_internal_cacheresource_file.php" => true,
- "smarty_internal_compile_append.php" => true,
- "smarty_internal_compile_assign.php" => true,
- "smarty_internal_compile_block.php" => true,
- "smarty_internal_compile_break.php" => true,
- "smarty_internal_compile_call.php" => true,
- "smarty_internal_compile_capture.php" => true,
- "smarty_internal_compile_config_load.php" => true,
- "smarty_internal_compile_continue.php" => true,
- "smarty_internal_compile_debug.php" => true,
- "smarty_internal_compile_eval.php" => true,
- "smarty_internal_compile_extends.php" => true,
- "smarty_internal_compile_for.php" => true,
- "smarty_internal_compile_foreach.php" => true,
- "smarty_internal_compile_function.php" => true,
- "smarty_internal_compile_if.php" => true,
- "smarty_internal_compile_include.php" => true,
- "smarty_internal_compile_include_php.php" => true,
- "smarty_internal_compile_insert.php" => true,
- "smarty_internal_compile_ldelim.php" => true,
- "smarty_internal_compile_nocache.php" => true,
- "smarty_internal_compile_private_block_plugin.php" => true,
- "smarty_internal_compile_private_function_plugin.php" => true,
- "smarty_internal_compile_private_modifier.php" => true,
- "smarty_internal_compile_private_object_block_function.php" => true,
- "smarty_internal_compile_private_object_function.php" => true,
- "smarty_internal_compile_private_print_expression.php" => true,
- "smarty_internal_compile_private_registered_block.php" => true,
- "smarty_internal_compile_private_registered_function.php" => true,
- "smarty_internal_compile_private_special_variable.php" => true,
- "smarty_internal_compile_rdelim.php" => true,
- "smarty_internal_compile_section.php" => true,
- "smarty_internal_compile_setfilter.php" => true,
- "smarty_internal_compile_while.php" => true,
- "smarty_internal_compilebase.php" => true,
- "smarty_internal_config_file_compiler.php" => true,
- "smarty_internal_configfilelexer.php" => true,
- "smarty_internal_configfileparser.php" => true,
- "smarty_internal_data.php" => true,
- "smarty_internal_debug.php" => true,
- "smarty_internal_extension_codeframe.php" => true,
- "smarty_internal_extension_config.php" => true,
- "smarty_internal_extension_defaulttemplatehandler.php" => true,
- "smarty_internal_filter_handler.php" => true,
- "smarty_internal_function_call_handler.php" => true,
- "smarty_internal_get_include_path.php" => true,
- "smarty_internal_nocache_insert.php" => true,
- "smarty_internal_parsetree.php" => true,
- "smarty_internal_parsetree_code.php" => true,
- "smarty_internal_parsetree_dq.php" => true,
- "smarty_internal_parsetree_dqcontent.php" => true,
- "smarty_internal_parsetree_tag.php" => true,
- "smarty_internal_parsetree_template.php" => true,
- "smarty_internal_parsetree_text.php" => true,
- "smarty_internal_resource_eval.php" => true,
- "smarty_internal_resource_extends.php" => true,
- "smarty_internal_resource_file.php" => true,
- "smarty_internal_resource_php.php" => true,
- "smarty_internal_resource_registered.php" => true,
- "smarty_internal_resource_stream.php" => true,
- "smarty_internal_resource_string.php" => true,
- "smarty_internal_smartytemplatecompiler.php" => true,
- "smarty_internal_template.php" => true,
- "smarty_internal_templatebase.php" => true,
- "smarty_internal_templatecompilerbase.php" => true,
- "smarty_internal_templatelexer.php" => true,
- "smarty_internal_templateparser.php" => true,
- "smarty_internal_utility.php" => true,
- "smarty_internal_write_file.php" => true,
- "smarty_resource.php" => true,
- "smarty_resource_custom.php" => true,
- "smarty_resource_recompiled.php" => true,
- "smarty_resource_uncompiled.php" => true,
- "smarty_security.php" => true,
- "smarty_template_cached.php" => true,
- "smarty_template_compiled.php" => true,
- "smarty_template_config.php" => true,
- "smarty_template_source.php" => true,
- "smarty_undefined_variable.php" => true,
- "smarty_variable.php" => true,
- "smartycompilerexception.php" => true,
- "smartyexception.php" => true,
- );
+ $expectedSysplugins = array('smartycompilerexception.php' => true,
+ 'smartyexception.php' => true,
+ 'smarty_cacheresource.php' => true,
+ 'smarty_cacheresource_custom.php' => true,
+ 'smarty_cacheresource_keyvaluestore.php' => true,
+ 'smarty_data.php' => true,
+ 'smarty_internal_cacheresource_file.php' => true,
+ 'smarty_internal_compilebase.php' => true,
+ 'smarty_internal_compile_append.php' => true,
+ 'smarty_internal_compile_assign.php' => true,
+ 'smarty_internal_compile_block.php' => true,
+ 'smarty_internal_compile_break.php' => true,
+ 'smarty_internal_compile_call.php' => true,
+ 'smarty_internal_compile_capture.php' => true,
+ 'smarty_internal_compile_config_load.php' => true,
+ 'smarty_internal_compile_continue.php' => true,
+ 'smarty_internal_compile_debug.php' => true,
+ 'smarty_internal_compile_eval.php' => true,
+ 'smarty_internal_compile_extends.php' => true,
+ 'smarty_internal_compile_for.php' => true,
+ 'smarty_internal_compile_foreach.php' => true,
+ 'smarty_internal_compile_function.php' => true,
+ 'smarty_internal_compile_if.php' => true,
+ 'smarty_internal_compile_include.php' => true,
+ 'smarty_internal_compile_include_php.php' => true,
+ 'smarty_internal_compile_insert.php' => true,
+ 'smarty_internal_compile_ldelim.php' => true,
+ 'smarty_internal_compile_nocache.php' => true,
+ 'smarty_internal_compile_private_block_plugin.php' => true,
+ 'smarty_internal_compile_private_foreachsection.php' => true,
+ 'smarty_internal_compile_private_function_plugin.php' => true,
+ 'smarty_internal_compile_private_modifier.php' => true,
+ 'smarty_internal_compile_private_object_block_function.php' => true,
+ 'smarty_internal_compile_private_object_function.php' => true,
+ 'smarty_internal_compile_private_php.php' => true,
+ 'smarty_internal_compile_private_print_expression.php' => true,
+ 'smarty_internal_compile_private_registered_block.php' => true,
+ 'smarty_internal_compile_private_registered_function.php' => true,
+ 'smarty_internal_compile_private_special_variable.php' => true,
+ 'smarty_internal_compile_rdelim.php' => true,
+ 'smarty_internal_compile_section.php' => true,
+ 'smarty_internal_compile_setfilter.php' => true,
+ 'smarty_internal_compile_shared_inheritance.php' => true,
+ 'smarty_internal_compile_while.php' => true,
+ 'smarty_internal_configfilelexer.php' => true,
+ 'smarty_internal_configfileparser.php' => true,
+ 'smarty_internal_config_file_compiler.php' => true,
+ 'smarty_internal_data.php' => true,
+ 'smarty_internal_debug.php' => true,
+ 'smarty_internal_extension_clear.php' => true,
+ 'smarty_internal_extension_handler.php' => true,
+ 'smarty_internal_method_addautoloadfilters.php' => true,
+ 'smarty_internal_method_adddefaultmodifiers.php' => true,
+ 'smarty_internal_method_append.php' => true,
+ 'smarty_internal_method_appendbyref.php' => true,
+ 'smarty_internal_method_assignbyref.php' => true,
+ 'smarty_internal_method_assignglobal.php' => true,
+ 'smarty_internal_method_clearallassign.php' => true,
+ 'smarty_internal_method_clearallcache.php' => true,
+ 'smarty_internal_method_clearassign.php' => true,
+ 'smarty_internal_method_clearcache.php' => true,
+ 'smarty_internal_method_clearcompiledtemplate.php' => true,
+ 'smarty_internal_method_clearconfig.php' => true,
+ 'smarty_internal_method_compileallconfig.php' => true,
+ 'smarty_internal_method_compilealltemplates.php' => true,
+ 'smarty_internal_method_configload.php' => true,
+ 'smarty_internal_method_createdata.php' => true,
+ 'smarty_internal_method_getautoloadfilters.php' => true,
+ 'smarty_internal_method_getconfigvars.php' => true,
+ 'smarty_internal_method_getdebugtemplate.php' => true,
+ 'smarty_internal_method_getdefaultmodifiers.php' => true,
+ 'smarty_internal_method_getregisteredobject.php' => true,
+ 'smarty_internal_method_getstreamvariable.php' => true,
+ 'smarty_internal_method_gettags.php' => true,
+ 'smarty_internal_method_gettemplatevars.php' => true,
+ 'smarty_internal_method_loadfilter.php' => true,
+ 'smarty_internal_method_loadplugin.php' => true,
+ 'smarty_internal_method_mustcompile.php' => true,
+ 'smarty_internal_method_registercacheresource.php' => true,
+ 'smarty_internal_method_registerclass.php' => true,
+ 'smarty_internal_method_registerdefaultconfighandler.php' => true,
+ 'smarty_internal_method_registerdefaultpluginhandler.php' => true,
+ 'smarty_internal_method_registerdefaulttemplatehandler.php' => true,
+ 'smarty_internal_method_registerfilter.php' => true,
+ 'smarty_internal_method_registerobject.php' => true,
+ 'smarty_internal_method_registerplugin.php' => true,
+ 'smarty_internal_method_registerresource.php' => true,
+ 'smarty_internal_method_setautoloadfilters.php' => true,
+ 'smarty_internal_method_setdebugtemplate.php' => true,
+ 'smarty_internal_method_setdefaultmodifiers.php' => true,
+ 'smarty_internal_method_unloadfilter.php' => true,
+ 'smarty_internal_method_unregistercacheresource.php' => true,
+ 'smarty_internal_method_unregisterfilter.php' => true,
+ 'smarty_internal_method_unregisterobject.php' => true,
+ 'smarty_internal_method_unregisterplugin.php' => true,
+ 'smarty_internal_method_unregisterresource.php' => true,
+ 'smarty_internal_nocache_insert.php' => true,
+ 'smarty_internal_parsetree.php' => true,
+ 'smarty_internal_parsetree_code.php' => true,
+ 'smarty_internal_parsetree_dq.php' => true,
+ 'smarty_internal_parsetree_dqcontent.php' => true,
+ 'smarty_internal_parsetree_tag.php' => true,
+ 'smarty_internal_parsetree_template.php' => true,
+ 'smarty_internal_parsetree_text.php' => true,
+ 'smarty_internal_resource_eval.php' => true,
+ 'smarty_internal_resource_extends.php' => true,
+ 'smarty_internal_resource_file.php' => true,
+ 'smarty_internal_resource_php.php' => true,
+ 'smarty_internal_resource_registered.php' => true,
+ 'smarty_internal_resource_stream.php' => true,
+ 'smarty_internal_resource_string.php' => true,
+ 'smarty_internal_runtime_cachemodify.php' => true,
+ 'smarty_internal_runtime_codeframe.php' => true,
+ 'smarty_internal_runtime_filterhandler.php' => true,
+ 'smarty_internal_runtime_foreach.php' => true,
+ 'smarty_internal_runtime_getincludepath.php' => true,
+ 'smarty_internal_runtime_hhvm.php' => true,
+ 'smarty_internal_runtime_inheritance.php' => true,
+ 'smarty_internal_runtime_iscached.php' => true,
+ 'smarty_internal_runtime_subtemplate.php' => true,
+ 'smarty_internal_runtime_tplfunction.php' => true,
+ 'smarty_internal_runtime_updatecache.php' => true,
+ 'smarty_internal_runtime_updatescope.php' => true,
+ 'smarty_internal_runtime_validatecompiled.php' => true,
+ 'smarty_internal_runtime_var.php' => true,
+ 'smarty_internal_runtime_writefile.php' => true,
+ 'smarty_internal_smartytemplatecompiler.php' => true,
+ 'smarty_internal_template.php' => true,
+ 'smarty_internal_templatebase.php' => true,
+ 'smarty_internal_templatecompilerbase.php' => true,
+ 'smarty_internal_templatelexer.php' => true,
+ 'smarty_internal_templateparser.php' => true,
+ 'smarty_internal_testinstall.php' => true,
+ 'smarty_internal_undefined.php' => true,
+ 'smarty_resource.php' => true,
+ 'smarty_resource_custom.php' => true,
+ 'smarty_resource_recompiled.php' => true,
+ 'smarty_resource_uncompiled.php' => true,
+ 'smarty_security.php' => true,
+ 'smarty_template_cached.php' => true,
+ 'smarty_template_compiled.php' => true,
+ 'smarty_template_config.php' => true,
+ 'smarty_template_resource_base.php' => true,
+ 'smarty_template_source.php' => true,
+ 'smarty_undefined_variable.php' => true,
+ 'smarty_variable.php' => true,);
$iterator = new DirectoryIterator($source);
foreach ($iterator as $file) {
if (!$file->isDot()) {
$filename = $file->getFilename();
- if (isset($expected[$filename])) {
- unset($expected[$filename]);
+ if (isset($expectedSysplugins[$filename])) {
+ unset($expectedSysplugins[$filename]);
}
}
}
- if ($expected) {
+ if ($expectedSysplugins) {
$status = false;
- $message = "FAILED: files missing from libs/sysplugins: " . join(', ', array_keys($expected));
+ $message = "FAILED: files missing from libs/sysplugins: " . join(', ', array_keys($expectedSysplugins));
if ($errors === null) {
echo $message . ".\n";
} else {
@@ -482,67 +540,43 @@ class Smarty_Internal_TestInstall
// test if core plugins are available
$source = SMARTY_PLUGINS_DIR;
if (is_dir($source)) {
- $expected = array(
- "block.textformat.php" => true,
- "function.counter.php" => true,
- "function.cycle.php" => true,
- "function.fetch.php" => true,
- "function.html_checkboxes.php" => true,
- "function.html_image.php" => true,
- "function.html_options.php" => true,
- "function.html_radios.php" => true,
- "function.html_select_date.php" => true,
- "function.html_select_time.php" => true,
- "function.html_table.php" => true,
- "function.mailto.php" => true,
- "function.math.php" => true,
- "modifier.capitalize.php" => true,
- "modifier.date_format.php" => true,
- "modifier.debug_print_var.php" => true,
- "modifier.escape.php" => true,
- "modifier.regex_replace.php" => true,
- "modifier.replace.php" => true,
- "modifier.spacify.php" => true,
- "modifier.truncate.php" => true,
- "modifiercompiler.cat.php" => true,
- "modifiercompiler.count_characters.php" => true,
- "modifiercompiler.count_paragraphs.php" => true,
- "modifiercompiler.count_sentences.php" => true,
- "modifiercompiler.count_words.php" => true,
- "modifiercompiler.default.php" => true,
- "modifiercompiler.escape.php" => true,
- "modifiercompiler.from_charset.php" => true,
- "modifiercompiler.indent.php" => true,
- "modifiercompiler.lower.php" => true,
- "modifiercompiler.noprint.php" => true,
- "modifiercompiler.string_format.php" => true,
- "modifiercompiler.strip.php" => true,
- "modifiercompiler.strip_tags.php" => true,
- "modifiercompiler.to_charset.php" => true,
- "modifiercompiler.unescape.php" => true,
- "modifiercompiler.upper.php" => true,
- "modifiercompiler.wordwrap.php" => true,
- "outputfilter.trimwhitespace.php" => true,
- "shared.escape_special_chars.php" => true,
- "shared.literal_compiler_param.php" => true,
- "shared.make_timestamp.php" => true,
- "shared.mb_str_replace.php" => true,
- "shared.mb_unicode.php" => true,
- "shared.mb_wordwrap.php" => true,
- "variablefilter.htmlspecialchars.php" => true,
- );
+ $expectedPlugins =
+ array('block.textformat.php' => true, 'function.counter.php' => true,
+ 'function.cycle.php' => true, 'function.fetch.php' => true,
+ 'function.html_checkboxes.php' => true, 'function.html_image.php' => true,
+ 'function.html_options.php' => true, 'function.html_radios.php' => true,
+ 'function.html_select_date.php' => true, 'function.html_select_time.php' => true,
+ 'function.html_table.php' => true, 'function.mailto.php' => true,
+ 'function.math.php' => true, 'modifier.capitalize.php' => true,
+ 'modifier.date_format.php' => true, 'modifier.debug_print_var.php' => true,
+ 'modifier.escape.php' => true, 'modifier.regex_replace.php' => true,
+ 'modifier.replace.php' => true, 'modifier.spacify.php' => true,
+ 'modifier.truncate.php' => true, 'modifiercompiler.cat.php' => true,
+ 'modifiercompiler.count_characters.php' => true, 'modifiercompiler.count_paragraphs.php' => true,
+ 'modifiercompiler.count_sentences.php' => true, 'modifiercompiler.count_words.php' => true,
+ 'modifiercompiler.default.php' => true, 'modifiercompiler.escape.php' => true,
+ 'modifiercompiler.from_charset.php' => true, 'modifiercompiler.indent.php' => true,
+ 'modifiercompiler.lower.php' => true, 'modifiercompiler.noprint.php' => true,
+ 'modifiercompiler.string_format.php' => true, 'modifiercompiler.strip.php' => true,
+ 'modifiercompiler.strip_tags.php' => true, 'modifiercompiler.to_charset.php' => true,
+ 'modifiercompiler.unescape.php' => true, 'modifiercompiler.upper.php' => true,
+ 'modifiercompiler.wordwrap.php' => true, 'outputfilter.trimwhitespace.php' => true,
+ 'shared.escape_special_chars.php' => true, 'shared.literal_compiler_param.php' => true,
+ 'shared.make_timestamp.php' => true, 'shared.mb_str_replace.php' => true,
+ 'shared.mb_unicode.php' => true, 'shared.mb_wordwrap.php' => true,
+ 'variablefilter.htmlspecialchars.php' => true,);
$iterator = new DirectoryIterator($source);
foreach ($iterator as $file) {
if (!$file->isDot()) {
$filename = $file->getFilename();
- if (isset($expected[$filename])) {
- unset($expected[$filename]);
+ if (isset($expectedPlugins[$filename])) {
+ unset($expectedPlugins[$filename]);
}
}
}
- if ($expected) {
+ if ($expectedPlugins) {
$status = false;
- $message = "FAILED: files missing from libs/plugins: " . join(', ', array_keys($expected));
+ $message = "FAILED: files missing from libs/plugins: " . join(', ', array_keys($expectedPlugins));
if ($errors === null) {
echo $message . ".\n";
} else {
diff --git a/library/Smarty/libs/sysplugins/smarty_internal_utility.php b/library/Smarty/libs/sysplugins/smarty_internal_utility.php
deleted file mode 100644
index cd027dec7..000000000
--- a/library/Smarty/libs/sysplugins/smarty_internal_utility.php
+++ /dev/null
@@ -1,303 +0,0 @@
-<?php
-/**
- * Project: Smarty: the PHP compiling template engine
- * File: smarty_internal_utility.php
- * SVN: $Id: $
- * 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
- * version 2.1 of the License, or (at your option) any later version.
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
- * For questions, help, comments, discussion, etc., please join the
- * Smarty mailing list. Send a blank e-mail to
- * smarty-discussion-subscribe@googlegroups.com
- *
- * @link http://www.smarty.net/
- * @copyright 2008 New Digital Group, Inc.
- * @author Monte Ohrt <monte at ohrt dot com>
- * @author Uwe Tews
- * @package Smarty
- * @subpackage PluginsInternal
- * @version 3-SVN$Rev: 3286 $
- */
-
-/**
- * Utility class
- *
- * @package Smarty
- * @subpackage Security
- */
-class Smarty_Internal_Utility
-{
- /**
- * private constructor to prevent calls creation of new instances
- */
- final private function __construct()
- {
- // intentionally left blank
- }
-
- /**
- * Compile all template files
- *
- * @param string $extension template file name extension
- * @param bool $force_compile force all to recompile
- * @param int $time_limit set maximum execution time
- * @param int $max_errors set maximum allowed errors
- * @param Smarty $smarty Smarty instance
- *
- * @return integer number of template files compiled
- */
- public static function compileAllTemplates($extension, $force_compile, $time_limit, $max_errors, Smarty $smarty)
- {
- // switch off time limit
- if (function_exists('set_time_limit')) {
- @set_time_limit($time_limit);
- }
- $smarty->force_compile = $force_compile;
- $_count = 0;
- $_error_count = 0;
- // loop over array of template directories
- foreach ($smarty->getTemplateDir() as $_dir) {
- $_compileDirs = new RecursiveDirectoryIterator($_dir);
- $_compile = new RecursiveIteratorIterator($_compileDirs);
- foreach ($_compile as $_fileinfo) {
- $_file = $_fileinfo->getFilename();
- if (substr(basename($_fileinfo->getPathname()), 0, 1) == '.' || strpos($_file, '.svn') !== false) {
- continue;
- }
- if (!substr_compare($_file, $extension, - strlen($extension)) == 0) {
- continue;
- }
- if ($_fileinfo->getPath() == substr($_dir, 0, - 1)) {
- $_template_file = $_file;
- } else {
- $_template_file = substr($_fileinfo->getPath(), strlen($_dir)) . DS . $_file;
- }
- echo '<br>', $_dir, '---', $_template_file;
- flush();
- $_start_time = microtime(true);
- try {
- $_tpl = $smarty->createTemplate($_template_file, null, null, null, false);
- if ($_tpl->mustCompile()) {
- $_tpl->compileTemplateSource();
- $_count ++;
- echo ' compiled in ', microtime(true) - $_start_time, ' seconds';
- flush();
- } else {
- echo ' is up to date';
- flush();
- }
- }
- catch (Exception $e) {
- echo 'Error: ', $e->getMessage(), "<br><br>";
- $_error_count ++;
- }
- // free memory
- $smarty->template_objects = array();
- $_tpl->smarty->template_objects = array();
- $_tpl = null;
- if ($max_errors !== null && $_error_count == $max_errors) {
- echo '<br><br>too many errors';
- exit();
- }
- }
- }
-
- return $_count;
- }
-
- /**
- * Compile all config files
- *
- * @param string $extension config file name extension
- * @param bool $force_compile force all to recompile
- * @param int $time_limit set maximum execution time
- * @param int $max_errors set maximum allowed errors
- * @param Smarty $smarty Smarty instance
- *
- * @return integer number of config files compiled
- */
- public static function compileAllConfig($extension, $force_compile, $time_limit, $max_errors, Smarty $smarty)
- {
- // switch off time limit
- if (function_exists('set_time_limit')) {
- @set_time_limit($time_limit);
- }
- $smarty->force_compile = $force_compile;
- $_count = 0;
- $_error_count = 0;
- // loop over array of template directories
- foreach ($smarty->getConfigDir() as $_dir) {
- $_compileDirs = new RecursiveDirectoryIterator($_dir);
- $_compile = new RecursiveIteratorIterator($_compileDirs);
- foreach ($_compile as $_fileinfo) {
- $_file = $_fileinfo->getFilename();
- if (substr(basename($_fileinfo->getPathname()), 0, 1) == '.' || strpos($_file, '.svn') !== false) {
- continue;
- }
- if (!substr_compare($_file, $extension, - strlen($extension)) == 0) {
- continue;
- }
- if ($_fileinfo->getPath() == substr($_dir, 0, - 1)) {
- $_config_file = $_file;
- } else {
- $_config_file = substr($_fileinfo->getPath(), strlen($_dir)) . DS . $_file;
- }
- echo '<br>', $_dir, '---', $_config_file;
- flush();
- $_start_time = microtime(true);
- try {
- $_config = new Smarty_Internal_Config($_config_file, $smarty);
- if ($_config->mustCompile()) {
- $_config->compileConfigSource();
- $_count ++;
- echo ' compiled in ', microtime(true) - $_start_time, ' seconds';
- flush();
- } else {
- echo ' is up to date';
- flush();
- }
- }
- catch (Exception $e) {
- echo 'Error: ', $e->getMessage(), "<br><br>";
- $_error_count ++;
- }
- if ($max_errors !== null && $_error_count == $max_errors) {
- echo '<br><br>too many errors';
- exit();
- }
- }
- }
-
- return $_count;
- }
-
- /**
- * Delete compiled template file
- *
- * @param string $resource_name template name
- * @param string $compile_id compile id
- * @param integer $exp_time expiration time
- * @param Smarty $smarty Smarty instance
- *
- * @return integer number of template files deleted
- */
- public static function clearCompiledTemplate($resource_name, $compile_id, $exp_time, Smarty $smarty)
- {
- $_compile_dir = realpath($smarty->getCompileDir()) . '/';
- if ($_compile_dir == '/') { //We should never want to delete this!
- return 0;
- }
- $_compile_id = isset($compile_id) ? preg_replace('![^\w\|]+!', '_', $compile_id) : null;
- $_dir_sep = $smarty->use_sub_dirs ? '/' : '^';
- if (isset($resource_name)) {
- $_save_stat = $smarty->caching;
- $smarty->caching = false;
- $tpl = new $smarty->template_class($resource_name, $smarty);
- $smarty->caching = $_save_stat;
-
- // remove from template cache
- $tpl->source; // have the template registered before unset()
- if ($smarty->allow_ambiguous_resources) {
- $_templateId = $tpl->source->unique_resource . $tpl->cache_id . $tpl->compile_id;
- } else {
- $_templateId = $smarty->joined_template_dir . '#' . $resource_name . $tpl->cache_id . $tpl->compile_id;
- }
- if (isset($_templateId[150])) {
- $_templateId = sha1($_templateId);
- }
- unset($smarty->template_objects[$_templateId]);
-
- if ($tpl->source->exists) {
- $_resource_part_1 = basename(str_replace('^', '/', $tpl->compiled->filepath));
- $_resource_part_1_length = strlen($_resource_part_1);
- } else {
- return 0;
- }
-
- $_resource_part_2 = str_replace('.php', '.cache.php', $_resource_part_1);
- $_resource_part_2_length = strlen($_resource_part_2);
- }
- $_dir = $_compile_dir;
- if ($smarty->use_sub_dirs && isset($_compile_id)) {
- $_dir .= $_compile_id . $_dir_sep;
- }
- if (isset($_compile_id)) {
- $_compile_id_part = str_replace('\\', '/', $_compile_dir . $_compile_id . $_dir_sep);
- $_compile_id_part_length = strlen($_compile_id_part);
- }
- $_count = 0;
- try {
- $_compileDirs = new RecursiveDirectoryIterator($_dir);
- // NOTE: UnexpectedValueException thrown for PHP >= 5.3
- }
- catch (Exception $e) {
- return 0;
- }
- $_compile = new RecursiveIteratorIterator($_compileDirs, RecursiveIteratorIterator::CHILD_FIRST);
- foreach ($_compile as $_file) {
- if (substr(basename($_file->getPathname()), 0, 1) == '.' || strpos($_file, '.svn') !== false) {
- continue;
- }
-
- $_filepath = str_replace('\\', '/', (string) $_file);
-
- if ($_file->isDir()) {
- if (!$_compile->isDot()) {
- // delete folder if empty
- @rmdir($_file->getPathname());
- }
- } else {
- $unlink = false;
- if ((!isset($_compile_id) || (isset($_filepath[$_compile_id_part_length]) && $a = !strncmp($_filepath, $_compile_id_part, $_compile_id_part_length)))
- && (!isset($resource_name)
- || (isset($_filepath[$_resource_part_1_length])
- && substr_compare($_filepath, $_resource_part_1, - $_resource_part_1_length, $_resource_part_1_length) == 0)
- || (isset($_filepath[$_resource_part_2_length])
- && substr_compare($_filepath, $_resource_part_2, - $_resource_part_2_length, $_resource_part_2_length) == 0))
- ) {
- if (isset($exp_time)) {
- if (time() - @filemtime($_filepath) >= $exp_time) {
- $unlink = true;
- }
- } else {
- $unlink = true;
- }
- }
-
- if ($unlink && @unlink($_filepath)) {
- $_count ++;
- }
- }
- }
- // clear compiled cache
- Smarty_Resource::$sources = array();
- Smarty_Resource::$compileds = array();
-
- return $_count;
- }
-
- /**
- * Return array of tag/attributes of all tags used by an template
- *
- * @param Smarty_Internal_Template $template
- *
- * @throws Exception
- * @throws SmartyException
- * @return array of tag/attributes
- */
- public static function getTags(Smarty_Internal_Template $template)
- {
- $template->smarty->get_used_tags = true;
- $template->compileTemplateSource();
-
- return $template->used_tags;
- }
-}
diff --git a/library/Smarty/libs/sysplugins/smarty_internal_write_file.php b/library/Smarty/libs/sysplugins/smarty_internal_write_file.php
deleted file mode 100644
index 9ecc7c0c8..000000000
--- a/library/Smarty/libs/sysplugins/smarty_internal_write_file.php
+++ /dev/null
@@ -1,88 +0,0 @@
-<?php
-/**
- * Smarty write file plugin
- *
- * @package Smarty
- * @subpackage PluginsInternal
- * @author Monte Ohrt
- */
-
-/**
- * Smarty Internal Write File Class
- *
- * @package Smarty
- * @subpackage PluginsInternal
- */
-class Smarty_Internal_Write_File
-{
- /**
- * Writes file in a safe way to disk
- *
- * @param string $_filepath complete filepath
- * @param string $_contents file content
- * @param Smarty $smarty smarty instance
- *
- * @throws SmartyException
- * @return boolean true
- */
- public function writeFile($_filepath, $_contents, Smarty $smarty)
- {
- $_error_reporting = error_reporting();
- error_reporting($_error_reporting & ~E_NOTICE & ~E_WARNING);
- if ($smarty->_file_perms !== null) {
- $old_umask = umask(0);
- }
-
- $_dirpath = dirname($_filepath);
- // if subdirs, create dir structure
- if ($_dirpath !== '.' && !file_exists($_dirpath)) {
- mkdir($_dirpath, $smarty->_dir_perms === null ? 0777 : $smarty->_dir_perms, true);
- }
-
- // write to tmp file, then move to overt file lock race condition
- $_tmp_file = $_dirpath . DS . str_replace(array('.', ','), '_', uniqid('wrt', true));
- if (!file_put_contents($_tmp_file, $_contents)) {
- error_reporting($_error_reporting);
- throw new SmartyException("unable to write file {$_tmp_file}");
- }
-
- /*
- * Windows' rename() fails if the destination exists,
- * Linux' rename() properly handles the overwrite.
- * Simply unlink()ing a file might cause other processes
- * currently reading that file to fail, but linux' rename()
- * seems to be smart enough to handle that for us.
- */
- if (Smarty::$_IS_WINDOWS) {
- // remove original file
- if (is_file($_filepath)) {
- @unlink($_filepath);
- }
- // rename tmp file
- $success = @rename($_tmp_file, $_filepath);
- } else {
- // rename tmp file
- $success = @rename($_tmp_file, $_filepath);
- if (!$success) {
- // remove original file
- if (is_file($_filepath)) {
- @unlink($_filepath);
- }
- // rename tmp file
- $success = @rename($_tmp_file, $_filepath);
- }
- }
- if (!$success) {
- error_reporting($_error_reporting);
- throw new SmartyException("unable to write file {$_filepath}");
- }
- if ($smarty->_file_perms !== null) {
- // set file permissions
- chmod($_filepath, $smarty->_file_perms);
- umask($old_umask);
- }
- error_reporting($_error_reporting);
-
- return true;
- }
-}
diff --git a/library/Smarty/libs/sysplugins/smarty_resource.php b/library/Smarty/libs/sysplugins/smarty_resource.php
index 5d5e368d9..72611255e 100644
--- a/library/Smarty/libs/sysplugins/smarty_resource.php
+++ b/library/Smarty/libs/sysplugins/smarty_resource.php
@@ -29,37 +29,25 @@ abstract class Smarty_Resource
* @var boolean
*/
public $recompiled = false;
+
/**
- * resource handler object
- *
- * @var Smarty_Resource
- */
- public $handler = null;
- /**
- * cache for Smarty_Template_Source instances
- *
- * @var array
- */
- public static $sources = array();
- /**
- * cache for Smarty_Template_Compiled instances
+ * resource types provided by the core
*
* @var array
*/
- public static $compileds = array();
+ public static $sysplugins = array('file' => 'smarty_internal_resource_file.php',
+ 'string' => 'smarty_internal_resource_string.php',
+ 'extends' => 'smarty_internal_resource_extends.php',
+ 'stream' => 'smarty_internal_resource_stream.php',
+ 'eval' => 'smarty_internal_resource_eval.php',
+ 'php' => 'smarty_internal_resource_php.php');
+
/**
- * resource types provided by the core
+ * Flag if resource does implement populateCompiledFilepath() method
*
- * @var array
+ * @var bool
*/
- protected static $sysplugins = array(
- 'file' => 'smarty_internal_resource_file.php',
- 'string' => 'smarty_internal_resource_string.php',
- 'extends' => 'smarty_internal_resource_extends.php',
- 'stream' => 'smarty_internal_resource_stream.php',
- 'eval' => 'smarty_internal_resource_eval.php',
- 'php' => 'smarty_internal_resource_php.php'
- );
+ public $hasCompiledHandler = false;
/**
* Name of the Class to compile this resource's contents with
@@ -84,7 +72,6 @@ abstract class Smarty_Resource
/**
* Load template's source into current template object
- * {@internal The loaded source is assigned to $_template->source->content directly.}}
*
* @param Smarty_Template_Source $source source object
*
@@ -123,9 +110,15 @@ abstract class Smarty_Resource
public function buildUniqueResourceName(Smarty $smarty, $resource_name, $isConfig = false)
{
if ($isConfig) {
- return get_class($this) . '#' . $smarty->joined_config_dir . '#' . $resource_name;
+ if (!isset($smarty->_joined_config_dir)) {
+ $smarty->getTemplateDir(null, true);
+ }
+ return get_class($this) . '#' . $smarty->_joined_config_dir . '#' . $resource_name;
} else {
- return get_class($this) . '#' . $smarty->joined_template_dir . '#' . $resource_name;
+ if (!isset($smarty->_joined_template_dir)) {
+ $smarty->getTemplateDir();
+ }
+ return get_class($this) . '#' . $smarty->_joined_template_dir . '#' . $resource_name;
}
}
@@ -153,42 +146,32 @@ abstract class Smarty_Resource
public static function load(Smarty $smarty, $type)
{
// try smarty's cache
- if (isset($smarty->_resource_handlers[$type])) {
- return $smarty->_resource_handlers[$type];
+ if (isset($smarty->_cache['resource_handlers'][$type])) {
+ return $smarty->_cache['resource_handlers'][$type];
}
// try registered resource
if (isset($smarty->registered_resources[$type])) {
- if ($smarty->registered_resources[$type] instanceof Smarty_Resource) {
- $smarty->_resource_handlers[$type] = $smarty->registered_resources[$type];
- } else {
- $smarty->_resource_handlers[$type] = new Smarty_Internal_Resource_Registered();
- }
-
- return $smarty->_resource_handlers[$type];
+ return $smarty->_cache['resource_handlers'][$type] =
+ $smarty->registered_resources[$type] instanceof Smarty_Resource ? $smarty->registered_resources[$type] :
+ new Smarty_Internal_Resource_Registered();
}
// try sysplugins dir
if (isset(self::$sysplugins[$type])) {
$_resource_class = 'Smarty_Internal_Resource_' . ucfirst($type);
- if (!class_exists($_resource_class, false)) {
- require SMARTY_SYSPLUGINS_DIR . self::$sysplugins[$type];
- }
- return $smarty->_resource_handlers[$type] = new $_resource_class();
+ return $smarty->_cache['resource_handlers'][$type] = new $_resource_class();
}
// try plugins dir
$_resource_class = 'Smarty_Resource_' . ucfirst($type);
if ($smarty->loadPlugin($_resource_class)) {
if (class_exists($_resource_class, false)) {
- return $smarty->_resource_handlers[$type] = new $_resource_class();
+ return $smarty->_cache['resource_handlers'][$type] = new $_resource_class();
} else {
- $smarty->registerResource($type, array(
- "smarty_resource_{$type}_source",
- "smarty_resource_{$type}_timestamp",
- "smarty_resource_{$type}_secure",
- "smarty_resource_{$type}_trusted"
- ));
+ $smarty->registerResource($type,
+ array("smarty_resource_{$type}_source", "smarty_resource_{$type}_timestamp",
+ "smarty_resource_{$type}_secure", "smarty_resource_{$type}_trusted"));
// give it another try, now that the resource is registered properly
return self::load($smarty, $type);
}
@@ -201,7 +184,7 @@ abstract class Smarty_Resource
if (is_object($smarty->security_policy)) {
$smarty->security_policy->isTrustedStream($type);
}
- return $smarty->_resource_handlers[$type] = new Smarty_Internal_Resource_Stream();;
+ return $smarty->_cache['resource_handlers'][$type] = new Smarty_Internal_Resource_Stream();
}
// TODO: try default_(template|config)_handler
@@ -221,7 +204,7 @@ abstract class Smarty_Resource
*/
public static function parseResourceName($resource_name, $default_resource)
{
- if (preg_match('/^([A-Za-z0-9_\-]{2,})[:]/', $resource_name, $match)) {
+ if (preg_match('/^([A-Za-z0-9_\-]{2,})[:]/', $resource_name, $match)) {
$type = $match[1];
$name = substr($resource_name, strlen($match[0]));
} else {
@@ -229,38 +212,30 @@ abstract class Smarty_Resource
// or single character before the colon is not a resource type, but part of the filepath
$type = $default_resource;
$name = $resource_name;
-
}
return array($name, $type);
}
/**
- * modify resource_name according to resource handlers specifications
- *
- * @param Smarty $smarty Smarty instance
- * @param string $resource_name resource_name to make unique
- *
- * @return string unique resource name
- */
-
- /**
* modify template_resource according to resource handlers specifications
*
- * @param Smarty_Internal_template $template Smarty instance
- * @param string $template_resource template_resource to extract resource handler and name of
+ * @param \Smarty_Internal_Template|\Smarty $obj Smarty instance
+ * @param string $template_resource template_resource to extract resource handler and name of
*
* @return string unique resource name
*/
- public static function getUniqueTemplateName($template, $template_resource)
+ public static function getUniqueTemplateName($obj, $template_resource)
{
- $smarty = isset($template->smarty) ? $template->smarty : $template;
+ $smarty = $obj->_objType == 2 ? $obj->smarty : $obj;
list($name, $type) = self::parseResourceName($template_resource, $smarty->default_resource_type);
// TODO: optimize for Smarty's internal resource types
$resource = Smarty_Resource::load($smarty, $type);
// go relative to a given template?
$_file_is_dotted = $name[0] == '.' && ($name[1] == '.' || $name[1] == '/');
- if ($template instanceof Smarty_Internal_Template && $_file_is_dotted && ($template->source->type == 'file' || $template->parent->source->type == 'extends')) {
- $name = dirname($template->source->filepath) . DS . $name;
+ if ($obj->_objType == 2 && $_file_is_dotted &&
+ ($obj->source->type == 'file' || $obj->parent->source->type == 'extends')
+ ) {
+ $name = dirname($obj->source->filepath) . DS . $name;
}
return $resource->buildUniqueResourceName($smarty, $name);
}
@@ -276,7 +251,8 @@ abstract class Smarty_Resource
*
* @return Smarty_Template_Source Source Object
*/
- public static function source(Smarty_Internal_Template $_template = null, Smarty $smarty = null, $template_resource = null)
+ public static function source(Smarty_Internal_Template $_template = null, Smarty $smarty = null,
+ $template_resource = null)
{
return Smarty_Template_Source::load($_template, $smarty, $template_resource);
}
diff --git a/library/Smarty/libs/sysplugins/smarty_resource_recompiled.php b/library/Smarty/libs/sysplugins/smarty_resource_recompiled.php
index c823387ba..cfd73401b 100644
--- a/library/Smarty/libs/sysplugins/smarty_resource_recompiled.php
+++ b/library/Smarty/libs/sysplugins/smarty_resource_recompiled.php
@@ -24,6 +24,13 @@ abstract class Smarty_Resource_Recompiled extends Smarty_Resource
public $recompiled = true;
/**
+ * Resource does implement populateCompiledFilepath() method
+ *
+ * @var bool
+ */
+ public $hasCompiledHandler = true;
+
+ /**
* populate Compiled Object with compiled filepath
*
* @param Smarty_Template_Compiled $compiled compiled object
diff --git a/library/Smarty/libs/sysplugins/smarty_resource_uncompiled.php b/library/Smarty/libs/sysplugins/smarty_resource_uncompiled.php
index a52d86e87..88d2bba81 100644
--- a/library/Smarty/libs/sysplugins/smarty_resource_uncompiled.php
+++ b/library/Smarty/libs/sysplugins/smarty_resource_uncompiled.php
@@ -24,6 +24,13 @@ abstract class Smarty_Resource_Uncompiled extends Smarty_Resource
public $uncompiled = true;
/**
+ * Resource does implement populateCompiledFilepath() method
+ *
+ * @var bool
+ */
+ public $hasCompiledHandler = true;
+
+ /**
* Render and output the template (without using the compiler)
*
* @param Smarty_Template_Source $source source object
diff --git a/library/Smarty/libs/sysplugins/smarty_security.php b/library/Smarty/libs/sysplugins/smarty_security.php
index af1ca5531..9d48bcb21 100644
--- a/library/Smarty/libs/sysplugins/smarty_security.php
+++ b/library/Smarty/libs/sysplugins/smarty_security.php
@@ -34,6 +34,7 @@ class Smarty_Security
* @var integer
*/
public $php_handling = Smarty::PHP_PASSTHRU;
+
/**
* This is the list of template directories that are considered secure.
* $template_dir is in this list implicitly.
@@ -41,6 +42,7 @@ class Smarty_Security
* @var array
*/
public $secure_dir = array();
+
/**
* This is an array of directories where trusted php scripts reside.
* {@link $security} is disabled during their inclusion/execution.
@@ -48,18 +50,21 @@ class Smarty_Security
* @var array
*/
public $trusted_dir = array();
+
/**
* List of regular expressions (PCRE) that include trusted URIs
*
* @var array
*/
public $trusted_uri = array();
+
/**
* List of trusted constants names
*
* @var array
*/
public $trusted_constants = array();
+
/**
* This is an array of trusted static classes.
* If empty access to all static classes is allowed.
@@ -96,6 +101,7 @@ class Smarty_Security
* @var array
*/
public $trusted_static_properties = array();
+
/**
* This is an array of trusted PHP functions.
* If empty all functions are allowed.
@@ -103,12 +109,8 @@ class Smarty_Security
*
* @var array
*/
- public $php_functions = array(
- 'isset', 'empty',
- 'count', 'sizeof',
- 'in_array', 'is_array',
- 'time',
- );
+ public $php_functions = array('isset', 'empty', 'count', 'sizeof', 'in_array', 'is_array', 'time',);
+
/**
* This is an array of trusted PHP modifiers.
* If empty all modifiers are allowed.
@@ -116,11 +118,8 @@ class Smarty_Security
*
* @var array
*/
- public $php_modifiers = array(
- 'escape',
- 'count',
- 'nl2br',
- );
+ public $php_modifiers = array('escape', 'count', 'nl2br',);
+
/**
* This is an array of allowed tags.
* If empty no restriction by allowed_tags.
@@ -128,6 +127,7 @@ class Smarty_Security
* @var array
*/
public $allowed_tags = array();
+
/**
* This is an array of disabled tags.
* If empty no restriction by disabled_tags.
@@ -135,6 +135,7 @@ class Smarty_Security
* @var array
*/
public $disabled_tags = array();
+
/**
* This is an array of allowed modifier plugins.
* If empty no restriction by allowed_modifiers.
@@ -142,6 +143,7 @@ class Smarty_Security
* @var array
*/
public $allowed_modifiers = array();
+
/**
* This is an array of disabled modifier plugins.
* If empty no restriction by disabled_modifiers.
@@ -149,12 +151,14 @@ class Smarty_Security
* @var array
*/
public $disabled_modifiers = array();
+
/**
* This is an array of disabled special $smarty variables.
*
* @var array
*/
public $disabled_special_smarty_vars = array();
+
/**
* This is an array of trusted streams.
* If empty all streams are allowed.
@@ -163,60 +167,70 @@ class Smarty_Security
* @var array
*/
public $streams = array('file');
+
/**
* + flag if constants can be accessed from template
*
* @var boolean
*/
public $allow_constants = true;
+
/**
* + flag if super globals can be accessed from template
*
* @var boolean
*/
public $allow_super_globals = true;
+
/**
* max template nesting level
*
* @var int
*/
public $max_template_nesting = 0;
+
/**
* current template nesting level
*
* @var int
*/
private $_current_template_nesting = 0;
+
/**
* Cache for $resource_dir lookup
*
* @var array
*/
- protected $_resource_dir = null;
+ protected $_resource_dir = array();
+
/**
* Cache for $template_dir lookup
*
* @var array
*/
- protected $_template_dir = null;
+ protected $_template_dir = array();
+
/**
* Cache for $config_dir lookup
*
* @var array
*/
- protected $_config_dir = null;
+ protected $_config_dir = array();
+
/**
* Cache for $secure_dir lookup
*
* @var array
*/
- protected $_secure_dir = null;
+ protected $_secure_dir = array();
+
/**
* Cache for $php_resource_dir lookup
*
* @var array
*/
protected $_php_resource_dir = null;
+
/**
* Cache for $trusted_dir lookup
*
@@ -225,6 +239,20 @@ class Smarty_Security
protected $_trusted_dir = null;
/**
+ * Cache for include path status
+ *
+ * @var bool
+ */
+ protected $_include_path_status = false;
+
+ /**
+ * Cache for $_include_array lookup
+ *
+ * @var array
+ */
+ protected $_include_dir = array();
+
+ /**
* @param Smarty $smarty
*/
public function __construct($smarty)
@@ -243,7 +271,9 @@ class Smarty_Security
*/
public function isTrustedPhpFunction($function_name, $compiler)
{
- if (isset($this->php_functions) && (empty($this->php_functions) || in_array($function_name, $this->php_functions))) {
+ if (isset($this->php_functions) &&
+ (empty($this->php_functions) || in_array($function_name, $this->php_functions))
+ ) {
return true;
}
@@ -263,7 +293,9 @@ class Smarty_Security
*/
public function isTrustedStaticClass($class_name, $compiler)
{
- if (isset($this->static_classes) && (empty($this->static_classes) || in_array($class_name, $this->static_classes))) {
+ if (isset($this->static_classes) &&
+ (empty($this->static_classes) || in_array($class_name, $this->static_classes))
+ ) {
return true;
}
@@ -301,9 +333,8 @@ class Smarty_Security
// fall back
return $this->isTrustedStaticClass($class_name, $compiler);
}
- if (isset($allowed[$class_name])
- && (empty($allowed[$class_name])
- || in_array($name, $allowed[$class_name]))
+ if (isset($allowed[$class_name]) &&
+ (empty($allowed[$class_name]) || in_array($name, $allowed[$class_name]))
) {
return true;
}
@@ -323,7 +354,9 @@ class Smarty_Security
*/
public function isTrustedPhpModifier($modifier_name, $compiler)
{
- if (isset($this->php_modifiers) && (empty($this->php_modifiers) || in_array($modifier_name, $this->php_modifiers))) {
+ if (isset($this->php_modifiers) &&
+ (empty($this->php_modifiers) || in_array($modifier_name, $this->php_modifiers))
+ ) {
return true;
}
@@ -344,9 +377,11 @@ class Smarty_Security
public function isTrustedTag($tag_name, $compiler)
{
// check for internal always required tags
- if (in_array($tag_name, array('assign', 'call', 'private_filter', 'private_block_plugin', 'private_function_plugin', 'private_object_block_function',
- 'private_object_function', 'private_registered_function', 'private_registered_block', 'private_special_variable', 'private_print_expression', 'private_modifier'))
- ) {
+ if (in_array($tag_name, array('assign', 'call', 'private_filter', 'private_block_plugin',
+ 'private_function_plugin', 'private_object_block_function',
+ 'private_object_function', 'private_registered_function',
+ 'private_registered_block', 'private_special_variable',
+ 'private_print_expression', 'private_modifier'))) {
return true;
}
// check security settings
@@ -354,12 +389,12 @@ class Smarty_Security
if (empty($this->disabled_tags) || !in_array($tag_name, $this->disabled_tags)) {
return true;
} else {
- $compiler->trigger_template_error("tag '{$tag_name}' disabled by security setting", $compiler->lex->taglineno);
+ $compiler->trigger_template_error("tag '{$tag_name}' disabled by security setting", null, true);
}
} elseif (in_array($tag_name, $this->allowed_tags) && !in_array($tag_name, $this->disabled_tags)) {
return true;
} else {
- $compiler->trigger_template_error("tag '{$tag_name}' not allowed by security setting", $compiler->lex->taglineno);
+ $compiler->trigger_template_error("tag '{$tag_name}' not allowed by security setting", null, true);
}
return false; // should not, but who knows what happens to the compiler in the future?
@@ -379,7 +414,7 @@ class Smarty_Security
if (!in_array($var_name, $this->disabled_special_smarty_vars)) {
return true;
} else {
- $compiler->trigger_template_error("special variable '\$smarty.{$var_name}' not allowed by security setting", $compiler->lex->taglineno);
+ $compiler->trigger_template_error("special variable '\$smarty.{$var_name}' not allowed by security setting", null, true);
}
return false; // should not, but who knows what happens to the compiler in the future?
@@ -405,12 +440,14 @@ class Smarty_Security
if (empty($this->disabled_modifiers) || !in_array($modifier_name, $this->disabled_modifiers)) {
return true;
} else {
- $compiler->trigger_template_error("modifier '{$modifier_name}' disabled by security setting", $compiler->lex->taglineno);
+ $compiler->trigger_template_error("modifier '{$modifier_name}' disabled by security setting", null, true);
}
- } elseif (in_array($modifier_name, $this->allowed_modifiers) && !in_array($modifier_name, $this->disabled_modifiers)) {
+ } elseif (in_array($modifier_name, $this->allowed_modifiers) &&
+ !in_array($modifier_name, $this->disabled_modifiers)
+ ) {
return true;
} else {
- $compiler->trigger_template_error("modifier '{$modifier_name}' not allowed by security setting", $compiler->lex->taglineno);
+ $compiler->trigger_template_error("modifier '{$modifier_name}' not allowed by security setting", null, true);
}
return false; // should not, but who knows what happens to the compiler in the future?
@@ -419,7 +456,7 @@ class Smarty_Security
/**
* Check if constants are enabled or trusted
*
- * @param string $const contant name
+ * @param string $const constant name
* @param object $compiler compiler object
*
* @return bool
@@ -463,81 +500,70 @@ class Smarty_Security
/**
* Check if directory of file resource is trusted.
*
- * @param string $filepath
+ * @param string $filepath
+ * @param null|bool $isConfig
*
- * @return boolean true if directory is trusted
- * @throws SmartyException if directory is not trusted
+ * @return bool true if directory is trusted
+ * @throws \SmartyException if directory is not trusted
*/
- public function isTrustedResourceDir($filepath)
+ public function isTrustedResourceDir($filepath, $isConfig = null)
{
- $_template = false;
- $_config = false;
- $_secure = false;
-
- $_template_dir = $this->smarty->getTemplateDir();
- $_config_dir = $this->smarty->getConfigDir();
-
- // check if index is outdated
- if ((!$this->_template_dir || $this->_template_dir !== $_template_dir)
- || (!$this->_config_dir || $this->_config_dir !== $_config_dir)
- || (!empty($this->secure_dir) && (!$this->_secure_dir || $this->_secure_dir !== $this->secure_dir))
- ) {
- $this->_resource_dir = array();
- $_template = true;
- $_config = true;
- $_secure = !empty($this->secure_dir);
- }
-
- // rebuild template dir index
- if ($_template) {
- $this->_template_dir = $_template_dir;
- foreach ($_template_dir as $directory) {
- $directory = realpath($directory);
- $this->_resource_dir[$directory] = true;
+ if ($this->_include_path_status !== $this->smarty->use_include_path) {
+ foreach ($this->_include_dir as $directory) {
+ unset($this->_resource_dir[$directory]);
}
+ if ($this->smarty->use_include_path) {
+ $this->_include_dir = array();
+ $_dirs = $this->smarty->ext->_getIncludePath->getIncludePathDirs($this->smarty);
+ foreach ($_dirs as $directory) {
+ $this->_include_dir[] = $directory;
+ $this->_resource_dir[$directory] = true;
+ }
+ }
+ $this->_include_path_status = $this->smarty->use_include_path;
}
-
- // rebuild config dir index
- if ($_config) {
- $this->_config_dir = $_config_dir;
- foreach ($_config_dir as $directory) {
- $directory = realpath($directory);
- $this->_resource_dir[$directory] = true;
+ if ($isConfig !== true &&
+ (!isset($this->smarty->_cache['template_dir_new']) || $this->smarty->_cache['template_dir_new'])
+ ) {
+ $_dir = $this->smarty->getTemplateDir();
+ if ($this->_template_dir !== $_dir) {
+ foreach ($this->_template_dir as $directory) {
+ unset($this->_resource_dir[$directory]);
+ }
+ foreach ($_dir as $directory) {
+ $this->_resource_dir[$directory] = true;
+ }
+ $this->_template_dir = $_dir;
}
+ $this->smarty->_cache['template_dir_new'] = false;
}
-
- // rebuild secure dir index
- if ($_secure) {
- $this->_secure_dir = $this->secure_dir;
- foreach ((array) $this->secure_dir as $directory) {
- $directory = realpath($directory);
- $this->_resource_dir[$directory] = true;
+ if ($isConfig !== false &&
+ (!isset($this->smarty->_cache['config_dir_new']) || $this->smarty->_cache['config_dir_new'])
+ ) {
+ $_dir = $this->smarty->getConfigDir();
+ if ($this->_config_dir !== $_dir) {
+ foreach ($this->_config_dir as $directory) {
+ unset($this->_resource_dir[$directory]);
+ }
+ foreach ($_dir as $directory) {
+ $this->_resource_dir[$directory] = true;
+ }
+ $this->_config_dir = $_dir;
}
+ $this->smarty->_cache['config_dir_new'] = false;
}
-
- $_filepath = realpath($filepath);
- $directory = dirname($_filepath);
- $_directory = array();
- while (true) {
- // remember the directory to add it to _resource_dir in case we're successful
- $_directory[$directory] = true;
- // test if the directory is trusted
- if (isset($this->_resource_dir[$directory])) {
- // merge sub directories of current $directory into _resource_dir to speed up subsequent lookup
- $this->_resource_dir = array_merge($this->_resource_dir, $_directory);
-
- return true;
+ if ($this->_secure_dir !== (array) $this->secure_dir) {
+ foreach ($this->_secure_dir as $directory) {
+ unset($this->_resource_dir[$directory]);
}
- // abort if we've reached root
- if (($pos = strrpos($directory, DS)) === false || !isset($directory[1])) {
- break;
+ foreach ((array) $this->secure_dir as $directory) {
+ $directory = $this->smarty->_realpath($directory . DS, true);
+ $this->_resource_dir[$directory] = true;
}
- // bubble up one level
- $directory = substr($directory, 0, $pos);
+ $this->_secure_dir = (array) $this->secure_dir;
}
-
- // give up
- throw new SmartyException("directory '{$_filepath}' not allowed by security setting");
+ $this->_resource_dir = $this->_checkDir($filepath, $this->_resource_dir);
+ return true;
}
/**
@@ -587,33 +613,13 @@ class Smarty_Security
$this->_trusted_dir = $this->trusted_dir;
foreach ((array) $this->trusted_dir as $directory) {
- $directory = realpath($directory);
+ $directory = $this->smarty->_realpath($directory . DS, true);
$this->_php_resource_dir[$directory] = true;
}
}
- $_filepath = realpath($filepath);
- $directory = dirname($_filepath);
- $_directory = array();
- while (true) {
- // remember the directory to add it to _resource_dir in case we're successful
- $_directory[] = $directory;
- // test if the directory is trusted
- if (isset($this->_php_resource_dir[$directory])) {
- // merge sub directories of current $directory into _resource_dir to speed up subsequent lookup
- $this->_php_resource_dir = array_merge($this->_php_resource_dir, $_directory);
-
- return true;
- }
- // abort if we've reached root
- if (($pos = strrpos($directory, DS)) === false || !isset($directory[2])) {
- break;
- }
- // bubble up one level
- $directory = substr($directory, 0, $pos);
- }
-
- throw new SmartyException("directory '{$_filepath}' not allowed by security setting");
+ $this->_php_resource_dir = $this->_checkDir($this->smarty->_realpath($filepath, true), $this->_php_resource_dir);
+ return true;
}
/**
@@ -633,12 +639,77 @@ class Smarty_Security
/**
* Exit template processing
*
- * @param $template
+ * @internal param $template
*/
- public function exitTemplate($template)
+ public function exitTemplate()
{
if ($this->max_template_nesting > 0) {
$this->_current_template_nesting --;
}
}
+
+ /**
+ * Check if file is inside a valid directory
+ *
+ * @param string $filepath
+ * @param array $dirs valid directories
+ *
+ * @return array
+ * @throws \SmartyException
+ */
+ private function _checkDir($filepath, $dirs)
+ {
+ $directory = dirname($filepath) . DS;
+ $_directory = array();
+ while (true) {
+ // remember the directory to add it to _resource_dir in case we're successful
+ $_directory[$directory] = true;
+ // test if the directory is trusted
+ if (isset($dirs[$directory])) {
+ // merge sub directories of current $directory into _resource_dir to speed up subsequent lookup
+ $dirs = array_merge($dirs, $_directory);
+
+ return $dirs;
+ }
+ // abort if we've reached root
+ if (!preg_match('#[\\\/][^\\\/]+[\\\/]$#', $directory)) {
+ break;
+ }
+ // bubble up one level
+ $directory = preg_replace('#[\\\/][^\\\/]+[\\\/]$#', DS, $directory);
+ }
+
+ // give up
+ throw new SmartyException("directory '{$filepath}' not allowed by security setting");
+ }
+
+ /**
+ * Loads security class and enables security
+ *
+ * @param \Smarty $smarty
+ * @param string|Smarty_Security $security_class if a string is used, it must be class-name
+ *
+ * @return \Smarty current Smarty instance for chaining
+ * @throws \SmartyException when an invalid class name is provided
+ */
+ public static function enableSecurity(Smarty $smarty, $security_class)
+ {
+ if ($security_class instanceof Smarty_Security) {
+ $smarty->security_policy = $security_class;
+ return;
+ } elseif (is_object($security_class)) {
+ throw new SmartyException("Class '" . get_class($security_class) . "' must extend Smarty_Security.");
+ }
+ if ($security_class == null) {
+ $security_class = $smarty->security_class;
+ }
+ if (!class_exists($security_class)) {
+ throw new SmartyException("Security class '$security_class' is not defined");
+ } elseif ($security_class !== 'Smarty_Security' && !is_subclass_of($security_class, 'Smarty_Security')) {
+ throw new SmartyException("Class '$security_class' must extend Smarty_Security.");
+ } else {
+ $smarty->security_policy = new $security_class($smarty);
+ }
+ return;
+ }
}
diff --git a/library/Smarty/libs/sysplugins/smarty_template_cached.php b/library/Smarty/libs/sysplugins/smarty_template_cached.php
index 5b9043958..cecf42986 100644
--- a/library/Smarty/libs/sysplugins/smarty_template_cached.php
+++ b/library/Smarty/libs/sysplugins/smarty_template_cached.php
@@ -14,37 +14,9 @@
* @subpackage TemplateResources
* @author Rodney Rehm
*/
-class Smarty_Template_Cached
+class Smarty_Template_Cached extends Smarty_Template_Resource_Base
{
/**
- * Source Filepath
- *
- * @var string
- */
- public $filepath = false;
-
- /**
- * Source Content
- *
- * @var string
- */
- public $content = null;
-
- /**
- * Source Timestamp
- *
- * @var integer
- */
- public $timestamp = false;
-
- /**
- * Source Existence
- *
- * @var boolean
- */
- public $exists = false;
-
- /**
* Cache Is Valid
*
* @var boolean
@@ -52,13 +24,6 @@ class Smarty_Template_Cached
public $valid = null;
/**
- * Cache was processed
- *
- * @var boolean
- */
- public $processed = false;
-
- /**
* CacheResource Handler
*
* @var Smarty_CacheResource
@@ -66,18 +31,18 @@ class Smarty_Template_Cached
public $handler = null;
/**
- * Template Compile Id (Smarty_Internal_Template::$compile_id)
+ * Template Cache Id (Smarty_Internal_Template::$cache_id)
*
* @var string
*/
- public $compile_id = null;
+ public $cache_id = null;
/**
- * Template Cache Id (Smarty_Internal_Template::$cache_id)
+ * saved cache lifetime in seconds
*
- * @var string
+ * @var integer
*/
- public $cache_id = null;
+ public $cache_lifetime = 0;
/**
* Id for cache locking
@@ -101,6 +66,13 @@ class Smarty_Template_Cached
public $source = null;
/**
+ * Nocache hash codes of processed compiled templates
+ *
+ * @var array
+ */
+ public $hashes = array();
+
+ /**
* create Cached Object container
*
* @param Smarty_Internal_Template $_template template object
@@ -109,9 +81,6 @@ class Smarty_Template_Cached
{
$this->compile_id = $_template->compile_id;
$this->cache_id = $_template->cache_id;
- if (!isset($_template->source)) {
- $_template->loadSource();
- }
$this->source = $_template->source;
if (!class_exists('Smarty_CacheResource', false)) {
require SMARTY_SYSPLUGINS_DIR . 'smarty_cacheresource.php';
@@ -126,13 +95,42 @@ class Smarty_Template_Cached
*/
static function load(Smarty_Internal_Template $_template)
{
- $_template->cached = $cached = new Smarty_Template_Cached($_template);
- $cached->handler->populate($cached, $_template);
+ $_template->cached = new Smarty_Template_Cached($_template);
+ $_template->cached->handler->populate($_template->cached, $_template);
// caching enabled ?
- if (!($_template->caching == Smarty::CACHING_LIFETIME_CURRENT || $_template->caching == Smarty::CACHING_LIFETIME_SAVED) || $_template->source->recompiled) {
- $cached->valid = false;
+ if (!($_template->caching == Smarty::CACHING_LIFETIME_CURRENT ||
+ $_template->caching == Smarty::CACHING_LIFETIME_SAVED) || $_template->source->handler->recompiled
+ ) {
+ $_template->cached->valid = false;
+ }
+ return $_template->cached;
+ }
+
+ /**
+ * Render cache template
+ *
+ * @param \Smarty_Internal_Template $_template
+ * @param bool $no_output_filter
+ *
+ * @throws \Exception
+ */
+ public function render(Smarty_Internal_Template $_template, $no_output_filter = true)
+ {
+ if ($this->isCached($_template)) {
+ if ($_template->smarty->debugging) {
+ $_template->smarty->_debug->start_cache($_template);
+ }
+ if (!$this->processed) {
+ $this->process($_template);
+ }
+ $this->getRenderedTemplateCode($_template);
+ if ($_template->smarty->debugging) {
+ $_template->smarty->_debug->end_cache($_template);
+ }
+ return;
+ } else {
+ $_template->smarty->ext->_updateCache->updateCache($this, $_template, $no_output_filter);
}
- return $cached;
}
/**
@@ -149,16 +147,20 @@ class Smarty_Template_Cached
}
while (true) {
while (true) {
- if ($this->exists === false || $_template->smarty->force_compile || $_template->smarty->force_cache) {
+ if ($this->exists === false || $_template->smarty->force_compile || $_template->smarty->force_cache) {
$this->valid = false;
} else {
$this->valid = true;
}
- if ($this->valid && $_template->caching == Smarty::CACHING_LIFETIME_CURRENT && $_template->cache_lifetime >= 0 && time() > ($this->timestamp + $_template->cache_lifetime)) {
+ if ($this->valid && $_template->caching == Smarty::CACHING_LIFETIME_CURRENT &&
+ $_template->cache_lifetime >= 0 && time() > ($this->timestamp + $_template->cache_lifetime)
+ ) {
// lifetime expired
$this->valid = false;
}
- if ($this->valid && $_template->source->timestamp > $this->timestamp) {
+ if ($this->valid && $_template->smarty->compile_check == 1 &&
+ $_template->source->getTimeStamp() > $this->timestamp
+ ) {
$this->valid = false;
}
if ($this->valid || !$_template->smarty->cache_locking) {
@@ -174,7 +176,7 @@ class Smarty_Template_Cached
if (!$_template->smarty->cache_locking || $this->handler->locked($_template->smarty, $this) === null) {
// load cache file for the following checks
if ($_template->smarty->debugging) {
- Smarty_Internal_Debug::start_cache($_template);
+ $_template->smarty->_debug->start_cache($_template);
}
if ($this->handler->process($_template, $this) === false) {
$this->valid = false;
@@ -182,7 +184,7 @@ class Smarty_Template_Cached
$this->processed = true;
}
if ($_template->smarty->debugging) {
- Smarty_Internal_Debug::end_cache($_template);
+ $_template->smarty->_debug->end_cache($_template);
}
} else {
$this->is_locked = true;
@@ -191,7 +193,10 @@ class Smarty_Template_Cached
} else {
return $this->valid;
}
- if ($this->valid && $_template->caching === Smarty::CACHING_LIFETIME_SAVED && $_template->properties['cache_lifetime'] >= 0 && (time() > ($_template->cached->timestamp + $_template->properties['cache_lifetime']))) {
+ if ($this->valid && $_template->caching === Smarty::CACHING_LIFETIME_SAVED &&
+ $_template->cached->cache_lifetime >= 0 &&
+ (time() > ($_template->cached->timestamp + $_template->cached->cache_lifetime))
+ ) {
$this->valid = false;
}
if ($_template->smarty->cache_locking) {
@@ -210,10 +215,11 @@ class Smarty_Template_Cached
* Process cached template
*
* @param Smarty_Internal_Template $_template template object
+ * @param bool $update flag if called because cache update
*/
- public function process(Smarty_Internal_Template $_template)
+ public function process(Smarty_Internal_Template $_template, $update = false)
{
- if ($this->handler->process($_template, $this) === false) {
+ if ($this->handler->process($_template, $this, $update) === false) {
$this->valid = false;
}
if ($this->valid) {
@@ -224,55 +230,6 @@ class Smarty_Template_Cached
}
/**
- * Render cached template
- *
- * @param Smarty_Internal_Template $_template
- *
- * @return string
- * @throws Exception
- */
- public function render(Smarty_Internal_Template $_template)
- {
- if (!$this->processed) {
- $this->process($_template);
- }
- return $_template->getRenderedTemplateCode();
- }
-
- /**
- * Write this cache object to handler
- *
- * @param Smarty_Internal_Template $_template template object
- * @param string $content content to cache
- *
- * @return boolean success
- */
- public function write(Smarty_Internal_Template $_template, $content)
- {
- if (!$_template->source->recompiled) {
- if ($this->handler->writeCachedContent($_template, $content)) {
- $this->content = null;
- $this->timestamp = time();
- $this->exists = true;
- $this->valid = true;
- $this->processed = false;
- if ($_template->smarty->cache_locking) {
- $this->handler->releaseLock($_template->smarty, $this);
- }
-
- return true;
- }
- $this->content = null;
- $this->timestamp = false;
- $this->exists = false;
- $this->valid = false;
- $this->processed = false;
- }
-
- return false;
- }
-
- /**
* Read cache content from handler
*
* @param Smarty_Internal_Template $_template template object
@@ -281,123 +238,9 @@ class Smarty_Template_Cached
*/
public function read(Smarty_Internal_Template $_template)
{
- if (!$_template->source->recompiled) {
+ if (!$_template->source->handler->recompiled) {
return $this->handler->readCachedContent($_template);
}
return false;
}
-
- /**
- * Sanitize content and write it to cache resource
- *
- * @param Smarty_Internal_Template $_template
- * @param string $content
- * @param bool $no_output_filter
- *
- * @throws SmartyException
- */
- public function updateCache(Smarty_Internal_Template $_template, $content, $no_output_filter)
- {
- $_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", $content);
- // get non-cached items
- preg_match_all("!/\*%%SmartyNocache:{$_template->properties['nocache_hash']}%%\*\/(.+?)/\*/%%SmartyNocache:{$_template->properties['nocache_hash']}%%\*/!s", $content, $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|<\?|\?>|<script\s+language\s*=\s*[\"\']?\s*php\s*[\"\']?\s*>)/', "<?php echo '\$1'; ?>\n", $curr_split);
- if (isset($cache_parts[0][$curr_idx])) {
- $_template->properties['has_nocache_code'] = true;
- $output .= $cache_parts[1][$curr_idx];
- }
- }
- if (!$no_output_filter && !$_template->has_nocache_code && (isset($_template->smarty->autoload_filters['output']) || isset($_template->smarty->registered_filters['output']))) {
- $output = Smarty_Internal_Filter_Handler::runFilter('output', $output, $_template);
- }
- // write cache file content
- $this->writeCachedContent($_template, $output);
- }
-
- /**
- * Writes the content to cache resource
- *
- * @param Smarty_Internal_Template $_template
- * @param string $content
- *
- * @return bool
- */
- public function writeCachedContent(Smarty_Internal_Template $_template, $content)
- {
- if ($_template->source->recompiled || !($_template->caching == Smarty::CACHING_LIFETIME_CURRENT || $_template->caching == Smarty::CACHING_LIFETIME_SAVED)) {
- // don't write cache file
- return false;
- }
- $_template->properties['cache_lifetime'] = $_template->cache_lifetime;
- $_template->properties['unifunc'] = 'content_' . str_replace(array('.', ','), '_', uniqid('', true));
- $content = Smarty_Internal_Extension_CodeFrame::create($_template, $content, true);
- if (!empty($_template->properties['tpl_function'])) {
- foreach ($_template->properties['tpl_function'] as $funcParam) {
- if (is_file($funcParam['compiled_filepath'])) {
- // read compiled file
- $code = file_get_contents($funcParam['compiled_filepath']);
- // grab template function
- if (preg_match("/\/\* {$funcParam['call_name']} \*\/([\S\s]*?)\/\*\/ {$funcParam['call_name']} \*\//", $code, $match)) {
- unset($code);
- $content .= "<?php " . $match[0] . "?>\n";
- }
- }
- }
- }
- return $this->write($_template, $content);
- }
-
- /**
- * check client side cache
- *
- * @param Smarty_Internal_Template $_template
- * @param string $content
- */
- public function cacheModifiedCheck(Smarty_Internal_Template $_template, $content)
- {
- $_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 && $this->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', $this->timestamp) . ' GMT';
- }
- break;
-
- default:
- header('Last-Modified: ' . gmdate('D, d M Y H:i:s', $this->timestamp) . ' GMT');
- break;
- }
- echo $content;
- }
- }
}
diff --git a/library/Smarty/libs/sysplugins/smarty_template_compiled.php b/library/Smarty/libs/sysplugins/smarty_template_compiled.php
index 3ff8fa897..e7710f85e 100644
--- a/library/Smarty/libs/sysplugins/smarty_template_compiled.php
+++ b/library/Smarty/libs/sysplugins/smarty_template_compiled.php
@@ -9,48 +9,15 @@
* @author Rodney Rehm
* @property string $content compiled content
*/
-class Smarty_Template_Compiled
+class Smarty_Template_Compiled extends Smarty_Template_Resource_Base
{
- /**
- * Compiled Filepath
- *
- * @var string
- */
- public $filepath = null;
-
- /**
- * Compiled Timestamp
- *
- * @var integer
- */
- public $timestamp = null;
-
- /**
- * Compiled Existence
- *
- * @var boolean
- */
- public $exists = false;
/**
- * Compiled Content Loaded
- *
- * @var boolean
- */
- public $processed = false;
- /**
- * Code of recompiled template resource
+ * nocache hash
*
* @var string|null
*/
- public $code = null;
-
- /**
- * create Compiled Object container
- */
- public function __construct()
- {
- }
+ public $nocache_hash = null;
/**
* get a Compiled Object of this source
@@ -61,11 +28,10 @@ class Smarty_Template_Compiled
*/
static function load($_template)
{
- if (!isset($_template->source)) {
- $_template->loadSource();
- }
// check runtime cache
- if (!$_template->source->recompiled && $_template->smarty->resource_caching) {
+ if (!$_template->source->handler->recompiled &&
+ ($_template->smarty->resource_cache_mode & Smarty::RESOURCE_CACHE_ON)
+ ) {
$_cache_key = $_template->source->unique_resource . '#';
if ($_template->caching) {
$_cache_key .= 'caching#';
@@ -76,13 +42,15 @@ class Smarty_Template_Compiled
}
}
$compiled = new Smarty_Template_Compiled();
- if (method_exists($_template->source->handler, 'populateCompiledFilepath')) {
+ if ($_template->source->handler->hasCompiledHandler) {
$_template->source->handler->populateCompiledFilepath($compiled, $_template);
} else {
$compiled->populateCompiledFilepath($_template);
}
// runtime cache
- if (!$_template->source->recompiled && $_template->smarty->resource_caching) {
+ if (!$_template->source->handler->recompiled &&
+ ($_template->smarty->resource_cache_mode & Smarty::RESOURCE_CACHE_ON)
+ ) {
$_template->source->compileds[$_cache_key] = $compiled;
}
return $compiled;
@@ -95,20 +63,20 @@ class Smarty_Template_Compiled
**/
public function populateCompiledFilepath(Smarty_Internal_Template $_template)
{
- $_compile_id = isset($_template->compile_id) ? preg_replace('![^\w\|]+!', '_', $_template->compile_id) : null;
+ $_compile_id = isset($_template->compile_id) ? preg_replace('![^\w]+!', '_', $_template->compile_id) : null;
if ($_template->source->isConfig) {
- $_flag = '_' . ((int) $_template->smarty->config_read_hidden + (int) $_template->smarty->config_booleanize * 2
- + (int) $_template->smarty->config_overwrite * 4);
+ $_flag = '_' .
+ ((int) $_template->smarty->config_read_hidden + (int) $_template->smarty->config_booleanize * 2 +
+ (int) $_template->smarty->config_overwrite * 4);
} else {
- $_flag = '_' . ((int) $_template->smarty->merge_compiled_includes + (int) $_template->smarty->escape_html * 2);
+ $_flag =
+ '_' . ((int) $_template->smarty->merge_compiled_includes + (int) $_template->smarty->escape_html * 2);
}
$_filepath = $_template->source->uid . $_flag;
// if use_sub_dirs, break file into directories
if ($_template->smarty->use_sub_dirs) {
- $_filepath = substr($_filepath, 0, 2) . DS
- . substr($_filepath, 2, 2) . DS
- . substr($_filepath, 4, 2) . DS
- . $_filepath;
+ $_filepath = substr($_filepath, 0, 2) . DS . substr($_filepath, 2, 2) . DS . substr($_filepath, 4, 2) . DS .
+ $_filepath;
}
$_compile_dir_sep = $_template->smarty->use_sub_dirs ? DS : '^';
if (isset($_compile_id)) {
@@ -124,7 +92,7 @@ class Smarty_Template_Compiled
// set basename if not specified
$_basename = $_template->source->handler->getBasename($_template->source);
if ($_basename === null) {
- $_basename = basename(preg_replace('![^\w\/]+!', '_', $_template->source->name));
+ $_basename = basename(preg_replace('![^\w]+!', '_', $_template->source->name));
}
// separate (optional) basename by dot
if ($_basename) {
@@ -132,9 +100,9 @@ class Smarty_Template_Compiled
}
$this->filepath = $_compile_dir . $_filepath . '.' . $_template->source->type . $_basename . $_cache . '.php';
- $this->timestamp = $this->exists = is_file($this->filepath);
- if ($this->exists) {
- $this->timestamp = @filemtime($this->filepath);
+ $this->exists = is_file($this->filepath);
+ if (!$this->exists) {
+ $this->timestamp = false;
}
}
@@ -148,15 +116,18 @@ class Smarty_Template_Compiled
public function process(Smarty_Internal_Template $_template)
{
$_smarty_tpl = $_template;
- if ($_template->source->recompiled || !$_template->compiled->exists || $_template->smarty->force_compile) {
+ if ($_template->source->handler->recompiled || !$_template->compiled->exists ||
+ $_template->smarty->force_compile || ($_template->smarty->compile_check &&
+ $_template->source->getTimeStamp() > $_template->compiled->getTimeStamp())
+ ) {
$this->compileTemplateSource($_template);
$compileCheck = $_template->smarty->compile_check;
$_template->smarty->compile_check = false;
- if ($_template->source->recompiled) {
+ if ($_template->source->handler->recompiled) {
$level = ob_get_level();
ob_start();
try {
- eval("?>" . $this->code);
+ eval("?>" . $this->content);
}
catch (Exception $e) {
while (ob_get_level() > $level) {
@@ -165,26 +136,47 @@ class Smarty_Template_Compiled
throw $e;
}
ob_get_clean();
- $this->code = null;
+ $this->content = null;
} else {
- include($_template->compiled->filepath);
+ $this->loadCompiledTemplate($_template);
}
$_template->smarty->compile_check = $compileCheck;
} else {
- include($_template->compiled->filepath);
+ $_template->mustCompile = true;
+ @include($_template->compiled->filepath);
if ($_template->mustCompile) {
$this->compileTemplateSource($_template);
$compileCheck = $_template->smarty->compile_check;
$_template->smarty->compile_check = false;
- include($_template->compiled->filepath);
+ $this->loadCompiledTemplate($_template);
$_template->smarty->compile_check = $compileCheck;
}
}
- $this->unifunc = $_template->properties['unifunc'];
+ $_template->smarty->ext->_subTemplate->registerSubTemplates($_template);
+
$this->processed = true;
}
/**
+ * Load fresh compiled template by including the PHP file
+ * HHVM requires a work around because of a PHP incompatibility
+ *
+ * @param \Smarty_Internal_Template $_template
+ */
+ private function loadCompiledTemplate(Smarty_Internal_Template $_template)
+ {
+ if (function_exists('opcache_invalidate')) {
+ opcache_invalidate($_template->compiled->filepath);
+ }
+ $_smarty_tpl = $_template;
+ if (defined('HHVM_VERSION')) {
+ $_template->smarty->ext->_hhvm->includeHhvm($_template, $_template->compiled->filepath);
+ } else {
+ include($_template->compiled->filepath);
+ }
+ }
+
+ /**
* render compiled template code
*
* @param Smarty_Internal_Template $_template
@@ -194,12 +186,26 @@ class Smarty_Template_Compiled
*/
public function render(Smarty_Internal_Template $_template)
{
-
+ if ($_template->smarty->debugging) {
+ $_template->smarty->_debug->start_render($_template);
+ }
if (!$this->processed) {
$this->process($_template);
}
- $_template->properties['unifunc'] = $this->unifunc;
- return $_template->getRenderedTemplateCode();
+ if (isset($_template->cached)) {
+ $_template->cached->file_dependency =
+ array_merge($_template->cached->file_dependency, $this->file_dependency);
+ }
+ $this->getRenderedTemplateCode($_template);
+ if ($_template->caching && $this->has_nocache_code) {
+ $_template->cached->hashes[$this->nocache_hash] = true;
+ }
+ if (isset($_template->parent) && $_template->parent->_objType == 2 && !empty($_template->tpl_function)) {
+ $_template->parent->tpl_function = array_merge($_template->parent->tpl_function, $_template->tpl_function);
+ }
+ if ($_template->smarty->debugging) {
+ $_template->smarty->_debug->end_render($_template);
+ }
}
/**
@@ -212,22 +218,26 @@ class Smarty_Template_Compiled
*/
public function compileTemplateSource(Smarty_Internal_Template $_template)
{
- if (!$_template->source->recompiled) {
- $_template->properties['file_dependency'] = array();
- }
+ $_template->source->compileds = array();
+ $this->file_dependency = array();
+ $this->tpl_function = array();
+ $this->includes = array();
+ $this->nocache_hash = null;
+ $this->unifunc = null;
// compile locking
- if (!$_template->source->recompiled) {
- if ($saved_timestamp = $_template->compiled->timestamp) {
+ if (!$_template->source->handler->recompiled) {
+ if ($saved_timestamp = $_template->compiled->getTimeStamp()) {
touch($_template->compiled->filepath);
}
}
// call compiler
try {
+ $_template->loadCompiler();
$code = $_template->compiler->compileTemplate($_template);
}
catch (Exception $e) {
// restore old timestamp in case of error
- if (!$_template->source->recompiled && $saved_timestamp) {
+ if (!$_template->source->handler->recompiled && $saved_timestamp) {
touch($_template->compiled->filepath, $saved_timestamp);
}
throw $e;
@@ -253,18 +263,17 @@ class Smarty_Template_Compiled
*/
public function write(Smarty_Internal_Template $_template, $code)
{
- if (!$_template->source->recompiled) {
- $obj = new Smarty_Internal_Write_File();
- if ($obj->writeFile($this->filepath, $code, $_template->smarty) === true) {
+ if (!$_template->source->handler->recompiled) {
+ if ($_template->smarty->ext->_writeFile->writeFile($this->filepath, $code, $_template->smarty) === true) {
$this->timestamp = $this->exists = is_file($this->filepath);
if ($this->exists) {
- $this->timestamp = @filemtime($this->filepath);
+ $this->timestamp = filemtime($this->filepath);
return true;
}
}
return false;
} else {
- $this->code = $code;
+ $this->content = $code;
}
$this->timestamp = time();
$this->exists = true;
@@ -280,7 +289,7 @@ class Smarty_Template_Compiled
*/
public function read(Smarty_Internal_Template $_template)
{
- if (!$_template->source->recompiled) {
+ if (!$_template->source->handler->recompiled) {
return file_get_contents($this->filepath);
}
return isset($this->content) ? $this->content : false;
diff --git a/library/Smarty/libs/sysplugins/smarty_template_config.php b/library/Smarty/libs/sysplugins/smarty_template_config.php
index f48d4711d..f0fff5080 100644
--- a/library/Smarty/libs/sysplugins/smarty_template_config.php
+++ b/library/Smarty/libs/sysplugins/smarty_template_config.php
@@ -14,35 +14,11 @@
* @package Smarty
* @subpackage TemplateResources
* @author Uwe Tews
- * @property integer $timestamp Source Timestamp
- * @property boolean $exists Source Existence
- * @property boolean $template Extended Template reference
- * @property string $content Source Content
+ *
*/
class Smarty_Template_Config extends Smarty_Template_Source
{
/**
- * Name of the Class to compile this resource's contents with
- *
- * @var string
- */
- public $compiler_class = 'Smarty_Internal_Config_File_Compiler';
-
- /**
- * Name of the Class to tokenize this resource's contents with
- *
- * @var string
- */
- public $template_lexer_class = 'Smarty_Internal_Configfilelexer';
-
- /**
- * Name of the Class to parse this resource's contents with
- *
- * @var string
- */
- public $template_parser_class = 'Smarty_Internal_Configfileparser';
-
- /**
* array of section names, single section or null
*
* @var null|string|array
@@ -74,7 +50,11 @@ class Smarty_Template_Config extends Smarty_Template_Source
*/
public function __construct(Smarty_Resource $handler, Smarty $smarty, $resource, $type, $name)
{
+ // must clone handler as we change class names
$this->handler = clone $handler; // Note: prone to circular references
+ $this->handler->compiler_class = 'Smarty_Internal_Config_File_Compiler';
+ $this->handler->template_lexer_class = 'Smarty_Internal_Configfilelexer';
+ $this->handler->template_parser_class = 'Smarty_Internal_Configfileparser';
$this->resource = $resource;
$this->type = $type;
$this->name = $name;
@@ -89,30 +69,29 @@ class Smarty_Template_Config extends Smarty_Template_Source
* @param Smarty $smarty smarty object
* @param string $template_resource resource identifier
*
- * @return Smarty_Template_Source Source Object
+ * @return Smarty_Template_Config Source Object
* @throws SmartyException
*/
public static function load(Smarty_Internal_Template $_template = null, Smarty $smarty = null, $template_resource = null)
{
static $_incompatible_resources = array('extends' => true, 'php' => true);
- $smarty = $_template->smarty;
$template_resource = $_template->template_resource;
if (empty($template_resource)) {
throw new SmartyException('Missing config name');
}
// parse resource_name, load resource handler
- list($name, $type) = Smarty_Resource::parseResourceName($template_resource, $smarty->default_config_type);
+ list($name, $type) = Smarty_Resource::parseResourceName($template_resource, $_template->smarty->default_config_type);
// make sure configs are not loaded via anything smarty can't handle
if (isset($_incompatible_resources[$type])) {
throw new SmartyException ("Unable to use resource '{$type}' for config");
}
- $resource = Smarty_Resource::load($smarty, $type);
- $source = new Smarty_Template_Config($resource, $smarty, $template_resource, $type, $name);
+ $resource = Smarty_Resource::load($_template->smarty, $type);
+ $source = new Smarty_Template_Config($resource, $_template->smarty, $template_resource, $type, $name);
$resource->populate($source, $_template);
- if ((!isset($source->exists) || !$source->exists) && isset($_template->smarty->default_config_handler_func)) {
- Smarty_Internal_Extension_DefaultTemplateHandler::_getDefault($_template, $source, $resource);
+ if (!$source->exists && isset($_template->smarty->default_config_handler_func)) {
+ Smarty_Internal_Method_RegisterDefaultTemplateHandler::_getDefaultTemplate($source);
}
- $source->unique_resource = $resource->buildUniqueResourceName($smarty, $name, true);
+ $source->unique_resource = $resource->buildUniqueResourceName($_template->smarty, $name, true);
return $source;
}
}
diff --git a/library/Smarty/libs/sysplugins/smarty_template_source.php b/library/Smarty/libs/sysplugins/smarty_template_source.php
index dd537f0e9..be5b62809 100644
--- a/library/Smarty/libs/sysplugins/smarty_template_source.php
+++ b/library/Smarty/libs/sysplugins/smarty_template_source.php
@@ -7,35 +7,11 @@
* @package Smarty
* @subpackage TemplateResources
* @author Rodney Rehm
- * @property integer $timestamp Source Timestamp
- * @property boolean $exists Source Existence
- * @property boolean $template Extended Template reference
- * @property string $content Source Content
+ *
*/
class Smarty_Template_Source
{
/**
- * Name of the Class to compile this resource's contents with
- *
- * @var string
- */
- public $compiler_class = null;
-
- /**
- * Name of the Class to tokenize this resource's contents with
- *
- * @var string
- */
- public $template_lexer_class = null;
-
- /**
- * Name of the Class to parse this resource's contents with
- *
- * @var string
- */
- public $template_parser_class = null;
-
- /**
* Unique Template ID
*
* @var string
@@ -76,6 +52,21 @@ class Smarty_Template_Source
* @var string
*/
public $filepath = null;
+
+ /**
+ * Source Timestamp
+ *
+ * @var integer
+ */
+ public $timestamp = null;
+
+ /**
+ * Source Existence
+ *
+ * @var boolean
+ */
+ public $exists = false;
+
/**
* Source File Base name
*
@@ -86,14 +77,14 @@ class Smarty_Template_Source
/**
* The Components an extended template is made of
*
- * @var array
+ * @var \Smarty_Template_Source[]
*/
public $components = null;
/**
* Resource Handler
*
- * @var Smarty_Resource
+ * @var \Smarty_Resource
*/
public $handler = null;
@@ -103,31 +94,27 @@ class Smarty_Template_Source
* @var Smarty
*/
public $smarty = null;
+
/**
* Resource is source
*
* @var bool
*/
public $isConfig = false;
- /**
- * Source is bypassing compiler
- *
- * @var boolean
- */
- public $uncompiled = false;
/**
- * Source must be recompiled on every occasion
+ * cache for Smarty_Template_Compiled instances
*
- * @var boolean
+ * @var Smarty_Template_Compiled[]
*/
- public $recompiled = false;
+ public $compileds = array();
+
/**
- * cache for Smarty_Template_Compiled instances
+ * Template source content eventually set by default handler
*
- * @var array
+ * @var string
*/
- public $compileds = array();
+ public $content = null;
/**
* create Source Object container
@@ -138,18 +125,10 @@ class Smarty_Template_Source
* @param string $type type of resource
* @param string $name resource name
*
- * @internal param string $unique_resource unique resource name
*/
public function __construct(Smarty_Resource $handler, Smarty $smarty, $resource, $type, $name)
{
$this->handler = $handler; // Note: prone to circular references
-
- $this->recompiled = $handler->recompiled;
- $this->uncompiled = $handler->uncompiled;
- $this->compiler_class = $handler->compiler_class;
- $this->template_lexer_class = $handler->template_lexer_class;
- $this->template_parser_class = $handler->template_parser_class;
-
$this->smarty = $smarty;
$this->resource = $resource;
$this->type = $type;
@@ -167,7 +146,8 @@ class Smarty_Template_Source
* @return Smarty_Template_Source Source Object
* @throws SmartyException
*/
- public static function load(Smarty_Internal_Template $_template = null, Smarty $smarty = null, $template_resource = null)
+ public static function load(Smarty_Internal_Template $_template = null, Smarty $smarty = null,
+ $template_resource = null)
{
if ($_template) {
$smarty = $_template->smarty;
@@ -177,36 +157,51 @@ class Smarty_Template_Source
throw new SmartyException('Missing template name');
}
// parse resource_name, load resource handler, identify unique resource name
- list($name, $type) = Smarty_Resource::parseResourceName($template_resource, $smarty->default_resource_type);
- $resource = Smarty_Resource::load($smarty, $type);
+ if (preg_match('/^([A-Za-z0-9_\-]{2,})[:]([\s\S]*)$/', $template_resource, $match)) {
+ $type = $match[1];
+ $name = $match[2];
+ } else {
+ // no resource given, use default
+ // or single character before the colon is not a resource type, but part of the filepath
+ $type = $smarty->default_resource_type;
+ $name = $template_resource;
+ }
+
+ $handler = isset($smarty->_cache['resource_handlers'][$type]) ?
+ $smarty->_cache['resource_handlers'][$type] :
+ Smarty_Resource::load($smarty, $type);
// if resource is not recompiling and resource name is not dotted we can check the source cache
- if ($smarty->resource_caching && !$resource->recompiled && !(isset($name[1]) && $name[0] == '.' && ($name[1] == '.' || $name[1] == '/'))) {
- $unique_resource = $resource->buildUniqueResourceName($smarty, $name);
- if (isset($smarty->source_objects[$unique_resource])) {
- return $smarty->source_objects[$unique_resource];
+ if (($smarty->resource_cache_mode & Smarty::RESOURCE_CACHE_ON) && !$handler->recompiled &&
+ !(isset($name[1]) && $name[0] == '.' && ($name[1] == '.' || $name[1] == '/'))
+ ) {
+ $unique_resource = $handler->buildUniqueResourceName($smarty, $name);
+ if (isset($smarty->_cache['source_objects'][$unique_resource])) {
+ return $smarty->_cache['source_objects'][$unique_resource];
}
} else {
$unique_resource = null;
}
// create new source object
- $source = new Smarty_Template_Source($resource, $smarty, $template_resource, $type, $name);
- $resource->populate($source, $_template);
- if ((!isset($source->exists) || !$source->exists) && isset($_template->smarty->default_template_handler_func)) {
- Smarty_Internal_Extension_DefaultTemplateHandler::_getDefault($_template, $source, $resObj);
+ $source = new Smarty_Template_Source($handler, $smarty, $template_resource, $type, $name);
+ $handler->populate($source, $_template);
+ if (!$source->exists && isset($_template->smarty->default_template_handler_func)) {
+ Smarty_Internal_Method_RegisterDefaultTemplateHandler::_getDefaultTemplate($source);
}
// on recompiling resources we are done
- if ($smarty->resource_caching && !$resource->recompiled) {
+ if (($smarty->resource_cache_mode & Smarty::RESOURCE_CACHE_ON) && !$handler->recompiled) {
// may by we have already $unique_resource
$is_relative = false;
if (!isset($unique_resource)) {
$is_relative = isset($name[1]) && $name[0] == '.' && ($name[1] == '.' || $name[1] == '/') &&
- ($type == 'file' || (isset($_template->parent->source) && $_template->parent->source->type == 'extends'));
- $unique_resource = $resource->buildUniqueResourceName($smarty, $is_relative ? $source->filepath . $name : $name);
+ ($type == 'file' ||
+ (isset($_template->parent->source) && $_template->parent->source->type == 'extends'));
+ $unique_resource =
+ $handler->buildUniqueResourceName($smarty, $is_relative ? $source->filepath . $name : $name);
}
$source->unique_resource = $unique_resource;
// save in runtime cache if not relative
if (!$is_relative) {
- $smarty->source_objects[$unique_resource] = $source;
+ $smarty->_cache['source_objects'][$unique_resource] = $source;
}
}
return $source;
@@ -216,70 +211,57 @@ class Smarty_Template_Source
* render the uncompiled source
*
* @param Smarty_Internal_Template $_template template object
+ *
+ * @return string
+ * @throws \Exception
*/
public function renderUncompiled(Smarty_Internal_Template $_template)
{
- $level = ob_get_level();
- ob_start();
- try {
+ $this->handler->renderUncompiled($_template->source, $_template);
+ }
+
+ /**
+ * Render uncompiled source
+ *
+ * @param \Smarty_Internal_Template $_template
+ */
+ public function render(Smarty_Internal_Template $_template)
+ {
+ if ($_template->source->handler->uncompiled) {
+ if ($_template->smarty->debugging) {
+ $_template->smarty->_debug->start_render($_template);
+ }
$this->handler->renderUncompiled($_template->source, $_template);
- return ob_get_clean();
- }
- catch (Exception $e) {
- while (ob_get_level() > $level) {
- ob_end_clean();
+ if (isset($_template->parent) && $_template->parent->_objType == 2 && !empty($_template->tpl_function)) {
+ $_template->parent->tpl_function =
+ array_merge($_template->parent->tpl_function, $_template->tpl_function);
+ }
+ if ($_template->smarty->debugging) {
+ $_template->smarty->_debug->end_render($_template);
}
- throw $e;
}
}
/**
- * <<magic>> Generic Setter.
+ * Get source time stamp
*
- * @param string $property_name valid: timestamp, exists, content, template
- * @param mixed $value new value (is not checked)
- *
- * @throws SmartyException if $property_name is not valid
+ * @return int
*/
- public function __set($property_name, $value)
+ public function getTimeStamp()
{
- switch ($property_name) {
- // regular attributes
- case 'timestamp':
- case 'exists':
- case 'content':
- // required for extends: only
- case 'template':
- $this->$property_name = $value;
- break;
-
- default:
- throw new SmartyException("source property '$property_name' does not exist.");
+ if (!isset($this->timestamp)) {
+ $this->handler->populateTimestamp($this);
}
+ return $this->timestamp;
}
/**
- * <<magic>> Generic getter.
+ * Get source content
*
- * @param string $property_name valid: timestamp, exists, content
- *
- * @return mixed
- * @throws SmartyException if $property_name is not valid
+ * @return string
*/
- public function __get($property_name)
+ public function getContent()
{
- switch ($property_name) {
- case 'timestamp':
- case 'exists':
- $this->handler->populateTimestamp($this);
-
- return $this->$property_name;
-
- case 'content':
- return $this->content = $this->handler->getContent($this);
-
- default:
- throw new SmartyException("source property '$property_name' does not exist.");
- }
+ return isset($this->content) ? $this->content : $this->handler->getContent($this);
}
}
diff --git a/library/Smarty/libs/sysplugins/smarty_variable.php b/library/Smarty/libs/sysplugins/smarty_variable.php
index c1de93cb5..a6504b18f 100644
--- a/library/Smarty/libs/sysplugins/smarty_variable.php
+++ b/library/Smarty/libs/sysplugins/smarty_variable.php
@@ -21,25 +21,17 @@ class Smarty_Variable
* @var boolean
*/
public $nocache = false;
- /**
- * the scope the variable will have (local,parent or root)
- *
- * @var int
- */
- public $scope = Smarty::SCOPE_LOCAL;
/**
* create Smarty variable object
*
* @param mixed $value the value to assign
* @param boolean $nocache if true any output of this variable will be not cached
- * @param int $scope the scope the variable will have (local,parent or root)
*/
- public function __construct($value = null, $nocache = false, $scope = Smarty::SCOPE_LOCAL)
+ public function __construct($value = null, $nocache = false)
{
$this->value = $value;
$this->nocache = $nocache;
- $this->scope = $scope;
}
/**