From aa68b3a7cbf096cebcdb1f9dd6b2fdb192e7d875 Mon Sep 17 00:00:00 2001 From: osben Date: Mon, 27 May 2019 01:40:13 +0300 Subject: [PATCH] update smarty to 3.1.33 (not testing) --- Smarty/.gitattributes | 22 - Smarty/.gitignore | 221 - Smarty/.travis.yml | 26 - Smarty/COMPOSER_RELEASE_NOTES.txt | 2 + Smarty/INHERITANCE_RELEASE_NOTES.txt | 29 +- Smarty/{COPYING.lib => LICENSE} | 16 +- Smarty/NEW_FEATURES.txt | 70 +- Smarty/README | 68 +- Smarty/README.md | 27 +- Smarty/SMARTY_2_BC_NOTES.txt | 48 +- Smarty/SMARTY_3.0_BC_NOTES.txt | 10 +- Smarty/SMARTY_3.1_NOTES.txt | 18 +- Smarty/change_log.txt | 653 ++- Smarty/composer.json | 42 + Smarty/error_reporting.ini | 1 + .../smarty_internal_configfilelexer.plex | 318 -- .../lexer/smarty_internal_configfileparser.y | 362 -- .../lexer/smarty_internal_templatelexer.plex | 682 --- Smarty/lexer/smarty_internal_templateparser.y | 1351 ------ Smarty/libs/Autoloader.php | 41 +- Smarty/libs/Smarty.class.php | 776 ++- Smarty/libs/SmartyBC.class.php | 68 +- Smarty/libs/bootstrap.php | 16 + Smarty/libs/debug.tpl | 6 +- Smarty/libs/plugins/block.textformat.php | 57 +- Smarty/libs/plugins/function.counter.php | 21 +- Smarty/libs/plugins/function.cycle.php | 53 +- Smarty/libs/plugins/function.fetch.php | 69 +- .../libs/plugins/function.html_checkboxes.php | 213 +- Smarty/libs/plugins/function.html_image.php | 64 +- Smarty/libs/plugins/function.html_options.php | 142 +- Smarty/libs/plugins/function.html_radios.php | 186 +- .../plugins/function.html_select_date.php | 171 +- .../plugins/function.html_select_time.php | 168 +- Smarty/libs/plugins/function.html_table.php | 72 +- Smarty/libs/plugins/function.mailto.php | 62 +- Smarty/libs/plugins/function.math.php | 78 +- Smarty/libs/plugins/modifier.capitalize.php | 82 +- Smarty/libs/plugins/modifier.date_format.php | 46 +- .../libs/plugins/modifier.debug_print_var.php | 51 +- Smarty/libs/plugins/modifier.escape.php | 145 +- Smarty/libs/plugins/modifier.mb_wordwrap.php | 71 + .../libs/plugins/modifier.regex_replace.php | 15 +- Smarty/libs/plugins/modifier.replace.php | 15 +- Smarty/libs/plugins/modifier.spacify.php | 7 +- Smarty/libs/plugins/modifier.truncate.php | 24 +- Smarty/libs/plugins/modifiercompiler.cat.php | 15 +- .../modifiercompiler.count_characters.php | 10 +- .../modifiercompiler.count_paragraphs.php | 9 +- .../modifiercompiler.count_sentences.php | 7 +- .../plugins/modifiercompiler.count_words.php | 5 +- .../libs/plugins/modifiercompiler.default.php | 7 +- .../libs/plugins/modifiercompiler.escape.php | 53 +- .../plugins/modifiercompiler.from_charset.php | 7 +- .../libs/plugins/modifiercompiler.indent.php | 7 +- .../libs/plugins/modifiercompiler.lower.php | 6 +- .../libs/plugins/modifiercompiler.noprint.php | 7 +- .../modifiercompiler.string_format.php | 5 +- .../libs/plugins/modifiercompiler.strip.php | 11 +- .../plugins/modifiercompiler.strip_tags.php | 7 +- .../plugins/modifiercompiler.to_charset.php | 7 +- .../plugins/modifiercompiler.unescape.php | 12 +- .../libs/plugins/modifiercompiler.upper.php | 5 +- .../plugins/modifiercompiler.wordwrap.php | 26 +- .../plugins/outputfilter.trimwhitespace.php | 48 +- .../plugins/shared.escape_special_chars.php | 8 +- .../plugins/shared.literal_compiler_param.php | 9 +- Smarty/libs/plugins/shared.make_timestamp.php | 28 +- Smarty/libs/plugins/shared.mb_str_replace.php | 12 +- Smarty/libs/plugins/shared.mb_unicode.php | 15 +- Smarty/libs/plugins/shared.mb_wordwrap.php | 75 - .../variablefilter.htmlspecialchars.php | 6 +- .../libs/sysplugins/smarty_cacheresource.php | 19 +- .../smarty_cacheresource_custom.php | 128 +- .../smarty_cacheresource_keyvaluestore.php | 217 +- Smarty/libs/sysplugins/smarty_data.php | 8 +- .../libs/sysplugins/smarty_internal_block.php | 6 +- .../smarty_internal_cacheresource_file.php | 51 +- .../smarty_internal_compile_append.php | 5 +- .../smarty_internal_compile_assign.php | 22 +- .../smarty_internal_compile_block.php | 146 +- .../smarty_internal_compile_block_child.php | 24 + .../smarty_internal_compile_block_parent.php | 31 + .../smarty_internal_compile_break.php | 70 +- .../smarty_internal_compile_call.php | 12 +- .../smarty_internal_compile_capture.php | 39 +- .../smarty_internal_compile_child.php | 79 + .../smarty_internal_compile_config_load.php | 16 +- .../smarty_internal_compile_continue.php | 60 +- .../smarty_internal_compile_debug.php | 6 +- .../smarty_internal_compile_eval.php | 12 +- .../smarty_internal_compile_extends.php | 64 +- .../smarty_internal_compile_for.php | 42 +- .../smarty_internal_compile_foreach.php | 89 +- .../smarty_internal_compile_function.php | 123 +- .../sysplugins/smarty_internal_compile_if.php | 91 +- .../smarty_internal_compile_include.php | 98 +- .../smarty_internal_compile_include_php.php | 19 +- .../smarty_internal_compile_insert.php | 33 +- .../smarty_internal_compile_ldelim.php | 5 +- .../smarty_internal_compile_make_nocache.php | 10 +- .../smarty_internal_compile_nocache.php | 6 +- .../smarty_internal_compile_parent.php | 31 + ..._internal_compile_private_block_plugin.php | 51 +- ...nternal_compile_private_foreachsection.php | 87 +- ...ternal_compile_private_function_plugin.php | 28 +- ...arty_internal_compile_private_modifier.php | 69 +- ..._compile_private_object_block_function.php | 6 +- ...ternal_compile_private_object_function.php | 27 +- .../smarty_internal_compile_private_php.php | 129 +- ...ernal_compile_private_print_expression.php | 81 +- ...ernal_compile_private_registered_block.php | 8 +- ...al_compile_private_registered_function.php | 45 +- ...ernal_compile_private_special_variable.php | 36 +- .../smarty_internal_compile_rdelim.php | 12 +- .../smarty_internal_compile_section.php | 181 +- .../smarty_internal_compile_setfilter.php | 8 +- ...ty_internal_compile_shared_inheritance.php | 29 +- .../smarty_internal_compile_while.php | 34 +- .../smarty_internal_compilebase.php | 47 +- .../smarty_internal_config_file_compiler.php | 54 +- .../smarty_internal_configfilelexer.php | 446 +- .../smarty_internal_configfileparser.php | 892 ++-- .../libs/sysplugins/smarty_internal_data.php | 117 +- .../libs/sysplugins/smarty_internal_debug.php | 73 +- .../smarty_internal_errorhandler.php | 113 + .../smarty_internal_extension_handler.php | 174 +- ...rty_internal_method_addautoloadfilters.php | 27 +- ...ty_internal_method_adddefaultmodifiers.php | 6 +- .../smarty_internal_method_append.php | 20 +- .../smarty_internal_method_appendbyref.php | 13 +- .../smarty_internal_method_assignbyref.php | 10 +- .../smarty_internal_method_assignglobal.php | 13 +- .../smarty_internal_method_clearallassign.php | 3 +- .../smarty_internal_method_clearallcache.php | 11 +- .../smarty_internal_method_clearassign.php | 5 +- .../smarty_internal_method_clearcache.php | 28 +- ..._internal_method_clearcompiledtemplate.php | 75 +- .../smarty_internal_method_clearconfig.php | 4 +- ...marty_internal_method_compileallconfig.php | 23 +- ...ty_internal_method_compilealltemplates.php | 69 +- .../smarty_internal_method_configload.php | 56 +- .../smarty_internal_method_createdata.php | 6 +- ...rty_internal_method_getautoloadfilters.php | 10 +- ...arty_internal_method_getconfigvariable.php | 34 + .../smarty_internal_method_getconfigvars.php | 6 +- ...marty_internal_method_getdebugtemplate.php | 4 +- ...ty_internal_method_getdefaultmodifiers.php | 4 +- .../smarty_internal_method_getglobal.php | 10 +- ...ty_internal_method_getregisteredobject.php | 6 +- ...arty_internal_method_getstreamvariable.php | 5 +- .../smarty_internal_method_gettags.php | 13 +- ...smarty_internal_method_gettemplatevars.php | 39 +- .../smarty_internal_method_literals.php | 100 + .../smarty_internal_method_loadfilter.php | 12 +- .../smarty_internal_method_loadplugin.php | 14 +- .../smarty_internal_method_mustcompile.php | 7 +- ..._internal_method_registercacheresource.php | 14 +- .../smarty_internal_method_registerclass.php | 8 +- ...al_method_registerdefaultconfighandler.php | 10 +- ...al_method_registerdefaultpluginhandler.php | 6 +- ..._method_registerdefaulttemplatehandler.php | 30 +- .../smarty_internal_method_registerfilter.php | 17 +- .../smarty_internal_method_registerobject.php | 44 +- .../smarty_internal_method_registerplugin.php | 31 +- ...marty_internal_method_registerresource.php | 16 +- ...rty_internal_method_setautoloadfilters.php | 24 +- ...marty_internal_method_setdebugtemplate.php | 6 +- ...ty_internal_method_setdefaultmodifiers.php | 8 +- .../smarty_internal_method_unloadfilter.php | 13 +- ...nternal_method_unregistercacheresource.php | 8 +- ...marty_internal_method_unregisterfilter.php | 9 +- ...marty_internal_method_unregisterobject.php | 6 +- ...marty_internal_method_unregisterplugin.php | 8 +- ...rty_internal_method_unregisterresource.php | 6 +- .../smarty_internal_nocache_insert.php | 22 +- .../sysplugins/smarty_internal_parsetree.php | 8 +- .../smarty_internal_parsetree_code.php | 2 +- .../smarty_internal_parsetree_dq.php | 24 +- .../smarty_internal_parsetree_tag.php | 4 +- .../smarty_internal_parsetree_template.php | 33 +- .../smarty_internal_resource_eval.php | 17 +- .../smarty_internal_resource_extends.php | 12 +- .../smarty_internal_resource_file.php | 170 +- .../smarty_internal_resource_php.php | 81 +- .../smarty_internal_resource_registered.php | 28 +- .../smarty_internal_resource_stream.php | 8 +- .../smarty_internal_resource_string.php | 21 +- .../smarty_internal_runtime_cachemodify.php | 14 +- ...ty_internal_runtime_cacheresourcefile.php} | 79 +- .../smarty_internal_runtime_capture.php | 39 +- .../smarty_internal_runtime_codeframe.php | 94 +- .../smarty_internal_runtime_filterhandler.php | 12 +- .../smarty_internal_runtime_foreach.php | 119 +- ...smarty_internal_runtime_getincludepath.php | 21 +- .../smarty_internal_runtime_inheritance.php | 81 +- .../smarty_internal_runtime_make_nocache.php | 14 +- .../smarty_internal_runtime_tplfunction.php | 86 +- .../smarty_internal_runtime_updatecache.php | 152 +- .../smarty_internal_runtime_updatescope.php | 36 +- .../smarty_internal_runtime_writefile.php | 29 +- ...smarty_internal_smartytemplatecompiler.php | 34 +- .../sysplugins/smarty_internal_template.php | 296 +- .../smarty_internal_templatebase.php | 164 +- .../smarty_internal_templatecompilerbase.php | 1357 ++++-- .../smarty_internal_templatelexer.php | 781 ++- .../smarty_internal_templateparser.php | 4174 ++++++++++------- .../smarty_internal_testinstall.php | 396 +- .../sysplugins/smarty_internal_undefined.php | 40 +- Smarty/libs/sysplugins/smarty_resource.php | 230 +- .../sysplugins/smarty_resource_custom.php | 12 +- .../sysplugins/smarty_resource_recompiled.php | 12 +- .../sysplugins/smarty_resource_uncompiled.php | 2 +- Smarty/libs/sysplugins/smarty_security.php | 293 +- .../sysplugins/smarty_template_cached.php | 25 +- .../sysplugins/smarty_template_compiled.php | 162 +- .../sysplugins/smarty_template_config.php | 19 +- .../smarty_template_resource_base.php | 16 +- .../sysplugins/smarty_template_source.php | 27 +- .../sysplugins/smarty_undefined_variable.php | 16 +- Smarty/libs/sysplugins/smarty_variable.php | 3 +- .../sysplugins/smartycompilerexception.php | 3 + Smarty/libs/sysplugins/smartyexception.php | 3 + Smarty/travis.ini | 2 - 224 files changed, 10524 insertions(+), 11047 deletions(-) delete mode 100644 Smarty/.gitattributes delete mode 100644 Smarty/.gitignore delete mode 100644 Smarty/.travis.yml rename Smarty/{COPYING.lib => LICENSE} (93%) create mode 100644 Smarty/composer.json create mode 100644 Smarty/error_reporting.ini delete mode 100644 Smarty/lexer/smarty_internal_configfilelexer.plex delete mode 100644 Smarty/lexer/smarty_internal_configfileparser.y delete mode 100644 Smarty/lexer/smarty_internal_templatelexer.plex delete mode 100644 Smarty/lexer/smarty_internal_templateparser.y create mode 100644 Smarty/libs/bootstrap.php create mode 100644 Smarty/libs/plugins/modifier.mb_wordwrap.php delete mode 100644 Smarty/libs/plugins/shared.mb_wordwrap.php create mode 100644 Smarty/libs/sysplugins/smarty_internal_compile_block_child.php create mode 100644 Smarty/libs/sysplugins/smarty_internal_compile_block_parent.php create mode 100644 Smarty/libs/sysplugins/smarty_internal_compile_child.php create mode 100644 Smarty/libs/sysplugins/smarty_internal_compile_parent.php create mode 100644 Smarty/libs/sysplugins/smarty_internal_errorhandler.php create mode 100644 Smarty/libs/sysplugins/smarty_internal_method_getconfigvariable.php create mode 100644 Smarty/libs/sysplugins/smarty_internal_method_literals.php rename Smarty/libs/sysplugins/{smarty_internal_extension_clear.php => smarty_internal_runtime_cacheresourcefile.php} (62%) delete mode 100644 Smarty/travis.ini diff --git a/Smarty/.gitattributes b/Smarty/.gitattributes deleted file mode 100644 index 412eeda..0000000 --- a/Smarty/.gitattributes +++ /dev/null @@ -1,22 +0,0 @@ -# Auto detect text files and perform LF normalization -* text=auto - -# Custom for Visual Studio -*.cs diff=csharp -*.sln merge=union -*.csproj merge=union -*.vbproj merge=union -*.fsproj merge=union -*.dbproj merge=union - -# Standard to msysgit -*.doc diff=astextplain -*.DOC diff=astextplain -*.docx diff=astextplain -*.DOCX diff=astextplain -*.dot diff=astextplain -*.DOT diff=astextplain -*.pdf diff=astextplain -*.PDF diff=astextplain -*.rtf diff=astextplain -*.RTF diff=astextplain diff --git a/Smarty/.gitignore b/Smarty/.gitignore deleted file mode 100644 index 0ff15aa..0000000 --- a/Smarty/.gitignore +++ /dev/null @@ -1,221 +0,0 @@ -################# -## Eclipse -################# - -*.pydevproject -.project -.metadata -bin/ -tmp/ -*.tmp -*.bak -*.swp -*~.nib -local.properties -.classpath -.settings/ -.loadpath - -# External tool builders -.externalToolBuilders/ - -# Locally stored "Eclipse launch configurations" -*.launch - -# CDT-specific -.cproject - -# PDT-specific -.buildpath - - -################# -## Visual Studio -################# - -## Ignore Visual Studio temporary files, build results, and -## files generated by popular Visual Studio add-ons. - -# User-specific files -*.suo -*.user -*.sln.docstates - -# Build results - -[Dd]ebug/ -[Rr]elease/ -x64/ -build/ -[Bb]in/ -[Oo]bj/ - -# MSTest test Results -[Tt]est[Rr]esult*/ -[Bb]uild[Ll]og.* - -*_i.c -*_p.c -*.ilk -*.meta -*.obj -*.pch -*.pdb -*.pgc -*.pgd -*.rsp -*.sbr -*.tlb -*.tli -*.tlh -*.tmp -*.tmp_proj -*.log -*.vspscc -*.vssscc -.builds -*.pidb -*.log -*.scc - -# Visual C++ cache files -ipch/ -*.aps -*.ncb -*.opensdf -*.sdf -*.cachefile - -# Visual Studio profiler -*.psess -*.vsp -*.vspx - -# Guidance Automation Toolkit -*.gpState - -# ReSharper is a .NET coding add-in -_ReSharper*/ -*.[Rr]e[Ss]harper - -# TeamCity is a build add-in -_TeamCity* - -# DotCover is a Code Coverage Tool -*.dotCover - -# NCrunch -*.ncrunch* -.*crunch*.local.xml - -# Installshield output folder -[Ee]xpress/ - -# DocProject is a documentation generator add-in -DocProject/buildhelp/ -DocProject/Help/*.HxT -DocProject/Help/*.HxC -DocProject/Help/*.hhc -DocProject/Help/*.hhk -DocProject/Help/*.hhp -DocProject/Help/Html2 -DocProject/Help/html - -# Click-Once directory -publish/ - -# Publish Web Output -*.Publish.xml -*.pubxml - -# NuGet Packages Directory -## TODO: If you have NuGet Package Restore enabled, uncomment the next line -#packages/ - -# Windows Azure Build Output -csx -*.build.csdef - -# Windows Store app package directory -AppPackages/ - -# Others -sql/ -*.Cache -ClientBin/ -[Ss]tyle[Cc]op.* -~$* -*~ -*.dbmdl -*.[Pp]ublish.xml -*.pfx -*.publishsettings - -# RIA/Silverlight projects -Generated_Code/ - -# Backup & report files from converting an old project file to a newer -# Visual Studio version. Backup files are not needed, because we have git ;-) -_UpgradeReport_Files/ -Backup*/ -UpgradeLog*.XML -UpgradeLog*.htm - -# SQL Server files -App_Data/*.mdf -App_Data/*.ldf - -############# -## Windows detritus -############# - -# Windows image file caches -Thumbs.db -ehthumbs.db - -# Folder config file -Desktop.ini - -# Recycle Bin used on file shares -$RECYCLE.BIN/ - -# Mac crap -.DS_Store - - -############# -## Python -############# - -*.py[co] - -# Packages -*.egg -*.egg-info -dist/ -build/ -eggs/ -parts/ -var/ -sdist/ -develop-eggs/ -.installed.cfg - -# Installer logs -pip-log.txt - -# Unit test / coverage reports -.coverage -.tox - -#Translations -*.mo - -#Mr Developer -.mr.developer.cfg - -.idea/ - -# Smarty -lexer/*.php -lexer/*.out diff --git a/Smarty/.travis.yml b/Smarty/.travis.yml deleted file mode 100644 index 975d202..0000000 --- a/Smarty/.travis.yml +++ /dev/null @@ -1,26 +0,0 @@ -language: php - -php: - - 5.3 - - 5.4 - - 5.5 - - 5.6 - - 7.0 - - hhvm - -services: - - memcached - - mysql - -before_script: - - if [ ${TRAVIS_PHP_VERSION:0:3} != "5.2" ]; then travis_retry composer --prefer-source --dev install; fi - - if [ ${TRAVIS_PHP_VERSION:0:3} <= "5.6" ]; then phpenv config-add travis.ini; fi - - mysql -e "create database IF NOT EXISTS test;" -uroot - -install: - - git clone --depth=50 --branch v3.1.30 git://github.com/smarty-php/smarty-phpunit.git - -script: - - cd smarty-phpunit - - phpunit ./ - diff --git a/Smarty/COMPOSER_RELEASE_NOTES.txt b/Smarty/COMPOSER_RELEASE_NOTES.txt index c943d9f..0644719 100644 --- a/Smarty/COMPOSER_RELEASE_NOTES.txt +++ b/Smarty/COMPOSER_RELEASE_NOTES.txt @@ -27,3 +27,5 @@ To retrieve the development and documentation folders add "smarty/smarty-dev": "~3.1@dev" } +If you are using (include) the composer generated autoloader.php which is located +in the /vendor folder it is no longer needed to require the Smarty.class.php file. \ No newline at end of file diff --git a/Smarty/INHERITANCE_RELEASE_NOTES.txt b/Smarty/INHERITANCE_RELEASE_NOTES.txt index 0d77238..67936a8 100644 --- a/Smarty/INHERITANCE_RELEASE_NOTES.txt +++ b/Smarty/INHERITANCE_RELEASE_NOTES.txt @@ -1,3 +1,20 @@ +3.1.3" +New tags for inheritance parent and chilD +{parent} == {$smarty.block.parent} +{child} == {$smarty.block.child} +Both tags support the assign attribute like +{child assign=foo} + +3.1.31 +New tags for inheritance parent and child +{block_parent} == {$smarty.block.parent} +{block_child} == {$smarty.block.child} + +Since 3.1.28 you can mix inheritance by extends resource with the {extends} tag. +A template called by extends resource can extend a subtemplate or chain buy the {extends} tag. +Since 3.1.31 this feature can be turned off by setting the new Smarty property Smarty::$extends_recursion to false. + +3.1.28 Starting with version 3.1.28 template inheritance is no longer a compile time process. All {block} tag parent/child relations are resolved at run time. This does resolve all known existing restrictions (see below). @@ -37,8 +54,8 @@ Any code outside root {block} tags in child templates is now executed but any ou .... {/block} -Starting with 3.1.28 you can mix inheritance by extends resuorce with the {extends} tag. -A template called by extends resoure can extend a subtemple or chain buy the {extends} tag. +Starting with 3.1.28 you can mix inheritance by extends resource with the {extends} tag. +A template called by extends resource can extend a subtemplate or chain buy the {extends} tag. NOTE There is a BC break. If you used the extends resource {extends} tags have been ignored. @@ -52,7 +69,7 @@ the compiled code of {include} subtemplates gets also merged in compiled inherit Merging the code into a single compile template has some drawbacks. 1. You could not use variable file names in {include} Smarty would use the {include} of compilation time. 2. You could not use individual compile_id in {include} -3. Seperate caching of subtemplate was not possible +3. Separate caching of subtemplate was not possible 4. Any change of the template directory structure between calls was not necessarily seen. Starting with 3.1.15 some of the above conditions got checked and resulted in an exception. It turned out @@ -64,13 +81,11 @@ With this setting all {include} subtemplate will be merge into the compiled inhe could be rejected by exception. -If $smarty->inheritance_merge_compiled_includes = false; {include} subtemplate will not be merged. -You must now manually merge all {include} subtemplate which do contain {block} tags. This is done by setting the "inline" option. +If $smarty->inheritance_merge_compiled_includes = false; {include} subtemplate will not be merged.You must now manually merge all {include} subtemplate which do contain {block} tags. This is done by setting the "inline" option. {include file='foo.bar' inline} 1. In case of a variable file name like {include file=$foo inline} you must use the variable in a compile_id $smarty->compile_id = $foo; -2. If you use individual compile_id in {include file='foo.tpl' compile_id=$bar inline} it must be used in the - global compile_id as well $smarty->compile_id = $bar; +2. If you use individual compile_id in {include file='foo.tpl' compile_id=$bar inline} it must be used in the global compile_id as well $smarty->compile_id = $bar; 3. If call templates with different template_dir configurations and a parent could same named child template from different folders you must make the folder name part of the compile_id. diff --git a/Smarty/COPYING.lib b/Smarty/LICENSE similarity index 93% rename from Smarty/COPYING.lib rename to Smarty/LICENSE index 02bbb60..fb8ca6c 100644 --- a/Smarty/COPYING.lib +++ b/Smarty/LICENSE @@ -1,3 +1,17 @@ +Smarty: the PHP compiling template engine + + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + This library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + + See the GNU Lesser General Public License below for more details. + + GNU LESSER GENERAL PUBLIC LICENSE Version 3, 29 June 2007 @@ -162,4 +176,4 @@ General Public License ever published by the Free Software Foundation. whether future versions of the GNU Lesser General Public License shall apply, that proxy's public statement of acceptance of any version is permanent authorization for you to choose that version for the -Library. \ No newline at end of file +Library. diff --git a/Smarty/NEW_FEATURES.txt b/Smarty/NEW_FEATURES.txt index f20a9f0..b3289df 100644 --- a/Smarty/NEW_FEATURES.txt +++ b/Smarty/NEW_FEATURES.txt @@ -2,6 +2,66 @@ This file contains a brief description of new features which have been added to Smarty 3.1 +Smarty 3.1.33-dev + Variable capture name in Smarty special variable + ================================================ + {$smarty.capture.$foo} can now be used to access the content of a named + capture block + +Smarty 3.1.32 + New tags for inheritance parent and child + ========================================= + {parent} == {$smarty.block.parent} + {child} == {$smarty.block.child} + Both tags support the assign attribute like + {child assign=foo} + + Deprecate functions Smarty::muteExpectedErrors() and Smarty::unmuteExpectedErrors() + =================================================================================== + These functions to start a special error handler are no longer needed as Smarty does + no longer use error suppression like @filemtime(). + For backward compatibility the functions still can be called. + + Using literals containing Smarty's left and right delimiter + =========================================================== + New Methods + $smarty->setLiterals(array $literals) + $smarty->addLiterals(array $literals) + to define literals containing Smarty delimiter. This can avoid the need for extreme usage + of {literal} {/literal} tags. + A) Treat '{{' and '}}' as literal + If Smarty::$auto_literal is enabled + {{ foo }} + will be treated now as literal. (This does apply for any number of delimiter repeatations). + However {{foo}} is not an literal but will be interpreted as a recursive Smarty tag. + If you use + $smarty->setLiteral(array('{{','}}')); + {{foo}} is now a literal as well. + NOTE: In the last example nested Smarty tags starting with '{{' or ending with '}}' will not + work any longer, but this should be very very raw occouring restriction. + B) Example 2 + Assume your delimiter are '<-' , '->' and '<--' , '-->' shall be literals + $smarty->setLiteral(array('<--','-->')); + + + The capture buffers can now be accessed as array + ================================================ + {capture name='foo'} + bah + {\capture} + {capture name='buh'} + blar + {\capture} + {foreach $smarty.capture as $name => $buffer} + .... + {/foreach} + +Smarty 3.1.31 + New tags for inheritance parent and child + ========================================= + {block_parent} == {$smarty.block.parent} + {block_child} == {$smarty.block.child} + Smarty 3.1.30 Loop optimization {foreach} and {section} @@ -39,8 +99,7 @@ Smarty 3.1.30 {/foreach} The {foreach} loop is rendered while processing the compiled template, but $current is a nocache - variable. Normally the {if $current==$item.id} would fail as the $item variable is unkown in the - cached template. {make_nocache $item} does make the current $item value known in thee cached template. + variable. Normally the {if $current==$item.id} would fail as the $item variable is unknown in the cached template. {make_nocache $item} does make the current $item value known in thee cached template. {make_nocache} is ignored when caching is disabled or the variable does exists as nocache variable. @@ -75,8 +134,7 @@ Smarty 3.1.30 Supported scope are parent, tpl_root, smarty, global and root. A scope used together with the {include} tag will cause that with some exceptions any variable assignment within that sub-template will update/assign the variable in other scopes according - to the above rules. It does include also variables assigned by plugins, tags supporting the assign=foo - attribute and direct assignments in {if} and {while} like {if $foo=$bar}. + to the above rules. It does include also variables assigned by plugins, tags supporting the assign=foo attribute and direct assignments in {if} and {while} like {if $foo=$bar}. Excluded are the key and value variables of {foreach}, {for} loop variables , variables passed by attributes in {include} and direct increments/decrements like {$foo++}, {$foo--} @@ -126,8 +184,8 @@ Smarty 3.1.28 as the corresponding Smarty methods to get the content of another template. Example: $template->display(); Does display template of template object - $template->display('foo.tpl'); Does display template 'foo.bar' - + $template->display('foo.tpl'); Does display template 'foo.bar' + File: resource ============== Multiple template_dir entries can now be selected by a comma separated list of indices. diff --git a/Smarty/README b/Smarty/README index 08b397c..9a71519 100644 --- a/Smarty/README +++ b/Smarty/README @@ -176,7 +176,7 @@ backward compatible with Smarty 2, except for the following items: There are many things that are new to Smarty 3. Here are the notable items: - + LEXER/PARSER ============ @@ -197,8 +197,8 @@ is still supported for BC. Examples: {$x+$y} will output the sum of x and y. {$foo = strlen($bar)} function in assignment -{assign var=foo value= $x+$y} in attributes -{$foo = myfunct( ($x+$y)*3 )} as function parameter +{assign var=foo value= $x+$y} in attributes +{$foo = myfunct( ($x+$y)*3 )} as function parameter {$foo[$x+3]} as array index Smarty tags can be used as values within other tags. @@ -239,18 +239,18 @@ Examples: The original "dot" notation stays, and with improvements. Examples: -{$foo.a.b.c} => $foo['a']['b']['c'] +{$foo.a.b.c} => $foo['a']['b']['c'] {$foo.a.$b.c} => $foo['a'][$b]['c'] with variable index {$foo.a.{$b+4}.c} => $foo['a'][$b+4]['c'] with expression as index {$foo.a.{$b.c}} => $foo['a'][$b['c']] with nested index -note that { and } are used to address ambiguties when nesting the dot syntax. +note that { and } are used to address ambiguties when nesting the dot syntax. Variable names themselves can be variable and contain expressions. Examples: $foo normal variable -$foo_{$bar} variable name containing other variable -$foo_{$x+$y} variable name containing expressions +$foo_{$bar} variable name containing other variable +$foo_{$x+$y} variable name containing expressions $foo_{$bar}_buh_{$blar} variable name with multiple segments {$foo_{$x}} will output the variable $foo_1 if $x has a value of 1. @@ -260,12 +260,12 @@ Example: {$object->method1($x)->method2($y)} {for} tag added for looping (replacement for {section} tag): {for $x=0, $y=count($foo); $x<$y; $x++} .... {/for} Any number of statements can be used separated by comma as the first -inital expression at {for}. +initial expression at {for}. {for $x = $start to $end step $step} ... {/for}is in the SVN now . You can use also {for $x = $start to $end} ... {/for} -In this case the step value will be automaticall 1 or -1 depending on the start and end values. +In this case the step value will be automatically 1 or -1 depending on the start and end values. Instead of $start and $end you can use any valid expression. Inside the loop the following special vars can be accessed: $x@iteration = number of iteration @@ -290,7 +290,7 @@ $var@last true on last iteration The Smarty 2 {foreach} tag syntax is still supported. -NOTE: {$bar[foo]} still indicates a variable inside of a {section} named foo. +NOTE: {$bar[foo]} still indicates a variable inside of a {section} named foo. If you want to access an array element with index foo, you must use quotes such as {$bar['foo']}, or use the dot syntax {$bar.foo}. @@ -377,12 +377,12 @@ $smarty->display('string:This is my template, {$foo}!'); // php VARIABLE SCOPE / VARIABLE STORAGE ================================= -In Smarty 2, all assigned variables were stored within the Smarty object. -Therefore, all variables assigned in PHP were accessible by all subsequent +In Smarty 2, all assigned variables were stored within the Smarty object. +Therefore, all variables assigned in PHP were accessible by all subsequent fetch and display template calls. -In Smarty 3, we have the choice to assign variables to the main Smarty object, -to user-created data objects, and to user-created template objects. +In Smarty 3, we have the choice to assign variables to the main Smarty object, +to user-created data objects, and to user-created template objects. These objects can be chained. The object at the end of a chain can access all variables belonging to that template and all variables within the parent objects. The Smarty object can only be the root of a chain, but a chain can be isolated @@ -396,7 +396,7 @@ global variables. A Smarty data object can be created as follows: $data = $smarty->createData(); // create root data object $data->assign('foo','bar'); // assign variables as usual -$data->config_load('my.conf'); // load config file +$data->config_load('my.conf'); // load config file $data= $smarty->createData($smarty); // create data object having a parent link to the Smarty object @@ -414,7 +414,7 @@ The first parameter can be a template name, a smarty object or a data object. Examples: $tpl = $smarty->createTemplate('mytpl.tpl'); // create template object not linked to any parent $tpl->assign('foo','bar'); // directly assign variables -$tpl->config_load('my.conf'); // load config file +$tpl->config_load('my.conf'); // load config file $tpl = $smarty->createTemplate('mytpl.tpl',$smarty); // create template having a parent link to the Smarty object $tpl = $smarty->createTemplate('mytpl.tpl',$data); // create template having a parent link to the $data object @@ -424,31 +424,31 @@ If the $parent parameter is not specified in these method calls, the template ob is will link back to the Smarty object as it's parent. If a template is called by an {include...} tag from another template, the -subtemplate links back to the calling template as it's parent. +subtemplate links back to the calling template as it's parent. All variables assigned locally or from a parent template are accessible. If the template creates or modifies a variable by using the {assign var=foo...} or {$foo=...} tags, these new values are only known locally (local scope). When the template exits, none of the new variables or modifications can be seen in the -parent template(s). This is same behavior as in Smarty 2. +parent template(s). This is same behavior as in Smarty 2. With Smarty 3, we can assign variables with a scope attribute which allows the availablility of these new variables or modifications globally (ie in the parent templates.) -Possible scopes are local, parent, root and global. +Possible scopes are local, parent, root and global. Examples: {assign var=foo value='bar'} // no scope is specified, the default 'local' {$foo='bar'} // same, local scope {assign var=foo value='bar' scope='local'} // same, local scope -{assign var=foo value='bar' scope='parent'} // Values will be available to the parent object +{assign var=foo value='bar' scope='parent'} // Values will be available to the parent object {$foo='bar' scope='parent'} // (normally the calling template) -{assign var=foo value='bar' scope='root'} // Values will be exported up to the root object, so they can +{assign var=foo value='bar' scope='root'} // Values will be exported up to the root object, so they can {$foo='bar' scope='root'} // be seen from all templates using the same root. -{assign var=foo value='bar' scope='global'} // Values will be exported to global variable storage, +{assign var=foo value='bar' scope='global'} // Values will be exported to global variable storage, {$foo='bar' scope='global'} // they are available to any and all templates. @@ -460,8 +460,8 @@ included template. PLUGINS ======= -Smarty 3 plugins follow the same coding rules as in Smarty 2. -The main difference is that the template object is now passed in place of the smarty object. +Smarty 3 plugins follow the same coding rules as in Smarty 2. +The main difference is that the template object is now passed in place of the smarty object. The smarty object can be still be accessed through $template->smarty. smarty_plugintype_name (array $params, Smarty_Internal_Template $template) @@ -473,7 +473,7 @@ TEMPLATE INHERITANCE: ===================== With template inheritance you can define blocks, which are areas that can be -overriden by child templates, so your templates could look like this: +overridden by child templates, so your templates could look like this: parent.tpl: @@ -491,14 +491,14 @@ parent.tpl: child.tpl: -{extends file='parent.tpl'} +{extends file='parent.tpl'} {block name='title'} Child title {/block} grandchild.tpl: -{extends file='child.tpl'} -{block name='title'}Home - {$smarty.block.parent}{/block} +{extends file='child.tpl'} +{block name='title'}Home - {$smarty.block.parent}{/block} {block name='page-title'}My home{/block} {block name='content'} {foreach $images as $img} @@ -508,10 +508,10 @@ grandchild.tpl: We redefined all the blocks here, however in the title block we used {$smarty.block.parent}, which tells Smarty to insert the default content from the parent template in its place. -The content block was overriden to display the image files, and page-title has also be -overriden to display a completely different title. +The content block was overridden to display the image files, and page-title has also be +overridden to display a completely different title. -If we render grandchild.tpl we will get this: +If we render grandchild.tpl we will get this: Home - Child title @@ -529,8 +529,8 @@ If we render grandchild.tpl we will get this: NOTE: In the child templates everything outside the {extends} or {block} tag sections is ignored. -The inheritance tree can be as big as you want (meaning you can extend a file that -extends another one that extends another one and so on..), but be aware that all files +The inheritance tree can be as big as you want (meaning you can extend a file that +extends another one that extends another one and so on..), but be aware that all files have to be checked for modifications at runtime so the more inheritance the more overhead you add. Instead of defining the parent/child relationships with the {extends} tag in the child template you @@ -538,7 +538,7 @@ can use the resource as follow: $smarty->display('extends:parent.tpl|child.tpl|grandchild.tpl'); -Child {block} tags may optionally have a append or prepend attribute. In this case the parent block content +Child {block} tags may optionally have a append or prepend attribute. In this case the parent block content is appended or prepended to the child block content. {block name='title' append} My title {/block} diff --git a/Smarty/README.md b/Smarty/README.md index 5783eb3..24baae4 100644 --- a/Smarty/README.md +++ b/Smarty/README.md @@ -1,5 +1,12 @@ -#Smarty 3 template engine -##Distribution repository +# Smarty 3 template engine +[smarty.net](https://www.smarty.net/) + +## Documentation + +For documentation see +[www.smarty.net/docs/en/](https://www.smarty.net/docs/en/) + +## Distribution repository > Smarty 3.1.28 introduces run time template inheritance @@ -10,7 +17,7 @@ Smarty versions 3.1.11 or later are now on github and can be installed with Comp The "smarty/smarty" package will start at libs/.... subfolder. -To get the latest stable version of Smarty 3.1 use +To get the latest stable version of Smarty 3.1 use: ```json "require": { @@ -20,7 +27,7 @@ To get the latest stable version of Smarty 3.1 use in your composer.json file. -To get the trunk version use +To get the trunk version use: ```json "require": { @@ -28,7 +35,7 @@ To get the trunk version use } ``` -For a specific version use something like +For a specific version use something like: ```json "require": { @@ -36,7 +43,7 @@ For a specific version use something like } ``` -PHPUnit test can be installed by corresponding composer entries like +PHPUnit test can be installed by corresponding composer entries like: ```json "require": { @@ -44,7 +51,7 @@ PHPUnit test can be installed by corresponding composer entries like } ``` -Similar applies for the lexer/parser generator +Similar applies for the lexer/parser generator. ```json "require": { @@ -52,7 +59,7 @@ Similar applies for the lexer/parser generator } ``` -Or you could use +Or you could use: ```json "require": { @@ -60,6 +67,6 @@ Or you could use } ``` -Which is a wrapper to install all 3 packages +Which is a wrapper to install all 3 packages. -Composer can also be used for Smarty2 versions 2.6.24 to 2.6.28 +Composer can also be used for Smarty2 versions 2.6.24 to 2.6.30. diff --git a/Smarty/SMARTY_2_BC_NOTES.txt b/Smarty/SMARTY_2_BC_NOTES.txt index 79a2cb1..fd36bd3 100644 --- a/Smarty/SMARTY_2_BC_NOTES.txt +++ b/Smarty/SMARTY_2_BC_NOTES.txt @@ -2,8 +2,8 @@ == Syntax == -Smarty 3 API has a new syntax. Much of the Smarty 2 syntax is supported -by a wrapper but deprecated. See the README that comes with Smarty 3 for more +Smarty 3 API has a new syntax. Much of the Smarty 2 syntax is supported +by a wrapper but deprecated. See the README that comes with Smarty 3 for more information. The {$array|@mod} syntax has always been a bit confusing, where an "@" is required @@ -32,9 +32,9 @@ Makes Javascript/CSS easier to work with, eliminating the need for {literal}. This can be disabled by setting $smarty->auto_literal = false; == Unquoted Strings == -Smarty 2 was a bit more forgiving (and ambiguous) when it comes to unquoted strings -in parameters. Smarty3 is more restrictive. You can still pass strings without quotes -so long as they contain no special characters. (anything outside of A-Za-z0-9_) +Smarty 2 was a bit more forgiving (and ambiguous) when it comes to unquoted strings +in parameters. Smarty3 is more restrictive. You can still pass strings without quotes +so long as they contain no special characters. (anything outside of A-Za-z0-9_) For example filename strings must be quoted @@ -42,16 +42,16 @@ For example filename strings must be quoted == Extending the Smarty class == -Smarty 3 makes use of the __construct method for initialization. If you are extending -the Smarty class, its constructor is not called implicitly if the your child class defines -its own constructor. In order to run Smarty's constructor, a call to parent::__construct() -within your child constructor is required. +Smarty 3 makes use of the __construct method for initialization. If you are extending +the Smarty class, its constructor is not called implicitly if the your child class defines +its own constructor. In order to run Smarty's constructor, a call to parent::__construct() +within your child constructor is required. class MySmarty extends Smarty { function __construct() { parent::__construct(); - + // your initialization code goes here } @@ -59,36 +59,36 @@ class MySmarty extends Smarty { == Autoloader == -Smarty 3 does register its own autoloader with spl_autoload_register. If your code has -an existing __autoload function then this function must be explicitly registered on -the __autoload stack. See http://us3.php.net/manual/en/function.spl-autoload-register.php +Smarty 3 does register its own autoloader with spl_autoload_register. If your code has +an existing __autoload function then this function must be explicitly registered on +the __autoload stack. See http://us3.php.net/manual/en/function.spl-autoload-register.php for further details. == Plugin Filenames == -Smarty 3 optionally supports the PHP spl_autoloader. The autoloader requires filenames -to be lower case. Because of this, Smarty plugin file names must also be lowercase. +Smarty 3 optionally supports the PHP spl_autoloader. The autoloader requires filenames +to be lower case. Because of this, Smarty plugin file names must also be lowercase. In Smarty 2, mixed case file names did work. == Scope of Special Smarty Variables == -In Smarty 2 the special Smarty variables $smarty.section... and $smarty.foreach... -had global scope. If you had loops with the same name in subtemplates you could accidentally +In Smarty 2 the special Smarty variables $smarty.section... and $smarty.foreach... +had global scope. If you had loops with the same name in subtemplates you could accidentally overwrite values of parent template. -In Smarty 3 these special Smarty variable have only local scope in the template which -is defining the loop. If you need their value in a subtemplate you have to pass them +In Smarty 3 these special Smarty variable have only local scope in the template which +is defining the loop. If you need their value in a subtemplate you have to pass them as parameter. {include file='path/foo.tpl' index=$smarty.section.foo.index} == SMARTY_RESOURCE_CHAR_SET == -Smarty 3 sets the constant SMARTY_RESOURCE_CHAR_SET to utf-8 as default template charset. -This is now used also on modifiers like escape as default charset. If your templates use -other charsets make sure that you define the constant accordingly. Otherwise you may not +Smarty 3 sets the constant SMARTY_RESOURCE_CHAR_SET to utf-8 as default template charset. +This is now used also on modifiers like escape as default charset. If your templates use +other charsets make sure that you define the constant accordingly. Otherwise you may not get any output. == newline at {if} tags == -A \n was added to the compiled code of the {if},{else},{elseif},{/if} tags to get output of newlines as expected by the template source. +A \n was added to the compiled code of the {if},{else},{elseif},{/if} tags to get output of newlines as expected by the template source. If one of the {if} tags is at the line end you will now get a newline in the HTML output. == trigger_error() == @@ -96,7 +96,7 @@ The API function trigger_error() has been removed because it did just map to PHP However it's still included in the Smarty2 API wrapper. == Smarty constants == -The constants +The constants SMARTY_PHP_PASSTHRU SMARTY_PHP_QUOTE SMARTY_PHP_REMOVE diff --git a/Smarty/SMARTY_3.0_BC_NOTES.txt b/Smarty/SMARTY_3.0_BC_NOTES.txt index fd8b540..24bdec6 100644 --- a/Smarty/SMARTY_3.0_BC_NOTES.txt +++ b/Smarty/SMARTY_3.0_BC_NOTES.txt @@ -1,14 +1,14 @@ == Smarty2 backward compatibility == -All Smarty2 specific API functions and deprecated functionallity has been moved +All Smarty2 specific API functions and deprecated functionality has been moved to the SmartyBC class. == {php} Tag == -The {php} tag is no longer available in the standard Smarty calls. -The use of {php} tags is deprecated and only available in the SmartyBC class. +The {php} tag is no longer available in the standard Smarty calls. +The use of {php} tags is deprecated and only available in the SmartyBC class. == {include_php} Tag == -The {include_php} tag is no longer available in the standard Smarty calls. -The use of {include_php} tags is deprecated and only available in the SmartyBC class. +The {include_php} tag is no longer available in the standard Smarty calls. +The use of {include_php} tags is deprecated and only available in the SmartyBC class. == php template resource == The support of the php template resource is removed. diff --git a/Smarty/SMARTY_3.1_NOTES.txt b/Smarty/SMARTY_3.1_NOTES.txt index 57709f0..d7c23cc 100644 --- a/Smarty/SMARTY_3.1_NOTES.txt +++ b/Smarty/SMARTY_3.1_NOTES.txt @@ -50,7 +50,7 @@ The escape modifier now knows the $double_encode option, which will prevent entities from being encoded again. The capitalize modifier now know the $lc_rest option, which makes sure -all letters following a captial letter are lower-cased. +all letters following a capital letter are lower-cased. The count_sentences modifier now accepts (.?!) as legitimate endings of a sentence - previously only (.) was @@ -62,7 +62,7 @@ entity. default_template_handler_func -The invocation of $smarty->$default_template_handler_func had to be +The invocation of $smarty->$default_template_handler_func had to be altered. Instead of a Smarty_Internal_Template, the fifth argument is now provided with the Smarty instance. New footprint: @@ -71,14 +71,14 @@ now provided with the Smarty instance. New footprint: * Default Template Handler * * called when Smarty's file: resource is unable to load a requested file - * + * * @param string $type resource type (e.g. "file", "string", "eval", "resource") * @param string $name resource name (e.g. "foo/bar.tpl") * @param string &$content template's content * @param integer &$modified template's modification time * @param Smarty $smarty Smarty instance - * @return string|boolean path to file or boolean true if $content and $modified - * have been filled, boolean false if no default template + * @return string|boolean path to file or boolean true if $content and $modified + * have been filled, boolean false if no default template * could be loaded */ function default_template_handler_func($type, $name, &$content, &$modified, Smarty $smarty) { @@ -126,7 +126,7 @@ run on variable output. SYNTAX: {setfilter filter1|filter2|filter3....} Smarty3 will lookup up matching filters in the following search order: -1. varibale filter plugin in plugins_dir. +1. variable filter plugin in plugins_dir. 2. a valid modifier. A modifier specification will also accept additional parameter like filter2:'foo' 3. a PHP function @@ -186,8 +186,8 @@ Note that old-fashioned registration of $cache_handler is not possible anymore. As the functionality had not been ported to Smarty 3.0.x properly, it has been dropped from 3.1 completely. -Locking facilities have been implemented to avoid concurrent cache -generation. Enable cache locking by setting +Locking facilities have been implemented to avoid concurrent cache +generation. Enable cache locking by setting $smarty->cache_locking = true; Relative Paths in Templates (File-Resource) @@ -258,7 +258,7 @@ default_config_handler_func() has been introduced. default_plugin_handler_func() -An optional default_plugin_handler_func() can be defined which gets called +An optional default_plugin_handler_func() can be defined which gets called by the compiler on tags which can't be resolved internally or by plugins. The default_plugin_handler() can map tags to plugins on the fly. diff --git a/Smarty/change_log.txt b/Smarty/change_log.txt index c19bf0f..70762ed 100644 --- a/Smarty/change_log.txt +++ b/Smarty/change_log.txt @@ -1,50 +1,347 @@ -===== 3.1.30 ===== (07.08.2016) +===== 3.1.33 release ===== 12.09.2018 +===== 3.1.33-dev-12 ===== +03.09.2018 + - bugfix {foreach} using new style property access like {$item@property} on + Smarty 2 style named foreach loop could produce errors https://github.com/smarty-php/smarty/issues/484 + +31.08.2018 + - bugfix some custom left and right delimiters like '{^' '^}' did not work + https://github.com/smarty-php/smarty/issues/450 https://github.com/smarty-php/smarty/pull/482 + + - reformating for PSR-2 coding standards https://github.com/smarty-php/smarty/pull/483 + + - bugfix on Windows absolute filepathes did fail if the drive letter was followed by a linux DIRECTORY_SEPARATOR + like C:/ at Smarty > 3.1.33-dev-5 https://github.com/smarty-php/smarty/issues/451 + + - PSR-2 code style fixes for config and template file Lexer/Parser generated with + the Smarty Lexer/Parser generator from https://github.com/smarty-php/smarty-lexer + https://github.com/smarty-php/smarty/pull/483 + +26.08.2018 + - bugfix/enhancement {capture} allow variable as capture block name in Smarty special variable + like $smarty.capture.$foo https://github.com/smarty-php/smarty/issues/478 https://github.com/smarty-php/smarty/pull/481 + +===== 3.1.33-dev-6 ===== +19.08.2018 + - fix PSR-2 coding standards and PHPDoc blocks https://github.com/smarty-php/smarty/pull/452 + https://github.com/smarty-php/smarty/pull/475 + https://github.com/smarty-php/smarty/pull/473 + - bugfix PHP5.2 compatibility https://github.com/smarty-php/smarty/pull/472 + +===== 3.1.33-dev-4 ===== +17.05.2018 + - bugfix strip-block produces different output in Smarty v3.1.32 https://github.com/smarty-php/smarty/issues/436 + - bugfix Smarty::compileAllTemplates ignores `$extension` parameter https://github.com/smarty-php/smarty/issues/437 + https://github.com/smarty-php/smarty/pull/438 + - improvement do not compute total property in {foreach} if not needed https://github.com/smarty-php/smarty/issues/443 + - bugfix plugins may not be loaded when setMergeCompiledIncludes is true https://github.com/smarty-php/smarty/issues/435 + +26.04.2018 + - bugfix regarding Security Vulnerability did not solve the problem under Linux. + Security issue CVE-2018-16831 + +===== 3.1.32 ===== (24.04.2018) +24.04.2018 + - bugfix possible Security Vulnerability in Smarty_Security class. + +26.03.2018 + - bugfix plugins may not be loaded if {function} or {block} tags are executed in nocache mode + https://github.com/smarty-php/smarty/issues/371 + +26.03.2018 + - new feature {parent} = {$smarty.block.parent} {child} = {$smarty.block.child} + +23.03.2018 + - bugfix preg_replace could fail on large content resulting in a blank page https://github.com/smarty-php/smarty/issues/417 + +21.03.2018 + - bugfix {$smarty.section...} used outside {section}{/section} showed incorrect values if {section}{/section} was called inside + another loop https://github.com/smarty-php/smarty/issues/422 + - bugfix short form of {section} attributes did not work https://github.com/smarty-php/smarty/issues/428 + +17.03.2018 + - improvement Smarty::compileAllTemplates() exit with a non-zero status code if max errors is reached https://github.com/smarty-php/smarty/pull/402 + +16.03.2018 + - bugfix extends resource did not work with user defined left/right delimiter https://github.com/smarty-php/smarty/issues/419 + +22.11.2017 + - bugfix {break} and {continue} could fail if {foreach}{/foreach} did contain other + looping tags like {for}, {section} and {while} https://github.com/smarty-php/smarty/issues/323 + +20.11.2017 + - bugfix rework of newline spacing between tag code and template text. + now again identical with Smarty2 (forum topic 26878) + - replacement of " by ' + +05.11.2017 + - lexer/parser optimization + - code cleanup and optimizations + - bugfix {$smarty.section.name.loop} used together with {$smarty.section.name.total} could produce + wrong results (forum topic 27041) + +26.10.2017 + - bugfix Smarty version was not filled in header comment of compiled and cached files + - optimization replace internal Smarty::$ds property by DIRECTORY_SEPARATOR + - deprecate functions Smarty::muteExpectedErrors() and Smarty::unmuteExpectedErrors() + as Smarty does no longer use error suppression like @filemtime(). + for backward compatibility code is moved from Smarty class to an external class and still can be + called. + - correction of PHPDoc blocks + - minor code cleanup + +21.10.2017 + - bugfix custom delimiters could fail since modification of version 3.1.32-dev-23 + https://github.com/smarty-php/smarty/issues/394 + +18.10.2017 + - bugfix fix implementation of unclosed block tag in double quoted string of 12.10.2017 + https://github.com/smarty-php/smarty/issues/396 https://github.com/smarty-php/smarty/issues/397 + https://github.com/smarty-php/smarty/issues/391 https://github.com/smarty-php/smarty/issues/392 + +12.10.2017 + - bugfix $smarty.block.child and $smarty.block.parent could not be used like any + $smarty special variable https://github.com/smarty-php/smarty/issues/393 + - unclosed block tag in double quoted string must throw compiler exception. + https://github.com/smarty-php/smarty/issues/391 https://github.com/smarty-php/smarty/issues/392 + +07.10.2017 + - bugfix modification of 9.8.2017 did fail on some recursive + tag nesting. https://github.com/smarty-php/smarty/issues/389 + +26.8.2017 + - bugfix chained modifier failed when last modifier parameter is a signed value + https://github.com/smarty-php/smarty/issues/327 + - bugfix templates filepath with multibyte characters did not work + https://github.com/smarty-php/smarty/issues/385 + - bugfix {make_nocache} did display code if the template did not contain other nocache code + https://github.com/smarty-php/smarty/issues/369 + +09.8.2017 + - improvement repeated delimiter like {{ and }} will be treated as literal + https://groups.google.com/forum/#!topic/smarty-developers/h9r82Bx4KZw + +05.8.2017 + - bugfix wordwrap modifier could fail if used in nocache code. + converted plugin file shared.mb_wordwrap.php into modifier.mb_wordwrap.php + - cleanup of _getSmartyObj() + +31.7.2017 + - Call clearstatcache() after mkdir() failure https://github.com/smarty-php/smarty/pull/379 + +30.7.2017 + - rewrite mkdir() bugfix to retry automatically see https://github.com/smarty-php/smarty/pull/377 + https://github.com/smarty-php/smarty/pull/379 + +21.7.2017 + - security possible PHP code injection on custom resources at display() or fetch() + calls if the resource does not sanitize the template name + - bugfix fix 'mkdir(): File exists' error on create directory from parallel + processes https://github.com/smarty-php/smarty/pull/377 + - bugfix solve preg_match() hhvm parameter problem https://github.com/smarty-php/smarty/pull/372 + +27.5.2017 + - bugfix change compiled code for registered function and modifiers to called as callable to allow closures + https://github.com/smarty-php/smarty/pull/368, https://github.com/smarty-php/smarty/issues/273 + - bugfix https://github.com/smarty-php/smarty/pull/368 did break the default plugin handler + - improvement replace phpversion() by PHP_VERSION constant. + https://github.com/smarty-php/smarty/pull/363 + +21.5.2017 + - performance store flag for already required shared plugin functions in static variable or + Smarty's $_cache to improve performance when plugins are often called + https://github.com/smarty-php/smarty/commit/51e0d5cd405d764a4ea257d1bac1fb1205f74528#commitcomment-22280086 + - bugfix remove special treatment of classes implementing ArrayAccess in {foreach} + https://github.com/smarty-php/smarty/issues/332 + - bugfix remove deleted files by clear_cache() and clear_compiled_template() from + ACP cache if present, add some is_file() checks to avoid possible warnings on filemtime() + caused by above functions. + https://github.com/smarty-php/smarty/issues/341 + - bugfix version 3.1.31 did fail under PHP 5.2 + https://github.com/smarty-php/smarty/issues/365 + +19.5.2017 + - change properties $accessMap and $obsoleteProperties from private to protected + https://github.com/smarty-php/smarty/issues/351 + - new feature The named capture buffers can now be accessed also as array + See NEWS_FEATURES.txt https://github.com/smarty-php/smarty/issues/366 + - improvement check if ini_get() and ini_set() not disabled + https://github.com/smarty-php/smarty/pull/362 + +24.4.2017 + - fix spelling https://github.com/smarty-php/smarty/commit/e3eda8a5f5653d8abb960eb1bc47e3eca679b1b4#commitcomment-21803095 + +17.4.2017 + - correct generated code on empty() and isset() call, observe change PHP behaviour since PHP 5.5 + https://github.com/smarty-php/smarty/issues/347 + +14.4.2017 + - merge pull requests https://github.com/smarty-php/smarty/pull/349, https://github.com/smarty-php/smarty/pull/322 and https://github.com/smarty-php/smarty/pull/337 to fix spelling and annotation + +13.4.2017 + - bugfix array_merge() parameter should be checked https://github.com/smarty-php/smarty/issues/350 + +===== 3.1.31 ===== (14.12.2016) + 23.11.2016 + - move template object cache into static variables + + 19.11.2016 + - bugfix inheritance root child templates containing nested {block}{/block} could call sub-bock content from parent + template https://github.com/smarty-php/smarty/issues/317 + - change version checking + + 11.11.2016 + - bugfix when Smarty is using a cached template object on Smarty::fetch() or Smarty::isCached() the inheritance data + must be removed https://github.com/smarty-php/smarty/issues/312 + - smaller speed optimization + + 08.11.2016 + - add bootstrap file to load and register Smarty_Autoloader. Change composer.json to make it known to composer + + 07.11.2016 + - optimization of lexer speed https://github.com/smarty-php/smarty/issues/311 + + 27.10.2016 + - bugfix template function definitions array has not been cached between Smarty::fetch() and Smarty::display() calls + https://github.com/smarty-php/smarty/issues/301 + + 23.10.2016 + - improvement/bugfix when Smarty::fetch() is called on a template object the inheritance and tplFunctions property + should be copied to the called template object + + 21.10.2016 + - bugfix for compile locking touched timestamp of old compiled file was not restored on compilation error https://github.com/smarty-php/smarty/issues/308 + + 20.10.2016 + - bugfix nocache code was not removed in cache file when subtemplate did contain PHP short tags in text but no other + nocache code https://github.com/smarty-php/smarty/issues/300 + + 19.10.2016 + - bugfix {make_nocache $var} did fail when variable value did contain '\' https://github.com/smarty-php/smarty/issues/305 + - bugfix {make_nocache $var} remove spaces from variable value https://github.com/smarty-php/smarty/issues/304 + + 12.10.2016 + - bugfix {include} with template names including variable or constants could fail after bugfix from + 28.09.2016 https://github.com/smarty-php/smarty/issues/302 + + 08.10.2016 + - optimization move runtime extension for template functions into Smarty objects + + 29.09.2016 + - improvement new Smarty::$extends_recursion property to disable execution of {extends} in templates called by extends resource + https://github.com/smarty-php/smarty/issues/296 + + 28.09.2016 + - bugfix the generated code for calling a subtemplate must pass the template resource name in single quotes https://github.com/smarty-php/smarty/issues/299 + - bugfix nocache hash was not removed for tags in subtemplates https://github.com/smarty-php/smarty/issues/300 + + 27.09.2016 + - bugfix when Smarty does use an internally cached template object on Smarty::fetch() calls + the template and config variables must be cleared https://github.com/smarty-php/smarty/issues/297 + + 20.09.2016 + - bugfix some $smarty special template variables are no longer accessed as real variable. + using them on calls like {if isset($smarty.foo)} or {if empty($smarty.foo)} will fail + http://www.smarty.net/forums/viewtopic.php?t=26222 + - temporary fix for https://github.com/smarty-php/smarty/issues/293 main reason still under investigation + - improvement new tags {block_parent} {block_child} in template inheritance + + 19.09.2016 + - optimization clear compiled and cached folder completely on detected version change + - cleanup convert cache resource file method clear into runtime extension + + 15.09.2016 + - bugfix assigning a variable in if condition by function like {if $value = array_shift($array)} the function got called twice https://github.com/smarty-php/smarty/issues/291 + - bugfix function plugins called with assign attribute like {foo assign='bar'} did not output returned content because + because assumption was made that it was assigned to a variable https://github.com/smarty-php/smarty/issues/292 + - bugfix calling $smarty->isCached() on a not existing cache file with $smarty->cache_locking = true; could cause a 10 second delay http://www.smarty.net/forums/viewtopic.php?t=26282 + - improvement make Smarty::clearCompiledTemplate() on custom resource independent from changes of templateId computation + + 11.09.2016 + - improvement {math} misleading E_USER_WARNING messages when parameter value = null https://github.com/smarty-php/smarty/issues/288 + - improvement move often used code snippets into methods + - performance Smarty::configLoad() did load unneeded template source object + + 09.09.2016 + - bugfix/optimization {foreach} did not execute the {foreachelse} when iterating empty objects https://github.com/smarty-php/smarty/pull/287 + - bugfix {foreach} must keep the @properties when restoring a saved $item variable as the properties might be used outside {foreach} https://github.com/smarty-php/smarty/issues/267 + - improvement {foreach} observe {break n} and {continue n} nesting levels when restoring saved $item and $key variables + + 08.09.2016 + - bugfix implement wrapper for removed method getConfigVariable() https://github.com/smarty-php/smarty/issues/286 + + 07.09.2016 + - bugfix using nocache like attribute with value true like {plugin nocache=true} did not work https://github.com/smarty-php/smarty/issues/285 + - bugfix uppercase TRUE, FALSE and NULL did not work when security was enabled https://github.com/smarty-php/smarty/issues/282 + - bugfix when {foreach} was looping over an object the total property like {$item@total} did always return 1 https://github.com/smarty-php/smarty/issues/281 + - bugfix {capture}{/capture} did add in 3.1.30 unintended additional blank lines https://github.com/smarty-php/smarty/issues/268 + + 01.09.2016 + - performance require_once should be called only once for shared plugins https://github.com/smarty-php/smarty/issues/280 + + 26.08.2016 + - bugfix change of 23.08.2016 failed on linux when use_include_path = true + + 23.08.2016 + - bugfix remove constant DS as shortcut for DIRECTORY_SEPARATOR as the user may have defined it to something else https://github.com/smarty-php/smarty/issues/277 + + 20.08-2016 + - bugfix {config_load ... scope="global"} shall not throw an arror but fallback to scope="smarty" https://github.com/smarty-php/smarty/issues/274 + - bugfix {make_nocache} failed when using composer autoloader https://github.com/smarty-php/smarty/issues/275 + + 14.08.2016 + - bugfix $smarty_>debugging = true; did E_NOTICE messages when {eval} tag was used https://github.com/smarty-php/smarty/issues/266 + - bugfix Class 'Smarty_Internal_Runtime_ValidateCompiled' not found when upgrading from some older Smarty versions with existing + compiled or cached template files https://github.com/smarty-php/smarty/issues/269 + - optimization remove unneeded call to update acopes when {assign} scope and template scope was local (default) + +===== 3.1.30 ===== (07.08.2016) 07.08.2016 - bugfix update of 04.08.2016 was incomplete 05.08.2016 - - bugfix compiling of templates failed when the Smarty delimiter did contain '/' https://github.com/smarty-php/smarty/issues/264 + - bugfix compiling of templates failed when the Smarty delimiter did contain '/' https://github.com/smarty-php/smarty/issues/264 - updated error checking at template and config default handler - + 04.08.2016 - improvement move template function source parameter into extension - + 26.07.2016 - optimization unneeded loading of compiled resource - + 24.07.2016 - regression this->addPluginsDir('/abs/path/to/dir') adding absolute path without trailing '/' did fail https://github.com/smarty-php/smarty/issues/260 - + 23.07.2016 - bugfix setTemplateDir('/') and setTemplateDir('') did create wrong absolute filepath https://github.com/smarty-php/smarty/issues/245 - optimization of filepath normalization - - improvement remove double funtion declaration in plugin shared.escape_special_cars.php https://github.com/smarty-php/smarty/issues/229 - + - improvement remove double function declaration in plugin shared.escape_special_cars.php https://github.com/smarty-php/smarty/issues/229 + 19.07.2016 - bugfix multiple {include} with relative filepath within {block}{/block} could fail https://github.com/smarty-php/smarty/issues/246 - bugfix {math} shell injection vulnerability patch provided by Tim Weber - + 18.07.2016 - bugfix {foreach} if key variable and item@key attribute have been used both the key variable was not updated https://github.com/smarty-php/smarty/issues/254 - bugfix modifier on plugins like {plugin|modifier ... } did fail when the plugin does return an array https://github.com/smarty-php/smarty/issues/228 - bugfix avoid opcache_invalidate to result in ErrorException when opcache.restrict_api is not empty https://github.com/smarty-php/smarty/pull/244 - bugfix multiple {include} with relative filepath within {block}{/block} could fail https://github.com/smarty-php/smarty/issues/246 - + 14.07.2016 - bugfix wrong parameter on compileAllTemplates() and compileAllConfig() https://github.com/smarty-php/smarty/issues/231 - + 13.07.2016 - bugfix PHP 7 compatibility on registered compiler plugins https://github.com/smarty-php/smarty/issues/241 - update testInstall() https://github.com/smarty-php/smarty/issues/248https://github.com/smarty-php/smarty/issues/248 - bugfix enable debugging could fail when template objects did already exists https://github.com/smarty-php/smarty/issues/237 - bugfix template function data should be merged when loading subtemplate https://github.com/smarty-php/smarty/issues/240 - bugfix wrong parameter on compileAllTemplates() https://github.com/smarty-php/smarty/issues/231 - + 12.07.2016 - bugfix {foreach} item variable must be created also on empty from array https://github.com/smarty-php/smarty/issues/238 and https://github.com/smarty-php/smarty/issues/239 - bugfix enableSecurity() must init cache flags https://github.com/smarty-php/smarty/issues/247 - + 27.05.2016 - bugfix/improvement of compileAlltemplates() follow symlinks in template folder (PHP >= 5.3.1) https://github.com/smarty-php/smarty/issues/224 clear internal cache and expension handler for each template to avoid possible conflicts https://github.com/smarty-php/smarty/issues/231 @@ -87,26 +384,26 @@ 11.03.2016 - optimization of capture and security handling - improvement $smarty->clearCompiledTemplate() should return on recompiled or uncompiled resources - + 10.03.2016 - optimization of resource processing - + 09.03.2016 - improvement rework of 'scope' attribute handling see see NEW_FEATURES.txt https://github.com/smarty-php/smarty/issues/194 https://github.com/smarty-php/smarty/issues/186 https://github.com/smarty-php/smarty/issues/179 - bugfix correct Autoloader update of 2.3.2014 https://github.com/smarty-php/smarty/issues/199 - + 04.03.2016 - bugfix change from 01.03.2016 will cause $smarty->isCached(..) failure if called multiple time for same template (forum topic 25935) - + 02.03.2016 - revert autoloader optimizations because of unexplainable warning when using plugins https://github.com/smarty-php/smarty/issues/199 - + 01.03.2016 - bugfix template objects must be cached on $smarty->fetch('foo.tpl) calls incase the template is fetched multiple times (forum topic 25909) - + 25.02.2016 - bugfix wrong _realpath with 4 or more parent-directories https://github.com/smarty-php/smarty/issues/190 - optimization of _realpath @@ -115,10 +412,10 @@ 20.02.2016 - bugfix {strip} must keep space between hmtl tags. Broken by changes of 10.2.2016 https://github.com/smarty-php/smarty/issues/184 - new feature/bugfix {foreach}{section} add 'properties' attribute to force compilation of loop properties - see NEW_FEATURES.txt https://github.com/smarty-php/smarty/issues/189 - + see NEW_FEATURES.txt https://github.com/smarty-php/smarty/issues/189 + 19.02.2016 - - revert output buffer flushing on display, echo content again because possible problems when PHP files had + - revert output buffer flushing on display, echo content again because possible problems when PHP files had characters (newline} after ?> at file end https://github.com/smarty-php/smarty/issues/187 14.02.2016 @@ -129,33 +426,33 @@ - optimization make compiler tag object cache static for higher compilation speed 11.02.2016 - - improvement added KnockoutJS comments to trimwhitespace outputfilter https://github.com/smarty-php/smarty/issues/82 + - improvement added KnockoutJS comments to trimwhitespace outputfilter https://github.com/smarty-php/smarty/issues/82 https://github.com/smarty-php/smarty/pull/181 - + 10.02.2016 - bugfix {strip} must keep space on output creating smarty tags within html tags https://github.com/smarty-php/smarty/issues/177 - bugfix wrong precedence on special if conditions like '$foo is ... by $bar' could cause wrong code https://github.com/smarty-php/smarty/issues/178 - improvement because of ambiguities the inline constant support has been removed from the $foo.bar syntax https://github.com/smarty-php/smarty/issues/149 - - bugfix other {strip} error with output tags between hmtl https://github.com/smarty-php/smarty/issues/180 + - bugfix other {strip} error with output tags between hmtl https://github.com/smarty-php/smarty/issues/180 09.02.2016 - move some code from parser into compiler - reformat all code for unique style - update/bugfix scope attribute handling reworked. Read the newfeatures.txt file - + 05.02.2016 - improvement internal compiler changes - + 01.02.2016 - bugfix {foreach} compilation failed when $smarty->merge_compiled_includes = true and pre-filters are used. 29.01.2016 - bugfix implement replacement code for _tag_stack property https://github.com/smarty-php/smarty/issues/151 - + 28.01.2016 - bugfix allow windows network filepath or wrapper (forum topic 25876) https://github.com/smarty-php/smarty/issues/170 - bugfix if fetch('foo.tpl') is called on a template object the $parent parameter should default to the calling template object https://github.com/smarty-php/smarty/issues/152 - + 27.01.2016 - revert bugfix compiling {section} did create warning - bugfix {$smarty.section.customer.loop} did throw compiler error https://github.com/smarty-php/smarty/issues/161 @@ -165,7 +462,7 @@ - bugfix {extends} with relative file path did not work https://github.com/smarty-php/smarty/issues/154 https://github.com/smarty-php/smarty/issues/158 - bugfix {capture} data could not been seen in other templates with {$smarty.capture.name} https://github.com/smarty-php/smarty/issues/153 - + 26.01.2016 - improvement observe Smarty::$_CHARSET in debugging console https://github.com/smarty-php/smarty/issues/169 - bugfix compiling {section} did create warning @@ -175,28 +472,28 @@ - update scope handling - optimize block plugin compiler - improvement runtime checks if registered block plugins are callable - + 01.01.2016 - remove Smarty::$resource_cache_mode property - + 31.12.2015 - optimization of {assign}, {if} and {while} compiled code - + 30.12.2015 - bugfix plugin names starting with "php" did not compile https://github.com/smarty-php/smarty/issues/147 29.12.2015 - bugfix Smarty::error_reporting was not observed when display() or fetch() was called on template objects https://github.com/smarty-php/smarty/issues/145 - + 28.12.2015 - optimization of {foreach} code size and processing - + 27.12.2015 - improve inheritance code - update external methods - code fixes - PHPdoc updates - + 25.12.2015 - compile {block} tag code and its processing into classes - optimization replace hhvm extension by inline code @@ -210,45 +507,45 @@ - optimization move internal method decodeProperties back into template object - optimization move subtemplate processing back into template object - new feature Caching does now observe the template_dir setting and will create separate cache files if required - + 22.12.2015 - change $xxx_dir properties from private to protected in case Smarty class gets extended - code optimizations - + 21.12.2015 - bugfix a filepath starting with '/' or '\' on windows should normalize to the root dir of current working drive https://github.com/smarty-php/smarty/issues/134 - optimization of filepath normalization - bugfix {strip} must remove all blanks between html tags https://github.com/smarty-php/smarty/issues/136 - + ===== 3.1.29 ===== (21.12.2015) 21.12.2015 - optimization improve speed of filetime checks on extends and extendsall resource - + 20.12.2015 - bugfix failure when the default resource type was set to 'extendsall' https://github.com/smarty-php/smarty/issues/123 - update compilation of Smarty special variables - bugfix add addition check for OS type on normalization of file path https://github.com/smarty-php/smarty/issues/134 - bugfix the source uid of the extendsall resource must contain $template_dir settings https://github.com/smarty-php/smarty/issues/123 - + 19.12.2015 - bugfix using $smarty.capture.foo in expressions could fail https://github.com/smarty-php/smarty/pull/138 - bugfix broken PHP 5.2 compatibility https://github.com/smarty-php/smarty/issues/139 - remove no longer used code - improvement make sure that compiled and cache templates never can contain a trailing '?>? - + 18.12.2015 - bugfix regression when modifier parameter was followed by math https://github.com/smarty-php/smarty/issues/132 - + 17.12.2015 - bugfix {$smarty.capture.nameFail} did lowercase capture name https://github.com/smarty-php/smarty/issues/135 - bugfix using {block append/prepend} on same block in multiple levels of inheritance templates could fail (forum topic 25827) - bugfix text content consisting of just a single '0' like in {if true}0{/if} was suppressed (forum topic 25834) - + 16.12.2015 - bugfix {foreach} did fail if from atrribute is a Generator class https://github.com/smarty-php/smarty/issues/128 - bugfix direct access $smarty->template_dir = 'foo'; should call Smarty::setTemplateDir() https://github.com/smarty-php/smarty/issues/121 - + 15.12.2015 - bugfix {$smarty.cookies.foo} did return the $_COOKIE array not the 'foo' value https://github.com/smarty-php/smarty/issues/122 - bugfix a call to clearAllCache() and other should clear all internal template object caches (forum topic 25828) @@ -256,25 +553,25 @@ 14.12.2015 - bugfix {$smarty.config.foo} broken in 3.1.28 https://github.com/smarty-php/smarty/issues/120 - bugfix multiple calls of {section} with same name droped E_NOTICE error https://github.com/smarty-php/smarty/issues/118 - + ===== 3.1.28 ===== (13.12.2015) 13.12.2015 - bugfix {foreach} and {section} with uppercase characters in name attribute did not work (forum topic 25819) - bugfix $smarty->debugging_ctrl = 'URL' did not work (forum topic 25811) - bugfix Debug Console could display incorrect data when using subtemplates - + 09.12.2015 - bugfix Smarty did fail under PHP 7.0.0 with use_include_path = true; - + 09.12.2015 - bugfix {strip} should exclude some html tags from stripping, related to fix for https://github.com/smarty-php/smarty/issues/111 - + 08.12.2015 - bugfix internal template function data got stored in wrong compiled file https://github.com/smarty-php/smarty/issues/114 - + 05.12.2015 -bugfix {strip} should insert a single space https://github.com/smarty-php/smarty/issues/111 - + 25.11.2015 -bugfix a left delimter like '[%' did fail on [%$var_[%$variable%]%] (forum topic 25798) @@ -283,7 +580,7 @@ 01.11.2015 - update config file processing - + 31.10.2015 - bugfix add missing $trusted_dir property to SmartyBC class (forum topic 25751) @@ -307,7 +604,7 @@ 18.09.2015 - bugfix {if $foo instanceof $bar} failed to compile if 2nd value is a variable https://github.com/smarty-php/smarty/issues/92 - + 17.09.2015 - bugfix {foreach} first attribute was not correctly reset since commit 05a8fa2 of 02.08.2015 https://github.com/smarty-php/smarty/issues/90 @@ -321,7 +618,7 @@ - move code of {call} processing back into Smarty_Internal_Template class - improvement invalidate OPCACHE for cleared compiled and cached template files (forum topic 25557) - bugfix unintended multiple debug windows (forum topic 25699) - + 30.08.2015 - size optimization move some runtime functions into extension - optimize inline template processing @@ -470,10 +767,10 @@ 01.06.2015 - bugfix including template variables broken since 3.1.22 https://github.com/smarty-php/smarty/issues/47 - + 27.05.2015 - bugfix {include} with variable file name must not create by default individual cache file (since 3.1.22) https://github.com/smarty-php/smarty/issues/43 - + 24.05.2015 - bugfix if condition string 'neq' broken due to a typo https://github.com/smarty-php/smarty/issues/42 @@ -481,11 +778,11 @@ 23.05.2015 - improvement on php_handling to allow very large PHP sections, better error handling - improvement allow extreme large comment sections (forum 25538) - + 21.05.2015 - bugfix broken PHP 5.2 compatibility when compiling 1 did compile into wrong code https://github.com/smarty-php/smarty/issues/41 - + 19.05.2015 - bugfix compiler did overwrite existing variable value when setting the nocache attribute https://github.com/smarty-php/smarty/issues/39 - bugfix output filter trimwhitespace could run into the pcre.backtrack_limit on large output (code.google issue 220) @@ -493,14 +790,14 @@ 18.05.2015 - improvement introduce shortcuts in lexer/parser rules for most frequent terms for higher - compilation speed + compilation speed 16.05.2015 - bugfix {php}{/php} did work just for single lines https://github.com/smarty-php/smarty/issues/33 - improvement remove not needed ?> handling from parser to new compiler module 05.05.2015 - bugfix code could be messed up when {tags} are used in multiple attributes https://github.com/smarty-php/smarty/issues/23 - + 04.05.2015 - bugfix Smarty_Resource::parseResourceName incompatible with Google AppEngine (https://github.com/smarty-php/smarty/issues/22) - improvement use is_file() checks to avoid errors suppressed by @ which could still cause problems (https://github.com/smarty-php/smarty/issues/24) @@ -550,13 +847,13 @@ 28.04.2015 - bugfix plugins of merged subtemplates not loaded in 3.1.22-dev (forum topic 25508) - - 23.04.2015 + + 23.04.2015 - bugfix a nocache template variable used as parameter at {insert} was by mistake cached - + 20.04.2015 - bugfix at a template function containing nocache code a parmeter could overwrite a template variable of same name - + 27.03.2015 - bugfix Smarty_Security->allow_constants=false; did also disable true, false and null (change of 16.03.2015) - improvement added a whitelist for trusted constants to security Smarty_Security::$trusted_constants (forum topic 25471) @@ -564,39 +861,39 @@ 20.03.2015 - bugfix make sure that function properties get saved only in compiled files containing the fuction definition {forum topic 25452} - bugfix correct update of global variable values on exit of template functions. (reported under Smarty Developers) - + 16.03.2015 - bugfix problems with {function}{/function} and {call} tags in different subtemplate cache files {forum topic 25452} - bugfix Smarty_Security->allow_constants=false; did not disallow direct usage of defined constants like {SMARTY_DIR} {forum topic 25457} - bugfix {block}{/block} tags did not work inside double quoted strings https://github.com/smarty-php/smarty/issues/18 - - + + 15.03.2015 - bugfix $smarty->compile_check must be restored before rendering of a just updated cache file {forum 25452} - + 14.03.2015 - bugfix {nocache} {/nocache} tags corrupted code when used within a nocache section caused by a nocache template variable. - + - bugfix template functions defined with {function} in an included subtemplate could not be called in nocache mode with {call... nocache} if the subtemplate had it's own cache file {forum 25452} - + 10.03.2015 - bugfix {include ... nocache} whith variable file or compile_id attribute was not executed in nocache mode. - + 12.02.2015 - bugfix multiple Smarty::fetch() of same template when $smarty->merge_compiled_includes = true; could cause function already defined error - + 11.02.2015 - bugfix recursive {includes} did create E_NOTICE message when $smarty->merge_compiled_includes = true; (github issue #16) - + 22.01.2015 - new feature security can now control access to static methods and properties see also NEW_FEATURES.txt 21.01.2015 - bugfix clearCompiledTemplates(), clearAll() and clear() could try to delete whole drive at wrong path permissions because realpath() fail (forum 25397) - - bugfix 'self::' and 'parent::' was interpreted in template syntax as static class - + - bugfix 'self::' and 'parent::' was interpreted in template syntax as static class + 04.01.2015 - push last weeks changes to github @@ -607,10 +904,10 @@ - optimization restructure config file processing 31.12.2014 - - bugfix use function_exists('mb_get_info') for setting Smarty::$_MBSTRING. + - bugfix use function_exists('mb_get_info') for setting Smarty::$_MBSTRING. Function mb_split could be overloaded depending on php.ini mbstring.func_overload - - + + 29.12.2014 - new feature security can now limit the template nesting level by property $max_template_nesting see also NEW_FEATURES.txt (forum 25370) @@ -624,14 +921,14 @@ 13.12.2014 - improvement optimization of lexer and parser resulting in a up to 30% higher compiling speed - + 11.12.2014 - bugfix resolve parser ambiguity between constant print tag {CONST} and other smarty tags after change of 09.12.2014 - + 09.12.2014 - bugfix variables $null, $true and $false did not work after the change of 12.11.2014 (forum 25342) - bugfix call of template function by a variable name did not work after latest changes (forum 25342) - + 23.11.2014 - bugfix a plugin with attached modifier could fail if the tag was immediately followed by another Smarty tag (since 3.1.21) (forum 25326) @@ -649,12 +946,12 @@ 04.11.2014 - new feature $smarty->debugging = true; => overwrite existing Debug Console window (old behaviour) $smarty->debugging = 2; => individual Debug Console window by template name - + 03.11.2014 - bugfix Debug Console did not show included subtemplates since 3.1.17 (forum 25301) - bugfix Modifier debug_print_var did not limit recursion or prevent recursive object display at Debug Console (ATTENTION: parameter order has changed to be able to specify maximum recursion) - - bugfix Debug consol did not include subtemplate information with $smarty->merge_compiled_includes = true + - bugfix Debug consol did not include subtemplate information with $smarty->merge_compiled_includes = true - improvement The template variables are no longer displayed as objects on the Debug Console - improvement $smarty->createData($parent = null, $name = null) new optional name parameter for display at Debug Console - addition of some hooks for future extension of Debug Console @@ -671,7 +968,7 @@ 26.10.2014 - bugfix E_NOTICE message was created during compilation when ASP tags '<%' or '%>' are in template source text - bugfix merge_compiled_includes option failed when caching enables and same subtemplate was included cached and not cached - + ===== 3.1.21 ===== (18.10.2014) 18.10.2014 - composer moved to github @@ -698,143 +995,143 @@ ===== 3.1.20 ===== (09.10.2014) 08.10.2014 - bugfix security mode of "'; - } elseif ($encode == 'javascript_charcode') { + } elseif ($encode === 'javascript_charcode') { $string = '' . $text . ''; - - for ($x = 0, $y = strlen($string); $x < $y; $x ++) { + for ($x = 0, $y = strlen($string); $x < $y; $x++) { $ord[] = ord($string[ $x ]); } - $_ret = "\n"; - return $_ret; - } elseif ($encode == 'hex') { + } elseif ($encode === 'hex') { preg_match('!^(.*)(\?.*)$!', $address, $match); if (!empty($match[ 2 ])) { trigger_error("mailto: hex encoding does not work with extra attributes. Try javascript.", E_USER_WARNING); - return; } $address_encode = ''; - for ($x = 0, $_length = strlen($address); $x < $_length; $x ++) { + for ($x = 0, $_length = strlen($address); $x < $_length; $x++) { if (preg_match('!\w!' . Smarty::$_UTF8_MODIFIER, $address[ $x ])) { $address_encode .= '%' . bin2hex($address[ $x ]); } else { @@ -139,12 +125,10 @@ function smarty_function_mailto($params) } } $text_encode = ''; - for ($x = 0, $_length = strlen($text); $x < $_length; $x ++) { + for ($x = 0, $_length = strlen($text); $x < $_length; $x++) { $text_encode .= '&#x' . bin2hex($text[ $x ]) . ';'; } - $mailto = "mailto:"; - return '' . $text_encode . ''; } else { // no encoding diff --git a/Smarty/libs/plugins/function.math.php b/Smarty/libs/plugins/function.math.php index 655fe72..7348d96 100644 --- a/Smarty/libs/plugins/function.math.php +++ b/Smarty/libs/plugins/function.math.php @@ -6,16 +6,15 @@ * @package Smarty * @subpackage PluginsFunction */ - /** * Smarty {math} function plugin - * Type: function
- * Name: math
+ * Type: function + * Name: math * Purpose: handle math computations in template * - * @link http://www.smarty.net/manual/en/language.function.math.php {math} + * @link http://www.smarty.net/manual/en/language.function.math.php {math} * (Smarty online manual) - * @author Monte Ohrt + * @author Monte Ohrt * * @param array $params parameters * @param Smarty_Internal_Template $template template object @@ -25,69 +24,78 @@ function smarty_function_math($params, $template) { static $_allowed_funcs = - array('int' => true, 'abs' => true, 'ceil' => true, 'cos' => true, 'exp' => true, 'floor' => true, - 'log' => true, 'log10' => true, 'max' => true, 'min' => true, 'pi' => true, 'pow' => true, 'rand' => true, - 'round' => true, 'sin' => true, 'sqrt' => true, 'srand' => true, 'tan' => true); + array( + 'int' => true, + 'abs' => true, + 'ceil' => true, + 'cos' => true, + 'exp' => true, + 'floor' => true, + 'log' => true, + 'log10' => true, + 'max' => true, + 'min' => true, + 'pi' => true, + 'pow' => true, + 'rand' => true, + 'round' => true, + 'sin' => true, + 'sqrt' => true, + 'srand' => true, + 'tan' => true + ); // be sure equation parameter is present if (empty($params[ 'equation' ])) { trigger_error("math: missing equation parameter", E_USER_WARNING); - return; } - $equation = $params[ 'equation' ]; - // make sure parenthesis are balanced - if (substr_count($equation, "(") != substr_count($equation, ")")) { + if (substr_count($equation, '(') !== substr_count($equation, ')')) { trigger_error("math: unbalanced parenthesis", E_USER_WARNING); - return; } - // disallow backticks if (strpos($equation, '`') !== false) { trigger_error("math: backtick character not allowed in equation", E_USER_WARNING); - return; } - // also disallow dollar signs if (strpos($equation, '$') !== false) { trigger_error("math: dollar signs not allowed in equation", E_USER_WARNING); - return; } - + foreach ($params as $key => $val) { + if ($key !== 'equation' && $key !== 'format' && $key !== 'assign') { + // make sure value is not empty + if (strlen($val) === 0) { + trigger_error("math: parameter '{$key}' is empty", E_USER_WARNING); + return; + } + if (!is_numeric($val)) { + trigger_error("math: parameter '{$key}' is not numeric", E_USER_WARNING); + return; + } + } + } // match all vars in equation, make sure all are passed preg_match_all('!(?:0x[a-fA-F0-9]+)|([a-zA-Z_\x7f-\xff][a-zA-Z0-9_\x7f-\xff]*)!', $equation, $match); - foreach ($match[ 1 ] as $curr_var) { if ($curr_var && !isset($params[ $curr_var ]) && !isset($_allowed_funcs[ $curr_var ])) { - trigger_error("math: function call $curr_var not allowed", E_USER_WARNING); - + trigger_error( + "math: function call '{$curr_var}' not allowed, or missing parameter '{$curr_var}'", + E_USER_WARNING + ); return; } } - foreach ($params as $key => $val) { - if ($key != "equation" && $key != "format" && $key != "assign") { - // make sure value is not empty - if (strlen($val) == 0) { - trigger_error("math: parameter $key is empty", E_USER_WARNING); - - return; - } - if (!is_numeric($val)) { - trigger_error("math: parameter $key: is not numeric", E_USER_WARNING); - - return; - } + if ($key !== 'equation' && $key !== 'format' && $key !== 'assign') { $equation = preg_replace("/\b$key\b/", " \$params['$key'] ", $equation); } } $smarty_math_result = null; eval("\$smarty_math_result = " . $equation . ";"); - if (empty($params[ 'format' ])) { if (empty($params[ 'assign' ])) { return $smarty_math_result; diff --git a/Smarty/libs/plugins/modifier.capitalize.php b/Smarty/libs/plugins/modifier.capitalize.php index 6513a04..c5fc400 100644 --- a/Smarty/libs/plugins/modifier.capitalize.php +++ b/Smarty/libs/plugins/modifier.capitalize.php @@ -5,11 +5,10 @@ * @package Smarty * @subpackage PluginsModifier */ - /** * Smarty capitalize modifier plugin - * Type: modifier
- * Name: capitalize
+ * Type: modifier + * Name: capitalize * Purpose: capitalize words in the string * {@internal {$string|capitalize:true:true} is the fastest option for MBString enabled systems }} * @@ -29,50 +28,75 @@ function smarty_modifier_capitalize($string, $uc_digits = false, $lc_rest = fals $upper_string = mb_convert_case($string, MB_CASE_TITLE, Smarty::$_CHARSET); } else { // uppercase word breaks - $upper_string = preg_replace_callback("!(^|[^\p{L}'])([\p{Ll}])!S" . Smarty::$_UTF8_MODIFIER, - 'smarty_mod_cap_mbconvert_cb', $string); + $upper_string = preg_replace_callback( + "!(^|[^\p{L}'])([\p{Ll}])!S" . Smarty::$_UTF8_MODIFIER, + 'smarty_mod_cap_mbconvert_cb', + $string + ); } // check uc_digits case if (!$uc_digits) { - if (preg_match_all("!\b([\p{L}]*[\p{N}]+[\p{L}]*)\b!" . Smarty::$_UTF8_MODIFIER, $string, $matches, - PREG_OFFSET_CAPTURE)) { + if (preg_match_all( + "!\b([\p{L}]*[\p{N}]+[\p{L}]*)\b!" . Smarty::$_UTF8_MODIFIER, + $string, + $matches, + PREG_OFFSET_CAPTURE + ) + ) { foreach ($matches[ 1 ] as $match) { $upper_string = - substr_replace($upper_string, mb_strtolower($match[ 0 ], Smarty::$_CHARSET), $match[ 1 ], - strlen($match[ 0 ])); + substr_replace( + $upper_string, + mb_strtolower($match[ 0 ], Smarty::$_CHARSET), + $match[ 1 ], + strlen($match[ 0 ]) + ); } } } $upper_string = - preg_replace_callback("!((^|\s)['\"])(\w)!" . Smarty::$_UTF8_MODIFIER, 'smarty_mod_cap_mbconvert2_cb', - $upper_string); + preg_replace_callback( + "!((^|\s)['\"])(\w)!" . Smarty::$_UTF8_MODIFIER, + 'smarty_mod_cap_mbconvert2_cb', + $upper_string + ); return $upper_string; } - // lowercase first if ($lc_rest) { $string = strtolower($string); } // uppercase (including hyphenated words) $upper_string = - preg_replace_callback("!(^|[^\p{L}'])([\p{Ll}])!S" . Smarty::$_UTF8_MODIFIER, 'smarty_mod_cap_ucfirst_cb', - $string); + preg_replace_callback( + "!(^|[^\p{L}'])([\p{Ll}])!S" . 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, $string, $matches, - PREG_OFFSET_CAPTURE)) { + if (preg_match_all( + "!\b([\p{L}]*[\p{N}]+[\p{L}]*)\b!" . Smarty::$_UTF8_MODIFIER, + $string, + $matches, + PREG_OFFSET_CAPTURE + ) + ) { foreach ($matches[ 1 ] as $match) { $upper_string = substr_replace($upper_string, strtolower($match[ 0 ]), $match[ 1 ], strlen($match[ 0 ])); } } } - $upper_string = preg_replace_callback("!((^|\s)['\"])(\w)!" . Smarty::$_UTF8_MODIFIER, 'smarty_mod_cap_ucfirst2_cb', - $upper_string); + $upper_string = preg_replace_callback( + "!((^|\s)['\"])(\w)!" . Smarty::$_UTF8_MODIFIER, + 'smarty_mod_cap_ucfirst2_cb', + $upper_string + ); return $upper_string; } -/* +/** * * Bug: create_function() use exhausts memory when used in long loops * Fix: use declared functions for callbacks instead of using create_function() @@ -80,21 +104,41 @@ function smarty_modifier_capitalize($string, $uc_digits = false, $lc_rest = fals * * @author Kyle Renfrow */ +/** + * @param $matches + * + * @return string + */ function smarty_mod_cap_mbconvert_cb($matches) { return stripslashes($matches[ 1 ]) . mb_convert_case(stripslashes($matches[ 2 ]), MB_CASE_UPPER, Smarty::$_CHARSET); } +/** + * @param $matches + * + * @return string + */ function smarty_mod_cap_mbconvert2_cb($matches) { return stripslashes($matches[ 1 ]) . mb_convert_case(stripslashes($matches[ 3 ]), MB_CASE_UPPER, Smarty::$_CHARSET); } +/** + * @param $matches + * + * @return string + */ function smarty_mod_cap_ucfirst_cb($matches) { return stripslashes($matches[ 1 ]) . ucfirst(stripslashes($matches[ 2 ])); } +/** + * @param $matches + * + * @return string + */ function smarty_mod_cap_ucfirst2_cb($matches) { return stripslashes($matches[ 1 ]) . ucfirst(stripslashes($matches[ 3 ])); diff --git a/Smarty/libs/plugins/modifier.date_format.php b/Smarty/libs/plugins/modifier.date_format.php index 28d6ff0..23b6943 100644 --- a/Smarty/libs/plugins/modifier.date_format.php +++ b/Smarty/libs/plugins/modifier.date_format.php @@ -5,13 +5,12 @@ * @package Smarty * @subpackage PluginsModifier */ - /** * Smarty date_format modifier plugin - * Type: modifier
- * Name: date_format
- * Purpose: format datestamps via strftime
- * Input:
+ * Type: modifier + * Name: date_format + * Purpose: format datestamps via strftime + * Input: * - string: input date string * - format: strftime format for output * - default_date: default date if $string is empty @@ -35,18 +34,40 @@ function smarty_modifier_date_format($string, $format = null, $default_date = '' /** * require_once the {@link shared.make_timestamp.php} plugin */ - require_once(SMARTY_PLUGINS_DIR . 'shared.make_timestamp.php'); - if ($string != '' && $string != '0000-00-00' && $string != '0000-00-00 00:00:00') { + 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; + } + if ($string !== '' && $string !== '0000-00-00' && $string !== '0000-00-00 00:00:00') { $timestamp = smarty_make_timestamp($string); - } elseif ($default_date != '') { + } elseif ($default_date !== '') { $timestamp = smarty_make_timestamp($default_date); } else { return; } - if ($formatter == 'strftime' || ($formatter == 'auto' && strpos($format, '%') !== false)) { - if (DS == '\\') { - $_win_from = array('%D', '%h', '%n', '%r', '%R', '%t', '%T'); - $_win_to = array('%m/%d/%y', '%b', "\n", '%I:%M:%S %p', '%H:%M', "\t", '%H:%M:%S'); + if ($formatter === 'strftime' || ($formatter === 'auto' && strpos($format, '%') !== false)) { + if (Smarty::$_IS_WINDOWS) { + $_win_from = array( + '%D', + '%h', + '%n', + '%r', + '%R', + '%t', + '%T' + ); + $_win_to = array( + '%m/%d/%y', + '%b', + "\n", + '%I:%M:%S %p', + '%H:%M', + "\t", + '%H:%M:%S' + ); if (strpos($format, '%e') !== false) { $_win_from[] = '%e'; $_win_to[] = sprintf('%\' 2d', date('j', $timestamp)); @@ -57,7 +78,6 @@ function smarty_modifier_date_format($string, $format = null, $default_date = '' } $format = str_replace($_win_from, $_win_to, $format); } - return strftime($format, $timestamp); } else { return date($format, $timestamp); diff --git a/Smarty/libs/plugins/modifier.debug_print_var.php b/Smarty/libs/plugins/modifier.debug_print_var.php index 34f85dc..78397d0 100644 --- a/Smarty/libs/plugins/modifier.debug_print_var.php +++ b/Smarty/libs/plugins/modifier.debug_print_var.php @@ -5,11 +5,10 @@ * @package Smarty * @subpackage Debug */ - /** * Smarty debug_print_var modifier plugin - * Type: modifier
- * Name: debug_print_var
+ * Type: modifier + * Name: debug_print_var * Purpose: formats variable contents for display in the console * * @author Monte Ohrt @@ -26,40 +25,38 @@ function smarty_modifier_debug_print_var($var, $max = 10, $length = 40, $depth = { $_replace = array("\n" => '\n', "\r" => '\r', "\t" => '\t'); switch (gettype($var)) { - case 'array' : + case 'array': $results = 'Array (' . count($var) . ')'; - if ($depth == $max) { + if ($depth === $max) { break; } foreach ($var as $curr_key => $curr_val) { $results .= '
' . str_repeat(' ', $depth * 2) . '' . strtr($curr_key, $_replace) . ' => ' . - smarty_modifier_debug_print_var($curr_val, $max, $length, ++ $depth, $objects); - $depth --; + smarty_modifier_debug_print_var($curr_val, $max, $length, ++$depth, $objects); + $depth--; } break; - - case 'object' : + case 'object': $object_vars = get_object_vars($var); $results = '' . get_class($var) . ' Object (' . count($object_vars) . ')'; if (in_array($var, $objects)) { $results .= ' called recursive'; break; } - if ($depth == $max) { + if ($depth === $max) { break; } $objects[] = $var; foreach ($object_vars as $curr_key => $curr_val) { $results .= '
' . str_repeat(' ', $depth * 2) . ' ->' . strtr($curr_key, $_replace) . - ' = ' . smarty_modifier_debug_print_var($curr_val, $max, $length, ++ $depth, $objects); - $depth --; + ' = ' . smarty_modifier_debug_print_var($curr_val, $max, $length, ++$depth, $objects); + $depth--; } break; - - case 'boolean' : - case 'NULL' : - case 'resource' : + case 'boolean': + case 'NULL': + case 'resource': if (true === $var) { $results = 'true'; } elseif (false === $var) { @@ -67,17 +64,15 @@ function smarty_modifier_debug_print_var($var, $max = 10, $length = 40, $depth = } elseif (null === $var) { $results = 'null'; } else { - $results = htmlspecialchars((string) $var); + $results = htmlspecialchars((string)$var); } $results = '' . $results . ''; break; - - case 'integer' : - case 'float' : - $results = htmlspecialchars((string) $var); + case 'integer': + case 'float': + $results = htmlspecialchars((string)$var); break; - - case 'string' : + case 'string': $results = strtr($var, $_replace); if (Smarty::$_MBSTRING) { if (mb_strlen($var, Smarty::$_CHARSET) > $length) { @@ -88,13 +83,11 @@ function smarty_modifier_debug_print_var($var, $max = 10, $length = 40, $depth = $results = substr($var, 0, $length - 3) . '...'; } } - $results = htmlspecialchars('"' . $results . '"', ENT_QUOTES, Smarty::$_CHARSET); break; - - case 'unknown type' : - default : - $results = strtr((string) $var, $_replace); + 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) . '...'; @@ -104,9 +97,7 @@ function smarty_modifier_debug_print_var($var, $max = 10, $length = 40, $depth = $results = substr($results, 0, $length - 3) . '...'; } } - $results = htmlspecialchars($results, ENT_QUOTES, Smarty::$_CHARSET); } - return $results; } diff --git a/Smarty/libs/plugins/modifier.escape.php b/Smarty/libs/plugins/modifier.escape.php index b9842aa..150901c 100644 --- a/Smarty/libs/plugins/modifier.escape.php +++ b/Smarty/libs/plugins/modifier.escape.php @@ -5,11 +5,10 @@ * @package Smarty * @subpackage PluginsModifier */ - /** * Smarty escape modifier plugin - * Type: modifier
- * Name: escape
+ * Type: modifier + * Name: escape * Purpose: escape string for output * * @link http://www.smarty.net/docs/en/language.modifier.escape @@ -25,14 +24,14 @@ function smarty_modifier_escape($string, $esc_type = 'html', $char_set = null, $double_encode = true) { static $_double_encode = null; + static $is_loaded_1 = false; + static $is_loaded_2 = false; if ($_double_encode === null) { $_double_encode = version_compare(PHP_VERSION, '5.2.3', '>='); } - if (!$char_set) { $char_set = Smarty::$_CHARSET; } - switch ($esc_type) { case 'html': if ($_double_encode) { @@ -46,12 +45,21 @@ function smarty_modifier_escape($string, $esc_type = 'html', $char_set = null, $ // php <5.2.3 - prevent double encoding $string = preg_replace('!&(#?\w+);!', '%%%SMARTY_START%%%\\1%%%SMARTY_END%%%', $string); $string = htmlspecialchars($string, ENT_QUOTES, $char_set); - $string = str_replace(array('%%%SMARTY_START%%%', '%%%SMARTY_END%%%'), array('&', ';'), $string); - + $string = str_replace( + array( + '%%%SMARTY_START%%%', + '%%%SMARTY_END%%%' + ), + array( + '&', + ';' + ), + $string + ); return $string; } } - + // no break case 'htmlall': if (Smarty::$_MBSTRING) { // mb_convert_encoding ignores htmlspecialchars() @@ -67,16 +75,23 @@ function smarty_modifier_escape($string, $esc_type = 'html', $char_set = null, $ $string = preg_replace('!&(#?\w+);!', '%%%SMARTY_START%%%\\1%%%SMARTY_END%%%', $string); $string = htmlspecialchars($string, ENT_QUOTES, $char_set); $string = - str_replace(array('%%%SMARTY_START%%%', '%%%SMARTY_END%%%'), array('&', ';'), $string); - + str_replace( + array( + '%%%SMARTY_START%%%', + '%%%SMARTY_END%%%' + ), + array( + '&', + ';' + ), + $string + ); return $string; } } - // htmlentities() won't convert everything, so use mb_convert_encoding return mb_convert_encoding($string, 'HTML-ENTITIES', $char_set); } - // no MBString fallback if ($_double_encode) { return htmlentities($string, ENT_QUOTES, $char_set, $double_encode); @@ -86,90 +101,134 @@ function smarty_modifier_escape($string, $esc_type = 'html', $char_set = null, $ } else { $string = preg_replace('!&(#?\w+);!', '%%%SMARTY_START%%%\\1%%%SMARTY_END%%%', $string); $string = htmlentities($string, ENT_QUOTES, $char_set); - $string = str_replace(array('%%%SMARTY_START%%%', '%%%SMARTY_END%%%'), array('&', ';'), $string); - + $string = str_replace( + array( + '%%%SMARTY_START%%%', + '%%%SMARTY_END%%%' + ), + array( + '&', + ';' + ), + $string + ); return $string; } } - + // no break case 'url': return rawurlencode($string); - case 'urlpathinfo': return str_replace('%2F', '/', rawurlencode($string)); - case 'quotes': // escape unescaped single quotes return preg_replace("%(? '\\\\', "'" => "\\'", '"' => '\\"', "\r" => '\\r', "\n" => '\\n', - ' '<\/')); - + return strtr( + $string, + array( + '\\' => '\\\\', + "'" => "\\'", + '"' => '\\"', + "\r" => '\\r', + "\n" => '\\n', + ' '<\/' + ) + ); case 'mail': if (Smarty::$_MBSTRING) { - require_once(SMARTY_PLUGINS_DIR . 'shared.mb_str_replace.php'); - - return smarty_mb_str_replace(array('@', '.'), array(' [AT] ', ' [DOT] '), $string); + 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; + } + return smarty_mb_str_replace( + array( + '@', + '.' + ), + array( + ' [AT] ', + ' [DOT] ' + ), + $string + ); } // no MBString fallback - return str_replace(array('@', '.'), array(' [AT] ', ' [DOT] '), $string); - + return str_replace( + array( + '@', + '.' + ), + array( + ' [AT] ', + ' [DOT] ' + ), + $string + ); case 'nonstd': // escape non-standard chars, such as ms document quotes $return = ''; if (Smarty::$_MBSTRING) { - require_once(SMARTY_PLUGINS_DIR . 'shared.mb_unicode.php'); + 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 ($unicode >= 126) { $return .= '&#' . $unicode . ';'; @@ -177,12 +236,10 @@ function smarty_modifier_escape($string, $esc_type = 'html', $char_set = null, $ $return .= chr($unicode); } } - return $return; } - $_length = strlen($string); - for ($_i = 0; $_i < $_length; $_i ++) { + for ($_i = 0; $_i < $_length; $_i++) { $_ord = ord(substr($string, $_i, 1)); // non-standard char, escape it if ($_ord >= 126) { @@ -191,9 +248,7 @@ function smarty_modifier_escape($string, $esc_type = 'html', $char_set = null, $ $return .= substr($string, $_i, 1); } } - return $return; - default: return $string; } diff --git a/Smarty/libs/plugins/modifier.mb_wordwrap.php b/Smarty/libs/plugins/modifier.mb_wordwrap.php new file mode 100644 index 0000000..1cd625b --- /dev/null +++ b/Smarty/libs/plugins/modifier.mb_wordwrap.php @@ -0,0 +1,71 @@ + $width) { + if ($cut) { + $_tokens = preg_split( + '!(.{' . $width . '})!S' . Smarty::$_UTF8_MODIFIER, + $_token, + -1, + PREG_SPLIT_NO_EMPTY + PREG_SPLIT_DELIM_CAPTURE + ); + } + } + foreach ($_tokens as $token) { + $_space = !!preg_match('!^\s$!S' . Smarty::$_UTF8_MODIFIER, $token); + $token_length = mb_strlen($token, Smarty::$_CHARSET); + $length += $token_length; + if ($length > $width) { + // remove space before inserted break + if ($_previous) { + $t = mb_substr($t, 0, -1, Smarty::$_CHARSET); + } + if (!$_space) { + // add the break before the token + if (!empty($t)) { + $t .= $break; + } + $length = $token_length; + } + } elseif ($token === "\n") { + // hard break must reset counters + $length = 0; + } + $_previous = $_space; + // add the token + $t .= $token; + } + } + return $t; +} diff --git a/Smarty/libs/plugins/modifier.regex_replace.php b/Smarty/libs/plugins/modifier.regex_replace.php index 85f41fd..7eb5506 100644 --- a/Smarty/libs/plugins/modifier.regex_replace.php +++ b/Smarty/libs/plugins/modifier.regex_replace.php @@ -5,16 +5,15 @@ * @package Smarty * @subpackage PluginsModifier */ - /** * Smarty regex_replace modifier plugin - * Type: modifier
- * Name: regex_replace
+ * Type: modifier + * Name: regex_replace * Purpose: regular expression search/replace * - * @link http://smarty.php.net/manual/en/language.modifier.regex.replace.php + * @link http://smarty.php.net/manual/en/language.modifier.regex.replace.php * regex_replace (Smarty online manual) - * @author Monte Ohrt + * @author Monte Ohrt * * @param string $string input string * @param string|array $search regular expression(s) to search for @@ -23,7 +22,7 @@ * * @return string */ -function smarty_modifier_regex_replace($string, $search, $replace, $limit = - 1) +function smarty_modifier_regex_replace($string, $search, $replace, $limit = -1) { if (is_array($search)) { foreach ($search as $idx => $s) { @@ -32,7 +31,6 @@ function smarty_modifier_regex_replace($string, $search, $replace, $limit = - 1) } else { $search = _smarty_regex_replace_check($search); } - return preg_replace($search, $replace, $string, $limit); } @@ -51,8 +49,7 @@ function _smarty_regex_replace_check($search) } // remove eval-modifier from $search if (preg_match('!([a-zA-Z\s]+)$!s', $search, $match) && (strpos($match[ 1 ], 'e') !== false)) { - $search = substr($search, 0, - strlen($match[ 1 ])) . preg_replace('![e\s]+!', '', $match[ 1 ]); + $search = substr($search, 0, -strlen($match[ 1 ])) . preg_replace('![e\s]+!', '', $match[ 1 ]); } - return $search; } diff --git a/Smarty/libs/plugins/modifier.replace.php b/Smarty/libs/plugins/modifier.replace.php index aa5e857..a98f5a4 100644 --- a/Smarty/libs/plugins/modifier.replace.php +++ b/Smarty/libs/plugins/modifier.replace.php @@ -5,11 +5,10 @@ * @package Smarty * @subpackage PluginsModifier */ - /** * Smarty replace modifier plugin - * Type: modifier
- * Name: replace
+ * Type: modifier + * Name: replace * Purpose: simple search/replace * * @link http://smarty.php.net/manual/en/language.modifier.replace.php replace (Smarty online manual) @@ -24,11 +23,15 @@ */ function smarty_modifier_replace($string, $search, $replace) { + static $is_loaded = false; if (Smarty::$_MBSTRING) { - require_once(SMARTY_PLUGINS_DIR . 'shared.mb_str_replace.php'); - + if (!$is_loaded) { + if (!is_callable('smarty_mb_str_replace')) { + include_once SMARTY_PLUGINS_DIR . 'shared.mb_str_replace.php'; + } + $is_loaded = true; + } return smarty_mb_str_replace($search, $replace, $string); } - return str_replace($search, $replace, $string); } diff --git a/Smarty/libs/plugins/modifier.spacify.php b/Smarty/libs/plugins/modifier.spacify.php index e5c41ad..98efd4b 100644 --- a/Smarty/libs/plugins/modifier.spacify.php +++ b/Smarty/libs/plugins/modifier.spacify.php @@ -5,11 +5,10 @@ * @package Smarty * @subpackage PluginsModifier */ - /** * Smarty spacify modifier plugin - * Type: modifier
- * Name: spacify
+ * Type: modifier + * Name: spacify * Purpose: add spaces between characters in a string * * @link http://smarty.php.net/manual/en/language.modifier.spacify.php spacify (Smarty online manual) @@ -23,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::$_UTF8_MODIFIER, $string, -1, PREG_SPLIT_NO_EMPTY)); } diff --git a/Smarty/libs/plugins/modifier.truncate.php b/Smarty/libs/plugins/modifier.truncate.php index 6fe8442..bb881bf 100644 --- a/Smarty/libs/plugins/modifier.truncate.php +++ b/Smarty/libs/plugins/modifier.truncate.php @@ -5,11 +5,10 @@ * @package Smarty * @subpackage PluginsModifier */ - /** * Smarty truncate modifier plugin - * Type: modifier
- * Name: truncate
+ * Type: modifier + * Name: truncate * Purpose: Truncate a string to a certain length if necessary, * optionally splitting in the middle of a word, and * appending the $etc string or inserting $etc into the middle. @@ -27,28 +26,27 @@ */ function smarty_modifier_truncate($string, $length = 80, $etc = '...', $break_words = false, $middle = false) { - if ($length == 0) { + if ($length === 0) { return ''; } - if (Smarty::$_MBSTRING) { if (mb_strlen($string, Smarty::$_CHARSET) > $length) { $length -= min($length, mb_strlen($etc, Smarty::$_CHARSET)); if (!$break_words && !$middle) { - $string = preg_replace('/\s+?(\S+)?$/' . Smarty::$_UTF8_MODIFIER, '', - mb_substr($string, 0, $length + 1, Smarty::$_CHARSET)); + $string = preg_replace( + '/\s+?(\S+)?$/' . Smarty::$_UTF8_MODIFIER, + '', + mb_substr($string, 0, $length + 1, Smarty::$_CHARSET) + ); } if (!$middle) { return mb_substr($string, 0, $length, Smarty::$_CHARSET) . $etc; } - return mb_substr($string, 0, $length / 2, Smarty::$_CHARSET) . $etc . - mb_substr($string, - $length / 2, $length, Smarty::$_CHARSET); + mb_substr($string, -$length / 2, $length, Smarty::$_CHARSET); } - return $string; } - // no MBString fallback if (isset($string[ $length ])) { $length -= min($length, strlen($etc)); @@ -58,9 +56,7 @@ function smarty_modifier_truncate($string, $length = 80, $etc = '...', $break_wo if (!$middle) { return substr($string, 0, $length) . $etc; } - - return substr($string, 0, $length / 2) . $etc . substr($string, - $length / 2); + return substr($string, 0, $length / 2) . $etc . substr($string, -$length / 2); } - return $string; } diff --git a/Smarty/libs/plugins/modifiercompiler.cat.php b/Smarty/libs/plugins/modifiercompiler.cat.php index db9d81f..21d0e66 100644 --- a/Smarty/libs/plugins/modifiercompiler.cat.php +++ b/Smarty/libs/plugins/modifiercompiler.cat.php @@ -5,19 +5,18 @@ * @package Smarty * @subpackage PluginsModifierCompiler */ - /** * Smarty cat modifier plugin - * Type: modifier
- * Name: cat
- * Date: Feb 24, 2003
- * Purpose: catenate a value to a variable
- * Input: string to catenate
+ * Type: modifier + * Name: cat + * Date: Feb 24, 2003 + * Purpose: catenate a value to a variable + * Input: string to catenate * Example: {$var|cat:"foo"} * - * @link http://smarty.php.net/manual/en/language.modifier.cat.php cat + * @link http://smarty.php.net/manual/en/language.modifier.cat.php cat * (Smarty online manual) - * @author Uwe Tews + * @author Uwe Tews * * @param array $params parameters * diff --git a/Smarty/libs/plugins/modifiercompiler.count_characters.php b/Smarty/libs/plugins/modifiercompiler.count_characters.php index 0a3ce25..6c44278 100644 --- a/Smarty/libs/plugins/modifiercompiler.count_characters.php +++ b/Smarty/libs/plugins/modifiercompiler.count_characters.php @@ -5,14 +5,14 @@ * @package Smarty * @subpackage PluginsModifierCompiler */ - /** * Smarty count_characters modifier plugin - * Type: modifier
- * Name: count_characteres
+ * Type: modifier + * Name: count_characters * Purpose: count the number of characters in a text * - * @link http://www.smarty.net/manual/en/language.modifier.count.characters.php count_characters (Smarty online manual) + * @link http://www.smarty.net/manual/en/language.modifier.count.characters.php count_characters (Smarty online + * manual) * @author Uwe Tews * * @param array $params parameters @@ -21,7 +21,7 @@ */ function smarty_modifiercompiler_count_characters($params) { - if (!isset($params[ 1 ]) || $params[ 1 ] != 'true') { + if (!isset($params[ 1 ]) || $params[ 1 ] !== 'true') { return 'preg_match_all(\'/[^\s]/' . Smarty::$_UTF8_MODIFIER . '\',' . $params[ 0 ] . ', $tmp)'; } if (Smarty::$_MBSTRING) { diff --git a/Smarty/libs/plugins/modifiercompiler.count_paragraphs.php b/Smarty/libs/plugins/modifiercompiler.count_paragraphs.php index f7f4477..e214a56 100644 --- a/Smarty/libs/plugins/modifiercompiler.count_paragraphs.php +++ b/Smarty/libs/plugins/modifiercompiler.count_paragraphs.php @@ -5,16 +5,15 @@ * @package Smarty * @subpackage PluginsModifierCompiler */ - /** * Smarty count_paragraphs modifier plugin - * Type: modifier
- * Name: count_paragraphs
+ * Type: modifier + * Name: count_paragraphs * Purpose: count the number of paragraphs in a text * - * @link http://www.smarty.net/manual/en/language.modifier.count.paragraphs.php + * @link http://www.smarty.net/manual/en/language.modifier.count.paragraphs.php * count_paragraphs (Smarty online manual) - * @author Uwe Tews + * @author Uwe Tews * * @param array $params parameters * diff --git a/Smarty/libs/plugins/modifiercompiler.count_sentences.php b/Smarty/libs/plugins/modifiercompiler.count_sentences.php index 2003292..0277456 100644 --- a/Smarty/libs/plugins/modifiercompiler.count_sentences.php +++ b/Smarty/libs/plugins/modifiercompiler.count_sentences.php @@ -5,16 +5,15 @@ * @package Smarty * @subpackage PluginsModifierCompiler */ - /** * Smarty count_sentences modifier plugin - * Type: modifier
+ * Type: modifier * Name: count_sentences * Purpose: count the number of sentences in a text * - * @link http://www.smarty.net/manual/en/language.modifier.count.paragraphs.php + * @link http://www.smarty.net/manual/en/language.modifier.count.paragraphs.php * count_sentences (Smarty online manual) - * @author Uwe Tews + * @author Uwe Tews * * @param array $params parameters * diff --git a/Smarty/libs/plugins/modifiercompiler.count_words.php b/Smarty/libs/plugins/modifiercompiler.count_words.php index f20a197..6d889da 100644 --- a/Smarty/libs/plugins/modifiercompiler.count_words.php +++ b/Smarty/libs/plugins/modifiercompiler.count_words.php @@ -5,11 +5,10 @@ * @package Smarty * @subpackage PluginsModifierCompiler */ - /** * Smarty count_words modifier plugin - * Type: modifier
- * Name: count_words
+ * Type: modifier + * Name: count_words * Purpose: count the number of words in a text * * @link http://www.smarty.net/manual/en/language.modifier.count.words.php count_words (Smarty online manual) diff --git a/Smarty/libs/plugins/modifiercompiler.default.php b/Smarty/libs/plugins/modifiercompiler.default.php index 2c4c00a..ae886c4 100644 --- a/Smarty/libs/plugins/modifiercompiler.default.php +++ b/Smarty/libs/plugins/modifiercompiler.default.php @@ -5,11 +5,10 @@ * @package Smarty * @subpackage PluginsModifierCompiler */ - /** * Smarty default modifier plugin - * Type: modifier
- * Name: default
+ * Type: modifier + * Name: default * Purpose: designate default value for empty variables * * @link http://www.smarty.net/manual/en/language.modifier.default.php default (Smarty online manual) @@ -25,11 +24,9 @@ function smarty_modifiercompiler_default($params) if (!isset($params[ 1 ])) { $params[ 1 ] = "''"; } - array_shift($params); foreach ($params as $param) { $output = '(($tmp = @' . $output . ')===null||$tmp===\'\' ? ' . $param . ' : $tmp)'; } - return $output; } diff --git a/Smarty/libs/plugins/modifiercompiler.escape.php b/Smarty/libs/plugins/modifiercompiler.escape.php index 4816106..e0763ad 100644 --- a/Smarty/libs/plugins/modifiercompiler.escape.php +++ b/Smarty/libs/plugins/modifiercompiler.escape.php @@ -5,42 +5,43 @@ * @package Smarty * @subpackage PluginsModifierCompiler */ - -/** - * @ignore - */ -require_once(SMARTY_PLUGINS_DIR . 'shared.literal_compiler_param.php'); - /** * Smarty escape modifier plugin - * Type: modifier
- * Name: escape
+ * Type: modifier + * Name: escape * Purpose: escape string for output * * @link http://www.smarty.net/docsv2/en/language.modifier.escape count_characters (Smarty online manual) * @author Rodney Rehm * - * @param array $params parameters - * @param $compiler + * @param array $params parameters + * @param Smarty_Internal_TemplateCompilerBase $compiler * * @return string with compiled code + * @throws \SmartyException */ -function smarty_modifiercompiler_escape($params, $compiler) +function smarty_modifiercompiler_escape($params, Smarty_Internal_TemplateCompilerBase $compiler) { static $_double_encode = null; + static $is_loaded = false; + $compiler->template->_checkPlugins( + array( + array( + 'function' => 'smarty_literal_compiler_param', + 'file' => SMARTY_PLUGINS_DIR . 'shared.literal_compiler_param.php' + ) + ) + ); if ($_double_encode === null) { $_double_encode = version_compare(PHP_VERSION, '5.2.3', '>='); } - try { $esc_type = smarty_literal_compiler_param($params, 1, 'html'); $char_set = smarty_literal_compiler_param($params, 2, Smarty::$_CHARSET); $double_encode = smarty_literal_compiler_param($params, 3, true); - if (!$char_set) { $char_set = Smarty::$_CHARSET; } - switch ($esc_type) { case 'html': if ($_double_encode) { @@ -51,7 +52,7 @@ function smarty_modifiercompiler_escape($params, $compiler) } else { // fall back to modifier.escape.php } - + // no break case 'htmlall': if (Smarty::$_MBSTRING) { if ($_double_encode) { @@ -67,7 +68,6 @@ function smarty_modifiercompiler_escape($params, $compiler) // fall back to modifier.escape.php } } - // no MBString fallback if ($_double_encode) { // php >=5.2.3 - go native @@ -79,39 +79,34 @@ function smarty_modifiercompiler_escape($params, $compiler) } else { // fall back to modifier.escape.php } - + // no break case 'url': return 'rawurlencode(' . $params[ 0 ] . ')'; - case 'urlpathinfo': return 'str_replace("%2F", "/", rawurlencode(' . $params[ 0 ] . '))'; - case 'quotes': // escape unescaped single quotes return 'preg_replace("%(? "\\\\\\\\", "\'" => "\\\\\'", "\"" => "\\\\\"", "\\r" => "\\\\r", "\\n" => "\\\n", " "<\/" ))'; } - } - catch (SmartyException $e) { + } 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->parent_compiler->template->compiled->required_plugins[ 'nocache' ][ 'escape' ][ 'modifier' ][ 'file' ] = + $compiler->required_plugins[ 'nocache' ][ 'escape' ][ 'modifier' ][ 'file' ] = SMARTY_PLUGINS_DIR . 'modifier.escape.php'; - $compiler->parent_compiler->template->compiled->required_plugins[ 'nocache' ][ 'escape' ][ 'modifier' ][ 'function' ] = + $compiler->required_plugins[ 'nocache' ][ 'escape' ][ 'modifier' ][ 'function' ] = 'smarty_modifier_escape'; } else { - $compiler->parent_compiler->template->compiled->required_plugins[ 'compiled' ][ 'escape' ][ 'modifier' ][ 'file' ] = + $compiler->required_plugins[ 'compiled' ][ 'escape' ][ 'modifier' ][ 'file' ] = SMARTY_PLUGINS_DIR . 'modifier.escape.php'; - $compiler->parent_compiler->template->compiled->required_plugins[ 'compiled' ][ 'escape' ][ 'modifier' ][ 'function' ] = + $compiler->required_plugins[ 'compiled' ][ 'escape' ][ 'modifier' ][ 'function' ] = 'smarty_modifier_escape'; } - return 'smarty_modifier_escape(' . join(', ', $params) . ')'; } diff --git a/Smarty/libs/plugins/modifiercompiler.from_charset.php b/Smarty/libs/plugins/modifiercompiler.from_charset.php index e25a957..acce778 100644 --- a/Smarty/libs/plugins/modifiercompiler.from_charset.php +++ b/Smarty/libs/plugins/modifiercompiler.from_charset.php @@ -5,11 +5,10 @@ * @package Smarty * @subpackage PluginsModifierCompiler */ - /** * Smarty from_charset modifier plugin - * Type: modifier
- * Name: from_charset
+ * Type: modifier + * Name: from_charset * Purpose: convert character encoding from $charset to internal encoding * * @author Rodney Rehm @@ -24,10 +23,8 @@ function smarty_modifiercompiler_from_charset($params) // 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 ] . ')'; } diff --git a/Smarty/libs/plugins/modifiercompiler.indent.php b/Smarty/libs/plugins/modifiercompiler.indent.php index 851f184..2088ad6 100644 --- a/Smarty/libs/plugins/modifiercompiler.indent.php +++ b/Smarty/libs/plugins/modifiercompiler.indent.php @@ -5,11 +5,10 @@ * @package Smarty * @subpackage PluginsModifierCompiler */ - /** * Smarty indent modifier plugin - * Type: modifier
- * Name: indent
+ * Type: modifier + * Name: indent * Purpose: indent lines of text * * @link http://www.smarty.net/manual/en/language.modifier.indent.php indent (Smarty online manual) @@ -19,7 +18,6 @@ * * @return string with compiled code */ - function smarty_modifiercompiler_indent($params) { if (!isset($params[ 1 ])) { @@ -28,6 +26,5 @@ function smarty_modifiercompiler_indent($params) if (!isset($params[ 2 ])) { $params[ 2 ] = "' '"; } - return 'preg_replace(\'!^!m\',str_repeat(' . $params[ 2 ] . ',' . $params[ 1 ] . '),' . $params[ 0 ] . ')'; } diff --git a/Smarty/libs/plugins/modifiercompiler.lower.php b/Smarty/libs/plugins/modifiercompiler.lower.php index a335eff..0d899a0 100644 --- a/Smarty/libs/plugins/modifiercompiler.lower.php +++ b/Smarty/libs/plugins/modifiercompiler.lower.php @@ -5,11 +5,10 @@ * @package Smarty * @subpackage PluginsModifierCompiler */ - /** * Smarty lower modifier plugin - * Type: modifier
- * Name: lower
+ * Type: modifier + * Name: lower * Purpose: convert string to lowercase * * @link http://www.smarty.net/manual/en/language.modifier.lower.php lower (Smarty online manual) @@ -20,7 +19,6 @@ * * @return string with compiled code */ - function smarty_modifiercompiler_lower($params) { if (Smarty::$_MBSTRING) { diff --git a/Smarty/libs/plugins/modifiercompiler.noprint.php b/Smarty/libs/plugins/modifiercompiler.noprint.php index 4906908..1275190 100644 --- a/Smarty/libs/plugins/modifiercompiler.noprint.php +++ b/Smarty/libs/plugins/modifiercompiler.noprint.php @@ -5,14 +5,13 @@ * @package Smarty * @subpackage PluginsModifierCompiler */ - /** * Smarty noprint modifier plugin - * Type: modifier
- * Name: noprint
+ * Type: modifier + * Name: noprint * Purpose: return an empty string * - * @author Uwe Tews + * @author Uwe Tews * @return string with compiled code */ function smarty_modifiercompiler_noprint() diff --git a/Smarty/libs/plugins/modifiercompiler.string_format.php b/Smarty/libs/plugins/modifiercompiler.string_format.php index bcf9883..6630943 100644 --- a/Smarty/libs/plugins/modifiercompiler.string_format.php +++ b/Smarty/libs/plugins/modifiercompiler.string_format.php @@ -5,11 +5,10 @@ * @package Smarty * @subpackage PluginsModifierCompiler */ - /** * Smarty string_format modifier plugin - * Type: modifier
- * Name: string_format
+ * Type: modifier + * Name: string_format * Purpose: format strings via sprintf * * @link http://www.smarty.net/manual/en/language.modifier.string.format.php string_format (Smarty online manual) diff --git a/Smarty/libs/plugins/modifiercompiler.strip.php b/Smarty/libs/plugins/modifiercompiler.strip.php index 8173eed..04ea332 100644 --- a/Smarty/libs/plugins/modifiercompiler.strip.php +++ b/Smarty/libs/plugins/modifiercompiler.strip.php @@ -5,14 +5,13 @@ * @package Smarty * @subpackage PluginsModifierCompiler */ - /** * Smarty strip modifier plugin - * Type: modifier
- * Name: strip
+ * Type: modifier + * Name: strip * Purpose: Replace all repeated spaces, newlines, tabs - * with a single space or supplied replacement string.
- * Example: {$var|strip} {$var|strip:" "}
+ * with a single space or supplied replacement string. + * Example: {$var|strip} {$var|strip:" "} * Date: September 25th, 2002 * * @link http://www.smarty.net/manual/en/language.modifier.strip.php strip (Smarty online manual) @@ -22,12 +21,10 @@ * * @return string with compiled code */ - function smarty_modifiercompiler_strip($params) { if (!isset($params[ 1 ])) { $params[ 1 ] = "' '"; } - return "preg_replace('!\s+!" . Smarty::$_UTF8_MODIFIER . "', {$params[1]},{$params[0]})"; } diff --git a/Smarty/libs/plugins/modifiercompiler.strip_tags.php b/Smarty/libs/plugins/modifiercompiler.strip_tags.php index e56bf93..1bca1a2 100644 --- a/Smarty/libs/plugins/modifiercompiler.strip_tags.php +++ b/Smarty/libs/plugins/modifiercompiler.strip_tags.php @@ -5,11 +5,10 @@ * @package Smarty * @subpackage PluginsModifierCompiler */ - /** * Smarty strip_tags modifier plugin - * Type: modifier
- * Name: strip_tags
+ * Type: modifier + * Name: strip_tags * Purpose: strip html tags from text * * @link http://www.smarty.net/docs/en/language.modifier.strip.tags.tpl strip_tags (Smarty online manual) @@ -21,7 +20,7 @@ */ function smarty_modifiercompiler_strip_tags($params) { - if (!isset($params[ 1 ]) || $params[ 1 ] === true || trim($params[ 1 ], '"') == 'true') { + if (!isset($params[ 1 ]) || $params[ 1 ] === true || trim($params[ 1 ], '"') === 'true') { return "preg_replace('!<[^>]*?>!', ' ', {$params[0]})"; } else { return 'strip_tags(' . $params[ 0 ] . ')'; diff --git a/Smarty/libs/plugins/modifiercompiler.to_charset.php b/Smarty/libs/plugins/modifiercompiler.to_charset.php index fea8d82..d652eab 100644 --- a/Smarty/libs/plugins/modifiercompiler.to_charset.php +++ b/Smarty/libs/plugins/modifiercompiler.to_charset.php @@ -5,11 +5,10 @@ * @package Smarty * @subpackage PluginsModifierCompiler */ - /** * Smarty to_charset modifier plugin - * Type: modifier
- * Name: to_charset
+ * Type: modifier + * Name: to_charset * Purpose: convert character encoding from internal encoding to $charset * * @author Rodney Rehm @@ -24,10 +23,8 @@ function smarty_modifiercompiler_to_charset($params) // 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) . '")'; } diff --git a/Smarty/libs/plugins/modifiercompiler.unescape.php b/Smarty/libs/plugins/modifiercompiler.unescape.php index a3409bc..05beb81 100644 --- a/Smarty/libs/plugins/modifiercompiler.unescape.php +++ b/Smarty/libs/plugins/modifiercompiler.unescape.php @@ -5,11 +5,10 @@ * @package Smarty * @subpackage PluginsModifierCompiler */ - /** * Smarty unescape modifier plugin - * Type: modifier
- * Name: unescape
+ * Type: modifier + * Name: unescape * Purpose: unescape html entities * * @author Rodney Rehm @@ -26,24 +25,19 @@ function smarty_modifiercompiler_unescape($params) if (!isset($params[ 2 ])) { $params[ 2 ] = '\'' . addslashes(Smarty::$_CHARSET) . '\''; } else { - $params[ 2 ] = "'" . $params[ 2 ] . "'"; + $params[ 2 ] = "'{$params[ 2 ]}'"; } - switch (trim($params[ 1 ], '"\'')) { case 'entity': case 'htmlall': if (Smarty::$_MBSTRING) { return 'mb_convert_encoding(' . $params[ 0 ] . ', ' . $params[ 2 ] . ', \'HTML-ENTITIES\')'; } - return 'html_entity_decode(' . $params[ 0 ] . ', ENT_NOQUOTES, ' . $params[ 2 ] . ')'; - case 'html': return 'htmlspecialchars_decode(' . $params[ 0 ] . ', ENT_QUOTES)'; - case 'url': return 'rawurldecode(' . $params[ 0 ] . ')'; - default: return $params[ 0 ]; } diff --git a/Smarty/libs/plugins/modifiercompiler.upper.php b/Smarty/libs/plugins/modifiercompiler.upper.php index a083c4f..ea4e95b 100644 --- a/Smarty/libs/plugins/modifiercompiler.upper.php +++ b/Smarty/libs/plugins/modifiercompiler.upper.php @@ -5,11 +5,10 @@ * @package Smarty * @subpackage PluginsModifierCompiler */ - /** * Smarty upper modifier plugin - * Type: modifier
- * Name: lower
+ * Type: modifier + * Name: lower * Purpose: convert string to uppercase * * @link http://smarty.php.net/manual/en/language.modifier.upper.php lower (Smarty online manual) diff --git a/Smarty/libs/plugins/modifiercompiler.wordwrap.php b/Smarty/libs/plugins/modifiercompiler.wordwrap.php index 9184973..8565f14 100644 --- a/Smarty/libs/plugins/modifiercompiler.wordwrap.php +++ b/Smarty/libs/plugins/modifiercompiler.wordwrap.php @@ -5,22 +5,22 @@ * @package Smarty * @subpackage PluginsModifierCompiler */ - /** * Smarty wordwrap modifier plugin - * Type: modifier
- * Name: wordwrap
+ * Type: modifier + * Name: wordwrap * Purpose: wrap a string of text at a given length * * @link http://smarty.php.net/manual/en/language.modifier.wordwrap.php wordwrap (Smarty online manual) * @author Uwe Tews * - * @param array $params parameters - * @param $compiler + * @param array $params parameters + * @param \Smarty_Internal_TemplateCompilerBase $compiler * * @return string with compiled code + * @throws \SmartyException */ -function smarty_modifiercompiler_wordwrap($params, $compiler) +function smarty_modifiercompiler_wordwrap($params, Smarty_Internal_TemplateCompilerBase $compiler) { if (!isset($params[ 1 ])) { $params[ 1 ] = 80; @@ -33,19 +33,7 @@ function smarty_modifiercompiler_wordwrap($params, $compiler) } $function = 'wordwrap'; if (Smarty::$_MBSTRING) { - if ($compiler->template->caching && ($compiler->tag_nocache | $compiler->nocache)) { - $compiler->parent_compiler->template->compiled->required_plugins[ 'nocache' ][ 'wordwrap' ][ 'modifier' ][ 'file' ] = - SMARTY_PLUGINS_DIR . 'shared.mb_wordwrap.php'; - $compiler->template->required_plugins[ 'nocache' ][ 'wordwrap' ][ 'modifier' ][ 'function' ] = - 'smarty_mb_wordwrap'; - } else { - $compiler->parent_compiler->template->compiled->required_plugins[ 'compiled' ][ 'wordwrap' ][ 'modifier' ][ 'file' ] = - SMARTY_PLUGINS_DIR . 'shared.mb_wordwrap.php'; - $compiler->parent_compiler->template->compiled->required_plugins[ 'compiled' ][ 'wordwrap' ][ 'modifier' ][ 'function' ] = - 'smarty_mb_wordwrap'; - } - $function = 'smarty_mb_wordwrap'; + $function = $compiler->getPlugin('mb_wordwrap', 'modifier'); } - return $function . '(' . $params[ 0 ] . ',' . $params[ 1 ] . ',' . $params[ 2 ] . ',' . $params[ 3 ] . ')'; } diff --git a/Smarty/libs/plugins/outputfilter.trimwhitespace.php b/Smarty/libs/plugins/outputfilter.trimwhitespace.php index 1a67123..7e4503a 100644 --- a/Smarty/libs/plugins/outputfilter.trimwhitespace.php +++ b/Smarty/libs/plugins/outputfilter.trimwhitespace.php @@ -5,85 +5,85 @@ * @package Smarty * @subpackage PluginsFilter */ - /** * Smarty trimwhitespace outputfilter plugin * Trim unnecessary whitespace from HTML markup. * - * @author Rodney Rehm + * @author Rodney Rehm * * @param string $source input string * * @return string filtered output - * @todo substr_replace() is not overloaded by mbstring.func_overload - so this function might fail! + * @todo substr_replace() is not overloaded by mbstring.func_overload - so this function might fail! */ function smarty_outputfilter_trimwhitespace($source) { $store = array(); $_store = 0; $_offset = 0; - // Unify Line-Breaks to \n - $source = preg_replace("/\015\012|\015|\012/", "\n", $source); - + $source = preg_replace('/\015\012|\015|\012/', "\n", $source); // capture Internet Explorer and KnockoutJS Conditional Comments - if (preg_match_all('##is', $source, $matches, - PREG_OFFSET_CAPTURE | PREG_SET_ORDER)) { + if (preg_match_all( + '##is', + $source, + $matches, + PREG_OFFSET_CAPTURE | PREG_SET_ORDER + ) + ) { foreach ($matches as $match) { $store[] = $match[ 0 ][ 0 ]; $_length = strlen($match[ 0 ][ 0 ]); $replace = '@!@SMARTY:' . $_store . ':SMARTY@!@'; $source = substr_replace($source, $replace, $match[ 0 ][ 1 ] - $_offset, $_length); - $_offset += $_length - strlen($replace); - $_store ++; + $_store++; } } - // Strip all HTML-Comments // yes, even the ones in