Commit Graph

628 Commits

Author SHA1 Message Date
Simon Wisselink
61db287b8f Scottchiefbaker/master (#1019)
* Add a PSR-4 loading script to allow Smarty to be used without Composer
authored-by: Scott Baker <scott@perturb.org>
2024-05-24 00:21:02 +02:00
Simon Wisselink
8fd949ac5d Smarty5 (#852)
* WIP converting code to PSR-4

* More PSR4 rewriting

* Removed autoload filters

* WIP making compile classes PSR-4

* WIP making compile classes PSR-4

* Replace Smarty:: with symfony/polyfill-mbstring

* WIP making compile classes PSR-4

* finished rewriting all compile classes into PSR-4

* Rewrote all Compile and Compiler classes to PSR-4

* WIP rewriting smarty_internal_method_*

* Finished moving smarty_internal_method_*

* smarty_internal_resource_* to PSR-4

* Refactored all _runtime_* by merging them into the proper classes or by transforming them into Runtime Extensions.

* src/Template/* to PSR-4

* src/sysplugins/* to PSR-4

* Entire src dir now PSR-4 compatible

* Add makefile, PSR-4 ModifierCompilers

* Rewrote all default modifiers and functions from the plugins folder to PSR-4 classes

* Rewrote remaining plugins to PSR-4, plugins dir is now gone.

* WIP moving Smarty to PSR-4.

* fixed pre/post/output filters and removed some old todo-comments

* filter tests passing

* Fixed TemplateObject test

* Fix CustomResourceAmbiguousTest

* Fixed CacheResource implementation and tests

* Fixed setfilter

* Fixed DefaultPluginHandlerTest for function plugins (blocks still break)

* move runPluginFromDefaultHandler to new Runtime class

* Introduce formatParamsArray method for recurring code fragment

* Fix code duplication in block compilers and fix (most) BlockPluginTests. Default plugin handler blocks still need fixing.

* minor fixes

* Implemented the DefaultHandlerBlockCompiler, made the dependencies of the template compiler into properties, fixed a couple of unit tests

* Removed support for PHP include path, and removed the ::loadPlugin method.

* Removed now unneeded PHPunit annotations @run(Tests)InSeparateProcess, @preserveGlobalState and @backupStaticAttributes. Made CacheResourceTestCommon abstract to prevent the base class from running tests (and always failing). Unregister a previously registered stream wrapper. Fixes a lot of tests.

* Fix scoping / global state problems in tests by using DI in Default Extension. Also removing a bunch of old fashioned phpdoc annotations that are superseded by namespaces.

* Make DefaultExtension lazy load again.

* Removed deprecated extends_recursion property and fix bug in CodeFrame compiler due to use of clone.

* Fixed BC loading of resource pluging from dir and all ResourcePluginTest tests

* Removed PHP functions and checks for the already removed php modifiers. Re-implemented functions as regular functions. Probably should compile these directly.

* Fixed stream resources

* 2 small fixes for unit tests

* Fixed modifiercompiler handling multiple/chained modifiers

* Rewrote global static global_tpl_vars to getters/setters on Smarty class, fixing several test cases. Added a ::getValue() method to Variable.

* Fixed issue related to scoping of left/right delimiter overrides

* Added strlen function, fixing some unit tests

* Fix bug in calling BC function handlers.

* WIP replacing direct access tpl_vars with proper getter/setters.

* WIP

* WIP rewriting variable scopes

* WIP fixing the complicated variables scopes architecture. Right now more tests are failing than before... :(

* Fixed minor unit tests

* Made variable scoping more sensible

* Fix configfile tests

* removed phpplugin, removed now unused uncompiled handler and all checks for this, fixed a refactorbug in InheritanceRuntime. Moved getRenderedTemplateCode method to Smarty\Template. Renamed Cache en Compiled base class to GeneratedPhpFile for more clarity and distinction from Resource classes. Inlined Cached::create into its only caller. Some other minor improvements. Removed php7.1 CI tests.

* Removed the allowUndefinedVars check from the smarty error handlers, because undefined vars no longer throw an error, unless smarty->error_unassigned is set to true.

* Replace direct access to inheritance property on Template object by proper getter.

* converted 3 public properties on Template into getters/setters. unified Template creation code. Provided a getter/setter for the has_nocache_code property. Removed the useless DataObject class. Fixed a few tests. Removed the variable-allow-php-templates property from the docs.

* Simplified the (no)caching architecture by:
- removing support for $cache_attrs for registered plugins,
- removing the undocumented {make_nocache} tag and the deprecated {insert} tag and associated code
- removing support for a compile_id property on include tags.

Fixes a bug in extends: resources by propagating the nocache-hashes between a master template and it's subtemplates in \Smarty\Template::_subTemplateRender. This might need further improvement.

* Removed unneeded magic setters/getters/destructors and the like.

* Replaced a bunch of direct property access with getters/setters.

* Update test runners: no longer support PHP7.1, add PHP8.2

* Fixed scope in variable assignments in included and extended templates, fixed dependencies for testing freshness of caches. Added some unit tests and fixed a class reference to pass some more tests.

* Fix searchParents parameter, fixing GetTemplateVarsTest

* @var integer > @var int for vsCode

* Fix function caching function name

* Fixed cacheability of block plugins.

* Moved handling of smarty.block.* to special compilers, because they aren't real tags. Organized tag-stack handling in compiler, unified nocache handling in compiler.

* Fixed block append/prepend functionality

* Fix testRegisterCompilerFunction by parsing argument correctly.

* Made exception msgs exactly the same again, fixing some unit tests

* Fix default plugin handler

* Simply the "isFresh" method by not including the first param anymore. Fix a couple of unit tests by respecting tag_nocache set by nocache vars used in a tag.

* Removed the undocumented {block_parent} and {parent} alternatives to {$smarty.block.parent}
and {block_child} and {child} alternatives to {$smarty.block.child}

* Fix inhertiance implementation for $smarty.block.child

* Fixed all inheritance issues

* Handle BC registered compilers and missed parameters for openTag and closeTag.

* Fix all foreach unit tests

* Fixed the {if} failures.

* Fix major {include} bug

* Fixed bug in {include} variable assignment and removed some unused/unrequired code

* Fix function call compilation using {functionname} syntax for in-template defined functions.

* Drop a unit tests bc we no longer support direct access to PHP-functinos such as sin()

* Fixed all scope assignment bugs

* Convert isset and empty to modifiercomilers, and smooth the error handling to fix unit tests.

* Fixed getCachedContent

* Add TODO list

* Run composer install before online test run

* Attempt to fix CI

* revise CI/CD workflows, bypass packagist for lexer

* Update ci.yml

* Update ci.yml

* fixes in source files

* Update ci.yml

* Update ci.yml

* attempt to load smarty-lexer directly from zip file

* Shouldnt need Github token now

* correct type of repository

* Updated the changelog

* Re-organized rendering (read source / compile / cache) process to avoid circular dependencies.
Deactivated merge_compiled_includes and the {include inline} attribute. They don't seem to do much in terms of performance, but we'll
have to check back.

* updated todo

* Fix smarty-lexer dependency for the time being

* Fix smarty-lexer dependency for the time being (remove direct ref to github)

* Pushed Lexers/Parsers into VCS again in order to be able to deliver using Packagist/Composer

* Re-organized rendering (read source / compile / cache) process to avoid circular dependencies.

* Run make regardless of timestamps, so we are sure unit tests run with the generated PHP code, not with accidental human made changes to Lexer/Parser.

* Update composer packages cache key

Update composer packages cache key to trigger refresh on lexer

* 4.0.2 of smarty-lexer is released, use that

* Throw compile error when using a modifier where it won't work. Fixes #526.

* verify that native PHP functions cannot be used as a modifier and verify that an easy userland workaround exists. Fixes #813.

* Add test for registering compiler plugin with positional params. Fixes #164

* move test methods because some other test methods rely on their relative positions

* Smarty no longer calls `mb_internal_encoding()` and doesn't check for deprecated `mbstring.func_overload` ini directive.
Fixes #480.

* Generated `<script>` tags lo longer have deprecated `type="text/javascript"` or `language="Javascript"` attributes.
Fixes #815.

* Fix error in docs on prepend/append. Fixes #818.

* Move all creating of templates to Smarty::createTemplate, adding a private property containing previously generated templates for speed.

* Load compiled object in template constructor so it will be cached.

* WIP for performance improvements.

Removed $smarty->_current_file and $smarty->allow_ambiguous_resources properties, both unused. Removed public Source::filepath property.
Cached an Compiled files (and Exceptions) no longer rely on the filepath being set. Removed explicit tests for cached and compiled filenames. The exact implementation is not important. Added tests for compile_check property, fixing a file_exists check that would always be done on source template files, even when compile_check was true. Remove code duplication between Source en Config classes. Added a local $_smarty_current_dir to the generated code files for backwards compatability for {$smarty.current_dir}.

* remove additional calls to getCached()

* updated todo

* Add mkdocs for docs

* add missing folder for unit tests

* Revert latest CI changes, we'll update docs by hand for now

* multiversion mkdocs config

* fixes to docs

* WIP improving the docs

* Improved another chunk of the designers docs

* Finished improving designers docs

* Update code examples to use Smarty\Smarty and autoload instead of require_once calls and new Smarty

* Further WIP improving docs

* Updated changelog and todo list

* WIP on API docs

* WIP docs (added page on config)

* Fixed markdown syntax. Fixes #879

* Added full support and documentation for ternary operator.
Fixes #881

* updated changelog

* fixed error in the mkdocs TOC

* Added support for null coalescing operator
Fixes #882

* Add docs for null coalescing

* more docs

* Improved docs on compile checking and inheritance

* Rewrote docs on filters and resources.

* Add makefile entries for generating docs

* Docs on caching

* finished docs on security and extending smarty

* Added Smarty::setExtensions(), fixed unit test for the null coalescing operator. Updated docs about registering a custom extension.

* updated todos

* fix template invalidation when migrating to 5.0
2023-08-08 00:04:14 +02:00
Simon Wisselink
edfd4c91da version bump 2023-07-19 12:27:34 +02:00
Simon Wisselink
fe7817c301 version bump 2023-03-28 21:47:01 +02:00
Simon Wisselink
044647bd71 Also mute php7 notices for undefined array indexes when muteUndefinedOrNullWarnings is activated. (#829)
Fixes #736
2022-11-23 23:26:24 +01:00
Simon Wisselink
67ab8f6879 version bump 2022-11-22 22:47:30 +01:00
Raimondas Rimkevičius
1b556c7077 Use __DIR__ instead of dirname(__FILE__) (#817) 2022-09-27 12:03:34 +02:00
Alec Smecher
0fb29024e7 #155 Adapt Smarty upper/lower functions to be codesafe (e.g. for Turkish locale) (#586)
* Implemented locale safe strotoupper, strolower and ucfirst functions for translating user string to filenames etc.

Fixes #155

Co-Authored-By: Alexkurd <7689609+Alexkurd@users.noreply.github.com>
2022-09-22 23:32:55 +02:00
Simon Wisselink
c693d81370 version bump 2022-09-14 12:58:59 +02:00
Simon Wisselink
ed454551a3 version bump 2022-08-01 23:57:36 +02:00
Simon Wisselink
78f0cf5f65 version bump 2022-05-17 14:56:26 +02:00
Jorge Sá Pereira
962f266483 Fix PHP 8.1 deprecated warning when calling rtrim
Fixes - Deprecated: rtrim(): Passing null to parameter #1 ($string) of type string is deprecated
2022-03-10 02:06:00 +00:00
Simon Wisselink
265cf4f3bc version bump 2022-02-06 21:34:26 +01:00
Simon Wisselink
995b7eb36f version bump 2022-01-18 00:17:17 +01:00
Simon Wisselink
ace1c8e90f version bump 2022-01-10 10:52:13 +01:00
Simon Wisselink
a535445dfd version bump 2022-01-10 00:09:06 +01:00
Simon Wisselink
23be620fc8 version bump 2022-01-09 23:20:44 +01:00
Simon Wisselink
e603269eda version bump 2021-11-25 22:18:24 +01:00
Simon Wisselink
d0863f0d0b version bump 2021-10-13 12:16:19 +02:00
Simon Wisselink
39b69f0142 Feature/php8 support (#629)
Adds support for PHP8.0, dropping support for PHP7.0 and below.

Backwards incompatible changes:
- Dropped support for php asp tags in templates (removed from php since php7.0)
- Dropped deprecated API calls that where only accessible through SmartyBC
- Dropped support for {php} and {include_php} tags and embedded PHP in templates. Embedded PHP will now be passed through as is.
- Removed all PHP_VERSION_ID and compare_version checks and conditional code blocks that are now no longer required
- Dropped deprecated SMARTY_RESOURCE_CHAR_SET and SMARTY_RESOURCE_DATE_FORMAT constants
- Dropped deprecated Smarty::muteExpectedErrors and Smarty::unmuteExpectedErrors API methods
- Dropped deprecated $smarty->getVariable() method. Use $smarty->getTemplateVars() instead.
- $smarty->registerResource() no longer accepts an array of callback functions

See the changelog for more details.

Switched CI from Travis to Github CI.
2021-10-13 12:15:17 +02:00
Simon Wisselink
7c4354e7b8 version bump 2021-10-13 12:04:29 +02:00
Simon Wisselink
a21f59663c version bump 2021-02-17 22:57:50 +01:00
Simon Wisselink
2af2a07906 version bump 2021-01-08 15:05:40 +01:00
Simon Wisselink
cb4254355e Removed unused error_reporting.ini file, updated version number in Smarty::SMARTY_VERSION, fixed inline phpdoc that caused an IDE error 2021-01-08 15:05:10 +01:00
Simon Wisselink
e2b28167f8 Clarify correct LGPL version.
Fixes #612
2021-01-05 22:23:13 +01:00
♚ PH⑦ de Soria™♛
859a09e1bb Bumped phpdoc @version tag to 3.1.36 (#598)
Although this could be removed, since the header comment is still there, it's good to keep the @version tag updated in order to avoid confusion for those who read it :)
2020-09-11 13:34:15 +02:00
Sławomir Kaleta
e1c050a32c Fix comment - Method can return string (#583) 2020-04-14 17:26:20 +02:00
Simon Wisselink
07772aac90 version bump 2020-04-14 16:44:24 +02:00
Simon Wisselink
e0ea6899c8 fixed version of Smarty::SMARTY_VERSION and updates make-release script to do so automatically from now on 2020-04-14 16:40:44 +02:00
uwetews
68537949f2 - bugfix a nested subblock in an inheritance child template was not replace by
outer level block with same name in same child template https://github.com/smarty-php/smarty/issues/500
2018-10-30 01:03:52 +01:00
uwetews
433d220fa1 - bugfix Smarty::$php_handling == PHP_PASSTHRU (default) did eat the "\n" (newline) character if it did directly followed
a PHP tag like "?>" or other https://github.com/smarty-php/smarty/issues/501
2018-10-29 23:32:22 +01:00
uwetews
3626e37c53 - bugfix autoloader exit shortcut https://github.com/smarty-php/smarty/issues/467 2018-10-14 04:18:45 +02:00
uwetews
b05bc1b617 - bugfix in date-format modifier; NULL at date string or default_date did not produce correct output
https://github.com/smarty-php/smarty/pull/458
2018-10-11 09:22:23 +02:00
uwetews
c930f0e207 - bugfix {insert} not works when caching is enabled and included template is present
https://github.com/smarty-php/smarty/issues/496
2018-10-11 06:56:22 +02:00
uwetews
7f531f6a44 09.10.2018
- bugfix fix of 26.8.2017 https://github.com/smarty-php/smarty/issues/327
   modifier is applied to sum expression https://github.com/smarty-php/smarty/issues/491
 - bugfix indexed arrays could not be defined "array(...)""
2018-10-09 03:36:14 +02:00
uwetews
a6cb648dfc - bugfix large plain text template sections without a Smarty tag > 700kB could
could fail in version 3.1.32 and 3.1.33 because PHP preg_match() restrictions
    https://github.com/smarty-php/smarty/issues/488
2018-09-18 04:46:30 +02:00
uwetews
dd55b23121 Prepare 3.1.33 release 2018-09-12 22:54:16 +02:00
uwetews
2d1905cd88 - 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
2018-09-03 01:18:26 +02:00
uwetews
2c60503dfc - 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
2018-08-31 17:32:44 +02:00
uwetews
4f7cd8f1b3 - reformating for PSR-2 coding standards https://github.com/smarty-php/smarty/pull/483 2018-08-31 16:45:09 +02:00
uwetews
8a4a817c66 - 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
2018-08-31 16:07:47 +02:00
uwetews
7a8607fe17 - 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
2018-08-31 02:37:47 +02:00
uwetews
8e09f97a14 - 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
2018-08-26 00:20:31 +02:00
uwetews
799b5cb342 - 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
2018-08-19 02:35:46 +02:00
Sławomir Kaleta
2404095783 Update PSR-2 2018-06-12 09:58:15 +02:00
Uwe Tews
cc4d8fa1a0 - bugfix strip-block produces different output in Smarty v3.1.32 https://github.com/smarty-php/smarty/issues/436 2018-05-17 16:04:48 +02:00
Uwe Tews
87ec44e9f8 - bugfix Smarty::compileAllTemplates ignores $extension parameter https://github.com/smarty-php/smarty/issues/437
https://github.com/smarty-php/smarty/pull/438
2018-05-17 13:50:14 +02:00
Uwe Tews
514d99beaa - improvement do not compute total property in {foreach} if not needed https://github.com/smarty-php/smarty/issues/443 2018-05-17 06:27:35 +02:00
Uwe Tews
115e178884 - bugfix plugins may not be loaded when setMergeCompiledIncludes is true https://github.com/smarty-php/smarty/issues/435 2018-05-17 04:40:58 +02:00
Uwe Tews
2e081a51b1 - bugfix regarding Security Vulnerability did not solve the problem under Linux 2018-04-26 18:06:45 +02:00