mirror of
https://github.com/smarty-php/smarty.git
synced 2026-08-04 12:34:33 +02:00
Compare commits
2 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| ed144d97bd | |||
| 6218f395f4 |
@@ -6,31 +6,11 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
||||
|
||||
## [Unreleased]
|
||||
|
||||
## [5.0.0] - 2024-03-25
|
||||
- Fixed that scoped variables would overwrite parent scope [#952](https://github.com/smarty-php/smarty/issues/952)
|
||||
- Removed publicly accessible `$tpl->_var_stack` variable
|
||||
|
||||
|
||||
### Fixed
|
||||
- Too many shorthand attributes error when using a modifier as a function with more than 3 parameters in an expression [#949](https://github.com/smarty-php/smarty/issues/949)
|
||||
|
||||
### Removed
|
||||
- Dropped support for undocumented `{time()}` added in v5.0.0 since we already have the documented `{$smarty.now}`
|
||||
|
||||
## [5.0.0-rc3] - 2024-02-26
|
||||
|
||||
### Added
|
||||
- PHP8.3 support [#925](https://github.com/smarty-php/smarty/issues/925)
|
||||
- Backlink to GitHub in docs
|
||||
- Explain how to do escaping and set-up auto-escaping in docs [#865](https://github.com/smarty-php/smarty/issues/865)
|
||||
- Link to variable scope page in the documentation for the assign tag [#878](https://github.com/smarty-php/smarty/issues/878)
|
||||
- Add support for implode, substr and json_encode as modifiers/functions in templates [#939](https://github.com/smarty-php/smarty/issues/939)
|
||||
- Add template path to CompilerException to enable rich debug features [#935](https://github.com/smarty-php/smarty/issues/935)
|
||||
|
||||
### Fixed
|
||||
- The {debug} tag was broken in v5 [#922](https://github.com/smarty-php/smarty/issues/922)
|
||||
- Documentation on `{if $x is even by $y}` syntax
|
||||
- Fix incorrect compilation of expressions when escape_html=true [#930](https://github.com/smarty-php/smarty/pull/930)
|
||||
|
||||
## [5.0.0-rc2] - 2023-11-11
|
||||
|
||||
|
||||
@@ -7,7 +7,7 @@ Smarty is a template engine for PHP, facilitating the separation of presentation
|
||||
Read the [documentation](https://smarty-php.github.io/smarty/) to find out how to use it.
|
||||
|
||||
## Requirements
|
||||
Smarty v5 can be run with PHP 7.2 to PHP 8.3.
|
||||
Smarty v5 can be run with PHP 7.2 to PHP 8.2.
|
||||
|
||||
## Installation
|
||||
Smarty versions 3.1.11 or later can be installed with [Composer](https://getcomposer.org/).
|
||||
|
||||
@@ -29,4 +29,5 @@
|
||||
|
||||
## Unrelated / other
|
||||
- review (and avoid) use of 'clone' keyword
|
||||
- compiler->has_code seems silly. Why not have proper return values?
|
||||
- what is 'user literal support', why are unit tests skipped?
|
||||
|
||||
@@ -1 +0,0 @@
|
||||
- Internal compiler classes always return a string (the internal has_code flag has been removed for simplicity) [#918](https://github.com/smarty-php/smarty/pull/918)
|
||||
+1
-2
@@ -89,5 +89,4 @@ Run this, and you will see:
|
||||
```
|
||||
|
||||
Note how the [escape modifier](../designers/language-modifiers/language-modifier-escape.md)
|
||||
translated the `&` character into the proper HTML syntax `&`.
|
||||
Read more about auto-escaping in the [next section](./configuring.md).
|
||||
translated the `&` character into the proper HTML syntax `&`.
|
||||
@@ -122,24 +122,6 @@ $smarty->setCacheDir('/data/caches');
|
||||
$cacheDir = $smarty->getCacheDir();
|
||||
```
|
||||
|
||||
## Enabling auto-escaping
|
||||
By default, Smarty does not escape anything you render in your templates. If you use
|
||||
Smarty to render a HTML-page, this means that you will have to make sure that you do
|
||||
not render any characters that have a special meaning in HTML, such as `&`, `<` and `>`,
|
||||
or apply the [escape modifier](../designers/language-modifiers/language-modifier-escape.md)
|
||||
to anything you want to render.
|
||||
|
||||
If you forget to do so, you may break your HTML page, or even create a vulnerability for
|
||||
attacks known as [XSS or Cross Site Scripting](https://cheatsheetseries.owasp.org/cheatsheets/Cross_Site_Scripting_Prevention_Cheat_Sheet.html).
|
||||
|
||||
Luckily, you can tell Smarty to automatically apply the escape modifier to any dynamic part of your template.
|
||||
It's like Smarty magically adds `|escape` to every variable you use on a web page.
|
||||
|
||||
Enable auto-escaping for HTML as follows:
|
||||
```php
|
||||
$smarty->setEscapeHtml(true);
|
||||
```
|
||||
|
||||
## Disabling compile check
|
||||
By default, Smarty tests to see if the
|
||||
current template has changed since the last time
|
||||
|
||||
@@ -88,6 +88,9 @@ Object chaining:
|
||||
|
||||
{$object->method1($x)->method2($y)}
|
||||
|
||||
Direct PHP function access:
|
||||
|
||||
{time()}
|
||||
```
|
||||
|
||||
> **Note**
|
||||
|
||||
@@ -8,12 +8,12 @@ execution of a template**.
|
||||
|----------------|------------|-----------------------------------------------------------------------|
|
||||
| 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' |
|
||||
| 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' |
|
||||
| scope | (optional) | The scope of the assigned variable: \'parent\',\'root\' or \'global\' |
|
||||
|
||||
## Option Flags
|
||||
| Name | Description |
|
||||
@@ -102,8 +102,6 @@ A global variable is seen by all templates.
|
||||
{$foo="bar" scope="global"}
|
||||
```
|
||||
|
||||
For more information on variable scope, please read the page on [variable scopes](../language-variables/language-variable-scopes.md).
|
||||
|
||||
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`.
|
||||
|
||||
@@ -252,7 +252,7 @@ iteration.
|
||||
|
||||
```smarty
|
||||
{foreach $myNames as $name}
|
||||
{if $name@index is even by 3}
|
||||
{if $name@iteration is even by 3}
|
||||
<span style="color: #000">{$name}</span>
|
||||
{else}
|
||||
<span style="color: #eee">{$name}</span>
|
||||
|
||||
@@ -478,13 +478,13 @@ header block every five rows.
|
||||
</table>
|
||||
```
|
||||
|
||||
An example that uses the `index` property to alternate a text color every
|
||||
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.index is even by 3}
|
||||
{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>
|
||||
|
||||
@@ -6,10 +6,34 @@ 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).
|
||||
(colon). Also, *all php-functions can be used as modifiers implicitly*
|
||||
(more below) and modifiers can be
|
||||
[combined](../language-combining-modifiers.md).
|
||||
|
||||
Modifiers can be applied to any type of variables, including arrays
|
||||
and objects.
|
||||
- [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
|
||||
|
||||
@@ -41,63 +65,40 @@ and objects.
|
||||
{* php's count *}
|
||||
{$myArray|@count}
|
||||
|
||||
{* this will uppercase the whole array *}
|
||||
{* this will uppercase and truncate the whole array *}
|
||||
<select name="name_id">
|
||||
{html_options output=$my_array|upper}
|
||||
{html_options output=$my_array|upper|truncate:20}
|
||||
</select>
|
||||
```
|
||||
|
||||
- Modifiers can be applied to any type of variables, including arrays
|
||||
and objects.
|
||||
|
||||
## Combining Modifiers
|
||||
> **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.
|
||||
|
||||
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.
|
||||
> **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}`.
|
||||
|
||||
```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. . .
|
||||
```
|
||||
|
||||
## Using modifiers in expressions
|
||||
|
||||
Modifiers can also be used in expressions. For example, you can use the [isset modifier](./language-modifier-isset.md)
|
||||
to test if a variable holds a value different from null.
|
||||
|
||||
```smarty
|
||||
{if $varA|isset}
|
||||
<b>variable A is set</b>
|
||||
{/if}
|
||||
```
|
||||
|
||||
You can also use modifiers in expressions in a PHP-style syntax:
|
||||
|
||||
```smarty
|
||||
{if isset($varA)}
|
||||
<b>variable A is set</b>
|
||||
{/if}
|
||||
```
|
||||
- Custom modifiers can be registered
|
||||
with the [`registerPlugin()`](../../programmers/api-functions/api-register-plugin.md)
|
||||
function.
|
||||
|
||||
See also [`registerPlugin()`](../../programmers/api-functions/api-register-plugin.md), [combining
|
||||
modifiers](../language-combining-modifiers.md). and [extending smarty with
|
||||
|
||||
@@ -1,21 +0,0 @@
|
||||
# count
|
||||
|
||||
Returns the number of elements in an array (or Countable object). Will return 0 for null.
|
||||
Returns 1 for any other type (such as a string).
|
||||
|
||||
If the optional mode parameter is set to 1, count() will recursively count the array.
|
||||
This is particularly useful for counting all the elements of a multidimensional array.
|
||||
|
||||
## Basic usage
|
||||
```smarty
|
||||
{if $myVar|count > 3}4 or more{/if}
|
||||
{if count($myVar) > 3}4 or more{/if}
|
||||
```
|
||||
|
||||
|
||||
## Parameters
|
||||
|
||||
| Parameter | Type | Required | Description |
|
||||
|-----------|------|----------|--------------------------------------------------------|
|
||||
| 1 | int | No | If set to 1, count() will recursively count the array. |
|
||||
|
||||
@@ -1,26 +0,0 @@
|
||||
# debug_print_var
|
||||
|
||||
|
||||
|
||||
Returns the value of the given variable in a human-readable format in HTML.
|
||||
Used in the [debug console](../chapter-debugging-console.md), but you can also use it in your template
|
||||
while developing to see what is going on under the hood.
|
||||
|
||||
> **Note**
|
||||
>
|
||||
> Use for debugging only! Since you may accidentally reveal sensitive information or introduce vulnerabilities such as XSS using this
|
||||
method never use it in production.
|
||||
|
||||
## Basic usage
|
||||
```smarty
|
||||
{$myVar|debug_print_var}
|
||||
```
|
||||
|
||||
|
||||
## Parameters
|
||||
|
||||
| Parameter | Type | Required | Description |
|
||||
|-----------|------|----------|------------------------------------------------------------------------|
|
||||
| 1 | int | No | maximum recursion depth if $var is an array or object (defaults to 10) |
|
||||
| 2 | int | No | maximum string length if $var is a string (defaults to 40) |
|
||||
|
||||
@@ -1,11 +0,0 @@
|
||||
# isset
|
||||
|
||||
Returns true if the variable(s) passed to it are different from null.
|
||||
|
||||
If multiple parameters are supplied then isset() will return true only if all of the parameters are
|
||||
not null.
|
||||
|
||||
## Basic usage
|
||||
```smarty
|
||||
{if $myVar|isset}all set!{/if}
|
||||
```
|
||||
@@ -1,26 +0,0 @@
|
||||
# join
|
||||
|
||||
Returns a string containing all the element of the given array
|
||||
with the separator string between each.
|
||||
|
||||
## Basic usage
|
||||
|
||||
For `$myArray` populated with `['a','b','c']`, the following will return the string `abc`.
|
||||
```smarty
|
||||
{$myArray|join}
|
||||
```
|
||||
|
||||
|
||||
## Parameters
|
||||
|
||||
| Parameter | Type | Required | Description |
|
||||
|-----------|--------|----------|-------------------------------------------------------------|
|
||||
| 1 | string | No | glue used between array elements. Defaults to empty string. |
|
||||
|
||||
## Examples
|
||||
|
||||
|
||||
For `$myArray` populated with `[1,2,3]`, the following will return the string `1-2-3`.
|
||||
```smarty
|
||||
{$myArray|join:"-"}
|
||||
```
|
||||
@@ -1,27 +0,0 @@
|
||||
# json_encode
|
||||
|
||||
Transforms a value into a valid JSON string.
|
||||
|
||||
## Basic usage
|
||||
```smarty
|
||||
{$user|json_encode}
|
||||
```
|
||||
Depending on the value of `$user` this would return a string in JSON-format, e.g. `{"username":"my_username","email":"my_username@smarty.net"}`.
|
||||
|
||||
|
||||
## Parameters
|
||||
|
||||
| Parameter | Type | Required | Description |
|
||||
|-----------|------|----------|-------------------------------------------------------------------------------------------|
|
||||
| 1 | int | No | bitmask of flags, directly passed to [PHP's json_encode](https://www.php.net/json_encode) |
|
||||
|
||||
|
||||
## Examples
|
||||
|
||||
By passing `16` as the second parameter, you can force json_encode to always format the JSON-string as an object.
|
||||
Without it, an array `$myArray = ["a","b"]` would be formatted as a javascript array:
|
||||
|
||||
```smarty
|
||||
{$myArray|json_encode} # renders: ["a","b"]
|
||||
{$myArray|json_encode:16} # renders: {"0":"a","1":"b"}
|
||||
```
|
||||
@@ -1,9 +0,0 @@
|
||||
# noprint
|
||||
|
||||
Always returns an empty string. This can be used to call a function or a method on an object that
|
||||
returns output, and suppress the output.
|
||||
|
||||
## Basic usage
|
||||
```smarty
|
||||
{$controller->sendEmail()|noprint}
|
||||
```
|
||||
@@ -1,32 +0,0 @@
|
||||
# number_format
|
||||
|
||||
Allows you to format a number using decimals and a thousands-separator. By default, the number of decimals is 0
|
||||
and the number is rounded.
|
||||
|
||||
## Basic usage
|
||||
```smarty
|
||||
{$num = 2000.151}
|
||||
{$num|number_format} # renders: 2,000
|
||||
```
|
||||
|
||||
|
||||
## Parameters
|
||||
|
||||
| Parameter | Type | Required | Description |
|
||||
|-----------|--------|----------|---------------------------------------|
|
||||
| 1 | int | No | number of decimals (defaults to 0) |
|
||||
| 2 | string | No | decimal separator (defaults to ".") |
|
||||
| 3 | string | No | thousands-separator (defaults to ",") |
|
||||
|
||||
|
||||
## Examples
|
||||
|
||||
```smarty
|
||||
{$num = 2000.151}
|
||||
{$num|number_format:2} # renders: 2,000.15
|
||||
```
|
||||
|
||||
```smarty
|
||||
{$num = 2000.151}
|
||||
{$num|number_format:2:".":""} # renders: 2000.15
|
||||
```
|
||||
@@ -1,35 +0,0 @@
|
||||
# round
|
||||
|
||||
Rounds a number to the specified precision.
|
||||
|
||||
## Basic usage
|
||||
```smarty
|
||||
{3.14|round} # renders: 3
|
||||
```
|
||||
|
||||
```smarty
|
||||
{3.141592|round:2} # renders: 3.14
|
||||
```
|
||||
|
||||
## Parameters
|
||||
|
||||
| Parameter | Type | Required | Description |
|
||||
|-----------|------|----------|---------------------------|
|
||||
| 1 | int | No | precision (defaults to 0) |
|
||||
| 2 | int | No | mode (defaults to 1) |
|
||||
|
||||
If 'precision' is negative, the number is rounded to the nearest power of 10. See examples below.
|
||||
|
||||
The parameter 'mode' defines how the rounding is done. By default, 2.5 is rounded to 3, whereas 2.45 is rounded to 2.
|
||||
You usually don't need to change this. For more details on rounding modes,
|
||||
see [PHP's documentation on round](https://www.php.net/manual/en/function.round).
|
||||
|
||||
## Examples
|
||||
|
||||
By passing `16` as the second parameter, you can force json_encode to always format the JSON-string as an object.
|
||||
Without it, an array `$myArray = ["a","b"]` would be formatted as a javascript array:
|
||||
|
||||
```smarty
|
||||
{$myArray|json_encode} # renders: ["a","b"]
|
||||
{$myArray|json_encode:16} # renders: {"0":"a","1":"b"}
|
||||
```
|
||||
@@ -1,32 +0,0 @@
|
||||
# split
|
||||
|
||||
Splits a string into an array, using the optional second parameter as the separator.
|
||||
|
||||
## Basic usage
|
||||
|
||||
For `$chars` populated with `'abc'`, the following will produce a html list with 3 elements (a, b and c).
|
||||
```smarty
|
||||
<ol>
|
||||
{foreach $chars|split as $char}
|
||||
<li>{$char|escape}</li>
|
||||
{/foreach}
|
||||
</ol>
|
||||
```
|
||||
|
||||
## Parameters
|
||||
|
||||
| Parameter | Type | Required | Description |
|
||||
|-----------|--------|----------|------------------------------------------------------------------------------------------------------------------------------|
|
||||
| 1 | string | No | separator used to split the string on. Defaults to empty string, causing each character in the source string to be separate. |
|
||||
|
||||
## Examples
|
||||
|
||||
|
||||
For `$ids` populated with `'1,2,3'`, the following will produce a html list with 3 elements (1, 2 and 3).
|
||||
```smarty
|
||||
<ol>
|
||||
{foreach $ids|split:',' as $id}
|
||||
<li>{$id|escape}</li>
|
||||
{/foreach}
|
||||
</ol>
|
||||
```
|
||||
@@ -1,14 +0,0 @@
|
||||
# str_repeat
|
||||
|
||||
Repeats the given value n times.
|
||||
|
||||
## Basic usage
|
||||
```smarty
|
||||
{"hi"|str_repeat:2} # renders: hihi
|
||||
```
|
||||
|
||||
## Parameters
|
||||
|
||||
| Parameter | Type | Required | Description |
|
||||
|-----------|------|----------|-----------------------|
|
||||
| 1 | int | yes | number of repetitions |
|
||||
@@ -1,9 +0,0 @@
|
||||
# strlen
|
||||
|
||||
Returns the length (number of characters) in the given string, including spaces.
|
||||
|
||||
## Basic usage
|
||||
```smarty
|
||||
{"Smarty"|strlen} # renders: 6
|
||||
{156|strlen} # renders: 3
|
||||
```
|
||||
@@ -1,25 +0,0 @@
|
||||
# substr
|
||||
|
||||
Returns a part (substring) of the given string starting at a given offset.
|
||||
|
||||
## Basic usage
|
||||
```smarty
|
||||
{"Smarty"|substr:2} # renders: arty
|
||||
{"Smarty"|substr:2:3} # renders: art
|
||||
```
|
||||
|
||||
## Parameters
|
||||
|
||||
| Parameter | Type | Required | Description |
|
||||
|-----------|------|----------|-----------------------------------------------------|
|
||||
| 1 | int | yes | offset (zero based, can be negative) |
|
||||
| 2 | int | no | length of substring returned (unlimited of omitted) |
|
||||
|
||||
|
||||
## Examples
|
||||
|
||||
When used with a negative offset, the substring starts n characters from the end of the string counting backwards.
|
||||
```smarty
|
||||
{"Smarty"|substr:-2} # renders: ty
|
||||
{"Smarty"|substr:-2:1} # renders: t
|
||||
```
|
||||
@@ -29,5 +29,5 @@ 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`](./language-modifier-lower.md) and
|
||||
See also [`lower`](lower) and
|
||||
[`capitalize`](language-modifier-capitalize.md).
|
||||
|
||||
+2
-18
@@ -1,7 +1,7 @@
|
||||
# Getting started
|
||||
|
||||
## Requirements
|
||||
Smarty can be run with PHP 7.2 to PHP 8.3.
|
||||
Smarty can be run with PHP 7.2 to PHP 8.2.
|
||||
|
||||
## Installation
|
||||
Smarty can be installed with [Composer](https://getcomposer.org/).
|
||||
@@ -86,7 +86,7 @@ needs to be located in the [`$template_dir`](./programmers/api-variables/variabl
|
||||
|
||||
```smarty
|
||||
{* Smarty *}
|
||||
<h1>Hello {$name|escape}, welcome to Smarty!</h1>
|
||||
Hello {$name}, welcome to Smarty!
|
||||
```
|
||||
|
||||
> **Note**
|
||||
@@ -132,20 +132,6 @@ Now, run your PHP file. You should see *"Hello Ned, welcome to Smarty!"*
|
||||
|
||||
You have completed the basic setup for Smarty!
|
||||
|
||||
## Escaping
|
||||
You may have noticed that the example template above renders the `$name` variable using
|
||||
the [escape modifier](./designers/language-modifiers/language-modifier-escape.md). This
|
||||
modifier makes string 'safe' to use in the context of an HTML page.
|
||||
|
||||
If you are primarily using Smarty for HTML-pages, it is recommended to enable automatic
|
||||
escaping. This way, you don't have to add `|escape` to every variable you use on a web page.
|
||||
Smarty will handle it automatically for you!
|
||||
|
||||
Enable auto-escaping for HTML as follows:
|
||||
```php
|
||||
$smarty->setEscapeHtml(true);
|
||||
```
|
||||
|
||||
## Extended Setup
|
||||
|
||||
This is a continuation of the [basic installation](#installation), please read that first!
|
||||
@@ -170,8 +156,6 @@ class My_GuestBook extends Smarty {
|
||||
$this->setCompileDir('/web/www.example.com/guestbook/templates_c/');
|
||||
$this->setConfigDir('/web/www.example.com/guestbook/configs/');
|
||||
$this->setCacheDir('/web/www.example.com/guestbook/cache/');
|
||||
|
||||
$this->setEscapeHtml(true);
|
||||
|
||||
$this->caching = Smarty::CACHING_LIFETIME_CURRENT;
|
||||
$this->assign('app_name', 'Guest Book');
|
||||
|
||||
@@ -26,10 +26,6 @@ and 480 for $height, the result is:
|
||||
- [Features](./features.md) - or "Why do I want Smarty?"
|
||||
|
||||
## Help
|
||||
- [Search or create an issue](https://github.com/smarty-php/smarty/issues)
|
||||
- [Upgrading from an older version](upgrading.md)
|
||||
- [Some random tips & tricks](./appendixes/tips.md)
|
||||
- [Troubleshooting](./appendixes/troubleshooting.md)
|
||||
|
||||
## Source code
|
||||
- [Smarty repository at GitHub](https://github.com/smarty-php/smarty)
|
||||
@@ -117,7 +117,6 @@ The following constants have been removed to prevent global side effects.
|
||||
- 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"}`
|
||||
- The ::getFile() method of a CompilerException will now return the full path of the template being compiled, if possible. This used to be 'file:relative_dir/filename.tpl'.
|
||||
|
||||
## Upgrading from v3 to v4
|
||||
|
||||
|
||||
+1
-1
@@ -12,7 +12,7 @@ git checkout -b "release/$1"
|
||||
php utilities/update-changelog.php $1
|
||||
php utilities/update-smarty-version-number.php $1
|
||||
|
||||
git add changelog CHANGELOG.md src/Smarty.php
|
||||
git add CHANGELOG.md src/Smarty.php
|
||||
git commit -m "version bump"
|
||||
|
||||
git checkout master
|
||||
|
||||
+1
-12
@@ -49,40 +49,29 @@ nav:
|
||||
- 'Introduction': 'designers/language-modifiers/index.md'
|
||||
- 'capitalize': 'designers/language-modifiers/language-modifier-capitalize.md'
|
||||
- 'cat': 'designers/language-modifiers/language-modifier-cat.md'
|
||||
- 'count': 'designers/language-modifiers/language-modifier-count.md'
|
||||
- 'count_characters': 'designers/language-modifiers/language-modifier-count-characters.md'
|
||||
- 'count_paragraphs': 'designers/language-modifiers/language-modifier-count-paragraphs.md'
|
||||
- 'count_sentences': 'designers/language-modifiers/language-modifier-count-sentences.md'
|
||||
- 'count_words': 'designers/language-modifiers/language-modifier-count-words.md'
|
||||
- 'date_format': 'designers/language-modifiers/language-modifier-date-format.md'
|
||||
- 'debug_print_var': 'designers/language-modifiers/language-modifier-debug-print-var.md'
|
||||
- 'default': 'designers/language-modifiers/language-modifier-default.md'
|
||||
- 'escape': 'designers/language-modifiers/language-modifier-escape.md'
|
||||
- 'from_charset': 'designers/language-modifiers/language-modifier-from-charset.md'
|
||||
- 'indent': 'designers/language-modifiers/language-modifier-indent.md'
|
||||
- 'isset': 'designers/language-modifiers/language-modifier-isset.md'
|
||||
- 'join': 'designers/language-modifiers/language-modifier-join.md'
|
||||
- 'json_encode': 'designers/language-modifiers/language-modifier-json-encode.md'
|
||||
- 'lower': 'designers/language-modifiers/language-modifier-lower.md'
|
||||
- 'noprint': 'designers/language-modifiers/language-modifier-noprint.md'
|
||||
- 'number_format': 'designers/language-modifiers/language-modifier-number-format.md'
|
||||
- 'nl2br': 'designers/language-modifiers/language-modifier-nl2br.md'
|
||||
- 'regex_replace': 'designers/language-modifiers/language-modifier-regex-replace.md'
|
||||
- 'replace': 'designers/language-modifiers/language-modifier-replace.md'
|
||||
- 'round': 'designers/language-modifiers/language-modifier-round.md'
|
||||
- 'spacify': 'designers/language-modifiers/language-modifier-spacify.md'
|
||||
- 'split': 'designers/language-modifiers/language-modifier-split.md'
|
||||
- 'str_repeat': 'designers/language-modifiers/language-modifier-str-repeat.md'
|
||||
- 'string_format': 'designers/language-modifiers/language-modifier-string-format.md'
|
||||
- 'strip': 'designers/language-modifiers/language-modifier-strip.md'
|
||||
- 'strip_tags': 'designers/language-modifiers/language-modifier-strip-tags.md'
|
||||
- 'strlen': 'designers/language-modifiers/language-modifier-strlen.md'
|
||||
- 'substr': 'designers/language-modifiers/language-modifier-substr.md'
|
||||
- 'to_charset': 'designers/language-modifiers/language-modifier-to-charset.md'
|
||||
- 'truncate': 'designers/language-modifiers/language-modifier-truncate.md'
|
||||
- 'unescape': 'designers/language-modifiers/language-modifier-unescape.md'
|
||||
- 'upper': 'designers/language-modifiers/language-modifier-upper.md'
|
||||
- 'wordwrap': 'designers/language-modifiers/language-modifier-wordwrap.md'
|
||||
- 'Combining Modifiers': 'designers/language-combining-modifiers.md'
|
||||
- 'Builtin Tags':
|
||||
- 'Introduction': 'designers/language-builtin-functions/index.md'
|
||||
- '{append}': 'designers/language-builtin-functions/language-function-append.md'
|
||||
|
||||
@@ -8,7 +8,7 @@
|
||||
COMPOSE_CMD="mutagen-compose"
|
||||
|
||||
$COMPOSE_CMD run --rm php72 ./run-tests.sh $@ && \
|
||||
$COMPOSE_CMD run --rm php73 ./run-tests.sh $@ && \
|
||||
$COMPOSE_CMD run --rm php74 ./run-tests.sh $@ && \
|
||||
$COMPOSE_CMD run --rm php74 ./run-tests.sh $@ && \
|
||||
$COMPOSE_CMD run --rm php80 ./run-tests.sh $@ && \
|
||||
$COMPOSE_CMD run --rm php81 ./run-tests.sh $@ && \
|
||||
|
||||
@@ -226,8 +226,8 @@ abstract class Base implements CompilerInterface {
|
||||
* @param Template $compiler compiler object
|
||||
* @param array $parameter array with compilation parameter
|
||||
*
|
||||
* @return string compiled code as a string
|
||||
* @return bool|string compiled code or true if no code has been compiled
|
||||
* @throws \Smarty\CompilerException
|
||||
*/
|
||||
abstract public function compile($args, Template $compiler, $parameter = array(), $tag = null, $function = null): string;
|
||||
abstract public function compile($args, Template $compiler, $parameter = array(), $tag = null, $function = null);
|
||||
}
|
||||
|
||||
@@ -50,8 +50,7 @@ class BlockCompiler extends Base {
|
||||
* @throws CompilerException
|
||||
* @throws Exception
|
||||
*/
|
||||
public function compile($args, Template $compiler, $parameter = [], $tag = null, $function = null): string
|
||||
{
|
||||
public function compile($args, Template $compiler, $parameter = [], $tag = null, $function = null) {
|
||||
|
||||
if (!isset($tag[5]) || substr($tag, -5) !== 'close') {
|
||||
$output = $this->compileOpeningTag($compiler, $args, $tag, $function);
|
||||
@@ -78,6 +77,7 @@ class BlockCompiler extends Base {
|
||||
);
|
||||
}
|
||||
$compiler->_cache['blockParams'][$compiler->_cache['blockNesting']]['callsChild'] = true;
|
||||
$compiler->has_code = true;
|
||||
$compiler->suppressNocacheProcessing = true;
|
||||
|
||||
$output = "<?php \n";
|
||||
@@ -102,6 +102,7 @@ class BlockCompiler extends Base {
|
||||
$compiler->getParser()->lex->taglineno
|
||||
);
|
||||
}
|
||||
$compiler->has_code = true;
|
||||
$compiler->suppressNocacheProcessing = true;
|
||||
|
||||
$output = "<?php \n";
|
||||
|
||||
@@ -17,10 +17,10 @@ interface CompilerInterface {
|
||||
* @param \Smarty\Compiler\Template $compiler compiler object
|
||||
* @param array $parameter array with compilation parameter
|
||||
*
|
||||
* @return string compiled code as a string
|
||||
* @return bool|string compiled code or true if no code has been compiled
|
||||
* @throws \Smarty\CompilerException
|
||||
*/
|
||||
public function compile($args, \Smarty\Compiler\Template $compiler, $parameter = [], $tag = null, $function = null): string;
|
||||
public function compile($args, \Smarty\Compiler\Template $compiler, $parameter = [], $tag = null, $function = null);
|
||||
|
||||
public function isCacheable(): bool;
|
||||
}
|
||||
@@ -27,8 +27,7 @@ class DefaultHandlerFunctionCallCompiler extends Base {
|
||||
* @throws \Smarty\CompilerException
|
||||
* @throws \Smarty\Exception
|
||||
*/
|
||||
public function compile($args, Template $compiler, $parameter = [], $tag = null, $function = null): string
|
||||
{
|
||||
public function compile($args, Template $compiler, $parameter = [], $tag = null, $function = null) {
|
||||
// check and get attributes
|
||||
$_attr = $this->getAttributes($compiler, $args);
|
||||
unset($_attr['nocache']);
|
||||
|
||||
@@ -34,7 +34,7 @@ class FunctionCallCompiler extends Base {
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
protected $shorttag_order = [];
|
||||
protected $shorttag_order = ['var1', 'var2', 'var3'];
|
||||
|
||||
/**
|
||||
* Compiles code for the execution of a registered function
|
||||
@@ -49,8 +49,7 @@ class FunctionCallCompiler extends Base {
|
||||
* @throws \Smarty\CompilerException
|
||||
* @throws \Smarty\Exception
|
||||
*/
|
||||
public function compile($args, Template $compiler, $parameter = [], $tag = null, $function = null): string
|
||||
{
|
||||
public function compile($args, Template $compiler, $parameter = [], $tag = null, $function = null) {
|
||||
|
||||
// check and get attributes
|
||||
$_attr = $this->getAttributes($compiler, $args);
|
||||
@@ -59,15 +58,19 @@ class FunctionCallCompiler extends Base {
|
||||
$_paramsArray = $this->formatParamsArray($_attr);
|
||||
$_params = 'array(' . implode(',', $_paramsArray) . ')';
|
||||
|
||||
try {
|
||||
$value = array_shift($_attr);
|
||||
$output = $compiler->compileModifier([array_merge([$function], $_attr)], $value);
|
||||
} catch (\Smarty\CompilerException $e) {
|
||||
if ($functionHandler = $compiler->getSmarty()->getFunctionHandler($function)) {
|
||||
|
||||
if ($functionHandler = $compiler->getSmarty()->getFunctionHandler($function)) {
|
||||
|
||||
// not cacheable?
|
||||
$compiler->tag_nocache = $compiler->tag_nocache || !$functionHandler->isCacheable();
|
||||
$output = "\$_smarty_tpl->getSmarty()->getFunctionHandler(" . var_export($function, true) . ")";
|
||||
$output .= "->handle($_params, \$_smarty_tpl)";
|
||||
} else {
|
||||
$compiler->trigger_template_error("unknown function '{$function}'", null, true);
|
||||
// not cacheable?
|
||||
$compiler->tag_nocache = $compiler->tag_nocache || !$functionHandler->isCacheable();
|
||||
$output = "\$_smarty_tpl->getSmarty()->getFunctionHandler(" . var_export($function, true) . ")";
|
||||
$output .= "->handle($_params, \$_smarty_tpl)";
|
||||
} else {
|
||||
throw $e;
|
||||
}
|
||||
}
|
||||
|
||||
if (!empty($parameter['modifierlist'])) {
|
||||
|
||||
@@ -1,19 +0,0 @@
|
||||
<?php
|
||||
namespace Smarty\Compile\Modifier;
|
||||
use Smarty\CompilerException;
|
||||
|
||||
/**
|
||||
* Smarty is_array modifier plugin
|
||||
*/
|
||||
class IsArrayModifierCompiler extends Base {
|
||||
|
||||
public function compile($params, \Smarty\Compiler\Template $compiler) {
|
||||
|
||||
if (count($params) !== 1) {
|
||||
throw new CompilerException("Invalid number of arguments for is_array. is_array expects exactly 1 parameter.");
|
||||
}
|
||||
|
||||
return 'is_array(' . $params[0] . ')';
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,14 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace Smarty\Compile\Modifier;
|
||||
|
||||
/**
|
||||
* Smarty json_encode modifier plugin
|
||||
*/
|
||||
class JsonEncodeModifierCompiler extends Base {
|
||||
|
||||
public function compile($params, \Smarty\Compiler\Template $compiler) {
|
||||
return 'json_encode(' . $params[0] . (isset($params[1]) ? ', (int) ' . $params[1] : '') . ')';
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,15 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace Smarty\Compile\Modifier;
|
||||
|
||||
/**
|
||||
* Smarty substr modifier plugin
|
||||
*/
|
||||
class SubstrModifierCompiler extends Base {
|
||||
|
||||
public function compile($params, \Smarty\Compiler\Template $compiler) {
|
||||
return 'substr((string) ' . $params[0] . ', (int) ' . $params[1] .
|
||||
(isset($params[2]) ? ', (int) ' . $params[2] : '') . ')';
|
||||
}
|
||||
|
||||
}
|
||||
@@ -33,8 +33,9 @@ class ModifierCompiler extends Base {
|
||||
* @throws \Smarty\CompilerException
|
||||
* @throws \Smarty\Exception
|
||||
*/
|
||||
public function compile($args, \Smarty\Compiler\Template $compiler, $parameter = [], $tag = null, $function = null): string
|
||||
{
|
||||
public function compile($args, \Smarty\Compiler\Template $compiler, $parameter = [], $tag = null, $function = null) {
|
||||
|
||||
$compiler->has_code = true;
|
||||
|
||||
$output = $parameter['value'];
|
||||
|
||||
@@ -42,19 +43,16 @@ class ModifierCompiler extends Base {
|
||||
foreach ($parameter['modifierlist'] as $single_modifier) {
|
||||
/* @var string $modifier */
|
||||
$modifier = $single_modifier[0];
|
||||
|
||||
|
||||
$modifier_params = array_values($single_modifier);
|
||||
|
||||
$modifier_params[0] = $output;
|
||||
$params = implode(',', $modifier_params);
|
||||
$single_modifier[0] = $output;
|
||||
$params = implode(',', $single_modifier);
|
||||
|
||||
if (!is_object($compiler->getSmarty()->security_policy)
|
||||
|| $compiler->getSmarty()->security_policy->isTrustedModifier($modifier, $compiler)
|
||||
) {
|
||||
|
||||
if ($handler = $compiler->getModifierCompiler($modifier)) {
|
||||
$output = $handler->compile($modifier_params, $compiler);
|
||||
$output = $handler->compile($single_modifier, $compiler);
|
||||
|
||||
} elseif ($compiler->getSmarty()->getModifierCallback($modifier)) {
|
||||
$output = sprintf(
|
||||
'$_smarty_tpl->getSmarty()->getModifierCallback(%s)(%s)',
|
||||
@@ -62,7 +60,7 @@ class ModifierCompiler extends Base {
|
||||
$params
|
||||
);
|
||||
} elseif ($callback = $compiler->getPluginFromDefaultHandler($modifier, \Smarty\Smarty::PLUGIN_MODIFIERCOMPILER)) {
|
||||
$output = (new \Smarty\Compile\Modifier\BCPluginWrapper($callback))->compile($modifier_params, $compiler);
|
||||
$output = (new \Smarty\Compile\Modifier\BCPluginWrapper($callback))->compile($single_modifier, $compiler);
|
||||
} elseif ($function = $compiler->getPluginFromDefaultHandler($modifier, \Smarty\Smarty::PLUGIN_MODIFIER)) {
|
||||
if (!is_array($function)) {
|
||||
$output = "{$function}({$params})";
|
||||
|
||||
@@ -39,8 +39,7 @@ class ObjectMethodCallCompiler extends Base {
|
||||
* @throws \Smarty\CompilerException
|
||||
* @throws \Smarty\Exception
|
||||
*/
|
||||
public function compile($args, \Smarty\Compiler\Template $compiler, $parameter = [], $tag = null, $function = null): string
|
||||
{
|
||||
public function compile($args, \Smarty\Compiler\Template $compiler, $parameter = [], $tag = null, $function = null) {
|
||||
// check and get attributes
|
||||
$_attr = $this->getAttributes($compiler, $args);
|
||||
unset($_attr['nocache']);
|
||||
|
||||
@@ -47,8 +47,9 @@ class PrintExpressionCompiler extends Base {
|
||||
* @return string
|
||||
* @throws \Smarty\Exception
|
||||
*/
|
||||
public function compile($args, \Smarty\Compiler\Template $compiler, $parameter = [], $tag = null, $function = null): string
|
||||
{
|
||||
public function compile($args, \Smarty\Compiler\Template $compiler, $parameter = [], $tag = null, $function = null) {
|
||||
|
||||
$compiler->has_code = true;
|
||||
|
||||
// check and get attributes
|
||||
$_attr = $this->getAttributes($compiler, $args);
|
||||
@@ -83,7 +84,7 @@ class PrintExpressionCompiler extends Base {
|
||||
}
|
||||
|
||||
if ($compiler->getTemplate()->getSmarty()->escape_html) {
|
||||
$output = "htmlspecialchars((string) ({$output}), ENT_QUOTES, '" . addslashes(\Smarty\Smarty::$_CHARSET) . "')";
|
||||
$output = "htmlspecialchars((string) {$output}, ENT_QUOTES, '" . addslashes(\Smarty\Smarty::$_CHARSET) . "')";
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -37,8 +37,9 @@ class SpecialVariableCompiler extends Base {
|
||||
* @return string compiled code
|
||||
* @throws CompilerException
|
||||
*/
|
||||
public function compile($args, \Smarty\Compiler\Template $compiler, $parameter = [], $tag = null, $function = null): string
|
||||
{
|
||||
public function compile($args, \Smarty\Compiler\Template $compiler, $parameter = [], $tag = null, $function = null) {
|
||||
|
||||
$compiler->has_code = true;
|
||||
|
||||
$_index = preg_split("/\]\[/", substr($parameter, 1, strlen($parameter) - 2));
|
||||
$variable = smarty_strtolower_ascii($compiler->getId($_index[0]));
|
||||
@@ -128,7 +129,5 @@ class SpecialVariableCompiler extends Base {
|
||||
}
|
||||
return $compiled_ref;
|
||||
}
|
||||
|
||||
return '';
|
||||
}
|
||||
}
|
||||
|
||||
@@ -35,8 +35,8 @@ class Append extends Assign
|
||||
* @return string compiled code
|
||||
* @throws \Smarty\CompilerException
|
||||
*/
|
||||
public function compile($args, \Smarty\Compiler\Template $compiler, $parameter = array(), $tag = null, $function = null): string
|
||||
{
|
||||
public function compile($args, \Smarty\Compiler\Template $compiler, $parameter = array(), $tag = null, $function = null)
|
||||
{
|
||||
|
||||
// check and get attributes
|
||||
$_attr = $this->getAttributes($compiler, $args);
|
||||
|
||||
@@ -55,8 +55,8 @@ class Assign extends Base
|
||||
* @return string compiled code
|
||||
* @throws \Smarty\CompilerException
|
||||
*/
|
||||
public function compile($args, \Smarty\Compiler\Template $compiler, $parameter = array(), $tag = null, $function = null): string
|
||||
{
|
||||
public function compile($args, \Smarty\Compiler\Template $compiler, $parameter = array(), $tag = null, $function = null)
|
||||
{
|
||||
|
||||
$_nocache = false;
|
||||
// check and get attributes
|
||||
|
||||
@@ -24,8 +24,7 @@ class BCPluginWrapper extends Base {
|
||||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
public function compile($args, \Smarty\Compiler\Template $compiler, $parameter = [], $tag = null, $function = null): string
|
||||
{
|
||||
public function compile($args, \Smarty\Compiler\Template $compiler, $parameter = [], $tag = null, $function = null) {
|
||||
return call_user_func($this->callback, $this->getAttributes($compiler, $args), $compiler->getSmarty());
|
||||
}
|
||||
}
|
||||
@@ -58,7 +58,7 @@ class Block extends Inheritance {
|
||||
* @param \Smarty\Compiler\Template $compiler compiler object
|
||||
* @param array $parameter array with compilation parameter
|
||||
*/
|
||||
public function compile($args, \Smarty\Compiler\Template $compiler, $parameter = array(), $tag = null, $function = null): string
|
||||
public function compile($args, \Smarty\Compiler\Template $compiler, $parameter = array(), $tag = null, $function = null)
|
||||
{
|
||||
if (!isset($compiler->_cache['blockNesting'])) {
|
||||
$compiler->_cache['blockNesting'] = 0;
|
||||
@@ -87,6 +87,5 @@ class Block extends Inheritance {
|
||||
$compiler->getParser()->current_buffer = new Template();
|
||||
$compiler->getTemplate()->getCompiled()->setNocacheCode(false);
|
||||
$compiler->suppressNocacheProcessing = true;
|
||||
return '';
|
||||
}
|
||||
}
|
||||
|
||||
@@ -18,7 +18,7 @@ class BlockClose extends Inheritance {
|
||||
*
|
||||
* @return bool true
|
||||
*/
|
||||
public function compile($args, \Smarty\Compiler\Template $compiler, $parameter = array(), $tag = null, $function = null): string
|
||||
public function compile($args, \Smarty\Compiler\Template $compiler, $parameter = array(), $tag = null, $function = null)
|
||||
{
|
||||
[$_attr, $_nocache, $_buffer, $_has_nocache_code, $_className] = $this->closeTag($compiler, ['block']);
|
||||
|
||||
@@ -103,6 +103,7 @@ class BlockClose extends Inheritance {
|
||||
if ($compiler->_cache['blockNesting'] === 0) {
|
||||
unset($compiler->_cache['blockNesting']);
|
||||
}
|
||||
$compiler->has_code = true;
|
||||
$compiler->suppressNocacheProcessing = true;
|
||||
return $output;
|
||||
}
|
||||
|
||||
@@ -52,7 +52,7 @@ class BreakTag extends Base {
|
||||
* @return string compiled code
|
||||
* @throws \Smarty\CompilerException
|
||||
*/
|
||||
public function compile($args, \Smarty\Compiler\Template $compiler, $parameter = array(), $tag = null, $function = null): string
|
||||
public function compile($args, \Smarty\Compiler\Template $compiler, $parameter = array(), $tag = null, $function = null)
|
||||
{
|
||||
[$levels, $foreachLevels] = $this->checkLevels($args, $compiler);
|
||||
$output = "<?php ";
|
||||
|
||||
@@ -47,8 +47,7 @@ class Call extends Base {
|
||||
*
|
||||
* @return string compiled code
|
||||
*/
|
||||
public function compile($args, \Smarty\Compiler\Template $compiler, $parameter = [], $tag = null, $function = null): string
|
||||
{
|
||||
public function compile($args, \Smarty\Compiler\Template $compiler, $parameter = [], $tag = null, $function = null) {
|
||||
// check and get attributes
|
||||
$_attr = $this->getAttributes($compiler, $args);
|
||||
// save possible attributes
|
||||
|
||||
@@ -53,8 +53,7 @@ class Capture extends Base {
|
||||
*
|
||||
* @return string compiled code
|
||||
*/
|
||||
public function compile($args, \Smarty\Compiler\Template $compiler, $parameter = [], $tag = null, $function = null): string
|
||||
{
|
||||
public function compile($args, \Smarty\Compiler\Template $compiler, $parameter = [], $tag = null, $function = null) {
|
||||
// check and get attributes
|
||||
$_attr = $this->getAttributes($compiler, $args);
|
||||
$buffer = $_attr['name'] ?? "'default'";
|
||||
@@ -67,6 +66,7 @@ class Capture extends Base {
|
||||
$compiler->openTag('nocache');
|
||||
}
|
||||
|
||||
return "<?php \$_smarty_tpl->getSmarty()->getRuntime('Capture')->open(\$_smarty_tpl, $buffer, $assign, $append);?>";
|
||||
$_output = "<?php \$_smarty_tpl->getSmarty()->getRuntime('Capture')->open(\$_smarty_tpl, $buffer, $assign, $append);?>";
|
||||
return $_output;
|
||||
}
|
||||
}
|
||||
@@ -29,8 +29,7 @@ class CaptureClose extends Base {
|
||||
*
|
||||
* @return string compiled code
|
||||
*/
|
||||
public function compile($args, \Smarty\Compiler\Template $compiler, $parameter = [], $tag = null, $function = null): string
|
||||
{
|
||||
public function compile($args, \Smarty\Compiler\Template $compiler, $parameter = [], $tag = null, $function = null) {
|
||||
|
||||
if (array_pop($compiler->_cache['capture_stack'])) {
|
||||
// pop the virtual {nocache} tag from the stack.
|
||||
|
||||
@@ -62,8 +62,7 @@ class ConfigLoad extends Base {
|
||||
* @return string compiled code
|
||||
* @throws \Smarty\CompilerException
|
||||
*/
|
||||
public function compile($args, \Smarty\Compiler\Template $compiler, $parameter = [], $tag = null, $function = null): string
|
||||
{
|
||||
public function compile($args, \Smarty\Compiler\Template $compiler, $parameter = [], $tag = null, $function = null) {
|
||||
// check and get attributes
|
||||
$_attr = $this->getAttributes($compiler, $args);
|
||||
if ($_attr['nocache'] === true) {
|
||||
|
||||
@@ -29,8 +29,7 @@ class Debug extends Base {
|
||||
*
|
||||
* @return string compiled code
|
||||
*/
|
||||
public function compile($args, \Smarty\Compiler\Template $compiler, $parameter = [], $tag = null, $function = null): string
|
||||
{
|
||||
public function compile($args, \Smarty\Compiler\Template $compiler, $parameter = [], $tag = null, $function = null) {
|
||||
// check and get attributes, may trigger errors
|
||||
$this->getAttributes($compiler, $args);
|
||||
|
||||
|
||||
@@ -22,8 +22,7 @@ class ElseIfTag extends Base {
|
||||
* @return string compiled code
|
||||
* @throws \Smarty\CompilerException
|
||||
*/
|
||||
public function compile($args, \Smarty\Compiler\Template $compiler, $parameter = [], $tag = null, $function = null): string
|
||||
{
|
||||
public function compile($args, \Smarty\Compiler\Template $compiler, $parameter = [], $tag = null, $function = null) {
|
||||
|
||||
[$nesting, $nocache_pushed] = $this->closeTag($compiler, ['if', 'elseif']);
|
||||
|
||||
|
||||
@@ -20,8 +20,7 @@ class ElseTag extends Base {
|
||||
*
|
||||
* @return string compiled code
|
||||
*/
|
||||
public function compile($args, \Smarty\Compiler\Template $compiler, $parameter = [], $tag = null, $function = null): string
|
||||
{
|
||||
public function compile($args, \Smarty\Compiler\Template $compiler, $parameter = [], $tag = null, $function = null) {
|
||||
[$nesting, $compiler->tag_nocache] = $this->closeTag($compiler, ['if', 'elseif']);
|
||||
$this->openTag($compiler, 'else', [$nesting, $compiler->tag_nocache]);
|
||||
return '<?php } else { ?>';
|
||||
|
||||
@@ -52,8 +52,7 @@ class EvalTag extends Base {
|
||||
*
|
||||
* @return string compiled code
|
||||
*/
|
||||
public function compile($args, \Smarty\Compiler\Template $compiler, $parameter = [], $tag = null, $function = null): string
|
||||
{
|
||||
public function compile($args, \Smarty\Compiler\Template $compiler, $parameter = [], $tag = null, $function = null) {
|
||||
// check and get attributes
|
||||
$_attr = $this->getAttributes($compiler, $args);
|
||||
if (isset($_attr['assign'])) {
|
||||
|
||||
@@ -52,8 +52,7 @@ class ExtendsTag extends Inheritance {
|
||||
* @throws \Smarty\CompilerException
|
||||
* @throws \Smarty\Exception
|
||||
*/
|
||||
public function compile($args, \Smarty\Compiler\Template $compiler, $parameter = [], $tag = null, $function = null): string
|
||||
{
|
||||
public function compile($args, \Smarty\Compiler\Template $compiler, $parameter = [], $tag = null, $function = null) {
|
||||
// check and get attributes
|
||||
$_attr = $this->getAttributes($compiler, $args);
|
||||
if ($_attr['nocache'] === true) {
|
||||
@@ -87,6 +86,7 @@ class ExtendsTag extends Inheritance {
|
||||
} else {
|
||||
$this->compileEndChild($compiler, $_attr['file']);
|
||||
}
|
||||
$compiler->has_code = false;
|
||||
return '';
|
||||
}
|
||||
|
||||
|
||||
@@ -29,8 +29,7 @@ class ForClose extends Base {
|
||||
*
|
||||
* @return string compiled code
|
||||
*/
|
||||
public function compile($args, \Smarty\Compiler\Template $compiler, $parameter = [], $tag = null, $function = null): string
|
||||
{
|
||||
public function compile($args, \Smarty\Compiler\Template $compiler, $parameter = [], $tag = null, $function = null) {
|
||||
$compiler->loopNesting--;
|
||||
|
||||
[$openTag, $nocache_pushed] = $this->closeTag($compiler, ['for', 'forelse']);
|
||||
|
||||
@@ -21,8 +21,7 @@ class ForElse extends Base {
|
||||
*
|
||||
* @return string compiled code
|
||||
*/
|
||||
public function compile($args, \Smarty\Compiler\Template $compiler, $parameter = [], $tag = null, $function = null): string
|
||||
{
|
||||
public function compile($args, \Smarty\Compiler\Template $compiler, $parameter = [], $tag = null, $function = null) {
|
||||
[$tagName, $nocache_pushed] = $this->closeTag($compiler, ['for']);
|
||||
$this->openTag($compiler, 'forelse', ['forelse', $nocache_pushed]);
|
||||
return "<?php }} else { ?>";
|
||||
|
||||
@@ -28,8 +28,7 @@ class ForTag extends Base {
|
||||
*
|
||||
* @return string compiled code
|
||||
*/
|
||||
public function compile($args, \Smarty\Compiler\Template $compiler, $parameter = [], $tag = null, $function = null): string
|
||||
{
|
||||
public function compile($args, \Smarty\Compiler\Template $compiler, $parameter = [], $tag = null, $function = null) {
|
||||
$compiler->loopNesting++;
|
||||
if ($parameter === 0) {
|
||||
$this->required_attributes = ['start', 'to'];
|
||||
|
||||
@@ -29,8 +29,7 @@ class ForeachClose extends Base {
|
||||
* @return string compiled code
|
||||
* @throws \Smarty\CompilerException
|
||||
*/
|
||||
public function compile($args, \Smarty\Compiler\Template $compiler, $parameter = [], $tag = null, $function = null): string
|
||||
{
|
||||
public function compile($args, \Smarty\Compiler\Template $compiler, $parameter = [], $tag = null, $function = null) {
|
||||
$compiler->loopNesting--;
|
||||
|
||||
[$openTag, $nocache_pushed, $localVariablePrefix, $item, $restore] = $this->closeTag($compiler, ['foreach', 'foreachelse']);
|
||||
|
||||
@@ -20,8 +20,7 @@ class ForeachElse extends Base {
|
||||
*
|
||||
* @return string compiled code
|
||||
*/
|
||||
public function compile($args, \Smarty\Compiler\Template $compiler, $parameter = [], $tag = null, $function = null): string
|
||||
{
|
||||
public function compile($args, \Smarty\Compiler\Template $compiler, $parameter = [], $tag = null, $function = null) {
|
||||
|
||||
[$openTag, $nocache_pushed, $localVariablePrefix, $item, $restore] = $this->closeTag($compiler, ['foreach']);
|
||||
$this->openTag($compiler, 'foreachelse', ['foreachelse', $nocache_pushed, $localVariablePrefix, $item, false]);
|
||||
|
||||
@@ -79,8 +79,7 @@ class ForeachTag extends ForeachSection {
|
||||
* @throws \Smarty\CompilerException
|
||||
* @throws \Smarty\Exception
|
||||
*/
|
||||
public function compile($args, \Smarty\Compiler\Template $compiler, $parameter = [], $tag = null, $function = null): string
|
||||
{
|
||||
public function compile($args, \Smarty\Compiler\Template $compiler, $parameter = [], $tag = null, $function = null) {
|
||||
$compiler->loopNesting++;
|
||||
// init
|
||||
$this->isNamed = false;
|
||||
|
||||
@@ -33,10 +33,9 @@ class FunctionClose extends Base {
|
||||
* @param array $args array with attributes from parser
|
||||
* @param object|\Smarty\Compiler\Template $compiler compiler object
|
||||
*
|
||||
* @return string compiled code
|
||||
* @return bool true
|
||||
*/
|
||||
public function compile($args, \Smarty\Compiler\Template $compiler, $parameter = [], $tag = null, $function = null): string
|
||||
{
|
||||
public function compile($args, \Smarty\Compiler\Template $compiler, $parameter = [], $tag = null, $function = null) {
|
||||
$this->compiler = $compiler;
|
||||
$saved_data = $this->closeTag($compiler, ['function']);
|
||||
$_attr = $saved_data[0];
|
||||
@@ -76,7 +75,7 @@ class FunctionClose extends Base {
|
||||
$output .= "foreach (\$params as \$key => \$value) {\n\$_smarty_tpl->assign(\$key, \$value);\n}\n";
|
||||
$output .= "\$params = var_export(\$params, true);\n";
|
||||
$output .= "echo \"/*%%SmartyNocache:{$compiler->getTemplate()->getCompiled()->nocache_hash}%%*/<?php ";
|
||||
$output .= "\\\$_smarty_tpl->pushStack();\nforeach (\$params as \\\$key => \\\$value) {\n\\\$_smarty_tpl->assign(\\\$key, \\\$value);\n}\n?>";
|
||||
$output .= "\\\$_smarty_tpl->getSmarty()->getRuntime('TplFunction')->saveTemplateVariables(\\\$_smarty_tpl, '{$_name}');\nforeach (\$params as \\\$key => \\\$value) {\n\\\$_smarty_tpl->assign(\\\$key, \\\$value);\n}\n?>";
|
||||
$output .= "/*/%%SmartyNocache:{$compiler->getTemplate()->getCompiled()->nocache_hash}%%*/\";?>";
|
||||
$compiler->getParser()->current_buffer->append_subtree(
|
||||
$compiler->getParser(),
|
||||
@@ -87,7 +86,7 @@ class FunctionClose extends Base {
|
||||
);
|
||||
$compiler->getParser()->current_buffer->append_subtree($compiler->getParser(), $_functionCode);
|
||||
$output = "<?php echo \"/*%%SmartyNocache:{$compiler->getTemplate()->getCompiled()->nocache_hash}%%*/<?php ";
|
||||
$output .= "\\\$_smarty_tpl->popStack();?>\n";
|
||||
$output .= "\\\$_smarty_tpl->getSmarty()->getRuntime('TplFunction')->restoreTemplateVariables(\\\$_smarty_tpl, '{$_name}');?>\n";
|
||||
$output .= "/*/%%SmartyNocache:{$compiler->getTemplate()->getCompiled()->nocache_hash}%%*/\";\n?>";
|
||||
$output .= "<?php echo str_replace('{$compiler->getTemplate()->getCompiled()->nocache_hash}', \$_smarty_tpl->getCompiled()->nocache_hash ?? '', ob_get_clean());\n";
|
||||
$output .= "}\n}\n";
|
||||
@@ -141,7 +140,7 @@ class FunctionClose extends Base {
|
||||
// restore old status
|
||||
$compiler->getTemplate()->getCompiled()->setNocacheCode($saved_data[2]);
|
||||
$compiler->getTemplate()->caching = $saved_data[3];
|
||||
return '';
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -42,11 +42,10 @@ class FunctionTag extends Base {
|
||||
* @param array $args array with attributes from parser
|
||||
* @param \Smarty\Compiler\Template $compiler compiler object
|
||||
*
|
||||
* @return string compiled code
|
||||
* @return bool true
|
||||
* @throws \Smarty\CompilerException
|
||||
*/
|
||||
public function compile($args, \Smarty\Compiler\Template $compiler, $parameter = [], $tag = null, $function = null): string
|
||||
{
|
||||
public function compile($args, \Smarty\Compiler\Template $compiler, $parameter = [], $tag = null, $function = null) {
|
||||
// check and get attributes
|
||||
$_attr = $this->getAttributes($compiler, $args);
|
||||
if ($_attr['nocache'] === true) {
|
||||
@@ -68,6 +67,6 @@ class FunctionTag extends Base {
|
||||
// Init temporary context
|
||||
$compiler->getParser()->current_buffer = new \Smarty\ParseTree\Template();
|
||||
$compiler->getTemplate()->getCompiled()->setNocacheCode(false);
|
||||
return '';
|
||||
return true;
|
||||
}
|
||||
}
|
||||
@@ -28,8 +28,7 @@ class IfClose extends Base {
|
||||
*
|
||||
* @return string compiled code
|
||||
*/
|
||||
public function compile($args, \Smarty\Compiler\Template $compiler, $parameter = [], $tag = null, $function = null): string
|
||||
{
|
||||
public function compile($args, \Smarty\Compiler\Template $compiler, $parameter = [], $tag = null, $function = null) {
|
||||
|
||||
[$nesting, $nocache_pushed] = $this->closeTag($compiler, ['if', 'else', 'elseif']);
|
||||
|
||||
|
||||
@@ -22,8 +22,7 @@ class IfTag extends Base {
|
||||
* @return string compiled code
|
||||
* @throws \Smarty\CompilerException
|
||||
*/
|
||||
public function compile($args, \Smarty\Compiler\Template $compiler, $parameter = [], $tag = null, $function = null): string
|
||||
{
|
||||
public function compile($args, \Smarty\Compiler\Template $compiler, $parameter = [], $tag = null, $function = null) {
|
||||
|
||||
if ($compiler->tag_nocache) {
|
||||
// push a {nocache} tag onto the stack to prevent caching of this block
|
||||
|
||||
@@ -67,8 +67,7 @@ class IncludeTag extends Base {
|
||||
* @throws \Smarty\CompilerException
|
||||
* @throws \Smarty\Exception
|
||||
*/
|
||||
public function compile($args, \Smarty\Compiler\Template $compiler, $parameter = [], $tag = null, $function = null): string
|
||||
{
|
||||
public function compile($args, \Smarty\Compiler\Template $compiler, $parameter = [], $tag = null, $function = null) {
|
||||
$uid = $t_hash = null;
|
||||
// check and get attributes
|
||||
$_attr = $this->getAttributes($compiler, $args);
|
||||
|
||||
@@ -30,8 +30,7 @@ class Ldelim extends Base {
|
||||
* @return string compiled code
|
||||
* @throws \Smarty\CompilerException
|
||||
*/
|
||||
public function compile($args, \Smarty\Compiler\Template $compiler, $parameter = [], $tag = null, $function = null): string
|
||||
{
|
||||
public function compile($args, \Smarty\Compiler\Template $compiler, $parameter = [], $tag = null, $function = null) {
|
||||
$_attr = $this->getAttributes($compiler, $args);
|
||||
if ($_attr['nocache'] === true) {
|
||||
$compiler->trigger_template_error('nocache option not allowed', null, true);
|
||||
|
||||
@@ -26,11 +26,12 @@ class Nocache extends Base {
|
||||
* @param array $args array with attributes from parser
|
||||
* @param \Smarty\Compiler\Template $compiler compiler object
|
||||
*
|
||||
* @return string
|
||||
* @return bool
|
||||
*/
|
||||
public function compile($args, \Smarty\Compiler\Template $compiler, $parameter = [], $tag = null, $function = null): string
|
||||
{
|
||||
public function compile($args, \Smarty\Compiler\Template $compiler, $parameter = [], $tag = null, $function = null) {
|
||||
$this->openTag($compiler, 'nocache');
|
||||
return '';
|
||||
// this tag does not return compiled code
|
||||
$compiler->has_code = false;
|
||||
return true;
|
||||
}
|
||||
}
|
||||
@@ -27,11 +27,12 @@ class NocacheClose extends Base {
|
||||
* @param array $args array with attributes from parser
|
||||
* @param \Smarty\Compiler\Template $compiler compiler object
|
||||
*
|
||||
* @return string
|
||||
* @return bool
|
||||
*/
|
||||
public function compile($args, \Smarty\Compiler\Template $compiler, $parameter = [], $tag = null, $function = null): string
|
||||
{
|
||||
public function compile($args, \Smarty\Compiler\Template $compiler, $parameter = [], $tag = null, $function = null) {
|
||||
$this->closeTag($compiler, ['nocache']);
|
||||
return '';
|
||||
// this tag does not return compiled code
|
||||
$compiler->has_code = false;
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -28,8 +28,7 @@ class Rdelim extends Ldelim {
|
||||
* @return string compiled code
|
||||
* @throws \Smarty\CompilerException
|
||||
*/
|
||||
public function compile($args, \Smarty\Compiler\Template $compiler, $parameter = [], $tag = null, $function = null): string
|
||||
{
|
||||
public function compile($args, \Smarty\Compiler\Template $compiler, $parameter = [], $tag = null, $function = null) {
|
||||
parent::compile($args, $compiler);
|
||||
return $compiler->getTemplate()->getRightDelimiter();
|
||||
}
|
||||
|
||||
@@ -82,8 +82,7 @@ class Section extends ForeachSection {
|
||||
* @throws \Smarty\CompilerException
|
||||
* @throws \Smarty\Exception
|
||||
*/
|
||||
public function compile($args, \Smarty\Compiler\Template $compiler, $parameter = [], $tag = null, $function = null): string
|
||||
{
|
||||
public function compile($args, \Smarty\Compiler\Template $compiler, $parameter = [], $tag = null, $function = null) {
|
||||
$compiler->loopNesting++;
|
||||
// check and get attributes
|
||||
$_attr = $this->getAttributes($compiler, $args);
|
||||
|
||||
@@ -25,8 +25,7 @@ class SectionClose extends Base {
|
||||
*
|
||||
* @return string compiled code
|
||||
*/
|
||||
public function compile($args, \Smarty\Compiler\Template $compiler, $parameter = [], $tag = null, $function = null): string
|
||||
{
|
||||
public function compile($args, \Smarty\Compiler\Template $compiler, $parameter = [], $tag = null, $function = null) {
|
||||
$compiler->loopNesting--;
|
||||
|
||||
[$openTag, $nocache_pushed] = $this->closeTag($compiler, ['section', 'sectionelse']);
|
||||
|
||||
@@ -20,8 +20,7 @@ class SectionElse extends Base {
|
||||
*
|
||||
* @return string compiled code
|
||||
*/
|
||||
public function compile($args, \Smarty\Compiler\Template $compiler, $parameter = [], $tag = null, $function = null): string
|
||||
{
|
||||
public function compile($args, \Smarty\Compiler\Template $compiler, $parameter = [], $tag = null, $function = null) {
|
||||
[$openTag, $nocache_pushed] = $this->closeTag($compiler, ['section']);
|
||||
$this->openTag($compiler, 'sectionelse', ['sectionelse', $nocache_pushed]);
|
||||
return "<?php }} else {\n ?>";
|
||||
|
||||
@@ -21,8 +21,7 @@ class Setfilter extends Base {
|
||||
*
|
||||
* @return string compiled code
|
||||
*/
|
||||
public function compile($args, \Smarty\Compiler\Template $compiler, $parameter = [], $tag = null, $function = null): string
|
||||
{
|
||||
public function compile($args, \Smarty\Compiler\Template $compiler, $parameter = [], $tag = null, $function = null) {
|
||||
$compiler->variable_filter_stack[] = $compiler->getSmarty()->getDefaultModifiers();
|
||||
|
||||
// The modifier_list is passed as an array of array's. The inner arrays have the modifier at index 0,
|
||||
@@ -35,6 +34,8 @@ class Setfilter extends Base {
|
||||
|
||||
$compiler->getSmarty()->setDefaultModifiers($newList);
|
||||
|
||||
return '';
|
||||
// this tag does not return compiled code
|
||||
$compiler->has_code = false;
|
||||
return true;
|
||||
}
|
||||
}
|
||||
@@ -29,8 +29,7 @@ class SetfilterClose extends Base {
|
||||
*
|
||||
* @return string compiled code
|
||||
*/
|
||||
public function compile($args, \Smarty\Compiler\Template $compiler, $parameter = [], $tag = null, $function = null): string
|
||||
{
|
||||
public function compile($args, \Smarty\Compiler\Template $compiler, $parameter = [], $tag = null, $function = null) {
|
||||
$this->getAttributes($compiler, $args);
|
||||
|
||||
// reset variable filter to previous state
|
||||
@@ -38,6 +37,8 @@ class SetfilterClose extends Base {
|
||||
count($compiler->variable_filter_stack) ? array_pop($compiler->variable_filter_stack) : []
|
||||
);
|
||||
|
||||
return '';
|
||||
// this tag does not return compiled code
|
||||
$compiler->has_code = false;
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -28,8 +28,7 @@ class WhileClose extends Base {
|
||||
*
|
||||
* @return string compiled code
|
||||
*/
|
||||
public function compile($args, \Smarty\Compiler\Template $compiler, $parameter = [], $tag = null, $function = null): string
|
||||
{
|
||||
public function compile($args, \Smarty\Compiler\Template $compiler, $parameter = [], $tag = null, $function = null) {
|
||||
$compiler->loopNesting--;
|
||||
|
||||
$nocache_pushed = $this->closeTag($compiler, ['while']);
|
||||
|
||||
@@ -22,8 +22,7 @@ class WhileTag extends Base {
|
||||
* @return string compiled code
|
||||
* @throws \Smarty\CompilerException
|
||||
*/
|
||||
public function compile($args, \Smarty\Compiler\Template $compiler, $parameter = [], $tag = null, $function = null): string
|
||||
{
|
||||
public function compile($args, \Smarty\Compiler\Template $compiler, $parameter = [], $tag = null, $function = null) {
|
||||
$compiler->loopNesting++;
|
||||
|
||||
if ($compiler->tag_nocache) {
|
||||
|
||||
@@ -121,6 +121,6 @@ class CodeFrame
|
||||
* @return string
|
||||
*/
|
||||
public function insertLocalVariables(): string {
|
||||
return '$_smarty_current_dir = ' . var_export(dirname($this->_template->getSource()->getFilepath() ?? '.'), true) . ";\n";
|
||||
return '$_smarty_current_dir = ' . var_export(dirname($this->_template->getSource()->getFilepath()), true) . ";\n";
|
||||
}
|
||||
}
|
||||
|
||||
@@ -65,6 +65,8 @@ class Configfile extends BaseCompiler {
|
||||
* @param Smarty $smarty global instance
|
||||
*/
|
||||
public function __construct(Smarty $smarty) {
|
||||
$this->smarty = $smarty;
|
||||
// get required plugins
|
||||
$this->smarty = $smarty;
|
||||
$this->config_data['sections'] = [];
|
||||
$this->config_data['vars'] = [];
|
||||
@@ -102,7 +104,7 @@ class Configfile extends BaseCompiler {
|
||||
) . "\n",
|
||||
$this
|
||||
);
|
||||
|
||||
/* @var ConfigfileParser $this->parser */
|
||||
$this->parser = new ConfigfileParser($this->lex, $this);
|
||||
if ($this->smarty->_parserdebug) {
|
||||
$this->parser->PrintTrace();
|
||||
|
||||
+19
-10
@@ -184,6 +184,13 @@ class Template extends BaseCompiler {
|
||||
*/
|
||||
public $prefixCodeStack = [];
|
||||
|
||||
/**
|
||||
* Tag has compiled code
|
||||
*
|
||||
* @var bool
|
||||
*/
|
||||
public $has_code = false;
|
||||
|
||||
/**
|
||||
* A variable string was compiled
|
||||
*
|
||||
@@ -841,7 +848,7 @@ class Template extends BaseCompiler {
|
||||
$e = new CompilerException(
|
||||
$error_text,
|
||||
0,
|
||||
$this->template->getSource()->getFilepath() ?? $this->template->getSource()->getFullResourceName(),
|
||||
$this->template->getSource()->getFullResourceName(),
|
||||
$line
|
||||
);
|
||||
$e->source = trim(preg_replace('![\t\r\n]+!', ' ', $match[$line - 1]));
|
||||
@@ -1067,10 +1074,12 @@ class Template extends BaseCompiler {
|
||||
}
|
||||
|
||||
public function compileChildBlock() {
|
||||
$this->has_code = true;
|
||||
return $this->blockCompiler->compileChild($this);
|
||||
}
|
||||
|
||||
public function compileParentBlock() {
|
||||
$this->has_code = true;
|
||||
return $this->blockCompiler->compileParent($this);
|
||||
}
|
||||
|
||||
@@ -1087,6 +1096,8 @@ class Template extends BaseCompiler {
|
||||
*/
|
||||
private function compileTag2($tag, $args, $parameter) {
|
||||
// $args contains the attributes parsed and compiled by the lexer/parser
|
||||
// assume that tag does compile into code, but creates no HTML output
|
||||
$this->has_code = true;
|
||||
|
||||
$this->handleNocacheFlag($args);
|
||||
|
||||
@@ -1095,10 +1106,12 @@ class Template extends BaseCompiler {
|
||||
if (!isset($this->smarty->security_policy) || $this->smarty->security_policy->isTrustedTag($tag, $this)) {
|
||||
$this->tag_nocache = $this->tag_nocache | !$tagCompiler->isCacheable();
|
||||
$_output = $tagCompiler->compile($args, $this, $parameter);
|
||||
if (!empty($parameter['modifierlist'])) {
|
||||
throw new CompilerException('No modifiers allowed on ' . $tag);
|
||||
if ($_output !== false) {
|
||||
if (!empty($parameter['modifierlist'])) {
|
||||
throw new CompilerException('No modifiers allowed on ' . $tag);
|
||||
}
|
||||
return $this->has_code && $_output !== true ? $_output : null;
|
||||
}
|
||||
return $_output;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1111,7 +1124,8 @@ class Template extends BaseCompiler {
|
||||
|
||||
$args['_attr']['name'] = "'{$tag}'";
|
||||
$tagCompiler = $this->getTagCompiler('call');
|
||||
return $tagCompiler === null ? false : $tagCompiler->compile($args, $this, $parameter);
|
||||
$_output = $tagCompiler === null ? false : $tagCompiler->compile($args, $this, $parameter);
|
||||
return $this->has_code ? $_output : null;
|
||||
}
|
||||
|
||||
// remaining tastes: (object-)function, (object-function-)block, custom-compiler
|
||||
@@ -1355,11 +1369,6 @@ class Template extends BaseCompiler {
|
||||
return $this->functionCallCompiler->compile($args, $this, $parameter, $base_tag, $base_tag);
|
||||
}
|
||||
|
||||
public function compileModifierInExpression(string $function, array $_attr) {
|
||||
$value = array_shift($_attr);
|
||||
return $this->compileModifier([array_merge([$function], $_attr)], $value);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return TemplateParser|null
|
||||
*/
|
||||
|
||||
@@ -47,20 +47,6 @@ class Data
|
||||
*/
|
||||
public $config_vars = array();
|
||||
|
||||
/**
|
||||
* This variable will hold a stack of template variables.
|
||||
*
|
||||
* @var null|array
|
||||
*/
|
||||
private $_var_stack = [];
|
||||
|
||||
/**
|
||||
* This variable will hold a stack of config variables.
|
||||
*
|
||||
* @var null|array
|
||||
*/
|
||||
private $_config_stack = [];
|
||||
|
||||
/**
|
||||
* Default scope for new variables
|
||||
* @var int
|
||||
@@ -507,20 +493,4 @@ class Data
|
||||
public function setParent($parent): void {
|
||||
$this->parent = $parent;
|
||||
}
|
||||
|
||||
public function pushStack(): void {
|
||||
$stackList = [];
|
||||
foreach ($this->tpl_vars as $name => $variable) {
|
||||
$stackList[$name] = clone $variable; // variables are stored in Variable objects
|
||||
}
|
||||
$this->_var_stack[] = $this->tpl_vars;
|
||||
$this->tpl_vars = $stackList;
|
||||
|
||||
$this->_config_stack[] = $this->config_vars;
|
||||
}
|
||||
|
||||
public function popStack(): void {
|
||||
$this->tpl_vars = array_pop($this->_var_stack);
|
||||
$this->config_vars = array_pop($this->_config_stack);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2,8 +2,6 @@
|
||||
|
||||
namespace Smarty\Extension;
|
||||
|
||||
use Smarty\Exception;
|
||||
|
||||
class DefaultExtension extends Base {
|
||||
|
||||
private $modifiers = [];
|
||||
@@ -29,9 +27,7 @@ class DefaultExtension extends Base {
|
||||
case 'escape': $this->modifiers[$modifier] = new \Smarty\Compile\Modifier\EscapeModifierCompiler(); break;
|
||||
case 'from_charset': $this->modifiers[$modifier] = new \Smarty\Compile\Modifier\FromCharsetModifierCompiler(); break;
|
||||
case 'indent': $this->modifiers[$modifier] = new \Smarty\Compile\Modifier\IndentModifierCompiler(); break;
|
||||
case 'is_array': $this->modifiers[$modifier] = new \Smarty\Compile\Modifier\IsArrayModifierCompiler(); break;
|
||||
case 'isset': $this->modifiers[$modifier] = new \Smarty\Compile\Modifier\IssetModifierCompiler(); break;
|
||||
case 'json_encode': $this->modifiers[$modifier] = new \Smarty\Compile\Modifier\JsonEncodeModifierCompiler(); break;
|
||||
case 'lower': $this->modifiers[$modifier] = new \Smarty\Compile\Modifier\LowerModifierCompiler(); break;
|
||||
case 'nl2br': $this->modifiers[$modifier] = new \Smarty\Compile\Modifier\Nl2brModifierCompiler(); break;
|
||||
case 'noprint': $this->modifiers[$modifier] = new \Smarty\Compile\Modifier\NoPrintModifierCompiler(); break;
|
||||
@@ -41,7 +37,6 @@ class DefaultExtension extends Base {
|
||||
case 'strip': $this->modifiers[$modifier] = new \Smarty\Compile\Modifier\StripModifierCompiler(); break;
|
||||
case 'strip_tags': $this->modifiers[$modifier] = new \Smarty\Compile\Modifier\StripTagsModifierCompiler(); break;
|
||||
case 'strlen': $this->modifiers[$modifier] = new \Smarty\Compile\Modifier\StrlenModifierCompiler(); break;
|
||||
case 'substr': $this->modifiers[$modifier] = new \Smarty\Compile\Modifier\SubstrModifierCompiler(); break;
|
||||
case 'to_charset': $this->modifiers[$modifier] = new \Smarty\Compile\Modifier\ToCharsetModifierCompiler(); break;
|
||||
case 'unescape': $this->modifiers[$modifier] = new \Smarty\Compile\Modifier\UnescapeModifierCompiler(); break;
|
||||
case 'upper': $this->modifiers[$modifier] = new \Smarty\Compile\Modifier\UpperModifierCompiler(); break;
|
||||
@@ -59,15 +54,11 @@ class DefaultExtension extends Base {
|
||||
case 'debug_print_var': return [$this, 'smarty_modifier_debug_print_var'];
|
||||
case 'escape': return [$this, 'smarty_modifier_escape'];
|
||||
case 'explode': return [$this, 'smarty_modifier_explode'];
|
||||
case 'implode': return [$this, 'smarty_modifier_implode'];
|
||||
case 'in_array': return [$this, 'smarty_modifier_in_array'];
|
||||
case 'join': return [$this, 'smarty_modifier_join'];
|
||||
case 'mb_wordwrap': return [$this, 'smarty_modifier_mb_wordwrap'];
|
||||
case 'number_format': return [$this, 'smarty_modifier_number_format'];
|
||||
case 'regex_replace': return [$this, 'smarty_modifier_regex_replace'];
|
||||
case 'replace': return [$this, 'smarty_modifier_replace'];
|
||||
case 'spacify': return [$this, 'smarty_modifier_spacify'];
|
||||
case 'split': return [$this, 'smarty_modifier_split'];
|
||||
case 'truncate': return [$this, 'smarty_modifier_truncate'];
|
||||
}
|
||||
return null;
|
||||
@@ -91,8 +82,12 @@ class DefaultExtension extends Base {
|
||||
case 'html_select_date': $this->functionHandlers[$functionName] = new \Smarty\FunctionHandler\HtmlSelectDate(); break;
|
||||
case 'html_select_time': $this->functionHandlers[$functionName] = new \Smarty\FunctionHandler\HtmlSelectTime(); break;
|
||||
case 'html_table': $this->functionHandlers[$functionName] = new \Smarty\FunctionHandler\HtmlTable(); break;
|
||||
case 'in_array': $this->functionHandlers[$functionName] = new \Smarty\FunctionHandler\InArray(); break;
|
||||
case 'is_array': $this->functionHandlers[$functionName] = new \Smarty\FunctionHandler\IsArray(); break;
|
||||
case 'mailto': $this->functionHandlers[$functionName] = new \Smarty\FunctionHandler\Mailto(); break;
|
||||
case 'math': $this->functionHandlers[$functionName] = new \Smarty\FunctionHandler\Math(); break;
|
||||
case 'strlen': $this->functionHandlers[$functionName] = new \Smarty\FunctionHandler\Strlen(); break;
|
||||
case 'time': $this->functionHandlers[$functionName] = new \Smarty\FunctionHandler\Time(); break;
|
||||
}
|
||||
|
||||
return $this->functionHandlers[$functionName] ?? null;
|
||||
@@ -216,7 +211,7 @@ class DefaultExtension extends Base {
|
||||
* > 1 would be returned, unless value was null, in which case 0 would be returned.
|
||||
*/
|
||||
|
||||
if ($arrayOrObject instanceof \Countable || is_array($arrayOrObject)) {
|
||||
if ($arrayOrObject instanceof Countable || is_array($arrayOrObject)) {
|
||||
return count($arrayOrObject, (int) $mode);
|
||||
} elseif ($arrayOrObject === null) {
|
||||
return 0;
|
||||
@@ -523,91 +518,10 @@ class DefaultExtension extends Base {
|
||||
*/
|
||||
public function smarty_modifier_explode($separator, $string, ?int $limit = null)
|
||||
{
|
||||
trigger_error("Using explode is deprecated. " .
|
||||
"Use split, using the array first, separator second.", E_USER_DEPRECATED);
|
||||
// provide $string default to prevent deprecation errors in PHP >=8.1
|
||||
return explode($separator, $string ?? '', $limit ?? PHP_INT_MAX);
|
||||
}
|
||||
|
||||
/**
|
||||
* Smarty split modifier plugin
|
||||
* Type: modifier
|
||||
* Name: split
|
||||
* Purpose: split a string by a string
|
||||
*
|
||||
* @param string $string
|
||||
* @param string $separator
|
||||
* @param int|null $limit
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function smarty_modifier_split($string, $separator, ?int $limit = null)
|
||||
{
|
||||
// provide $string default to prevent deprecation errors in PHP >=8.1
|
||||
return explode($separator, $string ?? '', $limit ?? PHP_INT_MAX);
|
||||
}
|
||||
|
||||
/**
|
||||
* Smarty implode modifier plugin
|
||||
* Type: modifier
|
||||
* Name: implode
|
||||
* Purpose: join an array of values into a single string
|
||||
*
|
||||
* @param array $values
|
||||
* @param string $separator
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function smarty_modifier_implode($values, $separator = '')
|
||||
{
|
||||
|
||||
trigger_error("Using implode is deprecated. " .
|
||||
"Use join using the array first, separator second.", E_USER_DEPRECATED);
|
||||
|
||||
if (is_array($separator)) {
|
||||
return implode((string) ($values ?? ''), (array) $separator);
|
||||
}
|
||||
return implode((string) ($separator ?? ''), (array) $values);
|
||||
}
|
||||
|
||||
/**
|
||||
* Smarty in_array modifier plugin
|
||||
* Type: modifier
|
||||
* Name: in_array
|
||||
* Purpose: test if value is contained in an array
|
||||
*
|
||||
* @param mixed $needle
|
||||
* @param array $array
|
||||
* @param bool $strict
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function smarty_modifier_in_array($needle, $array, $strict = false)
|
||||
{
|
||||
return in_array($needle, (array) $array, (bool) $strict);
|
||||
}
|
||||
|
||||
/**
|
||||
* Smarty join modifier plugin
|
||||
* Type: modifier
|
||||
* Name: join
|
||||
* Purpose: join an array of values into a single string
|
||||
*
|
||||
* @param array $values
|
||||
* @param string $separator
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function smarty_modifier_join($values, $separator = '')
|
||||
{
|
||||
if (is_array($separator)) {
|
||||
trigger_error("Using join with the separator first is deprecated. " .
|
||||
"Call join using the array first, separator second.", E_USER_DEPRECATED);
|
||||
return implode((string) ($values ?? ''), (array) $separator);
|
||||
}
|
||||
return implode((string) ($separator ?? ''), (array) $values);
|
||||
}
|
||||
|
||||
/**
|
||||
* Smarty wordwrap modifier plugin
|
||||
* Type: modifier
|
||||
|
||||
@@ -0,0 +1,30 @@
|
||||
<?php
|
||||
|
||||
namespace Smarty\FunctionHandler;
|
||||
|
||||
use Smarty\Exception;
|
||||
use Smarty\Template;
|
||||
|
||||
/**
|
||||
* in_array(mixed $needle, array $haystack, bool $strict = false): bool
|
||||
* Returns true if needle is found in the array, false otherwise
|
||||
*/
|
||||
class InArray extends Base {
|
||||
|
||||
public function handle($params, Template $template) {
|
||||
|
||||
$params = array_values($params ?? []);
|
||||
|
||||
if (count($params) < 2 || count($params) > 3) {
|
||||
throw new Exception("Invalid number of arguments for in_array. in_arrays expects 2 or 3 parameters.");
|
||||
}
|
||||
|
||||
// default to false, true if param 3 is set to true
|
||||
$needle = $params[0];
|
||||
$haystack = (array) $params[1];
|
||||
$strict = count($params) == 3 && $params[2];
|
||||
|
||||
return in_array($needle, $haystack, $strict);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,21 @@
|
||||
<?php
|
||||
|
||||
namespace Smarty\FunctionHandler;
|
||||
|
||||
use Smarty\Exception;
|
||||
use Smarty\Template;
|
||||
|
||||
/**
|
||||
* is_array(mixed $value): bool
|
||||
* Returns true if value is an array, false otherwise.
|
||||
*/
|
||||
class IsArray extends Base {
|
||||
|
||||
public function handle($params, Template $template) {
|
||||
if (count($params) !== 1) {
|
||||
throw new Exception("Invalid number of arguments for is_array. is_array expects exactly 1 parameter.");
|
||||
}
|
||||
return is_array(reset($params));
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,28 @@
|
||||
<?php
|
||||
|
||||
namespace Smarty\FunctionHandler;
|
||||
|
||||
use Smarty\Exception;
|
||||
use Smarty\Template;
|
||||
|
||||
/**
|
||||
* Get string length
|
||||
*
|
||||
* strlen(string $string): int
|
||||
*
|
||||
* Returns length of the string on success, and 0 if the string is empty.
|
||||
*/
|
||||
class Strlen extends Base {
|
||||
|
||||
public function handle($params, Template $template) {
|
||||
|
||||
$params = array_values($params ?? []);
|
||||
|
||||
if (count($params) !== 1) {
|
||||
throw new Exception("Invalid number of arguments for strlen. strlen expects exactly 1 parameter.");
|
||||
}
|
||||
|
||||
return strlen((string) $params[0]);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,21 @@
|
||||
<?php
|
||||
|
||||
namespace Smarty\FunctionHandler;
|
||||
|
||||
use Smarty\Exception;
|
||||
use Smarty\Template;
|
||||
|
||||
/**
|
||||
* is_array(mixed $value): bool
|
||||
* Returns true if value is an array, false otherwise.
|
||||
*/
|
||||
class Time extends Base {
|
||||
|
||||
public function handle($params, Template $template) {
|
||||
if (count($params) > 0) {
|
||||
throw new Exception("Invalid number of arguments for time. time expects no parameters.");
|
||||
}
|
||||
return time();
|
||||
}
|
||||
|
||||
}
|
||||
+137
-135
@@ -2134,11 +2134,13 @@ public static $yy_action = array(
|
||||
}
|
||||
// line 292 "src/Parser/TemplateParser.y"
|
||||
public function yy_r9(){
|
||||
$this->current_buffer->append_subtree($this, $this->mergePrefixCode($this->yystack[$this->yyidx + 0]->minor));
|
||||
if ($this->compiler->has_code) {
|
||||
$this->current_buffer->append_subtree($this, $this->mergePrefixCode($this->yystack[$this->yyidx + 0]->minor));
|
||||
}
|
||||
$this->compiler->has_variable_string = false;
|
||||
$this->block_nesting_level = $this->compiler->getTagStackCount();
|
||||
}
|
||||
// line 302 "src/Parser/TemplateParser.y"
|
||||
// line 304 "src/Parser/TemplateParser.y"
|
||||
public function yy_r11(){
|
||||
$var = trim(substr($this->yystack[$this->yyidx + 0]->minor, $this->compiler->getLdelLength(), -$this->compiler->getRdelLength()), ' $');
|
||||
$attributes = [];
|
||||
@@ -2148,7 +2150,7 @@ public static $yy_action = array(
|
||||
}
|
||||
$this->_retvalue = $this->compiler->compilePrintExpression($this->compiler->compileVariable('\''.$var.'\''), $attributes);
|
||||
}
|
||||
// line 313 "src/Parser/TemplateParser.y"
|
||||
// line 315 "src/Parser/TemplateParser.y"
|
||||
public function yy_r12(){
|
||||
$tag = trim(substr($this->yystack[$this->yyidx + 0]->minor, $this->compiler->getLdelLength(), -$this->compiler->getRdelLength()));
|
||||
if ($tag == 'strip') {
|
||||
@@ -2169,7 +2171,7 @@ public static $yy_action = array(
|
||||
}
|
||||
}
|
||||
}
|
||||
// line 334 "src/Parser/TemplateParser.y"
|
||||
// line 336 "src/Parser/TemplateParser.y"
|
||||
public function yy_r13(){
|
||||
$j = strrpos($this->yystack[$this->yyidx + 0]->minor,'.');
|
||||
if ($this->yystack[$this->yyidx + 0]->minor[$j+1] == 'c') {
|
||||
@@ -2180,35 +2182,35 @@ public static $yy_action = array(
|
||||
$this->_retvalue = $this->compiler->compileParentBlock();
|
||||
}
|
||||
}
|
||||
// line 345 "src/Parser/TemplateParser.y"
|
||||
// line 347 "src/Parser/TemplateParser.y"
|
||||
public function yy_r14(){
|
||||
$this->_retvalue = $this->yystack[$this->yyidx + -1]->minor;
|
||||
}
|
||||
// line 349 "src/Parser/TemplateParser.y"
|
||||
// line 351 "src/Parser/TemplateParser.y"
|
||||
public function yy_r15(){
|
||||
$this->_retvalue = $this->yystack[$this->yyidx + -1]->minor;
|
||||
}
|
||||
// line 353 "src/Parser/TemplateParser.y"
|
||||
// line 355 "src/Parser/TemplateParser.y"
|
||||
public function yy_r16(){
|
||||
$this->_retvalue = $this->compiler->compilePrintExpression($this->yystack[$this->yyidx + 0]->minor[0], $this->yystack[$this->yyidx + 0]->minor[1]);
|
||||
}
|
||||
// line 362 "src/Parser/TemplateParser.y"
|
||||
// line 364 "src/Parser/TemplateParser.y"
|
||||
public function yy_r17(){
|
||||
$this->_retvalue = $this->compiler->compileTag('assign',array_merge(array(array('value'=>$this->yystack[$this->yyidx + 0]->minor[0]),array('var'=>'\''.substr($this->yystack[$this->yyidx + -1]->minor,1).'\'')),$this->yystack[$this->yyidx + 0]->minor[1]));
|
||||
}
|
||||
// line 366 "src/Parser/TemplateParser.y"
|
||||
// line 368 "src/Parser/TemplateParser.y"
|
||||
public function yy_r18(){
|
||||
$this->_retvalue = $this->compiler->compileTag('assign',array_merge(array(array('value'=>$this->yystack[$this->yyidx + 0]->minor[0]),array('var'=>$this->yystack[$this->yyidx + -1]->minor['var'])),$this->yystack[$this->yyidx + 0]->minor[1]),array('smarty_internal_index'=>$this->yystack[$this->yyidx + -1]->minor['smarty_internal_index']));
|
||||
}
|
||||
// line 370 "src/Parser/TemplateParser.y"
|
||||
// line 372 "src/Parser/TemplateParser.y"
|
||||
public function yy_r19(){
|
||||
$this->_retvalue = $this->yystack[$this->yyidx + 0]->minor;
|
||||
}
|
||||
// line 374 "src/Parser/TemplateParser.y"
|
||||
// line 376 "src/Parser/TemplateParser.y"
|
||||
public function yy_r20(){
|
||||
$this->_retvalue = array($this->yystack[$this->yyidx + -1]->minor,$this->yystack[$this->yyidx + 0]->minor);
|
||||
}
|
||||
// line 389 "src/Parser/TemplateParser.y"
|
||||
// line 391 "src/Parser/TemplateParser.y"
|
||||
public function yy_r24(){
|
||||
if (defined($this->yystack[$this->yyidx + -1]->minor)) {
|
||||
if ($this->security) {
|
||||
@@ -2219,7 +2221,7 @@ public static $yy_action = array(
|
||||
$this->_retvalue = $this->compiler->compileTag($this->yystack[$this->yyidx + -1]->minor,$this->yystack[$this->yyidx + 0]->minor);
|
||||
}
|
||||
}
|
||||
// line 399 "src/Parser/TemplateParser.y"
|
||||
// line 401 "src/Parser/TemplateParser.y"
|
||||
public function yy_r25(){
|
||||
if (defined($this->yystack[$this->yyidx + 0]->minor)) {
|
||||
if ($this->security) {
|
||||
@@ -2230,7 +2232,7 @@ public static $yy_action = array(
|
||||
$this->_retvalue = $this->compiler->compileTag($this->yystack[$this->yyidx + 0]->minor,array());
|
||||
}
|
||||
}
|
||||
// line 412 "src/Parser/TemplateParser.y"
|
||||
// line 414 "src/Parser/TemplateParser.y"
|
||||
public function yy_r26(){
|
||||
if (defined($this->yystack[$this->yyidx + -2]->minor)) {
|
||||
if ($this->security) {
|
||||
@@ -2241,66 +2243,66 @@ public static $yy_action = array(
|
||||
$this->_retvalue = $this->compiler->compileTag($this->yystack[$this->yyidx + -2]->minor,$this->yystack[$this->yyidx + 0]->minor, array('modifierlist'=>$this->yystack[$this->yyidx + -1]->minor));
|
||||
}
|
||||
}
|
||||
// line 424 "src/Parser/TemplateParser.y"
|
||||
// line 426 "src/Parser/TemplateParser.y"
|
||||
public function yy_r27(){
|
||||
$this->_retvalue = $this->compiler->compileTag($this->yystack[$this->yyidx + -3]->minor,$this->yystack[$this->yyidx + 0]->minor,array('object_method'=>$this->yystack[$this->yyidx + -1]->minor));
|
||||
}
|
||||
// line 429 "src/Parser/TemplateParser.y"
|
||||
// line 431 "src/Parser/TemplateParser.y"
|
||||
public function yy_r28(){
|
||||
$this->_retvalue = $this->compiler->compileTag($this->yystack[$this->yyidx + -4]->minor,$this->yystack[$this->yyidx + 0]->minor,array('modifierlist'=>$this->yystack[$this->yyidx + -1]->minor, 'object_method'=>$this->yystack[$this->yyidx + -2]->minor));
|
||||
}
|
||||
// line 434 "src/Parser/TemplateParser.y"
|
||||
// line 436 "src/Parser/TemplateParser.y"
|
||||
public function yy_r29(){
|
||||
$tag = trim(substr($this->yystack[$this->yyidx + -1]->minor,$this->compiler->getLdelLength()));
|
||||
$this->_retvalue = $this->compiler->compileTag(($tag === 'else if')? 'elseif' : $tag,array(),array('if condition'=>$this->yystack[$this->yyidx + 0]->minor));
|
||||
}
|
||||
// line 439 "src/Parser/TemplateParser.y"
|
||||
// line 441 "src/Parser/TemplateParser.y"
|
||||
public function yy_r30(){
|
||||
$tag = trim(substr($this->yystack[$this->yyidx + -2]->minor,$this->compiler->getLdelLength()));
|
||||
$this->_retvalue = $this->compiler->compileTag(($tag === 'else if')? 'elseif' : $tag,$this->yystack[$this->yyidx + 0]->minor,array('if condition'=>$this->yystack[$this->yyidx + -1]->minor));
|
||||
}
|
||||
// line 444 "src/Parser/TemplateParser.y"
|
||||
// line 446 "src/Parser/TemplateParser.y"
|
||||
public function yy_r31(){
|
||||
$tag = trim(substr($this->yystack[$this->yyidx + -1]->minor,$this->compiler->getLdelLength()));
|
||||
$this->_retvalue = $this->compiler->compileTag(($tag === 'else if')? 'elseif' : $tag,array(),array('if condition'=>$this->yystack[$this->yyidx + 0]->minor));
|
||||
}
|
||||
// line 455 "src/Parser/TemplateParser.y"
|
||||
// line 457 "src/Parser/TemplateParser.y"
|
||||
public function yy_r33(){
|
||||
$this->_retvalue = $this->compiler->compileTag('for',array_merge($this->yystack[$this->yyidx + 0]->minor,array(array('start'=>$this->yystack[$this->yyidx + -6]->minor),array('ifexp'=>$this->yystack[$this->yyidx + -4]->minor),array('var'=>$this->yystack[$this->yyidx + -2]->minor),array('step'=>$this->yystack[$this->yyidx + -1]->minor))),1);
|
||||
}
|
||||
// line 459 "src/Parser/TemplateParser.y"
|
||||
// line 461 "src/Parser/TemplateParser.y"
|
||||
public function yy_r34(){
|
||||
$this->_retvalue = '='.$this->yystack[$this->yyidx + 0]->minor;
|
||||
}
|
||||
// line 467 "src/Parser/TemplateParser.y"
|
||||
// line 469 "src/Parser/TemplateParser.y"
|
||||
public function yy_r36(){
|
||||
$this->_retvalue = $this->compiler->compileTag('for',array_merge($this->yystack[$this->yyidx + 0]->minor,array(array('start'=>$this->yystack[$this->yyidx + -3]->minor),array('to'=>$this->yystack[$this->yyidx + -1]->minor))),0);
|
||||
}
|
||||
// line 471 "src/Parser/TemplateParser.y"
|
||||
// line 473 "src/Parser/TemplateParser.y"
|
||||
public function yy_r37(){
|
||||
$this->_retvalue = $this->compiler->compileTag('for',array_merge($this->yystack[$this->yyidx + 0]->minor,array(array('start'=>$this->yystack[$this->yyidx + -5]->minor),array('to'=>$this->yystack[$this->yyidx + -3]->minor),array('step'=>$this->yystack[$this->yyidx + -1]->minor))),0);
|
||||
}
|
||||
// line 476 "src/Parser/TemplateParser.y"
|
||||
// line 478 "src/Parser/TemplateParser.y"
|
||||
public function yy_r38(){
|
||||
$this->_retvalue = $this->compiler->compileTag('foreach',array_merge($this->yystack[$this->yyidx + 0]->minor,array(array('from'=>$this->yystack[$this->yyidx + -3]->minor),array('item'=>$this->yystack[$this->yyidx + -1]->minor))));
|
||||
}
|
||||
// line 480 "src/Parser/TemplateParser.y"
|
||||
// line 482 "src/Parser/TemplateParser.y"
|
||||
public function yy_r39(){
|
||||
$this->_retvalue = $this->compiler->compileTag('foreach',array_merge($this->yystack[$this->yyidx + 0]->minor,array(array('from'=>$this->yystack[$this->yyidx + -5]->minor),array('item'=>$this->yystack[$this->yyidx + -1]->minor),array('key'=>$this->yystack[$this->yyidx + -3]->minor))));
|
||||
}
|
||||
// line 483 "src/Parser/TemplateParser.y"
|
||||
// line 485 "src/Parser/TemplateParser.y"
|
||||
public function yy_r40(){
|
||||
$this->_retvalue = $this->compiler->compileTag('foreach',$this->yystack[$this->yyidx + 0]->minor);
|
||||
}
|
||||
// line 488 "src/Parser/TemplateParser.y"
|
||||
// line 490 "src/Parser/TemplateParser.y"
|
||||
public function yy_r41(){
|
||||
$this->_retvalue = $this->compiler->compileTag('setfilter',array(),array('modifier_list'=>array(array_merge(array($this->yystack[$this->yyidx + -1]->minor),$this->yystack[$this->yyidx + 0]->minor))));
|
||||
}
|
||||
// line 492 "src/Parser/TemplateParser.y"
|
||||
// line 494 "src/Parser/TemplateParser.y"
|
||||
public function yy_r42(){
|
||||
$this->_retvalue = $this->compiler->compileTag('setfilter',array(),array('modifier_list'=>array_merge(array(array_merge(array($this->yystack[$this->yyidx + -2]->minor),$this->yystack[$this->yyidx + -1]->minor)),$this->yystack[$this->yyidx + 0]->minor)));
|
||||
}
|
||||
// line 498 "src/Parser/TemplateParser.y"
|
||||
// line 500 "src/Parser/TemplateParser.y"
|
||||
public function yy_r43(){
|
||||
$tag = trim(substr($this->yystack[$this->yyidx + 0]->minor, $this->compiler->getLdelLength(), -$this->compiler->getRdelLength()), ' /');
|
||||
if ($tag === 'strip') {
|
||||
@@ -2310,36 +2312,36 @@ public static $yy_action = array(
|
||||
$this->_retvalue = $this->compiler->compileTag($tag.'close',array());
|
||||
}
|
||||
}
|
||||
// line 507 "src/Parser/TemplateParser.y"
|
||||
// line 509 "src/Parser/TemplateParser.y"
|
||||
public function yy_r44(){
|
||||
$this->_retvalue = $this->compiler->compileTag($this->yystack[$this->yyidx + 0]->minor.'close',array());
|
||||
}
|
||||
// line 511 "src/Parser/TemplateParser.y"
|
||||
// line 513 "src/Parser/TemplateParser.y"
|
||||
public function yy_r45(){
|
||||
$this->_retvalue = $this->compiler->compileTag($this->yystack[$this->yyidx + -1]->minor.'close',array(),array('modifier_list'=>$this->yystack[$this->yyidx + 0]->minor));
|
||||
}
|
||||
// line 516 "src/Parser/TemplateParser.y"
|
||||
// line 518 "src/Parser/TemplateParser.y"
|
||||
public function yy_r46(){
|
||||
$this->_retvalue = $this->compiler->compileTag($this->yystack[$this->yyidx + -2]->minor.'close',array(),array('object_method'=>$this->yystack[$this->yyidx + 0]->minor));
|
||||
}
|
||||
// line 520 "src/Parser/TemplateParser.y"
|
||||
// line 522 "src/Parser/TemplateParser.y"
|
||||
public function yy_r47(){
|
||||
$this->_retvalue = $this->compiler->compileTag($this->yystack[$this->yyidx + -3]->minor.'close',array(),array('object_method'=>$this->yystack[$this->yyidx + -1]->minor, 'modifier_list'=>$this->yystack[$this->yyidx + 0]->minor));
|
||||
}
|
||||
// line 528 "src/Parser/TemplateParser.y"
|
||||
// line 530 "src/Parser/TemplateParser.y"
|
||||
public function yy_r48(){
|
||||
$this->_retvalue = $this->yystack[$this->yyidx + -1]->minor;
|
||||
$this->_retvalue[] = $this->yystack[$this->yyidx + 0]->minor;
|
||||
}
|
||||
// line 534 "src/Parser/TemplateParser.y"
|
||||
// line 536 "src/Parser/TemplateParser.y"
|
||||
public function yy_r49(){
|
||||
$this->_retvalue = array($this->yystack[$this->yyidx + 0]->minor);
|
||||
}
|
||||
// line 539 "src/Parser/TemplateParser.y"
|
||||
// line 541 "src/Parser/TemplateParser.y"
|
||||
public function yy_r50(){
|
||||
$this->_retvalue = array();
|
||||
}
|
||||
// line 544 "src/Parser/TemplateParser.y"
|
||||
// line 546 "src/Parser/TemplateParser.y"
|
||||
public function yy_r51(){
|
||||
if (defined($this->yystack[$this->yyidx + 0]->minor)) {
|
||||
if ($this->security) {
|
||||
@@ -2350,108 +2352,108 @@ public static $yy_action = array(
|
||||
$this->_retvalue = array($this->yystack[$this->yyidx + -2]->minor=>'\''.$this->yystack[$this->yyidx + 0]->minor.'\'');
|
||||
}
|
||||
}
|
||||
// line 555 "src/Parser/TemplateParser.y"
|
||||
// line 557 "src/Parser/TemplateParser.y"
|
||||
public function yy_r52(){
|
||||
$this->_retvalue = array(trim($this->yystack[$this->yyidx + -1]->minor," =\n\r\t")=>$this->yystack[$this->yyidx + 0]->minor);
|
||||
}
|
||||
// line 563 "src/Parser/TemplateParser.y"
|
||||
// line 565 "src/Parser/TemplateParser.y"
|
||||
public function yy_r54(){
|
||||
$this->_retvalue = '\''.$this->yystack[$this->yyidx + 0]->minor.'\'';
|
||||
}
|
||||
// line 575 "src/Parser/TemplateParser.y"
|
||||
// line 577 "src/Parser/TemplateParser.y"
|
||||
public function yy_r57(){
|
||||
$this->_retvalue = array($this->yystack[$this->yyidx + -2]->minor=>$this->yystack[$this->yyidx + 0]->minor);
|
||||
}
|
||||
// line 588 "src/Parser/TemplateParser.y"
|
||||
// line 590 "src/Parser/TemplateParser.y"
|
||||
public function yy_r59(){
|
||||
$this->yystack[$this->yyidx + -2]->minor[]=$this->yystack[$this->yyidx + 0]->minor;
|
||||
$this->_retvalue = $this->yystack[$this->yyidx + -2]->minor;
|
||||
}
|
||||
// line 593 "src/Parser/TemplateParser.y"
|
||||
// line 595 "src/Parser/TemplateParser.y"
|
||||
public function yy_r60(){
|
||||
$this->_retvalue = array('var' => '\''.substr($this->yystack[$this->yyidx + -2]->minor,1).'\'', 'value'=>$this->yystack[$this->yyidx + 0]->minor);
|
||||
}
|
||||
// line 600 "src/Parser/TemplateParser.y"
|
||||
// line 602 "src/Parser/TemplateParser.y"
|
||||
public function yy_r62(){
|
||||
$this->_retvalue = array('var' => $this->yystack[$this->yyidx + -2]->minor, 'value'=>$this->yystack[$this->yyidx + 0]->minor);
|
||||
}
|
||||
// line 604 "src/Parser/TemplateParser.y"
|
||||
// line 606 "src/Parser/TemplateParser.y"
|
||||
public function yy_r63(){
|
||||
$this->_retvalue = $this->yystack[$this->yyidx + -1]->minor;
|
||||
}
|
||||
// line 629 "src/Parser/TemplateParser.y"
|
||||
// line 631 "src/Parser/TemplateParser.y"
|
||||
public function yy_r67(){
|
||||
$this->_retvalue = '$_smarty_tpl->getVariable(\''. substr($this->yystack[$this->yyidx + 0]->minor,1) .'\')->preIncDec(\'' . $this->yystack[$this->yyidx + -1]->minor . '\')';
|
||||
}
|
||||
// line 634 "src/Parser/TemplateParser.y"
|
||||
// line 636 "src/Parser/TemplateParser.y"
|
||||
public function yy_r68(){
|
||||
$this->_retvalue = '$_smarty_tpl->getVariable(\''. substr($this->yystack[$this->yyidx + -1]->minor,1) .'\')->postIncDec(\'' . $this->yystack[$this->yyidx + 0]->minor . '\')';
|
||||
}
|
||||
// line 639 "src/Parser/TemplateParser.y"
|
||||
// line 641 "src/Parser/TemplateParser.y"
|
||||
public function yy_r69(){
|
||||
$this->_retvalue = '$_smarty_tpl->getStreamVariable(\''.substr($this->yystack[$this->yyidx + -2]->minor,1).'://' . $this->yystack[$this->yyidx + 0]->minor . '\')';
|
||||
}
|
||||
// line 644 "src/Parser/TemplateParser.y"
|
||||
// line 646 "src/Parser/TemplateParser.y"
|
||||
public function yy_r70(){
|
||||
$this->_retvalue = $this->yystack[$this->yyidx + -2]->minor . trim($this->yystack[$this->yyidx + -1]->minor) . $this->yystack[$this->yyidx + 0]->minor;
|
||||
}
|
||||
// line 654 "src/Parser/TemplateParser.y"
|
||||
// line 656 "src/Parser/TemplateParser.y"
|
||||
public function yy_r72(){
|
||||
$this->_retvalue = $this->yystack[$this->yyidx + -1]->minor['pre']. $this->yystack[$this->yyidx + -2]->minor.$this->yystack[$this->yyidx + -1]->minor['op'].$this->yystack[$this->yyidx + 0]->minor .')';
|
||||
}
|
||||
// line 658 "src/Parser/TemplateParser.y"
|
||||
// line 660 "src/Parser/TemplateParser.y"
|
||||
public function yy_r73(){
|
||||
$this->_retvalue = $this->yystack[$this->yyidx + -2]->minor.$this->yystack[$this->yyidx + -1]->minor.$this->yystack[$this->yyidx + 0]->minor;
|
||||
}
|
||||
// line 662 "src/Parser/TemplateParser.y"
|
||||
// line 664 "src/Parser/TemplateParser.y"
|
||||
public function yy_r74(){
|
||||
$this->_retvalue = $this->yystack[$this->yyidx + 0]->minor . $this->yystack[$this->yyidx + -1]->minor . ')';
|
||||
}
|
||||
// line 666 "src/Parser/TemplateParser.y"
|
||||
// line 668 "src/Parser/TemplateParser.y"
|
||||
public function yy_r75(){
|
||||
$this->_retvalue = 'in_array('.$this->yystack[$this->yyidx + -2]->minor.','.$this->yystack[$this->yyidx + 0]->minor.')';
|
||||
}
|
||||
// line 670 "src/Parser/TemplateParser.y"
|
||||
// line 672 "src/Parser/TemplateParser.y"
|
||||
public function yy_r76(){
|
||||
$this->_retvalue = 'in_array('.$this->yystack[$this->yyidx + -2]->minor.',(array)'.$this->yystack[$this->yyidx + 0]->minor.')';
|
||||
}
|
||||
// line 675 "src/Parser/TemplateParser.y"
|
||||
// line 677 "src/Parser/TemplateParser.y"
|
||||
public function yy_r77(){
|
||||
$this->_retvalue = $this->yystack[$this->yyidx + -3]->minor.' ?? '.$this->yystack[$this->yyidx + 0]->minor;
|
||||
}
|
||||
// line 682 "src/Parser/TemplateParser.y"
|
||||
// line 684 "src/Parser/TemplateParser.y"
|
||||
public function yy_r78(){
|
||||
$this->_retvalue = $this->yystack[$this->yyidx + -4]->minor.' ? '. $this->compiler->compileVariable('\''.substr($this->yystack[$this->yyidx + -2]->minor,1).'\'') . ' : '.$this->yystack[$this->yyidx + 0]->minor;
|
||||
}
|
||||
// line 686 "src/Parser/TemplateParser.y"
|
||||
// line 688 "src/Parser/TemplateParser.y"
|
||||
public function yy_r79(){
|
||||
$this->_retvalue = $this->yystack[$this->yyidx + -4]->minor.' ? '.$this->yystack[$this->yyidx + -2]->minor.' : '.$this->yystack[$this->yyidx + 0]->minor;
|
||||
}
|
||||
// line 695 "src/Parser/TemplateParser.y"
|
||||
// line 697 "src/Parser/TemplateParser.y"
|
||||
public function yy_r81(){
|
||||
$this->_retvalue = $this->yystack[$this->yyidx + -3]->minor.' ?: '.$this->yystack[$this->yyidx + 0]->minor;
|
||||
}
|
||||
// line 705 "src/Parser/TemplateParser.y"
|
||||
// line 707 "src/Parser/TemplateParser.y"
|
||||
public function yy_r83(){
|
||||
$this->_retvalue = $this->yystack[$this->yyidx + -1]->minor.$this->yystack[$this->yyidx + 0]->minor;
|
||||
}
|
||||
// line 710 "src/Parser/TemplateParser.y"
|
||||
// line 712 "src/Parser/TemplateParser.y"
|
||||
public function yy_r84(){
|
||||
$this->_retvalue = '!'.$this->yystack[$this->yyidx + 0]->minor;
|
||||
}
|
||||
// line 731 "src/Parser/TemplateParser.y"
|
||||
// line 733 "src/Parser/TemplateParser.y"
|
||||
public function yy_r89(){
|
||||
$this->_retvalue = $this->yystack[$this->yyidx + -2]->minor.'.'.$this->yystack[$this->yyidx + 0]->minor;
|
||||
}
|
||||
// line 735 "src/Parser/TemplateParser.y"
|
||||
// line 737 "src/Parser/TemplateParser.y"
|
||||
public function yy_r90(){
|
||||
$this->_retvalue = $this->yystack[$this->yyidx + -1]->minor.'.';
|
||||
}
|
||||
// line 739 "src/Parser/TemplateParser.y"
|
||||
// line 741 "src/Parser/TemplateParser.y"
|
||||
public function yy_r91(){
|
||||
$this->_retvalue = '.'.$this->yystack[$this->yyidx + 0]->minor;
|
||||
}
|
||||
// line 744 "src/Parser/TemplateParser.y"
|
||||
// line 746 "src/Parser/TemplateParser.y"
|
||||
public function yy_r92(){
|
||||
if (defined($this->yystack[$this->yyidx + 0]->minor)) {
|
||||
if ($this->security) {
|
||||
@@ -2462,15 +2464,15 @@ public static $yy_action = array(
|
||||
$this->_retvalue = '\''.$this->yystack[$this->yyidx + 0]->minor.'\'';
|
||||
}
|
||||
}
|
||||
// line 761 "src/Parser/TemplateParser.y"
|
||||
// line 763 "src/Parser/TemplateParser.y"
|
||||
public function yy_r94(){
|
||||
$this->_retvalue = '('. $this->yystack[$this->yyidx + -1]->minor .')';
|
||||
}
|
||||
// line 765 "src/Parser/TemplateParser.y"
|
||||
// line 767 "src/Parser/TemplateParser.y"
|
||||
public function yy_r95(){
|
||||
$this->_retvalue = $this->yystack[$this->yyidx + -2]->minor.$this->yystack[$this->yyidx + -1]->minor.$this->yystack[$this->yyidx + 0]->minor;
|
||||
}
|
||||
// line 783 "src/Parser/TemplateParser.y"
|
||||
// line 785 "src/Parser/TemplateParser.y"
|
||||
public function yy_r99(){
|
||||
if ($this->security && $this->security->static_classes !== array()) {
|
||||
$this->compiler->trigger_template_error('dynamic static class not allowed by security setting');
|
||||
@@ -2483,18 +2485,18 @@ public static $yy_action = array(
|
||||
}
|
||||
$this->_retvalue = $prefixVar .'::'.$this->yystack[$this->yyidx + 0]->minor[0].$this->yystack[$this->yyidx + 0]->minor[1];
|
||||
}
|
||||
// line 797 "src/Parser/TemplateParser.y"
|
||||
// line 799 "src/Parser/TemplateParser.y"
|
||||
public function yy_r100(){
|
||||
$prefixVar = $this->compiler->getNewPrefixVariable();
|
||||
$tmp = $this->compiler->appendCode('<?php ob_start();?>', $this->yystack[$this->yyidx + 0]->minor);
|
||||
$this->compiler->appendPrefixCode($this->compiler->appendCode($tmp, "<?php {$prefixVar} = ob_get_clean();?>"));
|
||||
$this->_retvalue = $prefixVar;
|
||||
}
|
||||
// line 804 "src/Parser/TemplateParser.y"
|
||||
// line 806 "src/Parser/TemplateParser.y"
|
||||
public function yy_r101(){
|
||||
$this->_retvalue = $this->compiler->compileModifier($this->yystack[$this->yyidx + 0]->minor, $this->yystack[$this->yyidx + -1]->minor);
|
||||
}
|
||||
// line 817 "src/Parser/TemplateParser.y"
|
||||
// line 819 "src/Parser/TemplateParser.y"
|
||||
public function yy_r104(){
|
||||
if (!in_array(strtolower($this->yystack[$this->yyidx + -2]->minor), array('self', 'parent')) && (!$this->security || $this->security->isTrustedStaticClassAccess($this->yystack[$this->yyidx + -2]->minor, $this->yystack[$this->yyidx + 0]->minor, $this->compiler))) {
|
||||
if (isset($this->smarty->registered_classes[$this->yystack[$this->yyidx + -2]->minor])) {
|
||||
@@ -2506,15 +2508,15 @@ public static $yy_action = array(
|
||||
$this->compiler->trigger_template_error ('static class \''.$this->yystack[$this->yyidx + -2]->minor.'\' is undefined or not allowed by security setting');
|
||||
}
|
||||
}
|
||||
// line 836 "src/Parser/TemplateParser.y"
|
||||
// line 838 "src/Parser/TemplateParser.y"
|
||||
public function yy_r106(){
|
||||
$this->_retvalue = $this->yystack[$this->yyidx + 0]->minor;
|
||||
}
|
||||
// line 847 "src/Parser/TemplateParser.y"
|
||||
// line 849 "src/Parser/TemplateParser.y"
|
||||
public function yy_r107(){
|
||||
$this->_retvalue = $this->compiler->compileVariable('\''.substr($this->yystack[$this->yyidx + 0]->minor,1).'\'');
|
||||
}
|
||||
// line 850 "src/Parser/TemplateParser.y"
|
||||
// line 852 "src/Parser/TemplateParser.y"
|
||||
public function yy_r108(){
|
||||
if ($this->yystack[$this->yyidx + 0]->minor['var'] === '\'smarty\'') {
|
||||
$smarty_var = (new \Smarty\Compile\SpecialVariableCompiler())->compile(array(),$this->compiler,$this->yystack[$this->yyidx + 0]->minor['smarty_internal_index']);
|
||||
@@ -2526,104 +2528,104 @@ public static $yy_action = array(
|
||||
$this->_retvalue = $this->compiler->compileVariable($this->yystack[$this->yyidx + 0]->minor['var']).$this->yystack[$this->yyidx + 0]->minor['smarty_internal_index'];
|
||||
}
|
||||
}
|
||||
// line 863 "src/Parser/TemplateParser.y"
|
||||
// line 865 "src/Parser/TemplateParser.y"
|
||||
public function yy_r109(){
|
||||
$this->_retvalue = '$_smarty_tpl->getVariable('. $this->yystack[$this->yyidx + -2]->minor .')->'.$this->yystack[$this->yyidx + 0]->minor;
|
||||
}
|
||||
// line 873 "src/Parser/TemplateParser.y"
|
||||
// line 875 "src/Parser/TemplateParser.y"
|
||||
public function yy_r111(){
|
||||
$this->_retvalue = $this->compiler->compileConfigVariable('\'' . $this->yystack[$this->yyidx + -1]->minor . '\'');
|
||||
}
|
||||
// line 877 "src/Parser/TemplateParser.y"
|
||||
// line 879 "src/Parser/TemplateParser.y"
|
||||
public function yy_r112(){
|
||||
$this->_retvalue = '(is_array($tmp = ' . $this->compiler->compileConfigVariable('\'' . $this->yystack[$this->yyidx + -2]->minor . '\'') . ') ? $tmp'.$this->yystack[$this->yyidx + 0]->minor.' :null)';
|
||||
}
|
||||
// line 881 "src/Parser/TemplateParser.y"
|
||||
// line 883 "src/Parser/TemplateParser.y"
|
||||
public function yy_r113(){
|
||||
$this->_retvalue = $this->compiler->compileConfigVariable($this->yystack[$this->yyidx + -1]->minor);
|
||||
}
|
||||
// line 885 "src/Parser/TemplateParser.y"
|
||||
// line 887 "src/Parser/TemplateParser.y"
|
||||
public function yy_r114(){
|
||||
$this->_retvalue = '(is_array($tmp = ' . $this->compiler->compileConfigVariable($this->yystack[$this->yyidx + -2]->minor) . ') ? $tmp'.$this->yystack[$this->yyidx + 0]->minor.' : null)';
|
||||
}
|
||||
// line 889 "src/Parser/TemplateParser.y"
|
||||
// line 891 "src/Parser/TemplateParser.y"
|
||||
public function yy_r115(){
|
||||
$this->_retvalue = array('var'=>'\''.substr($this->yystack[$this->yyidx + -1]->minor,1).'\'', 'smarty_internal_index'=>$this->yystack[$this->yyidx + 0]->minor);
|
||||
}
|
||||
// line 892 "src/Parser/TemplateParser.y"
|
||||
// line 894 "src/Parser/TemplateParser.y"
|
||||
public function yy_r116(){
|
||||
$this->_retvalue = array('var'=>$this->yystack[$this->yyidx + -1]->minor, 'smarty_internal_index'=>$this->yystack[$this->yyidx + 0]->minor);
|
||||
}
|
||||
// line 905 "src/Parser/TemplateParser.y"
|
||||
// line 907 "src/Parser/TemplateParser.y"
|
||||
public function yy_r118(){
|
||||
return;
|
||||
}
|
||||
// line 911 "src/Parser/TemplateParser.y"
|
||||
// line 913 "src/Parser/TemplateParser.y"
|
||||
public function yy_r119(){
|
||||
$this->_retvalue = '['.$this->compiler->compileVariable('\''.substr($this->yystack[$this->yyidx + 0]->minor,1).'\'').']';
|
||||
}
|
||||
// line 914 "src/Parser/TemplateParser.y"
|
||||
// line 916 "src/Parser/TemplateParser.y"
|
||||
public function yy_r120(){
|
||||
$this->_retvalue = '['.$this->compiler->compileVariable($this->yystack[$this->yyidx + 0]->minor).']';
|
||||
}
|
||||
// line 918 "src/Parser/TemplateParser.y"
|
||||
// line 920 "src/Parser/TemplateParser.y"
|
||||
public function yy_r121(){
|
||||
$this->_retvalue = '['.$this->compiler->compileVariable($this->yystack[$this->yyidx + -2]->minor).'->'.$this->yystack[$this->yyidx + 0]->minor.']';
|
||||
}
|
||||
// line 922 "src/Parser/TemplateParser.y"
|
||||
// line 924 "src/Parser/TemplateParser.y"
|
||||
public function yy_r122(){
|
||||
$this->_retvalue = '[\''. $this->yystack[$this->yyidx + 0]->minor .'\']';
|
||||
}
|
||||
// line 926 "src/Parser/TemplateParser.y"
|
||||
// line 928 "src/Parser/TemplateParser.y"
|
||||
public function yy_r123(){
|
||||
$this->_retvalue = '['. $this->yystack[$this->yyidx + 0]->minor .']';
|
||||
}
|
||||
// line 931 "src/Parser/TemplateParser.y"
|
||||
// line 933 "src/Parser/TemplateParser.y"
|
||||
public function yy_r124(){
|
||||
$this->_retvalue = '['. $this->yystack[$this->yyidx + -1]->minor .']';
|
||||
}
|
||||
// line 936 "src/Parser/TemplateParser.y"
|
||||
// line 938 "src/Parser/TemplateParser.y"
|
||||
public function yy_r125(){
|
||||
$this->_retvalue = '['.(new \Smarty\Compile\SpecialVariableCompiler())->compile(array(),$this->compiler,'[\'section\'][\''.$this->yystack[$this->yyidx + -1]->minor.'\'][\'index\']').']';
|
||||
}
|
||||
// line 940 "src/Parser/TemplateParser.y"
|
||||
// line 942 "src/Parser/TemplateParser.y"
|
||||
public function yy_r126(){
|
||||
$this->_retvalue = '['.(new \Smarty\Compile\SpecialVariableCompiler())->compile(array(),$this->compiler,'[\'section\'][\''.$this->yystack[$this->yyidx + -3]->minor.'\'][\''.$this->yystack[$this->yyidx + -1]->minor.'\']').']';
|
||||
}
|
||||
// line 943 "src/Parser/TemplateParser.y"
|
||||
// line 945 "src/Parser/TemplateParser.y"
|
||||
public function yy_r127(){
|
||||
$this->_retvalue = '['.$this->yystack[$this->yyidx + -1]->minor.']';
|
||||
}
|
||||
// line 949 "src/Parser/TemplateParser.y"
|
||||
// line 951 "src/Parser/TemplateParser.y"
|
||||
public function yy_r129(){
|
||||
$this->_retvalue = '['.$this->compiler->compileVariable('\''.substr($this->yystack[$this->yyidx + -1]->minor,1).'\'').']';
|
||||
}
|
||||
// line 965 "src/Parser/TemplateParser.y"
|
||||
// line 967 "src/Parser/TemplateParser.y"
|
||||
public function yy_r133(){
|
||||
$this->_retvalue = '[]';
|
||||
}
|
||||
// line 975 "src/Parser/TemplateParser.y"
|
||||
// line 977 "src/Parser/TemplateParser.y"
|
||||
public function yy_r134(){
|
||||
$this->_retvalue = '\''.substr($this->yystack[$this->yyidx + 0]->minor,1).'\'';
|
||||
}
|
||||
// line 979 "src/Parser/TemplateParser.y"
|
||||
// line 981 "src/Parser/TemplateParser.y"
|
||||
public function yy_r135(){
|
||||
$this->_retvalue = '\'\'';
|
||||
}
|
||||
// line 984 "src/Parser/TemplateParser.y"
|
||||
// line 986 "src/Parser/TemplateParser.y"
|
||||
public function yy_r136(){
|
||||
$this->_retvalue = $this->yystack[$this->yyidx + -1]->minor.'.'.$this->yystack[$this->yyidx + 0]->minor;
|
||||
}
|
||||
// line 992 "src/Parser/TemplateParser.y"
|
||||
// line 994 "src/Parser/TemplateParser.y"
|
||||
public function yy_r138(){
|
||||
$var = trim(substr($this->yystack[$this->yyidx + 0]->minor, $this->compiler->getLdelLength(), -$this->compiler->getRdelLength()), ' $');
|
||||
$this->_retvalue = $this->compiler->compileVariable('\''.$var.'\'');
|
||||
}
|
||||
// line 998 "src/Parser/TemplateParser.y"
|
||||
// line 1000 "src/Parser/TemplateParser.y"
|
||||
public function yy_r139(){
|
||||
$this->_retvalue = '('.$this->yystack[$this->yyidx + -1]->minor.')';
|
||||
}
|
||||
// line 1005 "src/Parser/TemplateParser.y"
|
||||
// line 1007 "src/Parser/TemplateParser.y"
|
||||
public function yy_r140(){
|
||||
if ($this->yystack[$this->yyidx + -1]->minor['var'] === '\'smarty\'') {
|
||||
$this->_retvalue = (new \Smarty\Compile\SpecialVariableCompiler())->compile(array(),$this->compiler,$this->yystack[$this->yyidx + -1]->minor['smarty_internal_index']).$this->yystack[$this->yyidx + 0]->minor;
|
||||
@@ -2631,58 +2633,58 @@ public static $yy_action = array(
|
||||
$this->_retvalue = $this->compiler->compileVariable($this->yystack[$this->yyidx + -1]->minor['var']).$this->yystack[$this->yyidx + -1]->minor['smarty_internal_index'].$this->yystack[$this->yyidx + 0]->minor;
|
||||
}
|
||||
}
|
||||
// line 1014 "src/Parser/TemplateParser.y"
|
||||
// line 1016 "src/Parser/TemplateParser.y"
|
||||
public function yy_r141(){
|
||||
$this->_retvalue = $this->yystack[$this->yyidx + 0]->minor;
|
||||
}
|
||||
// line 1019 "src/Parser/TemplateParser.y"
|
||||
// line 1021 "src/Parser/TemplateParser.y"
|
||||
public function yy_r142(){
|
||||
$this->_retvalue = $this->yystack[$this->yyidx + -1]->minor.$this->yystack[$this->yyidx + 0]->minor;
|
||||
}
|
||||
// line 1024 "src/Parser/TemplateParser.y"
|
||||
// line 1026 "src/Parser/TemplateParser.y"
|
||||
public function yy_r143(){
|
||||
if ($this->security && substr($this->yystack[$this->yyidx + -1]->minor,0,1) === '_') {
|
||||
$this->compiler->trigger_template_error (self::ERR1);
|
||||
}
|
||||
$this->_retvalue = '->'.$this->yystack[$this->yyidx + -1]->minor.$this->yystack[$this->yyidx + 0]->minor;
|
||||
}
|
||||
// line 1031 "src/Parser/TemplateParser.y"
|
||||
// line 1033 "src/Parser/TemplateParser.y"
|
||||
public function yy_r144(){
|
||||
if ($this->security) {
|
||||
$this->compiler->trigger_template_error (self::ERR2);
|
||||
}
|
||||
$this->_retvalue = '->{'.$this->compiler->compileVariable($this->yystack[$this->yyidx + -1]->minor).$this->yystack[$this->yyidx + 0]->minor.'}';
|
||||
}
|
||||
// line 1038 "src/Parser/TemplateParser.y"
|
||||
// line 1040 "src/Parser/TemplateParser.y"
|
||||
public function yy_r145(){
|
||||
if ($this->security) {
|
||||
$this->compiler->trigger_template_error (self::ERR2);
|
||||
}
|
||||
$this->_retvalue = '->{'.$this->yystack[$this->yyidx + -2]->minor.$this->yystack[$this->yyidx + 0]->minor.'}';
|
||||
}
|
||||
// line 1045 "src/Parser/TemplateParser.y"
|
||||
// line 1047 "src/Parser/TemplateParser.y"
|
||||
public function yy_r146(){
|
||||
if ($this->security) {
|
||||
$this->compiler->trigger_template_error (self::ERR2);
|
||||
}
|
||||
$this->_retvalue = '->{\''.$this->yystack[$this->yyidx + -4]->minor.'\'.'.$this->yystack[$this->yyidx + -2]->minor.$this->yystack[$this->yyidx + 0]->minor.'}';
|
||||
}
|
||||
// line 1053 "src/Parser/TemplateParser.y"
|
||||
// line 1055 "src/Parser/TemplateParser.y"
|
||||
public function yy_r147(){
|
||||
$this->_retvalue = '->'.$this->yystack[$this->yyidx + 0]->minor;
|
||||
}
|
||||
// line 1061 "src/Parser/TemplateParser.y"
|
||||
// line 1063 "src/Parser/TemplateParser.y"
|
||||
public function yy_r148(){
|
||||
$this->_retvalue = $this->compiler->compileModifierInExpression($this->yystack[$this->yyidx + -3]->minor, $this->yystack[$this->yyidx + -1]->minor);
|
||||
$this->_retvalue = $this->compiler->compileFunctionCall($this->yystack[$this->yyidx + -3]->minor, $this->yystack[$this->yyidx + -1]->minor);
|
||||
}
|
||||
// line 1069 "src/Parser/TemplateParser.y"
|
||||
// line 1071 "src/Parser/TemplateParser.y"
|
||||
public function yy_r149(){
|
||||
if ($this->security && substr($this->yystack[$this->yyidx + -3]->minor,0,1) === '_') {
|
||||
$this->compiler->trigger_template_error (self::ERR1);
|
||||
}
|
||||
$this->_retvalue = $this->yystack[$this->yyidx + -3]->minor . '('. implode(',',$this->yystack[$this->yyidx + -1]->minor) .')';
|
||||
}
|
||||
// line 1076 "src/Parser/TemplateParser.y"
|
||||
// line 1078 "src/Parser/TemplateParser.y"
|
||||
public function yy_r150(){
|
||||
if ($this->security) {
|
||||
$this->compiler->trigger_template_error (self::ERR2);
|
||||
@@ -2691,55 +2693,55 @@ public static $yy_action = array(
|
||||
$this->compiler->appendPrefixCode("<?php {$prefixVar} = ".$this->compiler->compileVariable('\''.substr($this->yystack[$this->yyidx + -3]->minor,1).'\'').';?>');
|
||||
$this->_retvalue = $prefixVar .'('. implode(',',$this->yystack[$this->yyidx + -1]->minor) .')';
|
||||
}
|
||||
// line 1087 "src/Parser/TemplateParser.y"
|
||||
// line 1089 "src/Parser/TemplateParser.y"
|
||||
public function yy_r151(){
|
||||
$this->_retvalue = array_merge($this->yystack[$this->yyidx + -2]->minor,array($this->yystack[$this->yyidx + 0]->minor));
|
||||
}
|
||||
// line 1104 "src/Parser/TemplateParser.y"
|
||||
// line 1106 "src/Parser/TemplateParser.y"
|
||||
public function yy_r154(){
|
||||
$this->_retvalue = array_merge($this->yystack[$this->yyidx + -2]->minor,array(array_merge($this->yystack[$this->yyidx + -1]->minor,$this->yystack[$this->yyidx + 0]->minor)));
|
||||
}
|
||||
// line 1108 "src/Parser/TemplateParser.y"
|
||||
// line 1110 "src/Parser/TemplateParser.y"
|
||||
public function yy_r155(){
|
||||
$this->_retvalue = array(array_merge($this->yystack[$this->yyidx + -1]->minor,$this->yystack[$this->yyidx + 0]->minor));
|
||||
}
|
||||
// line 1116 "src/Parser/TemplateParser.y"
|
||||
// line 1118 "src/Parser/TemplateParser.y"
|
||||
public function yy_r157(){
|
||||
$this->_retvalue = array($this->yystack[$this->yyidx + 0]->minor);
|
||||
}
|
||||
// line 1124 "src/Parser/TemplateParser.y"
|
||||
// line 1126 "src/Parser/TemplateParser.y"
|
||||
public function yy_r158(){
|
||||
$this->_retvalue = array_merge($this->yystack[$this->yyidx + -1]->minor,$this->yystack[$this->yyidx + 0]->minor);
|
||||
}
|
||||
// line 1137 "src/Parser/TemplateParser.y"
|
||||
// line 1139 "src/Parser/TemplateParser.y"
|
||||
public function yy_r161(){
|
||||
$this->_retvalue = array(trim($this->yystack[$this->yyidx + -1]->minor).$this->yystack[$this->yyidx + 0]->minor);
|
||||
}
|
||||
// line 1146 "src/Parser/TemplateParser.y"
|
||||
// line 1148 "src/Parser/TemplateParser.y"
|
||||
public function yy_r163(){
|
||||
$this->_retvalue = array($this->yystack[$this->yyidx + 0]->minor, '', 'method');
|
||||
}
|
||||
// line 1151 "src/Parser/TemplateParser.y"
|
||||
// line 1153 "src/Parser/TemplateParser.y"
|
||||
public function yy_r164(){
|
||||
$this->_retvalue = array($this->yystack[$this->yyidx + -1]->minor, $this->yystack[$this->yyidx + 0]->minor, 'method');
|
||||
}
|
||||
// line 1156 "src/Parser/TemplateParser.y"
|
||||
// line 1158 "src/Parser/TemplateParser.y"
|
||||
public function yy_r165(){
|
||||
$this->_retvalue = array($this->yystack[$this->yyidx + 0]->minor, '');
|
||||
}
|
||||
// line 1161 "src/Parser/TemplateParser.y"
|
||||
// line 1163 "src/Parser/TemplateParser.y"
|
||||
public function yy_r166(){
|
||||
$this->_retvalue = array($this->yystack[$this->yyidx + -1]->minor, $this->yystack[$this->yyidx + 0]->minor, 'property');
|
||||
}
|
||||
// line 1166 "src/Parser/TemplateParser.y"
|
||||
// line 1168 "src/Parser/TemplateParser.y"
|
||||
public function yy_r167(){
|
||||
$this->_retvalue = array($this->yystack[$this->yyidx + -2]->minor, $this->yystack[$this->yyidx + -1]->minor.$this->yystack[$this->yyidx + 0]->minor, 'property');
|
||||
}
|
||||
// line 1172 "src/Parser/TemplateParser.y"
|
||||
// line 1174 "src/Parser/TemplateParser.y"
|
||||
public function yy_r168(){
|
||||
$this->_retvalue = ' '. trim($this->yystack[$this->yyidx + 0]->minor) . ' ';
|
||||
}
|
||||
// line 1176 "src/Parser/TemplateParser.y"
|
||||
// line 1178 "src/Parser/TemplateParser.y"
|
||||
public function yy_r169(){
|
||||
static $lops = array(
|
||||
'eq' => ' == ',
|
||||
@@ -2759,7 +2761,7 @@ public static $yy_action = array(
|
||||
$op = strtolower(preg_replace('/\s*/', '', $this->yystack[$this->yyidx + 0]->minor));
|
||||
$this->_retvalue = $lops[$op];
|
||||
}
|
||||
// line 1195 "src/Parser/TemplateParser.y"
|
||||
// line 1197 "src/Parser/TemplateParser.y"
|
||||
public function yy_r170(){
|
||||
static $tlops = array(
|
||||
'isdivby' => array('op' => ' % ', 'pre' => '!('),
|
||||
@@ -2772,7 +2774,7 @@ public static $yy_action = array(
|
||||
$op = strtolower(preg_replace('/\s*/', '', $this->yystack[$this->yyidx + 0]->minor));
|
||||
$this->_retvalue = $tlops[$op];
|
||||
}
|
||||
// line 1208 "src/Parser/TemplateParser.y"
|
||||
// line 1210 "src/Parser/TemplateParser.y"
|
||||
public function yy_r171(){
|
||||
static $scond = array (
|
||||
'iseven' => '!(1 & ',
|
||||
@@ -2783,53 +2785,53 @@ public static $yy_action = array(
|
||||
$op = strtolower(str_replace(' ', '', $this->yystack[$this->yyidx + 0]->minor));
|
||||
$this->_retvalue = $scond[$op];
|
||||
}
|
||||
// line 1222 "src/Parser/TemplateParser.y"
|
||||
// line 1224 "src/Parser/TemplateParser.y"
|
||||
public function yy_r172(){
|
||||
$this->_retvalue = 'array('.$this->yystack[$this->yyidx + -1]->minor.')';
|
||||
}
|
||||
// line 1233 "src/Parser/TemplateParser.y"
|
||||
// line 1235 "src/Parser/TemplateParser.y"
|
||||
public function yy_r175(){
|
||||
$this->_retvalue = $this->yystack[$this->yyidx + -2]->minor.','.$this->yystack[$this->yyidx + 0]->minor;
|
||||
}
|
||||
// line 1241 "src/Parser/TemplateParser.y"
|
||||
// line 1243 "src/Parser/TemplateParser.y"
|
||||
public function yy_r177(){
|
||||
$this->_retvalue = $this->yystack[$this->yyidx + -2]->minor.'=>'.$this->yystack[$this->yyidx + 0]->minor;
|
||||
}
|
||||
// line 1245 "src/Parser/TemplateParser.y"
|
||||
// line 1247 "src/Parser/TemplateParser.y"
|
||||
public function yy_r178(){
|
||||
$this->_retvalue = '\''.$this->yystack[$this->yyidx + -2]->minor.'\'=>'.$this->yystack[$this->yyidx + 0]->minor;
|
||||
}
|
||||
// line 1261 "src/Parser/TemplateParser.y"
|
||||
// line 1263 "src/Parser/TemplateParser.y"
|
||||
public function yy_r181(){
|
||||
$this->compiler->leaveDoubleQuote();
|
||||
$this->_retvalue = $this->yystack[$this->yyidx + -1]->minor->to_smarty_php($this);
|
||||
}
|
||||
// line 1267 "src/Parser/TemplateParser.y"
|
||||
// line 1269 "src/Parser/TemplateParser.y"
|
||||
public function yy_r182(){
|
||||
$this->yystack[$this->yyidx + -1]->minor->append_subtree($this, $this->yystack[$this->yyidx + 0]->minor);
|
||||
$this->_retvalue = $this->yystack[$this->yyidx + -1]->minor;
|
||||
}
|
||||
// line 1272 "src/Parser/TemplateParser.y"
|
||||
// line 1274 "src/Parser/TemplateParser.y"
|
||||
public function yy_r183(){
|
||||
$this->_retvalue = new Dq($this, $this->yystack[$this->yyidx + 0]->minor);
|
||||
}
|
||||
// line 1276 "src/Parser/TemplateParser.y"
|
||||
// line 1278 "src/Parser/TemplateParser.y"
|
||||
public function yy_r184(){
|
||||
$this->_retvalue = new Code('(string)'.$this->yystack[$this->yyidx + -1]->minor);
|
||||
}
|
||||
// line 1280 "src/Parser/TemplateParser.y"
|
||||
// line 1282 "src/Parser/TemplateParser.y"
|
||||
public function yy_r185(){
|
||||
$this->_retvalue = new Code('(string)('.$this->yystack[$this->yyidx + -1]->minor.')');
|
||||
}
|
||||
// line 1284 "src/Parser/TemplateParser.y"
|
||||
// line 1286 "src/Parser/TemplateParser.y"
|
||||
public function yy_r186(){
|
||||
$this->_retvalue = new Code('(string)$_smarty_tpl->getValue(\''. substr($this->yystack[$this->yyidx + 0]->minor,1) .'\')');
|
||||
}
|
||||
// line 1296 "src/Parser/TemplateParser.y"
|
||||
// line 1298 "src/Parser/TemplateParser.y"
|
||||
public function yy_r189(){
|
||||
$this->_retvalue = new Tag($this, $this->yystack[$this->yyidx + 0]->minor);
|
||||
}
|
||||
// line 1300 "src/Parser/TemplateParser.y"
|
||||
// line 1302 "src/Parser/TemplateParser.y"
|
||||
public function yy_r190(){
|
||||
$this->_retvalue = new DqContent($this->yystack[$this->yyidx + 0]->minor);
|
||||
}
|
||||
|
||||
@@ -290,7 +290,9 @@ literal_e1(A) ::= . {
|
||||
}
|
||||
// Smarty tag
|
||||
template ::= template smartytag(B). {
|
||||
$this->current_buffer->append_subtree($this, $this->mergePrefixCode(B));
|
||||
if ($this->compiler->has_code) {
|
||||
$this->current_buffer->append_subtree($this, $this->mergePrefixCode(B));
|
||||
}
|
||||
$this->compiler->has_variable_string = false;
|
||||
$this->block_nesting_level = $this->compiler->getTagStackCount();
|
||||
}
|
||||
@@ -1059,7 +1061,7 @@ objectelement(res)::= PTR method(f). {
|
||||
// function
|
||||
//
|
||||
function(res) ::= ns1(f) OPENP params(p) CLOSEP. {
|
||||
res = $this->compiler->compileModifierInExpression(f, p);
|
||||
res = $this->compiler->compileFunctionCall(f, p);
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -26,26 +26,31 @@ class TplFunctionRuntime {
|
||||
*/
|
||||
public function callTemplateFunction(Template $tpl, $name, $params, $nocache) {
|
||||
$funcParam = $tpl->tplFunctions[$name] ?? ($tpl->getSmarty()->tplFunctions[$name] ?? null);
|
||||
if (!isset($funcParam)) {
|
||||
throw new \Smarty\Exception("Unable to find template function '{$name}'");
|
||||
}
|
||||
|
||||
if (!$tpl->caching || ($tpl->caching && $nocache)) {
|
||||
$function = $funcParam['call_name'];
|
||||
} else {
|
||||
if (isset($funcParam['call_name_caching'])) {
|
||||
$function = $funcParam['call_name_caching'];
|
||||
} else {
|
||||
if (isset($funcParam)) {
|
||||
if (!$tpl->caching || ($tpl->caching && $nocache)) {
|
||||
$function = $funcParam['call_name'];
|
||||
} else {
|
||||
if (isset($funcParam['call_name_caching'])) {
|
||||
$function = $funcParam['call_name_caching'];
|
||||
} else {
|
||||
$function = $funcParam['call_name'];
|
||||
}
|
||||
}
|
||||
if (function_exists($function)) {
|
||||
$this->saveTemplateVariables($tpl, $name);
|
||||
$function($tpl, $params);
|
||||
$this->restoreTemplateVariables($tpl, $name);
|
||||
return;
|
||||
}
|
||||
// try to load template function dynamically
|
||||
if ($this->addTplFuncToCache($tpl, $name, $function)) {
|
||||
$this->saveTemplateVariables($tpl, $name);
|
||||
$function($tpl, $params);
|
||||
$this->restoreTemplateVariables($tpl, $name);
|
||||
return;
|
||||
}
|
||||
}
|
||||
if (!function_exists($function) && !$this->addTplFuncToCache($tpl, $name, $function)) {
|
||||
throw new \Smarty\Exception("Unable to find template function '{$name}'");
|
||||
}
|
||||
|
||||
$tpl->pushStack();
|
||||
$function($tpl, $params);
|
||||
$tpl->popStack();
|
||||
throw new \Smarty\Exception("Unable to find template function '{$name}'");
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -141,4 +146,28 @@ class TplFunctionRuntime {
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Save current template variables on stack
|
||||
*
|
||||
* @param \Smarty\Template $tpl
|
||||
* @param string $name stack name
|
||||
*/
|
||||
public function saveTemplateVariables(Template $tpl, $name) {
|
||||
$tpl->_var_stack[] =
|
||||
['tpl' => $tpl->tpl_vars, 'config' => $tpl->config_vars, 'name' => "_tplFunction_{$name}"];
|
||||
}
|
||||
|
||||
/**
|
||||
* Restore saved variables into template objects
|
||||
*
|
||||
* @param \Smarty\Template $tpl
|
||||
* @param string $name stack name
|
||||
*/
|
||||
public function restoreTemplateVariables(Template $tpl, $name) {
|
||||
if (isset($tpl->_var_stack)) {
|
||||
$vars = array_pop($tpl->_var_stack);
|
||||
$tpl->tpl_vars = $vars['tpl'];
|
||||
$tpl->config_vars = $vars['config'];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
+1
-1
@@ -53,7 +53,7 @@ class Smarty extends \Smarty\TemplateBase {
|
||||
/**
|
||||
* smarty version
|
||||
*/
|
||||
const SMARTY_VERSION = '5.0.0';
|
||||
const SMARTY_VERSION = '5.0.0-rc2';
|
||||
|
||||
/**
|
||||
* define caching modes
|
||||
|
||||
+4
-2
@@ -645,7 +645,8 @@ class Template extends TemplateBase {
|
||||
} else {
|
||||
|
||||
// After rendering a template, the tpl/config variables are reset, so the template can be re-used.
|
||||
$this->pushStack();
|
||||
$savedTplVars = $this->tpl_vars;
|
||||
$savedConfigVars = $this->config_vars;
|
||||
|
||||
// Start output-buffering.
|
||||
ob_start();
|
||||
@@ -653,7 +654,8 @@ class Template extends TemplateBase {
|
||||
$result = $this->render(false, $function);
|
||||
|
||||
// Restore the template to its previous state
|
||||
$this->popStack();
|
||||
$this->tpl_vars = $savedTplVars;
|
||||
$this->config_vars = $savedConfigVars;
|
||||
}
|
||||
|
||||
if (isset($errorHandler)) {
|
||||
|
||||
@@ -271,11 +271,11 @@ class Source {
|
||||
return $this->type . ':' . $this->name;
|
||||
}
|
||||
|
||||
public function getFilepath(): ?string {
|
||||
public function getFilepath(): string {
|
||||
if ($this->handler instanceof FilePlugin) {
|
||||
return $this->handler->getFilePath($this->name, $this->smarty, $this->isConfig);
|
||||
}
|
||||
return null;
|
||||
return '.';
|
||||
}
|
||||
|
||||
public function isConfig(): bool {
|
||||
|
||||
@@ -59,6 +59,13 @@ abstract class TemplateBase extends Data {
|
||||
*/
|
||||
public $tplFunctions = [];
|
||||
|
||||
/**
|
||||
* When initialized to an (empty) array, this variable will hold a stack of template variables.
|
||||
*
|
||||
* @var null|array
|
||||
*/
|
||||
public $_var_stack = null;
|
||||
|
||||
/**
|
||||
* @var Debug
|
||||
*/
|
||||
|
||||
@@ -303,7 +303,7 @@ class SecurityTest extends PHPUnit_Smarty
|
||||
}
|
||||
/**
|
||||
*
|
||||
* @group slow
|
||||
*
|
||||
*/
|
||||
public function testTrustedUri()
|
||||
{
|
||||
|
||||
@@ -304,8 +304,7 @@ class blockparamsCompiler extends \Smarty\Compile\Base {
|
||||
protected $shorttag_order = ["first", "second"];
|
||||
protected $optional_attributes = ["first", "second"];
|
||||
|
||||
public function compile($args, Template $compiler, $parameter = [], $tag = null, $function = null): string
|
||||
{
|
||||
public function compile($args, Template $compiler, $parameter = [], $tag = null, $function = null) {
|
||||
$_attr = $this->getAttributes($compiler, $args);
|
||||
|
||||
$output = '';
|
||||
|
||||
@@ -103,8 +103,7 @@ class RegisterModifierTest extends PHPUnit_Smarty
|
||||
|
||||
public function dataUnknownModifiers(): array {
|
||||
return [
|
||||
['{" blah"|ltrim:" "}', 'blah'],
|
||||
['{"blah"|strrev}', 'halb'],
|
||||
['{"blah"|substr:1:2}', 'la'],
|
||||
['{"blah"|ucfirst}', 'Blah'],
|
||||
['{"blah"|md5}', md5('blah')],
|
||||
];
|
||||
|
||||
+1
-2
@@ -6,8 +6,7 @@ use Smarty\Compile\Base;
|
||||
class smarty_compiler_test extends Base
|
||||
{
|
||||
|
||||
public function compile($args, \Smarty\Compiler\Template $compiler, $parameter = [], $tag = null, $function = null): string
|
||||
{
|
||||
public function compile($args, \Smarty\Compiler\Template $compiler, $parameter = [], $tag = null, $function = null) {
|
||||
$this->required_attributes = array('data');
|
||||
|
||||
$_attr = $this->getAttributes($compiler, $args);
|
||||
|
||||
+1
-2
@@ -6,8 +6,7 @@ use Smarty\Compile\Base;
|
||||
class smarty_compiler_testclose extends Base
|
||||
{
|
||||
|
||||
public function compile($args, \Smarty\Compiler\Template $compiler, $parameter = [], $tag = null, $function = null): string
|
||||
{
|
||||
public function compile($args, \Smarty\Compiler\Template $compiler, $parameter = [], $tag = null, $function = null) {
|
||||
|
||||
$this->closeTag($compiler, 'test');
|
||||
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user