mirror of
https://github.com/smarty-php/smarty.git
synced 2026-08-04 12:34:33 +02:00
Compare commits
20 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 3251b1c32d | |||
| c016895166 | |||
| f81720941c | |||
| e6ee257ca2 | |||
| 0d4939e135 | |||
| fc06d246bf | |||
| 292ad986cd | |||
| d024c3df4c | |||
| f98ba948c4 | |||
| 7468378e3b | |||
| de1f382f0b | |||
| a85296ab94 | |||
| 40f40e549d | |||
| 64e50e00c9 | |||
| 159ed4ee02 | |||
| 7f579fdc69 | |||
| c26151da1d | |||
| 078e2dbc1b | |||
| 36d157180a | |||
| eec791d943 |
@@ -31,6 +31,7 @@ jobs:
|
||||
- "7.4"
|
||||
- "8.0"
|
||||
- "8.1"
|
||||
- "8.2"
|
||||
|
||||
compiler:
|
||||
- default
|
||||
@@ -42,6 +43,9 @@ jobs:
|
||||
- os: ubuntu-latest
|
||||
php-version: "8.1"
|
||||
compiler: jit
|
||||
- os: ubuntu-latest
|
||||
php-version: "8.2"
|
||||
compiler: jit
|
||||
|
||||
steps:
|
||||
- name: Checkout
|
||||
|
||||
@@ -6,6 +6,9 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
||||
|
||||
## [Unreleased]
|
||||
|
||||
### Added
|
||||
- PHP8.2 compatibility [#775](https://github.com/smarty-php/smarty/pull/775)
|
||||
|
||||
### Changed
|
||||
- Include docs and demo in the releases [#799](https://github.com/smarty-php/smarty/issues/799)
|
||||
- Using PHP functions as modifiers now triggers a deprecation notice because we will drop support for this in the next major release [#813](https://github.com/smarty-php/smarty/issues/813)
|
||||
|
||||
@@ -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 can be run with PHP 7.1 to PHP 8.1.
|
||||
Smarty can be run with PHP 7.1 to PHP 8.2.
|
||||
|
||||
## Installation
|
||||
Smarty versions 3.1.11 or later can be installed with [Composer](https://getcomposer.org/).
|
||||
|
||||
@@ -38,3 +38,8 @@ services:
|
||||
service: base
|
||||
build:
|
||||
dockerfile: ./utilities/testrunners/php81/Dockerfile
|
||||
php82:
|
||||
extends:
|
||||
service: base
|
||||
build:
|
||||
dockerfile: ./utilities/testrunners/php82/Dockerfile
|
||||
|
||||
@@ -109,7 +109,7 @@ the corresponding error is in the template.
|
||||
|
||||
|
||||
|
||||
- This means that your application registered a custom error hander
|
||||
- This means that your application registered a custom error handler
|
||||
(using [set\_error\_handler()](&url.php-manual;set_error_handler))
|
||||
which is not respecting the given `$errno` as it should. If, for
|
||||
whatever reason, this is the desired behaviour of your custom error
|
||||
|
||||
@@ -3,14 +3,14 @@
|
||||
|
||||
`{block}` is used to define a named area of template source for template
|
||||
inheritance. For details see section of [Template
|
||||
Interitance](#advanced.features.template.inheritance).
|
||||
Inheritance](#advanced.features.template.inheritance).
|
||||
|
||||
The `{block}` template source area of a child template will replace the
|
||||
correponding areas in the parent template(s).
|
||||
corresponding areas in the parent template(s).
|
||||
|
||||
Optionally `{block}` areas of child and parent templates can be merged
|
||||
into each other. You can append or prepend the parent `{block}` content
|
||||
by using the `append` or `prepend` option flag with the childs `{block}`
|
||||
by using the `append` or `prepend` option flag with the child's `{block}`
|
||||
definition. With the {\$smarty.block.parent} the `{block}` content of
|
||||
the parent template can be inserted at any location of the child
|
||||
`{block}` content. {\$smarty.block.child} inserts the `{block}` content
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
|
||||
`{extends}` tags are used in child templates in template inheritance for
|
||||
extending parent templates. For details see section of [Template
|
||||
Interitance](#advanced.features.template.inheritance).
|
||||
Inheritance](#advanced.features.template.inheritance).
|
||||
|
||||
- The `{extends}` tag must be on the first line of the template.
|
||||
|
||||
@@ -33,5 +33,5 @@ Interitance](#advanced.features.template.inheritance).
|
||||
|
||||
|
||||
|
||||
See also [Template Interitance](#advanced.features.template.inheritance)
|
||||
See also [Template Inheritance](#advanced.features.template.inheritance)
|
||||
and [`{block}`](#language.function.block).
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
=====
|
||||
|
||||
The `{for}{forelse}` tag is used to create simple loops. The following
|
||||
different formarts are supported:
|
||||
different formats are supported:
|
||||
|
||||
- `{for $var=$start to $end}` simple loop with step size of 1.
|
||||
|
||||
|
||||
@@ -131,7 +131,7 @@ cache lifetime of 500 seconds.
|
||||
|
||||
|
||||
In this example included template will be cached independent of the
|
||||
global cahing setting.
|
||||
global caching setting.
|
||||
|
||||
|
||||
{include 'sub_template.tpl' caching}
|
||||
|
||||
@@ -65,7 +65,7 @@ and display the returned results in place of the {insert} tag.
|
||||
The path can be either absolute, or relative to
|
||||
[`$trusted_dir`](#variable.trusted.dir). If security is enabled,
|
||||
then the script must be located in the `$trusted_dir` path of the
|
||||
securty policy. See the [Security](#advanced.features.security)
|
||||
security policy. See the [Security](#advanced.features.security)
|
||||
section for details.
|
||||
|
||||
The Smarty object is passed as the second argument. This way you can
|
||||
|
||||
@@ -251,8 +251,8 @@ The above example will output:
|
||||
|
||||
{section}\'s can be nested as deep as you like. With nested
|
||||
{section}\'s, you can access complex data structures, such as
|
||||
multi-dimensional arrays. This is an example `.php` script thats
|
||||
assign\'s the arrays.
|
||||
multi-dimensional arrays. This is an example `.php` script that
|
||||
assigns the arrays.
|
||||
|
||||
|
||||
<?php
|
||||
|
||||
@@ -10,7 +10,7 @@ The filter can be:
|
||||
|
||||
- A variable filter plugin specified by it\'s name.
|
||||
|
||||
- A modidier specified by it\'s name and optional additional
|
||||
- A modifier specified by it\'s name and optional additional
|
||||
parameter.
|
||||
|
||||
`{setfilter}...{/setfilter}` blocks can be nested. The filter definition
|
||||
|
||||
@@ -22,7 +22,7 @@ ftp and display the contents.
|
||||
>
|
||||
> If security is enabled and you are fetching a file from the local
|
||||
> file system, `{fetch}` will only allow files from within the
|
||||
> `$secure_dir` path of the securty policy. See the
|
||||
> `$secure_dir` path of the security policy. See the
|
||||
> [Security](#advanced.features.security) section for details.
|
||||
|
||||
- If the `assign` attribute is set, the output of the `{fetch}`
|
||||
|
||||
@@ -19,7 +19,7 @@ automatically calculated from the image file if they are not supplied.
|
||||
from. If not given, the web server\'s document root
|
||||
`$_ENV['DOCUMENT_ROOT']` is used as the base. If security is
|
||||
enabled, then the image must be located in the `$secure_dir` path of
|
||||
the securty policy. See the [Security](#advanced.features.security)
|
||||
the security policy. See the [Security](#advanced.features.security)
|
||||
section for details.
|
||||
|
||||
- `href` is the href value to link the image to. If link is supplied,
|
||||
|
||||
@@ -115,7 +115,7 @@ These parameters follow the modifier name and are separated by a `:`
|
||||
|
||||
- Secondly - if security is enabled, all php-functions that are to
|
||||
be used as modifiers have to be declared trusted in the
|
||||
`$modifiers` property of the securty policy. See the
|
||||
`$modifiers` property of the security policy. See the
|
||||
[Security](../programmers/advanced-features/advanced-features-security.md) section for details.
|
||||
|
||||
See also [`registerPlugin()`](../programmers/api-functions/api-register-plugin.md), [combining
|
||||
|
||||
@@ -1,43 +1,41 @@
|
||||
# capitalize (modifier)
|
||||
capitalize {#language.modifier.capitalize}
|
||||
==========
|
||||
|
||||
This is used to capitalize the first letter of all words in a variable.
|
||||
This is similar to the PHP [`ucwords()`](&url.php-manual;ucwords)
|
||||
function.
|
||||
|
||||
## Parameters
|
||||
Parameter Position Type Required Default Description
|
||||
-------------------- --------- ---------- --------- -----------------------------------------------------------------------------------------------------------
|
||||
1 boolean No FALSE This determines whether or not words with digits will be uppercased
|
||||
2 boolean No FALSE This determines whether or not Capital letters within words should be lowercased, e.g. \"aAa\" to \"Aaa\"
|
||||
|
||||
| Position | Type | Required | Default | Description |
|
||||
|----------|---------|----------|---------|-------------------------------------------------------------------------------------------------------|
|
||||
| 1 | boolean | No | False | This determines whether or not words with digits will be uppercased. |
|
||||
| 2 | boolean | No | False | This determines whether or not Capital letters within words should be lowercased, e.g. "aAa" to "Aaa" |
|
||||
|
||||
## Example
|
||||
<?php
|
||||
|
||||
PHP-script:
|
||||
$smarty->assign('articleTitle', 'next x-men film, x3, delayed.');
|
||||
|
||||
?>
|
||||
|
||||
```php
|
||||
$smarty->assign('articleTitle', 'next x-men film, x3, delayed.');
|
||||
```
|
||||
|
||||
|
||||
Where the template is:
|
||||
|
||||
```smarty
|
||||
|
||||
{$articleTitle}
|
||||
{$articleTitle|capitalize}
|
||||
{$articleTitle|capitalize:true}
|
||||
```
|
||||
|
||||
|
||||
|
||||
|
||||
Will output:
|
||||
|
||||
```
|
||||
|
||||
next x-men film, x3, delayed.
|
||||
Next X-Men Film, x3, Delayed.
|
||||
Next X-Men Film, X3, Delayed.
|
||||
```
|
||||
|
||||
## See also
|
||||
|
||||
- [lower (modifier)](./language-modifier-lower.md)
|
||||
- [upper (modifier)](./language-modifier-upper.md)
|
||||
|
||||
See also [`lower`](#language.modifier.lower) and
|
||||
[`upper`](#language.modifier.upper)
|
||||
|
||||
@@ -1,26 +1,31 @@
|
||||
# cat (modifier)
|
||||
cat {#language.modifier.cat}
|
||||
===
|
||||
|
||||
This value is concatenated to the given variable.
|
||||
|
||||
## Parameters
|
||||
Parameter Position Type Required Default Description
|
||||
-------------------- -------- ---------- --------- -----------------------------------------------
|
||||
1 string No *empty* This value to catenate to the given variable.
|
||||
|
||||
| Position | Type | Required | Default | Description |
|
||||
|----------|--------|----------|---------|-----------------------------------------------|
|
||||
| 1 | string | No | *empty* | This value to catenate to the given variable. |
|
||||
|
||||
## Example
|
||||
<?php
|
||||
|
||||
$smarty->assign('articleTitle', "Psychics predict world didn't end");
|
||||
|
||||
?>
|
||||
|
||||
|
||||
|
||||
PHP-script:
|
||||
```php
|
||||
$smarty->assign('articleTitle', "Psychics predict world didn't end");
|
||||
```
|
||||
|
||||
Where template is:
|
||||
```smarty
|
||||
{$articleTitle|cat:' yesterday.'}
|
||||
```
|
||||
|
||||
|
||||
{$articleTitle|cat:' yesterday.'}
|
||||
|
||||
|
||||
|
||||
Will output:
|
||||
```
|
||||
|
||||
|
||||
Psychics predict world didn't end yesterday.
|
||||
```
|
||||
|
||||
|
||||
|
||||
@@ -15,5 +15,5 @@ modifier](#language.modifier.to_charset).
|
||||
> modifier should only be used in cases where the application cannot
|
||||
> anticipate that a certain string is required in another encoding.
|
||||
|
||||
See also [Charset Enconding](#charset), [from\_charset
|
||||
See also [Charset Encoding](#charset), [from\_charset
|
||||
modifier](#language.modifier.from_charset).
|
||||
|
||||
@@ -15,5 +15,5 @@ modifier](#language.modifier.from_charset).
|
||||
> modifier should only be used in cases where the application cannot
|
||||
> anticipate that a certain string is required in another encoding.
|
||||
|
||||
See also [Charset Enconding](#charset), [from\_charset
|
||||
See also [Charset Encoding](#charset), [from\_charset
|
||||
modifier](#language.modifier.from_charset).
|
||||
|
||||
@@ -157,13 +157,13 @@ Returns the version of Smarty the template was compiled with.
|
||||
----------------------
|
||||
|
||||
Returns block text from child template. See [Template
|
||||
interitance](#advanced.features.template.inheritance).
|
||||
inheritance](#advanced.features.template.inheritance).
|
||||
|
||||
{\$smarty.block.parent} {#language.variables.smarty.block.parent}
|
||||
-----------------------
|
||||
|
||||
Returns block text from parent template. See [Template
|
||||
interitance](#advanced.features.template.inheritance)
|
||||
inheritance](#advanced.features.template.inheritance)
|
||||
|
||||
{\$smarty.ldelim}, {\$smarty.rdelim} {#language.variables.smarty.ldelim}
|
||||
------------------------------------
|
||||
|
||||
@@ -2,7 +2,7 @@ What is Smarty?
|
||||
==============
|
||||
|
||||
## Requirements
|
||||
Smarty can be run with PHP 7.1 to PHP 8.1.
|
||||
Smarty can be run with PHP 7.1 to PHP 8.2.
|
||||
|
||||
## Installation
|
||||
Smarty versions 3.1.11 or later can be installed with [Composer](https://getcomposer.org/).
|
||||
|
||||
@@ -29,7 +29,7 @@ determined by your needs, but use the first method whenever possible to
|
||||
keep template syntax to a minimum.
|
||||
|
||||
If security is enabled, no private methods or functions can be accessed
|
||||
(beginningwith \'\_\'). If a method and property of the same name exist,
|
||||
(beginning with \'\_\'). If a method and property of the same name exist,
|
||||
the method will be used.
|
||||
|
||||
You can restrict the methods and properties that can be accessed by
|
||||
|
||||
@@ -2,7 +2,7 @@ Security {#advanced.features.security}
|
||||
========
|
||||
|
||||
Security is good for situations when you have untrusted parties editing
|
||||
the templates eg via ftp, and you want to reduce the risk of system
|
||||
the templates e.g. via ftp, and you want to reduce the risk of system
|
||||
security compromises through the template language.
|
||||
|
||||
The settings of the security policy are defined by properties of an
|
||||
@@ -10,7 +10,7 @@ instance of the Smarty\_Security class. These are the possible settings:
|
||||
|
||||
- `$secure_dir` is an array of template directories that are
|
||||
considered secure. [`$template_dir`](#variable.template.dir)
|
||||
concidered secure implicitly. The default is an empty array.
|
||||
considered secure implicitly. The default is an empty array.
|
||||
|
||||
- `$trusted_dir` is an array of all directories that are considered
|
||||
trusted. Trusted directories are where you keep php scripts that are
|
||||
@@ -27,7 +27,7 @@ instance of the Smarty\_Security class. These are the possible settings:
|
||||
like authentication-tokens).
|
||||
|
||||
The expression `'#https?://.*smarty.net$#i'` would allow accessing
|
||||
the follwing URIs:
|
||||
the following URIs:
|
||||
|
||||
- `http://smarty.net/foo`
|
||||
|
||||
@@ -140,5 +140,5 @@ Smarty\_Security class or create an instance of it.
|
||||
> **Note**
|
||||
>
|
||||
> Most security policy settings are only checked when the template gets
|
||||
> compiled. For that reasion you should delete all cached and compiled
|
||||
> compiled. For that reason you should delete all cached and compiled
|
||||
> template files when you change your security settings.
|
||||
|
||||
@@ -33,7 +33,7 @@ can override all or some of the parent named block areas.
|
||||
you can define the whole template inheritance tree in the PHP script
|
||||
when you are calling [`fetch()`](#api.fetch) or
|
||||
[`display()`](#api.display) with the `extends:` template resource
|
||||
type. The later provides even more flexibillity.
|
||||
type. The later provides even more flexibility.
|
||||
|
||||
> **Note**
|
||||
>
|
||||
|
||||
@@ -8,7 +8,7 @@ Modifications done to the Smarty object will be global for all
|
||||
templates.
|
||||
|
||||
However the Smarty class variables and functions can be accessed or
|
||||
called by induvidual template objects. Modification done to a template
|
||||
called by individual template objects. Modification done to a template
|
||||
object will apply only for that template and its included subtemplates.
|
||||
|
||||
|
||||
|
||||
@@ -26,7 +26,7 @@ the following parameters:
|
||||
variables assigned to any of the objects in it\'s parent chain.
|
||||
|
||||
Data objects are used to create scopes for assigned variables. They can
|
||||
be used to have controll which variables are seen by which templates.
|
||||
be used to control which variables are seen by which templates.
|
||||
|
||||
|
||||
<?php
|
||||
|
||||
@@ -9,7 +9,7 @@ string
|
||||
|
||||
disableSecurity
|
||||
|
||||
This disables securty checking on templates.
|
||||
This disables security checking on templates.
|
||||
|
||||
See also [`enableSecurity()`](#api.enable.security), and
|
||||
[Security](#advanced.features.security).
|
||||
|
||||
@@ -25,7 +25,7 @@ string
|
||||
|
||||
enableSecurity
|
||||
|
||||
This enables securty checking on templates. It uses the following
|
||||
This enables security checking on templates. It uses the following
|
||||
parameters:
|
||||
|
||||
- `securityclass` is an optional parameter. It\'s the name of the
|
||||
|
||||
@@ -16,6 +16,6 @@ given error was produced deliberately and must be ignored, or should be
|
||||
passed on to the next error handler.
|
||||
|
||||
`Smarty::unmuteExpectedErrors()` removes the current error handler.
|
||||
Please note, that if you\'ve registerd any custom error handlers after
|
||||
Please note, that if you\'ve registered any custom error handlers after
|
||||
the muteExpectedErrors() call, the unmute will not remove Smarty\'s
|
||||
muting error handler, but the one registered last.
|
||||
|
||||
@@ -18,7 +18,7 @@ not find a definition for a tag otherwise. It uses the following
|
||||
parameters:
|
||||
|
||||
If during compilation Smarty encounters tag which is not defined
|
||||
internal, registered or loacted in the plugins folder it tries to
|
||||
internal, registered or located in the plugins folder it tries to
|
||||
resolve it by calling the registered default plugin handler. The handler
|
||||
may be called several times for same undefined tag looping over valid
|
||||
plugin types.
|
||||
|
||||
@@ -10,7 +10,7 @@ void
|
||||
testInstall
|
||||
|
||||
This function verifies that all required working folders of the Smarty
|
||||
installation can be accessed. It does output a corresponding protocoll.
|
||||
installation can be accessed. It does output a corresponding protocol.
|
||||
|
||||
|
||||
<?php
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
\$compile\_id {#variable.compile.id}
|
||||
=============
|
||||
|
||||
Persistant compile identifier. As an alternative to passing the same
|
||||
Persistent compile identifier. As an alternative to passing the same
|
||||
`$compile_id` to each and every function call, you can set this
|
||||
`$compile_id` and it will be used implicitly thereafter.
|
||||
|
||||
@@ -10,7 +10,7 @@ post-filters](#plugins.prefilters.postfilters) you must use a unique
|
||||
`$compile_id` to keep the compiled template files separated.
|
||||
|
||||
For example a [prefilter](#plugins.prefilters.postfilters) that
|
||||
localizes your templates (that is: translates language dependend parts)
|
||||
localizes your templates (that is: translates language dependent parts)
|
||||
at compile time, then you could use the current language as
|
||||
`$compile_id` and you will get a set of compiled templates for each
|
||||
language you use.
|
||||
|
||||
@@ -2,6 +2,6 @@
|
||||
==================
|
||||
|
||||
This is maximum time in seconds a cache lock is valid to avoid dead
|
||||
locks. The deafult value is 10 seconds.
|
||||
locks. The default value is 10 seconds.
|
||||
|
||||
See also [`$cache_locking`](#variable.cache.locking)
|
||||
|
||||
@@ -10,7 +10,7 @@ environments do not allow PHP processes to create directories, so this
|
||||
must be disabled which is the default.
|
||||
|
||||
Sub directories are more efficient, so use them if you can.
|
||||
Theoretically you get much better perfomance on a filesystem with 10
|
||||
Theoretically you get much better performance on a filesystem with 10
|
||||
directories each having 100 files, than with 1 directory having 1000
|
||||
files. This was certainly the case with Solaris 7 (UFS)\... with newer
|
||||
filesystems such as ext3 and especially reiserfs, the difference is
|
||||
|
||||
@@ -25,10 +25,10 @@ like.
|
||||
- You CANNOT remove a specified template name under multiple cache
|
||||
groups such as `'/a/b/*/foo.tpl'`, the cache grouping works
|
||||
left-to-right ONLY. You will need to group your templates under a
|
||||
single cache group heirarchy to be able to clear them as a group.
|
||||
single cache group hierarchy to be able to clear them as a group.
|
||||
|
||||
Cache grouping should not be confused with your template directory
|
||||
heirarchy, the cache grouping has no knowledge of how your templates are
|
||||
hierarchy, the cache grouping has no knowledge of how your templates are
|
||||
structured. So for example, if you have a template structure like
|
||||
`themes/blue/index.tpl` and you want to be able to clear all the cache
|
||||
files for the "blue" theme, you will need to create a cache group
|
||||
|
||||
@@ -15,7 +15,7 @@ Smarty recognizes `UTF-8` as the internal charset if
|
||||
> `ISO-8859-1` has been PHP\'s default internal charset since the
|
||||
> beginning. Unicode has been evolving since 1991. Since then it has
|
||||
> become the one charset to conquer them all, as it is capable of
|
||||
> encoding most of the known characters even accross different character
|
||||
> encoding most of the known characters even across different character
|
||||
> systems (latin, cyrillic, japanese, ...). `UTF-8` is unicode\'s most
|
||||
> used encoding, as it allows referencing the thousands of character
|
||||
> with the smallest size overhead possible.
|
||||
|
||||
@@ -3,20 +3,20 @@ Extends Template Resources {#resources.extends}
|
||||
|
||||
The `extends:` resource is used to define child/parent relationships for
|
||||
template inheritance from the PHP script. For details see section of
|
||||
[Template Interitance](#advanced.features.template.inheritance).
|
||||
[Template Inheritance](#advanced.features.template.inheritance).
|
||||
|
||||
As of Smarty 3.1 the `extends:` resource may use any available [template
|
||||
resource](#resources), including `string:` and `eval:`. When [templates
|
||||
from strings](#resources.string) are used, make sure they are properly
|
||||
(url or base64) encoded. Is an `eval:` resource found within an
|
||||
inheritance chain, its \"don\'t save a compile file\" property is
|
||||
superseeded by the `extends:` resource. The templates within an
|
||||
superseded by the `extends:` resource. The templates within an
|
||||
inheritance chain are not compiled separately, though. Only a single
|
||||
compiled template will be generated.
|
||||
|
||||
> **Note**
|
||||
>
|
||||
> Use this when inheritance is required programatically. When inheriting
|
||||
> Use this when inheritance is required programmatically. When inheriting
|
||||
> within PHP, it is not obvious from the child template what inheritance
|
||||
> took place. If you have a choice, it is normally more flexible and
|
||||
> intuitive to handle inheritance chains from within the templates.
|
||||
|
||||
@@ -47,7 +47,7 @@ Templates from a specific \$template\_dir {#templates.from.specified.template.di
|
||||
Smarty 3.1 introduced the bracket-syntax for specifying an element from
|
||||
[`$template_dir`](#variable.template.dir). This allows websites
|
||||
employing multiple sets of templates better control over which template
|
||||
to acces.
|
||||
to access.
|
||||
|
||||
The bracket-syntax can be used from anywhere you can specify the `file:`
|
||||
resource type.
|
||||
|
||||
@@ -46,31 +46,6 @@ class Smarty_Autoloader
|
||||
*/
|
||||
public static $rootClasses = array('smarty' => 'Smarty.class.php');
|
||||
|
||||
/**
|
||||
* Registers Smarty_Autoloader backward compatible to older installations.
|
||||
*
|
||||
* @param bool $prepend Whether to prepend the autoloader or not.
|
||||
*/
|
||||
public static function registerBC($prepend = false)
|
||||
{
|
||||
/**
|
||||
* register the class autoloader
|
||||
*/
|
||||
if (!defined('SMARTY_SPL_AUTOLOAD')) {
|
||||
define('SMARTY_SPL_AUTOLOAD', 0);
|
||||
}
|
||||
if (SMARTY_SPL_AUTOLOAD
|
||||
&& set_include_path(get_include_path() . PATH_SEPARATOR . SMARTY_SYSPLUGINS_DIR) !== false
|
||||
) {
|
||||
$registeredAutoLoadFunctions = spl_autoload_functions();
|
||||
if (!isset($registeredAutoLoadFunctions[ 'spl_autoload' ])) {
|
||||
spl_autoload_register();
|
||||
}
|
||||
} else {
|
||||
self::register($prepend);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Registers Smarty_Autoloader as an SPL autoloader.
|
||||
*
|
||||
|
||||
@@ -139,7 +139,6 @@ class Smarty extends Smarty_Internal_TemplateBase
|
||||
const DEBUG_OFF = 0;
|
||||
const DEBUG_ON = 1;
|
||||
const DEBUG_INDIVIDUAL = 2;
|
||||
|
||||
/**
|
||||
* filter types
|
||||
*/
|
||||
@@ -780,7 +779,7 @@ class Smarty extends Smarty_Internal_TemplateBase
|
||||
$this->_normalizeTemplateConfig($isConfig);
|
||||
}
|
||||
if ($index !== null) {
|
||||
return isset($dir[ $index ]) ? $dir[ $index ] : null;
|
||||
return ($dir[ $index ] ?? null);
|
||||
}
|
||||
return $dir;
|
||||
}
|
||||
|
||||
+7
-17
@@ -12,7 +12,6 @@
|
||||
margin: 1px;
|
||||
padding: 0;
|
||||
}
|
||||
|
||||
h1 {
|
||||
margin: 0;
|
||||
text-align: left;
|
||||
@@ -22,7 +21,6 @@
|
||||
font-weight: bold;
|
||||
font-size: 1.2em;
|
||||
}
|
||||
|
||||
h2 {
|
||||
background-color: #9B410E;
|
||||
color: white;
|
||||
@@ -31,7 +29,6 @@
|
||||
padding: 2px;
|
||||
border-top: 1px solid black;
|
||||
}
|
||||
|
||||
h3 {
|
||||
text-align: left;
|
||||
font-weight: bold;
|
||||
@@ -39,71 +36,58 @@
|
||||
font-size: 0.7em;
|
||||
padding: 2px;
|
||||
}
|
||||
|
||||
body {
|
||||
background: black;
|
||||
}
|
||||
|
||||
p, table, div {
|
||||
background: #f0ead8;
|
||||
}
|
||||
|
||||
p {
|
||||
margin: 0;
|
||||
font-style: italic;
|
||||
text-align: center;
|
||||
}
|
||||
|
||||
table {
|
||||
width: 100%;
|
||||
}
|
||||
|
||||
th, td {
|
||||
font-family: monospace;
|
||||
vertical-align: top;
|
||||
text-align: left;
|
||||
}
|
||||
|
||||
td {
|
||||
color: green;
|
||||
}
|
||||
|
||||
tr:nth-child(odd) {
|
||||
background-color: #eeeeee;
|
||||
}
|
||||
|
||||
tr:nth-child(even) {
|
||||
background-color: #fafafa;
|
||||
}
|
||||
|
||||
.exectime {
|
||||
font-size: 0.8em;
|
||||
font-style: italic;
|
||||
}
|
||||
|
||||
#bold div {
|
||||
color: black;
|
||||
font-weight: bold;
|
||||
}
|
||||
|
||||
#blue h3 {
|
||||
color: blue;
|
||||
}
|
||||
|
||||
#normal div {
|
||||
color: black;
|
||||
font-weight: normal;
|
||||
}
|
||||
|
||||
#table_assigned_vars th {
|
||||
color: blue;
|
||||
font-weight: bold;
|
||||
}
|
||||
|
||||
#table_config_vars th {
|
||||
color: maroon;
|
||||
}
|
||||
{/literal}
|
||||
|
||||
</style>
|
||||
</head>
|
||||
<body>
|
||||
@@ -121,6 +105,7 @@
|
||||
</span>
|
||||
<br>
|
||||
{/foreach}
|
||||
|
||||
</div>
|
||||
{/if}
|
||||
|
||||
@@ -144,11 +129,14 @@
|
||||
{$vars['attributes']|debug_print_var nofilter}
|
||||
{/if}
|
||||
</td>
|
||||
</tr>
|
||||
{/foreach}
|
||||
|
||||
</table>
|
||||
|
||||
<h2>assigned config file variables</h2>
|
||||
|
||||
{if NOT empty($config_vars)}
|
||||
<table id="table_config_vars">
|
||||
{foreach $config_vars as $vars}
|
||||
<tr>
|
||||
@@ -163,6 +151,8 @@
|
||||
{/foreach}
|
||||
|
||||
</table>
|
||||
{/if}
|
||||
|
||||
</body>
|
||||
</html>
|
||||
{/capture}
|
||||
|
||||
@@ -20,7 +20,7 @@
|
||||
* - indent_char - string (" ")
|
||||
* - wrap_boundary - boolean (true)
|
||||
*
|
||||
* @link https://www.smarty.net/manual/en/language.function.textformat.php {textformat}
|
||||
* @link https://www.smarty.net/docs/en/language.function.textformat.php {textformat}
|
||||
* (Smarty online manual)
|
||||
*
|
||||
* @param array $params parameters
|
||||
|
||||
@@ -12,7 +12,7 @@
|
||||
* Purpose: print out a counter value
|
||||
*
|
||||
* @author Monte Ohrt <monte at ohrt dot com>
|
||||
* @link https://www.smarty.net/manual/en/language.function.counter.php {counter}
|
||||
* @link https://www.smarty.net/docs/en/language.function.counter.php {counter}
|
||||
* (Smarty online manual)
|
||||
*
|
||||
* @param array $params parameters
|
||||
@@ -23,7 +23,7 @@
|
||||
function smarty_function_counter($params, $template)
|
||||
{
|
||||
static $counters = array();
|
||||
$name = (isset($params[ 'name' ])) ? $params[ 'name' ] : 'default';
|
||||
$name = $params[ 'name' ] ?? 'default';
|
||||
if (!isset($counters[ $name ])) {
|
||||
$counters[ $name ] = array('start' => 1, 'skip' => 1, 'direction' => 'up', 'count' => 1);
|
||||
}
|
||||
|
||||
@@ -28,7 +28,7 @@
|
||||
* {cycle name=row values="one,two,three" reset=true}
|
||||
* {cycle name=row}
|
||||
*
|
||||
* @link https://www.smarty.net/manual/en/language.function.cycle.php {cycle}
|
||||
* @link https://www.smarty.net/docs/en/language.function.cycle.php {cycle}
|
||||
* (Smarty online manual)
|
||||
* @author Monte Ohrt <monte at ohrt dot com>
|
||||
* @author credit to Mark Priatel <mpriatel@rogers.com>
|
||||
|
||||
@@ -11,7 +11,7 @@
|
||||
* Name: fetch
|
||||
* Purpose: fetch file, web or ftp data and display results
|
||||
*
|
||||
* @link https://www.smarty.net/manual/en/language.function.fetch.php {fetch}
|
||||
* @link https://www.smarty.net/docs/en/language.function.fetch.php {fetch}
|
||||
* (Smarty online manual)
|
||||
* @author Monte Ohrt <monte at ohrt dot com>
|
||||
*
|
||||
|
||||
@@ -29,7 +29,7 @@
|
||||
* - assign (optional) - assign the output as an array to this variable
|
||||
* - escape (optional) - escape the content (not value), defaults to true
|
||||
*
|
||||
* @link https://www.smarty.net/manual/en/language.function.html.checkboxes.php {html_checkboxes}
|
||||
* @link https://www.smarty.net/docs/en/language.function.html.checkboxes.php {html_checkboxes}
|
||||
* (Smarty online manual)
|
||||
* @author Christopher Kvarme <christopher.kvarme@flashjab.com>
|
||||
* @author credits to Monte Ohrt <monte at ohrt dot com>
|
||||
|
||||
@@ -21,7 +21,7 @@
|
||||
* - basedir - (optional) - base directory for absolute paths, default is environment variable DOCUMENT_ROOT
|
||||
* - path_prefix - prefix for path output (optional, default empty)
|
||||
*
|
||||
* @link https://www.smarty.net/manual/en/language.function.html.image.php {html_image}
|
||||
* @link https://www.smarty.net/docs/en/language.function.html.image.php {html_image}
|
||||
* (Smarty online manual)
|
||||
* @author Monte Ohrt <monte at ohrt dot com>
|
||||
* @author credits to Duda <duda@big.hu>
|
||||
|
||||
@@ -21,7 +21,7 @@
|
||||
* - id (optional) - string default not set
|
||||
* - class (optional) - string default not set
|
||||
*
|
||||
* @link https://www.smarty.net/manual/en/language.function.html.options.php {html_image}
|
||||
* @link https://www.smarty.net/docs/en/language.function.html.options.php {html_image}
|
||||
* (Smarty online manual)
|
||||
* @author Monte Ohrt <monte at ohrt dot com>
|
||||
* @author Ralf Strehle (minor optimization) <ralf dot strehle at yahoo dot de>
|
||||
|
||||
@@ -29,7 +29,7 @@
|
||||
* {html_radios values=$ids name='box' separator='<br>' output=$names}
|
||||
* {html_radios values=$ids checked=$checked separator='<br>' output=$names}
|
||||
*
|
||||
* @link https://www.smarty.net/manual/en/language.function.html.radios.php {html_radios}
|
||||
* @link https://www.smarty.net/docs/en/language.function.html.radios.php {html_radios}
|
||||
* (Smarty online manual)
|
||||
* @author Christopher Kvarme <christopher.kvarme@flashjab.com>
|
||||
* @author credits to Monte Ohrt <monte at ohrt dot com>
|
||||
@@ -156,7 +156,7 @@ function smarty_function_html_radios($params, Smarty_Internal_Template $template
|
||||
}
|
||||
} else {
|
||||
foreach ($values as $_i => $_key) {
|
||||
$_val = isset($output[ $_i ]) ? $output[ $_i ] : '';
|
||||
$_val = $output[ $_i ] ?? '';
|
||||
$_html_result[] =
|
||||
smarty_function_html_radios_output(
|
||||
$name,
|
||||
|
||||
@@ -28,7 +28,7 @@
|
||||
* - 2.0 complete rewrite for performance,
|
||||
* added attributes month_names, *_id
|
||||
*
|
||||
* @link https://www.smarty.net/manual/en/language.function.html.select.date.php {html_select_date}
|
||||
* @link https://www.smarty.net/docs/en/language.function.html.select.date.php {html_select_date}
|
||||
* (Smarty online manual)
|
||||
* @version 2.0
|
||||
* @author Andrei Zmievski
|
||||
@@ -179,9 +179,7 @@ function smarty_function_html_select_date($params, Smarty_Internal_Template $tem
|
||||
'd' => 'Day'
|
||||
] as $_elementKey => $_elementName) {
|
||||
$_variableName = '_' . strtolower($_elementName);
|
||||
$$_variableName =
|
||||
isset($time[$prefix . $_elementName]) ? $time[$prefix . $_elementName] :
|
||||
date($_elementKey);
|
||||
$$_variableName = $params[ 'time' ][ $prefix . $_elementName ] ?? date($_elementKey);
|
||||
}
|
||||
} elseif (isset($time[$field_array][$prefix . 'Year'])) {
|
||||
// $_REQUEST given
|
||||
@@ -265,9 +263,8 @@ function smarty_function_html_select_date($params, Smarty_Internal_Template $tem
|
||||
if ($year_id !== null || $all_id !== null) {
|
||||
$_html_years .= ' id="' . smarty_function_escape_special_chars(
|
||||
$year_id !== null ?
|
||||
($year_id ? $year_id : $_name) :
|
||||
($all_id ? ($all_id . $_name) :
|
||||
$_name)
|
||||
($year_id ?? $_name) :
|
||||
($all_id ? ($all_id . $_name) : $_name)
|
||||
) . '"';
|
||||
}
|
||||
if ($year_size) {
|
||||
@@ -275,7 +272,7 @@ function smarty_function_html_select_date($params, Smarty_Internal_Template $tem
|
||||
}
|
||||
$_html_years .= $_extra . $extra_attrs . '>' . $option_separator;
|
||||
if (isset($year_empty) || isset($all_empty)) {
|
||||
$_html_years .= '<option value="">' . (isset($year_empty) ? $year_empty : $all_empty) . '</option>' .
|
||||
$_html_years .= '<option value="">' . ($year_empty ?? $all_empty) . '</option>' .
|
||||
$option_separator;
|
||||
}
|
||||
$op = $start_year > $end_year ? -1 : 1;
|
||||
@@ -300,9 +297,8 @@ function smarty_function_html_select_date($params, Smarty_Internal_Template $tem
|
||||
if ($month_id !== null || $all_id !== null) {
|
||||
$_html_months .= ' id="' . smarty_function_escape_special_chars(
|
||||
$month_id !== null ?
|
||||
($month_id ? $month_id : $_name) :
|
||||
($all_id ? ($all_id . $_name) :
|
||||
$_name)
|
||||
($month_id ?? $_name) :
|
||||
($all_id ? ($all_id . $_name) : $_name)
|
||||
) . '"';
|
||||
}
|
||||
if ($month_size) {
|
||||
@@ -310,7 +306,7 @@ function smarty_function_html_select_date($params, Smarty_Internal_Template $tem
|
||||
}
|
||||
$_html_months .= $_extra . $extra_attrs . '>' . $option_separator;
|
||||
if (isset($month_empty) || isset($all_empty)) {
|
||||
$_html_months .= '<option value="">' . (isset($month_empty) ? $month_empty : $all_empty) . '</option>' .
|
||||
$_html_months .= '<option value="">' . ($month_empty ?? $all_empty) . '</option>' .
|
||||
$option_separator;
|
||||
}
|
||||
for ($i = 1; $i <= 12; $i++) {
|
||||
@@ -346,7 +342,7 @@ function smarty_function_html_select_date($params, Smarty_Internal_Template $tem
|
||||
}
|
||||
$_html_days .= $_extra . $extra_attrs . '>' . $option_separator;
|
||||
if (isset($day_empty) || isset($all_empty)) {
|
||||
$_html_days .= '<option value="">' . (isset($day_empty) ? $day_empty : $all_empty) . '</option>' .
|
||||
$_html_days .= '<option value="">' . ($day_empty ?? $all_empty) . '</option>' .
|
||||
$option_separator;
|
||||
}
|
||||
for ($i = 1; $i <= 31; $i++) {
|
||||
|
||||
@@ -11,7 +11,7 @@
|
||||
* Name: html_select_time
|
||||
* Purpose: Prints the dropdowns for time selection
|
||||
*
|
||||
* @link https://www.smarty.net/manual/en/language.function.html.select.time.php {html_select_time}
|
||||
* @link https://www.smarty.net/docs/en/language.function.html.select.time.php {html_select_time}
|
||||
* (Smarty online manual)
|
||||
* @author Roberto Berto <roberto@berto.net>
|
||||
* @author Monte Ohrt <monte AT ohrt DOT com>
|
||||
@@ -147,9 +147,7 @@ function smarty_function_html_select_time($params, Smarty_Internal_Template $tem
|
||||
's' => 'Second'
|
||||
) as $_elementKey => $_elementName) {
|
||||
$_variableName = '_' . strtolower($_elementName);
|
||||
$$_variableName =
|
||||
isset($params[ 'time' ][ $prefix . $_elementName ]) ? $params[ 'time' ][ $prefix . $_elementName ] :
|
||||
date($_elementKey);
|
||||
$$_variableName = $params[ 'time' ][ $prefix . $_elementName ] ?? date($_elementKey);
|
||||
}
|
||||
$_meridian =
|
||||
isset($params[ 'time' ][ $prefix . 'Meridian' ]) ? (' ' . $params[ 'time' ][ $prefix . 'Meridian' ]) :
|
||||
@@ -199,7 +197,7 @@ function smarty_function_html_select_time($params, Smarty_Internal_Template $tem
|
||||
if ($hour_id !== null || $all_id !== null) {
|
||||
$_html_hours .= ' id="' .
|
||||
smarty_function_escape_special_chars(
|
||||
$hour_id !== null ? ($hour_id ? $hour_id : $_name) :
|
||||
$hour_id !== null ? ($hour_id ?? $_name) :
|
||||
($all_id ? ($all_id . $_name) : $_name)
|
||||
) . '"';
|
||||
}
|
||||
@@ -208,7 +206,7 @@ function smarty_function_html_select_time($params, Smarty_Internal_Template $tem
|
||||
}
|
||||
$_html_hours .= $_extra . $extra_attrs . '>' . $option_separator;
|
||||
if (isset($hour_empty) || isset($all_empty)) {
|
||||
$_html_hours .= '<option value="">' . (isset($hour_empty) ? $hour_empty : $all_empty) . '</option>' .
|
||||
$_html_hours .= '<option value="">' . ($hour_empty ?? $all_empty) . '</option>' .
|
||||
$option_separator;
|
||||
}
|
||||
$start = $use_24_hours ? 0 : 1;
|
||||
@@ -241,9 +239,8 @@ function smarty_function_html_select_time($params, Smarty_Internal_Template $tem
|
||||
if ($minute_id !== null || $all_id !== null) {
|
||||
$_html_minutes .= ' id="' . smarty_function_escape_special_chars(
|
||||
$minute_id !== null ?
|
||||
($minute_id ? $minute_id : $_name) :
|
||||
($all_id ? ($all_id . $_name) :
|
||||
$_name)
|
||||
($minute_id ?? $_name) :
|
||||
($all_id ? ($all_id . $_name) : $_name)
|
||||
) . '"';
|
||||
}
|
||||
if ($minute_size) {
|
||||
@@ -251,7 +248,7 @@ function smarty_function_html_select_time($params, Smarty_Internal_Template $tem
|
||||
}
|
||||
$_html_minutes .= $_extra . $extra_attrs . '>' . $option_separator;
|
||||
if (isset($minute_empty) || isset($all_empty)) {
|
||||
$_html_minutes .= '<option value="">' . (isset($minute_empty) ? $minute_empty : $all_empty) . '</option>' .
|
||||
$_html_minutes .= '<option value="">' . ($minute_empty ?? $all_empty) . '</option>' .
|
||||
$option_separator;
|
||||
}
|
||||
$selected = $_minute !== null ? ($_minute - $_minute % $minute_interval) : null;
|
||||
@@ -279,9 +276,8 @@ function smarty_function_html_select_time($params, Smarty_Internal_Template $tem
|
||||
if ($second_id !== null || $all_id !== null) {
|
||||
$_html_seconds .= ' id="' . smarty_function_escape_special_chars(
|
||||
$second_id !== null ?
|
||||
($second_id ? $second_id : $_name) :
|
||||
($all_id ? ($all_id . $_name) :
|
||||
$_name)
|
||||
($second_id ?? $_name) :
|
||||
($all_id ? ($all_id . $_name) : $_name)
|
||||
) . '"';
|
||||
}
|
||||
if ($second_size) {
|
||||
@@ -289,7 +285,7 @@ function smarty_function_html_select_time($params, Smarty_Internal_Template $tem
|
||||
}
|
||||
$_html_seconds .= $_extra . $extra_attrs . '>' . $option_separator;
|
||||
if (isset($second_empty) || isset($all_empty)) {
|
||||
$_html_seconds .= '<option value="">' . (isset($second_empty) ? $second_empty : $all_empty) . '</option>' .
|
||||
$_html_seconds .= '<option value="">' . ($second_empty ?? $all_empty) . '</option>' .
|
||||
$option_separator;
|
||||
}
|
||||
$selected = $_second !== null ? ($_second - $_second % $second_interval) : null;
|
||||
@@ -317,10 +313,8 @@ function smarty_function_html_select_time($params, Smarty_Internal_Template $tem
|
||||
if ($meridian_id !== null || $all_id !== null) {
|
||||
$_html_meridian .= ' id="' . smarty_function_escape_special_chars(
|
||||
$meridian_id !== null ?
|
||||
($meridian_id ? $meridian_id :
|
||||
$_name) :
|
||||
($all_id ? ($all_id . $_name) :
|
||||
$_name)
|
||||
($meridian_id ?? $_name) :
|
||||
($all_id ? ($all_id . $_name) : $_name)
|
||||
) . '"';
|
||||
}
|
||||
if ($meridian_size) {
|
||||
@@ -328,7 +322,7 @@ function smarty_function_html_select_time($params, Smarty_Internal_Template $tem
|
||||
}
|
||||
$_html_meridian .= $_extra . $extra_attrs . '>' . $option_separator;
|
||||
if (isset($meridian_empty) || isset($all_empty)) {
|
||||
$_html_meridian .= '<option value="">' . (isset($meridian_empty) ? $meridian_empty : $all_empty) .
|
||||
$_html_meridian .= '<option value="">' . ($meridian_empty ?? $all_empty) .
|
||||
'</option>' . $option_separator;
|
||||
}
|
||||
$_html_meridian .= '<option value="am"' . ($_hour > 0 && $_hour < 12 ? ' selected="selected"' : '') .
|
||||
|
||||
@@ -38,7 +38,7 @@
|
||||
* @author credit to Messju Mohr <messju at lammfellpuschen dot de>
|
||||
* @author credit to boots <boots dot smarty at yahoo dot com>
|
||||
* @version 1.1
|
||||
* @link https://www.smarty.net/manual/en/language.function.html.table.php {html_table}
|
||||
* @link https://www.smarty.net/docs/en/language.function.html.table.php {html_table}
|
||||
* (Smarty online manual)
|
||||
*
|
||||
* @param array $params parameters
|
||||
|
||||
@@ -36,7 +36,7 @@
|
||||
* {mailto address="me@domain.com" cc="you@domain.com,they@domain.com"}
|
||||
* {mailto address="me@domain.com" extra='class="mailto"'}
|
||||
*
|
||||
* @link https://www.smarty.net/manual/en/language.function.mailto.php {mailto}
|
||||
* @link https://www.smarty.net/docs/en/language.function.mailto.php {mailto}
|
||||
* (Smarty online manual)
|
||||
* @version 1.2
|
||||
* @author Monte Ohrt <monte at ohrt dot com>
|
||||
|
||||
@@ -12,7 +12,7 @@
|
||||
* Name: math
|
||||
* Purpose: handle math computations in template
|
||||
*
|
||||
* @link https://www.smarty.net/manual/en/language.function.math.php {math}
|
||||
* @link https://www.smarty.net/docs/en/language.function.math.php {math}
|
||||
* (Smarty online manual)
|
||||
* @author Monte Ohrt <monte at ohrt dot com>
|
||||
*
|
||||
@@ -25,35 +25,35 @@ function smarty_function_math($params, $template)
|
||||
{
|
||||
static $_allowed_funcs =
|
||||
array(
|
||||
'int' => true,
|
||||
'abs' => true,
|
||||
'ceil' => true,
|
||||
'acos' => true,
|
||||
'int' => true,
|
||||
'abs' => true,
|
||||
'ceil' => true,
|
||||
'acos' => true,
|
||||
'acosh' => true,
|
||||
'cos' => true,
|
||||
'cosh' => true,
|
||||
'deg2rad' => true,
|
||||
'rad2deg' => true,
|
||||
'exp' => true,
|
||||
'floor' => true,
|
||||
'log' => true,
|
||||
'log10' => true,
|
||||
'max' => true,
|
||||
'min' => true,
|
||||
'pi' => true,
|
||||
'pow' => true,
|
||||
'rand' => true,
|
||||
'round' => true,
|
||||
'asin' => true,
|
||||
'cos' => true,
|
||||
'cosh' => true,
|
||||
'deg2rad' => true,
|
||||
'rad2deg' => true,
|
||||
'exp' => true,
|
||||
'floor' => true,
|
||||
'log' => true,
|
||||
'log10' => true,
|
||||
'max' => true,
|
||||
'min' => true,
|
||||
'pi' => true,
|
||||
'pow' => true,
|
||||
'rand' => true,
|
||||
'round' => true,
|
||||
'asin' => true,
|
||||
'asinh' => true,
|
||||
'sin' => true,
|
||||
'sinh' => true,
|
||||
'sqrt' => true,
|
||||
'srand' => true,
|
||||
'atan' => true,
|
||||
'sin' => true,
|
||||
'sinh' => true,
|
||||
'sqrt' => true,
|
||||
'srand' => true,
|
||||
'atan' => true,
|
||||
'atanh' => true,
|
||||
'tan' => true,
|
||||
'tanh' => true
|
||||
'tan' => true,
|
||||
'tanh' => true
|
||||
);
|
||||
|
||||
// be sure equation parameter is present
|
||||
|
||||
@@ -15,7 +15,8 @@
|
||||
* - format: strftime format for output
|
||||
* - default_date: default date if $string is empty
|
||||
*
|
||||
* @link https://www.smarty.net/manual/en/language.modifier.date.format.php date_format (Smarty online manual)
|
||||
* @link https://www.smarty.net/docs/en/language.modifier.date.format.php date_format
|
||||
* (Smarty online manual)
|
||||
* @author Monte Ohrt <monte at ohrt dot com>
|
||||
*
|
||||
* @param string $string input date string
|
||||
|
||||
@@ -17,104 +17,31 @@
|
||||
* @param string $string input string
|
||||
* @param string $esc_type escape type
|
||||
* @param string $char_set character set, used for htmlspecialchars() or htmlentities()
|
||||
* @param boolean $double_encode encode already encoded entitites again, used for htmlspecialchars() or htmlentities()
|
||||
* @param boolean $double_encode encode already encoded entities again, used for htmlspecialchars() or htmlentities()
|
||||
*
|
||||
* @return string escaped input string
|
||||
*/
|
||||
function smarty_modifier_escape($string, $esc_type = 'html', $char_set = null, $double_encode = true)
|
||||
{
|
||||
static $_double_encode = true;
|
||||
static $is_loaded_1 = false;
|
||||
static $is_loaded_2 = false;
|
||||
|
||||
if (!$char_set) {
|
||||
$char_set = Smarty::$_CHARSET;
|
||||
}
|
||||
|
||||
$string = (string)$string;
|
||||
|
||||
switch ($esc_type) {
|
||||
case 'html':
|
||||
if ($_double_encode) {
|
||||
// php >=5.3.2 - go native
|
||||
return htmlspecialchars($string, ENT_QUOTES, $char_set, $double_encode);
|
||||
} else {
|
||||
if ($double_encode) {
|
||||
// php <5.2.3 - only handle double encoding
|
||||
return htmlspecialchars($string, ENT_QUOTES, $char_set);
|
||||
} else {
|
||||
// php <5.2.3 - prevent double encoding
|
||||
$string = preg_replace('!&(#?\w+);!', '%%%SMARTY_START%%%\\1%%%SMARTY_END%%%', $string);
|
||||
$string = htmlspecialchars($string, ENT_QUOTES, $char_set);
|
||||
$string = str_replace(
|
||||
array(
|
||||
'%%%SMARTY_START%%%',
|
||||
'%%%SMARTY_END%%%'
|
||||
),
|
||||
array(
|
||||
'&',
|
||||
';'
|
||||
),
|
||||
$string
|
||||
);
|
||||
return $string;
|
||||
}
|
||||
}
|
||||
return htmlspecialchars($string, ENT_QUOTES, $char_set, $double_encode);
|
||||
// no break
|
||||
case 'htmlall':
|
||||
if (Smarty::$_MBSTRING) {
|
||||
// mb_convert_encoding ignores htmlspecialchars()
|
||||
if ($_double_encode) {
|
||||
// php >=5.3.2 - go native
|
||||
$string = htmlspecialchars($string, ENT_QUOTES, $char_set, $double_encode);
|
||||
} else {
|
||||
if ($double_encode) {
|
||||
// php <5.2.3 - only handle double encoding
|
||||
$string = htmlspecialchars($string, ENT_QUOTES, $char_set);
|
||||
} else {
|
||||
// php <5.2.3 - prevent double encoding
|
||||
$string = preg_replace('!&(#?\w+);!', '%%%SMARTY_START%%%\\1%%%SMARTY_END%%%', $string);
|
||||
$string = htmlspecialchars($string, ENT_QUOTES, $char_set);
|
||||
$string =
|
||||
str_replace(
|
||||
array(
|
||||
'%%%SMARTY_START%%%',
|
||||
'%%%SMARTY_END%%%'
|
||||
),
|
||||
array(
|
||||
'&',
|
||||
';'
|
||||
),
|
||||
$string
|
||||
);
|
||||
return $string;
|
||||
}
|
||||
}
|
||||
// htmlentities() won't convert everything, so use mb_convert_encoding
|
||||
return mb_convert_encoding($string, 'HTML-ENTITIES', $char_set);
|
||||
$string = mb_convert_encoding($string, 'UTF-8', $char_set);
|
||||
return htmlentities($string, ENT_QUOTES, 'UTF-8', $double_encode);
|
||||
}
|
||||
// no MBString fallback
|
||||
if ($_double_encode) {
|
||||
return htmlentities($string, ENT_QUOTES, $char_set, $double_encode);
|
||||
} else {
|
||||
if ($double_encode) {
|
||||
return htmlentities($string, ENT_QUOTES, $char_set);
|
||||
} else {
|
||||
$string = preg_replace('!&(#?\w+);!', '%%%SMARTY_START%%%\\1%%%SMARTY_END%%%', $string);
|
||||
$string = htmlentities($string, ENT_QUOTES, $char_set);
|
||||
$string = str_replace(
|
||||
array(
|
||||
'%%%SMARTY_START%%%',
|
||||
'%%%SMARTY_END%%%'
|
||||
),
|
||||
array(
|
||||
'&',
|
||||
';'
|
||||
),
|
||||
$string
|
||||
);
|
||||
return $string;
|
||||
}
|
||||
}
|
||||
return htmlentities($string, ENT_QUOTES, $char_set, $double_encode);
|
||||
// no break
|
||||
case 'url':
|
||||
return rawurlencode($string);
|
||||
|
||||
@@ -11,7 +11,7 @@
|
||||
* Name: regex_replace
|
||||
* Purpose: regular expression search/replace
|
||||
*
|
||||
* @link https://www.smarty.net/manual/en/language.modifier.regex.replace.php
|
||||
* @link https://www.smarty.net/docs/en/language.modifier.regex.replace.php
|
||||
* regex_replace (Smarty online manual)
|
||||
* @author Monte Ohrt <monte at ohrt dot com>
|
||||
*
|
||||
|
||||
@@ -11,7 +11,8 @@
|
||||
* Name: replace
|
||||
* Purpose: simple search/replace
|
||||
*
|
||||
* @link https://www.smarty.net/manual/en/language.modifier.replace.php replace (Smarty online manual)
|
||||
* @link https://www.smarty.net/docs/en/language.modifier.replace.php replace
|
||||
* (Smarty online manual)
|
||||
* @author Monte Ohrt <monte at ohrt dot com>
|
||||
* @author Uwe Tews
|
||||
*
|
||||
|
||||
@@ -11,7 +11,8 @@
|
||||
* Name: spacify
|
||||
* Purpose: add spaces between characters in a string
|
||||
*
|
||||
* @link https://www.smarty.net/manual/en/language.modifier.spacify.php spacify (Smarty online manual)
|
||||
* @link https://www.smarty.net/docs/en/language.modifier.spacify.php spacify
|
||||
* (Smarty online manual)
|
||||
* @author Monte Ohrt <monte at ohrt dot com>
|
||||
*
|
||||
* @param string $string input string
|
||||
|
||||
@@ -13,7 +13,8 @@
|
||||
* optionally splitting in the middle of a word, and
|
||||
* appending the $etc string or inserting $etc into the middle.
|
||||
*
|
||||
* @link https://www.smarty.net/manual/en/language.modifier.truncate.php truncate (Smarty online manual)
|
||||
* @link https://www.smarty.net/docs/en/language.modifier.truncate.php truncate
|
||||
* (Smarty online manual)
|
||||
* @author Monte Ohrt <monte at ohrt dot com>
|
||||
*
|
||||
* @param string $string input string
|
||||
|
||||
@@ -14,7 +14,7 @@
|
||||
* Input: string to catenate
|
||||
* Example: {$var|cat:"foo"}
|
||||
*
|
||||
* @link https://www.smarty.net/manual/en/language.modifier.cat.php cat
|
||||
* @link https://www.smarty.net/docs/en/language.modifier.cat.php cat
|
||||
* (Smarty online manual)
|
||||
* @author Uwe Tews
|
||||
*
|
||||
|
||||
@@ -11,8 +11,8 @@
|
||||
* Name: count_characters
|
||||
* Purpose: count the number of characters in a text
|
||||
*
|
||||
* @link https://www.smarty.net/manual/en/language.modifier.count.characters.php count_characters (Smarty online
|
||||
* manual)
|
||||
* @link https://www.smarty.net/docs/en/language.modifier.count.characters.php count_characters
|
||||
* (Smarty online manual)
|
||||
* @author Uwe Tews
|
||||
*
|
||||
* @param array $params parameters
|
||||
|
||||
@@ -11,7 +11,7 @@
|
||||
* Name: count_paragraphs
|
||||
* Purpose: count the number of paragraphs in a text
|
||||
*
|
||||
* @link https://www.smarty.net/manual/en/language.modifier.count.paragraphs.php
|
||||
* @link https://www.smarty.net/docs/en/language.modifier.count.paragraphs.php
|
||||
* count_paragraphs (Smarty online manual)
|
||||
* @author Uwe Tews
|
||||
*
|
||||
|
||||
@@ -11,7 +11,7 @@
|
||||
* Name: count_sentences
|
||||
* Purpose: count the number of sentences in a text
|
||||
*
|
||||
* @link https://www.smarty.net/manual/en/language.modifier.count.paragraphs.php
|
||||
* @link https://www.smarty.net/docs/en/language.modifier.count.paragraphs.php
|
||||
* count_sentences (Smarty online manual)
|
||||
* @author Uwe Tews
|
||||
*
|
||||
|
||||
@@ -11,7 +11,8 @@
|
||||
* Name: count_words
|
||||
* Purpose: count the number of words in a text
|
||||
*
|
||||
* @link https://www.smarty.net/manual/en/language.modifier.count.words.php count_words (Smarty online manual)
|
||||
* @link https://www.smarty.net/docs/en/language.modifier.count.words.php count_words
|
||||
* (Smarty online manual)
|
||||
* @author Uwe Tews
|
||||
*
|
||||
* @param array $params parameters
|
||||
|
||||
@@ -11,7 +11,8 @@
|
||||
* Name: default
|
||||
* Purpose: designate default value for empty variables
|
||||
*
|
||||
* @link https://www.smarty.net/manual/en/language.modifier.default.php default (Smarty online manual)
|
||||
* @link https://www.smarty.net/docs/en/language.modifier.default default
|
||||
* (Smarty online manual)
|
||||
* @author Uwe Tews
|
||||
*
|
||||
* @param array $params parameters
|
||||
|
||||
@@ -11,19 +11,18 @@
|
||||
* Name: escape
|
||||
* Purpose: escape string for output
|
||||
*
|
||||
* @link https://www.smarty.net/docsv2/en/language.modifier.escape count_characters (Smarty online manual)
|
||||
* @link https://www.smarty.net/docs/en/language.modifier.escape count_characters
|
||||
* (Smarty online manual)
|
||||
* @author Rodney Rehm
|
||||
*
|
||||
* @param array $params parameters
|
||||
* @param Smarty_Internal_TemplateCompilerBase $compiler
|
||||
*
|
||||
* @return string with compiled code
|
||||
* @throws \SmartyException
|
||||
* @throws SmartyException
|
||||
*/
|
||||
function smarty_modifiercompiler_escape($params, Smarty_Internal_TemplateCompilerBase $compiler)
|
||||
{
|
||||
static $_double_encode = true;
|
||||
static $is_loaded = false;
|
||||
$compiler->template->_checkPlugins(
|
||||
array(
|
||||
array(
|
||||
@@ -41,42 +40,17 @@ function smarty_modifiercompiler_escape($params, Smarty_Internal_TemplateCompile
|
||||
}
|
||||
switch ($esc_type) {
|
||||
case 'html':
|
||||
if ($_double_encode) {
|
||||
return 'htmlspecialchars((string)' . $params[ 0 ] . ', ENT_QUOTES, ' . var_export($char_set, true) . ', ' .
|
||||
var_export($double_encode, true) . ')';
|
||||
} elseif ($double_encode) {
|
||||
return 'htmlspecialchars((string)' . $params[ 0 ] . ', ENT_QUOTES, ' . var_export($char_set, true) . ')';
|
||||
} else {
|
||||
// fall back to modifier.escape.php
|
||||
}
|
||||
// no break
|
||||
return 'htmlspecialchars((string)' . $params[ 0 ] . ', ENT_QUOTES, ' . var_export($char_set, true) . ', ' .
|
||||
var_export($double_encode, true) . ')';
|
||||
case 'htmlall':
|
||||
if (Smarty::$_MBSTRING) {
|
||||
if ($_double_encode) {
|
||||
// php >=5.2.3 - go native
|
||||
return 'mb_convert_encoding(htmlspecialchars((string)' . $params[ 0 ] . ', ENT_QUOTES, ' .
|
||||
var_export($char_set, true) . ', ' . var_export($double_encode, true) .
|
||||
'), "HTML-ENTITIES", ' . var_export($char_set, true) . ')';
|
||||
} elseif ($double_encode) {
|
||||
// php <5.2.3 - only handle double encoding
|
||||
return 'mb_convert_encoding(htmlspecialchars((string)' . $params[ 0 ] . ', ENT_QUOTES, ' .
|
||||
var_export($char_set, true) . '), "HTML-ENTITIES", ' . var_export($char_set, true) . ')';
|
||||
} else {
|
||||
// fall back to modifier.escape.php
|
||||
}
|
||||
return 'htmlentities(mb_convert_encoding((string)' . $params[ 0 ] . ', \'UTF-8\', ' .
|
||||
var_export($char_set, true) . '), ENT_QUOTES, \'UTF-8\', ' .
|
||||
var_export($double_encode, true) . ')';
|
||||
}
|
||||
// no MBString fallback
|
||||
if ($_double_encode) {
|
||||
// php >=5.2.3 - go native
|
||||
return 'htmlentities((string)' . $params[ 0 ] . ', ENT_QUOTES, ' . var_export($char_set, true) . ', ' .
|
||||
var_export($double_encode, true) . ')';
|
||||
} elseif ($double_encode) {
|
||||
// php <5.2.3 - only handle double encoding
|
||||
return 'htmlentities((string)' . $params[ 0 ] . ', ENT_QUOTES, ' . var_export($char_set, true) . ')';
|
||||
} else {
|
||||
// fall back to modifier.escape.php
|
||||
}
|
||||
// no break
|
||||
return 'htmlentities((string)' . $params[ 0 ] . ', ENT_QUOTES, ' . var_export($char_set, true) . ', ' .
|
||||
var_export($double_encode, true) . ')';
|
||||
case 'url':
|
||||
return 'rawurlencode((string)' . $params[ 0 ] . ')';
|
||||
case 'urlpathinfo':
|
||||
|
||||
@@ -11,7 +11,8 @@
|
||||
* Name: indent
|
||||
* Purpose: indent lines of text
|
||||
*
|
||||
* @link https://www.smarty.net/manual/en/language.modifier.indent.php indent (Smarty online manual)
|
||||
* @link https://www.smarty.net/docs/en/language.modifier.indent.php indent
|
||||
* (Smarty online manual)
|
||||
* @author Uwe Tews
|
||||
*
|
||||
* @param array $params parameters
|
||||
|
||||
@@ -11,7 +11,8 @@
|
||||
* Name: lower
|
||||
* Purpose: convert string to lowercase
|
||||
*
|
||||
* @link https://www.smarty.net/manual/en/language.modifier.lower.php lower (Smarty online manual)
|
||||
* @link https://www.smarty.net/docs/en/language.modifier.lower.php lower
|
||||
* (Smarty online manual)
|
||||
* @author Monte Ohrt <monte at ohrt dot com>
|
||||
* @author Uwe Tews
|
||||
*
|
||||
|
||||
@@ -11,7 +11,8 @@
|
||||
* Name: string_format
|
||||
* Purpose: format strings via sprintf
|
||||
*
|
||||
* @link https://www.smarty.net/manual/en/language.modifier.string.format.php string_format (Smarty online manual)
|
||||
* @link https://www.smarty.net/docs/en/language.modifier.string.format.php string_format
|
||||
* (Smarty online manual)
|
||||
* @author Uwe Tews
|
||||
*
|
||||
* @param array $params parameters
|
||||
|
||||
@@ -14,7 +14,8 @@
|
||||
* Example: {$var|strip} {$var|strip:" "}
|
||||
* Date: September 25th, 2002
|
||||
*
|
||||
* @link https://www.smarty.net/manual/en/language.modifier.strip.php strip (Smarty online manual)
|
||||
* @link https://www.smarty.net/docs/en/language.modifier.strip.php strip
|
||||
* (Smarty online manual)
|
||||
* @author Uwe Tews
|
||||
*
|
||||
* @param array $params parameters
|
||||
|
||||
@@ -39,9 +39,9 @@ function smarty_modifiercompiler_unescape($params, Smarty_Internal_TemplateCompi
|
||||
case 'entity':
|
||||
case 'htmlall':
|
||||
if (Smarty::$_MBSTRING) {
|
||||
return 'mb_convert_encoding(' . $params[ 0 ] . ', ' . $params[ 2 ] . ', \'HTML-ENTITIES\')';
|
||||
return 'html_entity_decode(mb_convert_encoding(' . $params[ 0 ] . ', ' . $params[ 2 ] . ', \'UTF-8\'), ENT_QUOTES | ENT_SUBSTITUTE | ENT_HTML401, ' . $params[ 2 ] . ')';
|
||||
}
|
||||
return 'html_entity_decode(' . $params[ 0 ] . ', ENT_NOQUOTES, ' . $params[ 2 ] . ')';
|
||||
return 'html_entity_decode(' . $params[ 0 ] . ', ENT_QUOTES | ENT_SUBSTITUTE | ENT_HTML401, ' . $params[ 2 ] . ')';
|
||||
case 'html':
|
||||
return 'htmlspecialchars_decode(' . $params[ 0 ] . ', ENT_QUOTES)';
|
||||
case 'url':
|
||||
|
||||
@@ -11,7 +11,8 @@
|
||||
* Name: lower
|
||||
* Purpose: convert string to uppercase
|
||||
*
|
||||
* @link https://www.smarty.net/manual/en/language.modifier.upper.php lower (Smarty online manual)
|
||||
* @link https://www.smarty.net/docs/en/language.modifier.upper.php lower
|
||||
* (Smarty online manual)
|
||||
* @author Uwe Tews
|
||||
*
|
||||
* @param array $params parameters
|
||||
|
||||
@@ -11,7 +11,8 @@
|
||||
* Name: wordwrap
|
||||
* Purpose: wrap a string of text at a given length
|
||||
*
|
||||
* @link https://www.smarty.net/manual/en/language.modifier.wordwrap.php wordwrap (Smarty online manual)
|
||||
* @link https://www.smarty.net/docs/en/language.modifier.wordwrap.php wordwrap
|
||||
* (Smarty online manual)
|
||||
* @author Uwe Tews
|
||||
*
|
||||
* @param array $params parameters
|
||||
|
||||
@@ -26,7 +26,7 @@ function smarty_literal_compiler_param($params, $index, $default = null)
|
||||
if (!preg_match('/^([\'"]?)[a-zA-Z0-9-]+(\\1)$/', $params[ $index ])) {
|
||||
throw new SmartyException(
|
||||
'$param[' . $index .
|
||||
'] is not a literal and is thus not evaluatable at compile time'
|
||||
'] is not a literal and is thus not evaluable at compile time'
|
||||
);
|
||||
}
|
||||
$t = null;
|
||||
|
||||
@@ -63,6 +63,7 @@ if (!function_exists('smarty_mb_str_replace')) {
|
||||
}
|
||||
|
||||
$parts = mb_split(preg_quote($search), $subject ?? "") ?: array();
|
||||
|
||||
// If original regex encoding was not unicode...
|
||||
if(!$reg_is_unicode) {
|
||||
// ...restore original regex encoding to avoid breaking the system.
|
||||
|
||||
@@ -117,7 +117,7 @@ abstract class Smarty_CacheResource_Custom extends Smarty_CacheResource
|
||||
$cached->content,
|
||||
$timestamp
|
||||
);
|
||||
$cached->timestamp = isset($timestamp) ? $timestamp : false;
|
||||
$cached->timestamp = $timestamp ?? false;
|
||||
$cached->exists = !!$cached->timestamp;
|
||||
}
|
||||
|
||||
@@ -138,8 +138,8 @@ abstract class Smarty_CacheResource_Custom extends Smarty_CacheResource
|
||||
if (!$cached) {
|
||||
$cached = $_smarty_tpl->cached;
|
||||
}
|
||||
$content = $cached->content ? $cached->content : null;
|
||||
$timestamp = $cached->timestamp ? $cached->timestamp : null;
|
||||
$content = $cached->content ?? null;
|
||||
$timestamp = $cached->timestamp ?? null;
|
||||
if ($content === null || !$timestamp) {
|
||||
$this->fetch(
|
||||
$_smarty_tpl->cached->filepath,
|
||||
@@ -187,7 +187,7 @@ abstract class Smarty_CacheResource_Custom extends Smarty_CacheResource
|
||||
*/
|
||||
public function readCachedContent(Smarty_Internal_Template $_template)
|
||||
{
|
||||
$content = $_template->cached->content ? $_template->cached->content : null;
|
||||
$content = $_template->cached->content ?? null;
|
||||
$timestamp = null;
|
||||
if ($content === null) {
|
||||
$timestamp = null;
|
||||
|
||||
@@ -102,8 +102,8 @@ abstract class Smarty_CacheResource_KeyValueStore extends Smarty_CacheResource
|
||||
if (!$cached) {
|
||||
$cached = $_smarty_tpl->cached;
|
||||
}
|
||||
$content = $cached->content ? $cached->content : null;
|
||||
$timestamp = $cached->timestamp ? $cached->timestamp : null;
|
||||
$content = $cached->content ?? null;
|
||||
$timestamp = $cached->timestamp ?? null;
|
||||
if ($content === null || !$timestamp) {
|
||||
if (!$this->fetch(
|
||||
$_smarty_tpl->cached->filepath,
|
||||
@@ -148,7 +148,7 @@ abstract class Smarty_CacheResource_KeyValueStore extends Smarty_CacheResource
|
||||
*/
|
||||
public function readCachedContent(Smarty_Internal_Template $_template)
|
||||
{
|
||||
$content = $_template->cached->content ? $_template->cached->content : null;
|
||||
$content = $_template->cached->content ?? null;
|
||||
$timestamp = null;
|
||||
if ($content === null) {
|
||||
if (!$this->fetch(
|
||||
|
||||
@@ -112,7 +112,7 @@ class Smarty_Internal_Compile_Blockclose extends Smarty_Internal_Compile_Shared_
|
||||
$_block = $compiler->_cache[ 'blockParams' ][ $compiler->_cache[ 'blockNesting' ] ];
|
||||
unset($compiler->_cache[ 'blockParams' ][ $compiler->_cache[ 'blockNesting' ] ]);
|
||||
$_name = $_attr[ 'name' ];
|
||||
$_assign = isset($_attr[ 'assign' ]) ? $_attr[ 'assign' ] : null;
|
||||
$_assign = $_attr[ 'assign' ] ?? null;
|
||||
unset($_attr[ 'assign' ], $_attr[ 'name' ]);
|
||||
foreach ($_attr as $name => $stat) {
|
||||
if ((is_bool($stat) && $stat !== false) || (!is_bool($stat) && $stat !== 'false')) {
|
||||
|
||||
@@ -63,9 +63,9 @@ class Smarty_Internal_Compile_Capture extends Smarty_Internal_CompileBase
|
||||
{
|
||||
// check and get attributes
|
||||
$_attr = $this->getAttributes($compiler, $args, $parameter, 'capture');
|
||||
$buffer = isset($_attr[ 'name' ]) ? $_attr[ 'name' ] : "'default'";
|
||||
$assign = isset($_attr[ 'assign' ]) ? $_attr[ 'assign' ] : 'null';
|
||||
$append = isset($_attr[ 'append' ]) ? $_attr[ 'append' ] : 'null';
|
||||
$buffer = $_attr[ 'name' ] ?? "'default'";
|
||||
$assign = $_attr[ 'assign' ] ?? 'null';
|
||||
$append = $_attr[ 'append' ] ?? 'null';
|
||||
$compiler->_cache[ 'capture_stack' ][] = array($compiler->nocache);
|
||||
// maybe nocache because of nocache variables
|
||||
$compiler->nocache = $compiler->nocache | $compiler->tag_nocache;
|
||||
|
||||
@@ -63,7 +63,7 @@ class Smarty_Internal_Compile_Child extends Smarty_Internal_CompileBase
|
||||
if ($this->blockType === 'Child') {
|
||||
$compiler->_cache[ 'blockParams' ][ $compiler->_cache[ 'blockNesting' ] ][ 'callsChild' ] = 'true';
|
||||
}
|
||||
$_assign = isset($_attr[ 'assign' ]) ? $_attr[ 'assign' ] : null;
|
||||
$_assign = $_attr[ 'assign' ] ?? null;
|
||||
$output = "<?php \n";
|
||||
if (isset($_assign)) {
|
||||
$output .= "ob_start();\n";
|
||||
|
||||
@@ -157,7 +157,7 @@ class Smarty_Internal_Compile_Functionclose extends Smarty_Internal_CompileBase
|
||||
$output = "<?php echo \"/*%%SmartyNocache:{$compiler->template->compiled->nocache_hash}%%*/<?php ";
|
||||
$output .= "\\\$_smarty_tpl->smarty->ext->_tplFunction->restoreTemplateVariables(\\\$_smarty_tpl, '{$_name}');?>\n";
|
||||
$output .= "/*/%%SmartyNocache:{$compiler->template->compiled->nocache_hash}%%*/\";\n?>";
|
||||
$output .= "<?php echo str_replace('{$compiler->template->compiled->nocache_hash}', \$_smarty_tpl->compiled->nocache_hash ?? '', ob_get_clean());\n";
|
||||
$output .= "<?php echo str_replace('{$compiler->template->compiled->nocache_hash}', \$_smarty_tpl->compiled->nocache_hash, ob_get_clean());\n";
|
||||
$output .= "}\n}\n";
|
||||
$output .= $compiler->cStyleComment("/ {$_funcName}_nocache ") . "\n\n";
|
||||
$output .= "?>\n";
|
||||
|
||||
@@ -196,7 +196,7 @@ class Smarty_Internal_Compile_Include extends Smarty_Internal_CompileBase
|
||||
}
|
||||
$has_compiled_template = false;
|
||||
if ($merge_compiled_includes) {
|
||||
$c_id = isset($_attr[ 'compile_id' ]) ? $_attr[ 'compile_id' ] : $compiler->template->compile_id;
|
||||
$c_id = $_attr[ 'compile_id' ] ?? $compiler->template->compile_id;
|
||||
// we must observe different compile_id and caching
|
||||
$t_hash = sha1($c_id . ($_caching ? '--caching' : '--nocaching'));
|
||||
$compiler->smarty->allow_ambiguous_resources = true;
|
||||
@@ -314,7 +314,7 @@ class Smarty_Internal_Compile_Include extends Smarty_Internal_CompileBase
|
||||
} else {
|
||||
$basename = $tpl->source->handler->getBasename($tpl->source);
|
||||
$sourceInfo = $tpl->source->type . ':' .
|
||||
($basename ? $basename : $tpl->source->name);
|
||||
($basename ?? $tpl->source->name);
|
||||
}
|
||||
// get compiled code
|
||||
$compiled_code = "<?php\n\n";
|
||||
|
||||
@@ -193,7 +193,7 @@ class Smarty_Internal_Configfilelexer
|
||||
$this->yyTraceFILE,
|
||||
"%sState push %s\n",
|
||||
$this->yyTracePrompt,
|
||||
isset($this->state_name[ $this->_yy_state ]) ? $this->state_name[ $this->_yy_state ] : $this->_yy_state
|
||||
$this->state_name[ $this->_yy_state ] ?? $this->_yy_state
|
||||
);
|
||||
}
|
||||
array_push($this->_yy_stack, $this->_yy_state);
|
||||
@@ -203,7 +203,7 @@ class Smarty_Internal_Configfilelexer
|
||||
$this->yyTraceFILE,
|
||||
"%snew State %s\n",
|
||||
$this->yyTracePrompt,
|
||||
isset($this->state_name[ $this->_yy_state ]) ? $this->state_name[ $this->_yy_state ] : $this->_yy_state
|
||||
$this->state_name[ $this->_yy_state ] ?? $this->_yy_state
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -215,7 +215,7 @@ class Smarty_Internal_Configfilelexer
|
||||
$this->yyTraceFILE,
|
||||
"%sState pop %s\n",
|
||||
$this->yyTracePrompt,
|
||||
isset($this->state_name[ $this->_yy_state ]) ? $this->state_name[ $this->_yy_state ] : $this->_yy_state
|
||||
$this->state_name[ $this->_yy_state ] ?? $this->_yy_state
|
||||
);
|
||||
}
|
||||
$this->_yy_state = array_pop($this->_yy_stack);
|
||||
@@ -224,7 +224,7 @@ class Smarty_Internal_Configfilelexer
|
||||
$this->yyTraceFILE,
|
||||
"%snew State %s\n",
|
||||
$this->yyTracePrompt,
|
||||
isset($this->state_name[ $this->_yy_state ]) ? $this->state_name[ $this->_yy_state ] : $this->_yy_state
|
||||
$this->state_name[ $this->_yy_state ] ?? $this->_yy_state
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -237,7 +237,7 @@ class Smarty_Internal_Configfilelexer
|
||||
$this->yyTraceFILE,
|
||||
"%sState set %s\n",
|
||||
$this->yyTracePrompt,
|
||||
isset($this->state_name[ $this->_yy_state ]) ? $this->state_name[ $this->_yy_state ] : $this->_yy_state
|
||||
$this->state_name[ $this->_yy_state ] ?? $this->_yy_state
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -69,6 +69,7 @@ class Smarty_Internal_Debug extends Smarty_Internal_Data
|
||||
public function end_template(Smarty_Internal_Template $template)
|
||||
{
|
||||
$key = $this->get_key($template);
|
||||
if (!isset($this->template_data[ $this->index ][ $key ][ 'start_template_time' ])) return; // see internal_template L 243
|
||||
$this->template_data[ $this->index ][ $key ][ 'total_time' ] +=
|
||||
microtime(true) - $this->template_data[ $this->index ][ $key ][ 'start_template_time' ];
|
||||
//$this->template_data[$this->index][$key]['properties'] = $template->properties;
|
||||
@@ -142,6 +143,7 @@ class Smarty_Internal_Debug extends Smarty_Internal_Data
|
||||
public function end_render(Smarty_Internal_Template $template)
|
||||
{
|
||||
$key = $this->get_key($template);
|
||||
if (!isset($this->template_data[ $this->index ][ $key ][ 'start_time' ])) return; // see template_compiled L 119
|
||||
$this->template_data[ $this->index ][ $key ][ 'render_time' ] +=
|
||||
microtime(true) - $this->template_data[ $this->index ][ $key ][ 'start_time' ];
|
||||
}
|
||||
@@ -220,8 +222,7 @@ class Smarty_Internal_Debug extends Smarty_Internal_Data
|
||||
$debObj->debugging = false;
|
||||
$debObj->debugging_ctrl = 'NONE';
|
||||
$debObj->error_reporting = E_ALL & ~E_NOTICE;
|
||||
$debObj->debug_tpl =
|
||||
isset($smarty->debug_tpl) ? $smarty->debug_tpl : 'file:' . __DIR__ . '/../debug.tpl';
|
||||
$debObj->debug_tpl = $smarty->debug_tpl ?? 'file:' . dirname(__FILE__) . '/../debug.tpl';
|
||||
$debObj->registered_plugins = array();
|
||||
$debObj->registered_resources = array();
|
||||
$debObj->registered_filters = array();
|
||||
|
||||
@@ -36,6 +36,7 @@
|
||||
* @property Smarty_Internal_Method_RegisterPlugin $registerPlugin
|
||||
* @property mixed|\Smarty_Template_Cached configLoad
|
||||
*/
|
||||
#[\AllowDynamicProperties]
|
||||
class Smarty_Internal_Extension_Handler
|
||||
{
|
||||
public $objType = null;
|
||||
@@ -66,7 +67,7 @@ class Smarty_Internal_Extension_Handler
|
||||
public function _callExternalMethod(Smarty_Internal_Data $data, $name, $args)
|
||||
{
|
||||
/* @var Smarty $data ->smarty */
|
||||
$smarty = isset($data->smarty) ? $data->smarty : $data;
|
||||
$smarty = isset($data->smarty) ? $data->smarty : $data; // don't use ?? for isset here since that would need a follow-up property define in Smarty class for __get()
|
||||
if (!isset($smarty->ext->$name)) {
|
||||
if (preg_match('/^((set|get)|(.*?))([A-Z].*)$/', $name, $match)) {
|
||||
$basename = $this->upperCase($match[ 4 ]);
|
||||
|
||||
@@ -30,7 +30,7 @@ class Smarty_Internal_Method_GetAutoloadFilters extends Smarty_Internal_Method_S
|
||||
$smarty = $obj->_getSmartyObj();
|
||||
if ($type !== null) {
|
||||
$this->_checkFilterType($type);
|
||||
return isset($smarty->autoload_filters[ $type ]) ? $smarty->autoload_filters[ $type ] : array();
|
||||
return ($smarty->autoload_filters[ $type ] ?? array());
|
||||
}
|
||||
return $smarty->autoload_filters;
|
||||
}
|
||||
|
||||
@@ -40,7 +40,7 @@ class Smarty_Internal_Method_GetStreamVariable
|
||||
fclose($fp);
|
||||
return $_result;
|
||||
}
|
||||
$smarty = isset($data->smarty) ? $data->smarty : $data;
|
||||
$smarty = $data->smarty ?? $data;
|
||||
if ($smarty->error_unassigned) {
|
||||
throw new SmartyException('Undefined stream variable "' . $variable . '"');
|
||||
} else {
|
||||
|
||||
@@ -44,7 +44,7 @@ class Smarty_Internal_Method_RegisterFilter
|
||||
{
|
||||
$smarty = $obj->_getSmartyObj();
|
||||
$this->_checkFilterType($type);
|
||||
$name = isset($name) ? $name : $this->_getFilterName($callback);
|
||||
$name = $name ?? $this->_getFilterName($callback);
|
||||
if (!is_callable($callback)) {
|
||||
throw new SmartyException("{$type}filter '{$name}' not callable");
|
||||
}
|
||||
|
||||
@@ -150,7 +150,7 @@ class Smarty_Internal_Runtime_Capture
|
||||
public function getBuffer(Smarty_Internal_Template $_template, $name = null)
|
||||
{
|
||||
if (isset($name)) {
|
||||
return isset($this->namedBuffer[ $name ]) ? $this->namedBuffer[ $name ] : null;
|
||||
return ($this->namedBuffer[ $name ] ?? null);
|
||||
} else {
|
||||
return $this->namedBuffer;
|
||||
}
|
||||
|
||||
@@ -120,14 +120,12 @@ class Smarty_Internal_Runtime_GetIncludePath
|
||||
public function getIncludePath($dirs, $file, Smarty $smarty)
|
||||
{
|
||||
//if (!(isset($this->_has_stream_include) ? $this->_has_stream_include : $this->_has_stream_include = false)) {
|
||||
if (!(isset($this->_has_stream_include) ? $this->_has_stream_include :
|
||||
$this->_has_stream_include = function_exists('stream_resolve_include_path'))
|
||||
) {
|
||||
if (!($this->_has_stream_include ?? ($this->_has_stream_include = function_exists('stream_resolve_include_path')))) {
|
||||
$this->isNewIncludePath($smarty);
|
||||
}
|
||||
// try PHP include_path
|
||||
foreach ($dirs as $dir) {
|
||||
$dir_n = isset($this->number[ $dir ]) ? $this->number[ $dir ] : $this->number[ $dir ] = $this->counter++;
|
||||
$dir_n = $this->number[ $dir ] ?? ($this->number[ $dir ] = $this->counter++);
|
||||
if (isset($this->isFile[ $dir_n ][ $file ])) {
|
||||
if ($this->isFile[ $dir_n ][ $file ]) {
|
||||
return $this->isFile[ $dir_n ][ $file ];
|
||||
@@ -153,14 +151,13 @@ class Smarty_Internal_Runtime_GetIncludePath
|
||||
$this->_user_dirs[ $dir_n ] = $dir;
|
||||
}
|
||||
if ($this->_has_stream_include) {
|
||||
$path = stream_resolve_include_path($dir . (isset($file) ? $file : ''));
|
||||
$path = stream_resolve_include_path($dir . ($file ?? ''));
|
||||
if ($path) {
|
||||
return $this->isFile[ $dir_n ][ $file ] = $path;
|
||||
}
|
||||
} else {
|
||||
foreach ($this->_include_dirs as $key => $_i_path) {
|
||||
$path = isset($this->isPath[ $key ][ $dir_n ]) ? $this->isPath[ $key ][ $dir_n ] :
|
||||
$this->isPath[ $key ][ $dir_n ] = is_dir($_dir_path = $_i_path . $dir) ? $_dir_path : false;
|
||||
$path = $this->isPath[ $key ][ $dir_n ] ?? ($this->isPath[ $key ][ $dir_n ] = is_dir($_dir_path = $_i_path . $dir) ? $_dir_path : false);
|
||||
if ($path === false) {
|
||||
continue;
|
||||
}
|
||||
|
||||
@@ -141,7 +141,7 @@ class Smarty_Internal_Runtime_Inheritance
|
||||
*/
|
||||
public function instanceBlock(Smarty_Internal_Template $tpl, $className, $name, $tplIndex = null)
|
||||
{
|
||||
$block = new $className($name, isset($tplIndex) ? $tplIndex : $this->tplIndex);
|
||||
$block = new $className($name, ($tplIndex ?? $this->tplIndex));
|
||||
if (isset($this->childRoot[ $name ])) {
|
||||
$block->child = $this->childRoot[ $name ];
|
||||
}
|
||||
|
||||
@@ -22,7 +22,7 @@ class Smarty_Internal_Runtime_Make_Nocache
|
||||
{
|
||||
if (isset($tpl->tpl_vars[ $var ])) {
|
||||
$export =
|
||||
preg_replace('/^Smarty_Variable::__set_state[(]|[)]$/', '', var_export($tpl->tpl_vars[ $var ], true));
|
||||
preg_replace('/^\\\\?Smarty_Variable::__set_state[(]|[)]$/', '', var_export($tpl->tpl_vars[ $var ], true));
|
||||
if (preg_match('/(\w+)::__set_state/', $export, $match)) {
|
||||
throw new SmartyException("{make_nocache \${$var}} in template '{$tpl->source->name}': variable does contain object '{$match[1]}' not implementing method '__set_state'");
|
||||
}
|
||||
|
||||
@@ -21,8 +21,7 @@ class Smarty_Internal_Runtime_TplFunction
|
||||
*/
|
||||
public function callTemplateFunction(Smarty_Internal_Template $tpl, $name, $params, $nocache)
|
||||
{
|
||||
$funcParam = isset($tpl->tplFunctions[ $name ]) ? $tpl->tplFunctions[ $name ] :
|
||||
(isset($tpl->smarty->tplFunctions[ $name ]) ? $tpl->smarty->tplFunctions[ $name ] : null);
|
||||
$funcParam = $tpl->tplFunctions[ $name ] ?? ($tpl->smarty->tplFunctions[ $name ] ?? null);
|
||||
if (isset($funcParam)) {
|
||||
if (!$tpl->caching || ($tpl->caching && $nocache)) {
|
||||
$function = $funcParam[ 'call_name' ];
|
||||
@@ -84,8 +83,7 @@ class Smarty_Internal_Runtime_TplFunction
|
||||
public function getTplFunction(Smarty_Internal_Template $tpl, $name = null)
|
||||
{
|
||||
if (isset($name)) {
|
||||
return isset($tpl->tplFunctions[ $name ]) ? $tpl->tplFunctions[ $name ] :
|
||||
(isset($tpl->smarty->tplFunctions[ $name ]) ? $tpl->smarty->tplFunctions[ $name ] : false);
|
||||
return ($tpl->tplFunctions[ $name ] ?? ($tpl->smarty->tplFunctions[ $name ] ?? false));
|
||||
} else {
|
||||
return empty($tpl->tplFunctions) ? $tpl->smarty->tplFunctions : $tpl->tplFunctions;
|
||||
}
|
||||
|
||||
@@ -24,6 +24,7 @@
|
||||
*
|
||||
* @method bool mustCompile()
|
||||
*/
|
||||
#[\AllowDynamicProperties]
|
||||
class Smarty_Internal_Template extends Smarty_Internal_TemplateBase
|
||||
{
|
||||
/**
|
||||
@@ -221,7 +222,7 @@ class Smarty_Internal_Template extends Smarty_Internal_TemplateBase
|
||||
$this->smarty->ext->_cacheModify->cacheModifiedCheck(
|
||||
$this->cached,
|
||||
$this,
|
||||
isset($content) ? $content : ob_get_clean()
|
||||
($content ?? ob_get_clean())
|
||||
);
|
||||
} else {
|
||||
if ((!$this->caching || $this->cached->has_nocache_code || $this->source->handler->recompiled)
|
||||
@@ -292,7 +293,7 @@ class Smarty_Internal_Template extends Smarty_Internal_TemplateBase
|
||||
$smarty = &$this->smarty;
|
||||
$_templateId = $smarty->_getTemplateId($template, $cache_id, $compile_id, $caching, $tpl);
|
||||
// recursive call ?
|
||||
if ((isset($tpl->templateId) ? $tpl->templateId : $tpl->_getTemplateId()) !== $_templateId) {
|
||||
if (($tpl->templateId ?? $tpl->_getTemplateId()) !== $_templateId) {
|
||||
// already in template cache?
|
||||
if (isset(self::$tplObjCache[ $_templateId ])) {
|
||||
// copy data from cached object
|
||||
@@ -537,7 +538,7 @@ class Smarty_Internal_Template extends Smarty_Internal_TemplateBase
|
||||
} else {
|
||||
$tpl->mustCompile = !$is_valid;
|
||||
$resource = $tpl->compiled;
|
||||
$resource->includes = isset($properties[ 'includes' ]) ? $properties[ 'includes' ] : array();
|
||||
$resource->includes = $properties[ 'includes' ] ?? array();
|
||||
}
|
||||
if ($is_valid) {
|
||||
$resource->unifunc = $properties[ 'unifunc' ];
|
||||
@@ -579,8 +580,8 @@ class Smarty_Internal_Template extends Smarty_Internal_TemplateBase
|
||||
*/
|
||||
public function _getTemplateId()
|
||||
{
|
||||
return isset($this->templateId) ? $this->templateId : $this->templateId =
|
||||
$this->smarty->_getTemplateId($this->template_resource, $this->cache_id, $this->compile_id);
|
||||
return ($this->templateId ?? ($this->templateId =
|
||||
$this->smarty->_getTemplateId($this->template_resource, $this->cache_id, $this->compile_id)));
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -186,7 +186,7 @@ abstract class Smarty_Internal_TemplateBase extends Smarty_Internal_Data
|
||||
} else {
|
||||
// get template object
|
||||
$saveVars = false;
|
||||
$template = $smarty->createTemplate($template, $cache_id, $compile_id, $parent ? $parent : $this, false);
|
||||
$template = $smarty->createTemplate($template, $cache_id, $compile_id, ($parent ?? $this), false);
|
||||
if ($this->_objType === 1) {
|
||||
// set caching in template object
|
||||
$template->caching = $this->caching;
|
||||
|
||||
@@ -428,8 +428,8 @@ abstract class Smarty_Internal_TemplateCompilerBase
|
||||
}
|
||||
$this->smarty->_debug->start_compile($this->template);
|
||||
}
|
||||
$this->parent_compiler = $parent_compiler ? $parent_compiler : $this;
|
||||
$nocache = isset($nocache) ? $nocache : false;
|
||||
$this->parent_compiler = $parent_compiler ?? $this;
|
||||
$nocache = $nocache ?? false;
|
||||
if (empty($template->compiled->nocache_hash)) {
|
||||
$template->compiled->nocache_hash = $this->nocache_hash;
|
||||
} else {
|
||||
@@ -1029,7 +1029,7 @@ abstract class Smarty_Internal_TemplateCompilerBase
|
||||
$_scope = $_scopeName;
|
||||
} elseif (is_string($_scopeName)) {
|
||||
$_scopeName = trim($_scopeName, '\'"');
|
||||
$_scope = isset($validScopes[ $_scopeName ]) ? $validScopes[ $_scopeName ] : false;
|
||||
$_scope = $validScopes[ $_scopeName ] ?? false;
|
||||
} else {
|
||||
$_scope = false;
|
||||
}
|
||||
|
||||
@@ -54,7 +54,7 @@ abstract class Smarty_Resource_Custom extends Smarty_Resource
|
||||
$source->timestamp = $mtime;
|
||||
} else {
|
||||
$this->fetch($source->name, $content, $timestamp);
|
||||
$source->timestamp = isset($timestamp) ? $timestamp : false;
|
||||
$source->timestamp = $timestamp ?? false;
|
||||
if (isset($content)) {
|
||||
$source->content = $content;
|
||||
}
|
||||
|
||||
@@ -19,9 +19,9 @@
|
||||
/**
|
||||
* This class does contain the security settings
|
||||
*/
|
||||
#[\AllowDynamicProperties]
|
||||
class Smarty_Security
|
||||
{
|
||||
|
||||
/**
|
||||
* This is the list of template directories that are considered secure.
|
||||
* $template_dir is in this list implicitly.
|
||||
|
||||
@@ -230,7 +230,7 @@ class Smarty_Template_Compiled extends Smarty_Template_Resource_Base
|
||||
if (!$_template->source->handler->recompiled) {
|
||||
return file_get_contents($this->filepath);
|
||||
}
|
||||
return isset($this->content) ? $this->content : false;
|
||||
return ($this->content ?? false);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user