From 8b5540f4f335415a0e33fe07bcb2f19b363cca4e Mon Sep 17 00:00:00 2001 From: Simon Wisselink Date: Wed, 30 Nov 2022 00:25:27 +0100 Subject: [PATCH] More PSR4 rewriting --- demo/index.php | 4 +- demo/plugins/cacheresource.apc.php | 2 +- demo/plugins/cacheresource.memcache.php | 2 +- demo/plugins/cacheresource.mysql.php | 2 +- demo/plugins/cacheresource.pdo.php | 5 +- demo/plugins/cacheresource.pdo_gzip.php | 1 - .../api-functions/api-is-cached.md | 4 +- .../api-functions/api-mute-expected-errors.md | 2 +- .../api-variables/variable-cache-lifetime.md | 8 +- .../api-variables/variable-caching.md | 10 +- .../api-variables/variable-compile-check.md | 2 +- .../api-variables/variable-error-reporting.md | 2 +- docs/programmers/caching/caching-custom.md | 10 +- .../programmers/caching/caching-setting-up.md | 6 +- docs/programmers/charset.md | 2 +- docs/programmers/plugins/plugins-writing.md | 18 +- plugins/block.textformat.php | 16 +- plugins/function.fetch.php | 2 +- plugins/function.html_checkboxes.php | 10 +- plugins/function.html_image.php | 8 - plugins/function.html_options.php | 8 - plugins/function.html_radios.php | 10 +- plugins/function.html_select_date.php | 16 - plugins/function.html_select_time.php | 16 - plugins/function.mailto.php | 6 +- plugins/modifier.capitalize.php | 22 +- plugins/modifier.date_format.php | 15 +- plugins/modifier.debug_print_var.php | 16 +- plugins/modifier.escape.php | 46 +- plugins/modifier.mb_wordwrap.php | 12 +- plugins/modifier.replace.php | 9 +- plugins/modifier.spacify.php | 2 +- plugins/modifier.truncate.php | 16 +- plugins/modifiercompiler.count_characters.php | 6 +- plugins/modifiercompiler.count_sentences.php | 2 +- plugins/modifiercompiler.count_words.php | 5 +- plugins/modifiercompiler.escape.php | 26 +- plugins/modifiercompiler.from_charset.php | 4 +- plugins/modifiercompiler.lower.php | 4 +- plugins/modifiercompiler.strip.php | 2 +- plugins/modifiercompiler.to_charset.php | 4 +- plugins/modifiercompiler.unescape.php | 13 +- plugins/modifiercompiler.upper.php | 4 +- plugins/modifiercompiler.wordwrap.php | 2 +- plugins/shared.escape_special_chars.php | 2 +- plugins/shared.mb_str_replace.php | 10 +- plugins/variablefilter.htmlspecialchars.php | 2 +- src/Autoloader.php | 111 - src/{smarty_internal_block.php => Block.php} | 12 +- .../{smarty_cacheresource.php => Base.php} | 27 +- ...ty_cacheresource_custom.php => Custom.php} | 48 +- .../File.php} | 33 +- ...ce_keyvaluestore.php => KeyValueStore.php} | 39 +- src/Compile/Append.php | 2 +- ...internal_compile_assign.php => Assign.php} | 3 +- ...shared_inheritance.php => Inheritance.php} | 11 +- src/Compile/smarty_internal_compile_block.php | 11 +- .../smarty_internal_compile_config_load.php | 6 +- src/Compile/smarty_internal_compile_debug.php | 7 +- .../smarty_internal_compile_extends.php | 4 +- .../smarty_internal_compile_function.php | 5 - .../smarty_internal_compile_include.php | 10 +- ...arty_internal_compile_private_modifier.php | 47 +- ...ernal_compile_private_print_expression.php | 12 +- ...ernal_compile_private_registered_block.php | 6 +- ...al_compile_private_registered_function.php | 8 +- ...ernal_compile_private_special_variable.php | 2 +- .../smarty_internal_compilebase.php | 0 .../smarty_internal_config_file_compiler.php | 4 +- ...smarty_internal_smartytemplatecompiler.php | 0 .../smarty_internal_templatecompilerbase.php | 203 +- src/{smarty_internal_debug.php => Debug.php} | 96 +- ...rnal_errorhandler.php => ErrorHandler.php} | 4 +- .../smarty_internal_configfilelexer.plex | 0 .../Lexer}/smarty_internal_templatelexer.plex | 0 .../smarty_internal_method_assignglobal.php | 4 +- .../smarty_internal_method_clearallcache.php | 2 +- .../smarty_internal_method_clearcache.php | 2 +- ..._internal_method_clearcompiledtemplate.php | 2 +- ...ty_internal_method_compilealltemplates.php | 2 +- .../smarty_internal_method_configload.php | 4 +- .../smarty_internal_method_createdata.php | 2 +- .../smarty_internal_method_getglobal.php | 6 +- ...smarty_internal_method_gettemplatevars.php | 8 +- .../smarty_internal_method_loadfilter.php | 14 +- .../smarty_internal_method_loadplugin.php | 111 - ..._internal_method_registercacheresource.php | 4 +- .../smarty_internal_configfileparser.y | 13 +- .../Parser}/smarty_internal_templateparser.y | 0 src/Resource/Base.php | 26 +- ...rty_internal_runtime_cacheresourcefile.php | 2 +- .../smarty_internal_runtime_filterhandler.php | 5 +- .../smarty_internal_runtime_inheritance.php | 38 +- .../smarty_internal_runtime_updatecache.php | 2 +- .../smarty_internal_runtime_updatescope.php | 12 +- .../smarty_internal_runtime_writefile.php | 2 +- src/{Smarty.class.php => Smarty.php} | 164 +- src/Template/smarty_template_cached.php | 15 +- src/Template/smarty_template_compiled.php | 6 +- src/TestInstall.php | 78 - src/functions.php | 5 - src/smarty_internal_configfilelexer.php | 739 ----- src/smarty_internal_configfileparser.php | 1046 ------ src/smarty_internal_extension_handler.php | 1 - src/smarty_internal_nocache_insert.php | 51 - src/smarty_internal_template.php | 51 +- src/smarty_internal_templatebase.php | 12 +- src/smarty_internal_templatelexer.php | 1088 ------ src/smarty_internal_templateparser.php | 2926 ----------------- src/smarty_internal_undefined.php | 67 - tests/PHPUnit_Smarty.php | 8 +- .../UnitTests/A_Core/Filter/FilterClosure.php | 2 +- tests/UnitTests/A_Core/Filter/FilterTest.php | 24 +- .../A_Core/Filter/RegisterFilterTest.php | 38 +- .../LoadPlugin/DefaultPluginHandlerTest.php | 8 +- .../A_Core/LoadPlugin/LoadPluginTest.php | 4 +- .../PHPunitplugins/cacheresource.filetest.php | 4 +- .../CompileCompilerPluginTest.php | 6 +- .../RegisterBlock/RegisterBlockTest.php | 30 +- .../RegisterCompilerFunctionTest.php | 26 +- .../RegisterFunction/RegisterFunctionTest.php | 32 +- .../RegisterModifier/RegisterModifierTest.php | 24 +- .../BlockPlugin/CompileBlockPluginTest.php | 10 +- .../CompileFunctionPluginTest.php | 2 +- .../TagTests/Insert/CompileInsertTest.php | 269 -- .../insert.insertplugintest.php | 7 - .../Insert/PHPunitplugins/insert.test2.php | 6 - .../TagTests/Insert/cache/.gitignore | 2 - .../TagTests/Insert/templates/inner.tpl | 1 - .../Insert/templates/insertplugintest.tpl | 1 - .../Insert/templates/insertplugintest2.tpl | 2 - .../TagTests/Insert/templates_c/.gitignore | 2 - .../TagTests/Insert/templates_tmp/.gitignore | 2 - .../PluginBlock/PluginBlockTextformatTest.php | 28 +- .../PluginFunctionMailtoTest.php | 36 +- .../PluginModifierCapitalizeTest.php | 28 +- .../PluginModifierCharsetTest.php | 16 +- .../PluginModifierCountCharactersTest.php | 16 +- .../PluginModifierCountSentencesTest.php | 4 +- .../PluginModifierCountWordsTest.php | 12 +- .../PluginModifierEscapeTest.php | 52 +- .../PluginModifierLowerTest.php | 8 +- .../PluginModifierRegexReplaceTest.php | 4 +- .../PluginModifierTruncateTest.php | 28 +- .../PluginModifierUnescapeTest.php | 8 +- .../PluginModifierUpperTest.php | 8 +- .../PluginModifierWordwrapTest.php | 28 +- .../ValueTests/Modifier/ModifierTest.php | 4 +- .../Error/SmartyErrorTest.php | 2 +- .../Version/SmartyVersionTest.php | 2 +- .../PHPunitplugins/function.checkvar.php | 4 +- 151 files changed, 732 insertions(+), 7683 deletions(-) delete mode 100644 src/Autoloader.php rename src/{smarty_internal_block.php => Block.php} (87%) rename src/Cacheresource/{smarty_cacheresource.php => Base.php} (88%) rename src/Cacheresource/{smarty_cacheresource_custom.php => Custom.php} (88%) rename src/{smarty_internal_cacheresource_file.php => Cacheresource/File.php} (92%) rename src/Cacheresource/{smarty_cacheresource_keyvaluestore.php => KeyValueStore.php} (95%) rename src/Compile/{smarty_internal_compile_assign.php => Assign.php} (96%) rename src/Compile/{smarty_internal_compile_shared_inheritance.php => Inheritance.php} (78%) rename src/{ => Compile}/smarty_internal_compilebase.php (100%) rename src/{ => Compiler}/smarty_internal_config_file_compiler.php (98%) rename src/{ => Compiler}/smarty_internal_smartytemplatecompiler.php (100%) rename src/{ => Compiler}/smarty_internal_templatecompilerbase.php (86%) rename src/{smarty_internal_debug.php => Debug.php} (80%) rename src/{smarty_internal_errorhandler.php => ErrorHandler.php} (98%) rename {lexer => src/Lexer}/smarty_internal_configfilelexer.plex (100%) rename {lexer => src/Lexer}/smarty_internal_templatelexer.plex (100%) delete mode 100644 src/Method/smarty_internal_method_loadplugin.php rename {lexer => src/Parser}/smarty_internal_configfileparser.y (96%) rename {lexer => src/Parser}/smarty_internal_templateparser.y (100%) rename src/{Smarty.class.php => Smarty.php} (86%) delete mode 100644 src/smarty_internal_configfilelexer.php delete mode 100644 src/smarty_internal_configfileparser.php delete mode 100644 src/smarty_internal_nocache_insert.php delete mode 100644 src/smarty_internal_templatelexer.php delete mode 100644 src/smarty_internal_templateparser.php delete mode 100644 src/smarty_internal_undefined.php delete mode 100644 tests/UnitTests/TemplateSource/TagTests/Insert/CompileInsertTest.php delete mode 100644 tests/UnitTests/TemplateSource/TagTests/Insert/PHPunitplugins/insert.insertplugintest.php delete mode 100644 tests/UnitTests/TemplateSource/TagTests/Insert/PHPunitplugins/insert.test2.php delete mode 100644 tests/UnitTests/TemplateSource/TagTests/Insert/cache/.gitignore delete mode 100644 tests/UnitTests/TemplateSource/TagTests/Insert/templates/inner.tpl delete mode 100644 tests/UnitTests/TemplateSource/TagTests/Insert/templates/insertplugintest.tpl delete mode 100644 tests/UnitTests/TemplateSource/TagTests/Insert/templates/insertplugintest2.tpl delete mode 100644 tests/UnitTests/TemplateSource/TagTests/Insert/templates_c/.gitignore delete mode 100644 tests/UnitTests/TemplateSource/TagTests/Insert/templates_tmp/.gitignore diff --git a/demo/index.php b/demo/index.php index 3aed3716..1e182c27 100644 --- a/demo/index.php +++ b/demo/index.php @@ -4,8 +4,8 @@ * * @package Example-application */ -require '../libs/Smarty.class.php'; -$smarty = new Smarty; + +$smarty = new \Smarty\Smarty; //$smarty->force_compile = true; $smarty->debugging = true; $smarty->caching = true; diff --git a/demo/plugins/cacheresource.apc.php b/demo/plugins/cacheresource.apc.php index 7867cc59..335cd524 100644 --- a/demo/plugins/cacheresource.apc.php +++ b/demo/plugins/cacheresource.apc.php @@ -9,7 +9,7 @@ * @package CacheResource-examples * @author Uwe Tews */ -class Smarty_CacheResource_Apc extends Smarty_CacheResource_KeyValueStore +class Smarty_CacheResource_Apc extends \Smarty\Cacheresource\KeyValueStore { /** * Smarty_CacheResource_Apc constructor. diff --git a/demo/plugins/cacheresource.memcache.php b/demo/plugins/cacheresource.memcache.php index 71fe9d3f..580d5e0e 100644 --- a/demo/plugins/cacheresource.memcache.php +++ b/demo/plugins/cacheresource.memcache.php @@ -10,7 +10,7 @@ * @package CacheResource-examples * @author Rodney Rehm */ -class Smarty_CacheResource_Memcache extends Smarty_CacheResource_KeyValueStore +class Smarty_CacheResource_Memcache extends \Smarty\Cacheresource\KeyValueStore { /** * memcache instance diff --git a/demo/plugins/cacheresource.mysql.php b/demo/plugins/cacheresource.mysql.php index c5037eb1..e9494dbf 100644 --- a/demo/plugins/cacheresource.mysql.php +++ b/demo/plugins/cacheresource.mysql.php @@ -22,7 +22,7 @@ * @package CacheResource-examples * @author Rodney Rehm */ -class Smarty_CacheResource_Mysql extends Smarty_CacheResource_Custom +class Smarty_CacheResource_Mysql extends \Smarty\Cacheresource\Custom { /** * @var \PDO diff --git a/demo/plugins/cacheresource.pdo.php b/demo/plugins/cacheresource.pdo.php index ae3ebbf7..c4c44de6 100644 --- a/demo/plugins/cacheresource.pdo.php +++ b/demo/plugins/cacheresource.pdo.php @@ -22,12 +22,11 @@ * Example usage : * $cnx = new PDO("mysql:host=localhost;dbname=mydb", "username", "password"); * $smarty->setCachingType('pdo'); - * $smarty->loadPlugin('Smarty_CacheResource_Pdo'); * $smarty->registerCacheResource('pdo', new Smarty_CacheResource_Pdo($cnx, 'smarty_cache')); * * @author Beno!t POLASZEK - 2014 */ -class Smarty_CacheResource_Pdo extends Smarty_CacheResource_Custom +class Smarty_CacheResource_Pdo extends \Smarty\Cacheresource\Custom { /** * @var string[] @@ -322,7 +321,7 @@ class Smarty_CacheResource_Pdo extends Smarty_CacheResource_Custom $where[] = 'compile_id = ' . $this->pdo->quote($compile_id); } // for clearing expired caches - if ($exp_time === Smarty::CLEAR_EXPIRED) { + if ($exp_time === \Smarty\Smarty::CLEAR_EXPIRED) { $where[] = 'expire < CURRENT_TIMESTAMP'; } // range test expiration time elseif ($exp_time !== null) { diff --git a/demo/plugins/cacheresource.pdo_gzip.php b/demo/plugins/cacheresource.pdo_gzip.php index 5560b9e3..acd21dd4 100644 --- a/demo/plugins/cacheresource.pdo_gzip.php +++ b/demo/plugins/cacheresource.pdo_gzip.php @@ -6,7 +6,6 @@ require_once 'cacheresource.pdo.php'; * Example usage : * $cnx = new PDO("mysql:host=localhost;dbname=mydb", "username", "password"); * $smarty->setCachingType('pdo_gzip'); - * $smarty->loadPlugin('Smarty_CacheResource_Pdo_Gzip'); * $smarty->registerCacheResource('pdo_gzip', new Smarty_CacheResource_Pdo_Gzip($cnx, 'smarty_cache')); * * @require Smarty_CacheResource_Pdo class diff --git a/docs/programmers/api-functions/api-is-cached.md b/docs/programmers/api-functions/api-is-cached.md index 0c41bf04..d9d3057f 100644 --- a/docs/programmers/api-functions/api-is-cached.md +++ b/docs/programmers/api-functions/api-is-cached.md @@ -22,8 +22,8 @@ string compile\_id - This only works if [`$caching`](#variable.caching) is set to one of - `Smarty::CACHING_LIFETIME_CURRENT` or - `Smarty::CACHING_LIFETIME_SAVED` to enable caching. See the [caching + `\Smarty\Smarty::CACHING_LIFETIME_CURRENT` or + `\Smarty\Smarty::CACHING_LIFETIME_SAVED` to enable caching. See the [caching section](#caching) for more info. - You can also pass a `$cache_id` as an optional second parameter in diff --git a/docs/programmers/api-functions/api-mute-expected-errors.md b/docs/programmers/api-functions/api-mute-expected-errors.md index c0c29c06..459ec9ea 100644 --- a/docs/programmers/api-functions/api-mute-expected-errors.md +++ b/docs/programmers/api-functions/api-mute-expected-errors.md @@ -15,7 +15,7 @@ handler merely inspects `$errno` and `$errfile` to determine if the given error was produced deliberately and must be ignored, or should be passed on to the next error handler. -`Smarty::unmuteExpectedErrors()` removes the current error handler. +`\Smarty\Smarty::unmuteExpectedErrors()` removes the current error handler. Please note, that if you\'ve registered any custom error handlers after the muteExpectedErrors() call, the unmute will not remove Smarty\'s muting error handler, but the one registered last. diff --git a/docs/programmers/api-variables/variable-cache-lifetime.md b/docs/programmers/api-variables/variable-cache-lifetime.md index c9624b55..481fbee8 100644 --- a/docs/programmers/api-variables/variable-cache-lifetime.md +++ b/docs/programmers/api-variables/variable-cache-lifetime.md @@ -5,8 +5,8 @@ This is the length of time in seconds that a template cache is valid. Once this time has expired, the cache will be regenerated. - `$caching` must be turned on (either - Smarty::CACHING\_LIFETIME\_CURRENT or - Smarty::CACHING\_LIFETIME\_SAVED) for `$cache_lifetime` to have any + \Smarty\Smarty::CACHING\_LIFETIME\_CURRENT or + \Smarty\Smarty::CACHING\_LIFETIME\_SAVED) for `$cache_lifetime` to have any purpose. - A `$cache_lifetime` value of -1 will force the cache to never @@ -14,11 +14,11 @@ Once this time has expired, the cache will be regenerated. - A value of 0 will cause the cache to always regenerate (good for testing only, to disable caching a more efficient method is to set - [`$caching`](#variable.caching) = Smarty::CACHING\_OFF). + [`$caching`](#variable.caching) = \Smarty\Smarty::CACHING\_OFF). - If you want to give certain templates their own cache lifetime, you could do this by setting [`$caching`](#variable.caching) = - Smarty::CACHING\_LIFETIME\_SAVED, then set `$cache_lifetime` to a + \Smarty\Smarty::CACHING\_LIFETIME\_SAVED, then set `$cache_lifetime` to a unique value just before calling [`display()`](#api.display) or [`fetch()`](#api.fetch). diff --git a/docs/programmers/api-variables/variable-caching.md b/docs/programmers/api-variables/variable-caching.md index 9377e3b6..7304e41d 100644 --- a/docs/programmers/api-variables/variable-caching.md +++ b/docs/programmers/api-variables/variable-caching.md @@ -3,21 +3,21 @@ This tells Smarty whether or not to cache the output of the templates to the [`$cache_dir`](#variable.cache.dir). By default this is set to the -constant Smarty::CACHING\_OFF. If your templates consistently generate +constant \Smarty\Smarty::CACHING\_OFF. If your templates consistently generate the same content, it is advisable to turn on `$caching`, as this may result in significant performance gains. You can also have [multiple](#caching.multiple.caches) caches for the same template. -- A constant value of Smarty::CACHING\_LIFETIME\_CURRENT or - Smarty::CACHING\_LIFETIME\_SAVED enables caching. +- A constant value of \Smarty\Smarty::CACHING\_LIFETIME\_CURRENT or + \Smarty\Smarty ::CACHING\_LIFETIME\_SAVED enables caching. -- A value of Smarty::CACHING\_LIFETIME\_CURRENT tells Smarty to use +- A value of \Smarty\Smarty::CACHING\_LIFETIME\_CURRENT tells Smarty to use the current [`$cache_lifetime`](#variable.cache.lifetime) variable to determine if the cache has expired. -- A value of Smarty::CACHING\_LIFETIME\_SAVED tells Smarty to use the +- A value of \Smarty\Smarty::CACHING\_LIFETIME\_SAVED tells Smarty to use the [`$cache_lifetime`](#variable.cache.lifetime) value at the time the cache was generated. This way you can set the [`$cache_lifetime`](#variable.cache.lifetime) just before diff --git a/docs/programmers/api-variables/variable-compile-check.md b/docs/programmers/api-variables/variable-compile-check.md index c0582d4d..459b5b30 100644 --- a/docs/programmers/api-variables/variable-compile-check.md +++ b/docs/programmers/api-variables/variable-compile-check.md @@ -18,7 +18,7 @@ enabled, then the cache files will get regenerated if an involved template file or config file was updated. As of Smarty 3.1 `$compile_check` can be set to the value -`Smarty::COMPILECHECK_CACHEMISS`. This enables Smarty to revalidate the +`\Smarty\Smarty::COMPILECHECK_CACHEMISS`. This enables Smarty to revalidate the compiled template, once a cache file is regenerated. So if there was a cached template, but it\'s expired, Smarty will run a single compile\_check before regenerating the cache. diff --git a/docs/programmers/api-variables/variable-error-reporting.md b/docs/programmers/api-variables/variable-error-reporting.md index eec7894d..db0281b4 100644 --- a/docs/programmers/api-variables/variable-error-reporting.md +++ b/docs/programmers/api-variables/variable-error-reporting.md @@ -7,7 +7,7 @@ When this value is set to a non-null-value it\'s value is used as php\'s Smarty 3.1.2 introduced the [`muteExpectedErrors()`](#api.mute.expected.errors) function. Calling -`Smarty::muteExpectedErrors();` after setting up custom error handling +`\Smarty\Smarty::muteExpectedErrors();` after setting up custom error handling will ensure that warnings and notices (deliberately) produced by Smarty will not be passed to other custom error handlers. If your error logs are filling up with warnings regarding `filemtime()` or `unlink()` diff --git a/docs/programmers/caching/caching-custom.md b/docs/programmers/caching/caching-custom.md index 77d2ce7b..ebbba2ad 100644 --- a/docs/programmers/caching/caching-custom.md +++ b/docs/programmers/caching/caching-custom.md @@ -17,11 +17,11 @@ faster storage engine, centralize the cache to be accessible to multiple servers. Smarty allows CacheResource implementations to use one of the APIs -`Smarty_CacheResource_Custom` or `Smarty_CacheResource_KeyValueStore`. -`Smarty_CacheResource_Custom` is a simple API directing all read, write, +`\Smarty\Cacheresource\Custom` or `\Smarty\Cacheresource\KeyValueStore`. +`\Smarty\Cacheresource\Custom` is a simple API directing all read, write, clear calls to your implementation. This API allows you to store wherever and however you deem fit. The -`Smarty_CacheResource_KeyValueStore` API allows you to turn any \"dumb\" +`\Smarty\Cacheresource\KeyValueStore` API allows you to turn any \"dumb\" KeyValue-Store (like APC, Memcache, ...) into a full-featured CacheResource implementation. That is, everything around deep cache-groups like \"a\|b\|c\" is being handled for you in way that @@ -66,7 +66,7 @@ to invoke your custom CacheResource implementation. * @package CacheResource-examples * @author Rodney Rehm */ - class Smarty_CacheResource_Mysql extends Smarty_CacheResource_Custom { + class Smarty_CacheResource_Mysql extends \Smarty\Cacheresource\Custom { // PDO instance protected $db; protected $fetch; @@ -214,7 +214,7 @@ to invoke your custom CacheResource implementation. * @package CacheResource-examples * @author Rodney Rehm */ - class Smarty_CacheResource_Memcache extends Smarty_CacheResource_KeyValueStore { + class Smarty_CacheResource_Memcache extends \Smarty\Cacheresource\KeyValueStore { /** * memcache instance * @var Memcache diff --git a/docs/programmers/caching/caching-setting-up.md b/docs/programmers/caching/caching-setting-up.md index bc9d2ad9..45adf673 100644 --- a/docs/programmers/caching/caching-setting-up.md +++ b/docs/programmers/caching/caching-setting-up.md @@ -3,7 +3,7 @@ Setting Up Caching {#caching.setting.up} The first thing to do is enable caching by setting [`$caching`](#variable.caching) to one of -`Smarty::CACHING_LIFETIME_CURRENT` or `Smarty::CACHING_LIFETIME_SAVED`. +`\Smarty\Smarty::CACHING_LIFETIME_CURRENT` or `Smarty::CACHING_LIFETIME_SAVED`. smarty->loadPlugin('smarty_shared_make_timestamp'); - // plugin code - } - ?> - - - + As a general rule, the currently evaluated template\'s Smarty\_Internal\_Template object is always passed to the plugins as the last parameter with two exceptions: diff --git a/plugins/block.textformat.php b/plugins/block.textformat.php index fed090e4..21a0a1d4 100644 --- a/plugins/block.textformat.php +++ b/plugins/block.textformat.php @@ -37,16 +37,6 @@ function smarty_block_textformat($params, $content, Smarty_Internal_Template $te if (is_null($content)) { return; } - if (Smarty::$_MBSTRING) { - $template->_checkPlugins( - array( - array( - 'function' => 'smarty_modifier_mb_wordwrap', - 'file' => SMARTY_PLUGINS_DIR . 'modifier.mb_wordwrap.php' - ) - ) - ); - } $style = null; $indent = 0; $indent_first = 0; @@ -88,8 +78,8 @@ function smarty_block_textformat($params, $content, Smarty_Internal_Template $te $_paragraph = preg_replace( array( - '!\s+!' . Smarty::$_UTF8_MODIFIER, - '!(^\s+)|(\s+$)!' . Smarty::$_UTF8_MODIFIER + '!\s+!' . \Smarty::$_UTF8_MODIFIER, + '!(^\s+)|(\s+$)!' . \Smarty::$_UTF8_MODIFIER ), array( ' ', @@ -102,7 +92,7 @@ function smarty_block_textformat($params, $content, Smarty_Internal_Template $te $_paragraph = str_repeat($indent_char, $indent_first) . $_paragraph; } // wordwrap sentences - if (Smarty::$_MBSTRING) { + if (\Smarty\Smarty::$_MBSTRING) { $_paragraph = smarty_modifier_mb_wordwrap($_paragraph, $wrap - $indent, $wrap_char, $wrap_cut); } else { $_paragraph = wordwrap($_paragraph, $wrap - $indent, $wrap_char, $wrap_cut); diff --git a/plugins/function.fetch.php b/plugins/function.fetch.php index 4a3e8819..d6b777e0 100644 --- a/plugins/function.fetch.php +++ b/plugins/function.fetch.php @@ -56,7 +56,7 @@ function smarty_function_fetch($params, $template) $host = $server_name = $uri_parts[ 'host' ]; $timeout = 30; $accept = 'image/gif, image/x-xbitmap, image/jpeg, image/pjpeg, */*'; - $agent = 'Smarty Template Engine ' . Smarty::SMARTY_VERSION; + $agent = 'Smarty Template Engine ' . \Smarty\Smarty::SMARTY_VERSION; $referer = ''; $uri = !empty($uri_parts[ 'path' ]) ? $uri_parts[ 'path' ] : '/'; $uri .= !empty($uri_parts[ 'query' ]) ? '?' . $uri_parts[ 'query' ] : ''; diff --git a/plugins/function.html_checkboxes.php b/plugins/function.html_checkboxes.php index a8e7a07d..e41de2de 100644 --- a/plugins/function.html_checkboxes.php +++ b/plugins/function.html_checkboxes.php @@ -44,14 +44,6 @@ */ function smarty_function_html_checkboxes($params, Smarty_Internal_Template $template) { - $template->_checkPlugins( - array( - array( - 'function' => 'smarty_function_escape_special_chars', - 'file' => SMARTY_PLUGINS_DIR . 'shared.escape_special_chars.php' - ) - ) - ); $name = 'checkbox'; $values = null; $options = null; @@ -251,7 +243,7 @@ function smarty_function_html_checkboxes_output( if ($label_ids) { $_id = smarty_function_escape_special_chars( preg_replace( - '![^\w\-\.]!' . Smarty::$_UTF8_MODIFIER, + '![^\w\-\.]!' . \Smarty\Smarty::$_UTF8_MODIFIER, '_', $name . '_' . $value ) diff --git a/plugins/function.html_image.php b/plugins/function.html_image.php index 71bc6386..ad39a8b1 100644 --- a/plugins/function.html_image.php +++ b/plugins/function.html_image.php @@ -36,14 +36,6 @@ */ function smarty_function_html_image($params, Smarty_Internal_Template $template) { - $template->_checkPlugins( - array( - array( - 'function' => 'smarty_function_escape_special_chars', - 'file' => SMARTY_PLUGINS_DIR . 'shared.escape_special_chars.php' - ) - ) - ); $alt = ''; $file = ''; $height = ''; diff --git a/plugins/function.html_options.php b/plugins/function.html_options.php index 3e433534..905e35a2 100644 --- a/plugins/function.html_options.php +++ b/plugins/function.html_options.php @@ -36,14 +36,6 @@ */ function smarty_function_html_options($params, Smarty_Internal_Template $template) { - $template->_checkPlugins( - array( - array( - 'function' => 'smarty_function_escape_special_chars', - 'file' => SMARTY_PLUGINS_DIR . 'shared.escape_special_chars.php' - ) - ) - ); $name = null; $values = null; $options = null; diff --git a/plugins/function.html_radios.php b/plugins/function.html_radios.php index 2223ff7e..96aa8ef6 100644 --- a/plugins/function.html_radios.php +++ b/plugins/function.html_radios.php @@ -44,14 +44,6 @@ */ function smarty_function_html_radios($params, Smarty_Internal_Template $template) { - $template->_checkPlugins( - array( - array( - 'function' => 'smarty_function_escape_special_chars', - 'file' => SMARTY_PLUGINS_DIR . 'shared.escape_special_chars.php' - ) - ) - ); $name = 'radio'; $values = null; $options = null; @@ -235,7 +227,7 @@ function smarty_function_html_radios_output( if ($label_ids) { $_id = smarty_function_escape_special_chars( preg_replace( - '![^\w\-\.]!' . Smarty::$_UTF8_MODIFIER, + '![^\w\-\.]!' . \Smarty\Smarty::$_UTF8_MODIFIER, '_', $name . '_' . $value ) diff --git a/plugins/function.html_select_date.php b/plugins/function.html_select_date.php index d9c57197..b84a547e 100644 --- a/plugins/function.html_select_date.php +++ b/plugins/function.html_select_date.php @@ -44,14 +44,6 @@ */ function smarty_function_html_select_date($params, Smarty_Internal_Template $template) { - $template->_checkPlugins( - array( - array( - 'function' => 'smarty_function_escape_special_chars', - 'file' => SMARTY_PLUGINS_DIR . 'shared.escape_special_chars.php' - ) - ) - ); // generate timestamps used for month names only static $_month_timestamps = null; static $_current_year = null; @@ -210,14 +202,6 @@ function smarty_function_html_select_date($params, Smarty_Internal_Template $tem [$_year, $_month, $_day] = explode('-', date('Y-m-d')); } } else { - $template->_checkPlugins( - array( - array( - 'function' => 'smarty_make_timestamp', - 'file' => SMARTY_PLUGINS_DIR . 'shared.make_timestamp.php' - ) - ) - ); $time = smarty_make_timestamp($time); [$_year, $_month, $_day] = explode('-', date('Y-m-d', $time)); } diff --git a/plugins/function.html_select_time.php b/plugins/function.html_select_time.php index 256b56b1..9f15d7da 100644 --- a/plugins/function.html_select_time.php +++ b/plugins/function.html_select_time.php @@ -26,14 +26,6 @@ */ function smarty_function_html_select_time($params, Smarty_Internal_Template $template) { - $template->_checkPlugins( - array( - array( - 'function' => 'smarty_function_escape_special_chars', - 'file' => SMARTY_PLUGINS_DIR . 'shared.escape_special_chars.php' - ) - ) - ); $prefix = 'Time_'; $field_array = null; $field_separator = "\n"; @@ -76,14 +68,6 @@ function smarty_function_html_select_time($params, Smarty_Internal_Template $tem switch ($_key) { case 'time': if (!is_array($_value) && $_value !== null) { - $template->_checkPlugins( - array( - array( - 'function' => 'smarty_make_timestamp', - 'file' => SMARTY_PLUGINS_DIR . 'shared.make_timestamp.php' - ) - ) - ); $time = smarty_make_timestamp($_value); } break; diff --git a/plugins/function.mailto.php b/plugins/function.mailto.php index 671ac069..d2b42524 100644 --- a/plugins/function.mailto.php +++ b/plugins/function.mailto.php @@ -101,8 +101,8 @@ function smarty_function_mailto($params) return; } - $string = '' . htmlspecialchars($text, ENT_QUOTES | ENT_SUBSTITUTE | ENT_HTML401, Smarty::$_CHARSET) . ''; + $string = '' . htmlspecialchars($text, ENT_QUOTES | ENT_SUBSTITUTE | ENT_HTML401, \Smarty\Smarty::$_CHARSET) . ''; if ($encode === 'javascript') { $js_encode = ''; @@ -123,7 +123,7 @@ function smarty_function_mailto($params) } $address_encode = ''; for ($x = 0, $_length = strlen($address); $x < $_length; $x++) { - if (preg_match('!\w!' . Smarty::$_UTF8_MODIFIER, $address[ $x ])) { + if (preg_match('!\w!' . \Smarty\Smarty::$_UTF8_MODIFIER, $address[ $x ])) { $address_encode .= '%' . bin2hex($address[ $x ]); } else { $address_encode .= $address[ $x ]; diff --git a/plugins/modifier.capitalize.php b/plugins/modifier.capitalize.php index 2903d61d..bc3e4615 100644 --- a/plugins/modifier.capitalize.php +++ b/plugins/modifier.capitalize.php @@ -24,14 +24,14 @@ function smarty_modifier_capitalize($string, $uc_digits = false, $lc_rest = fals { $string = (string) $string; - if (Smarty::$_MBSTRING) { + if (\Smarty\Smarty::$_MBSTRING) { if ($lc_rest) { // uppercase (including hyphenated words) - $upper_string = mb_convert_case($string, MB_CASE_TITLE, Smarty::$_CHARSET); + $upper_string = mb_convert_case($string, MB_CASE_TITLE, \Smarty\Smarty::$_CHARSET); } else { // uppercase word breaks $upper_string = preg_replace_callback( - "!(^|[^\p{L}'])([\p{Ll}])!S" . Smarty::$_UTF8_MODIFIER, + "!(^|[^\p{L}'])([\p{Ll}])!S" . \Smarty\Smarty::$_UTF8_MODIFIER, 'smarty_mod_cap_mbconvert_cb', $string ); @@ -39,7 +39,7 @@ function smarty_modifier_capitalize($string, $uc_digits = false, $lc_rest = fals // check uc_digits case if (!$uc_digits) { if (preg_match_all( - "!\b([\p{L}]*[\p{N}]+[\p{L}]*)\b!" . Smarty::$_UTF8_MODIFIER, + "!\b([\p{L}]*[\p{N}]+[\p{L}]*)\b!" . \Smarty\Smarty::$_UTF8_MODIFIER, $string, $matches, PREG_OFFSET_CAPTURE @@ -49,7 +49,7 @@ function smarty_modifier_capitalize($string, $uc_digits = false, $lc_rest = fals $upper_string = substr_replace( $upper_string, - mb_strtolower($match[ 0 ], Smarty::$_CHARSET), + mb_strtolower($match[ 0 ], \Smarty\Smarty::$_CHARSET), $match[ 1 ], strlen($match[ 0 ]) ); @@ -58,7 +58,7 @@ function smarty_modifier_capitalize($string, $uc_digits = false, $lc_rest = fals } $upper_string = preg_replace_callback( - "!((^|\s)['\"])(\w)!" . Smarty::$_UTF8_MODIFIER, + "!((^|\s)['\"])(\w)!" . \Smarty\Smarty::$_UTF8_MODIFIER, 'smarty_mod_cap_mbconvert2_cb', $upper_string ); @@ -71,14 +71,14 @@ function smarty_modifier_capitalize($string, $uc_digits = false, $lc_rest = fals // uppercase (including hyphenated words) $upper_string = preg_replace_callback( - "!(^|[^\p{L}'])([\p{Ll}])!S" . Smarty::$_UTF8_MODIFIER, + "!(^|[^\p{L}'])([\p{Ll}])!S" . \Smarty\Smarty::$_UTF8_MODIFIER, 'smarty_mod_cap_ucfirst_cb', $string ); // check uc_digits case if (!$uc_digits) { if (preg_match_all( - "!\b([\p{L}]*[\p{N}]+[\p{L}]*)\b!" . Smarty::$_UTF8_MODIFIER, + "!\b([\p{L}]*[\p{N}]+[\p{L}]*)\b!" . \Smarty\Smarty::$_UTF8_MODIFIER, $string, $matches, PREG_OFFSET_CAPTURE @@ -91,7 +91,7 @@ function smarty_modifier_capitalize($string, $uc_digits = false, $lc_rest = fals } } $upper_string = preg_replace_callback( - "!((^|\s)['\"])(\w)!" . Smarty::$_UTF8_MODIFIER, + "!((^|\s)['\"])(\w)!" . \Smarty\Smarty::$_UTF8_MODIFIER, 'smarty_mod_cap_ucfirst2_cb', $upper_string ); @@ -113,7 +113,7 @@ function smarty_modifier_capitalize($string, $uc_digits = false, $lc_rest = fals */ function smarty_mod_cap_mbconvert_cb($matches) { - return stripslashes($matches[ 1 ]) . mb_convert_case(stripslashes($matches[ 2 ]), MB_CASE_UPPER, Smarty::$_CHARSET); + return stripslashes($matches[ 1 ]) . mb_convert_case(stripslashes($matches[ 2 ]), MB_CASE_UPPER, \Smarty\Smarty::$_CHARSET); } /** @@ -123,7 +123,7 @@ function smarty_mod_cap_mbconvert_cb($matches) */ function smarty_mod_cap_mbconvert2_cb($matches) { - return stripslashes($matches[ 1 ]) . mb_convert_case(stripslashes($matches[ 3 ]), MB_CASE_UPPER, Smarty::$_CHARSET); + return stripslashes($matches[ 1 ]) . mb_convert_case(stripslashes($matches[ 3 ]), MB_CASE_UPPER, \Smarty\Smarty::$_CHARSET); } /** diff --git a/plugins/modifier.date_format.php b/plugins/modifier.date_format.php index e3589fd0..e879d6fc 100644 --- a/plugins/modifier.date_format.php +++ b/plugins/modifier.date_format.php @@ -29,18 +29,9 @@ function smarty_modifier_date_format($string, $format = null, $default_date = '', $formatter = 'auto') { if ($format === null) { - $format = Smarty::$_DATE_FORMAT; - } - /** - * require_once the {@link shared.make_timestamp.php} plugin - */ - static $is_loaded = false; - if (!$is_loaded) { - if (!is_callable('smarty_make_timestamp')) { - include_once SMARTY_PLUGINS_DIR . 'shared.make_timestamp.php'; - } - $is_loaded = true; + $format = \Smarty\Smarty::$_DATE_FORMAT; } + if (!empty($string) && $string !== '0000-00-00' && $string !== '0000-00-00 00:00:00') { $timestamp = smarty_make_timestamp($string); } elseif (!empty($default_date)) { @@ -49,7 +40,7 @@ function smarty_modifier_date_format($string, $format = null, $default_date = '' return; } if ($formatter === 'strftime' || ($formatter === 'auto' && strpos($format, '%') !== false)) { - if (Smarty::$_IS_WINDOWS) { + if (\Smarty\Smarty::$_IS_WINDOWS) { $_win_from = array( '%D', '%h', diff --git a/plugins/modifier.debug_print_var.php b/plugins/modifier.debug_print_var.php index 78397d01..982b5b12 100644 --- a/plugins/modifier.debug_print_var.php +++ b/plugins/modifier.debug_print_var.php @@ -74,30 +74,30 @@ function smarty_modifier_debug_print_var($var, $max = 10, $length = 40, $depth = break; case 'string': $results = strtr($var, $_replace); - if (Smarty::$_MBSTRING) { - if (mb_strlen($var, Smarty::$_CHARSET) > $length) { - $results = mb_substr($var, 0, $length - 3, Smarty::$_CHARSET) . '...'; + if (\Smarty\Smarty::$_MBSTRING) { + if (mb_strlen($var, \Smarty\Smarty::$_CHARSET) > $length) { + $results = mb_substr($var, 0, $length - 3, \Smarty\Smarty::$_CHARSET) . '...'; } } else { if (isset($var[ $length ])) { $results = substr($var, 0, $length - 3) . '...'; } } - $results = htmlspecialchars('"' . $results . '"', ENT_QUOTES, Smarty::$_CHARSET); + $results = htmlspecialchars('"' . $results . '"', ENT_QUOTES, \Smarty\Smarty::$_CHARSET); break; case 'unknown type': default: $results = strtr((string)$var, $_replace); - if (Smarty::$_MBSTRING) { - if (mb_strlen($results, Smarty::$_CHARSET) > $length) { - $results = mb_substr($results, 0, $length - 3, Smarty::$_CHARSET) . '...'; + if (\Smarty\Smarty::$_MBSTRING) { + if (mb_strlen($results, \Smarty\Smarty::$_CHARSET) > $length) { + $results = mb_substr($results, 0, $length - 3, \Smarty\Smarty::$_CHARSET) . '...'; } } else { if (strlen($results) > $length) { $results = substr($results, 0, $length - 3) . '...'; } } - $results = htmlspecialchars($results, ENT_QUOTES, Smarty::$_CHARSET); + $results = htmlspecialchars($results, ENT_QUOTES, \Smarty\Smarty::$_CHARSET); } return $results; } diff --git a/plugins/modifier.escape.php b/plugins/modifier.escape.php index 11e44682..9d446014 100644 --- a/plugins/modifier.escape.php +++ b/plugins/modifier.escape.php @@ -23,10 +23,8 @@ */ function smarty_modifier_escape($string, $esc_type = 'html', $char_set = null, $double_encode = true) { - static $is_loaded_1 = false; - static $is_loaded_2 = false; if (!$char_set) { - $char_set = Smarty::$_CHARSET; + $char_set = \Smarty\Smarty::$_CHARSET; } $string = (string)$string; @@ -36,7 +34,7 @@ function smarty_modifier_escape($string, $esc_type = 'html', $char_set = null, $ return htmlspecialchars($string, ENT_QUOTES, $char_set, $double_encode); // no break case 'htmlall': - if (Smarty::$_MBSTRING) { + if (\Smarty\Smarty::$_MBSTRING) { $string = mb_convert_encoding($string, 'UTF-8', $char_set); return htmlentities($string, ENT_QUOTES, 'UTF-8', $double_encode); } @@ -61,15 +59,9 @@ function smarty_modifier_escape($string, $esc_type = 'html', $char_set = null, $ return $return; case 'hexentity': $return = ''; - if (Smarty::$_MBSTRING) { - if (!$is_loaded_1) { - if (!is_callable('smarty_mb_to_unicode')) { - include_once SMARTY_PLUGINS_DIR . 'shared.mb_unicode.php'; - } - $is_loaded_1 = true; - } + if (\Smarty\Smarty::$_MBSTRING) { $return = ''; - foreach (smarty_mb_to_unicode($string, Smarty::$_CHARSET) as $unicode) { + foreach (smarty_mb_to_unicode($string, \Smarty\Smarty::$_CHARSET) as $unicode) { $return .= '&#x' . strtoupper(dechex($unicode)) . ';'; } return $return; @@ -82,15 +74,9 @@ function smarty_modifier_escape($string, $esc_type = 'html', $char_set = null, $ return $return; case 'decentity': $return = ''; - if (Smarty::$_MBSTRING) { - if (!$is_loaded_1) { - if (!is_callable('smarty_mb_to_unicode')) { - include_once SMARTY_PLUGINS_DIR . 'shared.mb_unicode.php'; - } - $is_loaded_1 = true; - } - $return = ''; - foreach (smarty_mb_to_unicode($string, Smarty::$_CHARSET) as $unicode) { + if (\Smarty\Smarty::$_MBSTRING) { + $return = ''; + foreach (smarty_mb_to_unicode($string, \Smarty\Smarty::$_CHARSET) as $unicode) { $return .= '&#' . $unicode . ';'; } return $return; @@ -119,13 +105,7 @@ function smarty_modifier_escape($string, $esc_type = 'html', $char_set = null, $ ) ); case 'mail': - if (Smarty::$_MBSTRING) { - if (!$is_loaded_2) { - if (!is_callable('smarty_mb_str_replace')) { - include_once SMARTY_PLUGINS_DIR . 'shared.mb_str_replace.php'; - } - $is_loaded_2 = true; - } + if (\Smarty\Smarty::$_MBSTRING) { return smarty_mb_str_replace( array( '@', @@ -153,14 +133,8 @@ function smarty_modifier_escape($string, $esc_type = 'html', $char_set = null, $ case 'nonstd': // escape non-standard chars, such as ms document quotes $return = ''; - if (Smarty::$_MBSTRING) { - if (!$is_loaded_1) { - if (!is_callable('smarty_mb_to_unicode')) { - include_once SMARTY_PLUGINS_DIR . 'shared.mb_unicode.php'; - } - $is_loaded_1 = true; - } - foreach (smarty_mb_to_unicode($string, Smarty::$_CHARSET) as $unicode) { + if (\Smarty\Smarty::$_MBSTRING) { + foreach (smarty_mb_to_unicode($string, \Smarty\Smarty::$_CHARSET) as $unicode) { if ($unicode >= 126) { $return .= '&#' . $unicode . ';'; } else { diff --git a/plugins/modifier.mb_wordwrap.php b/plugins/modifier.mb_wordwrap.php index 7c7bd875..fe169469 100644 --- a/plugins/modifier.mb_wordwrap.php +++ b/plugins/modifier.mb_wordwrap.php @@ -24,18 +24,18 @@ function smarty_modifier_mb_wordwrap($str, $width = 75, $break = "\n", $cut = false) { // break words into tokens using white space as a delimiter - $tokens = preg_split('!(\s)!S' . Smarty::$_UTF8_MODIFIER, $str, -1, PREG_SPLIT_NO_EMPTY + PREG_SPLIT_DELIM_CAPTURE); + $tokens = preg_split('!(\s)!S' . \Smarty\Smarty::$_UTF8_MODIFIER, $str, -1, PREG_SPLIT_NO_EMPTY + PREG_SPLIT_DELIM_CAPTURE); $length = 0; $t = ''; $_previous = false; $_space = false; foreach ($tokens as $_token) { - $token_length = mb_strlen($_token, Smarty::$_CHARSET); + $token_length = mb_strlen($_token, \Smarty\Smarty::$_CHARSET); $_tokens = array($_token); if ($token_length > $width) { if ($cut) { $_tokens = preg_split( - '!(.{' . $width . '})!S' . Smarty::$_UTF8_MODIFIER, + '!(.{' . $width . '})!S' . \Smarty\Smarty::$_UTF8_MODIFIER, $_token, -1, PREG_SPLIT_NO_EMPTY + PREG_SPLIT_DELIM_CAPTURE @@ -43,13 +43,13 @@ function smarty_modifier_mb_wordwrap($str, $width = 75, $break = "\n", $cut = fa } } foreach ($_tokens as $token) { - $_space = !!preg_match('!^\s$!S' . Smarty::$_UTF8_MODIFIER, $token); - $token_length = mb_strlen($token, Smarty::$_CHARSET); + $_space = !!preg_match('!^\s$!S' . \Smarty\Smarty::$_UTF8_MODIFIER, $token); + $token_length = mb_strlen($token, \Smarty\Smarty::$_CHARSET); $length += $token_length; if ($length > $width) { // remove space before inserted break if ($_previous) { - $t = mb_substr($t, 0, -1, Smarty::$_CHARSET); + $t = mb_substr($t, 0, -1, \Smarty\Smarty::$_CHARSET); } if (!$_space) { // add the break before the token diff --git a/plugins/modifier.replace.php b/plugins/modifier.replace.php index 71a7c632..75be0599 100644 --- a/plugins/modifier.replace.php +++ b/plugins/modifier.replace.php @@ -23,14 +23,7 @@ */ function smarty_modifier_replace($string, $search, $replace) { - static $is_loaded = false; - if (Smarty::$_MBSTRING) { - if (!$is_loaded) { - if (!is_callable('smarty_mb_str_replace')) { - include_once SMARTY_PLUGINS_DIR . 'shared.mb_str_replace.php'; - } - $is_loaded = true; - } + if (\Smarty\Smarty::$_MBSTRING) { return smarty_mb_str_replace($search, $replace, $string); } return str_replace($search, $replace, $string); diff --git a/plugins/modifier.spacify.php b/plugins/modifier.spacify.php index 251dbe71..1838a851 100644 --- a/plugins/modifier.spacify.php +++ b/plugins/modifier.spacify.php @@ -22,5 +22,5 @@ function smarty_modifier_spacify($string, $spacify_char = ' ') { // well… what about charsets besides latin and UTF-8? - return implode($spacify_char, preg_split('//' . Smarty::$_UTF8_MODIFIER, $string, -1, PREG_SPLIT_NO_EMPTY)); + return implode($spacify_char, preg_split('//' . \Smarty\Smarty::$_UTF8_MODIFIER, $string, -1, PREG_SPLIT_NO_EMPTY)); } diff --git a/plugins/modifier.truncate.php b/plugins/modifier.truncate.php index 80dcdb53..13644c56 100644 --- a/plugins/modifier.truncate.php +++ b/plugins/modifier.truncate.php @@ -29,21 +29,21 @@ function smarty_modifier_truncate($string, $length = 80, $etc = '...', $break_wo if ($length === 0) { return ''; } - if (Smarty::$_MBSTRING) { - if (mb_strlen($string, Smarty::$_CHARSET) > $length) { - $length -= min($length, mb_strlen($etc, Smarty::$_CHARSET)); + if (\Smarty\Smarty::$_MBSTRING) { + if (mb_strlen($string, \Smarty\Smarty::$_CHARSET) > $length) { + $length -= min($length, mb_strlen($etc, \Smarty\Smarty::$_CHARSET)); if (!$break_words && !$middle) { $string = preg_replace( - '/\s+?(\S+)?$/' . Smarty::$_UTF8_MODIFIER, + '/\s+?(\S+)?$/' . \Smarty\Smarty::$_UTF8_MODIFIER, '', - mb_substr($string, 0, $length + 1, Smarty::$_CHARSET) + mb_substr($string, 0, $length + 1, \Smarty\Smarty::$_CHARSET) ); } if (!$middle) { - return mb_substr($string, 0, $length, Smarty::$_CHARSET) . $etc; + return mb_substr($string, 0, $length, \Smarty\Smarty::$_CHARSET) . $etc; } - return mb_substr($string, 0, intval($length / 2), Smarty::$_CHARSET) . $etc . - mb_substr($string, -intval($length / 2), $length, Smarty::$_CHARSET); + return mb_substr($string, 0, intval($length / 2), \Smarty\Smarty::$_CHARSET) . $etc . + mb_substr($string, -intval($length / 2), $length, \Smarty\Smarty::$_CHARSET); } return $string; } diff --git a/plugins/modifiercompiler.count_characters.php b/plugins/modifiercompiler.count_characters.php index b5d97e27..1aa6fdd6 100644 --- a/plugins/modifiercompiler.count_characters.php +++ b/plugins/modifiercompiler.count_characters.php @@ -22,10 +22,10 @@ function smarty_modifiercompiler_count_characters($params) { if (!isset($params[ 1 ]) || $params[ 1 ] !== 'true') { - return 'preg_match_all(\'/[^\s]/' . Smarty::$_UTF8_MODIFIER . '\',' . $params[ 0 ] . ', $tmp)'; + return 'preg_match_all(\'/[^\s]/' . \Smarty\Smarty::$_UTF8_MODIFIER . '\',' . $params[ 0 ] . ', $tmp)'; } - if (Smarty::$_MBSTRING) { - return 'mb_strlen(' . $params[ 0 ] . ', \'' . addslashes(Smarty::$_CHARSET) . '\')'; + if (\Smarty\Smarty::$_MBSTRING) { + return 'mb_strlen(' . $params[ 0 ] . ', \'' . addslashes(\Smarty\Smarty::$_CHARSET) . '\')'; } // no MBString fallback return 'strlen(' . $params[ 0 ] . ')'; diff --git a/plugins/modifiercompiler.count_sentences.php b/plugins/modifiercompiler.count_sentences.php index 30e36e5f..d188c292 100644 --- a/plugins/modifiercompiler.count_sentences.php +++ b/plugins/modifiercompiler.count_sentences.php @@ -22,5 +22,5 @@ function smarty_modifiercompiler_count_sentences($params) { // find periods, question marks, exclamation marks with a word before but not after. - return 'preg_match_all("#\w[\.\?\!](\W|$)#S' . Smarty::$_UTF8_MODIFIER . '", ' . $params[ 0 ] . ', $tmp)'; + return 'preg_match_all("#\w[\.\?\!](\W|$)#S' . \Smarty\Smarty::$_UTF8_MODIFIER . '", ' . $params[ 0 ] . ', $tmp)'; } diff --git a/plugins/modifiercompiler.count_words.php b/plugins/modifiercompiler.count_words.php index cf2e5022..18a968a5 100644 --- a/plugins/modifiercompiler.count_words.php +++ b/plugins/modifiercompiler.count_words.php @@ -20,10 +20,9 @@ */ function smarty_modifiercompiler_count_words($params) { - if (Smarty::$_MBSTRING) { - // return 'preg_match_all(\'#[\w\pL]+#' . Smarty::$_UTF8_MODIFIER . '\', ' . $params[0] . ', $tmp)'; + if (\Smarty\Smarty::$_MBSTRING) { // expression taken from http://de.php.net/manual/en/function.str-word-count.php#85592 - return 'preg_match_all(\'/\p{L}[\p{L}\p{Mn}\p{Pd}\\\'\x{2019}]*/' . Smarty::$_UTF8_MODIFIER . '\', ' . + return 'preg_match_all(\'/\p{L}[\p{L}\p{Mn}\p{Pd}\\\'\x{2019}]*/' . \Smarty\Smarty::$_UTF8_MODIFIER . '\', ' . $params[ 0 ] . ', $tmp)'; } // no MBString fallback diff --git a/plugins/modifiercompiler.escape.php b/plugins/modifiercompiler.escape.php index 602c3dbf..ea4ff3e1 100644 --- a/plugins/modifiercompiler.escape.php +++ b/plugins/modifiercompiler.escape.php @@ -22,20 +22,12 @@ */ function smarty_modifiercompiler_escape($params, Smarty_Internal_TemplateCompilerBase $compiler) { - $compiler->template->_checkPlugins( - array( - array( - 'function' => 'smarty_literal_compiler_param', - 'file' => SMARTY_PLUGINS_DIR . 'shared.literal_compiler_param.php' - ) - ) - ); try { $esc_type = smarty_literal_compiler_param($params, 1, 'html'); - $char_set = smarty_literal_compiler_param($params, 2, Smarty::$_CHARSET); + $char_set = smarty_literal_compiler_param($params, 2, \Smarty\Smarty::$_CHARSET); $double_encode = smarty_literal_compiler_param($params, 3, true); if (!$char_set) { - $char_set = Smarty::$_CHARSET; + $char_set = \Smarty\Smarty::$_CHARSET; } switch ($esc_type) { case 'html': @@ -43,7 +35,7 @@ function smarty_modifiercompiler_escape($params, Smarty_Internal_TemplateCompile var_export($double_encode, true) . ')'; // no break case 'htmlall': - if (Smarty::$_MBSTRING) { + if (\Smarty\Smarty::$_MBSTRING) { return 'htmlentities(mb_convert_encoding((string)' . $params[ 0 ] . ', \'UTF-8\', ' . var_export($char_set, true) . '), ENT_QUOTES, \'UTF-8\', ' . var_export($double_encode, true) . ')'; @@ -69,17 +61,5 @@ function smarty_modifiercompiler_escape($params, Smarty_Internal_TemplateCompile } catch (SmartyException $e) { // pass through to regular plugin fallback } - // could not optimize |escape call, so fallback to regular plugin - if ($compiler->template->caching && ($compiler->tag_nocache | $compiler->nocache)) { - $compiler->required_plugins[ 'nocache' ][ 'escape' ][ 'modifier' ][ 'file' ] = - SMARTY_PLUGINS_DIR . 'modifier.escape.php'; - $compiler->required_plugins[ 'nocache' ][ 'escape' ][ 'modifier' ][ 'function' ] = - 'smarty_modifier_escape'; - } else { - $compiler->required_plugins[ 'compiled' ][ 'escape' ][ 'modifier' ][ 'file' ] = - SMARTY_PLUGINS_DIR . 'modifier.escape.php'; - $compiler->required_plugins[ 'compiled' ][ 'escape' ][ 'modifier' ][ 'function' ] = - 'smarty_modifier_escape'; - } return 'smarty_modifier_escape(' . join(', ', $params) . ')'; } diff --git a/plugins/modifiercompiler.from_charset.php b/plugins/modifiercompiler.from_charset.php index acce7784..75c2d80c 100644 --- a/plugins/modifiercompiler.from_charset.php +++ b/plugins/modifiercompiler.from_charset.php @@ -19,12 +19,12 @@ */ function smarty_modifiercompiler_from_charset($params) { - if (!Smarty::$_MBSTRING) { + if (!\Smarty\Smarty::$_MBSTRING) { // FIXME: (rodneyrehm) shouldn't this throw an error? return $params[ 0 ]; } if (!isset($params[ 1 ])) { $params[ 1 ] = '"ISO-8859-1"'; } - return 'mb_convert_encoding(' . $params[ 0 ] . ', "' . addslashes(Smarty::$_CHARSET) . '", ' . $params[ 1 ] . ')'; + return 'mb_convert_encoding(' . $params[ 0 ] . ', "' . addslashes(\Smarty\Smarty::$_CHARSET) . '", ' . $params[ 1 ] . ')'; } diff --git a/plugins/modifiercompiler.lower.php b/plugins/modifiercompiler.lower.php index ac9cc39d..1d11cfd1 100644 --- a/plugins/modifiercompiler.lower.php +++ b/plugins/modifiercompiler.lower.php @@ -21,8 +21,8 @@ */ function smarty_modifiercompiler_lower($params) { - if (Smarty::$_MBSTRING) { - return 'mb_strtolower(' . $params[ 0 ] . ', \'' . addslashes(Smarty::$_CHARSET) . '\')'; + if (\Smarty\Smarty::$_MBSTRING) { + return 'mb_strtolower(' . $params[ 0 ] . ', \'' . addslashes(\Smarty\Smarty::$_CHARSET) . '\')'; } // no MBString fallback return 'strtolower(' . $params[ 0 ] . ')'; diff --git a/plugins/modifiercompiler.strip.php b/plugins/modifiercompiler.strip.php index 51944bde..6c4dacf5 100644 --- a/plugins/modifiercompiler.strip.php +++ b/plugins/modifiercompiler.strip.php @@ -26,5 +26,5 @@ function smarty_modifiercompiler_strip($params) if (!isset($params[ 1 ])) { $params[ 1 ] = "' '"; } - return "preg_replace('!\s+!" . Smarty::$_UTF8_MODIFIER . "', {$params[1]},{$params[0]})"; + return "preg_replace('!\s+!" . \Smarty\Smarty::$_UTF8_MODIFIER . "', {$params[1]},{$params[0]})"; } diff --git a/plugins/modifiercompiler.to_charset.php b/plugins/modifiercompiler.to_charset.php index d652eab1..ed6ebd3b 100644 --- a/plugins/modifiercompiler.to_charset.php +++ b/plugins/modifiercompiler.to_charset.php @@ -19,12 +19,12 @@ */ function smarty_modifiercompiler_to_charset($params) { - if (!Smarty::$_MBSTRING) { + if (!\Smarty\Smarty::$_MBSTRING) { // FIXME: (rodneyrehm) shouldn't this throw an error? return $params[ 0 ]; } if (!isset($params[ 1 ])) { $params[ 1 ] = '"ISO-8859-1"'; } - return 'mb_convert_encoding(' . $params[ 0 ] . ', ' . $params[ 1 ] . ', "' . addslashes(Smarty::$_CHARSET) . '")'; + return 'mb_convert_encoding(' . $params[ 0 ] . ', ' . $params[ 1 ] . ', "' . addslashes(\Smarty\Smarty::$_CHARSET) . '")'; } diff --git a/plugins/modifiercompiler.unescape.php b/plugins/modifiercompiler.unescape.php index 9e1f06d6..c7e76eed 100644 --- a/plugins/modifiercompiler.unescape.php +++ b/plugins/modifiercompiler.unescape.php @@ -20,25 +20,16 @@ */ function smarty_modifiercompiler_unescape($params, Smarty_Internal_TemplateCompilerBase $compiler) { - $compiler->template->_checkPlugins( - array( - array( - 'function' => 'smarty_literal_compiler_param', - 'file' => SMARTY_PLUGINS_DIR . 'shared.literal_compiler_param.php' - ) - ) - ); - $esc_type = smarty_literal_compiler_param($params, 1, 'html'); if (!isset($params[ 2 ])) { - $params[ 2 ] = '\'' . addslashes(Smarty::$_CHARSET) . '\''; + $params[ 2 ] = '\'' . addslashes(\Smarty\Smarty::$_CHARSET) . '\''; } switch ($esc_type) { case 'entity': case 'htmlall': - if (Smarty::$_MBSTRING) { + if (\Smarty\Smarty::$_MBSTRING) { return 'html_entity_decode(mb_convert_encoding(' . $params[ 0 ] . ', ' . $params[ 2 ] . ', \'UTF-8\'), ENT_QUOTES | ENT_SUBSTITUTE | ENT_HTML401, ' . $params[ 2 ] . ')'; } return 'html_entity_decode(' . $params[ 0 ] . ', ENT_QUOTES | ENT_SUBSTITUTE | ENT_HTML401, ' . $params[ 2 ] . ')'; diff --git a/plugins/modifiercompiler.upper.php b/plugins/modifiercompiler.upper.php index 31a90a05..734e6c17 100644 --- a/plugins/modifiercompiler.upper.php +++ b/plugins/modifiercompiler.upper.php @@ -20,8 +20,8 @@ */ function smarty_modifiercompiler_upper($params) { - if (Smarty::$_MBSTRING) { - return 'mb_strtoupper(' . $params[ 0 ] . ' ?? \'\', \'' . addslashes(Smarty::$_CHARSET) . '\')'; + if (\Smarty\Smarty::$_MBSTRING) { + return 'mb_strtoupper(' . $params[ 0 ] . ' ?? \'\', \'' . addslashes(\Smarty\Smarty::$_CHARSET) . '\')'; } // no MBString fallback return 'strtoupper(' . $params[ 0 ] . ' ?? \'\')'; diff --git a/plugins/modifiercompiler.wordwrap.php b/plugins/modifiercompiler.wordwrap.php index 49cb40b0..dfa95dcd 100644 --- a/plugins/modifiercompiler.wordwrap.php +++ b/plugins/modifiercompiler.wordwrap.php @@ -32,7 +32,7 @@ function smarty_modifiercompiler_wordwrap($params, Smarty_Internal_TemplateCompi $params[ 3 ] = 'false'; } $function = 'wordwrap'; - if (Smarty::$_MBSTRING) { + if (\Smarty\Smarty::$_MBSTRING) { $function = $compiler->getPlugin('mb_wordwrap', 'modifier'); } return $function . '(' . $params[ 0 ] . ',' . $params[ 1 ] . ',' . $params[ 2 ] . ',' . $params[ 3 ] . ')'; diff --git a/plugins/shared.escape_special_chars.php b/plugins/shared.escape_special_chars.php index a204b092..b544b683 100644 --- a/plugins/shared.escape_special_chars.php +++ b/plugins/shared.escape_special_chars.php @@ -20,7 +20,7 @@ function smarty_function_escape_special_chars($string) { if (!is_array($string)) { - $string = htmlspecialchars($string, ENT_COMPAT, Smarty::$_CHARSET, false); + $string = htmlspecialchars($string, ENT_COMPAT, \Smarty\Smarty::$_CHARSET, false); } return $string; } diff --git a/plugins/shared.mb_str_replace.php b/plugins/shared.mb_str_replace.php index 7e85f7aa..bf40aa54 100644 --- a/plugins/shared.mb_str_replace.php +++ b/plugins/shared.mb_str_replace.php @@ -54,12 +54,12 @@ if (!function_exists('smarty_mb_str_replace')) { // See if charset used by Smarty is matching one used by regex... $current_charset = mb_regex_encoding(); - $convert_result = (bool)strcasecmp(Smarty::$_CHARSET, $current_charset); + $convert_result = (bool)strcasecmp(\Smarty\Smarty::$_CHARSET, $current_charset); if($convert_result) { // ...convert to it if not. - $subject = mb_convert_encoding($subject, $current_charset, Smarty::$_CHARSET); - $search = mb_convert_encoding($search, $current_charset, Smarty::$_CHARSET); - $replace = mb_convert_encoding($replace, $current_charset, Smarty::$_CHARSET); + $subject = mb_convert_encoding($subject, $current_charset, \Smarty\Smarty::$_CHARSET); + $search = mb_convert_encoding($search, $current_charset, \Smarty\Smarty::$_CHARSET); + $replace = mb_convert_encoding($replace, $current_charset, \Smarty\Smarty::$_CHARSET); } $parts = mb_split(preg_quote($search), $subject ?? "") ?: array(); @@ -79,7 +79,7 @@ if (!function_exists('smarty_mb_str_replace')) { $subject = implode($replace, $parts); // Convert results back to charset used by Smarty, if needed. if($convert_result) { - $subject = mb_convert_encoding($subject, Smarty::$_CHARSET, $current_charset); + $subject = mb_convert_encoding($subject, \Smarty\Smarty::$_CHARSET, $current_charset); } } return $subject; diff --git a/plugins/variablefilter.htmlspecialchars.php b/plugins/variablefilter.htmlspecialchars.php index 3c85295d..98b52c46 100644 --- a/plugins/variablefilter.htmlspecialchars.php +++ b/plugins/variablefilter.htmlspecialchars.php @@ -15,5 +15,5 @@ */ function smarty_variablefilter_htmlspecialchars($source, Smarty_Internal_Template $template) { - return htmlspecialchars($source, ENT_QUOTES, Smarty::$_CHARSET); + return htmlspecialchars($source, ENT_QUOTES, \Smarty\Smarty::$_CHARSET); } diff --git a/src/Autoloader.php b/src/Autoloader.php deleted file mode 100644 index da7e32ab..00000000 --- a/src/Autoloader.php +++ /dev/null @@ -1,111 +0,0 @@ - 'Smarty.class.php'); - - /** - * Registers Smarty_Autoloader backward compatible to older installations. - * - * @param bool $prepend Whether to prepend the autoloader or not. - */ - public static function registerBC($prepend = false) - { - /** - * register the class 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 - ) { - $registeredAutoLoadFunctions = spl_autoload_functions(); - if (!isset($registeredAutoLoadFunctions[ 'spl_autoload' ])) { - spl_autoload_register(); - } - } else { - self::register($prepend); - } - } - - /** - * Registers Smarty_Autoloader as an SPL autoloader. - * - * @param bool $prepend Whether to prepend the autoloader or not. - */ - public static function register($prepend = false) - { - self::$SMARTY_DIR = defined('SMARTY_DIR') ? SMARTY_DIR : __DIR__ . DIRECTORY_SEPARATOR; - self::$SMARTY_SYSPLUGINS_DIR = defined('SMARTY_SYSPLUGINS_DIR') ? SMARTY_SYSPLUGINS_DIR : - self::$SMARTY_DIR . 'sysplugins' . DIRECTORY_SEPARATOR; - spl_autoload_register(array(__CLASS__, 'autoload'), true, $prepend); - } - - /** - * Handles auto loading of classes. - * - * @param string $class A class name. - */ - public static function autoload($class) - { - if ($class[ 0 ] !== 'S' || strpos($class, 'Smarty') !== 0) { - return; - } - $_class = smarty_strtolower_ascii($class); - if (isset(self::$rootClasses[ $_class ])) { - $file = self::$SMARTY_DIR . self::$rootClasses[ $_class ]; - if (is_file($file)) { - include $file; - } - } else { - $file = self::$SMARTY_SYSPLUGINS_DIR . $_class . '.php'; - if (is_file($file)) { - include $file; - } - } - return; - } -} diff --git a/src/smarty_internal_block.php b/src/Block.php similarity index 87% rename from src/smarty_internal_block.php rename to src/Block.php index 9956d642..62ec95f8 100644 --- a/src/smarty_internal_block.php +++ b/src/Block.php @@ -1,5 +1,7 @@ 'smarty_internal_cacheresource_file.php',); + protected static $sysplugins = array('file' => 'File.php',); /** * populate Cached Object with meta data from Resource * - * @param \Smarty_Template_Cached $cached cached object + * @param Smarty_Template_Cached $cached cached object * @param Smarty_Internal_Template $_template template object * * @return void */ - abstract public function populate(\Smarty_Template_Cached $cached, Smarty_Internal_Template $_template); + abstract public function populate(Smarty_Template_Cached $cached, Smarty_Internal_Template $_template); /** * populate Cached Object with timestamp and exists from Resource @@ -187,7 +194,7 @@ abstract class Smarty_CacheResource * @param string $type name of the cache resource * * @throws SmartyException - * @return Smarty_CacheResource Cache Resource Handler + * @return Base Cache Resource Handler */ public static function load(Smarty $smarty, $type = null) { @@ -205,15 +212,11 @@ abstract class Smarty_CacheResource } // try sysplugins dir if (isset(self::$sysplugins[ $type ])) { - $cache_resource_class = 'Smarty_Internal_CacheResource_' . smarty_ucfirst_ascii($type); + $cache_resource_class = 'Smarty_Internal_CacheResource_' . \smarty_ucfirst_ascii($type); return $smarty->_cacheresource_handlers[ $type ] = new $cache_resource_class(); } // try plugins dir - $cache_resource_class = 'Smarty_CacheResource_' . smarty_ucfirst_ascii($type); - if ($smarty->loadPlugin($cache_resource_class)) { - return $smarty->_cacheresource_handlers[ $type ] = new $cache_resource_class(); - } - // give up - throw new SmartyException("Unable to load cache resource '{$type}'"); + $cache_resource_class = 'Smarty_CacheResource_' . \smarty_ucfirst_ascii($type); + return $smarty->_cacheresource_handlers[ $type ] = new $cache_resource_class(); } } diff --git a/src/Cacheresource/smarty_cacheresource_custom.php b/src/Cacheresource/Custom.php similarity index 88% rename from src/Cacheresource/smarty_cacheresource_custom.php rename to src/Cacheresource/Custom.php index 68ad1128..1555c644 100644 --- a/src/Cacheresource/smarty_cacheresource_custom.php +++ b/src/Cacheresource/Custom.php @@ -1,4 +1,7 @@ cached->content ? $_template->cached->content : null; - $timestamp = null; - if ($content === null) { + $content = $_template->cached->content ?: null; + if ($content === null) { $timestamp = null; $this->fetch( $_template->cached->filepath, @@ -206,15 +210,15 @@ abstract class Smarty_CacheResource_Custom extends Smarty_CacheResource return false; } - /** - * Empty cache - * - * @param Smarty $smarty Smarty object - * @param integer $exp_time expiration time (number of seconds, not timestamp) - * - * @return integer number of cache files deleted - */ - public function clearAll(Smarty $smarty, $exp_time = null) + /** + * Empty cache + * + * @param \Smarty\Smarty $smarty Smarty object + * @param null $exp_time expiration time (number of seconds, not timestamp) + * + * @return integer number of cache files deleted + */ + public function clearAll(\Smarty\Smarty $smarty, $exp_time = null) { return $this->delete(null, null, null, $exp_time); } @@ -222,7 +226,7 @@ abstract class Smarty_CacheResource_Custom extends Smarty_CacheResource /** * Empty cache for a specific template * - * @param Smarty $smarty Smarty object + * @param \Smarty\Smarty $smarty Smarty object * @param string $resource_name template name * @param string $cache_id cache id * @param string $compile_id compile id @@ -231,7 +235,7 @@ abstract class Smarty_CacheResource_Custom extends Smarty_CacheResource * @return int number of cache files deleted * @throws \SmartyException */ - public function clear(Smarty $smarty, $resource_name, $cache_id, $compile_id, $exp_time) + public function clear(\Smarty\Smarty $smarty, $resource_name, $cache_id, $compile_id, $exp_time) { $cache_name = null; if (isset($resource_name)) { @@ -248,12 +252,12 @@ abstract class Smarty_CacheResource_Custom extends Smarty_CacheResource /** * Check is cache is locked for this template * - * @param Smarty $smarty Smarty object + * @param \Smarty\Smarty $smarty Smarty object * @param Smarty_Template_Cached $cached cached object * * @return boolean true or false if cache is locked */ - public function hasLock(Smarty $smarty, Smarty_Template_Cached $cached) + public function hasLock(\Smarty\Smarty $smarty, Smarty_Template_Cached $cached) { $id = $cached->lock_id; $name = $cached->source->name . '.lock'; @@ -267,12 +271,12 @@ abstract class Smarty_CacheResource_Custom extends Smarty_CacheResource /** * Lock cache for this template * - * @param Smarty $smarty Smarty object + * @param \Smarty\Smarty $smarty Smarty object * @param Smarty_Template_Cached $cached cached object * * @return bool|void */ - public function acquireLock(Smarty $smarty, Smarty_Template_Cached $cached) + public function acquireLock(\Smarty\Smarty $smarty, Smarty_Template_Cached $cached) { $cached->is_locked = true; $id = $cached->lock_id; @@ -283,12 +287,12 @@ abstract class Smarty_CacheResource_Custom extends Smarty_CacheResource /** * Unlock cache for this template * - * @param Smarty $smarty Smarty object + * @param \Smarty\Smarty $smarty Smarty object * @param Smarty_Template_Cached $cached cached object * * @return bool|void */ - public function releaseLock(Smarty $smarty, Smarty_Template_Cached $cached) + public function releaseLock(\Smarty\Smarty $smarty, Smarty_Template_Cached $cached) { $cached->is_locked = false; $name = $cached->source->name . '.lock'; diff --git a/src/smarty_internal_cacheresource_file.php b/src/Cacheresource/File.php similarity index 92% rename from src/smarty_internal_cacheresource_file.php rename to src/Cacheresource/File.php index c77ae9e1..28a1aee7 100644 --- a/src/smarty_internal_cacheresource_file.php +++ b/src/Cacheresource/File.php @@ -1,4 +1,11 @@ exists = !!$cached->timestamp; } - /** - * Read the cached template and process the header - * - * @param \Smarty_Internal_Template $_smarty_tpl do not change variable name, is used by compiled template - * @param Smarty_Template_Cached $cached cached object - * @param boolean $update flag if called because cache update - * - * @return boolean true or false if the cached content does not exist - */ + /** + * Read the cached template and process the header + * + * @param Smarty_Internal_Template $_smarty_tpl do not change variable name, is used by compiled template + * @param Smarty_Template_Cached|null $cached cached object + * @param boolean $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 $_smarty_tpl, Smarty_Template_Cached $cached = null, @@ -102,8 +109,8 @@ abstract class Smarty_CacheResource_KeyValueStore extends Smarty_CacheResource if (!$cached) { $cached = $_smarty_tpl->cached; } - $content = $cached->content ? $cached->content : null; - $timestamp = $cached->timestamp ? $cached->timestamp : null; + $content = $cached->content ?: null; + $timestamp = $cached->timestamp ?: null; if ($content === null || !$timestamp) { if (!$this->fetch( $_smarty_tpl->cached->filepath, @@ -380,11 +387,7 @@ abstract class Smarty_CacheResource_KeyValueStore extends Smarty_CacheResource $compile_id = null, $resource_uid = null ) { - // abort if there is no CacheID - if (false && !$cid) { - return 0; - } - // abort if there are no InvalidationKeys to check + // abort if there are no InvalidationKeys to check if (!($_cid = $this->listInvalidationKeys($cid, $resource_name, $cache_id, $compile_id, $resource_uid))) { return 0; } @@ -489,7 +492,7 @@ abstract class Smarty_CacheResource_KeyValueStore extends Smarty_CacheResource * @param Smarty $smarty Smarty object * @param Smarty_Template_Cached $cached cached object * - * @return bool|void + * @return void */ public function releaseLock(Smarty $smarty, Smarty_Template_Cached $cached) { diff --git a/src/Compile/Append.php b/src/Compile/Append.php index 224a3099..707c9bc1 100644 --- a/src/Compile/Append.php +++ b/src/Compile/Append.php @@ -29,7 +29,7 @@ class Append extends Assign * @return string compiled code * @throws \SmartyCompilerException */ - public function compile($args, Smarty_Internal_TemplateCompilerBase $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/src/Compile/smarty_internal_compile_assign.php b/src/Compile/Assign.php similarity index 96% rename from src/Compile/smarty_internal_compile_assign.php rename to src/Compile/Assign.php index 54c35e79..f38c43b3 100644 --- a/src/Compile/smarty_internal_compile_assign.php +++ b/src/Compile/Assign.php @@ -3,6 +3,7 @@ namespace Smarty\Compile; use Smarty\CompileBase; +use Smarty\Smarty; /** * Smarty Internal Plugin Compile Assign @@ -50,7 +51,7 @@ class Assign extends CompileBase * @return string compiled code * @throws \SmartyCompilerException */ - public function compile($args, Smarty_Internal_TemplateCompilerBase $compiler, $parameter) + public function compile($args, \Smarty_Internal_TemplateCompilerBase $compiler, $parameter) { // the following must be assigned at runtime because it will be overwritten in Append $this->required_attributes = array('var', 'value'); diff --git a/src/Compile/smarty_internal_compile_shared_inheritance.php b/src/Compile/Inheritance.php similarity index 78% rename from src/Compile/smarty_internal_compile_shared_inheritance.php rename to src/Compile/Inheritance.php index d90262e6..ba226700 100644 --- a/src/Compile/smarty_internal_compile_shared_inheritance.php +++ b/src/Compile/Inheritance.php @@ -1,4 +1,7 @@ prefixCompiledCode .= "_loadInheritance();\n\$_smarty_tpl->inheritance->init(\$_smarty_tpl, " . var_export($initChildSequence, true) . ");\n?>\n"; @@ -34,11 +37,11 @@ class Smarty_Internal_Compile_Shared_Inheritance extends Smarty_Internal_Compile * @param \Smarty_Internal_TemplateCompilerBase $compiler * @param bool|false $initChildSequence if true force child template */ - public function registerInit(Smarty_Internal_TemplateCompilerBase $compiler, $initChildSequence = false) + public function registerInit(\Smarty_Internal_TemplateCompilerBase $compiler, $initChildSequence = false) { if ($initChildSequence || !isset($compiler->_cache[ 'inheritanceInit' ])) { $compiler->registerPostCompileCallback( - array('Smarty_Internal_Compile_Shared_Inheritance', 'postCompile'), + array(self::class, 'postCompile'), array($initChildSequence), 'inheritanceInit', $initChildSequence diff --git a/src/Compile/smarty_internal_compile_block.php b/src/Compile/smarty_internal_compile_block.php index ac507298..8e4a57c9 100644 --- a/src/Compile/smarty_internal_compile_block.php +++ b/src/Compile/smarty_internal_compile_block.php @@ -8,6 +8,8 @@ * file that was distributed with this source code. */ +use Smarty\Compile\Inheritance; + /** * Smarty Internal Plugin Compile Block Class * @@ -83,7 +85,6 @@ class Smarty_Internal_Compile_Block extends Smarty_Internal_Compile_Shared_Inher $compiler->template->caching ) ); - $compiler->saveRequiredPlugins(true); $compiler->nocache = $compiler->nocache | $compiler->tag_nocache; $compiler->parser->current_buffer = new \Smarty\ParseTree\Template(); $compiler->template->compiled->has_nocache_code = false; @@ -94,7 +95,7 @@ class Smarty_Internal_Compile_Block extends Smarty_Internal_Compile_Shared_Inher /** * Smarty Internal Plugin Compile BlockClose Class */ -class Smarty_Internal_Compile_Blockclose extends Smarty_Internal_Compile_Shared_Inheritance +class Smarty_Internal_Compile_Blockclose extends Inheritance { /** * Compiles code for the {/block} tag @@ -107,7 +108,7 @@ class Smarty_Internal_Compile_Blockclose extends Smarty_Internal_Compile_Shared_ */ public function compile($args, Smarty_Internal_TemplateCompilerBase $compiler, $parameter) { - list($_attr, $_nocache, $_buffer, $_has_nocache_code, $_caching) = $this->closeTag($compiler, array('block')); + [$_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' ] ]); @@ -126,14 +127,12 @@ class Smarty_Internal_Compile_Blockclose extends Smarty_Internal_Compile_Shared_ $compiler->parser->current_buffer = new \Smarty\ParseTree\Template(); $output = "cStyleComment(" {block {$_name}} ") . "\n"; - $output .= "class {$_className} extends Smarty_Internal_Block\n"; + $output .= "class {$_className} extends \\Smarty\\Block\n"; $output .= "{\n"; foreach ($_block as $property => $value) { $output .= "public \${$property} = " . var_export($value, true) . ";\n"; } $output .= "public function callBlock(Smarty_Internal_Template \$_smarty_tpl) {\n"; - $output .= $compiler->compileRequiredPlugins(); - $compiler->restoreRequiredPlugins(); if ($compiler->template->compiled->has_nocache_code) { $output .= "\$_smarty_tpl->cached->hashes['{$compiler->template->compiled->nocache_hash}'] = true;\n"; } diff --git a/src/Compile/smarty_internal_compile_config_load.php b/src/Compile/smarty_internal_compile_config_load.php index 8fe64ee1..2a775d56 100644 --- a/src/Compile/smarty_internal_compile_config_load.php +++ b/src/Compile/smarty_internal_compile_config_load.php @@ -54,9 +54,9 @@ class Smarty_Internal_Compile_Config_Load extends Smarty_Internal_CompileBase * @var array */ public $valid_scopes = array( - 'local' => Smarty::SCOPE_LOCAL, 'parent' => Smarty::SCOPE_PARENT, - 'root' => Smarty::SCOPE_ROOT, 'tpl_root' => Smarty::SCOPE_TPL_ROOT, - 'smarty' => Smarty::SCOPE_SMARTY, 'global' => Smarty::SCOPE_SMARTY + 'local' => \Smarty\Smarty::SCOPE_LOCAL, 'parent' => \Smarty\Smarty::SCOPE_PARENT, + 'root' => \Smarty\Smarty::SCOPE_ROOT, 'tpl_root' => \Smarty\Smarty::SCOPE_TPL_ROOT, + 'smarty' => \Smarty\Smarty::SCOPE_SMARTY, 'global' => \Smarty\Smarty::SCOPE_SMARTY ); /** diff --git a/src/Compile/smarty_internal_compile_debug.php b/src/Compile/smarty_internal_compile_debug.php index 79941668..16b63939 100644 --- a/src/Compile/smarty_internal_compile_debug.php +++ b/src/Compile/smarty_internal_compile_debug.php @@ -27,13 +27,14 @@ class Smarty_Internal_Compile_Debug extends Smarty_Internal_CompileBase */ public function compile($args, $compiler) { - // check and get attributes - $_attr = $this->getAttributes($compiler, $args); + // check and get attributes, may trigger errors + $this->getAttributes($compiler, $args); + // compile always as nocache $compiler->tag_nocache = true; // display debug template $_output = - "display_debug(\$_smarty_tpl);\n"; + "display_debug(\$_smarty_tpl);\n"; $_output .= "unset(\$_smarty_debug);\n?>"; return $_output; } diff --git a/src/Compile/smarty_internal_compile_extends.php b/src/Compile/smarty_internal_compile_extends.php index 839005de..ba874ed8 100644 --- a/src/Compile/smarty_internal_compile_extends.php +++ b/src/Compile/smarty_internal_compile_extends.php @@ -8,13 +8,15 @@ * @author Uwe Tews */ +use Smarty\Compile\Inheritance; + /** * Smarty Internal Plugin Compile extend Class * * @package Smarty * @subpackage Compiler */ -class Smarty_Internal_Compile_Extends extends Smarty_Internal_Compile_Shared_Inheritance +class Smarty_Internal_Compile_Extends extends Inheritance { /** * Attribute definition: Overwrites base class. diff --git a/src/Compile/smarty_internal_compile_function.php b/src/Compile/smarty_internal_compile_function.php index c924bd27..da9925a3 100644 --- a/src/Compile/smarty_internal_compile_function.php +++ b/src/Compile/smarty_internal_compile_function.php @@ -72,7 +72,6 @@ class Smarty_Internal_Compile_Function extends Smarty_Internal_CompileBase // Init temporary context $compiler->parser->current_buffer = new \Smarty\ParseTree\Template(); $compiler->template->compiled->has_nocache_code = false; - $compiler->saveRequiredPlugins(true); return true; } } @@ -138,7 +137,6 @@ class Smarty_Internal_Compile_Functionclose extends Smarty_Internal_CompileBase $output .= "if (!function_exists('{$_funcNameCaching}')) {\n"; $output .= "function {$_funcNameCaching} (Smarty_Internal_Template \$_smarty_tpl,\$params) {\n"; $output .= "ob_start();\n"; - $output .= $compiler->compileRequiredPlugins(); $output .= "\$_smarty_tpl->compiled->has_nocache_code = true;\n"; $output .= $_paramsCode; $output .= "foreach (\$params as \$key => \$value) {\n\$_smarty_tpl->tpl_vars[\$key] = new \\Smarty\\Variable(\$value, \$_smarty_tpl->isRenderingCache);\n}\n"; @@ -184,8 +182,6 @@ class Smarty_Internal_Compile_Functionclose extends Smarty_Internal_CompileBase $output .= "function {$_funcName}(Smarty_Internal_Template \$_smarty_tpl,\$params) {\n"; $output .= $_paramsCode; $output .= "foreach (\$params as \$key => \$value) {\n\$_smarty_tpl->tpl_vars[\$key] = new \\Smarty\\Variable(\$value, \$_smarty_tpl->isRenderingCache);\n}\n"; - $output .= $compiler->compileCheckPlugins(array_merge($compiler->required_plugins[ 'compiled' ], - $compiler->required_plugins[ 'nocache' ])); $output .= "?>\n"; $compiler->parser->current_buffer->append_subtree( $compiler->parser, @@ -209,7 +205,6 @@ class Smarty_Internal_Compile_Functionclose extends Smarty_Internal_CompileBase // restore old buffer $compiler->parser->current_buffer = $saved_data[ 1 ]; // restore old status - $compiler->restoreRequiredPlugins(); $compiler->template->compiled->has_nocache_code = $saved_data[ 2 ]; $compiler->template->caching = $saved_data[ 3 ]; return true; diff --git a/src/Compile/smarty_internal_compile_include.php b/src/Compile/smarty_internal_compile_include.php index a5c38635..763bb245 100644 --- a/src/Compile/smarty_internal_compile_include.php +++ b/src/Compile/smarty_internal_compile_include.php @@ -59,9 +59,9 @@ class Smarty_Internal_Compile_Include extends Smarty_Internal_CompileBase * @var array */ public $valid_scopes = array( - 'parent' => Smarty::SCOPE_PARENT, 'root' => Smarty::SCOPE_ROOT, - 'global' => Smarty::SCOPE_GLOBAL, 'tpl_root' => Smarty::SCOPE_TPL_ROOT, - 'smarty' => Smarty::SCOPE_SMARTY + 'parent' => \Smarty\Smarty::SCOPE_PARENT, 'root' => \Smarty\Smarty::SCOPE_ROOT, + 'global' => \Smarty\Smarty::SCOPE_GLOBAL, 'tpl_root' => \Smarty\Smarty::SCOPE_TPL_ROOT, + 'smarty' => \Smarty\Smarty::SCOPE_SMARTY ); /** @@ -127,7 +127,7 @@ class Smarty_Internal_Compile_Include extends Smarty_Internal_CompileBase $_cache_tpl = 'false'; } // assume caching is off - $_caching = Smarty::CACHING_OFF; + $_caching = \Smarty\Smarty::CACHING_OFF; $call_nocache = $compiler->tag_nocache || $compiler->nocache; // caching was on and {include} is not in nocache mode if ($compiler->template->caching && !$compiler->nocache && !$compiler->tag_nocache) { @@ -156,7 +156,7 @@ class Smarty_Internal_Compile_Include extends Smarty_Internal_CompileBase $_caching = $_new_caching = (int)$_attr[ 'caching' ]; $call_nocache = true; } else { - $_new_caching = Smarty::CACHING_LIFETIME_CURRENT; + $_new_caching = \Smarty\Smarty::CACHING_LIFETIME_CURRENT; } if (isset($_attr[ 'cache_lifetime' ])) { $_cache_lifetime = $_attr[ 'cache_lifetime' ]; diff --git a/src/Compile/smarty_internal_compile_private_modifier.php b/src/Compile/smarty_internal_compile_private_modifier.php index aea082f0..1f49643c 100644 --- a/src/Compile/smarty_internal_compile_private_modifier.php +++ b/src/Compile/smarty_internal_compile_private_modifier.php @@ -48,12 +48,12 @@ class Smarty_Internal_Compile_Private_Modifier extends Smarty_Internal_CompileBa switch ($type) { case 1: // registered modifier - if (isset($compiler->smarty->registered_plugins[ Smarty::PLUGIN_MODIFIER ][ $modifier ])) { - if (is_callable($compiler->smarty->registered_plugins[ Smarty::PLUGIN_MODIFIER ][ $modifier ][ 0 ])) { + if (isset($compiler->smarty->registered_plugins[ \Smarty\Smarty::PLUGIN_MODIFIER ][ $modifier ])) { + if (is_callable($compiler->smarty->registered_plugins[ \Smarty\Smarty::PLUGIN_MODIFIER ][ $modifier ][ 0 ])) { $output = sprintf( 'call_user_func_array($_smarty_tpl->registered_plugins[ \'%s\' ][ %s ][ 0 ], array( %s ))', - Smarty::PLUGIN_MODIFIER, + \Smarty\Smarty::PLUGIN_MODIFIER, var_export($modifier, true), $params ); @@ -64,10 +64,10 @@ class Smarty_Internal_Compile_Private_Modifier extends Smarty_Internal_CompileBa break; case 2: // registered modifier compiler - if (isset($compiler->smarty->registered_plugins[ Smarty::PLUGIN_MODIFIERCOMPILER ][ $modifier ][ 0 ])) { + if (isset($compiler->smarty->registered_plugins[ \Smarty\Smarty::PLUGIN_MODIFIERCOMPILER ][ $modifier ][ 0 ])) { $output = call_user_func( - $compiler->smarty->registered_plugins[ Smarty::PLUGIN_MODIFIERCOMPILER ][ $modifier ][ 0 ], + $compiler->smarty->registered_plugins[ \Smarty\Smarty::PLUGIN_MODIFIERCOMPILER ][ $modifier ][ 0 ], $single_modifier, $compiler->smarty ); @@ -77,21 +77,18 @@ class Smarty_Internal_Compile_Private_Modifier extends Smarty_Internal_CompileBa break; case 3: // 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) - ) { - $plugin = 'smarty_modifiercompiler_' . $modifier; - $output = $plugin($single_modifier, $compiler); - } - $compiler->known_modifier_type[ $modifier ] = $type; - break 2; + // check if modifier allowed + if (!is_object($compiler->smarty->security_policy) + || $compiler->smarty->security_policy->isTrustedModifier($modifier, $compiler) + ) { + $plugin = 'smarty_modifiercompiler_' . $modifier; + $output = $plugin($single_modifier, $compiler); } - break; + $compiler->known_modifier_type[ $modifier ] = $type; + break 2; case 4: // modifier plugin - if ($function = $compiler->getPlugin($modifier, Smarty::PLUGIN_MODIFIER)) { + if ($function = $compiler->getPlugin($modifier, \Smarty\Smarty::PLUGIN_MODIFIER)) { // check if modifier allowed if (!is_object($compiler->smarty->security_policy) || $compiler->smarty->security_policy->isTrustedModifier($modifier, $compiler) @@ -120,11 +117,11 @@ 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 ]) + if (isset($compiler->default_handler_plugins[ \Smarty\Smarty::PLUGIN_MODIFIER ][ $modifier ]) || (is_callable($compiler->smarty->default_plugin_handler_func) - && $compiler->getPluginFromDefaultHandler($modifier, Smarty::PLUGIN_MODIFIER)) + && $compiler->getPluginFromDefaultHandler($modifier, \Smarty\Smarty::PLUGIN_MODIFIER)) ) { - $function = $compiler->default_handler_plugins[ Smarty::PLUGIN_MODIFIER ][ $modifier ][ 0 ]; + $function = $compiler->default_handler_plugins[ \Smarty\Smarty::PLUGIN_MODIFIER ][ $modifier ][ 0 ]; // check if modifier allowed if (!is_object($compiler->smarty->security_policy) || $compiler->smarty->security_policy->isTrustedModifier($modifier, $compiler) @@ -139,15 +136,7 @@ class Smarty_Internal_Compile_Private_Modifier extends Smarty_Internal_CompileBa } } } - if (isset($compiler->required_plugins[ 'nocache' ][ $modifier ][ Smarty::PLUGIN_MODIFIER ][ 'file' ]) - || - isset($compiler->required_plugins[ 'compiled' ][ $modifier ][ Smarty::PLUGIN_MODIFIER ][ 'file' ]) - ) { - // was a plugin - $compiler->known_modifier_type[ $modifier ] = 4; - } else { - $compiler->known_modifier_type[ $modifier ] = $type; - } + $compiler->known_modifier_type[ $modifier ] = $type; break 2; } } diff --git a/src/Compile/smarty_internal_compile_private_print_expression.php b/src/Compile/smarty_internal_compile_private_print_expression.php index 96bd3724..69b83b57 100644 --- a/src/Compile/smarty_internal_compile_private_print_expression.php +++ b/src/Compile/smarty_internal_compile_private_print_expression.php @@ -93,25 +93,25 @@ class Smarty_Internal_Compile_Private_Print_Expression extends Smarty_Internal_C } // autoescape html if ($compiler->template->smarty->escape_html) { - $output = "htmlspecialchars((string) {$output}, ENT_QUOTES, '" . addslashes(Smarty::$_CHARSET) . "')"; + $output = "htmlspecialchars((string) {$output}, ENT_QUOTES, '" . addslashes(\Smarty\Smarty::$_CHARSET) . "')"; } // 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 => + if (!empty($compiler->template->smarty->registered_filters[ \Smarty\Smarty::FILTER_VARIABLE ])) { + foreach ($compiler->template->smarty->registered_filters[ \Smarty\Smarty::FILTER_VARIABLE ] as $key => $function) { if (!is_array($function)) { $output = "{$function}({$output},\$_smarty_tpl)"; } elseif (is_object($function[ 0 ])) { $output = - "\$_smarty_tpl->smarty->registered_filters[Smarty::FILTER_VARIABLE]['{$key}'][0]->{$function[1]}({$output},\$_smarty_tpl)"; + "\$_smarty_tpl->smarty->registered_filters[\Smarty\Smarty::FILTER_VARIABLE]['{$key}'][0]->{$function[1]}({$output},\$_smarty_tpl)"; } else { $output = "{$function[0]}::{$function[1]}({$output},\$_smarty_tpl)"; } } } // auto loaded filters - if (isset($compiler->smarty->autoload_filters[ Smarty::FILTER_VARIABLE ])) { - foreach ((array)$compiler->template->smarty->autoload_filters[ Smarty::FILTER_VARIABLE ] as $name) { + if (isset($compiler->smarty->autoload_filters[ \Smarty\Smarty::FILTER_VARIABLE ])) { + foreach ((array)$compiler->template->smarty->autoload_filters[ \Smarty\Smarty::FILTER_VARIABLE ] as $name) { $result = $this->compile_variable_filter($compiler, $name, $output); if ($result !== false) { $output = $result; diff --git a/src/Compile/smarty_internal_compile_private_registered_block.php b/src/Compile/smarty_internal_compile_private_registered_block.php index 0f818d1b..0f4cee2c 100644 --- a/src/Compile/smarty_internal_compile_private_registered_block.php +++ b/src/Compile/smarty_internal_compile_private_registered_block.php @@ -28,8 +28,8 @@ class Smarty_Internal_Compile_Private_Registered_Block extends Smarty_Internal_C */ public function setup(Smarty_Internal_TemplateCompilerBase $compiler, $_attr, $tag, $function) { - if (isset($compiler->smarty->registered_plugins[ Smarty::PLUGIN_BLOCK ][ $tag ])) { - $tag_info = $compiler->smarty->registered_plugins[ Smarty::PLUGIN_BLOCK ][ $tag ]; + if (isset($compiler->smarty->registered_plugins[ \Smarty\Smarty::PLUGIN_BLOCK ][ $tag ])) { + $tag_info = $compiler->smarty->registered_plugins[ \Smarty\Smarty::PLUGIN_BLOCK ][ $tag ]; $callback = $tag_info[ 0 ]; if (is_array($callback)) { if (is_object($callback[ 0 ])) { @@ -46,7 +46,7 @@ class Smarty_Internal_Compile_Private_Registered_Block extends Smarty_Internal_C $callback = array("\$_smarty_tpl->smarty->registered_plugins['block']['{$tag}'][0]", ''); } } else { - $tag_info = $compiler->default_handler_plugins[ Smarty::PLUGIN_BLOCK ][ $tag ]; + $tag_info = $compiler->default_handler_plugins[ \Smarty\Smarty::PLUGIN_BLOCK ][ $tag ]; $callback = $tag_info[ 0 ]; if (is_array($callback)) { $callable = "array('{$callback[0]}', '{$callback[1]}')"; diff --git a/src/Compile/smarty_internal_compile_private_registered_function.php b/src/Compile/smarty_internal_compile_private_registered_function.php index 2591107d..2c560733 100644 --- a/src/Compile/smarty_internal_compile_private_registered_function.php +++ b/src/Compile/smarty_internal_compile_private_registered_function.php @@ -41,11 +41,11 @@ class Smarty_Internal_Compile_Private_Registered_Function extends Smarty_Interna // check and get attributes $_attr = $this->getAttributes($compiler, $args); unset($_attr[ 'nocache' ]); - if (isset($compiler->smarty->registered_plugins[ Smarty::PLUGIN_FUNCTION ][ $tag ])) { - $tag_info = $compiler->smarty->registered_plugins[ Smarty::PLUGIN_FUNCTION ][ $tag ]; + if (isset($compiler->smarty->registered_plugins[ \Smarty\Smarty::PLUGIN_FUNCTION ][ $tag ])) { + $tag_info = $compiler->smarty->registered_plugins[ \Smarty\Smarty::PLUGIN_FUNCTION ][ $tag ]; $is_registered = true; } else { - $tag_info = $compiler->default_handler_plugins[ Smarty::PLUGIN_FUNCTION ][ $tag ]; + $tag_info = $compiler->default_handler_plugins[ \Smarty\Smarty::PLUGIN_FUNCTION ][ $tag ]; $is_registered = false; } // not cacheable? @@ -66,7 +66,7 @@ class Smarty_Internal_Compile_Private_Registered_Function extends Smarty_Interna // compile code if ($is_registered) { $output = - "call_user_func_array( \$_smarty_tpl->smarty->registered_plugins[Smarty::PLUGIN_FUNCTION]['{$tag}'][0], array( {$_params},\$_smarty_tpl ) )"; + "call_user_func_array( \$_smarty_tpl->smarty->registered_plugins[\\Smarty\\Smarty::PLUGIN_FUNCTION]['{$tag}'][0], array( {$_params},\$_smarty_tpl ) )"; } else { $function = $tag_info[ 0 ]; if (!is_array($function)) { diff --git a/src/Compile/smarty_internal_compile_private_special_variable.php b/src/Compile/smarty_internal_compile_private_special_variable.php index 590cba5a..615e5aaa 100644 --- a/src/Compile/smarty_internal_compile_private_special_variable.php +++ b/src/Compile/smarty_internal_compile_private_special_variable.php @@ -89,7 +89,7 @@ class Smarty_Internal_Compile_Private_Special_Variable extends Smarty_Internal_C case 'current_dir': return 'dirname($_smarty_tpl->source->filepath)'; case 'version': - return "Smarty::SMARTY_VERSION"; + return "\\Smarty\\Smarty::SMARTY_VERSION"; case 'const': if (isset($compiler->smarty->security_policy) && !$compiler->smarty->security_policy->allow_constants diff --git a/src/smarty_internal_compilebase.php b/src/Compile/smarty_internal_compilebase.php similarity index 100% rename from src/smarty_internal_compilebase.php rename to src/Compile/smarty_internal_compilebase.php diff --git a/src/smarty_internal_config_file_compiler.php b/src/Compiler/smarty_internal_config_file_compiler.php similarity index 98% rename from src/smarty_internal_config_file_compiler.php rename to src/Compiler/smarty_internal_config_file_compiler.php index cd1d73c9..668f5093 100644 --- a/src/smarty_internal_config_file_compiler.php +++ b/src/Compiler/smarty_internal_config_file_compiler.php @@ -110,7 +110,7 @@ class Smarty_Internal_Config_File_Compiler ); if ($this->smarty->debugging) { if (!isset($this->smarty->_debug)) { - $this->smarty->_debug = new Smarty_Internal_Debug(); + $this->smarty->_debug = new \Smarty\Debug(); } $this->smarty->_debug->start_compile($this->template); } @@ -159,7 +159,7 @@ class Smarty_Internal_Config_File_Compiler // template header code $template_header = sprintf( "\n", - Smarty::SMARTY_VERSION, + \Smarty\Smarty::SMARTY_VERSION, date("Y-m-d H:i:s"), str_replace('*/', '* /' , $this->template->source->filepath) ); diff --git a/src/smarty_internal_smartytemplatecompiler.php b/src/Compiler/smarty_internal_smartytemplatecompiler.php similarity index 100% rename from src/smarty_internal_smartytemplatecompiler.php rename to src/Compiler/smarty_internal_smartytemplatecompiler.php diff --git a/src/smarty_internal_templatecompilerbase.php b/src/Compiler/smarty_internal_templatecompilerbase.php similarity index 86% rename from src/smarty_internal_templatecompilerbase.php rename to src/Compiler/smarty_internal_templatecompilerbase.php index 5587828b..0484c1e1 100644 --- a/src/smarty_internal_templatecompilerbase.php +++ b/src/Compiler/smarty_internal_templatecompilerbase.php @@ -84,20 +84,6 @@ abstract class Smarty_Internal_TemplateCompilerBase */ public $_tag_stack_count = array(); - /** - * Plugins used by template - * - * @var array - */ - public $required_plugins = array('compiled' => array(), 'nocache' => array()); - - /** - * Required plugins stack - * - * @var array - */ - public $required_plugins_stack = array(); - /** * current template * @@ -416,7 +402,7 @@ abstract class Smarty_Internal_TemplateCompilerBase $this->template = $template; if ($this->smarty->debugging) { if (!isset($this->smarty->_debug)) { - $this->smarty->_debug = new Smarty_Internal_Debug(); + $this->smarty->_debug = new \Smarty\Debug(); } $this->smarty->_debug->start_compile($this->template); } @@ -456,9 +442,6 @@ abstract class Smarty_Internal_TemplateCompilerBase $_content = $this->template->source->getContent(); } $_compiled_code = $this->postFilter($this->doCompile($this->preFilter($_content), true)); - if (!empty($this->required_plugins[ 'compiled' ]) || !empty($this->required_plugins[ 'nocache' ])) { - $_compiled_code = 'compileRequiredPlugins() . "?>\n" . $_compiled_code; - } } catch (Exception $e) { if ($this->smarty->debugging) { $this->smarty->_debug->end_compile($this->template); @@ -777,63 +760,15 @@ abstract class Smarty_Internal_TemplateCompilerBase * @param string $plugin_type type of plugin * * @return string call name of function - * @throws \SmartyException */ public function getPlugin($plugin_name, $plugin_type) { - $function = null; - if ($this->caching && ($this->nocache || $this->tag_nocache)) { - if (isset($this->required_plugins[ 'nocache' ][ $plugin_name ][ $plugin_type ])) { - $function = - $this->required_plugins[ 'nocache' ][ $plugin_name ][ $plugin_type ][ 'function' ]; - } elseif (isset($this->required_plugins[ 'compiled' ][ $plugin_name ][ $plugin_type ])) { - $this->required_plugins[ 'nocache' ][ $plugin_name ][ $plugin_type ] = - $this->required_plugins[ 'compiled' ][ $plugin_name ][ $plugin_type ]; - $function = - $this->required_plugins[ 'nocache' ][ $plugin_name ][ $plugin_type ][ 'function' ]; - } - } else { - if (isset($this->required_plugins[ 'compiled' ][ $plugin_name ][ $plugin_type ])) { - $function = - $this->required_plugins[ 'compiled' ][ $plugin_name ][ $plugin_type ][ 'function' ]; - } elseif (isset($this->required_plugins[ 'nocache' ][ $plugin_name ][ $plugin_type ])) { - $this->required_plugins[ 'compiled' ][ $plugin_name ][ $plugin_type ] = - $this->required_plugins[ 'nocache' ][ $plugin_name ][ $plugin_type ]; - $function = - $this->required_plugins[ 'compiled' ][ $plugin_name ][ $plugin_type ][ 'function' ]; - } - } - if (isset($function)) { - if ($plugin_type === 'modifier') { - $this->modifier_plugins[ $plugin_name ] = true; - } - return $function; - } // loop through plugin dirs and find the plugin $function = 'smarty_' . $plugin_type . '_' . $plugin_name; - $file = $this->smarty->loadPlugin($function, false); - if (is_string($file)) { - if ($this->caching && ($this->nocache || $this->tag_nocache)) { - $this->required_plugins[ 'nocache' ][ $plugin_name ][ $plugin_type ][ 'file' ] = - $file; - $this->required_plugins[ 'nocache' ][ $plugin_name ][ $plugin_type ][ 'function' ] = - $function; - } else { - $this->required_plugins[ 'compiled' ][ $plugin_name ][ $plugin_type ][ 'file' ] = - $file; - $this->required_plugins[ 'compiled' ][ $plugin_name ][ $plugin_type ][ 'function' ] = - $function; - } - if ($plugin_type === 'modifier') { - $this->modifier_plugins[ $plugin_name ] = true; - } - return $function; + if ($plugin_type === 'modifier') { + $this->modifier_plugins[ $plugin_name ] = true; } - if (is_callable($function)) { - // plugin function is defined in the script - return $function; - } - return false; + return $function; } /** @@ -865,17 +800,6 @@ abstract class Smarty_Internal_TemplateCompilerBase $this->tag_nocache = $this->tag_nocache || !$cacheable; if ($script !== null) { if (is_file($script)) { - if ($this->caching && ($this->nocache || $this->tag_nocache)) { - $this->required_plugins[ 'nocache' ][ $tag ][ $plugin_type ][ 'file' ] = - $script; - $this->required_plugins[ 'nocache' ][ $tag ][ $plugin_type ][ 'function' ] = - $callback; - } else { - $this->required_plugins[ 'compiled' ][ $tag ][ $plugin_type ][ 'file' ] = - $script; - $this->required_plugins[ 'compiled' ][ $tag ][ $plugin_type ][ 'function' ] = - $callback; - } include_once $script; } else { $this->trigger_template_error("Default plugin handler: Returned script file '{$script}' for '{$tag}' not found"); @@ -938,13 +862,6 @@ abstract class Smarty_Internal_TemplateCompilerBase $_output = str_replace('^#^', '\'', $_output); $_output = "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->required_plugins[ 'compiled' ][ $plugin_name ][ 'modifier' ])) { - $this->required_plugins[ 'nocache' ][ $plugin_name ][ 'modifier' ] = - $this->required_plugins[ 'compiled' ][ $plugin_name ][ 'modifier' ]; - } - } } else { $_output = $content; } @@ -1363,65 +1280,6 @@ abstract class Smarty_Internal_TemplateCompilerBase return $code; } - /** - * Save current required plugins - * - * @param bool $init if true init required plugins - */ - public function saveRequiredPlugins($init = false) - { - $this->required_plugins_stack[] = $this->required_plugins; - if ($init) { - $this->required_plugins = array('compiled' => array(), 'nocache' => array()); - } - } - - /** - * Restore required plugins - */ - public function restoreRequiredPlugins() - { - $this->required_plugins = array_pop($this->required_plugins_stack); - } - - /** - * Compile code to call Smarty_Internal_Template::_checkPlugins() - * for required plugins - * - * @return string - */ - public function compileRequiredPlugins() - { - $code = $this->compileCheckPlugins($this->required_plugins[ 'compiled' ]); - if ($this->caching && !empty($this->required_plugins[ 'nocache' ])) { - $code .= $this->makeNocacheCode($this->compileCheckPlugins($this->required_plugins[ 'nocache' ])); - } - return $code; - } - - /** - * Compile code to call Smarty_Internal_Template::_checkPlugins - * - checks if plugin is callable require otherwise - * - * @param $requiredPlugins - * - * @return string - */ - public function compileCheckPlugins($requiredPlugins) - { - if (!empty($requiredPlugins)) { - $plugins = array(); - foreach ($requiredPlugins as $plugin) { - foreach ($plugin as $data) { - $plugins[] = $data; - } - } - return '$_smarty_tpl->_checkPlugins(' . $this->getVarExport($plugins) . ');' . "\n"; - } else { - return ''; - } - } - /** * method to compile a Smarty template * @@ -1528,13 +1386,13 @@ abstract class Smarty_Internal_TemplateCompilerBase } // check if tag is registered foreach (array( - Smarty::PLUGIN_COMPILER, - Smarty::PLUGIN_FUNCTION, - Smarty::PLUGIN_BLOCK, + \Smarty\Smarty::PLUGIN_COMPILER, + \Smarty\Smarty::PLUGIN_FUNCTION, + \Smarty\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) { + if ($plugin_type === \Smarty\Smarty::PLUGIN_COMPILER) { $new_args = array(); foreach ($args as $key => $mixed) { if (is_array($mixed)) { @@ -1555,7 +1413,7 @@ abstract class Smarty_Internal_TemplateCompilerBase ); } // compile registered function or block function - if ($plugin_type === Smarty::PLUGIN_FUNCTION || $plugin_type === Smarty::PLUGIN_BLOCK) { + if ($plugin_type === \Smarty\Smarty::PLUGIN_FUNCTION || $plugin_type === \Smarty\Smarty::PLUGIN_BLOCK) { return $this->callTagCompiler( 'private_registered_' . $plugin_type, $args, @@ -1567,8 +1425,7 @@ abstract class Smarty_Internal_TemplateCompilerBase } // check plugins from plugins folder foreach ($this->plugin_search_order as $plugin_type) { - if ($plugin_type === Smarty::PLUGIN_COMPILER - && $this->smarty->loadPlugin('smarty_compiler_' . $tag) + if ($plugin_type === \Smarty\Smarty::PLUGIN_COMPILER && (!isset($this->smarty->security_policy) || $this->smarty->security_policy->isTrustedTag($tag, $this)) ) { @@ -1628,7 +1485,7 @@ abstract class Smarty_Internal_TemplateCompilerBase } if ($found) { // if compiler function plugin call it now - if ($plugin_type === Smarty::PLUGIN_COMPILER) { + if ($plugin_type === \Smarty\Smarty::PLUGIN_COMPILER) { $new_args = array(); foreach ($args as $key => $mixed) { if (is_array($mixed)) { @@ -1679,21 +1536,21 @@ abstract class Smarty_Internal_TemplateCompilerBase } } // 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\Smarty::PLUGIN_BLOCK ][ $base_tag ]) + || isset($this->default_handler_plugins[ \Smarty\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 ])) { + if (isset($this->smarty->registered_plugins[ \Smarty\Smarty::PLUGIN_FUNCTION ][ $tag ])) { return $this->callTagCompiler('private_registered_function', $args, $parameter, $tag); } // block plugin? - if ($function = $this->getPlugin($base_tag, Smarty::PLUGIN_BLOCK)) { + if ($function = $this->getPlugin($base_tag, \Smarty\Smarty::PLUGIN_BLOCK)) { return $this->callTagCompiler('private_block_plugin', $args, $parameter, $tag, $function); } // function plugin? - if ($function = $this->getPlugin($tag, Smarty::PLUGIN_FUNCTION)) { + if ($function = $this->getPlugin($tag, \Smarty\Smarty::PLUGIN_FUNCTION)) { if (!isset($this->smarty->security_policy) || $this->smarty->security_policy->isTrustedTag($tag, $this) ) { @@ -1701,33 +1558,31 @@ abstract class Smarty_Internal_TemplateCompilerBase } } // registered compiler plugin ? - if (isset($this->smarty->registered_plugins[ Smarty::PLUGIN_COMPILER ][ $tag ])) { + if (isset($this->smarty->registered_plugins[ \Smarty\Smarty::PLUGIN_COMPILER ][ $tag ])) { // if compiler function plugin call it now $args = array(); - if (!$this->smarty->registered_plugins[ Smarty::PLUGIN_COMPILER ][ $tag ][ 1 ]) { + if (!$this->smarty->registered_plugins[ \Smarty\Smarty::PLUGIN_COMPILER ][ $tag ][ 1 ]) { $this->tag_nocache = true; } return call_user_func_array( - $this->smarty->registered_plugins[ Smarty::PLUGIN_COMPILER ][ $tag ][ 0 ], + $this->smarty->registered_plugins[ \Smarty\Smarty::PLUGIN_COMPILER ][ $tag ][ 0 ], array( $args, $this ) ); } - if ($this->smarty->loadPlugin('smarty_compiler_' . $tag)) { - $plugin = 'smarty_compiler_' . $tag; - if (is_callable($plugin)) { - return $plugin($args, $this->smarty); - } - if (class_exists($plugin, false)) { - $plugin_object = new $plugin; - if (method_exists($plugin_object, 'compile')) { - return $plugin_object->compile($args, $this); - } - } - throw new SmartyException("Plugin '{$tag}' not callable"); + $plugin = 'smarty_compiler_' . $tag; + if (is_callable($plugin)) { + return $plugin($args, $this->smarty); } + if (class_exists($plugin, false)) { + $plugin_object = new $plugin; + if (method_exists($plugin_object, 'compile')) { + return $plugin_object->compile($args, $this); + } + } + throw new SmartyException("Plugin '{$tag}' not callable"); } $this->trigger_template_error("unknown tag '{$tag}'", null, true); } diff --git a/src/smarty_internal_debug.php b/src/Debug.php similarity index 80% rename from src/smarty_internal_debug.php rename to src/Debug.php index 092f3a5d..07da997a 100644 --- a/src/smarty_internal_debug.php +++ b/src/Debug.php @@ -1,4 +1,7 @@ _isSubTpl()) { $this->index++; @@ -66,12 +69,11 @@ class Smarty_Internal_Debug extends \Smarty\Data * * @param \Smarty_Internal_Template $template cached template */ - public function end_template(Smarty_Internal_Template $template) + public function end_template(\Smarty_Internal_Template $template) { $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; } /** @@ -79,21 +81,13 @@ class Smarty_Internal_Debug extends \Smarty\Data * * @param \Smarty_Internal_Template $template */ - public 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($this->template_data[ $this->index ][ $key ])) { - if (isset($_is_stringy[ $template->source->type ])) { - $this->template_data[ $this->index ][ $key ][ 'name' ] = - '\'' . substr($template->source->name, 0, 25) . '...\''; - } else { - $this->template_data[ $this->index ][ $key ][ 'name' ] = $template->source->filepath; - } - $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->saveTemplateData($_is_stringy, $template, $key); } } else { if (isset($this->ignore_uid[ $template->source->uid ])) { @@ -109,7 +103,7 @@ class Smarty_Internal_Debug extends \Smarty\Data * * @param \Smarty_Internal_Template $template */ - public 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; @@ -128,7 +122,7 @@ class Smarty_Internal_Debug extends \Smarty\Data * * @param \Smarty_Internal_Template $template */ - public function start_render(Smarty_Internal_Template $template) + public function start_render(\Smarty_Internal_Template $template) { $key = $this->get_key($template); $this->template_data[ $this->index ][ $key ][ 'start_time' ] = microtime(true); @@ -139,7 +133,7 @@ class Smarty_Internal_Debug extends \Smarty\Data * * @param \Smarty_Internal_Template $template */ - public function end_render(Smarty_Internal_Template $template) + public function end_render(\Smarty_Internal_Template $template) { $key = $this->get_key($template); $this->template_data[ $this->index ][ $key ][ 'render_time' ] += @@ -151,7 +145,7 @@ class Smarty_Internal_Debug extends \Smarty\Data * * @param \Smarty_Internal_Template $template cached template */ - public function start_cache(Smarty_Internal_Template $template) + public function start_cache(\Smarty_Internal_Template $template) { $key = $this->get_key($template); $this->template_data[ $this->index ][ $key ][ 'start_time' ] = microtime(true); @@ -162,7 +156,7 @@ class Smarty_Internal_Debug extends \Smarty\Data * * @param \Smarty_Internal_Template $template cached template */ - public function end_cache(Smarty_Internal_Template $template) + public function end_cache(\Smarty_Internal_Template $template) { $key = $this->get_key($template); $this->template_data[ $this->index ][ $key ][ 'cache_time' ] += @@ -174,23 +168,23 @@ class Smarty_Internal_Debug extends \Smarty\Data * * @param \Smarty_Internal_Template $template cached template */ - public function register_template(Smarty_Internal_Template $template) + public function register_template(\Smarty_Internal_Template $template) { } /** * Register data object * - * @param \Smarty_Data $data data object + * @param Data $data data object */ - public static function register_data(Smarty_Data $data) + public static function register_data(Data $data) { } /** * Opens a window for the Smarty Debugging Console and display the data * - * @param Smarty_Internal_Template|Smarty $obj object to debug + * @param \Smarty_Internal_Template|\Smarty $obj object to debug * @param bool $full * * @throws \Exception @@ -206,14 +200,11 @@ class Smarty_Internal_Debug extends \Smarty\Data $smarty = $obj->_getSmartyObj(); // create fresh instance of smarty for displaying the debug console // to avoid problems if the application did overload the Smarty class - $debObj = new Smarty(); + $debObj = new \Smarty(); // copy the working dirs from application $debObj->setCompileDir($smarty->getCompileDir()); - // init properties by hand as user may have edited the original Smarty class - $debObj->setPluginsDir(is_dir(__DIR__ . '/../plugins') ? __DIR__ . - '/../plugins' : $smarty->getPluginsDir()); $debObj->force_compile = false; - $debObj->compile_check = Smarty::COMPILECHECK_ON; + $debObj->compile_check = \Smarty::COMPILECHECK_ON; $debObj->left_delimiter = '{'; $debObj->right_delimiter = '}'; $debObj->security_policy = null; @@ -228,7 +219,7 @@ class Smarty_Internal_Debug extends \Smarty\Data $debObj->autoload_filters = array(); $debObj->default_modifiers = array(); $debObj->escape_html = true; - $debObj->caching = Smarty::CACHING_OFF; + $debObj->caching = \Smarty::CACHING_OFF; $debObj->compile_id = null; $debObj->cache_id = null; // prepare information of assigned variables @@ -238,7 +229,7 @@ class Smarty_Internal_Debug extends \Smarty\Data $_config_vars = $ptr->config_vars; ksort($_config_vars); $debugging = $smarty->debugging; - $_template = new Smarty_Internal_Template($debObj->debug_tpl, $debObj); + $_template = new \Smarty_Internal_Template($debObj->debug_tpl, $debObj); if ($obj->_isTplObj()) { $_template->assign('template_name', $obj->source->type . ':' . $obj->source->name); } @@ -264,9 +255,9 @@ class Smarty_Internal_Debug extends \Smarty\Data /** * Recursively gets variables from all template/data scopes * - * @param Smarty_Internal_Template|Smarty_Data $obj object to debug + * @param \Smarty_Internal_Template|\Smarty_Data $obj object to debug * - * @return StdClass + * @return \StdClass */ public function get_debug_vars($obj) { @@ -321,7 +312,7 @@ class Smarty_Internal_Debug extends \Smarty\Data } $config_vars = array_merge($parent->config_vars, $config_vars); } else { - foreach (Smarty::$global_tpl_vars as $key => $var) { + foreach (\Smarty\Smarty::$global_tpl_vars as $key => $var) { if (!array_key_exists($key, $tpl_vars)) { foreach ($var as $varkey => $varvalue) { if ($varkey === 'value') { @@ -352,7 +343,7 @@ class Smarty_Internal_Debug extends \Smarty\Data * * @return string key into $template_data */ - private 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 @@ -363,16 +354,8 @@ class Smarty_Internal_Debug extends \Smarty\Data if (isset($this->template_data[ $this->index ][ $key ])) { return $key; } else { - if (isset($_is_stringy[ $template->source->type ])) { - $this->template_data[ $this->index ][ $key ][ 'name' ] = - '\'' . substr($template->source->name, 0, 25) . '...\''; - } else { - $this->template_data[ $this->index ][ $key ][ 'name' ] = $template->source->filepath; - } - $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; + $this->saveTemplateData($_is_stringy, $template, $key); + $this->template_data[ $this->index ][ $key ][ 'total_time' ] = 0; return $key; } } @@ -382,7 +365,7 @@ class Smarty_Internal_Debug extends \Smarty\Data * * @param \Smarty_Internal_Template $template */ - public function ignore(Smarty_Internal_Template $template) + public function ignore(\Smarty_Internal_Template $template) { // calculate Uid if not already done if ($template->source->uid === '') { @@ -394,9 +377,9 @@ class Smarty_Internal_Debug extends \Smarty\Data /** * handle 'URL' debugging mode * - * @param Smarty $smarty + * @param \Smarty $smarty */ - public function debugUrl(Smarty $smarty) + public function debugUrl(\Smarty $smarty) { if (isset($_SERVER[ 'QUERY_STRING' ])) { $_query_string = $_SERVER[ 'QUERY_STRING' ]; @@ -422,4 +405,23 @@ class Smarty_Internal_Debug extends \Smarty\Data } } } + + /** + * @param array $_is_stringy + * @param \Smarty_Internal_Template $template + * @param string $key + * + * @return void + */ + private function saveTemplateData(array $_is_stringy, \Smarty_Internal_Template $template, string $key): void { + if (isset($_is_stringy[$template->source->type])) { + $this->template_data[$this->index][$key]['name'] = + '\'' . substr($template->source->name, 0, 25) . '...\''; + } else { + $this->template_data[$this->index][$key]['name'] = $template->source->filepath; + } + $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; + } } diff --git a/src/smarty_internal_errorhandler.php b/src/ErrorHandler.php similarity index 98% rename from src/smarty_internal_errorhandler.php rename to src/ErrorHandler.php index f57cc21f..815038c7 100644 --- a/src/smarty_internal_errorhandler.php +++ b/src/ErrorHandler.php @@ -1,5 +1,7 @@ _isTplObj()) { - $ptr->tpl_vars[ $varName ] = clone Smarty::$global_tpl_vars[ $varName ]; + $ptr->tpl_vars[ $varName ] = clone \Smarty\Smarty::$global_tpl_vars[ $varName ]; $ptr = $ptr->parent; } } diff --git a/src/Method/smarty_internal_method_clearallcache.php b/src/Method/smarty_internal_method_clearallcache.php index b74d3058..b33bb310 100644 --- a/src/Method/smarty_internal_method_clearallcache.php +++ b/src/Method/smarty_internal_method_clearallcache.php @@ -35,7 +35,7 @@ class Smarty_Internal_Method_ClearAllCache { $smarty->_clearTemplateCache(); // load cache resource and call clearAll - $_cache_resource = Smarty_CacheResource::load($smarty, $type); + $_cache_resource = \Smarty\Cacheresource\Base::load($smarty, $type); return $_cache_resource->clearAll($smarty, $exp_time); } } diff --git a/src/Method/smarty_internal_method_clearcache.php b/src/Method/smarty_internal_method_clearcache.php index df766eee..d6ed15c2 100644 --- a/src/Method/smarty_internal_method_clearcache.php +++ b/src/Method/smarty_internal_method_clearcache.php @@ -44,7 +44,7 @@ class Smarty_Internal_Method_ClearCache ) { $smarty->_clearTemplateCache(); // load cache resource and call clear - $_cache_resource = Smarty_CacheResource::load($smarty, $type); + $_cache_resource = \Smarty\Cacheresource\Base::load($smarty, $type); return $_cache_resource->clear($smarty, $template_name, $cache_id, $compile_id, $exp_time); } } diff --git a/src/Method/smarty_internal_method_clearcompiledtemplate.php b/src/Method/smarty_internal_method_clearcompiledtemplate.php index db0a49b0..c6cf03b7 100644 --- a/src/Method/smarty_internal_method_clearcompiledtemplate.php +++ b/src/Method/smarty_internal_method_clearcompiledtemplate.php @@ -44,7 +44,7 @@ class Smarty_Internal_Method_ClearCompiledTemplate $_dir_sep = $smarty->use_sub_dirs ? DIRECTORY_SEPARATOR : '^'; if (isset($resource_name)) { $_save_stat = $smarty->caching; - $smarty->caching = Smarty::CACHING_OFF; + $smarty->caching = \Smarty\Smarty::CACHING_OFF; /* @var Smarty_Internal_Template $tpl */ $tpl = $smarty->createTemplate($resource_name); $smarty->caching = $_save_stat; diff --git a/src/Method/smarty_internal_method_compilealltemplates.php b/src/Method/smarty_internal_method_compilealltemplates.php index 5c046da4..92daef68 100644 --- a/src/Method/smarty_internal_method_compilealltemplates.php +++ b/src/Method/smarty_internal_method_compilealltemplates.php @@ -99,7 +99,7 @@ class Smarty_Internal_Method_CompileAllTemplates try { /* @var Smarty_Internal_Template $_tpl */ $_tpl = new $smarty->template_class($_file, $_smarty); - $_tpl->caching = Smarty::CACHING_OFF; + $_tpl->caching = \Smarty\Smarty::CACHING_OFF; $_tpl->source = $isConfig ? Smarty_Template_Config::load($_tpl) : Smarty_Template_Source::load($_tpl); if ($_tpl->mustCompile()) { diff --git a/src/Method/smarty_internal_method_configload.php b/src/Method/smarty_internal_method_configload.php index 2d67b7f7..201e8301 100644 --- a/src/Method/smarty_internal_method_configload.php +++ b/src/Method/smarty_internal_method_configload.php @@ -59,7 +59,7 @@ class Smarty_Internal_Method_ConfigLoad $smarty = $data->_getSmartyObj(); /* @var \Smarty_Internal_Template $confObj */ $confObj = new Smarty_Internal_Template($config_file, $smarty, $data, null, null, null, null, true); - $confObj->caching = Smarty::CACHING_OFF; + $confObj->caching = \Smarty\Smarty::CACHING_OFF; $confObj->source->config_sections = $sections; $confObj->source->scope = $scope; $confObj->compiled = Smarty_Template_Compiled::load($confObj); @@ -81,7 +81,7 @@ class Smarty_Internal_Method_ConfigLoad $this->_assignConfigVars($tpl->parent->config_vars, $tpl, $new_config_vars); $tagScope = $tpl->source->scope; if ($tagScope >= 0) { - if ($tagScope === Smarty::SCOPE_LOCAL) { + if ($tagScope === \Smarty\Smarty::SCOPE_LOCAL) { $this->_updateVarStack($tpl, $new_config_vars); $tagScope = 0; if (!$tpl->scope) { diff --git a/src/Method/smarty_internal_method_createdata.php b/src/Method/smarty_internal_method_createdata.php index 70f009fa..8b264810 100644 --- a/src/Method/smarty_internal_method_createdata.php +++ b/src/Method/smarty_internal_method_createdata.php @@ -37,7 +37,7 @@ class Smarty_Internal_Method_CreateData $smarty = $obj->_getSmartyObj(); $dataObj = new Smarty_Data($parent, $smarty, $name); if ($smarty->debugging) { - Smarty_Internal_Debug::register_data($dataObj); + \Smarty\Debug::register_data($dataObj); } return $dataObj; } diff --git a/src/Method/smarty_internal_method_getglobal.php b/src/Method/smarty_internal_method_getglobal.php index bb3aef3e..df95db81 100644 --- a/src/Method/smarty_internal_method_getglobal.php +++ b/src/Method/smarty_internal_method_getglobal.php @@ -31,14 +31,14 @@ class Smarty_Internal_Method_GetGlobal public function getGlobal(\Smarty\Data $data, $varName = null) { if (isset($varName)) { - if (isset(Smarty::$global_tpl_vars[ $varName ])) { - return Smarty::$global_tpl_vars[ $varName ]->value; + if (isset(\Smarty\Smarty::$global_tpl_vars[ $varName ])) { + return \Smarty\Smarty::$global_tpl_vars[ $varName ]->value; } else { return ''; } } else { $_result = array(); - foreach (Smarty::$global_tpl_vars as $key => $var) { + foreach (\Smarty\Smarty::$global_tpl_vars as $key => $var) { $_result[ $key ] = $var->value; } return $_result; diff --git a/src/Method/smarty_internal_method_gettemplatevars.php b/src/Method/smarty_internal_method_gettemplatevars.php index 0c850014..560bcdad 100644 --- a/src/Method/smarty_internal_method_gettemplatevars.php +++ b/src/Method/smarty_internal_method_gettemplatevars.php @@ -62,8 +62,8 @@ class Smarty_Internal_Method_GetTemplateVars $_ptr = null; } } - if ($searchParents && isset(Smarty::$global_tpl_vars)) { - foreach (Smarty::$global_tpl_vars as $key => $var) { + if ($searchParents && isset(\Smarty\Smarty::$global_tpl_vars)) { + foreach (\Smarty\Smarty::$global_tpl_vars as $key => $var) { if (!array_key_exists($key, $_result)) { $_result[ $key ] = $var->value; } @@ -106,9 +106,9 @@ class Smarty_Internal_Method_GetTemplateVars $_ptr = null; } } - if (isset(Smarty::$global_tpl_vars[ $varName ])) { + if (isset(\Smarty\Smarty::$global_tpl_vars[ $varName ])) { // found it, return it - return Smarty::$global_tpl_vars[ $varName ]; + return \Smarty\Smarty::$global_tpl_vars[ $varName ]; } if ($errorEnable && $data->_getSmartyObj()->error_unassigned) { // force a notice diff --git a/src/Method/smarty_internal_method_loadfilter.php b/src/Method/smarty_internal_method_loadfilter.php index af788a24..2efac815 100644 --- a/src/Method/smarty_internal_method_loadfilter.php +++ b/src/Method/smarty_internal_method_loadfilter.php @@ -49,14 +49,12 @@ class Smarty_Internal_Method_LoadFilter $smarty->registered_filters[ $type ][ $_filter_name ] = $_plugin; return true; } - 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; - } + 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 found or callable"); } diff --git a/src/Method/smarty_internal_method_loadplugin.php b/src/Method/smarty_internal_method_loadplugin.php deleted file mode 100644 index 6ddcaec9..00000000 --- a/src/Method/smarty_internal_method_loadplugin.php +++ /dev/null @@ -1,111 +0,0 @@ -loadPlugin() method - * - * @package Smarty - * @subpackage PluginsInternal - * @author Uwe Tews - */ -class Smarty_Internal_Method_LoadPlugin -{ - /** - * Cache of searched plugin files - * - * @var array - */ - public $plugin_files = array(); - - /** - * Takes unknown classes and loads plugin files for them - * class name format: Smarty_PluginType_PluginName - * plugin filename format: plugintype.pluginname.php - * - * @param \Smarty $smarty - * @param string $plugin_name class plugin name to load - * @param bool $check check if already loaded - * - * @return bool|string - * @throws \SmartyException - */ - public function loadPlugin(Smarty $smarty, $plugin_name, $check) - { - // if function or class exists, exit silently (already loaded) - if ($check && (is_callable($plugin_name) || class_exists($plugin_name, false))) { - return true; - } - if (!preg_match('#^smarty_((internal)|([^_]+))_(.+)$#i', $plugin_name, $match)) { - throw new SmartyException("plugin {$plugin_name} is not a valid name format"); - } - if (!empty($match[ 2 ])) { - $file = SMARTY_SYSPLUGINS_DIR . smarty_strtolower_ascii($plugin_name) . '.php'; - if (isset($this->plugin_files[ $file ])) { - if ($this->plugin_files[ $file ] !== false) { - return $this->plugin_files[ $file ]; - } else { - return false; - } - } else { - if (is_file($file)) { - $this->plugin_files[ $file ] = $file; - include_once $file; - return $file; - } else { - $this->plugin_files[ $file ] = false; - return false; - } - } - } - // plugin filename is expected to be: [type].[name].php - $_plugin_filename = "{$match[1]}.{$match[4]}.php"; - $_lower_filename = smarty_strtolower_ascii($_plugin_filename); - if (isset($this->plugin_files)) { - if (isset($this->plugin_files[ 'plugins_dir' ][ $_lower_filename ])) { - if (!$smarty->use_include_path || $this->plugin_files[ 'plugins_dir' ][ $_lower_filename ] !== false) { - return $this->plugin_files[ 'plugins_dir' ][ $_lower_filename ]; - } - } - if (!$smarty->use_include_path || $smarty->ext->_getIncludePath->isNewIncludePath($smarty)) { - unset($this->plugin_files[ 'include_path' ]); - } else { - if (isset($this->plugin_files[ 'include_path' ][ $_lower_filename ])) { - return $this->plugin_files[ 'include_path' ][ $_lower_filename ]; - } - } - } - $_file_names = array($_plugin_filename); - if ($_lower_filename !== $_plugin_filename) { - $_file_names[] = $_lower_filename; - } - $_p_dirs = $smarty->getPluginsDir(); - if (!isset($this->plugin_files[ 'plugins_dir' ][ $_lower_filename ])) { - // loop through plugin dirs and find the plugin - foreach ($_p_dirs as $_plugin_dir) { - foreach ($_file_names as $name) { - $file = $_plugin_dir . $name; - if (is_file($file)) { - $this->plugin_files[ 'plugins_dir' ][ $_lower_filename ] = $file; - include_once $file; - return $file; - } - $this->plugin_files[ 'plugins_dir' ][ $_lower_filename ] = false; - } - } - } - if ($smarty->use_include_path) { - foreach ($_file_names as $_file_name) { - // try PHP include_path - $file = $smarty->ext->_getIncludePath->getIncludePath($_p_dirs, $_file_name, $smarty); - $this->plugin_files[ 'include_path' ][ $_lower_filename ] = $file; - if ($file !== false) { - include_once $file; - return $file; - } - } - } - // no plugin loaded - return false; - } -} diff --git a/src/Method/smarty_internal_method_registercacheresource.php b/src/Method/smarty_internal_method_registercacheresource.php index 5608b3fd..ce2e735c 100644 --- a/src/Method/smarty_internal_method_registercacheresource.php +++ b/src/Method/smarty_internal_method_registercacheresource.php @@ -26,14 +26,14 @@ class Smarty_Internal_Method_RegisterCacheResource * * @param \Smarty_Internal_TemplateBase|\Smarty_Internal_Template|\Smarty $obj * @param string $name name of resource type - * @param \Smarty_CacheResource $resource_handler + * @param \Smarty\Cacheresource\Base $resource_handler * * @return \Smarty|\Smarty_Internal_Template */ public function registerCacheResource( Smarty_Internal_TemplateBase $obj, $name, - Smarty_CacheResource $resource_handler + \Smarty\Cacheresource\Base $resource_handler ) { $smarty = $obj->_getSmartyObj(); $smarty->registered_cache_resources[ $name ] = $resource_handler; diff --git a/lexer/smarty_internal_configfileparser.y b/src/Parser/smarty_internal_configfileparser.y similarity index 96% rename from lexer/smarty_internal_configfileparser.y rename to src/Parser/smarty_internal_configfileparser.y index c981b58e..3996676c 100644 --- a/lexer/smarty_internal_configfileparser.y +++ b/src/Parser/smarty_internal_configfileparser.y @@ -1,3 +1,8 @@ + +namespace Smarty\Parser; + +use \Smarty\Lexer\Configfile as Lexer; + /** * Smarty Internal Plugin Configfileparser * @@ -19,7 +24,7 @@ * @subpackage Compiler * @author Uwe Tews */ -class Smarty_Internal_Configfileparser +class Configfile } %include_class { @@ -42,7 +47,7 @@ class Smarty_Internal_Configfileparser /** * lexer object * - * @var Smarty_Internal_Configfilelexer + * @var Lexer */ private $lex; /** @@ -86,10 +91,10 @@ class Smarty_Internal_Configfileparser /** * constructor * - * @param Smarty_Internal_Configfilelexer $lex + * @param Lexer $lex * @param Smarty_Internal_Config_File_Compiler $compiler */ - public function __construct(Smarty_Internal_Configfilelexer $lex, Smarty_Internal_Config_File_Compiler $compiler) + public function __construct(Lexer $lex, Smarty_Internal_Config_File_Compiler $compiler) { $this->lex = $lex; $this->smarty = $compiler->smarty; diff --git a/lexer/smarty_internal_templateparser.y b/src/Parser/smarty_internal_templateparser.y similarity index 100% rename from lexer/smarty_internal_templateparser.y rename to src/Parser/smarty_internal_templateparser.y diff --git a/src/Resource/Base.php b/src/Resource/Base.php index 4aceed7b..0278908c 100644 --- a/src/Resource/Base.php +++ b/src/Resource/Base.php @@ -84,20 +84,18 @@ abstract class Base } // try plugins dir $_resource_class = 'Smarty_Resource_' . \smarty_ucfirst_ascii($type); - if ($smarty->loadPlugin($_resource_class)) { - if (class_exists($_resource_class, false)) { - return $smarty->_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" - ) - ); - // give it another try, now that the resource is registered properly - return self::load($smarty, $type); - } + if (class_exists($_resource_class, false)) { + return $smarty->_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" + ) + ); + // give it another try, now that the resource is registered properly + return self::load($smarty, $type); } // try streams $_known_stream = stream_get_wrappers(); diff --git a/src/Runtime/smarty_internal_runtime_cacheresourcefile.php b/src/Runtime/smarty_internal_runtime_cacheresourcefile.php index 28709643..93e46513 100644 --- a/src/Runtime/smarty_internal_runtime_cacheresourcefile.php +++ b/src/Runtime/smarty_internal_runtime_cacheresourcefile.php @@ -48,7 +48,7 @@ class Smarty_Internal_Runtime_CacheResourceFile } if (isset($resource_name)) { $_save_stat = $smarty->caching; - $smarty->caching = Smarty::CACHING_LIFETIME_CURRENT; + $smarty->caching = \Smarty\Smarty::CACHING_LIFETIME_CURRENT; $tpl = new $smarty->template_class($resource_name, $smarty); $smarty->caching = $_save_stat; // remove from template cache diff --git a/src/Runtime/smarty_internal_runtime_filterhandler.php b/src/Runtime/smarty_internal_runtime_filterhandler.php index 9f868e1a..b54dd932 100644 --- a/src/Runtime/smarty_internal_runtime_filterhandler.php +++ b/src/Runtime/smarty_internal_runtime_filterhandler.php @@ -40,7 +40,7 @@ class Smarty_Internal_Runtime_FilterHandler $callback = $plugin_name; } elseif (class_exists($plugin_name, false) && is_callable(array($plugin_name, 'execute'))) { $callback = array($plugin_name, 'execute'); - } elseif ($template->smarty->loadPlugin($plugin_name, false)) { + } else { if (function_exists($plugin_name)) { // use loaded Smarty2 style plugin $callback = $plugin_name; @@ -50,9 +50,6 @@ class Smarty_Internal_Runtime_FilterHandler } else { throw new SmartyException("Auto load {$type}-filter plugin method '{$plugin_name}::execute' not callable"); } - } else { - // nothing found, throw exception - throw new SmartyException("Unable to auto load {$type}-filter plugin '{$plugin_name}'"); } $content = call_user_func($callback, $content, $template); } diff --git a/src/Runtime/smarty_internal_runtime_inheritance.php b/src/Runtime/smarty_internal_runtime_inheritance.php index 8f7f02d5..5bd65e1f 100644 --- a/src/Runtime/smarty_internal_runtime_inheritance.php +++ b/src/Runtime/smarty_internal_runtime_inheritance.php @@ -24,7 +24,7 @@ class Smarty_Internal_Runtime_Inheritance /** * Array of root child {block} objects * - * @var Smarty_Internal_Block[] + * @var \Smarty\Block[] */ public $childRoot = array(); @@ -128,7 +128,7 @@ class Smarty_Internal_Runtime_Inheritance } /** - * Smarty_Internal_Block constructor. + * \Smarty\Block constructor. * - if outer level {block} of child template ($state === 1) save it as child root block * - otherwise process inheritance and render * @@ -159,16 +159,16 @@ class Smarty_Internal_Runtime_Inheritance /** * Goto child block or render this * - * @param \Smarty_Internal_Template $tpl - * @param \Smarty_Internal_Block $block - * @param \Smarty_Internal_Block|null $parent + * @param Smarty_Internal_Template $tpl + * @param \Smarty\Block $block + * @param \Smarty\Block|null $parent * - * @throws \SmartyException + * @throws SmartyException */ public function process( Smarty_Internal_Template $tpl, - Smarty_Internal_Block $block, - Smarty_Internal_Block $parent = null + \Smarty\Block $block, + \Smarty\Block $parent = null ) { if ($block->hide && !isset($block->child)) { return; @@ -203,13 +203,13 @@ class Smarty_Internal_Runtime_Inheritance /** * Render child on \$smarty.block.child * - * @param \Smarty_Internal_Template $tpl - * @param \Smarty_Internal_Block $block + * @param Smarty_Internal_Template $tpl + * @param \Smarty\Block $block * * @return null|string block content - * @throws \SmartyException + * @throws SmartyException */ - public function callChild(Smarty_Internal_Template $tpl, Smarty_Internal_Block $block) + public function callChild(Smarty_Internal_Template $tpl, \Smarty\Block $block) { if (isset($block->child)) { $this->process($tpl, $block->child, $block); @@ -219,14 +219,14 @@ class Smarty_Internal_Runtime_Inheritance /** * Render parent block on \$smarty.block.parent or {block append/prepend} * - * @param \Smarty_Internal_Template $tpl - * @param \Smarty_Internal_Block $block + * @param Smarty_Internal_Template $tpl + * @param \Smarty\Block $block * @param string $tag * * @return null|string block content - * @throws \SmartyException + * @throws SmartyException */ - public function callParent(Smarty_Internal_Template $tpl, Smarty_Internal_Block $block, $tag) + public function callParent(Smarty_Internal_Template $tpl, \Smarty\Block $block, $tag) { if (isset($block->parent)) { $this->callBlock($block->parent, $tpl); @@ -238,10 +238,10 @@ class Smarty_Internal_Runtime_Inheritance /** * render block * - * @param \Smarty_Internal_Block $block - * @param \Smarty_Internal_Template $tpl + * @param \Smarty\Block $block + * @param Smarty_Internal_Template $tpl */ - public function callBlock(Smarty_Internal_Block $block, Smarty_Internal_Template $tpl) + public function callBlock(\Smarty\Block $block, Smarty_Internal_Template $tpl) { $this->sourceStack[] = $tpl->source; $tpl->source = $this->sources[ $block->tplIndex ]; diff --git a/src/Runtime/smarty_internal_runtime_updatecache.php b/src/Runtime/smarty_internal_runtime_updatecache.php index 20f1e727..7359cc3a 100644 --- a/src/Runtime/smarty_internal_runtime_updatecache.php +++ b/src/Runtime/smarty_internal_runtime_updatecache.php @@ -41,7 +41,7 @@ class Smarty_Internal_Runtime_UpdateCache } $this->removeNoCacheHash($cached, $_template, $no_output_filter); $compile_check = (int)$_template->compile_check; - $_template->compile_check = Smarty::COMPILECHECK_OFF; + $_template->compile_check = \Smarty\Smarty::COMPILECHECK_OFF; if ($_template->_isSubTpl()) { $_template->compiled->unifunc = $_template->parent->compiled->unifunc; } diff --git a/src/Runtime/smarty_internal_runtime_updatescope.php b/src/Runtime/smarty_internal_runtime_updatescope.php index 3e003e80..8cda8c8a 100644 --- a/src/Runtime/smarty_internal_runtime_updatescope.php +++ b/src/Runtime/smarty_internal_runtime_updatescope.php @@ -20,15 +20,15 @@ class Smarty_Internal_Runtime_UpdateScope { if ($tagScope) { $this->_updateVarStack($tpl, $varName); - $tagScope = $tagScope & ~Smarty::SCOPE_LOCAL; + $tagScope = $tagScope & ~\Smarty\Smarty::SCOPE_LOCAL; if (!$tpl->scope && !$tagScope) { return; } } $mergedScope = $tagScope | $tpl->scope; if ($mergedScope) { - if ($mergedScope & Smarty::SCOPE_GLOBAL && $varName) { - Smarty::$global_tpl_vars[ $varName ] = $tpl->tpl_vars[ $varName ]; + if ($mergedScope & \Smarty\Smarty::SCOPE_GLOBAL && $varName) { + \Smarty\Smarty::$global_tpl_vars[ $varName ] = $tpl->tpl_vars[ $varName ]; } // update scopes foreach ($this->_getAffectedScopes($tpl, $mergedScope) as $ptr) { @@ -54,7 +54,7 @@ class Smarty_Internal_Runtime_UpdateScope $ptr = $tpl->parent; if ($mergedScope && isset($ptr) && $ptr->_isTplObj()) { $_stack[] = $ptr; - $mergedScope = $mergedScope & ~Smarty::SCOPE_PARENT; + $mergedScope = $mergedScope & ~\Smarty\Smarty::SCOPE_PARENT; if (!$mergedScope) { // only parent was set, we are done return $_stack; @@ -65,11 +65,11 @@ class Smarty_Internal_Runtime_UpdateScope $_stack[] = $ptr; $ptr = $ptr->parent; } - if ($mergedScope & Smarty::SCOPE_SMARTY) { + if ($mergedScope & \Smarty\Smarty::SCOPE_SMARTY) { if (isset($tpl->smarty)) { $_stack[] = $tpl->smarty; } - } elseif ($mergedScope & Smarty::SCOPE_ROOT) { + } elseif ($mergedScope & \Smarty\Smarty::SCOPE_ROOT) { while (isset($ptr)) { if (!$ptr->_isTplObj()) { $_stack[] = $ptr; diff --git a/src/Runtime/smarty_internal_runtime_writefile.php b/src/Runtime/smarty_internal_runtime_writefile.php index 492d5eb2..8d8e7ba2 100644 --- a/src/Runtime/smarty_internal_runtime_writefile.php +++ b/src/Runtime/smarty_internal_runtime_writefile.php @@ -60,7 +60,7 @@ class Smarty_Internal_Runtime_WriteFile * currently reading that file to fail, but linux' rename() * seems to be smart enough to handle that for us. */ - if (Smarty::$_IS_WINDOWS) { + if (\Smarty\Smarty::$_IS_WINDOWS) { // remove original file if (is_file($_filepath)) { @unlink($_filepath); diff --git a/src/Smarty.class.php b/src/Smarty.php similarity index 86% rename from src/Smarty.class.php rename to src/Smarty.php index a1d80b21..e61b823f 100644 --- a/src/Smarty.class.php +++ b/src/Smarty.php @@ -1,7 +1,9 @@ * @author Uwe Tews * @author Rodney Rehm + * @author Simon Wisselink * @package Smarty */ -/** - * set SMARTY_DIR to absolute path to Smarty library files. - * Sets SMARTY_DIR only if user application has not already defined it. - */ -if (!defined('SMARTY_DIR')) { - /** - * - */ - define('SMARTY_DIR', __DIR__ . DIRECTORY_SEPARATOR); -} -/** - * set SMARTY_SYSPLUGINS_DIR to absolute path to Smarty internal plugins. - * Sets SMARTY_SYSPLUGINS_DIR only if user application has not already defined it. - */ -if (!defined('SMARTY_SYSPLUGINS_DIR')) { - /** - * - */ - define('SMARTY_SYSPLUGINS_DIR', SMARTY_DIR . 'sysplugins' . DIRECTORY_SEPARATOR); -} -if (!defined('SMARTY_PLUGINS_DIR')) { - /** - * - */ - define('SMARTY_PLUGINS_DIR', SMARTY_DIR . 'plugins' . DIRECTORY_SEPARATOR); -} + if (!defined('SMARTY_MBSTRING')) { /** * @@ -61,32 +39,6 @@ if (!defined('SMARTY_MBSTRING')) { define('SMARTY_MBSTRING', function_exists('mb_get_info')); } -/** - * Load helper functions - */ -if (!defined('SMARTY_HELPER_FUNCTIONS_LOADED')) { - include __DIR__ . '/functions.php'; -} - -/** - * Load Smarty_Autoloader - */ -if (!class_exists('Smarty_Autoloader')) { - include __DIR__ . '/bootstrap.php'; -} - -/** - * Load always needed external class files - */ -require_once SMARTY_SYSPLUGINS_DIR . '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 . 'Base.php'; -require_once SMARTY_SYSPLUGINS_DIR . 'smarty_template_source.php'; -require_once SMARTY_SYSPLUGINS_DIR . 'smarty_template_resource_base.php'; -require_once SMARTY_SYSPLUGINS_DIR . 'smarty_internal_resource_file.php'; - /** * This is the main Smarty class * @@ -101,7 +53,7 @@ require_once SMARTY_SYSPLUGINS_DIR . 'smarty_internal_resource_file.php'; * @method int compileAllConfig(string $extension = '.conf', bool $force_compile = false, int $time_limit = 0, $max_errors = null) * @method int clearCompiledTemplate($resource_name = null, $compile_id = null, $exp_time = null) */ -class Smarty extends Smarty_Internal_TemplateBase +class Smarty extends \Smarty_Internal_TemplateBase { /** * smarty version @@ -131,14 +83,6 @@ class Smarty extends Smarty_Internal_TemplateBase */ const COMPILECHECK_OFF = 0; const COMPILECHECK_ON = 1; - const COMPILECHECK_CACHEMISS = 2; - /** - * define debug modes - */ - const DEBUG_OFF = 0; - const DEBUG_ON = 1; - const DEBUG_INDIVIDUAL = 2; - /** * filter types */ @@ -344,17 +288,17 @@ class Smarty extends Smarty_Internal_TemplateBase /** * class name - * This should be instance of Smarty_Security. + * This should be instance of \Smarty_Security. * * @var string - * @see Smarty_Security + * @see \Smarty_Security */ - public $security_class = 'Smarty_Security'; + public $security_class = \Smarty_Security::class; /** * implementation of security class * - * @var Smarty_Security + * @var \Smarty_Security */ public $security_policy = null; @@ -451,7 +395,7 @@ class Smarty extends Smarty_Internal_TemplateBase /** * resource type used if none given - * Must be an valid key of $registered_resources. + * Must be a valid key of $registered_resources. * * @var string */ @@ -573,7 +517,7 @@ class Smarty extends Smarty_Internal_TemplateBase /** * Debug object * - * @var Smarty_Internal_Debug + * @var \Smarty\Debug */ public $_debug = null; @@ -652,17 +596,17 @@ class Smarty extends Smarty_Internal_TemplateBase $this->_clearTemplateCache(); parent::__construct(); if (is_callable('mb_internal_encoding')) { - mb_internal_encoding(Smarty::$_CHARSET); + mb_internal_encoding(\Smarty\Smarty::$_CHARSET); } $this->start_time = microtime(true); if (isset($_SERVER[ 'SCRIPT_NAME' ])) { - Smarty::$global_tpl_vars[ 'SCRIPT_NAME' ] = new \Smarty\Variable($_SERVER[ 'SCRIPT_NAME' ]); + \Smarty\Smarty::$global_tpl_vars[ 'SCRIPT_NAME' ] = new \Smarty\Variable($_SERVER[ 'SCRIPT_NAME' ]); } - // Check if we're running on windows - Smarty::$_IS_WINDOWS = strtoupper(substr(PHP_OS, 0, 3)) === 'WIN'; + // Check if we're running on Windows + \Smarty\Smarty::$_IS_WINDOWS = strtoupper(substr(PHP_OS, 0, 3)) === 'WIN'; // let PCRE (preg_*) treat strings as ISO-8859-1 if we're not dealing with UTF-8 - if (Smarty::$_CHARSET !== 'UTF-8') { - Smarty::$_UTF8_MODIFIER = ''; + if (\Smarty\Smarty::$_CHARSET !== 'UTF-8') { + \Smarty\Smarty::$_UTF8_MODIFIER = ''; } } @@ -677,21 +621,21 @@ class Smarty extends Smarty_Internal_TemplateBase public function templateExists($resource_name) { // create source object - $source = Smarty_Template_Source::load(null, $this, $resource_name); + $source = \Smarty_Template_Source::load(null, $this, $resource_name); return $source->exists; } /** * Loads security class and enables security * - * @param string|Smarty_Security $security_class if a string is used, it must be class-name + * @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 */ public function enableSecurity($security_class = null) { - Smarty_Security::enableSecurity($this, $security_class); + \Smarty_Security::enableSecurity($this, $security_class); return $this; } @@ -780,7 +724,7 @@ class Smarty extends Smarty_Internal_TemplateBase * @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, $isConfig = false) { @@ -841,37 +785,11 @@ class Smarty extends Smarty_Internal_TemplateBase */ public function addPluginsDir($plugins_dir) { - if (empty($this->plugins_dir)) { - $this->plugins_dir[] = SMARTY_PLUGINS_DIR; - } $this->plugins_dir = array_merge($this->plugins_dir, (array)$plugins_dir); $this->_pluginsDirNormalized = false; return $this; } - /** - * Get plugin directories - * - * @return array list of plugin directories - */ - public function getPluginsDir() - { - if (empty($this->plugins_dir)) { - $this->plugins_dir[] = SMARTY_PLUGINS_DIR; - $this->_pluginsDirNormalized = false; - } - if (!$this->_pluginsDirNormalized) { - if (!is_array($this->plugins_dir)) { - $this->plugins_dir = (array)$this->plugins_dir; - } - foreach ($this->plugins_dir as $k => $v) { - $this->plugins_dir[ $k ] = $this->_realpath(rtrim($v ?? '', '/\\') . DIRECTORY_SEPARATOR, true); - } - $this->_pluginsDirNormalized = true; - } - return $this->plugins_dir; - } - /** * Set plugins directory * @@ -970,17 +888,17 @@ class Smarty extends Smarty_Internal_TemplateBase } $_templateId = $this->_getTemplateId($template, $cache_id, $compile_id); $tpl = null; - if ($this->caching && isset(Smarty_Internal_Template::$isCacheTplObj[ $_templateId ])) { - $tpl = $do_clone ? clone Smarty_Internal_Template::$isCacheTplObj[ $_templateId ] : - Smarty_Internal_Template::$isCacheTplObj[ $_templateId ]; + if ($this->caching && isset(\Smarty_Internal_Template::$isCacheTplObj[ $_templateId ])) { + $tpl = $do_clone ? clone \Smarty_Internal_Template::$isCacheTplObj[ $_templateId ] : + \Smarty_Internal_Template::$isCacheTplObj[ $_templateId ]; $tpl->inheritance = null; $tpl->tpl_vars = $tpl->config_vars = array(); - } elseif (!$do_clone && isset(Smarty_Internal_Template::$tplObjCache[ $_templateId ])) { - $tpl = clone Smarty_Internal_Template::$tplObjCache[ $_templateId ]; + } elseif (!$do_clone && isset(\Smarty_Internal_Template::$tplObjCache[ $_templateId ])) { + $tpl = clone \Smarty_Internal_Template::$tplObjCache[ $_templateId ]; $tpl->inheritance = null; $tpl->tpl_vars = $tpl->config_vars = array(); } else { - /* @var Smarty_Internal_Template $tpl */ + /* @var \Smarty_Internal_Template $tpl */ $tpl = new $this->template_class($template, $this, null, $cache_id, $compile_id, null, null); $tpl->templateId = $_templateId; } @@ -996,7 +914,7 @@ class Smarty extends Smarty_Internal_TemplateBase } } if ($this->debugging || $this->debugging_ctrl === 'URL') { - $tpl->smarty->_debug = new Smarty_Internal_Debug(); + $tpl->smarty->_debug = new \Smarty\Debug(); // check URL debugging control if (!$this->debugging && $this->debugging_ctrl === 'URL') { $tpl->smarty->_debug->debugUrl($tpl->smarty); @@ -1005,22 +923,6 @@ class Smarty extends Smarty_Internal_TemplateBase return $tpl; } - /** - * Takes unknown classes and loads plugin files for them - * class name format: Smarty_PluginType_PluginName - * plugin filename format: plugintype.pluginname.php - * - * @param string $plugin_name class plugin name to load - * @param bool $check check if already loaded - * - * @return string |boolean filepath of loaded file or false - * @throws \SmartyException - */ - public function loadPlugin($plugin_name, $check = true) - { - return $this->ext->loadPlugin->loadPlugin($this, $plugin_name, $check); - } - /** * Get unique template id * @@ -1038,7 +940,7 @@ class Smarty extends Smarty_Internal_TemplateBase $cache_id = null, $compile_id = null, $caching = null, - Smarty_Internal_Template $template = null + \Smarty_Internal_Template $template = null ) { $template_name = (strpos($template_name, ':') === false) ? "{$this->default_resource_type}:{$template_name}" : $template_name; @@ -1047,7 +949,7 @@ class Smarty extends Smarty_Internal_TemplateBase $caching = (int)($caching === null ? $this->caching : $caching); if ((isset($template) && strpos($template_name, ':.') !== false) || $this->allow_ambiguous_resources) { $_templateId = - Smarty_Resource::getUniqueTemplateName((isset($template) ? $template : $this), $template_name) . + \Smarty_Resource::getUniqueTemplateName((isset($template) ? $template : $this), $template_name) . "#{$cache_id}#{$compile_id}#{$caching}"; } else { $_templateId = $this->_joined_template_dir . "#{$template_name}#{$cache_id}#{$compile_id}#{$caching}"; @@ -1107,8 +1009,8 @@ class Smarty extends Smarty_Internal_TemplateBase */ public function _clearTemplateCache() { - Smarty_Internal_Template::$isCacheTplObj = array(); - Smarty_Internal_Template::$tplObjCache = array(); + \Smarty_Internal_Template::$isCacheTplObj = array(); + \Smarty_Internal_Template::$tplObjCache = array(); } /** diff --git a/src/Template/smarty_template_cached.php b/src/Template/smarty_template_cached.php index 508d27f3..4ff1f019 100644 --- a/src/Template/smarty_template_cached.php +++ b/src/Template/smarty_template_cached.php @@ -26,7 +26,7 @@ class Smarty_Template_Cached extends Smarty_Template_Resource_Base /** * CacheResource Handler * - * @var Smarty_CacheResource + * @var \Smarty\Cacheresource\Base */ public $handler = null; @@ -91,10 +91,7 @@ class Smarty_Template_Cached extends Smarty_Template_Resource_Base $this->compile_id = $_template->compile_id; $this->cache_id = $_template->cache_id; $this->source = $_template->source; - if (!class_exists('Smarty_CacheResource', false)) { - include SMARTY_SYSPLUGINS_DIR . 'smarty_cacheresource.php'; - } - $this->handler = Smarty_CacheResource::load($_template->smarty); + $this->handler = \Smarty\Cacheresource\Base::load($_template->smarty); } /** @@ -127,7 +124,7 @@ class Smarty_Template_Cached extends Smarty_Template_Resource_Base if ($this->isCached($_template)) { if ($_template->smarty->debugging) { if (!isset($_template->smarty->_debug)) { - $_template->smarty->_debug = new Smarty_Internal_Debug(); + $_template->smarty->_debug = new \Smarty\Debug(); } $_template->smarty->_debug->start_cache($_template); } @@ -163,13 +160,13 @@ class Smarty_Template_Cached extends Smarty_Template_Resource_Base } else { $this->valid = true; } - if ($this->valid && $_template->caching === Smarty::CACHING_LIFETIME_CURRENT + if ($this->valid && $_template->caching === \Smarty\Smarty::CACHING_LIFETIME_CURRENT && $_template->cache_lifetime >= 0 && time() > ($this->timestamp + $_template->cache_lifetime) ) { // lifetime expired $this->valid = false; } - if ($this->valid && $_template->compile_check === Smarty::COMPILECHECK_ON + if ($this->valid && $_template->compile_check === \Smarty\Smarty::COMPILECHECK_ON && $_template->source->getTimeStamp() > $this->timestamp ) { $this->valid = false; @@ -204,7 +201,7 @@ class Smarty_Template_Cached extends Smarty_Template_Resource_Base } else { return $this->valid; } - if ($this->valid && $_template->caching === Smarty::CACHING_LIFETIME_SAVED + if ($this->valid && $_template->caching === \Smarty\Smarty::CACHING_LIFETIME_SAVED && $_template->cached->cache_lifetime >= 0 && (time() > ($_template->cached->timestamp + $_template->cached->cache_lifetime)) ) { diff --git a/src/Template/smarty_template_compiled.php b/src/Template/smarty_template_compiled.php index 37d8f0a9..5c2fc9b0 100644 --- a/src/Template/smarty_template_compiled.php +++ b/src/Template/smarty_template_compiled.php @@ -97,7 +97,7 @@ class Smarty_Template_Compiled extends Smarty_Template_Resource_Base } if ($_template->smarty->debugging) { if (!isset($_template->smarty->_debug)) { - $_template->smarty->_debug = new Smarty_Internal_Debug(); + $_template->smarty->_debug = new \Smarty\Debug(); } $_template->smarty->_debug->start_render($_template); } @@ -140,7 +140,7 @@ class Smarty_Template_Compiled extends Smarty_Template_Resource_Base ) { $this->compileTemplateSource($_smarty_tpl); $compileCheck = $_smarty_tpl->compile_check; - $_smarty_tpl->compile_check = Smarty::COMPILECHECK_OFF; + $_smarty_tpl->compile_check = \Smarty\Smarty::COMPILECHECK_OFF; $this->loadCompiledTemplate($_smarty_tpl); $_smarty_tpl->compile_check = $compileCheck; } else { @@ -149,7 +149,7 @@ class Smarty_Template_Compiled extends Smarty_Template_Resource_Base if ($_smarty_tpl->mustCompile) { $this->compileTemplateSource($_smarty_tpl); $compileCheck = $_smarty_tpl->compile_check; - $_smarty_tpl->compile_check = Smarty::COMPILECHECK_OFF; + $_smarty_tpl->compile_check = \Smarty\Smarty::COMPILECHECK_OFF; $this->loadCompiledTemplate($_smarty_tpl); $_smarty_tpl->compile_check = $compileCheck; } diff --git a/src/TestInstall.php b/src/TestInstall.php index 57a4e7ad..c5819fb6 100644 --- a/src/TestInstall.php +++ b/src/TestInstall.php @@ -145,84 +145,6 @@ class TestInstall if ($errors === null) { echo "Testing plugins directory...\n"; } - // test if all registered plugins_dir are accessible - // and if core plugins directory is still registered - $_core_plugins_dir = realpath(__DIR__ . '/../plugins'); - $_core_plugins_available = false; - foreach ($smarty->getPluginsDir() as $plugin_dir) { - $_plugin_dir = $plugin_dir; - $plugin_dir = realpath($plugin_dir); - // resolve include_path or fail existence - if (!$plugin_dir) { - if ($smarty->use_include_path && !preg_match('/^([\/\\\\]|[a-zA-Z]:[\/\\\\])/', $_plugin_dir)) { - // try PHP include_path - if ($_stream_resolve_include_path) { - $plugin_dir = stream_resolve_include_path($_plugin_dir); - } else { - $plugin_dir = $smarty->ext->_getIncludePath->getIncludePath($_plugin_dir, null, $smarty); - } - if ($plugin_dir !== false) { - if ($errors === null) { - echo "$plugin_dir is OK.\n"; - } - continue; - } else { - $status = false; - $message = "FAILED: $_plugin_dir does not exist (and couldn't be found in include_path either)"; - if ($errors === null) { - echo $message . ".\n"; - } else { - $errors[ 'plugins_dir' ] = $message; - } - continue; - } - } else { - $status = false; - $message = "FAILED: $_plugin_dir does not exist"; - if ($errors === null) { - echo $message . ".\n"; - } else { - $errors[ 'plugins_dir' ] = $message; - } - continue; - } - } - if (!is_dir($plugin_dir)) { - $status = false; - $message = "FAILED: $plugin_dir is not a directory"; - if ($errors === null) { - echo $message . ".\n"; - } else { - $errors[ 'plugins_dir' ] = $message; - } - } elseif (!is_readable($plugin_dir)) { - $status = false; - $message = "FAILED: $plugin_dir is not readable"; - if ($errors === null) { - echo $message . ".\n"; - } else { - $errors[ 'plugins_dir' ] = $message; - } - } elseif ($_core_plugins_dir && $_core_plugins_dir == realpath($plugin_dir)) { - $_core_plugins_available = true; - if ($errors === null) { - echo "$plugin_dir is OK.\n"; - } - } else { - if ($errors === null) { - echo "$plugin_dir is OK.\n"; - } - } - } - if (!$_core_plugins_available) { - $status = false; - $message = "WARNING: Smarty's own libs/plugins is not available"; - if ($errors === null) { - echo $message . ".\n"; - } elseif (!isset($errors[ 'plugins_dir' ])) { - $errors[ 'plugins_dir' ] = $message; - } - } if ($errors === null) { echo "Testing cache directory...\n"; } diff --git a/src/functions.php b/src/functions.php index bac00e52..a21a292f 100644 --- a/src/functions.php +++ b/src/functions.php @@ -5,11 +5,6 @@ * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ -/** - * Registers some helper/polyfill functions. - */ - -const SMARTY_HELPER_FUNCTIONS_LOADED = true; /** * Converts the first characters in $string to uppercase (A-Z) if it is an ASCII lowercase character (a-z). diff --git a/src/smarty_internal_configfilelexer.php b/src/smarty_internal_configfilelexer.php deleted file mode 100644 index afb3efcb..00000000 --- a/src/smarty_internal_configfilelexer.php +++ /dev/null @@ -1,739 +0,0 @@ - 'START', 2 => 'VALUE', 3 => 'NAKED_STRING_VALUE', 4 => 'COMMENT', 5 => 'SECTION', 6 => 'TRIPPLE' - ); - - /** - * token names - * - * @var array - */ - public $smarty_token_names = array( // Text for parser error messages - ); - - /** - * compiler object - * - * @var Smarty_Internal_Config_File_Compiler - */ - private $compiler = null; - - /** - * copy of config_booleanize - * - * @var bool - */ - private $configBooleanize = false; - - /** - * storage for assembled token patterns - * - * @var string - */ - private $yy_global_pattern1 = null; - - private $yy_global_pattern2 = null; - - private $yy_global_pattern3 = null; - - private $yy_global_pattern4 = null; - - private $yy_global_pattern5 = null; - - private $yy_global_pattern6 = null; - - private $_yy_state = 1; - - private $_yy_stack = array(); - - /** - * constructor - * - * @param string $data template source - * @param Smarty_Internal_Config_File_Compiler $compiler - */ - public function __construct($data, Smarty_Internal_Config_File_Compiler $compiler) - { - $this->data = $data . "\n"; //now all lines are \n-terminated - $this->dataLength = strlen($data); - $this->counter = 0; - if (preg_match('/^\xEF\xBB\xBF/', $this->data, $match)) { - $this->counter += strlen($match[ 0 ]); - } - $this->line = 1; - $this->compiler = $compiler; - $this->smarty = $compiler->smarty; - $this->configBooleanize = $this->smarty->config_booleanize; - } - - public function replace($input) - { - return $input; - } // end function - - public function PrintTrace() - { - $this->yyTraceFILE = fopen('php://output', 'w'); - $this->yyTracePrompt = '
'; - } - - public function yylex() - { - return $this->{'yylex' . $this->_yy_state}(); - } - - 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 - ); - } - 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 - ); - } - } - - 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 - ); - } - $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 - ); - } - } - - public function yybegin($state) - { - $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 - ); - } - } - - public function yylex1() - { - if (!isset($this->yy_global_pattern1)) { - $this->yy_global_pattern1 = - $this->replace("/\G(#|;)|\G(\\[)|\G(\\])|\G(=)|\G([ \t\r]+)|\G(\n)|\G([0-9]*[a-zA-Z_]\\w*)|\G([\S\s])/isS"); - } - if (!isset($this->dataLength)) { - $this->dataLength = strlen($this->data); - } - if ($this->counter >= $this->dataLength) { - return false; // end of input - } - do { - if (preg_match($this->yy_global_pattern1, $this->data, $yymatches, 0, $this->counter)) { - if (!isset($yymatches[ 0 ][ 1 ])) { - $yymatches = preg_grep("/(.|\s)+/", $yymatches); - } else { - $yymatches = array_filter($yymatches); - } - if (empty($yymatches)) { - throw new Exception('Error: lexing failed because a rule matched' . - ' an empty string. Input "' . substr( - $this->data, - $this->counter, - 5 - ) . '... state START'); - } - next($yymatches); // skip global match - $this->token = key($yymatches); // token number - $this->value = current($yymatches); // token value - $r = $this->{'yy_r1_' . $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 >= $this->dataLength) { - 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); - } - - public function yy_r1_1() - { - $this->token = Smarty_Internal_Configfileparser::TPC_COMMENTSTART; - $this->yypushstate(self::COMMENT); - } - - public function yy_r1_2() - { - $this->token = Smarty_Internal_Configfileparser::TPC_OPENB; - $this->yypushstate(self::SECTION); - } - - public function yy_r1_3() - { - $this->token = Smarty_Internal_Configfileparser::TPC_CLOSEB; - } - - public function yy_r1_4() - { - $this->token = Smarty_Internal_Configfileparser::TPC_EQUAL; - $this->yypushstate(self::VALUE); - } // end function - - public function yy_r1_5() - { - return false; - } - - public function yy_r1_6() - { - $this->token = Smarty_Internal_Configfileparser::TPC_NEWLINE; - } - - public function yy_r1_7() - { - $this->token = Smarty_Internal_Configfileparser::TPC_ID; - } - - public function yy_r1_8() - { - $this->token = Smarty_Internal_Configfileparser::TPC_OTHER; - } - - public function yylex2() - { - if (!isset($this->yy_global_pattern2)) { - $this->yy_global_pattern2 = - $this->replace("/\G([ \t\r]+)|\G(\\d+\\.\\d+(?=[ \t\r]*[\n#;]))|\G(\\d+(?=[ \t\r]*[\n#;]))|\G(\"\"\")|\G('[^'\\\\]*(?:\\\\.[^'\\\\]*)*'(?=[ \t\r]*[\n#;]))|\G(\"[^\"\\\\]*(?:\\\\.[^\"\\\\]*)*\"(?=[ \t\r]*[\n#;]))|\G([a-zA-Z]+(?=[ \t\r]*[\n#;]))|\G([^\n]+?(?=[ \t\r]*\n))|\G(\n)/isS"); - } - if (!isset($this->dataLength)) { - $this->dataLength = strlen($this->data); - } - if ($this->counter >= $this->dataLength) { - return false; // end of input - } - do { - if (preg_match($this->yy_global_pattern2, $this->data, $yymatches, 0, $this->counter)) { - if (!isset($yymatches[ 0 ][ 1 ])) { - $yymatches = preg_grep("/(.|\s)+/", $yymatches); - } else { - $yymatches = array_filter($yymatches); - } - if (empty($yymatches)) { - throw new Exception('Error: lexing failed because a rule matched' . - ' an empty string. Input "' . substr( - $this->data, - $this->counter, - 5 - ) . '... state VALUE'); - } - next($yymatches); // skip global match - $this->token = key($yymatches); // token number - $this->value = current($yymatches); // token value - $r = $this->{'yy_r2_' . $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 >= $this->dataLength) { - 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); - } - - public function yy_r2_1() - { - return false; - } - - public function yy_r2_2() - { - $this->token = Smarty_Internal_Configfileparser::TPC_FLOAT; - $this->yypopstate(); - } - - public function yy_r2_3() - { - $this->token = Smarty_Internal_Configfileparser::TPC_INT; - $this->yypopstate(); - } - - public function yy_r2_4() - { - $this->token = Smarty_Internal_Configfileparser::TPC_TRIPPLE_QUOTES; - $this->yypushstate(self::TRIPPLE); - } - - public function yy_r2_5() - { - $this->token = Smarty_Internal_Configfileparser::TPC_SINGLE_QUOTED_STRING; - $this->yypopstate(); - } - - public function yy_r2_6() - { - $this->token = Smarty_Internal_Configfileparser::TPC_DOUBLE_QUOTED_STRING; - $this->yypopstate(); - } // end function - - public function yy_r2_7() - { - if (!$this->configBooleanize || - !in_array(strtolower($this->value), array('true', 'false', 'on', 'off', 'yes', 'no'))) { - $this->yypopstate(); - $this->yypushstate(self::NAKED_STRING_VALUE); - return true; //reprocess in new state - } else { - $this->token = Smarty_Internal_Configfileparser::TPC_BOOL; - $this->yypopstate(); - } - } - - public function yy_r2_8() - { - $this->token = Smarty_Internal_Configfileparser::TPC_NAKED_STRING; - $this->yypopstate(); - } - - public function yy_r2_9() - { - $this->token = Smarty_Internal_Configfileparser::TPC_NAKED_STRING; - $this->value = ''; - $this->yypopstate(); - } // end function - - public function yylex3() - { - if (!isset($this->yy_global_pattern3)) { - $this->yy_global_pattern3 = $this->replace("/\G([^\n]+?(?=[ \t\r]*\n))/isS"); - } - if (!isset($this->dataLength)) { - $this->dataLength = strlen($this->data); - } - if ($this->counter >= $this->dataLength) { - return false; // end of input - } - do { - if (preg_match($this->yy_global_pattern3, $this->data, $yymatches, 0, $this->counter)) { - if (!isset($yymatches[ 0 ][ 1 ])) { - $yymatches = preg_grep("/(.|\s)+/", $yymatches); - } else { - $yymatches = array_filter($yymatches); - } - if (empty($yymatches)) { - throw new Exception('Error: lexing failed because a rule matched' . - ' an empty string. Input "' . substr( - $this->data, - $this->counter, - 5 - ) . '... state NAKED_STRING_VALUE'); - } - next($yymatches); // skip global match - $this->token = key($yymatches); // token number - $this->value = current($yymatches); // token value - $r = $this->{'yy_r3_' . $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 >= $this->dataLength) { - 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); - } - - public function yy_r3_1() - { - $this->token = Smarty_Internal_Configfileparser::TPC_NAKED_STRING; - $this->yypopstate(); - } - - public function yylex4() - { - if (!isset($this->yy_global_pattern4)) { - $this->yy_global_pattern4 = $this->replace("/\G([ \t\r]+)|\G([^\n]+?(?=[ \t\r]*\n))|\G(\n)/isS"); - } - if (!isset($this->dataLength)) { - $this->dataLength = strlen($this->data); - } - if ($this->counter >= $this->dataLength) { - return false; // end of input - } - do { - if (preg_match($this->yy_global_pattern4, $this->data, $yymatches, 0, $this->counter)) { - if (!isset($yymatches[ 0 ][ 1 ])) { - $yymatches = preg_grep("/(.|\s)+/", $yymatches); - } else { - $yymatches = array_filter($yymatches); - } - if (empty($yymatches)) { - throw new Exception('Error: lexing failed because a rule matched' . - ' an empty string. Input "' . substr( - $this->data, - $this->counter, - 5 - ) . '... state COMMENT'); - } - next($yymatches); // skip global match - $this->token = key($yymatches); // token number - $this->value = current($yymatches); // token value - $r = $this->{'yy_r4_' . $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 >= $this->dataLength) { - 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); - } - - public function yy_r4_1() - { - return false; - } - - public function yy_r4_2() - { - $this->token = Smarty_Internal_Configfileparser::TPC_NAKED_STRING; - } // end function - - public function yy_r4_3() - { - $this->token = Smarty_Internal_Configfileparser::TPC_NEWLINE; - $this->yypopstate(); - } - - public function yylex5() - { - if (!isset($this->yy_global_pattern5)) { - $this->yy_global_pattern5 = $this->replace("/\G(\\.)|\G(.*?(?=[\.=[\]\r\n]))/isS"); - } - if (!isset($this->dataLength)) { - $this->dataLength = strlen($this->data); - } - if ($this->counter >= $this->dataLength) { - return false; // end of input - } - do { - if (preg_match($this->yy_global_pattern5, $this->data, $yymatches, 0, $this->counter)) { - if (!isset($yymatches[ 0 ][ 1 ])) { - $yymatches = preg_grep("/(.|\s)+/", $yymatches); - } else { - $yymatches = array_filter($yymatches); - } - if (empty($yymatches)) { - throw new Exception('Error: lexing failed because a rule matched' . - ' an empty string. Input "' . substr( - $this->data, - $this->counter, - 5 - ) . '... state SECTION'); - } - next($yymatches); // skip global match - $this->token = key($yymatches); // token number - $this->value = current($yymatches); // token value - $r = $this->{'yy_r5_' . $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 >= $this->dataLength) { - 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); - } - - public function yy_r5_1() - { - $this->token = Smarty_Internal_Configfileparser::TPC_DOT; - } - - public function yy_r5_2() - { - $this->token = Smarty_Internal_Configfileparser::TPC_SECTION; - $this->yypopstate(); - } // end function - - public function yylex6() - { - if (!isset($this->yy_global_pattern6)) { - $this->yy_global_pattern6 = $this->replace("/\G(\"\"\"(?=[ \t\r]*[\n#;]))|\G([\S\s])/isS"); - } - if (!isset($this->dataLength)) { - $this->dataLength = strlen($this->data); - } - if ($this->counter >= $this->dataLength) { - return false; // end of input - } - do { - if (preg_match($this->yy_global_pattern6, $this->data, $yymatches, 0, $this->counter)) { - if (!isset($yymatches[ 0 ][ 1 ])) { - $yymatches = preg_grep("/(.|\s)+/", $yymatches); - } else { - $yymatches = array_filter($yymatches); - } - if (empty($yymatches)) { - throw new Exception('Error: lexing failed because a rule matched' . - ' an empty string. Input "' . substr( - $this->data, - $this->counter, - 5 - ) . '... state TRIPPLE'); - } - 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 >= $this->dataLength) { - 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); - } - - public function yy_r6_1() - { - $this->token = Smarty_Internal_Configfileparser::TPC_TRIPPLE_QUOTES_END; - $this->yypopstate(); - $this->yypushstate(self::START); - } - - public function yy_r6_2() - { - $to = strlen($this->data); - preg_match("/\"\"\"[ \t\r]*[\n#;]/", $this->data, $match, PREG_OFFSET_CAPTURE, $this->counter); - if (isset($match[ 0 ][ 1 ])) { - $to = $match[ 0 ][ 1 ]; - } else { - $this->compiler->trigger_config_file_error('missing or misspelled literal closing tag'); - } - $this->value = substr($this->data, $this->counter, $to - $this->counter); - $this->token = Smarty_Internal_Configfileparser::TPC_TRIPPLE_TEXT; - } -} diff --git a/src/smarty_internal_configfileparser.php b/src/smarty_internal_configfileparser.php deleted file mode 100644 index 36fdb76e..00000000 --- a/src/smarty_internal_configfileparser.php +++ /dev/null @@ -1,1046 +0,0 @@ - 20, 1 => 2), - array(0 => 21, 1 => 1), - array(0 => 22, 1 => 2), - array(0 => 22, 1 => 0), - array(0 => 24, 1 => 5), - array(0 => 24, 1 => 6), - array(0 => 23, 1 => 2), - array(0 => 23, 1 => 2), - array(0 => 23, 1 => 0), - array(0 => 26, 1 => 3), - array(0 => 27, 1 => 1), - array(0 => 27, 1 => 1), - array(0 => 27, 1 => 1), - array(0 => 27, 1 => 1), - array(0 => 27, 1 => 1), - array(0 => 27, 1 => 3), - array(0 => 27, 1 => 2), - array(0 => 27, 1 => 1), - array(0 => 27, 1 => 1), - array(0 => 25, 1 => 1), - array(0 => 25, 1 => 2), - array(0 => 25, 1 => 3), - ); - - public static $yyReduceMap = array( - 0 => 0, - 2 => 0, - 3 => 0, - 19 => 0, - 20 => 0, - 21 => 0, - 1 => 1, - 4 => 4, - 5 => 5, - 6 => 6, - 7 => 7, - 8 => 8, - 9 => 9, - 10 => 10, - 11 => 11, - 12 => 12, - 13 => 13, - 14 => 14, - 15 => 15, - 16 => 16, - 17 => 17, - 18 => 17, - ); - - /** - * helper map - * - * @var array - */ - private static $escapes_single = array( - '\\' => '\\', - '\'' => '\'' - ); - - /** - * result status - * - * @var bool - */ - public $successful = true; - - /** - * return value - * - * @var mixed - */ - public $retvalue = 0; - - /** - * @var - */ - public $yymajor; - - /** - * compiler object - * - * @var Smarty_Internal_Config_File_Compiler - */ - public $compiler = null; - - /** - * smarty object - * - * @var Smarty - */ - public $smarty = null; - - public $yyTraceFILE; - - public $yyTracePrompt; - - public $yyidx; - - public $yyerrcnt; - - public $yystack = array(); - - public $yyTokenName = array( - '$', 'OPENB', 'SECTION', 'CLOSEB', - 'DOT', 'ID', 'EQUAL', 'FLOAT', - 'INT', 'BOOL', 'SINGLE_QUOTED_STRING', 'DOUBLE_QUOTED_STRING', - 'TRIPPLE_QUOTES', 'TRIPPLE_TEXT', 'TRIPPLE_QUOTES_END', 'NAKED_STRING', - 'OTHER', 'NEWLINE', 'COMMENTSTART', 'error', - 'start', 'global_vars', 'sections', 'var_list', - 'section', 'newline', 'var', 'value', - ); - - /** - * lexer object - * - * @var Smarty_Internal_Configfilelexer - */ - private $lex; - - /** - * internal error flag - * - * @var bool - */ - private $internalError = false; - - /** - * copy of config_overwrite property - * - * @var bool - */ - private $configOverwrite = false; - - /** - * copy of config_read_hidden property - * - * @var bool - */ - private $configReadHidden = false; - - private $_retvalue; - - /** - * constructor - * - * @param Smarty_Internal_Configfilelexer $lex - * @param Smarty_Internal_Config_File_Compiler $compiler - */ - public function __construct(Smarty_Internal_Configfilelexer $lex, Smarty_Internal_Config_File_Compiler $compiler) - { - $this->lex = $lex; - $this->smarty = $compiler->smarty; - $this->compiler = $compiler; - $this->configOverwrite = $this->smarty->config_overwrite; - $this->configReadHidden = $this->smarty->config_read_hidden; - } - - public static function yy_destructor($yymajor, $yypminor) - { - switch ($yymajor) { - default: - break; /* If no destructor action specified: do nothing */ - } - } - - /** - * parse single quoted string - * remove outer quotes - * unescape inner quotes - * - * @param string $qstr - * - * @return string - */ - private static function parse_single_quoted_string($qstr) - { - $escaped_string = substr($qstr, 1, strlen($qstr) - 2); //remove outer quotes - $ss = preg_split('/(\\\\.)/', $escaped_string, -1, PREG_SPLIT_DELIM_CAPTURE); - $str = ''; - foreach ($ss as $s) { - if (strlen($s) === 2 && $s[ 0 ] === '\\') { - if (isset(self::$escapes_single[ $s[ 1 ] ])) { - $s = self::$escapes_single[ $s[ 1 ] ]; - } - } - $str .= $s; - } - return $str; - } /* Index of top element in stack */ - /** - * parse double quoted string - * - * @param string $qstr - * - * @return string - */ - private static function parse_double_quoted_string($qstr) - { - $inner_str = substr($qstr, 1, strlen($qstr) - 2); - return stripcslashes($inner_str); - } /* Shifts left before out of the error */ - /** - * parse triple quoted string - * - * @param string $qstr - * - * @return string - */ - private static function parse_tripple_double_quoted_string($qstr) - { - return stripcslashes($qstr); - } /* The parser's stack */ - public function Trace($TraceFILE, $zTracePrompt) - { - if (!$TraceFILE) { - $zTracePrompt = 0; - } elseif (!$zTracePrompt) { - $TraceFILE = 0; - } - $this->yyTraceFILE = $TraceFILE; - $this->yyTracePrompt = $zTracePrompt; - } - - public function PrintTrace() - { - $this->yyTraceFILE = fopen('php://output', 'w'); - $this->yyTracePrompt = '
'; - } - - public function tokenName($tokenType) - { - if ($tokenType === 0) { - return 'End of Input'; - } - if ($tokenType > 0 && $tokenType < count($this->yyTokenName)) { - return $this->yyTokenName[ $tokenType ]; - } else { - return 'Unknown'; - } - } - - public function yy_pop_parser_stack() - { - if (empty($this->yystack)) { - return; - } - $yytos = array_pop($this->yystack); - if ($this->yyTraceFILE && $this->yyidx >= 0) { - fwrite( - $this->yyTraceFILE, - $this->yyTracePrompt . 'Popping ' . $this->yyTokenName[ $yytos->major ] . - "\n" - ); - } - $yymajor = $yytos->major; - self::yy_destructor($yymajor, $yytos->minor); - $this->yyidx--; - return $yymajor; - } - - public function __destruct() - { - while ($this->yystack !== array()) { - $this->yy_pop_parser_stack(); - } - if (is_resource($this->yyTraceFILE)) { - fclose($this->yyTraceFILE); - } - } - - public function yy_get_expected_tokens($token) - { - static $res3 = array(); - static $res4 = array(); - $state = $this->yystack[ $this->yyidx ]->stateno; - $expected = self::$yyExpectedTokens[ $state ]; - if (isset($res3[ $state ][ $token ])) { - if ($res3[ $state ][ $token ]) { - return $expected; - } - } else { - if ($res3[ $state ][ $token ] = in_array($token, self::$yyExpectedTokens[ $state ], true)) { - return $expected; - } - } - $stack = $this->yystack; - $yyidx = $this->yyidx; - do { - $yyact = $this->yy_find_shift_action($token); - if ($yyact >= self::YYNSTATE && $yyact < self::YYNSTATE + self::YYNRULE) { - // reduce action - $done = 0; - do { - if ($done++ === 100) { - $this->yyidx = $yyidx; - $this->yystack = $stack; - // too much recursion prevents proper detection - // so give up - return array_unique($expected); - } - $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 ] - ); - if (isset(self::$yyExpectedTokens[ $nextstate ])) { - $expected = array_merge($expected, self::$yyExpectedTokens[ $nextstate ]); - if (isset($res4[ $nextstate ][ $token ])) { - if ($res4[ $nextstate ][ $token ]) { - $this->yyidx = $yyidx; - $this->yystack = $stack; - return array_unique($expected); - } - } else { - if ($res4[ $nextstate ][ $token ] = - in_array($token, self::$yyExpectedTokens[ $nextstate ], true)) { - $this->yyidx = $yyidx; - $this->yystack = $stack; - return array_unique($expected); - } - } - } - if ($nextstate < self::YYNSTATE) { - // we need to shift a non-terminal - $this->yyidx++; - $x = new TPC_yyStackEntry; - $x->stateno = $nextstate; - $x->major = self::$yyRuleInfo[ $yyruleno ][ 0 ]; - $this->yystack[ $this->yyidx ] = $x; - continue 2; - } elseif ($nextstate === self::YYNSTATE + self::YYNRULE + 1) { - $this->yyidx = $yyidx; - $this->yystack = $stack; - // the last token was just ignored, we can't accept - // by ignoring input, this is in essence ignoring a - // syntax error! - return array_unique($expected); - } elseif ($nextstate === self::YY_NO_ACTION) { - $this->yyidx = $yyidx; - $this->yystack = $stack; - // input accepted, but not shifted (I guess) - return $expected; - } else { - $yyact = $nextstate; - } - } while (true); - } - break; - } while (true); - $this->yyidx = $yyidx; - $this->yystack = $stack; - return array_unique($expected); - } - - public function yy_is_expected_token($token) - { - static $res = array(); - static $res2 = array(); - if ($token === 0) { - return true; // 0 is not part of this - } - $state = $this->yystack[ $this->yyidx ]->stateno; - if (isset($res[ $state ][ $token ])) { - if ($res[ $state ][ $token ]) { - return true; - } - } else { - if ($res[ $state ][ $token ] = in_array($token, self::$yyExpectedTokens[ $state ], true)) { - return true; - } - } - $stack = $this->yystack; - $yyidx = $this->yyidx; - do { - $yyact = $this->yy_find_shift_action($token); - if ($yyact >= self::YYNSTATE && $yyact < self::YYNSTATE + self::YYNRULE) { - // reduce action - $done = 0; - do { - if ($done++ === 100) { - $this->yyidx = $yyidx; - $this->yystack = $stack; - // too much recursion prevents proper detection - // so give up - return true; - } - $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 ] - ); - if (isset($res2[ $nextstate ][ $token ])) { - if ($res2[ $nextstate ][ $token ]) { - $this->yyidx = $yyidx; - $this->yystack = $stack; - return true; - } - } else { - if ($res2[ $nextstate ][ $token ] = - (isset(self::$yyExpectedTokens[ $nextstate ]) && - in_array($token, self::$yyExpectedTokens[ $nextstate ], true))) { - $this->yyidx = $yyidx; - $this->yystack = $stack; - return true; - } - } - if ($nextstate < self::YYNSTATE) { - // we need to shift a non-terminal - $this->yyidx++; - $x = new TPC_yyStackEntry; - $x->stateno = $nextstate; - $x->major = self::$yyRuleInfo[ $yyruleno ][ 0 ]; - $this->yystack[ $this->yyidx ] = $x; - continue 2; - } elseif ($nextstate === self::YYNSTATE + self::YYNRULE + 1) { - $this->yyidx = $yyidx; - $this->yystack = $stack; - if (!$token) { - // end of input: this is valid - return true; - } - // the last token was just ignored, we can't accept - // by ignoring input, this is in essence ignoring a - // syntax error! - return false; - } elseif ($nextstate === self::YY_NO_ACTION) { - $this->yyidx = $yyidx; - $this->yystack = $stack; - // input accepted, but not shifted (I guess) - return true; - } else { - $yyact = $nextstate; - } - } while (true); - } - break; - } while (true); - $this->yyidx = $yyidx; - $this->yystack = $stack; - return true; - } - - public function yy_find_shift_action($iLookAhead) - { - $stateno = $this->yystack[ $this->yyidx ]->stateno; - /* if ($this->yyidx < 0) return self::YY_NO_ACTION; */ - if (!isset(self::$yy_shift_ofst[ $stateno ])) { - // no shift actions - return self::$yy_default[ $stateno ]; - } - $i = self::$yy_shift_ofst[ $stateno ]; - if ($i === self::YY_SHIFT_USE_DFLT) { - return self::$yy_default[ $stateno ]; - } - if ($iLookAhead === self::YYNOCODE) { - return self::YY_NO_ACTION; - } - $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 ($this->yyTraceFILE) { - fwrite($this->yyTraceFILE, $this->yyTracePrompt . 'FALLBACK ' . - $this->yyTokenName[ $iLookAhead ] . ' => ' . - $this->yyTokenName[ $iFallback ] . "\n"); - } - return $this->yy_find_shift_action($iFallback); - } - return self::$yy_default[ $stateno ]; - } else { - return self::$yy_action[ $i ]; - } - } - - public function yy_find_reduce_action($stateno, $iLookAhead) - { - /* $stateno = $this->yystack[$this->yyidx]->stateno; */ - if (!isset(self::$yy_reduce_ofst[ $stateno ])) { - return self::$yy_default[ $stateno ]; - } - $i = self::$yy_reduce_ofst[ $stateno ]; - if ($i === self::YY_REDUCE_USE_DFLT) { - return self::$yy_default[ $stateno ]; - } - if ($iLookAhead === self::YYNOCODE) { - return self::YY_NO_ACTION; - } - $i += $iLookAhead; - if ($i < 0 || $i >= self::YY_SZ_ACTTAB || - self::$yy_lookahead[ $i ] != $iLookAhead) { - return self::$yy_default[ $stateno ]; - } else { - return self::$yy_action[ $i ]; - } - } - - public function yy_shift($yyNewState, $yyMajor, $yypMinor) - { - $this->yyidx++; - if ($this->yyidx >= self::YYSTACKDEPTH) { - $this->yyidx--; - if ($this->yyTraceFILE) { - fprintf($this->yyTraceFILE, "%sStack Overflow!\n", $this->yyTracePrompt); - } - while ($this->yyidx >= 0) { - $this->yy_pop_parser_stack(); - } - // line 239 "../smarty/lexer/smarty_internal_configfileparser.y" - $this->internalError = true; - $this->compiler->trigger_config_file_error('Stack overflow in configfile parser'); - return; - } - $yytos = new TPC_yyStackEntry; - $yytos->stateno = $yyNewState; - $yytos->major = $yyMajor; - $yytos->minor = $yypMinor; - $this->yystack[] = $yytos; - if ($this->yyTraceFILE && $this->yyidx > 0) { - fprintf( - $this->yyTraceFILE, - "%sShift %d\n", - $this->yyTracePrompt, - $yyNewState - ); - fprintf($this->yyTraceFILE, "%sStack:", $this->yyTracePrompt); - for ($i = 1; $i <= $this->yyidx; $i++) { - fprintf( - $this->yyTraceFILE, - " %s", - $this->yyTokenName[ $this->yystack[ $i ]->major ] - ); - } - fwrite($this->yyTraceFILE, "\n"); - } - } - - public function yy_r0() - { - $this->_retvalue = null; - } - - public function yy_r1() - { - $this->add_global_vars($this->yystack[ $this->yyidx + 0 ]->minor); - $this->_retvalue = null; - } - - public function yy_r4() - { - $this->add_section_vars($this->yystack[ $this->yyidx + -3 ]->minor, $this->yystack[ $this->yyidx + 0 ]->minor); - $this->_retvalue = null; - } - - // line 245 "../smarty/lexer/smarty_internal_configfileparser.y" - public function yy_r5() - { - if ($this->configReadHidden) { - $this->add_section_vars( - $this->yystack[ $this->yyidx + -3 ]->minor, - $this->yystack[ $this->yyidx + 0 ]->minor - ); - } - $this->_retvalue = null; - } - - // line 250 "../smarty/lexer/smarty_internal_configfileparser.y" - public function yy_r6() - { - $this->_retvalue = $this->yystack[ $this->yyidx + -1 ]->minor; - } - - // line 264 "../smarty/lexer/smarty_internal_configfileparser.y" - public function yy_r7() - { - $this->_retvalue = - array_merge($this->yystack[ $this->yyidx + -1 ]->minor, array($this->yystack[ $this->yyidx + 0 ]->minor)); - } - - // line 269 "../smarty/lexer/smarty_internal_configfileparser.y" - public function yy_r8() - { - $this->_retvalue = array(); - } - - // line 277 "../smarty/lexer/smarty_internal_configfileparser.y" - public function yy_r9() - { - $this->_retvalue = - array( - 'key' => $this->yystack[ $this->yyidx + -2 ]->minor, - 'value' => $this->yystack[ $this->yyidx + 0 ]->minor - ); - } - - // line 281 "../smarty/lexer/smarty_internal_configfileparser.y" - public function yy_r10() - { - $this->_retvalue = (float)$this->yystack[ $this->yyidx + 0 ]->minor; - } - - // line 285 "../smarty/lexer/smarty_internal_configfileparser.y" - public function yy_r11() - { - $this->_retvalue = (int)$this->yystack[ $this->yyidx + 0 ]->minor; - } - - // line 291 "../smarty/lexer/smarty_internal_configfileparser.y" - public function yy_r12() - { - $this->_retvalue = $this->parse_bool($this->yystack[ $this->yyidx + 0 ]->minor); - } - - // line 296 "../smarty/lexer/smarty_internal_configfileparser.y" - public function yy_r13() - { - $this->_retvalue = self::parse_single_quoted_string($this->yystack[ $this->yyidx + 0 ]->minor); - } - - // line 300 "../smarty/lexer/smarty_internal_configfileparser.y" - public function yy_r14() - { - $this->_retvalue = self::parse_double_quoted_string($this->yystack[ $this->yyidx + 0 ]->minor); - } - - // line 304 "../smarty/lexer/smarty_internal_configfileparser.y" - public function yy_r15() - { - $this->_retvalue = self::parse_tripple_double_quoted_string($this->yystack[ $this->yyidx + -1 ]->minor); - } - - // line 308 "../smarty/lexer/smarty_internal_configfileparser.y" - public function yy_r16() - { - $this->_retvalue = ''; - } - - // line 312 "../smarty/lexer/smarty_internal_configfileparser.y" - public function yy_r17() - { - $this->_retvalue = $this->yystack[ $this->yyidx + 0 ]->minor; - } - - // line 316 "../smarty/lexer/smarty_internal_configfileparser.y" - 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 ] - ); - } - $this->_retvalue = $yy_lefthand_side = null; - if (isset(self::$yyReduceMap[ $yyruleno ])) { - // call the action - $this->_retvalue = null; - $this->{'yy_r' . self::$yyReduceMap[ $yyruleno ]}(); - $yy_lefthand_side = $this->_retvalue; - } - $yygoto = self::$yyRuleInfo[ $yyruleno ][ 0 ]; - $yysize = self::$yyRuleInfo[ $yyruleno ][ 1 ]; - $this->yyidx -= $yysize; - for ($i = $yysize; $i; $i--) { - // pop all of the right-hand side parameters - array_pop($this->yystack); - } - $yyact = $this->yy_find_reduce_action($this->yystack[ $this->yyidx ]->stateno, $yygoto); - if ($yyact < self::YYNSTATE) { - if (!$this->yyTraceFILE && $yysize) { - $this->yyidx++; - $x = new TPC_yyStackEntry; - $x->stateno = $yyact; - $x->major = $yygoto; - $x->minor = $yy_lefthand_side; - $this->yystack[ $this->yyidx ] = $x; - } else { - $this->yy_shift($yyact, $yygoto, $yy_lefthand_side); - } - } elseif ($yyact === self::YYNSTATE + self::YYNRULE + 1) { - $this->yy_accept(); - } - } - - // line 320 "../smarty/lexer/smarty_internal_configfileparser.y" - public function yy_parse_failed() - { - if ($this->yyTraceFILE) { - fprintf($this->yyTraceFILE, "%sFail!\n", $this->yyTracePrompt); - } - while ($this->yyidx >= 0) { - $this->yy_pop_parser_stack(); - } - } - - // line 324 "../smarty/lexer/smarty_internal_configfileparser.y" - public function yy_syntax_error($yymajor, $TOKEN) - { - // line 232 "../smarty/lexer/smarty_internal_configfileparser.y" - $this->internalError = true; - $this->yymajor = $yymajor; - $this->compiler->trigger_config_file_error(); - } - - public function yy_accept() - { - if ($this->yyTraceFILE) { - fprintf($this->yyTraceFILE, "%sAccept!\n", $this->yyTracePrompt); - } - while ($this->yyidx >= 0) { - $this->yy_pop_parser_stack(); - } - // line 225 "../smarty/lexer/smarty_internal_configfileparser.y" - $this->successful = !$this->internalError; - $this->internalError = false; - $this->retvalue = $this->_retvalue; - } - - public function doParse($yymajor, $yytokenvalue) - { - $yyerrorhit = 0; /* True if yymajor has invoked an error */ - if ($this->yyidx === null || $this->yyidx < 0) { - $this->yyidx = 0; - $this->yyerrcnt = -1; - $x = new TPC_yyStackEntry; - $x->stateno = 0; - $x->major = 0; - $this->yystack = array(); - $this->yystack[] = $x; - } - $yyendofinput = ($yymajor == 0); - if ($this->yyTraceFILE) { - fprintf( - $this->yyTraceFILE, - "%sInput %s\n", - $this->yyTracePrompt, - $this->yyTokenName[ $yymajor ] - ); - } - do { - $yyact = $this->yy_find_shift_action($yymajor); - if ($yymajor < self::YYERRORSYMBOL && - !$this->yy_is_expected_token($yymajor)) { - // force a syntax error - $yyact = self::YY_ERROR_ACTION; - } - if ($yyact < self::YYNSTATE) { - $this->yy_shift($yyact, $yymajor, $yytokenvalue); - $this->yyerrcnt--; - if ($yyendofinput && $this->yyidx >= 0) { - $yymajor = 0; - } else { - $yymajor = self::YYNOCODE; - } - } elseif ($yyact < self::YYNSTATE + self::YYNRULE) { - $this->yy_reduce($yyact - self::YYNSTATE); - } elseif ($yyact === self::YY_ERROR_ACTION) { - if ($this->yyTraceFILE) { - fprintf( - $this->yyTraceFILE, - "%sSyntax Error!\n", - $this->yyTracePrompt - ); - } - if (self::YYERRORSYMBOL) { - if ($this->yyerrcnt < 0) { - $this->yy_syntax_error($yymajor, $yytokenvalue); - } - $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 ] - ); - } - $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 - ) { - $this->yy_pop_parser_stack(); - } - if ($this->yyidx < 0 || $yymajor == 0) { - $this->yy_destructor($yymajor, $yytokenvalue); - $this->yy_parse_failed(); - $yymajor = self::YYNOCODE; - } elseif ($yymx !== self::YYERRORSYMBOL) { - $u2 = 0; - $this->yy_shift($yyact, self::YYERRORSYMBOL, $u2); - } - } - $this->yyerrcnt = 3; - $yyerrorhit = 1; - } else { - if ($this->yyerrcnt <= 0) { - $this->yy_syntax_error($yymajor, $yytokenvalue); - } - $this->yyerrcnt = 3; - $this->yy_destructor($yymajor, $yytokenvalue); - if ($yyendofinput) { - $this->yy_parse_failed(); - } - $yymajor = self::YYNOCODE; - } - } else { - $this->yy_accept(); - $yymajor = self::YYNOCODE; - } - } while ($yymajor !== self::YYNOCODE && $this->yyidx >= 0); - } - - /** - * parse optional boolean keywords - * - * @param string $str - * - * @return bool - */ - private function parse_bool($str) - { - $str = strtolower($str); - if (in_array($str, array('on', 'yes', 'true'))) { - $res = true; - } else { - $res = false; - } - return $res; - } - - /** - * set a config variable in target array - * - * @param array $var - * @param array $target_array - */ - private function set_var(array $var, array &$target_array) - { - $key = $var[ 'key' ]; - $value = $var[ 'value' ]; - if ($this->configOverwrite || !isset($target_array[ 'vars' ][ $key ])) { - $target_array[ 'vars' ][ $key ] = $value; - } else { - settype($target_array[ 'vars' ][ $key ], 'array'); - $target_array[ 'vars' ][ $key ][] = $value; - } - } - - /** - * add config variable to global vars - * - * @param array $vars - */ - private function add_global_vars(array $vars) - { - if (!isset($this->compiler->config_data[ 'vars' ])) { - $this->compiler->config_data[ 'vars' ] = array(); - } - foreach ($vars as $var) { - $this->set_var($var, $this->compiler->config_data); - } - } - - /** - * add config variable to section - * - * @param string $section_name - * @param array $vars - */ - private function add_section_vars($section_name, array $vars) - { - if (!isset($this->compiler->config_data[ 'sections' ][ $section_name ][ 'vars' ])) { - $this->compiler->config_data[ 'sections' ][ $section_name ][ 'vars' ] = array(); - } - foreach ($vars as $var) { - $this->set_var($var, $this->compiler->config_data[ 'sections' ][ $section_name ]); - } - } -} diff --git a/src/smarty_internal_extension_handler.php b/src/smarty_internal_extension_handler.php index 1f3a666d..b266d3d8 100644 --- a/src/smarty_internal_extension_handler.php +++ b/src/smarty_internal_extension_handler.php @@ -29,7 +29,6 @@ * @property Smarty_Internal_Method_AssignGlobal $assignGlobal * @property Smarty_Internal_Method_AssignByRef $assignByRef * @property Smarty_Internal_Method_LoadFilter $loadFilter - * @property Smarty_Internal_Method_LoadPlugin $loadPlugin * @property Smarty_Internal_Method_RegisterFilter $registerFilter * @property Smarty_Internal_Method_RegisterObject $registerObject * @property Smarty_Internal_Method_RegisterPlugin $registerPlugin diff --git a/src/smarty_internal_nocache_insert.php b/src/smarty_internal_nocache_insert.php deleted file mode 100644 index 88694dcf..00000000 --- a/src/smarty_internal_nocache_insert.php +++ /dev/null @@ -1,51 +0,0 @@ -assign('{$_assign}' , {$_function} (" . var_export($_attr, true) . - ',\$_smarty_tpl), true);?>'; - } else { - $_output .= "echo {$_function}(" . var_export($_attr, true) . ',$_smarty_tpl);?>'; - } - $_tpl = $_template; - while ($_tpl->_isSubTpl()) { - $_tpl = $_tpl->parent; - } - return "/*%%SmartyNocache:{$_tpl->compiled->nocache_hash}%%*/{$_output}/*/%%SmartyNocache:{$_tpl->compiled->nocache_hash}%%*/"; - } -} diff --git a/src/smarty_internal_template.php b/src/smarty_internal_template.php index a40d4e67..8a073a6d 100644 --- a/src/smarty_internal_template.php +++ b/src/smarty_internal_template.php @@ -187,7 +187,7 @@ class Smarty_Internal_Template extends Smarty_Internal_TemplateBase { if ($this->smarty->debugging) { if (!isset($this->smarty->_debug)) { - $this->smarty->_debug = new Smarty_Internal_Debug(); + $this->smarty->_debug = new \Smarty\Debug(); } $this->smarty->_debug->start_template($this, $display); } @@ -200,10 +200,10 @@ class Smarty_Internal_Template extends Smarty_Internal_TemplateBase } // disable caching for evaluated code if ($this->source->handler->recompiled) { - $this->caching = Smarty::CACHING_OFF; + $this->caching = \Smarty\Smarty::CACHING_OFF; } // read from cache or render - if ($this->caching === Smarty::CACHING_LIFETIME_CURRENT || $this->caching === Smarty::CACHING_LIFETIME_SAVED) { + if ($this->caching === \Smarty\Smarty::CACHING_LIFETIME_CURRENT || $this->caching === \Smarty\Smarty::CACHING_LIFETIME_SAVED) { if (!isset($this->cached) || $this->cached->cache_id !== $this->cache_id || $this->cached->compile_id !== $this->compile_id ) { @@ -369,7 +369,7 @@ class Smarty_Internal_Template extends Smarty_Internal_TemplateBase if (isset($uid)) { if ($smarty->debugging) { if (!isset($smarty->_debug)) { - $smarty->_debug = new Smarty_Internal_Debug(); + $smarty->_debug = new \Smarty\Debug(); } $smarty->_debug->start_template($tpl); $smarty->_debug->start_render($tpl); @@ -438,40 +438,6 @@ class Smarty_Internal_Template extends Smarty_Internal_TemplateBase } } - /** - * Check if plugins are callable require file otherwise - * - * @param array $plugins required plugins - * - * @throws \SmartyException - */ - public function _checkPlugins($plugins) - { - static $checked = array(); - foreach ($plugins as $plugin) { - $name = join('::', (array)$plugin[ 'function' ]); - if (!isset($checked[ $name ])) { - if (!is_callable($plugin[ 'function' ])) { - if (is_file($plugin[ 'file' ])) { - include_once $plugin[ 'file' ]; - if (is_callable($plugin[ 'function' ])) { - $checked[ $name ] = true; - } - } - } else { - $checked[ $name ] = true; - } - } - if (!isset($checked[ $name ])) { - if (false !== $this->smarty->loadPlugin($name)) { - $checked[ $name ] = true; - } else { - throw new SmartyException("Plugin '{$name}' not callable"); - } - } - } - } - /** * This function is executed automatically when a compiled or cached template file is included * - Decode saved properties from compiled template and cache files @@ -487,7 +453,7 @@ class Smarty_Internal_Template extends Smarty_Internal_TemplateBase public function _decodeProperties(Smarty_Internal_Template $tpl, $properties, $cache = false) { // on cache resources other than file check version stored in cache code - if (!isset($properties[ 'version' ]) || Smarty::SMARTY_VERSION !== $properties[ 'version' ]) { + if (!isset($properties[ 'version' ]) || \Smarty\Smarty::SMARTY_VERSION !== $properties[ 'version' ]) { if ($cache) { $tpl->smarty->clearAllCache(); } else { @@ -497,7 +463,7 @@ class Smarty_Internal_Template extends Smarty_Internal_TemplateBase } $is_valid = true; if (!empty($properties[ 'file_dependency' ]) - && ((!$cache && $tpl->compile_check) || $tpl->compile_check === Smarty::COMPILECHECK_ON) + && ((!$cache && $tpl->compile_check) || $tpl->compile_check === \Smarty\Smarty::COMPILECHECK_ON) ) { // check file dependencies at compiled code foreach ($properties[ 'file_dependency' ] as $_file_to_check) { @@ -527,7 +493,7 @@ class Smarty_Internal_Template extends Smarty_Internal_TemplateBase } if ($cache) { // CACHING_LIFETIME_SAVED cache expiry has to be validated here since otherwise we'd define the unifunc - if ($tpl->caching === Smarty::CACHING_LIFETIME_SAVED && $properties[ 'cache_lifetime' ] >= 0 + if ($tpl->caching === \Smarty\Smarty::CACHING_LIFETIME_SAVED && $properties[ 'cache_lifetime' ] >= 0 && (time() > ($tpl->cached->timestamp + $properties[ 'cache_lifetime' ])) ) { $is_valid = false; @@ -645,9 +611,6 @@ class Smarty_Internal_Template extends Smarty_Internal_TemplateBase */ public function loadCompiler() { - if (!class_exists($this->source->compiler_class)) { - $this->smarty->loadPlugin($this->source->compiler_class); - } $this->compiler = new $this->source->compiler_class( $this->source->template_lexer_class, diff --git a/src/smarty_internal_templatebase.php b/src/smarty_internal_templatebase.php index 032b1a60..ca5332cb 100644 --- a/src/smarty_internal_templatebase.php +++ b/src/smarty_internal_templatebase.php @@ -28,7 +28,7 @@ * @method array getDefaultModifier() * @method array getLiterals() * @method object getRegisteredObject(string $object_name) - * @method Smarty_Internal_TemplateBase registerCacheResource(string $name, Smarty_CacheResource $resource_handler) + * @method Smarty_Internal_TemplateBase registerCacheResource(string $name, \Smarty\Cacheresource\Base $resource_handler) * @method Smarty_Internal_TemplateBase registerClass(string $class_name, string $class_impl) * @method Smarty_Internal_TemplateBase registerDefaultConfigHandler(callback $callback) * @method Smarty_Internal_TemplateBase registerDefaultPluginHandler(callback $callback) @@ -68,14 +68,14 @@ abstract class Smarty_Internal_TemplateBase extends \Smarty\Data * * @var int */ - public $caching = Smarty::CACHING_OFF; + public $caching = \Smarty\Smarty::CACHING_OFF; /** * check template for modifications? * * @var int */ - public $compile_check = Smarty::COMPILECHECK_ON; + public $compile_check = \Smarty\Smarty::COMPILECHECK_ON; /** * cache lifetime in seconds @@ -200,7 +200,7 @@ abstract class Smarty_Internal_TemplateBase extends \Smarty\Data isset($smarty->error_reporting) ? error_reporting($smarty->error_reporting) : null; if ($smarty->isMutingUndefinedOrNullWarnings()) { - $errorHandler = new Smarty_Internal_ErrorHandler(); + $errorHandler = new \Smarty\ErrorHandler(); $errorHandler->activate(); } @@ -231,8 +231,8 @@ abstract class Smarty_Internal_TemplateBase extends \Smarty\Data } ob_start(); $template->_mergeVars(); - if (!empty(Smarty::$global_tpl_vars)) { - $template->tpl_vars = array_merge(Smarty::$global_tpl_vars, $template->tpl_vars); + if (!empty(\Smarty\Smarty::$global_tpl_vars)) { + $template->tpl_vars = array_merge(\Smarty\Smarty::$global_tpl_vars, $template->tpl_vars); } $result = $template->render(false, $function); $template->_cleanUp(); diff --git a/src/smarty_internal_templatelexer.php b/src/smarty_internal_templatelexer.php deleted file mode 100644 index 75ff5889..00000000 --- a/src/smarty_internal_templatelexer.php +++ /dev/null @@ -1,1088 +0,0 @@ - - */ -class Smarty_Internal_Templatelexer -{ - /** - * Source - * - * @var string - */ - public $data; - - /** - * Source length - * - * @var int - */ - public $dataLength = null; - - /** - * byte counter - * - * @var int - */ - public $counter; - - /** - * token number - * - * @var int - */ - public $token; - - /** - * token value - * - * @var string - */ - public $value; - - /** - * current line - * - * @var int - */ - public $line; - - /** - * tag start line - * - * @var - */ - public $taglineno; - - /** - * state number - * - * @var int - */ - public $state = 1; - - /** - * Smarty object - * - * @var Smarty - */ - public $smarty = null; - - /** - * compiler object - * - * @var Smarty_Internal_TemplateCompilerBase - */ - public $compiler = null; - - /** - * trace file - * - * @var resource - */ - public $yyTraceFILE; - - /** - * trace prompt - * - * @var string - */ - public $yyTracePrompt; - - /** - * XML flag true while processing xml - * - * @var bool - */ - public $is_xml = false; - - /** - * state names - * - * @var array - */ - public $state_name = array(1 => 'TEXT', 2 => 'TAG', 3 => 'TAGBODY', 4 => 'LITERAL', 5 => 'DOUBLEQUOTEDSTRING',); - - /** - * 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' => '" '"<", "==" ... logical operator', - 'TLOGOP' => '"lt", "eq" ... logical operator; "is div by" ... if condition', - 'SCOND' => '"is even" ... if condition', - ); - - /** - * literal tag nesting level - * - * @var int - */ - private $literal_cnt = 0; - - /** - * preg token pattern for state TEXT - * - * @var string - */ - private $yy_global_pattern1 = null; - - /** - * preg token pattern for state TAG - * - * @var string - */ - private $yy_global_pattern2 = null; - - /** - * preg token pattern for state TAGBODY - * - * @var string - */ - private $yy_global_pattern3 = null; - - /** - * preg token pattern for state LITERAL - * - * @var string - */ - private $yy_global_pattern4 = null; - - /** - * preg token pattern for state DOUBLEQUOTEDSTRING - * - * @var null - */ - private $yy_global_pattern5 = null; - - /** - * preg token pattern for text - * - * @var null - */ - private $yy_global_text = null; - - /** - * preg token pattern for literal - * - * @var null - */ - private $yy_global_literal = null; - - /** - * constructor - * - * @param string $source template source - * @param Smarty_Internal_TemplateCompilerBase $compiler - */ - public function __construct($source, Smarty_Internal_TemplateCompilerBase $compiler) - { - $this->data = $source; - $this->dataLength = strlen($this->data); - $this->counter = 0; - if (preg_match('/^\xEF\xBB\xBF/i', $this->data, $match)) { - $this->counter += strlen($match[0]); - } - $this->line = 1; - $this->smarty = $compiler->template->smarty; - $this->compiler = $compiler; - $this->compiler->initDelimiterPreg(); - $this->smarty_token_names['LDEL'] = $this->smarty->getLeftDelimiter(); - $this->smarty_token_names['RDEL'] = $this->smarty->getRightDelimiter(); - } - - /** - * open lexer/parser trace file - * - */ - public function PrintTrace() - { - $this->yyTraceFILE = fopen('php://output', 'w'); - $this->yyTracePrompt = '
'; - } - - /** - * replace placeholders with runtime preg code - * - * @param string $preg - * - * @return string - */ - public function replace($preg) - { - return $this->compiler->replaceDelimiter($preg); - } - - /** - * check if current value is an autoliteral left delimiter - * - * @return bool - */ - public function isAutoLiteral() - { - return $this->smarty->getAutoLiteral() && isset($this->value[ $this->compiler->getLdelLength() ]) ? - strpos(" \n\t\r", $this->value[ $this->compiler->getLdelLength() ]) !== false : false; - } - - - private $_yy_state = 1; - private $_yy_stack = array(); - - public function yylex() - { - return $this->{'yylex' . $this->_yy_state}(); - } - - 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); - } - 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); - } - } - - 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); - } - $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); - } - - } - - public function yybegin($state) - { - $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); - } - } - - - - public function yylex1() - { - if (!isset($this->yy_global_pattern1)) { - $this->yy_global_pattern1 = $this->replace("/\G([{][}])|\G((SMARTYldel)SMARTYal[*])|\G((SMARTYldel)SMARTYautoliteral\\s+SMARTYliteral)|\G((SMARTYldel)SMARTYalliteral\\s*SMARTYrdel)|\G((SMARTYldel)SMARTYal[\/]literal\\s*SMARTYrdel)|\G((SMARTYldel)SMARTYal)|\G([\S\s])/isS"); - } - if (!isset($this->dataLength)) { - $this->dataLength = strlen($this->data); - } - if ($this->counter >= $this->dataLength) { - return false; // end of input - } - - do { - if (preg_match($this->yy_global_pattern1,$this->data, $yymatches, 0, $this->counter)) { - if (!isset($yymatches[ 0 ][1])) { - $yymatches = preg_grep("/(.|\s)+/", $yymatches); - } else { - $yymatches = array_filter($yymatches); - } - 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'); - } - next($yymatches); // skip global match - $this->token = key($yymatches); // token number - $this->value = current($yymatches); // token value - $r = $this->{'yy_r1_' . $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 >= $this->dataLength) { - 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 TEXT = 1; - public function yy_r1_1() - { - - $this->token = Smarty_Internal_Templateparser::TP_TEXT; - } - public function yy_r1_2() - { - - $to = $this->dataLength; - preg_match("/[*]{$this->compiler->getRdelPreg()}[\n]?/",$this->data,$match,PREG_OFFSET_CAPTURE,$this->counter); - 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->getRightDelimiter()}'"); - } - $this->value = substr($this->data,$this->counter,$to-$this->counter); - return false; - } - public function yy_r1_4() - { - - $this->token = Smarty_Internal_Templateparser::TP_TEXT; - } - public function yy_r1_6() - { - - $this->token = Smarty_Internal_Templateparser::TP_LITERALSTART; - $this->yypushstate(self::LITERAL); - } - public function yy_r1_8() - { - - $this->token = Smarty_Internal_Templateparser::TP_LITERALEND; - $this->yypushstate(self::LITERAL); - } - public function yy_r1_10() - { - - $this->yypushstate(self::TAG); - return true; - } - public function yy_r1_12() - { - - if (!isset($this->yy_global_text)) { - $this->yy_global_text = $this->replace('/(SMARTYldel)SMARTYal/isS'); - } - $to = $this->dataLength; - preg_match($this->yy_global_text, $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; - } - - - public function yylex2() - { - if (!isset($this->yy_global_pattern2)) { - $this->yy_global_pattern2 = $this->replace("/\G((SMARTYldel)SMARTYal(if|elseif|else if|while)\\s+)|\G((SMARTYldel)SMARTYalfor\\s+)|\G((SMARTYldel)SMARTYalforeach(?![^\s]))|\G((SMARTYldel)SMARTYalsetfilter\\s+)|\G((SMARTYldel)SMARTYalmake_nocache\\s+)|\G((SMARTYldel)SMARTYal[0-9]*[a-zA-Z_]\\w*(\\s+nocache)?\\s*SMARTYrdel)|\G((SMARTYldel)SMARTYal[$]smarty\\.block\\.(child|parent)\\s*SMARTYrdel)|\G((SMARTYldel)SMARTYal[\/][0-9]*[a-zA-Z_]\\w*\\s*SMARTYrdel)|\G((SMARTYldel)SMARTYal[$][0-9]*[a-zA-Z_]\\w*(\\s+nocache)?\\s*SMARTYrdel)|\G((SMARTYldel)SMARTYal[\/])|\G((SMARTYldel)SMARTYal)/isS"); - } - if (!isset($this->dataLength)) { - $this->dataLength = strlen($this->data); - } - if ($this->counter >= $this->dataLength) { - return false; // end of input - } - - do { - if (preg_match($this->yy_global_pattern2,$this->data, $yymatches, 0, $this->counter)) { - if (!isset($yymatches[ 0 ][1])) { - $yymatches = preg_grep("/(.|\s)+/", $yymatches); - } else { - $yymatches = array_filter($yymatches); - } - 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'); - } - next($yymatches); // skip global match - $this->token = key($yymatches); // token number - $this->value = current($yymatches); // token value - $r = $this->{'yy_r2_' . $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 >= $this->dataLength) { - 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 TAG = 2; - public function yy_r2_1() - { - - $this->token = Smarty_Internal_Templateparser::TP_LDELIF; - $this->yybegin(self::TAGBODY); - $this->taglineno = $this->line; - } - public function yy_r2_4() - { - - $this->token = Smarty_Internal_Templateparser::TP_LDELFOR; - $this->yybegin(self::TAGBODY); - $this->taglineno = $this->line; - } - public function yy_r2_6() - { - - $this->token = Smarty_Internal_Templateparser::TP_LDELFOREACH; - $this->yybegin(self::TAGBODY); - $this->taglineno = $this->line; - } - public function yy_r2_8() - { - - $this->token = Smarty_Internal_Templateparser::TP_LDELSETFILTER; - $this->yybegin(self::TAGBODY); - $this->taglineno = $this->line; - } - public function yy_r2_10() - { - - $this->token = Smarty_Internal_Templateparser::TP_LDELMAKENOCACHE; - $this->yybegin(self::TAGBODY); - $this->taglineno = $this->line; - } - public function yy_r2_12() - { - - $this->yypopstate(); - $this->token = Smarty_Internal_Templateparser::TP_SIMPLETAG; - $this->taglineno = $this->line; - } - public function yy_r2_15() - { - - $this->yypopstate(); - $this->token = Smarty_Internal_Templateparser::TP_SMARTYBLOCKCHILDPARENT; - $this->taglineno = $this->line; - } - public function yy_r2_18() - { - - $this->yypopstate(); - $this->token = Smarty_Internal_Templateparser::TP_CLOSETAG; - $this->taglineno = $this->line; - } - public function yy_r2_20() - { - - if ($this->_yy_stack[count($this->_yy_stack)-1] === self::TEXT) { - $this->yypopstate(); - $this->token = Smarty_Internal_Templateparser::TP_SIMPELOUTPUT; - $this->taglineno = $this->line; - } else { - $this->value = $this->smarty->getLeftDelimiter(); - $this->token = Smarty_Internal_Templateparser::TP_LDEL; - $this->yybegin(self::TAGBODY); - $this->taglineno = $this->line; - } - } - public function yy_r2_23() - { - - $this->token = Smarty_Internal_Templateparser::TP_LDELSLASH; - $this->yybegin(self::TAGBODY); - $this->taglineno = $this->line; - } - public function yy_r2_25() - { - - $this->token = Smarty_Internal_Templateparser::TP_LDEL; - $this->yybegin(self::TAGBODY); - $this->taglineno = $this->line; - } - - - public function yylex3() - { - if (!isset($this->yy_global_pattern3)) { - $this->yy_global_pattern3 = $this->replace("/\G(\\s*SMARTYrdel)|\G((SMARTYldel)SMARTYal)|\G([\"])|\G('[^'\\\\]*(?:\\\\.[^'\\\\]*)*')|\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)\\s+)|\G(\\s+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(array\\s*[(]\\s*)|\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 (!isset($this->dataLength)) { - $this->dataLength = strlen($this->data); - } - if ($this->counter >= $this->dataLength) { - return false; // end of input - } - - do { - if (preg_match($this->yy_global_pattern3,$this->data, $yymatches, 0, $this->counter)) { - if (!isset($yymatches[ 0 ][1])) { - $yymatches = preg_grep("/(.|\s)+/", $yymatches); - } else { - $yymatches = array_filter($yymatches); - } - 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'); - } - next($yymatches); // skip global match - $this->token = key($yymatches); // token number - $this->value = current($yymatches); // token value - $r = $this->{'yy_r3_' . $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 >= $this->dataLength) { - 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 TAGBODY = 3; - public function yy_r3_1() - { - - $this->token = Smarty_Internal_Templateparser::TP_RDEL; - $this->yypopstate(); - } - public function yy_r3_2() - { - - $this->yypushstate(self::TAG); - return true; - } - public function yy_r3_4() - { - - $this->token = Smarty_Internal_Templateparser::TP_QUOTE; - $this->yypushstate(self::DOUBLEQUOTEDSTRING); - $this->compiler->enterDoubleQuote(); - } - public function yy_r3_5() - { - - $this->token = Smarty_Internal_Templateparser::TP_SINGLEQUOTESTRING; - } - public function yy_r3_6() - { - - $this->token = Smarty_Internal_Templateparser::TP_DOLLARID; - } - public function yy_r3_7() - { - - $this->token = Smarty_Internal_Templateparser::TP_DOLLAR; - } - public function yy_r3_8() - { - - $this->token = Smarty_Internal_Templateparser::TP_ISIN; - } - public function yy_r3_9() - { - - $this->token = Smarty_Internal_Templateparser::TP_AS; - } - public function yy_r3_10() - { - - $this->token = Smarty_Internal_Templateparser::TP_TO; - } - public function yy_r3_11() - { - - $this->token = Smarty_Internal_Templateparser::TP_STEP; - } - public function yy_r3_12() - { - - $this->token = Smarty_Internal_Templateparser::TP_INSTANCEOF; - } - public function yy_r3_13() - { - - $this->token = Smarty_Internal_Templateparser::TP_LOGOP; - } - public function yy_r3_15() - { - - $this->token = Smarty_Internal_Templateparser::TP_SLOGOP; - } - public function yy_r3_17() - { - - $this->token = Smarty_Internal_Templateparser::TP_TLOGOP; - } - public function yy_r3_20() - { - - $this->token = Smarty_Internal_Templateparser::TP_SINGLECOND; - } - public function yy_r3_23() - { - - $this->token = Smarty_Internal_Templateparser::TP_NOT; - } - public function yy_r3_24() - { - - $this->token = Smarty_Internal_Templateparser::TP_TYPECAST; - } - public function yy_r3_28() - { - - $this->token = Smarty_Internal_Templateparser::TP_OPENP; - } - public function yy_r3_29() - { - - $this->token = Smarty_Internal_Templateparser::TP_CLOSEP; - } - public function yy_r3_30() - { - - $this->token = Smarty_Internal_Templateparser::TP_OPENB; - } - public function yy_r3_31() - { - - $this->token = Smarty_Internal_Templateparser::TP_CLOSEB; - } - public function yy_r3_32() - { - - $this->token = Smarty_Internal_Templateparser::TP_PTR; - } - public function yy_r3_33() - { - - $this->token = Smarty_Internal_Templateparser::TP_APTR; - } - public function yy_r3_34() - { - - $this->token = Smarty_Internal_Templateparser::TP_EQUAL; - } - public function yy_r3_35() - { - - $this->token = Smarty_Internal_Templateparser::TP_INCDEC; - } - public function yy_r3_37() - { - - $this->token = Smarty_Internal_Templateparser::TP_UNIMATH; - } - public function yy_r3_39() - { - - $this->token = Smarty_Internal_Templateparser::TP_MATH; - } - public function yy_r3_41() - { - - $this->token = Smarty_Internal_Templateparser::TP_AT; - } - public function yy_r3_42() - { - - $this->token = Smarty_Internal_Templateparser::TP_ARRAYOPEN; - } - public function yy_r3_43() - { - - $this->token = Smarty_Internal_Templateparser::TP_HATCH; - } - public function yy_r3_44() - { - - // resolve conflicts with shorttag and right_delimiter starting with '=' - if (substr($this->data, $this->counter + strlen($this->value) - 1, $this->compiler->getRdelLength()) === $this->smarty->getRightDelimiter()) { - preg_match('/\s+/',$this->value,$match); - $this->value = $match[0]; - $this->token = Smarty_Internal_Templateparser::TP_SPACE; - } else { - $this->token = Smarty_Internal_Templateparser::TP_ATTR; - } - } - public function yy_r3_45() - { - - $this->token = Smarty_Internal_Templateparser::TP_NAMESPACE; - } - public function yy_r3_48() - { - - $this->token = Smarty_Internal_Templateparser::TP_ID; - } - public function yy_r3_49() - { - - $this->token = Smarty_Internal_Templateparser::TP_INTEGER; - } - public function yy_r3_50() - { - - $this->token = Smarty_Internal_Templateparser::TP_BACKTICK; - $this->yypopstate(); - } - public function yy_r3_51() - { - - $this->token = Smarty_Internal_Templateparser::TP_VERT; - } - public function yy_r3_52() - { - - $this->token = Smarty_Internal_Templateparser::TP_DOT; - } - public function yy_r3_53() - { - - $this->token = Smarty_Internal_Templateparser::TP_COMMA; - } - public function yy_r3_54() - { - - $this->token = Smarty_Internal_Templateparser::TP_SEMICOLON; - } - public function yy_r3_55() - { - - $this->token = Smarty_Internal_Templateparser::TP_DOUBLECOLON; - } - public function yy_r3_56() - { - - $this->token = Smarty_Internal_Templateparser::TP_COLON; - } - public function yy_r3_57() - { - - $this->token = Smarty_Internal_Templateparser::TP_QMARK; - } - public function yy_r3_58() - { - - $this->token = Smarty_Internal_Templateparser::TP_HEX; - } - public function yy_r3_59() - { - - $this->token = Smarty_Internal_Templateparser::TP_SPACE; - } - public function yy_r3_60() - { - - $this->token = Smarty_Internal_Templateparser::TP_TEXT; - } - - - - public function yylex4() - { - if (!isset($this->yy_global_pattern4)) { - $this->yy_global_pattern4 = $this->replace("/\G((SMARTYldel)SMARTYalliteral\\s*SMARTYrdel)|\G((SMARTYldel)SMARTYal[\/]literal\\s*SMARTYrdel)|\G([\S\s])/isS"); - } - if (!isset($this->dataLength)) { - $this->dataLength = strlen($this->data); - } - if ($this->counter >= $this->dataLength) { - return false; // end of input - } - - do { - if (preg_match($this->yy_global_pattern4,$this->data, $yymatches, 0, $this->counter)) { - if (!isset($yymatches[ 0 ][1])) { - $yymatches = preg_grep("/(.|\s)+/", $yymatches); - } else { - $yymatches = array_filter($yymatches); - } - 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'); - } - next($yymatches); // skip global match - $this->token = key($yymatches); // token number - $this->value = current($yymatches); // token value - $r = $this->{'yy_r4_' . $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 >= $this->dataLength) { - 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 LITERAL = 4; - public function yy_r4_1() - { - - $this->literal_cnt++; - $this->token = Smarty_Internal_Templateparser::TP_LITERAL; - } - public function yy_r4_3() - { - - if ($this->literal_cnt) { - $this->literal_cnt--; - $this->token = Smarty_Internal_Templateparser::TP_LITERAL; - } else { - $this->token = Smarty_Internal_Templateparser::TP_LITERALEND; - $this->yypopstate(); - } - } - public function yy_r4_5() - { - - if (!isset($this->yy_global_literal)) { - $this->yy_global_literal = $this->replace('/(SMARTYldel)SMARTYal[\/]?literalSMARTYrdel/isS'); - } - $to = $this->dataLength; - preg_match($this->yy_global_literal, $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_LITERAL; - } - - - public function yylex5() - { - if (!isset($this->yy_global_pattern5)) { - $this->yy_global_pattern5 = $this->replace("/\G((SMARTYldel)SMARTYautoliteral\\s+SMARTYliteral)|\G((SMARTYldel)SMARTYalliteral\\s*SMARTYrdel)|\G((SMARTYldel)SMARTYal[\/]literal\\s*SMARTYrdel)|\G((SMARTYldel)SMARTYal[\/])|\G((SMARTYldel)SMARTYal[0-9]*[a-zA-Z_]\\w*)|\G((SMARTYldel)SMARTYal)|\G([\"])|\G([`][$])|\G([$][0-9]*[a-zA-Z_]\\w*)|\G([$])|\G(([^\"\\\\]*?)((?:\\\\.[^\"\\\\]*?)*?)(?=((SMARTYldel)SMARTYal|\\$|`\\$|\"SMARTYliteral)))|\G([\S\s])/isS"); - } - if (!isset($this->dataLength)) { - $this->dataLength = strlen($this->data); - } - if ($this->counter >= $this->dataLength) { - return false; // end of input - } - - do { - if (preg_match($this->yy_global_pattern5,$this->data, $yymatches, 0, $this->counter)) { - if (!isset($yymatches[ 0 ][1])) { - $yymatches = preg_grep("/(.|\s)+/", $yymatches); - } else { - $yymatches = array_filter($yymatches); - } - 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'); - } - next($yymatches); // skip global match - $this->token = key($yymatches); // token number - $this->value = current($yymatches); // token value - $r = $this->{'yy_r5_' . $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 >= $this->dataLength) { - 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 DOUBLEQUOTEDSTRING = 5; - public function yy_r5_1() - { - - $this->token = Smarty_Internal_Templateparser::TP_TEXT; - } - public function yy_r5_3() - { - - $this->token = Smarty_Internal_Templateparser::TP_TEXT; - } - public function yy_r5_5() - { - - $this->token = Smarty_Internal_Templateparser::TP_TEXT; - } - public function yy_r5_7() - { - - $this->yypushstate(self::TAG); - return true; - } - public function yy_r5_9() - { - - $this->yypushstate(self::TAG); - return true; - } - public function yy_r5_11() - { - - $this->token = Smarty_Internal_Templateparser::TP_LDEL; - $this->taglineno = $this->line; - $this->yypushstate(self::TAGBODY); - } - public function yy_r5_13() - { - - $this->token = Smarty_Internal_Templateparser::TP_QUOTE; - $this->yypopstate(); - } - public function yy_r5_14() - { - - $this->token = Smarty_Internal_Templateparser::TP_BACKTICK; - $this->value = substr($this->value,0,-1); - $this->yypushstate(self::TAGBODY); - $this->taglineno = $this->line; - } - public function yy_r5_15() - { - - $this->token = Smarty_Internal_Templateparser::TP_DOLLARID; - } - public function yy_r5_16() - { - - $this->token = Smarty_Internal_Templateparser::TP_TEXT; - } - public function yy_r5_17() - { - - $this->token = Smarty_Internal_Templateparser::TP_TEXT; - } - public function yy_r5_22() - { - - $to = $this->dataLength; - $this->value = substr($this->data,$this->counter,$to-$this->counter); - $this->token = Smarty_Internal_Templateparser::TP_TEXT; - } - - } - - \ No newline at end of file diff --git a/src/smarty_internal_templateparser.php b/src/smarty_internal_templateparser.php deleted file mode 100644 index 4be2c2f4..00000000 --- a/src/smarty_internal_templateparser.php +++ /dev/null @@ -1,2926 +0,0 @@ - -*/ -class Smarty_Internal_Templateparser -{ -// line 23 "../smarty/lexer/smarty_internal_templateparser.y" - - const ERR1 = 'Security error: Call to private object member not allowed'; - const ERR2 = 'Security error: Call to dynamic object member not allowed'; - - /** - * result status - * - * @var bool - */ - public $successful = true; - - /** - * return value - * - * @var mixed - */ - public $retvalue = 0; - - /** - * @var - */ - public $yymajor; - - /** - * last index of array variable - * - * @var mixed - */ - public $last_index; - - /** - * last variable name - * - * @var string - */ - public $last_variable; - - /** - * root parse tree buffer - * - * @var \Smarty\ParseTree\Template - */ - public $root_buffer; - - /** - * current parse tree object - * - * @var \Smarty\ParseTree\Base - */ - public $current_buffer; - - /** - * lexer object - * - * @var Smarty_Internal_Templatelexer - */ - public $lex; - - /** - * internal error flag - * - * @var bool - */ - private $internalError = false; - - /** - * {strip} status - * - * @var bool - */ - public $strip = false; - /** - * compiler object - * - * @var Smarty_Internal_TemplateCompilerBase - */ - public $compiler = null; - - /** - * smarty object - * - * @var Smarty - */ - public $smarty = null; - - /** - * template object - * - * @var Smarty_Internal_Template - */ - public $template = null; - - /** - * block nesting level - * - * @var int - */ - public $block_nesting_level = 0; - - /** - * security object - * - * @var Smarty_Security - */ - public $security = null; - - /** - * template prefix array - * - * @var \Smarty\ParseTree\Base[] - */ - public $template_prefix = array(); - - /** - * template prefix array - * - * @var \Smarty\ParseTree\Base[] - */ - public $template_postfix = array(); - - /** - * constructor - * - * @param Smarty_Internal_Templatelexer $lex - * @param Smarty_Internal_TemplateCompilerBase $compiler - */ - public function __construct(Smarty_Internal_Templatelexer $lex, Smarty_Internal_TemplateCompilerBase $compiler) - { - $this->lex = $lex; - $this->compiler = $compiler; - $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\ParseTree\Template(); - } - - /** - * insert PHP code in current buffer - * - * @param string $code - */ - public function insertPhpCode($code) - { - $this->current_buffer->append_subtree($this, new \Smarty\ParseTree\Tag($this, $code)); - } - - /** - * error rundown - * - */ - public function errorRunDown() - { - while ($this->yystack !== array()) { - $this->yy_pop_parser_stack(); - } - if (is_resource($this->yyTraceFILE)) { - fclose($this->yyTraceFILE); - } - } - - /** - * merge PHP code with prefix code and return parse tree tag object - * - * @param string $code - * - * @return \Smarty\ParseTree\Tag - */ - public function mergePrefixCode($code) - { - $tmp = ''; - foreach ($this->compiler->prefix_code as $preCode) { - $tmp .= $preCode; - } - $this->compiler->prefix_code = array(); - $tmp .= $code; - return new \Smarty\ParseTree\Tag($this, $this->compiler->processNocacheCode($tmp, true)); - } - - - const TP_VERT = 1; - const TP_COLON = 2; - const TP_TEXT = 3; - const TP_STRIPON = 4; - const TP_STRIPOFF = 5; - const TP_LITERALSTART = 6; - const TP_LITERALEND = 7; - const TP_LITERAL = 8; - const TP_SIMPELOUTPUT = 9; - const TP_SIMPLETAG = 10; - const TP_SMARTYBLOCKCHILDPARENT = 11; - const TP_LDEL = 12; - const TP_RDEL = 13; - const TP_DOLLARID = 14; - const TP_EQUAL = 15; - const TP_ID = 16; - const TP_PTR = 17; - const TP_LDELMAKENOCACHE = 18; - const TP_LDELIF = 19; - const TP_LDELFOR = 20; - const TP_SEMICOLON = 21; - const TP_INCDEC = 22; - const TP_TO = 23; - const TP_STEP = 24; - const TP_LDELFOREACH = 25; - const TP_SPACE = 26; - const TP_AS = 27; - const TP_APTR = 28; - const TP_LDELSETFILTER = 29; - const TP_CLOSETAG = 30; - const TP_LDELSLASH = 31; - const TP_ATTR = 32; - const TP_INTEGER = 33; - const TP_COMMA = 34; - const TP_OPENP = 35; - const TP_CLOSEP = 36; - const TP_MATH = 37; - const TP_UNIMATH = 38; - const TP_ISIN = 39; - const TP_QMARK = 40; - const TP_NOT = 41; - const TP_TYPECAST = 42; - const TP_HEX = 43; - const TP_DOT = 44; - const TP_INSTANCEOF = 45; - const TP_SINGLEQUOTESTRING = 46; - const TP_DOUBLECOLON = 47; - const TP_NAMESPACE = 48; - const TP_AT = 49; - const TP_HATCH = 50; - const TP_OPENB = 51; - const TP_CLOSEB = 52; - const TP_DOLLAR = 53; - const TP_LOGOP = 54; - const TP_SLOGOP = 55; - const TP_TLOGOP = 56; - const TP_SINGLECOND = 57; - const TP_ARRAYOPEN = 58; - const TP_QUOTE = 59; - const TP_BACKTICK = 60; - const YY_NO_ACTION = 514; - const YY_ACCEPT_ACTION = 513; - const YY_ERROR_ACTION = 512; - - const YY_SZ_ACTTAB = 1997; -public static $yy_action = array( - 249, 250, 239, 1, 27, 127, 220, 184, 160, 213, - 11, 54, 278, 10, 173, 34, 108, 387, 282, 279, - 223, 321, 221, 8, 194, 387, 18, 387, 85, 41, - 387, 285, 42, 44, 264, 222, 387, 209, 387, 198, - 387, 52, 5, 307, 288, 288, 164, 283, 224, 4, - 50, 249, 250, 239, 1, 232, 131, 381, 189, 205, - 213, 11, 54, 39, 35, 243, 31, 108, 94, 17, - 381, 223, 321, 221, 439, 226, 381, 33, 49, 426, - 41, 439, 89, 42, 44, 264, 222, 9, 235, 163, - 198, 426, 52, 5, 131, 288, 212, 284, 102, 106, - 4, 50, 249, 250, 239, 1, 232, 129, 426, 189, - 347, 213, 11, 54, 175, 324, 347, 208, 108, 22, - 426, 301, 223, 321, 221, 302, 226, 135, 18, 49, - 52, 41, 26, 288, 42, 44, 264, 222, 16, 235, - 294, 198, 204, 52, 5, 170, 288, 32, 90, 267, - 268, 4, 50, 249, 250, 239, 1, 20, 129, 185, - 179, 255, 213, 11, 54, 455, 288, 192, 455, 108, - 175, 167, 455, 223, 321, 221, 439, 226, 256, 18, - 55, 292, 41, 439, 132, 42, 44, 264, 222, 427, - 235, 12, 198, 165, 52, 5, 232, 288, 288, 347, - 153, 427, 4, 50, 249, 250, 239, 1, 232, 129, - 286, 181, 347, 213, 11, 54, 24, 13, 347, 49, - 108, 232, 320, 426, 223, 321, 221, 195, 201, 173, - 18, 49, 139, 41, 296, 426, 42, 44, 264, 222, - 7, 235, 286, 198, 49, 52, 5, 147, 288, 117, - 150, 317, 263, 4, 50, 249, 250, 239, 1, 95, - 130, 173, 189, 155, 213, 11, 54, 22, 244, 271, - 192, 108, 323, 286, 101, 223, 321, 221, 294, 226, - 204, 18, 348, 257, 41, 166, 283, 42, 44, 264, - 222, 28, 235, 300, 198, 348, 52, 5, 247, 288, - 117, 348, 94, 206, 4, 50, 249, 250, 239, 1, - 95, 129, 22, 189, 277, 213, 11, 54, 91, 274, - 224, 426, 108, 323, 216, 156, 223, 321, 221, 132, - 180, 262, 18, 426, 100, 41, 12, 288, 42, 44, - 264, 222, 15, 235, 216, 198, 254, 52, 5, 233, - 288, 210, 190, 192, 100, 4, 50, 249, 250, 239, - 1, 3, 131, 94, 189, 192, 213, 11, 54, 269, - 10, 204, 290, 108, 325, 216, 224, 223, 321, 221, - 23, 226, 211, 33, 315, 100, 45, 513, 92, 42, - 44, 264, 222, 102, 235, 178, 198, 268, 52, 5, - 275, 288, 161, 192, 37, 25, 4, 50, 249, 250, - 239, 1, 286, 129, 172, 187, 305, 213, 11, 54, - 164, 283, 310, 141, 108, 281, 281, 236, 223, 321, - 221, 169, 226, 230, 18, 122, 171, 41, 225, 175, - 42, 44, 264, 222, 144, 235, 303, 198, 134, 52, - 5, 265, 288, 151, 286, 192, 175, 4, 50, 249, - 250, 239, 1, 286, 128, 94, 189, 143, 213, 11, - 54, 219, 152, 207, 193, 108, 149, 281, 31, 223, - 321, 221, 100, 226, 21, 6, 286, 288, 41, 158, - 16, 42, 44, 264, 222, 102, 235, 238, 198, 286, - 52, 5, 157, 288, 281, 122, 168, 283, 4, 50, - 249, 250, 239, 1, 30, 93, 308, 51, 215, 213, - 11, 54, 53, 251, 140, 248, 108, 245, 304, 116, - 223, 321, 221, 111, 226, 176, 18, 270, 266, 41, - 224, 322, 42, 44, 264, 222, 7, 235, 259, 198, - 147, 52, 5, 257, 288, 43, 40, 38, 83, 4, - 50, 241, 214, 204, 319, 280, 88, 107, 138, 182, - 97, 64, 311, 312, 313, 316, 95, 281, 298, 258, - 142, 234, 94, 105, 272, 197, 231, 482, 237, 323, - 37, 133, 324, 241, 214, 204, 319, 314, 88, 107, - 296, 183, 97, 82, 84, 43, 40, 38, 95, 296, - 296, 258, 296, 296, 296, 159, 272, 197, 231, 296, - 237, 323, 311, 312, 313, 316, 241, 296, 204, 296, - 296, 103, 296, 296, 199, 104, 77, 296, 296, 110, - 296, 95, 296, 296, 258, 278, 296, 296, 34, 272, - 197, 231, 279, 237, 323, 43, 40, 38, 296, 296, - 296, 241, 26, 204, 196, 276, 103, 296, 16, 199, - 104, 77, 311, 312, 313, 316, 95, 192, 296, 258, - 146, 296, 296, 296, 272, 197, 231, 296, 237, 323, - 286, 393, 39, 35, 243, 296, 296, 296, 296, 191, - 276, 296, 26, 318, 252, 253, 126, 296, 16, 249, - 250, 239, 1, 296, 296, 131, 296, 261, 213, 11, - 54, 296, 296, 296, 426, 108, 393, 393, 393, 223, - 321, 221, 241, 296, 204, 299, 426, 103, 107, 296, - 183, 97, 82, 393, 393, 393, 393, 95, 296, 260, - 258, 52, 296, 296, 288, 272, 197, 231, 296, 237, - 323, 293, 296, 296, 296, 296, 296, 249, 250, 239, - 2, 296, 295, 296, 296, 296, 213, 11, 54, 296, - 296, 177, 296, 108, 136, 296, 296, 223, 321, 221, - 296, 296, 296, 293, 43, 40, 38, 296, 296, 249, - 250, 239, 2, 296, 295, 43, 40, 38, 213, 11, - 54, 311, 312, 313, 316, 108, 296, 291, 14, 223, - 321, 221, 311, 312, 313, 316, 296, 296, 241, 296, - 204, 296, 192, 103, 296, 296, 199, 104, 77, 296, - 296, 296, 296, 95, 383, 296, 258, 296, 296, 297, - 14, 272, 197, 231, 296, 237, 323, 383, 296, 296, - 241, 296, 204, 383, 296, 99, 296, 287, 199, 120, - 48, 241, 112, 204, 296, 95, 103, 296, 258, 199, - 120, 74, 296, 272, 197, 231, 95, 237, 323, 258, - 455, 296, 296, 455, 272, 197, 231, 455, 237, 323, - 241, 296, 204, 296, 296, 103, 200, 296, 199, 120, - 74, 296, 296, 296, 296, 95, 296, 296, 258, 278, - 296, 296, 34, 272, 197, 231, 279, 237, 323, 241, - 455, 204, 296, 296, 99, 202, 296, 199, 120, 56, - 241, 211, 204, 296, 95, 103, 296, 258, 199, 120, - 74, 296, 272, 197, 231, 95, 237, 323, 258, 227, - 296, 296, 296, 272, 197, 231, 296, 237, 323, 241, - 296, 204, 148, 296, 103, 203, 86, 199, 120, 73, - 296, 296, 286, 296, 95, 296, 296, 258, 278, 296, - 296, 34, 272, 197, 231, 279, 237, 323, 241, 296, - 204, 175, 296, 103, 296, 296, 199, 120, 75, 241, - 296, 204, 296, 95, 103, 296, 258, 199, 120, 63, - 296, 272, 197, 231, 95, 237, 323, 258, 229, 192, - 296, 296, 272, 197, 231, 296, 237, 323, 241, 296, - 204, 380, 296, 103, 296, 296, 199, 120, 58, 296, - 296, 296, 296, 95, 380, 296, 258, 296, 296, 296, - 380, 272, 197, 231, 296, 237, 323, 241, 296, 204, - 296, 296, 103, 296, 296, 199, 120, 71, 241, 296, - 204, 296, 95, 103, 296, 258, 199, 120, 79, 296, - 272, 197, 231, 95, 237, 323, 258, 296, 296, 296, - 154, 272, 197, 231, 87, 237, 323, 241, 296, 204, - 286, 296, 103, 296, 296, 199, 120, 70, 296, 296, - 296, 296, 95, 296, 296, 258, 296, 296, 296, 175, - 272, 197, 231, 296, 237, 323, 241, 296, 204, 296, - 296, 103, 296, 296, 199, 120, 56, 241, 296, 204, - 296, 95, 103, 296, 258, 199, 120, 46, 296, 272, - 197, 231, 95, 237, 323, 258, 296, 296, 296, 296, - 272, 197, 231, 296, 237, 323, 241, 296, 204, 296, - 296, 103, 296, 296, 199, 120, 78, 296, 296, 296, - 296, 95, 296, 296, 258, 296, 296, 296, 296, 272, - 197, 231, 296, 237, 323, 241, 296, 204, 296, 296, - 103, 296, 296, 199, 120, 66, 241, 296, 204, 296, - 95, 103, 296, 258, 199, 120, 59, 296, 272, 197, - 231, 95, 237, 323, 258, 296, 296, 296, 296, 272, - 197, 231, 296, 237, 323, 241, 296, 204, 296, 296, - 103, 296, 296, 186, 109, 57, 296, 296, 296, 296, - 95, 296, 296, 258, 296, 296, 296, 296, 272, 197, - 231, 296, 237, 323, 241, 296, 204, 296, 296, 103, - 296, 296, 188, 120, 67, 241, 296, 204, 296, 95, - 103, 296, 258, 199, 96, 62, 296, 272, 197, 231, - 95, 237, 323, 258, 296, 296, 296, 296, 272, 197, - 231, 296, 237, 323, 241, 296, 204, 296, 296, 103, - 296, 296, 199, 120, 80, 296, 296, 296, 296, 95, - 296, 296, 258, 296, 296, 296, 296, 272, 197, 231, - 296, 237, 323, 241, 296, 204, 296, 296, 103, 296, - 296, 199, 120, 76, 241, 296, 204, 296, 95, 103, - 296, 258, 199, 120, 81, 296, 272, 197, 231, 95, - 237, 323, 258, 296, 296, 296, 296, 272, 197, 231, - 296, 237, 323, 241, 296, 204, 296, 296, 103, 296, - 296, 199, 120, 65, 296, 296, 296, 296, 95, 296, - 296, 258, 296, 296, 296, 296, 272, 197, 231, 296, - 237, 323, 241, 296, 204, 296, 296, 103, 296, 296, - 199, 96, 68, 241, 296, 204, 296, 95, 103, 296, - 258, 199, 120, 61, 296, 272, 197, 231, 95, 237, - 323, 258, 296, 296, 296, 296, 272, 197, 231, 296, - 237, 323, 241, 296, 204, 296, 296, 103, 296, 296, - 199, 98, 69, 296, 296, 296, 296, 95, 296, 296, - 258, 296, 296, 296, 296, 272, 197, 231, 296, 237, - 323, 241, 296, 204, 296, 296, 103, 296, 296, 199, - 120, 72, 241, 296, 204, 296, 95, 103, 296, 258, - 199, 120, 47, 296, 272, 197, 231, 95, 237, 323, - 258, 296, 296, 296, 296, 272, 197, 231, 296, 237, - 323, 241, 192, 204, 296, 296, 103, 296, 296, 199, - 120, 60, 296, 296, 351, 296, 95, 296, 217, 258, - 296, 296, 296, 296, 272, 197, 231, 26, 237, 323, - 241, 296, 204, 16, 296, 103, 426, 296, 199, 125, - 296, 241, 296, 204, 296, 95, 103, 296, 426, 199, - 118, 296, 242, 272, 197, 231, 95, 237, 323, 296, - 296, 296, 296, 246, 272, 197, 231, 296, 237, 323, - 241, 296, 204, 278, 296, 103, 34, 296, 199, 121, - 279, 296, 296, 296, 296, 95, 296, 296, 296, 296, - 26, 296, 162, 272, 197, 231, 16, 237, 323, 241, - 296, 204, 296, 296, 103, 296, 296, 199, 123, 296, - 241, 296, 204, 296, 95, 103, 296, 296, 199, 114, - 296, 296, 272, 197, 231, 95, 237, 323, 296, 296, - 296, 296, 296, 272, 197, 231, 296, 237, 323, 241, - 296, 204, 296, 145, 103, 296, 296, 199, 124, 296, - 296, 296, 296, 286, 95, 39, 35, 243, 296, 296, - 296, 296, 272, 197, 231, 296, 237, 323, 241, 296, - 204, 296, 296, 103, 296, 296, 199, 115, 296, 241, - 296, 204, 296, 95, 103, 296, 296, 199, 113, 296, - 296, 272, 197, 231, 95, 237, 323, 296, 296, 296, - 296, 296, 272, 197, 231, 228, 237, 323, 241, 296, - 204, 296, 455, 103, 296, 455, 199, 119, 3, 455, - 439, 296, 296, 95, 296, 296, 296, 296, 296, 296, - 296, 272, 197, 231, 228, 237, 323, 296, 296, 296, - 296, 455, 296, 296, 455, 296, 296, 439, 455, 439, - 439, 228, 455, 296, 439, 296, 296, 137, 455, 296, - 296, 455, 296, 296, 32, 455, 439, 286, 296, 39, - 35, 243, 29, 296, 26, 296, 439, 296, 296, 439, - 16, 455, 296, 439, 306, 43, 40, 38, 296, 296, - 296, 296, 296, 439, 296, 296, 439, 296, 455, 296, - 439, 26, 311, 312, 313, 316, 296, 16, 228, 296, - 296, 296, 43, 40, 38, 455, 296, 296, 455, 296, - 296, 296, 455, 439, 296, 296, 19, 296, 296, 311, - 312, 313, 316, 455, 296, 296, 455, 296, 296, 296, - 455, 439, 296, 296, 296, 43, 40, 38, 296, 296, - 439, 296, 296, 439, 174, 455, 296, 439, 296, 240, - 309, 296, 311, 312, 313, 316, 296, 289, 439, 296, - 36, 439, 296, 455, 296, 439, 296, 296, 43, 40, - 38, 296, 296, 43, 40, 38, 296, 296, 296, 296, - 296, 43, 40, 38, 296, 311, 312, 313, 316, 296, - 311, 312, 313, 316, 296, 43, 40, 38, 311, 312, - 313, 316, 273, 43, 40, 38, 296, 296, 296, 296, - 296, 296, 311, 312, 313, 316, 296, 296, 296, 296, - 311, 312, 313, 316, 455, 296, 296, 455, 43, 40, - 38, 455, 439, 218, 43, 40, 38, 296, 296, 296, - 296, 296, 296, 296, 296, 311, 312, 313, 316, 296, - 296, 311, 312, 313, 316, 296, 296, 296, 296, 439, - 296, 296, 439, 296, 455, 296, 439, - ); - public static $yy_lookahead = array( - 9, 10, 11, 12, 12, 14, 14, 16, 16, 18, - 19, 20, 9, 34, 102, 12, 25, 13, 70, 16, - 29, 30, 31, 35, 33, 21, 35, 23, 95, 38, - 26, 52, 41, 42, 43, 44, 32, 46, 34, 48, - 36, 50, 51, 52, 53, 53, 98, 99, 44, 58, - 59, 9, 10, 11, 12, 22, 14, 13, 16, 15, - 18, 19, 20, 85, 86, 87, 15, 25, 17, 21, - 26, 29, 30, 31, 44, 33, 32, 35, 45, 35, - 38, 51, 34, 41, 42, 43, 44, 35, 46, 77, - 48, 47, 50, 51, 14, 53, 16, 13, 47, 47, - 58, 59, 9, 10, 11, 12, 22, 14, 35, 16, - 26, 18, 19, 20, 102, 103, 32, 44, 25, 34, - 47, 36, 29, 30, 31, 52, 33, 14, 35, 45, - 50, 38, 26, 53, 41, 42, 43, 44, 32, 46, - 66, 48, 68, 50, 51, 77, 53, 15, 35, 7, - 8, 58, 59, 9, 10, 11, 12, 12, 14, 14, - 16, 16, 18, 19, 20, 9, 53, 1, 12, 25, - 102, 82, 16, 29, 30, 31, 44, 33, 33, 35, - 106, 107, 38, 51, 44, 41, 42, 43, 44, 35, - 46, 51, 48, 82, 50, 51, 22, 53, 53, 13, - 73, 47, 58, 59, 9, 10, 11, 12, 22, 14, - 83, 16, 26, 18, 19, 20, 28, 12, 32, 45, - 25, 22, 70, 35, 29, 30, 31, 65, 33, 102, - 35, 45, 73, 38, 60, 47, 41, 42, 43, 44, - 35, 46, 83, 48, 45, 50, 51, 95, 53, 71, - 95, 52, 74, 58, 59, 9, 10, 11, 12, 81, - 14, 102, 16, 73, 18, 19, 20, 34, 90, 36, - 1, 25, 94, 83, 81, 29, 30, 31, 66, 33, - 68, 35, 13, 96, 38, 98, 99, 41, 42, 43, - 44, 15, 46, 100, 48, 26, 50, 51, 14, 53, - 71, 32, 17, 74, 58, 59, 9, 10, 11, 12, - 81, 14, 34, 16, 36, 18, 19, 20, 82, 107, - 44, 35, 25, 94, 71, 95, 29, 30, 31, 44, - 33, 78, 35, 47, 81, 38, 51, 53, 41, 42, - 43, 44, 15, 46, 71, 48, 16, 50, 51, 22, - 53, 78, 79, 1, 81, 58, 59, 9, 10, 11, - 12, 15, 14, 17, 16, 1, 18, 19, 20, 66, - 34, 68, 36, 25, 16, 71, 44, 29, 30, 31, - 28, 33, 78, 35, 52, 81, 38, 62, 63, 41, - 42, 43, 44, 47, 46, 6, 48, 8, 50, 51, - 16, 53, 73, 1, 2, 40, 58, 59, 9, 10, - 11, 12, 83, 14, 77, 16, 52, 18, 19, 20, - 98, 99, 52, 95, 25, 97, 97, 92, 29, 30, - 31, 77, 33, 49, 35, 100, 14, 38, 16, 102, - 41, 42, 43, 44, 73, 46, 14, 48, 14, 50, - 51, 36, 53, 73, 83, 1, 102, 58, 59, 9, - 10, 11, 12, 83, 14, 17, 16, 50, 18, 19, - 20, 17, 71, 64, 65, 25, 73, 97, 15, 29, - 30, 31, 81, 33, 26, 35, 83, 53, 38, 73, - 32, 41, 42, 43, 44, 47, 46, 92, 48, 83, - 50, 51, 95, 53, 97, 100, 98, 99, 58, 59, - 9, 10, 11, 12, 23, 14, 52, 16, 16, 18, - 19, 20, 16, 7, 50, 16, 25, 13, 13, 16, - 29, 30, 31, 16, 33, 16, 35, 33, 33, 38, - 44, 16, 41, 42, 43, 44, 35, 46, 16, 48, - 95, 50, 51, 96, 53, 37, 38, 39, 81, 58, - 59, 66, 67, 68, 69, 83, 71, 72, 95, 74, - 75, 76, 54, 55, 56, 57, 81, 97, 60, 84, - 95, 13, 17, 80, 89, 90, 91, 1, 93, 94, - 2, 81, 103, 66, 67, 68, 69, 99, 71, 72, - 108, 74, 75, 76, 81, 37, 38, 39, 81, 108, - 108, 84, 108, 108, 108, 95, 89, 90, 91, 108, - 93, 94, 54, 55, 56, 57, 66, 108, 68, 108, - 108, 71, 108, 108, 74, 75, 76, 108, 108, 21, - 108, 81, 108, 108, 84, 9, 108, 108, 12, 89, - 90, 91, 16, 93, 94, 37, 38, 39, 108, 108, - 108, 66, 26, 68, 104, 105, 71, 108, 32, 74, - 75, 76, 54, 55, 56, 57, 81, 1, 108, 84, - 73, 108, 108, 108, 89, 90, 91, 108, 93, 94, - 83, 2, 85, 86, 87, 108, 108, 108, 108, 104, - 105, 108, 26, 3, 4, 5, 6, 108, 32, 9, - 10, 11, 12, 108, 108, 14, 108, 16, 18, 19, - 20, 108, 108, 108, 35, 25, 37, 38, 39, 29, - 30, 31, 66, 108, 68, 69, 47, 71, 72, 108, - 74, 75, 76, 54, 55, 56, 57, 81, 108, 48, - 84, 50, 108, 108, 53, 89, 90, 91, 108, 93, - 94, 3, 108, 108, 108, 108, 108, 9, 10, 11, - 12, 108, 14, 108, 108, 108, 18, 19, 20, 108, - 108, 13, 108, 25, 27, 108, 108, 29, 30, 31, - 108, 108, 108, 3, 37, 38, 39, 108, 108, 9, - 10, 11, 12, 108, 14, 37, 38, 39, 18, 19, - 20, 54, 55, 56, 57, 25, 108, 59, 60, 29, - 30, 31, 54, 55, 56, 57, 108, 108, 66, 108, - 68, 108, 1, 71, 108, 108, 74, 75, 76, 108, - 108, 108, 108, 81, 13, 108, 84, 108, 108, 59, - 60, 89, 90, 91, 108, 93, 94, 26, 108, 108, - 66, 108, 68, 32, 108, 71, 108, 105, 74, 75, - 76, 66, 78, 68, 108, 81, 71, 108, 84, 74, - 75, 76, 108, 89, 90, 91, 81, 93, 94, 84, - 9, 108, 108, 12, 89, 90, 91, 16, 93, 94, - 66, 108, 68, 108, 108, 71, 101, 108, 74, 75, - 76, 108, 108, 108, 108, 81, 108, 108, 84, 9, - 108, 108, 12, 89, 90, 91, 16, 93, 94, 66, - 49, 68, 108, 108, 71, 101, 108, 74, 75, 76, - 66, 78, 68, 108, 81, 71, 108, 84, 74, 75, - 76, 108, 89, 90, 91, 81, 93, 94, 84, 49, - 108, 108, 108, 89, 90, 91, 108, 93, 94, 66, - 108, 68, 73, 108, 71, 101, 77, 74, 75, 76, - 108, 108, 83, 108, 81, 108, 108, 84, 9, 108, - 108, 12, 89, 90, 91, 16, 93, 94, 66, 108, - 68, 102, 108, 71, 108, 108, 74, 75, 76, 66, - 108, 68, 108, 81, 71, 108, 84, 74, 75, 76, - 108, 89, 90, 91, 81, 93, 94, 84, 49, 1, - 108, 108, 89, 90, 91, 108, 93, 94, 66, 108, - 68, 13, 108, 71, 108, 108, 74, 75, 76, 108, - 108, 108, 108, 81, 26, 108, 84, 108, 108, 108, - 32, 89, 90, 91, 108, 93, 94, 66, 108, 68, - 108, 108, 71, 108, 108, 74, 75, 76, 66, 108, - 68, 108, 81, 71, 108, 84, 74, 75, 76, 108, - 89, 90, 91, 81, 93, 94, 84, 108, 108, 108, - 73, 89, 90, 91, 77, 93, 94, 66, 108, 68, - 83, 108, 71, 108, 108, 74, 75, 76, 108, 108, - 108, 108, 81, 108, 108, 84, 108, 108, 108, 102, - 89, 90, 91, 108, 93, 94, 66, 108, 68, 108, - 108, 71, 108, 108, 74, 75, 76, 66, 108, 68, - 108, 81, 71, 108, 84, 74, 75, 76, 108, 89, - 90, 91, 81, 93, 94, 84, 108, 108, 108, 108, - 89, 90, 91, 108, 93, 94, 66, 108, 68, 108, - 108, 71, 108, 108, 74, 75, 76, 108, 108, 108, - 108, 81, 108, 108, 84, 108, 108, 108, 108, 89, - 90, 91, 108, 93, 94, 66, 108, 68, 108, 108, - 71, 108, 108, 74, 75, 76, 66, 108, 68, 108, - 81, 71, 108, 84, 74, 75, 76, 108, 89, 90, - 91, 81, 93, 94, 84, 108, 108, 108, 108, 89, - 90, 91, 108, 93, 94, 66, 108, 68, 108, 108, - 71, 108, 108, 74, 75, 76, 108, 108, 108, 108, - 81, 108, 108, 84, 108, 108, 108, 108, 89, 90, - 91, 108, 93, 94, 66, 108, 68, 108, 108, 71, - 108, 108, 74, 75, 76, 66, 108, 68, 108, 81, - 71, 108, 84, 74, 75, 76, 108, 89, 90, 91, - 81, 93, 94, 84, 108, 108, 108, 108, 89, 90, - 91, 108, 93, 94, 66, 108, 68, 108, 108, 71, - 108, 108, 74, 75, 76, 108, 108, 108, 108, 81, - 108, 108, 84, 108, 108, 108, 108, 89, 90, 91, - 108, 93, 94, 66, 108, 68, 108, 108, 71, 108, - 108, 74, 75, 76, 66, 108, 68, 108, 81, 71, - 108, 84, 74, 75, 76, 108, 89, 90, 91, 81, - 93, 94, 84, 108, 108, 108, 108, 89, 90, 91, - 108, 93, 94, 66, 108, 68, 108, 108, 71, 108, - 108, 74, 75, 76, 108, 108, 108, 108, 81, 108, - 108, 84, 108, 108, 108, 108, 89, 90, 91, 108, - 93, 94, 66, 108, 68, 108, 108, 71, 108, 108, - 74, 75, 76, 66, 108, 68, 108, 81, 71, 108, - 84, 74, 75, 76, 108, 89, 90, 91, 81, 93, - 94, 84, 108, 108, 108, 108, 89, 90, 91, 108, - 93, 94, 66, 108, 68, 108, 108, 71, 108, 108, - 74, 75, 76, 108, 108, 108, 108, 81, 108, 108, - 84, 108, 108, 108, 108, 89, 90, 91, 108, 93, - 94, 66, 108, 68, 108, 108, 71, 108, 108, 74, - 75, 76, 66, 108, 68, 108, 81, 71, 108, 84, - 74, 75, 76, 108, 89, 90, 91, 81, 93, 94, - 84, 108, 108, 108, 108, 89, 90, 91, 108, 93, - 94, 66, 1, 68, 108, 108, 71, 108, 108, 74, - 75, 76, 108, 108, 13, 108, 81, 108, 17, 84, - 108, 108, 108, 108, 89, 90, 91, 26, 93, 94, - 66, 108, 68, 32, 108, 71, 35, 108, 74, 75, - 108, 66, 108, 68, 108, 81, 71, 108, 47, 74, - 75, 108, 88, 89, 90, 91, 81, 93, 94, 108, - 108, 108, 108, 88, 89, 90, 91, 108, 93, 94, - 66, 108, 68, 9, 108, 71, 12, 108, 74, 75, - 16, 108, 108, 108, 108, 81, 108, 108, 108, 108, - 26, 108, 28, 89, 90, 91, 32, 93, 94, 66, - 108, 68, 108, 108, 71, 108, 108, 74, 75, 108, - 66, 108, 68, 108, 81, 71, 108, 108, 74, 75, - 108, 108, 89, 90, 91, 81, 93, 94, 108, 108, - 108, 108, 108, 89, 90, 91, 108, 93, 94, 66, - 108, 68, 108, 73, 71, 108, 108, 74, 75, 108, - 108, 108, 108, 83, 81, 85, 86, 87, 108, 108, - 108, 108, 89, 90, 91, 108, 93, 94, 66, 108, - 68, 108, 108, 71, 108, 108, 74, 75, 108, 66, - 108, 68, 108, 81, 71, 108, 108, 74, 75, 108, - 108, 89, 90, 91, 81, 93, 94, 108, 108, 108, - 108, 108, 89, 90, 91, 2, 93, 94, 66, 108, - 68, 108, 9, 71, 108, 12, 74, 75, 15, 16, - 17, 108, 108, 81, 108, 108, 108, 108, 108, 108, - 108, 89, 90, 91, 2, 93, 94, 108, 108, 108, - 108, 9, 108, 108, 12, 108, 108, 44, 16, 17, - 47, 2, 49, 108, 51, 108, 108, 73, 9, 108, - 108, 12, 108, 108, 15, 16, 17, 83, 108, 85, - 86, 87, 24, 108, 26, 108, 44, 108, 108, 47, - 32, 49, 108, 51, 52, 37, 38, 39, 108, 108, - 108, 108, 108, 44, 108, 108, 47, 108, 49, 108, - 51, 26, 54, 55, 56, 57, 108, 32, 2, 108, - 108, 108, 37, 38, 39, 9, 108, 108, 12, 108, - 108, 108, 16, 17, 108, 108, 2, 108, 108, 54, - 55, 56, 57, 9, 108, 108, 12, 108, 108, 108, - 16, 17, 108, 108, 108, 37, 38, 39, 108, 108, - 44, 108, 108, 47, 13, 49, 108, 51, 108, 13, - 52, 108, 54, 55, 56, 57, 108, 13, 44, 108, - 2, 47, 108, 49, 108, 51, 108, 108, 37, 38, - 39, 108, 108, 37, 38, 39, 108, 108, 108, 108, - 108, 37, 38, 39, 108, 54, 55, 56, 57, 108, - 54, 55, 56, 57, 108, 37, 38, 39, 54, 55, - 56, 57, 36, 37, 38, 39, 108, 108, 108, 108, - 108, 108, 54, 55, 56, 57, 108, 108, 108, 108, - 54, 55, 56, 57, 9, 108, 108, 12, 37, 38, - 39, 16, 17, 36, 37, 38, 39, 108, 108, 108, - 108, 108, 108, 108, 108, 54, 55, 56, 57, 108, - 108, 54, 55, 56, 57, 108, 108, 108, 108, 44, - 108, 108, 47, 108, 49, 108, 51, -); - const YY_SHIFT_USE_DFLT = -22; - const YY_SHIFT_MAX = 230; - public static $yy_shift_ofst = array( - -22, 501, 501, 93, 399, 399, 450, 93, 93, 93, - 399, 450, -9, 93, 93, 93, 93, 93, 93, 144, - 93, 195, 93, 93, 93, 246, 195, 93, 93, 93, - 93, 93, 297, 93, 93, 93, 93, 348, 42, 42, - 42, 42, 42, 42, 42, 42, 1768, 1795, 1795, 701, - 758, 1521, 80, 676, 113, 790, 1927, 1828, 1896, 568, - 768, 1861, 757, 1866, 1874, 1888, 618, 518, 1921, 1921, - 1921, 1921, 1921, 1921, 1921, 1921, 1921, 1921, 1921, 1921, - 1921, 1921, 1921, 1584, 636, 285, 676, 676, 346, 113, - 113, 402, 700, 1723, -8, 910, 831, 269, 1028, 51, - 3, 3, 422, 448, 352, 106, 422, 106, 458, 364, - 434, 454, 106, 166, 166, 166, 166, 565, 166, 166, - 166, 586, 565, 166, 166, -22, -22, 1752, 1769, 1826, - 1844, 1945, 145, 979, 156, 132, 284, 106, 140, 106, - 30, 140, 140, 30, 106, 106, 106, 140, 106, 106, - 140, 106, 327, 106, 106, 106, 140, 140, 106, 140, - 205, 106, 284, 166, 565, 588, 565, 588, 565, 166, - 166, -12, 166, -22, -22, -22, -22, -22, -22, 689, - 4, 44, 84, 186, 73, 881, 199, 188, 174, 286, - 48, 336, 384, 389, 332, 142, -21, 52, 154, 33, - 85, 276, 278, 233, 515, 509, 474, 516, 502, 464, - 491, 415, 417, 432, 514, 370, 463, 506, 365, 513, - -12, 517, 504, 519, 505, 511, 496, 525, 532, 330, - 358, -); - const YY_REDUCE_USE_DFLT = -89; - const YY_REDUCE_MAX = 178; - public static $yy_reduce_ofst = array( - 325, 527, 495, 666, 595, 560, 863, 874, 834, 805, - 762, 794, 1179, 1455, 1208, 1012, 1386, 1139, 1070, 1110, - 1150, 1219, 1248, 1277, 1288, 1317, 1346, 1357, 1415, 1426, - 1081, 1041, 1001, 972, 943, 932, 903, 1484, 1495, 1622, - 1633, 1662, 1593, 1564, 1553, 1524, 1704, 607, 1590, 178, - 74, 1027, 229, 899, 273, 212, -22, -22, -22, -22, - -22, -22, -22, -22, -22, -22, -22, -22, -22, -22, - -22, -22, -22, -22, -22, -22, -22, -22, -22, -22, - -22, -22, -22, 380, 329, 187, 159, 127, -52, 253, - 304, 12, 303, 152, 193, 328, 68, 68, 68, 322, - 328, 407, 405, 322, 68, 190, 335, 416, 403, 68, - 401, 354, 371, 68, 68, 68, 337, 322, 68, 68, - 68, 68, 408, 68, 68, 68, 409, 455, 455, 455, - 455, 455, 510, 480, 455, 455, 477, 482, 457, 482, - 473, 457, 457, 485, 482, 482, 482, 457, 482, 482, - 457, 482, 503, 482, 482, 482, 457, 457, 482, 457, - 520, 482, 523, -88, 498, 489, 498, 489, 498, -88, - -88, -67, -88, 111, 155, 89, 236, 230, 162, -); - public static $yyExpectedTokens = array( - array(), - array(9, 10, 11, 12, 14, 16, 18, 19, 20, 25, 29, 30, 31, 33, 35, 38, 41, 42, 43, 44, 46, 48, 50, 51, 53, 58, 59, ), - array(9, 10, 11, 12, 14, 16, 18, 19, 20, 25, 29, 30, 31, 33, 35, 38, 41, 42, 43, 44, 46, 48, 50, 51, 53, 58, 59, ), - array(9, 10, 11, 12, 14, 16, 18, 19, 20, 25, 29, 30, 31, 33, 35, 38, 41, 42, 43, 44, 46, 48, 50, 51, 53, 58, 59, ), - array(9, 10, 11, 12, 14, 16, 18, 19, 20, 25, 29, 30, 31, 33, 35, 38, 41, 42, 43, 44, 46, 48, 50, 51, 53, 58, 59, ), - array(9, 10, 11, 12, 14, 16, 18, 19, 20, 25, 29, 30, 31, 33, 35, 38, 41, 42, 43, 44, 46, 48, 50, 51, 53, 58, 59, ), - array(9, 10, 11, 12, 14, 16, 18, 19, 20, 25, 29, 30, 31, 33, 35, 38, 41, 42, 43, 44, 46, 48, 50, 51, 53, 58, 59, ), - array(9, 10, 11, 12, 14, 16, 18, 19, 20, 25, 29, 30, 31, 33, 35, 38, 41, 42, 43, 44, 46, 48, 50, 51, 53, 58, 59, ), - array(9, 10, 11, 12, 14, 16, 18, 19, 20, 25, 29, 30, 31, 33, 35, 38, 41, 42, 43, 44, 46, 48, 50, 51, 53, 58, 59, ), - array(9, 10, 11, 12, 14, 16, 18, 19, 20, 25, 29, 30, 31, 33, 35, 38, 41, 42, 43, 44, 46, 48, 50, 51, 53, 58, 59, ), - array(9, 10, 11, 12, 14, 16, 18, 19, 20, 25, 29, 30, 31, 33, 35, 38, 41, 42, 43, 44, 46, 48, 50, 51, 53, 58, 59, ), - array(9, 10, 11, 12, 14, 16, 18, 19, 20, 25, 29, 30, 31, 33, 35, 38, 41, 42, 43, 44, 46, 48, 50, 51, 53, 58, 59, ), - array(9, 10, 11, 12, 14, 16, 18, 19, 20, 25, 29, 30, 31, 33, 35, 38, 41, 42, 43, 44, 46, 48, 50, 51, 52, 53, 58, 59, ), - array(9, 10, 11, 12, 14, 16, 18, 19, 20, 25, 29, 30, 31, 33, 35, 38, 41, 42, 43, 44, 46, 48, 50, 51, 53, 58, 59, ), - array(9, 10, 11, 12, 14, 16, 18, 19, 20, 25, 29, 30, 31, 33, 35, 38, 41, 42, 43, 44, 46, 48, 50, 51, 53, 58, 59, ), - array(9, 10, 11, 12, 14, 16, 18, 19, 20, 25, 29, 30, 31, 33, 35, 38, 41, 42, 43, 44, 46, 48, 50, 51, 53, 58, 59, ), - array(9, 10, 11, 12, 14, 16, 18, 19, 20, 25, 29, 30, 31, 33, 35, 38, 41, 42, 43, 44, 46, 48, 50, 51, 53, 58, 59, ), - array(9, 10, 11, 12, 14, 16, 18, 19, 20, 25, 29, 30, 31, 33, 35, 38, 41, 42, 43, 44, 46, 48, 50, 51, 53, 58, 59, ), - array(9, 10, 11, 12, 14, 16, 18, 19, 20, 25, 29, 30, 31, 33, 35, 38, 41, 42, 43, 44, 46, 48, 50, 51, 53, 58, 59, ), - array(9, 10, 11, 12, 14, 16, 18, 19, 20, 25, 29, 30, 31, 33, 35, 38, 41, 42, 43, 44, 46, 48, 50, 51, 53, 58, 59, ), - array(9, 10, 11, 12, 14, 16, 18, 19, 20, 25, 29, 30, 31, 33, 35, 38, 41, 42, 43, 44, 46, 48, 50, 51, 53, 58, 59, ), - array(9, 10, 11, 12, 14, 16, 18, 19, 20, 25, 29, 30, 31, 33, 35, 38, 41, 42, 43, 44, 46, 48, 50, 51, 53, 58, 59, ), - array(9, 10, 11, 12, 14, 16, 18, 19, 20, 25, 29, 30, 31, 33, 35, 38, 41, 42, 43, 44, 46, 48, 50, 51, 53, 58, 59, ), - array(9, 10, 11, 12, 14, 16, 18, 19, 20, 25, 29, 30, 31, 33, 35, 38, 41, 42, 43, 44, 46, 48, 50, 51, 53, 58, 59, ), - array(9, 10, 11, 12, 14, 16, 18, 19, 20, 25, 29, 30, 31, 33, 35, 38, 41, 42, 43, 44, 46, 48, 50, 51, 53, 58, 59, ), - array(9, 10, 11, 12, 14, 16, 18, 19, 20, 25, 29, 30, 31, 33, 35, 38, 41, 42, 43, 44, 46, 48, 50, 51, 53, 58, 59, ), - array(9, 10, 11, 12, 14, 16, 18, 19, 20, 25, 29, 30, 31, 33, 35, 38, 41, 42, 43, 44, 46, 48, 50, 51, 53, 58, 59, ), - array(9, 10, 11, 12, 14, 16, 18, 19, 20, 25, 29, 30, 31, 33, 35, 38, 41, 42, 43, 44, 46, 48, 50, 51, 53, 58, 59, ), - array(9, 10, 11, 12, 14, 16, 18, 19, 20, 25, 29, 30, 31, 33, 35, 38, 41, 42, 43, 44, 46, 48, 50, 51, 53, 58, 59, ), - array(9, 10, 11, 12, 14, 16, 18, 19, 20, 25, 29, 30, 31, 33, 35, 38, 41, 42, 43, 44, 46, 48, 50, 51, 53, 58, 59, ), - array(9, 10, 11, 12, 14, 16, 18, 19, 20, 25, 29, 30, 31, 33, 35, 38, 41, 42, 43, 44, 46, 48, 50, 51, 53, 58, 59, ), - array(9, 10, 11, 12, 14, 16, 18, 19, 20, 25, 29, 30, 31, 33, 35, 38, 41, 42, 43, 44, 46, 48, 50, 51, 53, 58, 59, ), - array(9, 10, 11, 12, 14, 16, 18, 19, 20, 25, 29, 30, 31, 33, 35, 38, 41, 42, 43, 44, 46, 48, 50, 51, 53, 58, 59, ), - array(9, 10, 11, 12, 14, 16, 18, 19, 20, 25, 29, 30, 31, 33, 35, 38, 41, 42, 43, 44, 46, 48, 50, 51, 53, 58, 59, ), - array(9, 10, 11, 12, 14, 16, 18, 19, 20, 25, 29, 30, 31, 33, 35, 38, 41, 42, 43, 44, 46, 48, 50, 51, 53, 58, 59, ), - array(9, 10, 11, 12, 14, 16, 18, 19, 20, 25, 29, 30, 31, 33, 35, 38, 41, 42, 43, 44, 46, 48, 50, 51, 53, 58, 59, ), - array(9, 10, 11, 12, 14, 16, 18, 19, 20, 25, 29, 30, 31, 33, 35, 38, 41, 42, 43, 44, 46, 48, 50, 51, 53, 58, 59, ), - array(9, 10, 11, 12, 14, 16, 18, 19, 20, 25, 29, 30, 31, 33, 35, 38, 41, 42, 43, 44, 46, 48, 50, 51, 53, 58, 59, ), - array(9, 10, 11, 12, 14, 16, 18, 19, 20, 25, 29, 30, 31, 33, 35, 38, 41, 42, 43, 44, 46, 48, 50, 51, 53, 58, 59, ), - array(9, 10, 11, 12, 14, 16, 18, 19, 20, 25, 29, 30, 31, 33, 35, 38, 41, 42, 43, 44, 46, 48, 50, 51, 53, 58, 59, ), - array(9, 10, 11, 12, 14, 16, 18, 19, 20, 25, 29, 30, 31, 33, 35, 38, 41, 42, 43, 44, 46, 48, 50, 51, 53, 58, 59, ), - array(9, 10, 11, 12, 14, 16, 18, 19, 20, 25, 29, 30, 31, 33, 35, 38, 41, 42, 43, 44, 46, 48, 50, 51, 53, 58, 59, ), - array(9, 10, 11, 12, 14, 16, 18, 19, 20, 25, 29, 30, 31, 33, 35, 38, 41, 42, 43, 44, 46, 48, 50, 51, 53, 58, 59, ), - array(9, 10, 11, 12, 14, 16, 18, 19, 20, 25, 29, 30, 31, 33, 35, 38, 41, 42, 43, 44, 46, 48, 50, 51, 53, 58, 59, ), - array(9, 10, 11, 12, 14, 16, 18, 19, 20, 25, 29, 30, 31, 33, 35, 38, 41, 42, 43, 44, 46, 48, 50, 51, 53, 58, 59, ), - array(9, 10, 11, 12, 14, 16, 18, 19, 20, 25, 29, 30, 31, 33, 35, 38, 41, 42, 43, 44, 46, 48, 50, 51, 53, 58, 59, ), - array(24, 26, 32, 37, 38, 39, 54, 55, 56, 57, ), - array(26, 32, 37, 38, 39, 54, 55, 56, 57, ), - array(26, 32, 37, 38, 39, 54, 55, 56, 57, ), - array(14, 16, 48, 50, 53, ), - array(3, 9, 10, 11, 12, 14, 18, 19, 20, 25, 29, 30, 31, 59, 60, ), - array(1, 13, 17, 26, 32, 35, 47, ), - array(14, 16, 50, 53, ), - array(1, 26, 32, ), - array(14, 35, 53, ), - array(3, 9, 10, 11, 12, 14, 18, 19, 20, 25, 29, 30, 31, 59, 60, ), - array(36, 37, 38, 39, 54, 55, 56, 57, ), - array(37, 38, 39, 52, 54, 55, 56, 57, ), - array(36, 37, 38, 39, 54, 55, 56, 57, ), - array(13, 37, 38, 39, 54, 55, 56, 57, ), - array(13, 37, 38, 39, 54, 55, 56, 57, ), - array(13, 37, 38, 39, 54, 55, 56, 57, ), - array(27, 37, 38, 39, 54, 55, 56, 57, ), - array(13, 37, 38, 39, 54, 55, 56, 57, ), - array(13, 37, 38, 39, 54, 55, 56, 57, ), - array(2, 37, 38, 39, 54, 55, 56, 57, ), - array(21, 37, 38, 39, 54, 55, 56, 57, ), - array(37, 38, 39, 54, 55, 56, 57, 60, ), - array(37, 38, 39, 54, 55, 56, 57, ), - array(37, 38, 39, 54, 55, 56, 57, ), - array(37, 38, 39, 54, 55, 56, 57, ), - array(37, 38, 39, 54, 55, 56, 57, ), - array(37, 38, 39, 54, 55, 56, 57, ), - array(37, 38, 39, 54, 55, 56, 57, ), - array(37, 38, 39, 54, 55, 56, 57, ), - array(37, 38, 39, 54, 55, 56, 57, ), - array(37, 38, 39, 54, 55, 56, 57, ), - array(37, 38, 39, 54, 55, 56, 57, ), - array(37, 38, 39, 54, 55, 56, 57, ), - array(37, 38, 39, 54, 55, 56, 57, ), - array(37, 38, 39, 54, 55, 56, 57, ), - array(37, 38, 39, 54, 55, 56, 57, ), - array(37, 38, 39, 54, 55, 56, 57, ), - array(9, 12, 16, 26, 28, 32, ), - array(9, 12, 16, 26, 32, ), - array(17, 44, 51, ), - array(1, 26, 32, ), - array(1, 26, 32, ), - array(15, 17, 47, ), - array(14, 35, 53, ), - array(14, 35, 53, ), - array(1, 2, ), - array(3, 4, 5, 6, 9, 10, 11, 12, 18, 19, 20, 25, 29, 30, 31, ), - array(2, 9, 12, 15, 16, 17, 44, 47, 49, 51, ), - array(12, 14, 16, 53, ), - array(9, 12, 16, 49, ), - array(1, 13, 26, 32, ), - array(1, 13, 26, 32, ), - array(1, 13, 26, 32, ), - array(15, 17, 47, ), - array(9, 12, 16, ), - array(9, 12, 16, ), - array(14, 16, ), - array(17, 47, ), - array(1, 28, ), - array(26, 32, ), - array(14, 16, ), - array(26, 32, ), - array(26, 32, ), - array(1, 52, ), - array(14, 53, ), - array(1, 17, ), - array(26, 32, ), - array(1, ), - array(1, ), - array(1, ), - array(1, ), - array(17, ), - array(1, ), - array(1, ), - array(1, ), - array(1, ), - array(17, ), - array(1, ), - array(1, ), - array(), - array(), - array(2, 9, 12, 16, 17, 44, 47, 49, 51, 52, ), - array(2, 9, 12, 15, 16, 17, 44, 47, 49, 51, ), - array(2, 9, 12, 16, 17, 44, 47, 49, 51, ), - array(2, 9, 12, 16, 17, 44, 47, 49, 51, ), - array(9, 12, 16, 17, 44, 47, 49, 51, ), - array(12, 14, 16, 33, 53, ), - array(9, 12, 16, 49, ), - array(9, 12, 16, ), - array(15, 44, 51, ), - array(14, 53, ), - array(26, 32, ), - array(44, 51, ), - array(26, 32, ), - array(44, 51, ), - array(44, 51, ), - array(44, 51, ), - array(44, 51, ), - array(26, 32, ), - array(26, 32, ), - array(26, 32, ), - array(44, 51, ), - array(26, 32, ), - array(26, 32, ), - array(44, 51, ), - array(26, 32, ), - array(15, 22, ), - array(26, 32, ), - array(26, 32, ), - array(26, 32, ), - array(44, 51, ), - array(44, 51, ), - array(26, 32, ), - array(44, 51, ), - array(12, 35, ), - array(26, 32, ), - array(14, 53, ), - array(1, ), - array(17, ), - array(2, ), - array(17, ), - array(2, ), - array(17, ), - array(1, ), - array(1, ), - array(35, ), - array(1, ), - array(), - array(), - array(), - array(), - array(), - array(), - array(2, 35, 37, 38, 39, 47, 54, 55, 56, 57, ), - array(13, 21, 23, 26, 32, 34, 36, 44, ), - array(13, 15, 26, 32, 35, 47, ), - array(13, 22, 26, 32, 45, ), - array(13, 22, 26, 32, 45, ), - array(35, 44, 47, 52, ), - array(9, 12, 16, 49, ), - array(22, 45, 52, ), - array(28, 35, 47, ), - array(22, 45, 60, ), - array(35, 47, ), - array(21, 34, ), - array(34, 36, ), - array(16, 49, ), - array(6, 8, ), - array(44, 52, ), - array(7, 8, ), - array(34, 52, ), - array(35, 47, ), - array(35, 47, ), - array(22, 45, ), - array(34, 36, ), - array(15, 44, ), - array(34, 36, ), - array(34, 36, ), - array(13, ), - array(16, ), - array(50, ), - array(7, ), - array(16, ), - array(52, ), - array(23, ), - array(36, ), - array(50, ), - array(14, ), - array(13, ), - array(52, ), - array(15, ), - array(16, ), - array(40, ), - array(16, ), - array(35, ), - array(16, ), - array(33, ), - array(16, ), - array(33, ), - array(35, ), - array(44, ), - array(16, ), - array(16, ), - array(16, ), - array(16, ), - 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(), -); - public static $yy_default = array( - 336, 512, 512, 512, 497, 497, 512, 474, 474, 474, - 512, 512, 512, 512, 512, 512, 512, 512, 512, 512, - 512, 512, 512, 512, 512, 512, 512, 512, 512, 512, - 512, 512, 512, 512, 512, 512, 512, 512, 512, 512, - 512, 512, 512, 512, 512, 512, 377, 377, 356, 512, - 512, 413, 512, 377, 512, 512, 512, 512, 512, 512, - 512, 512, 382, 512, 349, 512, 512, 512, 382, 379, - 389, 388, 384, 402, 473, 397, 498, 500, 401, 361, - 472, 499, 349, 377, 377, 487, 377, 377, 429, 512, - 512, 368, 326, 428, 512, 439, 391, 391, 391, 429, - 439, 439, 512, 429, 391, 377, 512, 377, 377, 391, - 512, 371, 358, 395, 394, 396, 373, 429, 400, 404, - 391, 404, 484, 406, 405, 481, 334, 428, 428, 428, - 428, 428, 512, 441, 439, 455, 512, 363, 435, 354, - 434, 437, 433, 432, 359, 357, 364, 436, 353, 367, - 466, 365, 512, 352, 350, 360, 467, 465, 346, 464, - 439, 366, 512, 369, 461, 475, 488, 476, 485, 372, - 422, 439, 374, 480, 439, 480, 480, 439, 334, 413, - 409, 413, 403, 403, 413, 440, 403, 413, 403, 413, - 512, 512, 512, 332, 409, 512, 512, 512, 423, 403, - 512, 409, 512, 512, 512, 512, 512, 512, 512, 418, - 385, 512, 512, 512, 512, 512, 512, 512, 415, 512, - 455, 512, 512, 512, 411, 486, 409, 512, 512, 512, - 512, 419, 407, 362, 445, 418, 425, 424, 420, 339, - 460, 421, 483, 398, 416, 340, 399, 455, 378, 337, - 338, 330, 328, 329, 442, 443, 444, 438, 392, 393, - 427, 426, 386, 417, 408, 390, 410, 331, 333, 335, - 412, 470, 414, 415, 503, 478, 495, 471, 459, 458, - 375, 457, 344, 462, 508, 493, 376, 496, 456, 509, - 494, 501, 504, 511, 510, 507, 505, 502, 506, 345, - 468, 469, 446, 355, 341, 452, 450, 454, 448, 453, - 447, 489, 490, 491, 463, 449, 492, 451, 327, 342, - 343, 370, 430, 431, 479, 477, -); - const YYNOCODE = 109; - const YYSTACKDEPTH = 500; - const YYNSTATE = 326; - const YYNRULE = 186; - const YYERRORSYMBOL = 61; - const YYERRSYMDT = 'yy0'; - const YYFALLBACK = 0; - public static $yyFallback = array( - ); - public function Trace($TraceFILE, $zTracePrompt) - { - if (!$TraceFILE) { - $zTracePrompt = 0; - } elseif (!$zTracePrompt) { - $TraceFILE = 0; - } - $this->yyTraceFILE = $TraceFILE; - $this->yyTracePrompt = $zTracePrompt; - } - - public function PrintTrace() - { - $this->yyTraceFILE = fopen('php://output', 'w'); - $this->yyTracePrompt = '
'; - } - - public $yyTraceFILE; - public $yyTracePrompt; - public $yyidx; /* Index of top element in stack */ - public $yyerrcnt; /* Shifts left before out of the error */ - public $yystack = array(); /* The parser's stack */ - - public $yyTokenName = array( - '$', 'VERT', 'COLON', 'TEXT', - 'STRIPON', 'STRIPOFF', 'LITERALSTART', 'LITERALEND', - 'LITERAL', 'SIMPELOUTPUT', 'SIMPLETAG', 'SMARTYBLOCKCHILDPARENT', - 'LDEL', 'RDEL', 'DOLLARID', 'EQUAL', - 'ID', 'PTR', 'LDELMAKENOCACHE', 'LDELIF', - 'LDELFOR', 'SEMICOLON', 'INCDEC', 'TO', - 'STEP', 'LDELFOREACH', 'SPACE', 'AS', - 'APTR', 'LDELSETFILTER', 'CLOSETAG', 'LDELSLASH', - 'ATTR', 'INTEGER', 'COMMA', 'OPENP', - 'CLOSEP', 'MATH', 'UNIMATH', 'ISIN', - 'QMARK', 'NOT', 'TYPECAST', 'HEX', - 'DOT', 'INSTANCEOF', 'SINGLEQUOTESTRING', 'DOUBLECOLON', - 'NAMESPACE', 'AT', 'HATCH', 'OPENB', - 'CLOSEB', 'DOLLAR', 'LOGOP', 'SLOGOP', - 'TLOGOP', 'SINGLECOND', 'ARRAYOPEN', 'QUOTE', - 'BACKTICK', 'error', 'start', 'template', - 'literal_e2', 'literal_e1', 'smartytag', 'tagbody', - 'tag', 'outattr', 'eqoutattr', 'varindexed', - 'output', 'attributes', 'variable', 'value', - 'expr', 'modifierlist', 'statement', 'statements', - 'foraction', 'varvar', 'modparameters', 'attribute', - 'ternary', 'tlop', 'lop', 'scond', - 'array', 'function', 'ns1', 'doublequoted_with_quotes', - 'static_class_access', 'arraydef', 'object', 'arrayindex', - 'indexdef', 'varvarele', 'objectchain', 'objectelement', - 'method', 'params', 'modifier', 'modparameter', - 'arrayelements', 'arrayelement', 'doublequoted', 'doublequotedcontent', - ); - - public static $yyRuleName = array( - 'start ::= template', - 'template ::= template TEXT', - 'template ::= template STRIPON', - 'template ::= template STRIPOFF', - 'template ::= template LITERALSTART literal_e2 LITERALEND', - 'literal_e2 ::= literal_e1 LITERALSTART literal_e1 LITERALEND', - 'literal_e2 ::= literal_e1', - 'literal_e1 ::= literal_e1 LITERAL', - 'literal_e1 ::=', - 'template ::= template smartytag', - 'template ::=', - 'smartytag ::= SIMPELOUTPUT', - 'smartytag ::= SIMPLETAG', - 'smartytag ::= SMARTYBLOCKCHILDPARENT', - 'smartytag ::= LDEL tagbody RDEL', - 'smartytag ::= tag RDEL', - 'tagbody ::= outattr', - 'tagbody ::= DOLLARID eqoutattr', - 'tagbody ::= varindexed eqoutattr', - 'eqoutattr ::= EQUAL outattr', - 'outattr ::= output attributes', - 'output ::= variable', - 'output ::= value', - 'output ::= expr', - '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 ::= LDELMAKENOCACHE DOLLARID', - '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 SPACE expr AS varvar attributes', - 'tag ::= LDELFOREACH SPACE expr AS varvar APTR varvar attributes', - 'tag ::= LDELFOREACH attributes', - 'tag ::= LDELSETFILTER ID modparameters', - 'tag ::= LDELSETFILTER ID modparameters modifierlist', - '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 ::= expr tlop value', - 'expr ::= expr lop expr', - 'expr ::= expr scond', - 'expr ::= expr ISIN array', - 'expr ::= expr ISIN value', - '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 ::= variable INSTANCEOF ns1', - 'value ::= variable INSTANCEOF variable', - 'value ::= SINGLEQUOTESTRING', - 'value ::= doublequoted_with_quotes', - 'value ::= varindexed DOUBLECOLON static_class_access', - 'value ::= smartytag', - 'value ::= value modifierlist', - 'value ::= NAMESPACE', - 'value ::= arraydef', - '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 UNIMATH 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 ::= SLOGOP', - 'tlop ::= TLOGOP', - 'scond ::= SINGLECOND', - 'arraydef ::= OPENB arrayelements CLOSEB', - 'arraydef ::= ARRAYOPEN arrayelements CLOSEP', - '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) - { - if ($tokenType === 0) { - return 'End of Input'; - } - if ($tokenType > 0 && $tokenType < count($this->yyTokenName)) { - return $this->yyTokenName[$tokenType]; - } else { - return 'Unknown'; - } - } - - public static function yy_destructor($yymajor, $yypminor) - { - switch ($yymajor) { - default: break; /* If no destructor action specified: do nothing */ - } - } - - public function yy_pop_parser_stack() - { - if (empty($this->yystack)) { - return; - } - $yytos = array_pop($this->yystack); - if ($this->yyTraceFILE && $this->yyidx >= 0) { - fwrite($this->yyTraceFILE, - $this->yyTracePrompt . 'Popping ' . $this->yyTokenName[$yytos->major] . - "\n"); - } - $yymajor = $yytos->major; - self::yy_destructor($yymajor, $yytos->minor); - $this->yyidx--; - - return $yymajor; - } - - public function __destruct() - { - while ($this->yystack !== Array()) { - $this->yy_pop_parser_stack(); - } - if (is_resource($this->yyTraceFILE)) { - fclose($this->yyTraceFILE); - } - } - - public function yy_get_expected_tokens($token) - { - static $res3 = array(); - static $res4 = array(); - $state = $this->yystack[$this->yyidx]->stateno; - $expected = self::$yyExpectedTokens[$state]; - if (isset($res3[$state][$token])) { - if ($res3[$state][$token]) { - return $expected; - } - } else { - if ($res3[$state][$token] = in_array($token, self::$yyExpectedTokens[$state], true)) { - return $expected; - } - } - $stack = $this->yystack; - $yyidx = $this->yyidx; - do { - $yyact = $this->yy_find_shift_action($token); - if ($yyact >= self::YYNSTATE && $yyact < self::YYNSTATE + self::YYNRULE) { - // reduce action - $done = 0; - do { - if ($done++ === 100) { - $this->yyidx = $yyidx; - $this->yystack = $stack; - // too much recursion prevents proper detection - // so give up - return array_unique($expected); - } - $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]); - if (isset(self::$yyExpectedTokens[$nextstate])) { - $expected = array_merge($expected, self::$yyExpectedTokens[$nextstate]); - if (isset($res4[$nextstate][$token])) { - if ($res4[$nextstate][$token]) { - $this->yyidx = $yyidx; - $this->yystack = $stack; - return array_unique($expected); - } - } else { - if ($res4[$nextstate][$token] = in_array($token, self::$yyExpectedTokens[$nextstate], true)) { - $this->yyidx = $yyidx; - $this->yystack = $stack; - return array_unique($expected); - } - } - } - if ($nextstate < self::YYNSTATE) { - // we need to shift a non-terminal - $this->yyidx++; - $x = new TP_yyStackEntry; - $x->stateno = $nextstate; - $x->major = self::$yyRuleInfo[$yyruleno][0]; - $this->yystack[$this->yyidx] = $x; - continue 2; - } elseif ($nextstate === self::YYNSTATE + self::YYNRULE + 1) { - $this->yyidx = $yyidx; - $this->yystack = $stack; - // the last token was just ignored, we can't accept - // by ignoring input, this is in essence ignoring a - // syntax error! - return array_unique($expected); - } elseif ($nextstate === self::YY_NO_ACTION) { - $this->yyidx = $yyidx; - $this->yystack = $stack; - // input accepted, but not shifted (I guess) - return $expected; - } else { - $yyact = $nextstate; - } - } while (true); - } - break; - } while (true); - $this->yyidx = $yyidx; - $this->yystack = $stack; - - return array_unique($expected); - } - - public function yy_is_expected_token($token) - { - static $res = array(); - static $res2 = array(); - if ($token === 0) { - return true; // 0 is not part of this - } - $state = $this->yystack[$this->yyidx]->stateno; - if (isset($res[$state][$token])) { - if ($res[$state][$token]) { - return true; - } - } else { - if ($res[$state][$token] = in_array($token, self::$yyExpectedTokens[$state], true)) { - return true; - } - } - $stack = $this->yystack; - $yyidx = $this->yyidx; - do { - $yyact = $this->yy_find_shift_action($token); - if ($yyact >= self::YYNSTATE && $yyact < self::YYNSTATE + self::YYNRULE) { - // reduce action - $done = 0; - do { - if ($done++ === 100) { - $this->yyidx = $yyidx; - $this->yystack = $stack; - // too much recursion prevents proper detection - // so give up - return true; - } - $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]); - if (isset($res2[$nextstate][$token])) { - if ($res2[$nextstate][$token]) { - $this->yyidx = $yyidx; - $this->yystack = $stack; - return true; - } - } else { - if ($res2[$nextstate][$token] = (isset(self::$yyExpectedTokens[$nextstate]) && in_array($token, self::$yyExpectedTokens[$nextstate], true))) { - $this->yyidx = $yyidx; - $this->yystack = $stack; - return true; - } - } - if ($nextstate < self::YYNSTATE) { - // we need to shift a non-terminal - $this->yyidx++; - $x = new TP_yyStackEntry; - $x->stateno = $nextstate; - $x->major = self::$yyRuleInfo[$yyruleno][0]; - $this->yystack[$this->yyidx] = $x; - continue 2; - } elseif ($nextstate === self::YYNSTATE + self::YYNRULE + 1) { - $this->yyidx = $yyidx; - $this->yystack = $stack; - if (!$token) { - // end of input: this is valid - return true; - } - // the last token was just ignored, we can't accept - // by ignoring input, this is in essence ignoring a - // syntax error! - return false; - } elseif ($nextstate === self::YY_NO_ACTION) { - $this->yyidx = $yyidx; - $this->yystack = $stack; - // input accepted, but not shifted (I guess) - return true; - } else { - $yyact = $nextstate; - } - } while (true); - } - break; - } while (true); - $this->yyidx = $yyidx; - $this->yystack = $stack; - - return true; - } - - public function yy_find_shift_action($iLookAhead) - { - $stateno = $this->yystack[$this->yyidx]->stateno; - - /* if ($this->yyidx < 0) return self::YY_NO_ACTION; */ - if (!isset(self::$yy_shift_ofst[$stateno])) { - // no shift actions - return self::$yy_default[$stateno]; - } - $i = self::$yy_shift_ofst[$stateno]; - if ($i === self::YY_SHIFT_USE_DFLT) { - return self::$yy_default[$stateno]; - } - if ($iLookAhead === self::YYNOCODE) { - return self::YY_NO_ACTION; - } - $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 ($this->yyTraceFILE) { - fwrite($this->yyTraceFILE, $this->yyTracePrompt . 'FALLBACK ' . - $this->yyTokenName[$iLookAhead] . ' => ' . - $this->yyTokenName[$iFallback] . "\n"); - } - - return $this->yy_find_shift_action($iFallback); - } - - return self::$yy_default[$stateno]; - } else { - return self::$yy_action[$i]; - } - } - - public function yy_find_reduce_action($stateno, $iLookAhead) - { - /* $stateno = $this->yystack[$this->yyidx]->stateno; */ - - if (!isset(self::$yy_reduce_ofst[$stateno])) { - return self::$yy_default[$stateno]; - } - $i = self::$yy_reduce_ofst[$stateno]; - if ($i === self::YY_REDUCE_USE_DFLT) { - return self::$yy_default[$stateno]; - } - if ($iLookAhead === self::YYNOCODE) { - return self::YY_NO_ACTION; - } - $i += $iLookAhead; - if ($i < 0 || $i >= self::YY_SZ_ACTTAB || - self::$yy_lookahead[$i] != $iLookAhead) { - return self::$yy_default[$stateno]; - } else { - return self::$yy_action[$i]; - } - } - - public function yy_shift($yyNewState, $yyMajor, $yypMinor) - { - $this->yyidx++; - if ($this->yyidx >= self::YYSTACKDEPTH) { - $this->yyidx--; - if ($this->yyTraceFILE) { - fprintf($this->yyTraceFILE, "%sStack Overflow!\n", $this->yyTracePrompt); - } - while ($this->yyidx >= 0) { - $this->yy_pop_parser_stack(); - } -// line 220 "../smarty/lexer/smarty_internal_templateparser.y" - - $this->internalError = true; - $this->compiler->trigger_template_error('Stack overflow in template parser'); - - return; - } - $yytos = new TP_yyStackEntry; - $yytos->stateno = $yyNewState; - $yytos->major = $yyMajor; - $yytos->minor = $yypMinor; - $this->yystack[] = $yytos; - if ($this->yyTraceFILE && $this->yyidx > 0) { - fprintf($this->yyTraceFILE, "%sShift %d\n", $this->yyTracePrompt, - $yyNewState); - fprintf($this->yyTraceFILE, "%sStack:", $this->yyTracePrompt); - for ($i = 1; $i <= $this->yyidx; $i++) { - fprintf($this->yyTraceFILE, " %s", - $this->yyTokenName[$this->yystack[$i]->major]); - } - fwrite($this->yyTraceFILE,"\n"); - } - } - - public static $yyRuleInfo = array( - array( 0 => 62, 1 => 1 ), - array( 0 => 63, 1 => 2 ), - array( 0 => 63, 1 => 2 ), - array( 0 => 63, 1 => 2 ), - array( 0 => 63, 1 => 4 ), - array( 0 => 64, 1 => 4 ), - array( 0 => 64, 1 => 1 ), - array( 0 => 65, 1 => 2 ), - array( 0 => 65, 1 => 0 ), - array( 0 => 63, 1 => 2 ), - array( 0 => 63, 1 => 0 ), - array( 0 => 66, 1 => 1 ), - array( 0 => 66, 1 => 1 ), - array( 0 => 66, 1 => 1 ), - array( 0 => 66, 1 => 3 ), - array( 0 => 66, 1 => 2 ), - array( 0 => 67, 1 => 1 ), - array( 0 => 67, 1 => 2 ), - array( 0 => 67, 1 => 2 ), - array( 0 => 70, 1 => 2 ), - array( 0 => 69, 1 => 2 ), - array( 0 => 72, 1 => 1 ), - array( 0 => 72, 1 => 1 ), - array( 0 => 72, 1 => 1 ), - array( 0 => 68, 1 => 3 ), - array( 0 => 68, 1 => 2 ), - array( 0 => 68, 1 => 4 ), - array( 0 => 68, 1 => 5 ), - array( 0 => 68, 1 => 6 ), - array( 0 => 68, 1 => 2 ), - array( 0 => 68, 1 => 2 ), - array( 0 => 68, 1 => 3 ), - array( 0 => 68, 1 => 2 ), - array( 0 => 68, 1 => 3 ), - array( 0 => 68, 1 => 8 ), - array( 0 => 80, 1 => 2 ), - array( 0 => 80, 1 => 1 ), - array( 0 => 68, 1 => 5 ), - array( 0 => 68, 1 => 7 ), - array( 0 => 68, 1 => 6 ), - array( 0 => 68, 1 => 8 ), - array( 0 => 68, 1 => 2 ), - array( 0 => 68, 1 => 3 ), - array( 0 => 68, 1 => 4 ), - array( 0 => 66, 1 => 1 ), - array( 0 => 68, 1 => 2 ), - array( 0 => 68, 1 => 3 ), - array( 0 => 68, 1 => 4 ), - array( 0 => 68, 1 => 5 ), - array( 0 => 73, 1 => 2 ), - array( 0 => 73, 1 => 1 ), - array( 0 => 73, 1 => 0 ), - array( 0 => 83, 1 => 4 ), - array( 0 => 83, 1 => 2 ), - array( 0 => 83, 1 => 2 ), - array( 0 => 83, 1 => 2 ), - array( 0 => 83, 1 => 2 ), - array( 0 => 83, 1 => 2 ), - array( 0 => 83, 1 => 4 ), - array( 0 => 79, 1 => 1 ), - array( 0 => 79, 1 => 3 ), - array( 0 => 78, 1 => 3 ), - array( 0 => 78, 1 => 3 ), - array( 0 => 78, 1 => 3 ), - array( 0 => 78, 1 => 3 ), - array( 0 => 76, 1 => 1 ), - array( 0 => 76, 1 => 1 ), - array( 0 => 76, 1 => 3 ), - array( 0 => 76, 1 => 3 ), - array( 0 => 76, 1 => 3 ), - array( 0 => 76, 1 => 3 ), - array( 0 => 76, 1 => 3 ), - array( 0 => 76, 1 => 2 ), - array( 0 => 76, 1 => 3 ), - array( 0 => 76, 1 => 3 ), - array( 0 => 84, 1 => 7 ), - array( 0 => 84, 1 => 7 ), - array( 0 => 75, 1 => 1 ), - array( 0 => 75, 1 => 2 ), - array( 0 => 75, 1 => 2 ), - array( 0 => 75, 1 => 2 ), - array( 0 => 75, 1 => 2 ), - array( 0 => 75, 1 => 1 ), - array( 0 => 75, 1 => 1 ), - array( 0 => 75, 1 => 3 ), - array( 0 => 75, 1 => 2 ), - array( 0 => 75, 1 => 2 ), - array( 0 => 75, 1 => 1 ), - array( 0 => 75, 1 => 1 ), - array( 0 => 75, 1 => 3 ), - array( 0 => 75, 1 => 3 ), - array( 0 => 75, 1 => 3 ), - array( 0 => 75, 1 => 1 ), - array( 0 => 75, 1 => 1 ), - array( 0 => 75, 1 => 3 ), - array( 0 => 75, 1 => 1 ), - array( 0 => 75, 1 => 2 ), - array( 0 => 75, 1 => 1 ), - array( 0 => 75, 1 => 1 ), - array( 0 => 75, 1 => 3 ), - array( 0 => 90, 1 => 1 ), - array( 0 => 90, 1 => 1 ), - array( 0 => 74, 1 => 1 ), - array( 0 => 74, 1 => 1 ), - array( 0 => 74, 1 => 3 ), - array( 0 => 74, 1 => 1 ), - array( 0 => 74, 1 => 3 ), - array( 0 => 74, 1 => 4 ), - array( 0 => 74, 1 => 3 ), - array( 0 => 74, 1 => 4 ), - array( 0 => 71, 1 => 2 ), - array( 0 => 71, 1 => 2 ), - array( 0 => 95, 1 => 2 ), - array( 0 => 95, 1 => 0 ), - array( 0 => 96, 1 => 2 ), - array( 0 => 96, 1 => 2 ), - array( 0 => 96, 1 => 4 ), - array( 0 => 96, 1 => 2 ), - array( 0 => 96, 1 => 2 ), - array( 0 => 96, 1 => 4 ), - array( 0 => 96, 1 => 3 ), - array( 0 => 96, 1 => 5 ), - array( 0 => 96, 1 => 3 ), - array( 0 => 96, 1 => 3 ), - array( 0 => 96, 1 => 3 ), - array( 0 => 96, 1 => 3 ), - array( 0 => 96, 1 => 3 ), - array( 0 => 96, 1 => 3 ), - array( 0 => 96, 1 => 2 ), - array( 0 => 81, 1 => 1 ), - array( 0 => 81, 1 => 1 ), - array( 0 => 81, 1 => 2 ), - array( 0 => 97, 1 => 1 ), - array( 0 => 97, 1 => 1 ), - array( 0 => 97, 1 => 3 ), - array( 0 => 94, 1 => 2 ), - array( 0 => 98, 1 => 1 ), - array( 0 => 98, 1 => 2 ), - array( 0 => 99, 1 => 3 ), - array( 0 => 99, 1 => 3 ), - array( 0 => 99, 1 => 5 ), - array( 0 => 99, 1 => 6 ), - array( 0 => 99, 1 => 2 ), - array( 0 => 89, 1 => 4 ), - array( 0 => 100, 1 => 4 ), - array( 0 => 100, 1 => 4 ), - array( 0 => 101, 1 => 3 ), - array( 0 => 101, 1 => 1 ), - array( 0 => 101, 1 => 0 ), - array( 0 => 77, 1 => 3 ), - array( 0 => 77, 1 => 2 ), - array( 0 => 102, 1 => 3 ), - array( 0 => 102, 1 => 2 ), - array( 0 => 82, 1 => 2 ), - array( 0 => 82, 1 => 0 ), - array( 0 => 103, 1 => 2 ), - array( 0 => 103, 1 => 3 ), - array( 0 => 103, 1 => 2 ), - array( 0 => 92, 1 => 1 ), - array( 0 => 92, 1 => 2 ), - array( 0 => 92, 1 => 1 ), - array( 0 => 92, 1 => 2 ), - array( 0 => 92, 1 => 3 ), - array( 0 => 86, 1 => 1 ), - array( 0 => 86, 1 => 1 ), - array( 0 => 85, 1 => 1 ), - array( 0 => 87, 1 => 1 ), - array( 0 => 93, 1 => 3 ), - array( 0 => 93, 1 => 3 ), - array( 0 => 104, 1 => 1 ), - array( 0 => 104, 1 => 3 ), - array( 0 => 104, 1 => 0 ), - array( 0 => 105, 1 => 3 ), - array( 0 => 105, 1 => 3 ), - array( 0 => 105, 1 => 1 ), - array( 0 => 91, 1 => 2 ), - array( 0 => 91, 1 => 3 ), - array( 0 => 106, 1 => 2 ), - array( 0 => 106, 1 => 1 ), - array( 0 => 107, 1 => 3 ), - array( 0 => 107, 1 => 3 ), - array( 0 => 107, 1 => 1 ), - array( 0 => 107, 1 => 3 ), - array( 0 => 107, 1 => 3 ), - array( 0 => 107, 1 => 1 ), - array( 0 => 107, 1 => 1 ), - ); - - public static $yyReduceMap = array( - 0 => 0, - 1 => 1, - 2 => 2, - 3 => 3, - 4 => 4, - 5 => 5, - 6 => 6, - 21 => 6, - 22 => 6, - 23 => 6, - 36 => 6, - 56 => 6, - 57 => 6, - 65 => 6, - 66 => 6, - 77 => 6, - 82 => 6, - 83 => 6, - 88 => 6, - 92 => 6, - 93 => 6, - 97 => 6, - 98 => 6, - 100 => 6, - 105 => 6, - 169 => 6, - 174 => 6, - 7 => 7, - 8 => 8, - 9 => 9, - 11 => 11, - 12 => 12, - 13 => 13, - 14 => 14, - 15 => 15, - 16 => 16, - 17 => 17, - 18 => 18, - 19 => 19, - 20 => 20, - 24 => 24, - 25 => 25, - 26 => 26, - 27 => 27, - 28 => 28, - 29 => 29, - 30 => 30, - 31 => 31, - 33 => 31, - 32 => 32, - 34 => 34, - 35 => 35, - 37 => 37, - 38 => 38, - 39 => 39, - 40 => 40, - 41 => 41, - 42 => 42, - 43 => 43, - 44 => 44, - 45 => 45, - 46 => 46, - 47 => 47, - 48 => 48, - 49 => 49, - 50 => 50, - 59 => 50, - 147 => 50, - 151 => 50, - 155 => 50, - 157 => 50, - 51 => 51, - 148 => 51, - 154 => 51, - 52 => 52, - 53 => 53, - 54 => 53, - 55 => 55, - 132 => 55, - 58 => 58, - 60 => 60, - 61 => 61, - 62 => 61, - 63 => 63, - 64 => 64, - 67 => 67, - 68 => 68, - 69 => 68, - 70 => 70, - 71 => 71, - 72 => 72, - 73 => 73, - 74 => 74, - 75 => 75, - 76 => 76, - 78 => 78, - 80 => 78, - 81 => 78, - 112 => 78, - 79 => 79, - 84 => 84, - 85 => 85, - 86 => 86, - 87 => 87, - 89 => 89, - 90 => 90, - 91 => 90, - 94 => 94, - 95 => 95, - 96 => 96, - 99 => 99, - 101 => 101, - 102 => 102, - 103 => 103, - 104 => 104, - 106 => 106, - 107 => 107, - 108 => 108, - 109 => 109, - 110 => 110, - 111 => 111, - 113 => 113, - 171 => 113, - 114 => 114, - 115 => 115, - 116 => 116, - 117 => 117, - 118 => 118, - 119 => 119, - 127 => 119, - 120 => 120, - 121 => 121, - 122 => 122, - 123 => 122, - 125 => 122, - 126 => 122, - 124 => 124, - 128 => 128, - 129 => 129, - 130 => 130, - 175 => 130, - 131 => 131, - 133 => 133, - 134 => 134, - 135 => 135, - 136 => 136, - 137 => 137, - 138 => 138, - 139 => 139, - 140 => 140, - 141 => 141, - 142 => 142, - 143 => 143, - 144 => 144, - 145 => 145, - 146 => 146, - 149 => 149, - 150 => 150, - 152 => 152, - 153 => 153, - 156 => 156, - 158 => 158, - 159 => 159, - 160 => 160, - 161 => 161, - 162 => 162, - 163 => 163, - 164 => 164, - 165 => 165, - 166 => 166, - 167 => 167, - 168 => 167, - 170 => 170, - 172 => 172, - 173 => 173, - 176 => 176, - 177 => 177, - 178 => 178, - 179 => 179, - 182 => 179, - 180 => 180, - 183 => 180, - 181 => 181, - 184 => 184, - 185 => 185, - ); -// line 233 "../smarty/lexer/smarty_internal_templateparser.y" - public function yy_r0(){ - $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 240 "../smarty/lexer/smarty_internal_templateparser.y" - public function yy_r1(){ - $text = $this->yystack[ $this->yyidx + 0 ]->minor; - - if ((string)$text == '') { - $this->current_buffer->append_subtree($this, null); - } - - $this->current_buffer->append_subtree($this, new \Smarty\ParseTree\Text($text, $this->strip)); - } -// line 250 "../smarty/lexer/smarty_internal_templateparser.y" - public function yy_r2(){ - $this->strip = true; - } -// line 254 "../smarty/lexer/smarty_internal_templateparser.y" - public function yy_r3(){ - $this->strip = false; - } -// line 259 "../smarty/lexer/smarty_internal_templateparser.y" - public function yy_r4(){ - $this->current_buffer->append_subtree($this, new \Smarty\ParseTree\Text($this->yystack[$this->yyidx + -1]->minor)); - } -// line 264 "../smarty/lexer/smarty_internal_templateparser.y" - public function yy_r5(){ - $this->_retvalue = $this->yystack[$this->yyidx + -3]->minor.$this->yystack[$this->yyidx + -1]->minor; - } -// line 267 "../smarty/lexer/smarty_internal_templateparser.y" - public function yy_r6(){ - $this->_retvalue = $this->yystack[$this->yyidx + 0]->minor; - } -// line 271 "../smarty/lexer/smarty_internal_templateparser.y" - public function yy_r7(){ - $this->_retvalue = $this->yystack[$this->yyidx + -1]->minor.$this->yystack[$this->yyidx + 0]->minor; - - } -// line 276 "../smarty/lexer/smarty_internal_templateparser.y" - public function yy_r8(){ - $this->_retvalue = ''; - } -// line 280 "../smarty/lexer/smarty_internal_templateparser.y" - public function yy_r9(){ - if ($this->compiler->has_code) { - $this->current_buffer->append_subtree($this, $this->mergePrefixCode($this->yystack[$this->yyidx + 0]->minor)); - } - $this->compiler->has_variable_string = false; - $this->block_nesting_level = count($this->compiler->_tag_stack); - } -// line 292 "../smarty/lexer/smarty_internal_templateparser.y" - public function yy_r11(){ - $var = trim(substr($this->yystack[$this->yyidx + 0]->minor, $this->compiler->getLdelLength(), -$this->compiler->getRdelLength()), ' $'); - if (preg_match('/^(.*)(\s+nocache)$/', $var, $match)) { - $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.'\''))); - } - } -// line 302 "../smarty/lexer/smarty_internal_templateparser.y" - public function yy_r12(){ - $tag = trim(substr($this->yystack[$this->yyidx + 0]->minor, $this->compiler->getLdelLength(), -$this->compiler->getRdelLength())); - if ($tag == 'strip') { - $this->strip = true; - $this->_retvalue = null; - } else { - if (defined($tag)) { - if ($this->security) { - $this->security->isTrustedConstant($tag, $this->compiler); - } - $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\'')); - } else { - $this->_retvalue = $this->compiler->compileTag($tag,array()); - } - } - } - } -// line 323 "../smarty/lexer/smarty_internal_templateparser.y" - public function yy_r13(){ - $j = strrpos($this->yystack[$this->yyidx + 0]->minor,'.'); - if ($this->yystack[$this->yyidx + 0]->minor[$j+1] == 'c') { - // {$smarty.block.child} - $this->_retvalue = $this->compiler->compileTag('child',array(),array($this->yystack[$this->yyidx + 0]->minor)); - } else { - // {$smarty.block.parent} - $this->_retvalue = $this->compiler->compileTag('parent',array(),array($this->yystack[$this->yyidx + 0]->minor)); - } - } -// line 334 "../smarty/lexer/smarty_internal_templateparser.y" - public function yy_r14(){ - $this->_retvalue = $this->yystack[$this->yyidx + -1]->minor; - } -// line 338 "../smarty/lexer/smarty_internal_templateparser.y" - public function yy_r15(){ - $this->_retvalue = $this->yystack[$this->yyidx + -1]->minor; - } -// line 342 "../smarty/lexer/smarty_internal_templateparser.y" - public function yy_r16(){ - $this->_retvalue = $this->compiler->compileTag('private_print_expression',$this->yystack[$this->yyidx + 0]->minor[1],array('value'=>$this->yystack[$this->yyidx + 0]->minor[0])); - } -// line 351 "../smarty/lexer/smarty_internal_templateparser.y" - public function yy_r17(){ - $this->_retvalue = $this->compiler->compileTag('assign',array_merge(array(array('value'=>$this->yystack[$this->yyidx + 0]->minor[0]),array('var'=>'\''.substr($this->yystack[$this->yyidx + -1]->minor,1).'\'')),$this->yystack[$this->yyidx + 0]->minor[1])); - } -// line 355 "../smarty/lexer/smarty_internal_templateparser.y" - public function yy_r18(){ - $this->_retvalue = $this->compiler->compileTag('assign',array_merge(array(array('value'=>$this->yystack[$this->yyidx + 0]->minor[0]),array('var'=>$this->yystack[$this->yyidx + -1]->minor['var'])),$this->yystack[$this->yyidx + 0]->minor[1]),array('smarty_internal_index'=>$this->yystack[$this->yyidx + -1]->minor['smarty_internal_index'])); - } -// line 359 "../smarty/lexer/smarty_internal_templateparser.y" - public function yy_r19(){ - $this->_retvalue = $this->yystack[$this->yyidx + 0]->minor; - } -// line 363 "../smarty/lexer/smarty_internal_templateparser.y" - public function yy_r20(){ - $this->_retvalue = array($this->yystack[$this->yyidx + -1]->minor,$this->yystack[$this->yyidx + 0]->minor); - } -// line 378 "../smarty/lexer/smarty_internal_templateparser.y" - public function yy_r24(){ - 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)); - } else { - $this->_retvalue = $this->compiler->compileTag($this->yystack[$this->yyidx + -1]->minor,$this->yystack[$this->yyidx + 0]->minor); - } - } -// line 388 "../smarty/lexer/smarty_internal_templateparser.y" - public function yy_r25(){ - 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)); - } else { - $this->_retvalue = $this->compiler->compileTag($this->yystack[$this->yyidx + 0]->minor,array()); - } - } -// line 401 "../smarty/lexer/smarty_internal_templateparser.y" - public function yy_r26(){ - 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)); - } else { - $this->_retvalue = $this->compiler->compileTag($this->yystack[$this->yyidx + -2]->minor,$this->yystack[$this->yyidx + 0]->minor, array('modifierlist'=>$this->yystack[$this->yyidx + -1]->minor)); - } - } -// line 413 "../smarty/lexer/smarty_internal_templateparser.y" - public function yy_r27(){ - $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 418 "../smarty/lexer/smarty_internal_templateparser.y" - public function yy_r28(){ - $this->_retvalue = $this->compiler->compileTag($this->yystack[$this->yyidx + -4]->minor,$this->yystack[$this->yyidx + 0]->minor,array('modifierlist'=>$this->yystack[$this->yyidx + -1]->minor, 'object_method'=>$this->yystack[$this->yyidx + -2]->minor)); - } -// line 423 "../smarty/lexer/smarty_internal_templateparser.y" - public function yy_r29(){ - $this->_retvalue = $this->compiler->compileTag('make_nocache',array(array('var'=>'\''.substr($this->yystack[$this->yyidx + 0]->minor,1).'\''))); - } -// line 428 "../smarty/lexer/smarty_internal_templateparser.y" - public function yy_r30(){ - $tag = trim(substr($this->yystack[$this->yyidx + -1]->minor,$this->compiler->getLdelLength())); - $this->_retvalue = $this->compiler->compileTag(($tag === 'else if')? 'elseif' : $tag,array(),array('if condition'=>$this->yystack[$this->yyidx + 0]->minor)); - } -// line 433 "../smarty/lexer/smarty_internal_templateparser.y" - public function yy_r31(){ - $tag = trim(substr($this->yystack[$this->yyidx + -2]->minor,$this->compiler->getLdelLength())); - $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 438 "../smarty/lexer/smarty_internal_templateparser.y" - public function yy_r32(){ - $tag = trim(substr($this->yystack[$this->yyidx + -1]->minor,$this->compiler->getLdelLength())); - $this->_retvalue = $this->compiler->compileTag(($tag === 'else if')? 'elseif' : $tag,array(),array('if condition'=>$this->yystack[$this->yyidx + 0]->minor)); - } -// line 449 "../smarty/lexer/smarty_internal_templateparser.y" - public function yy_r34(){ - $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 453 "../smarty/lexer/smarty_internal_templateparser.y" - public function yy_r35(){ - $this->_retvalue = '='.$this->yystack[$this->yyidx + 0]->minor; - } -// line 461 "../smarty/lexer/smarty_internal_templateparser.y" - public function yy_r37(){ - $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 465 "../smarty/lexer/smarty_internal_templateparser.y" - public function yy_r38(){ - $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 470 "../smarty/lexer/smarty_internal_templateparser.y" - public function yy_r39(){ - $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 474 "../smarty/lexer/smarty_internal_templateparser.y" - public function yy_r40(){ - $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 477 "../smarty/lexer/smarty_internal_templateparser.y" - public function yy_r41(){ - $this->_retvalue = $this->compiler->compileTag('foreach',$this->yystack[$this->yyidx + 0]->minor); - } -// line 482 "../smarty/lexer/smarty_internal_templateparser.y" - public function yy_r42(){ - $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 486 "../smarty/lexer/smarty_internal_templateparser.y" - public function yy_r43(){ - $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 492 "../smarty/lexer/smarty_internal_templateparser.y" - public function yy_r44(){ - $tag = trim(substr($this->yystack[$this->yyidx + 0]->minor, $this->compiler->getLdelLength(), -$this->compiler->getRdelLength()), ' /'); - if ($tag === 'strip') { - $this->strip = false; - $this->_retvalue = null; - } else { - $this->_retvalue = $this->compiler->compileTag($tag.'close',array()); - } - } -// line 501 "../smarty/lexer/smarty_internal_templateparser.y" - public function yy_r45(){ - $this->_retvalue = $this->compiler->compileTag($this->yystack[$this->yyidx + 0]->minor.'close',array()); - } -// line 505 "../smarty/lexer/smarty_internal_templateparser.y" - public function yy_r46(){ - $this->_retvalue = $this->compiler->compileTag($this->yystack[$this->yyidx + -1]->minor.'close',array(),array('modifier_list'=>$this->yystack[$this->yyidx + 0]->minor)); - } -// line 510 "../smarty/lexer/smarty_internal_templateparser.y" - public function yy_r47(){ - $this->_retvalue = $this->compiler->compileTag($this->yystack[$this->yyidx + -2]->minor.'close',array(),array('object_method'=>$this->yystack[$this->yyidx + 0]->minor)); - } -// line 514 "../smarty/lexer/smarty_internal_templateparser.y" - public function yy_r48(){ - $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 522 "../smarty/lexer/smarty_internal_templateparser.y" - public function yy_r49(){ - $this->_retvalue = $this->yystack[$this->yyidx + -1]->minor; - $this->_retvalue[] = $this->yystack[$this->yyidx + 0]->minor; - } -// line 528 "../smarty/lexer/smarty_internal_templateparser.y" - public function yy_r50(){ - $this->_retvalue = array($this->yystack[$this->yyidx + 0]->minor); - } -// line 533 "../smarty/lexer/smarty_internal_templateparser.y" - public function yy_r51(){ - $this->_retvalue = array(); - } -// line 538 "../smarty/lexer/smarty_internal_templateparser.y" - public function yy_r52(){ - 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); - } else { - $this->_retvalue = array($this->yystack[$this->yyidx + -2]->minor=>'\''.$this->yystack[$this->yyidx + 0]->minor.'\''); - } - } -// line 549 "../smarty/lexer/smarty_internal_templateparser.y" - public function yy_r53(){ - $this->_retvalue = array(trim($this->yystack[$this->yyidx + -1]->minor," =\n\r\t")=>$this->yystack[$this->yyidx + 0]->minor); - } -// line 557 "../smarty/lexer/smarty_internal_templateparser.y" - public function yy_r55(){ - $this->_retvalue = '\''.$this->yystack[$this->yyidx + 0]->minor.'\''; - } -// line 569 "../smarty/lexer/smarty_internal_templateparser.y" - public function yy_r58(){ - $this->_retvalue = array($this->yystack[$this->yyidx + -2]->minor=>$this->yystack[$this->yyidx + 0]->minor); - } -// line 582 "../smarty/lexer/smarty_internal_templateparser.y" - public function yy_r60(){ - $this->yystack[$this->yyidx + -2]->minor[]=$this->yystack[$this->yyidx + 0]->minor; - $this->_retvalue = $this->yystack[$this->yyidx + -2]->minor; - } -// line 587 "../smarty/lexer/smarty_internal_templateparser.y" - public function yy_r61(){ - $this->_retvalue = array('var' => '\''.substr($this->yystack[$this->yyidx + -2]->minor,1).'\'', 'value'=>$this->yystack[$this->yyidx + 0]->minor); - } -// line 594 "../smarty/lexer/smarty_internal_templateparser.y" - public function yy_r63(){ - $this->_retvalue = array('var' => $this->yystack[$this->yyidx + -2]->minor, 'value'=>$this->yystack[$this->yyidx + 0]->minor); - } -// line 598 "../smarty/lexer/smarty_internal_templateparser.y" - public function yy_r64(){ - $this->_retvalue = $this->yystack[$this->yyidx + -1]->minor; - } -// line 618 "../smarty/lexer/smarty_internal_templateparser.y" - public function yy_r67(){ - $this->_retvalue = '$_smarty_tpl->getStreamVariable(\''.substr($this->yystack[$this->yyidx + -2]->minor,1).'://' . $this->yystack[$this->yyidx + 0]->minor . '\')'; - } -// line 623 "../smarty/lexer/smarty_internal_templateparser.y" - public function yy_r68(){ - $this->_retvalue = $this->yystack[$this->yyidx + -2]->minor . trim($this->yystack[$this->yyidx + -1]->minor) . $this->yystack[$this->yyidx + 0]->minor; - } -// line 633 "../smarty/lexer/smarty_internal_templateparser.y" - public function yy_r70(){ - $this->_retvalue = $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 .')'; - } -// line 637 "../smarty/lexer/smarty_internal_templateparser.y" - public function yy_r71(){ - $this->_retvalue = $this->yystack[$this->yyidx + -2]->minor.$this->yystack[$this->yyidx + -1]->minor.$this->yystack[$this->yyidx + 0]->minor; - } -// line 641 "../smarty/lexer/smarty_internal_templateparser.y" - public function yy_r72(){ - $this->_retvalue = $this->yystack[$this->yyidx + 0]->minor . $this->yystack[$this->yyidx + -1]->minor . ')'; - } -// line 645 "../smarty/lexer/smarty_internal_templateparser.y" - public function yy_r73(){ - $this->_retvalue = 'in_array('.$this->yystack[$this->yyidx + -2]->minor.','.$this->yystack[$this->yyidx + 0]->minor.')'; - } -// line 649 "../smarty/lexer/smarty_internal_templateparser.y" - public function yy_r74(){ - $this->_retvalue = 'in_array('.$this->yystack[$this->yyidx + -2]->minor.',(array)'.$this->yystack[$this->yyidx + 0]->minor.')'; - } -// line 657 "../smarty/lexer/smarty_internal_templateparser.y" - public function yy_r75(){ - $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 661 "../smarty/lexer/smarty_internal_templateparser.y" - public function yy_r76(){ - $this->_retvalue = $this->yystack[$this->yyidx + -5]->minor.' ? '.$this->yystack[$this->yyidx + -2]->minor.' : '.$this->yystack[$this->yyidx + 0]->minor; - } -// line 671 "../smarty/lexer/smarty_internal_templateparser.y" - public function yy_r78(){ - $this->_retvalue = $this->yystack[$this->yyidx + -1]->minor.$this->yystack[$this->yyidx + 0]->minor; - } -// line 676 "../smarty/lexer/smarty_internal_templateparser.y" - public function yy_r79(){ - $this->_retvalue = '!'.$this->yystack[$this->yyidx + 0]->minor; - } -// line 697 "../smarty/lexer/smarty_internal_templateparser.y" - public function yy_r84(){ - $this->_retvalue = $this->yystack[$this->yyidx + -2]->minor.'.'.$this->yystack[$this->yyidx + 0]->minor; - } -// line 701 "../smarty/lexer/smarty_internal_templateparser.y" - public function yy_r85(){ - $this->_retvalue = $this->yystack[$this->yyidx + -1]->minor.'.'; - } -// line 705 "../smarty/lexer/smarty_internal_templateparser.y" - public function yy_r86(){ - $this->_retvalue = '.'.$this->yystack[$this->yyidx + 0]->minor; - } -// line 710 "../smarty/lexer/smarty_internal_templateparser.y" - public function yy_r87(){ - 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->yystack[$this->yyidx + 0]->minor; - } else { - $this->_retvalue = '\''.$this->yystack[$this->yyidx + 0]->minor.'\''; - } - } -// line 727 "../smarty/lexer/smarty_internal_templateparser.y" - public function yy_r89(){ - $this->_retvalue = '('. $this->yystack[$this->yyidx + -1]->minor .')'; - } -// line 731 "../smarty/lexer/smarty_internal_templateparser.y" - public function yy_r90(){ - $this->_retvalue = $this->yystack[$this->yyidx + -2]->minor.$this->yystack[$this->yyidx + -1]->minor.$this->yystack[$this->yyidx + 0]->minor; - } -// line 749 "../smarty/lexer/smarty_internal_templateparser.y" - public function yy_r94(){ - if ($this->security && $this->security->static_classes !== array()) { - $this->compiler->trigger_template_error('dynamic static class not allowed by security setting'); - } - $prefixVar = $this->compiler->getNewPrefixVariable(); - if ($this->yystack[$this->yyidx + -2]->minor['var'] === '\'smarty\'') { - $this->compiler->appendPrefixCode("compiler->compileTag('private_special_variable',array(),$this->yystack[$this->yyidx + -2]->minor['smarty_internal_index']).';?>'); - } else { - $this->compiler->appendPrefixCode("compiler->compileVariable($this->yystack[$this->yyidx + -2]->minor['var']).$this->yystack[$this->yyidx + -2]->minor['smarty_internal_index'].';?>'); - } - $this->_retvalue = $prefixVar .'::'.$this->yystack[$this->yyidx + 0]->minor[0].$this->yystack[$this->yyidx + 0]->minor[1]; - } -// line 760 "../smarty/lexer/smarty_internal_templateparser.y" - public function yy_r95(){ - $prefixVar = $this->compiler->getNewPrefixVariable(); - $tmp = $this->compiler->appendCode('', $this->yystack[$this->yyidx + 0]->minor); - $this->compiler->appendPrefixCode($this->compiler->appendCode($tmp, "")); - $this->_retvalue = $prefixVar; - } -// line 767 "../smarty/lexer/smarty_internal_templateparser.y" - public function yy_r96(){ - $this->_retvalue = $this->compiler->compileTag('private_modifier',array(),array('value'=>$this->yystack[$this->yyidx + -1]->minor,'modifierlist'=>$this->yystack[$this->yyidx + 0]->minor)); - } -// line 780 "../smarty/lexer/smarty_internal_templateparser.y" - public function yy_r99(){ - 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]; - } else { - $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'); - } - } -// line 799 "../smarty/lexer/smarty_internal_templateparser.y" - public function yy_r101(){ - $this->_retvalue = $this->yystack[$this->yyidx + 0]->minor; - } -// line 810 "../smarty/lexer/smarty_internal_templateparser.y" - public function yy_r102(){ - $this->_retvalue = $this->compiler->compileVariable('\''.substr($this->yystack[$this->yyidx + 0]->minor,1).'\''); - } -// line 813 "../smarty/lexer/smarty_internal_templateparser.y" - public function yy_r103(){ - 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']); - $this->_retvalue = $smarty_var; - } else { - // 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']; - } - } -// line 826 "../smarty/lexer/smarty_internal_templateparser.y" - public function yy_r104(){ - $this->_retvalue = '$_smarty_tpl->tpl_vars['. $this->yystack[$this->yyidx + -2]->minor .']->'.$this->yystack[$this->yyidx + 0]->minor; - } -// line 836 "../smarty/lexer/smarty_internal_templateparser.y" - public function yy_r106(){ - $this->_retvalue = $this->compiler->compileConfigVariable('\'' . $this->yystack[$this->yyidx + -1]->minor . '\''); - } -// line 840 "../smarty/lexer/smarty_internal_templateparser.y" - public function yy_r107(){ - $this->_retvalue = '(is_array($tmp = ' . $this->compiler->compileConfigVariable('\'' . $this->yystack[$this->yyidx + -2]->minor . '\'') . ') ? $tmp'.$this->yystack[$this->yyidx + 0]->minor.' :null)'; - } -// line 844 "../smarty/lexer/smarty_internal_templateparser.y" - public function yy_r108(){ - $this->_retvalue = $this->compiler->compileConfigVariable($this->yystack[$this->yyidx + -1]->minor); - } -// line 848 "../smarty/lexer/smarty_internal_templateparser.y" - public function yy_r109(){ - $this->_retvalue = '(is_array($tmp = ' . $this->compiler->compileConfigVariable($this->yystack[$this->yyidx + -2]->minor) . ') ? $tmp'.$this->yystack[$this->yyidx + 0]->minor.' : null)'; - } -// line 852 "../smarty/lexer/smarty_internal_templateparser.y" - public function yy_r110(){ - $this->_retvalue = array('var'=>'\''.substr($this->yystack[$this->yyidx + -1]->minor,1).'\'', 'smarty_internal_index'=>$this->yystack[$this->yyidx + 0]->minor); - } -// line 855 "../smarty/lexer/smarty_internal_templateparser.y" - public function yy_r111(){ - $this->_retvalue = array('var'=>$this->yystack[$this->yyidx + -1]->minor, 'smarty_internal_index'=>$this->yystack[$this->yyidx + 0]->minor); - } -// line 868 "../smarty/lexer/smarty_internal_templateparser.y" - public function yy_r113(){ - return; - } -// line 874 "../smarty/lexer/smarty_internal_templateparser.y" - public function yy_r114(){ - $this->_retvalue = '['.$this->compiler->compileVariable('\''.substr($this->yystack[$this->yyidx + 0]->minor,1).'\'').']'; - } -// line 877 "../smarty/lexer/smarty_internal_templateparser.y" - public function yy_r115(){ - $this->_retvalue = '['.$this->compiler->compileVariable($this->yystack[$this->yyidx + 0]->minor).']'; - } -// line 881 "../smarty/lexer/smarty_internal_templateparser.y" - public function yy_r116(){ - $this->_retvalue = '['.$this->compiler->compileVariable($this->yystack[$this->yyidx + -2]->minor).'->'.$this->yystack[$this->yyidx + 0]->minor.']'; - } -// line 885 "../smarty/lexer/smarty_internal_templateparser.y" - public function yy_r117(){ - $this->_retvalue = '[\''. $this->yystack[$this->yyidx + 0]->minor .'\']'; - } -// line 889 "../smarty/lexer/smarty_internal_templateparser.y" - public function yy_r118(){ - $this->_retvalue = '['. $this->yystack[$this->yyidx + 0]->minor .']'; - } -// line 894 "../smarty/lexer/smarty_internal_templateparser.y" - public function yy_r119(){ - $this->_retvalue = '['. $this->yystack[$this->yyidx + -1]->minor .']'; - } -// line 899 "../smarty/lexer/smarty_internal_templateparser.y" - public function yy_r120(){ - $this->_retvalue = '['.$this->compiler->compileTag('private_special_variable',array(),'[\'section\'][\''.$this->yystack[$this->yyidx + -1]->minor.'\'][\'index\']').']'; - } -// line 903 "../smarty/lexer/smarty_internal_templateparser.y" - public function yy_r121(){ - $this->_retvalue = '['.$this->compiler->compileTag('private_special_variable',array(),'[\'section\'][\''.$this->yystack[$this->yyidx + -3]->minor.'\'][\''.$this->yystack[$this->yyidx + -1]->minor.'\']').']'; - } -// line 906 "../smarty/lexer/smarty_internal_templateparser.y" - public function yy_r122(){ - $this->_retvalue = '['.$this->yystack[$this->yyidx + -1]->minor.']'; - } -// line 912 "../smarty/lexer/smarty_internal_templateparser.y" - public function yy_r124(){ - $this->_retvalue = '['.$this->compiler->compileVariable('\''.substr($this->yystack[$this->yyidx + -1]->minor,1).'\'').']'; - } -// line 928 "../smarty/lexer/smarty_internal_templateparser.y" - public function yy_r128(){ - $this->_retvalue = '[]'; - } -// line 938 "../smarty/lexer/smarty_internal_templateparser.y" - public function yy_r129(){ - $this->_retvalue = '\''.substr($this->yystack[$this->yyidx + 0]->minor,1).'\''; - } -// line 942 "../smarty/lexer/smarty_internal_templateparser.y" - public function yy_r130(){ - $this->_retvalue = '\'\''; - } -// line 947 "../smarty/lexer/smarty_internal_templateparser.y" - public function yy_r131(){ - $this->_retvalue = $this->yystack[$this->yyidx + -1]->minor.'.'.$this->yystack[$this->yyidx + 0]->minor; - } -// line 955 "../smarty/lexer/smarty_internal_templateparser.y" - public function yy_r133(){ - $var = trim(substr($this->yystack[$this->yyidx + 0]->minor, $this->compiler->getLdelLength(), -$this->compiler->getRdelLength()), ' $'); - $this->_retvalue = $this->compiler->compileVariable('\''.$var.'\''); - } -// line 961 "../smarty/lexer/smarty_internal_templateparser.y" - public function yy_r134(){ - $this->_retvalue = '('.$this->yystack[$this->yyidx + -1]->minor.')'; - } -// line 968 "../smarty/lexer/smarty_internal_templateparser.y" - public function yy_r135(){ - 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; - } 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; - } - } -// line 977 "../smarty/lexer/smarty_internal_templateparser.y" - public function yy_r136(){ - $this->_retvalue = $this->yystack[$this->yyidx + 0]->minor; - } -// line 982 "../smarty/lexer/smarty_internal_templateparser.y" - public function yy_r137(){ - $this->_retvalue = $this->yystack[$this->yyidx + -1]->minor.$this->yystack[$this->yyidx + 0]->minor; - } -// line 987 "../smarty/lexer/smarty_internal_templateparser.y" - public function yy_r138(){ - if ($this->security && substr($this->yystack[$this->yyidx + -1]->minor,0,1) === '_') { - $this->compiler->trigger_template_error (self::ERR1); - } - $this->_retvalue = '->'.$this->yystack[$this->yyidx + -1]->minor.$this->yystack[$this->yyidx + 0]->minor; - } -// line 994 "../smarty/lexer/smarty_internal_templateparser.y" - public function yy_r139(){ - 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.'}'; - } -// line 1001 "../smarty/lexer/smarty_internal_templateparser.y" - public function yy_r140(){ - if ($this->security) { - $this->compiler->trigger_template_error (self::ERR2); - } - $this->_retvalue = '->{'.$this->yystack[$this->yyidx + -2]->minor.$this->yystack[$this->yyidx + 0]->minor.'}'; - } -// line 1008 "../smarty/lexer/smarty_internal_templateparser.y" - public function yy_r141(){ - 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.'}'; - } -// line 1016 "../smarty/lexer/smarty_internal_templateparser.y" - public function yy_r142(){ - $this->_retvalue = '->'.$this->yystack[$this->yyidx + 0]->minor; - } -// line 1024 "../smarty/lexer/smarty_internal_templateparser.y" - public function yy_r143(){ - $this->_retvalue = $this->compiler->compilePHPFunctionCall($this->yystack[$this->yyidx + -3]->minor, $this->yystack[$this->yyidx + -1]->minor); - } -// line 1032 "../smarty/lexer/smarty_internal_templateparser.y" - public function yy_r144(){ - 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) .')'; - } -// line 1039 "../smarty/lexer/smarty_internal_templateparser.y" - public function yy_r145(){ - if ($this->security) { - $this->compiler->trigger_template_error (self::ERR2); - } - $prefixVar = $this->compiler->getNewPrefixVariable(); - $this->compiler->appendPrefixCode("compiler->compileVariable('\''.substr($this->yystack[$this->yyidx + -3]->minor,1).'\'').';?>'); - $this->_retvalue = $prefixVar .'('. implode(',',$this->yystack[$this->yyidx + -1]->minor) .')'; - } -// line 1050 "../smarty/lexer/smarty_internal_templateparser.y" - public function yy_r146(){ - $this->_retvalue = array_merge($this->yystack[$this->yyidx + -2]->minor,array($this->yystack[$this->yyidx + 0]->minor)); - } -// line 1067 "../smarty/lexer/smarty_internal_templateparser.y" - public function yy_r149(){ - $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 1071 "../smarty/lexer/smarty_internal_templateparser.y" - public function yy_r150(){ - $this->_retvalue = array(array_merge($this->yystack[$this->yyidx + -1]->minor,$this->yystack[$this->yyidx + 0]->minor)); - } -// line 1079 "../smarty/lexer/smarty_internal_templateparser.y" - public function yy_r152(){ - $this->_retvalue = array($this->yystack[$this->yyidx + 0]->minor); - } -// line 1087 "../smarty/lexer/smarty_internal_templateparser.y" - public function yy_r153(){ - $this->_retvalue = array_merge($this->yystack[$this->yyidx + -1]->minor,$this->yystack[$this->yyidx + 0]->minor); - } -// line 1100 "../smarty/lexer/smarty_internal_templateparser.y" - public function yy_r156(){ - $this->_retvalue = array(trim($this->yystack[$this->yyidx + -1]->minor).$this->yystack[$this->yyidx + 0]->minor); - } -// line 1109 "../smarty/lexer/smarty_internal_templateparser.y" - public function yy_r158(){ - $this->_retvalue = array($this->yystack[$this->yyidx + 0]->minor, '', 'method'); - } -// line 1114 "../smarty/lexer/smarty_internal_templateparser.y" - public function yy_r159(){ - $this->_retvalue = array($this->yystack[$this->yyidx + -1]->minor, $this->yystack[$this->yyidx + 0]->minor, 'method'); - } -// line 1119 "../smarty/lexer/smarty_internal_templateparser.y" - public function yy_r160(){ - $this->_retvalue = array($this->yystack[$this->yyidx + 0]->minor, ''); - } -// line 1124 "../smarty/lexer/smarty_internal_templateparser.y" - public function yy_r161(){ - $this->_retvalue = array($this->yystack[$this->yyidx + -1]->minor, $this->yystack[$this->yyidx + 0]->minor, 'property'); - } -// line 1129 "../smarty/lexer/smarty_internal_templateparser.y" - public function yy_r162(){ - $this->_retvalue = array($this->yystack[$this->yyidx + -2]->minor, $this->yystack[$this->yyidx + -1]->minor.$this->yystack[$this->yyidx + 0]->minor, 'property'); - } -// line 1135 "../smarty/lexer/smarty_internal_templateparser.y" - public function yy_r163(){ - $this->_retvalue = ' '. trim($this->yystack[$this->yyidx + 0]->minor) . ' '; - } -// line 1139 "../smarty/lexer/smarty_internal_templateparser.y" - public function yy_r164(){ - static $lops = array( - 'eq' => ' == ', - 'ne' => ' != ', - 'neq' => ' != ', - 'gt' => ' > ', - 'ge' => ' >= ', - 'gte' => ' >= ', - 'lt' => ' < ', - 'le' => ' <= ', - 'lte' => ' <= ', - 'mod' => ' % ', - 'and' => ' && ', - 'or' => ' || ', - 'xor' => ' xor ', - ); - $op = strtolower(preg_replace('/\s*/', '', $this->yystack[$this->yyidx + 0]->minor)); - $this->_retvalue = $lops[$op]; - } -// line 1158 "../smarty/lexer/smarty_internal_templateparser.y" - public function yy_r165(){ - static $tlops = array( - 'isdivby' => array('op' => ' % ', 'pre' => '!('), - 'isnotdivby' => array('op' => ' % ', 'pre' => '('), - 'isevenby' => array('op' => ' / ', 'pre' => '!(1 & '), - 'isnotevenby' => array('op' => ' / ', 'pre' => '(1 & '), - 'isoddby' => array('op' => ' / ', 'pre' => '(1 & '), - 'isnotoddby' => array('op' => ' / ', 'pre' => '!(1 & '), - ); - $op = strtolower(preg_replace('/\s*/', '', $this->yystack[$this->yyidx + 0]->minor)); - $this->_retvalue = $tlops[$op]; - } -// line 1171 "../smarty/lexer/smarty_internal_templateparser.y" - public function yy_r166(){ - static $scond = array ( - 'iseven' => '!(1 & ', - 'isnoteven' => '(1 & ', - 'isodd' => '(1 & ', - 'isnotodd' => '!(1 & ', - ); - $op = strtolower(str_replace(' ', '', $this->yystack[$this->yyidx + 0]->minor)); - $this->_retvalue = $scond[$op]; - } -// line 1185 "../smarty/lexer/smarty_internal_templateparser.y" - public function yy_r167(){ - $this->_retvalue = 'array('.$this->yystack[$this->yyidx + -1]->minor.')'; - } -// line 1196 "../smarty/lexer/smarty_internal_templateparser.y" - public function yy_r170(){ - $this->_retvalue = $this->yystack[$this->yyidx + -2]->minor.','.$this->yystack[$this->yyidx + 0]->minor; - } -// line 1204 "../smarty/lexer/smarty_internal_templateparser.y" - public function yy_r172(){ - $this->_retvalue = $this->yystack[$this->yyidx + -2]->minor.'=>'.$this->yystack[$this->yyidx + 0]->minor; - } -// line 1208 "../smarty/lexer/smarty_internal_templateparser.y" - public function yy_r173(){ - $this->_retvalue = '\''.$this->yystack[$this->yyidx + -2]->minor.'\'=>'.$this->yystack[$this->yyidx + 0]->minor; - } -// line 1224 "../smarty/lexer/smarty_internal_templateparser.y" - public function yy_r176(){ - $this->compiler->leaveDoubleQuote(); - $this->_retvalue = $this->yystack[$this->yyidx + -1]->minor->to_smarty_php($this); - } -// line 1230 "../smarty/lexer/smarty_internal_templateparser.y" - public function yy_r177(){ - $this->yystack[$this->yyidx + -1]->minor->append_subtree($this, $this->yystack[$this->yyidx + 0]->minor); - $this->_retvalue = $this->yystack[$this->yyidx + -1]->minor; - } -// line 1235 "../smarty/lexer/smarty_internal_templateparser.y" - public function yy_r178(){ - $this->_retvalue = new \Smarty\ParseTree\Dq($this, $this->yystack[$this->yyidx + 0]->minor); - } -// line 1239 "../smarty/lexer/smarty_internal_templateparser.y" - public function yy_r179(){ - $this->_retvalue = new \Smarty\ParseTree\Code('(string)'.$this->yystack[$this->yyidx + -1]->minor); - } -// line 1243 "../smarty/lexer/smarty_internal_templateparser.y" - public function yy_r180(){ - $this->_retvalue = new \Smarty\ParseTree\Code('(string)('.$this->yystack[$this->yyidx + -1]->minor.')'); - } -// line 1247 "../smarty/lexer/smarty_internal_templateparser.y" - public function yy_r181(){ - $this->_retvalue = new \Smarty\ParseTree\Code('(string)$_smarty_tpl->tpl_vars[\''. substr($this->yystack[$this->yyidx + 0]->minor,1) .'\']->value'); - } -// line 1259 "../smarty/lexer/smarty_internal_templateparser.y" - public function yy_r184(){ - $this->_retvalue = new \Smarty\ParseTree\Tag($this, $this->yystack[$this->yyidx + 0]->minor); - } -// line 1263 "../smarty/lexer/smarty_internal_templateparser.y" - public function yy_r185(){ - $this->_retvalue = new \Smarty\ParseTree\DqContent($this->yystack[$this->yyidx + 0]->minor); - } - - private $_retvalue; - - 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]); - } - - $this->_retvalue = $yy_lefthand_side = null; - if (isset(self::$yyReduceMap[$yyruleno])) { - // call the action - $this->_retvalue = null; - $this->{'yy_r' . self::$yyReduceMap[$yyruleno]}(); - $yy_lefthand_side = $this->_retvalue; - } - $yygoto = self::$yyRuleInfo[$yyruleno][0]; - $yysize = self::$yyRuleInfo[$yyruleno][1]; - $this->yyidx -= $yysize; - for ($i = $yysize; $i; $i--) { - // pop all of the right-hand side parameters - array_pop($this->yystack); - } - $yyact = $this->yy_find_reduce_action($this->yystack[$this->yyidx]->stateno, $yygoto); - if ($yyact < self::YYNSTATE) { - if (!$this->yyTraceFILE && $yysize) { - $this->yyidx++; - $x = new TP_yyStackEntry; - $x->stateno = $yyact; - $x->major = $yygoto; - $x->minor = $yy_lefthand_side; - $this->yystack[$this->yyidx] = $x; - } else { - $this->yy_shift($yyact, $yygoto, $yy_lefthand_side); - } - } elseif ($yyact === self::YYNSTATE + self::YYNRULE + 1) { - $this->yy_accept(); - } - } - - public function yy_parse_failed() - { - if ($this->yyTraceFILE) { - fprintf($this->yyTraceFILE, "%sFail!\n", $this->yyTracePrompt); - } while ($this->yyidx >= 0) { - $this->yy_pop_parser_stack(); - } - } - - public function yy_syntax_error($yymajor, $TOKEN) - { -// line 213 "../smarty/lexer/smarty_internal_templateparser.y" - - $this->internalError = true; - $this->yymajor = $yymajor; - $this->compiler->trigger_template_error(); - } - - public function yy_accept() - { - if ($this->yyTraceFILE) { - fprintf($this->yyTraceFILE, "%sAccept!\n", $this->yyTracePrompt); - } while ($this->yyidx >= 0) { - $this->yy_pop_parser_stack(); - } -// line 206 "../smarty/lexer/smarty_internal_templateparser.y" - - $this->successful = !$this->internalError; - $this->internalError = false; - $this->retvalue = $this->_retvalue; - } - - public function doParse($yymajor, $yytokenvalue) - { - $yyerrorhit = 0; /* True if yymajor has invoked an error */ - - if ($this->yyidx === null || $this->yyidx < 0) { - $this->yyidx = 0; - $this->yyerrcnt = -1; - $x = new TP_yyStackEntry; - $x->stateno = 0; - $x->major = 0; - $this->yystack = array(); - $this->yystack[] = $x; - } - $yyendofinput = ($yymajor==0); - - if ($this->yyTraceFILE) { - fprintf($this->yyTraceFILE, "%sInput %s\n", - $this->yyTracePrompt, $this->yyTokenName[$yymajor]); - } - - do { - $yyact = $this->yy_find_shift_action($yymajor); - if ($yymajor < self::YYERRORSYMBOL && - !$this->yy_is_expected_token($yymajor)) { - // force a syntax error - $yyact = self::YY_ERROR_ACTION; - } - if ($yyact < self::YYNSTATE) { - $this->yy_shift($yyact, $yymajor, $yytokenvalue); - $this->yyerrcnt--; - if ($yyendofinput && $this->yyidx >= 0) { - $yymajor = 0; - } else { - $yymajor = self::YYNOCODE; - } - } elseif ($yyact < self::YYNSTATE + self::YYNRULE) { - $this->yy_reduce($yyact - self::YYNSTATE); - } elseif ($yyact === self::YY_ERROR_ACTION) { - if ($this->yyTraceFILE) { - fprintf($this->yyTraceFILE, "%sSyntax Error!\n", - $this->yyTracePrompt); - } - if (self::YYERRORSYMBOL) { - if ($this->yyerrcnt < 0) { - $this->yy_syntax_error($yymajor, $yytokenvalue); - } - $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]); - } - $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 - ){ - $this->yy_pop_parser_stack(); - } - if ($this->yyidx < 0 || $yymajor==0) { - $this->yy_destructor($yymajor, $yytokenvalue); - $this->yy_parse_failed(); - $yymajor = self::YYNOCODE; - } elseif ($yymx !== self::YYERRORSYMBOL) { - $u2 = 0; - $this->yy_shift($yyact, self::YYERRORSYMBOL, $u2); - } - } - $this->yyerrcnt = 3; - $yyerrorhit = 1; - } else { - if ($this->yyerrcnt <= 0) { - $this->yy_syntax_error($yymajor, $yytokenvalue); - } - $this->yyerrcnt = 3; - $this->yy_destructor($yymajor, $yytokenvalue); - if ($yyendofinput) { - $this->yy_parse_failed(); - } - $yymajor = self::YYNOCODE; - } - } else { - $this->yy_accept(); - $yymajor = self::YYNOCODE; - } - } while ($yymajor !== self::YYNOCODE && $this->yyidx >= 0); - } -} - diff --git a/src/smarty_internal_undefined.php b/src/smarty_internal_undefined.php deleted file mode 100644 index 7df0acc2..00000000 --- a/src/smarty_internal_undefined.php +++ /dev/null @@ -1,67 +0,0 @@ -class = $class; - } - - /** - * Wrapper for obsolete class Smarty_Internal_Runtime_ValidateCompiled - * - * @param \Smarty_Internal_Template $tpl - * @param array $properties special template properties - * @param bool $cache flag if called from cache file - * - * @return bool false - */ - public function decodeProperties(Smarty_Internal_Template $tpl, $properties, $cache = false) - { - if ($cache) { - $tpl->cached->valid = false; - } else { - $tpl->mustCompile = true; - } - return false; - } - - /** - * Call error handler for undefined method - * - * @param string $name unknown method-name - * @param array $args argument array - * - * @return mixed - * @throws SmartyException - */ - public function __call($name, $args) - { - if (isset($this->class)) { - throw new SmartyException("undefined extension class '{$this->class}'"); - } else { - throw new SmartyException(get_class($args[ 0 ]) . "->{$name}() undefined method"); - } - } -} diff --git a/tests/PHPUnit_Smarty.php b/tests/PHPUnit_Smarty.php index 4bcca74f..f7769af3 100644 --- a/tests/PHPUnit_Smarty.php +++ b/tests/PHPUnit_Smarty.php @@ -13,7 +13,7 @@ class PHPUnit_Smarty extends PHPUnit\Framework\TestCase /** * Smarty object * - * @var Smarty + * @var \Smarty\Smarty */ public $smarty = null; @@ -143,7 +143,7 @@ class PHPUnit_Smarty extends PHPUnit\Framework\TestCase clearstatcache(); // instance Smarty class - $this->smarty = new Smarty; + $this->smarty = new \Smarty\Smarty(); if (individualFolders != 'true') { $this->smarty->setCompileDir(__DIR__ . '/templates_c'); $this->smarty->setCacheDir(__DIR__ . '/cache'); @@ -400,7 +400,7 @@ KEY `name` (`name`) case 'php': case 'file': case 'filetest': - if ($tpl instanceof Smarty) { + if ($tpl instanceof \Smarty\Smarty) { return sha1($this->normalizePath($this->smarty->getTemplateDir(0) . $name) . $this->smarty->_joined_template_dir); } @@ -436,7 +436,7 @@ KEY `name` (`name`) if ($match[1] === '') { if ($match[ 2 ] !== '' || $match[ 2 ] . $match[ 3 ] . $match[ 4 ] === '') { $path = $getcwd . $ds . $path; - } else if (Smarty::$_IS_WINDOWS && $match[ 3 ] !== '') { + } else if (\Smarty\Smarty::$_IS_WINDOWS && $match[ 3 ] !== '') { $path = substr($getcwd, 0, 2) . $path; } } diff --git a/tests/UnitTests/A_Core/Filter/FilterClosure.php b/tests/UnitTests/A_Core/Filter/FilterClosure.php index 2b642640..effbf29a 100644 --- a/tests/UnitTests/A_Core/Filter/FilterClosure.php +++ b/tests/UnitTests/A_Core/Filter/FilterClosure.php @@ -5,7 +5,7 @@ * @requires PHP 5.3 */ - $this->smarty->registerFilter(Smarty::FILTER_PRE, function ($input) { + $this->smarty->registerFilter(\Smarty\Smarty::FILTER_PRE, function ($input) { return '{$foo}' . $input; }); $tpl = $this->smarty->createTemplate('eval:{" hello world"}'); diff --git a/tests/UnitTests/A_Core/Filter/FilterTest.php b/tests/UnitTests/A_Core/Filter/FilterTest.php index bea43e33..0fd26254 100644 --- a/tests/UnitTests/A_Core/Filter/FilterTest.php +++ b/tests/UnitTests/A_Core/Filter/FilterTest.php @@ -51,7 +51,7 @@ class FilterTest extends PHPUnit_Smarty */ public function testLoadedOutputFilter() { - $this->smarty->loadFilter(Smarty::FILTER_OUTPUT, 'trimwhitespace'); + $this->smarty->loadFilter(\Smarty\Smarty::FILTER_OUTPUT, 'trimwhitespace'); $tpl = $this->smarty->createTemplate('string:{"
hello world"}'); $this->assertEquals("
hello world", $this->smarty->fetch($tpl)); } @@ -61,7 +61,7 @@ class FilterTest extends PHPUnit_Smarty */ public function testRegisteredOutputFilter() { - $this->smarty->registerFilter(Smarty::FILTER_OUTPUT, 'myoutputfilter'); + $this->smarty->registerFilter(\Smarty\Smarty::FILTER_OUTPUT, 'myoutputfilter'); $tpl = $this->smarty->createTemplate('eval:{"hello world"}'); $this->assertEquals("hello world", $this->smarty->fetch($tpl)); } @@ -76,7 +76,7 @@ class FilterTest extends PHPUnit_Smarty { $this->smarty->assign('foo', 1); $this->smarty->assign('bar', 2); - $this->smarty->registerFilter(Smarty::FILTER_OUTPUT, 'myoutputfilter2'); + $this->smarty->registerFilter(\Smarty\Smarty::FILTER_OUTPUT, 'myoutputfilter2'); $this->assertEquals('1 filter 2', $this->smarty->fetch('output_001.tpl')); } @@ -90,7 +90,7 @@ class FilterTest extends PHPUnit_Smarty { $this->smarty->assign('foo', 3); $this->smarty->assign('bar', 4); - $this->smarty->registerFilter(Smarty::FILTER_OUTPUT, 'myoutputfilter2'); + $this->smarty->registerFilter(\Smarty\Smarty::FILTER_OUTPUT, 'myoutputfilter2'); $this->assertEquals('3 filter 4', $this->smarty->fetch('output_001.tpl')); } @@ -105,7 +105,7 @@ class FilterTest extends PHPUnit_Smarty $this->smarty->setCaching(true); $this->smarty->assign('foo', 5); $this->smarty->assign('bar', 6); - $this->smarty->registerFilter(Smarty::FILTER_OUTPUT, 'myoutputfilter2'); + $this->smarty->registerFilter(\Smarty\Smarty::FILTER_OUTPUT, 'myoutputfilter2'); $this->assertEquals('5 filter 6', $this->smarty->fetch('output_001.tpl')); } @@ -120,7 +120,7 @@ class FilterTest extends PHPUnit_Smarty $this->smarty->setCaching(true); $this->smarty->assign('foo', 7); $this->smarty->assign('bar', 8); - $this->smarty->registerFilter(Smarty::FILTER_OUTPUT, 'myoutputfilter2'); + $this->smarty->registerFilter(\Smarty\Smarty::FILTER_OUTPUT, 'myoutputfilter2'); $this->assertEquals('5 filter 6', $this->smarty->fetch('output_001.tpl')); } @@ -135,7 +135,7 @@ class FilterTest extends PHPUnit_Smarty $this->smarty->setCaching(true); $this->smarty->assign('foo', 10); $this->smarty->assign('bar', 11); - $this->smarty->registerFilter(Smarty::FILTER_OUTPUT, 'myoutputfilter2'); + $this->smarty->registerFilter(\Smarty\Smarty::FILTER_OUTPUT, 'myoutputfilter2'); $this->assertEquals('10 filter 11', $this->smarty->fetch('output_002.tpl')); } @@ -150,7 +150,7 @@ class FilterTest extends PHPUnit_Smarty $this->smarty->setCaching(true); $this->smarty->assign('foo', 12); $this->smarty->assign('bar', 13); - $this->smarty->registerFilter(Smarty::FILTER_OUTPUT, 'myoutputfilter2'); + $this->smarty->registerFilter(\Smarty\Smarty::FILTER_OUTPUT, 'myoutputfilter2'); $this->assertEquals('12 filter 13', $this->smarty->fetch('output_002.tpl')); } @@ -171,7 +171,7 @@ class FilterTest extends PHPUnit_Smarty return '{$foo}' . $input; } - $this->smarty->registerFilter(Smarty::FILTER_PRE, 'myprefilter'); + $this->smarty->registerFilter(\Smarty\Smarty::FILTER_PRE, 'myprefilter'); $tpl = $this->smarty->createTemplate('eval:{" hello world"}'); $tpl->assign('foo', 'bar'); $this->assertEquals("bar hello world", $this->smarty->fetch($tpl)); @@ -191,7 +191,7 @@ class FilterTest extends PHPUnit_Smarty */ public function testRegisteredPreFilterClass() { - $this->smarty->registerFilter(Smarty::FILTER_PRE, array('myprefilterclass', 'myprefilter')); + $this->smarty->registerFilter(\Smarty\Smarty::FILTER_PRE, array('myprefilterclass', 'myprefilter')); $tpl = $this->smarty->createTemplate('eval:{" hello world"}'); $tpl->assign('foo', 'bar'); $this->assertEquals("bar hello world", $this->smarty->fetch($tpl)); @@ -207,7 +207,7 @@ class FilterTest extends PHPUnit_Smarty return '{$foo}' . $input; } - $this->smarty->registerFilter(Smarty::FILTER_POST, 'mypostfilter'); + $this->smarty->registerFilter(\Smarty\Smarty::FILTER_POST, 'mypostfilter'); $tpl = $this->smarty->createTemplate('eval:{" hello world"}'); $tpl->assign('foo', 'bar'); $this->assertEquals('{$foo} hello world', $this->smarty->fetch($tpl)); @@ -231,7 +231,7 @@ class FilterTest extends PHPUnit_Smarty { $var = new VarFilter(); - $this->smarty->registerFilter(Smarty::FILTER_VARIABLE, array($var, 'variablefilter')); + $this->smarty->registerFilter(\Smarty\Smarty::FILTER_VARIABLE, array($var, 'variablefilter')); $tpl = $this->smarty->createTemplate('string:{$foo}'); $tpl->assign('foo', 'bar'); $this->assertEquals('var{$foo}bar', $this->smarty->fetch($tpl)); diff --git a/tests/UnitTests/A_Core/Filter/RegisterFilterTest.php b/tests/UnitTests/A_Core/Filter/RegisterFilterTest.php index 95e806ac..fc1e7550 100644 --- a/tests/UnitTests/A_Core/Filter/RegisterFilterTest.php +++ b/tests/UnitTests/A_Core/Filter/RegisterFilterTest.php @@ -25,7 +25,7 @@ class RegisterFilterTest extends PHPUnit_Smarty */ public function testRegisterPrefilterFunction() { - $this->smarty->registerFilter(Smarty::FILTER_PRE, 'myfilter'); + $this->smarty->registerFilter(\Smarty\Smarty::FILTER_PRE, 'myfilter'); $this->assertTrue(is_callable($this->smarty->registered_filters['pre']['myfilter'])); } @@ -34,7 +34,7 @@ class RegisterFilterTest extends PHPUnit_Smarty */ public function testRegisterPrefiltermethod() { - $this->smarty->registerFilter(Smarty::FILTER_PRE, array('myfilterclass', 'execute')); + $this->smarty->registerFilter(\Smarty\Smarty::FILTER_PRE, array('myfilterclass', 'execute')); $this->assertTrue(is_callable($this->smarty->registered_filters['pre']['myfilterclass_execute'])); } @@ -43,7 +43,7 @@ class RegisterFilterTest extends PHPUnit_Smarty */ public function testRegisterPrefilterObject() { - $this->smarty->registerFilter(Smarty::FILTER_PRE, array(new myfilterclass, 'execute')); + $this->smarty->registerFilter(\Smarty\Smarty::FILTER_PRE, array(new myfilterclass, 'execute')); $this->assertTrue(is_callable($this->smarty->registered_filters['pre']['myfilterclass_execute'])); } @@ -52,8 +52,8 @@ class RegisterFilterTest extends PHPUnit_Smarty */ public function testUnegisterPrefilterFunction() { - $this->smarty->registerFilter(Smarty::FILTER_PRE, 'myfilter'); - $this->smarty->unregisterFilter(Smarty::FILTER_PRE, 'myfilter'); + $this->smarty->registerFilter(\Smarty\Smarty::FILTER_PRE, 'myfilter'); + $this->smarty->unregisterFilter(\Smarty\Smarty::FILTER_PRE, 'myfilter'); $this->assertFalse(isset($this->smarty->registered_filters['pre']['myfilter'])); } @@ -62,8 +62,8 @@ class RegisterFilterTest extends PHPUnit_Smarty */ public function testUnregisterPrefiltermethod() { - $this->smarty->registerFilter(Smarty::FILTER_PRE, array('myfilterclass', 'execute')); - $this->smarty->unregisterFilter(Smarty::FILTER_PRE, array('myfilterclass', 'execute')); + $this->smarty->registerFilter(\Smarty\Smarty::FILTER_PRE, array('myfilterclass', 'execute')); + $this->smarty->unregisterFilter(\Smarty\Smarty::FILTER_PRE, array('myfilterclass', 'execute')); $this->assertFalse(isset($this->smarty->registered_filters['pre']['myfilterclass_execute'])); } @@ -72,7 +72,7 @@ class RegisterFilterTest extends PHPUnit_Smarty */ public function testRegisterPostfilterFunction() { - $this->smarty->registerFilter(Smarty::FILTER_POST, 'myfilter'); + $this->smarty->registerFilter(\Smarty\Smarty::FILTER_POST, 'myfilter'); $this->assertTrue(is_callable($this->smarty->registered_filters['post']['myfilter'])); } @@ -81,7 +81,7 @@ class RegisterFilterTest extends PHPUnit_Smarty */ public function testRegisterPostfiltermethod() { - $this->smarty->registerFilter(Smarty::FILTER_POST, array('myfilterclass', 'execute')); + $this->smarty->registerFilter(\Smarty\Smarty::FILTER_POST, array('myfilterclass', 'execute')); $this->assertTrue(is_callable($this->smarty->registered_filters['post']['myfilterclass_execute'])); } @@ -90,8 +90,8 @@ class RegisterFilterTest extends PHPUnit_Smarty */ public function testUnegisterPostfilterFunction() { - $this->smarty->registerFilter(Smarty::FILTER_POST, 'myfilter'); - $this->smarty->unregisterFilter(Smarty::FILTER_POST, 'myfilter'); + $this->smarty->registerFilter(\Smarty\Smarty::FILTER_POST, 'myfilter'); + $this->smarty->unregisterFilter(\Smarty\Smarty::FILTER_POST, 'myfilter'); $this->assertFalse(isset($this->smarty->registered_filters['post']['myfilter'])); } @@ -100,8 +100,8 @@ class RegisterFilterTest extends PHPUnit_Smarty */ public function testUnregisterPostfiltermethod() { - $this->smarty->registerFilter(Smarty::FILTER_POST, array('myfilterclass', 'execute')); - $this->smarty->unregisterFilter(Smarty::FILTER_POST, array('myfilterclass', 'execute')); + $this->smarty->registerFilter(\Smarty\Smarty::FILTER_POST, array('myfilterclass', 'execute')); + $this->smarty->unregisterFilter(\Smarty\Smarty::FILTER_POST, array('myfilterclass', 'execute')); $this->assertFalse(isset($this->smarty->registered_filters['post']['myfilterclass_execute'])); } @@ -110,7 +110,7 @@ class RegisterFilterTest extends PHPUnit_Smarty */ public function testRegisterOutputfilterFunction() { - $this->smarty->registerFilter(Smarty::FILTER_OUTPUT, 'myfilter'); + $this->smarty->registerFilter(\Smarty\Smarty::FILTER_OUTPUT, 'myfilter'); $this->assertTrue(is_callable($this->smarty->registered_filters['output']['myfilter'])); } @@ -119,7 +119,7 @@ class RegisterFilterTest extends PHPUnit_Smarty */ public function testRegisterOutputfiltermethod() { - $this->smarty->registerFilter(Smarty::FILTER_OUTPUT, array('myfilterclass', 'execute')); + $this->smarty->registerFilter(\Smarty\Smarty::FILTER_OUTPUT, array('myfilterclass', 'execute')); $this->assertTrue(is_callable($this->smarty->registered_filters['output']['myfilterclass_execute'])); } @@ -128,8 +128,8 @@ class RegisterFilterTest extends PHPUnit_Smarty */ public function testUnegisterOutputfilterFunction() { - $this->smarty->registerFilter(Smarty::FILTER_OUTPUT, 'myfilter'); - $this->smarty->unregisterFilter(Smarty::FILTER_OUTPUT, 'myfilter'); + $this->smarty->registerFilter(\Smarty\Smarty::FILTER_OUTPUT, 'myfilter'); + $this->smarty->unregisterFilter(\Smarty\Smarty::FILTER_OUTPUT, 'myfilter'); $this->assertFalse(isset($this->smarty->registered_filters['output']['myfilter'])); } @@ -138,8 +138,8 @@ class RegisterFilterTest extends PHPUnit_Smarty */ public function testUnregisterOutputfiltermethod() { - $this->smarty->registerFilter(Smarty::FILTER_OUTPUT, array('myfilterclass', 'execute')); - $this->smarty->unregisterFilter(Smarty::FILTER_OUTPUT, array('myfilterclass', 'execute')); + $this->smarty->registerFilter(\Smarty\Smarty::FILTER_OUTPUT, array('myfilterclass', 'execute')); + $this->smarty->unregisterFilter(\Smarty\Smarty::FILTER_OUTPUT, array('myfilterclass', 'execute')); $this->assertFalse(isset($this->smarty->registered_filters['output']['myfilterclass_execute'])); } } diff --git a/tests/UnitTests/A_Core/LoadPlugin/DefaultPluginHandlerTest.php b/tests/UnitTests/A_Core/LoadPlugin/DefaultPluginHandlerTest.php index 78d2c93f..23b6050d 100644 --- a/tests/UnitTests/A_Core/LoadPlugin/DefaultPluginHandlerTest.php +++ b/tests/UnitTests/A_Core/LoadPlugin/DefaultPluginHandlerTest.php @@ -96,7 +96,7 @@ class DefaultPluginHandlerTest extends PHPUnit_Smarty function my_plugin_handler($tag, $type, $template, &$callback, &$script, &$cachable) { switch ($type) { - case Smarty::PLUGIN_FUNCTION: + case \Smarty\Smarty::PLUGIN_FUNCTION: switch ($tag) { case 'scriptfunction': $script = './scripts/script_function_tag.php'; @@ -116,7 +116,7 @@ function my_plugin_handler($tag, $type, $template, &$callback, &$script, &$cacha default: return false; } - case Smarty::PLUGIN_COMPILER: + case \Smarty\Smarty::PLUGIN_COMPILER: switch ($tag) { case 'scriptcompilerfunction': $script = './scripts/script_compiler_function_tag.php'; @@ -128,7 +128,7 @@ function my_plugin_handler($tag, $type, $template, &$callback, &$script, &$cacha default: return false; } - case Smarty::PLUGIN_BLOCK: + case \Smarty\Smarty::PLUGIN_BLOCK: switch ($tag) { case 'scriptblock': $script = './scripts/script_block_tag.php'; @@ -138,7 +138,7 @@ function my_plugin_handler($tag, $type, $template, &$callback, &$script, &$cacha default: return false; } - case Smarty::PLUGIN_MODIFIER: + case \Smarty\Smarty::PLUGIN_MODIFIER: switch ($tag) { case 'scriptmodifier': $script = './scripts/script_modifier.php'; diff --git a/tests/UnitTests/A_Core/LoadPlugin/LoadPluginTest.php b/tests/UnitTests/A_Core/LoadPlugin/LoadPluginTest.php index 820f31a4..84dc7ad1 100644 --- a/tests/UnitTests/A_Core/LoadPlugin/LoadPluginTest.php +++ b/tests/UnitTests/A_Core/LoadPlugin/LoadPluginTest.php @@ -29,11 +29,11 @@ class LoadPluginTest extends PHPUnit_Smarty } /** - * loadPlugin test Smarty_Internal_Debug exists + * loadPlugin test \Smarty\Debug exists */ public function testLoadPluginSmartyInternalDebug() { - $this->assertTrue($this->smarty->loadPlugin('Smarty_Internal_Debug') == true); + $this->assertTrue($this->smarty->loadPlugin('\Smarty\Debug') == true); } /** diff --git a/tests/UnitTests/CacheResourceTests/_shared/PHPunitplugins/cacheresource.filetest.php b/tests/UnitTests/CacheResourceTests/_shared/PHPunitplugins/cacheresource.filetest.php index 369460b7..ef9546f9 100644 --- a/tests/UnitTests/CacheResourceTests/_shared/PHPunitplugins/cacheresource.filetest.php +++ b/tests/UnitTests/CacheResourceTests/_shared/PHPunitplugins/cacheresource.filetest.php @@ -1,11 +1,11 @@ lockTime) { $this->lockTime--; diff --git a/tests/UnitTests/Compiler/CompilerPlugin/CompileCompilerPluginTest.php b/tests/UnitTests/Compiler/CompilerPlugin/CompileCompilerPluginTest.php index e28b35e8..e85828a6 100644 --- a/tests/UnitTests/Compiler/CompilerPlugin/CompileCompilerPluginTest.php +++ b/tests/UnitTests/Compiler/CompilerPlugin/CompileCompilerPluginTest.php @@ -30,7 +30,7 @@ class CompileCompilerPluginTest extends PHPUnit_Smarty */ public function testCompilerPluginFunction() { - $this->smarty->registerPlugin(Smarty::PLUGIN_COMPILER, 'compilerplugin', 'mycompilerplugin'); + $this->smarty->registerPlugin(\Smarty\Smarty::PLUGIN_COMPILER, 'compilerplugin', 'mycompilerplugin'); $this->smarty->compile_id = 'function'; $this->assertEquals("Hello World", $this->smarty->fetch('compilerplugintest.tpl')); } @@ -39,7 +39,7 @@ class CompileCompilerPluginTest extends PHPUnit_Smarty */ public function testCompilerPluginClassStatic() { - $this->smarty->registerPlugin(Smarty::PLUGIN_COMPILER, 'compilerplugin', array('CompilerPluginClass', 'statCompile')); + $this->smarty->registerPlugin(\Smarty\Smarty::PLUGIN_COMPILER, 'compilerplugin', array('CompilerPluginClass', 'statCompile')); $this->smarty->compile_id = 'static'; $this->assertEquals("Static World", $this->smarty->fetch('compilerplugintest.tpl')); } @@ -49,7 +49,7 @@ class CompileCompilerPluginTest extends PHPUnit_Smarty public function testCompilerPluginClassObject() { $plugin = new CompilerPluginClass; - $this->smarty->registerPlugin(Smarty::PLUGIN_COMPILER, 'compilerplugin', array($plugin, 'compile')); + $this->smarty->registerPlugin(\Smarty\Smarty::PLUGIN_COMPILER, 'compilerplugin', array($plugin, 'compile')); $this->smarty->compile_id = 'object'; $this->assertEquals("Public World", $this->smarty->fetch('compilerplugintest.tpl')); } diff --git a/tests/UnitTests/SmartyMethodsTests/RegisterBlock/RegisterBlockTest.php b/tests/UnitTests/SmartyMethodsTests/RegisterBlock/RegisterBlockTest.php index dce15034..d9b2ece1 100644 --- a/tests/UnitTests/SmartyMethodsTests/RegisterBlock/RegisterBlockTest.php +++ b/tests/UnitTests/SmartyMethodsTests/RegisterBlock/RegisterBlockTest.php @@ -31,21 +31,21 @@ class RegisterBlockTest extends PHPUnit_Smarty */ public function testRegisterBlockFunction() { - $this->smarty->registerPlugin(Smarty::PLUGIN_BLOCK, 'testblock', 'myblock'); + $this->smarty->registerPlugin(\Smarty\Smarty::PLUGIN_BLOCK, 'testblock', 'myblock'); $this->smarty->assign('value', 1); $this->assertEquals('function hello world 1 1 function hello world 1 2 function hello world 1 3 ', $this->smarty->fetch('eval:{testblock}hello world {$value}{/testblock}')); } public function testRegisterBlockFunctionModifier1() { - $this->smarty->registerPlugin(Smarty::PLUGIN_BLOCK, 'testblock', 'myblock'); + $this->smarty->registerPlugin(\Smarty\Smarty::PLUGIN_BLOCK, 'testblock', 'myblock'); $this->smarty->assign('value', 1); $this->assertEquals(strtoupper('function hello world 1 1 function hello world 1 2 function hello world 1 3 '), $this->smarty->fetch('eval:{testblock}hello world {$value}{/testblock|upper}')); } public function testRegisterBlockFunctionModifier2() { - $this->smarty->registerPlugin(Smarty::PLUGIN_BLOCK, 'testblock', 'myblock'); + $this->smarty->registerPlugin(\Smarty\Smarty::PLUGIN_BLOCK, 'testblock', 'myblock'); $this->smarty->assign('value', 1); $this->assertEquals(strtoupper('function hello world 1 1 function hello world 1 2 function hello world 1 3 '), $this->smarty->fetch('eval:{testblock}hello world {$value}{/testblock|default:""|upper}')); } @@ -62,7 +62,7 @@ class RegisterBlockTest extends PHPUnit_Smarty */ public function testRegisterBlockClass() { - $this->smarty->registerPlugin(Smarty::PLUGIN_BLOCK, 'testblock', array('myblockclass', 'static_method')); + $this->smarty->registerPlugin(\Smarty\Smarty::PLUGIN_BLOCK, 'testblock', array('myblockclass', 'static_method')); $this->smarty->assign('value', 2); $this->assertEquals('static hello world 2 1 static hello world 2 2 static hello world 2 3 ', $this->smarty->fetch('eval:{testblock}hello world {$value}{/testblock}')); } @@ -80,7 +80,7 @@ class RegisterBlockTest extends PHPUnit_Smarty public function testRegisterBlockObject() { $myblock_object = new myblockclass; - $this->smarty->registerPlugin(Smarty::PLUGIN_BLOCK, 'testblock', array($myblock_object, 'object_method')); + $this->smarty->registerPlugin(\Smarty\Smarty::PLUGIN_BLOCK, 'testblock', array($myblock_object, 'object_method')); $this->smarty->assign('value', 3); $this->assertEquals('object hello world 3 1 object hello world 3 2 object hello world 3 3 ', $this->smarty->fetch('eval:{testblock}hello world {$value}{/testblock}')); } @@ -104,7 +104,7 @@ class RegisterBlockTest extends PHPUnit_Smarty $this->smarty->assign('x', 1); $this->smarty->assign('y', 10); $this->smarty->assign('z', 100); - $this->smarty->registerPlugin(Smarty::PLUGIN_BLOCK, 'testblock', 'myblockcache'); + $this->smarty->registerPlugin(\Smarty\Smarty::PLUGIN_BLOCK, 'testblock', 'myblockcache'); $this->assertEquals('1 10 100', $this->smarty->fetch('test_register_block.tpl')); } @@ -120,7 +120,7 @@ class RegisterBlockTest extends PHPUnit_Smarty $this->smarty->assign('x', 2); $this->smarty->assign('y', 20); $this->smarty->assign('z', 200); - $this->smarty->registerPlugin(Smarty::PLUGIN_BLOCK, 'testblock', 'myblockcache'); + $this->smarty->registerPlugin(\Smarty\Smarty::PLUGIN_BLOCK, 'testblock', 'myblockcache'); $this->assertEquals('1 10 100', $this->smarty->fetch('test_register_block.tpl')); } @@ -137,7 +137,7 @@ class RegisterBlockTest extends PHPUnit_Smarty $this->smarty->assign('x', 3); $this->smarty->assign('y', 30); $this->smarty->assign('z', 300); - $this->smarty->registerPlugin(Smarty::PLUGIN_BLOCK, 'testblock', 'myblockcache', false); + $this->smarty->registerPlugin(\Smarty\Smarty::PLUGIN_BLOCK, 'testblock', 'myblockcache', false); $this->assertEquals('3 30 300', $this->smarty->fetch('test_register_block.tpl')); } @@ -153,7 +153,7 @@ class RegisterBlockTest extends PHPUnit_Smarty $this->smarty->assign('x', 4); $this->smarty->assign('y', 40); $this->smarty->assign('z', 400); - $this->smarty->registerPlugin(Smarty::PLUGIN_BLOCK, 'testblock', 'myblockcache', false); + $this->smarty->registerPlugin(\Smarty\Smarty::PLUGIN_BLOCK, 'testblock', 'myblockcache', false); $this->assertEquals('3 40 300', $this->smarty->fetch('test_register_block.tpl')); } @@ -228,16 +228,16 @@ class RegisterBlockTest extends PHPUnit_Smarty */ public function testUnregisterBlock() { - $this->smarty->registerPlugin(Smarty::PLUGIN_BLOCK, 'testblock', 'myblock'); - $this->smarty->unregisterPlugin(Smarty::PLUGIN_BLOCK, 'testblock'); - $this->assertFalse(isset($this->smarty->registered_plugins[Smarty::PLUGIN_BLOCK]['testblock'])); + $this->smarty->registerPlugin(\Smarty\Smarty::PLUGIN_BLOCK, 'testblock', 'myblock'); + $this->smarty->unregisterPlugin(\Smarty\Smarty::PLUGIN_BLOCK, 'testblock'); + $this->assertFalse(isset($this->smarty->registered_plugins[\Smarty\Smarty::PLUGIN_BLOCK]['testblock'])); } public function testUnregisterBlockWrapper() { $this->smarty->registerPlugin('block', 'testblock', 'myblock'); $this->smarty->unregisterPlugin('block', 'testblock'); - $this->assertFalse(isset($this->smarty->registered_plugins[Smarty::PLUGIN_BLOCK]['testblock'])); + $this->assertFalse(isset($this->smarty->registered_plugins[\Smarty\Smarty::PLUGIN_BLOCK]['testblock'])); } /** @@ -245,8 +245,8 @@ class RegisterBlockTest extends PHPUnit_Smarty */ public function testUnregisterBlockNotRegistered() { - $this->smarty->unregisterPlugin(Smarty::PLUGIN_BLOCK, 'testblock'); - $this->assertFalse(isset($this->smarty->registered_plugins[Smarty::PLUGIN_BLOCK]['testblock'])); + $this->smarty->unregisterPlugin(\Smarty\Smarty::PLUGIN_BLOCK, 'testblock'); + $this->assertFalse(isset($this->smarty->registered_plugins[\Smarty\Smarty::PLUGIN_BLOCK]['testblock'])); } } diff --git a/tests/UnitTests/SmartyMethodsTests/RegisterCompiler/RegisterCompilerFunctionTest.php b/tests/UnitTests/SmartyMethodsTests/RegisterCompiler/RegisterCompilerFunctionTest.php index 62494be1..376c8207 100644 --- a/tests/UnitTests/SmartyMethodsTests/RegisterCompiler/RegisterCompilerFunctionTest.php +++ b/tests/UnitTests/SmartyMethodsTests/RegisterCompiler/RegisterCompilerFunctionTest.php @@ -30,7 +30,7 @@ class RegisterCompilerFunctionTest extends PHPUnit_Smarty */ public function testRegisterCompilerFunction() { - $this->smarty->registerPlugin(Smarty::PLUGIN_COMPILER, 'testcompilerfunction', 'mycompilerfunction'); + $this->smarty->registerPlugin(\Smarty\Smarty::PLUGIN_COMPILER, 'testcompilerfunction', 'mycompilerfunction'); $this->assertEquals('mycompilerfunction', $this->smarty->registered_plugins['compiler']['testcompilerfunction'][0]); $this->assertEquals('hello world 1', $this->smarty->fetch('eval:{testcompilerfunction var=1}')); } @@ -40,8 +40,8 @@ class RegisterCompilerFunctionTest extends PHPUnit_Smarty */ public function testRegisterCompilerFunctionBlock() { - $this->smarty->registerPlugin(Smarty::PLUGIN_COMPILER, 'foo', 'mycompilerfunctionopen'); - $this->smarty->registerPlugin(Smarty::PLUGIN_COMPILER, 'fooclose', 'mycompilerfunctionclose'); + $this->smarty->registerPlugin(\Smarty\Smarty::PLUGIN_COMPILER, 'foo', 'mycompilerfunctionopen'); + $this->smarty->registerPlugin(\Smarty\Smarty::PLUGIN_COMPILER, 'fooclose', 'mycompilerfunctionclose'); $result = $this->smarty->fetch('eval:{foo} hallo {/foo}'); $this->assertEquals('open tag hallo close tag', $result); } @@ -51,7 +51,7 @@ class RegisterCompilerFunctionTest extends PHPUnit_Smarty */ public function testRegisterCompilerFunctionClass() { - $this->smarty->registerPlugin(Smarty::PLUGIN_COMPILER, 'testcompilerfunction', array('mycompilerfunctionclass', 'execute')); + $this->smarty->registerPlugin(\Smarty\Smarty::PLUGIN_COMPILER, 'testcompilerfunction', array('mycompilerfunctionclass', 'execute')); $this->assertEquals('hello world 2', $this->smarty->fetch('eval:{testcompilerfunction var1=2}')); } @@ -61,7 +61,7 @@ class RegisterCompilerFunctionTest extends PHPUnit_Smarty public function testRegisterCompilerFunctionObject() { $obj = new mycompilerfunctionclass; - $this->smarty->registerPlugin(Smarty::PLUGIN_COMPILER, 'testcompilerfunction', array($obj, 'compile')); + $this->smarty->registerPlugin(\Smarty\Smarty::PLUGIN_COMPILER, 'testcompilerfunction', array($obj, 'compile')); $this->assertEquals('hello world 3', $this->smarty->fetch('eval:{testcompilerfunction var2=3}')); } @@ -70,9 +70,9 @@ class RegisterCompilerFunctionTest extends PHPUnit_Smarty */ public function testUnregisterCompilerFunction() { - $this->smarty->registerPlugin(Smarty::PLUGIN_COMPILER, 'testcompilerfunction', 'mycompilerfunction'); - $this->smarty->unregisterPlugin(Smarty::PLUGIN_COMPILER, 'testcompilerfunction'); - $this->assertFalse(isset($this->smarty->registered_plugins[Smarty::PLUGIN_COMPILER]['testcompilerfunction'])); + $this->smarty->registerPlugin(\Smarty\Smarty::PLUGIN_COMPILER, 'testcompilerfunction', 'mycompilerfunction'); + $this->smarty->unregisterPlugin(\Smarty\Smarty::PLUGIN_COMPILER, 'testcompilerfunction'); + $this->assertFalse(isset($this->smarty->registered_plugins[\Smarty\Smarty::PLUGIN_COMPILER]['testcompilerfunction'])); } /** @@ -80,8 +80,8 @@ class RegisterCompilerFunctionTest extends PHPUnit_Smarty */ public function testUnregisterCompilerFunctionNotRegistered() { - $this->smarty->unregisterPlugin(Smarty::PLUGIN_COMPILER, 'testcompilerfunction'); - $this->assertFalse(isset($this->smarty->registered_plugins[Smarty::PLUGIN_COMPILER]['testcompilerfunction'])); + $this->smarty->unregisterPlugin(\Smarty\Smarty::PLUGIN_COMPILER, 'testcompilerfunction'); + $this->assertFalse(isset($this->smarty->registered_plugins[\Smarty\Smarty::PLUGIN_COMPILER]['testcompilerfunction'])); } /** @@ -89,9 +89,9 @@ class RegisterCompilerFunctionTest extends PHPUnit_Smarty */ public function testUnregisterCompilerFunctionOtherRegistered() { - $this->smarty->registerPlugin(Smarty::PLUGIN_BLOCK, 'testcompilerfunction', 'mycompilerfunction'); - $this->smarty->unregisterPlugin(Smarty::PLUGIN_COMPILER, 'testcompilerfunction'); - $this->assertTrue(isset($this->smarty->registered_plugins[Smarty::PLUGIN_BLOCK]['testcompilerfunction'])); + $this->smarty->registerPlugin(\Smarty\Smarty::PLUGIN_BLOCK, 'testcompilerfunction', 'mycompilerfunction'); + $this->smarty->unregisterPlugin(\Smarty\Smarty::PLUGIN_COMPILER, 'testcompilerfunction'); + $this->assertTrue(isset($this->smarty->registered_plugins[\Smarty\Smarty::PLUGIN_BLOCK]['testcompilerfunction'])); } } diff --git a/tests/UnitTests/SmartyMethodsTests/RegisterFunction/RegisterFunctionTest.php b/tests/UnitTests/SmartyMethodsTests/RegisterFunction/RegisterFunctionTest.php index 29f44336..97958eb4 100644 --- a/tests/UnitTests/SmartyMethodsTests/RegisterFunction/RegisterFunctionTest.php +++ b/tests/UnitTests/SmartyMethodsTests/RegisterFunction/RegisterFunctionTest.php @@ -31,9 +31,9 @@ class RegisterFunctionTest extends PHPUnit_Smarty */ public function testRegisterFunction() { - $this->smarty->registerPlugin(Smarty::PLUGIN_FUNCTION, 'testfunction', 'myfunction'); + $this->smarty->registerPlugin(\Smarty\Smarty::PLUGIN_FUNCTION, 'testfunction', 'myfunction'); $this->assertEquals('myfunction', - $this->smarty->registered_plugins[ Smarty::PLUGIN_FUNCTION ][ 'testfunction' ][ 0 ]); + $this->smarty->registered_plugins[ \Smarty\Smarty::PLUGIN_FUNCTION ][ 'testfunction' ][ 0 ]); $this->assertEquals('hello world 1', $this->smarty->fetch('eval:{testfunction value=1}')); } @@ -42,7 +42,7 @@ class RegisterFunctionTest extends PHPUnit_Smarty */ public function testRegisterFunctionClass() { - $this->smarty->registerPlugin(Smarty::PLUGIN_FUNCTION, 'testfunction', array('myfunctionclass', 'execute')); + $this->smarty->registerPlugin(\Smarty\Smarty::PLUGIN_FUNCTION, 'testfunction', array('myfunctionclass', 'execute')); $this->assertEquals('hello world 2', $this->smarty->fetch('eval:{testfunction value=2}')); } @@ -52,7 +52,7 @@ class RegisterFunctionTest extends PHPUnit_Smarty public function testRegisterFunctionObject() { $myfunction_object = new myfunctionclass; - $this->smarty->registerPlugin(Smarty::PLUGIN_FUNCTION, 'testfunction', array($myfunction_object, 'execute')); + $this->smarty->registerPlugin(\Smarty\Smarty::PLUGIN_FUNCTION, 'testfunction', array($myfunction_object, 'execute')); $this->assertEquals('hello world 3', $this->smarty->fetch('eval:{testfunction value=3}')); } @@ -69,7 +69,7 @@ class RegisterFunctionTest extends PHPUnit_Smarty $this->smarty->setForceCompile(true); $this->smarty->assign('x', 0); $this->smarty->assign('y', 10); - $this->smarty->registerPlugin(Smarty::PLUGIN_FUNCTION, 'testfunction', 'myfunction'); + $this->smarty->registerPlugin(\Smarty\Smarty::PLUGIN_FUNCTION, 'testfunction', 'myfunction'); $this->assertEquals('hello world 0 10', $this->smarty->fetch('test_register_function.tpl')); } @@ -86,7 +86,7 @@ class RegisterFunctionTest extends PHPUnit_Smarty $this->smarty->cache_lifetime = 1000; $this->smarty->assign('x', 1); $this->smarty->assign('y', 20); - $this->smarty->registerPlugin(Smarty::PLUGIN_FUNCTION, 'testfunction', 'myfunction'); + $this->smarty->registerPlugin(\Smarty\Smarty::PLUGIN_FUNCTION, 'testfunction', 'myfunction'); $this->assertEquals('hello world 0 10', $this->smarty->fetch('test_register_function.tpl')); } @@ -104,7 +104,7 @@ class RegisterFunctionTest extends PHPUnit_Smarty $this->smarty->setForceCompile(true); $this->smarty->assign('x', 2); $this->smarty->assign('y', 30); - $this->smarty->registerPlugin(Smarty::PLUGIN_FUNCTION, 'testfunction', 'myfunction', false); + $this->smarty->registerPlugin(\Smarty\Smarty::PLUGIN_FUNCTION, 'testfunction', 'myfunction', false); $this->assertEquals('hello world 2 30', $this->smarty->fetch('test_register_function.tpl')); } @@ -121,7 +121,7 @@ class RegisterFunctionTest extends PHPUnit_Smarty $this->smarty->cache_lifetime = 1000; $this->smarty->assign('x', 3); $this->smarty->assign('y', 40); - $this->smarty->registerPlugin(Smarty::PLUGIN_FUNCTION, 'testfunction', 'myfunction', false); + $this->smarty->registerPlugin(\Smarty\Smarty::PLUGIN_FUNCTION, 'testfunction', 'myfunction', false); $this->assertEquals('hello world 3 30', $this->smarty->fetch('test_register_function.tpl')); } @@ -130,9 +130,9 @@ class RegisterFunctionTest extends PHPUnit_Smarty */ public function testUnregisterFunction() { - $this->smarty->registerPlugin(Smarty::PLUGIN_FUNCTION, 'testfunction', 'myfunction'); - $this->smarty->unregisterPlugin(Smarty::PLUGIN_FUNCTION, 'testfunction'); - $this->assertFalse(isset($this->smarty->registered_plugins[ Smarty::PLUGIN_FUNCTION ][ 'testfunction' ])); + $this->smarty->registerPlugin(\Smarty\Smarty::PLUGIN_FUNCTION, 'testfunction', 'myfunction'); + $this->smarty->unregisterPlugin(\Smarty\Smarty::PLUGIN_FUNCTION, 'testfunction'); + $this->assertFalse(isset($this->smarty->registered_plugins[ \Smarty\Smarty::PLUGIN_FUNCTION ][ 'testfunction' ])); } /** @@ -140,8 +140,8 @@ class RegisterFunctionTest extends PHPUnit_Smarty */ public function testUnregisterFunctionNotRegistered() { - $this->smarty->unregisterPlugin(Smarty::PLUGIN_FUNCTION, 'testfunction'); - $this->assertFalse(isset($this->smarty->registered_plugins[ Smarty::PLUGIN_FUNCTION ][ 'testfunction' ])); + $this->smarty->unregisterPlugin(\Smarty\Smarty::PLUGIN_FUNCTION, 'testfunction'); + $this->assertFalse(isset($this->smarty->registered_plugins[ \Smarty\Smarty::PLUGIN_FUNCTION ][ 'testfunction' ])); } /** @@ -149,9 +149,9 @@ class RegisterFunctionTest extends PHPUnit_Smarty */ public function testUnregisterFunctionOtherRegistered() { - $this->smarty->registerPlugin(Smarty::PLUGIN_BLOCK, 'testfunction', 'myfunction'); - $this->smarty->unregisterPlugin(Smarty::PLUGIN_FUNCTION, 'testfunction'); - $this->assertTrue(isset($this->smarty->registered_plugins[ Smarty::PLUGIN_BLOCK ][ 'testfunction' ])); + $this->smarty->registerPlugin(\Smarty\Smarty::PLUGIN_BLOCK, 'testfunction', 'myfunction'); + $this->smarty->unregisterPlugin(\Smarty\Smarty::PLUGIN_FUNCTION, 'testfunction'); + $this->assertTrue(isset($this->smarty->registered_plugins[ \Smarty\Smarty::PLUGIN_BLOCK ][ 'testfunction' ])); } } diff --git a/tests/UnitTests/SmartyMethodsTests/RegisterModifier/RegisterModifierTest.php b/tests/UnitTests/SmartyMethodsTests/RegisterModifier/RegisterModifierTest.php index 50b25086..fd8392c7 100644 --- a/tests/UnitTests/SmartyMethodsTests/RegisterModifier/RegisterModifierTest.php +++ b/tests/UnitTests/SmartyMethodsTests/RegisterModifier/RegisterModifierTest.php @@ -30,8 +30,8 @@ class RegisterModifierTest extends PHPUnit_Smarty */ public function testRegisterModifier() { - $this->smarty->registerPlugin(Smarty::PLUGIN_MODIFIER, 'testmodifier', 'mymodifier'); - $this->assertEquals('mymodifier', $this->smarty->registered_plugins[Smarty::PLUGIN_MODIFIER]['testmodifier'][0]); + $this->smarty->registerPlugin(\Smarty\Smarty::PLUGIN_MODIFIER, 'testmodifier', 'mymodifier'); + $this->assertEquals('mymodifier', $this->smarty->registered_plugins[\Smarty\Smarty::PLUGIN_MODIFIER]['testmodifier'][0]); $this->smarty->assign('foo', 'foo'); $this->smarty->assign('bar', 'bar'); $this->assertEquals('foo function blar bar', $this->smarty->fetch('eval:{$foo|testmodifier:blar:$bar}')); @@ -42,7 +42,7 @@ class RegisterModifierTest extends PHPUnit_Smarty */ public function testRegisterModifierClass() { - $this->smarty->registerPlugin(Smarty::PLUGIN_MODIFIER, 'testmodifier', array('mymodifierclass', 'static_method')); + $this->smarty->registerPlugin(\Smarty\Smarty::PLUGIN_MODIFIER, 'testmodifier', array('mymodifierclass', 'static_method')); $this->smarty->assign('foo', 'foo'); $this->smarty->assign('bar', 'bar'); $this->assertEquals('foo static blar bar', $this->smarty->fetch('eval:{$foo|testmodifier:blar:$bar}')); @@ -54,7 +54,7 @@ class RegisterModifierTest extends PHPUnit_Smarty public function testRegisterModifierObject() { $obj = new mymodifierclass; - $this->smarty->registerPlugin(Smarty::PLUGIN_MODIFIER, 'testmodifier', array($obj, 'object_method')); + $this->smarty->registerPlugin(\Smarty\Smarty::PLUGIN_MODIFIER, 'testmodifier', array($obj, 'object_method')); $this->smarty->assign('foo', 'foo'); $this->smarty->assign('bar', 'bar'); $this->assertEquals('foo object blar bar', $this->smarty->fetch('eval:{$foo|testmodifier:blar:$bar}')); @@ -65,9 +65,9 @@ class RegisterModifierTest extends PHPUnit_Smarty */ public function testUnregisterModifier() { - $this->smarty->registerPlugin(Smarty::PLUGIN_MODIFIER, 'testmodifier', 'mymodifier'); - $this->smarty->unregisterPlugin(Smarty::PLUGIN_MODIFIER, 'testmodifier'); - $this->assertFalse(isset($this->smarty->registered_plugins[Smarty::PLUGIN_MODIFIER]['testmodifier'])); + $this->smarty->registerPlugin(\Smarty\Smarty::PLUGIN_MODIFIER, 'testmodifier', 'mymodifier'); + $this->smarty->unregisterPlugin(\Smarty\Smarty::PLUGIN_MODIFIER, 'testmodifier'); + $this->assertFalse(isset($this->smarty->registered_plugins[\Smarty\Smarty::PLUGIN_MODIFIER]['testmodifier'])); } /** @@ -75,8 +75,8 @@ class RegisterModifierTest extends PHPUnit_Smarty */ public function testUnregisterModifierNotRegistered() { - $this->smarty->unregisterPlugin(Smarty::PLUGIN_MODIFIER, 'testmodifier'); - $this->assertFalse(isset($this->smarty->registered_plugins[Smarty::PLUGIN_MODIFIER]['testmodifier'])); + $this->smarty->unregisterPlugin(\Smarty\Smarty::PLUGIN_MODIFIER, 'testmodifier'); + $this->assertFalse(isset($this->smarty->registered_plugins[\Smarty\Smarty::PLUGIN_MODIFIER]['testmodifier'])); } /** @@ -84,9 +84,9 @@ class RegisterModifierTest extends PHPUnit_Smarty */ public function testUnregisterModifierOtherRegistered() { - $this->smarty->registerPlugin(Smarty::PLUGIN_BLOCK, 'testmodifier', 'mymodifier'); - $this->smarty->unregisterPlugin(Smarty::PLUGIN_MODIFIER, 'testmodifier'); - $this->assertTrue(isset($this->smarty->registered_plugins[Smarty::PLUGIN_BLOCK]['testmodifier'])); + $this->smarty->registerPlugin(\Smarty\Smarty::PLUGIN_BLOCK, 'testmodifier', 'mymodifier'); + $this->smarty->unregisterPlugin(\Smarty\Smarty::PLUGIN_MODIFIER, 'testmodifier'); + $this->assertTrue(isset($this->smarty->registered_plugins[\Smarty\Smarty::PLUGIN_BLOCK]['testmodifier'])); } } diff --git a/tests/UnitTests/TemplateSource/TagTests/BlockPlugin/CompileBlockPluginTest.php b/tests/UnitTests/TemplateSource/TagTests/BlockPlugin/CompileBlockPluginTest.php index 1c3e8b2e..4532f6ed 100644 --- a/tests/UnitTests/TemplateSource/TagTests/BlockPlugin/CompileBlockPluginTest.php +++ b/tests/UnitTests/TemplateSource/TagTests/BlockPlugin/CompileBlockPluginTest.php @@ -64,7 +64,7 @@ class CompileBlockPluginTest extends PHPUnit_Smarty */ public function testBlockPluginRegisteredFunction() { - $this->smarty->registerPlugin(Smarty::PLUGIN_BLOCK, 'blockplugintest', 'myblockplugintest'); + $this->smarty->registerPlugin(\Smarty\Smarty::PLUGIN_BLOCK, 'blockplugintest', 'myblockplugintest'); $this->assertEquals('block test', $this->smarty->fetch('registered.tpl')); } @@ -90,7 +90,7 @@ class CompileBlockPluginTest extends PHPUnit_Smarty */ public function testBlockPluginRegisteredStatic() { - $this->smarty->registerPlugin(Smarty::PLUGIN_BLOCK, 'blockpluginstatic', array('myblockclass1', 'staticfunc')); + $this->smarty->registerPlugin(\Smarty\Smarty::PLUGIN_BLOCK, 'blockpluginstatic', array('myblockclass1', 'staticfunc')); $this->assertEquals('static block test', $this->smarty->fetch('registered_static.tpl')); } @@ -118,7 +118,7 @@ class CompileBlockPluginTest extends PHPUnit_Smarty public function testBlockPluginRegisteredMethod() { $object = new myblockclass1(); - $this->smarty->registerPlugin(Smarty::PLUGIN_BLOCK, 'blockpluginmethod', array($object, 'methodfunc')); + $this->smarty->registerPlugin(\Smarty\Smarty::PLUGIN_BLOCK, 'blockpluginmethod', array($object, 'methodfunc')); $this->assertEquals('method block test', $this->smarty->fetch('registered_method.tpl')); } @@ -281,7 +281,7 @@ class CompileBlockPluginTest extends PHPUnit_Smarty $testName) { $this->smarty->registerFilter('pre', array($this, 'prefilterTest')); - $this->smarty->registerPlugin(Smarty::PLUGIN_BLOCK, 'cachetest', 'myblockplugintest2', $cachable); + $this->smarty->registerPlugin(\Smarty\Smarty::PLUGIN_BLOCK, 'cachetest', 'myblockplugintest2', $cachable); $this->smarty->compile_id = $compileid; $this->smarty->caching = $caching; $this->smarty->cache_lifetime = 1000; @@ -507,7 +507,7 @@ class myblockclass1 function my_block_plugin_handler($tag, $type, $template, &$callback, &$script, &$cachable) { switch ($type) { - case Smarty::PLUGIN_BLOCK: + case \Smarty\Smarty::PLUGIN_BLOCK: switch ($tag) { case 'scriptblock': $script = './scripts/script_block_tag.php'; diff --git a/tests/UnitTests/TemplateSource/TagTests/FunctionPlugin/CompileFunctionPluginTest.php b/tests/UnitTests/TemplateSource/TagTests/FunctionPlugin/CompileFunctionPluginTest.php index bb130b58..8897ddf2 100644 --- a/tests/UnitTests/TemplateSource/TagTests/FunctionPlugin/CompileFunctionPluginTest.php +++ b/tests/UnitTests/TemplateSource/TagTests/FunctionPlugin/CompileFunctionPluginTest.php @@ -42,7 +42,7 @@ class CompileFunctionPluginTest extends PHPUnit_Smarty */ public function testFunctionPluginRegisteredFunction() { - $this->smarty->registerPlugin(Smarty::PLUGIN_FUNCTION, 'plugintest', 'myplugintest'); + $this->smarty->registerPlugin(\Smarty\Smarty::PLUGIN_FUNCTION, 'plugintest', 'myplugintest'); $tpl = $this->smarty->createTemplate('string:{plugintest foo=bar}', $this->smarty); $this->assertEquals("plugin test called bar", $this->smarty->fetch($tpl)); } diff --git a/tests/UnitTests/TemplateSource/TagTests/Insert/CompileInsertTest.php b/tests/UnitTests/TemplateSource/TagTests/Insert/CompileInsertTest.php deleted file mode 100644 index e9a5328f..00000000 --- a/tests/UnitTests/TemplateSource/TagTests/Insert/CompileInsertTest.php +++ /dev/null @@ -1,269 +0,0 @@ -setUpSmarty(__DIR__); - $this->smarty->addPluginsDir(__DIR__ . "/PHPunitplugins/"); - $this->smarty->enableSecurity(); - } - - - public function testInit() - { - $this->cleanDirs(); - } - /** - * Test For - * - * @preserveGlobalState disabled - * @dataProvider dataTestInsert - * @runInSeparateProcess - */ - public function testInsert($code, $result, $testName, $testNumber) - { - $name = empty($testName) ? $testNumber : $testName; - $file = "Insert_{$name}.tpl"; - $this->makeTemplateFile($file, $code); - $this->smarty->assign('variable', 'test'); - $this->smarty->setTemplateDir('./templates_tmp'); - $this->assertEquals($result, - $this->smarty->fetch($file), - $file); - } - - /* - * Data provider für testInsert - */ - public function dataTestInsert() - { - $i = 1; - /* - * Code - * result - * test name - * test number - */ - return array( - array('start {insert name=\'test\' foo=\'bar\'} end', 'start insert function parameter value bar end', 'T1', $i++), - array('start {insert name="test" foo=\'bar\'} end', 'start insert function parameter value bar end', 'T2', $i++), - array('start {insert name=$variable foo=\'bar\'} end', 'start insert function parameter value bar end', 'T3', $i++), - array("start {insert name='test' foo='bar' assign=blar} end {\$blar}", 'start end insert function parameter value bar', 'T4', $i++), - array("start {insert name='test' foo='bar' assign=blar} end", 'start end', 'T5', $i++), - ); - } - - - - - /** - * test insert plugin - * @runInSeparateProcess - * @preserveGlobalState disabled - */ - public function testInsertPlugin1() - { - global $insertglobal; - $insertglobal = 'global'; - $tpl = $this->smarty->createTemplate('insertplugintest.tpl'); - $tpl->assign('foo', 'bar'); - $this->assertEquals('param foo bar globalvar global', $this->smarty->fetch($tpl)); - } - /** - * @runInSeparateProcess - * @preserveGlobalState disabled - * test insert plugin - */ - public function testInsertPlugin2() - { - global $insertglobal; - $insertglobal = 'global 2'; - $tpl = $this->smarty->createTemplate('insertplugintest.tpl'); - $tpl->assign('foo', 'buh'); - $this->assertEquals('param foo buh globalvar global 2', $this->smarty->fetch($tpl)); - } - - /** - * test insert plugin caching - * @runInSeparateProcess - * @preserveGlobalState disabled - */ - public function testInsertPluginCaching1_1() - { - global $insertglobal; - $insertglobal = 'global'; - $this->smarty->caching = true; - $tpl = $this->smarty->createTemplate('insertplugintest.tpl'); - $tpl->assign('foo', 'bar', true); - $this->assertEquals('param foo bar globalvar global', $this->smarty->fetch($tpl)); - } - - /** - * - * @runInSeparateProcess - * @preserveGlobalState disabled - * - */ - public function testInsertPluginCaching1_2() - { - $this->smarty->addPluginsDir(__DIR__ . "/PHPunitplugins/"); - global $insertglobal; - $insertglobal = 'changed global 2'; - $this->smarty->caching = 1; - $tpl = $this->smarty->createTemplate('insertplugintest.tpl'); - $tpl->assign('foo', 'buh', true); -// $this->assertTrue($tpl->isCached()); - $this->assertEquals('param foo buh globalvar changed global 2', $this->smarty->fetch($tpl)); - } - - /** - * - * @runInSeparateProcess - * @preserveGlobalState disabled - * - */ - public function testInsertPluginCaching1_3() - { - $this->smarty->addPluginsDir(__DIR__ . "/PHPunitplugins/"); - global $insertglobal; - $insertglobal = 'changed global'; - $this->smarty->caching = 1; -// $this->smarty->setForceCompile(true); - $this->smarty->assign('foo', 'bar', true); - $this->assertEquals('param foo bar globalvar changed global', $this->smarty->fetch('insertplugintest.tpl')); - } - - /** - * - * @runInSeparateProcess - * @preserveGlobalState disabled - * - */ - public function testInsertPluginCaching1_4() - { - global $insertglobal; - $this->smarty->addPluginsDir(__DIR__ . "/PHPunitplugins/"); - $insertglobal = 'changed global 4'; - $this->smarty->caching = 1; - $this->smarty->assign('foo', 'buh', true); - $this->assertTrue($this->smarty->isCached('insertplugintest.tpl')); - $this->assertEquals('param foo buh globalvar changed global 4', $this->smarty->fetch('insertplugintest.tpl')); - } - /** - * test insert plugin caching 2 - * @runInSeparateProcess - * @preserveGlobalState disabled - */ - public function testInsertPluginCaching2_1() - { - global $insertglobal; - $insertglobal = 'global'; - $this->smarty->caching = true; - $this->smarty->compile_id = 1; - $tpl = $this->smarty->createTemplate('insertplugintest.tpl'); - $tpl->assign('foo', 'bar'); - $this->assertEquals('param foo bar globalvar global', $this->smarty->fetch($tpl)); - } - - /** - * test insert plugin caching 2 - * @runInSeparateProcess - * @preserveGlobalState disabled - */ - public function testInsertPluginCaching2_2() - { - global $insertglobal; - $insertglobal = 'global 2'; - $this->smarty->caching = true; - $this->smarty->compile_id = 1; - $tpl = $this->smarty->createTemplate('insertplugintest.tpl'); - $tpl->assign('foo', 'buh'); - $this->assertStringContainsString('param foo bar globalvar global 2', $this->smarty->fetch($tpl)); - } - /** - * test insert plugin caching 3 - * @runInSeparateProcess - * @preserveGlobalState disabled - */ - public function testInsertPluginCaching3_1() - { - $this->smarty->caching = true; - $this->smarty->assign('insert',$t=time()); - $this->assertStringContainsString($t.'Inner template', $this->smarty->fetch('insertplugintest2.tpl')); - } - - /** - * test insert plugin caching 2 - * @runInSeparateProcess - * @preserveGlobalState disabled - * @group slow - */ - public function testInsertPluginCaching3_2() - { - sleep(2); - $this->smarty->caching = true; - $this->smarty->assign('insert',$t=time()); - $this->assertStringContainsString($t.'Inner template', $this->smarty->fetch('insertplugintest2.tpl')); - } - - - /** - * test inserted function none existing function - * @runInSeparateProcess - * @preserveGlobalState disabled - */ - public function testInsertFunctionNoneExistingFunction() - { - $tpl = $this->smarty->createTemplate("eval:start {insert name='mustfail' foo='bar' assign=blar} end {\$blar}"); - try { - $this->smarty->fetch($tpl); - } - catch (Exception $e) { - $this->assertStringContainsString("{insert} no function or plugin found for 'mustfail'", $e->getMessage()); - - return; - } - $this->fail('Exception for "function is not callable" has not been raised.'); - } - - /** - * test inserted function none existing script - * @runInSeparateProcess - * @preserveGlobalState disabled - */ - public function testInsertFunctionNoneExistingScript() - { - $tpl = $this->smarty->createTemplate("eval:{insert name='mustfail' foo='bar' script='nofile.php'}"); - try { - $this->smarty->fetch($tpl); - } - catch (Exception $e) { - $this->assertStringContainsString('missing script file', $e->getMessage()); - - return; - } - $this->fail('Exception for "missing file" has not been raised.'); - } -} - -/** - * test function - */ -function insert_test($params, $template) -{ - return "insert function parameter value $params[foo]"; -} diff --git a/tests/UnitTests/TemplateSource/TagTests/Insert/PHPunitplugins/insert.insertplugintest.php b/tests/UnitTests/TemplateSource/TagTests/Insert/PHPunitplugins/insert.insertplugintest.php deleted file mode 100644 index cd2e27cd..00000000 --- a/tests/UnitTests/TemplateSource/TagTests/Insert/PHPunitplugins/insert.insertplugintest.php +++ /dev/null @@ -1,7 +0,0 @@ -tpl_vars[$params['var']]->value; -} diff --git a/tests/UnitTests/TemplateSource/TagTests/Insert/cache/.gitignore b/tests/UnitTests/TemplateSource/TagTests/Insert/cache/.gitignore deleted file mode 100644 index d88cc144..00000000 --- a/tests/UnitTests/TemplateSource/TagTests/Insert/cache/.gitignore +++ /dev/null @@ -1,2 +0,0 @@ -# Ignore anything in here, but keep this directory -* diff --git a/tests/UnitTests/TemplateSource/TagTests/Insert/templates/inner.tpl b/tests/UnitTests/TemplateSource/TagTests/Insert/templates/inner.tpl deleted file mode 100644 index e5f67304..00000000 --- a/tests/UnitTests/TemplateSource/TagTests/Insert/templates/inner.tpl +++ /dev/null @@ -1 +0,0 @@ -Inner template diff --git a/tests/UnitTests/TemplateSource/TagTests/Insert/templates/insertplugintest.tpl b/tests/UnitTests/TemplateSource/TagTests/Insert/templates/insertplugintest.tpl deleted file mode 100644 index 579f2548..00000000 --- a/tests/UnitTests/TemplateSource/TagTests/Insert/templates/insertplugintest.tpl +++ /dev/null @@ -1 +0,0 @@ -{insert name='insertplugintest' foo=$foo} \ No newline at end of file diff --git a/tests/UnitTests/TemplateSource/TagTests/Insert/templates/insertplugintest2.tpl b/tests/UnitTests/TemplateSource/TagTests/Insert/templates/insertplugintest2.tpl deleted file mode 100644 index a1834ab0..00000000 --- a/tests/UnitTests/TemplateSource/TagTests/Insert/templates/insertplugintest2.tpl +++ /dev/null @@ -1,2 +0,0 @@ -{insert name='test2' var='insert'} -{include 'inner.tpl'} \ No newline at end of file diff --git a/tests/UnitTests/TemplateSource/TagTests/Insert/templates_c/.gitignore b/tests/UnitTests/TemplateSource/TagTests/Insert/templates_c/.gitignore deleted file mode 100644 index d88cc144..00000000 --- a/tests/UnitTests/TemplateSource/TagTests/Insert/templates_c/.gitignore +++ /dev/null @@ -1,2 +0,0 @@ -# Ignore anything in here, but keep this directory -* diff --git a/tests/UnitTests/TemplateSource/TagTests/Insert/templates_tmp/.gitignore b/tests/UnitTests/TemplateSource/TagTests/Insert/templates_tmp/.gitignore deleted file mode 100644 index d88cc144..00000000 --- a/tests/UnitTests/TemplateSource/TagTests/Insert/templates_tmp/.gitignore +++ /dev/null @@ -1,2 +0,0 @@ -# Ignore anything in here, but keep this directory -* diff --git a/tests/UnitTests/TemplateSource/TagTests/PluginBlock/PluginBlockTextformatTest.php b/tests/UnitTests/TemplateSource/TagTests/PluginBlock/PluginBlockTextformatTest.php index 854d2b4a..e92c3ca1 100644 --- a/tests/UnitTests/TemplateSource/TagTests/PluginBlock/PluginBlockTextformatTest.php +++ b/tests/UnitTests/TemplateSource/TagTests/PluginBlock/PluginBlockTextformatTest.php @@ -31,11 +31,11 @@ class PluginBlockTextformatTest extends PHPUnit_Smarty public function testDefaultWithoutMbstring() { - Smarty::$_MBSTRING = false; + \Smarty\Smarty::$_MBSTRING = false; $result = "This is foo. This is foo. This is foo.\nThis is foo. This is foo. This is foo.\n\nThis is bar.\n\nbar foo bar foo foo. bar foo bar foo\nfoo. bar foo bar foo foo. bar foo bar\nfoo foo. bar foo bar foo foo. bar foo\nbar foo foo. bar foo bar foo foo.\n\n"; $tpl = $this->smarty->createTemplate('string:{textformat wrap=40}' . $this->string . '{/textformat}'); $this->assertEquals($result, $this->smarty->fetch($tpl)); - Smarty::$_MBSTRING = true; + \Smarty\Smarty::$_MBSTRING = true; } public function testIndent() @@ -47,11 +47,11 @@ class PluginBlockTextformatTest extends PHPUnit_Smarty public function testIndentWithoutMbstring() { - Smarty::$_MBSTRING = false; + \Smarty\Smarty::$_MBSTRING = false; $result = " This is foo. This is foo. This is\n foo. This is foo. This is foo. This\n is foo.\n\n This is bar.\n\n bar foo bar foo foo. bar foo bar foo\n foo. bar foo bar foo foo. bar foo\n bar foo foo. bar foo bar foo foo.\n bar foo bar foo foo. bar foo bar foo\n foo.\n\n"; $tpl = $this->smarty->createTemplate('string:{textformat wrap=40 indent=4}' . $this->string . '{/textformat}'); $this->assertEquals($result, $this->smarty->fetch($tpl)); - Smarty::$_MBSTRING = true; + \Smarty\Smarty::$_MBSTRING = true; } public function testIndentFirst() @@ -63,11 +63,11 @@ class PluginBlockTextformatTest extends PHPUnit_Smarty public function testIndentFirstWithoutMbstring() { - Smarty::$_MBSTRING = false; + \Smarty\Smarty::$_MBSTRING = false; $result = " This is foo. This is foo. This\n is foo. This is foo. This is foo.\n This is foo.\n\n This is bar.\n\n bar foo bar foo foo. bar foo bar\n foo foo. bar foo bar foo foo. bar\n foo bar foo foo. bar foo bar foo\n foo. bar foo bar foo foo. bar foo\n bar foo foo.\n\n"; $tpl = $this->smarty->createTemplate('string:{textformat wrap=40 indent=4 indent_first=4}' . $this->string . '{/textformat}'); $this->assertEquals($result, $this->smarty->fetch($tpl)); - Smarty::$_MBSTRING = true; + \Smarty\Smarty::$_MBSTRING = true; } public function testIndentchar() @@ -79,11 +79,11 @@ class PluginBlockTextformatTest extends PHPUnit_Smarty public function testIndentcharWithoutMbstring() { - Smarty::$_MBSTRING = false; + \Smarty\Smarty::$_MBSTRING = false; $result = "####This is foo. This is foo. This is\n####foo. This is foo. This is foo. This\n####is foo.\n\n####This is bar.\n\n####bar foo bar foo foo. bar foo bar foo\n####foo. bar foo bar foo foo. bar foo\n####bar foo foo. bar foo bar foo foo.\n####bar foo bar foo foo. bar foo bar foo\n####foo.\n\n"; $tpl = $this->smarty->createTemplate('string:{textformat wrap=40 indent=4 indent_char="#"}' . $this->string . '{/textformat}'); $this->assertEquals($result, $this->smarty->fetch($tpl)); - Smarty::$_MBSTRING = true; + \Smarty\Smarty::$_MBSTRING = true; } public function testIndentcharFirst() @@ -95,11 +95,11 @@ class PluginBlockTextformatTest extends PHPUnit_Smarty public function testIndentcharFirstWithoutMbstring() { - Smarty::$_MBSTRING = false; + \Smarty\Smarty::$_MBSTRING = false; $result = "########This is foo. This is foo. This\n####is foo. This is foo. This is foo.\n####This is foo.\n\n########This is bar.\n\n########bar foo bar foo foo. bar foo bar\n####foo foo. bar foo bar foo foo. bar\n####foo bar foo foo. bar foo bar foo\n####foo. bar foo bar foo foo. bar foo\n####bar foo foo.\n\n"; $tpl = $this->smarty->createTemplate('string:{textformat wrap=40 indent=4 indent_first=4 indent_char="#"}' . $this->string . '{/textformat}'); $this->assertEquals($result, $this->smarty->fetch($tpl)); - Smarty::$_MBSTRING = true; + \Smarty\Smarty::$_MBSTRING = true; } public function testWrapchar() @@ -111,11 +111,11 @@ class PluginBlockTextformatTest extends PHPUnit_Smarty public function testWrapcharWithoutMbstring() { - Smarty::$_MBSTRING = false; + \Smarty\Smarty::$_MBSTRING = false; $result = " This is foo. This is foo. This is#foo. This is foo. This is foo. This#is foo.## This is bar.## bar foo bar foo foo. bar foo bar foo#foo. bar foo bar foo foo. bar foo#bar foo foo. bar foo bar foo foo.#bar foo bar foo foo. bar foo bar foo#foo.##"; $tpl = $this->smarty->createTemplate('string:{textformat wrap=40 indent=4 wrap_char="#"}' . $this->string . '{/textformat}'); $this->assertEquals($result, $this->smarty->fetch($tpl)); - Smarty::$_MBSTRING = true; + \Smarty\Smarty::$_MBSTRING = true; } public function testStyleEmail() @@ -127,10 +127,10 @@ class PluginBlockTextformatTest extends PHPUnit_Smarty public function testStyleEmailWithoutMbstring() { - Smarty::$_MBSTRING = false; + \Smarty\Smarty::$_MBSTRING = false; $result = "This is foo. This is foo. This is foo. This is foo. This is foo. This is\nfoo.\n\nThis is bar.\n\nbar foo bar foo foo. bar foo bar foo foo. bar foo bar foo foo. bar foo\nbar foo foo. bar foo bar foo foo. bar foo bar foo foo. bar foo bar foo\nfoo.\n\n"; $tpl = $this->smarty->createTemplate('string:{textformat style="email"}' . $this->string . '{/textformat}'); $this->assertEquals($result, $this->smarty->fetch($tpl)); - Smarty::$_MBSTRING = true; + \Smarty\Smarty::$_MBSTRING = true; } } diff --git a/tests/UnitTests/TemplateSource/TagTests/PluginFunction/PluginFunctionMailtoTest.php b/tests/UnitTests/TemplateSource/TagTests/PluginFunction/PluginFunctionMailtoTest.php index 792142c6..547945b3 100644 --- a/tests/UnitTests/TemplateSource/TagTests/PluginFunction/PluginFunctionMailtoTest.php +++ b/tests/UnitTests/TemplateSource/TagTests/PluginFunction/PluginFunctionMailtoTest.php @@ -29,11 +29,11 @@ class PluginFunctionMailtoTest extends PHPUnit_Smarty public function testDefaultWithoutMbstring() { - Smarty::$_MBSTRING = false; + \Smarty\Smarty::$_MBSTRING = false; $result = 'me@example.com'; $tpl = $this->smarty->createTemplate('eval:{mailto address="me@example.com"}'); $this->assertEquals(str_replace("\r", '', $result), $this->smarty->fetch($tpl)); - Smarty::$_MBSTRING = true; + \Smarty\Smarty::$_MBSTRING = true; } public function testText() @@ -45,11 +45,11 @@ class PluginFunctionMailtoTest extends PHPUnit_Smarty public function testTextWithoutMbstring() { - Smarty::$_MBSTRING = false; + \Smarty\Smarty::$_MBSTRING = false; $result = 'send me some mail'; $tpl = $this->smarty->createTemplate('eval:{mailto address="me@example.com" text="send me some mail"}'); $this->assertEquals(str_replace("\r", '', $result), $this->smarty->fetch($tpl)); - Smarty::$_MBSTRING = true; + \Smarty\Smarty::$_MBSTRING = true; } public function testEncodeJavascript() @@ -61,11 +61,11 @@ class PluginFunctionMailtoTest extends PHPUnit_Smarty public function testEncodeJavascriptWithoutMbstring() { - Smarty::$_MBSTRING = false; + \Smarty\Smarty::$_MBSTRING = false; $result = ''; $tpl = $this->smarty->createTemplate('eval:{mailto address="me@example.com" encode="javascript"}'); $this->assertEquals(str_replace("\r", '', $result), $this->smarty->fetch($tpl)); - Smarty::$_MBSTRING = true; + \Smarty\Smarty::$_MBSTRING = true; } public function testEncodeJavascriptCharcode() @@ -77,11 +77,11 @@ class PluginFunctionMailtoTest extends PHPUnit_Smarty public function testEncodeJavascriptCharcodeWithoutMbstring() { - Smarty::$_MBSTRING = false; + \Smarty\Smarty::$_MBSTRING = false; $result = ''; $tpl = $this->smarty->createTemplate('eval:{mailto address="me@example.com" encode="javascript_charcode"}'); $this->assertEquals(str_replace("\r", '', $result), $this->smarty->fetch($tpl)); - Smarty::$_MBSTRING = true; + \Smarty\Smarty::$_MBSTRING = true; } public function testEncodeHex() @@ -93,11 +93,11 @@ class PluginFunctionMailtoTest extends PHPUnit_Smarty public function testEncodeHexWithoutMbstring() { - Smarty::$_MBSTRING = false; + \Smarty\Smarty::$_MBSTRING = false; $result = 'me@example.com'; $tpl = $this->smarty->createTemplate('eval:{mailto address="me@example.com" encode="hex"}'); $this->assertEquals(str_replace("\r", '', $result), $this->smarty->fetch($tpl)); - Smarty::$_MBSTRING = true; + \Smarty\Smarty::$_MBSTRING = true; } public function testSubject() @@ -109,11 +109,11 @@ class PluginFunctionMailtoTest extends PHPUnit_Smarty public function testSubjectWithoutMbstring() { - Smarty::$_MBSTRING = false; + \Smarty\Smarty::$_MBSTRING = false; $result = 'me@example.com'; $tpl = $this->smarty->createTemplate('eval:{mailto address="me@example.com" subject="Hello to you!"}'); $this->assertEquals(str_replace("\r", '', $result), $this->smarty->fetch($tpl)); - Smarty::$_MBSTRING = true; + \Smarty\Smarty::$_MBSTRING = true; } public function testCc() @@ -125,11 +125,11 @@ class PluginFunctionMailtoTest extends PHPUnit_Smarty public function testCcWithoutMbstring() { - Smarty::$_MBSTRING = false; + \Smarty\Smarty::$_MBSTRING = false; $result = 'me@example.com'; $tpl = $this->smarty->createTemplate('eval:{mailto address="me@example.com" cc="you@example.com,they@example.com"}'); $this->assertEquals(str_replace("\r", '', $result), $this->smarty->fetch($tpl)); - Smarty::$_MBSTRING = true; + \Smarty\Smarty::$_MBSTRING = true; } public function testExtra() @@ -141,11 +141,11 @@ class PluginFunctionMailtoTest extends PHPUnit_Smarty public function testExtraWithoutMbstring() { - Smarty::$_MBSTRING = false; + \Smarty\Smarty::$_MBSTRING = false; $result = ''; $tpl = $this->smarty->createTemplate('eval:{mailto address="me@example.com" extra=\'class="email"\'}'); $this->assertEquals(str_replace("\r", '', $result), $this->smarty->fetch($tpl)); - Smarty::$_MBSTRING = true; + \Smarty\Smarty::$_MBSTRING = true; } public function testUmlauts() @@ -157,11 +157,11 @@ class PluginFunctionMailtoTest extends PHPUnit_Smarty public function testUmlautsWithoutMbstring() { - Smarty::$_MBSTRING = false; + \Smarty\Smarty::$_MBSTRING = false; $result = 'me+smtpext@example.com'; $tpl = $this->smarty->createTemplate('eval:{mailto address="me+smtpext@example.com" cc="you@example.com,they@example.com" subject="hällo wörld"}'); $this->assertEquals(str_replace("\r", '', $result), $this->smarty->fetch($tpl)); - Smarty::$_MBSTRING = true; + \Smarty\Smarty::$_MBSTRING = true; } public function testJavascriptChars() diff --git a/tests/UnitTests/TemplateSource/TagTests/PluginModifier/PluginModifierCapitalizeTest.php b/tests/UnitTests/TemplateSource/TagTests/PluginModifier/PluginModifierCapitalizeTest.php index 9fc10d75..0bc14272 100644 --- a/tests/UnitTests/TemplateSource/TagTests/PluginModifier/PluginModifierCapitalizeTest.php +++ b/tests/UnitTests/TemplateSource/TagTests/PluginModifier/PluginModifierCapitalizeTest.php @@ -42,29 +42,29 @@ class PluginModifierCapitalizeTest extends PHPUnit_Smarty public function testDefaultWithoutMbstring() { - Smarty::$_MBSTRING = false; + \Smarty\Smarty::$_MBSTRING = false; $this->smarty->setCompileId('mb'); $tpl = $this->smarty->createTemplate('string:{"next x-men fiLm, x3, delayed."|capitalize}'); $this->assertEquals("Next X-Men FiLm, x3, Delayed.", $this->smarty->fetch($tpl)); - Smarty::$_MBSTRING = true; + \Smarty\Smarty::$_MBSTRING = true; } public function testDigitsWithoutMbstring() { - Smarty::$_MBSTRING = false; + \Smarty\Smarty::$_MBSTRING = false; $this->smarty->setCompileId('mb'); $tpl = $this->smarty->createTemplate('string:{"next x-men fiLm, x3, delayed."|capitalize:true}'); $this->assertEquals("Next X-Men FiLm, X3, Delayed.", $this->smarty->fetch($tpl)); - Smarty::$_MBSTRING = true; + \Smarty\Smarty::$_MBSTRING = true; } public function testTrueCaptialsWithoutMbstring() { - Smarty::$_MBSTRING = false; + \Smarty\Smarty::$_MBSTRING = false; $this->smarty->setCompileId('mb'); $tpl = $this->smarty->createTemplate('string:{"next x-men fiLm, x3, delayed."|capitalize:true:true}'); $this->assertEquals("Next X-Men Film, X3, Delayed.", $this->smarty->fetch($tpl)); - Smarty::$_MBSTRING = true; + \Smarty\Smarty::$_MBSTRING = true; } public function testQuotes() @@ -77,13 +77,13 @@ class PluginModifierCapitalizeTest extends PHPUnit_Smarty public function testQuotesWithoutMbstring() { - Smarty::$_MBSTRING = false; + \Smarty\Smarty::$_MBSTRING = false; $this->smarty->setCompileId('mb'); $tpl = $this->smarty->createTemplate('string:{"next x-men fiLm, x3, \"delayed. umlauts\" foo."|capitalize}'); $this->assertEquals("Next X-Men FiLm, x3, \"Delayed. Umlauts\" Foo.", $this->smarty->fetch($tpl)); $tpl = $this->smarty->createTemplate('string:{"next x-men fiLm, x3, \'delayed. umlauts\' foo."|capitalize}'); $this->assertEquals("Next X-Men FiLm, x3, 'Delayed. Umlauts' Foo.", $this->smarty->fetch($tpl)); - Smarty::$_MBSTRING = true; + \Smarty\Smarty::$_MBSTRING = true; } public function testQuotesDigits() @@ -98,7 +98,7 @@ class PluginModifierCapitalizeTest extends PHPUnit_Smarty public function testQuotesDigitsWithoutMbstring() { - Smarty::$_MBSTRING = false; + \Smarty\Smarty::$_MBSTRING = false; $this->smarty->setCompileId('mb'); $tpl = $this->smarty->createTemplate('string:{"next x-men fiLm, x3, \"delayed. umlauts\" foo."|capitalize:true}'); @@ -106,7 +106,7 @@ class PluginModifierCapitalizeTest extends PHPUnit_Smarty $tpl = $this->smarty->createTemplate('string:{"next x-men fiLm, x3, \'delayed. umlauts\' foo."|capitalize:true}'); $this->assertEquals("Next X-Men FiLm, X3, 'Delayed. Umlauts' Foo.", $this->smarty->fetch($tpl)); - Smarty::$_MBSTRING = true; + \Smarty\Smarty::$_MBSTRING = true; } public function testQuotesTrueCapitals() @@ -121,7 +121,7 @@ class PluginModifierCapitalizeTest extends PHPUnit_Smarty public function testQuotesTrueCapitalsWithoutMbstring() { - Smarty::$_MBSTRING = false; + \Smarty\Smarty::$_MBSTRING = false; $this->smarty->setCompileId('mb'); $tpl = $this->smarty->createTemplate('string:{"next x-men fiLm, x3, \"delayed. umlauts\" foo."|capitalize:true:true}'); @@ -129,7 +129,7 @@ class PluginModifierCapitalizeTest extends PHPUnit_Smarty $tpl = $this->smarty->createTemplate('string:{"next x-men fiLm, x3, \'delayed. umlauts\' foo."|capitalize:true:true}'); $this->assertEquals("Next X-Men Film, X3, 'Delayed. Umlauts' Foo.", $this->smarty->fetch($tpl)); - Smarty::$_MBSTRING = true; + \Smarty\Smarty::$_MBSTRING = true; } public function testQuotesBeginning() @@ -142,12 +142,12 @@ class PluginModifierCapitalizeTest extends PHPUnit_Smarty public function testQuotesBeginningWithoutMbstring() { - Smarty::$_MBSTRING = false; + \Smarty\Smarty::$_MBSTRING = false; $this->smarty->setCompileId('mb'); $tpl = $this->smarty->createTemplate('string:{"\"delayed. umlauts\" foo."|capitalize}'); $this->assertEquals("\"Delayed. Umlauts\" Foo.", $this->smarty->fetch($tpl)); $tpl = $this->smarty->createTemplate('string:{"\'delayed. umlauts\' foo."|capitalize}'); $this->assertEquals("'Delayed. Umlauts' Foo.", $this->smarty->fetch($tpl)); - Smarty::$_MBSTRING = true; + \Smarty\Smarty::$_MBSTRING = true; } } diff --git a/tests/UnitTests/TemplateSource/TagTests/PluginModifier/PluginModifierCharsetTest.php b/tests/UnitTests/TemplateSource/TagTests/PluginModifier/PluginModifierCharsetTest.php index 92ff9514..e5b6038b 100644 --- a/tests/UnitTests/TemplateSource/TagTests/PluginModifier/PluginModifierCharsetTest.php +++ b/tests/UnitTests/TemplateSource/TagTests/PluginModifier/PluginModifierCharsetTest.php @@ -30,13 +30,13 @@ class PluginModifierCharsetTest extends PHPUnit_Smarty public function testToLatin1WithoutMbstring() { - Smarty::$_MBSTRING = false; + \Smarty\Smarty::$_MBSTRING = false; $this->smarty->setCompileId('mb'); $encoded = "hällö wörld 2"; $result = mb_convert_encoding($encoded, 'ISO-8859-1', 'UTF-8'); $tpl = $this->smarty->createTemplate('string:{"' . $encoded . '"|to_charset}'); $this->assertEquals($encoded, $tpl->fetch()); - Smarty::$_MBSTRING = true; + \Smarty\Smarty::$_MBSTRING = true; } public function testFromLatin1() @@ -49,13 +49,13 @@ class PluginModifierCharsetTest extends PHPUnit_Smarty public function testFromLatin1WithoutMbstring() { - Smarty::$_MBSTRING = false; + \Smarty\Smarty::$_MBSTRING = false; $this->smarty->setCompileId('mb'); $result = "hällö wörld 4"; $encoded = mb_convert_encoding($result, 'ISO-8859-1', 'UTF-8'); $tpl = $this->smarty->createTemplate('string:{"' . $encoded . '"|from_charset}'); $this->assertEquals($encoded, $tpl->fetch()); - Smarty::$_MBSTRING = true; + \Smarty\Smarty::$_MBSTRING = true; } public function testFromUtf32le() @@ -68,13 +68,13 @@ class PluginModifierCharsetTest extends PHPUnit_Smarty public function testFromUtf32leWithoutMbstring() { - Smarty::$_MBSTRING = false; + \Smarty\Smarty::$_MBSTRING = false; $this->smarty->setCompileId('mb'); $result = "hällö wörld 6"; $encoded = mb_convert_encoding($result, "UTF-32LE", "UTF-8"); $tpl = $this->smarty->createTemplate('string:{"' . $encoded . '"|from_charset:"UTF-32LE"}'); $this->assertEquals($encoded, $tpl->fetch()); - Smarty::$_MBSTRING = true; + \Smarty\Smarty::$_MBSTRING = true; } public function testToUtf32le() @@ -87,12 +87,12 @@ class PluginModifierCharsetTest extends PHPUnit_Smarty public function testToUtf32leWithoutMbstring() { - Smarty::$_MBSTRING = false; + \Smarty\Smarty::$_MBSTRING = false; $this->smarty->setCompileId('mb'); $encoded = "hällö wörld 8"; $result = mb_convert_encoding($encoded, "UTF-32LE", "UTF-8"); $tpl = $this->smarty->createTemplate('string:{"' . $encoded . '"|to_charset:"UTF-32LE"}'); $this->assertEquals($encoded, $tpl->fetch()); - Smarty::$_MBSTRING = true; + \Smarty\Smarty::$_MBSTRING = true; } } diff --git a/tests/UnitTests/TemplateSource/TagTests/PluginModifier/PluginModifierCountCharactersTest.php b/tests/UnitTests/TemplateSource/TagTests/PluginModifier/PluginModifierCountCharactersTest.php index 14955ded..2d894858 100644 --- a/tests/UnitTests/TemplateSource/TagTests/PluginModifier/PluginModifierCountCharactersTest.php +++ b/tests/UnitTests/TemplateSource/TagTests/PluginModifier/PluginModifierCountCharactersTest.php @@ -29,12 +29,12 @@ class PluginModifierCountCharactersTest extends PHPUnit_Smarty public function testDefaultWithoutMbstring() { - Smarty::$_MBSTRING = false; + \Smarty\Smarty::$_MBSTRING = false; $this->smarty->setCompileId ('mb'); $result = "29"; $tpl = $this->smarty->createTemplate('string:{"Cold Wave Linked to Temperatures."|count_characters}'); $this->assertEquals(str_replace("\r", '', $result), $this->smarty->fetch($tpl)); - Smarty::$_MBSTRING = true; + \Smarty\Smarty::$_MBSTRING = true; } public function testSpaces() @@ -46,12 +46,12 @@ class PluginModifierCountCharactersTest extends PHPUnit_Smarty public function testSpacesWithoutMbstring() { - Smarty::$_MBSTRING = false; + \Smarty\Smarty::$_MBSTRING = false; $this->smarty->setCompileId ('mb'); $result = "33"; $tpl = $this->smarty->createTemplate('string:{"Cold Wave Linked to Temperatures."|count_characters:true}'); $this->assertEquals(str_replace("\r", '', $result), $this->smarty->fetch($tpl)); - Smarty::$_MBSTRING = true; + \Smarty\Smarty::$_MBSTRING = true; } public function testUmlauts() @@ -63,12 +63,12 @@ class PluginModifierCountCharactersTest extends PHPUnit_Smarty public function testUmlautsWithoutMbstring() { - Smarty::$_MBSTRING = false; + \Smarty\Smarty::$_MBSTRING = false; $this->smarty->setCompileId ('mb'); $result = "29"; $tpl = $this->smarty->createTemplate('string:{"Cold Wäve Linked tö Temperatures."|count_characters}'); $this->assertEquals(str_replace("\r", '', $result), $this->smarty->fetch($tpl)); - Smarty::$_MBSTRING = true; + \Smarty\Smarty::$_MBSTRING = true; } public function testUmlautsSpaces() @@ -80,11 +80,11 @@ class PluginModifierCountCharactersTest extends PHPUnit_Smarty public function testUmlautsSpacesWithoutMbstring() { - Smarty::$_MBSTRING = false; + \Smarty\Smarty::$_MBSTRING = false; $this->smarty->setCompileId ('mb'); $result = "33"; $tpl = $this->smarty->createTemplate('string:{"Cold Wäve Linked tö Temperatures."|count_characters:true}'); $this->assertNotEquals($result, $this->smarty->fetch($tpl)); - Smarty::$_MBSTRING = true; + \Smarty\Smarty::$_MBSTRING = true; } } diff --git a/tests/UnitTests/TemplateSource/TagTests/PluginModifier/PluginModifierCountSentencesTest.php b/tests/UnitTests/TemplateSource/TagTests/PluginModifier/PluginModifierCountSentencesTest.php index 1abd12b8..bde85da2 100644 --- a/tests/UnitTests/TemplateSource/TagTests/PluginModifier/PluginModifierCountSentencesTest.php +++ b/tests/UnitTests/TemplateSource/TagTests/PluginModifier/PluginModifierCountSentencesTest.php @@ -37,14 +37,14 @@ class PluginModifierCountSentencesTest extends PHPUnit_Smarty public function testDefaultWithoutMbstring() { - Smarty::$_MBSTRING = false;$this->smarty->setCompileId('mb'); + \Smarty\Smarty::$_MBSTRING = false;$this->smarty->setCompileId('mb'); $tpl = $this->smarty->createTemplate('string:{"hello world."|count_sentences}'); $this->assertEquals("1", $this->smarty->fetch($tpl)); $tpl = $this->smarty->createTemplate('string:{"hello world. I\'m another? Sentence!"|count_sentences}'); $this->assertEquals("3", $this->smarty->fetch($tpl)); $tpl = $this->smarty->createTemplate('string:{"hello world.wrong"|count_sentences}'); $this->assertEquals("0", $this->smarty->fetch($tpl)); - Smarty::$_MBSTRING = true; + \Smarty\Smarty::$_MBSTRING = true; } public function testUmlauts() diff --git a/tests/UnitTests/TemplateSource/TagTests/PluginModifier/PluginModifierCountWordsTest.php b/tests/UnitTests/TemplateSource/TagTests/PluginModifier/PluginModifierCountWordsTest.php index c6c1b543..11b71d61 100644 --- a/tests/UnitTests/TemplateSource/TagTests/PluginModifier/PluginModifierCountWordsTest.php +++ b/tests/UnitTests/TemplateSource/TagTests/PluginModifier/PluginModifierCountWordsTest.php @@ -29,11 +29,11 @@ class PluginModifierCountWordsTest extends PHPUnit_Smarty public function testDefaultWithoutMbstring() { - Smarty::$_MBSTRING = false;$this->smarty->setCompileId('mb'); + \Smarty\Smarty::$_MBSTRING = false;$this->smarty->setCompileId('mb'); $result = "7"; $tpl = $this->smarty->createTemplate('string:{"Dealers Will Hear Car Talk at Noon."|count_words}'); $this->assertEquals(str_replace("\r", '', $result), $this->smarty->fetch($tpl)); - Smarty::$_MBSTRING = true; + \Smarty\Smarty::$_MBSTRING = true; } public function testDashes() @@ -45,11 +45,11 @@ class PluginModifierCountWordsTest extends PHPUnit_Smarty public function testDashesWithoutMbstring() { - Smarty::$_MBSTRING = false;$this->smarty->setCompileId('mb'); + \Smarty\Smarty::$_MBSTRING = false;$this->smarty->setCompileId('mb'); $result = "7"; $tpl = $this->smarty->createTemplate('string:{"Smalltime-Dealers Will Hear Car Talk at Noon."|count_words}'); $this->assertEquals(str_replace("\r", '', $result), $this->smarty->fetch($tpl)); - Smarty::$_MBSTRING = true; + \Smarty\Smarty::$_MBSTRING = true; } public function testUmlauts() @@ -61,10 +61,10 @@ class PluginModifierCountWordsTest extends PHPUnit_Smarty public function testUmlautsWithoutMbstring() { - Smarty::$_MBSTRING = false;$this->smarty->setCompileId('mb'); + \Smarty\Smarty::$_MBSTRING = false;$this->smarty->setCompileId('mb'); $result = "7"; $tpl = $this->smarty->createTemplate('string:{"Dealers Will Hear Cär Talk at Nöön."|count_words}'); $this->assertNotEquals($result, $this->smarty->fetch($tpl)); - Smarty::$_MBSTRING = true; + \Smarty\Smarty::$_MBSTRING = true; } } diff --git a/tests/UnitTests/TemplateSource/TagTests/PluginModifier/PluginModifierEscapeTest.php b/tests/UnitTests/TemplateSource/TagTests/PluginModifier/PluginModifierEscapeTest.php index 309a71ab..c39229ff 100644 --- a/tests/UnitTests/TemplateSource/TagTests/PluginModifier/PluginModifierEscapeTest.php +++ b/tests/UnitTests/TemplateSource/TagTests/PluginModifier/PluginModifierEscapeTest.php @@ -35,10 +35,10 @@ class PluginModifierEscapeTest extends PHPUnit_Smarty public function testHtmlWithoutMbstring() { - Smarty::$_MBSTRING = false;$this->smarty->setCompileId('mb'); + \Smarty\Smarty::$_MBSTRING = false;$this->smarty->setCompileId('mb'); $tpl = $this->smarty->createTemplate('string:{"I\'m some to ä be \"escaped\" or ©"|escape:"html"}'); $this->assertEquals("I'm some <html> to ä be "escaped" or &copy;", $this->smarty->fetch($tpl)); - Smarty::$_MBSTRING = true; + \Smarty\Smarty::$_MBSTRING = true; } public function testHtmlDouble() @@ -49,10 +49,10 @@ class PluginModifierEscapeTest extends PHPUnit_Smarty public function testHtmlDoubleWithoutMbstring() { - Smarty::$_MBSTRING = false;$this->smarty->setCompileId('mb'); + \Smarty\Smarty::$_MBSTRING = false;$this->smarty->setCompileId('mb'); $tpl = $this->smarty->createTemplate('string:{"I\'m some to ä be \"escaped\" or ©"|escape:"html":null:false}'); $this->assertEquals("I'm some <html> to ä be "escaped" or ©", $this->smarty->fetch($tpl)); - Smarty::$_MBSTRING = true; + \Smarty\Smarty::$_MBSTRING = true; } public function testHtmlallCompiled() @@ -70,19 +70,19 @@ class PluginModifierEscapeTest extends PHPUnit_Smarty public function testHtmlallWithoutMbstringCompiled() { - Smarty::$_MBSTRING = false;$this->smarty->setCompileId('mb'); + \Smarty\Smarty::$_MBSTRING = false;$this->smarty->setCompileId('mb'); $tpl = $this->smarty->createTemplate('string:{"I\'m some to ä be \"escaped\" or ©"|escape:"htmlall"}'); $this->assertEquals("I'm some <html> to ä be "escaped" or &copy;", $this->smarty->fetch($tpl)); - Smarty::$_MBSTRING = true; + \Smarty\Smarty::$_MBSTRING = true; } public function testHtmlallWithoutMbstringModifier() { - Smarty::$_MBSTRING = false;$this->smarty->setCompileId('mb'); + \Smarty\Smarty::$_MBSTRING = false;$this->smarty->setCompileId('mb'); $tpl = $this->smarty->createTemplate('string:{"I\'m some to ä be \"escaped\" or ©"|escape:$mode}'); $this->smarty->assign('mode', 'htmlall'); $this->assertEquals("I'm some <html> to ä be "escaped" or &copy;", $this->smarty->fetch($tpl)); - Smarty::$_MBSTRING = true; + \Smarty\Smarty::$_MBSTRING = true; } public function testHtmlallDouble() @@ -93,10 +93,10 @@ class PluginModifierEscapeTest extends PHPUnit_Smarty public function testHtmlallDoubleWithoutMbstring() { - Smarty::$_MBSTRING = false;$this->smarty->setCompileId('mb'); + \Smarty\Smarty::$_MBSTRING = false;$this->smarty->setCompileId('mb'); $tpl = $this->smarty->createTemplate('string:{"I\'m some to ä be \"escaped\" or ©"|escape:"htmlall":null:false}'); $this->assertEquals("I'm some <html> to ä be "escaped" or ©", $this->smarty->fetch($tpl)); - Smarty::$_MBSTRING = true; + \Smarty\Smarty::$_MBSTRING = true; } public function testUrlCompiled() @@ -114,10 +114,10 @@ class PluginModifierEscapeTest extends PHPUnit_Smarty public function testUrlWithoutMbstring() { - Smarty::$_MBSTRING = false;$this->smarty->setCompileId('mb'); + \Smarty\Smarty::$_MBSTRING = false;$this->smarty->setCompileId('mb'); $tpl = $this->smarty->createTemplate('string:{"http://some.encoded.com/url?parts#foo"|escape:"url"}'); $this->assertEquals("http%3A%2F%2Fsome.encoded.com%2Furl%3Fparts%23foo", $this->smarty->fetch($tpl)); - Smarty::$_MBSTRING = true; + \Smarty\Smarty::$_MBSTRING = true; } public function testUrlpathinfo() @@ -128,10 +128,10 @@ class PluginModifierEscapeTest extends PHPUnit_Smarty public function testUrlpathinfoWithoutMbstring() { - Smarty::$_MBSTRING = false;$this->smarty->setCompileId('mb'); + \Smarty\Smarty::$_MBSTRING = false;$this->smarty->setCompileId('mb'); $tpl = $this->smarty->createTemplate('string:{"http://some.encoded.com/url?parts#foo"|escape:"urlpathinfo"}'); $this->assertEquals("http%3A//some.encoded.com/url%3Fparts%23foo", $this->smarty->fetch($tpl)); - Smarty::$_MBSTRING = true; + \Smarty\Smarty::$_MBSTRING = true; } public function testHex() @@ -142,10 +142,10 @@ class PluginModifierEscapeTest extends PHPUnit_Smarty public function testHexWithoutMbstring() { - Smarty::$_MBSTRING = false;$this->smarty->setCompileId('mb'); + \Smarty\Smarty::$_MBSTRING = false;$this->smarty->setCompileId('mb'); $tpl = $this->smarty->createTemplate('string:{"a/cäa"|escape:"hex"}'); $this->assertEquals("%61%2f%63%c3%a4%61", $this->smarty->fetch($tpl)); - Smarty::$_MBSTRING = true; + \Smarty\Smarty::$_MBSTRING = true; } public function testHexentity() @@ -161,7 +161,7 @@ class PluginModifierEscapeTest extends PHPUnit_Smarty public function testHexentityWithoutMbstring() { - Smarty::$_MBSTRING = false;$this->smarty->setCompileId('mb'); + \Smarty\Smarty::$_MBSTRING = false;$this->smarty->setCompileId('mb'); $q = "aäЗдравсствуйте"; $r = html_entity_decode($q, ENT_NOQUOTES, 'UTF-8'); $tpl = $this->smarty->createTemplate('string:{"' . $r . '"|escape:"hexentity"}'); @@ -169,7 +169,7 @@ class PluginModifierEscapeTest extends PHPUnit_Smarty $tpl = $this->smarty->createTemplate('string:{"abc"|escape:"hexentity"}'); $this->assertEquals("abc", $this->smarty->fetch($tpl)); - Smarty::$_MBSTRING = true; + \Smarty\Smarty::$_MBSTRING = true; } public function testDecentity() @@ -185,7 +185,7 @@ class PluginModifierEscapeTest extends PHPUnit_Smarty public function testDecentityWithoutMbstring() { - Smarty::$_MBSTRING = false;$this->smarty->setCompileId('mb'); + \Smarty\Smarty::$_MBSTRING = false;$this->smarty->setCompileId('mb'); $q = "aäЗдравсствуйте"; $r = html_entity_decode($q, ENT_NOQUOTES, 'UTF-8'); $tpl = $this->smarty->createTemplate('string:{"' . $r . '"|escape:"decentity"}'); @@ -193,7 +193,7 @@ class PluginModifierEscapeTest extends PHPUnit_Smarty $tpl = $this->smarty->createTemplate('string:{"abc"|escape:"decentity"}'); $this->assertEquals("abc", $this->smarty->fetch($tpl)); - Smarty::$_MBSTRING = true; + \Smarty\Smarty::$_MBSTRING = true; } public function testJavascript() @@ -204,10 +204,10 @@ class PluginModifierEscapeTest extends PHPUnit_Smarty public function testJavascriptWithoutMbstring() { - Smarty::$_MBSTRING = false;$this->smarty->setCompileId('mb'); + \Smarty\Smarty::$_MBSTRING = false;$this->smarty->setCompileId('mb'); $tpl = $this->smarty->createTemplate('string:{"var x = { foo : \"bar\n\" };"|escape:"javascript"}'); $this->assertEquals("var x = { foo : \\\"bar\\n\\\" };", $this->smarty->fetch($tpl)); - Smarty::$_MBSTRING = true; + \Smarty\Smarty::$_MBSTRING = true; } public function testMail() @@ -218,10 +218,10 @@ class PluginModifierEscapeTest extends PHPUnit_Smarty public function testMailWithoutMbstring() { - Smarty::$_MBSTRING = false;$this->smarty->setCompileId('mb'); + \Smarty\Smarty::$_MBSTRING = false;$this->smarty->setCompileId('mb'); $tpl = $this->smarty->createTemplate('string:{"smarty@example.com"|escape:"mail"}'); $this->assertEquals("smarty [AT] example [DOT] com", $this->smarty->fetch($tpl)); - Smarty::$_MBSTRING = true; + \Smarty\Smarty::$_MBSTRING = true; } public function testNonstd() @@ -232,9 +232,9 @@ class PluginModifierEscapeTest extends PHPUnit_Smarty public function testNonstdWithoutMbstring() { - Smarty::$_MBSTRING = false;$this->smarty->setCompileId('mb'); + \Smarty\Smarty::$_MBSTRING = false;$this->smarty->setCompileId('mb'); $tpl = $this->smarty->createTemplate('string:{"' . mb_convert_encoding('sma\'rty@»example«.com', 'ISO-8859-1', 'UTF-8') . '"|escape:"nonstd"}'); $this->assertEquals("sma'rty@»example«.com", $this->smarty->fetch($tpl)); - Smarty::$_MBSTRING = true; + \Smarty\Smarty::$_MBSTRING = true; } } diff --git a/tests/UnitTests/TemplateSource/TagTests/PluginModifier/PluginModifierLowerTest.php b/tests/UnitTests/TemplateSource/TagTests/PluginModifier/PluginModifierLowerTest.php index 06235551..edf36c31 100644 --- a/tests/UnitTests/TemplateSource/TagTests/PluginModifier/PluginModifierLowerTest.php +++ b/tests/UnitTests/TemplateSource/TagTests/PluginModifier/PluginModifierLowerTest.php @@ -28,11 +28,11 @@ class PluginModifierLowerTest extends PHPUnit_Smarty public function testDefaultWithoutMbstring() { - Smarty::$_MBSTRING = false;$this->smarty->setCompileId('mb'); + \Smarty\Smarty::$_MBSTRING = false;$this->smarty->setCompileId('mb'); $result = "two convicts evade noose, jury hung."; $tpl = $this->smarty->createTemplate('string:{"Two Convicts Evade Noose, Jury Hung."|lower}'); $this->assertEquals(str_replace("\r", '', $result), $this->smarty->fetch($tpl)); - Smarty::$_MBSTRING = true; + \Smarty\Smarty::$_MBSTRING = true; } public function testUmlauts() @@ -44,10 +44,10 @@ class PluginModifierLowerTest extends PHPUnit_Smarty public function testUmlautsWithoutMbstring() { - Smarty::$_MBSTRING = false;$this->smarty->setCompileId('mb'); + \Smarty\Smarty::$_MBSTRING = false;$this->smarty->setCompileId('mb'); $result = "two convicts eväde nööse, jury hung."; $tpl = $this->smarty->createTemplate('string:{"Two Convicts Eväde NöÖse, Jury Hung."|lower}'); $this->assertNotEquals($result, $this->smarty->fetch($tpl)); - Smarty::$_MBSTRING = true; + \Smarty\Smarty::$_MBSTRING = true; } } diff --git a/tests/UnitTests/TemplateSource/TagTests/PluginModifier/PluginModifierRegexReplaceTest.php b/tests/UnitTests/TemplateSource/TagTests/PluginModifier/PluginModifierRegexReplaceTest.php index f0a79ffc..d2e379ea 100644 --- a/tests/UnitTests/TemplateSource/TagTests/PluginModifier/PluginModifierRegexReplaceTest.php +++ b/tests/UnitTests/TemplateSource/TagTests/PluginModifier/PluginModifierRegexReplaceTest.php @@ -28,10 +28,10 @@ class PluginModifierRegexReplaceTest extends PHPUnit_Smarty public function testDefaultWithoutMbstring() { - Smarty::$_MBSTRING = false;$this->smarty->setCompileId('mb'); + \Smarty\Smarty::$_MBSTRING = false;$this->smarty->setCompileId('mb'); $tpl = $this->smarty->createTemplate('string:{"Infertility unlikely to\nbe passed on, experts say."|regex_replace:"/[\r\t\n]/":" "}'); $this->assertEquals("Infertility unlikely to be passed on, experts say.", $this->smarty->fetch($tpl)); - Smarty::$_MBSTRING = true; + \Smarty\Smarty::$_MBSTRING = true; } public function testUmlauts() diff --git a/tests/UnitTests/TemplateSource/TagTests/PluginModifier/PluginModifierTruncateTest.php b/tests/UnitTests/TemplateSource/TagTests/PluginModifier/PluginModifierTruncateTest.php index 667fb7d7..e7c4a987 100644 --- a/tests/UnitTests/TemplateSource/TagTests/PluginModifier/PluginModifierTruncateTest.php +++ b/tests/UnitTests/TemplateSource/TagTests/PluginModifier/PluginModifierTruncateTest.php @@ -29,11 +29,11 @@ class PluginModifierTruncateTest extends PHPUnit_Smarty public function testDefaultWithoutMbstring() { - Smarty::$_MBSTRING = false;$this->smarty->setCompileId('mb'); + \Smarty\Smarty::$_MBSTRING = false;$this->smarty->setCompileId('mb'); $result = 'Two Sisters Reunite after Eighteen Years at Checkout Counter.'; $tpl = $this->smarty->createTemplate('string:{"Two Sisters Reunite after Eighteen Years at Checkout Counter."|truncate}'); $this->assertEquals(str_replace("\r", '', $result), $this->smarty->fetch($tpl)); - Smarty::$_MBSTRING = true; + \Smarty\Smarty::$_MBSTRING = true; } public function testLength() @@ -45,11 +45,11 @@ class PluginModifierTruncateTest extends PHPUnit_Smarty public function testLengthWithoutMbstring() { - Smarty::$_MBSTRING = false;$this->smarty->setCompileId('mb'); + \Smarty\Smarty::$_MBSTRING = false;$this->smarty->setCompileId('mb'); $result = 'Two Sisters Reunite after...'; $tpl = $this->smarty->createTemplate('string:{"Two Sisters Reunite after Eighteen Years at Checkout Counter."|truncate:30}'); $this->assertEquals(str_replace("\r", '', $result), $this->smarty->fetch($tpl)); - Smarty::$_MBSTRING = true; + \Smarty\Smarty::$_MBSTRING = true; } public function testEtc() @@ -61,11 +61,11 @@ class PluginModifierTruncateTest extends PHPUnit_Smarty public function testEtcWithoutMbstring() { - Smarty::$_MBSTRING = false;$this->smarty->setCompileId('mb'); + \Smarty\Smarty::$_MBSTRING = false;$this->smarty->setCompileId('mb'); $result = 'Two Sisters Reunite after'; $tpl = $this->smarty->createTemplate('string:{"Two Sisters Reunite after Eighteen Years at Checkout Counter."|truncate:30:""}'); $this->assertEquals(str_replace("\r", '', $result), $this->smarty->fetch($tpl)); - Smarty::$_MBSTRING = true; + \Smarty\Smarty::$_MBSTRING = true; } public function testEtc2() @@ -77,11 +77,11 @@ class PluginModifierTruncateTest extends PHPUnit_Smarty public function testEtc2WithoutMbstring() { - Smarty::$_MBSTRING = false;$this->smarty->setCompileId('mb'); + \Smarty\Smarty::$_MBSTRING = false;$this->smarty->setCompileId('mb'); $result = 'Two Sisters Reunite after---'; $tpl = $this->smarty->createTemplate('string:{"Two Sisters Reunite after Eighteen Years at Checkout Counter."|truncate:30:"---"}'); $this->assertEquals(str_replace("\r", '', $result), $this->smarty->fetch($tpl)); - Smarty::$_MBSTRING = true; + \Smarty\Smarty::$_MBSTRING = true; } public function testBreak() @@ -93,11 +93,11 @@ class PluginModifierTruncateTest extends PHPUnit_Smarty public function testBreakWithoutMbstring() { - Smarty::$_MBSTRING = false;$this->smarty->setCompileId('mb'); + \Smarty\Smarty::$_MBSTRING = false;$this->smarty->setCompileId('mb'); $result = 'Two Sisters Reunite after Eigh'; $tpl = $this->smarty->createTemplate('string:{"Two Sisters Reunite after Eighteen Years at Checkout Counter."|truncate:30:"":true}'); $this->assertEquals(str_replace("\r", '', $result), $this->smarty->fetch($tpl)); - Smarty::$_MBSTRING = true; + \Smarty\Smarty::$_MBSTRING = true; } public function testBreak2() @@ -109,11 +109,11 @@ class PluginModifierTruncateTest extends PHPUnit_Smarty public function testBreak2WithoutMbstring() { - Smarty::$_MBSTRING = false;$this->smarty->setCompileId('mb'); + \Smarty\Smarty::$_MBSTRING = false;$this->smarty->setCompileId('mb'); $result = 'Two Sisters Reunite after E...'; $tpl = $this->smarty->createTemplate('string:{"Two Sisters Reunite after Eighteen Years at Checkout Counter."|truncate:30:"...":true}'); $this->assertEquals(str_replace("\r", '', $result), $this->smarty->fetch($tpl)); - Smarty::$_MBSTRING = true; + \Smarty\Smarty::$_MBSTRING = true; } public function testMiddle() @@ -125,10 +125,10 @@ class PluginModifierTruncateTest extends PHPUnit_Smarty public function testMiddleWithoutMbstring() { - Smarty::$_MBSTRING = false;$this->smarty->setCompileId('mb'); + \Smarty\Smarty::$_MBSTRING = false;$this->smarty->setCompileId('mb'); $result = 'Two Sisters Re..ckout Counter.'; $tpl = $this->smarty->createTemplate('string:{"Two Sisters Reunite after Eighteen Years at Checkout Counter."|truncate:30:"..":true:true}'); $this->assertEquals(str_replace("\r", '', $result), $this->smarty->fetch($tpl)); - Smarty::$_MBSTRING = true; + \Smarty\Smarty::$_MBSTRING = true; } } diff --git a/tests/UnitTests/TemplateSource/TagTests/PluginModifier/PluginModifierUnescapeTest.php b/tests/UnitTests/TemplateSource/TagTests/PluginModifier/PluginModifierUnescapeTest.php index 2fdefb2e..def8f99d 100644 --- a/tests/UnitTests/TemplateSource/TagTests/PluginModifier/PluginModifierUnescapeTest.php +++ b/tests/UnitTests/TemplateSource/TagTests/PluginModifier/PluginModifierUnescapeTest.php @@ -30,12 +30,12 @@ class PluginModifierUnescapeTest extends PHPUnit_Smarty public function testHtmlWithoutMbstring() { - Smarty::$_MBSTRING = false;$this->smarty->setCompileId('mb'); + \Smarty\Smarty::$_MBSTRING = false;$this->smarty->setCompileId('mb'); $encoded = "aäЗдра><&amp;ääвсствуйте"; $result = "aäЗдра><&ääвсствуйте"; $tpl = $this->smarty->createTemplate('string:{"' . $encoded . '"|unescape:"html"}'); $this->assertEquals($result, $this->smarty->fetch($tpl)); - Smarty::$_MBSTRING = true; + \Smarty\Smarty::$_MBSTRING = true; } public function testHtmlall() @@ -48,12 +48,12 @@ class PluginModifierUnescapeTest extends PHPUnit_Smarty public function testHtmlallWithoutMbstring() { - Smarty::$_MBSTRING = false;$this->smarty->setCompileId('mb'); + \Smarty\Smarty::$_MBSTRING = false;$this->smarty->setCompileId('mb'); $encoded = "'"aäЗдра><&amp;ääвсствуйте"; $result = "'\"aäЗдра><&ääвсствуйте"; $tpl = $this->smarty->createTemplate('string:{"' . $encoded . '"|unescape:"htmlall"}'); $this->assertEquals($result, $this->smarty->fetch($tpl)); - Smarty::$_MBSTRING = true; + \Smarty\Smarty::$_MBSTRING = true; } public function testUrl() diff --git a/tests/UnitTests/TemplateSource/TagTests/PluginModifier/PluginModifierUpperTest.php b/tests/UnitTests/TemplateSource/TagTests/PluginModifier/PluginModifierUpperTest.php index 84d35a7c..eeec696f 100644 --- a/tests/UnitTests/TemplateSource/TagTests/PluginModifier/PluginModifierUpperTest.php +++ b/tests/UnitTests/TemplateSource/TagTests/PluginModifier/PluginModifierUpperTest.php @@ -29,11 +29,11 @@ class PluginModifierUpperTest extends PHPUnit_Smarty public function testDefaultWithoutMbstring() { - Smarty::$_MBSTRING = false;$this->smarty->setCompileId('mb'); + \Smarty\Smarty::$_MBSTRING = false;$this->smarty->setCompileId('mb'); $result = "IF STRIKE ISN'T SETTLED QUICKLY IT MAY LAST A WHILE."; $tpl = $this->smarty->createTemplate('string:{"If Strike isn\'t Settled Quickly it may Last a While."|upper}'); $this->assertEquals(str_replace("\r", '', $result), $this->smarty->fetch($tpl)); - Smarty::$_MBSTRING = true; + \Smarty\Smarty::$_MBSTRING = true; } public function testUmlauts() @@ -45,10 +45,10 @@ class PluginModifierUpperTest extends PHPUnit_Smarty public function testUmlautsWithoutMbstring() { - Smarty::$_MBSTRING = false;$this->smarty->setCompileId('mb'); + \Smarty\Smarty::$_MBSTRING = false;$this->smarty->setCompileId('mb'); $result = "IF STRIKE ISN'T SÄTTLED ÜQUICKLY IT MAY LAST A WHILE."; $tpl = $this->smarty->createTemplate('string:{"If Strike isn\'t Sättled ÜQuickly it may Last a While."|upper}'); $this->assertNotEquals($result, $this->smarty->fetch($tpl)); - Smarty::$_MBSTRING = true; + \Smarty\Smarty::$_MBSTRING = true; } } diff --git a/tests/UnitTests/TemplateSource/TagTests/PluginModifier/PluginModifierWordwrapTest.php b/tests/UnitTests/TemplateSource/TagTests/PluginModifier/PluginModifierWordwrapTest.php index 20b6f223..7a1396fa 100644 --- a/tests/UnitTests/TemplateSource/TagTests/PluginModifier/PluginModifierWordwrapTest.php +++ b/tests/UnitTests/TemplateSource/TagTests/PluginModifier/PluginModifierWordwrapTest.php @@ -28,11 +28,11 @@ class PluginModifierWordwrapTest extends PHPUnit_Smarty public function testDefaultWithoutMbstring() { - Smarty::$_MBSTRING = false; + \Smarty\Smarty::$_MBSTRING = false; $this->smarty->setCompileId('mb'); $tpl = $this->smarty->createTemplate('string:{"Blind woman gets new kidney from dad she hasn\'t seen in years."|wordwrap}'); $this->assertEquals("Blind woman gets new kidney from dad she hasn't seen in years.", $this->smarty->fetch($tpl)); - Smarty::$_MBSTRING = true; + \Smarty\Smarty::$_MBSTRING = true; } public function testDefaultUmlauts() @@ -49,11 +49,11 @@ class PluginModifierWordwrapTest extends PHPUnit_Smarty public function testLengthWithoutMbstring() { - Smarty::$_MBSTRING = false; + \Smarty\Smarty::$_MBSTRING = false; $this->smarty->setCompileId('mb'); $tpl = $this->smarty->createTemplate('string:{"Blind woman gets new kidney from dad she hasn\'t seen in years."|wordwrap:30}'); $this->assertEquals("Blind woman gets new kidney\nfrom dad she hasn't seen in\nyears.", $this->smarty->fetch($tpl)); - Smarty::$_MBSTRING = true; + \Smarty\Smarty::$_MBSTRING = true; } public function testBreak() @@ -64,11 +64,11 @@ class PluginModifierWordwrapTest extends PHPUnit_Smarty public function testBreakWithoutMbstring() { - Smarty::$_MBSTRING = false; + \Smarty\Smarty::$_MBSTRING = false; $this->smarty->setCompileId('mb'); $tpl = $this->smarty->createTemplate('string:{"Blind woman gets new kidney from dad she hasn\'t seen in years."|wordwrap:30:"
\n"}'); $this->assertEquals("Blind woman gets new kidney
\nfrom dad she hasn't seen in
\nyears.", $this->smarty->fetch($tpl)); - Smarty::$_MBSTRING = true; + \Smarty\Smarty::$_MBSTRING = true; } public function testLong() @@ -79,11 +79,11 @@ class PluginModifierWordwrapTest extends PHPUnit_Smarty public function testLongWithoutMbstring() { - Smarty::$_MBSTRING = false; + \Smarty\Smarty::$_MBSTRING = false; $this->smarty->setCompileId('mb'); $tpl = $this->smarty->createTemplate('string:{"Blind woman withaverylongandunpronoucablenameorso gets new kidney from dad she hasn\'t seen in years."|wordwrap:26:"\n"}'); $this->assertEquals("Blind woman\nwithaverylongandunpronoucablenameorso\ngets new kidney from dad\nshe hasn't seen in years.", $this->smarty->fetch($tpl)); - Smarty::$_MBSTRING = true; + \Smarty\Smarty::$_MBSTRING = true; } public function testLongUmlauts() @@ -100,11 +100,11 @@ class PluginModifierWordwrapTest extends PHPUnit_Smarty public function testLongCutWithoutMbstring() { - Smarty::$_MBSTRING = false; + \Smarty\Smarty::$_MBSTRING = false; $this->smarty->setCompileId('mb'); $tpl = $this->smarty->createTemplate('string:{"Blind woman withaverylongandunpronoucablenameorso gets new kidney from dad she hasn\'t seen in years."|wordwrap:26:"\n":true}'); $this->assertEquals("Blind woman\nwithaverylongandunpronouca\nblenameorso gets new\nkidney from dad she hasn't\nseen in years.", $this->smarty->fetch($tpl)); - Smarty::$_MBSTRING = true; + \Smarty\Smarty::$_MBSTRING = true; } public function testLongCutUmlauts() @@ -121,11 +121,11 @@ class PluginModifierWordwrapTest extends PHPUnit_Smarty public function testLinebreaksWithoutMbstring() { - Smarty::$_MBSTRING = false; + \Smarty\Smarty::$_MBSTRING = false; $this->smarty->setCompileId('mb'); $tpl = $this->smarty->createTemplate('string:{"Blind woman\ngets new kidney from dad she hasn\'t seen in years."|wordwrap:30}'); $this->assertEquals("Blind woman\ngets new kidney from dad she\nhasn't seen in years.", $this->smarty->fetch($tpl)); - Smarty::$_MBSTRING = true; + \Smarty\Smarty::$_MBSTRING = true; } public function testLinebreaks2() @@ -140,7 +140,7 @@ class PluginModifierWordwrapTest extends PHPUnit_Smarty public function testLinebreaks2WithoutMbstring() { - Smarty::$_MBSTRING = false; + \Smarty\Smarty::$_MBSTRING = false; $this->smarty->setCompileId('mb'); $tpl = $this->smarty->createTemplate('string:{"Blind woman gets @@ -148,7 +148,7 @@ class PluginModifierWordwrapTest extends PHPUnit_Smarty $this->assertEquals("Blind woman gets new kidney from\ndad she hasn't seen in years.", $this->smarty->fetch($tpl)); - Smarty::$_MBSTRING = true; + \Smarty\Smarty::$_MBSTRING = true; } /* public function testUnicodeSpaces() diff --git a/tests/UnitTests/TemplateSource/ValueTests/Modifier/ModifierTest.php b/tests/UnitTests/TemplateSource/ValueTests/Modifier/ModifierTest.php index 065a4920..f783f63b 100644 --- a/tests/UnitTests/TemplateSource/ValueTests/Modifier/ModifierTest.php +++ b/tests/UnitTests/TemplateSource/ValueTests/Modifier/ModifierTest.php @@ -79,7 +79,7 @@ class ModifierTest extends PHPUnit_Smarty */ public function testModifierRegisteredStaticClass() { - $this->smarty->registerPlugin(Smarty::PLUGIN_MODIFIER, 'testmodifier', array('testmodifierclass', 'staticcall')); + $this->smarty->registerPlugin(\Smarty\Smarty::PLUGIN_MODIFIER, 'testmodifier', array('testmodifierclass', 'staticcall')); $this->smarty->assign('foo', 1); $this->assertEquals("mymodifier static 1", $this->smarty->fetch('testModifier_RegisteredStatic.tpl')); } @@ -90,7 +90,7 @@ class ModifierTest extends PHPUnit_Smarty public function testModifierRegisteredMethodCall() { $obj = new testmodifierclass(); - $this->smarty->registerPlugin(Smarty::PLUGIN_MODIFIER, 'testmodifier', array($obj, 'method')); + $this->smarty->registerPlugin(\Smarty\Smarty::PLUGIN_MODIFIER, 'testmodifier', array($obj, 'method')); $this->smarty->assign('foo', 3); $this->assertEquals("mymodifier method 3", $this->smarty->fetch('testModifier_RegisteredMethod.tpl')); } diff --git a/tests/UnitTests/TemplateSource/ValueTests/SmartySpecialVars/Error/SmartyErrorTest.php b/tests/UnitTests/TemplateSource/ValueTests/SmartySpecialVars/Error/SmartyErrorTest.php index 40f85e59..7b7bbd68 100644 --- a/tests/UnitTests/TemplateSource/ValueTests/SmartySpecialVars/Error/SmartyErrorTest.php +++ b/tests/UnitTests/TemplateSource/ValueTests/SmartySpecialVars/Error/SmartyErrorTest.php @@ -30,6 +30,6 @@ class SmartyErrorTest extends PHPUnit_Smarty public function testSmartyError() { $this->expectException('SmartyException'); $this->expectExceptionMessage('$smarty.foo is not defined'); - $this->assertEquals(Smarty::SMARTY_VERSION, $this->smarty->fetch('error.tpl')); + $this->assertEquals(\Smarty\Smarty::SMARTY_VERSION, $this->smarty->fetch('error.tpl')); } } diff --git a/tests/UnitTests/TemplateSource/ValueTests/SmartySpecialVars/Version/SmartyVersionTest.php b/tests/UnitTests/TemplateSource/ValueTests/SmartySpecialVars/Version/SmartyVersionTest.php index 8e295824..909c6f0c 100644 --- a/tests/UnitTests/TemplateSource/ValueTests/SmartySpecialVars/Version/SmartyVersionTest.php +++ b/tests/UnitTests/TemplateSource/ValueTests/SmartySpecialVars/Version/SmartyVersionTest.php @@ -29,6 +29,6 @@ class SmartyVersionTest extends PHPUnit_Smarty * */ public function testSmartyVersion() { - $this->assertEquals(Smarty::SMARTY_VERSION, $this->smarty->fetch('version.tpl')); + $this->assertEquals(\Smarty\Smarty::SMARTY_VERSION, $this->smarty->fetch('version.tpl')); } } diff --git a/tests/UnitTests/__shared/PHPunitplugins/function.checkvar.php b/tests/UnitTests/__shared/PHPunitplugins/function.checkvar.php index 30646486..5f0ca229 100644 --- a/tests/UnitTests/__shared/PHPunitplugins/function.checkvar.php +++ b/tests/UnitTests/__shared/PHPunitplugins/function.checkvar.php @@ -49,8 +49,8 @@ function smarty_function_checkvar($params, $template) } if (in_array('global', $types)) { $output .= "#global:\${$var} ="; - $output .= isset(Smarty::$global_tpl_vars[ $var ]) ? - preg_replace('/\s/', '', var_export(Smarty::$global_tpl_vars[ $var ]->value, true)) : '>unassigned<'; + $output .= isset(\Smarty\Smarty::$global_tpl_vars[ $var ]) ? + preg_replace('/\s/', '', var_export(\Smarty\Smarty::$global_tpl_vars[ $var ]->value, true)) : '>unassigned<'; } return $output; }