mirror of
https://github.com/smarty-php/smarty.git
synced 2026-08-10 15:31:28 +02:00
Compare commits
109
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
3251b1c32d | ||
|
|
c016895166 | ||
|
|
f81720941c | ||
|
|
e6ee257ca2 | ||
|
|
1ff79c6c38 | ||
|
|
254b5cabee | ||
|
|
1b556c7077 | ||
|
|
4550fc0339 | ||
|
|
4fc39d59a5 | ||
|
|
0fb29024e7 | ||
|
|
612bd3f657 | ||
|
|
9eea30ec1e | ||
|
|
ea95e8b047 | ||
|
|
474138fd7e | ||
|
|
b91c04bfcf | ||
|
|
c53342c9fc | ||
|
|
f8a958cd53 | ||
|
|
45345e75ec | ||
|
|
bf7d6b8bd8 | ||
|
|
32a11b34ea | ||
|
|
db80246b58 | ||
|
|
d683641f90 | ||
|
|
0d4939e135 | ||
|
|
e2e68b3622 | ||
|
|
ffa2b81a8e | ||
|
|
c693d81370 | ||
|
|
813c83f7a3 | ||
|
|
55ea25d1f5 | ||
|
|
d304d349b4 | ||
|
|
7494818434 | ||
|
|
50d5890eac | ||
|
|
6872e78238 | ||
|
|
5479e3362c | ||
|
|
f8f97b4e2d | ||
|
|
1bc7c722a3 | ||
|
|
02968a82b5 | ||
|
|
fc06d246bf | ||
|
|
292ad986cd | ||
|
|
d024c3df4c | ||
|
|
f98ba948c4 | ||
|
|
7468378e3b | ||
|
|
de1f382f0b | ||
|
|
a85296ab94 | ||
|
|
40f40e549d | ||
|
|
64e50e00c9 | ||
|
|
159ed4ee02 | ||
|
|
7f579fdc69 | ||
|
|
c26151da1d | ||
|
|
078e2dbc1b | ||
|
|
36d157180a | ||
|
|
eec791d943 | ||
|
|
97aeb14c6f | ||
|
|
ed454551a3 | ||
|
|
f4b26a3cbf | ||
|
|
20a8026ccd | ||
|
|
27910bf2c1 | ||
|
|
cb95216671 | ||
|
|
d6ac3297df | ||
|
|
560475a2f2 | ||
|
|
382d66305d | ||
|
|
44bac8d58c | ||
|
|
f8e1ba76f7 | ||
|
|
629504485f | ||
|
|
71036be8be | ||
|
|
78f0cf5f65 | ||
|
|
64ad6442ca | ||
|
|
7eff7d6fb0 | ||
|
|
05f1a7deda | ||
|
|
3f97b7352e | ||
|
|
a6711b3833 | ||
|
|
52056ce65a | ||
|
|
8b96efad45 | ||
|
|
bfa02f3b91 | ||
|
|
89dc506638 | ||
|
|
e68065bc33 | ||
|
|
db2547287c | ||
|
|
962f266483 | ||
|
|
8aeb5d6821 | ||
|
|
a2e1df1768 | ||
|
|
fe6d333c60 | ||
|
|
50c4604857 | ||
|
|
e5a6ff42f8 | ||
|
|
3cc56392c6 | ||
|
|
17025423e1 | ||
|
|
18d3e564da | ||
|
|
0d2c38b482 | ||
|
|
f90348971b | ||
|
|
9e0536de18 | ||
|
|
265cf4f3bc | ||
|
|
47f95ad324 | ||
|
|
02633ecaba | ||
|
|
6786623afb | ||
|
|
2d97169086 | ||
|
|
0f098802c6 | ||
|
|
bbcd5817f6 | ||
|
|
612094d763 | ||
|
|
0ef0dda825 | ||
|
|
cef8951100 | ||
|
|
323aefa89f | ||
|
|
277648b81c | ||
|
|
8d3a7af308 | ||
|
|
cdf0f2b164 | ||
|
|
995b7eb36f | ||
|
|
059bea274c | ||
|
|
f707dadecb | ||
|
|
ace1c8e90f | ||
|
|
19ae410bf5 | ||
|
|
baad3115cd | ||
|
|
dff1955cd5 |
+4
-2
@@ -7,8 +7,10 @@
|
|||||||
|
|
||||||
# exclude from git export
|
# exclude from git export
|
||||||
/tests export-ignore
|
/tests export-ignore
|
||||||
/utilities/ export-ignore
|
/utilities export-ignore
|
||||||
|
/docker-compose.yml export-ignore
|
||||||
|
/.github export-ignore
|
||||||
|
/run_tests_for_all_php_versions.sh export-ignore
|
||||||
/.gitattributes export-ignore
|
/.gitattributes export-ignore
|
||||||
/.gitignore export-ignore
|
/.gitignore export-ignore
|
||||||
/make-release.sh export-ignore
|
/make-release.sh export-ignore
|
||||||
|
|||||||
@@ -1,8 +1,10 @@
|
|||||||
# https://help.github.com/en/categories/automating-your-workflow-with-github-actions
|
# https://help.github.com/en/categories/automating-your-workflow-with-github-actions
|
||||||
|
|
||||||
on:
|
on:
|
||||||
- pull_request
|
pull_request:
|
||||||
- push
|
push:
|
||||||
|
branches:
|
||||||
|
- 'master'
|
||||||
|
|
||||||
name: CI
|
name: CI
|
||||||
|
|
||||||
@@ -28,6 +30,8 @@ jobs:
|
|||||||
- "7.3"
|
- "7.3"
|
||||||
- "7.4"
|
- "7.4"
|
||||||
- "8.0"
|
- "8.0"
|
||||||
|
- "8.1"
|
||||||
|
- "8.2"
|
||||||
|
|
||||||
compiler:
|
compiler:
|
||||||
- default
|
- default
|
||||||
@@ -36,6 +40,12 @@ jobs:
|
|||||||
- os: ubuntu-latest
|
- os: ubuntu-latest
|
||||||
php-version: "8.0"
|
php-version: "8.0"
|
||||||
compiler: jit
|
compiler: jit
|
||||||
|
- os: ubuntu-latest
|
||||||
|
php-version: "8.1"
|
||||||
|
compiler: jit
|
||||||
|
- os: ubuntu-latest
|
||||||
|
php-version: "8.2"
|
||||||
|
compiler: jit
|
||||||
|
|
||||||
steps:
|
steps:
|
||||||
- name: Checkout
|
- name: Checkout
|
||||||
@@ -65,9 +75,5 @@ jobs:
|
|||||||
restore-keys: |
|
restore-keys: |
|
||||||
${{ runner.os }}-php-${{ matrix.php-version }}-
|
${{ runner.os }}-php-${{ matrix.php-version }}-
|
||||||
|
|
||||||
- name: Install dependencies
|
|
||||||
if: steps.composer-cache.outputs.cache-hit != 'true'
|
|
||||||
run: composer install --prefer-dist --no-progress --no-suggest
|
|
||||||
|
|
||||||
- name: Run tests with phpunit
|
- name: Run tests with phpunit
|
||||||
run: ./phpunit.sh
|
run: ./run-tests.sh
|
||||||
|
|||||||
@@ -5,7 +5,6 @@
|
|||||||
lexer/*.php
|
lexer/*.php
|
||||||
lexer/*.php.bak
|
lexer/*.php.bak
|
||||||
lexer/*.out
|
lexer/*.out
|
||||||
utilies/*.php
|
|
||||||
|
|
||||||
# Dev
|
# Dev
|
||||||
phpunit*
|
phpunit*
|
||||||
|
|||||||
@@ -6,6 +6,72 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
|||||||
|
|
||||||
## [Unreleased]
|
## [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)
|
||||||
|
- Dropped remaining references to removed PHP-support in Smarty 4 from docs, lexer and security class. [#816](https://github.com/smarty-php/smarty/issues/816)
|
||||||
|
|
||||||
|
### Fixed
|
||||||
|
- Output buffer is now cleaned for internal PHP errors as well, not just for Exceptions [#514](https://github.com/smarty-php/smarty/issues/514)
|
||||||
|
- Fixed recursion and out of memory errors when caching in complicated template set-ups using inheritance and includes [#801](https://github.com/smarty-php/smarty/pull/801)
|
||||||
|
- Fixed PHP8.1 deprecation errors in strip_tags
|
||||||
|
- Fix Variable Usage in Exception message when unable to load subtemplate [#808](https://github.com/smarty-php/smarty/pull/808)
|
||||||
|
- Fixed PHP8.1 deprecation notices for strftime [#672](https://github.com/smarty-php/smarty/issues/672)
|
||||||
|
- Fixed PHP8.1 deprecation errors passing null to parameter in trim [#807](https://github.com/smarty-php/smarty/pull/807)
|
||||||
|
- Adapt Smarty upper/lower functions to be codesafe (e.g. for Turkish locale) [#586](https://github.com/smarty-php/smarty/pull/586)
|
||||||
|
- Bug fix for underscore and limited length in template name in custom resources [#581](https://github.com/smarty-php/smarty/pull/581)
|
||||||
|
|
||||||
|
## [4.2.1] - 2022-09-14
|
||||||
|
|
||||||
|
### Security
|
||||||
|
- Applied appropriate javascript and html escaping in mailto plugin to counter injection attacks [#454](https://github.com/smarty-php/smarty/issues/454)
|
||||||
|
|
||||||
|
### Fixed
|
||||||
|
- Fixed PHP8.1 deprecation notices in modifiers (upper, explode, number_format and replace) [#755](https://github.com/smarty-php/smarty/pull/755) and [#788](https://github.com/smarty-php/smarty/pull/788)
|
||||||
|
- Fixed PHP8.1 deprecation notices in capitalize modifier [#789](https://github.com/smarty-php/smarty/issues/789)
|
||||||
|
- Fixed use of `rand()` without a parameter in math function [#794](https://github.com/smarty-php/smarty/issues/794)
|
||||||
|
- Fixed unselected year/month/day not working in html_select_date [#395](https://github.com/smarty-php/smarty/issues/395)
|
||||||
|
|
||||||
|
## [4.2.0] - 2022-08-01
|
||||||
|
|
||||||
|
### Fixed
|
||||||
|
- Fixed problems with smarty_mb_str_replace [#549](https://github.com/smarty-php/smarty/issues/549)
|
||||||
|
- Fixed second parameter of unescape modifier not working [#777](https://github.com/smarty-php/smarty/issues/777)
|
||||||
|
|
||||||
|
### Changed
|
||||||
|
- Updated HTML of the debug template [#599](https://github.com/smarty-php/smarty/pull/599)
|
||||||
|
|
||||||
|
## [4.1.1] - 2022-05-17
|
||||||
|
|
||||||
|
### Security
|
||||||
|
- Prevent PHP injection through malicious block name or include file name. This addresses CVE-2022-29221
|
||||||
|
|
||||||
|
### Fixed
|
||||||
|
- Exclude docs and demo from export and composer [#751](https://github.com/smarty-php/smarty/pull/751)
|
||||||
|
- PHP 8.1 deprecation notices in demo/plugins/cacheresource.pdo.php [#706](https://github.com/smarty-php/smarty/issues/706)
|
||||||
|
- PHP 8.1 deprecation notices in truncate modifier [#699](https://github.com/smarty-php/smarty/issues/699)
|
||||||
|
- Math equation `max(x, y)` didn't work anymore [#721](https://github.com/smarty-php/smarty/issues/721)
|
||||||
|
- Fix PHP 8.1 deprecated warning when calling rtrim [#743](https://github.com/smarty-php/smarty/pull/743)
|
||||||
|
- PHP 8.1: fix deprecation in escape modifier [#727](https://github.com/smarty-php/smarty/pull/727)
|
||||||
|
|
||||||
|
## [4.1.0] - 2022-02-06
|
||||||
|
|
||||||
|
### Added
|
||||||
|
- PHP8.1 compatibility [#713](https://github.com/smarty-php/smarty/pull/713)
|
||||||
|
|
||||||
|
## [4.0.4] - 2022-01-18
|
||||||
|
|
||||||
|
### Fixed
|
||||||
|
- Fixed illegal characters bug in math function security check [#702](https://github.com/smarty-php/smarty/issues/702)
|
||||||
|
|
||||||
|
## [4.0.3] - 2022-01-10
|
||||||
|
|
||||||
|
### Security
|
||||||
|
- Prevent evasion of the `static_classes` security policy. This addresses CVE-2021-21408
|
||||||
|
|
||||||
## [4.0.2] - 2022-01-10
|
## [4.0.2] - 2022-01-10
|
||||||
|
|
||||||
### Security
|
### Security
|
||||||
|
|||||||
@@ -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.
|
Read the [documentation](https://smarty-php.github.io/smarty/) to find out how to use it.
|
||||||
|
|
||||||
## Requirements
|
## Requirements
|
||||||
Smarty can be run with PHP 7.1 to PHP 8.0.
|
Smarty can be run with PHP 7.1 to PHP 8.2.
|
||||||
|
|
||||||
## Installation
|
## Installation
|
||||||
Smarty versions 3.1.11 or later can be installed with [Composer](https://getcomposer.org/).
|
Smarty versions 3.1.11 or later can be installed with [Composer](https://getcomposer.org/).
|
||||||
|
|||||||
+1
-1
@@ -2,7 +2,7 @@
|
|||||||
|
|
||||||
## Supported Versions
|
## Supported Versions
|
||||||
|
|
||||||
Smarty currently supports the latest minor version of Smarty 3 and Smarty 4. (Smarty 4 has not been released yet.)
|
Smarty currently supports the latest minor version of Smarty 3 and Smarty 4.
|
||||||
|
|
||||||
| Version | Supported |
|
| Version | Supported |
|
||||||
| ------- | ------------------ |
|
| ------- | ------------------ |
|
||||||
|
|||||||
@@ -196,7 +196,7 @@ class Smarty_CacheResource_Pdo extends Smarty_CacheResource_Custom
|
|||||||
* @return void
|
* @return void
|
||||||
* @access protected
|
* @access protected
|
||||||
*/
|
*/
|
||||||
protected function fetch($id, $name, $cache_id = null, $compile_id = null, &$content, &$mtime)
|
protected function fetch($id, $name, $cache_id, $compile_id, &$content, &$mtime)
|
||||||
{
|
{
|
||||||
$stmt = $this->getFetchStatement($this->fetchColumns, $id, $cache_id, $compile_id);
|
$stmt = $this->getFetchStatement($this->fetchColumns, $id, $cache_id, $compile_id);
|
||||||
$stmt->execute();
|
$stmt->execute();
|
||||||
@@ -244,7 +244,7 @@ class Smarty_CacheResource_Pdo extends Smarty_CacheResource_Custom
|
|||||||
* @return boolean success
|
* @return boolean success
|
||||||
* @access protected
|
* @access protected
|
||||||
*/
|
*/
|
||||||
protected function save($id, $name, $cache_id = null, $compile_id = null, $exp_time, $content)
|
protected function save($id, $name, $cache_id, $compile_id, $exp_time, $content)
|
||||||
{
|
{
|
||||||
$stmt = $this->pdo->prepare($this->insertStatement);
|
$stmt = $this->pdo->prepare($this->insertStatement);
|
||||||
$stmt->bindValue('id', $id);
|
$stmt->bindValue('id', $id);
|
||||||
|
|||||||
@@ -0,0 +1,45 @@
|
|||||||
|
version: "2"
|
||||||
|
services:
|
||||||
|
base:
|
||||||
|
build:
|
||||||
|
context: .
|
||||||
|
dockerfile: ./utilities/testrunners/php71/Dockerfile
|
||||||
|
volumes:
|
||||||
|
- .:/app
|
||||||
|
working_dir: /app
|
||||||
|
entrypoint: sh ./run-tests.sh
|
||||||
|
php71:
|
||||||
|
extends:
|
||||||
|
service: base
|
||||||
|
build:
|
||||||
|
dockerfile: ./utilities/testrunners/php71/Dockerfile
|
||||||
|
php72:
|
||||||
|
extends:
|
||||||
|
service: base
|
||||||
|
build:
|
||||||
|
dockerfile: ./utilities/testrunners/php72/Dockerfile
|
||||||
|
php73:
|
||||||
|
extends:
|
||||||
|
service: base
|
||||||
|
build:
|
||||||
|
dockerfile: ./utilities/testrunners/php73/Dockerfile
|
||||||
|
php74:
|
||||||
|
extends:
|
||||||
|
service: base
|
||||||
|
build:
|
||||||
|
dockerfile: ./utilities/testrunners/php74/Dockerfile
|
||||||
|
php80:
|
||||||
|
extends:
|
||||||
|
service: base
|
||||||
|
build:
|
||||||
|
dockerfile: ./utilities/testrunners/php80/Dockerfile
|
||||||
|
php81:
|
||||||
|
extends:
|
||||||
|
service: base
|
||||||
|
build:
|
||||||
|
dockerfile: ./utilities/testrunners/php81/Dockerfile
|
||||||
|
php82:
|
||||||
|
extends:
|
||||||
|
service: base
|
||||||
|
build:
|
||||||
|
dockerfile: ./utilities/testrunners/php82/Dockerfile
|
||||||
+2
-65
@@ -188,67 +188,6 @@ See also [`{html_select_date}`](#language.function.html.select.date),
|
|||||||
[`date_format`](#language.modifier.date.format) and
|
[`date_format`](#language.modifier.date.format) and
|
||||||
[`$smarty.now`](#language.variables.smarty.now),
|
[`$smarty.now`](#language.variables.smarty.now),
|
||||||
|
|
||||||
WAP/WML {#tips.wap}
|
|
||||||
=======
|
|
||||||
|
|
||||||
WAP/WML templates require a php [Content-Type
|
|
||||||
header](&url.php-manual;header) to be passed along with the template.
|
|
||||||
The easist way to do this would be to write a custom function that
|
|
||||||
prints the header. If you are using [caching](#caching), that won\'t
|
|
||||||
work so we\'ll do it using the [`{insert}`](#language.function.insert)
|
|
||||||
tag; remember `{insert}` tags are not cached! Be sure that there is
|
|
||||||
nothing output to the browser before the template, or else the header
|
|
||||||
may fail.
|
|
||||||
|
|
||||||
|
|
||||||
<?php
|
|
||||||
|
|
||||||
// be sure apache is configure for the .wml extensions!
|
|
||||||
// put this function somewhere in your application, or in Smarty.addons.php
|
|
||||||
function insert_header($params)
|
|
||||||
{
|
|
||||||
// this function expects $content argument
|
|
||||||
if (empty($params['content'])) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
header($params['content']);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
?>
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
your Smarty template *must* begin with the insert tag :
|
|
||||||
|
|
||||||
|
|
||||||
{insert name=header content="Content-Type: text/vnd.wap.wml"}
|
|
||||||
|
|
||||||
<?xml version="1.0"?>
|
|
||||||
<!DOCTYPE wml PUBLIC "-//WAPFORUM//DTD WML 1.1//EN" "http://www.wapforum.org/DTD/wml_1.1.xml">
|
|
||||||
|
|
||||||
<!-- begin new wml deck -->
|
|
||||||
<wml>
|
|
||||||
<!-- begin first card -->
|
|
||||||
<card>
|
|
||||||
<do type="accept">
|
|
||||||
<go href="#two"/>
|
|
||||||
</do>
|
|
||||||
<p>
|
|
||||||
Welcome to WAP with Smarty!
|
|
||||||
Press OK to continue...
|
|
||||||
</p>
|
|
||||||
</card>
|
|
||||||
<!-- begin second card -->
|
|
||||||
<card id="two">
|
|
||||||
<p>
|
|
||||||
Pretty easy isn't it?
|
|
||||||
</p>
|
|
||||||
</card>
|
|
||||||
</wml>
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
Componentized Templates {#tips.componentized.templates}
|
Componentized Templates {#tips.componentized.templates}
|
||||||
=======================
|
=======================
|
||||||
|
|
||||||
@@ -259,7 +198,7 @@ Smarty object, [`assign()`](#api.assign) the variables and
|
|||||||
[`display()`](#api.display) the template. So lets say for example we
|
[`display()`](#api.display) the template. So lets say for example we
|
||||||
have a stock ticker on our template. We would collect the stock data in
|
have a stock ticker on our template. We would collect the stock data in
|
||||||
our application, then assign these variables in the template and display
|
our application, then assign these variables in the template and display
|
||||||
it. Now wouldn\'t it be nice if you could add this stock ticker to any
|
it. Now wouldn't it be nice if you could add this stock ticker to any
|
||||||
application by merely including the template, and not worry about
|
application by merely including the template, and not worry about
|
||||||
fetching the data up front?
|
fetching the data up front?
|
||||||
|
|
||||||
@@ -301,9 +240,7 @@ assigning it to a template variable.
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
See also [`{include_php}`](#language.function.include.php),
|
See also: [`{include}`](#language.function.include).
|
||||||
[`{include}`](#language.function.include) and
|
|
||||||
[`{php}`](#language.function.php).
|
|
||||||
|
|
||||||
Obfuscating E-mail Addresses {#tips.obfuscating.email}
|
Obfuscating E-mail Addresses {#tips.obfuscating.email}
|
||||||
============================
|
============================
|
||||||
|
|||||||
@@ -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))
|
(using [set\_error\_handler()](&url.php-manual;set_error_handler))
|
||||||
which is not respecting the given `$errno` as it should. If, for
|
which is not respecting the given `$errno` as it should. If, for
|
||||||
whatever reason, this is the desired behaviour of your custom error
|
whatever reason, this is the desired behaviour of your custom error
|
||||||
|
|||||||
@@ -3,7 +3,7 @@ Attributes {#language.syntax.attributes}
|
|||||||
|
|
||||||
Most of the [functions](#language.syntax.functions) take attributes that
|
Most of the [functions](#language.syntax.functions) take attributes that
|
||||||
specify or modify their behavior. Attributes to Smarty functions are
|
specify or modify their behavior. Attributes to Smarty functions are
|
||||||
much like HTML attributes. Static values don\'t have to be enclosed in
|
much like HTML attributes. Static values don't have to be enclosed in
|
||||||
quotes, but it is required for literal strings. Variables with or
|
quotes, but it is required for literal strings. Variables with or
|
||||||
without modifiers may also be used, and should not be in quotes. You can
|
without modifiers may also be used, and should not be in quotes. You can
|
||||||
even use PHP function results, plugin results and complex expressions.
|
even use PHP function results, plugin results and complex expressions.
|
||||||
|
|||||||
@@ -16,7 +16,6 @@ Built-in Functions {#language.builtin.functions}
|
|||||||
- [{function}](./language-builtin-functions/language-function-function.md)
|
- [{function}](./language-builtin-functions/language-function-function.md)
|
||||||
- [{if},{elseif},{else}](./language-builtin-functions/language-function-if.md)
|
- [{if},{elseif},{else}](./language-builtin-functions/language-function-if.md)
|
||||||
- [{include}](./language-builtin-functions/language-function-include.md)
|
- [{include}](./language-builtin-functions/language-function-include.md)
|
||||||
- [{include_php}](./language-builtin-functions/language-function-include.php)
|
|
||||||
- [{insert}](./language-builtin-functions/language-function-insert.md)
|
- [{insert}](./language-builtin-functions/language-function-insert.md)
|
||||||
- [{ldelim},{rdelim}](./language-builtin-functions/language-function-ldelim.md)
|
- [{ldelim},{rdelim}](./language-builtin-functions/language-function-ldelim.md)
|
||||||
- [{literal}](./language-builtin-functions/language-function-literal.md)
|
- [{literal}](./language-builtin-functions/language-function-literal.md)
|
||||||
|
|||||||
@@ -135,7 +135,6 @@ The following functions can also *optionally* assign template variables.
|
|||||||
|
|
||||||
[`{capture}`](#language.function.capture),
|
[`{capture}`](#language.function.capture),
|
||||||
[`{include}`](#language.function.include),
|
[`{include}`](#language.function.include),
|
||||||
[`{include_php}`](#language.function.include.php),
|
|
||||||
[`{insert}`](#language.function.insert),
|
[`{insert}`](#language.function.insert),
|
||||||
[`{counter}`](#language.function.counter),
|
[`{counter}`](#language.function.counter),
|
||||||
[`{cycle}`](#language.function.cycle),
|
[`{cycle}`](#language.function.cycle),
|
||||||
|
|||||||
@@ -3,14 +3,14 @@
|
|||||||
|
|
||||||
`{block}` is used to define a named area of template source for template
|
`{block}` is used to define a named area of template source for template
|
||||||
inheritance. For details see section of [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
|
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
|
Optionally `{block}` areas of child and parent templates can be merged
|
||||||
into each other. You can append or prepend the parent `{block}` content
|
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
|
definition. With the {\$smarty.block.parent} the `{block}` content of
|
||||||
the parent template can be inserted at any location of the child
|
the parent template can be inserted at any location of the child
|
||||||
`{block}` content. {\$smarty.block.child} inserts the `{block}` content
|
`{block}` content. {\$smarty.block.child} inserts the `{block}` content
|
||||||
|
|||||||
@@ -3,7 +3,7 @@
|
|||||||
|
|
||||||
`{extends}` tags are used in child templates in template inheritance for
|
`{extends}` tags are used in child templates in template inheritance for
|
||||||
extending parent templates. For details see section of [Template
|
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.
|
- 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).
|
and [`{block}`](#language.function.block).
|
||||||
|
|||||||
@@ -2,7 +2,7 @@
|
|||||||
=====
|
=====
|
||||||
|
|
||||||
The `{for}{forelse}` tag is used to create simple loops. The following
|
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.
|
- `{for $var=$start to $end}` simple loop with step size of 1.
|
||||||
|
|
||||||
|
|||||||
@@ -1,74 +0,0 @@
|
|||||||
{include\_php} {#language.function.include.php}
|
|
||||||
==============
|
|
||||||
|
|
||||||
> **Note**
|
|
||||||
>
|
|
||||||
> `{include_php}` is deprecated from Smarty, use registered plugins to
|
|
||||||
> properly insulate presentation from the application code. As of Smarty
|
|
||||||
> 3.1 the `{include_php}` tags are only available from [SmartyBC](#bc).
|
|
||||||
|
|
||||||
Attribute Name Type Required Default Description
|
|
||||||
---------------- --------- ---------- --------- ----------------------------------------------------------------------------------
|
|
||||||
file string Yes *n/a* The name of the php file to include as absolute path
|
|
||||||
once boolean No *TRUE* whether or not to include the php file more than once if included multiple times
|
|
||||||
assign string No *n/a* The name of the variable that the output of include\_php will be assigned to
|
|
||||||
|
|
||||||
**Option Flags:**
|
|
||||||
|
|
||||||
Name Description
|
|
||||||
--------- ----------------------------------------
|
|
||||||
nocache Disables caching of inluded PHP script
|
|
||||||
|
|
||||||
`{include_php}` tags are used to include a php script in your template.
|
|
||||||
The path of the attribute `file` 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) section for
|
|
||||||
details.
|
|
||||||
|
|
||||||
By default, php files are only included once even if called multiple
|
|
||||||
times in the template. You can specify that it should be included every
|
|
||||||
time with the `once` attribute. Setting once to FALSE will include the
|
|
||||||
php script each time it is included in the template.
|
|
||||||
|
|
||||||
You can optionally pass the `assign` attribute, which will specify a
|
|
||||||
template variable name that the output of `{include_php}` will be
|
|
||||||
assigned to instead of displayed.
|
|
||||||
|
|
||||||
The smarty object is available as `$_smarty_tpl->smarty` within the PHP
|
|
||||||
script that you include.
|
|
||||||
|
|
||||||
The `load_nav.php` file:
|
|
||||||
|
|
||||||
|
|
||||||
<?php
|
|
||||||
|
|
||||||
// load in variables from a mysql db and assign them to the template
|
|
||||||
require_once('database.class.php');
|
|
||||||
$db = new Db();
|
|
||||||
$db->query('select url, name from navigation order by name');
|
|
||||||
$this->assign('navigation', $db->getRows());
|
|
||||||
|
|
||||||
?>
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
where the template is:
|
|
||||||
|
|
||||||
|
|
||||||
{* absolute path, or relative to $trusted_dir *}
|
|
||||||
{include_php file='/path/to/load_nav.php'}
|
|
||||||
{include_php '/path/to/load_nav.php'} {* short-hand *}
|
|
||||||
|
|
||||||
{foreach item='nav' from=$navigation}
|
|
||||||
<a href="{$nav.url}">{$nav.name}</a><br />
|
|
||||||
{/foreach}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
See also [`{include}`](#language.function.include),
|
|
||||||
[`$trusted_dir`](#variable.trusted.dir),
|
|
||||||
[`{php}`](#language.function.php),
|
|
||||||
[`{capture}`](#language.function.capture), [template
|
|
||||||
resources](#resources) and [componentized
|
|
||||||
templates](#tips.componentized.templates)
|
|
||||||
@@ -131,7 +131,7 @@ cache lifetime of 500 seconds.
|
|||||||
|
|
||||||
|
|
||||||
In this example included template will be cached independent of the
|
In this example included template will be cached independent of the
|
||||||
global cahing setting.
|
global caching setting.
|
||||||
|
|
||||||
|
|
||||||
{include 'sub_template.tpl' caching}
|
{include 'sub_template.tpl' caching}
|
||||||
@@ -188,7 +188,5 @@ current template.
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
See also [`{include_php}`](#language.function.include.php),
|
See also [`{insert}`](#language.function.insert), [template resources](#resources) and
|
||||||
[`{insert}`](#language.function.insert),
|
|
||||||
[`{php}`](#language.function.php), [template resources](#resources) and
|
|
||||||
[componentized templates](#tips.componentized.templates).
|
[componentized templates](#tips.componentized.templates).
|
||||||
|
|||||||
@@ -65,7 +65,7 @@ and display the returned results in place of the {insert} tag.
|
|||||||
The path can be either absolute, or relative to
|
The path can be either absolute, or relative to
|
||||||
[`$trusted_dir`](#variable.trusted.dir). If security is enabled,
|
[`$trusted_dir`](#variable.trusted.dir). If security is enabled,
|
||||||
then the script must be located in the `$trusted_dir` path of the
|
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.
|
section for details.
|
||||||
|
|
||||||
The Smarty object is passed as the second argument. This way you can
|
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 can be nested as deep as you like. With nested
|
||||||
{section}\'s, you can access complex data structures, such as
|
{section}\'s, you can access complex data structures, such as
|
||||||
multi-dimensional arrays. This is an example `.php` script thats
|
multi-dimensional arrays. This is an example `.php` script that
|
||||||
assign\'s the arrays.
|
assigns the arrays.
|
||||||
|
|
||||||
|
|
||||||
<?php
|
<?php
|
||||||
|
|||||||
@@ -10,7 +10,7 @@ The filter can be:
|
|||||||
|
|
||||||
- A variable filter plugin specified by it\'s name.
|
- 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.
|
parameter.
|
||||||
|
|
||||||
`{setfilter}...{/setfilter}` blocks can be nested. The filter definition
|
`{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
|
> If security is enabled and you are fetching a file from the local
|
||||||
> file system, `{fetch}` will only allow files from within the
|
> 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.
|
> [Security](#advanced.features.security) section for details.
|
||||||
|
|
||||||
- If the `assign` attribute is set, the output of the `{fetch}`
|
- 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
|
from. If not given, the web server\'s document root
|
||||||
`$_ENV['DOCUMENT_ROOT']` is used as the base. If security is
|
`$_ENV['DOCUMENT_ROOT']` is used as the base. If security is
|
||||||
enabled, then the image must be located in the `$secure_dir` path of
|
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.
|
section for details.
|
||||||
|
|
||||||
- `href` is the href value to link the image to. If link is supplied,
|
- `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
|
- Secondly - if security is enabled, all php-functions that are to
|
||||||
be used as modifiers have to be declared trusted in the
|
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.
|
[Security](../programmers/advanced-features/advanced-features-security.md) section for details.
|
||||||
|
|
||||||
See also [`registerPlugin()`](../programmers/api-functions/api-register-plugin.md), [combining
|
See also [`registerPlugin()`](../programmers/api-functions/api-register-plugin.md), [combining
|
||||||
|
|||||||
@@ -15,5 +15,5 @@ modifier](#language.modifier.to_charset).
|
|||||||
> modifier should only be used in cases where the application cannot
|
> modifier should only be used in cases where the application cannot
|
||||||
> anticipate that a certain string is required in another encoding.
|
> 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).
|
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
|
> modifier should only be used in cases where the application cannot
|
||||||
> anticipate that a certain string is required in another encoding.
|
> 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).
|
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
|
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}
|
{\$smarty.block.parent} {#language.variables.smarty.block.parent}
|
||||||
-----------------------
|
-----------------------
|
||||||
|
|
||||||
Returns block text from parent template. See [Template
|
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}
|
{\$smarty.ldelim}, {\$smarty.rdelim} {#language.variables.smarty.ldelim}
|
||||||
------------------------------------
|
------------------------------------
|
||||||
|
|||||||
@@ -2,7 +2,7 @@ What is Smarty?
|
|||||||
==============
|
==============
|
||||||
|
|
||||||
## Requirements
|
## Requirements
|
||||||
Smarty can be run with PHP 7.1 to PHP 8.0.
|
Smarty can be run with PHP 7.1 to PHP 8.2.
|
||||||
|
|
||||||
## Installation
|
## Installation
|
||||||
Smarty versions 3.1.11 or later can be installed with [Composer](https://getcomposer.org/).
|
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.
|
keep template syntax to a minimum.
|
||||||
|
|
||||||
If security is enabled, no private methods or functions can be accessed
|
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.
|
the method will be used.
|
||||||
|
|
||||||
You can restrict the methods and properties that can be accessed by
|
You can restrict the methods and properties that can be accessed by
|
||||||
|
|||||||
@@ -2,36 +2,20 @@ Security {#advanced.features.security}
|
|||||||
========
|
========
|
||||||
|
|
||||||
Security is good for situations when you have untrusted parties editing
|
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.
|
security compromises through the template language.
|
||||||
|
|
||||||
The settings of the security policy are defined by properties of an
|
The settings of the security policy are defined by properties of an
|
||||||
instance of the Smarty\_Security class. These are the possible settings:
|
instance of the Smarty\_Security class. These are the possible settings:
|
||||||
|
|
||||||
- `$php_handling` determines how Smarty to handle PHP code embedded in
|
|
||||||
templates. Possible values are:
|
|
||||||
|
|
||||||
- Smarty::PHP\_PASSTHRU -\> echo PHP tags as they are
|
|
||||||
|
|
||||||
- Smarty::PHP\_QUOTE -\> escape tags as entities
|
|
||||||
|
|
||||||
- Smarty::PHP\_REMOVE -\> remove php tags
|
|
||||||
|
|
||||||
- Smarty::PHP\_ALLOW -\> execute php tags
|
|
||||||
|
|
||||||
The default value is Smarty::PHP\_PASSTHRU.
|
|
||||||
|
|
||||||
If security is enabled the [`$php_handling`](#variable.php.handling)
|
|
||||||
setting of the Smarty object is not checked for security.
|
|
||||||
|
|
||||||
- `$secure_dir` is an array of template directories that are
|
- `$secure_dir` is an array of template directories that are
|
||||||
considered secure. [`$template_dir`](#variable.template.dir)
|
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_dir` is an array of all directories that are considered
|
||||||
trusted. Trusted directories are where you keep php scripts that are
|
trusted. Trusted directories are where you keep php scripts that are
|
||||||
executed directly from the templates with
|
executed directly from the templates with
|
||||||
[`{include_php}`](#language.function.include.php). The default is an
|
[`{insert}`](#language.function.insert.php). The default is an
|
||||||
empty array.
|
empty array.
|
||||||
|
|
||||||
- `$trusted_uri` is an array of regular expressions matching URIs that
|
- `$trusted_uri` is an array of regular expressions matching URIs that
|
||||||
@@ -43,7 +27,7 @@ instance of the Smarty\_Security class. These are the possible settings:
|
|||||||
like authentication-tokens).
|
like authentication-tokens).
|
||||||
|
|
||||||
The expression `'#https?://.*smarty.net$#i'` would allow accessing
|
The expression `'#https?://.*smarty.net$#i'` would allow accessing
|
||||||
the follwing URIs:
|
the following URIs:
|
||||||
|
|
||||||
- `http://smarty.net/foo`
|
- `http://smarty.net/foo`
|
||||||
|
|
||||||
@@ -110,12 +94,8 @@ instance of the Smarty\_Security class. These are the possible settings:
|
|||||||
super globals can be accessed by the template. The default is
|
super globals can be accessed by the template. The default is
|
||||||
\"true\".
|
\"true\".
|
||||||
|
|
||||||
- `$allow_php_tag` is a boolean flag which controls if {php} and
|
|
||||||
{include\_php} tags can be used by the template. The default is
|
|
||||||
\"false\".
|
|
||||||
|
|
||||||
If security is enabled, no private methods, functions or properties of
|
If security is enabled, no private methods, functions or properties of
|
||||||
static classes or assigned objects can be accessed (beginningwith
|
static classes or assigned objects can be accessed (beginning with
|
||||||
\'\_\') by the template.
|
\'\_\') by the template.
|
||||||
|
|
||||||
To customize the security policy settings you can extend the
|
To customize the security policy settings you can extend the
|
||||||
@@ -128,8 +108,6 @@ Smarty\_Security class or create an instance of it.
|
|||||||
class My_Security_Policy extends Smarty_Security {
|
class My_Security_Policy extends Smarty_Security {
|
||||||
// disable all PHP functions
|
// disable all PHP functions
|
||||||
public $php_functions = null;
|
public $php_functions = null;
|
||||||
// remove PHP tags
|
|
||||||
public $php_handling = Smarty::PHP_REMOVE;
|
|
||||||
// allow everthing as modifier
|
// allow everthing as modifier
|
||||||
public $php_modifiers = array();
|
public $php_modifiers = array();
|
||||||
}
|
}
|
||||||
@@ -145,8 +123,6 @@ Smarty\_Security class or create an instance of it.
|
|||||||
$my_security_policy = new Smarty_Security($smarty);
|
$my_security_policy = new Smarty_Security($smarty);
|
||||||
// disable all PHP functions
|
// disable all PHP functions
|
||||||
$my_security_policy->php_functions = null;
|
$my_security_policy->php_functions = null;
|
||||||
// remove PHP tags
|
|
||||||
$my_security_policy->php_handling = Smarty::PHP_REMOVE;
|
|
||||||
// allow everthing as modifier
|
// allow everthing as modifier
|
||||||
$my_security_policy->php_modifiers = array();
|
$my_security_policy->php_modifiers = array();
|
||||||
// enable security
|
// enable security
|
||||||
@@ -164,5 +140,5 @@ Smarty\_Security class or create an instance of it.
|
|||||||
> **Note**
|
> **Note**
|
||||||
>
|
>
|
||||||
> Most security policy settings are only checked when the template gets
|
> 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.
|
> 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
|
you can define the whole template inheritance tree in the PHP script
|
||||||
when you are calling [`fetch()`](#api.fetch) or
|
when you are calling [`fetch()`](#api.fetch) or
|
||||||
[`display()`](#api.display) with the `extends:` template resource
|
[`display()`](#api.display) with the `extends:` template resource
|
||||||
type. The later provides even more flexibillity.
|
type. The later provides even more flexibility.
|
||||||
|
|
||||||
> **Note**
|
> **Note**
|
||||||
>
|
>
|
||||||
|
|||||||
@@ -8,7 +8,7 @@ Modifications done to the Smarty object will be global for all
|
|||||||
templates.
|
templates.
|
||||||
|
|
||||||
However the Smarty class variables and functions can be accessed or
|
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.
|
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.
|
variables assigned to any of the objects in it\'s parent chain.
|
||||||
|
|
||||||
Data objects are used to create scopes for assigned variables. They can
|
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
|
<?php
|
||||||
|
|||||||
@@ -9,7 +9,7 @@ string
|
|||||||
|
|
||||||
disableSecurity
|
disableSecurity
|
||||||
|
|
||||||
This disables securty checking on templates.
|
This disables security checking on templates.
|
||||||
|
|
||||||
See also [`enableSecurity()`](#api.enable.security), and
|
See also [`enableSecurity()`](#api.enable.security), and
|
||||||
[Security](#advanced.features.security).
|
[Security](#advanced.features.security).
|
||||||
|
|||||||
@@ -25,7 +25,7 @@ string
|
|||||||
|
|
||||||
enableSecurity
|
enableSecurity
|
||||||
|
|
||||||
This enables securty checking on templates. It uses the following
|
This enables security checking on templates. It uses the following
|
||||||
parameters:
|
parameters:
|
||||||
|
|
||||||
- `securityclass` is an optional parameter. It\'s the name of the
|
- `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.
|
passed on to the next error handler.
|
||||||
|
|
||||||
`Smarty::unmuteExpectedErrors()` removes the current 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
|
the muteExpectedErrors() call, the unmute will not remove Smarty\'s
|
||||||
muting error handler, but the one registered last.
|
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:
|
parameters:
|
||||||
|
|
||||||
If during compilation Smarty encounters tag which is not defined
|
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
|
resolve it by calling the registered default plugin handler. The handler
|
||||||
may be called several times for same undefined tag looping over valid
|
may be called several times for same undefined tag looping over valid
|
||||||
plugin types.
|
plugin types.
|
||||||
|
|||||||
@@ -10,7 +10,7 @@ void
|
|||||||
testInstall
|
testInstall
|
||||||
|
|
||||||
This function verifies that all required working folders of the Smarty
|
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
|
<?php
|
||||||
|
|||||||
@@ -39,7 +39,6 @@ them directly, or use the corresponding setter/getter methods.
|
|||||||
- [$left_delimiter](./api-variables/variable-left-delimiter.md)
|
- [$left_delimiter](./api-variables/variable-left-delimiter.md)
|
||||||
- [$locking_timeout](./api-variables/variable-locking-timeout.md)
|
- [$locking_timeout](./api-variables/variable-locking-timeout.md)
|
||||||
- [$merge_compiled_includes](./api-variables/variable-merge-compiled-includes.md)
|
- [$merge_compiled_includes](./api-variables/variable-merge-compiled-includes.md)
|
||||||
- [$php_handling](./api-variables/variable-php-handling.md)
|
|
||||||
- [$plugins_dir](./api-variables/variable-plugins-dir.md)
|
- [$plugins_dir](./api-variables/variable-plugins-dir.md)
|
||||||
- [$right_delimiter](./api-variables/variable-right-delimiter.md)
|
- [$right_delimiter](./api-variables/variable-right-delimiter.md)
|
||||||
- [$smarty_debug_id](./api-variables/variable-smarty-debug-id.md)
|
- [$smarty_debug_id](./api-variables/variable-smarty-debug-id.md)
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
\$compile\_id {#variable.compile.id}
|
\$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` to each and every function call, you can set this
|
||||||
`$compile_id` and it will be used implicitly thereafter.
|
`$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.
|
`$compile_id` to keep the compiled template files separated.
|
||||||
|
|
||||||
For example a [prefilter](#plugins.prefilters.postfilters) that
|
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
|
at compile time, then you could use the current language as
|
||||||
`$compile_id` and you will get a set of compiled templates for each
|
`$compile_id` and you will get a set of compiled templates for each
|
||||||
language you use.
|
language you use.
|
||||||
|
|||||||
@@ -3,7 +3,7 @@
|
|||||||
|
|
||||||
Setting `$escape_html` to TRUE will escape all template variable output
|
Setting `$escape_html` to TRUE will escape all template variable output
|
||||||
by wrapping it in
|
by wrapping it in
|
||||||
`htmlspecialchars({$output}, ENT_QUOTES, SMARTY_RESOURCE_CHAR_SET);`,
|
`htmlspecialchars({$output}, ENT_QUOTES, $char_set);`,
|
||||||
which is the same as `{$variable|escape:"html"}`.
|
which is the same as `{$variable|escape:"html"}`.
|
||||||
|
|
||||||
Template designers can choose to selectively disable this feature by
|
Template designers can choose to selectively disable this feature by
|
||||||
|
|||||||
@@ -2,6 +2,6 @@
|
|||||||
==================
|
==================
|
||||||
|
|
||||||
This is maximum time in seconds a cache lock is valid to avoid dead
|
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)
|
See also [`$cache_locking`](#variable.cache.locking)
|
||||||
|
|||||||
@@ -1,21 +0,0 @@
|
|||||||
\$php\_handling {#variable.php.handling}
|
|
||||||
===============
|
|
||||||
|
|
||||||
This tells Smarty how to handle PHP code embedded in the templates.
|
|
||||||
There are four possible settings, the default being
|
|
||||||
`Smarty::PHP_PASSTHRU`. Note that this does NOT affect php code within
|
|
||||||
[`{php}{/php}`](#language.function.php) tags in the template.
|
|
||||||
|
|
||||||
- `Smarty::PHP_PASSTHRU` - Smarty echos tags as-is.
|
|
||||||
|
|
||||||
- `Smarty::PHP_QUOTE` - Smarty quotes the tags as html entities.
|
|
||||||
|
|
||||||
- `Smarty::PHP_REMOVE` - Smarty removes the tags from the templates.
|
|
||||||
|
|
||||||
- `Smarty::PHP_ALLOW` - Smarty will execute the tags as PHP code.
|
|
||||||
|
|
||||||
> **Note**
|
|
||||||
>
|
|
||||||
> Embedding PHP code into templates is highly discouraged. Use [custom
|
|
||||||
> functions](#plugins.functions) or [modifiers](#plugins.modifiers)
|
|
||||||
> instead.
|
|
||||||
@@ -5,4 +5,4 @@
|
|||||||
array of all directories that are considered trusted. Trusted
|
array of all directories that are considered trusted. Trusted
|
||||||
directories are where you keep php scripts that are executed directly
|
directories are where you keep php scripts that are executed directly
|
||||||
from the templates with
|
from the templates with
|
||||||
[`{include_php}`](#language.function.include.php).
|
[`{insert}`](#language.function.insert.php).
|
||||||
|
|||||||
@@ -10,7 +10,7 @@ environments do not allow PHP processes to create directories, so this
|
|||||||
must be disabled which is the default.
|
must be disabled which is the default.
|
||||||
|
|
||||||
Sub directories are more efficient, so use them if you can.
|
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
|
directories each having 100 files, than with 1 directory having 1000
|
||||||
files. This was certainly the case with Solaris 7 (UFS)\... with newer
|
files. This was certainly the case with Solaris 7 (UFS)\... with newer
|
||||||
filesystems such as ext3 and especially reiserfs, the difference is
|
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
|
- You CANNOT remove a specified template name under multiple cache
|
||||||
groups such as `'/a/b/*/foo.tpl'`, the cache grouping works
|
groups such as `'/a/b/*/foo.tpl'`, the cache grouping works
|
||||||
left-to-right ONLY. You will need to group your templates under a
|
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
|
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
|
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
|
`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
|
files for the "blue" theme, you will need to create a cache group
|
||||||
|
|||||||
@@ -5,17 +5,17 @@ Charset Encoding {#charset.encoding}
|
|||||||
================
|
================
|
||||||
|
|
||||||
There are a variety of encodings for textual data, ISO-8859-1 (Latin1)
|
There are a variety of encodings for textual data, ISO-8859-1 (Latin1)
|
||||||
and UTF-8 being the most popular. Unless specified otherwise with the
|
and UTF-8 being the most popular. Unless you change `Smarty::$_CHARSET`,
|
||||||
`SMARTY_RESOURCE_CHAR_SET` constant, Smarty recognizes `UTF-8` as the
|
Smarty recognizes `UTF-8` as the internal charset if
|
||||||
internal charset if [Multibyte String](https://www.php.net/mbstring) is
|
[Multibyte String](https://www.php.net/mbstring) is available,
|
||||||
available, `ISO-8859-1` if not.
|
`ISO-8859-1` if not.
|
||||||
|
|
||||||
> **Note**
|
> **Note**
|
||||||
>
|
>
|
||||||
> `ISO-8859-1` has been PHP\'s default internal charset since the
|
> `ISO-8859-1` has been PHP\'s default internal charset since the
|
||||||
> beginning. Unicode has been evolving since 1991. Since then it has
|
> beginning. Unicode has been evolving since 1991. Since then it has
|
||||||
> become the one charset to conquer them all, as it is capable of
|
> 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
|
> systems (latin, cyrillic, japanese, ...). `UTF-8` is unicode\'s most
|
||||||
> used encoding, as it allows referencing the thousands of character
|
> used encoding, as it allows referencing the thousands of character
|
||||||
> with the smallest size overhead possible.
|
> with the smallest size overhead possible.
|
||||||
@@ -36,8 +36,9 @@ available, `ISO-8859-1` if not.
|
|||||||
if (function_exists('mb_internal_charset')) {
|
if (function_exists('mb_internal_charset')) {
|
||||||
mb_internal_charset('EUC-JP');
|
mb_internal_charset('EUC-JP');
|
||||||
}
|
}
|
||||||
define('SMARTY_RESOURCE_CHAR_SET', 'EUC-JP');
|
|
||||||
require_once 'libs/Smarty.class.php';
|
require_once 'libs/Smarty.class.php';
|
||||||
|
Smarty::$_CHARSET = 'EUC-JP';
|
||||||
$smarty = new Smarty();
|
$smarty = new Smarty();
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -3,20 +3,20 @@ Extends Template Resources {#resources.extends}
|
|||||||
|
|
||||||
The `extends:` resource is used to define child/parent relationships for
|
The `extends:` resource is used to define child/parent relationships for
|
||||||
template inheritance from the PHP script. For details see section of
|
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
|
As of Smarty 3.1 the `extends:` resource may use any available [template
|
||||||
resource](#resources), including `string:` and `eval:`. When [templates
|
resource](#resources), including `string:` and `eval:`. When [templates
|
||||||
from strings](#resources.string) are used, make sure they are properly
|
from strings](#resources.string) are used, make sure they are properly
|
||||||
(url or base64) encoded. Is an `eval:` resource found within an
|
(url or base64) encoded. Is an `eval:` resource found within an
|
||||||
inheritance chain, its \"don\'t save a compile file\" property is
|
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
|
inheritance chain are not compiled separately, though. Only a single
|
||||||
compiled template will be generated.
|
compiled template will be generated.
|
||||||
|
|
||||||
> **Note**
|
> **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
|
> 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
|
> took place. If you have a choice, it is normally more flexible and
|
||||||
> intuitive to handle inheritance chains from within the templates.
|
> 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
|
Smarty 3.1 introduced the bracket-syntax for specifying an element from
|
||||||
[`$template_dir`](#variable.template.dir). This allows websites
|
[`$template_dir`](#variable.template.dir). This allows websites
|
||||||
employing multiple sets of templates better control over which template
|
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:`
|
The bracket-syntax can be used from anywhere you can specify the `file:`
|
||||||
resource type.
|
resource type.
|
||||||
|
|||||||
@@ -23,5 +23,4 @@ to determine the appropriate value automatically. If defined, the path
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
See also [`$smarty.const`](../designers/language-variables/language-variables-smarty.md) and
|
See also [`$smarty.const`](../designers/language-variables/language-variables-smarty.md).
|
||||||
[`$php_handling constants`](./api-variables/variable-php-handling.md)
|
|
||||||
|
|||||||
@@ -161,7 +161,6 @@ class Smarty_Internal_Templatelexer
|
|||||||
'COMMENT' => 'comment',
|
'COMMENT' => 'comment',
|
||||||
'AS' => 'as',
|
'AS' => 'as',
|
||||||
'TO' => 'to',
|
'TO' => 'to',
|
||||||
'PHP' => '"<?php", "<%", "{php}" tag',
|
|
||||||
'LOGOP' => '"<", "==" ... logical operator',
|
'LOGOP' => '"<", "==" ... logical operator',
|
||||||
'TLOGOP' => '"lt", "eq" ... logical operator; "is div by" ... if condition',
|
'TLOGOP' => '"lt", "eq" ... logical operator; "is div by" ... if condition',
|
||||||
'SCOND' => '"is even" ... if condition',
|
'SCOND' => '"is even" ... if condition',
|
||||||
|
|||||||
@@ -747,6 +747,9 @@ value(res) ::= doublequoted_with_quotes(s). {
|
|||||||
|
|
||||||
|
|
||||||
value(res) ::= varindexed(vi) DOUBLECOLON static_class_access(r). {
|
value(res) ::= varindexed(vi) DOUBLECOLON static_class_access(r). {
|
||||||
|
if ($this->security && $this->security->static_classes !== array()) {
|
||||||
|
$this->compiler->trigger_template_error('dynamic static class not allowed by security setting');
|
||||||
|
}
|
||||||
$prefixVar = $this->compiler->getNewPrefixVariable();
|
$prefixVar = $this->compiler->getNewPrefixVariable();
|
||||||
if (vi['var'] === '\'smarty\'') {
|
if (vi['var'] === '\'smarty\'') {
|
||||||
$this->compiler->appendPrefixCode("<?php {$prefixVar} = ". $this->compiler->compileTag('private_special_variable',array(),vi['smarty_internal_index']).';?>');
|
$this->compiler->appendPrefixCode("<?php {$prefixVar} = ". $this->compiler->compileTag('private_special_variable',array(),vi['smarty_internal_index']).';?>');
|
||||||
|
|||||||
+7
-27
@@ -5,6 +5,11 @@
|
|||||||
* @package Smarty
|
* @package Smarty
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
if (!defined('SMARTY_HELPER_FUNCTIONS_LOADED')) {
|
||||||
|
include __DIR__ . '/functions.php';
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Smarty Autoloader
|
* Smarty Autoloader
|
||||||
*
|
*
|
||||||
@@ -41,31 +46,6 @@ class Smarty_Autoloader
|
|||||||
*/
|
*/
|
||||||
public static $rootClasses = array('smarty' => 'Smarty.class.php');
|
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.
|
* Registers Smarty_Autoloader as an SPL autoloader.
|
||||||
*
|
*
|
||||||
@@ -73,7 +53,7 @@ class Smarty_Autoloader
|
|||||||
*/
|
*/
|
||||||
public static function register($prepend = false)
|
public static function register($prepend = false)
|
||||||
{
|
{
|
||||||
self::$SMARTY_DIR = defined('SMARTY_DIR') ? SMARTY_DIR : dirname(__FILE__) . DIRECTORY_SEPARATOR;
|
self::$SMARTY_DIR = defined('SMARTY_DIR') ? SMARTY_DIR : __DIR__ . DIRECTORY_SEPARATOR;
|
||||||
self::$SMARTY_SYSPLUGINS_DIR = defined('SMARTY_SYSPLUGINS_DIR') ? SMARTY_SYSPLUGINS_DIR :
|
self::$SMARTY_SYSPLUGINS_DIR = defined('SMARTY_SYSPLUGINS_DIR') ? SMARTY_SYSPLUGINS_DIR :
|
||||||
self::$SMARTY_DIR . 'sysplugins' . DIRECTORY_SEPARATOR;
|
self::$SMARTY_DIR . 'sysplugins' . DIRECTORY_SEPARATOR;
|
||||||
spl_autoload_register(array(__CLASS__, 'autoload'), true, $prepend);
|
spl_autoload_register(array(__CLASS__, 'autoload'), true, $prepend);
|
||||||
@@ -89,7 +69,7 @@ class Smarty_Autoloader
|
|||||||
if ($class[ 0 ] !== 'S' || strpos($class, 'Smarty') !== 0) {
|
if ($class[ 0 ] !== 'S' || strpos($class, 'Smarty') !== 0) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
$_class = strtolower($class);
|
$_class = smarty_strtolower_ascii($class);
|
||||||
if (isset(self::$rootClasses[ $_class ])) {
|
if (isset(self::$rootClasses[ $_class ])) {
|
||||||
$file = self::$SMARTY_DIR . self::$rootClasses[ $_class ];
|
$file = self::$SMARTY_DIR . self::$rootClasses[ $_class ];
|
||||||
if (is_file($file)) {
|
if (is_file($file)) {
|
||||||
|
|||||||
+16
-8
@@ -36,7 +36,7 @@ if (!defined('SMARTY_DIR')) {
|
|||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
define('SMARTY_DIR', dirname(__FILE__) . DIRECTORY_SEPARATOR);
|
define('SMARTY_DIR', __DIR__ . DIRECTORY_SEPARATOR);
|
||||||
}
|
}
|
||||||
/**
|
/**
|
||||||
* set SMARTY_SYSPLUGINS_DIR to absolute path to Smarty internal plugins.
|
* set SMARTY_SYSPLUGINS_DIR to absolute path to Smarty internal plugins.
|
||||||
@@ -60,12 +60,21 @@ if (!defined('SMARTY_MBSTRING')) {
|
|||||||
*/
|
*/
|
||||||
define('SMARTY_MBSTRING', function_exists('mb_get_info'));
|
define('SMARTY_MBSTRING', function_exists('mb_get_info'));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Load helper functions
|
||||||
|
*/
|
||||||
|
if (!defined('SMARTY_HELPER_FUNCTIONS_LOADED')) {
|
||||||
|
include __DIR__ . '/functions.php';
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Load Smarty_Autoloader
|
* Load Smarty_Autoloader
|
||||||
*/
|
*/
|
||||||
if (!class_exists('Smarty_Autoloader')) {
|
if (!class_exists('Smarty_Autoloader')) {
|
||||||
include dirname(__FILE__) . '/bootstrap.php';
|
include __DIR__ . '/bootstrap.php';
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Load always needed external class files
|
* Load always needed external class files
|
||||||
*/
|
*/
|
||||||
@@ -98,7 +107,7 @@ class Smarty extends Smarty_Internal_TemplateBase
|
|||||||
/**
|
/**
|
||||||
* smarty version
|
* smarty version
|
||||||
*/
|
*/
|
||||||
const SMARTY_VERSION = '4.0.2';
|
const SMARTY_VERSION = '4.2.1';
|
||||||
/**
|
/**
|
||||||
* define variable scopes
|
* define variable scopes
|
||||||
*/
|
*/
|
||||||
@@ -130,7 +139,6 @@ class Smarty extends Smarty_Internal_TemplateBase
|
|||||||
const DEBUG_OFF = 0;
|
const DEBUG_OFF = 0;
|
||||||
const DEBUG_ON = 1;
|
const DEBUG_ON = 1;
|
||||||
const DEBUG_INDIVIDUAL = 2;
|
const DEBUG_INDIVIDUAL = 2;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* filter types
|
* filter types
|
||||||
*/
|
*/
|
||||||
@@ -771,7 +779,7 @@ class Smarty extends Smarty_Internal_TemplateBase
|
|||||||
$this->_normalizeTemplateConfig($isConfig);
|
$this->_normalizeTemplateConfig($isConfig);
|
||||||
}
|
}
|
||||||
if ($index !== null) {
|
if ($index !== null) {
|
||||||
return isset($dir[ $index ]) ? $dir[ $index ] : null;
|
return ($dir[ $index ] ?? null);
|
||||||
}
|
}
|
||||||
return $dir;
|
return $dir;
|
||||||
}
|
}
|
||||||
@@ -867,7 +875,7 @@ class Smarty extends Smarty_Internal_TemplateBase
|
|||||||
$this->plugins_dir = (array)$this->plugins_dir;
|
$this->plugins_dir = (array)$this->plugins_dir;
|
||||||
}
|
}
|
||||||
foreach ($this->plugins_dir as $k => $v) {
|
foreach ($this->plugins_dir as $k => $v) {
|
||||||
$this->plugins_dir[ $k ] = $this->_realpath(rtrim($v, '/\\') . DIRECTORY_SEPARATOR, true);
|
$this->plugins_dir[ $k ] = $this->_realpath(rtrim($v ?? '', '/\\') . DIRECTORY_SEPARATOR, true);
|
||||||
}
|
}
|
||||||
$this->_cache[ 'plugin_files' ] = array();
|
$this->_cache[ 'plugin_files' ] = array();
|
||||||
$this->_pluginsDirNormalized = true;
|
$this->_pluginsDirNormalized = true;
|
||||||
@@ -1345,7 +1353,7 @@ class Smarty extends Smarty_Internal_TemplateBase
|
|||||||
*/
|
*/
|
||||||
private function _normalizeDir($dirName, $dir)
|
private function _normalizeDir($dirName, $dir)
|
||||||
{
|
{
|
||||||
$this->{$dirName} = $this->_realpath(rtrim($dir, "/\\") . DIRECTORY_SEPARATOR, true);
|
$this->{$dirName} = $this->_realpath(rtrim($dir ?? '', "/\\") . DIRECTORY_SEPARATOR, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -1367,7 +1375,7 @@ class Smarty extends Smarty_Internal_TemplateBase
|
|||||||
}
|
}
|
||||||
foreach ($dir as $k => $v) {
|
foreach ($dir as $k => $v) {
|
||||||
if (!isset($processed[ $k ])) {
|
if (!isset($processed[ $k ])) {
|
||||||
$dir[ $k ] = $v = $this->_realpath(rtrim($v, "/\\") . DIRECTORY_SEPARATOR, true);
|
$dir[ $k ] = $v = $this->_realpath(rtrim($v ?? '', "/\\") . DIRECTORY_SEPARATOR, true);
|
||||||
$processed[ $k ] = true;
|
$processed[ $k ] = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
+1
-1
@@ -11,6 +11,6 @@
|
|||||||
* Load and register Smarty Autoloader
|
* Load and register Smarty Autoloader
|
||||||
*/
|
*/
|
||||||
if (!class_exists('Smarty_Autoloader')) {
|
if (!class_exists('Smarty_Autoloader')) {
|
||||||
include dirname(__FILE__) . '/Autoloader.php';
|
include __DIR__ . '/Autoloader.php';
|
||||||
}
|
}
|
||||||
Smarty_Autoloader::register(true);
|
Smarty_Autoloader::register(true);
|
||||||
|
|||||||
+37
-32
@@ -1,9 +1,9 @@
|
|||||||
{capture name='_smarty_debug' assign=debug_output}
|
{capture name='_smarty_debug' assign=debug_output}
|
||||||
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
|
<!DOCTYPE html>
|
||||||
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en">
|
<html lang="en">
|
||||||
<head>
|
<head>
|
||||||
<title>Smarty Debug Console</title>
|
<title>Smarty Debug Console</title>
|
||||||
<style type="text/css">
|
<style>
|
||||||
{literal}
|
{literal}
|
||||||
body, h1, h2, h3, td, th, p {
|
body, h1, h2, h3, td, th, p {
|
||||||
font-family: sans-serif;
|
font-family: sans-serif;
|
||||||
@@ -12,7 +12,6 @@
|
|||||||
margin: 1px;
|
margin: 1px;
|
||||||
padding: 0;
|
padding: 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
h1 {
|
h1 {
|
||||||
margin: 0;
|
margin: 0;
|
||||||
text-align: left;
|
text-align: left;
|
||||||
@@ -22,7 +21,6 @@
|
|||||||
font-weight: bold;
|
font-weight: bold;
|
||||||
font-size: 1.2em;
|
font-size: 1.2em;
|
||||||
}
|
}
|
||||||
|
|
||||||
h2 {
|
h2 {
|
||||||
background-color: #9B410E;
|
background-color: #9B410E;
|
||||||
color: white;
|
color: white;
|
||||||
@@ -38,48 +36,38 @@
|
|||||||
font-size: 0.7em;
|
font-size: 0.7em;
|
||||||
padding: 2px;
|
padding: 2px;
|
||||||
}
|
}
|
||||||
|
|
||||||
body {
|
body {
|
||||||
background: black;
|
background: black;
|
||||||
}
|
}
|
||||||
|
|
||||||
p, table, div {
|
p, table, div {
|
||||||
background: #f0ead8;
|
background: #f0ead8;
|
||||||
}
|
}
|
||||||
|
|
||||||
p {
|
p {
|
||||||
margin: 0;
|
margin: 0;
|
||||||
font-style: italic;
|
font-style: italic;
|
||||||
text-align: center;
|
text-align: center;
|
||||||
}
|
}
|
||||||
|
|
||||||
table {
|
table {
|
||||||
width: 100%;
|
width: 100%;
|
||||||
}
|
}
|
||||||
|
|
||||||
th, td {
|
th, td {
|
||||||
font-family: monospace;
|
font-family: monospace;
|
||||||
vertical-align: top;
|
vertical-align: top;
|
||||||
text-align: left;
|
text-align: left;
|
||||||
}
|
}
|
||||||
|
|
||||||
td {
|
td {
|
||||||
color: green;
|
color: green;
|
||||||
}
|
}
|
||||||
|
tr:nth-child(odd) {
|
||||||
.odd {
|
|
||||||
background-color: #eeeeee;
|
background-color: #eeeeee;
|
||||||
}
|
}
|
||||||
|
tr:nth-child(even) {
|
||||||
.even {
|
|
||||||
background-color: #fafafa;
|
background-color: #fafafa;
|
||||||
}
|
}
|
||||||
|
|
||||||
.exectime {
|
.exectime {
|
||||||
font-size: 0.8em;
|
font-size: 0.8em;
|
||||||
font-style: italic;
|
font-style: italic;
|
||||||
}
|
}
|
||||||
|
|
||||||
#bold div {
|
#bold div {
|
||||||
color: black;
|
color: black;
|
||||||
font-weight: bold;
|
font-weight: bold;
|
||||||
@@ -95,12 +83,11 @@
|
|||||||
color: blue;
|
color: blue;
|
||||||
font-weight: bold;
|
font-weight: bold;
|
||||||
}
|
}
|
||||||
|
|
||||||
#table_config_vars th {
|
#table_config_vars th {
|
||||||
color: maroon;
|
color: maroon;
|
||||||
}
|
}
|
||||||
|
|
||||||
{/literal}
|
{/literal}
|
||||||
|
|
||||||
</style>
|
</style>
|
||||||
</head>
|
</head>
|
||||||
<body>
|
<body>
|
||||||
@@ -112,12 +99,13 @@
|
|||||||
<h2>included templates & config files (load time in seconds)</h2>
|
<h2>included templates & config files (load time in seconds)</h2>
|
||||||
<div>
|
<div>
|
||||||
{foreach $template_data as $template}
|
{foreach $template_data as $template}
|
||||||
<font color=brown>{$template.name}</font>
|
<span style="color: brown;">{$template.name}</span>
|
||||||
<br /> <span class="exectime">
|
<br> <span class="exectime">
|
||||||
(compile {$template['compile_time']|string_format:"%.5f"}) (render {$template['render_time']|string_format:"%.5f"}) (cache {$template['cache_time']|string_format:"%.5f"})
|
(compile {$template['compile_time']|string_format:"%.5f"}) (render {$template['render_time']|string_format:"%.5f"}) (cache {$template['cache_time']|string_format:"%.5f"})
|
||||||
</span>
|
</span>
|
||||||
<br />
|
<br>
|
||||||
{/foreach}
|
{/foreach}
|
||||||
|
|
||||||
</div>
|
</div>
|
||||||
{/if}
|
{/if}
|
||||||
|
|
||||||
@@ -125,29 +113,46 @@
|
|||||||
|
|
||||||
<table id="table_assigned_vars">
|
<table id="table_assigned_vars">
|
||||||
{foreach $assigned_vars as $vars}
|
{foreach $assigned_vars as $vars}
|
||||||
<tr class="{if $vars@iteration % 2 eq 0}odd{else}even{/if}">
|
<tr>
|
||||||
<td><h3><font color=blue>${$vars@key}</font></h3>
|
<td>
|
||||||
{if isset($vars['nocache'])}<b>Nocache</b><br />{/if}
|
<h3 style="color: blue;">${$vars@key}</h3>
|
||||||
{if isset($vars['scope'])}<b>Origin:</b> {$vars['scope']|debug_print_var nofilter}{/if}
|
{if isset($vars['nocache'])}<strong>Nocache</strong><br>{/if}
|
||||||
|
{if isset($vars['scope'])}<strong>Origin:</strong> {$vars['scope']|debug_print_var nofilter}{/if}
|
||||||
</td>
|
</td>
|
||||||
<td><h3>Value</h3>{$vars['value']|debug_print_var:10:80 nofilter}</td>
|
<td>
|
||||||
<td>{if isset($vars['attributes'])}<h3>Attributes</h3>{$vars['attributes']|debug_print_var nofilter} {/if}</td>
|
<h3>Value</h3>
|
||||||
|
{$vars['value']|debug_print_var:10:80 nofilter}
|
||||||
|
</td>
|
||||||
|
<td>
|
||||||
|
{if isset($vars['attributes'])}
|
||||||
|
<h3>Attributes</h3>
|
||||||
|
{$vars['attributes']|debug_print_var nofilter}
|
||||||
|
{/if}
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
{/foreach}
|
{/foreach}
|
||||||
|
|
||||||
</table>
|
</table>
|
||||||
|
|
||||||
<h2>assigned config file variables</h2>
|
<h2>assigned config file variables</h2>
|
||||||
|
|
||||||
|
{if NOT empty($config_vars)}
|
||||||
<table id="table_config_vars">
|
<table id="table_config_vars">
|
||||||
{foreach $config_vars as $vars}
|
{foreach $config_vars as $vars}
|
||||||
<tr class="{if $vars@iteration % 2 eq 0}odd{else}even{/if}">
|
<tr>
|
||||||
<td><h3><font color=blue>#{$vars@key}#</font></h3>
|
<td>
|
||||||
{if isset($vars['scope'])}<b>Origin:</b> {$vars['scope']|debug_print_var nofilter}{/if}
|
<h3 style="color: blue;">#{$vars@key}#</h3>
|
||||||
|
{if isset($vars['scope'])}<strong>Origin:</strong> {$vars['scope']|debug_print_var nofilter}{/if}
|
||||||
|
</td>
|
||||||
|
<td>
|
||||||
|
{$vars['value']|debug_print_var:10:80 nofilter}
|
||||||
</td>
|
</td>
|
||||||
<td>{$vars['value']|debug_print_var:10:80 nofilter}</td>
|
|
||||||
</tr>
|
</tr>
|
||||||
{/foreach}
|
{/foreach}
|
||||||
|
|
||||||
</table>
|
</table>
|
||||||
|
{/if}
|
||||||
|
|
||||||
</body>
|
</body>
|
||||||
</html>
|
</html>
|
||||||
{/capture}
|
{/capture}
|
||||||
|
|||||||
@@ -0,0 +1,51 @@
|
|||||||
|
<?php
|
||||||
|
/**
|
||||||
|
* This file is part of the Smarty package.
|
||||||
|
*
|
||||||
|
* For the full copyright and license information, please view the LICENSE
|
||||||
|
* file that was distributed with this source code.
|
||||||
|
*/
|
||||||
|
/**
|
||||||
|
* Registers some helper/polyfill functions.
|
||||||
|
*/
|
||||||
|
|
||||||
|
const SMARTY_HELPER_FUNCTIONS_LOADED = true;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Converts the first characters in $string to uppercase (A-Z) if it is an ASCII lowercase character (a-z).
|
||||||
|
*
|
||||||
|
* May not be required when running PHP8.2+: https://wiki.php.net/rfc/strtolower-ascii
|
||||||
|
*
|
||||||
|
* @param $string
|
||||||
|
*
|
||||||
|
* @return string
|
||||||
|
*/
|
||||||
|
function smarty_ucfirst_ascii($string): string {
|
||||||
|
return smarty_strtoupper_ascii(substr($string, 0, 1)) . substr($string, 1);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Converts all uppercase ASCII characters (A-Z) in $string to lowercase (a-z).
|
||||||
|
*
|
||||||
|
* May not be required when running PHP8.2+: https://wiki.php.net/rfc/strtolower-ascii
|
||||||
|
*
|
||||||
|
* @param $string
|
||||||
|
*
|
||||||
|
* @return string
|
||||||
|
*/
|
||||||
|
function smarty_strtolower_ascii($string): string {
|
||||||
|
return strtr($string, 'ABCDEFGHIJKLMNOPQRSTUVWXYZ', 'abcdefghijklmnopqrstuvwxyz');
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Converts all lowercase ASCII characters (a-z) in $string to uppercase (A-Z).
|
||||||
|
*
|
||||||
|
* May not be required when running PHP8.2+: https://wiki.php.net/rfc/strtolower-ascii
|
||||||
|
*
|
||||||
|
* @param $string
|
||||||
|
*
|
||||||
|
* @return string
|
||||||
|
*/
|
||||||
|
function smarty_strtoupper_ascii($string): string {
|
||||||
|
return strtr($string, 'abcdefghijklmnopqrstuvwxyz', 'ABCDEFGHIJKLMNOPQRSTUVWXYZ');
|
||||||
|
}
|
||||||
@@ -20,7 +20,7 @@
|
|||||||
* - indent_char - string (" ")
|
* - indent_char - string (" ")
|
||||||
* - wrap_boundary - boolean (true)
|
* - 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)
|
* (Smarty online manual)
|
||||||
*
|
*
|
||||||
* @param array $params parameters
|
* @param array $params parameters
|
||||||
|
|||||||
@@ -12,7 +12,7 @@
|
|||||||
* Purpose: print out a counter value
|
* Purpose: print out a counter value
|
||||||
*
|
*
|
||||||
* @author Monte Ohrt <monte at ohrt dot com>
|
* @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)
|
* (Smarty online manual)
|
||||||
*
|
*
|
||||||
* @param array $params parameters
|
* @param array $params parameters
|
||||||
@@ -23,7 +23,7 @@
|
|||||||
function smarty_function_counter($params, $template)
|
function smarty_function_counter($params, $template)
|
||||||
{
|
{
|
||||||
static $counters = array();
|
static $counters = array();
|
||||||
$name = (isset($params[ 'name' ])) ? $params[ 'name' ] : 'default';
|
$name = $params[ 'name' ] ?? 'default';
|
||||||
if (!isset($counters[ $name ])) {
|
if (!isset($counters[ $name ])) {
|
||||||
$counters[ $name ] = array('start' => 1, 'skip' => 1, 'direction' => 'up', 'count' => 1);
|
$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 values="one,two,three" reset=true}
|
||||||
* {cycle name=row}
|
* {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)
|
* (Smarty online manual)
|
||||||
* @author Monte Ohrt <monte at ohrt dot com>
|
* @author Monte Ohrt <monte at ohrt dot com>
|
||||||
* @author credit to Mark Priatel <mpriatel@rogers.com>
|
* @author credit to Mark Priatel <mpriatel@rogers.com>
|
||||||
|
|||||||
@@ -11,7 +11,7 @@
|
|||||||
* Name: fetch
|
* Name: fetch
|
||||||
* Purpose: fetch file, web or ftp data and display results
|
* 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)
|
* (Smarty online manual)
|
||||||
* @author Monte Ohrt <monte at ohrt dot com>
|
* @author Monte Ohrt <monte at ohrt dot com>
|
||||||
*
|
*
|
||||||
|
|||||||
@@ -29,7 +29,7 @@
|
|||||||
* - assign (optional) - assign the output as an array to this variable
|
* - assign (optional) - assign the output as an array to this variable
|
||||||
* - escape (optional) - escape the content (not value), defaults to true
|
* - 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)
|
* (Smarty online manual)
|
||||||
* @author Christopher Kvarme <christopher.kvarme@flashjab.com>
|
* @author Christopher Kvarme <christopher.kvarme@flashjab.com>
|
||||||
* @author credits to Monte Ohrt <monte at ohrt dot 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
|
* - basedir - (optional) - base directory for absolute paths, default is environment variable DOCUMENT_ROOT
|
||||||
* - path_prefix - prefix for path output (optional, default empty)
|
* - 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)
|
* (Smarty online manual)
|
||||||
* @author Monte Ohrt <monte at ohrt dot com>
|
* @author Monte Ohrt <monte at ohrt dot com>
|
||||||
* @author credits to Duda <duda@big.hu>
|
* @author credits to Duda <duda@big.hu>
|
||||||
|
|||||||
@@ -21,7 +21,7 @@
|
|||||||
* - id (optional) - string default not set
|
* - id (optional) - string default not set
|
||||||
* - class (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)
|
* (Smarty online manual)
|
||||||
* @author Monte Ohrt <monte at ohrt dot com>
|
* @author Monte Ohrt <monte at ohrt dot com>
|
||||||
* @author Ralf Strehle (minor optimization) <ralf dot strehle at yahoo dot de>
|
* @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 name='box' separator='<br>' output=$names}
|
||||||
* {html_radios values=$ids checked=$checked 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)
|
* (Smarty online manual)
|
||||||
* @author Christopher Kvarme <christopher.kvarme@flashjab.com>
|
* @author Christopher Kvarme <christopher.kvarme@flashjab.com>
|
||||||
* @author credits to Monte Ohrt <monte at ohrt dot 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 {
|
} else {
|
||||||
foreach ($values as $_i => $_key) {
|
foreach ($values as $_i => $_key) {
|
||||||
$_val = isset($output[ $_i ]) ? $output[ $_i ] : '';
|
$_val = $output[ $_i ] ?? '';
|
||||||
$_html_result[] =
|
$_html_result[] =
|
||||||
smarty_function_html_radios_output(
|
smarty_function_html_radios_output(
|
||||||
$name,
|
$name,
|
||||||
|
|||||||
@@ -28,7 +28,7 @@
|
|||||||
* - 2.0 complete rewrite for performance,
|
* - 2.0 complete rewrite for performance,
|
||||||
* added attributes month_names, *_id
|
* 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)
|
* (Smarty online manual)
|
||||||
* @version 2.0
|
* @version 2.0
|
||||||
* @author Andrei Zmievski
|
* @author Andrei Zmievski
|
||||||
@@ -101,6 +101,7 @@ function smarty_function_html_select_date($params, Smarty_Internal_Template $tem
|
|||||||
$field_separator = "\n";
|
$field_separator = "\n";
|
||||||
$option_separator = "\n";
|
$option_separator = "\n";
|
||||||
$time = null;
|
$time = null;
|
||||||
|
|
||||||
// $all_empty = null;
|
// $all_empty = null;
|
||||||
// $day_empty = null;
|
// $day_empty = null;
|
||||||
// $month_empty = null;
|
// $month_empty = null;
|
||||||
@@ -113,17 +114,7 @@ function smarty_function_html_select_date($params, Smarty_Internal_Template $tem
|
|||||||
foreach ($params as $_key => $_value) {
|
foreach ($params as $_key => $_value) {
|
||||||
switch ($_key) {
|
switch ($_key) {
|
||||||
case 'time':
|
case 'time':
|
||||||
if (!is_array($_value) && $_value !== null) {
|
$$_key = $_value; // we'll handle conversion below
|
||||||
$template->_checkPlugins(
|
|
||||||
array(
|
|
||||||
array(
|
|
||||||
'function' => 'smarty_make_timestamp',
|
|
||||||
'file' => SMARTY_PLUGINS_DIR . 'shared.make_timestamp.php'
|
|
||||||
)
|
|
||||||
)
|
|
||||||
);
|
|
||||||
$time = smarty_make_timestamp($_value);
|
|
||||||
}
|
|
||||||
break;
|
break;
|
||||||
case 'month_names':
|
case 'month_names':
|
||||||
if (is_array($_value) && count($_value) === 12) {
|
if (is_array($_value) && count($_value) === 12) {
|
||||||
@@ -178,43 +169,57 @@ function smarty_function_html_select_date($params, Smarty_Internal_Template $tem
|
|||||||
}
|
}
|
||||||
// Note: date() is faster than strftime()
|
// Note: date() is faster than strftime()
|
||||||
// Note: explode(date()) is faster than date() date() date()
|
// Note: explode(date()) is faster than date() date() date()
|
||||||
if (isset($params[ 'time' ]) && is_array($params[ 'time' ])) {
|
|
||||||
if (isset($params[ 'time' ][ $prefix . 'Year' ])) {
|
if (isset($time) && is_array($time)) {
|
||||||
|
if (isset($time[$prefix . 'Year'])) {
|
||||||
// $_REQUEST[$field_array] given
|
// $_REQUEST[$field_array] given
|
||||||
foreach (array(
|
foreach ([
|
||||||
'Y' => 'Year',
|
'Y' => 'Year',
|
||||||
'm' => 'Month',
|
'm' => 'Month',
|
||||||
'd' => 'Day'
|
'd' => 'Day'
|
||||||
) as $_elementKey => $_elementName) {
|
] as $_elementKey => $_elementName) {
|
||||||
$_variableName = '_' . strtolower($_elementName);
|
$_variableName = '_' . strtolower($_elementName);
|
||||||
$$_variableName =
|
$$_variableName = $params[ 'time' ][ $prefix . $_elementName ] ?? date($_elementKey);
|
||||||
isset($params[ 'time' ][ $prefix . $_elementName ]) ? $params[ 'time' ][ $prefix . $_elementName ] :
|
|
||||||
date($_elementKey);
|
|
||||||
}
|
}
|
||||||
} elseif (isset($params[ 'time' ][ $field_array ][ $prefix . 'Year' ])) {
|
} elseif (isset($time[$field_array][$prefix . 'Year'])) {
|
||||||
// $_REQUEST given
|
// $_REQUEST given
|
||||||
foreach (array(
|
foreach ([
|
||||||
'Y' => 'Year',
|
'Y' => 'Year',
|
||||||
'm' => 'Month',
|
'm' => 'Month',
|
||||||
'd' => 'Day'
|
'd' => 'Day'
|
||||||
) as $_elementKey => $_elementName) {
|
] as $_elementKey => $_elementName) {
|
||||||
$_variableName = '_' . strtolower($_elementName);
|
$_variableName = '_' . strtolower($_elementName);
|
||||||
$$_variableName = isset($params[ 'time' ][ $field_array ][ $prefix . $_elementName ]) ?
|
$$_variableName = isset($time[$field_array][$prefix . $_elementName]) ?
|
||||||
$params[ 'time' ][ $field_array ][ $prefix . $_elementName ] : date($_elementKey);
|
$time[$field_array][$prefix . $_elementName] : date($_elementKey);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
// no date found, use NOW
|
// no date found, use NOW
|
||||||
list($_year, $_month, $_day) = $time = explode('-', date('Y-m-d'));
|
[$_year, $_month, $_day] = explode('-', date('Y-m-d'));
|
||||||
}
|
}
|
||||||
|
} elseif (isset($time) && preg_match("/(\d*)-(\d*)-(\d*)/", $time, $matches)) {
|
||||||
|
$_year = $_month = $_day = null;
|
||||||
|
if ($matches[1] > '') $_year = (int) $matches[1];
|
||||||
|
if ($matches[2] > '') $_month = (int) $matches[2];
|
||||||
|
if ($matches[3] > '') $_day = (int) $matches[3];
|
||||||
} elseif ($time === null) {
|
} elseif ($time === null) {
|
||||||
if (array_key_exists('time', $params)) {
|
if (array_key_exists('time', $params)) {
|
||||||
$_year = $_month = $_day = $time = null;
|
$_year = $_month = $_day = null;
|
||||||
} else {
|
} else {
|
||||||
list($_year, $_month, $_day) = $time = explode('-', date('Y-m-d'));
|
[$_year, $_month, $_day] = explode('-', date('Y-m-d'));
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
list($_year, $_month, $_day) = $time = explode('-', date('Y-m-d', $time));
|
$template->_checkPlugins(
|
||||||
|
array(
|
||||||
|
array(
|
||||||
|
'function' => 'smarty_make_timestamp',
|
||||||
|
'file' => SMARTY_PLUGINS_DIR . 'shared.make_timestamp.php'
|
||||||
|
)
|
||||||
|
)
|
||||||
|
);
|
||||||
|
$time = smarty_make_timestamp($time);
|
||||||
|
[$_year, $_month, $_day] = explode('-', date('Y-m-d', $time));
|
||||||
}
|
}
|
||||||
|
|
||||||
// make syntax "+N" or "-N" work with $start_year and $end_year
|
// make syntax "+N" or "-N" work with $start_year and $end_year
|
||||||
// Note preg_match('!^(\+|\-)\s*(\d+)$!', $end_year, $match) is slower than trim+substr
|
// Note preg_match('!^(\+|\-)\s*(\d+)$!', $end_year, $match) is slower than trim+substr
|
||||||
foreach (array(
|
foreach (array(
|
||||||
@@ -258,9 +263,8 @@ function smarty_function_html_select_date($params, Smarty_Internal_Template $tem
|
|||||||
if ($year_id !== null || $all_id !== null) {
|
if ($year_id !== null || $all_id !== null) {
|
||||||
$_html_years .= ' id="' . smarty_function_escape_special_chars(
|
$_html_years .= ' id="' . smarty_function_escape_special_chars(
|
||||||
$year_id !== null ?
|
$year_id !== null ?
|
||||||
($year_id ? $year_id : $_name) :
|
($year_id ?? $_name) :
|
||||||
($all_id ? ($all_id . $_name) :
|
($all_id ? ($all_id . $_name) : $_name)
|
||||||
$_name)
|
|
||||||
) . '"';
|
) . '"';
|
||||||
}
|
}
|
||||||
if ($year_size) {
|
if ($year_size) {
|
||||||
@@ -268,7 +272,7 @@ function smarty_function_html_select_date($params, Smarty_Internal_Template $tem
|
|||||||
}
|
}
|
||||||
$_html_years .= $_extra . $extra_attrs . '>' . $option_separator;
|
$_html_years .= $_extra . $extra_attrs . '>' . $option_separator;
|
||||||
if (isset($year_empty) || isset($all_empty)) {
|
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;
|
$option_separator;
|
||||||
}
|
}
|
||||||
$op = $start_year > $end_year ? -1 : 1;
|
$op = $start_year > $end_year ? -1 : 1;
|
||||||
@@ -293,9 +297,8 @@ function smarty_function_html_select_date($params, Smarty_Internal_Template $tem
|
|||||||
if ($month_id !== null || $all_id !== null) {
|
if ($month_id !== null || $all_id !== null) {
|
||||||
$_html_months .= ' id="' . smarty_function_escape_special_chars(
|
$_html_months .= ' id="' . smarty_function_escape_special_chars(
|
||||||
$month_id !== null ?
|
$month_id !== null ?
|
||||||
($month_id ? $month_id : $_name) :
|
($month_id ?? $_name) :
|
||||||
($all_id ? ($all_id . $_name) :
|
($all_id ? ($all_id . $_name) : $_name)
|
||||||
$_name)
|
|
||||||
) . '"';
|
) . '"';
|
||||||
}
|
}
|
||||||
if ($month_size) {
|
if ($month_size) {
|
||||||
@@ -303,14 +306,14 @@ function smarty_function_html_select_date($params, Smarty_Internal_Template $tem
|
|||||||
}
|
}
|
||||||
$_html_months .= $_extra . $extra_attrs . '>' . $option_separator;
|
$_html_months .= $_extra . $extra_attrs . '>' . $option_separator;
|
||||||
if (isset($month_empty) || isset($all_empty)) {
|
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;
|
$option_separator;
|
||||||
}
|
}
|
||||||
for ($i = 1; $i <= 12; $i++) {
|
for ($i = 1; $i <= 12; $i++) {
|
||||||
$_val = sprintf('%02d', $i);
|
$_val = sprintf('%02d', $i);
|
||||||
$_text = isset($month_names) ? smarty_function_escape_special_chars($month_names[ $i ]) :
|
$_text = isset($month_names) ? smarty_function_escape_special_chars($month_names[ $i ]) :
|
||||||
($month_format === '%m' ? $_val : strftime($month_format, $_month_timestamps[ $i ]));
|
($month_format === '%m' ? $_val : @strftime($month_format, $_month_timestamps[ $i ]));
|
||||||
$_value = $month_value_format === '%m' ? $_val : strftime($month_value_format, $_month_timestamps[ $i ]);
|
$_value = $month_value_format === '%m' ? $_val : @strftime($month_value_format, $_month_timestamps[ $i ]);
|
||||||
$_html_months .= '<option value="' . $_value . '"' . ($_val == $_month ? ' selected="selected"' : '') .
|
$_html_months .= '<option value="' . $_value . '"' . ($_val == $_month ? ' selected="selected"' : '') .
|
||||||
'>' . $_text . '</option>' . $option_separator;
|
'>' . $_text . '</option>' . $option_separator;
|
||||||
}
|
}
|
||||||
@@ -339,7 +342,7 @@ function smarty_function_html_select_date($params, Smarty_Internal_Template $tem
|
|||||||
}
|
}
|
||||||
$_html_days .= $_extra . $extra_attrs . '>' . $option_separator;
|
$_html_days .= $_extra . $extra_attrs . '>' . $option_separator;
|
||||||
if (isset($day_empty) || isset($all_empty)) {
|
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;
|
$option_separator;
|
||||||
}
|
}
|
||||||
for ($i = 1; $i <= 31; $i++) {
|
for ($i = 1; $i <= 31; $i++) {
|
||||||
|
|||||||
@@ -11,7 +11,7 @@
|
|||||||
* Name: html_select_time
|
* Name: html_select_time
|
||||||
* Purpose: Prints the dropdowns for time selection
|
* 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)
|
* (Smarty online manual)
|
||||||
* @author Roberto Berto <roberto@berto.net>
|
* @author Roberto Berto <roberto@berto.net>
|
||||||
* @author Monte Ohrt <monte AT ohrt DOT com>
|
* @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'
|
's' => 'Second'
|
||||||
) as $_elementKey => $_elementName) {
|
) as $_elementKey => $_elementName) {
|
||||||
$_variableName = '_' . strtolower($_elementName);
|
$_variableName = '_' . strtolower($_elementName);
|
||||||
$$_variableName =
|
$$_variableName = $params[ 'time' ][ $prefix . $_elementName ] ?? date($_elementKey);
|
||||||
isset($params[ 'time' ][ $prefix . $_elementName ]) ? $params[ 'time' ][ $prefix . $_elementName ] :
|
|
||||||
date($_elementKey);
|
|
||||||
}
|
}
|
||||||
$_meridian =
|
$_meridian =
|
||||||
isset($params[ 'time' ][ $prefix . 'Meridian' ]) ? (' ' . $params[ 'time' ][ $prefix . '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) {
|
if ($hour_id !== null || $all_id !== null) {
|
||||||
$_html_hours .= ' id="' .
|
$_html_hours .= ' id="' .
|
||||||
smarty_function_escape_special_chars(
|
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)
|
($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;
|
$_html_hours .= $_extra . $extra_attrs . '>' . $option_separator;
|
||||||
if (isset($hour_empty) || isset($all_empty)) {
|
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;
|
$option_separator;
|
||||||
}
|
}
|
||||||
$start = $use_24_hours ? 0 : 1;
|
$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) {
|
if ($minute_id !== null || $all_id !== null) {
|
||||||
$_html_minutes .= ' id="' . smarty_function_escape_special_chars(
|
$_html_minutes .= ' id="' . smarty_function_escape_special_chars(
|
||||||
$minute_id !== null ?
|
$minute_id !== null ?
|
||||||
($minute_id ? $minute_id : $_name) :
|
($minute_id ?? $_name) :
|
||||||
($all_id ? ($all_id . $_name) :
|
($all_id ? ($all_id . $_name) : $_name)
|
||||||
$_name)
|
|
||||||
) . '"';
|
) . '"';
|
||||||
}
|
}
|
||||||
if ($minute_size) {
|
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;
|
$_html_minutes .= $_extra . $extra_attrs . '>' . $option_separator;
|
||||||
if (isset($minute_empty) || isset($all_empty)) {
|
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;
|
$option_separator;
|
||||||
}
|
}
|
||||||
$selected = $_minute !== null ? ($_minute - $_minute % $minute_interval) : null;
|
$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) {
|
if ($second_id !== null || $all_id !== null) {
|
||||||
$_html_seconds .= ' id="' . smarty_function_escape_special_chars(
|
$_html_seconds .= ' id="' . smarty_function_escape_special_chars(
|
||||||
$second_id !== null ?
|
$second_id !== null ?
|
||||||
($second_id ? $second_id : $_name) :
|
($second_id ?? $_name) :
|
||||||
($all_id ? ($all_id . $_name) :
|
($all_id ? ($all_id . $_name) : $_name)
|
||||||
$_name)
|
|
||||||
) . '"';
|
) . '"';
|
||||||
}
|
}
|
||||||
if ($second_size) {
|
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;
|
$_html_seconds .= $_extra . $extra_attrs . '>' . $option_separator;
|
||||||
if (isset($second_empty) || isset($all_empty)) {
|
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;
|
$option_separator;
|
||||||
}
|
}
|
||||||
$selected = $_second !== null ? ($_second - $_second % $second_interval) : null;
|
$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) {
|
if ($meridian_id !== null || $all_id !== null) {
|
||||||
$_html_meridian .= ' id="' . smarty_function_escape_special_chars(
|
$_html_meridian .= ' id="' . smarty_function_escape_special_chars(
|
||||||
$meridian_id !== null ?
|
$meridian_id !== null ?
|
||||||
($meridian_id ? $meridian_id :
|
($meridian_id ?? $_name) :
|
||||||
$_name) :
|
($all_id ? ($all_id . $_name) : $_name)
|
||||||
($all_id ? ($all_id . $_name) :
|
|
||||||
$_name)
|
|
||||||
) . '"';
|
) . '"';
|
||||||
}
|
}
|
||||||
if ($meridian_size) {
|
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;
|
$_html_meridian .= $_extra . $extra_attrs . '>' . $option_separator;
|
||||||
if (isset($meridian_empty) || isset($all_empty)) {
|
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;
|
'</option>' . $option_separator;
|
||||||
}
|
}
|
||||||
$_html_meridian .= '<option value="am"' . ($_hour > 0 && $_hour < 12 ? ' selected="selected"' : '') .
|
$_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 Messju Mohr <messju at lammfellpuschen dot de>
|
||||||
* @author credit to boots <boots dot smarty at yahoo dot com>
|
* @author credit to boots <boots dot smarty at yahoo dot com>
|
||||||
* @version 1.1
|
* @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)
|
* (Smarty online manual)
|
||||||
*
|
*
|
||||||
* @param array $params parameters
|
* @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" cc="you@domain.com,they@domain.com"}
|
||||||
* {mailto address="me@domain.com" extra='class="mailto"'}
|
* {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)
|
* (Smarty online manual)
|
||||||
* @version 1.2
|
* @version 1.2
|
||||||
* @author Monte Ohrt <monte at ohrt dot com>
|
* @author Monte Ohrt <monte at ohrt dot com>
|
||||||
@@ -48,8 +48,13 @@
|
|||||||
*/
|
*/
|
||||||
function smarty_function_mailto($params)
|
function smarty_function_mailto($params)
|
||||||
{
|
{
|
||||||
static $_allowed_encoding =
|
static $_allowed_encoding = [
|
||||||
array('javascript' => true, 'javascript_charcode' => true, 'hex' => true, 'none' => true);
|
'javascript' => true,
|
||||||
|
'javascript_charcode' => true,
|
||||||
|
'hex' => true,
|
||||||
|
'none' => true
|
||||||
|
];
|
||||||
|
|
||||||
$extra = '';
|
$extra = '';
|
||||||
if (empty($params[ 'address' ])) {
|
if (empty($params[ 'address' ])) {
|
||||||
trigger_error("mailto: missing 'address' parameter", E_USER_WARNING);
|
trigger_error("mailto: missing 'address' parameter", E_USER_WARNING);
|
||||||
@@ -57,19 +62,19 @@ function smarty_function_mailto($params)
|
|||||||
} else {
|
} else {
|
||||||
$address = $params[ 'address' ];
|
$address = $params[ 'address' ];
|
||||||
}
|
}
|
||||||
|
|
||||||
$text = $address;
|
$text = $address;
|
||||||
|
|
||||||
// netscape and mozilla do not decode %40 (@) in BCC field (bug?)
|
// netscape and mozilla do not decode %40 (@) in BCC field (bug?)
|
||||||
// so, don't encode it.
|
// so, don't encode it.
|
||||||
$search = array('%40', '%2C');
|
$mail_parms = [];
|
||||||
$replace = array('@', ',');
|
|
||||||
$mail_parms = array();
|
|
||||||
foreach ($params as $var => $value) {
|
foreach ($params as $var => $value) {
|
||||||
switch ($var) {
|
switch ($var) {
|
||||||
case 'cc':
|
case 'cc':
|
||||||
case 'bcc':
|
case 'bcc':
|
||||||
case 'followupto':
|
case 'followupto':
|
||||||
if (!empty($value)) {
|
if (!empty($value)) {
|
||||||
$mail_parms[] = $var . '=' . str_replace($search, $replace, rawurlencode($value));
|
$mail_parms[] = $var . '=' . str_replace(['%40', '%2C'], ['@', ','], rawurlencode($value));
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case 'subject':
|
case 'subject':
|
||||||
@@ -83,6 +88,7 @@ function smarty_function_mailto($params)
|
|||||||
default:
|
default:
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($mail_parms) {
|
if ($mail_parms) {
|
||||||
$address .= '?' . join('&', $mail_parms);
|
$address .= '?' . join('&', $mail_parms);
|
||||||
}
|
}
|
||||||
@@ -94,19 +100,21 @@ function smarty_function_mailto($params)
|
|||||||
);
|
);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
$string = '<a href="mailto:' . htmlspecialchars($address, ENT_QUOTES | ENT_SUBSTITUTE | ENT_HTML401, Smarty::$_CHARSET) .
|
||||||
|
'" ' . $extra . '>' . htmlspecialchars($text, ENT_QUOTES | ENT_SUBSTITUTE | ENT_HTML401, Smarty::$_CHARSET) . '</a>';
|
||||||
|
|
||||||
if ($encode === 'javascript') {
|
if ($encode === 'javascript') {
|
||||||
$string = '<a href="mailto:' . $address . '" ' . $extra . '>' . $text . '</a>';
|
|
||||||
$js_encode = '';
|
$js_encode = '';
|
||||||
for ($x = 0, $_length = strlen($string); $x < $_length; $x++) {
|
for ($x = 0, $_length = strlen($string); $x < $_length; $x++) {
|
||||||
$js_encode .= '%' . bin2hex($string[ $x ]);
|
$js_encode .= '%' . bin2hex($string[ $x ]);
|
||||||
}
|
}
|
||||||
return '<script type="text/javascript">document.write(unescape(\'' . $js_encode . '\'))</script>';
|
return '<script type="text/javascript">document.write(unescape(\'' . $js_encode . '\'))</script>';
|
||||||
} elseif ($encode === 'javascript_charcode') {
|
} elseif ($encode === 'javascript_charcode') {
|
||||||
$string = '<a href="mailto:' . $address . '" ' . $extra . '>' . $text . '</a>';
|
|
||||||
for ($x = 0, $_length = strlen($string); $x < $_length; $x++) {
|
for ($x = 0, $_length = strlen($string); $x < $_length; $x++) {
|
||||||
$ord[] = ord($string[ $x ]);
|
$ord[] = ord($string[ $x ]);
|
||||||
}
|
}
|
||||||
return '<script type="text/javascript">document.write(String.fromCharCode(' . implode(',', $ord) . '))</script>';
|
return '<script type="text/javascript">document.write(String.fromCharCode(' . implode(',', $ord) . '))</script>';
|
||||||
} elseif ($encode === 'hex') {
|
} elseif ($encode === 'hex') {
|
||||||
preg_match('!^(.*)(\?.*)$!', $address, $match);
|
preg_match('!^(.*)(\?.*)$!', $address, $match);
|
||||||
if (!empty($match[ 2 ])) {
|
if (!empty($match[ 2 ])) {
|
||||||
@@ -129,6 +137,6 @@ function smarty_function_mailto($params)
|
|||||||
return '<a href="' . $mailto . $address_encode . '" ' . $extra . '>' . $text_encode . '</a>';
|
return '<a href="' . $mailto . $address_encode . '" ' . $extra . '>' . $text_encode . '</a>';
|
||||||
} else {
|
} else {
|
||||||
// no encoding
|
// no encoding
|
||||||
return '<a href="mailto:' . $address . '" ' . $extra . '>' . $text . '</a>';
|
return $string;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -12,7 +12,7 @@
|
|||||||
* Name: math
|
* Name: math
|
||||||
* Purpose: handle math computations in template
|
* 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)
|
* (Smarty online manual)
|
||||||
* @author Monte Ohrt <monte at ohrt dot com>
|
* @author Monte Ohrt <monte at ohrt dot com>
|
||||||
*
|
*
|
||||||
@@ -25,35 +25,35 @@ function smarty_function_math($params, $template)
|
|||||||
{
|
{
|
||||||
static $_allowed_funcs =
|
static $_allowed_funcs =
|
||||||
array(
|
array(
|
||||||
'int' => true,
|
'int' => true,
|
||||||
'abs' => true,
|
'abs' => true,
|
||||||
'ceil' => true,
|
'ceil' => true,
|
||||||
'acos' => true,
|
'acos' => true,
|
||||||
'acosh' => true,
|
'acosh' => true,
|
||||||
'cos' => true,
|
'cos' => true,
|
||||||
'cosh' => true,
|
'cosh' => true,
|
||||||
'deg2rad' => true,
|
'deg2rad' => true,
|
||||||
'rad2deg' => true,
|
'rad2deg' => true,
|
||||||
'exp' => true,
|
'exp' => true,
|
||||||
'floor' => true,
|
'floor' => true,
|
||||||
'log' => true,
|
'log' => true,
|
||||||
'log10' => true,
|
'log10' => true,
|
||||||
'max' => true,
|
'max' => true,
|
||||||
'min' => true,
|
'min' => true,
|
||||||
'pi' => true,
|
'pi' => true,
|
||||||
'pow' => true,
|
'pow' => true,
|
||||||
'rand' => true,
|
'rand' => true,
|
||||||
'round' => true,
|
'round' => true,
|
||||||
'asin' => true,
|
'asin' => true,
|
||||||
'asinh' => true,
|
'asinh' => true,
|
||||||
'sin' => true,
|
'sin' => true,
|
||||||
'sinh' => true,
|
'sinh' => true,
|
||||||
'sqrt' => true,
|
'sqrt' => true,
|
||||||
'srand' => true,
|
'srand' => true,
|
||||||
'atan' => true,
|
'atan' => true,
|
||||||
'atanh' => true,
|
'atanh' => true,
|
||||||
'tan' => true,
|
'tan' => true,
|
||||||
'tanh' => true
|
'tanh' => true
|
||||||
);
|
);
|
||||||
|
|
||||||
// be sure equation parameter is present
|
// be sure equation parameter is present
|
||||||
@@ -69,8 +69,8 @@ function smarty_function_math($params, $template)
|
|||||||
// Adapted from https://www.php.net/manual/en/function.eval.php#107377
|
// Adapted from https://www.php.net/manual/en/function.eval.php#107377
|
||||||
$number = '(?:\d+(?:[,.]\d+)?|pi|π)'; // What is a number
|
$number = '(?:\d+(?:[,.]\d+)?|pi|π)'; // What is a number
|
||||||
$functionsOrVars = '((?:0x[a-fA-F0-9]+)|([a-zA-Z_\x7f-\xff][a-zA-Z0-9_\x7f-\xff]*))';
|
$functionsOrVars = '((?:0x[a-fA-F0-9]+)|([a-zA-Z_\x7f-\xff][a-zA-Z0-9_\x7f-\xff]*))';
|
||||||
$operators = '[+\/*\^%-]'; // Allowed math operators
|
$operators = '[,+\/*\^%-]'; // Allowed math operators
|
||||||
$regexp = '/^(('.$number.'|'.$functionsOrVars.'|('.$functionsOrVars.'\s*\((?1)+\)|\((?1)+\)))(?:'.$operators.'(?2))?)+$/';
|
$regexp = '/^(('.$number.'|'.$functionsOrVars.'|('.$functionsOrVars.'\s*\((?1)*\)|\((?1)*\)))(?:'.$operators.'(?1))?)+$/';
|
||||||
|
|
||||||
if (!preg_match($regexp, $equation)) {
|
if (!preg_match($regexp, $equation)) {
|
||||||
trigger_error("math: illegal characters", E_USER_WARNING);
|
trigger_error("math: illegal characters", E_USER_WARNING);
|
||||||
|
|||||||
@@ -22,6 +22,8 @@
|
|||||||
*/
|
*/
|
||||||
function smarty_modifier_capitalize($string, $uc_digits = false, $lc_rest = false)
|
function smarty_modifier_capitalize($string, $uc_digits = false, $lc_rest = false)
|
||||||
{
|
{
|
||||||
|
$string = (string) $string;
|
||||||
|
|
||||||
if (Smarty::$_MBSTRING) {
|
if (Smarty::$_MBSTRING) {
|
||||||
if ($lc_rest) {
|
if ($lc_rest) {
|
||||||
// uppercase (including hyphenated words)
|
// uppercase (including hyphenated words)
|
||||||
|
|||||||
@@ -0,0 +1,36 @@
|
|||||||
|
<?php
|
||||||
|
/**
|
||||||
|
* Smarty plugin
|
||||||
|
*
|
||||||
|
* @package Smarty
|
||||||
|
* @subpackage PluginsModifier
|
||||||
|
*/
|
||||||
|
/**
|
||||||
|
* Smarty count modifier plugin
|
||||||
|
* Type: modifier
|
||||||
|
* Name: count
|
||||||
|
* Purpose: counts all elements in an array or in a Countable object
|
||||||
|
* Input:
|
||||||
|
* - Countable|array: array or object to count
|
||||||
|
* - mode: int defaults to 0 for normal count mode, if set to 1 counts recursive
|
||||||
|
*
|
||||||
|
* @param mixed $arrayOrObject input array/object
|
||||||
|
* @param int $mode count mode
|
||||||
|
*
|
||||||
|
* @return int
|
||||||
|
*/
|
||||||
|
function smarty_modifier_count($arrayOrObject, $mode = 0)
|
||||||
|
{
|
||||||
|
/*
|
||||||
|
* @see https://www.php.net/count
|
||||||
|
* > Prior to PHP 8.0.0, if the parameter was neither an array nor an object that implements the Countable interface,
|
||||||
|
* > 1 would be returned, unless value was null, in which case 0 would be returned.
|
||||||
|
*/
|
||||||
|
|
||||||
|
if ($arrayOrObject instanceof Countable || is_array($arrayOrObject)) {
|
||||||
|
return count($arrayOrObject, (int) $mode);
|
||||||
|
} elseif ($arrayOrObject === null) {
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
@@ -15,7 +15,8 @@
|
|||||||
* - format: strftime format for output
|
* - format: strftime format for output
|
||||||
* - default_date: default date if $string is empty
|
* - 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>
|
* @author Monte Ohrt <monte at ohrt dot com>
|
||||||
*
|
*
|
||||||
* @param string $string input date string
|
* @param string $string input date string
|
||||||
@@ -78,7 +79,8 @@ function smarty_modifier_date_format($string, $format = null, $default_date = ''
|
|||||||
}
|
}
|
||||||
$format = str_replace($_win_from, $_win_to, $format);
|
$format = str_replace($_win_from, $_win_to, $format);
|
||||||
}
|
}
|
||||||
return strftime($format, $timestamp);
|
// @ to suppress deprecation errors when running in PHP8.1 or higher.
|
||||||
|
return @strftime($format, $timestamp);
|
||||||
} else {
|
} else {
|
||||||
return date($format, $timestamp);
|
return date($format, $timestamp);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -17,101 +17,31 @@
|
|||||||
* @param string $string input string
|
* @param string $string input string
|
||||||
* @param string $esc_type escape type
|
* @param string $esc_type escape type
|
||||||
* @param string $char_set character set, used for htmlspecialchars() or htmlentities()
|
* @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
|
* @return string escaped input string
|
||||||
*/
|
*/
|
||||||
function smarty_modifier_escape($string, $esc_type = 'html', $char_set = null, $double_encode = true)
|
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_1 = false;
|
||||||
static $is_loaded_2 = false;
|
static $is_loaded_2 = false;
|
||||||
|
|
||||||
if (!$char_set) {
|
if (!$char_set) {
|
||||||
$char_set = Smarty::$_CHARSET;
|
$char_set = Smarty::$_CHARSET;
|
||||||
}
|
}
|
||||||
|
$string = (string)$string;
|
||||||
|
|
||||||
switch ($esc_type) {
|
switch ($esc_type) {
|
||||||
case 'html':
|
case 'html':
|
||||||
if ($_double_encode) {
|
return htmlspecialchars($string, ENT_QUOTES, $char_set, $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;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
// no break
|
// no break
|
||||||
case 'htmlall':
|
case 'htmlall':
|
||||||
if (Smarty::$_MBSTRING) {
|
if (Smarty::$_MBSTRING) {
|
||||||
// mb_convert_encoding ignores htmlspecialchars()
|
$string = mb_convert_encoding($string, 'UTF-8', $char_set);
|
||||||
if ($_double_encode) {
|
return htmlentities($string, ENT_QUOTES, 'UTF-8', $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);
|
|
||||||
}
|
}
|
||||||
// no MBString fallback
|
// no MBString fallback
|
||||||
if ($_double_encode) {
|
return htmlentities($string, ENT_QUOTES, $char_set, $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;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
// no break
|
// no break
|
||||||
case 'url':
|
case 'url':
|
||||||
return rawurlencode($string);
|
return rawurlencode($string);
|
||||||
|
|||||||
@@ -0,0 +1,25 @@
|
|||||||
|
<?php
|
||||||
|
/**
|
||||||
|
* Smarty plugin
|
||||||
|
*
|
||||||
|
* @package Smarty
|
||||||
|
* @subpackage PluginsModifier
|
||||||
|
*/
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Smarty explode modifier plugin
|
||||||
|
* Type: modifier
|
||||||
|
* Name: explode
|
||||||
|
* Purpose: split a string by a string
|
||||||
|
*
|
||||||
|
* @param string $separator
|
||||||
|
* @param string $string
|
||||||
|
* @param int|null $limit
|
||||||
|
*
|
||||||
|
* @return array
|
||||||
|
*/
|
||||||
|
function smarty_modifier_explode($separator, $string, ?int $limit = null)
|
||||||
|
{
|
||||||
|
// provide $string default to prevent deprecation errors in PHP >=8.1
|
||||||
|
return explode($separator, $string ?? '', $limit ?? PHP_INT_MAX);
|
||||||
|
}
|
||||||
@@ -0,0 +1,26 @@
|
|||||||
|
<?php
|
||||||
|
/**
|
||||||
|
* Smarty plugin
|
||||||
|
*
|
||||||
|
* @package Smarty
|
||||||
|
* @subpackage PluginsModifier
|
||||||
|
*/
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Smarty number_format modifier plugin
|
||||||
|
* Type: modifier
|
||||||
|
* Name: number_format
|
||||||
|
* Purpose: Format a number with grouped thousands
|
||||||
|
*
|
||||||
|
* @param float|null $num
|
||||||
|
* @param int $decimals
|
||||||
|
* @param string|null $decimal_separator
|
||||||
|
* @param string|null $thousands_separator
|
||||||
|
*
|
||||||
|
* @return string
|
||||||
|
*/
|
||||||
|
function smarty_modifier_number_format(?float $num, int $decimals = 0, ?string $decimal_separator = ".", ?string $thousands_separator = ",")
|
||||||
|
{
|
||||||
|
// provide $num default to prevent deprecation errors in PHP >=8.1
|
||||||
|
return number_format($num ?? 0.0, $decimals, $decimal_separator, $thousands_separator);
|
||||||
|
}
|
||||||
@@ -11,7 +11,7 @@
|
|||||||
* Name: regex_replace
|
* Name: regex_replace
|
||||||
* Purpose: regular expression search/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)
|
* regex_replace (Smarty online manual)
|
||||||
* @author Monte Ohrt <monte at ohrt dot com>
|
* @author Monte Ohrt <monte at ohrt dot com>
|
||||||
*
|
*
|
||||||
|
|||||||
@@ -11,7 +11,8 @@
|
|||||||
* Name: replace
|
* Name: replace
|
||||||
* Purpose: simple search/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 Monte Ohrt <monte at ohrt dot com>
|
||||||
* @author Uwe Tews
|
* @author Uwe Tews
|
||||||
*
|
*
|
||||||
|
|||||||
@@ -11,7 +11,8 @@
|
|||||||
* Name: spacify
|
* Name: spacify
|
||||||
* Purpose: add spaces between characters in a string
|
* 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>
|
* @author Monte Ohrt <monte at ohrt dot com>
|
||||||
*
|
*
|
||||||
* @param string $string input string
|
* @param string $string input string
|
||||||
|
|||||||
@@ -13,7 +13,8 @@
|
|||||||
* optionally splitting in the middle of a word, and
|
* optionally splitting in the middle of a word, and
|
||||||
* appending the $etc string or inserting $etc into the middle.
|
* 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>
|
* @author Monte Ohrt <monte at ohrt dot com>
|
||||||
*
|
*
|
||||||
* @param string $string input string
|
* @param string $string input string
|
||||||
@@ -42,8 +43,8 @@ function smarty_modifier_truncate($string, $length = 80, $etc = '...', $break_wo
|
|||||||
if (!$middle) {
|
if (!$middle) {
|
||||||
return mb_substr($string, 0, $length, Smarty::$_CHARSET) . $etc;
|
return mb_substr($string, 0, $length, Smarty::$_CHARSET) . $etc;
|
||||||
}
|
}
|
||||||
return mb_substr($string, 0, $length / 2, Smarty::$_CHARSET) . $etc .
|
return mb_substr($string, 0, intval($length / 2), Smarty::$_CHARSET) . $etc .
|
||||||
mb_substr($string, -$length / 2, $length, Smarty::$_CHARSET);
|
mb_substr($string, -intval($length / 2), $length, Smarty::$_CHARSET);
|
||||||
}
|
}
|
||||||
return $string;
|
return $string;
|
||||||
}
|
}
|
||||||
@@ -56,7 +57,7 @@ function smarty_modifier_truncate($string, $length = 80, $etc = '...', $break_wo
|
|||||||
if (!$middle) {
|
if (!$middle) {
|
||||||
return substr($string, 0, $length) . $etc;
|
return substr($string, 0, $length) . $etc;
|
||||||
}
|
}
|
||||||
return substr($string, 0, $length / 2) . $etc . substr($string, -$length / 2);
|
return substr($string, 0, intval($length / 2)) . $etc . substr($string, -intval($length / 2));
|
||||||
}
|
}
|
||||||
return $string;
|
return $string;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -14,7 +14,7 @@
|
|||||||
* Input: string to catenate
|
* Input: string to catenate
|
||||||
* Example: {$var|cat:"foo"}
|
* 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)
|
* (Smarty online manual)
|
||||||
* @author Uwe Tews
|
* @author Uwe Tews
|
||||||
*
|
*
|
||||||
|
|||||||
@@ -11,8 +11,8 @@
|
|||||||
* Name: count_characters
|
* Name: count_characters
|
||||||
* Purpose: count the number of characters in a text
|
* 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
|
* @link https://www.smarty.net/docs/en/language.modifier.count.characters.php count_characters
|
||||||
* manual)
|
* (Smarty online manual)
|
||||||
* @author Uwe Tews
|
* @author Uwe Tews
|
||||||
*
|
*
|
||||||
* @param array $params parameters
|
* @param array $params parameters
|
||||||
|
|||||||
@@ -11,7 +11,7 @@
|
|||||||
* Name: count_paragraphs
|
* Name: count_paragraphs
|
||||||
* Purpose: count the number of paragraphs in a text
|
* 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)
|
* count_paragraphs (Smarty online manual)
|
||||||
* @author Uwe Tews
|
* @author Uwe Tews
|
||||||
*
|
*
|
||||||
|
|||||||
@@ -11,7 +11,7 @@
|
|||||||
* Name: count_sentences
|
* Name: count_sentences
|
||||||
* Purpose: count the number of sentences in a text
|
* 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)
|
* count_sentences (Smarty online manual)
|
||||||
* @author Uwe Tews
|
* @author Uwe Tews
|
||||||
*
|
*
|
||||||
|
|||||||
@@ -11,7 +11,8 @@
|
|||||||
* Name: count_words
|
* Name: count_words
|
||||||
* Purpose: count the number of words in a text
|
* 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
|
* @author Uwe Tews
|
||||||
*
|
*
|
||||||
* @param array $params parameters
|
* @param array $params parameters
|
||||||
|
|||||||
@@ -11,7 +11,8 @@
|
|||||||
* Name: default
|
* Name: default
|
||||||
* Purpose: designate default value for empty variables
|
* 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
|
* @author Uwe Tews
|
||||||
*
|
*
|
||||||
* @param array $params parameters
|
* @param array $params parameters
|
||||||
|
|||||||
@@ -11,19 +11,18 @@
|
|||||||
* Name: escape
|
* Name: escape
|
||||||
* Purpose: escape string for output
|
* 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
|
* @author Rodney Rehm
|
||||||
*
|
*
|
||||||
* @param array $params parameters
|
* @param array $params parameters
|
||||||
* @param Smarty_Internal_TemplateCompilerBase $compiler
|
* @param Smarty_Internal_TemplateCompilerBase $compiler
|
||||||
*
|
*
|
||||||
* @return string with compiled code
|
* @return string with compiled code
|
||||||
* @throws \SmartyException
|
* @throws SmartyException
|
||||||
*/
|
*/
|
||||||
function smarty_modifiercompiler_escape($params, Smarty_Internal_TemplateCompilerBase $compiler)
|
function smarty_modifiercompiler_escape($params, Smarty_Internal_TemplateCompilerBase $compiler)
|
||||||
{
|
{
|
||||||
static $_double_encode = true;
|
|
||||||
static $is_loaded = false;
|
|
||||||
$compiler->template->_checkPlugins(
|
$compiler->template->_checkPlugins(
|
||||||
array(
|
array(
|
||||||
array(
|
array(
|
||||||
@@ -41,53 +40,28 @@ function smarty_modifiercompiler_escape($params, Smarty_Internal_TemplateCompile
|
|||||||
}
|
}
|
||||||
switch ($esc_type) {
|
switch ($esc_type) {
|
||||||
case 'html':
|
case 'html':
|
||||||
if ($_double_encode) {
|
return 'htmlspecialchars((string)' . $params[ 0 ] . ', ENT_QUOTES, ' . var_export($char_set, true) . ', ' .
|
||||||
return 'htmlspecialchars(' . $params[ 0 ] . ', ENT_QUOTES, ' . var_export($char_set, true) . ', ' .
|
var_export($double_encode, true) . ')';
|
||||||
var_export($double_encode, true) . ')';
|
|
||||||
} elseif ($double_encode) {
|
|
||||||
return 'htmlspecialchars(' . $params[ 0 ] . ', ENT_QUOTES, ' . var_export($char_set, true) . ')';
|
|
||||||
} else {
|
|
||||||
// fall back to modifier.escape.php
|
|
||||||
}
|
|
||||||
// no break
|
|
||||||
case 'htmlall':
|
case 'htmlall':
|
||||||
if (Smarty::$_MBSTRING) {
|
if (Smarty::$_MBSTRING) {
|
||||||
if ($_double_encode) {
|
return 'htmlentities(mb_convert_encoding((string)' . $params[ 0 ] . ', \'UTF-8\', ' .
|
||||||
// php >=5.2.3 - go native
|
var_export($char_set, true) . '), ENT_QUOTES, \'UTF-8\', ' .
|
||||||
return 'mb_convert_encoding(htmlspecialchars(' . $params[ 0 ] . ', ENT_QUOTES, ' .
|
var_export($double_encode, true) . ')';
|
||||||
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(' . $params[ 0 ] . ', ENT_QUOTES, ' .
|
|
||||||
var_export($char_set, true) . '), "HTML-ENTITIES", ' . var_export($char_set, true) . ')';
|
|
||||||
} else {
|
|
||||||
// fall back to modifier.escape.php
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
// no MBString fallback
|
// no MBString fallback
|
||||||
if ($_double_encode) {
|
return 'htmlentities((string)' . $params[ 0 ] . ', ENT_QUOTES, ' . var_export($char_set, true) . ', ' .
|
||||||
// php >=5.2.3 - go native
|
var_export($double_encode, true) . ')';
|
||||||
return 'htmlentities(' . $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(' . $params[ 0 ] . ', ENT_QUOTES, ' . var_export($char_set, true) . ')';
|
|
||||||
} else {
|
|
||||||
// fall back to modifier.escape.php
|
|
||||||
}
|
|
||||||
// no break
|
|
||||||
case 'url':
|
case 'url':
|
||||||
return 'rawurlencode(' . $params[ 0 ] . ')';
|
return 'rawurlencode((string)' . $params[ 0 ] . ')';
|
||||||
case 'urlpathinfo':
|
case 'urlpathinfo':
|
||||||
return 'str_replace("%2F", "/", rawurlencode(' . $params[ 0 ] . '))';
|
return 'str_replace("%2F", "/", rawurlencode((string)' . $params[ 0 ] . '))';
|
||||||
case 'quotes':
|
case 'quotes':
|
||||||
// escape unescaped single quotes
|
// escape unescaped single quotes
|
||||||
return 'preg_replace("%(?<!\\\\\\\\)\'%", "\\\'",' . $params[ 0 ] . ')';
|
return 'preg_replace("%(?<!\\\\\\\\)\'%", "\\\'", (string)' . $params[ 0 ] . ')';
|
||||||
case 'javascript':
|
case 'javascript':
|
||||||
// escape quotes and backslashes, newlines, etc.
|
// escape quotes and backslashes, newlines, etc.
|
||||||
// see https://html.spec.whatwg.org/multipage/scripting.html#restrictions-for-contents-of-script-elements
|
// see https://html.spec.whatwg.org/multipage/scripting.html#restrictions-for-contents-of-script-elements
|
||||||
return 'strtr(' .
|
return 'strtr((string)' .
|
||||||
$params[ 0 ] .
|
$params[ 0 ] .
|
||||||
', array("\\\\" => "\\\\\\\\", "\'" => "\\\\\'", "\"" => "\\\\\"", "\\r" => "\\\\r", "\\n" => "\\\n", "</" => "<\/", "<!--" => "<\!--", "<s" => "<\s", "<S" => "<\S" ))';
|
', array("\\\\" => "\\\\\\\\", "\'" => "\\\\\'", "\"" => "\\\\\"", "\\r" => "\\\\r", "\\n" => "\\\n", "</" => "<\/", "<!--" => "<\!--", "<s" => "<\s", "<S" => "<\S" ))';
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -11,7 +11,8 @@
|
|||||||
* Name: indent
|
* Name: indent
|
||||||
* Purpose: indent lines of text
|
* 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
|
* @author Uwe Tews
|
||||||
*
|
*
|
||||||
* @param array $params parameters
|
* @param array $params parameters
|
||||||
|
|||||||
@@ -11,7 +11,8 @@
|
|||||||
* Name: lower
|
* Name: lower
|
||||||
* Purpose: convert string to lowercase
|
* 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 Monte Ohrt <monte at ohrt dot com>
|
||||||
* @author Uwe Tews
|
* @author Uwe Tews
|
||||||
*
|
*
|
||||||
|
|||||||
@@ -0,0 +1,23 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Smarty plugin
|
||||||
|
*
|
||||||
|
* @package Smarty
|
||||||
|
* @subpackage PluginsModifierCompiler
|
||||||
|
*/
|
||||||
|
/**
|
||||||
|
* Smarty nl2br modifier plugin
|
||||||
|
* Type: modifier
|
||||||
|
* Name: nl2br
|
||||||
|
* Purpose: insert HTML line breaks before all newlines in a string
|
||||||
|
*
|
||||||
|
* @link https://www.smarty.net/docs/en/language.modifier.nl2br.tpl nl2br (Smarty online manual)
|
||||||
|
*
|
||||||
|
* @param array $params parameters
|
||||||
|
*
|
||||||
|
* @return string with compiled code
|
||||||
|
*/
|
||||||
|
function smarty_modifiercompiler_nl2br($params) {
|
||||||
|
return 'nl2br((string) ' . $params[0] . ', (bool) ' . ($params[1] ?? true) . ')';
|
||||||
|
}
|
||||||
@@ -0,0 +1,23 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Smarty plugin
|
||||||
|
*
|
||||||
|
* @package Smarty
|
||||||
|
* @subpackage PluginsModifierCompiler
|
||||||
|
*/
|
||||||
|
/**
|
||||||
|
* Smarty round modifier plugin
|
||||||
|
* Type: modifier
|
||||||
|
* Name: round
|
||||||
|
* Purpose: Returns the rounded value of num to specified precision (number of digits after the decimal point)
|
||||||
|
*
|
||||||
|
* @link https://www.smarty.net/docs/en/language.modifier.round.tpl round (Smarty online manual)
|
||||||
|
*
|
||||||
|
* @param array $params parameters
|
||||||
|
*
|
||||||
|
* @return string with compiled code
|
||||||
|
*/
|
||||||
|
function smarty_modifiercompiler_round($params) {
|
||||||
|
return 'round((float) ' . $params[0] . ', (int) ' . ($params[1] ?? 0) . ', (int) ' . ($params[2] ?? PHP_ROUND_HALF_UP) . ')';
|
||||||
|
}
|
||||||
@@ -0,0 +1,23 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Smarty plugin
|
||||||
|
*
|
||||||
|
* @package Smarty
|
||||||
|
* @subpackage PluginsModifierCompiler
|
||||||
|
*/
|
||||||
|
/**
|
||||||
|
* Smarty str_repeat modifier plugin
|
||||||
|
* Type: modifier
|
||||||
|
* Name: str_repeat
|
||||||
|
* Purpose: returns string repeated times times
|
||||||
|
*
|
||||||
|
* @link https://www.smarty.net/docs/en/language.modifier.str_repeat.tpl str_repeat (Smarty online manual)
|
||||||
|
*
|
||||||
|
* @param array $params parameters
|
||||||
|
*
|
||||||
|
* @return string with compiled code
|
||||||
|
*/
|
||||||
|
function smarty_modifiercompiler_str_repeat($params) {
|
||||||
|
return 'str_repeat((string) ' . $params[0] . ', (int) ' . $params[1] . ')';
|
||||||
|
}
|
||||||
@@ -11,7 +11,8 @@
|
|||||||
* Name: string_format
|
* Name: string_format
|
||||||
* Purpose: format strings via sprintf
|
* 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
|
* @author Uwe Tews
|
||||||
*
|
*
|
||||||
* @param array $params parameters
|
* @param array $params parameters
|
||||||
|
|||||||
@@ -14,7 +14,8 @@
|
|||||||
* Example: {$var|strip} {$var|strip:" "}
|
* Example: {$var|strip} {$var|strip:" "}
|
||||||
* Date: September 25th, 2002
|
* 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
|
* @author Uwe Tews
|
||||||
*
|
*
|
||||||
* @param array $params parameters
|
* @param array $params parameters
|
||||||
|
|||||||
@@ -21,8 +21,8 @@
|
|||||||
function smarty_modifiercompiler_strip_tags($params)
|
function smarty_modifiercompiler_strip_tags($params)
|
||||||
{
|
{
|
||||||
if (!isset($params[ 1 ]) || $params[ 1 ] === true || trim($params[ 1 ], '"') === 'true') {
|
if (!isset($params[ 1 ]) || $params[ 1 ] === true || trim($params[ 1 ], '"') === 'true') {
|
||||||
return "preg_replace('!<[^>]*?>!', ' ', {$params[0]})";
|
return "preg_replace('!<[^>]*?>!', ' ', {$params[0]} ?: '')";
|
||||||
} else {
|
} else {
|
||||||
return 'strip_tags(' . $params[ 0 ] . ')';
|
return 'strip_tags((string) ' . $params[ 0 ] . ')';
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,23 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Smarty plugin
|
||||||
|
*
|
||||||
|
* @package Smarty
|
||||||
|
* @subpackage PluginsModifierCompiler
|
||||||
|
*/
|
||||||
|
/**
|
||||||
|
* Smarty strlen modifier plugin
|
||||||
|
* Type: modifier
|
||||||
|
* Name: strlen
|
||||||
|
* Purpose: return the length of the given string
|
||||||
|
*
|
||||||
|
* @link https://www.smarty.net/docs/en/language.modifier.strlen.tpl strlen (Smarty online manual)
|
||||||
|
*
|
||||||
|
* @param array $params parameters
|
||||||
|
*
|
||||||
|
* @return string with compiled code
|
||||||
|
*/
|
||||||
|
function smarty_modifiercompiler_strlen($params) {
|
||||||
|
return 'strlen((string) ' . $params[0] . ')';
|
||||||
|
}
|
||||||
@@ -14,26 +14,34 @@
|
|||||||
* @author Rodney Rehm
|
* @author Rodney Rehm
|
||||||
*
|
*
|
||||||
* @param array $params parameters
|
* @param array $params parameters
|
||||||
|
* @param Smarty_Internal_TemplateCompilerBase $compiler
|
||||||
*
|
*
|
||||||
* @return string with compiled code
|
* @return string with compiled code
|
||||||
*/
|
*/
|
||||||
function smarty_modifiercompiler_unescape($params)
|
function smarty_modifiercompiler_unescape($params, Smarty_Internal_TemplateCompilerBase $compiler)
|
||||||
{
|
{
|
||||||
if (!isset($params[ 1 ])) {
|
$compiler->template->_checkPlugins(
|
||||||
$params[ 1 ] = 'html';
|
array(
|
||||||
}
|
array(
|
||||||
|
'function' => 'smarty_literal_compiler_param',
|
||||||
|
'file' => SMARTY_PLUGINS_DIR . 'shared.literal_compiler_param.php'
|
||||||
|
)
|
||||||
|
)
|
||||||
|
);
|
||||||
|
|
||||||
|
$esc_type = smarty_literal_compiler_param($params, 1, 'html');
|
||||||
|
|
||||||
if (!isset($params[ 2 ])) {
|
if (!isset($params[ 2 ])) {
|
||||||
$params[ 2 ] = '\'' . addslashes(Smarty::$_CHARSET) . '\'';
|
$params[ 2 ] = '\'' . addslashes(Smarty::$_CHARSET) . '\'';
|
||||||
} else {
|
|
||||||
$params[ 2 ] = "'{$params[ 2 ]}'";
|
|
||||||
}
|
}
|
||||||
switch (trim($params[ 1 ], '"\'')) {
|
|
||||||
|
switch ($esc_type) {
|
||||||
case 'entity':
|
case 'entity':
|
||||||
case 'htmlall':
|
case 'htmlall':
|
||||||
if (Smarty::$_MBSTRING) {
|
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':
|
case 'html':
|
||||||
return 'htmlspecialchars_decode(' . $params[ 0 ] . ', ENT_QUOTES)';
|
return 'htmlspecialchars_decode(' . $params[ 0 ] . ', ENT_QUOTES)';
|
||||||
case 'url':
|
case 'url':
|
||||||
|
|||||||
@@ -11,7 +11,8 @@
|
|||||||
* Name: lower
|
* Name: lower
|
||||||
* Purpose: convert string to uppercase
|
* 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
|
* @author Uwe Tews
|
||||||
*
|
*
|
||||||
* @param array $params parameters
|
* @param array $params parameters
|
||||||
@@ -21,8 +22,8 @@
|
|||||||
function smarty_modifiercompiler_upper($params)
|
function smarty_modifiercompiler_upper($params)
|
||||||
{
|
{
|
||||||
if (Smarty::$_MBSTRING) {
|
if (Smarty::$_MBSTRING) {
|
||||||
return 'mb_strtoupper(' . $params[ 0 ] . ', \'' . addslashes(Smarty::$_CHARSET) . '\')';
|
return 'mb_strtoupper(' . $params[ 0 ] . ' ?? \'\', \'' . addslashes(Smarty::$_CHARSET) . '\')';
|
||||||
}
|
}
|
||||||
// no MBString fallback
|
// no MBString fallback
|
||||||
return 'strtoupper(' . $params[ 0 ] . ')';
|
return 'strtoupper(' . $params[ 0 ] . ' ?? \'\')';
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -11,7 +11,8 @@
|
|||||||
* Name: wordwrap
|
* Name: wordwrap
|
||||||
* Purpose: wrap a string of text at a given length
|
* 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
|
* @author Uwe Tews
|
||||||
*
|
*
|
||||||
* @param array $params parameters
|
* @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 ])) {
|
if (!preg_match('/^([\'"]?)[a-zA-Z0-9-]+(\\1)$/', $params[ $index ])) {
|
||||||
throw new SmartyException(
|
throw new SmartyException(
|
||||||
'$param[' . $index .
|
'$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;
|
$t = null;
|
||||||
|
|||||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user