From b19d6137fb93f6c18c7ac0045413d98a112e7edf Mon Sep 17 00:00:00 2001 From: Ian Date: Tue, 16 Jun 2015 12:28:49 +0200 Subject: [PATCH] Smarty bugfix releases, since last upgrade, to 3.1.25 Will now compile vastly better! Please read change_log.txt and NEW_FEATURES.txt We may want to use some of these new features in 2.1, which briefly are about: Namespace support within templates, Security, Compiled Templates, Debugging --- .../Smarty/INHERITANCE_RELEASE_NOTES.txt | 4 +- bundled-libs/Smarty/NEW_FEATURES.txt | 86 + bundled-libs/Smarty/README | 2 +- bundled-libs/Smarty/README.md | 52 + bundled-libs/Smarty/change_log.txt | 233 +- bundled-libs/Smarty/libs/Autoloader.php | 158 + bundled-libs/Smarty/libs/Smarty.class.php | 846 +-- bundled-libs/Smarty/libs/SmartyBC.class.php | 27 +- bundled-libs/Smarty/libs/debug.tpl | 57 +- .../Smarty/libs/plugins/cacheresource.apc.php | 61 - .../libs/plugins/cacheresource.memcache.php | 91 - .../libs/plugins/modifier.date_format.php | 2 +- .../libs/plugins/modifier.debug_print_var.php | 26 +- .../plugins/outputfilter.trimwhitespace.php | 4 +- .../libs/sysplugins/smarty_cacheresource.php | 225 +- .../smarty_cacheresource_custom.php | 52 +- .../smarty_cacheresource_keyvaluestore.php | 35 +- .../libs/sysplugins/smarty_config_source.php | 94 - .../Smarty/libs/sysplugins/smarty_data.php | 66 + .../smarty_internal_cacheresource_file.php | 45 +- .../smarty_internal_compile_assign.php | 6 +- .../smarty_internal_compile_block.php | 23 +- .../smarty_internal_compile_call.php | 52 +- .../smarty_internal_compile_config_load.php | 3 +- .../smarty_internal_compile_for.php | 47 +- .../smarty_internal_compile_foreach.php | 155 +- .../smarty_internal_compile_function.php | 216 +- .../sysplugins/smarty_internal_compile_if.php | 29 +- .../smarty_internal_compile_include.php | 217 +- .../smarty_internal_compile_insert.php | 20 +- .../smarty_internal_compile_nocache.php | 13 +- .../smarty_internal_compile_private_php.php | 197 + ...ernal_compile_private_special_variable.php | 138 +- .../smarty_internal_compile_while.php | 9 +- .../sysplugins/smarty_internal_config.php | 306 - .../smarty_internal_config_file_compiler.php | 75 +- .../smarty_internal_configfilelexer.php | 399 +- .../smarty_internal_configfileparser.php | 704 ++- .../libs/sysplugins/smarty_internal_data.php | 260 +- .../libs/sysplugins/smarty_internal_debug.php | 434 +- .../smarty_internal_extension_codeframe.php | 127 + .../smarty_internal_extension_config.php | 160 + ...ernal_extension_defaulttemplatehandler.php | 85 + .../smarty_internal_function_call_handler.php | 65 +- .../sysplugins/smarty_internal_parsetree.php | 318 +- .../smarty_internal_parsetree_code.php | 42 + .../smarty_internal_parsetree_dq.php | 86 + .../smarty_internal_parsetree_dqcontent.php | 42 + .../smarty_internal_parsetree_tag.php | 66 + .../smarty_internal_parsetree_template.php | 98 + .../smarty_internal_parsetree_text.php | 40 + .../smarty_internal_resource_eval.php | 6 +- .../smarty_internal_resource_extends.php | 2 +- .../smarty_internal_resource_file.php | 152 +- .../smarty_internal_resource_php.php | 59 +- .../smarty_internal_resource_registered.php | 2 +- .../smarty_internal_resource_stream.php | 4 +- .../smarty_internal_resource_string.php | 6 +- ...smarty_internal_smartytemplatecompiler.php | 16 +- .../sysplugins/smarty_internal_template.php | 762 ++- .../smarty_internal_templatebase.php | 613 +- .../smarty_internal_templatecompilerbase.php | 331 +- .../smarty_internal_templatelexer.php | 1322 ++--- .../smarty_internal_templateparser.php | 5139 +++++------------ .../smarty_internal_testinstall.php | 571 ++ .../sysplugins/smarty_internal_utility.php | 539 +- .../sysplugins/smarty_internal_write_file.php | 12 +- .../libs/sysplugins/smarty_resource.php | 732 +-- .../sysplugins/smarty_resource_custom.php | 2 +- .../sysplugins/smarty_resource_recompiled.php | 7 + .../sysplugins/smarty_resource_uncompiled.php | 31 + .../libs/sysplugins/smarty_security.php | 170 +- .../sysplugins/smarty_template_cached.php | 403 ++ .../sysplugins/smarty_template_compiled.php | 288 + .../sysplugins/smarty_template_config.php | 118 + .../sysplugins/smarty_template_source.php | 285 + .../sysplugins/smarty_undefined_variable.php | 37 + .../libs/sysplugins/smarty_variable.php | 55 + .../sysplugins/smartycompilerexception.php | 39 + .../libs/sysplugins/smartyexception.php | 15 + 80 files changed, 8956 insertions(+), 9360 deletions(-) create mode 100644 bundled-libs/Smarty/NEW_FEATURES.txt create mode 100644 bundled-libs/Smarty/README.md create mode 100644 bundled-libs/Smarty/libs/Autoloader.php delete mode 100644 bundled-libs/Smarty/libs/plugins/cacheresource.apc.php delete mode 100644 bundled-libs/Smarty/libs/plugins/cacheresource.memcache.php delete mode 100644 bundled-libs/Smarty/libs/sysplugins/smarty_config_source.php create mode 100644 bundled-libs/Smarty/libs/sysplugins/smarty_data.php create mode 100644 bundled-libs/Smarty/libs/sysplugins/smarty_internal_compile_private_php.php delete mode 100644 bundled-libs/Smarty/libs/sysplugins/smarty_internal_config.php create mode 100644 bundled-libs/Smarty/libs/sysplugins/smarty_internal_extension_codeframe.php create mode 100644 bundled-libs/Smarty/libs/sysplugins/smarty_internal_extension_config.php create mode 100644 bundled-libs/Smarty/libs/sysplugins/smarty_internal_extension_defaulttemplatehandler.php create mode 100644 bundled-libs/Smarty/libs/sysplugins/smarty_internal_parsetree_code.php create mode 100644 bundled-libs/Smarty/libs/sysplugins/smarty_internal_parsetree_dq.php create mode 100644 bundled-libs/Smarty/libs/sysplugins/smarty_internal_parsetree_dqcontent.php create mode 100644 bundled-libs/Smarty/libs/sysplugins/smarty_internal_parsetree_tag.php create mode 100644 bundled-libs/Smarty/libs/sysplugins/smarty_internal_parsetree_template.php create mode 100644 bundled-libs/Smarty/libs/sysplugins/smarty_internal_parsetree_text.php create mode 100644 bundled-libs/Smarty/libs/sysplugins/smarty_internal_testinstall.php create mode 100644 bundled-libs/Smarty/libs/sysplugins/smarty_template_cached.php create mode 100644 bundled-libs/Smarty/libs/sysplugins/smarty_template_compiled.php create mode 100644 bundled-libs/Smarty/libs/sysplugins/smarty_template_config.php create mode 100644 bundled-libs/Smarty/libs/sysplugins/smarty_template_source.php create mode 100644 bundled-libs/Smarty/libs/sysplugins/smarty_undefined_variable.php create mode 100644 bundled-libs/Smarty/libs/sysplugins/smarty_variable.php create mode 100644 bundled-libs/Smarty/libs/sysplugins/smartycompilerexception.php create mode 100644 bundled-libs/Smarty/libs/sysplugins/smartyexception.php diff --git a/bundled-libs/Smarty/INHERITANCE_RELEASE_NOTES.txt b/bundled-libs/Smarty/INHERITANCE_RELEASE_NOTES.txt index 4a351fa5..a7d285f0 100644 --- a/bundled-libs/Smarty/INHERITANCE_RELEASE_NOTES.txt +++ b/bundled-libs/Smarty/INHERITANCE_RELEASE_NOTES.txt @@ -23,9 +23,9 @@ If $smarty->inheritance_merge_compiled_includes = false; {include} subtemplate w 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 you the variable in a compile_id $smarty->compile_id = $foo; +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 = $foo; + 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/bundled-libs/Smarty/NEW_FEATURES.txt b/bundled-libs/Smarty/NEW_FEATURES.txt new file mode 100644 index 00000000..b2c18c99 --- /dev/null +++ b/bundled-libs/Smarty/NEW_FEATURES.txt @@ -0,0 +1,86 @@ + + +This file contains a brief description of new features which have been added to Smarty 3.1 + +Smarty 3.1.22 + + Namespace support within templates + ================================== + Within templates you can now use namespace specifications on: + - Constants like foo\bar\FOO + - Class names like foo\bar\Baz::FOO, foo\bar\Baz::$foo, foo\bar\Baz::foo() + - PHP function names like foo\bar\baz() + + Security + ======== + - disable special $smarty variable - + The Smarty_Security class has the new property $disabled_special_smarty_vars. + It's an array which can be loaded with the $smarty special variable names like + 'template_object', 'template', 'current_dir' and others which will be disabled. + Note: That this security check is performed at compile time. + + - limit template nesting - + Property $max_template_nesting of Smarty_Security does set the maximum template nesting level. + The main template is level 1. The nesting level is checked at run time. When the maximum will be exceeded + an Exception will be thrown. The default setting is 0 which does disable this check. + + - trusted static methods - + The Smarty_Security class has the new property $trusted_static_methods to restrict access to static methods. + It's an nested array of trusted class and method names. + Format: + array ( + 'class_1' => array('method_1', 'method_2'), // allowed methods + 'class_2' => array(), // all methods of class allowed + ) + To disable access for all methods of all classes set $trusted_static_methods = null; + The default value is an empty array() which does enables all methods of all classes, but for backward compatibility + the setting of $static_classes will be checked. + Note: That this security check is performed at compile time. + + - trusted static properties - + The Smarty_Security class has the new property $trusted_static_properties to restrict access to static properties. + It's an nested array of trusted class and property names. + Format: + array ( + 'class_1' => array('prop_1', 'prop_2'), // allowed properties listed + 'class_2' => array(), // all properties of class allowed + } + To disable access for all properties of all classes set $trusted_static_properties = null; + The default value is an empty array() which does enables all properties of all classes, but for backward compatibility + the setting of $static_classes will be checked. + Note: That this security check is performed at compile time. + + - trusted constants . + The Smarty_Security class has the new property $trusted_constants to restrict access to constants. + It's an array of trusted constant names. + Format: + array ( + 'SMARTY_DIR' , // allowed constant + } + If the array is empty (default) the usage of constants can be controlled with the + Smarty_Security::$allow_constants property (default true) + + + + Compiled Templates + ================== + Smarty does now automatically detects a change of the $merge_compiled_includes and $escape_html + property and creates different compiled templates files depending on the setting. + + Same applies to config files and the $config_overwrite, $config_booleanize and + $config_read_hidden properties. + + Debugging + ========= + The layout of the debug window has been changed for better readability + + New class constants + Smarty::DEBUG_OFF + Smarty::DEBUG_ON + Smarty::DEBUG_INDIVIDUAL + have been introduced for setting the $debugging property. + + Smarty::DEBUG_INDIVIDUAL will create for each display() and fetch() call an individual gebug window. + + . + \ No newline at end of file diff --git a/bundled-libs/Smarty/README b/bundled-libs/Smarty/README index 6367f030..9304219b 100644 --- a/bundled-libs/Smarty/README +++ b/bundled-libs/Smarty/README @@ -1,4 +1,4 @@ -Smarty 3.1.21 +Smarty 3.x Author: Monte Ohrt Author: Uwe Tews diff --git a/bundled-libs/Smarty/README.md b/bundled-libs/Smarty/README.md new file mode 100644 index 00000000..f5f93fa9 --- /dev/null +++ b/bundled-libs/Smarty/README.md @@ -0,0 +1,52 @@ +#Smarty 3 template engine +##Distribution repository + +*Read the NEW_FEATURES file for recent extensions to Smarty 3.1 functionality* + +Smarty versions 3.1.11 or later are now on github and can be installed with Composer. + + +The "smarty/smarty" package will start at libs/.... subfolder. + +To get the latest stable version of Smarty 3.1 use + + "require": { + "smarty/smarty": "~3.1" + } + +in your composer.json file. + + To get the trunk version use + + "require": { + "smarty/smarty": "~3.1@dev" + } + +For a specific version use something like + + "require": { + "smarty/smarty": "3.1.19" + } + +PHPUnit test can be installed by corresponding composer entries like + + "require": { + "smarty/smarty-phpunit": "3.1.19" + } + +Similar applies for the lexer/parser generator + + "require": { + "smarty/smarty-lexer": "3.1.19" + } + +Or you could use + + "require": { + "smarty/smarty-dev": "3.1.19" + } + +Which is a wrapper to install all 3 packages + + +Composer can also be used for Smarty2 versions 2.6.24 to 2.6.28 diff --git a/bundled-libs/Smarty/change_log.txt b/bundled-libs/Smarty/change_log.txt index a0161659..d06c8ce3 100644 --- a/bundled-libs/Smarty/change_log.txt +++ b/bundled-libs/Smarty/change_log.txt @@ -1,8 +1,231 @@ - ===== 3.1.22-dev ===== (xx.xx.2014) + ===== 3.1.25===== (15.06.2015) + 15.06.2015 + - optimization of smarty_cachereource_keyvaluestore.php code + + 14.06.2015 + - bugfix a relative sub template path could fail if template_dir path did contain /../ https://github.com/smarty-php/smarty/issues/50 + - optimization rework of path normalization + - bugfix an output tag with variable, modifier followed by an operator like {$foo|modifier+1} did fail https://github.com/smarty-php/smarty/issues/53 + + 13.06.2015 + - bugfix a custom cache resource using smarty_cachereource_keyvaluestore.php did fail if php.ini mbstring.func_overload = 2 (forum topic 25568) + + 11.06.2015 + - bugfix the lexer could hang on very large quoted strings (forum topic 25570) + + 08.06.2015 + - bugfix using {$foo} as array index like $bar.{$foo} or in double quoted string like "some {$foo} thing" failed https://github.com/smarty-php/smarty/issues/49 + + 04.06.2015 + - bugfix possible error message on unset() while compiling {block} tags https://github.com/smarty-php/smarty/issues/46 + + 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 + + ===== 3.1.24===== (23.05.2015) + 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) + - bugfix compiler could run into the pcre.backtrack_limit on larger comment or {php} tag sections (forum 25538) + + 18.05.2015 + - improvement introduce shortcuts in lexer/parser rules for most frequent terms for higher + 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) + + 28.04.2015 + - bugfix plugins of merged subtemplates not loaded in 3.1.22-dev (forum topic 25508) 2nd fix + + 28.04.2015 + - bugfix plugins of merged subtemplates not loaded in 3.1.22-dev (forum topic 25508) + + 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) + + 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 + + 04.01.2015 + - push last weeks changes to github + + - different optimizations + - improvement automatically create different versions of compiled templates and config files depending + on property settings. + - optimization restructure template processing by moving code into classes it better belongs to + - optimization restructure config file processing + + 31.12.2014 + - 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) + + 29.12.2014 + - new feature security can now disable special $smarty variables listed in property $disabled_special_smarty_vars + see also NEW_FEATURES.txt (forum 25370) + + 27.12.2014 + - bugfix clear internal _is_file_cache when plugins_dir was modified + + 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) + + 13.11.2014 + - improvement move autoload code into Autoloader.php. Use Composer autoloader when possible + + 12.11.2014 + - new feature added support of namespaces to template code + + 08.11.2014 - 10.11.2014 + - bugfix subtemplate called in nocache mode could be called with wrong compile_id when it did change on one of the calling templates + - improvement add code of template functions called in nocache mode dynamically to cache file (related to bugfix of 01.11.2014) + - bugfix Debug Console did not include all data from merged compiled subtemplates + + 04.11.2014 + - new feature $smarty->debug = true; => overwrite existing Debug Console window (old behaviour) + $smarty->debug = 2; => individual Debug Console window by template name + + 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 + - 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 + + 01.11.2014 + - bugfix and enhancement on subtemplate {include} and template {function} tags. + * Calling a template which has a nocache section could fail if it was called from a cached and a not cached subtemplate. + * Calling the same subtemplate cached and not cached with the $smarty->merge_compiled_includes enabled could cause problems + * Many smaller related changes + + 30.10.2014 + - bugfix access to class constant by object like {$object::CONST} or variable class name {$class::CONST} did not work (forum 25301) + + 26.10.2014 + - bugfix E_NOTICE message was created during compilation when ASP tags '<%' or '%>' are in template source text + - bugfix merge_compiled_includes option failed when caching enables and same subtemplate was included cached and not cached + ===== 3.1.21 ===== (18.10.2014) 18.10.2014 - - composer moved to github - - add COMPOSER_RELEASE_NOTES + - composer moved to github 17.10.2014 - bugfix on $php_handling security and optimization of smarty_internal_parsetree (Thue Kristensen) @@ -43,7 +266,7 @@ 04.07.2014 - bugfix the bufix of 02.06.2014 broke correct handling of child templates with same name but different template folders in extends resource (issue 194 and topic 25099) - ===== 3.1.19 ===== (06.30.2014) + ===== 3.1.19 ===== (30.06.2014) 20.06.2014 - bugfix template variables could not be passed as parameter in {include} when the include was in a {nocache} section (topic 25131) @@ -732,7 +955,7 @@ 15/07/2011 - bugfix individual cache_lifetime of {include} did not work correctly inside {block} tags -- added caches for Smarty_Template_Source and Smarty_Template_Compiled to reduce I/O for multiple cache_id rendering +- added caches for Smarty_Internal_TemplateSource and Smarty_Internal_TemplateCompiled to reduce I/O for multiple cache_id rendering 14/07/2011 - made Smarty::loadPlugin() respect the include_path if required diff --git a/bundled-libs/Smarty/libs/Autoloader.php b/bundled-libs/Smarty/libs/Autoloader.php new file mode 100644 index 00000000..a24cad6f --- /dev/null +++ b/bundled-libs/Smarty/libs/Autoloader.php @@ -0,0 +1,158 @@ + 'Smarty.class.php', + 'SmartyBC' => 'SmartyBC.class.php', + ); + + private static $syspluginsClasses = array( + 'smarty_config_source' => true, + 'smarty_security' => true, + 'smarty_cacheresource' => true, + 'smarty_compiledresource' => true, + 'smarty_cacheresource_custom' => true, + 'smarty_cacheresource_keyvaluestore' => true, + 'smarty_resource' => true, + 'smarty_resource_custom' => true, + 'smarty_resource_uncompiled' => true, + 'smarty_resource_recompiled' => true, + 'smarty_template_source' => true, + 'smarty_template_compiled' => true, + 'smarty_template_cached' => true, + 'smarty_template_config' => true, + 'smarty_data' => true, + 'smarty_variable' => true, + 'smarty_undefined_variable' => true, + 'smartyexception' => true, + 'smartycompilerexception' => true, + 'smarty_internal_data' => true, + 'smarty_internal_template' => true, + 'smarty_internal_templatebase' => true, + 'smarty_internal_resource_file' => true, + 'smarty_internal_resource_extends' => true, + 'smarty_internal_resource_eval' => true, + 'smarty_internal_resource_string' => true, + 'smarty_internal_resource_registered' => true, + 'smarty_internal_extension_codeframe' => true, + 'smarty_internal_extension_config' => true, + 'smarty_internal_filter_handler' => true, + 'smarty_internal_function_call_handler' => true, + 'smarty_internal_cacheresource_file' => true, + 'smarty_internal_write_file' => true, + ); + + /** + * Registers Smarty_Autoloader backward compatible to older installations. + * + * @param bool $prepend Whether to prepend the autoloader or not. + */ + public static function registerBC($prepend = false) + { + /** + * register the class autoloader + */ + if (!defined('SMARTY_SPL_AUTOLOAD')) { + define('SMARTY_SPL_AUTOLOAD', 0); + } + if (SMARTY_SPL_AUTOLOAD && set_include_path(get_include_path() . PATH_SEPARATOR . SMARTY_SYSPLUGINS_DIR) !== false) { + $registeredAutoLoadFunctions = spl_autoload_functions(); + if (!isset($registeredAutoLoadFunctions['spl_autoload'])) { + spl_autoload_register(); + } + } else { + self::register($prepend); + } + } + + /** + * Registers Smarty_Autoloader as an SPL autoloader. + * + * @param bool $prepend Whether to prepend the autoloader or not. + */ + public static function register($prepend = false) + { + self::$SMARTY_DIR = defined('SMARTY_DIR') ? SMARTY_DIR : dirname(__FILE__) . '/'; + self::$SMARTY_SYSPLUGINS_DIR = defined('SMARTY_SYSPLUGINS_DIR') ? SMARTY_SYSPLUGINS_DIR : self::$SMARTY_DIR . 'sysplugins/'; + if (version_compare(phpversion(), '5.3.0', '>=')) { + spl_autoload_register(array(__CLASS__, 'autoload'), true, $prepend); + } else { + spl_autoload_register(array(__CLASS__, 'autoload')); + } + } + + /** + * Handles autoloading of classes. + * + * @param string $class A class name. + */ + public static function autoload($class) + { + // Request for Smarty or already unknown class + if (isset(self::$unknown[$class])) { + return; + } + $_class = strtolower($class); + if (isset(self::$syspluginsClasses[$_class])) { + $_class = (self::$syspluginsClasses[$_class] === true) ? $_class : self::$syspluginsClasses[$_class]; + $file = self::$SMARTY_SYSPLUGINS_DIR . $_class . '.php'; + require_once $file; + return; + } elseif (0 !== strpos($_class, 'smarty_internal_')) { + if (isset(self::$rootClasses[$class])) { + $file = self::$SMARTY_DIR . self::$rootClasses[$class]; + require_once $file; + return; + } + self::$unknown[$class] = true; + return; + } + $file = self::$SMARTY_SYSPLUGINS_DIR . $_class . '.php'; + if (is_file($file)) { + require_once $file; + return; + } + self::$unknown[$class] = true; + return; + } +} diff --git a/bundled-libs/Smarty/libs/Smarty.class.php b/bundled-libs/Smarty/libs/Smarty.class.php index 832b0d30..e8af0a22 100644 --- a/bundled-libs/Smarty/libs/Smarty.class.php +++ b/bundled-libs/Smarty/libs/Smarty.class.php @@ -2,15 +2,17 @@ /** * Project: Smarty: the PHP compiling template engine * File: Smarty.class.php - * SVN: $Id: Smarty.class.php 4897 2014-10-14 22:29:58Z Uwe.Tews@googlemail.com $ + * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public * License as published by the Free Software Foundation; either * version 2.1 of the License, or (at your option) any later version. + * * This library is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. + * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA @@ -19,12 +21,13 @@ * smarty-discussion-subscribe@googlegroups.com * * @link http://www.smarty.net/ - * @copyright 2008 New Digital Group, Inc. + * @copyright 2015 New Digital Group, Inc. + * @copyright 2015 Uwe Tews * @author Monte Ohrt * @author Uwe Tews * @author Rodney Rehm * @package Smarty - * @version 3.1.21 + * @version 3.1.25 */ /** @@ -53,7 +56,7 @@ if (!defined('SMARTY_PLUGINS_DIR')) { define('SMARTY_PLUGINS_DIR', SMARTY_DIR . 'plugins' . DS); } if (!defined('SMARTY_MBSTRING')) { - define('SMARTY_MBSTRING', function_exists('mb_split')); + define('SMARTY_MBSTRING', function_exists('mb_get_info')); } if (!defined('SMARTY_RESOURCE_CHAR_SET')) { // UTF-8 can only be done properly when mbstring is available! @@ -70,31 +73,29 @@ if (!defined('SMARTY_RESOURCE_DATE_FORMAT')) { } /** - * register the class autoloader + * Try loading the Smarty_Internal_Data class + * If we fail we must load Smarty's autoloader. + * Otherwise we may have a global autoloader like Composer */ -if (!defined('SMARTY_SPL_AUTOLOAD')) { - define('SMARTY_SPL_AUTOLOAD', 0); -} - -if (SMARTY_SPL_AUTOLOAD && set_include_path(get_include_path() . PATH_SEPARATOR . SMARTY_SYSPLUGINS_DIR) !== false) { - $registeredAutoLoadFunctions = spl_autoload_functions(); - if (!isset($registeredAutoLoadFunctions['spl_autoload'])) { - spl_autoload_register(); +if (!class_exists('Smarty_Autoloader', false)) { + if (!class_exists('Smarty_Internal_Data', true)) { + require_once 'Autoloader.php'; + Smarty_Autoloader::registerBC(); } -} else { - spl_autoload_register('smartyAutoload'); } /** * Load always needed external class files */ -include_once SMARTY_SYSPLUGINS_DIR . 'smarty_internal_data.php'; -include_once SMARTY_SYSPLUGINS_DIR . 'smarty_internal_templatebase.php'; -include_once SMARTY_SYSPLUGINS_DIR . 'smarty_internal_template.php'; -include_once SMARTY_SYSPLUGINS_DIR . 'smarty_resource.php'; -include_once SMARTY_SYSPLUGINS_DIR . 'smarty_internal_resource_file.php'; -include_once SMARTY_SYSPLUGINS_DIR . 'smarty_cacheresource.php'; -include_once SMARTY_SYSPLUGINS_DIR . 'smarty_internal_cacheresource_file.php'; + +if (!class_exists('Smarty_Internal_Data', false)) { + require_once SMARTY_SYSPLUGINS_DIR . 'smarty_internal_data.php'; +} +require_once SMARTY_SYSPLUGINS_DIR . 'smarty_internal_templatebase.php'; +require_once SMARTY_SYSPLUGINS_DIR . 'smarty_internal_template.php'; +require_once SMARTY_SYSPLUGINS_DIR . 'smarty_resource.php'; +require_once SMARTY_SYSPLUGINS_DIR . 'smarty_variable.php'; +require_once SMARTY_SYSPLUGINS_DIR . 'smarty_template_source.php'; /** * This is the main Smarty class @@ -110,21 +111,28 @@ class Smarty extends Smarty_Internal_TemplateBase /** * smarty version */ - const SMARTY_VERSION = 'Smarty-3.1.21-dev'; + const SMARTY_VERSION = '3.1.25'; /** * define variable scopes */ const SCOPE_LOCAL = 0; + const SCOPE_PARENT = 1; + const SCOPE_ROOT = 2; + const SCOPE_GLOBAL = 3; + /** * define caching modes */ const CACHING_OFF = 0; + const CACHING_LIFETIME_CURRENT = 1; + const CACHING_LIFETIME_SAVED = 2; + /** * define constant for clearing cache files be saved expiration datees */ @@ -134,29 +142,53 @@ class Smarty extends Smarty_Internal_TemplateBase * define compile check modes */ const COMPILECHECK_OFF = 0; + const COMPILECHECK_ON = 1; + const COMPILECHECK_CACHEMISS = 2; + + /** + * define debug modes + */ + const DEBUG_OFF = 0; + + const DEBUG_ON = 1; + + const DEBUG_INDIVIDUAL = 2; + /** * modes for handling of "" tags in templates. */ const PHP_PASSTHRU = 0; //-> print tags as plain text + const PHP_QUOTE = 1; //-> escape tags as entities + const PHP_REMOVE = 2; //-> escape tags as entities + const PHP_ALLOW = 3; //-> escape tags as entities + /** * filter types */ const FILTER_POST = 'post'; + const FILTER_PRE = 'pre'; + const FILTER_OUTPUT = 'output'; + const FILTER_VARIABLE = 'variable'; + /** * plugin types */ const PLUGIN_FUNCTION = 'function'; + const PLUGIN_BLOCK = 'block'; + const PLUGIN_COMPILER = 'compiler'; + const PLUGIN_MODIFIER = 'modifier'; + const PLUGIN_MODIFIERCOMPILER = 'modifiercompiler'; /**#@-*/ @@ -170,23 +202,28 @@ class Smarty extends Smarty_Internal_TemplateBase * error handler returned by set_error_hanlder() in Smarty::muteExpectedErrors() */ public static $_previous_error_handler = null; + /** * contains directories outside of SMARTY_DIR that are to be muted by muteExpectedErrors() */ - public static $_muted_directories = array(); + public static $_muted_directories = array('./templates_c/' => null, './cache/' => null); + /** * Flag denoting if Multibyte String functions are available */ public static $_MBSTRING = SMARTY_MBSTRING; + /** * The character set to adhere to (e.g. "UTF-8") */ public static $_CHARSET = SMARTY_RESOURCE_CHAR_SET; + /** * The date format to be used internally * (accepts date() and strftime()) */ public static $_DATE_FORMAT = SMARTY_RESOURCE_DATE_FORMAT; + /** * Flag denoting if PCRE should run in UTF-8 mode */ @@ -207,158 +244,154 @@ class Smarty extends Smarty_Internal_TemplateBase * @var boolean */ public $auto_literal = true; + /** * display error on not assigned variables * * @var boolean */ public $error_unassigned = false; + /** * look up relative filepaths in include_path * * @var boolean */ public $use_include_path = false; + /** * template directory * * @var array */ - private $template_dir = array(); + private $template_dir = array('./templates/'); + /** * joined template directory string used in cache keys * * @var string */ - public $joined_template_dir = null; + public $joined_template_dir = './templates/'; + /** * joined config directory string used in cache keys * * @var string */ - public $joined_config_dir = null; + public $joined_config_dir = './configs/'; + /** * default template handler * * @var callable */ public $default_template_handler_func = null; + /** * default config handler * * @var callable */ public $default_config_handler_func = null; + /** * default plugin handler * * @var callable */ public $default_plugin_handler_func = null; + /** * compile directory * * @var string */ - private $compile_dir = null; + private $compile_dir = './templates_c/'; + /** * plugins directory * * @var array */ - private $plugins_dir = array(); + private $plugins_dir = null; + /** * cache directory * * @var string */ - private $cache_dir = null; + private $cache_dir = './cache/'; + /** * config directory * * @var array */ - private $config_dir = array(); + private $config_dir = array('./configs/'); + /** * force template compiling? * * @var boolean */ public $force_compile = false; + /** * check template for modifications? * * @var boolean */ public $compile_check = true; + /** * use sub dirs for compiled/cached files? * * @var boolean */ public $use_sub_dirs = false; + /** * allow ambiguous resources (that are made unique by the resource handler) * * @var boolean */ public $allow_ambiguous_resources = false; - /** - * caching enabled - * - * @var boolean - */ - public $caching = false; + /** * merge compiled includes * * @var boolean */ public $merge_compiled_includes = false; + /** * template inheritance merge compiled includes * * @var boolean */ public $inheritance_merge_compiled_includes = true; - /** - * cache lifetime in seconds - * - * @var integer - */ - public $cache_lifetime = 3600; + /** * force cache file creation * * @var boolean */ public $force_cache = false; - /** - * Set this if you want different sets of cache files for the same - * templates. - * - * @var string - */ - public $cache_id = null; - /** - * Set this if you want different sets of compiled files for the same - * templates. - * - * @var string - */ - public $compile_id = null; + /** * template left-delimiter * * @var string */ public $left_delimiter = "{"; + /** * template right-delimiter * * @var string */ public $right_delimiter = "}"; + /**#@+ * security */ @@ -370,24 +403,28 @@ class Smarty extends Smarty_Internal_TemplateBase * @see Smarty_Security */ public $security_class = 'Smarty_Security'; + /** * implementation of security class * * @var Smarty_Security */ public $security_policy = null; + /** * controls handling of PHP-blocks * * @var integer */ public $php_handling = self::PHP_PASSTHRU; + /** * controls if the php template file resource is allowed * * @var bool */ public $allow_php_templates = false; + /** * Should compiled-templates be prevented from being called directly? * {@internal @@ -397,6 +434,7 @@ class Smarty extends Smarty_Internal_TemplateBase * @var boolean */ public $direct_access_security = true; + /**#@-*/ /** * debug mode @@ -405,6 +443,7 @@ class Smarty extends Smarty_Internal_TemplateBase * @var boolean */ public $debugging = false; + /** * This determines if debugging is enable-able from the browser. *
    @@ -415,26 +454,30 @@ class Smarty extends Smarty_Internal_TemplateBase * @var string */ public $debugging_ctrl = 'NONE'; + /** * Name of debugging URL-param. * Only used when $debugging_ctrl is set to 'URL'. * The name of the URL-parameter that activates debugging. * - * @var type + * @var string */ public $smarty_debug_id = 'SMARTY_DEBUG'; + /** * Path of debug template. * * @var string */ public $debug_tpl = null; + /** * When set, smarty uses this value as error_reporting-level. * * @var int */ public $error_reporting = null; + /** * Internal flag for getTags() * @@ -452,12 +495,14 @@ class Smarty extends Smarty_Internal_TemplateBase * @var boolean */ public $config_overwrite = true; + /** * Controls whether config values of on/true/yes and off/false/no get converted to boolean. * * @var boolean */ public $config_booleanize = true; + /** * Controls whether hidden config sections/vars are read from the file. * @@ -477,12 +522,14 @@ class Smarty extends Smarty_Internal_TemplateBase * @var boolean */ public $compile_locking = true; + /** * Controls whether cache resources should emply locking mechanism * * @var boolean */ public $cache_locking = false; + /** * seconds to wait for acquiring a lock before ignoring the write lock * @@ -492,12 +539,6 @@ class Smarty extends Smarty_Internal_TemplateBase /**#@-*/ - /** - * global template functions - * - * @var array - */ - public $template_functions = array(); /** * resource type used if none given * Must be an valid key of $registered_resources. @@ -505,6 +546,7 @@ class Smarty extends Smarty_Internal_TemplateBase * @var string */ public $default_resource_type = 'file'; + /** * caching type * Must be an element of $cache_resource_types. @@ -512,256 +554,284 @@ class Smarty extends Smarty_Internal_TemplateBase * @var string */ public $caching_type = 'file'; + /** * internal config properties * * @var array */ public $properties = array(); + /** * config type * * @var string */ public $default_config_type = 'file'; + + /** + * cached template objects + * + * @var array + */ + public $source_objects = array(); + /** * cached template objects * * @var array */ public $template_objects = array(); + + /** + * enable resource caching + * + * @var bool + */ + public $resource_caching = false; + + /** + * enable template resource caching + * + * @var bool + */ + public $template_resource_caching = true; + /** * check If-Modified-Since headers * * @var boolean */ public $cache_modified_check = false; + /** * registered plugins * * @var array */ public $registered_plugins = array(); + /** * plugin search order * * @var array */ public $plugin_search_order = array('function', 'block', 'compiler', 'class'); + /** * registered objects * * @var array */ public $registered_objects = array(); + /** * registered classes * * @var array */ public $registered_classes = array(); + /** * registered filters * * @var array */ public $registered_filters = array(); + /** * registered resources * * @var array */ public $registered_resources = array(); + /** * resource handler cache * * @var array */ public $_resource_handlers = array(); + /** * registered cache resources * * @var array */ public $registered_cache_resources = array(); + /** * cache resource handler cache * * @var array */ public $_cacheresource_handlers = array(); + /** * autoload filter * * @var array */ public $autoload_filters = array(); + /** * default modifier * * @var array */ public $default_modifiers = array(); + /** * autoescape variable output * * @var boolean */ public $escape_html = false; + /** * global internal smarty vars * * @var array */ public static $_smarty_vars = array(); + /** * start time for execution time calculation * * @var int */ public $start_time = 0; + /** * default file permissions * * @var int */ public $_file_perms = 0644; + /** * default dir permissions * * @var int */ public $_dir_perms = 0771; + /** * block tag hierarchy * * @var array */ public $_tag_stack = array(); - /** - * self pointer to Smarty object - * - * @var Smarty - */ - public $smarty; + /** * required by the compiler for BC * * @var string */ public $_current_file = null; + /** * internal flag to enable parser debugging * * @var bool */ public $_parserdebug = false; - /** - * Saved parameter of merged templates during compilation - * - * @var array - */ - public $merged_templates_func = array(); /** * Cache of is_file results of loadPlugin() - * + * * @var array */ - public static $_is_file_cache= array(); + public $_is_file_cache = array(); /**#@-*/ /** * Initialize new Smarty object - */ public function __construct() { - // selfpointer needed by some other class methods - $this->smarty = $this; if (is_callable('mb_internal_encoding')) { mb_internal_encoding(Smarty::$_CHARSET); } $this->start_time = microtime(true); - // set default dirs - $this->setTemplateDir('.' . DS . 'templates' . DS) - ->setCompileDir('.' . DS . 'templates_c' . DS) - ->setPluginsDir(SMARTY_PLUGINS_DIR) - ->setCacheDir('.' . DS . 'cache' . DS) - ->setConfigDir('.' . DS . 'configs' . DS); - - $this->debug_tpl = 'file:' . dirname(__FILE__) . '/debug.tpl'; + // check default dirs for overloading + if ($this->template_dir[0] !== './templates/' || isset($this->template_dir[1])) { + $this->setTemplateDir($this->template_dir); + } + if ($this->config_dir[0] !== './configs/' || isset($this->config_dir[1])) { + $this->setConfigDir($this->config_dir); + } + if ($this->compile_dir !== './templates_c/') { + unset(self::$_muted_directories['./templates_c/']); + $this->setCompileDir($this->compile_dir); + } + if ($this->cache_dir !== './cache/') { + unset(self::$_muted_directories['./cache/']); + $this->setCacheDir($this->cache_dir); + } + if (isset($this->plugins_dir)) { + $this->setPluginsDir($this->plugins_dir); + } else { + $this->setPluginsDir(SMARTY_PLUGINS_DIR); + } if (isset($_SERVER['SCRIPT_NAME'])) { - $this->assignGlobal('SCRIPT_NAME', $_SERVER['SCRIPT_NAME']); + Smarty::$global_tpl_vars['SCRIPT_NAME'] = new Smarty_Variable($_SERVER['SCRIPT_NAME']); + } + + // Check if we're running on windows + Smarty::$_IS_WINDOWS = strtoupper(substr(PHP_OS, 0, 3)) === 'WIN'; + + // let PCRE (preg_*) treat strings as ISO-8859-1 if we're not dealing with UTF-8 + if (Smarty::$_CHARSET !== 'UTF-8') { + Smarty::$_UTF8_MODIFIER = ''; } } /** - * Class destructor - */ - public function __destruct() - { - // intentionally left blank - } - - /** - * <> set selfpointer on cloned object - */ - public function __clone() - { - $this->smarty = $this; - } - - /** - * <> Generic getter. - * Calls the appropriate getter function. - * Issues an E_USER_NOTICE if no valid getter is found. + * fetches a rendered Smarty template * - * @param string $name property name + * @param string $template the resource handle of the template file or template object + * @param mixed $cache_id cache id to be used with this template + * @param mixed $compile_id compile id to be used with this template + * @param object $parent next higher level of Smarty variables + * @param bool $display true: display, false: fetch + * @param bool $merge_tpl_vars not used - left for BC + * @param bool $no_output_filter not used - left for BC * - * @return mixed + * @throws Exception + * @throws SmartyException + * @return string rendered template output */ - public function __get($name) + public function fetch($template = null, $cache_id = null, $compile_id = null, $parent = null, $display = false, $merge_tpl_vars = true, $no_output_filter = false) { - $allowed = array( - 'template_dir' => 'getTemplateDir', - 'config_dir' => 'getConfigDir', - 'plugins_dir' => 'getPluginsDir', - 'compile_dir' => 'getCompileDir', - 'cache_dir' => 'getCacheDir', - ); - - if (isset($allowed[$name])) { - return $this->{$allowed[$name]}(); - } else { - trigger_error('Undefined property: ' . get_class($this) . '::$' . $name, E_USER_NOTICE); + if ($cache_id !== null && is_object($cache_id)) { + $parent = $cache_id; + $cache_id = null; } + if ($parent === null) { + $parent = $this; + } + // get template object + $_template = is_object($template) ? $template : $this->createTemplate($template, $cache_id, $compile_id, $parent, false); + // set caching in template object + $_template->caching = $this->caching; + // fetch template content + return $_template->render(true, false, $display); } /** - * <> Generic setter. - * Calls the appropriate setter function. - * Issues an E_USER_NOTICE if no valid setter is found. + * displays a Smarty template * - * @param string $name property name - * @param mixed $value parameter passed to setter + * @param string $template the resource handle of the template file or template object + * @param mixed $cache_id cache id to be used with this template + * @param mixed $compile_id compile id to be used with this template + * @param object $parent next higher level of Smarty variables */ - public function __set($name, $value) + public function display($template = null, $cache_id = null, $compile_id = null, $parent = null) { - $allowed = array( - 'template_dir' => 'setTemplateDir', - 'config_dir' => 'setConfigDir', - 'plugins_dir' => 'setPluginsDir', - 'compile_dir' => 'setCompileDir', - 'cache_dir' => 'setCacheDir', - ); - - if (isset($allowed[$name])) { - $this->{$allowed[$name]}($value); - } else { - trigger_error('Undefined property: ' . get_class($this) . '::$' . $name, E_USER_NOTICE); - } + // display template + $this->fetch($template, $cache_id, $compile_id, $parent, true); } /** @@ -899,11 +969,9 @@ class Smarty extends Smarty_Internal_TemplateBase { $this->template_dir = array(); foreach ((array) $template_dir as $k => $v) { - $this->template_dir[$k] = preg_replace('#(\w+)(/|\\\\){1,}#', '$1$2', rtrim($v, '/\\')) . DS; + $this->template_dir[$k] = rtrim($v, '/\\') . DS; } - - $this->joined_template_dir = join(DIRECTORY_SEPARATOR, $this->template_dir); - + $this->joined_template_dir = join(' # ', $this->template_dir); return $this; } @@ -918,32 +986,8 @@ class Smarty extends Smarty_Internal_TemplateBase */ public function addTemplateDir($template_dir, $key = null) { - // make sure we're dealing with an array - $this->template_dir = (array) $this->template_dir; - - if (is_array($template_dir)) { - foreach ($template_dir as $k => $v) { - $v = preg_replace('#(\w+)(/|\\\\){1,}#', '$1$2', rtrim($v, '/\\')) . DS; - if (is_int($k)) { - // indexes are not merged but appended - $this->template_dir[] = $v; - } else { - // string indexes are overridden - $this->template_dir[$k] = $v; - } - } - } else { - $v = preg_replace('#(\w+)(/|\\\\){1,}#', '$1$2', rtrim($template_dir, '/\\')) . DS; - if ($key !== null) { - // override directory at specified index - $this->template_dir[$key] = $v; - } else { - // append new directory - $this->template_dir[] = $v; - } - } - $this->joined_template_dir = join(DIRECTORY_SEPARATOR, $this->template_dir); - + $this->_addDir('template_dir', $template_dir, $key); + $this->joined_template_dir = join(' # ', $this->template_dir); return $this; } @@ -959,7 +1003,6 @@ class Smarty extends Smarty_Internal_TemplateBase if ($index !== null) { return isset($this->template_dir[$index]) ? $this->template_dir[$index] : null; } - return (array) $this->template_dir; } @@ -974,51 +1017,24 @@ class Smarty extends Smarty_Internal_TemplateBase { $this->config_dir = array(); foreach ((array) $config_dir as $k => $v) { - $this->config_dir[$k] = preg_replace('#(\w+)(/|\\\\){1,}#', '$1$2', rtrim($v, '/\\')) . DS; + $this->config_dir[$k] = rtrim($v, '/\\') . DS; } - - $this->joined_config_dir = join(DIRECTORY_SEPARATOR, $this->config_dir); - + $this->joined_config_dir = join(' # ', $this->config_dir); return $this; } /** * Add config directory(s) * - * @param string|array $config_dir directory(s) of config sources - * @param mixed $key key of the array element to assign the config dir to + * @param string|array $config_dir directory(s) of config sources + * @param mixed $key key of the array element to assign the config dir to * * @return Smarty current Smarty instance for chaining */ public function addConfigDir($config_dir, $key = null) { - // make sure we're dealing with an array - $this->config_dir = (array) $this->config_dir; - - if (is_array($config_dir)) { - foreach ($config_dir as $k => $v) { - $v = preg_replace('#(\w+)(/|\\\\){1,}#', '$1$2', rtrim($v, '/\\')) . DS; - if (is_int($k)) { - // indexes are not merged but appended - $this->config_dir[] = $v; - } else { - // string indexes are overridden - $this->config_dir[$k] = $v; - } - } - } else { - $v = preg_replace('#(\w+)(/|\\\\){1,}#', '$1$2', rtrim($config_dir, '/\\')) . DS; - if ($key !== null) { - // override directory at specified index - $this->config_dir[$key] = rtrim($v, '/\\') . DS; - } else { - // append new directory - $this->config_dir[] = rtrim($v, '/\\') . DS; - } - } - - $this->joined_config_dir = join(DIRECTORY_SEPARATOR, $this->config_dir); - + $this->_addDir('config_dir', $config_dir, $key); + $this->joined_config_dir = join(' # ', $this->config_dir); return $this; } @@ -1034,7 +1050,6 @@ class Smarty extends Smarty_Internal_TemplateBase if ($index !== null) { return isset($this->config_dir[$index]) ? $this->config_dir[$index] : null; } - return (array) $this->config_dir; } @@ -1048,10 +1063,7 @@ class Smarty extends Smarty_Internal_TemplateBase public function setPluginsDir($plugins_dir) { $this->plugins_dir = array(); - foreach ((array) $plugins_dir as $k => $v) { - $this->plugins_dir[$k] = rtrim($v, '/\\') . DS; - } - + $this->addPluginsDir($plugins_dir); return $this; } @@ -1066,24 +1078,11 @@ class Smarty extends Smarty_Internal_TemplateBase { // make sure we're dealing with an array $this->plugins_dir = (array) $this->plugins_dir; - - if (is_array($plugins_dir)) { - foreach ($plugins_dir as $k => $v) { - if (is_int($k)) { - // indexes are not merged but appended - $this->plugins_dir[] = rtrim($v, '/\\') . DS; - } else { - // string indexes are overridden - $this->plugins_dir[$k] = rtrim($v, '/\\') . DS; - } - } - } else { - // append new directory - $this->plugins_dir[] = rtrim($plugins_dir, '/\\') . DS; + foreach ((array) $plugins_dir as $v) { + $this->plugins_dir[] = rtrim($v, '/\\') . DS; } - $this->plugins_dir = array_unique($this->plugins_dir); - + $this->_is_file_cache = array(); return $this; } @@ -1137,7 +1136,6 @@ class Smarty extends Smarty_Internal_TemplateBase if (!isset(Smarty::$_muted_directories[$this->cache_dir])) { Smarty::$_muted_directories[$this->cache_dir] = null; } - return $this; } @@ -1151,6 +1149,39 @@ class Smarty extends Smarty_Internal_TemplateBase return $this->cache_dir; } + /** + * add directories to given property name + * + * @param string $dirName directory property name + * @param string|array $dir directory string or array of strings + * @param mixed $key optional key + */ + private function _addDir($dirName, $dir, $key = null) + { + // make sure we're dealing with an array + $this->$dirName = (array) $this->$dirName; + + if (is_array($dir)) { + foreach ($dir as $k => $v) { + if (is_int($k)) { + // indexes are not merged but appended + $this->{$dirName}[] = rtrim($v, '/\\') . DS; + } else { + // string indexes are overridden + $this->{$dirName}[$k] = rtrim($v, '/\\') . DS; + } + } + } else { + if ($key !== null) { + // override directory at specified index + $this->{$dirName}[$key] = rtrim($dir, '/\\') . DS; + } else { + // append new directory + $this->{$dirName}[] = rtrim($dir, '/\\') . DS; + } + } + } + /** * Set default modifiers * @@ -1197,7 +1228,8 @@ class Smarty extends Smarty_Internal_TemplateBase * Set autoload filters * * @param array $filters filters to load automatically - * @param string $type "pre", "output", … specify the filter type to set. Defaults to none treating $filters' keys as the appropriate types + * @param string $type "pre", "output", … specify the filter type to set. Defaults to none treating $filters' + * keys as the appropriate types * * @return Smarty current Smarty instance for chaining */ @@ -1216,7 +1248,8 @@ class Smarty extends Smarty_Internal_TemplateBase * Add autoload filters * * @param array $filters filters to load automatically - * @param string $type "pre", "output", … specify the filter type to set. Defaults to none treating $filters' keys as the appropriate types + * @param string $type "pre", "output", … specify the filter type to set. Defaults to none treating $filters' + * keys as the appropriate types * * @return Smarty current Smarty instance for chaining */ @@ -1246,7 +1279,8 @@ class Smarty extends Smarty_Internal_TemplateBase * * @param string $type type of filter to get autoloads for. Defaults to all autoload filters * - * @return array array( 'type1' => array( 'filter1', 'filter2', … ) ) or array( 'filter1', 'filter2', …) if $type was specified + * @return array array( 'type1' => array( 'filter1', 'filter2', … ) ) or array( 'filter1', 'filter2', …) if $type + * was specified */ public function getAutoloadFilters($type = null) { @@ -1308,48 +1342,34 @@ class Smarty extends Smarty_Internal_TemplateBase } else { $data = null; } - // default to cache_id and compile_id of Smarty object - $cache_id = $cache_id === null ? $this->cache_id : $cache_id; - $compile_id = $compile_id === null ? $this->compile_id : $compile_id; - // already in template cache? - if ($this->allow_ambiguous_resources) { - $_templateId = Smarty_Resource::getUniqueTemplateName($this, $template) . $cache_id . $compile_id; - } else { - $_templateId = $this->joined_template_dir . '#' . $template . $cache_id . $compile_id; - } - if (isset($_templateId[150])) { - $_templateId = sha1($_templateId); - } - if ($do_clone) { - if (isset($this->template_objects[$_templateId])) { - // return cached template object + $_templateId = $this->getTemplateId($template, $cache_id, $compile_id); + if (isset($this->template_objects[$_templateId])) { + if ($do_clone) { $tpl = clone $this->template_objects[$_templateId]; $tpl->smarty = clone $tpl->smarty; - $tpl->parent = $parent; - $tpl->tpl_vars = array(); - $tpl->config_vars = array(); } else { - $tpl = new $this->template_class($template, clone $this, $parent, $cache_id, $compile_id); - } - } else { - if (isset($this->template_objects[$_templateId])) { - // return cached template object $tpl = $this->template_objects[$_templateId]; - $tpl->parent = $parent; - $tpl->tpl_vars = array(); - $tpl->config_vars = array(); - } else { - $tpl = new $this->template_class($template, $this, $parent, $cache_id, $compile_id); } + $tpl->parent = $parent; + $tpl->tpl_vars = array(); + $tpl->config_vars = array(); + } else { + $tpl = new $this->template_class($template, $this, $parent, $cache_id, $compile_id); + if ($do_clone) { + $tpl->smarty = clone $tpl->smarty; + } + $tpl->templateId = $_templateId; } // fill data if present if (!empty($data) && is_array($data)) { // set up variable values foreach ($data as $_key => $_val) { - $tpl->tpl_vars[$_key] = new Smarty_variable($_val); + $tpl->tpl_vars[$_key] = new Smarty_Variable($_val); } } - + if ($this->debugging) { + Smarty_Internal_Debug::register_template($tpl); + } return $tpl; } @@ -1380,7 +1400,7 @@ class Smarty extends Smarty_Internal_TemplateBase // if type is "internal", get plugin from sysplugins if (strtolower($_name_parts[1]) == 'internal') { $file = SMARTY_SYSPLUGINS_DIR . strtolower($plugin_name) . '.php'; - if (isset(self::$_is_file_cache[$file]) ? self::$_is_file_cache[$file] : self::$_is_file_cache[$file] = is_file($file)) { + if (isset($this->_is_file_cache[$file]) ? $this->_is_file_cache[$file] : $this->_is_file_cache[$file] = is_file($file)) { require_once($file); return $file; } else { @@ -1394,12 +1414,9 @@ class Smarty extends Smarty_Internal_TemplateBase // loop through plugin dirs and find the plugin foreach ($this->getPluginsDir() as $_plugin_dir) { - $names = array( - $_plugin_dir . $_plugin_filename, - $_plugin_dir . strtolower($_plugin_filename), - ); + $names = array($_plugin_dir . $_plugin_filename, $_plugin_dir . strtolower($_plugin_filename),); foreach ($names as $file) { - if (isset(self::$_is_file_cache[$file]) ? self::$_is_file_cache[$file] : self::$_is_file_cache[$file] = is_file($file)) { + if (isset($this->_is_file_cache[$file]) ? $this->_is_file_cache[$file] : $this->_is_file_cache[$file] = is_file($file)) { require_once($file); return $file; } @@ -1488,7 +1505,202 @@ class Smarty extends Smarty_Internal_TemplateBase */ public function testInstall(&$errors = null) { - return Smarty_Internal_Utility::testInstall($this, $errors); + return Smarty_Internal_TestInstall::testInstall($this, $errors); + } + + /** + * @param boolean $compile_check + */ + public function setCompileCheck($compile_check) + { + $this->compile_check = $compile_check; + } + + /** + * @param boolean $use_sub_dirs + */ + public function setUseSubDirs($use_sub_dirs) + { + $this->use_sub_dirs = $use_sub_dirs; + } + + /** + * @param boolean $caching + */ + public function setCaching($caching) + { + $this->caching = $caching; + } + + /** + * @param int $cache_lifetime + */ + public function setCacheLifetime($cache_lifetime) + { + $this->cache_lifetime = $cache_lifetime; + } + + /** + * @param string $compile_id + */ + public function setCompileId($compile_id) + { + $this->compile_id = $compile_id; + } + + /** + * @param string $cache_id + */ + public function setCacheId($cache_id) + { + $this->cache_id = $cache_id; + } + + /** + * @param int $error_reporting + */ + public function setErrorReporting($error_reporting) + { + $this->error_reporting = $error_reporting; + } + + /** + * @param boolean $escape_html + */ + public function setEscapeHtml($escape_html) + { + $this->escape_html = $escape_html; + } + + /** + * @param boolean $auto_literal + */ + public function setAutoLiteral($auto_literal) + { + $this->auto_literal = $auto_literal; + } + + /** + * @param boolean $force_compile + */ + public function setForceCompile($force_compile) + { + $this->force_compile = $force_compile; + } + + /** + * @param boolean $merge_compiled_includes + */ + public function setMergeCompiledIncludes($merge_compiled_includes) + { + $this->merge_compiled_includes = $merge_compiled_includes; + } + + /** + * @param string $left_delimiter + */ + public function setLeftDelimiter($left_delimiter) + { + $this->left_delimiter = $left_delimiter; + } + + /** + * @param string $right_delimiter + */ + public function setRightDelimiter($right_delimiter) + { + $this->right_delimiter = $right_delimiter; + } + + /** + * @param boolean $debugging + */ + public function setDebugging($debugging) + { + $this->debugging = $debugging; + } + + /** + * @param boolean $config_overwrite + */ + public function setConfigOverwrite($config_overwrite) + { + $this->config_overwrite = $config_overwrite; + } + + /** + * @param boolean $config_booleanize + */ + public function setConfigBooleanize($config_booleanize) + { + $this->config_booleanize = $config_booleanize; + } + + /** + * @param boolean $config_read_hidden + */ + public function setConfigReadHidden($config_read_hidden) + { + $this->config_read_hidden = $config_read_hidden; + } + + /** + * @param boolean $compile_locking + */ + public function setCompileLocking($compile_locking) + { + $this->compile_locking = $compile_locking; + } + + /** + * Class destructor + */ + public function __destruct() + { + // intentionally left blank + } + + /** + * <> Generic getter. + * Calls the appropriate getter function. + * Issues an E_USER_NOTICE if no valid getter is found. + * + * @param string $name property name + * + * @return mixed + */ + public function __get($name) + { + $allowed = array('template_dir' => 'getTemplateDir', 'config_dir' => 'getConfigDir', + 'plugins_dir' => 'getPluginsDir', 'compile_dir' => 'getCompileDir', + 'cache_dir' => 'getCacheDir',); + + if (isset($allowed[$name])) { + return $this->{$allowed[$name]}(); + } else { + trigger_error('Undefined property: ' . get_class($this) . '::$' . $name, E_USER_NOTICE); + } + } + + /** + * <> Generic setter. + * Calls the appropriate setter function. + * Issues an E_USER_NOTICE if no valid setter is found. + * + * @param string $name property name + * @param mixed $value parameter passed to setter + */ + public function __set($name, $value) + { + $allowed = array('template_dir' => 'setTemplateDir', 'config_dir' => 'setConfigDir', + 'plugins_dir' => 'setPluginsDir', 'compile_dir' => 'setCompileDir', + 'cache_dir' => 'setCacheDir',); + + if (isset($allowed[$name])) { + $this->{$allowed[$name]}($value); + } else { + trigger_error('Undefined property: ' . get_class($this) . '::$' . $name, E_USER_NOTICE); + } } /** @@ -1512,10 +1724,8 @@ class Smarty extends Smarty_Internal_TemplateBase if (!isset(Smarty::$_muted_directories[SMARTY_DIR])) { $smarty_dir = realpath(SMARTY_DIR); if ($smarty_dir !== false) { - Smarty::$_muted_directories[SMARTY_DIR] = array( - 'file' => $smarty_dir, - 'length' => strlen($smarty_dir), - ); + Smarty::$_muted_directories[SMARTY_DIR] = array('file' => $smarty_dir, + 'length' => strlen($smarty_dir),); } } @@ -1529,10 +1739,7 @@ class Smarty extends Smarty_Internal_TemplateBase unset(Smarty::$_muted_directories[$key]); continue; } - $dir = array( - 'file' => $file, - 'length' => strlen($file), - ); + $dir = array('file' => $file, 'length' => strlen($file),); } if (!strncmp($errfile, $dir['file'], $dir['length'])) { $_is_muted_directory = true; @@ -1593,88 +1800,3 @@ class Smarty extends Smarty_Internal_TemplateBase restore_error_handler(); } } - -// Check if we're running on windows -Smarty::$_IS_WINDOWS = strtoupper(substr(PHP_OS, 0, 3)) === 'WIN'; - -// let PCRE (preg_*) treat strings as ISO-8859-1 if we're not dealing with UTF-8 -if (Smarty::$_CHARSET !== 'UTF-8') { - Smarty::$_UTF8_MODIFIER = ''; -} - -/** - * Smarty exception class - * - * @package Smarty - */ -class SmartyException extends Exception -{ - public static $escape = false; - - public function __toString() - { - return ' --> Smarty: ' . (self::$escape ? htmlentities($this->message) : $this->message) . ' <-- '; - } -} - -/** - * Smarty compiler exception class - * - * @package Smarty - */ -class SmartyCompilerException extends SmartyException -{ - public function __toString() - { - return ' --> Smarty Compiler: ' . $this->message . ' <-- '; - } - - /** - * The line number of the template error - * - * @type int|null - */ - public $line = null; - /** - * The template source snippet relating to the error - * - * @type string|null - */ - public $source = null; - /** - * The raw text of the error message - * - * @type string|null - */ - public $desc = null; - /** - * The resource identifier or template name - * - * @type string|null - */ - public $template = null; -} - -/** - * Autoloader - */ -function smartyAutoload($class) -{ - $_class = strtolower($class); - static $_classes = array( - 'smarty_config_source' => true, - 'smarty_config_compiled' => true, - 'smarty_security' => true, - 'smarty_cacheresource' => true, - 'smarty_cacheresource_custom' => true, - 'smarty_cacheresource_keyvaluestore' => true, - 'smarty_resource' => true, - 'smarty_resource_custom' => true, - 'smarty_resource_uncompiled' => true, - 'smarty_resource_recompiled' => true, - ); - - if (!strncmp($_class, 'smarty_internal_', 16) || isset($_classes[$_class])) { - include SMARTY_SYSPLUGINS_DIR . $_class . '.php'; - } -} diff --git a/bundled-libs/Smarty/libs/SmartyBC.class.php b/bundled-libs/Smarty/libs/SmartyBC.class.php index cec94674..76dd8bd0 100644 --- a/bundled-libs/Smarty/libs/SmartyBC.class.php +++ b/bundled-libs/Smarty/libs/SmartyBC.class.php @@ -52,8 +52,6 @@ class SmartyBC extends Smarty public function __construct(array $options = array()) { parent::__construct($options); - // register {php} tag - $this->registerPlugin('block', 'php', 'smarty_php_tag'); } /** @@ -115,10 +113,10 @@ class SmartyBC extends Smarty /** * Registers object to be used in templates * - * @param string $object name of template object - * @param object $object_impl the referenced PHP object to register - * @param array $allowed list of allowed methods (empty = all) - * @param boolean $smarty_args smarty argument format, else traditional + * @param string $object name of template object + * @param object $object_impl the referenced PHP object to register + * @param array $allowed list of allowed methods (empty = all) + * @param boolean $smarty_args smarty argument format, else traditional * @param array $block_methods list of methods that are block format * * @throws SmartyException @@ -448,20 +446,3 @@ class SmartyBC extends Smarty trigger_error("Smarty error: $error_msg", $error_type); } } - -/** - * Smarty {php}{/php} block function - * - * @param array $params parameter list - * @param string $content contents of the block - * @param object $template template object - * @param boolean &$repeat repeat flag - * - * @return string content re-formatted - */ -function smarty_php_tag($params, $content, $template, &$repeat) -{ - eval($content); - - return ''; -} diff --git a/bundled-libs/Smarty/libs/debug.tpl b/bundled-libs/Smarty/libs/debug.tpl index 61b8876a..5b09c5bd 100644 --- a/bundled-libs/Smarty/libs/debug.tpl +++ b/bundled-libs/Smarty/libs/debug.tpl @@ -5,7 +5,7 @@ Smarty Debug Console