mirror of
https://github.com/smarty-php/smarty.git
synced 2026-08-04 12:34:33 +02:00
Compare commits
12 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| ed144d97bd | |||
| 6218f395f4 | |||
| 08c90664f0 | |||
| f2a66365de | |||
| c338585791 | |||
| c011891247 | |||
| 6ca6f72750 | |||
| 39c150ae58 | |||
| 58991f3f63 | |||
| 4038fa615b | |||
| 198338e2a2 | |||
| bc4e70f2c0 |
@@ -31,6 +31,7 @@ jobs:
|
||||
- "8.0"
|
||||
- "8.1"
|
||||
- "8.2"
|
||||
- "8.3"
|
||||
|
||||
compiler:
|
||||
- default
|
||||
@@ -45,6 +46,9 @@ jobs:
|
||||
- os: ubuntu-latest
|
||||
php-version: "8.2"
|
||||
compiler: jit
|
||||
- os: ubuntu-latest
|
||||
php-version: "8.3"
|
||||
compiler: jit
|
||||
|
||||
steps:
|
||||
- name: Checkout
|
||||
|
||||
+10
-1
@@ -6,6 +6,14 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
||||
|
||||
## [Unreleased]
|
||||
|
||||
### Added
|
||||
- PHP8.3 support [#925](https://github.com/smarty-php/smarty/issues/925)
|
||||
|
||||
### Fixed
|
||||
- The {debug} tag was broken in v5 [#922](https://github.com/smarty-php/smarty/issues/922)
|
||||
|
||||
## [5.0.0-rc2] - 2023-11-11
|
||||
|
||||
### Fixed
|
||||
- Registered output filters wouldn't run [#899](https://github.com/smarty-php/smarty/issues/899)
|
||||
- Use of negative numbers in {math} equations [#895](https://github.com/smarty-php/smarty/issues/895)
|
||||
@@ -37,7 +45,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
||||
multibyte extension for optimal performance.
|
||||
- Smarty no longer calls `mb_internal_encoding()` and doesn't check for deprecated `mbstring.func_overload` ini directive [#480](https://github.com/smarty-php/smarty/issues/480)
|
||||
- Generated `<script>` tags lo longer have deprecated `type="text/javascript"` or `language="Javascript"` attributes [#815](https://github.com/smarty-php/smarty/issues/815)
|
||||
- Smarty will throw a compiler exception insteadd of silently ignoring a modifier on a function call, like this: `{include|dot:"x-template-id" file="included.dot.tpl"}` [#526](https://github.com/smarty-php/smarty/issues/526)
|
||||
- Smarty will throw a compiler exception instead of silently ignoring a modifier on a function call, like this: `{include|dot:"x-template-id" file="included.dot.tpl"}` [#526](https://github.com/smarty-php/smarty/issues/526)
|
||||
- The documentation was largely rewritten
|
||||
|
||||
### Deprecated
|
||||
@@ -69,6 +77,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
||||
- Removed constants such as SMARTY_DIR to prevent global side effects.
|
||||
- Removed direct access to `$smarty->template_dir`. Use `$smarty->setTemplateDir()`.
|
||||
- Removed direct access to `$smarty->cache_dir`. Use `$smarty->setCacheDir()`.
|
||||
- Removed direct access to `$smarty->compile_dir`. Use `$smarty->setCompileDir()`.
|
||||
- Removed `$smarty->loadPlugin()`, use `$smarty->registerPlugin()` instead.
|
||||
- Removed `$smarty->appendByRef()` and `$smarty->assignByRef()`.
|
||||
- Removed `$smarty->_current_file`
|
||||
|
||||
+5
-1
@@ -37,7 +37,11 @@ services:
|
||||
service: base
|
||||
build:
|
||||
dockerfile: ./utilities/testrunners/php82/Dockerfile
|
||||
|
||||
php83:
|
||||
extends:
|
||||
service: base
|
||||
build:
|
||||
dockerfile: ./utilities/testrunners/php83/Dockerfile
|
||||
volumes:
|
||||
smarty-code:
|
||||
|
||||
|
||||
+2
-2
@@ -134,8 +134,8 @@ that would be needed otherwise? Does the codebase or framework you plan
|
||||
on using have the features you need for the presentation component?
|
||||
|
||||
## Sites using Smarty
|
||||
Many well-known PHP projects make use of Smarty such as XOOPS CMS, CMS Made Simple, Tiki
|
||||
CMS/Groupware and X-Cart to name a few.
|
||||
Many well-known PHP projects make use of Smarty such as XOOPS CMS, CMS Made Simple,
|
||||
Tiki Wiki CMS Groupware and X-Cart to name a few.
|
||||
|
||||
## Summary
|
||||
Whether you are using Smarty for a small website or massive enterprise
|
||||
|
||||
@@ -16,9 +16,9 @@ To get the latest, unreleased version, use:
|
||||
composer require smarty/smarty:dev-master
|
||||
```
|
||||
|
||||
To get the previous stable version of Smarty, Smarty 3, use:
|
||||
To get the previous stable version of Smarty, Smarty 4, use:
|
||||
```shell
|
||||
composer require smarty/smarty:^3
|
||||
composer require smarty/smarty:^4
|
||||
```
|
||||
|
||||
Here's how you create an instance of Smarty in your PHP scripts:
|
||||
|
||||
@@ -26,5 +26,6 @@ and 480 for $height, the result is:
|
||||
- [Features](./features.md) - or "Why do I want Smarty?"
|
||||
|
||||
## Help
|
||||
- [Upgrading from an older version](upgrading.md)
|
||||
- [Some random tips & tricks](./appendixes/tips.md)
|
||||
- [Troubleshooting](./appendixes/troubleshooting.md)
|
||||
|
||||
@@ -0,0 +1,156 @@
|
||||
# Upgrading from an older version
|
||||
|
||||
## Upgrading from v4 to v5
|
||||
|
||||
Smarty 5 adds support for PHP8.2 and drops support for PHP7.1. Smarty also adds support for new features
|
||||
such as the ternary operator (`{$test ? $a : $b}` and `{$var ?: $value_if_falsy}`), the null coalescing operator (`{$var ?? $value_if_null}`)
|
||||
and positional parameters for custom tags.
|
||||
Smarty 5 also has a brand-new extension architecture that allows you to write neat extension packs.
|
||||
|
||||
### Namespaces
|
||||
All Smarty code has been moved into the `\Smarty` namespace. This reduces
|
||||
the chance of conflicts with other (your) code.
|
||||
|
||||
For simple use-cases, you only need to add `use Smarty\Smarty;` to your script and everything will work.
|
||||
|
||||
```php
|
||||
<?php
|
||||
use Smarty\Smarty;
|
||||
$smarty = new Smarty();
|
||||
|
||||
$smarty->display('homepage.tpl');
|
||||
```
|
||||
For more information, see [getting started](getting-started.md).
|
||||
|
||||
If you extend Smarty or use Smarty plug-ins, please review your code to see if they assume specific class or method names.
|
||||
E.g.: `Smarty_Internal_Template` is now `\Smarty\Template\`, `SmartyException` is now `\Smarty\Exception`.
|
||||
|
||||
### Variable scope bubbling
|
||||
Template variable scope bubbling has been simplified and made more consistent. The global scope now equals the Smarty
|
||||
scope in order to avoid global state side effects. Please read the [documentation on language variable scope](designers/language-variables/language-variable-scopes.md)
|
||||
for more details.
|
||||
|
||||
Also, `{config_load}` no longer has a `scope` parameter, which means you can no longer load config
|
||||
from inside your template into the global scope (again, to avoid global state side effects). If you
|
||||
need to set global config, use the [configLoad API method](api/variables/config-files.md) from your PHP code.
|
||||
|
||||
### Using native PHP-functions or userland functions in your templates
|
||||
You can no longer use native PHP-functions or userland functions in your templates without registering them.
|
||||
If you need a function in your templates, register it first.
|
||||
|
||||
The easiest way to do so is as follows:
|
||||
```php
|
||||
// native PHP functions used as modifiers need to be registered
|
||||
$smarty->registerPlugin('modifier', 'substr', 'substr');
|
||||
|
||||
// userland PHP functions used as modifiers need to be registered
|
||||
$smarty->registerPlugin('modifier', 'my_special_func', 'my_special_func');
|
||||
```
|
||||
|
||||
But you may want to consider writing a proper [extension](api/extending/extensions.md).
|
||||
|
||||
### Removed undocumented tags
|
||||
|
||||
Smarty 4 still supported some tags that have been carried over from previous version, but have never been documented.
|
||||
|
||||
- `{block_parent}` should be replaced with `{$smarty.block.parent}`
|
||||
- `{parent}` should be replaced with `{$smarty.block.parent}`
|
||||
- `{block_child}` should be replaced with `{$smarty.block.child}`
|
||||
- `{child}` should be replaced with `{$smarty.block.child}`
|
||||
|
||||
- `{make_nocache}` is no longer supported
|
||||
- `{insert}` is no longer supported
|
||||
|
||||
### Removed Smarty API properties
|
||||
|
||||
In Smarty 4, you could make many configuration changes by directly accessing public properties on the Smarty object in PHP.
|
||||
In many cases, these properties have been made private, and you should now use the appropriate setter method:
|
||||
|
||||
- `$smarty->left_delimiter` should be replaced with `$smarty->getLeftDelimiter()`/`$smarty->setLeftDelimiter()`
|
||||
- `$smarty->right_delimiter` should be replaced with `$smarty->getRightDelimiter()`/`$smarty->setRightDelimiter()`
|
||||
- `$smarty->autoload_filters` should be replaced with `$smarty->registerFilter()`
|
||||
- `$smarty->template_dir` should be replaced with `$smarty->setTemplateDir()`
|
||||
- `$smarty->cache_dir` should be replaced with `$smarty->setCacheDir()`
|
||||
- `$smarty->compile_dir` should be replaced with `$smarty->setCompileDir()`
|
||||
|
||||
Other public properties have been removed altogether, and you should no longer access them:
|
||||
|
||||
- `$smarty->_current_file`
|
||||
- `$smarty->allow_ambiguous_resources` (ambiguous resources handlers should still work)
|
||||
- `$smarty->registered_filters`
|
||||
- `$smarty->direct_access_security`
|
||||
- `$smarty->trusted_dir`
|
||||
- `$smarty->allow_php_templates`
|
||||
- `$smarty->php_functions`
|
||||
- `$smarty->php_modifiers`
|
||||
|
||||
### Backwards incompatible changes to custom plugins
|
||||
|
||||
We have dropped support for `$smarty->plugins_dir` and `$smarty->use_include_path`.
|
||||
Use `$smarty->addPluginsDir()` or consider writing a proper [extension](api/extending/extensions.md).
|
||||
|
||||
The 'insert' plugin type is no longer supported.
|
||||
|
||||
The `$cache_attrs` parameter for registered plugins is no longer supported.
|
||||
|
||||
### Removed Smarty API methods
|
||||
|
||||
Search your code for the following changes:
|
||||
|
||||
- `$smarty->getTags()` is no longer supported
|
||||
- `$smarty->appendByRef()` should be replaced with `$smarty->append()`
|
||||
- `$smarty->assignByRef()` should be replaced with `$smarty->assign()`
|
||||
- `$smarty->loadPlugin()` should be replaced with `$smarty->registerPlugin()`
|
||||
|
||||
### Removed PHP constants
|
||||
|
||||
The following constants have been removed to prevent global side effects.
|
||||
|
||||
- `SMARTY_DIR`
|
||||
- `SMARTY_SYSPLUGINS_DIR`
|
||||
- `SMARTY_PLUGINS_DIR`
|
||||
- `SMARTY_MBSTRING`
|
||||
- `SMARTY_HELPER_FUNCTIONS_LOADED`
|
||||
|
||||
### Other changes
|
||||
|
||||
- Smarty now always runs in multibyte mode. Make sure you use the [PHP multibyte extension](https://www.php.net/manual/en/book.mbstring.php) in production for optimal performance.
|
||||
- Generated `<script>` tags lo longer have deprecated `type="text/javascript"` or `language="Javascript"` attributes
|
||||
- Smarty will throw a compiler exception instead of silently ignoring a modifier on a function call, like this: `{include|dot:"x-template-id" file="included.dot.tpl"}`
|
||||
|
||||
## Upgrading from v3 to v4
|
||||
|
||||
Smarty 4 is mostly identical to Smarty 3. Most notably, it adds support for PHP8 and drops support for PHP7.0 and below.
|
||||
Additionally, some deprecated features that have long been discouraged have been dropped from the language.
|
||||
|
||||
### Muting PHP8 warnings
|
||||
If you simultaneously upgrade Smarty to v4 van PHP to v8, you may notice your error logs filling up with warnings about undefined or null template vars
|
||||
due to a change in how PHP handles these. This may be helpful to spot errors, but if you find this annoying, you can use
|
||||
`$smarty->muteUndefinedOrNullWarnings()` to make Smarty convert these warnings into notices.
|
||||
|
||||
### ASP tags
|
||||
You can no longer user ASP-style tags like `<% %>` and `<%= %>` in your templates.
|
||||
Replace them with `{...}` tags.
|
||||
|
||||
### SmartyBC
|
||||
Check your codebase for `SmartyBC`.
|
||||
We have dropped deprecated API calls that where only accessible through the SmartyBC class.
|
||||
|
||||
### No more embedded PHP
|
||||
We have completely dropped support for `{php}` and `{include_php}` tags and embedded PHP in templates.
|
||||
Check your templates for this, and rewrite any embedded PHP blocks, by moving logic to your PHP files or by
|
||||
creating a [custom tag](./api/extending/tags.md).
|
||||
|
||||
### Other changes
|
||||
|
||||
Search your code for the following changes:
|
||||
|
||||
- `SMARTY_RESOURCE_CHAR_SET` and `SMARTY_RESOURCE_DATE_FORMAT` constants have been removed
|
||||
- `Smarty::muteExpectedErrors` and `Smarty::unmuteExpectedErrors` API methods have been removed
|
||||
- `Smarty::getVariable` method has been removed. Use [Smarty::getTemplateVars](designers/language-builtin-functions/language-function-assign.md) instead.
|
||||
- [Smarty::registerResource](api/resources.md) no longer accepts an array of callback functions
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
+3
-2
@@ -8,8 +8,9 @@ else
|
||||
fi
|
||||
|
||||
git checkout -b "release/$1"
|
||||
sed -i "s/## \\[Unreleased\\]/## \\[Unreleased\\]\\n\\n## \\[$1\\] - $(date +%Y-%m-%d)/" CHANGELOG.md
|
||||
sed -i "s/const SMARTY_VERSION = '[^']\+';/const SMARTY_VERSION = '$1';/" src/Smarty.php
|
||||
|
||||
php utilities/update-changelog.php $1
|
||||
php utilities/update-smarty-version-number.php $1
|
||||
|
||||
git add CHANGELOG.md src/Smarty.php
|
||||
git commit -m "version bump"
|
||||
|
||||
+3
-1
@@ -26,7 +26,9 @@ markdown_extensions:
|
||||
|
||||
nav:
|
||||
- Home: 'index.md'
|
||||
- 'Getting started': 'getting-started.md'
|
||||
- 'Getting started':
|
||||
- Introduction: 'getting-started.md'
|
||||
- 'Upgrading from an older version': 'upgrading.md'
|
||||
- 'Language reference':
|
||||
- 'Basic Syntax':
|
||||
- Introduction: 'designers/language-basic-syntax/index.md'
|
||||
|
||||
@@ -13,3 +13,4 @@ $COMPOSE_CMD run --rm php74 ./run-tests.sh $@ && \
|
||||
$COMPOSE_CMD run --rm php80 ./run-tests.sh $@ && \
|
||||
$COMPOSE_CMD run --rm php81 ./run-tests.sh $@ && \
|
||||
$COMPOSE_CMD run --rm php82 ./run-tests.sh $@
|
||||
$COMPOSE_CMD run --rm php83 ./run-tests.sh $@
|
||||
|
||||
@@ -593,8 +593,6 @@ class Template extends BaseCompiler {
|
||||
public function getTagCompiler($tag): ?\Smarty\Compile\CompilerInterface {
|
||||
$tag = strtolower($tag);
|
||||
|
||||
$tag = strtolower($tag);
|
||||
|
||||
if (isset($this->smarty->security_policy) && !$this->smarty->security_policy->isTrustedTag($tag, $this)) {
|
||||
return null;
|
||||
}
|
||||
|
||||
+37
-46
@@ -6,16 +6,7 @@ namespace Smarty;
|
||||
* Smarty Internal Plugin Debug
|
||||
* Class to collect data for the Smarty Debugging Console
|
||||
*
|
||||
|
||||
|
||||
* @author Uwe Tews
|
||||
*/
|
||||
|
||||
/**
|
||||
* Smarty Internal Plugin Debug Class
|
||||
*
|
||||
|
||||
|
||||
*/
|
||||
class Debug extends Data
|
||||
{
|
||||
@@ -24,14 +15,14 @@ class Debug extends Data
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
public $template_data = array();
|
||||
public $template_data = [];
|
||||
|
||||
/**
|
||||
* List of uid's which shall be ignored
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
public $ignore_uid = array();
|
||||
public $ignore_uid = [];
|
||||
|
||||
/**
|
||||
* Index of display() and fetch() calls
|
||||
@@ -50,10 +41,10 @@ class Debug extends Data
|
||||
/**
|
||||
* Start logging template
|
||||
*
|
||||
* @param \Smarty\Template $template template
|
||||
* @param Template $template template
|
||||
* @param null $mode true: display false: fetch null: subtemplate
|
||||
*/
|
||||
public function start_template(\Smarty\Template $template, $mode = null)
|
||||
public function start_template(Template $template, $mode = null)
|
||||
{
|
||||
if (isset($mode) && !$template->_isSubTpl()) {
|
||||
$this->index++;
|
||||
@@ -67,9 +58,9 @@ class Debug extends Data
|
||||
/**
|
||||
* End logging of cache time
|
||||
*
|
||||
* @param \Smarty\Template $template cached template
|
||||
* @param Template $template cached template
|
||||
*/
|
||||
public function end_template(\Smarty\Template $template)
|
||||
public function end_template(Template $template)
|
||||
{
|
||||
$key = $this->get_key($template);
|
||||
$this->template_data[ $this->index ][ $key ][ 'total_time' ] +=
|
||||
@@ -79,15 +70,15 @@ class Debug extends Data
|
||||
/**
|
||||
* Start logging of compile time
|
||||
*
|
||||
* @param \Smarty\Template $template
|
||||
* @param Template $template
|
||||
*/
|
||||
public function start_compile(\Smarty\Template $template)
|
||||
public function start_compile(Template $template)
|
||||
{
|
||||
static $_is_stringy = array('string' => true, 'eval' => true);
|
||||
if (!empty($template->getCompiler()->trace_uid)) {
|
||||
$key = $template->getCompiler()->trace_uid;
|
||||
if (!isset($this->template_data[ $this->index ][ $key ])) {
|
||||
$this->saveTemplateData($_is_stringy, $template, $key);
|
||||
$this->saveTemplateData($_is_stringy, $template, $key);
|
||||
}
|
||||
} else {
|
||||
if (isset($this->ignore_uid[ $template->getSource()->uid ])) {
|
||||
@@ -101,9 +92,9 @@ class Debug extends Data
|
||||
/**
|
||||
* End logging of compile time
|
||||
*
|
||||
* @param \Smarty\Template $template
|
||||
* @param Template $template
|
||||
*/
|
||||
public function end_compile(\Smarty\Template $template)
|
||||
public function end_compile(Template $template)
|
||||
{
|
||||
if (!empty($template->getCompiler()->trace_uid)) {
|
||||
$key = $template->getCompiler()->trace_uid;
|
||||
@@ -120,9 +111,9 @@ class Debug extends Data
|
||||
/**
|
||||
* Start logging of render time
|
||||
*
|
||||
* @param \Smarty\Template $template
|
||||
* @param Template $template
|
||||
*/
|
||||
public function start_render(\Smarty\Template $template)
|
||||
public function start_render(Template $template)
|
||||
{
|
||||
$key = $this->get_key($template);
|
||||
$this->template_data[ $this->index ][ $key ][ 'start_time' ] = microtime(true);
|
||||
@@ -131,9 +122,9 @@ class Debug extends Data
|
||||
/**
|
||||
* End logging of compile time
|
||||
*
|
||||
* @param \Smarty\Template $template
|
||||
* @param Template $template
|
||||
*/
|
||||
public function end_render(\Smarty\Template $template)
|
||||
public function end_render(Template $template)
|
||||
{
|
||||
$key = $this->get_key($template);
|
||||
$this->template_data[ $this->index ][ $key ][ 'render_time' ] +=
|
||||
@@ -143,9 +134,9 @@ class Debug extends Data
|
||||
/**
|
||||
* Start logging of cache time
|
||||
*
|
||||
* @param \Smarty\Template $template cached template
|
||||
* @param Template $template cached template
|
||||
*/
|
||||
public function start_cache(\Smarty\Template $template)
|
||||
public function start_cache(Template $template)
|
||||
{
|
||||
$key = $this->get_key($template);
|
||||
$this->template_data[ $this->index ][ $key ][ 'start_time' ] = microtime(true);
|
||||
@@ -154,9 +145,9 @@ class Debug extends Data
|
||||
/**
|
||||
* End logging of cache time
|
||||
*
|
||||
* @param \Smarty\Template $template cached template
|
||||
* @param Template $template cached template
|
||||
*/
|
||||
public function end_cache(\Smarty\Template $template)
|
||||
public function end_cache(Template $template)
|
||||
{
|
||||
$key = $this->get_key($template);
|
||||
$this->template_data[ $this->index ][ $key ][ 'cache_time' ] +=
|
||||
@@ -166,9 +157,9 @@ class Debug extends Data
|
||||
/**
|
||||
* Register template object
|
||||
*
|
||||
* @param \Smarty\Template $template cached template
|
||||
* @param Template $template cached template
|
||||
*/
|
||||
public function register_template(\Smarty\Template $template)
|
||||
public function register_template(Template $template)
|
||||
{
|
||||
}
|
||||
|
||||
@@ -184,13 +175,13 @@ class Debug extends Data
|
||||
/**
|
||||
* Opens a window for the Smarty Debugging Console and display the data
|
||||
*
|
||||
* @param \Smarty\Template|\Smarty $obj object to debug
|
||||
* @param Template|Smarty $obj object to debug
|
||||
* @param bool $full
|
||||
*
|
||||
* @throws \Exception
|
||||
* @throws \Smarty\Exception
|
||||
* @throws Exception
|
||||
*/
|
||||
public function display_debug($obj, $full = false)
|
||||
public function display_debug($obj, bool $full = false)
|
||||
{
|
||||
if (!$full) {
|
||||
$this->offset++;
|
||||
@@ -200,18 +191,18 @@ class Debug extends Data
|
||||
$smarty = $obj->getSmarty();
|
||||
// create fresh instance of smarty for displaying the debug console
|
||||
// to avoid problems if the application did overload the Smarty class
|
||||
$debObj = new \Smarty\Smarty();
|
||||
$debObj = new Smarty();
|
||||
// copy the working dirs from application
|
||||
$debObj->setCompileDir($smarty->getCompileDir());
|
||||
$debObj->compile_check = \Smarty::COMPILECHECK_ON;
|
||||
$debObj->compile_check = Smarty::COMPILECHECK_ON;
|
||||
$debObj->security_policy = null;
|
||||
$debObj->debugging = false;
|
||||
$debObj->debugging_ctrl = 'NONE';
|
||||
$debObj->error_reporting = E_ALL & ~E_NOTICE;
|
||||
$debObj->debug_tpl = $smarty->debug_tpl ?? 'file:' . __DIR__ . '/../debug.tpl';
|
||||
$debObj->debug_tpl = $smarty->debug_tpl ?? 'file:' . __DIR__ . '/debug.tpl';
|
||||
$debObj->registered_resources = array();
|
||||
$debObj->escape_html = true;
|
||||
$debObj->caching = \Smarty::CACHING_OFF;
|
||||
$debObj->caching = Smarty::CACHING_OFF;
|
||||
// prepare information of assigned variables
|
||||
$ptr = $this->get_debug_vars($obj);
|
||||
$_assigned_vars = $ptr->tpl_vars;
|
||||
@@ -223,7 +214,7 @@ class Debug extends Data
|
||||
$displayMode = $debugging === 2 || !$full;
|
||||
$offset = $this->offset * 50;
|
||||
$_template = $debObj->doCreateTemplate($debObj->debug_tpl);
|
||||
if ($obj instanceof \Smarty\Template) {
|
||||
if ($obj instanceof Template) {
|
||||
$_template->assign('template_name', $templateName);
|
||||
} elseif ($obj instanceof Smarty || $full) {
|
||||
$_template->assign('template_data', $this->template_data[$this->index]);
|
||||
@@ -298,11 +289,11 @@ class Debug extends Data
|
||||
/**
|
||||
* Return key into $template_data for template
|
||||
*
|
||||
* @param \Smarty\Template $template template object
|
||||
* @param Template $template template object
|
||||
*
|
||||
* @return string key into $template_data
|
||||
*/
|
||||
private function get_key(\Smarty\Template $template)
|
||||
private function get_key(Template $template)
|
||||
{
|
||||
static $_is_stringy = array('string' => true, 'eval' => true);
|
||||
|
||||
@@ -319,9 +310,9 @@ class Debug extends Data
|
||||
/**
|
||||
* Ignore template
|
||||
*
|
||||
* @param \Smarty\Template $template
|
||||
* @param Template $template
|
||||
*/
|
||||
public function ignore(\Smarty\Template $template)
|
||||
public function ignore(Template $template)
|
||||
{
|
||||
$this->ignore_uid[$template->getSource()->uid] = true;
|
||||
}
|
||||
@@ -329,9 +320,9 @@ class Debug extends Data
|
||||
/**
|
||||
* handle 'URL' debugging mode
|
||||
*
|
||||
* @param \Smarty $smarty
|
||||
* @param Smarty $smarty
|
||||
*/
|
||||
public function debugUrl(\Smarty $smarty)
|
||||
public function debugUrl(Smarty $smarty)
|
||||
{
|
||||
if (isset($_SERVER[ 'QUERY_STRING' ])) {
|
||||
$_query_string = $_SERVER[ 'QUERY_STRING' ];
|
||||
@@ -360,12 +351,12 @@ class Debug extends Data
|
||||
|
||||
/**
|
||||
* @param array $_is_stringy
|
||||
* @param \Smarty\Template $template
|
||||
* @param Template $template
|
||||
* @param string $key
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
private function saveTemplateData(array $_is_stringy, \Smarty\Template $template, string $key): void {
|
||||
private function saveTemplateData(array $_is_stringy, Template $template, string $key): void {
|
||||
if (isset($_is_stringy[$template->getSource()->type])) {
|
||||
$this->template_data[$this->index][$key]['name'] =
|
||||
'\'' . substr($template->getSource()->name, 0, 25) . '...\'';
|
||||
|
||||
@@ -77,7 +77,7 @@ class ErrorHandler
|
||||
}
|
||||
|
||||
if ($this->allowUndefinedArrayKeys && preg_match(
|
||||
'/^(Undefined index|Undefined array key|Trying to access array offset on value of type)/',
|
||||
'/^(Undefined index|Undefined array key|Trying to access array offset on)/',
|
||||
$errstr
|
||||
)) {
|
||||
return; // suppresses this error
|
||||
|
||||
@@ -2,20 +2,82 @@
|
||||
|
||||
namespace Smarty\Extension;
|
||||
|
||||
use Smarty\BlockHandler\BlockHandlerInterface;
|
||||
use Smarty\Compile\CompilerInterface;
|
||||
use Smarty\Compile\Modifier\ModifierCompilerInterface;
|
||||
use Smarty\FunctionHandler\FunctionHandlerInterface;
|
||||
|
||||
interface ExtensionInterface {
|
||||
|
||||
public function getTagCompiler(string $tag): ?\Smarty\Compile\CompilerInterface;
|
||||
/**
|
||||
* Either return \Smarty\Compile\CompilerInterface that will compile the given $tag or
|
||||
* return null to indicate that you do not know how to handle this $tag. (Another Extension might.)
|
||||
*
|
||||
* @param string $tag
|
||||
* @return CompilerInterface|null
|
||||
*/
|
||||
public function getTagCompiler(string $tag): ?CompilerInterface;
|
||||
|
||||
public function getModifierCompiler(string $modifier): ?\Smarty\Compile\Modifier\ModifierCompilerInterface;
|
||||
/**
|
||||
* Either return \Smarty\Compile\Modifier\ModifierCompilerInterface that will compile the given $modifier or
|
||||
* return null to indicate that you do not know how to handle this $modifier. (Another Extension might.)
|
||||
*
|
||||
* @param string $modifier
|
||||
* @return ModifierCompilerInterface|null
|
||||
*/
|
||||
public function getModifierCompiler(string $modifier): ?ModifierCompilerInterface;
|
||||
|
||||
public function getFunctionHandler(string $functionName): ?\Smarty\FunctionHandler\FunctionHandlerInterface;
|
||||
/**
|
||||
* Either return \Smarty\FunctionHandler\FunctionHandlerInterface that will handle the given $functionName or
|
||||
* return null to indicate that you do not know how to handle this $functionName. (Another Extension might.)
|
||||
*
|
||||
* @param string $functionName
|
||||
* @return FunctionHandlerInterface|null
|
||||
*/
|
||||
public function getFunctionHandler(string $functionName): ?FunctionHandlerInterface;
|
||||
|
||||
public function getBlockHandler(string $blockTagName): ?\Smarty\BlockHandler\BlockHandlerInterface;
|
||||
/**
|
||||
* Either return \Smarty\BlockHandler\BlockHandlerInterface that will handle the given $blockTagName or return null
|
||||
* to indicate that you do not know how to handle this $blockTagName. (Another Extension might.)
|
||||
*
|
||||
* @param string $blockTagName
|
||||
* @return BlockHandlerInterface|null
|
||||
*/
|
||||
public function getBlockHandler(string $blockTagName): ?BlockHandlerInterface;
|
||||
|
||||
/**
|
||||
* Either return a callable that takes at least 1 parameter (a string) and returns a modified string or return null
|
||||
* to indicate that you do not know how to handle this $modifierName. (Another Extension might.)
|
||||
*
|
||||
* The callable can accept additional optional parameters.
|
||||
*
|
||||
* @param string $modifierName
|
||||
* @return callable|null
|
||||
*/
|
||||
public function getModifierCallback(string $modifierName);
|
||||
|
||||
/**
|
||||
* Return a list of prefilters that will all be applied, in sequence.
|
||||
* Template prefilters can be used to preprocess templates before they are compiled.
|
||||
*
|
||||
* @return \Smarty\Filter\FilterInterface[]
|
||||
*/
|
||||
public function getPreFilters(): array;
|
||||
|
||||
/**
|
||||
* Return a list of postfilters that will all be applied, in sequence.
|
||||
* Template postfilters can be used to process compiled template code (so, after the compilation).
|
||||
*
|
||||
* @return \Smarty\Filter\FilterInterface[]
|
||||
*/
|
||||
public function getPostFilters(): array;
|
||||
|
||||
/**
|
||||
* Return a list of outputfilters that will all be applied, in sequence.
|
||||
* Template outputfilters can be used to change template output just before it is rendered.
|
||||
*
|
||||
* @return \Smarty\Filter\FilterInterface[]
|
||||
*/
|
||||
public function getOutputFilters(): array;
|
||||
|
||||
}
|
||||
+4
-3
@@ -53,7 +53,7 @@ class Smarty extends \Smarty\TemplateBase {
|
||||
/**
|
||||
* smarty version
|
||||
*/
|
||||
const SMARTY_VERSION = '5.0.0-rc1';
|
||||
const SMARTY_VERSION = '5.0.0-rc2';
|
||||
|
||||
/**
|
||||
* define caching modes
|
||||
@@ -251,9 +251,10 @@ class Smarty extends \Smarty\TemplateBase {
|
||||
|
||||
/**
|
||||
* debug mode
|
||||
* Setting this to true enables the debug-console.
|
||||
* Setting this to true enables the debug-console. Setting it to 2 enables individual Debug Console window by
|
||||
* template name.
|
||||
*
|
||||
* @var boolean
|
||||
* @var boolean|int
|
||||
*/
|
||||
public $debugging = false;
|
||||
|
||||
|
||||
+3
-3
@@ -1,4 +1,4 @@
|
||||
{capture name='_smarty_debug' assign=debug_output}
|
||||
{capture name='_smarty_debug' assign='debug_output'}
|
||||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
@@ -108,7 +108,7 @@
|
||||
</head>
|
||||
<body>
|
||||
|
||||
<h1>Smarty {Smarty::SMARTY_VERSION} Debug Console
|
||||
<h1>Smarty {\Smarty\Smarty::SMARTY_VERSION} Debug Console
|
||||
- {if isset($template_name)}{$template_name|debug_print_var nofilter} {/if}{if !empty($template_data)}Total Time {$execution_time|string_format:"%.5f"}{/if}</h1>
|
||||
|
||||
{if !empty($template_data)}
|
||||
@@ -166,7 +166,7 @@
|
||||
</body>
|
||||
</html>
|
||||
{/capture}
|
||||
<script type="text/javascript">
|
||||
<script>
|
||||
_smarty_console = window.open("", "console{$targetWindow}", "width=1024,height=600,left={$offset},top={$offset},resizable,scrollbars=yes");
|
||||
_smarty_console.document.write("{$debug_output|escape:'javascript' nofilter}");
|
||||
_smarty_console.document.close();
|
||||
|
||||
@@ -0,0 +1,22 @@
|
||||
<?php
|
||||
|
||||
namespace UnitTests\TemplateSource\TagTests\Debug;
|
||||
use PHPUnit_Smarty;
|
||||
use Smarty\Smarty;
|
||||
|
||||
/**
|
||||
* Smarty PHPunit tests of {debug} tag
|
||||
*/
|
||||
class PluginModifierStripTagsTest extends PHPUnit_Smarty {
|
||||
|
||||
public function setUp(): void {
|
||||
$this->setUpSmarty(__DIR__);
|
||||
}
|
||||
public function testDefault() {
|
||||
$tpl = $this->smarty->createTemplate('eval:{debug}');
|
||||
$output = $this->smarty->fetch($tpl);
|
||||
$this->assertStringContainsString("<script", $output);
|
||||
$this->assertStringContainsString("</script>", $output);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,10 @@
|
||||
FROM php:8.3-cli
|
||||
|
||||
## Basic utilities
|
||||
RUN apt-get update -yqq && apt-get install -y curl apt-utils git zip unzip
|
||||
|
||||
## Composer
|
||||
COPY ./utilities/testrunners/shared/install-composer.sh /root/install-composer.sh
|
||||
WORKDIR /root
|
||||
RUN sh ./install-composer.sh
|
||||
RUN mv ./composer.phar /usr/local/bin/composer
|
||||
@@ -0,0 +1,42 @@
|
||||
<?php
|
||||
|
||||
// This takes the *.md files in changelog/ dir and inserts them
|
||||
// right below the '## [Unreleased]' marker in CHANGELOG.md
|
||||
|
||||
$path_to_main_changelog = 'CHANGELOG.md';
|
||||
$marker = '## [Unreleased]';
|
||||
$changelog_files_pattern = 'changelog/*.md';
|
||||
$new_version = $argv[1];
|
||||
|
||||
$file_contents = file_get_contents($path_to_main_changelog);
|
||||
|
||||
foreach (glob($changelog_files_pattern) as $filename) {
|
||||
$content_to_insert = file_get_contents($filename);
|
||||
|
||||
if (!endsWithNewline($content_to_insert)) {
|
||||
$content_to_insert .= "\n";
|
||||
}
|
||||
|
||||
$file_contents = str_replace(
|
||||
$marker,
|
||||
$marker . $content_to_insert,
|
||||
$file_contents
|
||||
);
|
||||
unlink($filename);
|
||||
}
|
||||
|
||||
|
||||
// add the version number and date
|
||||
$file_contents = str_replace(
|
||||
$marker,
|
||||
$marker . sprintf("\n\n## [%s] - %s\n", $new_version, date('Y-m-d')),
|
||||
$file_contents
|
||||
);
|
||||
|
||||
file_put_contents($path_to_main_changelog, $file_contents);
|
||||
|
||||
|
||||
function endsWithNewline($str): bool
|
||||
{
|
||||
return preg_match('/[\r\n]$/', $str) === 1;
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
<?php
|
||||
|
||||
// This takes the Smarty class file and updates the SMARTY_VERSION constant
|
||||
|
||||
$path_to_smarty_class = 'src/Smarty.php';
|
||||
$pattern = "/const SMARTY_VERSION = '[^']+'/";
|
||||
$replacement = "const SMARTY_VERSION = '" . $argv[1] . "'";
|
||||
|
||||
$file_contents = preg_replace($pattern, $replacement, file_get_contents($path_to_smarty_class));
|
||||
|
||||
file_put_contents($path_to_smarty_class, $file_contents);
|
||||
Reference in New Issue
Block a user