Compare commits

...

1322 Commits

Author SHA1 Message Date
Simon Wisselink 3931d8f54b Merge branch 'release/4.3.4' into support/4.3 2023-09-14 12:59:08 +02:00
Simon Wisselink d8c1dfe56e version bump 2023-09-14 12:59:07 +02:00
Simon Wisselink 6887e55ded Merge branch 'release/4.3.3' into support/4.3 2023-09-14 11:00:40 +02:00
Simon Wisselink 642fd69fea version bump 2023-09-14 11:00:38 +02:00
Simon Wisselink 17a7d6fb5b Fix release-script to user support-branch 2023-09-14 11:00:08 +02:00
Simon Wisselink b96a5c3953 version bump 2023-09-14 10:57:44 +02:00
Simon Wisselink 2ff66e0fcc Fix use of negative numbers in math equations. (#904)
Fixes #895
2023-09-14 10:38:53 +02:00
Simon Wisselink d6c4274822 Fix phpdoc.
Fixes #897
2023-09-13 22:10:36 +02:00
Simon Wisselink a3cbdc46fb Fix strip_tags modifier for falsy input. (#893)
Fixes #890
2023-08-04 22:40:19 +02:00
Simon Wisselink 1d9cda2be3 Merge branch 'release/4.3.2' 2023-07-19 12:27:36 +02:00
Simon Wisselink edfd4c91da version bump 2023-07-19 12:27:34 +02:00
Simon Wisselink 4434e128c6 muteUndefinedOrNullWarnings() now also mutes PHP8 warnings for undefined properties (#891) 2023-07-19 12:27:17 +02:00
Jon 19df91b692 Remove md5 modifier from debug.tpl (#871)
* Remove `md5` modifier from debug.tpl

Replaced with a regular function call. 
See https://github.com/smarty-php/smarty/issues/813

* Move `md5()` in debug.tpl to PHP

---------

Co-authored-by: jonathan <jonathan@devrygreenhouses.com>
2023-04-30 23:25:39 +02:00
Simon Wisselink e28cb0915b Merge branch 'release/4.3.1' 2023-03-28 21:47:03 +02:00
Simon Wisselink fe7817c301 version bump 2023-03-28 21:47:01 +02:00
Simon Wisselink 685662466f Merge branch 'js_escape_security_fix' 2023-03-28 21:46:46 +02:00
Simon Wisselink 71d113550c Add changelog 2023-03-28 21:43:36 +02:00
takaram 5512d64521 Upgrade actions/checkout and actions/cache (#870) 2023-03-25 15:38:18 +01:00
Simon Wisselink 2038890f19 Changelog 2023-03-24 12:19:40 +01:00
Simon Wisselink e75165565e Implement fix and tests 2023-03-24 12:19:34 +01:00
Simon Wisselink 3d2a8dc5fd Update SECURITY.md with correct version info. 2023-02-23 22:44:34 +01:00
Simon Wisselink 2764816407 Add missing dirs 2023-02-23 22:30:15 +01:00
Simon Wisselink 801d186ea4 CompileCheck test and extra note on how it works in docs 2023-02-23 22:17:06 +01:00
Simon Wisselink 09d26579ce Some additional unit tests 2023-02-23 22:06:37 +01:00
Simon Wisselink badcae6e0c Finished improving designers docs 2023-02-06 14:42:31 +01:00
Simon Wisselink 694ff1b733 Improved another chunk of the designers docs 2023-02-06 10:40:00 +01:00
Simon Wisselink 1e0d25638e WIP improving the docs 2023-02-05 23:14:10 +01:00
Simon Wisselink 51ed0d6791 fixes to docs 2023-02-03 22:31:59 +01:00
Simon Wisselink c94d3ddafa multiversion mkdocs config 2023-02-03 22:29:08 +01:00
Simon Wisselink 5fdcb3c6fa Fix error in docs on prepend/append. Fixes #818. 2023-01-31 11:24:20 +01:00
Adrien Poupa 5988116c81 PHP 8.1 deprecation warnings on null strings in modifiers (#834) 2023-01-17 00:24:23 +01:00
Simon Wisselink 73ff8fd3d0 Fix unit tests that broke because now is now in 2023 2023-01-13 22:19:17 +01:00
Simon Wisselink d900a0ef4a Added variable scope test for multi-level extends resource 2023-01-13 19:23:12 +01:00
Simon Wisselink a34ee98e21 Allow dereferencing of non-objects accross all supported PHP versions (#832)
Fixes #831
2022-11-24 18:44:19 +01:00
Simon Wisselink 4d1cf61bb8 Simplify test running to support all phpunit cmdline options 2022-11-24 18:24:17 +01:00
Simon Wisselink c0a6b641bf Treat undefined vars and array access of a null or false variables equivalent across all supported PHP versions (#830)
* Added test to see what changed exactly

* Treat undefined vars and array access of a null or false variables
  equivalent across all supported PHP versions

* Removed 2 tests that produce inconsistent results between PHP7.x versions.

* Fix regex matching for slightly different error message for php7.1
2022-11-24 09:43:51 +01: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 c02e9e135e Merge branch 'release/4.3.0' 2022-11-22 22:47:32 +01:00
Simon Wisselink 67ab8f6879 version bump 2022-11-22 22:47:30 +01:00
Simon Wisselink 773b3b4b7c Change file permissions for directories and respect umask for written files. (#828)
Fixes #548
Fixes #819
2022-11-22 22:31:54 +01:00
Hunman 613c5d691c Make SmartyCompilerException play nicer with error handler libraries (#782)
* Make SmartyCompilerException play nicer with error handler libraries

Added a new constructor, which accepts a filename and a line number too
(similar to ErrorException, except no severity parameter)
This way error handlers will display the correct file's correct line as
the source of the exception, instead of the template's line in the
core of the parser (php file)

Kept the __toString() method, but removed $source, $desc, and $template

* Revert the breaking changes
2022-11-22 21:58:13 +01:00
Progi1984 c016895166 PHP8.2 compatibility (#775)
* PHP8.2 compatibility

* PHP8.2 compatibility : Fixed unit tests

* PHP8.2 compatibility : Replace ENT_COMPAT by ENT_QUOTES | ENT_SUBSTITUTE | ENT_HTML401

* PHP8.2 compatibility : Remove deprecated utf8_decode

* PHP8.2 compatibility : Remove HTML-ENTITIES parameter

* Removed some unused code for clarity, updated the changelog.

* More concise escape implementation and unit test to cover both modifierplugin and modifiercompiler.

* Fix htmlall unescape of quotes without mbstring too

Co-authored-by: Simon Wisselink <s.wisselink@iwink.nl>
2022-11-22 21:22:57 +01:00
Andrew Dawes f81720941c Fixed several typos and grammar errors (#821) 2022-10-22 22:08:38 +02:00
Simon Wisselink 1ff79c6c38 Update changelog
Closes #816
2022-09-27 12:24:08 +02:00
Simon Wisselink 254b5cabee Dropped remaining references to removed PHP-support in Smarty 4 from docs, lexer and security class. 2022-09-27 12:21:01 +02:00
Raimondas Rimkevičius 1b556c7077 Use __DIR__ instead of dirname(__FILE__) (#817) 2022-09-27 12:03:34 +02:00
Simon Wisselink 4550fc0339 Using PHP functions as modifiers now triggers a deprecation notice (#814)
Fixes #813
2022-09-23 00:09:00 +02:00
Scott Newton 4fc39d59a5 Bug fix for underscore in template name (#581)
* Corrected bug #578, where underscore characters were being stripped from template names when using a custom resource
* Increased the maximum template name length to 127 characters when using a custom resource
2022-09-22 23:56:18 +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 612bd3f657 Fixed PHP8.1 deprecation errors in strip_tags (#803) 2022-09-22 14:55:20 +02:00
Simon Wisselink 9eea30ec1e Removed now superfluous phpunit.sh 2022-09-22 14:44:45 +02:00
Simon Wisselink ea95e8b047 Re-organize all testrunners to use the same script(s). (#812) 2022-09-22 14:31:49 +02:00
Simon Wisselink 474138fd7e Updated changelog 2022-09-22 14:31:01 +02:00
Mathias b91c04bfcf Fixed PHP8.1 deprecation errors passing null to parameter in trim (#807)
Fixed a PHP 8.1 deprecation error:  trim(): Passing null to parameter #1 ($string) of type string is deprecated in cacheresource_keyvaluestore.php on line 247 and in cacheresource_keyvaluestore.php on line 431
2022-09-22 14:29:51 +02:00
Simon Wisselink c53342c9fc Silence deprecation errors for strtime in PHP8.1 or higher
Fixes #672 (#811)
2022-09-22 14:11:36 +02:00
Simon Wisselink f8a958cd53 Update changelog 2022-09-21 21:56:39 +02:00
Jonathan Stoll 45345e75ec Fix Variable Usage (#808)
Fix Variable Usage in Exception message when unable to load subtemplate
2022-09-21 21:54:41 +02:00
Simon Wisselink bf7d6b8bd8 Include docs en demo in the releases.
Fixes #799
2022-09-20 22:45:16 +02:00
Simon Wisselink 32a11b34ea Added changelog 2022-09-18 17:18:32 +02:00
Storyxx db80246b58 fix compilation for caching templates (#801) 2022-09-18 17:15:56 +02:00
Hypolite Petovan d683641f90 Fix wrong indentation in libs/plugins/modifier.capitalize.php (#802) 2022-09-18 11:14:59 +02:00
Simon Wisselink e2e68b3622 clean output buffer for Throwable instead of just Exception (#797)
Fixes #514
2022-09-14 13:47:36 +02:00
Simon Wisselink ffa2b81a8e Merge branch 'release/4.2.1' 2022-09-14 12:59:01 +02:00
Simon Wisselink c693d81370 version bump 2022-09-14 12:58:59 +02:00
Simon Wisselink 813c83f7a3 Fixed unselected year/month/day not working in html_select_date
Fixes #395
2022-09-14 12:44:37 +02:00
Simon Wisselink 55ea25d1f5 Applied appropriate javascript and html escaping in mailto plugin to counter injection attacks
Fixes #454
2022-09-14 11:38:18 +02:00
Simon Wisselink d304d349b4 Fixed PHP8.1 deprecation errors in capitalize modifier
Fixes #789
2022-09-13 12:19:44 +02:00
Simon Wisselink 7494818434 prevent double CI workflows in PRs 2022-09-12 16:02:42 +02:00
Simon Wisselink 50d5890eac Exclude unit test files from git export 2022-09-12 15:52:32 +02:00
Simon Wisselink 6872e78238 Utility script for running unit tests on all PHP versions locally 2022-09-12 15:50:09 +02:00
Simon Wisselink 5479e3362c Fixed use of rand() without a parameter in math function (#795)
* Fixed use of `rand()` without a parameter in math function
Fixes #794
2022-09-12 12:13:42 +02:00
Simon Wisselink f8f97b4e2d Fixed PHP8.1 deprecation errors in upper modifier #788 2022-09-10 12:34:20 +02:00
Mark Fettig 1bc7c722a3 address PHP 8.1 'explode', 'number_format', and 'replace' deprecations (#755) 2022-09-09 22:39:24 +02:00
Simon Wisselink 02968a82b5 Update SECURITY.md
Removed comment that still indicated v4 wasn’t released yet.
2022-08-16 22:43:47 +02:00
Simon Wisselink 97aeb14c6f Merge branch 'release/4.2.0' 2022-08-01 23:57:38 +02:00
Simon Wisselink ed454551a3 version bump 2022-08-01 23:57:36 +02:00
Simon Wisselink f4b26a3cbf Fixed second param of unescape modifier (#778)
Fixes #777
2022-08-01 23:49:19 +02:00
Simon Wisselink 20a8026ccd Merge branch 'fix-issue-549-v3' of github.com:AnrDaemon/smarty into AnrDaemon-fix-issue-549-v3 (#771) 2022-07-19 22:55:07 +02:00
Simon Wisselink 27910bf2c1 git push origin masterMerge branch 'JonisoftGermany-master' 2022-07-17 00:54:29 +02:00
Simon Wisselink cb95216671 Changelog 2022-07-17 00:54:20 +02:00
Simon Wisselink d6ac3297df Merge branch 'master' of github.com:JonisoftGermany/smarty into JonisoftGermany-master 2022-07-17 00:53:25 +02:00
Simon Wisselink 560475a2f2 Do not use obsolete smarty properties '_dir_perms', '_file_perms', 'plugin_search_order' in our own code. (#772) 2022-07-17 00:13:57 +02:00
Gunnar Kreitz 382d66305d Fix PHP 8.1 htmlspecialchars deprecation (#766) 2022-07-14 23:51:26 +02:00
Simon Wisselink 44bac8d58c add local testrunners for all supported PHP versions using docker. (#770) 2022-07-14 23:50:22 +02:00
Simon Wisselink f8e1ba76f7 Replaced outdated references to SMARTY_RESOURCE_CHAR_SET in docs with Smarty::$_CHARSET. 2022-06-15 22:12:38 +02:00
Simon Wisselink 629504485f Add CVE to changelog 2022-05-17 14:58:05 +02:00
Simon Wisselink 71036be8be Merge branch 'release/4.1.1' 2022-05-17 14:56:28 +02:00
Simon Wisselink 78f0cf5f65 version bump 2022-05-17 14:56:26 +02:00
Simon Wisselink 64ad6442ca Merge branch 'security/blockfunctioninjection' 2022-05-17 14:55:47 +02:00
Simon Wisselink 7eff7d6fb0 Changelog 2022-05-16 13:31:15 +02:00
Simon Wisselink 05f1a7deda Replace '*/' in user supplied input in C-style comments with '* /'. 2022-05-16 12:34:49 +02:00
Simon Wisselink 3f97b7352e Changelog 2022-04-26 22:11:59 +02:00
Simon Wisselink a6711b3833 Merge pull request #727 from liborm85/escape-modifier-fix
PHP 8.1: fix deprecation in escape modifier
2022-04-26 22:11:33 +02:00
Simon Wisselink 52056ce65a Changelog 2022-04-26 22:09:50 +02:00
Simon Wisselink 8b96efad45 Merge pull request #743 from xorti/fix-php81-rtrim-calls
Fix PHP 8.1 deprecated warning when calling rtrim
2022-04-26 22:09:10 +02:00
Simon Wisselink bfa02f3b91 Merge branch 'patch-1' 2022-04-26 22:06:29 +02:00
Simon Wisselink 89dc506638 Add changelog 2022-04-26 22:05:34 +02:00
Stephen Sigwart e68065bc33 Exclude demo from export and composer 2022-04-01 22:48:14 -04:00
Stephen Sigwart db2547287c Exclude docs from export and composer 2022-04-01 22:46:50 -04: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 8aeb5d6821 Merge pull request #726 from pH-7/patch-1
gitattributes: Ignore `.github` folder for distribution
2022-02-13 22:34:29 +01:00
Libor M a2e1df1768 PHP 8.1: fix deprecation in escape modifier 2022-02-08 13:30:19 +01:00
♚ PH⑦ de Soria™♛ fe6d333c60 Ignore .github folder for distribution
`.github` wasn't added here was it got created. However, we don't want `.github` for the distribution builds. Further info about this: https://www.pixelite.co.nz/article/using-git-attributes-exclude-files-your-release/
2022-02-08 06:32:27 +10:30
Simon Wisselink 50c4604857 Added issue 721 to changelog 2022-02-07 09:43:49 +01:00
Simon Wisselink e5a6ff42f8 Merge pull request #725 from smarty-php/bugfix/699
prevent float to int cast deprecation warning in truncate modifier
2022-02-06 22:25:34 +01:00
Simon Wisselink 3cc56392c6 prevent float to int cast deprecation warning in truncate modifier
Fixes #699
2022-02-06 22:20:05 +01:00
Simon Wisselink 17025423e1 Merge pull request #724 from smarty-php/bugfix/706
Fix PHP 8.1 deprecation notices in demo/plugins/cacheresource.pdo.php
2022-02-06 22:09:39 +01:00
Simon Wisselink 18d3e564da Merge branch 'master' into bugfix/706 2022-02-06 22:05:01 +01:00
Simon Wisselink 0d2c38b482 fix PHP 8.1 deprecation notices in demo/plugins/cacheresource.pdo.php
Fixes #706
2022-02-06 22:03:24 +01:00
Simon Wisselink f90348971b Merge pull request #722 from kochichi/bugfix/721
math equation return warning: max(x, y)
2022-02-06 21:54:54 +01:00
Simon Wisselink 9e0536de18 Merge branch 'release/4.1.0' 2022-02-06 21:34:27 +01:00
Simon Wisselink 265cf4f3bc version bump 2022-02-06 21:34:26 +01:00
Simon Wisselink 47f95ad324 Merge pull request #717 from vemaeg/php81-doc
Updating PHP 8.0 to 8.1 in the docs and add php8.1 test runner.
2022-02-06 21:30:52 +01:00
Pavel Kochman 02633ecaba math equation return warning: math: illegal character for : {math equation="max(x, y)" x=$x y=$y} 2022-02-04 21:03:25 +01:00
Thomas A. Hirsch 6786623afb Activating jit compiler for ubuntu-latest + php 8.1 2022-01-21 17:58:35 +01:00
Thomas 2d97169086 Merge branch 'smarty-php:master' into php81-doc 2022-01-21 17:57:27 +01:00
Thomas 0f098802c6 Create getting-started.md 2022-01-21 17:55:23 +01:00
Thomas bbcd5817f6 Update README.md 2022-01-21 17:51:45 +01:00
Simon Wisselink 612094d763 Updated changelog 2022-01-21 10:21:00 +01:00
Simon Wisselink 0ef0dda825 Merge pull request #713 from vemaeg/php81
PHP 8.1 compatibility (without IntlDateFormatter)
2022-01-21 10:18:48 +01:00
Thomas BACCELLI cef8951100 Add PHP 8.1 tests 2022-01-18 15:56:23 +01:00
Thomas BACCELLI 323aefa89f Fix phpunit warning 2022-01-18 15:56:23 +01:00
Thomas A. Hirsch 277648b81c Cherry-picked from da76d927ed
Co-Authored-By: Thomas BACCELLI <tbaccelli@gmail.com>
2022-01-18 15:56:23 +01:00
Thomas A. Hirsch 8d3a7af308 Cherry-picked from da76d927ed
Co-Authored-By: Thomas BACCELLI <tbaccelli@gmail.com>
2022-01-18 15:56:23 +01:00
Simon Wisselink cdf0f2b164 Merge branch 'release/4.0.4' 2022-01-18 00:17:19 +01:00
Simon Wisselink 995b7eb36f version bump 2022-01-18 00:17:17 +01:00
Claas Augner 059bea274c Support multiple operators in math equations (#708)
* fix(math): fix equation regexp

Fixes #702.
2022-01-18 00:10:17 +01:00
Simon Wisselink f707dadecb Merge branch 'release/4.0.3' 2022-01-10 10:52:14 +01:00
Simon Wisselink ace1c8e90f version bump 2022-01-10 10:52:13 +01:00
Simon Wisselink 19ae410bf5 Merge pull request from GHSA-4h9c-v5vg-5m6m
* Prevent evasion of the static_classes security policy.

* Updated deprecated exception expectations.
2022-01-10 10:48:27 +01:00
Simon Wisselink baad3115cd Fixed PHPUnit expected Exceptions. (#701) 2022-01-10 09:46:01 +01:00
Simon Wisselink 6f4f06db7e Merge branch 'release/4.0.2' 2022-01-10 00:09:08 +01:00
Simon Wisselink a535445dfd version bump 2022-01-10 00:09:06 +01:00
Simon Wisselink 215d81a9fa Merge pull request from GHSA-29gp-2c3m-3j6m
* Temporary fix. Waiting for CVE

* Add CVE
2022-01-10 00:01:43 +01:00
Simon Wisselink efb416e5ef Fixed unit tests 2022-01-09 23:29:43 +01:00
Simon Wisselink 29c0e5ac51 Merge branch 'release/4.0.1' 2022-01-09 23:20:45 +01:00
Simon Wisselink 23be620fc8 version bump 2022-01-09 23:20:44 +01:00
Simon Wisselink e6ab34654b Merge remote-tracking branch 'origin/master' 2022-01-09 23:15:44 +01:00
Simon Wisselink c7576eb1a1 Rewrote the mailto function to not use eval when encoding with javascript 2022-01-09 23:15:25 +01:00
Marc Laporte 56aadc697f Fix a typo in docs (#690) 2021-12-22 23:01:19 +01:00
Darek Krzysztofiak cd962280ce Fix for php 8.0 (#687)
* Fix PHP 8.0
$parts must be an array, because the argument for count() must be countable, mb_split() returns an array or a boolean.
2021-12-03 17:13:52 +01:00
Simon Wisselink cb5efd04c3 Improve the documentation, bringing it up to date with PHP7/8 and Smarty 4 and providing
a more logical introduction and getting started experience.
2021-12-03 16:51:08 +01:00
Simon Wisselink 3a91df797e added links to appndixes, removed unuseful old appendixes 2021-12-03 12:18:46 +01:00
Simon Wisselink 6983788dfb Merge branch 'master' of github.com:smarty-php/smarty 2021-12-03 12:15:04 +01:00
Simon Wisselink 09875a61f4 changed homepage links in composer.json 2021-12-03 12:04:13 +01:00
Simon Wisselink 428a701b18 Feature/add docs (#689)
* Add converted docs repo

* Set theme jekyll-theme-minimal

* Removed BC docs, added TOC

* Added TOCs, rewrote most important links in documentation. Linked README to new Github Pages site

* some link fixes
2021-12-03 11:59:22 +01:00
Simon Wisselink baebd59bb4 Merge branch 'release/4.0.0' 2021-11-25 22:18:25 +01:00
Simon Wisselink e603269eda version bump 2021-11-25 22:18:24 +01:00
Simon Wisselink 572cbe5595 Make make-release.sh safer by checking for version number. 2021-10-22 15:59:46 +02:00
Simon Wisselink ffb2fd923b Update README.md. Fix references to Smarty3. Get rid of old changelog-like files. 2021-10-13 22:49:43 +02:00
Simon Wisselink 64a6333d5d Merge branch 'release/4.0.0-rc.0' 2021-10-13 12:16:20 +02: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 9d4f8309ed Merge branch 'release/3.1.40' 2021-10-13 12:04:31 +02:00
Simon Wisselink 7c4354e7b8 version bump 2021-10-13 12:04:29 +02:00
Simon Wisselink 770bc4aae2 Merge branch 'm-haritonov-escape' 2021-08-19 16:15:57 +02:00
Simon Wisselink 0ff7ba5ab6 Add changelog 2021-08-19 16:13:30 +02:00
Simon Wisselink 3b0fd82849 Merge branch 'escape' of https://github.com/m-haritonov/smarty into m-haritonov-escape 2021-08-19 15:26:27 +02:00
Ikko Ashimine 1a68b79b6c Update README.md (#668)
github -> GitHub
2021-08-18 23:23:36 +02:00
Michael Voříšek e3eabe0b96 Delete uninted file expectException (#664) 2021-05-25 21:18:07 +02:00
Simon Wisselink 4698dd9fb0 Changelog 2021-03-21 21:24:32 +01:00
David Goodwin 039043e5a2 Update modifier.escape.php (#649)
trigger a notice if an incorrect modifier was used (E.g.|escape:quotes vs |escape:quote).
2021-03-21 21:21:55 +01:00
Mihail Haritonov 9cde36e3bc plugins: escape: javascript escaping secure fix 2021-02-28 16:44:56 +03:00
Simon Wisselink 290aee6db3 Update CHANGELOG.md
Add CVE's
2021-02-21 22:23:45 +01:00
Simon Wisselink e2485fa45e Create SECURITY.md 2021-02-21 22:03:44 +01:00
Simon Wisselink e27da524f7 Merge branch 'release/3.1.39' 2021-02-17 22:57:51 +01:00
Simon Wisselink a21f59663c version bump 2021-02-17 22:57:50 +01:00
Simon Wisselink 3148d406a0 changelog 2021-02-17 22:57:33 +01:00
Simon Wisselink 4f634c0097 Merge branch 'bugfix/tplfunction_sandbox_escape' 2021-02-17 22:52:34 +01:00
Simon Wisselink c9272058d9 Merge branch 'bugfix/template_object_sandbox_escape' 2021-02-17 22:51:38 +01:00
Simon Wisselink e66e293a8a Do not push release automatically in make release script, to enable a chance to catch any errors. 2021-02-17 22:50:52 +01:00
Simon Wisselink 74cab5a56b updated changelog header to security 2021-02-17 22:30:35 +01:00
Simon Wisselink 8fc66e27a7 Cannot use in Smarty3 yet, revert to @expectedException 2021-02-01 10:33:00 +01:00
Simon Wisselink 2543174460 Cannot use in Smarty3 yet, revert to @expectedException 2021-02-01 10:31:20 +01:00
Simon Wisselink 288a54f6b0 Add unit test 2021-01-24 23:52:45 +01:00
Simon Wisselink 165f1bd4d2 Fixed Code injection vulnerability by using illegal function names 2021-01-24 23:44:07 +01:00
Simon Wisselink 6463519a6c Prevent access to .template_object when in security mode to prevent PHP code injection vulnerability 2021-01-24 23:13:26 +01:00
Simon Wisselink fedc127057 Mark tests that use sleep calls as slow, so we can ignore them when running unit tests in development 2021-01-16 23:01:15 +01:00
Ikko Ashimine 3af2df20a4 Fix typo in StreamVariableTest.php (#616)
existant -> existent
2021-01-08 17:28:33 +01:00
Simon Wisselink 63b3c0aed0 Merge branch 'release/3.1.38' 2021-01-08 15:05:42 +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 f65e7ddd22 fixed changelog 2021-01-07 00:34:08 +01:00
Simon Wisselink 92e05d4f8d Brought lexer source functionally up-to-date with compiled version (#625)
Fixes #621
2021-01-07 00:26:28 +01:00
Simon Wisselink e2b28167f8 Clarify correct LGPL version.
Fixes #612
2021-01-05 22:23:13 +01:00
Libor M 820782cd80 const fix for usage with comparison operators (#618)
Fixes #609 #613
2021-01-05 22:07:44 +01:00
Simon Wisselink c295786e43 Fixes for php8.0.0beta3 (#608)
* Set $errcontext argument optional to support PHP 8

- Argument is optional and deprecated in PHP 7.2

* Getting ready for PHP8, handling changed error levels/handlers mostly

* php5 compat syntax

* Updated UndefinedTemplateVarTest for PHP8 (and disabled a check for PHP<5.6) and re-enabled php:nightly in travis config

* Attempt to fix travis runs for (almost) all php versions supported

* Fix unit tests for php8, force composer to think we are still php7 to pick a supported phpunit and being less specific about an error msg because PHP8 is in active development and the exact wording is changing.

* Fixed a unit test that accidentally passed on phpunit < 7 because of sloppy string comparison.

* changelog

* run travis in xenial where possible for latest php versions. Fix unit tests from freakingo over inconsistent error messages in php8-beta.

* Incorporated AnrDaemons suggestions, making composer figure out the required phpunit version instead of specifying it explicitly and removing a unneeded error supression (@).

Co-authored-by: Jorge Sá Pereira <me@jorgesapereira.com>
2020-09-12 21:37:31 +02: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
Simon Wisselink a5934a755d Fixed a unit test that accidentally passed on phpunit < 7 because of sloppy string comparison. 2020-09-11 13:22:45 +02:00
Stoll, Jonathan dff1955cd5 Update to HTML5-syntax in debug template
* Replace deprecated tags
* Use CSS3 selectors
* Update html-frame
* Remove deprecated syntax
* Harmonize syntax in general
2020-06-19 21:20:46 +02:00
Simon Wisselink 5a72624380 Test travis config for PHP5 versions (#592)
* Run tests for PHP5.x
* Start from 5.3 since composer requires it and without it we cannot install phpunit
* Specify dist for 5.3
* Disabled nightly testing because phpunit doesn't support php8 yet.
2020-05-05 15:08:31 +02:00
Simon Wisselink 1418c8c422 Merge branch 'AnrDaemon-fix-php5.3-compat' 2020-05-05 09:21:07 +02:00
Simon Wisselink f46c13b32a Updated changelog 2020-05-05 09:20:56 +02:00
AnrDaemon eae19f23b9 PHP 5.3 compatibility fixes 2020-05-05 01:37:36 +03:00
Sławomir Kaleta e1c050a32c Fix comment - Method can return string (#583) 2020-04-14 17:26:20 +02:00
Simon Wisselink fd148f7ade Merge branch 'release/3.1.36' 2020-04-14 16:44:26 +02:00
Simon Wisselink 07772aac90 version bump 2020-04-14 16:44:24 +02:00
Simon Wisselink 08227651fc Fixed #584 2020-04-14 16:44:09 +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
Simon Wisselink 97f700971f Merge branch 'release/3.1.35' 2020-04-14 00:02:48 +02:00
Simon Wisselink a0abc47588 version bump 2020-04-14 00:02:39 +02:00
Simon Wisselink 728a584ad5 Moved changelog to a keepachangelog.com format and added a release script 2020-04-14 00:02:18 +02:00
Simon Wisselink 290f7cfc3d Moved the isset tests into the test suite 2020-04-13 23:44:39 +02:00
Simon Wisselink 48d24b7ad1 Fix repo layout for package maintainers (#571)
* Do not ignore lexer subfolder for export as this contains source files and add smarty-lexer as a composer dev-dependency.
* Remove unit tests etc from archive export

Please note that the generated lexer / parser classes are not exactly equivalent, as they have been editing to conform to coding standards afterwards. I did a quick review and there don't seem to be any differences in semantics though.
2020-04-13 22:32:23 +02:00
Simon Wisselink 19ef8342aa Strip now removes whitespaces after comment (#582)
* Mark text sections as to be stripped, but do not strip them right away. Combine equivalent sections in chunks at the template level and strip combined chunks where possible.
- simplified Smarty_Internal_TemplateCompilerBase::processText along the way
Fixes #447
2020-04-13 22:27:42 +02:00
Simon Wisselink 4f89f6d84f Throw SmartyException when setting caching attributes for cacheable plugin as compiling this would fail (#573)
Fixes #457
2020-04-13 22:26:24 +02:00
Simon Wisselink 4396351d75 Switched to a more advanced regex to test wheter parameter is a variable (#567)
* This appears to fix #453, #498, #499 and possibly more issues.
2020-04-13 22:24:29 +02:00
Simon Wisselink 17d4d43624 Feature/merge smarty-phpunit into tests subfolder (#580)
* Removed unneeded files and replace dummy.txt with .gitignore files
* Synced unit tests with master codebase, noted TODO's, fixed phpunit scripts and travis config
* fix php7.4 deprecation and remove php7.4 from travis allow_failures since php7.4 is current stable

Co-authored-by: Uwe Tews <uwe.tews@googlemail.com>
Co-authored-by: Uwe Tews <uwe.tews@gmail.com>
Co-authored-by: AnrDaemon <anrdaemon@yandex.ru>
2020-04-13 15:30:52 +02:00
Simon Wisselink 61e7412807 Merge pull request #570 from vadimkuragkovskiy/master
fix minor typo
2020-04-12 11:41:22 +02:00
Vadim Kuragkovskiy 38b5ac72fa fix minor typo 2020-02-07 18:56:25 +02:00
Simon Wisselink 4b29dfce11 Merge pull request #566 from smarty-php/bugfix/506_foreachelse_on_arrayiterators
Bugfix/506 foreachelse on arrayiterators
2020-01-27 16:08:35 +01:00
Simon Wisselink e0df3d47e2 Ignore templates_c dir 2020-01-27 16:04:04 +01:00
Simon Wisselink 62d772e734 Fixed broken nesting and null handling. 2020-01-27 16:02:02 +01:00
Simon Wisselink 388993e9ca Fix foreachelse on arrayiterators
Keep track of main loop using a do_else variable.
Fixed #506
2020-01-27 15:24:45 +01:00
Simon Wisselink 97c27a0f2f Merge pull request #503 from SeahunOh/master
fix typo
2020-01-26 23:49:57 +01:00
Monte Ohrt b2ecd98ae0 update changelog to reflect resent pull request merges 2020-01-13 18:56:03 -06:00
mohrt 4911f49b9c Merge pull request #535 from glensc/patch-1
exclude error_reporting.ini from git export
2020-01-13 18:51:34 -06:00
mohrt a62a7caf97 Merge pull request #540 from Hunman/master
Fixing problem with assigning value to object variables as arrays in smarty_internal_compile_assign
2020-01-13 18:50:41 -06:00
mohrt 704fcef160 Merge pull request #542 from IT-Experte/master
Fixed using wrong get and set methods from class memcached
2020-01-13 18:48:56 -06:00
mohrt d1f37449a9 Merge pull request #546 from matks/enhance-readme
Add Travis badge and php compatibility infos in readme
2020-01-13 18:46:14 -06:00
mohrt 9e9961feae Merge pull request #551 from bits4breakfast/master
Replace callback typehint with callable
2020-01-13 18:45:23 -06:00
mohrt 4fb3f616b2 Merge pull request #560 from JercSi/master
Typo in exception message
2020-01-13 18:44:07 -06:00
mohrt e4239d095a Merge pull request #563 from caugner/patch-1
Fixes the change log date of the 3.1.34 release
2020-01-13 18:42:54 -06:00
Claas Augner 5547e0177b fix change log date 2020-01-13 18:51:37 +01:00
JercSi b9b9d30144 Typo in exception message
Added space between 'line' and line number.
2019-12-20 09:49:32 +01:00
Monte Ohrt 0137c2e7e6 update change log version 2019-12-12 18:56:47 -06:00
Matteo Galli c7ee6a3333 Replace callback typehint with callable
`callback` is not a valid PHP type and makes static analysis tools failing
2019-08-14 09:34:42 +02:00
Mathieu Ferment 651b129700 Add Travis badge and php compatibility infos in readme 2019-07-04 11:11:51 +02:00
Mathias 6d8d3b67d8 Changed read and write methods for compatibility with class memcached
The methods of the memcached class have different parameters than the memcache class.
2019-05-24 12:08:44 +02:00
Sanyi 7bc96d56fe Fix missing parenthesises in smarty_internal_compile_assign 2019-05-13 17:15:14 +02:00
Elan Ruusamäe 78924d8d68 exclude error_reporting.ini from git export 2019-03-02 18:11:04 +02:00
uwetews c9f0de05f4 Fix PHPunit tests for PHP7 https://github.com/smarty-php/smarty/pull/532 2019-02-28 07:42:20 +01:00
uwetews f93f95787f Fix PHPunit tests for PHP7 https://github.com/smarty-php/smarty/pull/532 2019-02-28 05:59:23 +01:00
uwetews 70fc2fd276 Travis fix 2018-12-09 05:06:53 +01:00
uwetews 3ddd960337 Travis fix 2018-12-09 04:42:05 +01:00
uwetews 20bb96c1b0 Revert "Travis fix"
This reverts commit eca7ec7f48.
2018-12-09 04:28:51 +01:00
uwetews 22cb50fcda Revert "Travis fix"
This reverts commit 2db8437354.
2018-12-09 04:28:28 +01:00
uwetews f0d1b52094 Revert "Travis fix"
This reverts commit 4dbaa25cee.
2018-12-09 04:27:56 +01:00
uwetews 4dbaa25cee Travis fix 2018-12-09 04:23:02 +01:00
uwetews 2db8437354 Travis fix 2018-12-09 04:17:23 +01:00
uwetews eca7ec7f48 Travis fix 2018-12-09 04:05:30 +01:00
uwetews d453d9e667 Merge pull request #515 from AnrDaemon/use-classmaps
Use Composer classmap autoload instead of custom bootstrap.
2018-11-28 07:01:04 +01:00
AnrDaemon dc2484dd3c Merge branch 'master' into use-classmaps 2018-11-26 21:21:43 +03:00
AnrDaemon 91af98d328 Tweaked the composer.json a little. 2018-11-26 20:58:42 +03:00
uwetews 69c6a0d650 Merge pull request #509 from jplusc/patch-1
minor typo in NEW_FEATURES.txt (setLiterals)
2018-11-11 09:16:56 +01:00
jplusc 69e8f3f892 minor typo in NEW_FEATURES.txt (setLiterals)
function is actually 'setLiterals' but docs refer to 'setLiteral'
2018-11-10 21:44:33 -05:00
shpik 5ccdf3a3fc fix typo
fix typo
2018-11-01 01:01:47 +09: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 9301ba4bfc 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:34:34 +02:00
uwetews 5204723bc6 update .travis.yml 2018-09-18 05:36:27 +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
AnrDaemon b9dbd46289 Merge branch 'master' into use-classmaps 2018-09-14 17:25:51 +03: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 7b64226e16 - reformating for PSR-2 coding standards https://github.com/smarty-php/smarty/pull/483 2018-08-31 16:46:20 +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 d52a04fba1 travis configuration problem fpr PHP 5.4 2018-08-31 16:24:31 +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
Uwe Tews 3a78a21f14 Update .gitattributes to force eol=lf 2018-08-30 17:38:07 +02:00
uwetews a1f6720318 - 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:46:29 +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 72185fb743 Merge pull request #477 from dusta/master
Fixed #476, Wrong demo directory location
2018-08-19 11:48:13 +02:00
uwetews 7096c99ff3 - 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 (reverted from commit 2fe3a30e75) (reverted from commit ed674ee050)
2018-08-19 10:30:28 +02:00
uwetews ed674ee050 - 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 (reverted from commit 2fe3a30e75)
2018-08-19 10:22:47 +02:00
Sławomir Kaleta d191935127 Fixed #476, Wrong demo directory location 2018-08-19 09:47:58 +02:00
uwetews 2fe3a30e75 - 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:41:43 +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
uwetews b5e5085391 Merge pull request #452 from dusta/Update-PSR-2
Update PSR-2
2018-08-12 03:20:33 +02:00
AnrDaemon da29452d74 Updated composer.json with require-dev deps. 2018-07-19 20:03:29 +03:00
AnrDaemon e9dacb4fd0 Integrate ongoing master. 2018-06-19 07:51:02 +03: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 e2aec4d011 Fix annotation https://github.com/smarty-php/smarty/issues/441 2018-05-17 08:12:26 +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 cb59fc5537 Delete unwanted file 2018-04-28 05:32:02 +02:00
Uwe Tews c9dbe1d08c - bugfix regarding Security Vulnerability did not solve the problem under Linux 2018-04-26 21:38:08 +02:00
Uwe Tews 2e081a51b1 - bugfix regarding Security Vulnerability did not solve the problem under Linux 2018-04-26 18:06:45 +02:00
Uwe Tews f9ca3c63d1 - bugfix regarding Security Vulnerability did not solve the problem under Linux 2018-04-26 13:02:51 +02:00
Uwe Tews ac9d4b587e Release version 3.1.32 2018-04-24 16:53:33 +02:00
Uwe Tews e83bdc2ece Revert "remove - php: nightly test"
This reverts commit 216ada91f3.
2018-04-24 16:51:39 +02:00
Uwe Tews bcedfd6b58 Release version 3.1.32 2018-04-24 16:14:10 +02:00
Uwe Tews 216ada91f3 remove - php: nightly test 2018-04-24 16:00:35 +02:00
Uwe Tews a57d514e8c update .travis.yml 2018-04-24 12:41:39 +02:00
Uwe Tews 20c3f70379 update .travis.yml 2018-04-24 12:37:01 +02:00
Uwe Tews c95d3f3a4d - fix compatibility for PHP version < 5.6 2018-04-24 11:33:47 +02:00
Uwe Tews 8d21f38dc3 - bugfix possible Security Vulnerability in Smarty_Security class. 2018-04-24 10:38:18 +02:00
Uwe Tews fbbb292ef0 update access to parent object 2018-04-19 16:04:41 +02:00
Uwe Tews 8bea607b78 fix comment lines of inline subtemplates 2018-04-19 15:57:37 +02:00
uwetews 7c3606e839 Merge pull request #432 from dusta/patch-1
Update README.md
2018-04-19 13:14:12 +02:00
Dusta b2d55b677d Update README.md
Add https, add dots
2018-04-14 20:32:35 +02:00
Uwe Tews 860ebb618e - bugfix plugins may not be loaded if {function} or {block} tags are executed in nocache mode 2018-03-28 07:35:52 +02:00
Uwe Tews 336c07c23f - bugfix plugins may not be loaded if {function} or {block} tags are executed in nocache mode
https://github.com/smarty-php/smarty/issues/371
2018-03-28 07:15:29 +02:00
Uwe Tews cf22e986c0 - new feature {parent} = {$smarty.block.parent} {child} = {$smarty.block.child} 2018-03-28 07:14:29 +02:00
Uwe Tews 0dbace8321 - new feature {parent} = {$smarty.block.parent} {child} = {$smarty.block.child} 2018-03-26 22:35:31 +02:00
Uwe Tews c81948d602 - bugfix preg_replace could fail on large content resulting in a blank page https://github.com/smarty-php/smarty/issues/417 2018-03-23 19:34:18 +01:00
Uwe Tews 3a3b8c75a1 - bugfix preg_replace could fail on large content resulting in a blank page https://github.com/smarty-php/smarty/issues/417 2018-03-23 19:14:53 +01:00
Uwe Tews d646d4678c - bugfix preg_replace could fail on large content resulting in a blank page https://github.com/smarty-php/smarty/issues/417 2018-03-23 19:11:12 +01:00
Uwe Tews d79af55485 - bugfix short form of {section} attributes did not work https://github.com/smarty-php/smarty/issues/428 2018-03-21 15:19:57 +01:00
Uwe Tews b7e7def0b1 - 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
2018-03-21 07:36:11 +01:00
Uwe Tews 60415e6f2a - improvement Smarty::compileAllTemplates() exit with a non-zero status code if max errors is reached https://github.com/smarty-php/smarty/pull/402 2018-03-17 08:31:40 +01:00
Uwe Tews a5961606f3 - bugfix extends resource did not work with user defined left/right delimiter https://github.com/smarty-php/smarty/issues/419 2018-03-16 18:44:47 +01:00
AnrDaemon ca00a31f71 Use Composer classmap instead of bootstrap. 2017-12-05 21:19:17 +03:00
Uwe Tews 93909aacf8 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 2017-11-22 01:21:09 +01:00
Uwe Tews 40ea5d89da - replacement of " by ' 2017-11-20 12:26:48 +01:00
Uwe Tews fcf108b33f bugfix variable filter might not have been loaded in cache file for use in nocache sections. 2017-11-20 11:11:46 +01:00
Uwe Tews 96fd914cc1 bugfix rework of newline spacing between tag code and template text.
now again identical with Smarty2 (forum topic 26878)
2017-11-20 04:07:51 +01:00
Uwe Tews 654659aadf remove html tags from PHPDoc blocks 2017-11-11 07:11:33 +01:00
Uwe Tews 96bcbd2221 fix comment correct last commit 2017-11-11 07:10:35 +01:00
Uwe Tews efe0e4c40c fix comment 2017-11-11 06:44:33 +01:00
Uwe Tews da273df95f remove blanks on line endings 2017-11-06 19:27:14 +01:00
Uwe Tews 5220ca6776 - bugfix {$smarty.section.name.loop} used together with {$smarty.section.name.total} could produce
wrong results (forum topic 27041) 3.1.32-dev-35
2017-11-06 04:58:02 +01:00
Uwe Tews 3fc8abeb98 code cleanup and optimizations 3.1.32-dev-34 2017-11-06 01:02:56 +01:00
Uwe Tews 3799714d53 lexer/parser optimization 2017-11-05 20:04:32 +01:00
Uwe Tews dd9c076dfa - correction of PHPDoc blocks
- minor code cleanup
2017-10-26 10:25:41 +02:00
Uwe Tews 812758225c - optimization replace internal Smarty::$ds property by DIRECTORY_SEPARATOR
version update because of recent commit problems
2017-10-26 06:34:51 +02:00
Uwe Tews 5d8cd94c1d - optimization replace internal Smarty::$ds property by DIRECTORY_SEPARATOR 2017-10-26 06:30:19 +02:00
Uwe Tews 570bc41b12 - optimization replace internal Smarty::$ds property by DIRECTORY_SEPARATOR 2017-10-26 06:14:22 +02:00
Uwe Tews 4575a31e62 - 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.
2017-10-26 06:00:40 +02:00
Uwe Tews 926ed8714b - optimization replace internal Smarty::$ds property by DIRECTORY_SEPARATOR 2017-10-26 05:36:13 +02:00
Uwe Tews f86d251e5b - optimization replace internal Smarty::$ds property by DIRECTORY_SEPARATOR 2017-10-26 05:27:25 +02:00
Uwe Tews c404294a1f - bugfix Smarty version was not filled in header comment of compiled and cached files 2017-10-26 05:09:07 +02:00
Uwe Tews 87f260e3a9 fix Smarty version in header comment (reverted from commit 5ec2e1f62b) 2017-10-26 04:37:39 +02:00
Uwe Tews 41621ca35e - optimization replace internal Smarty::$ds property by DIRECTORY_SEPARATOR (reverted from commit f7a5316205) 2017-10-26 04:37:31 +02:00
Uwe Tews a675aaf68e - optimization replace internal Smarty::$ds property by DIRECTORY_SEPARATOR (reverted from commit f7a5316205) (reverted from commit beaa293eb3) 2017-10-26 04:37:17 +02:00
Uwe Tews f3950a45a7 - bugfix Smarty version was not filled in header comment of compiled and cached files
- optimization replace internal Smarty::$ds property by DIRECTORY_SEPARATOR (reverted from commit 1e787d08f1)
2017-10-26 04:37:05 +02:00
Uwe Tews 8e9108544a - bugfix Smarty version was not filled in header comment of compiled and cached files
- optimization replace internal Smarty::$ds property by DIRECTORY_SEPARATOR (reverted from commit 1e787d08f1) (reverted from commit 42a292d56a)
2017-10-26 04:36:41 +02:00
Uwe Tews 4cbc436599 - optimization replace internal Smarty::$ds property by DIRECTORY_SEPARATOR (reverted from commit f7a5316205) (reverted from commit beaa293eb3) (reverted from commit 86f36196e2) 2017-10-26 04:36:17 +02:00
Uwe Tews eaac933770 - optimization replace internal Smarty::$ds property by DIRECTORY_SEPARATOR (reverted from commit f7a5316205) (reverted from commit beaa293eb3) (reverted from commit 86f36196e2) (reverted from commit 36c6a72015) 2017-10-26 04:36:08 +02:00
Uwe Tews 36c6a72015 - optimization replace internal Smarty::$ds property by DIRECTORY_SEPARATOR (reverted from commit f7a5316205) (reverted from commit beaa293eb3) (reverted from commit 86f36196e2) 2017-10-26 04:35:56 +02:00
Uwe Tews 86f36196e2 - optimization replace internal Smarty::$ds property by DIRECTORY_SEPARATOR (reverted from commit f7a5316205) (reverted from commit beaa293eb3) 2017-10-26 04:19:23 +02:00
Uwe Tews 42a292d56a - bugfix Smarty version was not filled in header comment of compiled and cached files
- optimization replace internal Smarty::$ds property by DIRECTORY_SEPARATOR (reverted from commit 1e787d08f1)
2017-10-26 04:18:28 +02:00
Uwe Tews 1e787d08f1 - bugfix Smarty version was not filled in header comment of compiled and cached files
- optimization replace internal Smarty::$ds property by DIRECTORY_SEPARATOR
2017-10-26 03:38:27 +02:00
Uwe Tews beaa293eb3 - optimization replace internal Smarty::$ds property by DIRECTORY_SEPARATOR (reverted from commit f7a5316205) 2017-10-26 03:37:40 +02:00
Uwe Tews f7a5316205 - optimization replace internal Smarty::$ds property by DIRECTORY_SEPARATOR 2017-10-22 03:38:10 +02:00
Uwe Tews 5ec2e1f62b fix Smarty version in header comment 2017-10-21 23:43:22 +02:00
Uwe Tews 3d7dece088 - bugfix custom delimiters could fail since modification of version 3.1.32-dev-23
https://github.com/smarty-php/smarty/issues/394
2017-10-21 13:14:14 +02:00
Uwe Tews 668d07cda9 disable php5.2 tests 2017-10-18 14:03:22 +02:00
Uwe Tews 338f5a5769 enable PHPunit tests for PHP 5.2 and 5.3 2017-10-18 13:50:29 +02:00
Uwe Tews 19ebab9e4a enable PHPunit tests for PHP 5.2 and 5.3 2017-10-18 13:39:19 +02:00
Uwe Tews e4f41adf5a -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
2017-10-18 09:40:38 +02:00
Uwe Tews 6b97d5cdd5 - unclosed block tag in double quted string must throw compiler exception.
https://github.com/smarty-php/smarty/issues/391 https://github.com/smarty-php/smarty/issues/392
2017-10-12 20:15:42 +02:00
Uwe Tews b271173a2d 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
2017-10-12 08:21:12 +02:00
Uwe Tews 34fc5e6b46 remove phpunit tests for hhvm 2017-10-09 23:50:45 +02:00
Uwe Tews 64ed85a954 enable PHPunit tests for PHP 7.2 and hhvm 2017-10-09 23:28:58 +02:00
Uwe Tews 0bf112c2bb Use phpunit 6.4.1 for PHP 7.1 2017-10-09 21:26:36 +02:00
Uwe Tews 157f51086c Test phpunit 6.4.1 (reverted from commit f60d8a763c) 2017-10-09 17:04:03 +02:00
Uwe Tews 7e84d34363 Use phpunit 6.4.1 for PHP 7.1 2017-10-09 16:38:32 +02:00
Uwe Tews 0f0fdf0200 Use phpunit 6.4.1 for PHP 7.1 2017-10-09 15:22:35 +02:00
Uwe Tews 0b8940c75e Use phpunit 6.4.1 for PHP 7.1 2017-10-09 14:30:08 +02:00
Uwe Tews b98be78cbf Use phpunit 6.4.1 for PHP 7.1 2017-10-09 14:17:47 +02:00
Uwe Tews 0cad914147 Test phpunit 6.4.1 2017-10-09 14:08:36 +02:00
Uwe Tews d76a00673b Test phpunit 6.4.1 2017-10-09 13:56:16 +02:00
Uwe Tews f60d8a763c Test phpunit 6.4.1 2017-10-09 13:53:21 +02:00
Uwe Tews 1bb374c1fb Test phpunit 6.4.1 2017-10-09 13:39:54 +02:00
Uwe Tews 8d3153401a Test phpunit 6.4.1 2017-10-09 13:27:39 +02:00
Uwe Tews f55baf5e73 Test phpunit 6.4.1 2017-10-09 13:19:19 +02:00
Uwe Tews 89d924659e Test phpunit 6.4.1 2017-10-09 13:15:55 +02:00
Uwe Tews 989e49a7de Test phpunit 6.4.1 2017-10-09 13:13:11 +02:00
Uwe Tews 2777efb84e Test phpunit 6.4.1 2017-10-09 13:07:51 +02:00
Uwe Tews 68b73fe153 Test phpunit 6.1 2017-10-09 13:02:59 +02:00
Uwe Tews 030abc6364 Test against 7.1.9
PHPunit does fail on 7.1.10
2017-10-09 10:53:47 +02:00
Uwe Tews b1cc51a380 set error_reporting = E_ALL & ~E_DEPRECATED & ~E_STRICT for PHP versions == 7.1 2017-10-09 10:23:21 +02:00
Uwe Tews e25bc7a291 set error_reporting = E_ALL & ~E_DEPRECATED & ~E_STRICT for PHP versions >= 7.0 2017-10-09 10:13:52 +02:00
Uwe Tews 9ad66c695d Update COMPOSER_RELEASE_NOTES.txt
https://github.com/smarty-php/smarty/issues/373
2017-10-09 08:53:58 +02:00
Uwe Tews 428efa634d - bugfix modification of 9.8.2017 did fail on some recursive
tag nesting. https://github.com/smarty-php/smarty/issues/389
2017-10-07 09:05:54 +02:00
Uwe Tews b0ea1cb5df Improve extension handler 2017-10-07 08:20:18 +02:00
Uwe Tews deb9e12aaa - bugfix {make_nocache} did display code if the template did not contain other nocache code
https://github.com/smarty-php/smarty/issues/369
2017-08-26 16:13:04 +02:00
Uwe Tews 94c2ab7e54 - bugfix templates filepath with multibyte characters did not work
https://github.com/smarty-php/smarty/issues/385
2017-08-26 14:56:02 +02:00
Uwe Tews f90b449d21 - bugfix chained modifier failed when last modifier parameter is a signed value
https://github.com/smarty-php/smarty/issues/327
2017-08-26 11:47:41 +02:00
Uwe Tews 511773ce6b - improvement repeated delimiter like {{ and }} will be treated as literal
https://groups.google.com/forum/#!topic/smarty-developers/h9r82Bx4KZw
2017-08-09 12:58:47 +02:00
Uwe Tews 2c1f0312a1 register autoloader as first in chain 2017-08-09 12:22:37 +02:00
Uwe Tews 6a257a7ad3 - improvement repeated delimiter like {{ and }} will be treated as literal
https://groups.google.com/forum/#!topic/smarty-developers/h9r82Bx4KZw
2017-08-09 12:20:33 +02:00
Uwe Tews 418a1fd443 - improvement repeated delimiter like {{ and }} will be treated as literal
https://groups.google.com/forum/#!topic/smarty-developers/h9r82Bx4KZw
2017-08-09 11:15:33 +02:00
Uwe Tews 353240c38d fixed spelling 2017-08-06 05:01:15 +02:00
Uwe Tews db16d0d2e6 fixed typo 2017-08-06 02:58:05 +02:00
Uwe Tews 30526520b6 - cleanup of _getSmartyObj() 2017-08-05 23:08:59 +02:00
Uwe Tews 5cc9b27784 - bugfix wordwrap modifier could fail if used in nocache code.
converted plugin file shared.mb_wordwrap.php into modifier.mb_wordwrap.php
2017-08-05 19:59:23 +02:00
Uwe Tews c3b331d2ad remove PHP 5.3 test 2017-07-31 23:26:41 +02:00
Uwe Tews da6181f733 Update travis.yml 2017-07-31 23:23:35 +02:00
Uwe Tews 036f1143fa Update travis.yml 2017-07-31 23:09:38 +02:00
Uwe Tews 105651a469 - Call clearstatcache() after mkdir() failure https://github.com/smarty-php/smarty/pull/379 2017-07-31 18:58:41 +02:00
Uwe Tews bcfea52cbf - rewrite mkdir() bugfix to retry automatically see https://github.com/smarty-php/smarty/pull/377
https://github.com/smarty-php/smarty/pull/379
2017-07-30 05:16:31 +02:00
Uwe Tews 5165776aec add link to documentation
https://github.com/smarty-php/smarty/issues/380
2017-07-30 00:39:41 +02:00
uwetews b562e9527e Merge pull request #320 from glensc/patch-1
Update Autoloader.php comment
2017-07-21 08:17:14 +02:00
Uwe Tews 5a8d015ef1 - bugfix solve preg_match() hhvm parameter problem https://github.com/smarty-php/smarty/pull/372 2017-07-21 08:12:33 +02:00
Uwe Tews f3325c4923 Merge pull request #377 from a-shpota/fix-writefile-sysplugin
fix 'mkdir(): File exists' error on create directory from parallel processes
2017-07-21 06:46:13 +02:00
uwetews ba2de9721b Merge pull request #377 from a-shpota/fix-writefile-sysplugin
fix 'mkdir(): File exists' error on create directory from parallel processes
2017-07-21 06:38:05 +02:00
Uwe Tews 67e9d08371 remove hhvm from travis tests 2017-07-21 05:53:22 +02:00
Uwe Tews bd6bf0628e fix travis for hhvm testing 2017-07-21 05:43:05 +02:00
Uwe Tews 614ad1f8b9 - security possible PHP code injection on custom resources at display() or fetch()
calls if the resource does not sanitize the template name
2017-07-21 05:13:54 +02:00
Andrew Shpota 6768340a97 fix 'mkdir(): File exists' error on create directory from parallel
processes
2017-07-14 15:10:12 +03:00
uwetews a6f3a518e1 - improvement replace phpversion() by PHP_VERSION constant.
https://github.com/smarty-php/smarty/pull/363
2017-05-27 14:37:35 +02:00
uwetews 03e2a1c8a2 - bugfix https://github.com/smarty-php/smarty/pull/368 did break the default plugin handler 2017-05-27 12:33:48 +02:00
uwetews ea93486135 - bugfix https://github.com/smarty-php/smarty/pull/368 did break the default plugin handler 2017-05-27 12:18:43 +02:00
uwetews ef889c79e0 - bugfix change compiled code for registered function and modifiers to called as callable to allow closures
https://github.com/smarty-php/smarty/pull/368
2017-05-27 11:30:21 +02:00
uwetews e51b0ac4af - 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
2017-05-27 11:04:00 +02:00
uwetews a49a08748f Remove nightly test. Does hang on PHP 7.2 2017-05-21 19:55:25 +02:00
uwetews 63b578708f disable PHP 5.2 tests 2017-05-21 19:23:25 +02:00
uwetews 0f2d703c63 Add PHP 5.2 to test (reverted from commit 3dbb5c4eae) 2017-05-21 18:59:00 +02:00
uwetews 3dbb5c4eae Add PHP 5.2 to test 2017-05-21 18:34:21 +02:00
uwetews cd1a864751 Add PHP 5.2 to test (reverted from commit 9e7c1f4b0d) 2017-05-21 18:22:43 +02:00
uwetews 9e7c1f4b0d Add PHP 5.2 to test 2017-05-21 18:20:19 +02:00
uwetews f860f7ce88 - bugfix version 3.1.31 did fail under PHP 5.2
https://github.com/smarty-php/smarty/issues/365
2017-05-21 18:19:52 +02:00
uwetews 28688d5ce7 - 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
    fixed bug in above change
2017-05-21 17:14:30 +02:00
uwetews 4fd1f7684e - 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
2017-05-21 16:58:58 +02:00
uwetews 61b59a9ec3 - bugfix remove special treatment of classes implementing ArrayAccess in {foreach}
https://github.com/smarty-php/smarty/issues/332
2017-05-21 02:24:48 +02:00
uwetews da22c961bb - improvement check if ini_get() and ini_set() not disabled
https://github.com/smarty-php/smarty/pull/362
2017-05-21 02:24:48 +02:00
uwetews 2782e83a92 - 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
2017-05-21 02:24:48 +02:00
uwetews d571ffa111 Merge pull request #361 from zonuexe/patch-1
Fix markdown
2017-05-19 19:02:48 +02:00
uwetews 8f54ad7c96 Merge pull request #354 from jcodt/master
Fix markdown titles
2017-05-19 19:02:08 +02:00
uwetews f0e215b954 - change properties $accessMap and $obsoleteProperties from private to protected
https://github.com/smarty-php/smarty/issues/351
2017-05-19 04:54:49 +02:00
USAMI Kenta e3cea24be1 Fix markdown
affected by GitHub's Markdown parser change
https://githubengineering.com/a-formal-spec-for-github-markdown/
2017-05-11 10:50:42 +09:00
jcodt 5af93831ee Fix markdown titles 2017-04-25 17:49:55 +02:00
uwetews 5448fecc9d - fix spelling https://github.com/smarty-php/smarty/commit/e3eda8a5f5653d8abb960eb1bc47e3eca679b1b4#commitcomment-21803095 2017-04-24 18:21:37 +02:00
uwetews e3eda8a5f5 - correct generated code on empty() and isset() call, observe change PHP behaviour since PHP 5.5
https://github.com/smarty-php/smarty/issues/347
2017-04-17 05:32:24 +02:00
uwetews 29388b8baa - correct generated code on empty() and isset() call, observe change PHP behaviour since PHP 5.5
https://github.com/smarty-php/smarty/issues/347 (reverted from commit cfd8bf32b0)
2017-04-17 05:04:44 +02:00
uwetews f7bdfe463b Add PHP 7.1 to travis tests 2017-04-17 04:35:17 +02:00
uwetews cfd8bf32b0 - correct generated code on empty() and isset() call, observe change PHP behaviour since PHP 5.5
https://github.com/smarty-php/smarty/issues/347
2017-04-17 03:49:39 +02:00
uwetews 1a7328ca67 - 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
2017-04-14 15:01:43 +02:00
uwetews cfc3f8c424 Merge pull request #322 from simivar/patch-1
Fix annotation for addPluginsDir()
2017-04-14 14:52:18 +02:00
uwetews ec9fd99684 Merge pull request #349 from ka7/feature/spelling
spelling fixes
2017-04-14 14:37:18 +02:00
uwetews 00974d74b8 Merge pull request #337 from SvenRtbg/patch-1
Fix typo in @method annotation
2017-04-14 14:33:19 +02:00
uwetews 6d85c715f1 - bugfix array_merge() parameter should be checked https://github.com/smarty-php/smarty/issues/350 2017-04-13 07:15:46 +02:00
uwetews fd95365bf3 Prepare 3.1.32-dev 2017-04-13 05:17:27 +02:00
klemens 51a0e764e8 spelling fixes 2017-04-08 12:10:39 +02:00
SvenRtbg 697df30d18 Fix typo in @method annotation
It's `setDefaultModifiers()`, not `setDefaultModifier()`
2017-02-14 22:48:26 +01:00
simivar 1900ce24a3 Fix annotation for addPluginsDir()
Param of [addPluginsDir()](http://www.smarty.net/docs/en/api.add.plugins.dir.tpl) can be null, array or a string. Fixed annotation so there will be no IDE warnings.
2016-12-29 14:52:35 +01:00
Elan Ruusamäe 66205d5565 Update Autoloader.php
spelling fix
2016-12-21 23:36:37 +02:00
uwetews c7d42e4a32 prepare 3.1.31 release 2016-12-14 22:57:25 +01:00
uwetews 27928ece9c - move template object cache into static variables 2016-11-23 17:12:38 +01:00
uwetews 04a2327c75 - change version checking 2016-11-19 18:13:00 +01:00
uwetews 91af9d090a - 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
2016-11-19 07:34:06 +01:00
uwetews 05933749c0 - smaller speed optimization 2016-11-11 23:09:28 +01:00
uwetews be054c1727 touch 2016-11-11 22:17:35 +01:00
uwetews 5b9699b41a touch 2016-11-11 22:16:58 +01:00
uwetews b745a31a2d fixed spelling chilek commented on c4746e9 2016-11-11 21:17:32 +01:00
uwetews d120c1fad2 - 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
2016-11-11 20:13:40 +01:00
uwetews e867ae125e add utility to build Smarty_Internal_Testinstall 2016-11-08 18:09:14 +01:00
uwetews 7438ac39d0 Merge pull request #295 from glensc/patch-1
exclude files from git export
2016-11-08 18:04:08 +01:00
uwetews 428a7ad883 - add bootstrap file to load and register Smarty_Autoloader. Change composer.json to make it known to composer 2016-11-08 17:48:25 +01:00
uwetews c4746e9080 - optimization of lexer speed https://github.com/smarty-php/smarty/issues/311 2016-11-07 03:08:11 +01:00
uwetews 2d2be8f57f - bugfix template function definitions array has not been cached between Smarty::fetch() and Smarty::display() calls
https://github.com/smarty-php/smarty/issues/301
2016-10-27 05:42:17 +02:00
uwetews 98efe22e02 - improvement/bugfix when Smarty::fetch() is called on a template object the inheritance and tplFunctions property
should be copied to the called template object
2016-10-23 18:48:17 +02:00
uwetews d79edd2fe0 - improvement/bugfix when Smarty::fetch() is called on a template object the inheritance and tplFunctions property
should be copied to the called template object
2016-10-23 18:34:59 +02:00
uwetews 29cbe10857 - bugfix for compile locking touched timestamp of old compiled file was not restored on compilation error https://github.com/smarty-php/smarty/issues/308 2016-10-21 04:00:07 +02:00
uwetews 6699299767 - 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
2016-10-20 00:53:04 +02:00
uwetews 34e5739fc1 - bugfix {make_nocache $var} remove spaces from variable value https://github.com/smarty-php/smarty/issues/304 2016-10-19 20:43:17 +02:00
uwetews 80a024f44e - bugfix {make_nocache $var} did fail when variable value did contain '\' https://github.com/smarty-php/smarty/issues/305 2016-10-19 19:35:58 +02:00
uwetews f3e0e01266 - 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
2016-10-12 01:02:54 +02:00
uwetews 3c07a28434 - optimization move runtime extension for template functions into Smarty objects 2016-10-08 06:07:14 +02:00
uwetews caceefc300 use absolute path normalizaion 2016-09-30 04:10:25 +02:00
uwetews 80af6ea2b5 - 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
2016-09-30 02:30:39 +02:00
uwetews 68ab01dc9e - 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
2016-09-29 04:26:44 +02:00
uwetews 4de72f1acd - 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
2016-09-29 04:22:20 +02:00
uwetews 5b508b7bf3 - bugfix nocache hash was not removed for <?xml ?> tags in subtemplates https://github.com/smarty-php/smarty/issues/300 2016-09-28 23:39:05 +02:00
uwetews 998c778948 - 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 2016-09-28 04:59:51 +02:00
uwetews 3f0d519daf - 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
2016-09-27 23:19:56 +02:00
Elan Ruusamäe beeec36bb8 exclude files from git export
add files to be excluded from git export

visible when used via composer --prefer-dist
2016-09-24 11:03:02 +03:00
uwetews efa18457f2 - temporary fix for https://github.com/smarty-php/smarty/issues/293 main reason still under investigation 2016-09-20 16:06:01 +02:00
uwetews ec3a00e5ab - improvement new tags {block_parent} {block_child} in template inheritance 2016-09-20 16:00:28 +02:00
uwetews b8acd7ea17 - 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
2016-09-20 14:21:39 +02:00
uwetews d9a6938473 - cleanup convert cache resource file method clear into runtime extension 2016-09-19 16:39:19 +02:00
uwetews a9e7e8881e - optimization clear compiled and cached folder completely on detected version change 2016-09-19 14:59:49 +02:00
uwetews 8835408e0d - improvement make Smarty::clearCompiledTemplate() on custom resource independent from changes of templateId computation 2016-09-15 09:14:56 +02:00
uwetews cd28347130 - 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 2016-09-15 08:36:12 +02:00
uwetews f95b81a6f9 - 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 2016-09-15 06:43:36 +02:00
uwetews 58b6472d4f - 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
2016-09-15 03:23:04 +02:00
uwetews 424dca6d24 - 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 2016-09-15 02:56:34 +02:00
uwetews 44189a7531 - performance Smarty::configLoad() did load unneeded template source object 2016-09-11 05:41:16 +02:00
uwetews 0a8e47ecb2 - improvement move often used code snippets into methods 2016-09-11 04:35:52 +02:00
uwetews e62b40c421 - improvement {math} misleading E_USER_WARNING messages when parameter value = null https://github.com/smarty-php/smarty/issues/288 2016-09-11 00:23:37 +02:00
uwetews 7e230713c6 - improvement {math} misleading E_NOTICE messages when parameter value = null https://github.com/smarty-php/smarty/issues/288 (reverted from commit 810881c76e) 2016-09-11 00:21:45 +02:00
uwetews 810881c76e - improvement {math} misleading E_NOTICE messages when parameter value = null https://github.com/smarty-php/smarty/issues/288 2016-09-11 00:13:29 +02:00
uwetews 62099617ae - improvement {foreach} observe {break n} and {continue n} nesting levels when restoring saved $item and $key variables 2016-09-09 22:54:42 +02:00
uwetews 0e942e4821 - 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 2016-09-09 19:45:08 +02:00
uwetews 21aa211ddb - bugfix/optimization {foreach} did not execute the {foreachelse} when iterating empty objects https://github.com/smarty-php/smarty/pull/287 2016-09-09 18:43:37 +02:00
uwetews 124b333da2 - bugfix implement wrapper for removed method getConfigVariable() https://github.com/smarty-php/smarty/issues/286 2016-09-08 22:28:06 +02:00
uwetews bfc1ef8885 - bugfix {capture}{/capture} did add in 3.1.30 unintended additional blank lines https://github.com/smarty-php/smarty/issues/268 2016-09-07 17:43:10 +02:00
uwetews 0429272370 - 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 2016-09-07 00:41:31 +02:00
uwetews e5bbc052b1 - bugfix uppercase TRUE, FALSE and NULL did not work when security was enabled https://github.com/smarty-php/smarty/issues/282 2016-09-07 00:15:44 +02:00
uwetews e82f966682 - bugfix using nocache like attribute with value true like {plugin nocache=true} did not work https://github.com/smarty-php/smarty/issues/285 2016-09-07 00:06:17 +02:00
uwetews 51e0d5cd40 - performance require_once should be called only once for shared plugins https://github.com/smarty-php/smarty/issues/280 2016-09-06 04:26:46 +02:00
uwetews e1d27d68d7 - performance require_once should be called only once for shared plugins https://github.com/smarty-php/smarty/issues/280 2016-09-02 01:08:50 +02:00
uwetews 5580857d9b - bugfix change of 23.08.2016 failed on linux when use_include_path = true 2016-08-26 05:54:11 +02:00
uwetews 2003020df9 - 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 2016-08-23 08:03:39 +02:00
uwetews be39cc0121 - bugfix {make_nocache} failed when using composer autoloader https://github.com/smarty-php/smarty/issues/275 2016-08-20 15:58:12 +02:00
uwetews c39abdf83e - bugfix {config_load ... scope="global"} shall not throw an arror but fallback to scope="smarty" https://github.com/smarty-php/smarty/issues/274 2016-08-20 14:18:43 +02:00
uwetews db01627c1c - optimization remove unneeded call to update acopes when {assign} scope and template scope was local (default) 2016-08-14 03:32:07 +02:00
uwetews 1b6d2a9375 - 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
2016-08-14 02:38:55 +02:00
uwetews fee77dbfb8 - bugfix $smarty_>debugging = true; did E_NOTICE messages when {eval} tag was used https://github.com/smarty-php/smarty/issues/266 2016-08-14 01:12:37 +02:00
uwetews 7f932e7ac4 Prepare 3.1.31-dev 2016-08-07 20:57:11 +02:00
uwetews ed2b7f1146 Release 3.1.30 2016-08-07 20:46:49 +02:00
uwetews 0cc1577b1b Update travis for 3.1.30 test 2016-08-07 20:35:44 +02:00
uwetews 001f16aa0a update error message 2016-08-07 16:08:10 +02:00
uwetews 761e516a32 - bugfix update of 04.08.2016 was incomplete 2016-08-07 15:31:01 +02:00
uwetews 25ad0b3b5a - updated error checking at template and config default handler 2016-08-05 21:29:15 +02:00
uwetews 04301645d6 - bugfix compiling of templates failed when the Smarty delimiter did contain '/' https://github.com/smarty-php/smarty/issues/264 2016-08-05 01:00:51 +02:00
uwetews e96a218e8b Merge pull request #263 from a-shpota/fix-method-define
Fix define method in registered objects
2016-08-04 23:11:59 +02:00
uwetews ffa270c395 04.08.2015
- improvement move template function source parameter into extension
2016-08-04 23:10:26 +02:00
Andrey Shpota a3c1a152ca fix define method in registered objects 2016-08-04 12:28:19 +03:00
uwetews 335f199cbc - optimization unneeded loading of compiled resource 2016-07-26 04:00:15 +02:00
uwetews f74a0d575a - regression this->addPluginsDir('/abs/path/to/dir') adding absolute path without trailing '/' did fail https://github.com/smarty-php/smarty/issues/260 2016-07-24 20:31:27 +02:00
uwetews eb2d9d4e6d - improvement remove double funtion declaration in plugin shared.escape_special_cars.php https://github.com/smarty-php/smarty/issues/229 2016-07-23 22:37:17 +02:00
uwetews 2ba2f6e2e7 - bugfix setTemplateDir('/') and setTemplateDir('') did create wrong absolute filepath https://github.com/smarty-php/smarty/issues/245
- optimization of filepath normalization
2016-07-23 22:21:14 +02:00
uwetews 6d7d36d9a6 Fx changelog text for - bugfix {match} shell injection vulnerability patch provided by Tim Weber 2016-07-19 20:22:10 +02:00
uwetews 50068ca52a - bugfix {match} shell injection vulnerability patch provided by Tim Weber 2016-07-19 20:17:47 +02:00
uwetews f39e61762c - bugfix multiple {include} with relative filepath within {block}{/block} could fail https://github.com/smarty-php/smarty/issues/246 2016-07-19 03:37:01 +02:00
uwetews afb971f84b - bugfix multiple {include} with relative filepath within {block}{/block} could fail https://github.com/smarty-php/smarty/issues/246 (reverted from commit 09d8eab89f) (reverted from commit 3fdd9e4b89) 2016-07-19 00:25:49 +02:00
uwetews e865374fc2 - bugfix multiple {include} with relative filepath within {block}{/block} could fail https://github.com/smarty-php/smarty/issues/246 (reverted from commit 09d8eab89f) (reverted from commit 3fdd9e4b89) 2016-07-19 00:19:22 +02:00
uwetews 3fdd9e4b89 - bugfix multiple {include} with relative filepath within {block}{/block} could fail https://github.com/smarty-php/smarty/issues/246 (reverted from commit 09d8eab89f) 2016-07-19 00:14:51 +02:00
uwetews 09d8eab89f - bugfix multiple {include} with relative filepath within {block}{/block} could fail https://github.com/smarty-php/smarty/issues/246 2016-07-18 23:50:37 +02:00
uwetews 5fd21b7361 - bugfix multiple {include} with relative filepath within {block}{/block} could fail https://github.com/smarty-php/smarty/issues/246 2016-07-18 23:43:58 +02:00
uwetews d854219696 - bugfix avoid opcache_invalidate to result in ErrorException when opcache.restrict_api is not empty https://github.com/smarty-php/smarty/pull/244 2016-07-18 19:45:30 +02:00
uwetews 92945eaf12 - bugfix modifier on plugins like {plugin|modifier ... } did fail when the plugin does return an array https://github.com/smarty-php/smarty/issues/228 2016-07-18 17:57:50 +02:00
uwetews 79a4fdcd52 - 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 2016-07-18 05:27:46 +02:00
uwetews c666ec9a34 - bugfix wrong parameter on compileAllTemplates() and compileAllConfig() https://github.com/smarty-php/smarty/issues/231 2016-07-14 20:32:41 +02:00
uwetews e5eebc3cc2 - bugfix wrong parameter on compileAllTemplates() https://github.com/smarty-php/smarty/issues/231 2016-07-13 01:49:38 +02:00
uwetews cbea88b3a7 - bugfix template function data should be merged when loading subtemplate https://github.com/smarty-php/smarty/issues/240 2016-07-13 01:42:54 +02:00
uwetews 38b13661fe - bugfix enable debugging could fail when template objects did already exists https://github.com/smarty-php/smarty/issues/237 2016-07-13 01:07:53 +02:00
uwetews 31f6afd16e - update testInstall() https://github.com/smarty-php/smarty/issues/248https://github.com/smarty-php/smarty/issues/248 2016-07-13 00:26:17 +02:00
uwetews 353ee1a490 - bugfix PHP 7 compatibility on registered compiler plugins https://github.com/smarty-php/smarty/issues/241 2016-07-13 00:12:58 +02:00
uwetews 02f95184ab - bugfix enableSecurity() must init cache flags https://github.com/smarty-php/smarty/issues/247 2016-07-12 02:30:14 +02:00
uwetews b525d4d1d7 - 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 2016-07-12 00:24:11 +02:00
uwetews b46a9a8dbd - 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
2016-05-28 03:33:32 +02:00
uwetews 778b0d920e - 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
2016-05-27 22:22:57 +02:00
uwetews dccfc6c2f5 - broken PHP 5.3 and 5.4 compatibility 2016-05-16 18:17:58 +02:00
uwetews 0fcac38c70 - optimization {foreach} compiler and processing 2016-05-16 17:57:06 +02:00
uwetews a62557e817 - broken PHP 5.3 and 5.4 compatibility 2016-05-15 11:51:46 +02:00
uwetews 6ef0d0eaa0 - optimization and cleanup of resource code 2016-05-15 11:13:31 +02:00
uwetews 1fbf16afed - optimization of inheritance processing 2016-05-10 03:54:56 +02:00
uwetews 608064e5f2 -bugfix Only variables should be assigned by reference https://github.com/smarty-php/smarty/issues/227 2016-05-07 13:46:37 +02:00
uwetews f02f943021 Merge pull request #188 from tinogo/master
Minor optimization for Smarty_Internal_Data::assign()
2016-05-03 21:55:46 +02:00
uwetews ecdd33d334 - bugfix same relative filepath at {include} called from template in different folders could display wrong sub-template 2016-05-02 04:28:09 +02:00
uwetews 971058fc61 - enhancement {block} tag names can now be variable https://github.com/smarty-php/smarty/issues/221 2016-05-02 00:58:17 +02:00
uwetews f1b3662b28 - bugfix same relative filepath at {include} called from template in different folders could display wrong sub-template 2016-05-01 23:53:38 +02:00
uwetews 2cb03512f7 - bugfix {strip} remove space on linebreak between html tags https://github.com/smarty-php/smarty/issues/213 2016-04-29 00:24:47 +02:00
uwetews 116854cee2 Merge pull request #222 from glensc/patch-1
Update NEW_FEATURES.txt
2016-04-24 15:18:03 +02:00
Elan Ruusamäe 608dbd0f7f whitespace cleanup 2016-04-24 15:21:08 +03:00
Elan Ruusamäe af1b632a11 Update NEW_FEATURES.txt 2016-04-24 15:19:30 +03:00
uwetews 13a2127b50 - bugfix nested {include} with relative file path could fail when called in {block} ... {/block} https://github.com/smarty-php/smarty/issues/218 2016-04-24 11:04:36 +02:00
uwetews d3b7a344aa - bugfix the default template handler must calculate the source uid https://github.com/smarty-php/smarty/issues/205 2016-04-14 21:24:26 +02:00
uwetews 9839de9cc4 - bugfix special variable {$smarty.capture.name} was not case sensitive on name https://github.com/smarty-php/smarty/issues/210 2016-04-14 21:12:34 +02:00
uwetews 6d4a4de0d5 - bugfix template inheritance status must be saved when calling sub-templates https://github.com/smarty-php/smarty/issues/215 2016-04-13 03:36:16 +02:00
uwetews a36d9bc809 Fixing wrong date 2016-03-27 18:53:53 +02:00
uwetews 2dac1729c2 - bugfix change of 11.03.2014 cause again {capture} data could not been seen in other templates with {$smarty.capture.name} https://github.com/smarty-php/smarty/issues/153 2016-03-27 18:44:19 +02:00
uwetews ff6a8521bb - improvement $smarty->clearCompiledTemplate() should return on recompiled or uncompiled resources 2016-03-11 03:36:43 +01:00
uwetews af71fda639 - optimization of capture and security handling 2016-03-11 02:55:55 +01:00
uwetews 62bf9eeddc - optimization of resource processing 2016-03-11 01:07:26 +01:00
uwetews 880967aff3 - optimization of resource processing 2016-03-11 01:05:26 +01:00
uwetews 4815464b9c - optimization of resource processing 2016-03-10 22:22:46 +01:00
uwetews 00be382842 fix function name case 2016-03-09 04:03:37 +01:00
uwetews 5c1907052e fix class name case 2016-03-09 04:01:47 +01:00
uwetews 23acdf722c fix passed parameter 2016-03-09 03:53:12 +01:00
uwetews 43c5aabda5 update {capture} compiler tag nesting code 2016-03-09 03:13:15 +01:00
uwetews f63ceb1c05 - remove access to removed an not needed property 2016-03-09 02:44:38 +01:00
uwetews 91b4992ab8 - 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
  missed commit
2016-03-09 02:11:06 +01:00
uwetews e066488f8b - bugfix correct Autoloader update of 2.3.2014 https://github.com/smarty-php/smarty/issues/199 2016-03-09 01:44:10 +01:00
uwetews abf5be58ad - 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
2016-03-09 01:01:32 +01:00
uwetews d88168d1b6 - bugfix change from 01.03.2016 will cause $smarty->isCached(..) failure if called multiple time for same template
(forum topic 25935) related to 825aa26079
2016-03-04 17:54:10 +01:00
uwetews 4f5aeeb2b6 - revert autoloader optimizations because of unexplainable warning when using plugins https://github.com/smarty-php/smarty/issues/199 2016-03-02 18:17:22 +01:00
uwetews b99bc7b8da - bugfix template objects must be cached on $smarty->fetch('foo.tpl) calls incase the template is fetched
multiple times (forum topic 25909)
2016-03-01 00:55:28 +01:00
uwetews 825aa26079 - bugfix template objects must be cached on $smarty->fetch('foo.tpl) calls incase the template is fetched
multiple times (forum topic 25909)
2016-03-01 00:54:33 +01:00
uwetews 0e5ea2a467 - bugfix instanceof expression in template code must be treated as value https://github.com/smarty-php/smarty/issues/191 2016-02-26 00:50:15 +01:00
uwetews a5b465e2c6 - optimization of _realpath 2016-02-25 23:36:53 +01:00
uwetews 8df91e9d0d - bugfix wrong _realpath with 4 or more parent-directories https://github.com/smarty-php/smarty/issues/190 2016-02-25 02:53:55 +01:00
uwetews b39f561083 update https://github.com/smarty-php/smarty/issues/179 2016-02-20 22:00:19 +01:00
uwetews 4530a8232f - 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
2016-02-20 21:45:21 +01:00
uwetews b832cd36a5 - 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} new attribute 'property' to force compilation of loop property
    read NEW_FEATURES.txt https://github.com/smarty-php/smarty/issues/189 (reverted from commit 4958deaf09)
2016-02-20 21:33:31 +01:00
uwetews 4958deaf09 - 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} new attribute 'property' to force compilation of loop property
    read NEW_FEATURES.txt https://github.com/smarty-php/smarty/issues/189
2016-02-20 21:13:38 +01:00
uwetews a884855818 - bugfix {strip} must keep space between hmtl tags. Broken by changes of 10.2.2016 https://github.com/smarty-php/smarty/issues/184 2016-02-20 17:24:48 +01:00
uwetews 3e463c1be0 - 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
2016-02-19 16:10:17 +01:00
Tino Goratsch 8dc8fc23c8 Optimization for Smarty_Internal_Data::assign()
Removed the extra if block, when an array has been given as the $tpl_var argument, because in the else block there is already a "not empty check".
2016-02-19 09:44:07 +01:00
uwetews 0735ff9605 - optimization make compiler tag object cache static for higher compilation speed 2016-02-14 20:57:21 +01:00
uwetews 30328d318c - optimization of tag attribute compiling 2016-02-14 19:58:55 +01:00
uwetews 7e36f98c1d - bugfix using extendsall as default resource and {include} inside {block} tags could produce unexpected results https://github.com/smarty-php/smarty/issues/183 2016-02-14 14:33:59 +01:00
uwetews 4b1ba73eea - optimization of sub-template processing 2016-02-14 09:17:55 +01:00
uwetews 0f7f0d87b6 - new tag {make_nocache} read NEW_FEATURES.txt https://github.com/smarty-php/smarty/issues/110 2016-02-14 02:54:38 +01:00
uwetews 3756588858 - improvement added KnockoutJS comments to trimwhitespace outputfilter https://github.com/smarty-php/smarty/issues/82
https://github.com/smarty-php/smarty/pull/181
2016-02-11 22:05:45 +01:00
uwetews 00f07690e7 update of the inheritance release notes 2016-02-10 21:32:52 +01:00
uwetews 9c37394ccb - bugfix other {strip} error with output tags between hmtl https://github.com/smarty-php/smarty/issues/180 2016-02-10 21:12:35 +01:00
uwetews a8d3373f26 - improvement because of ambiguities the inline constant support has been removed from the $foo.bar syntax https://github.com/smarty-php/smarty/issues/149 2016-02-10 04:06:05 +01:00
uwetews b8fb986327 - bugfix {strip} must keep space on output creating smarty tags within html tags https://github.com/smarty-php/smarty/issues/177 other update for BC 2016-02-10 03:49:09 +01:00
uwetews 47237eb84f - bugfix wrong precedence on special if conditions like '$foo is ... by $bar' could cause wrong code https://github.com/smarty-php/smarty/issues/178 2016-02-10 03:19:25 +01:00
uwetews 417088bdb7 - bugfix {strip} must keep space on output creating smarty tags within html tags https://github.com/smarty-php/smarty/issues/177 2016-02-10 03:17:32 +01:00
uwetews 08db1a4a3f - bugfix {strip} must keep space on output creating smarty tags within html tags https://github.com/smarty-php/smarty/issues/177 2016-02-10 01:12:57 +01:00
uwetews 2f62b99173 - update/bugfix scope attribute handling reworked. Read the newfeatures.txt file 2016-02-09 23:27:07 +01:00
uwetews 37e6d26b23 - move some code from parser into compiler 2016-02-09 04:48:08 +01:00
uwetews b04486a091 - reformat all code for unique style 2016-02-09 01:27:15 +01:00
uwetews c59ca44b9f - move some code from parser into compiler 2016-02-09 01:15:12 +01:00
uwetews c1f34b1314 - improvement internal compiler changes 2016-02-05 17:41:11 +01:00
uwetews 85eedd0c11 - bugfix {foreach} compilation failed when $smarty->merge_compiled_includes = true and pre-filters are used.
https://github.com/smarty-php/smarty/issues/172
2016-02-01 00:46:15 +01:00
uwetews e1bf16a504 - bugfix implement replacement code for _tag_stack property https://github.com/smarty-php/smarty/issues/151 2016-01-29 01:21:00 +01:00
uwetews addd2a74e2 Merge pull request #156 from glensc/patch-1
Update change_log.txt
2016-01-28 05:49:12 +01:00
uwetews a687a127c4 - 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 2016-01-28 05:34:41 +01:00
uwetews 193163be29 - bugfix allow windows network filepath or wrapper (forum topic 25876) https://github.com/smarty-php/smarty/issues/170 2016-01-28 03:51:54 +01:00
uwetews 41684818d9 - bugfix {capture} data could not been seen in other templates with {$smarty.capture.name} https://github.com/smarty-php/smarty/issues/153 2016-01-27 05:18:29 +01:00
uwetews f59b00c6dd - 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
2016-01-27 04:51:02 +01:00
uwetews 04d9c5cc34 - bugfix output filters did not observe nocache code flag https://github.com/smarty-php/smarty/issues/160 2016-01-27 00:35:04 +01:00
uwetews 71f71e6262 - bugfix string resource could inject code at {block} or inline subtemplates through PHP comments https://github.com/smarty-php/smarty/issues/157 2016-01-26 22:22:20 +01:00
uwetews 867a2f3165 - bugfix string resource could inject code at {block} or inline subtemplates through PHP comments https://github.com/smarty-php/smarty/issues/157 (reverted from commit 2850cce19f) 2016-01-26 21:49:56 +01:00
uwetews 2850cce19f - bugfix string resource could inject code at {block} or inline subtemplates through PHP comments https://github.com/smarty-php/smarty/issues/157 2016-01-26 21:34:11 +01:00
uwetews 0b31052418 - bugfix {$smarty.section.customer.loop} did throw compiler error https://github.com/smarty-php/smarty/issues/161
update of yesterdays fix
2016-01-26 21:25:29 +01:00
uwetews 8a0c783b71 - revert bugfix compiling {section} did create warning 2016-01-26 20:49:46 +01:00
uwetews ccbc4303ed - bugfix {$smarty.section.customer.loop} did throw compiler error https://github.com/smarty-php/smarty/issues/161 2016-01-26 03:01:33 +01:00
uwetews b58e1cdc5a - bugfix compiling {section} did create warning 2016-01-26 02:57:21 +01:00
uwetews 8b0e0a3df6 - improvement observe Smarty::$_CHARSET in debugging console https://github.com/smarty-php/smarty/issues/169 2016-01-26 00:15:39 +01:00
Elan Ruusamäe 5cf9824cdf Update change_log.txt
typo fixes
2016-01-06 23:40:13 +02:00
uwetews dd0f4c7c36 - improvement runtime checks if registered block plugins are callabel 2016-01-02 17:58:58 +01:00
uwetews 418492b40b - optimize block plugin compiler 2016-01-02 11:27:44 +01:00
uwetews 59343127f7 - update scope handling 2016-01-02 02:47:32 +01:00
uwetews bdf9f41da8 - remove Smarty::$resource_cache_mode property 2016-01-01 18:28:27 +01:00
uwetews 8e9cb7586f add memcache tests to travis 2015-12-31 06:45:19 +01:00
uwetews d381c47ba8 add memcache tests to travis 2015-12-31 06:36:19 +01:00
uwetews ea866a5a92 add memcache tests to travis 2015-12-31 06:33:47 +01:00
uwetews 04afbdb18d disable 5.2 2015-12-31 06:07:18 +01:00
uwetews 0dc576bfc0 enable 5.2 2015-12-31 06:03:56 +01:00
uwetews d32badfdee disable 5.2 2015-12-31 05:45:24 +01:00
uwetews b935ae803b enable 5.2 2015-12-31 05:20:50 +01:00
uwetews fe85dd4a3b disable 5.2 2015-12-31 05:08:25 +01:00
uwetews 77b6a9e8e1 Add travis test for php 5.2 2015-12-31 04:55:59 +01:00
uwetews 633a6285b0 Test if class Memcached exists 2015-12-31 03:44:42 +01:00
uwetews 239fed38b9 enable mysql and memcache tests on travis 2015-12-31 02:49:45 +01:00
uwetews c60cdb3e64 - optimization of {assign}, {if} and {while} compiled code 2015-12-31 02:20:47 +01:00
uwetews 7eb56ac5e3 - bugfix plugin names starting with "php" did not compile https://github.com/smarty-php/smarty/issues/147 2015-12-30 22:11:15 +01:00
uwetews 34062d45b7 - bugfix Smarty::error_reporting was not observed when display() or fetch() was called on template objects https://github.com/smarty-php/smarty/issues/145 2015-12-29 16:54:15 +01:00
uwetews 59b3a53089 remove allowed failure on hhvm 2015-12-28 06:00:03 +01:00
uwetews afec7564d6 - optimization of {foreach} code size and processing 2015-12-28 00:58:22 +01:00
uwetews c8c82a292a - PHPdoc updates 2015-12-27 08:12:46 +01:00
uwetews c2f05e8c3c - code fixes 2015-12-27 08:11:31 +01:00
uwetews 94cc120439 update SmartyBC 2015-12-27 07:19:04 +01:00
uwetews b0691dd056 - update external methods 2015-12-27 07:18:35 +01:00
uwetews 4dd8b0bf73 new _clearTemplateCache() method 2015-12-27 05:43:11 +01:00
uwetews ca48e93f00 force opcache invalidation 2015-12-27 05:42:30 +01:00
uwetews 1ebaac314c remove obsolete code 2015-12-27 05:37:50 +01:00
uwetews dc6da4384b - improve inheritance code 2015-12-27 04:02:21 +01:00
uwetews 7e7591f6c0 new _clearTemplateCache() method 2015-12-27 03:28:26 +01:00
uwetews fbf544286a - new feature If ACP is enabled force an apc_compile_file() when compiled or cached template was updated 2015-12-25 10:29:29 +01:00
uwetews 613e66c257 - optimization replace hhvm extension by inline code 2015-12-25 10:02:10 +01:00
uwetews fdd20dd4f1 - compile {block} tag code and its processing into classes 2015-12-25 09:10:39 +01:00
uwetews 2ebacc3b54 - bugfix post filter did fail on template inheritance https://github.com/smarty-php/smarty/issues/144 2015-12-24 05:52:41 +01:00
uwetews 297f47a15a - new feature Compiler does now observe the template_dir setting and will create separate compiled files if required 2015-12-24 02:29:21 +01:00
uwetews 9d0865aaf8 - new feature Caching does now observe the template_dir setting and will create separate cache files if required 2015-12-24 02:26:31 +01:00
uwetews 5c377637e1 - new feature Caching does now observe the template_dir setting and will create separate cache files if required 2015-12-23 04:35:48 +01:00
uwetews db2cace210 - optimization move subtemplate processing back into template object 2015-12-23 03:08:23 +01:00
uwetews 8a0562fb58 lost code on last commit 2015-12-23 00:57:52 +01:00
uwetews ad635471cb - optimization move internal method decodeProperties back into template object 2015-12-23 00:44:51 +01:00
uwetews ef3da3cc0b - code optimizations 2015-12-22 23:49:25 +01:00
uwetews 136e94ae74 - change $xxx_dir properties from private to protected in case Smarty class gets extended.
Properties like $template_dir must never be accessed directly or overloaded by a user class. Use getter/setter methods like setTemplateDir()
2015-12-22 01:21:35 +01:00
uwetews a8f8efd4b4 - bugfix {strip} must remove all blanks between html tags https://github.com/smarty-php/smarty/issues/136 2015-12-21 23:35:52 +01:00
uwetews fd09164be5 - optimization of filepath normalization 2015-12-21 22:50:55 +01:00
uwetews 76bb166eda - 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 (reverted from commit e29834387f) (reverted from commit 5a418efe57)
2015-12-21 17:19:39 +01:00
uwetews 5a418efe57 - 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 (reverted from commit e29834387f)
2015-12-21 16:36:33 +01:00
uwetews e29834387f - 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
2015-12-21 16:34:46 +01:00
uwetews b22686023e Merge pull request #141 from m1nd53t/master
set correct path to template in CompileAll
2015-12-21 15:05:53 +01:00
Kars Frijters d8109dda75 set correct path to template in CompileAll
When the template is in a subdirectory of the sourcedir, the the template could not be loaded
2015-12-21 14:27:26 +01:00
uwetews fa482f09f5 Fix typo in version 2015-12-21 03:08:35 +01:00
uwetews ee0ea0afbf Prepare 3.1.20-dev 2015-12-21 03:01:41 +01:00
uwetews 35480f10e7 Release 3.1.29 2015-12-21 02:57:06 +01:00
uwetews 6867515183 v3.1.28-p1 patch 2015-12-21 02:49:46 +01:00
uwetews efaa61cfb6 - optimization improve speed of filetime checks on extends and extendsall resource 2015-12-21 02:18:27 +01:00
uwetews 3548de5fa1 - bugfix the source uid of the extendsall resource must contain $template_dir settings https://github.com/smarty-php/smarty/issues/123 2015-12-20 17:51:16 +01:00
uwetews 78243be722 - bugfix add addition check for OS type on normalization of file path https://github.com/smarty-php/smarty/issues/134 2015-12-20 16:21:32 +01:00
uwetews 6483164d18 - update compilation of Smarty special variables 2015-12-20 15:13:34 +01:00
uwetews e655856871 - bugfix failure when the default resource type was set to 'extendsall' https://github.com/smarty-php/smarty/issues/123 2015-12-20 05:27:43 +01:00
uwetews dc9872e0e2 - bugfix broken PHP 5.2 compatibility https://github.com/smarty-php/smarty/issues/139 2015-12-19 21:55:32 +01:00
uwetews 9cdf68807f - improvement make sure that compiled and cache templates never can contain a trailing '?>? 2015-12-19 21:37:46 +01:00
uwetews d11956fc78 - remove no longer used code 2015-12-19 21:35:24 +01:00
uwetews 116c0caa5b update travis 2015-12-19 20:19:32 +01:00
uwetews b75f638d20 update travis 2015-12-19 20:16:18 +01:00
uwetews 5558f4face update travis 2015-12-19 20:13:46 +01:00
uwetews 224a1c4874 - bugfix broken PHP 5.2 compatibility 2015-12-19 20:10:45 +01:00
uwetews e32720ef4e - bugfix using $smarty.capture.foo in expressions could fail https://github.com/smarty-php/smarty/pull/138 2015-12-19 19:18:31 +01:00
uwetews 818715351a typo 2015-12-18 05:52:04 +01:00
uwetews 44eea98260 - bugfix regression when mdifier parameter was follow by math https://github.com/smarty-php/smarty/issues/132 2015-12-18 04:43:55 +01:00
uwetews 05c069d889 - bugfix using {block append/prepend} on same block in multiple levels of inheritance templates could fail (forum topic 25827) 2015-12-18 00:34:58 +01:00
uwetews 9a8bcb93b1 - bugfix text content consisting of just a single '0' like in {if true}0{/if} was suppressed (forum topic 25834) 2015-12-17 21:51:19 +01:00
uwetews 919861014a - bugfix using {block append/prepend} on same block in multiple levels of inheritance templates could fail (forum topic 25827) 2015-12-17 21:32:36 +01:00
uwetews fb80bd53a5 - bugfix {$smarty.capture.nameFail} did lowercase capture name https://github.com/smarty-php/smarty/issues/135 2015-12-17 20:31:30 +01:00
uwetews b7118b6beb - optimize direct access $smarty->template_dir = 'foo'; should call Smarty::setTemplateDir() https://github.com/smarty-php/smarty/issues/121 2015-12-16 22:32:07 +01:00
uwetews c4a5aca865 - bugfix direct access $smarty->template_dir = 'foo'; should call Smarty::setTemplateDir() https://github.com/smarty-php/smarty/issues/121 2015-12-16 04:54:34 +01:00
uwetews fa3aed33ee - bugfix {foreach} did fail if from atrribute is a Generator class https://github.com/smarty-php/smarty/issues/128 2015-12-16 03:25:33 +01:00
uwetews e1eefdca75 Merge pull request #127 from logbon72/master
Restored Smarty_Internal_Data::getVariable()
2015-12-16 00:58:13 +01:00
uwetews b842934abd Merge pull request #129 from eaglewu/patch-1
Compatible with PHP7
2015-12-16 00:57:54 +01:00
Di Wu 1f7a82e2be Compatible with PHP7
Explicitly defining the evaluation order with the curly braces.

In PHP5
``
$person->$property['first'] is evaluated as $person->{$property['first']}
``

But in PHP7
``
$person->$property['first'] is evaluated as {$person->$property}['first']
``
2015-12-15 17:37:53 +08:00
Joseph Orilogbon 048b648bff - Restored Smarty_Internal_Data::getVariable(), but added deprecation message. 2015-12-15 08:54:21 +01:00
uwetews 017120c1ef - bugfix a call to clearAllCache() and other should clear all internal template object caches (forum topic 25828) 2015-12-15 03:37:13 +01:00
uwetews 80f872ac06 Merge pull request #126 from glensc/patch-1
Update NEW_FEATURES.txt
2015-12-15 01:52:53 +01:00
uwetews 862ce9db08 - bugfix {$smarty.cookies.foo} did return the $_COOKIE array not the 'foo' value https://github.com/smarty-php/smarty/issues/122 2015-12-15 01:34:18 +01:00
Elan Ruusamäe ca12046179 typos here too 2015-12-14 23:33:42 +02:00
Elan Ruusamäe 362af770fe one more typo fix
altho not sure where the quote should be here
2015-12-14 23:31:40 +02:00
Elan Ruusamäe b40684c5d5 more typos 2015-12-14 23:30:45 +02:00
Elan Ruusamäe 5c71e35d4f Update NEW_FEATURES.txt
typos
2015-12-14 23:29:07 +02:00
uwetews c4e6ad6c35 - bugfix multiple calls of {section} with same name droped E_NOTICE error https://github.com/smarty-php/smarty/issues/118 2015-12-14 00:18:27 +01:00
uwetews f8ec3ecaef - bugfix {$smarty.config.foo} broken in 3.1.28 https://github.com/smarty-php/smarty/issues/120 2015-12-14 00:04:31 +01:00
uwetews bc3ea2c878 Prepare .1.29-dev 2015-12-13 15:41:00 +01:00
uwetews d234f79203 Prepare release 3.1.28 2015-12-13 15:19:58 +01:00
uwetews 15e3d10267 Fix typos 2015-12-13 15:16:20 +01:00
uwetews 2cab5c74ff fix link to documentation 2015-12-13 14:50:11 +01:00
uwetews dca9cd887e Merge pull request #117 from yonexyonex/fix_typo
fix typo in template error message
2015-12-13 14:41:20 +01:00
yonex fc999d81be fix typo in template error message 2015-12-13 22:35:22 +09:00
uwetews e8078f55ae - bugfix Debug Console could display incorrect data when using subtemplates 2015-12-13 14:15:54 +01:00
uwetews 7e521a92d9 - bugfix $smarty->debugging_ctrl = 'URL' did not work (forum topic 25811) 2015-12-13 10:16:10 +01:00
uwetews 6dc9196c35 - bugfix {foreach} and {section} with uppercase characters in name attribute did not work (forum topic 25819) 2015-12-13 06:30:08 +01:00
uwetews 71e364e4b2 - bugix Smarty did fail under PHP 7.0.0 with use_include_path = true; 2015-12-09 02:16:48 +01:00
uwetews e783f61132 - bugix Smarty did fail under PHP 7.0.0 with use_include_path = true; 2015-12-09 02:03:56 +01:00
uwetews 260d3e3e46 -bugfix {strip} should exclude some html tags from stripping, related to fix for https://github.com/smarty-php/smarty/issues/111 2015-12-09 01:35:17 +01:00
uwetews ee743d2729 update of SMARTY_VERSION 2015-12-08 23:45:04 +01:00
uwetews 29e2eb0bca - bugfix internal template function data got stored in wrong compiled file https://github.com/smarty-php/smarty/issues/114 2015-12-08 23:41:42 +01:00
uwetews be8340bef2 - remove no longer needed file and updated testinstall 2015-12-08 23:41:01 +01:00
uwetews 4839d0e0cc -bugfix {strip} should insert a single space https://github.com/smarty-php/smarty/issues/111 2015-12-05 17:28:05 +01:00
uwetews 54fe432730 Merge pull request #109 from KLVTZ/master
Refactor readme: use github markdown parser
2015-12-04 04:11:16 +01:00
Justin Page a061365844 Provide new line to separate highlights 2015-11-28 16:51:14 -08:00
Justin Page 0403c876ed Use quotes to highlight features 2015-11-28 16:48:27 -08:00
Justin Page 2bc86a00f1 Wrap JSON examples in language specific code wrap
This allows Github or any repo system to parse and display correctly code
examples by proper wrappers.
2015-11-28 16:45:46 -08:00
uwetews e0fc310b6e -bugfix a left delimter like '[%' did fail on [%$var_[%$variable%]%] (forum topic 25798) 2015-11-25 21:19:23 +01:00
uwetews 5ca1cd485f - bugfix {include} with variable file name like {include file="foo_$bar.tpl"} did fail in 3.1.28-dev https://github.com/smarty-php/smarty/issues/102 2015-11-02 23:04:52 +01:00
uwetews aa730800bd - bugfix {include} with variable file name like {include file="foo_$bar.tpl"} did fail in 3.1.28-dev https://github.com/smarty-php/smarty/issues/102 2015-11-02 18:06:42 +01:00
uwetews cc3f69a2a3 - update config file processing 2015-11-01 02:58:27 +01:00
uwetews 8a78038181 update PHPdoc 2015-11-01 02:57:50 +01:00
uwetews 72258bc28d add test for valid scope name 2015-11-01 02:02:27 +01:00
uwetews 9496df8e1f - bugfix add missing $trusted_dir property to SmartyBC class (forum topic 25751) 2015-10-31 23:13:12 +01:00
uwetews eedfdff62f - improve template scope handling 2015-10-29 22:33:00 +01:00
uwetews 55f38125a4 - improve template scope handling 2015-10-29 22:17:35 +01:00
uwetews a0f583078d - minor optimizations 2015-10-29 21:41:21 +01:00
uwetews 862b23fe52 - update testinstall() 2015-10-26 01:27:06 +01:00
uwetews 6e3d94c13e - more optimizations of template processing 2015-10-25 05:59:45 +01:00
uwetews 2b9dcb22b5 - more optimizations of template processing 2015-10-25 05:03:23 +01:00
uwetews 42e722926a - bugfix Error when using {include} within {capture} https://github.com/smarty-php/smarty/issues/100 2015-10-25 04:53:58 +01:00
uwetews 1a51c1c17b - more optimizations of template processing 2015-10-25 04:53:19 +01:00
uwetews 50760c794c - more optimizations of template processing 2015-10-24 22:43:19 +02:00
uwetews 4ea4d1ff41 - improve autoloader speed 2015-10-24 05:20:09 +02:00
uwetews abdb335b26 - fix comment 2015-10-24 05:17:17 +02:00
uwetews b7fb490cb1 - improve compiled code 2015-10-24 05:16:54 +02:00
uwetews 891495f849 - improve recovery from ivalid compiled template code 2015-10-24 05:14:47 +02:00
uwetews 0ea1360d65 - new extension handler to load functions when called 2015-10-24 05:12:10 +02:00
uwetews 888014b908 - new extension handler to load functions when called 2015-10-24 05:02:24 +02:00
uwetews eec7639c9c - fix template scope processing 2015-10-24 04:45:09 +02:00
uwetews b26ba9ce52 update travis 2015-10-21 04:32:27 +02:00
uwetews e25a8ab661 - move some code into runtime extensions 2015-10-21 03:53:25 +02:00
uwetews ad65c850f7 - move some code into runtime extensions 2015-10-21 02:02:42 +02:00
uwetews 4e1d6707fe - update code generated by template function call handler 2015-10-18 22:12:16 +02:00
uwetews 0e28150b4a - fix compiled code for new {block} assign attribute 2015-10-18 11:35:08 +02:00
uwetews bd7d10e09d Update travis 2015-10-18 05:14:27 +02:00
uwetews bf6910ee21 - bugfix under HHVM temporary cache file must only be created when caches template was updated 2015-10-18 05:08:03 +02:00
uwetews 4776491a7f - bugfix under HHVM temporary cache file must only be created when caches template was updated 2015-10-18 04:58:53 +02:00
uwetews c99fe144f6 - speed and size optimizations 2015-10-18 04:54:09 +02:00
uwetews 8dc2a0af7c - rework of template inheritance 2015-10-18 04:46:05 +02:00
uwetews ca9ccfc919 - optimize filepath normalization 2015-10-18 04:40:45 +02:00
uwetews 757d66a731 parser: add support for template prefix and postfix code 2015-10-18 02:02:43 +02:00
uwetews 5cde3a8799 compiler: add support for post compile callbacks 2015-10-18 02:02:42 +02:00
uwetews 8dc777effd Merge pull request #96 from glensc/patch-1
do not load "Autoloader" from include path
2015-10-18 02:00:49 +02:00
Elan Ruusamäe 87a04b2ef6 do not load "Autoloader" from include path
loading it from include path (without abs path) can be dangerous, can load some other project's Autoloader.php instead the right one.
2015-10-13 10:32:04 +03:00
uwetews 788566cf70 - bugfix {if $foo instanceof $bar} failed to compile if 2nd value is a variable https://github.com/smarty-php/smarty/issues/92 (reverted from commit 428e667453) 2015-10-08 19:53:25 +02:00
uwetews 428e667453 - bugfix {if $foo instanceof $bar} failed to compile if 2nd value is a variable https://github.com/smarty-php/smarty/issues/92 2015-10-08 19:47:43 +02:00
uwetews 7f0a2f788f Merge pull request #95 from dshepherd/patch-1
Update README with correct plugin method signature
2015-10-08 19:42:03 +02:00
Dan Shepherd d45652afe2 Update README with correct plugin method signature
The existing README states that 3 params are passed for plugins (params, smarty, template) but the smarty object was actually removed long ago. This update correct this.
2015-10-08 13:50:46 +01:00
uwetews 64464e8fbe - bugfix {if $foo instanceof $bar} failed to compile if 2nd value is a variable https://github.com/smarty-php/smarty/issues/92 2015-09-19 19:55:14 +02:00
uwetews d5ca4518be - bugfix {foreach} first attribute was not correctly reset since commit 05a8fa2 of 02.08.2015 https://github.com/smarty-php/smarty/issues/90 2015-09-17 21:01:48 +02:00
uwetews e1e8d2feda - update compiler by moving no longer needed properties, code optimizations and other 2015-09-16 16:23:38 +02:00
uwetews 5a9500c2d9 - remove not needed compiled code whan caching is disabled 2015-09-15 01:25:40 +02:00
uwetews 83a68c99c8 - update template inheritance processing 2015-09-15 00:44:34 +02:00
uwetews fb9f2c9267 fix 2015-09-15 00:21:28 +02:00
uwetews ceb9afbb5d - bugfix unintended multiple debug windows (forum topic 25699) 2015-09-15 00:18:17 +02:00
uwetews 0eb7f4b8d1 - improvement invalidate OPCACHE for cleared compiled and cached template files (forum topic 25557) 2015-09-15 00:15:12 +02:00
uwetews 6ff3505a37 - move code of {call} processing back into Smarty_Internal_Template class 2015-09-14 23:50:20 +02:00
uwetews 8d734a9d52 - update template inheritance processing 2015-09-14 23:46:17 +02:00
uwetews 71c1b32c51 - optimize internal subtemplate handling 2015-09-14 23:39:04 +02:00
uwetews 5cbedc87f0 - optimize internal subtemplate handling 2015-09-14 23:16:13 +02:00
uwetews df0824675a - optimize internal subtemplate handling 2015-09-14 23:12:03 +02:00
uwetews 56a884a428 - optimize autoloader 2015-09-14 23:02:59 +02:00
uwetews bfcffb009a - remove unneeded code and properties, minor fixes 2015-09-01 02:52:09 +02:00
uwetews ca0b3f02b9 add some cope needed for PHPunit tests 2015-09-01 02:35:51 +02:00
uwetews 2e0b834b59 remove unneeded realpath call 2015-09-01 02:34:59 +02:00
uwetews d2fa4083f7 - move template function code into runtime extension 2015-09-01 02:30:56 +02:00
uwetews 2ba7109043 - move subtemplate code into runtime extension and optimize for size and speed 2015-09-01 02:27:22 +02:00
uwetews 37e6529c7b - improvement convert template inheritance into runtime processing
- bugfix {$smarty.block.parent} did always reference the root parent block https://github.com/smarty-php/smarty/issues/68
2015-09-01 02:10:15 +02:00
uwetews 620e52405b - improvement convert template inheritance into runtime processing
- bugfix {$smarty.block.parent} did always reference the root parent block https://github.com/smarty-php/smarty/issues/68
2015-09-01 01:54:28 +02:00
uwetews 54d54e5000 hook for runtime extension loading 2015-09-01 00:33:10 +02:00
uwetews 0d46c17578 - rearrange internal cache 2015-08-29 14:37:59 +02:00
uwetews 31a7162fba - remove double break 2015-08-27 19:26:49 +02:00
uwetews 3ba86e8d91 remove permission properties 2015-08-23 19:58:27 +02:00
uwetews d67acf7e9a revert removal of permission properties 2015-08-23 18:46:32 +02:00
uwetews 470cd186c4 major push of internal changes for size and speed optimizations 2015-08-23 17:23:09 +02:00
uwetews 0e4039f5c0 - bugfix compiling super globals like {$smarty.get.foo} did fail in the master branch https://github.com/smarty-php/smarty/issues/77 2015-08-23 16:59:34 +02:00
uwetews 9fd0b3086d - remove redundant code 2015-08-23 13:53:03 +02:00
uwetews 9eb87ef5a2 - relocate properties for size optimization 2015-08-23 13:24:24 +02:00
uwetews 606b8e8669 - optimize use_include_path processing 2015-08-23 11:13:20 +02:00
uwetews 2c197a2ea6 - check if $includes entry does exist 2015-08-23 06:47:39 +02:00
uwetews 3382aab429 - fix output buffer handling 2015-08-23 06:46:03 +02:00
uwetews 0b9e46d6ed - bugfix do not cache template object for config files 2015-08-23 05:36:20 +02:00
uwetews c6ea69feb7 - bugfix uncompiled templates could not be cached after recent change 2015-08-23 05:35:13 +02:00
uwetews 3daf187fb1 - bugfix of unneeded instanceof conditions replacement 2015-08-23 05:33:04 +02:00
uwetews 189b2af115 - optimize invalidation of internal caches 2015-08-23 05:27:16 +02:00
uwetews 1ae11c26c0 - optimize Smarty::templateExists() 2015-08-23 05:15:05 +02:00
uwetews fb83a888f3 varname changes 2015-08-23 02:03:25 +02:00
uwetews e2f11126eb fix PHPDoc 2015-08-23 02:00:25 +02:00
uwetews a413a2a2e1 replace unneeded instanceof conditions 2015-08-23 01:50:05 +02:00
uwetews 6eed7732df - remove properties with redundant content 2015-08-23 01:46:30 +02:00
uwetews 87985d1243 - move caching to Smarty::_cache 2015-08-23 01:39:18 +02:00
uwetews 6a26393099 - optimize rendering 2015-08-23 01:26:46 +02:00
uwetews 329cd6ec4d - remove not really needed properties 2015-08-19 02:19:25 +02:00
uwetews df541858de - cache template object of {include} if same template is included several times 2015-08-19 01:22:27 +02:00
uwetews 7935b181fb - optimize nocache hash processing 2015-08-19 01:18:25 +02:00
uwetews 8292a3581c - use output buffers for better performance and less memory usage 2015-08-19 01:09:08 +02:00
uwetews 6087ac5de0 - convert debug console processing to object 2015-08-19 00:58:47 +02:00
uwetews 5f7b5a45ac improve performance 2015-08-18 03:20:01 +02:00
uwetews 457a0486f5 - cache template object of {include} if same template is included several times 2015-08-18 02:55:53 +02:00
uwetews e8252906ba - make sure that property value is set 2015-08-17 22:27:41 +02:00
uwetews 6cbcdf4d7b - load seldom used Smarty API methods dynamically to reduce memory footprint 2015-08-17 21:52:32 +02:00
uwetews eb7aa8fe92 update template_id handling 2015-08-15 18:35:51 +02:00
uwetews 8a9b52e975 optimize $properties array 2015-08-15 18:32:27 +02:00
uwetews 9ad5e1eb1e define missing properties 2015-08-15 18:25:06 +02:00
uwetews af6f77a9e6 create raw compiled object to avoid checking for compiled file 2015-08-10 22:45:56 +02:00
uwetews e63926088c optimize compilation of merged subtemplates 2015-08-10 22:35:33 +02:00
uwetews 0260b525b8 introduce Smarty::$resource_cache_mode and cache template object of {include} inside loop 2015-08-10 21:57:06 +02:00
uwetews 5c9c57df7d replace property array by object properties 2015-08-09 21:14:16 +02:00
uwetews 6bcdd0edbe remove unused parameter 2015-08-09 20:56:18 +02:00
uwetews dde6bc506b remove unneeded method 2015-08-09 20:54:13 +02:00
uwetews 7d2e27ae2f use parent_compiler object for storing required plugins 2015-08-09 20:53:32 +02:00
uwetews 3619b672f4 replace property array by object properties 2015-08-09 20:48:33 +02:00
uwetews c08191d191 replace property array by object properties 2015-08-09 20:45:28 +02:00
uwetews d16e2d3a15 replace property array by object properties 2015-08-09 20:43:04 +02:00
Uwe Tews 643e6784e8 - bugfix Smarty failed when compile_id did contain "|" 2015-08-06 21:42:20 +02:00
Uwe Tews c5cf7884d5 - commit several internal improvements 2015-08-06 19:46:44 +02:00
Uwe Tews ea6f848e04 fix properties 2015-08-06 19:42:40 +02:00
Uwe Tews 5d1ba7ca9c restore template object state on exception, free lexer/parser resources 2015-08-06 19:40:37 +02:00
Uwe Tews e402e2f893 no need to clone handler 2015-08-06 19:32:33 +02:00
Uwe Tews de49865d22 optimize template object caching 2015-08-06 19:25:00 +02:00
Uwe Tews 16fc95ccf7 load source resource at template object creation 2015-08-06 19:16:41 +02:00
Uwe Tews 1ed4808bd9 check parent object type 2015-08-06 19:14:55 +02:00
Uwe Tews 5ca4f0484a load source resource at template object creation 2015-08-06 19:12:24 +02:00
Uwe Tews 35c7e9767d remove unneeded properties 2015-08-06 19:05:11 +02:00
Uwe Tews 8cffee8426 invalidate compiled resource cache 2015-08-06 19:02:30 +02:00
Uwe Tews 63a1e74811 - rewrite compileAll... utility methods 2015-08-06 01:29:36 +02:00
Uwe Tews a7098432ba Make declaration compatible with compile assign 2015-08-06 01:24:41 +02:00
Uwe Tews e1cc514a68 - avoid possible circular object referances caused by parser/lexer objects 2015-08-06 01:19:11 +02:00
Uwe Tews ca969fe663 fix autoloader optimization 2015-08-06 00:59:06 +02:00
Uwe Tews 8c5f20430d optimize duplicate code 2015-08-06 00:57:36 +02:00
Uwe Tews 80ee385965 - improve getIncludePath() to return directory i 2015-08-03 22:32:09 +02:00
Uwe Tews 201ea13a33 - bugfix compileAllConfig() was broken since 3.1.22 because of the changes in config file processing 2015-08-03 21:39:30 +02:00
Uwe Tews f2585a035c - rework clear cache methods 2015-08-03 05:40:34 +02:00
Uwe Tews 147ba329b5 Fix generated code 2015-08-03 03:14:25 +02:00
Uwe Tews 7dfe853076 remove unneed dummy $smarty template variable 2015-08-02 21:12:33 +02:00
Uwe Tews c95ff14434 - rework {capture} compiler 2015-08-02 20:57:46 +02:00
Uwe Tews e205cb7a89 - optimization and code cleanup of {foreach} and {section} compiler 2015-08-02 19:43:21 +02:00
Uwe Tews 05a8fa245e - improvement show resource type and start of template source instead of uid on eval: and string: resource (forum topic 25630) 2015-08-01 14:28:39 +02:00
Uwe Tews 3d2a15be3c - update DateTime object can be instance of DateTimeImmutable since PHP5.5 https://github.com/smarty-php/smarty/pull/75 2015-08-01 13:09:41 +02:00
Uwe Tews c5cdd90352 - optimize {foreach} and {section} compiler 2015-07-31 01:03:29 +02:00
Uwe Tews e9d172d8ac - optimize {section} compiler for speed and size of compiled code 2015-07-30 02:45:38 +02:00
Uwe Tews 20640577a1 Revert "- optimize {section} compiler for speed and size of compiled code"
This reverts commit 1074090473.
2015-07-30 02:03:29 +02:00
Uwe Tews 1074090473 - optimize {section} compiler for speed and size of compiled code 2015-07-30 01:15:22 +02:00
Uwe Tews aa6e2219ec - optimize {section} compiler for speed and size of compiled code 2015-07-30 01:03:12 +02:00
Uwe Tews 8eabafed83 add some error suppression for undefined variables 2015-07-29 23:30:52 +02:00
Uwe Tews 99d802f30c - optimize {section} compiler for speed and size of compiled code 2015-07-29 22:23:23 +02:00
Uwe Tews c9f2a0d26e - update for PHP 7 compatibility 2015-07-28 01:39:08 +02:00
Uwe Tews fe4fdd15d8 add PHP 7 to travis tests 2015-07-28 01:15:31 +02:00
Uwe Tews d192e470d5 add PHP 7 to travis tests 2015-07-28 01:12:45 +02:00
Uwe Tews 0436176739 add hhvm to travis test 2015-07-26 18:11:10 +02:00
Uwe Tews f9d9ca0f67 - improvement impement workaround for HHVM PHP incompatibillity https://github.com/facebook/hhvm/issues/4797 2015-07-26 18:04:40 +02:00
Uwe Tews bb3dfc6fdf - bugfix parser did hang on text starting <?something https://github.com/smarty-php/smarty/issues/74 2015-07-25 22:32:10 +02:00
Uwe Tews f61084f70f move Smarty::clear() into extension 2015-07-20 04:38:13 +02:00
Uwe Tews 8cbe51a603 - improvement invalidate PHP 5.5 opcache for recompiled and cached templates https://github.com/smarty-php/smarty/issues/72 2015-07-20 04:01:43 +02:00
Uwe Tews 3e54c268ab - bugfix config files got recompiled on each request 2015-07-20 03:15:45 +02:00
Uwe Tews 61253c1999 optimization 2015-07-12 07:03:55 +02:00
Uwe Tews 208628080f reformat 2015-07-12 07:02:25 +02:00
Uwe Tews 21e07daf6d optimization 2015-07-12 02:26:42 +02:00
Uwe Tews 878724c4ea - optimize {extends} compilation 2015-07-12 01:11:22 +02:00
Uwe Tews b3fd262541 - bugfix force file: resource in demo resource.extendsall.php 2015-07-10 05:18:10 +02:00
Uwe Tews 7a56edc180 - bugfix convert each word of class names to ucfirst in in compiler. (forum topic 25588) 2015-07-08 04:59:37 +02:00
Uwe Tews 40f0dda0e6 - new feature multiple indices on file: resource 2015-07-07 18:18:19 +02:00
Uwe Tews 1e4f28da54 update Smarty::_realpath() 2015-07-07 17:56:50 +02:00
Uwe Tews 7fa6c4fd47 update include_path handling 2015-07-07 17:55:45 +02:00
Uwe Tews 733755f94a reformat 2015-07-07 17:51:40 +02:00
uwetews f66cd7e062 Merge pull request #71 from mmerian/master
Added $limit parameter to regex_replace modifier
2015-07-07 15:40:28 +02:00
Maxime Mérian 73dc3f311a Added $limit parameter to regex_replace modifier 2015-07-07 09:32:40 +02:00
Uwe Tews bc99747f93 - improvement allow fetch() or display() called on a template object to get output from other template
like $template->fetch('foo.tpl') https://github.com/smarty-php/smarty/issues/70
2015-07-07 02:01:45 +02:00
Uwe Tews 5b401789b5 - optimization resource extendsall 2015-07-06 06:57:56 +02:00
uwetews a35294946e Merge pull request #69 from bmewburn/master
removed invalid .gitignore pattern
2015-07-06 05:46:01 +02:00
Uwe Tews 06096191c5 - optimize {block} compilation 2015-07-06 03:41:37 +02:00
Uwe Tews b1fdc085e7 - optimization get rid of __get and __set in source object 2015-07-06 03:25:03 +02:00
Uwe Tews b198e6488c - optimize {block} compilation 2015-07-06 03:12:25 +02:00
bmewburn da38a22621 removed invalid .gitignore pattern
git ignore pattern .idea\ causes version control in netbeans 8.02 to crash
2015-07-06 11:12:11 +10:00
Uwe Tews 7e7112153a search {foreach} properties also in parent compiler 2015-07-01 13:01:16 +02:00
Uwe Tews e5bea506af - bugfix debugging console did not display string values containing \n, \r or \t correctly https://github.com/smarty-php/smarty/issues/66 2015-07-01 10:54:45 +02:00
Uwe Tews a756ce3d9e add error messages 2015-07-01 10:46:51 +02:00
Uwe Tews be212a2a87 load template source early 2015-07-01 06:44:28 +02:00
Uwe Tews 9ac1dd44e2 - update {foreach} compiler 2015-07-01 03:30:08 +02:00
Uwe Tews a9f0b8ad1f - optimize compile check handling 2015-07-01 03:27:06 +02:00
Uwe Tews 86783c857d use tag object cache of parent compiler 2015-07-01 03:25:55 +02:00
Uwe Tews 2762d81d93 add new methods and optimizations 2015-07-01 03:23:40 +02:00
Uwe Tews 8567f08248 fix flag in file status cache 2015-06-30 02:59:41 +02:00
Uwe Tews c84e406db5 observe $smarty->compile_check 2015-06-29 20:48:49 +02:00
Uwe Tews 83f6154eae - compiler optimization 2015-06-29 20:45:21 +02:00
Uwe Tews 3052406cfc - fix $smarty->use_include_path option and optimize file path code 2015-06-29 02:41:42 +02:00
Uwe Tews 99fe8120c8 - remove redundant code 2015-06-28 15:45:50 +02:00
Uwe Tews 8d30442450 - bugfix PATH_SEPARATOR was replaced by mistake in autoloader 2015-06-28 15:12:00 +02:00
Uwe Tews cd132140f2 - optimize file path normalization 2015-06-28 12:54:47 +02:00
Uwe Tews c1ae1a52af - optimize autoloader 2015-06-28 08:33:18 +02:00
Uwe Tews ce0c1dcfae - move $smarty->append() and $smarty->appendByRef() into extension 2015-06-28 05:22:19 +02:00
Uwe Tews 3442acd407 update comment 2015-06-28 05:00:47 +02:00
Uwe Tews f4d7838a8f - move getStreamVariable() into extension 2015-06-28 05:00:27 +02:00
Uwe Tews afe9af11b7 - move $smarty->getTemplateVars() into extension 2015-06-28 04:44:16 +02:00
Uwe Tews 85eb95d960 - move auto load filter methods into extension 2015-06-28 04:05:07 +02:00
Uwe Tews aee07f7bba - optimize security isTrustedResourceDir() 2015-06-28 02:37:41 +02:00
Uwe Tews 5377fd5926 - move $smarty->enableSecurity() into Smarty_Security class 2015-06-28 01:38:52 +02:00
Uwe Tews 15d8e545cd - rework of $smarty->clearCompiledTemplate() and move it to its own extension 2015-06-27 23:59:12 +02:00
Uwe Tews 9d937ffe68 - bugfix allow function plugins with name ending with 'close' https://github.com/smarty-php/smarty/issues/52 2015-06-27 22:18:08 +02:00
Uwe Tews 1360be4eef - minor compiler optimizations 2015-06-27 21:50:33 +02:00
Uwe Tews 38e47c7ee2 - minor compiler optimizations 2015-06-27 21:23:22 +02:00
Uwe Tews 291c06dbea - move $smarty->loadPlugin() into extension 2015-06-27 20:56:27 +02:00
Uwe Tews 75ccd86c8a - update {include_php} with new realpath handling 2015-06-27 20:25:54 +02:00
Uwe Tews f567d5d778 - update Smarty security with new realpath handling 2015-06-27 20:18:01 +02:00
Uwe Tews 6197df45b5 - update $smarty->_realpath for relative path not starting with './' 2015-06-27 20:08:17 +02:00
Uwe Tews aefec40962 - fix special cases of filepath normalization 2015-06-27 18:30:47 +02:00
Uwe Tews e0630b106a revert 2015-06-27 16:31:26 +02:00
Uwe Tews c5ea2e4b48 add hhvm 2015-06-27 16:26:31 +02:00
Uwe Tews 9986286af0 - bugfix resolve naming conflict between custom Smarty delimiter '<%' and PHP ASP tags https://github.com/smarty-php/smarty/issues/64 2015-06-27 16:09:50 +02:00
Uwe Tews 3239a19435 - bugfix resolve naming conflict between custom Smarty delimiter '<%' and PHP ASP tags https://github.com/smarty-php/smarty/issues/64 2015-06-27 15:35:27 +02:00
Uwe Tews 6b875397a5 update autoloader 2015-06-21 13:56:10 +02:00
Uwe Tews b64d5d26c9 - update realpath handling 2015-06-21 13:53:52 +02:00
Uwe Tews 666f7264f4 optimization 2015-06-21 13:51:50 +02:00
Uwe Tews dd4cbfac3a - move registerObject / registerClass into extension 2015-06-21 13:43:17 +02:00
Uwe Tews 1a24b3971d - optimization of filter execution 2015-06-21 13:23:23 +02:00
Uwe Tews c09b05cbe3 - optimization of directory handling / build realpath 2015-06-21 13:11:52 +02:00
Uwe Tews 31d94d05d3 - optimization of template/config file normalization 2015-06-21 12:52:49 +02:00
Uwe Tews 4e471b19e2 - optimization of template/config file normalization 2015-06-21 12:42:53 +02:00
Uwe Tews 2d0f457abd Update 2015-06-20 18:25:05 +02:00
Uwe Tews afe79aac2e - improvement allow closures as callback at $smarty->registerFilter() https://github.com/smarty-php/smarty/issues/59 2015-06-19 03:21:52 +02:00
Uwe Tews 4537d8aae6 Release 3.1.27 2015-06-18 02:55:59 +02:00
Uwe Tews 34531edb4c - bugfix another update on file path normalization failed on path containing something like "/.foo/" https://github.com/smarty-php/smarty/issues/56 2015-06-18 02:53:22 +02:00
Uwe Tews 2cdba79a74 Release 3.1.26 2015-06-18 02:08:42 +02:00
Uwe Tews 7b469c1f4a - bugfix file path normalization failed on path containing something like "/.foo/" https://github.com/smarty-php/smarty/issues/56 2015-06-18 01:46:35 +02:00
Uwe Tews 52ced72361 - bugfix calling a plugin with nocache option but no other attributes like {foo nocache} caused call to undefined function https://github.com/smarty-php/smarty/issues/55 2015-06-18 00:06:40 +02:00
Uwe Tews 58616d6ee5 Release 3.1.25 2015-06-16 00:23:24 +02:00
Uwe Tews ec383370cb - optimization of smarty_cachereource_keyvaluestore.php code 2015-06-15 23:39:42 +02:00
Uwe Tews 3bb22560c0 - 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 2015-06-14 04:26:37 +02:00
Uwe Tews 83f3f6d7f1 - 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 2015-06-14 04:23:50 +02:00
Uwe Tews ecddc1f720 - 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
2015-06-14 03:30:31 +02:00
Uwe Tews e96ee1b5d6 - bugfix a custom cache resource using smarty_cachereource_keyvaluestore.php did fail if php.ini mbstring.func_overload = 2 (forum topic 25568) 2015-06-13 19:39:02 +02:00
Uwe Tews 768b7d1ec5 - bugfix the lexer could hang on very large quoted strings (forum topic 25570) 2015-06-11 23:33:30 +02:00
Uwe Tews f1e1f56ffe - 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 2015-06-08 23:54:46 +02:00
Uwe Tews d804454f21 Fix spelling 2015-06-04 02:40:36 +02:00
Uwe Tews 2a1badfebb - bugfix possible error message on unset() while compiling {block} tags https://github.com/smarty-php/smarty/issues/46 2015-06-04 02:39:26 +02:00
Uwe Tews fa269d418f - bugfix <?xml ... ?> including template variables broken since 3.1.22 https://github.com/smarty-php/smarty/issues/47 2015-06-01 22:26:45 +02:00
Uwe Tews 3771ea8d35 Fix comments 2015-05-28 22:31:35 +02:00
Uwe Tews 63b1d343b8 - 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 2015-05-27 22:24:24 +02:00
Uwe Tews 0434f34bdd - bugfix if condition string 'neq' broken due to a typo https://github.com/smarty-php/smarty/issues/42 2015-05-24 18:37:53 +02:00
Uwe Tews c9cd39f36f minor bugfix when processing autoliteral { php} tag. Does not effect generated output. 2015-05-23 23:40:02 +02:00
Uwe Tews 0356b70578 minor fix 2015-05-23 22:40:24 +02:00
Uwe Tews aa1e554993 Remove redundant code 2015-05-23 22:36:46 +02:00
Uwe Tews 531b298886 Prepare 3.1.25-dev 2015-05-23 19:25:50 +02:00
Uwe Tews b58771e31b Release 3.1.24 2015-05-23 19:22:14 +02:00
Uwe Tews c226fbd3d9 Travis setup does not work for PHP 5.2 for some reason 2015-05-23 19:04:19 +02:00
Uwe Tews 25391749a1 - improvement on php_handling to allow very large PHP sections, better error handling
- improvement allow extreme large comment sections (forum 25538)
2015-05-23 19:03:13 +02:00
Uwe Tews ec449734c3 - improvement on php_handling to allow very large PHP sections, better error handling
- improvement allow extreme large comment sections (forum 25538)
2015-05-23 18:56:00 +02:00
Uwe Tews c8ecad0b06 - bugfix named {foreach} comparison like $smarty.foreach.foobar.index > 1 did compile into wrong code https://github.com/smarty-php/smarty/issues/41 2015-05-21 00:59:26 +02:00
Uwe Tews 5d8718f761 - bugfix broken PHP 5.2 compatibility when compiling <?php tags https://github.com/smarty-php/smarty/issues/40 2015-05-21 00:05:16 +02:00
Uwe Tews 85e05458c6 - bugfix compiler could run into the pcre.backtrack_limit on larger comment or {php} tag sections (forum 25538) 2015-05-20 05:48:45 +02:00
Uwe Tews b8eb8784d4 - bugfix output filter trimwhitespace could run into the pcre.backtrack_limit on large output (code.google issue 220) 2015-05-20 04:26:29 +02:00
Uwe Tews 5468f140fa - bugfix compiler did overwrite existing variable value when setting the nocache attribute https://github.com/smarty-php/smarty/issues/39 2015-05-19 22:47:04 +02:00
Uwe Tews dcf53ca957 Fix max nesting parameter 2015-05-18 05:39:57 +02:00
Uwe Tews ed740b967a Removed redundant code 2015-05-18 04:26:46 +02:00
Uwe Tews ac99173cea - improvement introduce shortcuts in lexer/parser rules for most frequent terms for higher
compilation speed
2015-05-18 04:12:40 +02:00
Uwe Tews bef7c55544 {for} should be able to init array elements 2015-05-18 04:00:17 +02:00
Uwe Tews e3123c0427 - improvement higher compilation speed by modified lexer/parser generator at "smarty/smarty-lexer" 2015-05-16 16:33:50 +02:00
Uwe Tews d21921de22 - improvement reduce number of lexer tokens on operators and if conditions 2015-05-16 14:47:12 +02:00
Uwe Tews 22bccee350 - improvement remove not needed ?><?php transitions from compiled code 2015-05-16 14:17:59 +02:00
Uwe Tews 0bdd805d6b remove code not intended for this version 2015-05-16 13:40:45 +02:00
Uwe Tews a74804b061 - bugfix {php}{/php} did work just for single lines https://github.com/smarty-php/smarty/issues/33 2015-05-16 13:33:04 +02:00
Uwe Tews 9f1061f5bc - bugfix template functions failed when calling the function recursively with function name as tag name https://github.com/smarty-php/smarty/issues/28 2015-05-14 15:13:09 +02:00
Uwe Tews 2db464a6e5 - bugfix template functions failed when calling the function recursively with function name as tag name https://github.com/smarty-php/smarty/issues/28 2015-05-14 15:11:38 +02:00
Uwe Tews 8ee805632d - bugfix in Smarty_Security 'nl2br' should be a trusted modifier, not PHP function (code.google issue 223) 2015-05-13 20:17:02 +02:00
Uwe Tews dea56a2243 default for $debug_tpl will be set up in Smarty_Internal_Debug 2015-05-13 19:25:05 +02:00
Uwe Tews e0dbc79204 Debugging - add display of Smarty version 2015-05-13 19:10:06 +02:00
Uwe Tews a3c89bb4f4 Debugging - truncate output of Origin to 80 characters and increase string values from 40 to 80 characters 2015-05-13 19:03:54 +02:00
Uwe Tews 319e396937 use clean Smarty object to display the debugging console.
Avoid possible promblems when application did overload the Smarty object or properties go modified hardcoded in the class source.
2015-05-13 18:04:29 +02:00
Uwe Tews 3240b5a596 - improvement remove not needed ?><?php transitions from compiled code 2015-05-13 02:09:00 +02:00
Uwe Tews 2b858212b7 - improvement remove not needed ?><?php transitions from compiled code 2015-05-13 02:06:33 +02:00
Uwe Tews cf5b5c4e1f Disable hhvm test because of a hhvm PHP compatibility problem 2015-05-13 01:50:23 +02:00
Uwe Tews 07c781d9cf - bugfix in nested {foreach} saved item attributes got overwritten https://github.com/smarty-php/smarty/issues/33 2015-05-13 00:33:23 +02:00
Uwe Tews e4741e9dd7 version update after fixed issues 28 and 29 2015-05-12 20:41:41 +02:00
Uwe Tews ece0e2241f Log fixes for issue 28 and 29 2015-05-12 20:39:10 +02:00
Uwe Tews 3ac71869a6 Remove PHP nightly test 2015-05-12 20:33:18 +02:00
uwetews f791eeba11 Merge pull request #32 from Stricted/patch-1
fix variable name
2015-05-12 18:40:53 +02:00
uwetews 962cf3d193 Merge pull request #30 from Stricted/master
fix constant handling
2015-05-12 18:40:08 +02:00
Stricted a8f30dc7f6 fix variable name 2015-05-12 15:52:54 +02:00
Stricted 4af23bc104 fix last commit 2015-05-12 15:44:54 +02:00
Stricted 811e2e0e13 fix constant handling
on undefined constants you get 'TEST_CONST' on definied constants TEST_CONST
2015-05-12 15:43:57 +02:00
Uwe Tews 2ff51de3df allow failures of hhvm 2015-05-12 04:48:10 +02:00
Uwe Tews 04f0090c40 release 3.1.23 2015-05-12 04:08:22 +02:00
Uwe Tews e6a4e68139 remove hhvm nightly test 2015-05-12 04:01:10 +02:00
Uwe Tews d234625d7c - bugfix of smaller performance issue introduce in 3.1.22 when caching is enabled 2015-05-12 03:34:38 +02:00
Uwe Tews b4792df08a - bugfix missig entry for smarty-temmplate-config in autoloader 2015-05-12 03:07:24 +02:00
Uwe Tews 6deb3cee7c update travis 2015-05-12 02:58:32 +02:00
Uwe Tews c12655ded2 - bugfix of smaller performance issue introduce in 3.1.22 when caching is enabled 2015-05-12 02:52:30 +02:00
Uwe Tews 8acb920e20 update 2015-05-12 01:17:14 +02:00
Uwe Tews d276829aa6 fix comment 2015-05-11 23:09:27 +02:00
Uwe Tews 556185c9e2 Update 2015-05-10 23:17:43 +02:00
Uwe Tews ebef3b1988 Update 2015-05-10 23:14:51 +02:00
Uwe Tews ee8a695a57 Update 2015-05-10 22:46:48 +02:00
Uwe Tews 94d5e1e198 Update 2015-05-10 22:42:24 +02:00
Uwe Tews 469a6ad860 correction 2015-05-10 21:55:43 +02:00
Uwe Tews 735507b0ba correction 2015-05-10 21:53:16 +02:00
Uwe Tews 4c3e67a301 update 2015-05-10 21:47:34 +02:00
Uwe Tews 31edf7fcea push 2015-05-10 21:44:18 +02:00
Uwe Tews 5963632a99 add .travis.yml 2015-05-10 21:05:54 +02:00
Uwe Tews 3836cafd90 Prepare 3.1.23-dev 2015-05-10 13:17:33 +02:00
Uwe Tews 0f9ec2642a Release 3.1.22 2015-05-10 13:08:04 +02:00
Uwe Tews ab93b0feee - improvement added constants for $debugging 2015-05-10 12:18:41 +02:00
Uwe Tews 741a07fc8f new dev version 2015-05-10 12:13:21 +02:00
Uwe Tews 8a34ad0cd2 parameter cleanup 2015-05-10 12:09:24 +02:00
Uwe Tews b0ca67b213 - bugfix cache lock was not handled correctly after timeout when $cache_locking == true 2015-05-10 12:08:47 +02:00
Uwe Tews 5ce5d4df49 - bugfix custom cache resource did not observe compile_id and cache_id when $cache_locking == true 2015-05-10 12:00:19 +02:00
Uwe Tews edf49ca3cf formatting 2015-05-10 11:53:09 +02:00
Uwe Tews af4a923da5 - uodate and fixes at cache locking 2015-05-08 07:27:45 +02:00
Uwe Tews d7b0b57420 - optimization of resource class loading 2015-05-08 06:02:59 +02:00
Uwe Tews c5468b421e - optimization of resource class loading 2015-05-07 22:57:59 +02:00
Uwe Tews 37449b2fcb - improvement of the debugging console. Read NEW_FEATURES.txt 2015-05-07 04:36:49 +02:00
Uwe Tews af08353e93 - bugfix/improvement in 3.1.22-dev cache locking did not work as expected 2015-05-06 23:10:39 +02:00
Uwe Tews 57df382ff2 - bugfix in 3.1.22-dev cache resource must not be loaded for subtemplates 2015-05-06 22:10:04 +02:00
Uwe Tews d92714cc7e - optimization move <?php ?> handling from parser to new compiler module 2015-05-06 00:03:26 +02:00
Uwe Tews d7ff1eec47 - optimization on cache update when main template is modified 2015-05-05 15:46:24 +02:00
Uwe Tews 914815d438 Fix broken code 2015-05-05 06:48:37 +02:00
Uwe Tews 3e4734acfb - bugfix code could be messed up when {tags} are used in multiple attributes https://github.com/smarty-php/smarty/issues/23 2015-05-05 03:33:53 +02:00
Uwe Tews 6575e11f68 Add missing properties 2015-05-05 03:27:16 +02:00
Uwe Tews c5915a8c0c - improvement use is_file() checks to avoid errors suppressed by @ which could still cause problems (https://github.com/smarty-php/smarty/issues/24) 2015-05-05 00:41:30 +02:00
Uwe Tews f14f2dcc6f - bugfix Smarty_Resource::parseResourceName incompatible with Google AppEngine (https://github.com/smarty-php/smarty/issues/22) 2015-05-04 22:44:29 +02:00
Uwe Tews 22ea1404df add information how to get development tools 2015-05-04 18:21:55 +02:00
Uwe Tews 08c81acbb1 add require-dev to load PHPUnit tests and lxer/parser generator (reverted from commit f3d7b05ccb) 2015-05-04 18:20:44 +02:00
Uwe Tews 9789867d8b Revert "add require-dev to load PHPUnit tests and lxer/parser generator"
This reverts commit f3d7b05ccb.
2015-05-04 18:09:21 +02:00
Uwe Tews 80926a538d Revert "test"
This reverts commit d40e2a0286.
2015-05-04 18:08:41 +02:00
Uwe Tews d40e2a0286 test 2015-05-04 05:54:05 +02:00
Uwe Tews f3d7b05ccb add require-dev to load PHPUnit tests and lxer/parser generator 2015-05-04 05:20:22 +02:00
Uwe Tews ea17aad266 - bugfix plugins of merged subtemplates not loaded in 3.1.22-dev (forum topic 25508) 2nd fix 2015-04-28 23:12:12 +02:00
Uwe Tews e312dd9b59 - bugfix plugins of merged subtemplates not loaded in 3.1.22-dev (forum topic 25508) 2015-04-28 01:38:45 +02:00
Uwe Tews c7ba22dc98 - bugfix a nocache template variable used as parameter at {insert} was by mistake cached 2015-04-23 02:34:28 +02:00
Uwe Tews de892651c2 - bugfix at a template function containing nocache code a parmeter could overwrite a template variable of same name 2015-04-20 22:59:45 +02:00
Uwe Tews 6fb27d5ae4 strip property must now be public 2015-04-07 02:11:20 +02:00
Uwe Tews a92302d059 move strip processing from parser to compiler 2015-04-02 01:42:53 +02:00
Uwe Tews e9fd2354ef move compileVariable() from parser to compiler 2015-04-02 01:35:16 +02:00
Uwe Tews ea2a566b1f - 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)
2015-03-28 03:58:08 +01:00
Uwe Tews 443ae8c216 - bugfix problems when {function}{/function} defined a template function in a cached subtemplate and it was called {call} from a not cached subtemplate {forum topic 25468} 2015-03-23 00:39:22 +01:00
Uwe Tews 2a005ac6d6 - bugfix correct update of global variable values on exit of template functions. (reported under Smarty Developers) 2015-03-20 18:25:59 +01:00
Uwe Tews 2758cb8ce9 Correct version number 2015-03-20 01:49:52 +01:00
Uwe Tews 4ecc75344f - bugfix make sure that function properties get saved only in compiled files containing the fuction definition {forum topic 25452} 2015-03-20 00:41:55 +01:00
Uwe Tews 03c7b786a0 Clean up template functions property structure 2015-03-17 04:53:57 +01:00
Uwe Tews ab1272a2e4 fix whitespaces on tags included in double quoted strings 2015-03-17 04:31:51 +01:00
Uwe Tews 4c0e124c22 - bugfix {block}{/block} tags did not work inside double quoted strings issues #18 2015-03-17 03:40:01 +01:00
Uwe Tews 6df84b6fe3 - bugfix {block}{/block} tags did not work inside double quoted issues #18 2015-03-17 03:31:44 +01:00
Uwe Tews e7ad5909e5 - bugfix Smarty_Security->allow_constants=false; did not disallow direct usage of defined constants like {SMARTY_DIR} {forum topic 25457} 2015-03-17 02:29:19 +01:00
Uwe Tews eead9c81e9 - bugfix problems with {function}{/function} and {call} tags in different subtemplate cache files {forum topic 25452} 2015-03-17 01:10:51 +01:00
Uwe Tews 7b7118eea9 - bugfix $smarty->compile_check must be restored before rendering of a just updated cache file {forum 25452} 2015-03-15 02:01:07 +01:00
Uwe Tews 7fe81e6d79 - bugfix {nocache} {/nocache} tags corrupted code when used within a nocache section caused by a nocache template variable 2015-03-14 15:17:58 +01:00
Uwe Tews 8020144d46 - 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}
2015-03-14 12:02:57 +01:00
Uwe Tews e9b1f296cb - bugfix {include ... nocache} with variable file or compile_id attribute was not executed in nocache mode. 2015-03-10 18:06:05 +01:00
Uwe Tews 8892f358ad - bugfix __get() was called when loading config files 2015-03-07 01:44:30 +01:00
Uwe Tews b1cd4cd7d2 Return to saved output buffer level on exceptions 2015-03-01 21:39:54 +01:00
Uwe Tews 464b37c053 optimize compiled code of {foreach} 2015-02-15 16:58:42 +01:00
Uwe Tews 8082bc7471 get rid of smarty object self pointer 2015-02-15 01:45:37 +01:00
Uwe Tews f93cfc63ad get rid of reference parameter 2015-02-14 21:57:42 +01:00
Uwe Tews 6925c98af0 - bugfix multiple Smarty::fetch() of same template when $smarty->merge_compiled_includes = true; could cause function alreday defined error 2015-02-12 23:56:43 +01:00
Uwe Tews 0e87a99507 - bugfix recursive {includes} did create E_NOTICE message when $smarty->$merge_compiled_includes = true; 2015-02-11 07:15:40 +01:00
Uwe Tews aec380839c - bugfix recursive {includes} did create E_NOTICE message when $smarty->$merge_compiled_includes = true; 2015-02-11 06:57:17 +01:00
Uwe Tews 05f5ddf573 remove comments 2015-02-09 23:52:25 +01:00
Uwe Tews d62d394345 update 2015-02-08 22:22:52 +01:00
Uwe Tews d288e58692 update 2015-02-08 21:36:32 +01:00
Uwe Tews b2b114d5b8 udate 2015-02-08 21:21:30 +01:00
Uwe Tews 10bf6f6032 add isset($_smarty_tpl) to avoid errors when unit test runs in separate process 2015-02-08 21:10:45 +01:00
Uwe Tews 1fc2b9ece2 add isset($_smarty_tpl) to avoid errors when unit test runs in separate process 2015-02-08 19:57:14 +01:00
Uwe Tews e4e3e176c0 add note 2015-01-22 04:07:58 +01:00
Uwe Tews 1a781b39b1 new feature: security can now control access to static methods and properties
see also NEW_FEATURES.txt
2015-01-22 03:53:01 +01:00
Uwe Tews ec19bc763f - bugfix 'self::' and 'parent::' was interpreted in template syntax as static class 2015-01-21 23:30:37 +01:00
Uwe Tews 8d5fa36a80 - bugfix clearCompiledTemplates(), clearAll() and clear() could try to delete whole drive
at wrong path permissions because realpath() fail (forum 25397)
2015-01-21 22:14:25 +01:00
Uwe Tews 85f24ce413 convert writeFile() to object method to remove a vulnerability 2015-01-21 21:12:00 +01:00
Uwe Tews 7a1df12afa - bugfix clearCompiledTemplates() could try to delete whole drive
at wrong path permissions because realpath() fail (forum 25397)
2015-01-20 22:33:38 +01:00
Uwe Tews 4428d72e6d Update testInstall() and move it into its own class 2015-01-12 22:12:20 +01:00
Uwe Tews 593f984f6a load source, compiled and cache resource manually in normal flow (avoid __get()) 2015-01-07 17:46:12 +01:00
Uwe Tews 466c3ee9f8 Use require_once ; remove unnedded paramter 2015-01-07 16:46:57 +01:00
Uwe Tews 740a583c7c Use require_once 2015-01-07 16:46:03 +01:00
Uwe Tews b3f8ddefd2 remove redundant overloaded methods 2015-01-06 04:42:49 +01:00
Uwe Tews 43f043364f fix case in class name 2015-01-06 01:18:58 +01:00
Uwe Tews 67162324bb check ..._dir property overloading
if $template_dir, $compile_dir, $cache_dir, $config_dir or $plugins_dir properties
are overloaded the setters must be called for required processing
2015-01-05 02:03:24 +01:00
Uwe Tews 2aaa29ad20 reset _is_file_cache 2015-01-04 23:54:11 +01:00
Uwe Tews 7cc981e6a6 revert some unneeded normalization of compiled_dir, cache_dir and plugins_dir 2015-01-04 23:42:22 +01:00
Uwe Tews 3463fae2a1 push llast weeks changes to github 2015-01-04 05:57:49 +01:00
Uwe Tews 111a10bb17 Move some classes into its own files 2015-01-04 05:51:52 +01:00
Uwe Tews d528234a97 Small optimization 2015-01-04 05:51:03 +01:00
Uwe Tews 068da64c99 best defaults for internal resource caching
$resource_caching = false and $template_resource_caching = true

fixed typos
2015-01-04 05:49:38 +01:00
Uwe Tews 66eac7bc2a fix code frame of inline (merged) subtemplate 2015-01-03 21:32:33 +01:00
Uwe Tews 8b71e591c0 some minor speed optimization 2015-01-03 21:27:33 +01:00
Uwe Tews 57620443e9 Optimize constructor 2015-01-03 07:56:03 +01:00
Uwe Tews f236905fed create different compiled templates and config files
Smarty does now automatically detect a change of the $merge_compiled_includes and $escape_html
    property and create different compiled templates files depending on the setting.

    Same applies to config files and the $config_overwrite, $config_booleanize and
    $config_read_hidden properties.
2015-01-03 07:36:07 +01:00
Uwe Tews cfdd53c6b4 restructure config file processing
move code into an extension class
use Smarty_Internal_Template
2015-01-02 22:30:53 +01:00
Uwe Tews 75ad0b4da5 move default template handling into an extesion class 2015-01-02 10:48:07 +01:00
Uwe Tews 15728f6ea3 normalize directory path 2015-01-02 10:22:36 +01:00
Uwe Tews c8712b8b7e update autoloader 2015-01-02 09:12:27 +01:00
Uwe Tews 0a3579f9ca restructure template processing
Code was moved into classes it better belongs to.
This does reduce also Smarty's memory footprint
2015-01-02 09:12:01 +01:00
Uwe Tews 8c1f400c09 remove \r from template source before compiling 2015-01-02 08:25:27 +01:00
Uwe Tews 97e7948e16 fix update of file dependency 2015-01-02 08:20:57 +01:00
Uwe Tews 6f801de283 update buildFilepath() 2015-01-02 06:29:08 +01:00
Uwe Tews c55367d1f6 update buildFilepath() 2015-01-02 06:26:04 +01:00
Uwe Tews 296a88b557 Change class name case because of composer autoloader problems 2015-01-02 06:07:19 +01:00
Uwe Tews 3f08b18170 Correct recompiled check 2015-01-02 01:05:03 +01:00
Uwe Tews 48f66c81c7 rework class Smarty_Template_Cached
- move class Smarty_Template_Cached in its own file
- implement all code for chached template handling in class
2015-01-01 23:53:59 +01:00
Uwe Tews c3aa9994c8 rework source resource handling
- move class Smarty_Template_Source into its own file
- impelement all source processing into the classes it better belongs to
2015-01-01 23:34:29 +01:00
Uwe Tews dd2d24d1d6 rework class Smarty_Template_Compiled
- move class Smarty_Template_Compiled in its own file
- implement all code for compiled template handling in class
2015-01-01 23:28:09 +01:00
Uwe Tews 7c4e5175a4 rework class Smarty_Template_Compiled
- move class Smarty_Template_Compiled in its own file
- implement all code for compiled template handling in class (reverted from commit f6a1349fdb)
2015-01-01 23:15:08 +01:00
Uwe Tews f6a1349fdb rework class Smarty_Template_Compiled
- move class Smarty_Template_Compiled in its own file
- implement all code for compiled template handling in class
2015-01-01 23:11:35 +01:00
Uwe Tews 80bf76cc6e move internal createTemplateCodeFrame() method into an extension class 2015-01-01 22:59:07 +01:00
Uwe Tews e8a77171d3 implement templateId generation as method 2015-01-01 22:27:45 +01:00
Uwe Tews 2f8d4f1dbf missing property 2014-12-31 16:08:36 +01:00
Uwe Tews 0cb8b24055 implement most common stetters as method for better performance 2014-12-31 15:56:59 +01:00
Uwe Tews b013984dfd move properties into classes where they better belong to 2014-12-31 15:44:08 +01:00
Uwe Tews 2687f36849 update autoloader with for special class names 2014-12-31 14:32:47 +01:00
Uwe Tews 47faa63a0e use function_exists('mb_get_info') for setting Smarty::$_MBSTRING
Function mb_split could be overloaded depending on php.ini mbstring.func_overload
2014-12-31 06:07:17 +01:00
Uwe Tews 4b7fba4d88 get config properties via compiler object
- reverting part of earlier change of today
2014-12-30 18:16:51 +01:00
Uwe Tews e351c0123f move some code into Smarty_Internal_Debug class
where it better belongs to
2014-12-30 17:17:15 +01:00
Uwe Tews d3e26fb679 template function call handling 2014-12-30 16:43:42 +01:00
Uwe Tews 1d248d6349 formatting 2014-12-30 16:28:18 +01:00
Uwe Tews 8fe6f14af7 Change class name case because of composer autoloader problems 2014-12-30 16:27:08 +01:00
Uwe Tews b122878131 rename parse tree class names and minor fixes 2014-12-30 16:22:03 +01:00
Uwe Tews 825ccc9f47 rename parse tree class names to Smarty_Internal_ParseTree.... 2014-12-30 16:16:54 +01:00
Uwe Tews 485f093e0b get config properties via template object 2014-12-30 16:03:21 +01:00
Uwe Tews 6be6bf7b70 limit the template nesting level by security 2014-12-30 12:57:43 +01:00
Uwe Tews 1da50aa61d security can now disable special $smarty variables
see also NEW_FEATURES.txt
2014-12-29 21:59:23 +01:00
Uwe Tews 49a3427515 clear internal _is_file_cache when plugins_dir was modified 2014-12-27 23:06:04 +01:00
Uwe Tews 5e4f55d121 add .plex and .y files
add lexer .plex and parser .y files to distribution for easier version
control
2014-12-14 00:49:42 +01:00
Uwe Tews 46654268ef update .gitignore 2014-12-14 00:44:11 +01:00
Uwe Tews 2fb5bc6bbe lexer and parser optimizations
up to 30% higher compiling speed depending on template complexity
2014-12-13 23:02:29 +01:00
Uwe Tews 2fe60e8996 resolve parser ambiguity
- bugfix resolve parser ambiguity between constant print tag {CONST} and
other smarty tags after change of 09.12.2014
2014-12-11 05:21:21 +01:00
Smarty PHP Template Engine 042e93c725 Merge pull request #12 from jenolan/master
Commit 7b2a2c4a88 changed the constant pro...
2014-12-11 03:11:19 +01:00
Larry Lewis 7bb7b3ac03 Commit 7b2a2c4a88 changed the constant processing to allow a variable in teh $smarty.const but this broke the normal callout. Change allows both methods. 2014-12-11 08:06:27 +11:00
Uwe Tews 2a2a73cabc - bugfix call of template function by a variable name
did not work after latest changes (forum 25342)
2014-12-10 00:51:09 +01:00
Uwe Tews 7bd40d2c0b - bugfix variables $null, $true and $false did not work
after the change of 12.11.2014 (forum 25342)
2014-12-09 23:33:11 +01:00
Uwe Tews ffbfe40043 - bugfix a plugin with attached modifier could fail
if the tag was immediately followed by another Smarty tag (since 3.1.21) (forum 25326)
2014-11-23 13:25:09 +01:00
Uwe Tews de7310b702 Revert "delete unwanted file"
This reverts commit 77d8349ffb.
2014-11-13 19:52:41 +01:00
Uwe Tews 77d8349ffb delete unwanted file 2014-11-13 19:48:34 +01:00
Uwe Tews 0b6af0add7 move autoload code into Autoloader.php.
Use Composer autoloader when possible
2014-11-13 19:42:01 +01:00
Uwe Tews 0b21213c55 new feature - added support of namespaces to template code 2014-11-12 19:07:00 +01:00
Uwe Tews c7e8881c76 bugfix for recent changes of {function} tag handling 2014-11-11 01:01:01 +01:00
Uwe Tews 9ecbb93ebb update of the $smarty->merge_compiled_includes option 2014-11-11 00:03:08 +01:00
Uwe Tews 460be5a5da bugfix for recent changes of {function} tag handling 2014-11-10 23:57:30 +01:00
Uwe Tews adc6091c4d update of cache resources for template function calls in nocache mode 2014-11-09 10:20:06 +01:00
Uwe Tews 223cdc0787 moved code into constructor 2014-11-09 10:15:16 +01:00
Uwe Tews 230c5787e6 move Smarty exceptions into syslibs folder 2014-11-09 06:42:20 +01:00
Uwe Tews 4edb5fce30 Update of change log 2014-11-08 21:44:55 +01:00
Uwe Tews b82756a705 - bugfix subtemplate called in nocache mode could be called with wrong compile_id when it did change on one of the calling templates 2014-11-08 21:27:53 +01:00
Uwe Tews ea9c681106 remove no longer needed code 2014-11-08 21:06:53 +01:00
Uwe Tews f92af96419 fixed $smarty->debugging on merged compiled subtemplates 2014-11-08 21:02:14 +01:00
Uwe Tews 8f8d462b8a add code of template functions called in nocache mode dynamically to cache file 2014-11-08 17:19:53 +01:00
uwetews 845c4184b2 Merge pull request #9 from uwetews/master
new $smarty->debug options
2014-11-04 19:00:56 +01:00
Uwe Tews 963e5dae5e new $smarty->debug options
- new feature $smarty->debug = true; => overwrite existing Debug Console
window (old behaviour)
$smarty->debug = 2; => individual Debug Console window by template name
2014-11-04 18:59:57 +01:00
uwetews 5b1c649c6a Merge pull request #8 from uwetews/master
Debug Console Update
2014-11-03 22:31:13 +01:00
Uwe Tews 158b7be58a Debug Console Update
- 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
2014-11-03 22:27:32 +01:00
uwetews 4b3196fe30 Merge pull request #2 from smarty-php/master
Merge pull request #7 from uwetews/master
2014-11-02 14:57:41 +01:00
uwetews 4369b2fe05 Merge pull request #7 from uwetews/master
-bugfix and enhancement on subtemplate {include} and template {function}
2014-11-01 22:52:01 +01:00
Uwe Tews bc13ebbc9b -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
2014-11-01 22:42:34 +01:00
uwetews 5f2f292739 Merge pull request #1 from smarty-php/master
merge
2014-11-01 11:24:58 +01:00
Smarty PHP Template Engine 337ab5bd1e Merge pull request #6 from aivus/patch-1
Clean merge conflicts
2014-11-01 11:14:25 +01:00
Ilya Antipenko 95cc39deb6 Clean merge conflicts 2014-11-01 11:22:03 +02:00
Smarty PHP Template Engine 402547baaf Merge pull request #5 from uwetews/master
resolved merge conflict
2014-11-01 00:42:31 +01:00
Uwe Tews 199c16e827 resolved merge conflict 2014-11-01 00:34:32 +01:00
Uwe Tews 84e5ef7345 3.1.22-dev 2014-10-31 05:48:52 +01:00
Uwe Tews 21204c6613 Merge branch 'trunk' 2014-10-31 05:31:56 +01:00
Uwe Tews 1f878e6d74 v3.1.21 2014-10-31 05:22:20 +01:00
Uwe Tews 6254b5d4df Merge branch 'v3.1.21' 2014-10-31 05:16:16 +01:00
Uwe Tews cef27602bb v3.1.20 2014-10-31 05:12:39 +01:00
Uwe Tews 1153afe2f5 Merge branch 'v3.1.20' 2014-10-31 05:05:40 +01:00
Uwe Tews be0fd3186c Merge branch 'v3.1.19' 2014-10-31 02:29:14 +01:00
Uwe Tews c65444124a v3.1.19 2014-10-31 02:26:40 +01:00
Uwe Tews bf1de6c105 Merge branch 'v3.1.18' 2014-10-31 02:15:15 +01:00
Uwe Tews 97decc4c04 Merge branch 'v3.1.17' 2014-10-31 02:10:17 +01:00
Uwe Tews 43be80762e Merge branch 'v3.1.16' 2014-10-31 02:05:49 +01:00
Uwe Tews 1bdaf9a2a6 v3.1.15 2014-10-31 02:02:52 +01:00
Uwe Tews 4281d16bd4 Merge branch 'v3.1.15' 2014-10-31 01:59:07 +01:00
Uwe Tews 52fb7b1e25 - bugfix access to class constant by object like {$object::CONST} or variable class name {$class::CONST} did not work (forum 25301) me 2014-10-30 00:55:01 +01:00
Uwe Tews 0c9ca2994e - bugfix merge_compiled_includes option failed when caching enables and same subtemplate was included cached and not cached 2014-10-26 09:47:10 +01:00
Uwe Tews f7955513b2 Revert "- bugfix template function call handler must never be called as nocache code"
This reverts commit db183d1aa4.
2014-10-24 00:09:45 +02:00
Uwe Tews db183d1aa4 - bugfix template function call handler must never be called as nocache code 2014-10-23 19:05:25 +02:00
Uwe Tews a22ee9f264 - bugfix E_NOTICE message was created during compilation when ASP tags '<%' or '%>' are in template source text 2014-10-23 18:27:12 +02:00
Uwe Tews fc55a39d67 Update README.md 2014-10-23 18:13:05 +02:00
Uwe Tews 53c5e3fc4a Added licence file and demo folder 2014-10-18 17:42:52 +02:00
Uwe Tews cbc9ce927e add composer release notes 2014-10-18 07:48:57 +02:00
Uwe Tews c0a9a0449b add composer release notes 2014-10-18 07:44:20 +02:00
Uwe Tews 16afbfaca1 Prepare 3.1.22-dev 2014-10-18 01:21:53 +02:00
Uwe Tews 1441f32fce Upload 3.1.21 2014-10-18 01:19:29 +02:00
Uwe Tews 117d28f647 Upload 3.21 2014-10-18 01:17:22 +02:00
Uwe Tews 542892dded Upload 3.1.21 2014-10-18 01:09:18 +02:00
Uwe Tews 024b336bea Upload 3.1.20 2014-10-18 01:05:22 +02:00
Uwe Tews 7c6b3d21fa revert 2014-10-18 01:01:36 +02:00
Uwe Tews 6cb40b8bcc Upload 3.1.20 2014-10-18 00:55:00 +02:00
Uwe Tews bdac1cb2e1 Upload 3.1.20 2014-10-18 00:53:39 +02:00
Uwe Tews d26db3f717 Revert "Prepare 3.2.22-dev"
This reverts commit 451c62001d.
2014-10-18 00:45:38 +02:00
Uwe Tews 451c62001d Prepare 3.2.22-dev 2014-10-18 00:38:59 +02:00
Uwe Tews eb48f3bcea Upload 3.1.21 2014-10-18 00:31:50 +02:00
Uwe Tews 0409ab005e Upload version 3.1.20 2014-10-18 00:18:11 +02:00
uwetews d091179e43 Initial commit 2014-10-17 19:51:33 +02:00
Uwe.Tews@googlemail.com 279bdbd352 - bugfix on $php_handling security and optimization of smarty_internal_parsetree (Thue Kristensen) 2014-10-16 22:53:22 +00:00
Uwe.Tews@googlemail.com 1c63d3a9fc - bugfix composer.json update 2014-10-16 01:33:28 +00:00
Uwe.Tews@googlemail.com b10b12165a - bugfix calling a new created cache file with fetch() and Smarty::CACHING_LIFETIME_SAVED multiple times did fail (forum 22350) 2014-10-15 20:22:22 +00:00
Uwe.Tews@googlemail.com dece63c5d7 - improvement cache is_file(file_exists) results of loadPlugin() to avoid unnecessary calls during compilation (Issue 201} 2014-10-14 22:29:58 +00:00
Uwe.Tews@googlemail.com d9bc39da57 - bugfix classmap in root composer.json should start at "libs/..." 2014-10-14 21:59:49 +00:00
Uwe.Tews@googlemail.com c77cc80a8c - bugfix any tag placed within "<script language=php>" will throw a security exception to close all thinkable holes 2014-10-14 21:45:05 +00:00
Uwe.Tews@googlemail.com 4dde85a089 - bugfix "<script language=php>" with $php_handling PHP_PASSTHRU was executed in {nocache} sections 2014-10-12 15:57:16 +00:00
Uwe.Tews@googlemail.com f03fc13bc9 - bugfix change of 08.10.2014 could create E_NOTICE meassage when using "<?php" tags 2014-10-12 15:09:52 +00:00
Uwe.Tews@googlemail.com 6af75db3c3 2014-10-12 14:11:34 +00:00
Uwe.Tews@googlemail.com a1dac5a053 Switch trunk version to 3.1.21-dev 2014-10-10 17:12:39 +00:00
monte.ohrt 11e0cd566c fix date format 2014-10-09 21:37:21 +00:00
monte.ohrt d0673df7c2 update composer file 2014-10-09 21:29:46 +00:00
monte.ohrt 821456043b update changelog 2014-10-09 21:23:23 +00:00
Uwe.Tews@googlemail.com a7b4f6cdd9 2014-10-07 22:20:21 +00:00
Uwe.Tews@googlemail.com 6af4441f0e - bugfix security mode of "<script language=php>" must be controlled by $php_handling property (Thue Kristensen) 2014-10-07 22:07:15 +00:00
monte.ohrt 795c3af692 update classmap 2014-10-02 15:48:56 +00:00
Uwe.Tews@googlemail.com 2a311c5473 - bugfix existing child {block} tag must override parent {block} tag append / prepend setting (topic 25259) 2014-10-01 21:03:40 +00:00
monte.ohrt 7add711ea0 add composer.json to dist folder 2014-10-01 18:57:34 +00:00
monte.ohrt f57bb66746 revert move 2014-10-01 18:52:28 +00:00
monte.ohrt 2d3a853bce move composer file 2014-10-01 18:50:11 +00:00
Uwe.Tews@googlemail.com bbf0e42847 Fix typo's in Smarty_Security class comment and documentation 2014-10-01 17:15:24 +00:00
Uwe.Tews@googlemail.com 68b83f591d - bugfix template resource of inheritance blocks could get invalid if the default resource type is not 'file'(Issue 202) 2014-09-30 23:20:56 +00:00
Uwe.Tews@googlemail.com 254230a5d5 Correct wording 2014-08-06 17:29:53 +00:00
Uwe.Tews@googlemail.com 95760bb537 fixed spelling 2014-08-02 15:39:02 +00:00
Uwe.Tews@googlemail.com 9307f0cfcb - bugfix modifier wordwrap did output break string wrong if first word was exceeding lenght with cut = true (topic 25193) 2014-08-02 15:24:28 +00:00
monte.ohrt 9b06625c74 update changelog 2014-07-24 15:10:55 +00:00
monte.ohrt fcece85062 fix issue where cache dir does not exist
-This line, and those below, will be ignored--

M    distribution/libs/sysplugins/smarty_internal_cacheresource_file.php
2014-07-24 15:08:32 +00:00
Uwe.Tews@googlemail.com 071f9af42f anchor BOM regex to front of file 2014-07-16 21:40:57 +00:00
Uwe.Tews@googlemail.com 77292d394a - enhancement remove BOM automatically from template source (topic 25161) 2014-07-16 18:21:25 +00:00
Uwe.Tews@googlemail.com c2bba29216 - 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) 2014-07-03 23:16:23 +00:00
monte.ohrt 4b3e1eb89d fix url in comment 2014-07-01 19:33:25 +00:00
monte.ohrt 84a2b19447 update version 2014-07-01 05:20:41 +00:00
Uwe.Tews@googlemail.com fb28ee9d2e - bugfix template variables could not be passed as paramter in {include} when the include was in a {nocache} section (topic 25131) 2014-06-21 08:56:11 +00:00
Uwe.Tews@googlemail.com a75e36b357 - bugfix template variables could not be passed as paramter in {include} when the include was in a {nocache} section (topic 25131) 2014-06-21 08:53:38 +00:00
Uwe.Tews@googlemail.com ee69f963c6 - bugfix large template text of some charsets could cause parsing errors (topic 24630) 2014-06-17 20:24:20 +00:00
Uwe.Tews@googlemail.com 0e1f7fdcfc - bugfix {html_image} security check did fail on files relative to basedir (Issue 191) 2014-06-08 19:03:39 +00:00
Uwe.Tews@googlemail.com 7ca939f47b - bugfix UNC WINDOWS PATH like "\\psf\path\to\dir" did not work as template directory (Issue 192) 2014-06-08 18:12:09 +00:00
Uwe.Tews@googlemail.com ee4a77b797 upload reformatted versions 2014-06-08 16:00:56 +00:00
Uwe.Tews@googlemail.com e5dd155809 - bugfix {block} tags within {literal} .. {/literal} got not displayed correctly (topic 25024) 2014-06-08 15:52:08 +00:00
Uwe.Tews@googlemail.com 642c071437 - bugfix registered objects did not work after spelling fixes of 006.06.2014 2014-06-08 15:43:02 +00:00
Uwe.Tews@googlemail.com 425091a19f - fixed spelling, PHPDoc , minor errors, code cleanup 2014-06-06 02:40:04 +00:00
Uwe.Tews@googlemail.com ca6a908c83 - fixed PHPUnit outputFilterTrimWhitespaceTests.php assertion of test result 2014-06-05 22:58:58 +00:00
Uwe.Tews@googlemail.com 3a124b4a56 Rename release note file 2014-06-02 20:11:09 +00:00
Uwe.Tews@googlemail.com 2c5ce49b97 - using multiple cwd with relative template dirs could result in identical compiled file names. (issue 194 and topic 25099) 2014-06-02 19:56:38 +00:00
Uwe.Tews@googlemail.com c7071d9d2c - bugfix clearCompiledTemplate() did not delete files on WINDOWS when a compile_id was specified 2014-04-19 13:53:20 +00:00
Uwe.Tews@googlemail.com 8658b04c86 bugfix calling createTemplate(template, data) with empty data array caused notice of array to string conversion (Issue 189) 2014-04-19 11:42:11 +00:00
Uwe.Tews@googlemail.com d6c1482996 fixed typos 2014-04-18 08:13:32 +00:00
Uwe.Tews@googlemail.com 608dddc19a 2014-04-18 08:09:38 +00:00
Uwe.Tews@googlemail.com a613394887 Update dev version number to 3.1.19-dev 2014-04-07 19:57:42 +00:00
monte.ohrt f67473f085 update to 3.1.18 2014-04-07 18:30:41 +00:00
Uwe.Tews@googlemail.com 00c919dcc2 bugfix update of composer file (Issue 168 and 184) 2014-04-06 19:06:32 +00:00
Uwe.Tews@googlemail.com 668bc16717 - bugfix template inheritance fail when using custom resource after patch of 8.3.2014 (Issue 187) 2014-04-06 18:50:39 +00:00
Uwe.Tews@googlemail.com 79d67afb0f - bugfix default date format leads to extra spaces when displaying dates with single digit days (Issue 182) 2014-04-04 23:38:36 +00:00
Uwe.Tews@googlemail.com 58982caf27 - bugfix Smart_Resource_Custom should not lowercase the resource name (Issue 183) 2014-03-26 20:33:03 +00:00
Uwe.Tews@googlemail.com 474e863af1 - bugfix using a {foreach} property like @iteration could fail when used in inheritance parent templates (Issue 182) 2014-03-24 18:52:29 +00:00
Uwe.Tews@googlemail.com 478db521c9 - bugfix $smarty->auto_literal and mbsting.func_overload 2, 6 or 7 did fail (forum topic 24899) 2014-03-20 22:07:26 +00:00
Uwe.Tews@googlemail.com 7dec7d9963 - revert change of 17.03.2014 2014-03-18 18:22:33 +00:00
Uwe.Tews@googlemail.com d82d54bffd fix line endings 2014-03-17 21:57:15 +00:00
Uwe.Tews@googlemail.com 45fc4cd729 - bugfix $smarty->auto_literal and mbsting.func_overload 2, 6 or 7 did fail (forum topic 24899) 2014-03-17 19:04:48 +00:00
Uwe.Tews@googlemail.com ad62b0b2f8 - bugfix Smarty_CacheResource_Keyvaluestore did use different keys on read/writes and clearCache() calls (Issue 169) 2014-03-15 21:43:04 +00:00
Uwe.Tews@googlemail.com 3d4d35f4d7 - bugfix clearXxx() change of 27.1.2014 did not work when specifing cache_id or compile_id (forum topic 24868 and 24867) 2014-03-13 20:32:39 +00:00
monte.ohrt 40acefe91b update changelog 2014-03-12 19:50:58 +00:00
Uwe.Tews@googlemail.com af13907219 08.03.2014
- bugfix relative file path {include} within {block} of child templates did throw exception on first call (Issue 177)
2014-03-08 23:03:08 +00:00
Uwe.Tews@googlemail.com f06013927c - bugfix Smarty failed when executing PHP on HHVM (Hip Hop 2.4) because uniqid('',true) does return string with ',' (forum topic 20343) 2014-02-17 18:21:31 +00:00
Uwe.Tews@googlemail.com bfa0ce8ba4 - bugfix a '//' or '\\' in template_dir path could produce wrong path on relative filepath in {include} (Issue 175) 2014-02-16 18:34:08 +00:00
Uwe.Tews@googlemail.com f242ce30fb - bugfix shared.literal_compiler_param.php did throw an exception when literal did contain a '-' (smarty-developers group) 2014-02-05 19:39:21 +00:00
Uwe.Tews@googlemail.com ba2996fef5 - bugfix clearCompiledTemplate(), clearAll() and clear() should use realpath to avoid possible exception from RecursiveDirectoryIterator (Issue 171) 2014-01-27 16:35:56 +00:00
Uwe.Tews@googlemail.com 79dfde4977 - bugfix $smarty->debugging = true; did show the variable of the $smarty object not the variables used in display() call (forum topic 24764) 2014-01-27 16:08:55 +00:00
Uwe.Tews@googlemail.com 0e03ba5b61 - bugfix undo block nesting checks for {nocache} for reasons like forum topic 23280 (forum topic 24762) 2014-01-26 20:11:19 +00:00
Uwe.Tews@googlemail.com 290dd3f73f - bugfix the compiler did fail when using template inheritance and recursive {include} (smarty-developers group) 2014-01-18 14:43:02 +00:00
Uwe.Tews@googlemail.com 1dfbe19ebf - internals content cache should be clear when updating cache file 2014-01-11 12:21:12 +00:00
Uwe.Tews@googlemail.com 18ff092501 2014-01-11 12:15:37 +00:00
Uwe.Tews@googlemail.com 54d5d949de - bugfix SmartyBC.class.php should use require_once to load Smarty.class.php (forum topic 24683) 2014-01-08 21:16:06 +00:00
Uwe.Tews@googlemail.com 797bd37c5f - bugfix Smarty_CacheResource_Custom did not handle template resource type specifications on clearCache() calls (Issue 161) 2014-01-08 21:05:58 +00:00
monte.ohrt fa09638f95 update changelog 2013-12-17 16:06:12 +00:00
Uwe.Tews@googlemail.com a0a24e1975 - enhancement additional debug output at $smarty->_parserdebug = true; 2013-12-15 15:25:50 +00:00
Uwe.Tews@googlemail.com 7f88dcd31f - bugfix {include} with {block} tag handling (forum topic 24599, 24594, 24682) (Issue 161)
Read 3.1.16_RELEASE_NOTES for more details
2013-12-15 15:19:01 +00:00
Uwe.Tews@googlemail.com 6abc9ea0d3 - bugfix compiler could fail if PHP mbstring.func_overload is enabled (Issue 164) 2013-11-07 20:00:56 +00:00
Uwe.Tews@googlemail.com 4e1f7b1568 - bugfix too restrictive handling of {include} within {block} tags. 3.1.15 did throw errors where 3.1.14 did not (forum topic 24599) 2013-11-07 19:09:37 +00:00
Uwe.Tews@googlemail.com c8996a4085 - bugfix multiple {block}s with same name in parent did not work (forum topic 24631) 2013-10-29 00:40:14 +00:00
Uwe.Tews@googlemail.com 5dc4b61771 - bugfix correction of modifier capitalize fix from 3.10.2013 (issue 159) 2013-10-28 23:56:41 +00:00
Uwe.Tews@googlemail.com c3e6823f5d - bugfix notice "Trying to get property of non-object" removed (Issue 163) 2013-10-28 23:53:01 +00:00
Uwe.Tews@googlemail.com 26e4a5120e - bugfix variable resource name at custom resource plugin did not work within {block} tags (Issue 163) 2013-10-28 18:24:01 +00:00
Uwe.Tews@googlemail.com 8342cf45f3 - bugfix a variable file name at {extends} tag did fail (forum topic 24618) 2013-10-20 15:27:35 +00:00
Uwe.Tews@googlemail.com fccd80818b - bugfix yesterdays fix could result in an undefined variable 2013-10-14 07:47:49 +00:00
Uwe.Tews@googlemail.com c3994f4006 .- bugfix relative includes with same name like {include './foo.tpl'} from different folder failed (forum topic 24590)(Issue 161) 2013-10-13 17:49:38 +00:00
Uwe.Tews@googlemail.com cd6c1c2ff8 bugfix variable names on {include} in template inheritance did unextepted error message (forum topic 24585) (Issue 161) 2013-10-13 12:48:07 +00:00
Uwe.Tews@googlemail.com 51453d196b - bugfix variable file names at {extends} had been disbabled by mistake with the rewrite of
template inheritance of 24.08.2013   (forum topic 24585)
2013-10-04 08:47:46 +00:00
Uwe.Tews@googlemail.com 655a2d9301 - bugfix loops using modifier capitalize did eat up memory (issue 159) 2013-10-03 09:16:27 +00:00
monte.ohrt 3281c14769 update change log 2013-10-01 19:35:02 +00:00
Uwe.Tews@googlemail.com 953f6f5a14 - improvement on performance when using error handler and multiple template folders (issue 152) 2013-10-01 18:56:49 +00:00
Uwe.Tews@googlemail.com 51ee8c4ad9 - use current delimiters in compiler error messages (issue 157) 2013-10-01 18:48:29 +00:00
Uwe.Tews@googlemail.com 5bbfbafc47 - improvement added patch for additional SmartyCompilerException properties for better access to scource information (forum topic 24559) 2013-09-17 20:44:41 +00:00
Uwe.Tews@googlemail.com bf8275ee20 - bugfix recompiled templates did not show on first request with zend opcache cache (forum topic 24320) 2013-09-16 18:47:04 +00:00
Uwe.Tews@googlemail.com a0dcb5611b - bugfix html_select_time defaulting error for the Meridian dropdown (forum topic 24549) 2013-09-13 20:48:40 +00:00
Uwe.Tews@googlemail.com 0d9f9802db - bugfix incorrect compiled code with array(object,method) callback at registered Variable Filter (forum topic 24542} 2013-09-09 16:10:13 +00:00
Uwe.Tews@googlemail.com 70d5af437e fixed spelling 2013-09-03 16:20:04 +00:00
Uwe.Tews@googlemail.com 96c2a9c71a - bugfix delimiter followed by linebreak did not work as auto literak after update form 24.08.2013 (forum topic 24518} 2013-08-27 19:42:38 +00:00
Uwe.Tews@googlemail.com 98c1dd29cd - bugfix and enhancement
Because several recent problems with template inheritance the {block} tag compiler has been rewriten
   - Error messages shown now the correct child template file and line number
   - The compiler could fail on some larger UTF-8 text block (forum topic 24455}
   - The {strip} tag can now be placed outside {block} tags in child templates (forum topic 24289}
- change SmartyException::$escape  is now false by default
- change PHP traceback has been remove for SmartyException and SmartyCompilerException
2013-08-24 18:46:31 +00:00
Uwe.Tews@googlemail.com e206ba63f0 - bugfix compiled filepath of config file did not observe different config_dir (forum topic 24493) 2013-08-14 19:38:03 +00:00
Uwe.Tews@googlemail.com e9601e1d6d - bugfix avoid possible E_STRICT error after bugfix for (forum topic 24493) 2013-08-13 23:03:28 +00:00
Uwe.Tews@googlemail.com 3ad903ad21 - bugfix the internal resource cache did not observe config_dir changes (forum topic 24493) 2013-08-13 20:54:59 +00:00
Uwe.Tews@googlemail.com 518ffca6f5 - bugfix internal $tmpx variables must be unique over all inheritance templates (Issue 149) 2013-08-12 21:09:29 +00:00
Uwe.Tews@googlemail.com 35d2e254bb - bugfix a newline was eaten when a <?xml ... ?> was passed by a Smarty variable and caching was enabled (forum topic 24482) 2013-08-10 09:55:27 +00:00
Uwe.Tews@googlemail.com 6d88d33c5b - bugfix headers already send warning thrown when using 'SMARTY_DEBUG=on' from URL (Issue 148) 2013-07-29 13:58:08 +00:00
Uwe.Tews@googlemail.com 6851c57ef8 - enhancement allow access to properties of registered opjects for Smarty2 BC (forum topic 24344) 2013-07-27 10:06:43 +00:00
Uwe.Tews@googlemail.com e62dcaa6a9 - enhancement allow access to properties of registered opjects for Smarty2 BC (forum topic 24344) 2013-07-27 09:48:42 +00:00
Uwe.Tews@googlemail.com 697696fef9 Source code reformatted 2013-07-27 07:05:26 +00:00
Uwe.Tews@googlemail.com f83eba920d - bugfix template inheritance nesting problem (forum topic 24387) 2013-07-26 13:50:44 +00:00
Uwe.Tews@googlemail.com 584886cb1c - update code generated by PSR-2 standards fixer which introduced PHP 5.4 incompatibilities of 14.7.2013 2013-07-15 18:18:28 +00:00
Uwe.Tews@googlemail.com 00ccae8857 - update for PHP 5.4 compatibility
- reformat source to PSR-2 standard
2013-07-14 22:15:45 +00:00
Uwe.Tews@googlemail.com f99e6a83ce - bugfix increase of internal maximum parser stacksize to allow more complex tag code {forum topic 24426} 2013-07-14 21:12:08 +00:00
Uwe.Tews@googlemail.com 917f92d38b - bugfix Do not remove '//' from file path at normalization (Issue 142) 2013-07-12 00:16:43 +00:00
monte.ohrt a74d8d5416 update change log 2013-07-02 14:16:49 +00:00
monte.ohrt a0f26a96cc fix order of replacements (mohrt) 2013-07-02 14:11:12 +00:00
monte.ohrt 739688a454 update change log 2013-06-28 02:02:53 +00:00
1325 changed files with 69150 additions and 18800 deletions
+19
View File
@@ -0,0 +1,19 @@
# Auto detect text files and perform LF normalization
* text=auto
*.php text eol=lf
*.y text eol=lf
*.lex text eol=lf
# exclude from git export
/tests export-ignore
/utilities export-ignore
/docker-compose.yml export-ignore
/.github export-ignore
/run_tests_for_all_php_versions.sh export-ignore
/.gitattributes export-ignore
/.gitignore export-ignore
/make-release.sh export-ignore
/phpunit.sh export-ignore
/phpunit.xml export-ignore
/TODO.md export-ignore
+79
View File
@@ -0,0 +1,79 @@
# https://help.github.com/en/categories/automating-your-workflow-with-github-actions
on:
pull_request:
push:
branches:
- 'master'
name: CI
jobs:
tests:
name: Tests
runs-on: ${{ matrix.os }}
env:
PHP_EXTENSIONS: dom, json, libxml, mbstring, pdo_sqlite, soap, xml, xmlwriter
PHP_INI_VALUES: assert.exception=1, zend.assertions=1
strategy:
fail-fast: false
matrix:
os:
- ubuntu-latest
php-version:
- "7.1"
- "7.2"
- "7.3"
- "7.4"
- "8.0"
- "8.1"
- "8.2"
compiler:
- default
include:
- os: ubuntu-latest
php-version: "8.0"
compiler: jit
- os: ubuntu-latest
php-version: "8.1"
compiler: jit
- os: ubuntu-latest
php-version: "8.2"
compiler: jit
steps:
- name: Checkout
uses: actions/checkout@v3
- name: Override PHP ini values for JIT compiler
if: matrix.compiler == 'jit'
run: echo "PHP_INI_VALUES::assert.exception=1, zend.assertions=1, opcache.enable=1, opcache.enable_cli=1, opcache.optimization_level=-1, opcache.jit=1255, opcache.jit_buffer_size=32M" >> $GITHUB_ENV
- name: Install PHP with extensions
uses: shivammathur/setup-php@v2
with:
php-version: ${{ matrix.php-version }}
coverage: pcov
extensions: ${{ env.PHP_EXTENSIONS }}
ini-values: ${{ env.PHP_INI_VALUES }}
- name: Validate composer.json and composer.lock
run: composer validate
- name: Cache Composer packages
id: composer-cache
uses: actions/cache@v3
with:
path: vendor
key: ${{ runner.os }}-php-${{ matrix.php-version }}-${{ hashFiles('**/composer.lock') }}
restore-keys: |
${{ runner.os }}-php-${{ matrix.php-version }}-
- name: Run tests with phpunit
run: ./run-tests.sh
+15
View File
@@ -0,0 +1,15 @@
.idea/
# Smarty
lexer/*.php
lexer/*.php.bak
lexer/*.out
/site
# Dev
phpunit*
.phpunit.result.cache
vendor/*
composer.lock
File diff suppressed because it is too large Load Diff
+15 -1
View File
@@ -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 3.0 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.
Library.
-574
View File
@@ -1,574 +0,0 @@
Smarty 3.x
Author: Monte Ohrt <monte at ohrt dot com >
Author: Uwe Tews
AN INTRODUCTION TO SMARTY 3
NOTICE FOR 3.1 release:
Please see the SMARTY_3.1_NOTES.txt file that comes with the distribution.
NOTICE for 3.0.5 release:
Smarty now follows the PHP error_reporting level by default. If PHP does not mask E_NOTICE and you try to access an unset template variable, you will now get an E_NOTICE warning. To revert to the old behavior:
$smarty->error_reporting = E_ALL & ~E_NOTICE;
NOTICE for 3.0 release:
IMPORTANT: Some API adjustments have been made between the RC4 and 3.0 release.
We felt it is better to make these now instead of after a 3.0 release, then have to
immediately deprecate APIs in 3.1. Online documentation has been updated
to reflect these changes. Specifically:
---- API CHANGES RC4 -> 3.0 ----
$smarty->register->*
$smarty->unregister->*
$smarty->utility->*
$samrty->cache->*
Have all been changed to local method calls such as:
$smarty->clearAllCache()
$smarty->registerFoo()
$smarty->unregisterFoo()
$smarty->testInstall()
etc.
Registration of function, block, compiler, and modifier plugins have been
consolidated under two API calls:
$smarty->registerPlugin(...)
$smarty->unregisterPlugin(...)
Registration of pre, post, output and variable filters have been
consolidated under two API calls:
$smarty->registerFilter(...)
$smarty->unregisterFilter(...)
Please refer to the online documentation for all specific changes:
http://www.smarty.net/documentation
----
The Smarty 3 API has been refactored to a syntax geared
for consistency and modularity. The Smarty 2 API syntax is still supported, but
will throw a deprecation notice. You can disable the notices, but it is highly
recommended to adjust your syntax to Smarty 3, as the Smarty 2 syntax must run
through an extra rerouting wrapper.
Basically, all Smarty methods now follow the "fooBarBaz" camel case syntax. Also,
all Smarty properties now have getters and setters. So for example, the property
$smarty->cache_dir can be set with $smarty->setCacheDir('foo/') and can be
retrieved with $smarty->getCacheDir().
Some of the Smarty 3 APIs have been revoked such as the "is*" methods that were
just duplicate functions of the now available "get*" methods.
Here is a rundown of the Smarty 3 API:
$smarty->fetch($template, $cache_id = null, $compile_id = null, $parent = null)
$smarty->display($template, $cache_id = null, $compile_id = null, $parent = null)
$smarty->isCached($template, $cache_id = null, $compile_id = null)
$smarty->createData($parent = null)
$smarty->createTemplate($template, $cache_id = null, $compile_id = null, $parent = null)
$smarty->enableSecurity()
$smarty->disableSecurity()
$smarty->setTemplateDir($template_dir)
$smarty->addTemplateDir($template_dir)
$smarty->templateExists($resource_name)
$smarty->loadPlugin($plugin_name, $check = true)
$smarty->loadFilter($type, $name)
$smarty->setExceptionHandler($handler)
$smarty->addPluginsDir($plugins_dir)
$smarty->getGlobal($varname = null)
$smarty->getRegisteredObject($name)
$smarty->getDebugTemplate()
$smarty->setDebugTemplate($tpl_name)
$smarty->assign($tpl_var, $value = null, $nocache = false)
$smarty->assignGlobal($varname, $value = null, $nocache = false)
$smarty->assignByRef($tpl_var, &$value, $nocache = false)
$smarty->append($tpl_var, $value = null, $merge = false, $nocache = false)
$smarty->appendByRef($tpl_var, &$value, $merge = false)
$smarty->clearAssign($tpl_var)
$smarty->clearAllAssign()
$smarty->configLoad($config_file, $sections = null)
$smarty->getVariable($variable, $_ptr = null, $search_parents = true, $error_enable = true)
$smarty->getConfigVariable($variable)
$smarty->getStreamVariable($variable)
$smarty->getConfigVars($varname = null)
$smarty->clearConfig($varname = null)
$smarty->getTemplateVars($varname = null, $_ptr = null, $search_parents = true)
$smarty->clearAllCache($exp_time = null, $type = null)
$smarty->clearCache($template_name, $cache_id = null, $compile_id = null, $exp_time = null, $type = null)
$smarty->registerPlugin($type, $tag, $callback, $cacheable = true, $cache_attr = array())
$smarty->registerObject($object_name, $object_impl, $allowed = array(), $smarty_args = true, $block_methods = array())
$smarty->registerFilter($type, $function_name)
$smarty->registerResource($resource_type, $function_names)
$smarty->registerDefaultPluginHandler($function_name)
$smarty->registerDefaultTemplateHandler($function_name)
$smarty->unregisterPlugin($type, $tag)
$smarty->unregisterObject($object_name)
$smarty->unregisterFilter($type, $function_name)
$smarty->unregisterResource($resource_type)
$smarty->compileAllTemplates($extension = '.tpl', $force_compile = false, $time_limit = 0, $max_errors = null)
$smarty->clearCompiledTemplate($resource_name = null, $compile_id = null, $exp_time = null)
$smarty->testInstall()
// then all the getters/setters, available for all properties. Here are a few:
$caching = $smarty->getCaching(); // get $smarty->caching
$smarty->setCaching(true); // set $smarty->caching
$smarty->setDeprecationNotices(false); // set $smarty->deprecation_notices
$smarty->setCacheId($id); // set $smarty->cache_id
$debugging = $smarty->getDebugging(); // get $smarty->debugging
FILE STRUCTURE
The Smarty 3 file structure is similar to Smarty 2:
/libs/
Smarty.class.php
/libs/sysplugins/
internal.*
/libs/plugins/
function.mailto.php
modifier.escape.php
...
A lot of Smarty 3 core functionality lies in the sysplugins directory; you do
not need to change any files here. The /libs/plugins/ folder is where Smarty
plugins are located. You can add your own here, or create a separate plugin
directory, just the same as Smarty 2. You will still need to create your own
/cache/, /templates/, /templates_c/, /configs/ folders. Be sure /cache/ and
/templates_c/ are writable.
The typical way to use Smarty 3 should also look familiar:
require('Smarty.class.php');
$smarty = new Smarty;
$smarty->assign('foo','bar');
$smarty->display('index.tpl');
However, Smarty 3 works completely different on the inside. Smarty 3 is mostly
backward compatible with Smarty 2, except for the following items:
*) Smarty 3 is PHP 5 only. It will not work with PHP 4.
*) The {php} tag is disabled by default. Enable with $smarty->allow_php_tag=true.
*) Delimiters surrounded by whitespace are no longer treated as Smarty tags.
Therefore, { foo } will not compile as a tag, you must use {foo}. This change
Makes Javascript/CSS easier to work with, eliminating the need for {literal}.
This can be disabled by setting $smarty->auto_literal = false;
*) The Smarty 3 API is a bit different. Many Smarty 2 API calls are deprecated
but still work. You will want to update your calls to Smarty 3 for maximum
efficiency.
There are many things that are new to Smarty 3. Here are the notable items:
LEXER/PARSER
============
Smarty 3 now uses a lexing tokenizer for its parser/compiler. Basically, this
means Smarty has some syntax additions that make life easier such as in-template
math, shorter/intuitive function parameter options, infinite function recursion,
more accurate error handling, etc.
WHAT IS NEW IN SMARTY TEMPLATE SYNTAX
=====================================
Smarty 3 allows expressions almost anywhere. Expressions can include PHP
functions as long as they are not disabled by the security policy, object
methods and properties, etc. The {math} plugin is no longer necessary but
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
{$foo[$x+3]} as array index
Smarty tags can be used as values within other tags.
Example: {$foo={counter}+3}
Smarty tags can also be used inside double quoted strings.
Example: {$foo="this is message {counter}"}
You can define arrays within templates.
Examples:
{assign var=foo value=[1,2,3]}
{assign var=foo value=['y'=>'yellow','b'=>'blue']}
Arrays can be nested.
{assign var=foo value=[1,[9,8],3]}
There is a new short syntax supported for assigning variables.
Example: {$foo=$bar+2}
You can assign a value to a specific array element. If the variable exists but
is not an array, it is converted to an array before the new values are assigned.
Examples:
{$foo['bar']=1}
{$foo['bar']['blar']=1}
You can append values to an array. If the variable exists but is not an array,
it is converted to an array before the new values are assigned.
Example: {$foo[]=1}
You can use a PHP-like syntax for accessing array elements, as well as the
original "dot" notation.
Examples:
{$foo[1]} normal access
{$foo['bar']}
{$foo['bar'][1]}
{$foo[$x+$x]} index may contain any expression
{$foo[$bar[1]]} nested index
{$foo[section_name]} smarty section access, not array access!
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'] 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.
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}_buh_{$blar} variable name with multiple segments
{$foo_{$x}} will output the variable $foo_1 if $x has a value of 1.
Object method chaining is implemented.
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}.
{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.
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
$x@total = total number of iterations
$x@first = true on first iteration
$x@last = true on last iteration
The Smarty 2 {section} syntax is still supported.
New shorter {foreach} syntax to loop over an array.
Example: {foreach $myarray as $var}...{/foreach}
Within the foreach loop, properties are access via:
$var@key foreach $var array key
$var@iteration foreach current iteration count (1,2,3...)
$var@index foreach current index count (0,1,2...)
$var@total foreach $var array total
$var@first true on first iteration
$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.
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}.
while block tag is now implemented:
{while $foo}...{/while}
{while $x lt 10}...{/while}
Direct access to PHP functions:
Just as you can use PHP functions as modifiers directly, you can now access
PHP functions directly, provided they are permitted by security settings:
{time()}
There is a new {function}...{/function} block tag to implement a template function.
This enables reuse of code sequences like a plugin function. It can call itself recursively.
Template function must be called with the new {call name=foo...} tag.
Example:
Template file:
{function name=menu level=0}
<ul class="level{$level}">
{foreach $data as $entry}
{if is_array($entry)}
<li>{$entry@key}</li>
{call name=menu data=$entry level=$level+1}
{else}
<li>{$entry}</li>
{/if}
{/foreach}
</ul>
{/function}
{$menu = ['item1','item2','item3' => ['item3-1','item3-2','item3-3' =>
['item3-3-1','item3-3-2']],'item4']}
{call name=menu data=$menu}
Generated output:
* item1
* item2
* item3
o item3-1
o item3-2
o item3-3
+ item3-3-1
+ item3-3-2
* item4
The function tag itself must have the "name" attribute. This name is the tag
name when calling the function. The function tag may have any number of
additional attributes. These will be default settings for local variables.
New {nocache} block function:
{nocache}...{/nocache} will declare a section of the template to be non-cached
when template caching is enabled.
New nocache attribute:
You can declare variable/function output as non-cached with the nocache attribute.
Examples:
{$foo nocache=true}
{$foo nocache} /* same */
{foo bar="baz" nocache=true}
{foo bar="baz" nocache} /* same */
{time() nocache=true}
{time() nocache} /* same */
Or you can also assign the variable in your script as nocache:
$smarty->assign('foo',$something,true); // third param is nocache setting
{$foo} /* non-cached */
$smarty.current_dir returns the directory name of the current template.
You can use strings directly as templates with the "string" resource type.
Examples:
$smarty->display('string:This is my template, {$foo}!'); // php
{include file="string:This is my template, {$foo}!"} // template
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
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.
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
from the Smarty object.
All known Smarty assignment interfaces will work on the data and template objects.
Besides the above mentioned objects, there is also a special storage area for
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= $smarty->createData($smarty); // create data object having a parent link to
the Smarty object
$data2= $smarty->createData($data); // create data object having a parent link to
the $data data object
A template object can be created by using the createTemplate method. It has the
same parameter assignments as the fetch() or display() method.
Function definition:
function createTemplate($template, $cache_id = null, $compile_id = null, $parent = null)
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 = $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
The standard fetch() and display() methods will implicitly create a template object.
If the $parent parameter is not specified in these method calls, the template object
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.
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.
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.
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
{$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
{$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,
{$foo='bar' scope='global'} // they are available to any and all templates.
The scope attribute can also be attached to the {include...} tag. In this case,
the specified scope will be the default scope for all assignments within the
included template.
PLUGINS
=======
Smarty3 are following the same coding rules as in Smarty2.
The only difference is that the template object is passed as additional third parameter.
smarty_plugintype_name (array $params, object $smarty, object $template)
The Smarty 2 plugins are still compatible as long as they do not make use of specific Smarty2 internals.
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:
parent.tpl:
<html>
<head>
<title>{block name='title'}My site name{/block}</title>
</head>
<body>
<h1>{block name='page-title'}Default page title{/block}</h1>
<div id="content">
{block name='content'}
Default content
{/block}
</div>
</body>
</html>
child.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}
{block name='page-title'}My home{/block}
{block name='content'}
{foreach $images as $img}
<img src="{$img.url}" alt="{$img.description}" />
{/foreach}
{/block}
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.
If we render grandchild.tpl we will get this:
<html>
<head>
<title>Home - Child title</title>
</head>
<body>
<h1>My home</h1>
<div id="content">
<img src="/example.jpg" alt="image" />
<img src="/example2.jpg" alt="image" />
<img src="/example3.jpg" alt="image" />
</div>
</body>
</html>
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
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
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
is appended or prepended to the child block content.
{block name='title' append} My title {/block}
PHP STREAMS:
============
(see online documentation)
VARIBLE FILTERS:
================
(see online documentation)
STATIC CLASS ACCESS AND NAMESPACE SUPPORT
=========================================
You can register a class with optional namespace for the use in the template like:
$smarty->register->templateClass('foo','name\name2\myclass');
In the template you can use it like this:
{foo::method()} etc.
=======================
Please look through it and send any questions/suggestions/etc to the forums.
http://www.phpinsider.com/smarty-forum/viewtopic.php?t=14168
Monte and Uwe
+14 -22
View File
@@ -1,28 +1,20 @@
#Smarty 3 template engine
##Distribution repository
Starting with Smarty 3.1.21 Composer has been configured to load the packages from github.
**NOTE: Because of this change you must clear your local composer cache with the "composer clearcache" command**
# Smarty template engine
Smarty is a template engine for PHP, facilitating the separation of presentation (HTML/CSS) from application logic.
To get the latest stable version use
![CI](https://github.com/smarty-php/smarty/workflows/CI/badge.svg)
"require": {
"smarty/smarty": "~3.1"
}
## Documentation
Read the [documentation](https://smarty-php.github.io/smarty/) to find out how to use it.
in your composer.json file.
To get the trunk version use
## Requirements
Smarty can be run with PHP 7.1 to PHP 8.2.
"require": {
"smarty/smarty": "~3.1@dev"
}
## Installation
Smarty versions 3.1.11 or later can be installed with [Composer](https://getcomposer.org/).
The "smarty/smarty" package will start at libs/.... subfolder.
To retrieve the development and documentation folders add
"require-dev": {
"smarty/smarty-dev": "~3.1@dev"
}
To get the latest stable version of Smarty use:
```bash
composer require smarty/smarty
````
More in the [Getting Started](./docs/getting-started.md) section of the docs.
+20
View File
@@ -0,0 +1,20 @@
# Security Policy
## Supported Versions
Smarty currently supports the latest minor version of Smarty 3 and Smarty 4.
| Version | Supported |
|---------|--------------------|
| 4.3.x | :white_check_mark: |
| 3.1.x | :white_check_mark: |
| < 3.1 | :x: |
## Reporting a Vulnerability
If you have discovered a security issue with Smarty, please contact us at mail [at] simonwisselink.nl. Do not
disclose your findings publicly and **PLEASE** do not file an Issue (because that would disclose your findings
publicly.)
We will try to confirm the vulnerability and develop a fix if appropriate. When we release the fix, we will publish
a security release. Please let us know if you want to be credited.
-109
View File
@@ -1,109 +0,0 @@
= Known incompatibilities with Smarty 2 =
== 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
information.
The {$array|@mod} syntax has always been a bit confusing, where an "@" is required
to apply a modifier to an array instead of the individual elements. Normally you
always want the modifier to apply to the variable regardless of its type. In Smarty 3,
{$array|mod} and {$array|@mod} behave identical. It is safe to drop the "@" and the
modifier will still apply to the array. If you really want the modifier to apply to
each array element, you must loop the array in-template, or use a custom modifier that
supports array iteration. Most smarty functions already escape values where necessary
such as {html_options}
== PHP Version ==
Smarty 3 is PHP 5 only. It will not work with PHP 4.
== {php} Tag ==
The {php} tag is disabled by default. The use of {php} tags is
deprecated. It can be enabled with $smarty->allow_php_tag=true.
But if you scatter PHP code which belongs together into several
{php} tags it may not work any longer.
== Delimiters and whitespace ==
Delimiters surrounded by whitespace are no longer treated as Smarty tags.
Therefore, { foo } will not compile as a tag, you must use {foo}. This change
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_)
For example filename strings must be quoted
<source lang="smarty">
{include file='path/foo.tpl'}
</source>
== 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.
<source lang="php">
class MySmarty extends Smarty {
function __construct() {
parent::__construct();
// your initialization code goes here
}
}
</source>
== 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
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.
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
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
as parameter.
<source lang="smarty">
{include file='path/foo.tpl' index=$smarty.section.foo.index}
</source>
== 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
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.
If one of the {if} tags is at the line end you will now get a newline in the HTML output.
== trigger_error() ==
The API function trigger_error() has been removed because it did just map to PHP trigger_error.
However it's still included in the Smarty2 API wrapper.
== Smarty constants ==
The constants
SMARTY_PHP_PASSTHRU
SMARTY_PHP_QUOTE
SMARTY_PHP_REMOVE
SMARTY_PHP_ALLOW
have been replaced with class constants
Smarty::PHP_PASSTHRU
Smarty::PHP_QUOTE
Smarty::PHP_REMOVE
Smarty::PHP_ALLOW
-24
View File
@@ -1,24 +0,0 @@
== Smarty2 backward compatibility ==
All Smarty2 specific API functions and deprecated functionallity 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.
== {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.
== php template resource ==
The support of the php template resource is removed.
== $cache_dir, $compile_dir, $config_dir, $template_dir access ==
The mentioned properties can't be accessed directly any longer. You must use
corresponding getter/setters like addConfigDir(), setConfigDir(), getConfigDir()
== obsolete Smarty class properties ==
The following no longer used properties are removed:
$allow_php_tag
$allow_php_template
$deprecation_notices
-306
View File
@@ -1,306 +0,0 @@
Smarty 3.1 Notes
================
Smarty 3.1 is a departure from 2.0 compatibility. Most notably, all
backward compatibility has been moved to a separate class file named
SmartyBC.class.php. If you require compatibility with 2.0, you will
need to use this class.
Some differences from 3.0 are also present. 3.1 begins the journey of
requiring setters/getters for property access. So far this is only
implemented on the five directory properties: template_dir,
plugins_dir, configs_dir, compile_dir and cache_dir. These properties
are now protected, it is required to use the setters/getters instead.
That said, direct property access will still work, however slightly
slower since they will now fall through __set() and __get() and in
turn passed through the setter/getter methods. 3.2 will exhibit a full
list of setter/getter methods for all (currently) public properties,
so code-completion in your IDE will work as expected.
There is absolutely no PHP allowed in templates any more. All
deprecated features of Smarty 2.0 are gone. Again, use the SmartyBC
class if you need any backward compatibility.
Internal Changes
Full UTF-8 Compatibility
The plugins shipped with Smarty 3.1 have been rewritten to fully
support UTF-8 strings if Multibyte String is available. Without
MBString UTF-8 cannot be handled properly. For those rare cases where
templates themselves have to juggle encodings, the new modifiers
to_charset and from_charset may come in handy.
Plugin API and Performance
All Plugins (modifiers, functions, blocks, resources,
default_template_handlers, etc) are now receiving the
Smarty_Internal_Template instance, where they were supplied with the
Smarty instance in Smarty 3.0. *. As The Smarty_Internal_Template
mimics the behavior of Smarty, this API simplification should not
require any changes to custom plugins.
The plugins shipped with Smarty 3.1 have been rewritten for better
performance. Most notably {html_select_date} and {html_select_time}
have been improved vastly. Performance aside, plugins have also been
reviewed and generalized in their API. {html_select_date} and
{html_select_time} now share almost all available options.
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.
The count_sentences modifier now accepts (.?!) as
legitimate endings of a sentence - previously only (.) was
accepted
The new unescape modifier is there to reverse the effects of the
escape modifier. This applies to the escape formats html, htmlall and
entity.
default_template_handler_func
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:
/**
* 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
* could be loaded
*/
function default_template_handler_func($type, $name, &$content, &$modified, Smarty $smarty) {
if (false) {
// return corrected filepath
return "/tmp/some/foobar.tpl";
} elseif (false) {
// return a template directly
$content = "the template source";
$modified = time();
return true;
} else {
// tell smarty that we failed
return false;
}
}
Stuff done to the compiler
Many performance improvements have happened internally. One notable
improvement is that all compiled templates are now handled as PHP
functions. This speeds up repeated templates tremendously, as each one
calls an (in-memory) PHP function instead of performing another file
include/scan.
New Features
Template syntax
{block}..{/block}
The {block} tag has a new hide option flag. It does suppress the block
content if no corresponding child block exists.
EXAMPLE:
parent.tpl
{block name=body hide} child content "{$smarty.block.child}" was
inserted {block}
In the above example the whole block will be suppressed if no child
block "body" is existing.
{setfilter}..{/setfilter}
The new {setfilter} block tag allows the definition of filters which
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.
2. a valid modifier. A modifier specification will also accept
additional parameter like filter2:'foo'
3. a PHP function
{/setfilter} will turn previous filter setting off again.
{setfilter} tags can be nested.
EXAMPLE:
{setfilter filter1}
{$foo}
{setfilter filter2}
{$bar}
{/setfilter}
{$buh}
{/setfilter}
{$blar}
In the above example filter1 will run on the output of $foo, filter2
on $bar, filter1 again on $buh and no filter on $blar.
NOTES:
- {$foo nofilter} will suppress the filters
- These filters will run in addition to filters defined by
registerFilter('variable',...), autoLoadFilter('variable',...) and
defined default modifier.
- {setfilter} will effect only the current template, not included
subtemplates.
Resource API
Smarty 3.1 features a new approach to resource management. The
Smarty_Resource API allows simple, yet powerful integration of custom
resources for templates and configuration files. It offers simple
functions for loading data from a custom resource (e.g. database) as
well as define new template types adhering to the special
non-compiling (e,g, plain php) and non-compile-caching (e.g. eval:
resource type) resources.
See demo/plugins/resource.mysql.php for an example custom database
resource.
Note that old-fashioned registration of callbacks for resource
management has been deprecated but is still possible with SmartyBC.
CacheResource API
In line with the Resource API, the CacheResource API offers a more
comfortable handling of output-cache data. With the
Smarty_CacheResource_Custom accessing databases is made simple. With
the introduction of Smarty_CacheResource_KeyValueStore the
implementation of resources like memcache or APC became a no-brainer;
simple hash-based storage systems are now supporting hierarchical
output-caches.
See demo/plugins/cacheresource.mysql.php for an example custom
database CacheResource.
See demo/plugins/cacheresource.memcache.php for an example custom
memcache CacheResource using the KeyValueStore helper.
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
$smarty->cache_locking = true;
Relative Paths in Templates (File-Resource)
As of Smarty 3.1 {include file="../foo.tpl"} and {include
file="./foo.tpl"} will resolve relative to the template they're in.
Relative paths are available with {include file="..."} and
{extends file="..."}. As $smarty->fetch('../foo.tpl') and
$smarty->fetch('./foo.tpl') cannot be relative to a template, an
exception is thrown.
Addressing a specific $template_dir
Smarty 3.1 introduces the $template_dir index notation.
$smarty->fetch('[foo]bar.tpl') and {include file="[foo]bar.tpl"}
require the template bar.tpl to be loaded from $template_dir['foo'];
Smarty::setTemplateDir() and Smarty::addTemplateDir() offer ways to
define indexes along with the actual directories.
Mixing Resources in extends-Resource
Taking the php extends: template resource one step further, it is now
possible to mix resources within an extends: call like
$smarty->fetch("extends:file:foo.tpl|db:bar.tpl");
To make eval: and string: resources available to the inheritance
chain, eval:base64:TPL_STRING and eval:urlencode:TPL_STRING have been
introduced. Supplying the base64 or urlencode flags will trigger
decoding the TPL_STRING in with either base64_decode() or urldecode().
extends-Resource in template inheritance
Template based inheritance may now inherit from php's extends:
resource like {extends file="extends:foo.tpl|db:bar.tpl"}.
New Smarty property escape_html
$smarty->escape_html = true will autoescape all template variable
output by calling htmlspecialchars({$output}, ENT_QUOTES,
SMARTY_RESOURCE_CHAR_SET).
NOTE:
This is a compile time option. If you change the setting you must make
sure that the templates get recompiled.
New option at Smarty property compile_check
The automatic recompilation of modified templates can now be
controlled by the following settings:
$smarty->compile_check = COMPILECHECK_OFF (false) - template files
will not be checked
$smarty->compile_check = COMPILECHECK_ON (true) - template files will
always be checked
$smarty->compile_check = COMPILECHECK_CACHEMISS - template files will
be checked if caching is enabled and there is no existing cache file
or it has expired
Automatic recompilation on Smarty version change
Templates will now be automatically recompiled on Smarty version
changes to avoide incompatibillities in the compiled code. Compiled
template checked against the current setting of the SMARTY_VERSION
constant.
default_config_handler_func()
Analogous to the default_template_handler_func()
default_config_handler_func() has been introduced.
default_plugin_handler_func()
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.
New getters/setters
The following setters/getters will be part of the official
documentation, and will be strongly recommended. Direct property
access will still work for the foreseeable future... it will be
transparently routed through the setters/getters, and consequently a
bit slower.
array|string getTemplateDir( [string $index] )
replaces $smarty->template_dir; and $smarty->template_dir[$index];
Smarty setTemplateDir( array|string $path )
replaces $smarty->template_dir = "foo"; and $smarty->template_dir =
array("foo", "bar");
Smarty addTemplateDir( array|string $path, [string $index])
replaces $smarty->template_dir[] = "bar"; and
$smarty->template_dir[$index] = "bar";
array|string getConfigDir( [string $index] )
replaces $smarty->config_dir; and $smarty->config_dir[$index];
Smarty setConfigDir( array|string $path )
replaces $smarty->config_dir = "foo"; and $smarty->config_dir =
array("foo", "bar");
Smarty addConfigDir( array|string $path, [string $index])
replaces $smarty->config_dir[] = "bar"; and
$smarty->config_dir[$index] = "bar";
array getPluginsDir()
replaces $smarty->plugins_dir;
Smarty setPluginsDir( array|string $path )
replaces $smarty->plugins_dir = "foo";
Smarty addPluginsDir( array|string $path )
replaces $smarty->plugins_dir[] = "bar";
string getCompileDir()
replaces $smarty->compile_dir;
Smarty setCompileDir( string $path )
replaces $smarty->compile_dir = "foo";
string getCacheDir()
replaces $smarty->cache_dir;
Smarty setCacheDir( string $path )
replaces $smarty->cache_dir;
+17 -11
View File
@@ -2,8 +2,10 @@
"name": "smarty/smarty",
"type": "library",
"description": "Smarty - the compiling PHP template engine",
"keywords": ["templating"],
"homepage": "http://www.smarty.net",
"keywords": [
"templating"
],
"homepage": "https://smarty-php.github.io/smarty/",
"license": "LGPL-3.0",
"authors": [
{
@@ -17,27 +19,31 @@
{
"name": "Rodney Rehm",
"email": "rodney.rehm@medialize.de"
},
{
"name": "Simon Wisselink",
"homepage": "https://www.iwink.nl/"
}
],
"support": {
"irc": "irc://irc.freenode.org/smarty",
"issues": "http://code.google.com/p/smarty-php/issues/list",
"forum": "http://www.smarty.net/forums/"
"issues": "https://github.com/smarty-php/smarty/issues",
"forum": "https://github.com/smarty-php/smarty/discussions"
},
"require": {
"php": ">=5.2"
"php": "^7.1 || ^8.0"
},
"autoload": {
"classmap": [
"libs/Smarty.class.php",
"libs/SmartyBC.class.php",
"libs/sysplugins/smarty_security.php"
"libs/"
]
},
"extra": {
"branch-alias": {
"dev-master": "3.1.x-dev"
"dev-master": "4.0.x-dev"
}
},
"require-dev": {
"phpunit/phpunit": "^8.5 || ^7.5",
"smarty/smarty-lexer": "^3.1"
}
}
+24 -22
View File
@@ -1,33 +1,35 @@
<?php
/**
/**
* Example Application
*
* @package Example-application
*/
require('../libs/Smarty.class.php');
require '../libs/Smarty.class.php';
$smarty = new Smarty;
//$smarty->force_compile = true;
$smarty->debugging = true;
$smarty->caching = true;
$smarty->cache_lifetime = 120;
$smarty->assign("Name","Fred Irving Johnathan Bradley Peppergill",true);
$smarty->assign("FirstName",array("John","Mary","James","Henry"));
$smarty->assign("LastName",array("Doe","Smith","Johnson","Case"));
$smarty->assign("Class",array(array("A","B","C","D"), array("E", "F", "G", "H"),
array("I", "J", "K", "L"), array("M", "N", "O", "P")));
$smarty->assign("contacts", array(array("phone" => "1", "fax" => "2", "cell" => "3"),
array("phone" => "555-4444", "fax" => "555-3333", "cell" => "760-1234")));
$smarty->assign("option_values", array("NY","NE","KS","IA","OK","TX"));
$smarty->assign("option_output", array("New York","Nebraska","Kansas","Iowa","Oklahoma","Texas"));
$smarty->assign("Name", "Fred Irving Johnathan Bradley Peppergill", true);
$smarty->assign("FirstName", array("John", "Mary", "James", "Henry"));
$smarty->assign("LastName", array("Doe", "Smith", "Johnson", "Case"));
$smarty->assign(
"Class",
array(
array("A", "B", "C", "D"),
array("E", "F", "G", "H"),
array("I", "J", "K", "L"),
array("M", "N", "O", "P")
)
);
$smarty->assign(
"contacts",
array(
array("phone" => "1", "fax" => "2", "cell" => "3"),
array("phone" => "555-4444", "fax" => "555-3333", "cell" => "760-1234")
)
);
$smarty->assign("option_values", array("NY", "NE", "KS", "IA", "OK", "TX"));
$smarty->assign("option_output", array("New York", "Nebraska", "Kansas", "Iowa", "Oklahoma", "Texas"));
$smarty->assign("option_selected", "NE");
$smarty->display('index.tpl');
?>
+18 -10
View File
@@ -2,19 +2,24 @@
/**
* APC CacheResource
*
* CacheResource Implementation based on the KeyValueStore API to use
* memcache as the storage resource for Smarty's output caching.
* *
*
* @package CacheResource-examples
* @author Uwe Tews
* @author Uwe Tews
*/
class Smarty_CacheResource_Apc extends Smarty_CacheResource_KeyValueStore {
class Smarty_CacheResource_Apc extends Smarty_CacheResource_KeyValueStore
{
/**
* Smarty_CacheResource_Apc constructor.
*
* @throws \Exception
*/
public function __construct()
{
// test if APC is present
if(!function_exists('apc_cache_info')) {
if (!function_exists('apc_cache_info')) {
throw new Exception('APC Template Caching Error: APC is not installed');
}
}
@@ -23,7 +28,8 @@ class Smarty_CacheResource_Apc extends Smarty_CacheResource_KeyValueStore {
* Read values for a set of keys from cache
*
* @param array $keys list of keys to fetch
* @return array list of values with the given keys used as indexes
*
* @return array list of values with the given keys used as indexes
* @return boolean true on success, false on failure
*/
protected function read(array $keys)
@@ -31,7 +37,7 @@ class Smarty_CacheResource_Apc extends Smarty_CacheResource_KeyValueStore {
$_res = array();
$res = apc_fetch($keys);
foreach ($res as $k => $v) {
$_res[$k] = $v;
$_res[ $k ] = $v;
}
return $_res;
}
@@ -39,11 +45,12 @@ class Smarty_CacheResource_Apc extends Smarty_CacheResource_KeyValueStore {
/**
* Save values for a set of keys to cache
*
* @param array $keys list of values to save
* @param int $expire expiration time
* @param array $keys list of values to save
* @param int $expire expiration time
*
* @return boolean true on success, false on failure
*/
protected function write(array $keys, $expire=null)
protected function write(array $keys, $expire = null)
{
foreach ($keys as $k => $v) {
apc_store($k, $v, $expire);
@@ -55,6 +62,7 @@ class Smarty_CacheResource_Apc extends Smarty_CacheResource_KeyValueStore {
* Remove values from cache
*
* @param array $keys list of keys to delete
*
* @return boolean true on success, false on failure
*/
protected function delete(array $keys)
+33 -25
View File
@@ -2,64 +2,71 @@
/**
* Memcache CacheResource
*
* CacheResource Implementation based on the KeyValueStore API to use
* memcache as the storage resource for Smarty's output caching.
*
* Note that memcache has a limitation of 256 characters per cache-key.
* To avoid complications all cache-keys are translated to a sha1 hash.
*
* @package CacheResource-examples
* @author Rodney Rehm
* @author Rodney Rehm
*/
class Smarty_CacheResource_Memcache extends Smarty_CacheResource_KeyValueStore {
class Smarty_CacheResource_Memcache extends Smarty_CacheResource_KeyValueStore
{
/**
* memcache instance
*
* @var Memcache
*/
protected $memcache = null;
/**
* Smarty_CacheResource_Memcache constructor.
*/
public function __construct()
{
$this->memcache = new Memcache();
$this->memcache->addServer( '127.0.0.1', 11211 );
if (class_exists('Memcached')) {
$this->memcache = new Memcached();
} else {
$this->memcache = new Memcache();
}
$this->memcache->addServer('127.0.0.1', 11211);
}
/**
* Read values for a set of keys from cache
*
* @param array $keys list of keys to fetch
* @return array list of values with the given keys used as indexes
*
* @return array list of values with the given keys used as indexes
* @return boolean true on success, false on failure
*/
protected function read(array $keys)
{
$_keys = $lookup = array();
foreach ($keys as $k) {
$_k = sha1($k);
$_keys[] = $_k;
$lookup[$_k] = $k;
$res = array();
foreach ($keys as $key) {
$k = sha1($key);
$res[$key] = $this->memcache->get($k);
}
$_res = array();
$res = $this->memcache->get($_keys);
foreach ($res as $k => $v) {
$_res[$lookup[$k]] = $v;
}
return $_res;
return $res;
}
/**
* Save values for a set of keys to cache
*
* @param array $keys list of values to save
* @param int $expire expiration time
* @param array $keys list of values to save
* @param int $expire expiration time
*
* @return boolean true on success, false on failure
*/
protected function write(array $keys, $expire=null)
protected function write(array $keys, $expire = null)
{
foreach ($keys as $k => $v) {
$k = sha1($k);
$this->memcache->set($k, $v, 0, $expire);
if (class_exists('Memcached')) {
$this->memcache->set($k, $v, $expire);
} else {
$this->memcache->set($k, $v, 0, $expire);
}
}
return true;
}
@@ -68,6 +75,7 @@ class Smarty_CacheResource_Memcache extends Smarty_CacheResource_KeyValueStore {
* Remove values from cache
*
* @param array $keys list of keys to delete
*
* @return boolean true on success, false on failure
*/
protected function delete(array $keys)
+78 -47
View File
@@ -2,10 +2,8 @@
/**
* MySQL CacheResource
*
* CacheResource Implementation based on the Custom API to use
* MySQL as the storage resource for Smarty's output caching.
*
* Table definition:
* <pre>CREATE TABLE IF NOT EXISTS `output_cache` (
* `id` CHAR(40) NOT NULL COMMENT 'sha1 hash',
@@ -22,60 +20,87 @@
* ) ENGINE = InnoDB;</pre>
*
* @package CacheResource-examples
* @author Rodney Rehm
* @author Rodney Rehm
*/
class Smarty_CacheResource_Mysql extends Smarty_CacheResource_Custom {
// PDO instance
class Smarty_CacheResource_Mysql extends Smarty_CacheResource_Custom
{
/**
* @var \PDO
*/
protected $db;
/**
* @var \PDOStatement
*/
protected $fetch;
/**
* @var \PDOStatement
*/
protected $fetchTimestamp;
/**
* @var \PDOStatement
*/
protected $save;
public function __construct() {
/**
* Smarty_CacheResource_Mysql constructor.
*
* @throws \SmartyException
*/
public function __construct()
{
try {
$this->db = new PDO("mysql:dbname=test;host=127.0.0.1", "smarty", "smarty");
$this->db = new PDO("mysql:dbname=test;host=127.0.0.1", "smarty");
} catch (PDOException $e) {
throw new SmartyException('Mysql Resource failed: ' . $e->getMessage());
}
$this->fetch = $this->db->prepare('SELECT modified, content FROM output_cache WHERE id = :id');
$this->fetchTimestamp = $this->db->prepare('SELECT modified FROM output_cache WHERE id = :id');
$this->save = $this->db->prepare('REPLACE INTO output_cache (id, name, cache_id, compile_id, content)
VALUES (:id, :name, :cache_id, :compile_id, :content)');
$this->save = $this->db->prepare(
'REPLACE INTO output_cache (id, name, cache_id, compile_id, content)
VALUES (:id, :name, :cache_id, :compile_id, :content)'
);
}
/**
* fetch cached content and its modification time from data source
*
* @param string $id unique cache content identifier
* @param string $name template name
* @param string $cache_id cache id
* @param string $compile_id compile id
* @param string $content cached content
* @param integer $mtime cache modification timestamp (epoch)
* @param string $id unique cache content identifier
* @param string $name template name
* @param string $cache_id cache id
* @param string $compile_id compile id
* @param string $content cached content
* @param integer $mtime cache modification timestamp (epoch)
*
* @return void
*/
protected function fetch($id, $name, $cache_id, $compile_id, &$content, &$mtime)
{
$this->fetch->execute(array('id' => $id));
$row = $this->fetch->fetch();
$this->fetch->closeCursor();
$this->fetch->closeCursor();
if ($row) {
$content = $row['content'];
$mtime = strtotime($row['modified']);
$content = $row[ 'content' ];
$mtime = strtotime($row[ 'modified' ]);
} else {
$content = null;
$mtime = null;
}
}
/**
* Fetch cached content's modification timestamp from data source
*
* @note implementing this method is optional. Only implement it if modification times can be accessed faster than loading the complete cached content.
* @param string $id unique cache content identifier
* @param string $name template name
* @param string $cache_id cache id
* @note implementing this method is optional. Only implement it if modification times can be accessed faster than
* loading the complete cached content.
*
* @param string $id unique cache content identifier
* @param string $name template name
* @param string $cache_id cache id
* @param string $compile_id compile id
*
* @return integer|boolean timestamp (epoch) the template was modified, or false if not found
*/
protected function fetchTimestamp($id, $name, $cache_id, $compile_id)
@@ -85,38 +110,40 @@ class Smarty_CacheResource_Mysql extends Smarty_CacheResource_Custom {
$this->fetchTimestamp->closeCursor();
return $mtime;
}
/**
* Save content to cache
*
* @param string $id unique cache content identifier
* @param string $name template name
* @param string $cache_id cache id
* @param string $compile_id compile id
* @param integer|null $exp_time seconds till expiration time in seconds or null
* @param string $content content to cache
* @return boolean success
* @param string $id unique cache content identifier
* @param string $name template name
* @param string $cache_id cache id
* @param string $compile_id compile id
* @param integer|null $exp_time seconds till expiration time in seconds or null
* @param string $content content to cache
*
* @return boolean success
*/
protected function save($id, $name, $cache_id, $compile_id, $exp_time, $content)
{
$this->save->execute(array(
'id' => $id,
'name' => $name,
'cache_id' => $cache_id,
'compile_id' => $compile_id,
'content' => $content,
));
$this->save->execute(
array('id' => $id,
'name' => $name,
'cache_id' => $cache_id,
'compile_id' => $compile_id,
'content' => $content,)
);
return !!$this->save->rowCount();
}
/**
* Delete content from cache
*
* @param string $name template name
* @param string $cache_id cache id
* @param string $compile_id compile id
* @param integer|null $exp_time seconds till expiration or null
* @return integer number of deleted caches
* @param string $name template name
* @param string $cache_id cache id
* @param string $compile_id compile id
* @param integer|null $exp_time seconds till expiration or null
*
* @return integer number of deleted caches
*/
protected function delete($name, $cache_id, $compile_id, $exp_time)
{
@@ -142,8 +169,12 @@ class Smarty_CacheResource_Mysql extends Smarty_CacheResource_Custom {
}
// equal test cache_id and match sub-groups
if ($cache_id !== null) {
$where[] = '(cache_id = '. $this->db->quote($cache_id)
. ' OR cache_id LIKE '. $this->db->quote($cache_id .'|%') .')';
$where[] =
'(cache_id = ' .
$this->db->quote($cache_id) .
' OR cache_id LIKE ' .
$this->db->quote($cache_id . '|%') .
')';
}
// run delete query
$query = $this->db->query('DELETE FROM output_cache WHERE ' . join(' AND ', $where));
+346
View File
@@ -0,0 +1,346 @@
<?php
/**
* PDO Cache Handler
* Allows you to store Smarty Cache files into your db.
* Example table :
* CREATE TABLE `smarty_cache` (
* `id` char(40) NOT NULL COMMENT 'sha1 hash',
* `name` varchar(250) NOT NULL,
* `cache_id` varchar(250) DEFAULT NULL,
* `compile_id` varchar(250) DEFAULT NULL,
* `modified` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,
* `expire` timestamp NOT NULL DEFAULT '0000-00-00 00:00:00',
* `content` mediumblob NOT NULL,
* PRIMARY KEY (`id`),
* KEY `name` (`name`),
* KEY `cache_id` (`cache_id`),
* KEY `compile_id` (`compile_id`),
* KEY `modified` (`modified`),
* KEY `expire` (`expire`)
* ) ENGINE=InnoDB
* Example usage :
* $cnx = new PDO("mysql:host=localhost;dbname=mydb", "username", "password");
* $smarty->setCachingType('pdo');
* $smarty->loadPlugin('Smarty_CacheResource_Pdo');
* $smarty->registerCacheResource('pdo', new Smarty_CacheResource_Pdo($cnx, 'smarty_cache'));
*
* @author Beno!t POLASZEK - 2014
*/
class Smarty_CacheResource_Pdo extends Smarty_CacheResource_Custom
{
/**
* @var string[]
*/
protected $fetchStatements = array('default' => 'SELECT %2$s
FROM %1$s
WHERE 1
AND id = :id
AND cache_id IS NULL
AND compile_id IS NULL',
'withCacheId' => 'SELECT %2$s
FROM %1$s
WHERE 1
AND id = :id
AND cache_id = :cache_id
AND compile_id IS NULL',
'withCompileId' => 'SELECT %2$s
FROM %1$s
WHERE 1
AND id = :id
AND compile_id = :compile_id
AND cache_id IS NULL',
'withCacheIdAndCompileId' => 'SELECT %2$s
FROM %1$s
WHERE 1
AND id = :id
AND cache_id = :cache_id
AND compile_id = :compile_id');
/**
* @var string
*/
protected $insertStatement = 'INSERT INTO %s
SET id = :id,
name = :name,
cache_id = :cache_id,
compile_id = :compile_id,
modified = CURRENT_TIMESTAMP,
expire = DATE_ADD(CURRENT_TIMESTAMP, INTERVAL :expire SECOND),
content = :content
ON DUPLICATE KEY UPDATE
name = :name,
cache_id = :cache_id,
compile_id = :compile_id,
modified = CURRENT_TIMESTAMP,
expire = DATE_ADD(CURRENT_TIMESTAMP, INTERVAL :expire SECOND),
content = :content';
/**
* @var string
*/
protected $deleteStatement = 'DELETE FROM %1$s WHERE %2$s';
/**
* @var string
*/
protected $truncateStatement = 'TRUNCATE TABLE %s';
/**
* @var string
*/
protected $fetchColumns = 'modified, content';
/**
* @var string
*/
protected $fetchTimestampColumns = 'modified';
/**
* @var \PDO
*/
protected $pdo;
/**
* @var
*/
protected $table;
/**
* @var null
*/
protected $database;
/**
* Constructor
*
* @param PDO $pdo PDO : active connection
* @param string $table : table (or view) name
* @param string $database : optional - if table is located in another db
*
* @throws \SmartyException
*/
public function __construct(PDO $pdo, $table, $database = null)
{
if (is_null($table)) {
throw new SmartyException("Table name for caching can't be null");
}
$this->pdo = $pdo;
$this->table = $table;
$this->database = $database;
$this->fillStatementsWithTableName();
}
/**
* Fills the table name into the statements.
*
* @return $this Current Instance
* @access protected
*/
protected function fillStatementsWithTableName()
{
foreach ($this->fetchStatements as &$statement) {
$statement = sprintf($statement, $this->getTableName(), '%s');
}
$this->insertStatement = sprintf($this->insertStatement, $this->getTableName());
$this->deleteStatement = sprintf($this->deleteStatement, $this->getTableName(), '%s');
$this->truncateStatement = sprintf($this->truncateStatement, $this->getTableName());
return $this;
}
/**
* Gets the fetch statement, depending on what you specify
*
* @param string $columns : the column(s) name(s) you want to retrieve from the database
* @param string $id unique cache content identifier
* @param string|null $cache_id cache id
* @param string|null $compile_id compile id
*
* @access protected
* @return \PDOStatement
*/
protected function getFetchStatement($columns, $id, $cache_id = null, $compile_id = null)
{
$args = array();
if (!is_null($cache_id) && !is_null($compile_id)) {
$query = $this->fetchStatements[ 'withCacheIdAndCompileId' ] and
$args = array('id' => $id, 'cache_id' => $cache_id, 'compile_id' => $compile_id);
} elseif (is_null($cache_id) && !is_null($compile_id)) {
$query = $this->fetchStatements[ 'withCompileId' ] and
$args = array('id' => $id, 'compile_id' => $compile_id);
} elseif (!is_null($cache_id) && is_null($compile_id)) {
$query = $this->fetchStatements[ 'withCacheId' ] and $args = array('id' => $id, 'cache_id' => $cache_id);
} else {
$query = $this->fetchStatements[ 'default' ] and $args = array('id' => $id);
}
$query = sprintf($query, $columns);
$stmt = $this->pdo->prepare($query);
foreach ($args as $key => $value) {
$stmt->bindValue($key, $value);
}
return $stmt;
}
/**
* fetch cached content and its modification time from data source
*
* @param string $id unique cache content identifier
* @param string $name template name
* @param string|null $cache_id cache id
* @param string|null $compile_id compile id
* @param string $content cached content
* @param integer $mtime cache modification timestamp (epoch)
*
* @return void
* @access protected
*/
protected function fetch($id, $name, $cache_id, $compile_id, &$content, &$mtime)
{
$stmt = $this->getFetchStatement($this->fetchColumns, $id, $cache_id, $compile_id);
$stmt->execute();
$row = $stmt->fetch();
$stmt->closeCursor();
if ($row) {
$content = $this->outputContent($row[ 'content' ]);
$mtime = strtotime($row[ 'modified' ]);
} else {
$content = null;
$mtime = null;
}
}
/**
* Fetch cached content's modification timestamp from data source
* {@internal implementing this method is optional.
* Only implement it if modification times can be accessed faster than loading the complete cached content.}}
*
* @param string $id unique cache content identifier
* @param string $name template name
* @param string|null $cache_id cache id
* @param string|null $compile_id compile id
*
* @return integer|boolean timestamp (epoch) the template was modified, or false if not found
* @access protected
*/
// protected function fetchTimestamp($id, $name, $cache_id = null, $compile_id = null) {
// $stmt = $this->getFetchStatement($this->fetchTimestampColumns, $id, $cache_id, $compile_id);
// $stmt -> execute();
// $mtime = strtotime($stmt->fetchColumn());
// $stmt -> closeCursor();
// return $mtime;
// }
/**
* Save content to cache
*
* @param string $id unique cache content identifier
* @param string $name template name
* @param string|null $cache_id cache id
* @param string|null $compile_id compile id
* @param integer|null $exp_time seconds till expiration time in seconds or null
* @param string $content content to cache
*
* @return boolean success
* @access protected
*/
protected function save($id, $name, $cache_id, $compile_id, $exp_time, $content)
{
$stmt = $this->pdo->prepare($this->insertStatement);
$stmt->bindValue('id', $id);
$stmt->bindValue('name', $name);
$stmt->bindValue('cache_id', $cache_id, (is_null($cache_id)) ? PDO::PARAM_NULL : PDO::PARAM_STR);
$stmt->bindValue('compile_id', $compile_id, (is_null($compile_id)) ? PDO::PARAM_NULL : PDO::PARAM_STR);
$stmt->bindValue('expire', (int)$exp_time, PDO::PARAM_INT);
$stmt->bindValue('content', $this->inputContent($content));
$stmt->execute();
return !!$stmt->rowCount();
}
/**
* Encodes the content before saving to database
*
* @param string $content
*
* @return string $content
* @access protected
*/
protected function inputContent($content)
{
return $content;
}
/**
* Decodes the content before saving to database
*
* @param string $content
*
* @return string $content
* @access protected
*/
protected function outputContent($content)
{
return $content;
}
/**
* Delete content from cache
*
* @param string|null $name template name
* @param string|null $cache_id cache id
* @param string|null $compile_id compile id
* @param integer|null|-1 $exp_time seconds till expiration or null
*
* @return integer number of deleted caches
* @access protected
*/
protected function delete($name = null, $cache_id = null, $compile_id = null, $exp_time = null)
{
// delete the whole cache
if ($name === null && $cache_id === null && $compile_id === null && $exp_time === null) {
// returning the number of deleted caches would require a second query to count them
$this->pdo->query($this->truncateStatement);
return -1;
}
// build the filter
$where = array();
// equal test name
if ($name !== null) {
$where[] = 'name = ' . $this->pdo->quote($name);
}
// equal test cache_id and match sub-groups
if ($cache_id !== null) {
$where[] =
'(cache_id = ' .
$this->pdo->quote($cache_id) .
' OR cache_id LIKE ' .
$this->pdo->quote($cache_id . '|%') .
')';
}
// equal test compile_id
if ($compile_id !== null) {
$where[] = 'compile_id = ' . $this->pdo->quote($compile_id);
}
// for clearing expired caches
if ($exp_time === Smarty::CLEAR_EXPIRED) {
$where[] = 'expire < CURRENT_TIMESTAMP';
} // range test expiration time
elseif ($exp_time !== null) {
$where[] = 'modified < DATE_SUB(NOW(), INTERVAL ' . intval($exp_time) . ' SECOND)';
}
// run delete query
$query = $this->pdo->query(sprintf($this->deleteStatement, join(' AND ', $where)));
return $query->rowCount();
}
/**
* Gets the formatted table name
*
* @return string
* @access protected
*/
protected function getTableName()
{
return (is_null($this->database)) ? "`{$this->table}`" : "`{$this->database}`.`{$this->table}`";
}
}
+42
View File
@@ -0,0 +1,42 @@
<?php
require_once 'cacheresource.pdo.php';
/**
* PDO Cache Handler with GZIP support
* Example usage :
* $cnx = new PDO("mysql:host=localhost;dbname=mydb", "username", "password");
* $smarty->setCachingType('pdo_gzip');
* $smarty->loadPlugin('Smarty_CacheResource_Pdo_Gzip');
* $smarty->registerCacheResource('pdo_gzip', new Smarty_CacheResource_Pdo_Gzip($cnx, 'smarty_cache'));
*
* @require Smarty_CacheResource_Pdo class
* @author Beno!t POLASZEK - 2014
*/
class Smarty_CacheResource_Pdo_Gzip extends Smarty_CacheResource_Pdo
{
/**
* Encodes the content before saving to database
*
* @param string $content
*
* @return string $content
* @access protected
*/
protected function inputContent($content)
{
return gzdeflate($content);
}
/**
* Decodes the content before saving to database
*
* @param string $content
*
* @return string $content
* @access protected
*/
protected function outputContent($content)
{
return gzinflate($content);
}
}
+27 -25
View File
@@ -2,59 +2,61 @@
/**
* Extends All Resource
*
* Resource Implementation modifying the extends-Resource to walk
* through the template_dirs and inherit all templates of the same name
*
*
* @package Resource-examples
* @author Rodney Rehm
* @author Rodney Rehm
*/
class Smarty_Resource_Extendsall extends Smarty_Internal_Resource_Extends {
class Smarty_Resource_Extendsall extends Smarty_Internal_Resource_Extends
{
/**
* populate Source Object with meta data from Resource
*
* @param Smarty_Template_Source $source source object
* @param Smarty_Template_Source $source source object
* @param Smarty_Internal_Template $_template template object
*
* @return void
*/
public function populate(Smarty_Template_Source $source, Smarty_Internal_Template $_template=null)
public function populate(Smarty_Template_Source $source, Smarty_Internal_Template $_template = null)
{
$uid = '';
$sources = array();
$exists = true;
foreach ($_template->smarty->getTemplateDir() as $key => $directory) {
$timestamp = 0;
foreach ($source->smarty->getTemplateDir() as $key => $directory) {
try {
$s = Smarty_Resource::source(null, $source->smarty, '[' . $key . ']' . $source->name );
$s = Smarty_Resource::source(null, $source->smarty, 'file:' . '[' . $key . ']' . $source->name);
if (!$s->exists) {
continue;
}
$sources[$s->uid] = $s;
$sources[ $s->uid ] = $s;
$uid .= $s->filepath;
$timestamp = $s->timestamp > $timestamp ? $s->timestamp : $timestamp;
} catch (SmartyException $e) {
}
catch (SmartyException $e) {}
}
if (!$sources) {
$source->exists = false;
$source->template = $_template;
return;
}
$sources = array_reverse($sources, true);
reset($sources);
$s = current($sources);
$source->components = $sources;
$source->filepath = $s->filepath;
$source->uid = sha1($uid);
$source->exists = $exists;
if ($_template && $_template->smarty->compile_check) {
$source->timestamp = $s->timestamp;
}
// need the template at getContent()
$source->template = $_template;
$source->uid = sha1($uid . $source->smarty->_joined_template_dir);
$source->exists = true;
$source->timestamp = $timestamp;
}
}
?>
/**
* Disable timestamp checks for extendsall resource.
* The individual source components will be checked.
*
* @return bool false
*/
public function checkTimestamps()
{
return false;
}
}
+45 -20
View File
@@ -2,10 +2,8 @@
/**
* MySQL Resource
*
* Resource Implementation based on the Custom API to use
* MySQL as the storage resource for Smarty's templates and configs.
*
* Table definition:
* <pre>CREATE TABLE IF NOT EXISTS `templates` (
* `name` varchar(100) NOT NULL,
@@ -13,37 +11,60 @@
* `source` text,
* PRIMARY KEY (`name`)
* ) ENGINE=InnoDB DEFAULT CHARSET=utf8;</pre>
*
* Demo data:
* <pre>INSERT INTO `templates` (`name`, `modified`, `source`) VALUES ('test.tpl', "2010-12-25 22:00:00", '{$x="hello world"}{$x}');</pre>
* <pre>INSERT INTO `templates` (`name`, `modified`, `source`) VALUES ('test.tpl', "2010-12-25 22:00:00", '{$x="hello
* world"}{$x}');</pre>
*
*
* @package Resource-examples
* @author Rodney Rehm
* @author Rodney Rehm
*/
class Smarty_Resource_Mysql extends Smarty_Resource_Custom {
// PDO instance
class Smarty_Resource_Mysql extends Smarty_Resource_Custom
{
/**
* PDO instance
*
* @var \PDO
*/
protected $db;
// prepared fetch() statement
/**
* prepared fetch() statement
*
* @var \PDOStatement
*/
protected $fetch;
// prepared fetchTimestamp() statement
/**
* prepared fetchTimestamp() statement
*
* @var \PDOStatement
*/
protected $mtime;
public function __construct() {
/**
* Smarty_Resource_Mysql constructor.
*
* @throws \SmartyException
*/
public function __construct()
{
try {
$this->db = new PDO("mysql:dbname=test;host=127.0.0.1", "smarty", "smarty");
$this->db = new PDO("mysql:dbname=test;host=127.0.0.1", "smarty");
} catch (PDOException $e) {
throw new SmartyException('Mysql Resource failed: ' . $e->getMessage());
}
$this->fetch = $this->db->prepare('SELECT modified, source FROM templates WHERE name = :name');
$this->mtime = $this->db->prepare('SELECT modified FROM templates WHERE name = :name');
}
/**
* Fetch a template and its modification time from database
*
* @param string $name template name
* @param string $source template source
* @param integer $mtime template modification timestamp (epoch)
* @param string $name template name
* @param string $source template source
* @param integer $mtime template modification timestamp (epoch)
*
* @return void
*/
protected function fetch($name, &$source, &$mtime)
@@ -52,22 +73,26 @@ class Smarty_Resource_Mysql extends Smarty_Resource_Custom {
$row = $this->fetch->fetch();
$this->fetch->closeCursor();
if ($row) {
$source = $row['source'];
$mtime = strtotime($row['modified']);
$source = $row[ 'source' ];
$mtime = strtotime($row[ 'modified' ]);
} else {
$source = null;
$mtime = null;
}
}
/**
* Fetch a template's modification time from database
*
* @note implementing this method is optional. Only implement it if modification times can be accessed faster than loading the comple template source.
* @note implementing this method is optional. Only implement it if modification times can be accessed faster than
* loading the comple template source.
*
* @param string $name template name
*
* @return integer timestamp (epoch) the template was modified
*/
protected function fetchTimestamp($name) {
protected function fetchTimestamp($name)
{
$this->mtime->execute(array('name' => $name));
$mtime = $this->mtime->fetchColumn();
$this->mtime->closeCursor();
+32 -17
View File
@@ -2,13 +2,10 @@
/**
* MySQL Resource
*
* Resource Implementation based on the Custom API to use
* MySQL as the storage resource for Smarty's templates and configs.
*
* Note that this MySQL implementation fetches the source and timestamps in
* a single database query, instead of two separate like resource.mysql.php does.
*
* Table definition:
* <pre>CREATE TABLE IF NOT EXISTS `templates` (
* `name` varchar(100) NOT NULL,
@@ -16,34 +13,52 @@
* `source` text,
* PRIMARY KEY (`name`)
* ) ENGINE=InnoDB DEFAULT CHARSET=utf8;</pre>
*
* Demo data:
* <pre>INSERT INTO `templates` (`name`, `modified`, `source`) VALUES ('test.tpl', "2010-12-25 22:00:00", '{$x="hello world"}{$x}');</pre>
* <pre>INSERT INTO `templates` (`name`, `modified`, `source`) VALUES ('test.tpl', "2010-12-25 22:00:00", '{$x="hello
* world"}{$x}');</pre>
*
*
* @package Resource-examples
* @author Rodney Rehm
* @author Rodney Rehm
*/
class Smarty_Resource_Mysqls extends Smarty_Resource_Custom {
// PDO instance
class Smarty_Resource_Mysqls extends Smarty_Resource_Custom
{
/**
* PDO instance
*
* @var \PDO
*/
protected $db;
// prepared fetch() statement
/**
* prepared fetch() statement
*
* @var \PDOStatement
*/
protected $fetch;
public function __construct() {
/**
* Smarty_Resource_Mysqls constructor.
*
* @throws \SmartyException
*/
public function __construct()
{
try {
$this->db = new PDO("mysql:dbname=test;host=127.0.0.1", "smarty", "smarty");
$this->db = new PDO("mysql:dbname=test;host=127.0.0.1", "smarty");
} catch (PDOException $e) {
throw new SmartyException('Mysql Resource failed: ' . $e->getMessage());
}
$this->fetch = $this->db->prepare('SELECT modified, source FROM templates WHERE name = :name');
}
/**
* Fetch a template and its modification time from database
*
* @param string $name template name
* @param string $source template source
* @param integer $mtime template modification timestamp (epoch)
* @param string $name template name
* @param string $source template source
* @param integer $mtime template modification timestamp (epoch)
*
* @return void
*/
protected function fetch($name, &$source, &$mtime)
@@ -52,8 +67,8 @@ class Smarty_Resource_Mysqls extends Smarty_Resource_Custom {
$row = $this->fetch->fetch();
$this->fetch->closeCursor();
if ($row) {
$source = $row['source'];
$mtime = strtotime($row['modified']);
$source = $row[ 'source' ];
$mtime = strtotime($row[ 'modified' ]);
} else {
$source = null;
$mtime = null;
+45 -40
View File
@@ -4,18 +4,18 @@
<PRE>
{* bold and title are read from the config file *}
{if #bold#}<b>{/if}
{* capitalize the first letters of each word of the title *}
Title: {#title#|capitalize}
{if #bold#}</b>{/if}
{if #bold#}<b>{/if}
{* capitalize the first letters of each word of the title *}
Title: {#title#|capitalize}
{if #bold#}</b>{/if}
The current date and time is {$smarty.now|date_format:"%Y-%m-%d %H:%M:%S"}
The current date and time is {$smarty.now|date_format:"%Y-%m-%d %H:%M:%S"}
The value of global assigned variable $SCRIPT_NAME is {$SCRIPT_NAME}
The value of global assigned variable $SCRIPT_NAME is {$SCRIPT_NAME}
Example of accessing server environment variable SERVER_NAME: {$smarty.server.SERVER_NAME}
Example of accessing server environment variable SERVER_NAME: {$smarty.server.SERVER_NAME}
The value of {ldelim}$Name{rdelim} is <b>{$Name}</b>
The value of {ldelim}$Name{rdelim} is <b>{$Name}</b>
variable modifier example of {ldelim}$Name|upper{rdelim}
@@ -24,59 +24,64 @@ variable modifier example of {ldelim}$Name|upper{rdelim}
An example of a section loop:
{section name=outer
loop=$FirstName}
{if $smarty.section.outer.index is odd by 2}
{$smarty.section.outer.rownum} . {$FirstName[outer]} {$LastName[outer]}
{else}
{$smarty.section.outer.rownum} * {$FirstName[outer]} {$LastName[outer]}
{/if}
{sectionelse}
none
{/section}
{section name=outer
loop=$FirstName}
{if $smarty.section.outer.index is odd by 2}
{$smarty.section.outer.rownum} . {$FirstName[outer]} {$LastName[outer]}
{else}
{$smarty.section.outer.rownum} * {$FirstName[outer]} {$LastName[outer]}
{/if}
{sectionelse}
none
{/section}
An example of section looped key values:
An example of section looped key values:
{section name=sec1 loop=$contacts}
phone: {$contacts[sec1].phone}<br>
fax: {$contacts[sec1].fax}<br>
cell: {$contacts[sec1].cell}<br>
{/section}
<p>
{section name=sec1 loop=$contacts}
phone: {$contacts[sec1].phone}
<br>
testing strip tags
{strip}
fax: {$contacts[sec1].fax}
<br>
cell: {$contacts[sec1].cell}
<br>
{/section}
<p>
testing strip tags
{strip}
<table border=0>
<tr>
<td>
<A HREF="{$SCRIPT_NAME}">
<font color="red">This is a test </font>
</A>
</td>
</tr>
<tr>
<td>
<A HREF="{$SCRIPT_NAME}">
<font color="red">This is a test </font>
</A>
</td>
</tr>
</table>
{/strip}
{/strip}
</PRE>
This is an example of the html_select_date function:
<form>
{html_select_date start_year=1998 end_year=2010}
{html_select_date start_year=1998 end_year=2010}
</form>
This is an example of the html_select_time function:
<form>
{html_select_time use_24_hours=false}
{html_select_time use_24_hours=false}
</form>
This is an example of the html_options function:
<form>
<select name=states>
{html_options values=$option_values selected=$option_selected output=$option_output}
</select>
<select name=states>
{html_options values=$option_values selected=$option_selected output=$option_output}
</select>
</form>
{include file="footer.tpl"}
+44
View File
@@ -0,0 +1,44 @@
version: "2"
services:
base:
build:
context: .
dockerfile: ./utilities/testrunners/php71/Dockerfile
volumes:
- .:/app
working_dir: /app
php71:
extends:
service: base
build:
dockerfile: ./utilities/testrunners/php71/Dockerfile
php72:
extends:
service: base
build:
dockerfile: ./utilities/testrunners/php72/Dockerfile
php73:
extends:
service: base
build:
dockerfile: ./utilities/testrunners/php73/Dockerfile
php74:
extends:
service: base
build:
dockerfile: ./utilities/testrunners/php74/Dockerfile
php80:
extends:
service: base
build:
dockerfile: ./utilities/testrunners/php80/Dockerfile
php81:
extends:
service: base
build:
dockerfile: ./utilities/testrunners/php81/Dockerfile
php82:
extends:
service: base
build:
dockerfile: ./utilities/testrunners/php82/Dockerfile
+1
View File
@@ -0,0 +1 @@
theme: jekyll-theme-minimal
+274
View File
@@ -0,0 +1,274 @@
# Tips & Tricks
## Blank Variable Handling
There may be times when you want to print a default value for an empty
variable instead of printing nothing, such as printing `&nbsp;` so that
html table backgrounds work properly. Many would use an
[`{if}`](../designers/language-builtin-functions/language-function-if.md) statement to handle this, but there is a
shorthand way with Smarty, using the
[`default`](../designers/language-modifiers/language-modifier-default.md) variable modifier.
> **Note**
>
> "Undefined variable" errors will show an E\_NOTICE if not disabled in
> PHP's [`error_reporting()`](https://www.php.net/error_reporting) level or
> Smarty's [`$error_reporting`](../programmers/api-variables/variable-error-reporting.md) property and
> a variable had not been assigned to Smarty.
```smarty
{* the long way *}
{if $title eq ''}
&nbsp;
{else}
{$title}
{/if}
{* the short way *}
{$title|default:'&nbsp;'}
```
See also [`default`](../designers/language-modifiers/language-modifier-default.md) modifier and [default
variable handling](#default-variable-handling).
## Default Variable Handling
If a variable is used frequently throughout your templates, applying the
[`default`](../designers/language-modifiers/language-modifier-default.md) modifier every time it is
mentioned can get a bit ugly. You can remedy this by assigning the
variable its default value with the
[`{assign}`](../designers/language-builtin-functions/language-function-assign.md) function.
{* do this somewhere at the top of your template *}
{assign var='title' value=$title|default:'no title'}
{* if $title was empty, it now contains the value "no title" when you use it *}
{$title}
See also [`default`](../designers/language-modifiers/language-modifier-default.md) modifier and [blank
variable handling](#blank-variable-handling).
## Passing variable title to header template
When the majority of your templates use the same headers and footers, it
is common to split those out into their own templates and
[`{include}`](../designers/language-builtin-functions/language-function-include.md) them. But what if the header
needs to have a different title, depending on what page you are coming
from? You can pass the title to the header as an
[attribute](../designers/language-basic-syntax/language-syntax-attributes.md) when it is included.
`mainpage.tpl` - When the main page is drawn, the title of "Main Page"
is passed to the `header.tpl`, and will subsequently be used as the
title.
```smarty
{include file='header.tpl' title='Main Page'}
{* template body goes here *}
{include file='footer.tpl'}
```
`archives.tpl` - When the archives page is drawn, the title will be
"Archives". Notice in the archive example, we are using a variable from
the `archives_page.conf` file instead of a hard coded variable.
```smarty
{config_load file='archive_page.conf'}
{include file='header.tpl' title=#archivePageTitle#}
{* template body goes here *}
{include file='footer.tpl'}
```
`header.tpl` - Notice that "Smarty News" is printed if the `$title`
variable is not set, using the [`default`](../designers/language-modifiers/language-modifier-default.md)
variable modifier.
```smarty
<html>
<head>
<title>{$title|default:'Smarty News'}</title>
</head>
<body>
```
`footer.tpl`
```smarty
</body>
</html>
```
## Dates
As a rule of thumb, always pass dates to Smarty as
[timestamps](https://www.php.net/time). This allows template designers to
use the [`date_format`](../designers/language-modifiers/language-modifier-date-format.md) modifier for
full control over date formatting, and also makes it easy to compare
dates if necessary.
```smarty
{$startDate|date_format}
```
This will output:
```
Jan 4, 2009
```
```smarty
{$startDate|date_format:"%Y/%m/%d"}
```
This will output:
```
2009/01/04
```
Dates can be compared in the template by timestamps with:
```smarty
{if $order_date < $invoice_date}
...do something..
{/if}
```
When using [`{html_select_date}`](../designers/language-custom-functions/language-function-html-select-date.md)
in a template, the programmer will most likely want to convert the
output from the form back into timestamp format. Here is a function to
help you with that.
```php
<?php
// this assumes your form elements are named
// startDate_Day, startDate_Month, startDate_Year
$startDate = makeTimeStamp($startDate_Year, $startDate_Month, $startDate_Day);
function makeTimeStamp($year='', $month='', $day='')
{
if(empty($year)) {
$year = strftime('%Y');
}
if(empty($month)) {
$month = strftime('%m');
}
if(empty($day)) {
$day = strftime('%d');
}
return mktime(0, 0, 0, $month, $day, $year);
}
```
See also [`{html_select_date}`](../designers/language-custom-functions/language-function-html-select-date.md),
[`{html_select_time}`](../designers/language-custom-functions/language-function-html-select-time.md),
[`date_format`](../designers/language-modifiers/language-modifier-date-format.md) and
[`$smarty.now`](../designers/language-variables/language-variables-smarty.md#smarty-now),
## Componentized Templates
Traditionally, programming templates into your applications goes as
follows: First, you accumulate your variables within your PHP
application, (maybe with database queries.) Then, you instantiate your
Smarty object, [`assign()`](../programmers/api-functions/api-assign.md) the variables and
[`display()`](../programmers/api-functions/api-display.md) the template. So lets say for example we
have a stock ticker on our template. We would collect the stock data in
our application, then assign these variables in the template and display
it. Now wouldn't it be nice if you could add this stock ticker to any
application by merely including the template, and not worry about
fetching the data up front?
You can do this by writing a custom plugin for fetching the content and
assigning it to a template variable.
`function.load_ticker.php` - drop file in
[`$plugins directory`](../programmers/api-variables/variable-plugins-dir.md)
```php
<?php
// setup our function for fetching stock data
function fetch_ticker($symbol)
{
// put logic here that fetches $ticker_info
// from some ticker resource
return $ticker_info;
}
function smarty_function_load_ticker($params, $smarty)
{
// call the function
$ticker_info = fetch_ticker($params['symbol']);
// assign template variable
$smarty->assign($params['assign'], $ticker_info);
}
```
`index.tpl`
```smarty
{load_ticker symbol='SMARTY' assign='ticker'}
Stock Name: {$ticker.name} Stock Price: {$ticker.price}
```
See also: [`{include}`](../designers/language-builtin-functions/language-function-include.md).
## Obfuscating E-mail Addresses
Do you ever wonder how your email address gets on so many spam mailing
lists? One way spammers collect email addresses is from web pages. To
help combat this problem, you can make your email address show up in
scrambled javascript in the HTML source, yet it it will look and work
correctly in the browser. This is done with the
[`{mailto}`](../designers/language-custom-functions/language-function-mailto.md) plugin.
```smarty
<div id="contact">Send inquiries to
{mailto address=$EmailAddress encode='javascript' subject='Hello'}
</div>
```
> **Note**
>
> This method isn\'t 100% foolproof. A spammer could conceivably program
> his e-mail collector to decode these values, but not likely\....
> hopefully..yet \... wheres that quantum computer :-?.
See also [`escape`](../designers/language-modifiers/language-modifier-escape.md) modifier and
[`{mailto}`](../designers/language-custom-functions/language-function-mailto.md).
+104
View File
@@ -0,0 +1,104 @@
# Troubleshooting
## Smarty/PHP errors
Smarty can catch many errors such as missing tag attributes or malformed
variable names. If this happens, you will see an error similar to the
following:
```
Warning: Smarty: [in index.tpl line 4]: syntax error: unknown tag - '%blah'
in /path/to/smarty/Smarty.class.php on line 1041
Fatal error: Smarty: [in index.tpl line 28]: syntax error: missing section name
in /path/to/smarty/Smarty.class.php on line 1041
```
Smarty shows you the template name, the line number and the error. After
that, the error consists of the actual line number in the Smarty class
that the error occurred.
There are certain errors that Smarty cannot catch, such as missing close
tags. These types of errors usually end up in PHP compile-time parsing
errors.
`Parse error: parse error in /path/to/smarty/templates_c/index.tpl.php on line 75`
When you encounter a PHP parsing error, the error line number will
correspond to the compiled PHP script, NOT the template itself. Usually
you can look at the template and spot the syntax error. Here are some
common things to look for: missing close tags for
[`{if}{/if}`](../designers/language-builtin-functions/language-function-if.md) or
[`{section}{/section}`](../designers/language-builtin-functions/language-function-section.md),
or syntax of logic within an `{if}` tag. If you can\'t find the error, you might have to
open the compiled PHP file and go to the line number to figure out where
the corresponding error is in the template.
```
Warning: Smarty error: unable to read resource: "index.tpl" in...
```
or
```
Warning: Smarty error: unable to read resource: "site.conf" in...
```
- The [`$template_dir`](../programmers/api-variables/variable-template-dir.md) is incorrect, doesn't
exist or the file `index.tpl` is not in the `templates/` directory
- A [`{config_load}`](../designers/language-builtin-functions/language-function-config-load.md) function is
within a template (or [`configLoad()`](../programmers/api-functions/api-config-load.md) has been
called) and either [`$config_dir`](../programmers/api-variables/variable-config-dir.md) is
incorrect, does not exist or `site.conf` is not in the directory.
```
Fatal error: Smarty error: the $compile_dir 'templates_c' does not exist,
or is not a directory...
```
- Either the [`$compile_dir`](../programmers/api-variables/variable-compile-dir.md)is incorrectly
set, the directory does not exist, or `templates_c` is a file and
not a directory.
```
Fatal error: Smarty error: unable to write to $compile_dir '....
```
- The [`$compile_dir`](../programmers/api-variables/variable-compile-dir.md) is not writable by the
web server. See the bottom of the [installing
smarty](../getting-started.md#installation) page for more about permissions.
```
Fatal error: Smarty error: the $cache_dir 'cache' does not exist,
or is not a directory. in /..
```
- This means that [`$caching`](../programmers/api-variables/variable-caching.md) is enabled and
either; the [`$cache_dir`](../programmers/api-variables/variable-cache-dir.md) is incorrectly set,
the directory does not exist, or `cache/` is a file and not a
directory.
```
Fatal error: Smarty error: unable to write to $cache_dir '/...
```
- This means that [`$caching`](../programmers/api-variables/variable-caching.md) is enabled and the
[`$cache_dir`](../programmers/api-variables/variable-cache-dir.md) is not writable by the web
server. See the bottom of the [installing
smarty](../getting-started.md#installation) page for permissions.
```
Warning: filemtime(): stat failed for /path/to/smarty/cache/3ab50a623e65185c49bf17c63c90cc56070ea85c.one.tpl.php
in /path/to/smarty/libs/sysplugins/smarty_resource.php
```
- This means that your application registered a custom error handler
(using [set_error_handler()](https://www.php.net/set_error_handler))
which is not respecting the given `$errno` as it should. If, for
whatever reason, this is the desired behaviour of your custom error
handler, please call
[`muteExpectedErrors()`](../programmers/api-functions/api-mute-expected-errors.md) after you've
registered your custom error handler.
See also [debugging](../designers/chapter-debugging-console.md).
@@ -0,0 +1,40 @@
# Debugging Console
There is a debugging console included with Smarty. The console informs
you of all the [included](./language-builtin-functions/language-function-include.md) templates,
[assigned](../programmers/api-functions/api-assign.md) variables and
[config](./language-variables/language-config-variables.md) file variables for the current
invocation of the template. A template file named `debug.tpl` is
included with the distribution of Smarty which controls the formatting
of the console.
Set [`$debugging`](../programmers/api-variables/variable-debugging.md) to TRUE in Smarty, and if needed
set [`$debug_tpl`](../programmers/api-variables/variable-debug-template.md) to the template resource
path to `debug.tpl` (this is in [`SMARTY_DIR`](../programmers/smarty-constants.md) by
default). When you load the page, a Javascript console window will pop
up and give you the names of all the included templates and assigned
variables for the current page.
To see the available variables for a particular template, see the
[`{debug}`](./language-builtin-functions/language-function-debug.md) template function. To disable the
debugging console, set [`$debugging`](../programmers/api-variables/variable-debugging.md) to FALSE. You
can also temporarily turn on the debugging console by putting
`SMARTY_DEBUG` in the URL if you enable this option with
[`$debugging_ctrl`](../programmers/api-variables/variable-debugging-ctrl.md).
> **Note**
>
> The debugging console does not work when you use the
> [`fetch()`](../programmers/api-functions/api-fetch.md) API, only when using
> [`display()`](../programmers/api-functions/api-display.md). It is a set of javascript statements
> added to the very bottom of the generated template. If you do not like
> javascript, you can edit the `debug.tpl` template to format the output
> however you like. Debug data is not cached and `debug.tpl` info is not
> included in the output of the debug console.
> **Note**
>
> The load times of each template and config file are in seconds, or
> fractions thereof.
See also [troubleshooting](../appendixes/troubleshooting.md).
+74
View File
@@ -0,0 +1,74 @@
# Config Files
Config files are handy for designers to manage global template variables
from one file. One example is template colors. Normally if you wanted to
change the color scheme of an application, you would have to go through
each and every template file and change the colors. With a config file,
the colors can be kept in one place, and only one file needs to be
updated.
```ini
# global variables
pageTitle = "Main Menu"
bodyBgColor = #000000
tableBgColor = #000000
rowBgColor = #00ff00
[Customer]
pageTitle = "Customer Info"
[Login]
pageTitle = "Login"
focus = "username"
Intro = """This is a value that spans more
than one line. you must enclose
it in triple quotes."""
# hidden section
[.Database]
host=my.example.com
db=ADDRESSBOOK
user=php-user
pass=foobar
```
Values of [config file variables](./language-variables/language-config-variables.md) can be in
quotes, but not necessary. You can use either single or double quotes.
If you have a value that spans more than one line, enclose the entire
value with triple quotes \("""\). You can put comments into config
files by any syntax that is not a valid config file syntax. We recommend
using a `#` (hash) at the beginning of the line.
The example config file above has two sections. Section names are
enclosed in \[brackets\]. Section names can be arbitrary strings not
containing `[` or `]` symbols. The four variables at the top are global
variables, or variables not within a section. These variables are always
loaded from the config file. If a particular section is loaded, then the
global variables and the variables from that section are also loaded. If
a variable exists both as a global and in a section, the section
variable is used. If you name two variables the same within a section,
the last one will be used unless
[`$config_overwrite`](../programmers/api-variables/variable-config-overwrite.md) is disabled.
Config files are loaded into templates with the built-in template
function [`{config_load}`](./language-builtin-functions/language-function-config-load.md) or the API
[`configLoad()`](../programmers/api-functions/api-config-load.md) function.
You can hide variables or entire sections by prepending the variable
name or section name with a period(.) eg `[.hidden]`. This is useful if
your application reads the config files and gets sensitive data from
them that the template engine does not need. If you have third parties
doing template editing, you can be certain that they cannot read
sensitive data from the config file by loading it into the template.
Config files (or resources) are loaded by the same resource facilities
as templates. That means that a config file can also be loaded from a db
`$smarty->configLoad("db:my.conf")`.
See also [`{config_load}`](./language-builtin-functions/language-function-config-load.md),
[`$config_overwrite`](../programmers/api-variables/variable-config-overwrite.md),
[`$default_config_handler_func`](../programmers/api-variables/variable-default-config-handler-func.md),
[`getConfigVars()`](../programmers/api-functions/api-get-config-vars.md),
[`clearConfig()`](../programmers/api-functions/api-clear-config.md) and
[`configLoad()`](../programmers/api-functions/api-config-load.md)
@@ -0,0 +1,33 @@
# Basic Syntax
A simple Smarty template could look like this:
```smarty
<h1>{$title|escape}</h1>
<ul>
{foreach $cities as $city}
<li>{$city.name|escape} ({$city.population})</li>
{foreachelse}
<li>no cities found</li>
{/foreach}
</ul>
```
All Smarty template tags are enclosed within delimiters. By default
these are `{` and `}`, but they can be
[changed](../../programmers/api-variables/variable-left-delimiter.md).
For the examples in this manual, we will assume that you are using the
default delimiters. In Smarty, all content outside of delimiters is
displayed as static content, or unchanged. When Smarty encounters
template tags, it attempts to interpret them, and displays the
appropriate output in their place.
The basis components of the Smarty syntax are:
- [Comments](language-syntax-comments.md)
- [Variables](language-syntax-variables.md)
- [Functions](language-syntax-functions.md)
- [Attributes](language-syntax-attributes.md)
- [Quotes](language-syntax-quotes.md)
- [Math](language-math.md)
- [Escaping](language-escaping.md)
@@ -0,0 +1,79 @@
# Escaping Smarty parsing
It is sometimes desirable or even necessary to have Smarty ignore
sections it would otherwise parse. A classic example is embedding
Javascript or CSS code in a template. The problem arises as those
languages use the { and } characters which are also the default
[delimiters](../language-builtin-functions/language-function-ldelim.md) for Smarty.
> **Note**
>
> A good practice for avoiding escapement altogether is by separating
> your Javascript/CSS into their own files and use standard HTML methods
> to access them. This will also take advantage of browser script
> caching. When you need to embed Smarty variables/functions into your
> Javascript/CSS, then the following applies.
In Smarty templates, the { and } braces will be ignored so long as they
are surrounded by white space. This behavior can be disabled by setting
the Smarty class variable [`$auto_literal`](../../programmers/api-variables/variable-auto-literal.md) to
false.
## Examples
```smarty
<script>
// the following braces are ignored by Smarty
// since they are surrounded by whitespace
function foobar {
alert('foobar!');
}
// this one will need literal escapement
{literal}
function bazzy {alert('foobar!');}
{/literal}
</script>
```
[`{literal}..{/literal}`](../language-builtin-functions/language-function-literal.md) blocks are used
for escaping blocks of template logic. You can also escape the braces
individually with
[`{ldelim}`, `{rdelim}`](../language-builtin-functions/language-function-ldelim.md) tags or
[`{$smarty.ldelim}`,`{$smarty.rdelim}`](../language-variables/language-variables-smarty.md#smartyldelim-smartyrdelim-languagevariablessmartyldelim)
variables.
Smarty's default delimiters { and } cleanly represent presentational
content. However, if another set of delimiters suit your needs better,
you can change them with Smarty's
[`$left_delimiter`](../../programmers/api-variables/variable-left-delimiter.md) and
[`$right_delimiter`](../../programmers/api-variables/variable-right-delimiter.md) values.
> **Note**
>
> Changing delimiters affects ALL template syntax and escapement. Be
> sure to clear out cache and compiled files if you decide to change
> them.
```php
<?php
$smarty->left_delimiter = '<!--{';
$smarty->right_delimiter = '}-->';
$smarty->assign('foo', 'bar');
$smarty->assign('name', 'Albert');
$smarty->display('example.tpl');
```
Where the template is:
```smarty
Welcome <!--{$name}--> to Smarty
<script language="javascript">
var foo = <!--{$foo}-->;
function dosomething() {
alert("foo is " + foo);
}
dosomething();
</script>
```
@@ -0,0 +1,28 @@
# Math
Math can be applied directly to variable values.
## Examples
```smarty
{$foo+1}
{$foo*$bar}
{* some more complicated examples *}
{$foo->bar-$bar[1]*$baz->foo->bar()-3*7}
{if ($foo+$bar.test%$baz*134232+10+$b+10)}
{$foo|truncate:"`$fooTruncCount/$barTruncFactor-1`"}
{assign var="foo" value="`$foo+$bar`"}
```
> **Note**
>
> Although Smarty can handle some very complex expressions and syntax,
> it is a good rule of thumb to keep the template syntax minimal and
> focused on presentation. If you find your template syntax getting too
> complex, it may be a good idea to move the bits that do not deal
> explicitly with presentation to PHP by way of plugins or modifiers.
@@ -0,0 +1,49 @@
# Attributes
Most of the [functions](./language-syntax-functions.md) take attributes that
specify or modify their behavior. Attributes to Smarty functions are
much like HTML attributes. Static values don't have to be enclosed in
quotes, but it is required for literal strings. Variables with or
without modifiers may also be used, and should not be in quotes. You can
even use PHP function results, plugin results and complex expressions.
Some attributes require boolean values (TRUE or FALSE). These can be
specified as `true` and `false`. If an attribute has no value assigned
it gets the default boolean value of true.
## Examples
```smarty
{include file="header.tpl"}
{include file="header.tpl" nocache} // is equivalent to nocache=true
{include file="header.tpl" attrib_name="attrib value"}
{include file=$includeFile}
{include file=#includeFile# title="My Title"}
{assign var=foo value={counter}} // plugin result
{assign var=foo value=substr($bar,2,5)} // PHP function result
{assign var=foo value=$bar|strlen} // using modifier
{assign var=foo value=$buh+$bar|strlen} // more complex expression
{html_select_date display_days=true}
{mailto address="smarty@example.com"}
<select name="company_id">
{html_options options=$companies selected=$company_id}
</select>
```
> **Note**
>
> Although Smarty can handle some very complex expressions and syntax,
> it is a good rule of thumb to keep the template syntax minimal and
> focused on presentation. If you find your template syntax getting too
> complex, it may be a good idea to move the bits that do not deal
> explicitly with presentation to PHP by way of plugins or modifiers.
@@ -0,0 +1,69 @@
# Comments
Template comments are surrounded by asterisks, and that is surrounded by
the [delimiter](../../programmers/api-variables/variable-left-delimiter.md) tags like so:
## Examples
```smarty
{* this is a comment *}
```
Smarty comments are NOT displayed in the final output of the template,
unlike `<!-- HTML comments -->`. These are useful for making internal
notes in the templates which no one will see ;-)
```smarty
{* I am a Smarty comment, I don't exist in the compiled output *}
<html>
<head>
<title>{$title}</title>
</head>
<body>
{* another single line smarty comment *}
<!-- HTML comment that is sent to the browser -->
{* this multiline smarty
comment is
not sent to browser
*}
{*********************************************************
Multi line comment block with credits block
@ author: bg@example.com
@ maintainer: support@example.com
@ para: var that sets block style
@ css: the style output
**********************************************************}
{* The header file with the main logo and stuff *}
{include file='header.tpl'}
{* Dev note: the $includeFile var is assigned in foo.php script *}
<!-- Displays main content block -->
{include file=$includeFile}
{* this <select> block is redundant *}
{*
<select name="company">
{html_options options=$vals selected=$selected_id}
</select>
*}
<!-- Show header from affiliate is disabled -->
{* $affiliate|upper *}
{* you cannot nest comments *}
{*
<select name="company">
{* <option value="0">-- none -- </option> *}
{html_options options=$vals selected=$selected_id}
</select>
*}
</body>
</html>
```
@@ -0,0 +1,40 @@
# Functions
Every Smarty tag either prints a [variable](./language-syntax-variables.md) or
invokes some sort of function. These are processed and displayed by
enclosing the function and its [attributes](./language-syntax-attributes.md)
within delimiters like so: `{funcname attr1="val1" attr2="val2"}`.
## Examples
```smarty
{config_load file="colors.conf"}
{include file="header.tpl"}
{insert file="banner_ads.tpl" title="My Site"}
{if $logged_in}
Welcome, <span style="color:{#fontColor#}">{$name}!</span>
{else}
hi, {$name}
{/if}
{include file="footer.tpl"}
```
- Both [built-in functions](../language-builtin-functions/index.md) and [custom
functions](../language-custom-functions/index.md) have the same syntax within
templates.
- Built-in functions are the **inner** workings of Smarty, such as
[`{if}`](../language-builtin-functions/language-function-if.md),
[`{section}`](../language-builtin-functions/language-function-section.md) and
[`{strip}`](../language-builtin-functions/language-function-strip.md). There should be no need to
change or modify them.
- Custom functions are **additional** functions implemented via
[plugins](../../programmers/plugins.md). They can be modified to your liking, or you can
create new ones. [`{html_options}`](../language-custom-functions/language-function-html-options.md)
is an example of a custom function.
See also [`registerPlugin()`](../../programmers/api-functions/api-register-plugin.md)
@@ -0,0 +1,54 @@
# Embedding Vars in Double Quotes
- Smarty will recognize [assigned](../../programmers/api-functions/api-assign.md)
[variables](./language-syntax-variables.md) embedded in "double
quotes" so long as the variable name contains only numbers, letters
and under_scores. See [naming](https://www.php.net/language.variables)
for more detail.
- With any other characters, for example a period(.) or
`$object->reference`, then the variable must be surrounded by `` `backticks` ``.
- In addition, Smarty does allow embedded Smarty tags in double-quoted
strings. This is useful if you want to include variables with
modifiers, plugin or PHP function results.
## Examples
```smarty
{func var="test $foo test"} // sees $foo
{func var="test $foo_bar test"} // sees $foo_bar
{func var="test `$foo[0]` test"} // sees $foo[0]
{func var="test `$foo[bar]` test"} // sees $foo[bar]
{func var="test $foo.bar test"} // sees $foo (not $foo.bar)
{func var="test `$foo.bar` test"} // sees $foo.bar
{func var="test `$foo.bar` test"|escape} // modifiers outside quotes!
{func var="test {$foo|escape} test"} // modifiers inside quotes!
{func var="test {time()} test"} // PHP function result
{func var="test {counter} test"} // plugin result
{func var="variable foo is {if !$foo}not {/if} defined"} // Smarty block function
{* will replace $tpl_name with value *}
{include file="subdir/$tpl_name.tpl"}
{* does NOT replace $tpl_name *}
{include file='subdir/$tpl_name.tpl'} // vars require double quotes!
{* must have backticks as it contains a dot "." *}
{cycle values="one,two,`$smarty.config.myval`"}
{* must have backticks as it contains a dot "." *}
{include file="`$module.contact`.tpl"}
{* can use variable with dot syntax *}
{include file="`$module.$view`.tpl"}
```
> **Note**
>
> Although Smarty can handle some very complex expressions and syntax,
> it is a good rule of thumb to keep the template syntax minimal and
> focused on presentation. If you find your template syntax getting too
> complex, it may be a good idea to move the bits that do not deal
> explicitly with presentation to PHP by way of plugins or modifiers.
See also [`escape`](../language-modifiers/language-modifier-escape.md).
@@ -0,0 +1,109 @@
# Variables
Template variables start with the $dollar sign. They can contain
numbers, letters and underscores, much like a [PHP
variable](https://www.php.net/language.variables). You can reference arrays
by index numerically or non-numerically. Also reference object
properties and methods.
[Config file variables](../language-variables/language-config-variables.md) are an exception to
the \$dollar syntax and are instead referenced with surrounding
\#hashmarks\#, or via the [`$smarty.config`](../language-variables/language-variables-smarty.md#smartyconfig-languagevariablessmartyconfig) variable.
## Examples
```smarty
{$foo} <-- displaying a simple variable (non array/object)
{$foo[4]} <-- display the 5th element of a zero-indexed array
{$foo.bar} <-- display the "bar" key value of an array, similar to PHP $foo['bar']
{$foo.$bar} <-- display variable key value of an array, similar to PHP $foo[$bar]
{$foo->bar} <-- display the object property "bar"
{$foo->bar()} <-- display the return value of object method "bar"
{#foo#} <-- display the config file variable "foo"
{$smarty.config.foo} <-- synonym for {#foo#}
{$foo[bar]} <-- syntax only valid in a section loop, see {section}
{assign var=foo value='baa'}{$foo} <-- displays "baa", see {assign}
Many other combinations are allowed
{$foo.bar.baz}
{$foo.$bar.$baz}
{$foo[4].baz}
{$foo[4].$baz}
{$foo.bar.baz[4]}
{$foo->bar($baz,2,$bar)} <-- passing parameters
{"foo"} <-- static values are allowed
{* display the server variable "SERVER_NAME" ($_SERVER['SERVER_NAME'])*}
{$smarty.server.SERVER_NAME}
Math and embedding tags:
{$x+$y} // will output the sum of x and y.
{assign var=foo value=$x+$y} // in attributes
{$foo[$x+3]} // as array index
{$foo={counter}+3} // tags within tags
{$foo="this is message {counter}"} // tags within double quoted strings
Defining Arrays:
{assign var=foo value=[1,2,3]}
{assign var=foo value=['y'=>'yellow','b'=>'blue']}
{assign var=foo value=[1,[9,8],3]} // can be nested
Short variable assignment:
{$foo=$bar+2}
{$foo = strlen($bar)} // function in assignment
{$foo = myfunct( ($x+$y)*3 )} // as function parameter
{$foo.bar=1} // assign to specific array element
{$foo.bar.baz=1}
{$foo[]=1} // appending to an array
Smarty "dot" syntax (note: embedded {} are used to address ambiguities):
{$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
PHP-like syntax, alternative to "dot" syntax:
{$foo[1]} // normal access
{$foo['bar']}
{$foo['bar'][1]}
{$foo[$x+$x]} // index may contain any expression
{$foo[$bar[1]]} // nested index
{$foo[section_name]} // smarty {section} access, not array access!
Variable variables:
$foo // normal variable
$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.
Object chaining:
{$object->method1($x)->method2($y)}
Direct PHP function access:
{time()}
```
> **Note**
>
> Although Smarty can handle some very complex expressions and syntax,
> it is a good rule of thumb to keep the template syntax minimal and
> focused on presentation. If you find your template syntax getting too
> complex, it may be a good idea to move the bits that do not deal
> explicitly with presentation to PHP by way of plugins or modifiers.
Request variables such as `$_GET`, `$_SESSION`, etc are available via
the reserved [`$smarty`](../language-variables/language-variables-smarty.md) variable.
See also [`$smarty`](../language-variables/language-variables-smarty.md), [config
variables](../language-variables/language-config-variables.md)
[`{assign}`](../language-builtin-functions/language-function-assign.md) and [`assign()`](../../programmers/api-functions/api-assign.md).
@@ -0,0 +1,35 @@
# Built-in Functions
Smarty comes with several built-in functions. These built-in functions
are the integral part of the smarty template engine. They are compiled
into corresponding inline PHP code for maximum performance.
You cannot create your own [custom functions](../language-custom-functions/index.md) with the same name; and you
should not need to modify the built-in functions.
A few of these functions have an `assign` attribute which collects the
result the function to a named template variable instead of being
output; much like the [`{assign}`](language-function-assign.md) function.
- [{append}](language-function-append.md)
- [{assign} or {$var=...}](language-function-assign.md)
- [{block}](language-function-block.md)
- [{call}](language-function-call.md)
- [{capture}](language-function-capture.md)
- [{config_load}](language-function-config-load.md)
- [{debug}](language-function-debug.md)
- [{extends}](language-function-extends.md)
- [{for}](language-function-for.md)
- [{foreach}, {foreachelse}](language-function-foreach.md)
- [{function}](language-function-function.md)
- [{if}, {elseif}, {else}](language-function-if.md)
- [{include}](language-function-include.md)
- [{insert}](language-function-insert.md)
- [{ldelim}, {rdelim}](language-function-ldelim.md)
- [{literal}](language-function-literal.md)
- [{nocache}](language-function-nocache.md)
- [{section}, {sectionelse}](language-function-section.md)
- [{setfilter}](language-function-setfilter.md)
- [{strip}](language-function-strip.md)
- [{while}](language-function-while.md)
@@ -0,0 +1,49 @@
# {append}
`{append}` is used for creating or appending template variable arrays
**during the execution of a template**.
## Attributes
| Attribute | Required | Description |
|-----------|------------|----------------------------------------------------------------------------------------------------|
| var | | The name of the variable being assigned |
| value | | The value being assigned |
| index | (optional) | The index for the new array element. If not specified the value is append to the end of the array. |
| scope | (optional) | The scope of the assigned variable: parent, root or global. Defaults to local if omitted. |
## Option Flags
| Name | Description |
|---------|-----------------------------------------------------|
| nocache | Assigns the variable with the 'nocache' attribute |
> **Note**
>
> Assignment of variables in-template is essentially placing application
> logic into the presentation that may be better handled in PHP. Use at
> your own discretion.
## Examples
```smarty
{append var='name' value='Bob' index='first'}
{append var='name' value='Meyer' index='last'}
// or
{append 'name' 'Bob' index='first'} {* short-hand *}
{append 'name' 'Meyer' index='last'} {* short-hand *}
The first name is {$name.first}.<br>
The last name is {$name.last}.
```
The above example will output:
The first name is Bob.
The last name is Meyer.
See also [`append()`](#api.append) and
[`getTemplateVars()`](#api.get.template.vars).
@@ -0,0 +1,147 @@
# {assign}, {$var=...}
`{assign}` or `{$var=...}` is used for assigning template variables **during the
execution of a template**.
## Attributes of the {assign} syntax
| Attribute Name | Required | Description |
|----------------|------------|-----------------------------------------------------------------------|
| var | | The name of the variable being assigned |
| value | | The value being assigned |
| scope | (optional) | The scope of the assigned variable: \'parent\',\'root\' or \'global\' |
## Attributes of the {$var=...} syntax
| Attribute Name | Required | Description |
|----------------|------------|-----------------------------------------------------------------------|
| scope | (optional) | The scope of the assigned variable: \'parent\',\'root\' or \'global\' |
## Option Flags
| Name | Description |
|---------|---------------------------------------------------|
| nocache | Assigns the variable with the 'nocache' attribute |
> **Note**
>
> Assignment of variables in-template is essentially placing application
> logic into the presentation that may be better handled in PHP. Use at
> your own discretion.
## Examples
```smarty
{assign var="name" value="Bob"} {* or *}
{assign "name" "Bob"} {* short-hand, or *}
{$name='Bob'}
The value of $name is {$name}.
```
The above example will output:
```
The value of $name is Bob.
```
```smarty
{assign var="name" value="Bob" nocache} {* or *}
{assign "name" "Bob" nocache} {* short-hand, or *}
{$name='Bob' nocache}
The value of $name is {$name}.
```
The above example will output:
```
The value of $name is Bob.
```
```smarty
{assign var=running_total value=$running_total+$some_array[$row].some_value} {* or *}
{$running_total=$running_total+$some_array[row].some_value}
```
Variables assigned in the included template will be seen in the
including template.
```smarty
{include file="sub_template.tpl"}
{* display variable assigned in sub_template *}
{$foo}<br>
```
The template above includes the example `sub_template.tpl` below:
```smarty
{* foo will be known also in the including template *}
{assign var="foo" value="something" scope=parent}
{$foo="something" scope=parent}
{* bar is assigned only local in the including template *}
{assign var="bar" value="value"} {* or *}
{$var="value"}
```
You can assign a variable to root of the current root tree. The variable
is seen by all templates using the same root tree.
```smarty
{assign var=foo value="bar" scope="root"}
```
A global variable is seen by all templates.
```smarty
{assign var=foo value="bar" scope="global"} {* or *}
{assign "foo" "bar" scope="global"} {* short-hand, or *}
{$foo="bar" scope="global"}
```
To access `{assign}` variables from a php script use
[`getTemplateVars()`](../../programmers/api-functions/api-get-template-vars.md).
Here's the template that creates the variable `$foo`.
```smarty
{assign var="foo" value="Smarty"} {* or *}
{$foo="Smarty"}
```
The template variables are only available after/during template
execution as in the following script.
```php
<?php
// this will output nothing as the template has not been executed
echo $smarty->getTemplateVars('foo');
// fetch the template to a variable
$whole_page = $smarty->fetch('index.tpl');
// this will output 'smarty' as the template has been executed
echo $smarty->getTemplateVars('foo');
$smarty->assign('foo','Even smarter');
// this will output 'Even smarter'
echo $smarty->getTemplateVars('foo');
```
The following functions can also *optionally* assign template variables: [`{capture}`](#language.function.capture),
[`{include}`](#language.function.include),
[`{insert}`](#language.function.insert),
[`{counter}`](#language.function.counter),
[`{cycle}`](#language.function.cycle),
[`{eval}`](#language.function.eval),
[`{fetch}`](#language.function.fetch),
[`{math}`](#language.function.math) and
[`{textformat}`](#language.function.textformat).
See also [`{append}`](./language-function-append.md),
[`assign()`](#api.assign) and
[`getTemplateVars()`](#api.get.template.vars).
@@ -0,0 +1,201 @@
# {block}
`{block}` is used to define a named area of template source for template
inheritance. For details see section of [Template
Inheritance](../../programmers/advanced-features/advanced-features-template-inheritance.md).
The `{block}` template source area of a child template will replace the
corresponding areas in the parent template(s).
Optionally `{block}` areas of child and parent templates can be merged
into each other. You can append or prepend the parent `{block}` content
by using the `append` or `prepend` option flag with the child's `{block}`
definition. With `{$smarty.block.parent}` the `{block}` content of
the parent template can be inserted at any location of the child
`{block}` content. `{$smarty.block.child}` inserts the `{block}` content
of the child template at any location of the parent `{block}`.
`{blocks}'s` can be nested.
## Attributes
| Attribute Name | Required | Description |
|----------------|----------|----------------------------------------------------------------------------------------------------------------------|
| name | yes | The name of the template source block |
| assign | no | The name of variable to assign the output of the block to. |
> **Note**
>
> The assign attribute only works on the block that actually gets executed, so you may need
> to add it to each child block as well.
## Option Flags (in child templates only):
| Name | Description |
|---------|-----------------------------------------------------------------------------------------|
| append | The `{block}` content will be appended to the content of the parent template `{block}` |
| prepend | The `{block}` content will be prepended to the content of the parent template `{block}` |
| hide | Ignore the block content if no child block of same name is existing. |
| nocache | Disables caching of the `{block}` content |
## Examples
parent.tpl
```smarty
<html>
<head>
<title>{block name="title"}Default Title{/block}</title>
<title>{block "title"}Default Title{/block}</title> {* short-hand *}
</head>
</html>
```
child.tpl
```smarty
{extends file="parent.tpl"}
{block name="title"}
Page Title
{/block}
```
The result would look like
```html
<html>
<head>
<title>Page Title</title>
</head>
</html>
```
parent.tpl
```smarty
<html>
<head>
<title>{block name="title"}Title - {/block}</title>
</head>
</html>
```
child.tpl
```smarty
{extends file="parent.tpl"}
{block name="title" append}
Page Title
{/block}
```
The result would look like
```html
<html>
<head>
<title>Title - Page Title</title>
</head>
</html>
```
parent.tpl
```smarty
<html>
<head>
<title>{block name="title"} is my title{/block}</title>
</head>
</html>
```
child.tpl
```smarty
{extends file="parent.tpl"}
{block name="title" prepend}
Page Title
{/block}
```
The result would look like
```html
<html>
<head>
<title>Page title is my titel</title>
</head>
</html>
```
parent.tpl
```smarty
<html>
<head>
<title>{block name="title"}The {$smarty.block.child} was inserted here{/block}</title>
</head>
</html>
```
child.tpl
```smarty
{extends file="parent.tpl"}
{block name="title"}
Child Title
{/block}
```
The result would look like
```html
<html>
<head>
<title>The Child Title was inserted here</title>
</head>
</html>
```
parent.tpl
```smarty
<html>
<head>
<title>{block name="title"}Parent Title{/block}</title>
</head>
</html>
```
child.tpl
```smarty
{extends file="parent.tpl"}
{block name="title"}
You will see now - {$smarty.block.parent} - here
{/block}
```
The result would look like
```html
<html>
<head>
<title>You will see now - Parent Title - here</title>
</head>
</html>
```
See also [Template
Inheritance](../../programmers/advanced-features/advanced-features-template-inheritance.md),
[`$smarty.block.parent`](../language-variables/language-variables-smarty.md#smartyblockparent-languagevariablessmartyblockparent),
[`$smarty.block.child`](../language-variables/language-variables-smarty.md#smartyblockchild-languagevariablessmartyblockchild), and
[`{extends}`](./language-function-extends.md)
@@ -0,0 +1,77 @@
# {call}
`{call}` is used to call a template function defined by the
[`{function}`](./language-function-function.md) tag just like a plugin
function.
> **Note**
>
> Template functions are defined global. Since the Smarty compiler is a
> single-pass compiler, The `{call}` tag must
> be used to call a template function defined externally from the given
> template. Otherwise you can directly use the function as
> `{funcname ...}` in the template.
- The `{call}` tag must have the `name` attribute which contains the
name of the template function.
- Values for variables can be passed to the template function as
[attributes](../language-basic-syntax/language-syntax-attributes.md).
## Attributes
| Attribute Name | Required | Description |
|----------------|----------|------------------------------------------------------------------------------------------|
| name | Yes | The name of the template function |
| assign | No | The name of the variable that the output of called template function will be assigned to |
| [var ...] | No | variable to pass local to template function |
## Option Flags
| Name | Description |
|---------|--------------------------------------------|
| nocache | Call the template function in nocache mode |
## Examples
```smarty
{* define the function *}
{function name=menu level=0}
<ul class="level{$level}">
{foreach $data as $entry}
{if is_array($entry)}
<li>{$entry@key}</li>
{call name=menu data=$entry level=$level+1}
{else}
<li>{$entry}</li>
{/if}
{/foreach}
</ul>
{/function}
{* create an array to demonstrate *}
{$menu = ['item1','item2','item3' => ['item3-1','item3-2','item3-3' =>
['item3-3-1','item3-3-2']],'item4']}
{* run the array through the function *}
{call name=menu data=$menu}
{call menu data=$menu} {* short-hand *}
```
Will generate the following output
```
* item1
* item2
* item3
o item3-1
o item3-2
o item3-3
+ item3-3-1
+ item3-3-2
* item4
```
See also [`{function}`](./language-function-function.md).
@@ -0,0 +1,81 @@
# {capture}
`{capture}` is used to collect the output of the template between the
tags into a variable instead of displaying it. Any content between
`{capture name='foo'}` and `{/capture}` is collected into the variable
specified in the `name` attribute.
The captured content can be used in the template from the variable
[`$smarty.capture.foo`](../language-variables/language-variables-smarty.md#smartycapture-languagevariablessmartycapture) where "foo"
is the value passed in the `name` attribute. If you do not supply the
`name` attribute, then "default" will be used as the name ie
`$smarty.capture.default`.
`{capture}'s` can be nested.
## Attributes
| Attribute Name | Required | Description |
|----------------|----------|----------------------------------------------------------------------|
| name | Yes | The name of the captured block |
| assign | No | The variable name where to assign the captured output to |
| append | No | The name of an array variable where to append the captured output to |
## Option Flags
| Name | Description |
|---------|-----------------------------------------|
| nocache | Disables caching of this captured block |
> **Note**
>
> Be careful when capturing [`{insert}`](#language.function.insert)
> output. If you have [`$caching`](#caching) enabled and you have
> [`{insert}`](#language.function.insert) commands that you expect to
> run within cached content, do not capture this content.
## Examples
```smarty
{* we don't want to print a div tag unless content is displayed *}
{capture name="banner"}
{capture "banner"} {* short-hand *}
{include file="get_banner.tpl"}
{/capture}
{if $smarty.capture.banner ne ""}
<div id="banner">{$smarty.capture.banner}</div>
{/if}
```
This example demonstrates the capture function.
```smarty
{capture name=some_content assign=popText}
{capture some_content assign=popText} {* short-hand *}
The server is {$my_server_name|upper} at {$my_server_addr}<br>
Your ip is {$my_ip}.
{/capture}
<a href="#">{$popText}</a>
```
This example also demonstrates how multiple calls of capture can be used
to create an array with captured content.
```smarty
{capture append="foo"}hello{/capture}I say just {capture append="foo"}world{/capture}
{foreach $foo as $text}{$text} {/foreach}
```
The above example will output:
```
I say just hello world
```
See also [`$smarty.capture`](../language-variables/language-variables-smarty.md#smartycapture-languagevariablessmartycapture),
[`{eval}`](../language-custom-functions/language-function-eval.md),
[`{fetch}`](../language-custom-functions/language-function-fetch.md), [`fetch()`](../../programmers/api-functions/api-fetch.md) and
[`{assign}`](./language-function-assign.md).
@@ -0,0 +1,88 @@
# {config_load}
`{config_load}` is used for loading config
[`#variables#`](#language.config.variables) from a [configuration file](#config.files) into the template.
## Attributes
| Attribute Name | Required | Description |
|----------------|----------|---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| file | Yes | The name of the config file to include |
| section | No | The name of the section to load |
| scope | no | How the scope of the loaded variables are treated, which must be one of local, parent or global. local means variables are loaded into the local template context. parent means variables are loaded into both the local context and the parent template that called it. global means variables are available to all templates. |
## Examples
The `example.conf` file.
```ini
#this is config file comment
# global variables
pageTitle = "Main Menu"
bodyBgColor = #000000
tableBgColor = #000000
rowBgColor = #00ff00
#customer variables section
[Customer]
pageTitle = "Customer Info"
```
and the template
```smarty
{config_load file="example.conf"}
{config_load "example.conf"} {* short-hand *}
<html>
<title>{#pageTitle#|default:"No title"}</title>
<body bgcolor="{#bodyBgColor#}">
<table border="{#tableBorderSize#}" bgcolor="{#tableBgColor#}">
<tr bgcolor="{#rowBgColor#}">
<td>First</td>
<td>Last</td>
<td>Address</td>
</tr>
</table>
</body>
</html>
```
[Config Files](#config.files) may also contain sections. You can load
variables from within a section with the added attribute `section`. Note
that global config variables are always loaded along with section
variables, and same-named section variables overwrite the globals.
> **Note**
>
> Config file *sections* and the built-in template function called
> [`{section}`](../language-builtin-functions/language-function-section.md) have nothing to do with each
> other, they just happen to share a common naming convention.
```smarty
{config_load file='example.conf' section='Customer'}
{config_load 'example.conf' 'Customer'} {* short-hand *}
<html>
<title>{#pageTitle#}</title>
<body bgcolor="{#bodyBgColor#}">
<table border="{#tableBorderSize#}" bgcolor="{#tableBgColor#}">
<tr bgcolor="{#rowBgColor#}">
<td>First</td>
<td>Last</td>
<td>Address</td>
</tr>
</table>
</body>
</html>
```
See [`$config_overwrite`](../../programmers/api-variables/variable-config-overwrite.md) to create arrays
of config file variables.
See also the [config files](../config-files.md) page, [config variables](../language-variables/language-config-variables.md) page,
[`$config_dir`](../../programmers/api-variables/variable-config-dir.md),
[`getConfigVars()`](../../programmers/api-functions/api-get-config-vars.md) and
[`configLoad()`](../../programmers/api-functions/api-config-load.md).
@@ -0,0 +1,17 @@
# {debug}
`{debug}` dumps the debug console to the page. This works regardless of
the [debug](../chapter-debugging-console.md) settings in the php script.
Since this gets executed at runtime, this is only able to show the
[assigned](../../programmers/api-functions/api-assign.md) variables; not the templates that are in use.
However, you can see all the currently available variables within the
scope of a template.
If caching is enabled and a page is loaded from cache `{debug}` does
show only the variables which assigned for the cached page.
In order to see also the variables which have been locally assigned
within the template it does make sense to place the `{debug}` tag at the
end of the template.
See also the [debugging console page](../chapter-debugging-console.md).
@@ -0,0 +1,37 @@
# {extends}
`{extends}` tags are used in child templates in template inheritance for
extending parent templates. For details see section of [Template
Inheritance](../../programmers/advanced-features/advanced-features-template-inheritance.md).
- The `{extends}` tag must be on the first line of the template.
- If a child template extends a parent template with the `{extends}`
tag it may contain only `{block}` tags. Any other template content
is ignored.
- Use the syntax for [template resources](../../programmers/resources.md) to extend files
outside the [`$template_dir`](../../programmers/api-variables/variable-template-dir.md) directory.
## Attributes
| Attribute | Required | Description |
|-----------|----------|-------------------------------------------------|
| file | Yes | The name of the template file which is extended |
> **Note**
>
> When extending a variable parent like `{extends file=$parent_file}`,
> make sure you include `$parent_file` in the
> [`$compile_id`](../../programmers/api-variables/variable-compile-id.md). Otherwise, Smarty cannot
> distinguish between different `$parent_file`s.
## Examples
```smarty
{extends file='parent.tpl'}
{extends 'parent.tpl'} {* short-hand *}
```
See also [Template Inheritance](../../programmers/advanced-features/advanced-features-template-inheritance.md)
and [`{block}`](./language-function-block.md).
@@ -0,0 +1,91 @@
# {for}
The `{for}{forelse}` tag is used to create simple loops. The following different formats are supported:
- `{for $var=$start to $end}` simple loop with step size of 1.
- `{for $var=$start to $end step $step}` loop with individual step
size.
`{forelse}` is executed when the loop is not iterated.
## Attributes
| Attribute | Required | Description |
|-----------|----------|--------------------------------|
| max | No | Limit the number of iterations |
## Option Flags
| Name | Description |
|---------|--------------------------------------|
| nocache | Disables caching of the `{for}` loop |
## Examples
```smarty
<ul>
{for $foo=1 to 3}
<li>{$foo}</li>
{/for}
</ul>
```
The above example will output:
```html
<ul>
<li>1</li>
<li>2</li>
<li>3</li>
</ul>
```
```php
<?php
$smarty->assign('to',10);
```
```smarty
<ul>
{for $foo=3 to $to max=3}
<li>{$foo}</li>
{/for}
</ul>
```
The above example will output:
```html
<ul>
<li>3</li>
<li>4</li>
<li>5</li>
</ul>
```
```php
<?php
$smarty->assign('start',10);
$smarty->assign('to',5);
```
```smarty
<ul>
{for $foo=$start to $to}
<li>{$foo}</li>
{forelse}
no iteration
{/for}
</ul>
```
The above example will output:
```
no iteration
```
See also [`{foreach}`](./language-function-foreach.md),
[`{section}`](./language-function-section.md) and
[`{while}`](./language-function-while.md)
@@ -0,0 +1,389 @@
# {foreach},{foreachelse}
`{foreach}` is used for looping over arrays of data. `{foreach}` has a
simpler and cleaner syntax than the
[`{section}`](./language-function-section.md) loop, and can also loop over
associative arrays.
## Option Flags
| Name | Description |
|---------|------------------------------------------|
| nocache | Disables caching of the `{foreach}` loop |
## Examples
```smarty
{foreach $arrayvar as $itemvar}
{$itemvar|escape}
{/foreach}
{foreach $arrayvar as $keyvar=>$itemvar}
{$keyvar}: {$itemvar|escape}
{/foreach}
```
> **Note**
>
> This foreach syntax does not accept any named attributes. This syntax
> is new to Smarty 3, however the Smarty 2.x syntax
> `{foreach from=$myarray key="mykey" item="myitem"}` is still
> supported.
- `{foreach}` loops can be nested.
- The `array` variable, usually an array of values, determines the
number of times `{foreach}` will loop. You can also pass an integer
for arbitrary loops.
- `{foreachelse}` is executed when there are no values in the `array`
variable.
- `{foreach}` properties are [`@index`](#index),
[`@iteration`](#iteration),
[`@first`](#first),
[`@last`](#last),
[`@show`](#show),
[`@total`](#total).
- `{foreach}` constructs are [`{break}`](#break),
[`{continue}`](#continue).
- Instead of specifying the `key` variable you can access the current
key of the loop item by `{$item@key}` (see examples below).
> **Note**
>
> The `$var@property` syntax is new to Smarty 3, however when using the
> Smarty 2 `{foreach from=$myarray key="mykey" item="myitem"}` style
> syntax, the `$smarty.foreach.name.property` syntax is still supported.
> **Note**
>
> Although you can retrieve the array key with the syntax
> `{foreach $myArray as $myKey => $myValue}`, the key is always
> available as `$myValue@key` within the foreach loop.
```php
<?php
$arr = array('red', 'green', 'blue');
$smarty->assign('myColors', $arr);
```
Template to output `$myColors` in an un-ordered list
```smarty
<ul>
{foreach $myColors as $color}
<li>{$color}</li>
{/foreach}
</ul>
```
The above example will output:
```html
<ul>
<li>red</li>
<li>green</li>
<li>blue</li>
</ul>
```
```php
<?php
$people = array('fname' => 'John', 'lname' => 'Doe', 'email' => 'j.doe@example.com');
$smarty->assign('myPeople', $people);
```
Template to output `$myArray` as key/value pairs.
```smarty
<ul>
{foreach $myPeople as $value}
<li>{$value@key}: {$value}</li>
{/foreach}
</ul>
```
The above example will output:
```html
<ul>
<li>fname: John</li>
<li>lname: Doe</li>
<li>email: j.doe@example.com</li>
</ul>
```
Assign an array to Smarty, the key contains the key for each looped
value.
```php
<?php
$smarty->assign(
'contacts',
[
['phone' => '555-555-1234', 'fax' => '555-555-5678', 'cell' => '555-555-0357'],
['phone' => '800-555-4444', 'fax' => '800-555-3333', 'cell' => '800-555-2222'],
]
);
```
The template to output `$contact`.
```smarty
{* key always available as a property *}
{foreach $contacts as $contact}
{foreach $contact as $value}
{$value@key}: {$value}
{/foreach}
{/foreach}
{* accessing key the PHP syntax alternate *}
{foreach $contacts as $contact}
{foreach $contact as $key => $value}
{$key}: {$value}
{/foreach}
{/foreach}
```
Either of the above examples will output:
```
phone: 555-555-1234
fax: 555-555-5678
cell: 555-555-0357
phone: 800-555-4444
fax: 800-555-3333
cell: 800-555-2222
```
A database (PDO) example of looping over search results. This example is
looping over a PHP iterator instead of an array().
```php
<?php
include('Smarty.class.php');
$smarty = new Smarty;
$dsn = 'mysql:host=localhost;dbname=test';
$login = 'test';
$passwd = 'test';
// setting PDO to use buffered queries in mysql is
// important if you plan on using multiple result cursors
// in the template.
$db = new PDO($dsn, $login, $passwd, array(
PDO::MYSQL_ATTR_USE_BUFFERED_QUERY => true));
$res = $db->prepare("select * from users");
$res->execute();
$res->setFetchMode(PDO::FETCH_LAZY);
// assign to smarty
$smarty->assign('res',$res);
$smarty->display('index.tpl');?>
```
```smarty
{foreach $res as $r}
{$r.id}
{$r.name}
{foreachelse}
.. no results ..
{/foreach}
```
The above is assuming the results contain the columns named `id` and
`name`.
What is the advantage of an iterator vs. looping over a plain old array?
With an array, all the results are accumulated into memory before being
looped. With an iterator, each result is loaded/released within the
loop. This saves processing time and memory, especially for very large
result sets.
## @index
`index` contains the current array index, starting with zero.
```smarty
{* output empty row on the 4th iteration (when index is 3) *}
<table>
{foreach $items as $i}
{if $i@index eq 3}
{* put empty table row *}
<tr><td>nbsp;</td></tr>
{/if}
<tr><td>{$i.label}</td></tr>
{/foreach}
</table>
```
## @iteration
`iteration` contains the current loop iteration and always starts at
one, unlike [`index`](#index). It is incremented by one
on each iteration.
The *"is div by"* operator can be used to detect a specific iteration.
Here we bold-face the name every 4th iteration.
```smarty
{foreach $myNames as $name}
{if $name@iteration is div by 4}
<b>{$name}</b>
{/if}
{$name}
{/foreach}
```
The *"is even by"* and *"is odd by"* operators can be used to
alternate something every so many iterations. Choosing between even or
odd rotates which one starts. Here we switch the font color every 3rd
iteration.
```smarty
{foreach $myNames as $name}
{if $name@iteration is even by 3}
<span style="color: #000">{$name}</span>
{else}
<span style="color: #eee">{$name}</span>
{/if}
{/foreach}
```
This will output something similar to this:
```html
<span style="color: #000">...</span>
<span style="color: #000">...</span>
<span style="color: #000">...</span>
<span style="color: #eee">...</span>
<span style="color: #eee">...</span>
<span style="color: #eee">...</span>
<span style="color: #000">...</span>
<span style="color: #000">...</span>
<span style="color: #000">...</span>
<span style="color: #eee">...</span>
<span style="color: #eee">...</span>
<span style="color: #eee">...</span>
...
```
## @first
`first` is TRUE if the current `{foreach}` iteration is the initial one.
Here we display a table header row on the first iteration.
```smarty
{* show table header at first iteration *}
<table>
{foreach $items as $i}
{if $i@first}
<tr>
<th>key</td>
<th>name</td>
</tr>
{/if}
<tr>
<td>{$i@key}</td>
<td>{$i.name}</td>
</tr>
{/foreach}
</table>
```
## @last
`last` is set to TRUE if the current `{foreach}` iteration is the final
one. Here we display a horizontal rule on the last iteration.
```smarty
{* Add horizontal rule at end of list *}
{foreach $items as $item}
<a href="#{$item.id}">{$item.name}</a>{if $item@last}<hr>{else},{/if}
{foreachelse}
... no items to loop ...
{/foreach}
```
## @show
The show `show` property can be used after the execution of a
`{foreach}` loop to detect if data has been displayed or not. `show` is
a boolean value.
```smarty
<ul>
{foreach $myArray as $name}
<li>{$name}</li>
{/foreach}
</ul>
{if $name@show} do something here if the array contained data {/if}
```
## @total
`total` contains the number of iterations that this `{foreach}` will
loop. This can be used inside or after the `{foreach}`.
```smarty
{* show number of rows at end *}
{foreach $items as $item}
{$item.name}<hr/>
{if $item@last}
<div id="total">{$item@total} items</div>
{/if}
{foreachelse}
... no items to loop ...
{/foreach}
```
See also [`{section}`](./language-function-section.md),
[`{for}`](./language-function-for.md) and
[`{while}`](./language-function-while.md)
## {break}
`{break}` aborts the iteration of the array
```smarty
{$data = [1,2,3,4,5]}
{foreach $data as $value}
{if $value == 3}
{* abort iterating the array *}
{break}
{/if}
{$value}
{/foreach}
{*
prints: 1 2
*}
```
## {continue}
`{continue}` leaves the current iteration and begins with the next
iteration.
```smarty
{$data = [1,2,3,4,5]}
{foreach $data as $value}
{if $value == 3}
{* skip this iteration *}
{continue}
{/if}
{$value}
{/foreach}
{*
prints: 1 2 4 5
*}
```
@@ -0,0 +1,89 @@
# {function}
`{function}` is used to create functions within a template and call them
just like a plugin function. Instead of writing a plugin that generates
presentational content, keeping it in the template is often a more
manageable choice. It also simplifies data traversal, such as deeply
nested menus.
> **Note**
>
> Template functions are defined global. Since the Smarty compiler is a
> single-pass compiler, The [`{call}`](#language.function.call) tag must
> be used to call a template function defined externally from the given
> template. Otherwise, you can directly use the function as
> `{funcname ...}` in the template.
## Attributes
| Attribute Name | Required | Description |
|----------------|----------|---------------------------------------------------------------|
| name | Yes | The name of the template function |
| \[var \...\] | No | default variable value to pass local to the template function |
- The `{function}` tag must have the `name` attribute which contains
the name of the template function. A tag with this name can be
used to call the template function.
- Default values for variables can be passed to the template function
as [attributes](../language-basic-syntax/language-syntax-attributes.md). Like in PHP function
declarations you can only use scalar values as default. The default
values can be overwritten when the template function is being
called.
- You can use all variables from the calling template inside the
template function. Changes to variables or new created variables
inside the template function have local scope and are not visible
inside the calling template after the template function is executed.
> **Note**
>
> You can pass any number of parameter to the template function when it
> is called. The parameter variables must not be declared in the
> `{funcname ...}` tag unless you what to use default values. Default
> values must be scalar and can not be variable. Variables must be
> passed when the template is called.
## Examples
```smarty
{* define the function *}
{function name=menu level=0}
{function menu level=0} {* short-hand *}
<ul class="level{$level}">
{foreach $data as $entry}
{if is_array($entry)}
<li>{$entry@key}</li>
{menu data=$entry level=$level+1}
{else}
<li>{$entry}</li>
{/if}
{/foreach}
</ul>
{/function}
{* create an array to demonstrate *}
{$menu = ['item1','item2','item3' => ['item3-1','item3-2','item3-3' =>
['item3-3-1','item3-3-2']],'item4']}
{* run the array through the function *}
{menu data=$menu}
```
Will generate the following output
```
* item1
* item2
* item3
o item3-1
o item3-2
o item3-3
+ item3-3-1
+ item3-3-2
* item4
```
See also [`{call}`](./language-function-call.md)
@@ -0,0 +1,120 @@
# {if},{elseif},{else}
`{if}` statements in Smarty have much the same flexibility as PHP
[if](https://www.php.net/if) statements, with a few added features for the
template engine. Every `{if}` must be paired with a matching `{/if}`.
`{else}` and `{elseif}` are also permitted. All PHP conditionals and
functions are recognized, such as *\|\|*, *or*, *&&*, *and*,
*is_array()*, etc.
If security is enabled, only PHP functions from `$php_functions` property
of the security policy are allowed. See the
[Security](../../programmers/advanced-features/advanced-features-security.md) section for details.
The following is a list of recognized qualifiers, which must be
separated from surrounding elements by spaces. Note that items listed in
\[brackets\] are optional. PHP equivalents are shown where applicable.
## Qualifiers
| Qualifier | Alternates | Syntax Example | Meaning | PHP Equivalent |
|--------------------|------------|----------------------|--------------------------------|--------------------|
| == | eq | $a eq $b | equals | == |
| != | ne, neq | $a neq $b | not equals | != |
| > | gt | $a gt $b | greater than | > |
| < | lt | $a lt $b | less than | < |
| >= | gte, ge | $a ge $b | greater than or equal | >= |
| <= | lte, le | $a le $b | less than or equal | <= |
| === | | $a === 0 | check for identity | === |
| ! | not | not $a | negation (unary) | ! |
| % | mod | $a mod $b | modulo | % |
| is \[not\] div by | | $a is not div by 4 | divisible by | $a % $b == 0 |
| is \[not\] even | | $a is not even | \[not\] an even number (unary) | $a % 2 == 0 |
| is \[not\] even by | | $a is not even by $b | grouping level \[not\] even | ($a / $b) % 2 == 0 |
| is \[not\] odd | | $a is not odd | \[not\] an odd number (unary) | $a % 2 != 0 |
| is \[not\] odd by | | $a is not odd by $b | \[not\] an odd grouping | ($a / $b) % 2 != 0 |
## Examples
```smarty
{if $name eq 'Fred'}
Welcome Sir.
{elseif $name eq 'Wilma'}
Welcome Ma'am.
{else}
Welcome, whatever you are.
{/if}
{* an example with "or" logic *}
{if $name eq 'Fred' or $name eq 'Wilma'}
...
{/if}
{* same as above *}
{if $name == 'Fred' || $name == 'Wilma'}
...
{/if}
{* parenthesis are allowed *}
{if ( $amount < 0 or $amount > 1000 ) and $volume >= #minVolAmt#}
...
{/if}
{* you can also embed php function calls *}
{if count($var) gt 0}
...
{/if}
{* check for array. *}
{if is_array($foo) }
.....
{/if}
{* check for not null. *}
{if isset($foo) }
.....
{/if}
{* test if values are even or odd *}
{if $var is even}
...
{/if}
{if $var is odd}
...
{/if}
{if $var is not odd}
...
{/if}
{* test if var is divisible by 4 *}
{if $var is div by 4}
...
{/if}
{*
test if var is even, grouped by two. i.e.,
0=even, 1=even, 2=odd, 3=odd, 4=even, 5=even, etc.
*}
{if $var is even by 2}
...
{/if}
{* 0=even, 1=even, 2=even, 3=odd, 4=odd, 5=odd, etc. *}
{if $var is even by 3}
...
{/if}
{if isset($name) && $name == 'Blog'}
{* do something *}
{elseif $name == $foo}
{* do something *}
{/if}
{if is_array($foo) && count($foo) > 0}
{* do a foreach loop *}
{/if}
```
@@ -0,0 +1,187 @@
# {include}
`{include}` tags are used for including other templates in the current
template. Any variables available in the current template are also
available within the included template.
## Attributes
| Attribute Name | Required | Description |
|----------------|----------|--------------------------------------------------------------------------------------------|
| file | Yes | The name of the template file to include |
| assign | No | The name of the variable that the output of include will be assigned to |
| cache_lifetime | No | Enable caching of this subtemplate with an individual cache lifetime |
| compile_id | No | Compile this subtemplate with an individual compile_id |
| cache_id | No | Enable caching of this subtemplate with an individual cache_id |
| scope | No | Define the scope of all in the subtemplate assigned variables: 'parent','root' or 'global' |
| \[var \...\] | No | variable to pass local to template |
- The `{include}` tag must have the `file` attribute which contains
the template resource path.
- Setting the optional `assign` attribute specifies the template
variable that the output of `{include}` is assigned to, instead of
being displayed. Similar to [`{assign}`](./language-function-assign.md).
- Variables can be passed to included templates as
[attributes](../language-basic-syntax/language-syntax-attributes.md). Any variables explicitly
passed to an included template are only available within the scope
of the included file. Attribute variables override current template
variables, in the case when they are named the same.
- You can use all variables from the including template inside the
included template. But changes to variables or new created variables
inside the included template have local scope and are not visible
inside the including template after the `{include}` statement. This
default behaviour can be changed for all variables assigned in the
included template by using the scope attribute at the `{include}`
statement or for individual variables by using the scope attribute
at the [`{assign}`](./language-function-assign.md) statement. The later
is useful to return values from the included template to the
including template.
- Use the syntax for [template resources](../../programmers/resources.md) to `{include}`
files outside of the [`$template_dir`](../../programmers/api-variables/variable-template-dir.md)
directory.
## Option Flags
| Name | Description |
|---------|--------------------------------------------------------------------------------------|
| nocache | Disables caching of this subtemplate |
| caching | Enable caching of this subtemplate |
| inline | If set, merge the compile-code of the subtemplate into the compiled calling template |
## Examples
```smarty
<html>
<head>
<title>{$title}</title>
</head>
<body>
{include file='page_header.tpl'}
{* body of template goes here, the $tpl_name variable
is replaced with a value eg 'contact.tpl'
*}
{include file="$tpl_name.tpl"}
{* using shortform file attribute *}
{include 'page_footer.tpl'}
</body>
</html>
```
```smarty
{include 'links.tpl' title='Newest links' links=$link_array}
{* body of template goes here *}
{include 'footer.tpl' foo='bar'}
```
The template above includes the example `links.tpl` below
```smarty
<div id="box">
<h3>{$title}{/h3>
<ul>
{foreach from=$links item=l}
.. do stuff ...
</foreach}
</ul>
</div>
```
Variables assigned in the included template will be seen in the
including template.
```smarty
{include 'sub_template.tpl' scope=parent}
...
{* display variables assigned in sub_template *}
{$foo}<br>
{$bar}<br>
...
```
The template above includes the example `sub_template.tpl` below
```smarty
...
{assign var=foo value='something'}
{assign var=bar value='value'}
...
```
The included template will not be cached.
```smarty
{include 'sub_template.tpl' nocache}
...
```
In this example included template will be cached with an individual
cache lifetime of 500 seconds.
```smarty
{include 'sub_template.tpl' cache_lifetime=500}
...
```
In this example included template will be cached independent of the
global caching setting.
```smarty
{include 'sub_template.tpl' caching}
...
```
This example assigns the contents of `nav.tpl` to the `$navbar`
variable, which is then output at both the top and bottom of the page.
```smarty
<body>
{include 'nav.tpl' assign=navbar}
{include 'header.tpl' title='Smarty is cool'}
{$navbar}
{* body of template goes here *}
{$navbar}
{include 'footer.tpl'}
</body>
```
This example includes another template relative to the directory of the
current template.
```smarty
{include 'template-in-a-template_dir-directory.tpl'}
{include './template-in-same-directory.tpl'}
{include '../template-in-parent-directory.tpl'}
```
```smarty
{* absolute filepath *}
{include file='/usr/local/include/templates/header.tpl'}
{* absolute filepath (same thing) *}
{include file='file:/usr/local/include/templates/header.tpl'}
{* windows absolute filepath (MUST use "file:" prefix) *}
{include file='file:C:/www/pub/templates/header.tpl'}
{* include from template resource named "db" *}
{include file='db:header.tpl'}
{* include a $variable template - eg $module = 'contacts' *}
{include file="$module.tpl"}
{* wont work as its single quotes ie no variable substitution *}
{include file='$module.tpl'}
{* include a multi $variable template - eg amber/links.view.tpl *}
{include file="$style_dir/$module.$view.tpl"}
```
See also [`{insert}`](./language-function-insert.md), [template resources](../../programmers/resources.md) and
[componentized templates](../../appendixes/tips.md#componentized-templates).
@@ -0,0 +1,86 @@
# {insert}
> **Note**
>
> `{insert}` tags are deprecated from Smarty, and should not be used.
> Put your PHP logic in PHP scripts or plugin functions instead.
> As of Smarty 3.1 the `{insert}` tags are only available from
> [SmartyBC](#bc).
`{insert}` tags work much like [`{include}`](./language-function-include.md)
tags, except that `{insert}` tags are NOT cached when template
[caching](../../programmers/caching.md) is enabled. They will be executed on every
invocation of the template.
| Attribute Name | Required | Description |
|----------------|----------|----------------------------------------------------------------------------------|
| name | Yes | The name of the insert function (insert_`name`) or insert plugin |
| assign | No | The name of the template variable the output will be assigned to |
| script | No | The name of the php script that is included before the insert function is called |
| \[var \...\] | No | variable to pass to insert function |
## Examples
Let's say you have a template with a banner slot at the top of the
page. The banner can contain any mixture of HTML, images, flash, etc. so
we can't just use a static link here, and we don't want this contents
cached with the page. In comes the {insert} tag: the template knows
\#banner\_location\_id\# and \#site\_id\# values (gathered from a
[config file](../config-files.md)), and needs to call a function to get the
banner contents.
```smarty
{* example of fetching a banner *}
{insert name="getBanner" lid=#banner_location_id# sid=#site_id#}
{insert "getBanner" lid=#banner_location_id# sid=#site_id#} {* short-hand *}
```
In this example, we are using the name "getBanner" and passing the
parameters \#banner\_location\_id\# and \#site\_id\#. Smarty will look
for a function named insert\_getBanner() in your PHP application,
passing the values of \#banner\_location\_id\# and \#site\_id\# as the
first argument in an associative array. All {insert} function names in
your application must be prepended with "insert_" to remedy possible
function name-space conflicts. Your insert\_getBanner() function should
do something with the passed values and return the results. These
results are then displayed in the template in place of the {insert} tag.
In this example, Smarty would call this function:
insert_getBanner(array("lid" => "12345","sid" => "67890"));
and display the returned results in place of the {insert} tag.
- If you supply the `assign` attribute, the output of the `{insert}`
tag will be assigned to this template variable instead of being
output to the template.
> **Note**
>
> Assigning the output to a template variable isn't too useful with
> [caching](../../programmers/api-variables/variable-caching.md) enabled.
- If you supply the `script` attribute, this php script will be
included (only once) before the `{insert}` function is executed.
This is the case where the insert function may not exist yet, and a
php script must be included first to make it work.
The path can be either absolute, or relative to
[`$trusted_dir`](../../programmers/api-variables/variable-trusted-dir.md). If security is enabled,
then the script must be located in the `$trusted_dir` path of the
security policy. See the [Security](../../programmers/advanced-features/advanced-features-security.md)
section for details.
The Smarty object is passed as the second argument. This way you can
reference and modify information in the Smarty object from within the
`{insert}` function.
If no PHP script can be found Smarty is looking for a corresponding
insert plugin.
> **Note**
>
> It is possible to have portions of the template not cached. If you
> have [caching](../../programmers/api-variables/variable-caching.md) turned on, `{insert}` tags will not be
> cached. They will run dynamically every time the page is created, even
> within cached pages. This works good for things like banners, polls,
> live weather, search results, user feedback areas, etc.
See also [`{include}`](./language-function-include.md)
@@ -0,0 +1,51 @@
# {ldelim}, {rdelim}
`{ldelim}` and `{rdelim}` are used for [escaping](../language-basic-syntax/language-escaping.md)
template delimiters, by default **{** and **}**. You can also use
[`{literal}{/literal}`](./language-function-literal.md) to escape blocks of
text eg Javascript or CSS. See also the complementary
[`{$smarty.ldelim}`](../../programmers/api-variables/variable-left-delimiter.md).
```smarty
{* this will print literal delimiters out of the template *}
{ldelim}funcname{rdelim} is how functions look in Smarty!
```
The above example will output:
```
{funcname} is how functions look in Smarty!
```
Another example with some Javascript
```smarty
<script>
function foo() {ldelim}
... code ...
{rdelim}
</script>
```
will output
```html
<script>
function foo() {
.... code ...
}
</script>
```
```smarty
<script>
function myJsFunction(){ldelim}
alert("The server name\n{$smarty.server.SERVER_NAME|escape:javascript}\n{$smarty.server.SERVER_ADDR|escape:javascript}");
{rdelim}
</script>
<a href="javascript:myJsFunction()">Click here for Server Info</a>
```
See also [`{literal}`](./language-function-literal.md) and [escaping Smarty
parsing](../language-basic-syntax/language-escaping.md).
@@ -0,0 +1,34 @@
# {literal}
`{literal}` tags allow a block of data to be taken literally. This is
typically used around Javascript or stylesheet blocks where {curly
braces} would interfere with the template
[delimiter](../../programmers/api-variables/variable-left-delimiter.md) syntax. Anything within
`{literal}{/literal}` tags is not interpreted, but displayed as-is. If
you need template tags embedded in a `{literal}` block, consider using
[`{ldelim}{rdelim}`](./language-function-ldelim.md) to escape the individual
delimiters instead.
> **Note**
>
> `{literal}{/literal}` tags are normally not necessary, as Smarty
> ignores delimiters that are surrounded by whitespace. Be sure your
> javascript and CSS curly braces are surrounded by whitespace. This is
> new behavior to Smarty 3.
```smarty
<script>
// the following braces are ignored by Smarty
// since they are surrounded by whitespace
function myFoo {
alert('Foo!');
}
// this one will need literal escapement
{literal}
function myBar {alert('Bar!');}
{/literal}
</script>
```
See also [`{ldelim} {rdelim}`](./language-function-ldelim.md) and the
[escaping Smarty parsing](../language-basic-syntax/language-escaping.md) page.
@@ -0,0 +1,20 @@
# {nocache}
`{nocache}` is used to disable caching of a template section. Every
`{nocache}` must be paired with a matching `{/nocache}`.
> **Note**
>
> Be sure any variables used within a non-cached section are also
> assigned from PHP when the page is loaded from the cache.
```smarty
Today's date is
{nocache}
{$smarty.now|date_format}
{/nocache}
```
The above code will output the current date on a cached page.
See also the [caching section](../../programmers/caching.md).
@@ -0,0 +1,610 @@
# {section}, {sectionelse}
A `{section}` is for looping over **sequentially indexed arrays of
data**, unlike [`{foreach}`](./language-function-foreach.md) which is used
to loop over a **single associative array**. Every `{section}` tag must
be paired with a closing `{/section}` tag.
> **Note**
>
> The [`{foreach}`](./language-function-foreach.md) loop can do everything a
> {section} loop can do, and has a simpler and easier syntax. It is
> usually preferred over the {section} loop.
> **Note**
>
> {section} loops cannot loop over associative arrays, they must be
> numerically indexed, and sequential (0,1,2,\...). For associative
> arrays, use the [`{foreach}`](./language-function-foreach.md) loop.
## Attributes
| Attribute Name | Required | Description |
|----------------|----------|--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| name | Yes | The name of the section |
| loop | Yes | Value to determine the number of loop iterations |
| start | No | The index position that the section will begin looping. If the value is negative, the start position is calculated from the end of the array. For example, if there are seven values in the loop array and start is -2, the start index is 5. Invalid values (values outside of the length of the loop array) are automatically truncated to the closest valid value. Defaults to 0. |
| step | No | The step value that will be used to traverse the loop array. For example, step=2 will loop on index 0, 2, 4, etc. If step is negative, it will step through the array backwards. Defaults to 1. |
| max | No | Sets the maximum number of times the section will loop. |
| show | No | Determines whether to show this section (defaults to true) |
## Option Flags
| Name | Description |
|---------|------------------------------------------|
| nocache | Disables caching of the `{section}` loop |
- Required attributes are `name` and `loop`.
- The `name` of the `{section}` can be anything you like, made up of
letters, numbers and underscores, like [PHP
variables](https://www.php.net/language.variables).
- {section}'s can be nested, and the nested `{section}` names must be
unique from each other.
- The `loop` attribute, usually an array of values, determines the
number of times the `{section}` will loop. You can also pass an
integer as the loop value.
- When printing a variable within a `{section}`, the `{section}`
`name` must be given next to variable name within \[brackets\].
- `{sectionelse}` is executed when there are no values in the loop
variable.
- A `{section}` also has its own variables that handle `{section}`
properties. These properties are accessible as:
[`{$smarty.section.name.property}`](../language-variables/language-variables-smarty.md#smartysection-languagevariablessmartyloops)
where "name" is the attribute `name`.
- `{section}` properties are [`index`](#index),
[`index_prev`](#index_prev),
[`index_next`](#index_next),
[`iteration`](#iteration),
[`first`](#first),
[`last`](#last),
[`rownum`](#rownum),
[`loop`](#loop), [`show`](#show),
[`total`](#total).
[`assign()`](../../programmers/api-functions/api-assign.md) an array to Smarty
## Examples
```php
<?php
$data = [1000, 1001, 1002];
$smarty->assign('custid', $data);
```
The template that outputs the array
```smarty
{* this example will print out all the values of the $custid array *}
{section name=customer loop=$custid}
{section customer $custid} {* short-hand *}
id: {$custid[customer]}<br />
{/section}
<hr />
{* print out all the values of the $custid array reversed *}
{section name=foo loop=$custid step=-1}
{section foo $custid step=-1} {* short-hand *}
{$custid[foo]}<br />
{/section}
```
The above example will output:
```html
id: 1000<br />
id: 1001<br />
id: 1002<br />
<hr />
id: 1002<br />
id: 1001<br />
id: 1000<br />
```
```smarty
{section name=foo start=10 loop=20 step=2}
{$smarty.section.foo.index}
{/section}
<hr />
{section name=bar loop=21 max=6 step=-2}
{$smarty.section.bar.index}
{/section}
```
The above example will output:
```html
10 12 14 16 18
<hr />
20 18 16 14 12 10
```
The `name` of the `{section}` can be anything you like, see [PHP
variables](https://www.php.net/language.variables). It is used to reference
the data within the `{section}`.
```smarty
{section name=anything loop=$myArray}
{$myArray[anything].foo}
{$name[anything]}
{$address[anything].bar}
{/section}
```
This is an example of printing an associative array of data with a
`{section}`. Following is the php script to assign the `$contacts` array
to Smarty.
```php
<?php
$data = [
['name' => 'John Smith', 'home' => '555-555-5555',
'cell' => '666-555-5555', 'email' => 'john@myexample.com'],
['name' => 'Jack Jones', 'home' => '777-555-5555',
'cell' => '888-555-5555', 'email' => 'jack@myexample.com'],
['name' => 'Jane Munson', 'home' => '000-555-5555',
'cell' => '123456', 'email' => 'jane@myexample.com']
];
$smarty->assign('contacts',$data);
```
The template to output `$contacts`
```smarty
{section name=customer loop=$contacts}
<p>
name: {$contacts[customer].name}<br />
home: {$contacts[customer].home}<br />
cell: {$contacts[customer].cell}<br />
e-mail: {$contacts[customer].email}
</p>
{/section}
```
The above example will output:
```html
<p>
name: John Smith<br />
home: 555-555-5555<br />
cell: 666-555-5555<br />
e-mail: john@myexample.com
</p>
<p>
name: Jack Jones<br />
home phone: 777-555-5555<br />
cell phone: 888-555-5555<br />
e-mail: jack@myexample.com
</p>
<p>
name: Jane Munson<br />
home phone: 000-555-5555<br />
cell phone: 123456<br />
e-mail: jane@myexample.com
</p>
```
This example assumes that `$custid`, `$name` and `$address` are all
arrays containing the same number of values. First the php script that
assign's the arrays to Smarty.
```php
<?php
$id = [1001,1002,1003];
$smarty->assign('custid',$id);
$fullnames = ['John Smith','Jack Jones','Jane Munson'];
$smarty->assign('name',$fullnames);
$addr = ['253 Abbey road', '417 Mulberry ln', '5605 apple st'];
$smarty->assign('address',$addr);
```
The `loop` variable only determines the number of times to loop. You can
access ANY variable from the template within the `{section}`. This is
useful for looping multiple arrays. You can pass an array which will
determine the loop count by the array size, or you can pass an integer
to specify the number of loops.
```smarty
{section name=customer loop=$custid}
<p>
id: {$custid[customer]}<br />
name: {$name[customer]}<br />
address: {$address[customer]}
</p>
{/section}
```
The above example will output:
```html
<p>
id: 1000<br />
name: John Smith<br />
address: 253 Abbey road
</p>
<p>
id: 1001<br />
name: Jack Jones<br />
address: 417 Mulberry ln
</p>
<p>
id: 1002<br />
name: Jane Munson<br />
address: 5605 apple st
</p>
```
{section}'s can be nested as deep as you like. With nested
{section}'s, you can access complex data structures, such as
multidimensional arrays. This is an example `.php` script that
assigns the arrays.
```php
<?php
$id = [1001,1002,1003];
$smarty->assign('custid',$id);
$fullnames = ['John Smith','Jack Jones','Jane Munson'];
$smarty->assign('name',$fullnames);
$addr = ['253 N 45th', '417 Mulberry ln', '5605 apple st'];
$smarty->assign('address',$addr);
$types = [
[ 'home phone', 'cell phone', 'e-mail'],
[ 'home phone', 'web'],
[ 'cell phone']
];
$smarty->assign('contact_type', $types);
$info = [
['555-555-5555', '666-555-5555', 'john@myexample.com'],
[ '123-456-4', 'www.example.com'],
[ '0457878']
];
$smarty->assign('contact_info', $info);
```
In this template, *$contact_type\[customer\]* is an array of contact
types for the current customer.
```smarty
{section name=customer loop=$custid}
<hr>
id: {$custid[customer]}<br />
name: {$name[customer]}<br />
address: {$address[customer]}<br />
{section name=contact loop=$contact_type[customer]}
{$contact_type[customer][contact]}: {$contact_info[customer][contact]}<br />
{/section}
{/section}
```
The above example will output:
```html
<hr>
id: 1000<br />
name: John Smith<br />
address: 253 N 45th<br />
home phone: 555-555-5555<br />
cell phone: 666-555-5555<br />
e-mail: john@myexample.com<br />
<hr>
id: 1001<br />
name: Jack Jones<br />
address: 417 Mulberry ln<br />
home phone: 123-456-4<br />
web: www.example.com<br />
<hr>
id: 1002<br />
name: Jane Munson<br />
address: 5605 apple st<br />
cell phone: 0457878<br />
```
Results of a database search (eg ADODB or PEAR) are assigned to Smarty
```php
<?php
$sql = 'select id, name, home, cell, email from contacts '
."where name like '$foo%' ";
$smarty->assign('contacts', $db->getAll($sql));
```
The template to output the database result in a HTML table
```smarty
<table>
<tr><th>&nbsp;</th><th>Name></th><th>Home</th><th>Cell</th><th>Email</th></tr>
{section name=co loop=$contacts}
<tr>
<td><a href="view.php?id={$contacts[co].id}">view<a></td>
<td>{$contacts[co].name}</td>
<td>{$contacts[co].home}</td>
<td>{$contacts[co].cell}</td>
<td>{$contacts[co].email}</td>
<tr>
{sectionelse}
<tr><td colspan="5">No items found</td></tr>
{/section}
</table>
```
## .index
`index` contains the current array index, starting with zero or the
`start` attribute if given. It increments by one or by the `step`
attribute if given.
> **Note**
>
> If the `step` and `start` properties are not modified, then this works
> the same as the [`iteration`](#iteration) property,
> except it starts at zero instead of one.
> **Note**
>
> `$custid[customer.index]` and `$custid[customer]` are identical.
```smarty
{section name=customer loop=$custid}
{$smarty.section.customer.index} id: {$custid[customer]}<br />
{/section}
```
The above example will output:
```html
0 id: 1000<br />
1 id: 1001<br />
2 id: 1002<br />
```
## .index_prev
`index_prev` is the previous loop index. On the first loop, this is set to -1.
## .index_next
`index_next` is the next loop index. On the last loop, this is still one
more than the current index, respecting the setting of the `step`
attribute, if given.
```php
<?php
$data = [1001,1002,1003,1004,1005];
$smarty->assign('rows',$data);
```
Template to output the above array in a table
```smarty
{* $rows[row.index] and $rows[row] are identical in meaning *}
<table>
<tr>
<th>index</th><th>id</th>
<th>index_prev</th><th>prev_id</th>
<th>index_next</th><th>next_id</th>
</tr>
{section name=row loop=$rows}
<tr>
<td>{$smarty.section.row.index}</td><td>{$rows[row]}</td>
<td>{$smarty.section.row.index_prev}</td><td>{$rows[row.index_prev]}</td>
<td>{$smarty.section.row.index_next}</td><td>{$rows[row.index_next]}</td>
</tr>
{/section}
</table>
```
The above example will output a table containing the following:
```
index id index_prev prev_id index_next next_id
0 1001 -1 1 1002
1 1002 0 1001 2 1003
2 1003 1 1002 3 1004
3 1004 2 1003 4 1005
4 1005 3 1004 5
```
## .iteration
`iteration` contains the current loop iteration and starts at one.
> **Note**
>
> This is not affected by the `{section}` properties `start`, `step` and
> `max`, unlike the [`index`](#index) property.
> `iteration` also starts with one instead of zero unlike `index`.
> [`rownum`](#rownum) is an alias to `iteration`, they
> are identical.
```php
<?php
// array of 3000 to 3015
$id = range(3000,3015);
$smarty->assign('arr', $id);
```
Template to output every other element of the `$arr` array as `step=2`
```smarty
{section name=cu loop=$arr start=5 step=2}
iteration={$smarty.section.cu.iteration}
index={$smarty.section.cu.index}
id={$custid[cu]}<br />
{/section}
```
The above example will output:
```html
iteration=1 index=5 id=3005<br />
iteration=2 index=7 id=3007<br />
iteration=3 index=9 id=3009<br />
iteration=4 index=11 id=3011<br />
iteration=5 index=13 id=3013<br />
iteration=6 index=15 id=3015<br />
```
Another example that uses the `iteration` property to output a table
header block every five rows.
```smarty
<table>
{section name=co loop=$contacts}
{if $smarty.section.co.iteration is div by 5}
<tr><th>&nbsp;</th><th>Name></th><th>Home</th><th>Cell</th><th>Email</th></tr>
{/if}
<tr>
<td><a href="view.php?id={$contacts[co].id}">view<a></td>
<td>{$contacts[co].name}</td>
<td>{$contacts[co].home}</td>
<td>{$contacts[co].cell}</td>
<td>{$contacts[co].email}</td>
<tr>
{/section}
</table>
```
An example that uses the `iteration` property to alternate a text color every
third row.
```smarty
<table>
{section name=co loop=$contacts}
{if $smarty.section.co.iteration is even by 3}
<span style="color: #ffffff">{$contacts[co].name}</span>
{else}
<span style="color: #dddddd">{$contacts[co].name}</span>
{/if}
{/section}
</table>
```
> **Note**
>
> The *"is div by"* syntax is a simpler alternative to the PHP mod
> operator syntax. The mod operator is allowed:
> `{if $smarty.section.co.iteration % 5 == 1}` will work just the same.
> **Note**
>
> You can also use *"is odd by"* to reverse the alternating.
## .first
`first` is set to TRUE if the current `{section}` iteration is the initial one.
## .last
`last` is set to TRUE if the current section iteration is the final one.
This example loops the `$customers` array, outputs a header block on the
first iteration and on the last outputs the footer block. Also uses the
[`total`](#total) property.
```smarty
{section name=customer loop=$customers}
{if $smarty.section.customer.first}
<table>
<tr><th>id</th><th>customer</th></tr>
{/if}
<tr>
<td>{$customers[customer].id}}</td>
<td>{$customers[customer].name}</td>
</tr>
{if $smarty.section.customer.last}
<tr><td></td><td>{$smarty.section.customer.total} customers</td></tr>
</table>
{/if}
{/section}
```
## .rownum
`rownum` contains the current loop iteration, starting with one. It is
an alias to [`iteration`](#iteration), they work
identically.
## .loop
`loop` contains the last index number that this {section} looped. This
can be used inside or after the `{section}`.
```smarty
{section name=customer loop=$custid}
{$smarty.section.customer.index} id: {$custid[customer]}<br />
{/section}
There are {$smarty.section.customer.loop} customers shown above.
```
The above example will output:
```html
0 id: 1000<br />
1 id: 1001<br />
2 id: 1002<br />
There are 3 customers shown above.
```
## .show
`show` is used as a parameter to section and is a boolean value. If
FALSE, the section will not be displayed. If there is a `{sectionelse}`
present, that will be alternately displayed.
Boolean `$show_customer_info` has been passed from the PHP application,
to regulate whether this section shows.
```smarty
{section name=customer loop=$customers show=$show_customer_info}
{$smarty.section.customer.rownum} id: {$customers[customer]}<br />
{/section}
{if $smarty.section.customer.show}
the section was shown.
{else}
the section was not shown.
{/if}
```
The above example will output:
```html
1 id: 1000<br />
2 id: 1001<br />
3 id: 1002<br />
the section was shown.
```
## .total
`total` contains the number of iterations that this `{section}` will
loop. This can be used inside or after a `{section}`.
```smarty
{section name=customer loop=$custid step=2}
{$smarty.section.customer.index} id: {$custid[customer]}<br />
{/section}
There are {$smarty.section.customer.total} customers shown above.
```
See also [`{foreach}`](./language-function-foreach.md),
[`{for}`](./language-function-for.md), [`{while}`](./language-function-while.md)
and [`$smarty.section`](../language-variables/language-variables-smarty.md#smartysection-languagevariablessmartyloops).
@@ -0,0 +1,43 @@
# {setfilter}
The `{setfilter}...{/setfilter}` block tag allows the definition of
template instance's variable filters.
SYNTAX: `{setfilter filter1\|filter2\|filter3\....}\...{/setfilter}`
The filter can be:
- A variable filter plugin specified by it's name.
- A modifier specified by it's name and optional additional
parameter.
`{setfilter}...{/setfilter}` blocks can be nested. The filter definition
of inner blocks does replace the definition of the outer block.
Template instance filters run in addition to other modifiers and
filters. They run in the following order: modifier, default_modifier,
$escape_html, registered variable filters, autoloaded variable
filters, template instance's variable filters. Everything after
default_modifier can be disabled with the `nofilter` flag.
> **Note**
>
> The setting of template instance filters does not affect the output of
> included subtemplates.
## Examples
```smarty
<script>
{setfilter filter1}
{$foo} {* filter1 runs on output of $foo *}
{setfilter filter2|mod:true}
{$bar} {* filter2 and modifier mod runs on output of $bar *}
{/setfilter}
{$buh} {* filter1 runs on output of $buh *}
{/setfilter}
{$blar} {* no template instance filter runs on output of $blar}
</script>
```
@@ -0,0 +1,45 @@
# {strip}
Many times web designers run into the issue where white space and
carriage returns affect the output of the rendered HTML (browser
"features"), so you must run all your tags together in the template to
get the desired results. This usually ends up in unreadable or
unmanageable templates.
Anything within `{strip}{/strip}` tags are stripped of the extra spaces
or carriage returns at the beginnings and ends of the lines before they
are displayed. This way you can keep your templates readable, and not
worry about extra white space causing problems.
> **Note**
>
> `{strip}{/strip}` does not affect the contents of template variables,
> see the [strip modifier](../language-modifiers/language-modifier-strip.md) instead.
```smarty
{* the following will be all run into one line upon output *}
{strip}
<table>
<tr>
<td>
<a href="#">
This is a test
</a>
</td>
</tr>
</table>
{/strip}
```
The above example will output:
```html
<table><tr><td><a href="#">This is a test</a></td></tr></table>
```
Notice that in the above example, all the lines begin and end with HTML
tags. Be aware that all the lines are run together. If you have plain
text at the beginning or end of any line, they will be run together, and
may not be desired results.
See also the [`strip`](../language-modifiers/language-modifier-strip.md) modifier.
@@ -0,0 +1,43 @@
# {while}
`{while}` loops in Smarty have much the same flexibility as PHP
[while](https://www.php.net/while) statements, with a few added features for
the template engine. Every `{while}` must be paired with a matching
`{/while}`. All PHP conditionals and functions are recognized, such as
*\|\|*, *or*, *&&*, *and*, *is_array()*, etc.
The following is a list of recognized qualifiers, which must be
separated from surrounding elements by spaces. Note that items listed in
\[brackets\] are optional. PHP equivalents are shown where applicable.
## Qualifiers
| Qualifier | Alternates | Syntax Example | Meaning | PHP Equivalent |
|--------------------|------------|----------------------|--------------------------------|--------------------|
| == | eq | $a eq $b | equals | == |
| != | ne, neq | $a neq $b | not equals | != |
| > | gt | $a gt $b | greater than | > |
| < | lt | $a lt $b | less than | < |
| >= | gte, ge | $a ge $b | greater than or equal | >= |
| <= | lte, le | $a le $b | less than or equal | <= |
| === | | $a === 0 | check for identity | === |
| ! | not | not $a | negation (unary) | ! |
| % | mod | $a mod $b | modulo | % |
| is \[not\] div by | | $a is not div by 4 | divisible by | $a % $b == 0 |
| is \[not\] even | | $a is not even | \[not\] an even number (unary) | $a % 2 == 0 |
| is \[not\] even by | | $a is not even by $b | grouping level \[not\] even | ($a / $b) % 2 == 0 |
| is \[not\] odd | | $a is not odd | \[not\] an odd number (unary) | $a % 2 != 0 |
| is \[not\] odd by | | $a is not odd by $b | \[not\] an odd grouping | ($a / $b) % 2 != 0 |
## Examples
```smarty
{while $foo > 0}
{$foo--}
{/while}
```
The above example will count down the value of $foo until 1 is reached.
See also [`{foreach}`](./language-function-foreach.md),
[`{for}`](./language-function-for.md) and
[`{section}`](./language-function-section.md).
@@ -0,0 +1,32 @@
# Combining Modifiers
You can apply any number of modifiers to a variable. They will be
applied in the order they are combined, from left to right. They must be
separated with a `|` (pipe) character.
```php
<?php
$smarty->assign('articleTitle', 'Smokers are Productive, but Death Cuts Efficiency.');
```
where template is:
```smarty
{$articleTitle}
{$articleTitle|upper|spacify}
{$articleTitle|lower|spacify|truncate}
{$articleTitle|lower|truncate:30|spacify}
{$articleTitle|lower|spacify|truncate:30:". . ."}
```
The above example will output:
```
Smokers are Productive, but Death Cuts Efficiency.
S M O K E R S A R ....snip.... H C U T S E F F I C I E N C Y .
s m o k e r s a r ....snip.... b u t d e a t h c u t s...
s m o k e r s a r e p r o d u c t i v e , b u t . . .
s m o k e r s a r e p. . .
```
@@ -0,0 +1,19 @@
# Custom Functions
Smarty comes with several custom plugin functions that you can use in
the templates.
- [{counter}](language-function-counter.md)
- [{cycle}](language-function-cycle.md)
- [{eval}](language-function-eval.md)
- [{fetch}](language-function-fetch.md)
- [{html_checkboxes}](language-function-html-checkboxes.md)
- [{html_image}](language-function-html-image.md)
- [{html_options}](language-function-html-options.md)
- [{html_radios}](language-function-html-radios.md)
- [{html_select_date}](language-function-html-select-date.md)
- [{html_select_time}](language-function-html-select-time.md)
- [{html_table}](language-function-html-table.md)
- [{mailto}](language-function-mailto.md)
- [{math}](language-function-math.md)
- [{textformat}](language-function-textformat.md)
@@ -0,0 +1,45 @@
# {counter}
`{counter}` is used to print out a count. `{counter}` will remember the
count on each iteration. You can adjust the number, the interval and the
direction of the count, as well as determine whether to print the
value. You can run multiple counters concurrently by supplying a unique
name for each one. If you do not supply a name, the name "default" will
be used.
## Attributes
| Attribute Name | Required | Description |
|----------------|----------|-----------------------------------------------------------|
| name | No | The name of the counter |
| start | No | The initial number to start counting from (defaults to 1) |
| skip | No | The interval to count by (defaults to 1) |
| direction | No | The direction to count (up/down) (defaults to 'up') |
| print | No | Whether or not to print the value (defaults to true) |
| assign | No | the template variable the output will be assigned to |
If you supply the `assign` attribute, the output of the `{counter}`
function will be assigned to this template variable instead of being
output to the template.
## Examples
```smarty
{* initialize the count *}
{counter start=0 skip=2}<br />
{counter}<br />
{counter}<br />
{counter}<br />
```
this will output:
```html
0<br />
2<br />
4<br />
6<br />
```
@@ -0,0 +1,55 @@
# {cycle}
`{cycle}` is used to alternate a set of values. This makes it easy to
for example, alternate between two or more colors in a table, or cycle
through an array of values.
## Attributes
| Attribute Name | Required | Description |
|----------------|----------|-------------------------------------------------------------------------------------------------------------|
| name | No | The name of the cycle |
| values | Yes | The values to cycle through, either a comma delimited list (see delimiter attribute), or an array of values |
| print | No | Whether to print the value or not (defaults to true) |
| advance | No | Whether or not to advance to the next value (defaults to true) |
| delimiter | No | The delimiter to use in the values attribute (defaults to ',') |
| assign | No | The template variable the output will be assigned to |
| reset | No | The cycle will be set to the first value and not advanced (defaults to false) |
- You can `{cycle}` through more than one set of values in a template
by supplying a `name` attribute. Give each `{cycle}` a unique
`name`.
- You can force the current value not to print with the `print`
attribute set to FALSE. This would be useful for silently skipping a
value.
- The `advance` attribute is used to repeat a value. When set to
FALSE, the next call to `{cycle}` will print the same value.
- If you supply the `assign` attribute, the output of the `{cycle}`
function will be assigned to a template variable instead of being
output to the template.
## Examples
```smarty
{section name=rows loop=$data}
<tr class="{cycle values="odd,even"}">
<td>{$data[rows]}</td>
</tr>
{/section}
```
The above template would output:
```html
<tr class="odd">
<td>1</td>
</tr>
<tr class="even">
<td>2</td>
</tr>
<tr class="odd">
<td>3</td>
</tr>
```
@@ -0,0 +1,14 @@
# {debug}
`{debug}` dumps the debug console to the page. This works regardless of
the [debug](../chapter-debugging-console.md) settings in the php script.
Since this gets executed at runtime, this is only able to show the
[assigned](../../programmers/api-functions/api-assign.md) variables; not the templates that are in use.
However, you can see all the currently available variables within the
scope of a template.
| Attribute Name | Required | Description |
|----------------|----------|------------------------------------------------------------|
| output | No | output type, html or javascript (defaults to 'javascript') |
See also the [debugging console page](../chapter-debugging-console.md).
@@ -0,0 +1,81 @@
# {eval}
`{eval}` is used to evaluate a variable as a template. This can be used
for things like embedding template tags/variables into variables or
tags/variables into config file variables.
## Attributes
| Attribute Name | Required | Description |
|----------------|----------|------------------------------------------------------|
| var | Yes | Variable (or string) to evaluate |
| assign | No | The template variable the output will be assigned to |
If you supply the `assign` attribute, the output of the `{eval}`
function will be assigned to this template variable instead of being
output to the template.
> **Note**
>
> - Evaluated variables are treated the same as templates. They follow
> the same escapement and security features just as if they were
> templates.
>
> - Evaluated variables are compiled on every invocation, the compiled
> versions are not saved! However, if you have [caching](../../programmers/caching.md)
> enabled, the output will be cached with the rest of the template.
>
> - If the content to evaluate doesn't change often, or is used
> repeatedly, consider using
> `{include file="string:{$template_code}"}` instead. This may cache
> the compiled state and thus doesn't have to run the (comparably
> slow) compiler on every invocation.
## Examples
The contents of the config file, `setup.conf`.
```ini
emphstart = <strong>
emphend = </strong>
title = Welcome to {$company}'s home page!
ErrorCity = You must supply a {#emphstart#}city{#emphend#}.
ErrorState = You must supply a {#emphstart#}state{#emphend#}.
```
Where the template is:
```smarty
{config_load file='setup.conf'}
{eval var=$foo}
{eval var=#title#}
{eval var=#ErrorCity#}
{eval var=#ErrorState# assign='state_error'}
{$state_error}
```
The above template will output:
```html
This is the contents of foo.
Welcome to Foobar Pub & Grill's home page!
You must supply a <strong>city</strong>.
You must supply a <strong>state</strong>.
```
This outputs the server name (in uppercase) and IP. The assigned
variable `$str` could be from a database query.
```php
<?php
$str = 'The server name is {$smarty.server.SERVER_NAME|upper} '
.'at {$smarty.server.SERVER_ADDR}';
$smarty->assign('foo',$str);
```
Where the template is:
```smarty
{eval var=$foo}
```
@@ -0,0 +1,61 @@
# {fetch}
`{fetch}` is used to retrieve files from the local file system, http, or
ftp and display the contents.
## Attributes
| Attribute | Required | Description |
|-----------|----------|------------------------------------------------------|
| file | Yes | The file, http or ftp site to fetch |
| assign | No | The template variable the output will be assigned to |
- If the file name begins with `http://`, the website page will be
fetched and displayed.
> **Note**
>
> This will not support http redirects, be sure to include a
> trailing slash on your web page fetches where necessary.
- If the file name begins with `ftp://`, the file will be downloaded
from the ftp server and displayed.
- For local files, either a full system file path must be given, or a
path relative to the executed php script.
> **Note**
>
> If security is enabled, and you are fetching a file from the local
> file system, `{fetch}` will only allow files from within the
> `$secure_dir` path of the security policy. See the
> [Security](../../programmers/advanced-features/advanced-features-security.md) section for details.
- If the `assign` attribute is set, the output of the `{fetch}`
function will be assigned to this template variable instead of being
output to the template.
## Examples
```smarty
{* include some javascript in your template *}
{fetch file='/export/httpd/www.example.com/docs/navbar.js'}
{* embed some weather text in your template from another web site *}
{fetch file='http://www.myweather.com/68502/'}
{* fetch a news headline file via ftp *}
{fetch file='ftp://user:password@ftp.example.com/path/to/currentheadlines.txt'}
{* as above but with variables *}
{fetch file="ftp://`$user`:`$password`@`$server`/`$path`"}
{* assign the fetched contents to a template variable *}
{fetch file='http://www.myweather.com/68502/' assign='weather'}
{if $weather ne ''}
<div id="weather">{$weather}</div>
{/if}
```
See also [`{capture}`](../language-builtin-functions/language-function-capture.md),
[`{eval}`](language-function-eval.md),
[`{assign}`](../language-builtin-functions/language-function-assign.md) and [`fetch()`](../../programmers/api-functions/api-fetch.md).
@@ -0,0 +1,102 @@
# {html_checkboxes}
`{html_checkboxes}` is a [custom function](index.md)
that creates an html checkbox group with provided data. It takes care of
which item(s) are selected by default as well.
## Attributes
| Attribute Name | Required | Description |
|----------------|-------------------------------------|---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| name | No | Name of checkbox list (defaults to 'checkbox') |
| values | Yes, unless using options attribute | An array of values for checkbox buttons |
| output | Yes, unless using options attribute | An array of output for checkbox buttons |
| selected | No | The selected checkbox element(s) as a string or array |
| options | Yes, unless using values and output | An associative array of values and output |
| separator | No | String of text to separate each checkbox item |
| assign | No | Assign checkbox tags to an array instead of output |
| labels | No | Add <label\>-tags to the output (defaults to true) |
| label\_ids | No | Add id-attributes to <label\> and <input\> to the output (defaults to false) |
| escape | No | Escape the output / content (values are always escaped) (defaults to true) |
| strict | No | Will make the "extra" attributes *disabled* and *readonly* only be set, if they were supplied with either boolean *TRUE* or string *"disabled"* and *"readonly"* respectively (defaults to false) |
- Required attributes are `values` and `output`, unless you use `options` instead.
- All output is XHTML compliant.
- All parameters that are not in the list above are printed as
name/value-pairs inside each of the created <input\>-tags.
## Examples
```php
<?php
$smarty->assign('cust_ids', array(1000,1001,1002,1003));
$smarty->assign('cust_names', array(
'Joe Schmoe',
'Jack Smith',
'Jane Johnson',
'Charlie Brown')
);
$smarty->assign('customer_id', 1001);
```
where template is
```smarty
{html_checkboxes name='id' values=$cust_ids output=$cust_names selected=$customer_id separator='<br />'}
```
or where PHP code is:
```php
<?php
$smarty->assign(
'cust_checkboxes',
[
1000 => 'Joe Schmoe',
1001 => 'Jack Smith',
1002 => 'Jane Johnson',
1003 => 'Charlie Brown',
]
);
$smarty->assign('customer_id', 1001);
```
and the template is
```smarty
{html_checkboxes name='id' options=$cust_checkboxes selected=$customer_id separator='<br />'}
```
both examples will output:
```html
<label><input type="checkbox" name="id[]" value="1000" />Joe Schmoe</label><br />
<label><input type="checkbox" name="id[]" value="1001" checked="checked" />Jack Smith</label>
<br />
<label><input type="checkbox" name="id[]" value="1002" />Jane Johnson</label><br />
<label><input type="checkbox" name="id[]" value="1003" />Charlie Brown</label><br />
```
```php
<?php
$sql = 'select type_id, types from contact_types order by type';
$smarty->assign('contact_types',$db->getAssoc($sql));
$sql = 'select contact_id, contact_type_id, contact '
.'from contacts where contact_id=12';
$smarty->assign('contact',$db->getRow($sql));
```
The results of the database queries above would be output with.
```smarty
{html_checkboxes name='contact_type_id' options=$contact_types selected=$contact.contact_type_id separator='<br />'}
```
See also [`{html_radios}`](./language-function-html-radios.md) and
[`{html_options}`](./language-function-html-options.md)
@@ -0,0 +1,58 @@
# {html_image}
`{html_image}` is a [custom function](index.md) that
generates an HTML `<img>` tag. The `height` and `width` are
automatically calculated from the image file if they are not supplied.
## Attributes
| Attribute Name | Required | Description |
|----------------|----------|-------------------------------------------------------------------------|
| file | Yes | name/path to image |
| height | No | Height to display image (defaults to actual image height) |
| width | No | Width to display image (defaults to actual image width) |
| basedir | no | Directory to base relative paths from (defaults to web server doc root) |
| alt | no | Alternative description of the image |
| href | no | href value to link the image to |
| path\_prefix | no | Prefix for output path |
- `basedir` is the base directory that relative image paths are based
from. If not given, the web server's document root
`$_ENV['DOCUMENT_ROOT']` is used as the base. If security is
enabled, then the image must be located in the `$secure_dir` path of
the security policy. See the [Security](../../programmers/advanced-features/advanced-features-security.md)
section for details.
- `href` is the href value to link the image to. If link is supplied,
an `<a href="LINKVALUE"><a>` tag is placed around the image tag.
- `path_prefix` is an optional prefix string you can give the output
path. This is useful if you want to supply a different server name
for the image.
- All parameters that are not in the list above are printed as
name/value-pairs inside the created `<img>` tag.
> **Note**
>
> `{html_image}` requires a hit to the disk to read the image and
> calculate the height and width. If you don't use template
> [caching](../../programmers/caching.md), it is generally better to avoid `{html_image}`
> and leave image tags static for optimal performance.
## Examples
```smarty
{html_image file='pumpkin.jpg'}
{html_image file='/path/from/docroot/pumpkin.jpg'}
{html_image file='../path/relative/to/currdir/pumpkin.jpg'}
```
Example output of the above template would be:
```html
<img src="pumpkin.jpg" alt="" width="44" height="68" />
<img src="/path/from/docroot/pumpkin.jpg" alt="" width="44" height="68" />
<img src="../path/relative/to/currdir/pumpkin.jpg" alt="" width="44" height="68" />
```
@@ -0,0 +1,146 @@
# {html_options}
`{html_options}` is a [custom function](index.md) that
creates the html `<select><option>` group with the assigned data. It
takes care of which item(s) are selected by default as well.
## Attributes
| Attribute Name | Required | Description |
|----------------|-------------------------------------|---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| values | Yes, unless using options attribute | An array of values for dropdown |
| output | Yes, unless using options attribute | An array of output for dropdown |
| selected | No | The selected option element(s) as a string or array |
| options | Yes, unless using values and output | An associative array of values and output |
| name | No | Name of select group |
| strict | No | Will make the "extra" attributes *disabled* and *readonly* only be set, if they were supplied with either boolean *TRUE* or string *"disabled"* and *"readonly"* respectively (defaults to false) |
- Required attributes are `values` and `output`, unless you use the
combined `options` instead.
- If the optional `name` attribute is given, the `<select></select>`
tags are created, otherwise ONLY the `<option>` list is generated.
- If a given value is an array, it will treat it as an html
`<optgroup>`, and display the groups. Recursion is supported with
`<optgroup>`.
- All parameters that are not in the list above are printed as
name/value-pairs inside the `<select>` tag. They are ignored if the
optional `name` is not given.
- All output is XHTML compliant.
## Examples
```php
<?php
$smarty->assign('myOptions', [
1800 => 'Joe Schmoe',
9904 => 'Jack Smith',
2003 => 'Charlie Brown']
);
$smarty->assign('mySelect', 9904);
```
The following template will generate a drop-down list. Note the presence
of the `name` attribute which creates the `<select>` tags.
```smarty
{html_options name=foo options=$myOptions selected=$mySelect}
```
Output of the above example would be:
```html
<select name="foo">
<option value="1800">Joe Schmoe</option>
<option value="9904" selected="selected">Jack Smith</option>
<option value="2003">Charlie Brown</option>
</select>
```
```php
<?php
$smarty->assign('cust_ids', [56,92,13]);
$smarty->assign('cust_names', [
'Joe Schmoe',
'Jane Johnson',
'Charlie Brown']);
$smarty->assign('customer_id', 92);
```
The above arrays would be output with the following template (note the
use of the php [`count()`](https://www.php.net/function.count) function as a
modifier to set the select size).
```smarty
<select name="customer_id" size="{$cust_names|@count}">
{html_options values=$cust_ids output=$cust_names selected=$customer_id}
</select>
```
The above example would output:
```html
<select name="customer_id" size="3">
<option value="56">Joe Schmoe</option>
<option value="92" selected="selected">Jane Johnson</option>
<option value="13">Charlie Brown</option>
</select>
```
```php
<?php
$sql = 'select type_id, types from contact_types order by type';
$smarty->assign('contact_types',$db->getAssoc($sql));
$sql = 'select contact_id, name, email, contact_type_id
from contacts where contact_id='.$contact_id;
$smarty->assign('contact',$db->getRow($sql));
```
Where a template could be as follows. Note the use of the
[`truncate`](../language-modifiers/language-modifier-truncate.md) modifier.
```smarty
<select name="type_id">
<option value='null'>-- none --</option>
{html_options options=$contact_types|truncate:20 selected=$contact.type_id}
</select>
```
```php
<?php
$arr['Sport'] = array(6 => 'Golf', 9 => 'Cricket',7 => 'Swim');
$arr['Rest'] = array(3 => 'Sauna',1 => 'Massage');
$smarty->assign('lookups', $arr);
$smarty->assign('fav', 7);
```
The script above and the following template
```smarty
{html_options name=foo options=$lookups selected=$fav}
```
would output:
```html
<select name="foo">
<optgroup label="Sport">
<option value="6">Golf</option>
<option value="9">Cricket</option>
<option value="7" selected="selected">Swim</option>
</optgroup>
<optgroup label="Rest">
<option value="3">Sauna</option>
<option value="1">Massage</option>
</optgroup>
</select>
```
See also [`{html_checkboxes}`](./language-function-html-checkboxes.md) and
[`{html_radios}`](./language-function-html-radios.md)
@@ -0,0 +1,104 @@
# {html_radios}
`{html_radios}` is a [custom function](index.md) that
creates an HTML radio button group. It also takes care of which item is
selected by default as well.
## Attributes
| Attribute Name | Required | Description |
|----------------|-------------------------------------|---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| name | No | Name of radio list |
| values | Yes, unless using options attribute | An array of values for radio buttons |
| output | Yes, unless using options attribute | An array of output for radio buttons |
| selected | No | The selected radio element |
| options | Yes, unless using values and output | An associative array of values and output |
| separator | No | String of text to separate each radio item |
| assign | No | Assign radio tags to an array instead of output |
| labels | No | Add <label>-tags to the output (defaults to true) |
| label\_ids | No | Add id-attributes to <label\> and <input\> to the output (defaults to false) |
| escape | No | Escape the output / content (values are always escaped) (defaults to true) |
| strict | No | Will make the "extra" attributes *disabled* and *readonly* only be set, if they were supplied with either boolean *TRUE* or string *"disabled"* and *"readonly"* respectively (defaults to false) |
- Required attributes are `values` and `output`, unless you use
`options` instead.
- All output is XHTML compliant.
- All parameters that are not in the list above are output as
name/value-pairs inside each of the created `<input>`-tags.
## Examples
```php
<?php
$smarty->assign('cust_ids', array(1000,1001,1002,1003));
$smarty->assign('cust_names', array(
'Joe Schmoe',
'Jack Smith',
'Jane Johnson',
'Charlie Brown')
);
$smarty->assign('customer_id', 1001);
```
Where template is:
```smarty
{html_radios name='id' values=$cust_ids output=$cust_names
selected=$customer_id separator='<br />'}
```
```php
<?php
$smarty->assign('cust_radios', array(
1000 => 'Joe Schmoe',
1001 => 'Jack Smith',
1002 => 'Jane Johnson',
1003 => 'Charlie Brown'));
$smarty->assign('customer_id', 1001);
```
Where template is:
```smarty
{html_radios name='id' options=$cust_radios
selected=$customer_id separator='<br />'}
```
Both examples will output:
```html
<label><input type="radio" name="id" value="1000" />Joe Schmoe</label><br />
<label><input type="radio" name="id" value="1001" checked="checked" />Jack Smith</label><br />
<label><input type="radio" name="id" value="1002" />Jane Johnson</label><br />
<label><input type="radio" name="id" value="1003" />Charlie Brown</label><br />
```
```php
<?php
$sql = 'select type_id, types from contact_types order by type';
$smarty->assign('contact_types',$db->getAssoc($sql));
$sql = 'select contact_id, name, email, contact_type_id '
.'from contacts where contact_id='.$contact_id;
$smarty->assign('contact',$db->getRow($sql));
```
The variable assigned from the database above would be output with the
template:
```smarty
{html_radios name='contact_type_id' options=$contact_types
selected=$contact.contact_type_id separator='<br />'}
```
See also [`{html_checkboxes}`](language-function-html-checkboxes.md) and
[`{html_options}`](language-function-html-options.md)
@@ -0,0 +1,118 @@
# {html_select_date}
`{html_select_date}` is a [custom function](index.md)
that creates date dropdowns. It can display any or all of: year, month,
and day. All parameters that are not in the list below are printed as
name/value-pairs inside the `<select>` tags of day, month and year.
## Attributes
| Attribute Name | Default | Description |
|--------------------|--------------------|----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| prefix | Date_ | What to prefix the var name with |
| time | | What date/time to pre-select. Accepts timestamps, DateTime objects or any string parseable by [strtotime()](https://www.php.net/strtotime). If an array is given, the attributes field_array and prefix are used to identify the array elements to extract year, month and day from. Omitting this parameter or supplying a falsy value will select the current date. To prevent date selection, pass in NULL. |
| start_year | current year | The first year in the dropdown, either year number, or relative to current year (+/- N) |
| end_year | same as start_year | The last year in the dropdown, either year number, or relative to current year (+/- N) |
| display_days | TRUE | Whether to display days or not |
| display_months | TRUE | Whether to display months or not |
| display_years | TRUE | Whether to display years or not |
| month_names | | List of strings to display for months. array(1 =\> 'Jan', ..., 12 =\> 'Dec') |
| month_format | \%B | What format the month should be in (strftime) |
| day_format | \%02d | What format the day output should be in (sprintf) |
| day_value_format | \%d | What format the day value should be in (sprintf) |
| year_as_text | FALSE | Whether or not to display the year as text |
| reverse_years | FALSE | Display years in reverse order |
| field_array | | If a name is given, the select boxes will be drawn such that the results will be returned to PHP in the form of name\[Day\], name\[Year\], name\[Month\]. |
| day_size | | Adds size attribute to select tag if given |
| month_size | | Adds size attribute to select tag if given |
| year_size | | Adds size attribute to select tag if given |
| all_extra | | Adds extra attributes to all select/input tags if given |
| day_extra | | Adds extra attributes to select/input tags if given |
| month_extra | | Adds extra attributes to select/input tags if given |
| year_extra | | Adds extra attributes to select/input tags if given |
| all_id | | Adds id-attribute to all select/input tags if given |
| day_id | | Adds id-attribute to select/input tags if given |
| month_id | | Adds id-attribute to select/input tags if given |
| year_id | | Adds id-attribute to select/input tags if given |
| field_order | MDY | The order in which to display the fields |
| field_separator | \\n | String printed between different fields |
| month_value_format | \%m | strftime() format of the month values, default is %m for month numbers. |
| all_empty | | If supplied then the first element of any select-box has this value as it's label and "" as it's value. This is useful to make the select-boxes read "Please select" for example. |
| year_empty | | If supplied then the first element of the year's select-box has this value as it's label and "" as it's value. This is useful to make the select-box read "Please select a year" for example. Note that you can use values like "-MM-DD" as time-attribute to indicate an unselected year. |
| month_empty | | If supplied then the first element of the month's select-box has this value as it's label and "" as it's value. . Note that you can use values like "YYYY\--DD" as time-attribute to indicate an unselected month. |
| day_empty | | If supplied then the first element of the day's select-box has this value as it's label and "" as it's value. Note that you can use values like "YYYY-MM-" as time-attribute to indicate an unselected day. |
> **Note**
>
> There is an useful php function on the [date tips page](../../appendixes/tips.md)
> for converting `{html_select_date}` form values to a timestamp.
## Exaples
Template code
```smarty
{html_select_date}
```
This will output:
```html
<select name="Date_Month">
<option value="1">January</option>
<option value="2">February</option>
<option value="3">March</option>
..... snipped .....
<option value="10">October</option>
<option value="11">November</option>
<option value="12" selected="selected">December</option>
</select>
<select name="Date_Day">
<option value="1">01</option>
<option value="2">02</option>
<option value="3">03</option>
..... snipped .....
<option value="11">11</option>
<option value="12">12</option>
<option value="13" selected="selected">13</option>
<option value="14">14</option>
<option value="15">15</option>
..... snipped .....
<option value="29">29</option>
<option value="30">30</option>
<option value="31">31</option>
</select>
<select name="Date_Year">
<option value="2006" selected="selected">2006</option>
</select>
```
```smarty
{* start and end year can be relative to current year *}
{html_select_date prefix='StartDate' time=$time start_year='-5'
end_year='+1' display_days=false}
```
With 2000 as the current year the output:
```html
<select name="StartDateMonth">
<option value="1">January</option>
<option value="2">February</option>
.... snipped ....
<option value="11">November</option>
<option value="12" selected="selected">December</option>
</select>
<select name="StartDateYear">
<option value="1995">1995</option>
.... snipped ....
<option value="1999">1999</option>
<option value="2000" selected="selected">2000</option>
<option value="2001">2001</option>
</select>
```
See also [`{html_select_time}`](language-function-html-select-time.md),
[`date_format`](../language-modifiers/language-modifier-date-format.md),
[`$smarty.now`](../language-variables/language-variables-smarty.md#smartynow-languagevariablessmartynow) and the [date tips
page](../../appendixes/tips.md#dates).
@@ -0,0 +1,100 @@
# {html_select_time}
`{html_select_time}` is a [custom function](index.md)
that creates time dropdowns for you. It can display any or all of: hour,
minute, second and meridian.
The `time` attribute can have different formats. It can be a unique
timestamp, a string of the format `YYYYMMDDHHMMSS` or a string that is
parseable by PHP's [`strtotime()`](https://www.php.net/strtotime).
## Attributes
| Attribute Name | Default | Description |
|-----------------------|--------------------------------------------------------|------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| prefix | Time\_ | What to prefix the var name with |
| time | current [timestamp](https://www.php.net/function.time) | What date/time to pre-select. Accepts [timestamp](https://www.php.net/function.time), [DateTime](https://www.php.net/class.DateTime), mysql timestamp or any string parsable by [`strtotime()`](https://www.php.net/strtotime). If an array is given, the attributes field\_array and prefix are used to identify the array elements to extract hour, minute, second and meridian from. |
| display\_hours | TRUE | Whether or not to display hours |
| display\_minutes | TRUE | Whether or not to display minutes |
| display\_seconds | TRUE | Whether or not to display seconds |
| display\_meridian | TRUE | Whether or not to display meridian (am/pm) |
| use\_24\_hours | TRUE | Whether or not to use 24 hour clock |
| minute\_interval | 1 | Number interval in minute dropdown |
| second\_interval | 1 | Number interval in second dropdown |
| hour\_format | \%02d | What format the hour label should be in (sprintf) |
| hour\_value\_format | \%20d | What format the hour value should be in (sprintf) |
| minute\_format | \%02d | What format the minute label should be in (sprintf) |
| minute\_value\_format | \%20d | What format the minute value should be in (sprintf) |
| second\_format | \%02d | What format the second label should be in (sprintf) |
| second\_value\_format | \%20d | What format the second value should be in (sprintf) |
| field\_array | n/a | Outputs values to array of this name |
| all\_extra | null | Adds extra attributes to select/input tags if given |
| hour\_extra | null | Adds extra attributes to select/input tags if given |
| minute\_extra | null | Adds extra attributes to select/input tags if given |
| second\_extra | null | Adds extra attributes to select/input tags if given |
| meridian\_extra | null | Adds extra attributes to select/input tags if given |
| field\_separator | \\n | String printed between different fields |
| option\_separator | \\n | String printed between different options of a field |
| all\_id | null | Adds id-attribute to all select/input tags if given |
| hour\_id | null | Adds id-attribute to select/input tags if given |
| minute\_id | null | Adds id-attribute to select/input tags if given |
| second\_id | null | Adds id-attribute to select/input tags if given |
| meridian\_id | null | Adds id-attribute to select/input tags if given |
| all\_empty | null | If supplied then the first element of any select-box has this value as it's label and "" as it's value. This is useful to make the select-boxes read "Please select" for example. |
| hour\_empty | null | If supplied then the first element of the hour's select-box has this value as it's label and "" as it's value. This is useful to make the select-box read "Please select an hour" for example. |
| minute\_empty | null | If supplied then the first element of the minute's select-box has this value as it's label and "" as it's value. This is useful to make the select-box read "Please select an minute" for example. |
| second\_empty | null | If supplied then the first element of the second's select-box has this value as it's label and "" as it's value. This is useful to make the select-box read "Please select an second" for example. |
| meridian\_empty | null | If supplied then the first element of the meridian's select-box has this value as it's label and "" as it's value. This is useful to make the select-box read "Please select an meridian" for example. |
## Examples
```smarty
{html_select_time use_24_hours=true}
```
At 9:20 and 23 seconds in the morning the template above would output:
```html
<select name="Time_Hour">
<option value="00">00</option>
<option value="01">01</option>
... snipped ....
<option value="08">08</option>
<option value="09" selected>09</option>
<option value="10">10</option>
... snipped ....
<option value="22">22</option>
<option value="23">23</option>
</select>
<select name="Time_Minute">
<option value="00">00</option>
<option value="01">01</option>
... snipped ....
<option value="19">19</option>
<option value="20" selected>20</option>
<option value="21">21</option>
... snipped ....
<option value="58">58</option>
<option value="59">59</option>
</select>
<select name="Time_Second">
<option value="00">00</option>
<option value="01">01</option>
... snipped ....
<option value="22">22</option>
<option value="23" selected>23</option>
<option value="24">24</option>
... snipped ....
<option value="58">58</option>
<option value="59">59</option>
</select>
<select name="Time_Meridian">
<option value="am" selected>AM</option>
<option value="pm">PM</option>
</select>
```
See also [`$smarty.now`](../language-variables/language-variables-smarty.md#smartynow-languagevariablessmartynow),
[`{html_select_date}`](language-function-html-select-date.md) and the
[date tips page](../../appendixes/tips.md#dates).
@@ -0,0 +1,93 @@
# {html_table}
`{html_table}` is a [custom function](index.md) that
dumps an array of data into an HTML `<table>`.
## Attributes
| Attribute Name | Required | Description |
|----------------|----------|---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| loop | Yes | Array of data to loop through |
| cols | No | Number of columns in the table or a comma-separated list of column heading names or an array of column heading names.if the cols-attribute is empty, but rows are given, then the number of cols is computed by the number of rows and the number of elements to display to be just enough cols to display all elements. If both, rows and cols, are omitted cols defaults to 3. if given as a list or array, the number of columns is computed from the number of elements in the list or array. |
| rows | No | Number of rows in the table. if the rows-attribute is empty, but cols are given, then the number of rows is computed by the number of cols and the number of elements to display to be just enough rows to display all elements. |
| inner | No | Direction of consecutive elements in the loop-array to be rendered. *cols* means elements are displayed col-by-col. *rows* means elements are displayed row-by-row. |
| caption | No | Text to be used for the `<caption>` element of the table |
| table\_attr | No | Attributes for `<table>` tag (defaults to 'border="1"') |
| th\_attr | No | Attributes for `<th>` tag (arrays are cycled) |
| tr\_attr | No | attributes for `<tr>` tag (arrays are cycled) |
| td\_attr | No | Attributes for `<td>` tag (arrays are cycled) |
| trailpad | No | Value to pad the trailing cells on last row with (if any) (defaults to '&nbsp;') |
| hdir | No | Direction of each row to be rendered. possible values: *right* (left-to-right), and *left* (right-to-left) (defaults to 'right') |
| vdir | No | Direction of each column to be rendered. possible values: *down* (top-to-bottom), *up* (bottom-to-top) (defaults to 'down') |
- The `cols` attribute determines how many columns will be in the
table.
- The `table_attr`, `tr_attr` and `td_attr` values determine the
attributes given to the `<table>`, `<tr>` and `<td>` tags.
- If `tr_attr` or `td_attr` are arrays, they will be cycled through.
- `trailpad` is the value put into the trailing cells on the last
table row if there are any present.
## Examples
```php
<?php
$smarty->assign( 'data', array(1,2,3,4,5,6,7,8,9) );
$smarty->assign( 'tr', array('bgcolor="#eeeeee"','bgcolor="#dddddd"') );
$smarty->display('index.tpl');
```
The variables assigned from php could be displayed as these three
examples demonstrate. Each example shows the template followed by
output.
** Example 1 **
```smarty
{html_table loop=$data}
```
```html
<table border="1">
<tbody>
<tr><td>1</td><td>2</td><td>3</td></tr>
<tr><td>4</td><td>5</td><td>6</td></tr>
<tr><td>7</td><td>8</td><td>9</td></tr>
</tbody>
</table>
```
** Example 2 **
```smarty
{html_table loop=$data cols=4 table_attr='border="0"'}
```
```html
<table border="0">
<tbody>
<tr><td>1</td><td>2</td><td>3</td><td>4</td></tr>
<tr><td>5</td><td>6</td><td>7</td><td>8</td></tr>
<tr><td>9</td><td>&nbsp;</td><td>&nbsp;</td><td>&nbsp;</td></tr>
</tbody>
</table>
```
** Example 3 **
```smarty
{html_table loop=$data cols="first,second,third,fourth" tr_attr=$tr}
```
```html
<table border="1">
<thead>
<tr>
<th>first</th><th>second</th><th>third</th><th>fourth</th>
</tr>
</thead>
<tbody>
<tr bgcolor="#eeeeee"><td>1</td><td>2</td><td>3</td><td>4</td></tr>
<tr bgcolor="#dddddd"><td>5</td><td>6</td><td>7</td><td>8</td></tr>
<tr bgcolor="#eeeeee"><td>9</td><td>&nbsp;</td><td>&nbsp;</td><td>&nbsp;</td></tr>
</tbody>
</table>
```
@@ -0,0 +1,61 @@
# {mailto}
`{mailto}` automates the creation of a `mailto:` anchor links and
optionally encodes them. Encoding emails makes it more difficult for web
spiders to lift email addresses off of a site.
## Attributes
| Attribute Name | Required | Description |
|----------------|----------|-----------------------------------------------------------------------------------------------|
| address | Yes | The e-mail address |
| text | No | The text to display, default is the e-mail address |
| encode | No | How to encode the e-mail. Can be one of `none`, `hex`, `javascript` or `javascript_charcode`. |
| cc | No | Email addresses to carbon copy, separate entries by a comma. |
| bcc | No | Email addresses to blind carbon copy, separate entries by a comma |
| subject | No | Email subject |
| newsgroups | No | Newsgroups to post to, separate entries by a comma. |
| followupto | No | Addresses to follow up to, separate entries by a comma. |
| extra | No | Any extra information you want passed to the link, such as style sheet classes |
> **Note**
>
> Javascript is probably the most thorough form of encoding, although
> you can use hex encoding too.
## Examples
```smarty
{mailto address="me@example.com"}
<a href="mailto:me@example.com" >me@example.com</a>
{mailto address="me@example.com" text="send me some mail"}
<a href="mailto:me@example.com" >send me some mail</a>
{mailto address="me@example.com" encode="javascript"}
<script type="text/javascript" language="javascript">
eval(unescape('%64%6f% ... snipped ...%61%3e%27%29%3b'))
</script>
{mailto address="me@example.com" encode="hex"}
<a href="mailto:%6d%65.. snipped..3%6f%6d">&#x6d;&..snipped...#x6f;&#x6d;</a>
{mailto address="me@example.com" subject="Hello to you!"}
<a href="mailto:me@example.com?subject=Hello%20to%20you%21" >me@example.com</a>
{mailto address="me@example.com" cc="you@example.com,they@example.com"}
<a href="mailto:me@example.com?cc=you@example.com,they@example.com" >me@example.com</a>
{mailto address="me@example.com" extra='class="email"'}
<a href="mailto:me@example.com" class="email">me@example.com</a>
{mailto address="me@example.com" encode="javascript_charcode"}
<script type="text/javascript" language="javascript">
{document.write(String.fromCharCode(60,97, ... snipped ....60,47,97,62))}
</script>
```
See also [`escape`](../language-modifiers/language-modifier-escape.md),
[`{textformat}`](../language-custom-functions/language-function-textformat.md) and [obfuscating email
addresses](../../appendixes/tips.md#obfuscating-e-mail-addresses).
@@ -0,0 +1,99 @@
# {math}
`{math}` allows the template designer to do math equations in the
template.
## Attributes
| Attribute Name | Required | Description |
|----------------|----------|--------------------------------------------------|
| equation | Yes | The equation to execute |
| format | No | The format of the result (sprintf) |
| var | Yes | Equation variable value |
| assign | No | Template variable the output will be assigned to |
| \[var \...\] | Yes | Equation variable value |
- Any numeric template variables may be used in the equations, and the
result is printed in place of the tag.
- The variables used in the equation are passed as parameters, which
can be template variables or static values.
- +, -, /, \*, abs, ceil, cos, exp, floor, log, log10, max, min, pi,
pow, rand, round, sin, sqrt, srans and tan are all valid operators.
Check the PHP documentation for further information on these
[math](https://www.php.net/eval) functions.
- If you supply the `assign` attribute, the output of the `{math}`
function will be assigned to this template variable instead of being
output to the template.
> **Note**
>
> `{math}` is an expensive function in performance due to its use of the
> php [`eval()`](https://www.php.net/eval) function. Doing the math in PHP
> is much more efficient, so whenever possible do the math calculations
> in the script and [`assign()`](../../programmers/api-functions/api-assign.md) the results to the
> template. Definitely avoid repetitive `{math}` function calls, eg
> within [`{section}`](../language-builtin-functions/language-function-section.md) loops.
## Examples
**Example 1**
```smarty
{* $height=4, $width=5 *}
{math equation="x + y" x=$height y=$width}
```
The above example will output:
```
9
```
**Example 2**
```smarty
{* $row_height = 10, $row_width = 20, #col_div# = 2, assigned in template *}
{math equation="height * width / division"
height=$row_height
width=$row_width
division=#col_div#}
```
The above example will output:
```
100
```
**Example 3**
```smarty
{* you can use parenthesis *}
{math equation="(( x + y ) / z )" x=2 y=10 z=2}
```
The above example will output:
```
6
```
**Example 4**
```smarty
{* you can supply a format parameter in sprintf format *}
{math equation="x + y" x=4.4444 y=5.0000 format="%.2f"}
```
The above example will output:
```
9.44
```
@@ -0,0 +1,182 @@
# {textformat}
`{textformat}` is a [block function](../../programmers/plugins/plugins-block-functions.md) used to
format text. It basically cleans up spaces and special characters, and
formats paragraphs by wrapping at a boundary and indenting lines.
You can set the parameters explicitly, or use a preset style. Currently,
"email" is the only available style.
## Attributes
| Attribute Name | Default | Description |
|----------------|------------------|----------------------------------------------------------------------------------------|
| style | *n/a* | Preset style |
| indent | *0* | The number of chars to indent every line |
| indent\_first | *0* | The number of chars to indent the first line |
| indent\_char | *(single space)* | The character (or string of chars) to indent with |
| wrap | *80* | How many characters to wrap each line to |
| wrap\_char | *\\n* | The character (or string of chars) to break each line with |
| wrap\_cut | *FALSE* | If TRUE, wrap will break the line at the exact character instead of at a word boundary |
| assign | *n/a* | The template variable the output will be assigned to |
## Examples
```smarty
{textformat wrap=40}
This is foo.
This is foo.
This is foo.
This is foo.
This is foo.
This is foo.
This is bar.
bar foo bar foo foo.
bar foo bar foo foo.
bar foo bar foo foo.
bar foo bar foo foo.
bar foo bar foo foo.
bar foo bar foo foo.
bar foo bar foo foo.
{/textformat}
```
The above example will output:
```
This is foo. This is foo. This is foo.
This is foo. This is foo. This is foo.
This is bar.
bar foo bar foo foo. bar foo bar foo
foo. bar foo bar foo foo. bar foo bar
foo foo. bar foo bar foo foo. bar foo
bar foo foo. bar foo bar foo foo.
```
```smarty
{textformat wrap=40 indent=4}
This is foo.
This is foo.
This is foo.
This is foo.
This is foo.
This is foo.
This is bar.
bar foo bar foo foo.
bar foo bar foo foo.
bar foo bar foo foo.
bar foo bar foo foo.
bar foo bar foo foo.
bar foo bar foo foo.
bar foo bar foo foo.
{/textformat}
```
The above example will output:
```
This is foo. This is foo. This is
foo. This is foo. This is foo. This
is foo.
This is bar.
bar foo bar foo foo. bar foo bar foo
foo. bar foo bar foo foo. bar foo
bar foo foo. bar foo bar foo foo.
bar foo bar foo foo. bar foo bar
foo foo.
```
```smarty
{textformat wrap=40 indent=4 indent_first=4}
This is foo.
This is foo.
This is foo.
This is foo.
This is foo.
This is foo.
This is bar.
bar foo bar foo foo.
bar foo bar foo foo.
bar foo bar foo foo.
bar foo bar foo foo.
bar foo bar foo foo.
bar foo bar foo foo.
bar foo bar foo foo.
{/textformat}
```
The above example will output:
```
This is foo. This is foo. This
is foo. This is foo. This is foo.
This is foo.
This is bar.
bar foo bar foo foo. bar foo bar
foo foo. bar foo bar foo foo. bar
foo bar foo foo. bar foo bar foo
foo. bar foo bar foo foo. bar foo
bar foo foo.
```
```smarty
{textformat style="email"}
This is foo.
This is foo.
This is foo.
This is foo.
This is foo.
This is foo.
This is bar.
bar foo bar foo foo.
bar foo bar foo foo.
bar foo bar foo foo.
bar foo bar foo foo.
bar foo bar foo foo.
bar foo bar foo foo.
bar foo bar foo foo.
{/textformat}
```
The above example will output:
```
This is foo. This is foo. This is foo. This is foo. This is foo. This is
foo.
This is bar.
bar foo bar foo foo. bar foo bar foo foo. bar foo bar foo foo. bar foo
bar foo foo. bar foo bar foo foo. bar foo bar foo foo. bar foo bar foo
foo.
```
See also [`{strip}`](../language-builtin-functions/language-function-strip.md) and
[`wordwrap`](../language-modifiers/language-modifier-wordwrap.md).
+122
View File
@@ -0,0 +1,122 @@
# Variable Modifiers
Variable modifiers can be applied to
[variables](../language-variables/index.md), [custom functions](../language-custom-functions/index.md)
or strings. To apply a modifier,
specify the value followed by a `|` (pipe) and the modifier name. A
modifier may accept additional parameters that affect its behavior.
These parameters follow the modifier name and are separated by a `:`
(colon). Also, *all php-functions can be used as modifiers implicitly*
(more below) and modifiers can be
[combined](../language-combining-modifiers.md).
- [capitalize](language-modifier-capitalize.md)
- [cat](language-modifier-cat.md)
- [count_characters](language-modifier-count-characters.md)
- [count_paragraphs](language-modifier-count-paragraphs.md)
- [count_sentences](language-modifier-count-sentences.md)
- [count_words](language-modifier-count-words.md)
- [date_format](language-modifier-date-format.md)
- [default](language-modifier-default.md)
- [escape](language-modifier-escape.md)
- [from_charset](language-modifier-from-charset.md)
- [indent](language-modifier-indent.md)
- [lower](language-modifier-lower.md)
- [nl2br](language-modifier-nl2br.md)
- [regex_replace](language-modifier-regex-replace.md)
- [replace](language-modifier-replace.md)
- [spacify](language-modifier-spacify.md)
- [string_format](language-modifier-string-format.md)
- [strip](language-modifier-strip.md)
- [strip_tags](language-modifier-strip-tags.md)
- [to_charset](language-modifier-to-charset.md)
- [truncate](language-modifier-truncate.md)
- [unescape](language-modifier-unescape.md)
- [upper](language-modifier-upper.md)
- [wordwrap](language-modifier-wordwrap.md)
## Examples
```smarty
{* apply modifier to a variable *}
{$title|upper}
{* modifier with parameters *}
{$title|truncate:40:"..."}
{* apply modifier to a function parameter *}
{html_table loop=$myvar|upper}
{* with parameters *}
{html_table loop=$myvar|truncate:40:"..."}
{* apply modifier to literal string *}
{"foobar"|upper}
{* using date_format to format the current date *}
{$smarty.now|date_format:"%Y/%m/%d"}
{* apply modifier to a custom function *}
{mailto|upper address="smarty@example.com"}
{* using php's str_repeat *}
{"="|str_repeat:80}
{* php's count *}
{$myArray|@count}
{* this will uppercase and truncate the whole array *}
<select name="name_id">
{html_options output=$my_array|upper|truncate:20}
</select>
```
- Modifiers can be applied to any type of variables, including arrays
and objects.
> **Note**
>
> The default behavior was changed with Smarty 3. In Smarty 2.x, you
> had to use an "`@`" symbol to apply a modifier to an array, such
> as `{$articleTitle|@count}`. With Smarty 3, the "`@`" is no
> longer necessary, and is ignored.
>
> If you want a modifier to apply to each individual item of an
> array, you will either need to loop the array in the template, or
> provide for this functionality inside your modifier function.
> **Note**
>
> Second, in Smarty 2.x, modifiers were applied to the result of
> math expressions like `{8+2}`, meaning that
> `{8+2|count_characters}` would give `2`, as 8+2=10 and 10 is two
> characters long. With Smarty 3, modifiers are applied to the
> variables or atomic expressions before executing the calculations,
> so since 2 is one character long, `{8+2|count_characters}`
> gives 9. To get the old result use parentheses like
> `{(8+2)|count_characters}`.
- Modifiers are autoloaded from the
[`$plugins_dir`](../../programmers/api-variables/variable-plugins-dir.md) or can be registered
explicitly with the [`registerPlugin()`](../../programmers/api-functions/api-register-plugin.md)
function. The later is useful for sharing a function between php
scripts and smarty templates.
- All php-functions can be used as modifiers implicitly, as
demonstrated in the example above. However, using php-functions as
modifiers has two little pitfalls:
- First - sometimes the order of the function-parameters is not
the desirable one. Formatting `$foo` with
`{"%2.f"|sprintf:$foo}` actually works, but asks for the more
intuitive, like `{$foo|string_format:"%2.f"}` that is provided
by the Smarty distribution.
- Secondly - if security is enabled, all php-functions that are to
be used as modifiers have to be declared trusted in the
`$modifiers` property of the security policy. See the
[Security](../../programmers/advanced-features/advanced-features-security.md) section for details.
See also [`registerPlugin()`](../../programmers/api-functions/api-register-plugin.md), [combining
modifiers](../language-combining-modifiers.md). and [extending smarty with
plugins](../../programmers/plugins.md)
@@ -0,0 +1,49 @@
# capitalize
This is used to capitalize the first letter of all words in a variable.
This is similar to the PHP [`ucwords()`](https://www.php.net/ucwords)
function.
## Basic usage
```smarty
{$myVar|capitalize}
```
## Parameters
| Parameter | Type | Required | Description |
|-----------|---------|----------|-------------------------------------------------------------------------------------------------------|
| 1 | boolean | No | This determines whether or not words with digits will be uppercased |
| 2 | boolean | No | This determines whether or not Capital letters within words should be lowercased, e.g. "aAa" to "Aaa" |
## Examples
```php
<?php
$smarty->assign('articleTitle', 'next x-men film, x3, delayed.');
```
Where the template is:
```smarty
{$articleTitle}
{$articleTitle|capitalize}
{$articleTitle|capitalize:true}
```
Will output:
```
next x-men film, x3, delayed.
Next X-Men Film, x3, Delayed.
Next X-Men Film, X3, Delayed.
```
See also [`lower`](language-modifier-lower.md) and
[`upper`](language-modifier-upper.md)
@@ -0,0 +1,36 @@
# cat
This value is concatenated to the given variable.
## Basic usage
```smarty
{$myVar|cat:' units'}
```
## Parameters
| Parameter | Type | Required | Description |
|-----------|--------|----------|--------------------------------------------------|
| 1 | string | No | This value to concatenate to the given variable. |
## Examples
```php
<?php
$smarty->assign('articleTitle', "Psychics predict world didn't end");
```
Where template is:
```smarty
{$articleTitle|cat:' yesterday.'}
```
Will output:
```
Psychics predict world didn't end yesterday.
```
@@ -0,0 +1,43 @@
# count_characters
This is used to count the number of characters in a variable.
## Basic usage
```smarty
{$myVar|count_characters}
```
## Parameters
| Parameter | Type | Required | Description |
|-----------|---------|----------|------------------------------------------------------------------------|
| 1 | boolean | No | This determines whether to include whitespace characters in the count. |
## Examples
```php
<?php
$smarty->assign('articleTitle', 'Cold Wave Linked to Temperatures.');
```
Where template is:
```smarty
{$articleTitle}
{$articleTitle|count_characters}
{$articleTitle|count_characters:true}
```
Will output:
```
Cold Wave Linked to Temperatures.
29
33
```
See also [`count_words`](language-modifier-count-words.md),
[`count_sentences`](language-modifier-count-sentences.md) and
[`count_paragraphs`](language-modifier-count-paragraphs.md).
@@ -0,0 +1,41 @@
# count_paragraphs
This is used to count the number of paragraphs in a variable.
## Basic usage
```smarty
{$myVar|count_paragraphs}
```
## Examples
```php
<?php
$smarty->assign('articleTitle',
"War Dims Hope for Peace. Child's Death Ruins Couple's Holiday.\n\n
Man is Fatally Slain. Death Causes Loneliness, Feeling of Isolation."
);
```
Where template is:
```smarty
{$articleTitle}
{$articleTitle|count_paragraphs}
```
Will output:
```
War Dims Hope for Peace. Child's Death Ruins Couple's Holiday.
Man is Fatally Slain. Death Causes Loneliness, Feeling of Isolation.
2
```
See also [`count_characters`](language-modifier-count-characters.md),
[`count_sentences`](language-modifier-count-sentences.md) and
[`count_words`](language-modifier-count-words.md).
@@ -0,0 +1,39 @@
# count_sentences
This is used to count the number of sentences in a variable. A sentence
being delimited by a dot, question- or exclamation-mark (.?!).
## Basic usage
```smarty
{$myVar|count_sentences}
```
## Examples
```php
<?php
$smarty->assign('articleTitle',
'Two Soviet Ships Collide - One Dies.
Enraged Cow Injures Farmer with Axe.'
);
```
Where template is:
```smarty
{$articleTitle}
{$articleTitle|count_sentences}
```
Will output:
```
Two Soviet Ships Collide - One Dies. Enraged Cow Injures Farmer with Axe.
2
```
See also [`count_characters`](language-modifier-count-characters.md),
[`count_paragraphs`](language-modifier-count-paragraphs.md) and
[`count_words`](language-modifier-count-words.md).
@@ -0,0 +1,35 @@
# count_words
This is used to count the number of words in a variable.
## Basic usage
```smarty
{$myVar|count_words}
```
## Examples
```php
<?php
$smarty->assign('articleTitle', 'Dealers Will Hear Car Talk at Noon.');
```
Where template is:
```smarty
{$articleTitle}
{$articleTitle|count_words}
```
This will output:
```
Dealers Will Hear Car Talk at Noon.
7
```
See also [`count_characters`](language-modifier-count-characters.md),
[`count_paragraphs`](language-modifier-count-paragraphs.md) and
[`count_sentences`](language-modifier-count-sentences.md).
@@ -0,0 +1,145 @@
# date_format
This formats a date and time into the given
[`strftime()`](https://www.php.net/strftime) format. Dates can be passed to
Smarty as unix [timestamps](https://www.php.net/function.time), [DateTime
objects](https://www.php.net/class.DateTime), mysql timestamps or any string
made up of month day year, parsable by php\'s
[`strtotime()`](https://www.php.net/strtotime). Designers can then use
`date_format` to have complete control of the formatting of the date. If
the date passed to `date_format` is empty and a second parameter is
passed, that will be used as the date to format.
## Basic usage
```smarty
{$myVar|date_format:"%Y-%m-%d"}
```
## Parameters
| Parameter Position | Type | Required | Default | Description |
|--------------------|--------|----------|-----------|-------------------------------------------------|
| 1 | string | No | %b %e, %Y | This is the format for the outputted date. |
| 2 | string | No | n/a | This is the default date if the input is empty. |
> **Note**
>
> Since Smarty-2.6.10 numeric values passed to `date_format` are
> *always* (except for mysql timestamps, see below) interpreted as a
> unix timestamp.
>
> Before Smarty-2.6.10 numeric strings that where also parsable by
> `strtotime()` in php (like `YYYYMMDD`) where sometimes (depending on
> the underlying implementation of `strtotime()`) interpreted as date
> strings and NOT as timestamps.
>
> The only exception are mysql timestamps: They are also numeric only
> and 14 characters long (`YYYYMMDDHHMMSS`), mysql timestamps have
> precedence over unix timestamps.
> **Note**
>
> `date_format` is essentially a wrapper to PHP's
> [`strftime()`](https://www.php.net/strftime) function. You may have more
> or less conversion specifiers available depending on your system's
> [`strftime()`](https://www.php.net/strftime) function where PHP was
> compiled. Check your system\'s manpage for a full list of valid
> specifiers. However, a few of the specifiers are emulated on Windows.
> These are: %D, %e, %h, %l, %n, %r, %R, %t, %T.
## Examples
```php
<?php
$config['date'] = '%I:%M %p';
$config['time'] = '%H:%M:%S';
$smarty->assign('config', $config);
$smarty->assign('yesterday', strtotime('-1 day'));
```
This template uses [`$smarty.now`](../language-variables/language-variables-smarty.md#smartynow-languagevariablessmartynow) to
get the current time:
```smarty
{$smarty.now|date_format}
{$smarty.now|date_format:"%D"}
{$smarty.now|date_format:$config.date}
{$yesterday|date_format}
{$yesterday|date_format:"%A, %B %e, %Y"}
{$yesterday|date_format:$config.time}
```
This above will output:
```
Jan 1, 2022
01/01/22
02:33 pm
Dec 31, 2021
Monday, December 1, 2021
14:33:00
```
## Conversion specifiers
`date_format` conversion specifiers:
- %a - abbreviated weekday name according to the current locale
- %A - full weekday name according to the current locale
- %b - abbreviated month name according to the current locale
- %B - full month name according to the current locale
- %c - preferred date and time representation for the current locale
- %C - century number (the year divided by 100 and truncated to an
integer, range 00 to 99)
- %d - day of the month as a decimal number (range 01 to 31)
- %D - same as %m/%d/%y
- %e - day of the month as a decimal number, a single digit is
preceded by a space (range 1 to 31)
- %g - Week-based year within century \[00,99\]
- %G - Week-based year, including the century \[0000,9999\]
- %h - same as %b
- %H - hour as a decimal number using a 24-hour clock (range 00
to 23)
- %I - hour as a decimal number using a 12-hour clock (range 01
to 12)
- %j - day of the year as a decimal number (range 001 to 366)
- %k - Hour (24-hour clock) single digits are preceded by a blank.
(range 0 to 23)
- %l - hour as a decimal number using a 12-hour clock, single digits
preceded by a space (range 1 to 12)
- %m - month as a decimal number (range 01 to 12)
- %M - minute as a decimal number
- %n - newline character
- %p - either 'am' or 'pm' according to the given time value, or
the corresponding strings for the current locale
- %r - time in a.m. and p.m. notation
- %R - time in 24 hour notation
- %S - second as a decimal number
- %t - tab character
- %T - current time, equal to %H:%M:%S
- %u - weekday as a decimal number \[1,7\], with 1 representing
Monday
- %U - week number of the current year as a decimal number, starting
with the first Sunday as the first day of the first week
- %V - The ISO 8601:1988 week number of the current year as a decimal
number, range 01 to 53, where week 1 is the first week that has at
least 4 days in the current year, and with Monday as the first day
of the week.
- %w - day of the week as a decimal, Sunday being 0
- %W - week number of the current year as a decimal number, starting
with the first Monday as the first day of the first week
- %x - preferred date representation for the current locale without
the time
- %X - preferred time representation for the current locale without
the date
- %y - year as a decimal number without a century (range 00 to 99)
- %Y - year as a decimal number including the century
- %Z - time zone or name or abbreviation
- %% - a literal '%' character
See also [`$smarty.now`](../language-variables/language-variables-smarty.md#smartynow-languagevariablessmartynow),
[`strftime()`](https://www.php.net/strftime),
[`{html_select_date}`](../language-custom-functions/language-function-html-select-date.md) and the
[date tips](../../appendixes/tips.md#dates) page.
@@ -0,0 +1,45 @@
# default
This is used to set a default value for a variable. If the variable is
unset or an empty string, the given default value is printed instead.
Default takes the one argument.
## Basic usage
```smarty
{$myVar|default:"(none)"}
```
## Parameters
| Parameter | Type | Required | Default | Description |
|-----------|--------|----------|---------|---------------------------------------------------------------|
| 1 | string | No | *empty* | This is the default value to output if the variable is empty. |
## Examples
```php
<?php
$smarty->assign('articleTitle', 'Dealers Will Hear Car Talk at Noon.');
$smarty->assign('email', '');
```
Where template is:
```smarty
{$articleTitle|default:'no title'}
{$myTitle|default:'no title'}
{$email|default:'No email address available'}
```
Will output:
```
Dealers Will Hear Car Talk at Noon.
no title
No email address available
```
See also the [default variable handling](../../appendixes/tips.md#default-variable-handling) and
the [blank variable handling](../../appendixes/tips.md#blank-variable-handling) pages.
@@ -0,0 +1,78 @@
# escape
`escape` is used to encode or escape a variable to `html`, `url`,
`single quotes`, `hex`, `hexentity`, `javascript` and `mail`. By default
its `html`.
## Basic usage
```smarty
{$myVar|escape}
```
## Parameters
| Parameter Position | Type | Required | Possible Values | Default | Description |
|--------------------|---------|----------|----------------------------------------------------------------------------------------------------------------|---------|--------------------------------------------------------------------------------------|
| 1 | string | No | `html`, `htmlall`, `url`, `urlpathinfo`, `quotes`, `hex`, `hexentity`, `javascript`, `mail` | `html` | This is the escape format to use. |
| 2 | string | No | `ISO-8859-1`, `UTF-8`, and any character set supported by [`htmlentities()`](https://www.php.net/htmlentities) | `UTF-8` | The character set encoding passed to htmlentities() et. al. |
| 3 | boolean | No | FALSE | TRUE | Double encode entities from &amp; to &amp;amp; (applies to `html` and `htmlall` only) |
## Examples
```php
<?php
$smarty->assign('articleTitle',
"'Stiff Opposition Expected to Casketless Funeral Plan'"
);
$smarty->assign('EmailAddress','smarty@example.com');
```
These are example `escape` template lines followed by the output
```smarty
{$articleTitle}
'Stiff Opposition Expected to Casketless Funeral Plan'
{$articleTitle|escape}
&#039;Stiff Opposition Expected to Casketless Funeral Plan&#039;
{$articleTitle|escape:'html'} {* escapes & " ' < > *}
&#039;Stiff Opposition Expected to Casketless Funeral Plan&#039;
{$articleTitle|escape:'htmlall'} {* escapes ALL html entities *}
&#039;Stiff Opposition Expected to Casketless Funeral Plan&#039;
<a href="?title={$articleTitle|escape:'url'}">click here</a>
<a
href="?title=%27Stiff%20Opposition%20Expected%20to%20Casketless%20Funeral%20Plan%27">click here</a>
{$articleTitle|escape:'quotes'}
\'Stiff Opposition Expected to Casketless Funeral Plan\'
<a href="mailto:{$EmailAddress|escape:"hex"}">{$EmailAddress|escape:"hexentity"}</a>
{$EmailAddress|escape:'mail'} {* this converts to email to text *}
<a href="mailto:%62%6f%..snip..%65%74">&#x62;&#x6f;&#x62..snip..&#x65;&#x74;</a>
{'mail@example.com'|escape:'mail'}
smarty [AT] example [DOT] com
{* the "rewind" parameter registers the current location *}
<a href="$my_path?page=foo&rewind={$my_uri|escape:url}">click here</a>
```
This snippet is useful for emails, but see also
[`{mailto}`](../language-custom-functions/language-function-mailto.md)
```smarty
{* email address mangled *}
<a href="mailto:{$EmailAddress|escape:'hex'}">{$EmailAddress|escape:'mail'}</a>
```
See also [escaping smarty parsing](../language-basic-syntax/language-escaping.md),
[`{mailto}`](../language-custom-functions/language-function-mailto.md) and the [obfuscating email
addresses](../../appendixes/tips.md#obfuscating-e-mail-addresses) page.
@@ -0,0 +1,20 @@
# from_charset
`from_charset` is used to transcode a string from a given charset to the
internal charset. This is the exact opposite of the [to_charset
modifier](language-modifier-to-charset.md).
## Parameters
| Parameter Position | Type | Required | Possible Values | Default | Description |
|--------------------|--------|----------|------------------------------------------------------------------------------------------------------------------------------|--------------|---------------------------------------------------------------|
| 1 | string | No | `ISO-8859-1`, `UTF-8`, and any character set supported by [`mb_convert_encoding()`](https://www.php.net/mb_convert_encoding) | `ISO-8859-1` | The charset encoding the value is supposed to be decoded from |
> **Note**
>
> Charset encoding should be handled by the application itself. This
> modifier should only be used in cases where the application cannot
> anticipate that a certain string is required in another encoding.
See also [Charset Encoding](../../programmers/charset.md), [to_charset
modifier](language-modifier-to-charset.md).
@@ -0,0 +1,67 @@
# indent
This indents a string on each line, default is 4. As an optional
parameter, you can specify the number of characters to indent. As an
optional second parameter, you can specify the character to use to
indent with. For example: use `"\t"` for a tab.
## Basic usage
```smarty
{$myVar|indent:4}
```
## Parameters
| Parameter Position | Type | Required | Default | Description |
|--------------------|---------|----------|-------------|---------------------------------------------------|
| 1 | integer | No | 4 | This determines how many characters to indent to. |
| 2 | string | No | (one space) | This is the character used to indent with. |
## Examples
```php
<?php
$smarty->assign('articleTitle',
'NJ judge to rule on nude beach.
Sun or rain expected today, dark tonight.
Statistics show that teen pregnancy drops off significantly after 25.'
);
```
Where template is:
```smarty
{$articleTitle}
{$articleTitle|indent}
{$articleTitle|indent:10}
{$articleTitle|indent:1:"\t"}
```
Will output:
```
NJ judge to rule on nude beach.
Sun or rain expected today, dark tonight.
Statistics show that teen pregnancy drops off significantly after 25.
NJ judge to rule on nude beach.
Sun or rain expected today, dark tonight.
Statistics show that teen pregnancy drops off significantly after 25.
NJ judge to rule on nude beach.
Sun or rain expected today, dark tonight.
Statistics show that teen pregnancy drops off significantly after 25.
NJ judge to rule on nude beach.
Sun or rain expected today, dark tonight.
Statistics show that teen pregnancy drops off significantly after 25.
```
See also [`strip`](language-modifier-strip.md),
[`wordwrap`](language-modifier-wordwrap.md) and
[`spacify`](language-modifier-spacify.md).
@@ -0,0 +1,34 @@
# lower
This is used to lowercase a variable. This is equivalent to the PHP
[`strtolower()`](https://www.php.net/strtolower) function.
## Basic usage
```smarty
{$myVar|lower}
```
## Examples
```php
<?php
$smarty->assign('articleTitle', 'Two Convicts Evade Noose, Jury Hung.');
```
Where template is:
```smarty
{$articleTitle}
{$articleTitle|lower}
```
This will output:
```
Two Convicts Evade Noose, Jury Hung.
two convicts evade noose, jury hung.
```
See also [`upper`](language-modifier-upper.md) and
[`capitalize`](language-modifier-capitalize.md).
@@ -0,0 +1,37 @@
# nl2br
All `"\n"` line breaks will be converted to html `<br />` tags in the
given variable. This is equivalent to the PHP\'s
[`nl2br()`](https://www.php.net/nl2br) function.
## Basic usage
```smarty
{$myVar|nl2br}
```
## Examples
```php
<?php
$smarty->assign('articleTitle',
"Sun or rain expected\ntoday, dark tonight"
);
```
Where the template is:
```smarty
{$articleTitle|nl2br}
```
Will output:
```
Sun or rain expected<br />today, dark tonight
```
See also [`word_wrap`](language-modifier-wordwrap.md),
[`count_paragraphs`](language-modifier-count-paragraphs.md) and
[`count_sentences`](language-modifier-count-sentences.md).
@@ -0,0 +1,55 @@
# regex_replace
A regular expression search and replace on a variable. Use the
[`preg_replace()`](https://www.php.net/preg_replace) syntax from the PHP
manual.
## Basic usage
```smarty
{$myVar|regex_replace:"/foo/":"bar"}
```
> **Note**
>
> Although Smarty supplies this regex convenience modifier, it is
> usually better to apply regular expressions in PHP, either via custom
> functions or modifiers. Regular expressions are considered application
> code and are not part of presentation logic.
## Parameters
| Parameter Position | Type | Required | Description |
|--------------------|--------|----------|------------------------------------------------|
| 1 | string | Yes | This is the regular expression to be replaced. |
| 2 | string | Yes | This is the string of text to replace with. |
## Examples
```php
<?php
$smarty->assign('articleTitle', "Infertility unlikely to\nbe passed on, experts say.");
```
Where template is:
```smarty
{* replace each carriage return, tab and new line with a space *}
{$articleTitle}
{$articleTitle|regex_replace:"/[\r\t\n]/":" "}
```
Will output:
```
Infertility unlikely to
be passed on, experts say.
Infertility unlikely to be passed on, experts say.
```
See also [`replace`](language-modifier-replace.md) and
[`escape`](language-modifier-escape.md).
@@ -0,0 +1,45 @@
# replace
A simple search and replace on a variable. This is equivalent to the
PHP's [`str_replace()`](https://www.php.net/str_replace) function.
## Basic usage
```smarty
{$myVar|replace:"foo":"bar"}
```
## Parameters
| Parameter Position | Type | Required | Description |
|--------------------|--------|----------|---------------------------------------------|
| 1 | string | Yes | This is the string of text to be replaced. |
| 2 | string | Yes | This is the string of text to replace with. |
## Examples
```php
<?php
$smarty->assign('articleTitle', "Child's Stool Great for Use in Garden.");
```
Where template is:
```smarty
{$articleTitle}
{$articleTitle|replace:'Garden':'Vineyard'}
{$articleTitle|replace:' ':' '}
```
Will output:
```
Child's Stool Great for Use in Garden.
Child's Stool Great for Use in Vineyard.
Child's Stool Great for Use in Garden.
```
See also [`regex_replace`](language-modifier-regex-replace.md) and
[`escape`](language-modifier-escape.md).
@@ -0,0 +1,44 @@
# spacify
`spacify` is a way to insert a space between every character of a
variable. You can optionally pass a different character or string to
insert.
## Basic usage
```smarty
{$myVar|spacify}
```
## Parameters
| Parameter Position | Type | Required | Default | Description |
|--------------------|--------|----------|-------------|-----------------------------------------------------------------|
| 1 | string | No | *one space* | This what gets inserted between each character of the variable. |
## Examples
```php
<?php
$smarty->assign('articleTitle', 'Something Went Wrong in Jet Crash, Experts Say.');
```
Where template is:
```smarty
{$articleTitle}
{$articleTitle|spacify}
{$articleTitle|spacify:"^^"}
```
Will output:
```
Something Went Wrong in Jet Crash, Experts Say.
S o m e t h i n g W .... snip .... s h , E x p e r t s S a y .
S^^o^^m^^e^^t^^h^^i^^n^^g^^ .... snip .... ^^e^^r^^t^^s^^ ^^S^^a^^y^^.
```
See also [`wordwrap`](language-modifier-wordwrap.md) and
[`nl2br`](language-modifier-nl2br.md).
@@ -0,0 +1,43 @@
# string_format
This is a way to format strings, such as decimal numbers and such. Use
the syntax for [`sprintf()`](https://www.php.net/sprintf) for the
formatting.
## Basic usage
```smarty
{$myVar|string_format:"%d"}
```
## Parameters
| Parameter Position | Type | Required | Description |
|--------------------|--------|----------|---------------------------------------|
| 1 | string | Yes | This is what format to use. (sprintf) |
## Examples
```php
<?php
$smarty->assign('number', 23.5787446);
```
Where template is:
```smarty
{$number}
{$number|string_format:"%.2f"}
{$number|string_format:"%d"}
```
Will output:
```
23.5787446
23.58
23
```
See also [`date_format`](language-modifier-date-format.md).
@@ -0,0 +1,46 @@
# strip_tags
This strips out HTML markup tags, basically anything between `<` and `>`.
## Basic usage
```smarty
{$myVar|strip_tags}
```
## Parameters
| Parameter Position | Type | Required | Default | Description |
|--------------------|------|----------|---------|------------------------------------------------------------|
| 1 | bool | No | TRUE | This determines whether the tags are replaced by ' ' or '' |
## Examples
```php
<?php
$smarty->assign('articleTitle',
"Blind Woman Gets <font face=\"helvetica\">New
Kidney</font> from Dad she Hasn't Seen in <b>years</b>."
);
```
Where template is:
```smarty
{$articleTitle}
{$articleTitle|strip_tags} {* same as {$articleTitle|strip_tags:true} *}
{$articleTitle|strip_tags:false}
```
Will output:
```html
Blind Woman Gets <font face="helvetica">New Kidney</font> from Dad she Hasn't Seen in <b>years</b>.
Blind Woman Gets New Kidney from Dad she Hasn't Seen in years .
Blind Woman Gets New Kidney from Dad she Hasn't Seen in years.
```
See also [`replace`](language-modifier-replace.md) and
[`regex_replace`](language-modifier-regex-replace.md).
@@ -0,0 +1,42 @@
# strip
This replaces all spaces, newlines and tabs with a single space, or with
the supplied string.
## Basic usage
```smarty
{$myVar|strip}
```
> **Note**
>
> If you want to strip blocks of template text, use the built-in
> [`{strip}`](../language-builtin-functions/language-function-strip.md) function.
## Examples
```php
<?php
$smarty->assign('articleTitle', "Grandmother of\neight makes\t hole in one.");
$smarty->display('index.tpl');
```
Where template is:
```smarty
{$articleTitle}
{$articleTitle|strip}
{$articleTitle|strip:'&nbsp;'}
```
Will output:
```html
Grandmother of
eight makes hole in one.
Grandmother of eight makes hole in one.
Grandmother&nbsp;of&nbsp;eight&nbsp;makes&nbsp;hole&nbsp;in&nbsp;one.
```
See also [`{strip}`](../language-builtin-functions/language-function-strip.md) and
[`truncate`](language-modifier-truncate.md).
@@ -0,0 +1,20 @@
# to_charset
`to_charset` is used to transcode a string from the internal charset to
a given charset. This is the exact opposite of the [from_charset
modifier](#language.modifier.from_charset).
## Parameters
| Parameter Position | Type | Required | Possible Values | Default | Description |
|--------------------|--------|----------|------------------------------------------------------------------------------------------------------------------------------|--------------|-------------------------------------------------------------|
| 1 | string | No | `ISO-8859-1`, `UTF-8`, and any character set supported by [`mb_convert_encoding()`](https://www.php.net/mb_convert_encoding) | `ISO-8859-1` | The charset encoding the value is supposed to be encoded to |
> **Note**
>
> Charset encoding should be handled by the application itself. This
> modifier should only be used in cases where the application cannot
> anticipate that a certain string is required in another encoding.
See also [Charset Encoding](../../programmers/charset.md), [from_charset
modifier](language-modifier-from-charset.md).
@@ -0,0 +1,57 @@
# truncate
This truncates a variable to a character length, the default is 80. As
an optional second parameter, you can specify a string of text to
display at the end if the variable was truncated. The characters in the
string are included with the original truncation length. By default,
`truncate` will attempt to cut off at a word boundary. If you want to
cut off at the exact character length, pass the optional third parameter
of TRUE.
## Basic usage
```smarty
{$myVar|truncate:40:"..."}
```
## Parameters
| Parameter Position | Type | Required | Default | Description |
|--------------------|---------|----------|---------|----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| 1 | integer | No | 80 | This determines how many characters to truncate to. |
| 2 | string | No | \... | This is a text string that replaces the truncated text. Its length is included in the truncation length setting. |
| 3 | boolean | No | FALSE | This determines whether or not to truncate at a word boundary with FALSE, or at the exact character with TRUE. |
| 4 | boolean | No | FALSE | This determines whether the truncation happens at the end of the string with FALSE, or in the middle of the string with TRUE. Note that if this setting is TRUE, then word boundaries are ignored. |
## Examples
```php
<?php
$smarty->assign('articleTitle', 'Two Sisters Reunite after Eighteen Years at Checkout Counter.');
```
where template is:
```smarty
{$articleTitle}
{$articleTitle|truncate}
{$articleTitle|truncate:30}
{$articleTitle|truncate:30:""}
{$articleTitle|truncate:30:"---"}
{$articleTitle|truncate:30:"":true}
{$articleTitle|truncate:30:"...":true}
{$articleTitle|truncate:30:'..':true:true}
```
This will output:
```
Two Sisters Reunite after Eighteen Years at Checkout Counter.
Two Sisters Reunite after Eighteen Years at Checkout Counter.
Two Sisters Reunite after...
Two Sisters Reunite after
Two Sisters Reunite after---
Two Sisters Reunite after Eigh
Two Sisters Reunite after E...
Two Sisters Re..ckout Counter.
```
@@ -0,0 +1,43 @@
# unescape
`unescape` is used to decode `entity`, `html` and `htmlall`. It counters
the effects of the [escape modifier](language-modifier-escape.md) for the
given types.
## Basic usage
```smarty
{$myVar|unescape}
```
## Parameters
| Parameter Position | Type | Required | Possible Values | Default | Description |
|--------------------|--------|----------|----------------------------------------------------------------------------------------------------------------|---------|------------------------------------------------------------------------------------------------------------------------------|
| 1 | string | No | `html`, `htmlall`, `entity`, | `html` | This is the escape format to use. |
| 2 | string | No | `ISO-8859-1`, `UTF-8`, and any character set supported by [`htmlentities()`](https://www.php.net/htmlentities) | `UTF-8` | The character set encoding passed to html\_entity\_decode() or htmlspecialchars\_decode() or mb\_convert\_encoding() et. al. |
## Examples
```php
<?php
$smarty->assign('articleTitle',
"Germans use &quot;&Uuml;mlauts&quot; and pay in &euro;uro"
);
```
These are example `unescape` template lines followed by the output
```smarty
{$articleTitle}
Germans use &quot;&Uuml;mlauts&quot; and pay in &euro;uro
{$articleTitle|unescape:"html"}
Germans use "&Uuml;mlauts" and pay in &euro;uro
{$articleTitle|unescape:"htmlall"}
Germans use "Ümlauts" and pay in €uro
```
See also [escaping smarty parsing](../language-basic-syntax/language-escaping.md), [escape
modifier](language-modifier-escape.md).
@@ -0,0 +1,33 @@
# upper
This is used to uppercase a variable. This is equivalent to the PHP
[`strtoupper()`](https://www.php.net/strtoupper) function.
## Basic usage
```smarty
{$myVar|upper}
```
## Examples
```php
<?php
$smarty->assign('articleTitle', "If Strike isn't Settled Quickly it may Last a While.");
```
Where template is:
```smarty
{$articleTitle}
{$articleTitle|upper}
```
Will output:
```
If Strike isn't Settled Quickly it may Last a While.
IF STRIKE ISN'T SETTLED QUICKLY IT MAY LAST A WHILE.
```
See also [`lower`](lower) and
[`capitalize`](language-modifier-capitalize.md).
@@ -0,0 +1,73 @@
# wordwrap
Wraps a string to a column width, the default is 80. As an optional
second parameter, you can specify a string of text to wrap the text to
the next line, the default is a carriage return `"\n"`. By default,
`wordwrap` will attempt to wrap at a word boundary. If you want to cut
off at the exact character length, pass the optional third parameter as
TRUE. This is equivalent to the PHP
[`wordwrap()`](https://www.php.net/wordwrap) function.
## Basic usage
```smarty
{$myVar|wordwrap:30}
```
## Parameters
| Parameter Position | Type | Required | Default | Description |
|--------------------|---------|----------|---------|-----------------------------------------------------------------------------------------------|
| 1 | integer | No | 80 | This determines how many columns to wrap to. |
| 2 | string | No | \\n | This is the string used to wrap words with. |
| 3 | boolean | No | FALSE | This determines whether to wrap at a word boundary (FALSE), or at the exact character (TRUE). |
## Examples
```php
<?php
$smarty->assign('articleTitle',
"Blind woman gets new kidney from dad she hasn't seen in years."
);
```
Where template is
```smarty
{$articleTitle}
{$articleTitle|wordwrap:30}
{$articleTitle|wordwrap:20}
{$articleTitle|wordwrap:30:"<br />\n"}
{$articleTitle|wordwrap:26:"\n":true}
```
Will output:
```html
Blind woman gets new kidney from dad she hasn't seen in years.
Blind woman gets new kidney
from dad she hasn't seen in
years.
Blind woman gets new
kidney from dad she
hasn't seen in
years.
Blind woman gets new kidney<br />
from dad she hasn't seen in<br />
years.
Blind woman gets new kidn
ey from dad she hasn't se
en in years.
```
See also [`nl2br`](language-modifier-nl2br.md) and
[`{textformat}`](../language-custom-functions/language-function-textformat.md).

Some files were not shown because too many files have changed in this diff Show More