mirror of
https://github.com/smarty-php/smarty.git
synced 2025-09-26 04:10:54 +02:00
Feature/php8 support (#629)
Adds support for PHP8.0, dropping support for PHP7.0 and below. Backwards incompatible changes: - Dropped support for php asp tags in templates (removed from php since php7.0) - Dropped deprecated API calls that where only accessible through SmartyBC - Dropped support for {php} and {include_php} tags and embedded PHP in templates. Embedded PHP will now be passed through as is. - Removed all PHP_VERSION_ID and compare_version checks and conditional code blocks that are now no longer required - Dropped deprecated SMARTY_RESOURCE_CHAR_SET and SMARTY_RESOURCE_DATE_FORMAT constants - Dropped deprecated Smarty::muteExpectedErrors and Smarty::unmuteExpectedErrors API methods - Dropped deprecated $smarty->getVariable() method. Use $smarty->getTemplateVars() instead. - $smarty->registerResource() no longer accepts an array of callback functions See the changelog for more details. Switched CI from Travis to Github CI.
This commit is contained in:
2
.gitattributes
vendored
2
.gitattributes
vendored
@@ -11,9 +11,7 @@
|
|||||||
|
|
||||||
/.gitattributes export-ignore
|
/.gitattributes export-ignore
|
||||||
/.gitignore export-ignore
|
/.gitignore export-ignore
|
||||||
/.travis.yml export-ignore
|
|
||||||
/make-release.sh export-ignore
|
/make-release.sh export-ignore
|
||||||
/phpunit.sh export-ignore
|
/phpunit.sh export-ignore
|
||||||
/phpunit.xml export-ignore
|
/phpunit.xml export-ignore
|
||||||
/TODO.md export-ignore
|
/TODO.md export-ignore
|
||||||
/travis.ini export-ignore
|
|
||||||
|
73
.github/workflows/ci.yml
vendored
Normal file
73
.github/workflows/ci.yml
vendored
Normal file
@@ -0,0 +1,73 @@
|
|||||||
|
# https://help.github.com/en/categories/automating-your-workflow-with-github-actions
|
||||||
|
|
||||||
|
on:
|
||||||
|
- pull_request
|
||||||
|
- push
|
||||||
|
|
||||||
|
name: CI
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
tests:
|
||||||
|
name: Tests
|
||||||
|
|
||||||
|
runs-on: ${{ matrix.os }}
|
||||||
|
|
||||||
|
env:
|
||||||
|
PHP_EXTENSIONS: dom, json, libxml, mbstring, pdo_sqlite, soap, xml, xmlwriter
|
||||||
|
PHP_INI_VALUES: assert.exception=1, zend.assertions=1
|
||||||
|
|
||||||
|
strategy:
|
||||||
|
fail-fast: false
|
||||||
|
matrix:
|
||||||
|
os:
|
||||||
|
- ubuntu-latest
|
||||||
|
|
||||||
|
php-version:
|
||||||
|
- "7.1"
|
||||||
|
- "7.2"
|
||||||
|
- "7.3"
|
||||||
|
- "7.4"
|
||||||
|
- "8.0"
|
||||||
|
|
||||||
|
compiler:
|
||||||
|
- default
|
||||||
|
|
||||||
|
include:
|
||||||
|
- os: ubuntu-latest
|
||||||
|
php-version: "8.0"
|
||||||
|
compiler: jit
|
||||||
|
|
||||||
|
steps:
|
||||||
|
- name: Checkout
|
||||||
|
uses: actions/checkout@v2
|
||||||
|
|
||||||
|
- name: Override PHP ini values for JIT compiler
|
||||||
|
if: matrix.compiler == 'jit'
|
||||||
|
run: echo "PHP_INI_VALUES::assert.exception=1, zend.assertions=1, opcache.enable=1, opcache.enable_cli=1, opcache.optimization_level=-1, opcache.jit=1255, opcache.jit_buffer_size=32M" >> $GITHUB_ENV
|
||||||
|
|
||||||
|
- name: Install PHP with extensions
|
||||||
|
uses: shivammathur/setup-php@v2
|
||||||
|
with:
|
||||||
|
php-version: ${{ matrix.php-version }}
|
||||||
|
coverage: pcov
|
||||||
|
extensions: ${{ env.PHP_EXTENSIONS }}
|
||||||
|
ini-values: ${{ env.PHP_INI_VALUES }}
|
||||||
|
|
||||||
|
- name: Validate composer.json and composer.lock
|
||||||
|
run: composer validate
|
||||||
|
|
||||||
|
- name: Cache Composer packages
|
||||||
|
id: composer-cache
|
||||||
|
uses: actions/cache@v2
|
||||||
|
with:
|
||||||
|
path: vendor
|
||||||
|
key: ${{ runner.os }}-php-${{ matrix.php-version }}-${{ hashFiles('**/composer.lock') }}
|
||||||
|
restore-keys: |
|
||||||
|
${{ 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
|
||||||
|
run: ./phpunit.sh
|
1
.gitignore
vendored
1
.gitignore
vendored
@@ -9,5 +9,6 @@ utilies/*.php
|
|||||||
|
|
||||||
# Dev
|
# Dev
|
||||||
phpunit*
|
phpunit*
|
||||||
|
.phpunit.result.cache
|
||||||
vendor/*
|
vendor/*
|
||||||
composer.lock
|
composer.lock
|
||||||
|
39
.travis.yml
39
.travis.yml
@@ -1,39 +0,0 @@
|
|||||||
language: php
|
|
||||||
os: linux
|
|
||||||
dist: xenial
|
|
||||||
|
|
||||||
install:
|
|
||||||
- travis_retry composer install
|
|
||||||
|
|
||||||
jobs:
|
|
||||||
include:
|
|
||||||
- php: 5.3 # Composer and PHPUnit require PHP 5.3.2+ to run, so we cannot test below 5.3
|
|
||||||
dist: precise # PHP 5.3 is supported only on Precise.
|
|
||||||
- php: 5.4
|
|
||||||
dist: trusty # PHP 5.4 is supported only on Trusty.
|
|
||||||
- php: 5.5
|
|
||||||
dist: trusty # PHP 5.5 is supported only on Trusty.
|
|
||||||
- php: 5.6
|
|
||||||
- php: 7.0
|
|
||||||
- php: 7.1
|
|
||||||
- php: 7.2
|
|
||||||
- php: 7.3
|
|
||||||
- php: 7.4
|
|
||||||
- php: nightly
|
|
||||||
install: travis_retry composer config platform.php 7.4.0 && composer install
|
|
||||||
fast_finish: true
|
|
||||||
allow_failures:
|
|
||||||
- php: nightly # PHP 8 is still in beta
|
|
||||||
|
|
||||||
services:
|
|
||||||
- memcached
|
|
||||||
- mysql
|
|
||||||
|
|
||||||
before_script:
|
|
||||||
- mysql -e "create database IF NOT EXISTS test;" -uroot
|
|
||||||
|
|
||||||
before_install:
|
|
||||||
- phpenv config-rm xdebug.ini || return 0
|
|
||||||
|
|
||||||
script:
|
|
||||||
- ./phpunit.sh
|
|
18
CHANGELOG.md
18
CHANGELOG.md
@@ -6,6 +6,24 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
|||||||
|
|
||||||
## [Unreleased]
|
## [Unreleased]
|
||||||
|
|
||||||
|
### Added
|
||||||
|
- You can now use `$smarty->muteUndefinedOrNullWarnings()` to activate convert warnings about undefined or null template vars to notices when running PHP8
|
||||||
|
|
||||||
|
### Changed
|
||||||
|
- Switch CI from Travis to Github CI
|
||||||
|
- Updated unit tests to avoid skipped and risky test warnings
|
||||||
|
|
||||||
|
### Removed
|
||||||
|
- Dropped support for PHP7.0 and below, so Smarty now requires PHP >=7.1
|
||||||
|
- Dropped support for php asp tags in templates (removed from php since php7.0)
|
||||||
|
- Dropped deprecated API calls that where only accessible through SmartyBC
|
||||||
|
- Dropped support for {php} and {include_php} tags and embedded PHP in templates. Embedded PHP will now be passed through as is.
|
||||||
|
- Removed all PHP_VERSION_ID and compare_version checks and conditional code blocks that are now no longer required
|
||||||
|
- Dropped deprecated SMARTY_RESOURCE_CHAR_SET and SMARTY_RESOURCE_DATE_FORMAT constants
|
||||||
|
- Dropped deprecated Smarty::muteExpectedErrors and Smarty::unmuteExpectedErrors API methods
|
||||||
|
- Dropped deprecated $smarty->getVariable() method. Use $smarty->getTemplateVars() instead.
|
||||||
|
- $smarty->registerResource() no longer accepts an array of callback functions
|
||||||
|
|
||||||
## [3.1.40] - 2021-10-13
|
## [3.1.40] - 2021-10-13
|
||||||
|
|
||||||
### Changed
|
### Changed
|
||||||
|
2
README
2
README
@@ -51,7 +51,7 @@ $smarty->unregisterFilter(...)
|
|||||||
|
|
||||||
Please refer to the online documentation for all specific changes:
|
Please refer to the online documentation for all specific changes:
|
||||||
|
|
||||||
http://www.smarty.net/documentation
|
https://www.smarty.net/documentation
|
||||||
|
|
||||||
----
|
----
|
||||||
|
|
||||||
|
@@ -1,7 +1,7 @@
|
|||||||
# Smarty 3 template engine
|
# Smarty 3 template engine
|
||||||
[smarty.net](https://www.smarty.net/)
|
[smarty.net](https://www.smarty.net/)
|
||||||
|
|
||||||
[](https://travis-ci.org/smarty-php/smarty)
|

|
||||||
|
|
||||||
## Documentation
|
## Documentation
|
||||||
|
|
||||||
@@ -9,8 +9,7 @@ For documentation see
|
|||||||
[www.smarty.net/docs/en/](https://www.smarty.net/docs/en/)
|
[www.smarty.net/docs/en/](https://www.smarty.net/docs/en/)
|
||||||
|
|
||||||
## Requirements
|
## Requirements
|
||||||
|
Smarty can be run with PHP 7.1 to PHP 8.0.
|
||||||
Smarty can be run with PHP 5.2 to PHP 7.4.
|
|
||||||
|
|
||||||
## Distribution repository
|
## Distribution repository
|
||||||
|
|
||||||
@@ -74,5 +73,3 @@ Or you could use:
|
|||||||
```
|
```
|
||||||
|
|
||||||
Which is a wrapper to install all 3 packages.
|
Which is a wrapper to install all 3 packages.
|
||||||
|
|
||||||
Composer can also be used for Smarty2 versions 2.6.24 to 2.6.30.
|
|
||||||
|
@@ -5,7 +5,7 @@
|
|||||||
"keywords": [
|
"keywords": [
|
||||||
"templating"
|
"templating"
|
||||||
],
|
],
|
||||||
"homepage": "http://www.smarty.net",
|
"homepage": "https://www.smarty.net",
|
||||||
"license": "LGPL-3.0",
|
"license": "LGPL-3.0",
|
||||||
"authors": [
|
"authors": [
|
||||||
{
|
{
|
||||||
@@ -19,15 +19,18 @@
|
|||||||
{
|
{
|
||||||
"name": "Rodney Rehm",
|
"name": "Rodney Rehm",
|
||||||
"email": "rodney.rehm@medialize.de"
|
"email": "rodney.rehm@medialize.de"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "Simon Wisselink",
|
||||||
|
"homepage": "https://www.iwink.nl/"
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
"support": {
|
"support": {
|
||||||
"irc": "irc://irc.freenode.org/smarty",
|
|
||||||
"issues": "https://github.com/smarty-php/smarty/issues",
|
"issues": "https://github.com/smarty-php/smarty/issues",
|
||||||
"forum": "http://www.smarty.net/forums/"
|
"forum": "https://www.smarty.net/forums/"
|
||||||
},
|
},
|
||||||
"require": {
|
"require": {
|
||||||
"php": ">=5.2"
|
"php": "^7.1 || ^8.0"
|
||||||
},
|
},
|
||||||
"autoload": {
|
"autoload": {
|
||||||
"classmap": [
|
"classmap": [
|
||||||
@@ -36,11 +39,11 @@
|
|||||||
},
|
},
|
||||||
"extra": {
|
"extra": {
|
||||||
"branch-alias": {
|
"branch-alias": {
|
||||||
"dev-master": "3.1.x-dev"
|
"dev-master": "4.0.x-dev"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"require-dev": {
|
"require-dev": {
|
||||||
"phpunit/phpunit": "^7.5 || ^6.5 || ^5.7 || ^4.8",
|
"phpunit/phpunit": "^8.5 || ^7.5",
|
||||||
"smarty/smarty-lexer": "^3.1"
|
"smarty/smarty-lexer": "^3.1"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -289,8 +289,6 @@ class Smarty_Internal_Templatelexer
|
|||||||
textdoublequoted = ~([^"\\]*?)((?:\\.[^"\\]*?)*?)(?=((SMARTYldel)SMARTYal|\$|`\$|"SMARTYliteral))~
|
textdoublequoted = ~([^"\\]*?)((?:\\.[^"\\]*?)*?)(?=((SMARTYldel)SMARTYal|\$|`\$|"SMARTYliteral))~
|
||||||
namespace = ~([0-9]*[a-zA-Z_]\w*)?(\\[0-9]*[a-zA-Z_]\w*)+~
|
namespace = ~([0-9]*[a-zA-Z_]\w*)?(\\[0-9]*[a-zA-Z_]\w*)+~
|
||||||
emptyjava = ~[{][}]~
|
emptyjava = ~[{][}]~
|
||||||
phptag = ~(SMARTYldel)SMARTYalphp([ ].*?)?SMARTYrdel|(SMARTYldel)SMARTYal[/]phpSMARTYrdel~
|
|
||||||
phpstart = ~[<][?]((php\s+|=)|\s+)|[<][%]|[<][?]xml\s+|[<]script\s+language\s*=\s*["']?\s*php\s*["']?\s*[>]|[?][>]|[%][>]~
|
|
||||||
slash = ~[/]~
|
slash = ~[/]~
|
||||||
ldel = ~(SMARTYldel)SMARTYal~
|
ldel = ~(SMARTYldel)SMARTYal~
|
||||||
rdel = ~\s*SMARTYrdel~
|
rdel = ~\s*SMARTYrdel~
|
||||||
@@ -362,9 +360,6 @@ class Smarty_Internal_Templatelexer
|
|||||||
$this->value = substr($this->data,$this->counter,$to-$this->counter);
|
$this->value = substr($this->data,$this->counter,$to-$this->counter);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
phptag {
|
|
||||||
$this->compiler->getTagCompiler('private_php')->parsePhp($this);
|
|
||||||
}
|
|
||||||
userliteral {
|
userliteral {
|
||||||
$this->token = Smarty_Internal_Templateparser::TP_TEXT;
|
$this->token = Smarty_Internal_Templateparser::TP_TEXT;
|
||||||
}
|
}
|
||||||
@@ -380,12 +375,9 @@ class Smarty_Internal_Templatelexer
|
|||||||
$this->yypushstate(self::TAG);
|
$this->yypushstate(self::TAG);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
phpstart {
|
|
||||||
$this->compiler->getTagCompiler('private_php')->parsePhp($this);
|
|
||||||
}
|
|
||||||
char {
|
char {
|
||||||
if (!isset($this->yy_global_text)) {
|
if (!isset($this->yy_global_text)) {
|
||||||
$this->yy_global_text = $this->replace('/(SMARTYldel)SMARTYal|[<][?]((php\s+|=)|\s+)|[<][%]|[<][?]xml\s+|[<]script\s+language\s*=\s*["\']?\s*php\s*["\']?\s*[>]|[?][>]|[%][>]SMARTYliteral/isS');
|
$this->yy_global_text = $this->replace('/(SMARTYldel)SMARTYal/isS');
|
||||||
}
|
}
|
||||||
$to = $this->dataLength;
|
$to = $this->dataLength;
|
||||||
preg_match($this->yy_global_text, $this->data,$match,PREG_OFFSET_CAPTURE,$this->counter);
|
preg_match($this->yy_global_text, $this->data,$match,PREG_OFFSET_CAPTURE,$this->counter);
|
||||||
|
@@ -23,7 +23,6 @@ class Smarty_Internal_Templateparser
|
|||||||
{
|
{
|
||||||
const ERR1 = 'Security error: Call to private object member not allowed';
|
const ERR1 = 'Security error: Call to private object member not allowed';
|
||||||
const ERR2 = 'Security error: Call to dynamic object member not allowed';
|
const ERR2 = 'Security error: Call to dynamic object member not allowed';
|
||||||
const ERR3 = 'PHP in template not allowed. Use SmartyBC to enable it';
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* result status
|
* result status
|
||||||
@@ -237,16 +236,6 @@ start(res) ::= template. {
|
|||||||
res = $this->root_buffer->to_smarty_php($this);
|
res = $this->root_buffer->to_smarty_php($this);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// php tags
|
|
||||||
template ::= template PHP(B). {
|
|
||||||
$code = $this->compiler->compileTag('private_php',array(array('code' => B), array('type' => $this->lex->phpType )),array());
|
|
||||||
if ($this->compiler->has_code && !empty($code)) {
|
|
||||||
$tmp =''; foreach ($this->compiler->prefix_code as $code) {$tmp.=$code;} $this->compiler->prefix_code=array();
|
|
||||||
$this->current_buffer->append_subtree($this, new Smarty_Internal_ParseTree_Tag($this, $this->compiler->processNocacheCode($tmp.$code,true)));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// template text
|
// template text
|
||||||
template ::= template TEXT(B). {
|
template ::= template TEXT(B). {
|
||||||
$text = $this->yystack[ $this->yyidx + 0 ]->minor;
|
$text = $this->yystack[ $this->yyidx + 0 ]->minor;
|
||||||
|
@@ -39,7 +39,7 @@ class Smarty_Autoloader
|
|||||||
*
|
*
|
||||||
* @var array
|
* @var array
|
||||||
*/
|
*/
|
||||||
public static $rootClasses = array('smarty' => 'Smarty.class.php', 'smartybc' => 'SmartyBC.class.php',);
|
public static $rootClasses = array('smarty' => 'Smarty.class.php');
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Registers Smarty_Autoloader backward compatible to older installations.
|
* Registers Smarty_Autoloader backward compatible to older installations.
|
||||||
@@ -76,11 +76,7 @@ class Smarty_Autoloader
|
|||||||
self::$SMARTY_DIR = defined('SMARTY_DIR') ? SMARTY_DIR : dirname(__FILE__) . DIRECTORY_SEPARATOR;
|
self::$SMARTY_DIR = defined('SMARTY_DIR') ? SMARTY_DIR : dirname(__FILE__) . 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;
|
||||||
if (version_compare(PHP_VERSION, '5.3.0', '>=')) {
|
spl_autoload_register(array(__CLASS__, 'autoload'), true, $prepend);
|
||||||
spl_autoload_register(array(__CLASS__, 'autoload'), true, $prepend);
|
|
||||||
} else {
|
|
||||||
spl_autoload_register(array(__CLASS__, 'autoload'));
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@@ -20,7 +20,7 @@
|
|||||||
* Smarty mailing list. Send a blank e-mail to
|
* Smarty mailing list. Send a blank e-mail to
|
||||||
* smarty-discussion-subscribe@googlegroups.com
|
* smarty-discussion-subscribe@googlegroups.com
|
||||||
*
|
*
|
||||||
* @link http://www.smarty.net/
|
* @link https://www.smarty.net/
|
||||||
* @copyright 2018 New Digital Group, Inc.
|
* @copyright 2018 New Digital Group, Inc.
|
||||||
* @copyright 2018 Uwe Tews
|
* @copyright 2018 Uwe Tews
|
||||||
* @author Monte Ohrt <monte at ohrt dot com>
|
* @author Monte Ohrt <monte at ohrt dot com>
|
||||||
@@ -60,19 +60,6 @@ if (!defined('SMARTY_MBSTRING')) {
|
|||||||
*/
|
*/
|
||||||
define('SMARTY_MBSTRING', function_exists('mb_get_info'));
|
define('SMARTY_MBSTRING', function_exists('mb_get_info'));
|
||||||
}
|
}
|
||||||
if (!defined('SMARTY_RESOURCE_CHAR_SET')) {
|
|
||||||
// UTF-8 can only be done properly when mbstring is available!
|
|
||||||
/**
|
|
||||||
* @deprecated in favor of Smarty::$_CHARSET
|
|
||||||
*/
|
|
||||||
define('SMARTY_RESOURCE_CHAR_SET', SMARTY_MBSTRING ? 'UTF-8' : 'ISO-8859-1');
|
|
||||||
}
|
|
||||||
if (!defined('SMARTY_RESOURCE_DATE_FORMAT')) {
|
|
||||||
/**
|
|
||||||
* @deprecated in favor of Smarty::$_DATE_FORMAT
|
|
||||||
*/
|
|
||||||
define('SMARTY_RESOURCE_DATE_FORMAT', '%b %e, %Y');
|
|
||||||
}
|
|
||||||
/**
|
/**
|
||||||
* Load Smarty_Autoloader
|
* Load Smarty_Autoloader
|
||||||
*/
|
*/
|
||||||
@@ -143,13 +130,7 @@ 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;
|
||||||
/**
|
|
||||||
* modes for handling of "<?php ... ?>" tags in templates.
|
|
||||||
*/
|
|
||||||
const PHP_PASSTHRU = 0; //-> print tags as plain text
|
|
||||||
const PHP_QUOTE = 1; //-> escape tags as entities
|
|
||||||
const PHP_REMOVE = 2; //-> escape tags as entities
|
|
||||||
const PHP_ALLOW = 3; //-> escape tags as entities
|
|
||||||
/**
|
/**
|
||||||
* filter types
|
* filter types
|
||||||
*/
|
*/
|
||||||
@@ -179,13 +160,13 @@ class Smarty extends Smarty_Internal_TemplateBase
|
|||||||
/**
|
/**
|
||||||
* The character set to adhere to (e.g. "UTF-8")
|
* The character set to adhere to (e.g. "UTF-8")
|
||||||
*/
|
*/
|
||||||
public static $_CHARSET = SMARTY_RESOURCE_CHAR_SET;
|
public static $_CHARSET = SMARTY_MBSTRING ? 'UTF-8' : 'ISO-8859-1';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The date format to be used internally
|
* The date format to be used internally
|
||||||
* (accepts date() and strftime())
|
* (accepts date() and strftime())
|
||||||
*/
|
*/
|
||||||
public static $_DATE_FORMAT = SMARTY_RESOURCE_DATE_FORMAT;
|
public static $_DATE_FORMAT = '%b %e, %Y';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Flag denoting if PCRE should run in UTF-8 mode
|
* Flag denoting if PCRE should run in UTF-8 mode
|
||||||
@@ -369,13 +350,6 @@ class Smarty extends Smarty_Internal_TemplateBase
|
|||||||
*/
|
*/
|
||||||
public $security_policy = null;
|
public $security_policy = null;
|
||||||
|
|
||||||
/**
|
|
||||||
* controls handling of PHP-blocks
|
|
||||||
*
|
|
||||||
* @var integer
|
|
||||||
*/
|
|
||||||
public $php_handling = self::PHP_PASSTHRU;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* controls if the php template file resource is allowed
|
* controls if the php template file resource is allowed
|
||||||
*
|
*
|
||||||
@@ -666,6 +640,12 @@ class Smarty extends Smarty_Internal_TemplateBase
|
|||||||
'cache_dir' => 'CacheDir',
|
'cache_dir' => 'CacheDir',
|
||||||
);
|
);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* PHP7 Compatibility mode
|
||||||
|
* @var bool
|
||||||
|
*/
|
||||||
|
private $isMutingUndefinedOrNullWarnings = false;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Initialize new Smarty object
|
* Initialize new Smarty object
|
||||||
*/
|
*/
|
||||||
@@ -688,27 +668,6 @@ class Smarty extends Smarty_Internal_TemplateBase
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Enable error handler to mute expected messages
|
|
||||||
*
|
|
||||||
* @return boolean
|
|
||||||
* @deprecated
|
|
||||||
*/
|
|
||||||
public static function muteExpectedErrors()
|
|
||||||
{
|
|
||||||
return Smarty_Internal_ErrorHandler::muteExpectedErrors();
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Disable error handler muting expected messages
|
|
||||||
*
|
|
||||||
* @deprecated
|
|
||||||
*/
|
|
||||||
public static function unmuteExpectedErrors()
|
|
||||||
{
|
|
||||||
restore_error_handler();
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Check if a template resource exists
|
* Check if a template resource exists
|
||||||
*
|
*
|
||||||
@@ -1387,11 +1346,6 @@ 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);
|
||||||
if (class_exists('Smarty_Internal_ErrorHandler', false)) {
|
|
||||||
if (!isset(Smarty_Internal_ErrorHandler::$mutedDirectories[ $this->{$dirName} ])) {
|
|
||||||
Smarty_Internal_ErrorHandler::$mutedDirectories[ $this->{$dirName} ] = null;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -1421,4 +1375,23 @@ class Smarty extends Smarty_Internal_TemplateBase
|
|||||||
$isConfig ? $this->_joined_config_dir = join('#', $this->config_dir) :
|
$isConfig ? $this->_joined_config_dir = join('#', $this->config_dir) :
|
||||||
$this->_joined_template_dir = join('#', $this->template_dir);
|
$this->_joined_template_dir = join('#', $this->template_dir);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Activates PHP7 compatibility mode:
|
||||||
|
* - converts E_WARNINGS for "undefined array key" and "trying to read property of null" errors to E_NOTICE
|
||||||
|
*
|
||||||
|
* @void
|
||||||
|
*/
|
||||||
|
public function muteUndefinedOrNullWarnings(): void {
|
||||||
|
$this->isMutingUndefinedOrNullWarnings = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Indicates if PHP7 compatibility mode is set.
|
||||||
|
* @bool
|
||||||
|
*/
|
||||||
|
public function isMutingUndefinedOrNullWarnings(): bool {
|
||||||
|
return $this->isMutingUndefinedOrNullWarnings;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@@ -1,477 +0,0 @@
|
|||||||
<?php
|
|
||||||
/**
|
|
||||||
* Project: Smarty: the PHP compiling template engine
|
|
||||||
* File: SmartyBC.class.php
|
|
||||||
* SVN: $Id: $
|
|
||||||
* This library is free software; you can redistribute it and/or
|
|
||||||
* modify it under the terms of the GNU Lesser General Public
|
|
||||||
* License as published by the Free Software Foundation; either
|
|
||||||
* version 3.0 of the License, or (at your option) any later version.
|
|
||||||
* This library is distributed in the hope that it will be useful,
|
|
||||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
||||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
||||||
* Lesser General Public License for more details.
|
|
||||||
* You should have received a copy of the GNU Lesser General Public
|
|
||||||
* License along with this library; if not, write to the Free Software
|
|
||||||
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
|
||||||
* For questions, help, comments, discussion, etc., please join the
|
|
||||||
* Smarty mailing list. Send a blank e-mail to
|
|
||||||
* smarty-discussion-subscribe@googlegroups.com
|
|
||||||
*
|
|
||||||
* @link http://www.smarty.net/
|
|
||||||
* @copyright 2008 New Digital Group, Inc.
|
|
||||||
* @author Monte Ohrt <monte at ohrt dot com>
|
|
||||||
* @author Uwe Tews
|
|
||||||
* @author Rodney Rehm
|
|
||||||
* @package Smarty
|
|
||||||
*/
|
|
||||||
/**
|
|
||||||
* @ignore
|
|
||||||
*/
|
|
||||||
require_once dirname(__FILE__) . '/Smarty.class.php';
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Smarty Backward Compatibility Wrapper Class
|
|
||||||
*
|
|
||||||
* @package Smarty
|
|
||||||
*/
|
|
||||||
class SmartyBC extends Smarty
|
|
||||||
{
|
|
||||||
/**
|
|
||||||
* Smarty 2 BC
|
|
||||||
*
|
|
||||||
* @var string
|
|
||||||
*/
|
|
||||||
public $_version = self::SMARTY_VERSION;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* This is an array of directories where trusted php scripts reside.
|
|
||||||
*
|
|
||||||
* @var array
|
|
||||||
*/
|
|
||||||
public $trusted_dir = array();
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Initialize new SmartyBC object
|
|
||||||
*/
|
|
||||||
public function __construct()
|
|
||||||
{
|
|
||||||
parent::__construct();
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* wrapper for assign_by_ref
|
|
||||||
*
|
|
||||||
* @param string $tpl_var the template variable name
|
|
||||||
* @param mixed &$value the referenced value to assign
|
|
||||||
*/
|
|
||||||
public function assign_by_ref($tpl_var, &$value)
|
|
||||||
{
|
|
||||||
$this->assignByRef($tpl_var, $value);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* wrapper for append_by_ref
|
|
||||||
*
|
|
||||||
* @param string $tpl_var the template variable name
|
|
||||||
* @param mixed &$value the referenced value to append
|
|
||||||
* @param boolean $merge flag if array elements shall be merged
|
|
||||||
*/
|
|
||||||
public function append_by_ref($tpl_var, &$value, $merge = false)
|
|
||||||
{
|
|
||||||
$this->appendByRef($tpl_var, $value, $merge);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* clear the given assigned template variable.
|
|
||||||
*
|
|
||||||
* @param string $tpl_var the template variable to clear
|
|
||||||
*/
|
|
||||||
public function clear_assign($tpl_var)
|
|
||||||
{
|
|
||||||
$this->clearAssign($tpl_var);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Registers custom function to be used in templates
|
|
||||||
*
|
|
||||||
* @param string $function the name of the template function
|
|
||||||
* @param string $function_impl the name of the PHP function to register
|
|
||||||
* @param bool $cacheable
|
|
||||||
* @param mixed $cache_attrs
|
|
||||||
*
|
|
||||||
* @throws \SmartyException
|
|
||||||
*/
|
|
||||||
public function register_function($function, $function_impl, $cacheable = true, $cache_attrs = null)
|
|
||||||
{
|
|
||||||
$this->registerPlugin('function', $function, $function_impl, $cacheable, $cache_attrs);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Unregister custom function
|
|
||||||
*
|
|
||||||
* @param string $function name of template function
|
|
||||||
*/
|
|
||||||
public function unregister_function($function)
|
|
||||||
{
|
|
||||||
$this->unregisterPlugin('function', $function);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Registers object to be used in templates
|
|
||||||
*
|
|
||||||
* @param string $object name of template object
|
|
||||||
* @param object $object_impl the referenced PHP object to register
|
|
||||||
* @param array $allowed list of allowed methods (empty = all)
|
|
||||||
* @param boolean $smarty_args smarty argument format, else traditional
|
|
||||||
* @param array $block_methods list of methods that are block format
|
|
||||||
*
|
|
||||||
* @throws SmartyException
|
|
||||||
* @internal param array $block_functs list of methods that are block format
|
|
||||||
*/
|
|
||||||
public function register_object(
|
|
||||||
$object,
|
|
||||||
$object_impl,
|
|
||||||
$allowed = array(),
|
|
||||||
$smarty_args = true,
|
|
||||||
$block_methods = array()
|
|
||||||
) {
|
|
||||||
settype($allowed, 'array');
|
|
||||||
settype($smarty_args, 'boolean');
|
|
||||||
$this->registerObject($object, $object_impl, $allowed, $smarty_args, $block_methods);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Unregister object
|
|
||||||
*
|
|
||||||
* @param string $object name of template object
|
|
||||||
*/
|
|
||||||
public function unregister_object($object)
|
|
||||||
{
|
|
||||||
$this->unregisterObject($object);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Registers block function to be used in templates
|
|
||||||
*
|
|
||||||
* @param string $block name of template block
|
|
||||||
* @param string $block_impl PHP function to register
|
|
||||||
* @param bool $cacheable
|
|
||||||
* @param mixed $cache_attrs
|
|
||||||
*
|
|
||||||
* @throws \SmartyException
|
|
||||||
*/
|
|
||||||
public function register_block($block, $block_impl, $cacheable = true, $cache_attrs = null)
|
|
||||||
{
|
|
||||||
$this->registerPlugin('block', $block, $block_impl, $cacheable, $cache_attrs);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Unregister block function
|
|
||||||
*
|
|
||||||
* @param string $block name of template function
|
|
||||||
*/
|
|
||||||
public function unregister_block($block)
|
|
||||||
{
|
|
||||||
$this->unregisterPlugin('block', $block);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Registers compiler function
|
|
||||||
*
|
|
||||||
* @param string $function name of template function
|
|
||||||
* @param string $function_impl name of PHP function to register
|
|
||||||
* @param bool $cacheable
|
|
||||||
*
|
|
||||||
* @throws \SmartyException
|
|
||||||
*/
|
|
||||||
public function register_compiler_function($function, $function_impl, $cacheable = true)
|
|
||||||
{
|
|
||||||
$this->registerPlugin('compiler', $function, $function_impl, $cacheable);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Unregister compiler function
|
|
||||||
*
|
|
||||||
* @param string $function name of template function
|
|
||||||
*/
|
|
||||||
public function unregister_compiler_function($function)
|
|
||||||
{
|
|
||||||
$this->unregisterPlugin('compiler', $function);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Registers modifier to be used in templates
|
|
||||||
*
|
|
||||||
* @param string $modifier name of template modifier
|
|
||||||
* @param string $modifier_impl name of PHP function to register
|
|
||||||
*
|
|
||||||
* @throws \SmartyException
|
|
||||||
*/
|
|
||||||
public function register_modifier($modifier, $modifier_impl)
|
|
||||||
{
|
|
||||||
$this->registerPlugin('modifier', $modifier, $modifier_impl);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Unregister modifier
|
|
||||||
*
|
|
||||||
* @param string $modifier name of template modifier
|
|
||||||
*/
|
|
||||||
public function unregister_modifier($modifier)
|
|
||||||
{
|
|
||||||
$this->unregisterPlugin('modifier', $modifier);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Registers a resource to fetch a template
|
|
||||||
*
|
|
||||||
* @param string $type name of resource
|
|
||||||
* @param array $functions array of functions to handle resource
|
|
||||||
*/
|
|
||||||
public function register_resource($type, $functions)
|
|
||||||
{
|
|
||||||
$this->registerResource($type, $functions);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Unregister a resource
|
|
||||||
*
|
|
||||||
* @param string $type name of resource
|
|
||||||
*/
|
|
||||||
public function unregister_resource($type)
|
|
||||||
{
|
|
||||||
$this->unregisterResource($type);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Registers a prefilter function to apply
|
|
||||||
* to a template before compiling
|
|
||||||
*
|
|
||||||
* @param callable $function
|
|
||||||
*
|
|
||||||
* @throws \SmartyException
|
|
||||||
*/
|
|
||||||
public function register_prefilter($function)
|
|
||||||
{
|
|
||||||
$this->registerFilter('pre', $function);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Unregister a prefilter function
|
|
||||||
*
|
|
||||||
* @param callable $function
|
|
||||||
*/
|
|
||||||
public function unregister_prefilter($function)
|
|
||||||
{
|
|
||||||
$this->unregisterFilter('pre', $function);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Registers a postfilter function to apply
|
|
||||||
* to a compiled template after compilation
|
|
||||||
*
|
|
||||||
* @param callable $function
|
|
||||||
*
|
|
||||||
* @throws \SmartyException
|
|
||||||
*/
|
|
||||||
public function register_postfilter($function)
|
|
||||||
{
|
|
||||||
$this->registerFilter('post', $function);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Unregister a postfilter function
|
|
||||||
*
|
|
||||||
* @param callable $function
|
|
||||||
*/
|
|
||||||
public function unregister_postfilter($function)
|
|
||||||
{
|
|
||||||
$this->unregisterFilter('post', $function);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Registers an output filter function to apply
|
|
||||||
* to a template output
|
|
||||||
*
|
|
||||||
* @param callable $function
|
|
||||||
*
|
|
||||||
* @throws \SmartyException
|
|
||||||
*/
|
|
||||||
public function register_outputfilter($function)
|
|
||||||
{
|
|
||||||
$this->registerFilter('output', $function);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Unregister an outputfilter function
|
|
||||||
*
|
|
||||||
* @param callable $function
|
|
||||||
*/
|
|
||||||
public function unregister_outputfilter($function)
|
|
||||||
{
|
|
||||||
$this->unregisterFilter('output', $function);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* load a filter of specified type and name
|
|
||||||
*
|
|
||||||
* @param string $type filter type
|
|
||||||
* @param string $name filter name
|
|
||||||
*
|
|
||||||
* @throws \SmartyException
|
|
||||||
*/
|
|
||||||
public function load_filter($type, $name)
|
|
||||||
{
|
|
||||||
$this->loadFilter($type, $name);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* clear cached content for the given template and cache id
|
|
||||||
*
|
|
||||||
* @param string $tpl_file name of template file
|
|
||||||
* @param string $cache_id name of cache_id
|
|
||||||
* @param string $compile_id name of compile_id
|
|
||||||
* @param string $exp_time expiration time
|
|
||||||
*
|
|
||||||
* @return boolean
|
|
||||||
*/
|
|
||||||
public function clear_cache($tpl_file = null, $cache_id = null, $compile_id = null, $exp_time = null)
|
|
||||||
{
|
|
||||||
return $this->clearCache($tpl_file, $cache_id, $compile_id, $exp_time);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* clear the entire contents of cache (all templates)
|
|
||||||
*
|
|
||||||
* @param string $exp_time expire time
|
|
||||||
*
|
|
||||||
* @return boolean
|
|
||||||
*/
|
|
||||||
public function clear_all_cache($exp_time = null)
|
|
||||||
{
|
|
||||||
return $this->clearCache(null, null, null, $exp_time);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* test to see if valid cache exists for this template
|
|
||||||
*
|
|
||||||
* @param string $tpl_file name of template file
|
|
||||||
* @param string $cache_id
|
|
||||||
* @param string $compile_id
|
|
||||||
*
|
|
||||||
* @return bool
|
|
||||||
* @throws \Exception
|
|
||||||
* @throws \SmartyException
|
|
||||||
*/
|
|
||||||
public function is_cached($tpl_file, $cache_id = null, $compile_id = null)
|
|
||||||
{
|
|
||||||
return $this->isCached($tpl_file, $cache_id, $compile_id);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* clear all the assigned template variables.
|
|
||||||
*/
|
|
||||||
public function clear_all_assign()
|
|
||||||
{
|
|
||||||
$this->clearAllAssign();
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* clears compiled version of specified template resource,
|
|
||||||
* or all compiled template files if one is not specified.
|
|
||||||
* This function is for advanced use only, not normally needed.
|
|
||||||
*
|
|
||||||
* @param string $tpl_file
|
|
||||||
* @param string $compile_id
|
|
||||||
* @param string $exp_time
|
|
||||||
*
|
|
||||||
* @return boolean results of {@link smarty_core_rm_auto()}
|
|
||||||
*/
|
|
||||||
public function clear_compiled_tpl($tpl_file = null, $compile_id = null, $exp_time = null)
|
|
||||||
{
|
|
||||||
return $this->clearCompiledTemplate($tpl_file, $compile_id, $exp_time);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Checks whether requested template exists.
|
|
||||||
*
|
|
||||||
* @param string $tpl_file
|
|
||||||
*
|
|
||||||
* @return bool
|
|
||||||
* @throws \SmartyException
|
|
||||||
*/
|
|
||||||
public function template_exists($tpl_file)
|
|
||||||
{
|
|
||||||
return $this->templateExists($tpl_file);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Returns an array containing template variables
|
|
||||||
*
|
|
||||||
* @param string $name
|
|
||||||
*
|
|
||||||
* @return array
|
|
||||||
*/
|
|
||||||
public function get_template_vars($name = null)
|
|
||||||
{
|
|
||||||
return $this->getTemplateVars($name);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Returns an array containing config variables
|
|
||||||
*
|
|
||||||
* @param string $name
|
|
||||||
*
|
|
||||||
* @return array
|
|
||||||
*/
|
|
||||||
public function get_config_vars($name = null)
|
|
||||||
{
|
|
||||||
return $this->getConfigVars($name);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* load configuration values
|
|
||||||
*
|
|
||||||
* @param string $file
|
|
||||||
* @param string $section
|
|
||||||
* @param string $scope
|
|
||||||
*/
|
|
||||||
public function config_load($file, $section = null, $scope = 'global')
|
|
||||||
{
|
|
||||||
$this->ConfigLoad($file, $section, $scope);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* return a reference to a registered object
|
|
||||||
*
|
|
||||||
* @param string $name
|
|
||||||
*
|
|
||||||
* @return object
|
|
||||||
*/
|
|
||||||
public function get_registered_object($name)
|
|
||||||
{
|
|
||||||
return $this->getRegisteredObject($name);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* clear configuration values
|
|
||||||
*
|
|
||||||
* @param string $var
|
|
||||||
*/
|
|
||||||
public function clear_config($var = null)
|
|
||||||
{
|
|
||||||
$this->clearConfig($var);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* trigger Smarty error
|
|
||||||
*
|
|
||||||
* @param string $error_msg
|
|
||||||
* @param integer $error_type
|
|
||||||
*/
|
|
||||||
public function trigger_error($error_msg, $error_type = E_USER_WARNING)
|
|
||||||
{
|
|
||||||
trigger_error("Smarty error: $error_msg", $error_type);
|
|
||||||
}
|
|
||||||
}
|
|
@@ -20,7 +20,7 @@
|
|||||||
* - indent_char - string (" ")
|
* - indent_char - string (" ")
|
||||||
* - wrap_boundary - boolean (true)
|
* - wrap_boundary - boolean (true)
|
||||||
*
|
*
|
||||||
* @link http://www.smarty.net/manual/en/language.function.textformat.php {textformat}
|
* @link https://www.smarty.net/manual/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 http://www.smarty.net/manual/en/language.function.counter.php {counter}
|
* @link https://www.smarty.net/manual/en/language.function.counter.php {counter}
|
||||||
* (Smarty online manual)
|
* (Smarty online manual)
|
||||||
*
|
*
|
||||||
* @param array $params parameters
|
* @param array $params parameters
|
||||||
|
@@ -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 http://www.smarty.net/manual/en/language.function.cycle.php {cycle}
|
* @link https://www.smarty.net/manual/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 http://www.smarty.net/manual/en/language.function.fetch.php {fetch}
|
* @link https://www.smarty.net/manual/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 http://www.smarty.net/manual/en/language.function.html.checkboxes.php {html_checkboxes}
|
* @link https://www.smarty.net/manual/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 http://www.smarty.net/manual/en/language.function.html.image.php {html_image}
|
* @link https://www.smarty.net/manual/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 http://www.smarty.net/manual/en/language.function.html.options.php {html_image}
|
* @link https://www.smarty.net/manual/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 http://smarty.php.net/manual/en/language.function.html.radios.php {html_radios}
|
* @link https://www.smarty.net/manual/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>
|
||||||
|
@@ -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 http://www.smarty.net/manual/en/language.function.html.select.date.php {html_select_date}
|
* @link https://www.smarty.net/manual/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
|
||||||
|
@@ -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 http://www.smarty.net/manual/en/language.function.html.select.time.php {html_select_time}
|
* @link https://www.smarty.net/manual/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>
|
||||||
|
@@ -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 http://www.smarty.net/manual/en/language.function.html.table.php {html_table}
|
* @link https://www.smarty.net/manual/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 http://www.smarty.net/manual/en/language.function.mailto.php {mailto}
|
* @link https://www.smarty.net/manual/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>
|
||||||
|
@@ -12,7 +12,7 @@
|
|||||||
* Name: math
|
* Name: math
|
||||||
* Purpose: handle math computations in template
|
* Purpose: handle math computations in template
|
||||||
*
|
*
|
||||||
* @link http://www.smarty.net/manual/en/language.function.math.php {math}
|
* @link https://www.smarty.net/manual/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>
|
||||||
*
|
*
|
||||||
|
@@ -15,7 +15,7 @@
|
|||||||
* - 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 http://www.smarty.net/manual/en/language.modifier.date.format.php date_format (Smarty online manual)
|
* @link https://www.smarty.net/manual/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
|
||||||
|
@@ -11,7 +11,7 @@
|
|||||||
* Name: escape
|
* Name: escape
|
||||||
* Purpose: escape string for output
|
* Purpose: escape string for output
|
||||||
*
|
*
|
||||||
* @link http://www.smarty.net/docs/en/language.modifier.escape
|
* @link https://www.smarty.net/docs/en/language.modifier.escape
|
||||||
* @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
|
||||||
@@ -23,12 +23,9 @@
|
|||||||
*/
|
*/
|
||||||
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 = null;
|
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 ($_double_encode === null) {
|
|
||||||
$_double_encode = version_compare(PHP_VERSION, '5.2.3', '>=');
|
|
||||||
}
|
|
||||||
if (!$char_set) {
|
if (!$char_set) {
|
||||||
$char_set = Smarty::$_CHARSET;
|
$char_set = Smarty::$_CHARSET;
|
||||||
}
|
}
|
||||||
|
@@ -11,7 +11,7 @@
|
|||||||
* Name: mb_wordwrap
|
* Name: mb_wordwrap
|
||||||
* Purpose: Wrap a string to a given number of characters
|
* Purpose: Wrap a string to a given number of characters
|
||||||
*
|
*
|
||||||
* @link http://php.net/manual/en/function.wordwrap.php for similarity
|
* @link https://php.net/manual/en/function.wordwrap.php for similarity
|
||||||
*
|
*
|
||||||
* @param string $str the string to wrap
|
* @param string $str the string to wrap
|
||||||
* @param int $width the width of the output
|
* @param int $width the width of the output
|
||||||
|
@@ -11,7 +11,7 @@
|
|||||||
* Name: regex_replace
|
* Name: regex_replace
|
||||||
* Purpose: regular expression search/replace
|
* Purpose: regular expression search/replace
|
||||||
*
|
*
|
||||||
* @link http://smarty.php.net/manual/en/language.modifier.regex.replace.php
|
* @link https://www.smarty.net/manual/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,7 @@
|
|||||||
* Name: replace
|
* Name: replace
|
||||||
* Purpose: simple search/replace
|
* Purpose: simple search/replace
|
||||||
*
|
*
|
||||||
* @link http://smarty.php.net/manual/en/language.modifier.replace.php replace (Smarty online manual)
|
* @link https://www.smarty.net/manual/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,7 @@
|
|||||||
* Name: spacify
|
* Name: spacify
|
||||||
* Purpose: add spaces between characters in a string
|
* Purpose: add spaces between characters in a string
|
||||||
*
|
*
|
||||||
* @link http://smarty.php.net/manual/en/language.modifier.spacify.php spacify (Smarty online manual)
|
* @link https://www.smarty.net/manual/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,7 @@
|
|||||||
* 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 http://smarty.php.net/manual/en/language.modifier.truncate.php truncate (Smarty online manual)
|
* @link https://www.smarty.net/manual/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
|
||||||
|
@@ -14,7 +14,7 @@
|
|||||||
* Input: string to catenate
|
* Input: string to catenate
|
||||||
* Example: {$var|cat:"foo"}
|
* Example: {$var|cat:"foo"}
|
||||||
*
|
*
|
||||||
* @link http://smarty.php.net/manual/en/language.modifier.cat.php cat
|
* @link https://www.smarty.net/manual/en/language.modifier.cat.php cat
|
||||||
* (Smarty online manual)
|
* (Smarty online manual)
|
||||||
* @author Uwe Tews
|
* @author Uwe Tews
|
||||||
*
|
*
|
||||||
|
@@ -11,7 +11,7 @@
|
|||||||
* 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 http://www.smarty.net/manual/en/language.modifier.count.characters.php count_characters (Smarty online
|
* @link https://www.smarty.net/manual/en/language.modifier.count.characters.php count_characters (Smarty online
|
||||||
* manual)
|
* manual)
|
||||||
* @author Uwe Tews
|
* @author Uwe Tews
|
||||||
*
|
*
|
||||||
|
@@ -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 http://www.smarty.net/manual/en/language.modifier.count.paragraphs.php
|
* @link https://www.smarty.net/manual/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 http://www.smarty.net/manual/en/language.modifier.count.paragraphs.php
|
* @link https://www.smarty.net/manual/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,7 @@
|
|||||||
* 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 http://www.smarty.net/manual/en/language.modifier.count.words.php count_words (Smarty online manual)
|
* @link https://www.smarty.net/manual/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,7 @@
|
|||||||
* Name: default
|
* Name: default
|
||||||
* Purpose: designate default value for empty variables
|
* Purpose: designate default value for empty variables
|
||||||
*
|
*
|
||||||
* @link http://www.smarty.net/manual/en/language.modifier.default.php default (Smarty online manual)
|
* @link https://www.smarty.net/manual/en/language.modifier.default.php default (Smarty online manual)
|
||||||
* @author Uwe Tews
|
* @author Uwe Tews
|
||||||
*
|
*
|
||||||
* @param array $params parameters
|
* @param array $params parameters
|
||||||
@@ -26,7 +26,7 @@ function smarty_modifiercompiler_default($params)
|
|||||||
}
|
}
|
||||||
array_shift($params);
|
array_shift($params);
|
||||||
foreach ($params as $param) {
|
foreach ($params as $param) {
|
||||||
$output = '(($tmp = @' . $output . ')===null||$tmp===\'\' ? ' . $param . ' : $tmp)';
|
$output = '(($tmp = ' . $output . ' ?? null)===null||$tmp===\'\' ? ' . $param . ' ?? null : $tmp)';
|
||||||
}
|
}
|
||||||
return $output;
|
return $output;
|
||||||
}
|
}
|
||||||
|
@@ -11,7 +11,7 @@
|
|||||||
* Name: escape
|
* Name: escape
|
||||||
* Purpose: escape string for output
|
* Purpose: escape string for output
|
||||||
*
|
*
|
||||||
* @link http://www.smarty.net/docsv2/en/language.modifier.escape count_characters (Smarty online manual)
|
* @link https://www.smarty.net/docsv2/en/language.modifier.escape count_characters (Smarty online manual)
|
||||||
* @author Rodney Rehm
|
* @author Rodney Rehm
|
||||||
*
|
*
|
||||||
* @param array $params parameters
|
* @param array $params parameters
|
||||||
@@ -22,7 +22,7 @@
|
|||||||
*/
|
*/
|
||||||
function smarty_modifiercompiler_escape($params, Smarty_Internal_TemplateCompilerBase $compiler)
|
function smarty_modifiercompiler_escape($params, Smarty_Internal_TemplateCompilerBase $compiler)
|
||||||
{
|
{
|
||||||
static $_double_encode = null;
|
static $_double_encode = true;
|
||||||
static $is_loaded = false;
|
static $is_loaded = false;
|
||||||
$compiler->template->_checkPlugins(
|
$compiler->template->_checkPlugins(
|
||||||
array(
|
array(
|
||||||
@@ -32,9 +32,6 @@ function smarty_modifiercompiler_escape($params, Smarty_Internal_TemplateCompile
|
|||||||
)
|
)
|
||||||
)
|
)
|
||||||
);
|
);
|
||||||
if ($_double_encode === null) {
|
|
||||||
$_double_encode = version_compare(PHP_VERSION, '5.2.3', '>=');
|
|
||||||
}
|
|
||||||
try {
|
try {
|
||||||
$esc_type = smarty_literal_compiler_param($params, 1, 'html');
|
$esc_type = smarty_literal_compiler_param($params, 1, 'html');
|
||||||
$char_set = smarty_literal_compiler_param($params, 2, Smarty::$_CHARSET);
|
$char_set = smarty_literal_compiler_param($params, 2, Smarty::$_CHARSET);
|
||||||
|
@@ -11,7 +11,7 @@
|
|||||||
* Name: indent
|
* Name: indent
|
||||||
* Purpose: indent lines of text
|
* Purpose: indent lines of text
|
||||||
*
|
*
|
||||||
* @link http://www.smarty.net/manual/en/language.modifier.indent.php indent (Smarty online manual)
|
* @link https://www.smarty.net/manual/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,7 @@
|
|||||||
* Name: lower
|
* Name: lower
|
||||||
* Purpose: convert string to lowercase
|
* Purpose: convert string to lowercase
|
||||||
*
|
*
|
||||||
* @link http://www.smarty.net/manual/en/language.modifier.lower.php lower (Smarty online manual)
|
* @link https://www.smarty.net/manual/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
|
||||||
*
|
*
|
||||||
|
@@ -11,7 +11,7 @@
|
|||||||
* Name: string_format
|
* Name: string_format
|
||||||
* Purpose: format strings via sprintf
|
* Purpose: format strings via sprintf
|
||||||
*
|
*
|
||||||
* @link http://www.smarty.net/manual/en/language.modifier.string.format.php string_format (Smarty online manual)
|
* @link https://www.smarty.net/manual/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,7 @@
|
|||||||
* Example: {$var|strip} {$var|strip:" "}
|
* Example: {$var|strip} {$var|strip:" "}
|
||||||
* Date: September 25th, 2002
|
* Date: September 25th, 2002
|
||||||
*
|
*
|
||||||
* @link http://www.smarty.net/manual/en/language.modifier.strip.php strip (Smarty online manual)
|
* @link https://www.smarty.net/manual/en/language.modifier.strip.php strip (Smarty online manual)
|
||||||
* @author Uwe Tews
|
* @author Uwe Tews
|
||||||
*
|
*
|
||||||
* @param array $params parameters
|
* @param array $params parameters
|
||||||
|
@@ -11,7 +11,7 @@
|
|||||||
* Name: strip_tags
|
* Name: strip_tags
|
||||||
* Purpose: strip html tags from text
|
* Purpose: strip html tags from text
|
||||||
*
|
*
|
||||||
* @link http://www.smarty.net/docs/en/language.modifier.strip.tags.tpl strip_tags (Smarty online manual)
|
* @link https://www.smarty.net/docs/en/language.modifier.strip.tags.tpl strip_tags (Smarty online manual)
|
||||||
* @author Uwe Tews
|
* @author Uwe Tews
|
||||||
*
|
*
|
||||||
* @param array $params parameters
|
* @param array $params parameters
|
||||||
|
@@ -11,7 +11,7 @@
|
|||||||
* Name: lower
|
* Name: lower
|
||||||
* Purpose: convert string to uppercase
|
* Purpose: convert string to uppercase
|
||||||
*
|
*
|
||||||
* @link http://smarty.php.net/manual/en/language.modifier.upper.php lower (Smarty online manual)
|
* @link https://www.smarty.net/manual/en/language.modifier.upper.php lower (Smarty online manual)
|
||||||
* @author Uwe Tews
|
* @author Uwe Tews
|
||||||
*
|
*
|
||||||
* @param array $params parameters
|
* @param array $params parameters
|
||||||
|
@@ -11,7 +11,7 @@
|
|||||||
* 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 http://smarty.php.net/manual/en/language.modifier.wordwrap.php wordwrap (Smarty online manual)
|
* @link https://www.smarty.net/manual/en/language.modifier.wordwrap.php wordwrap (Smarty online manual)
|
||||||
* @author Uwe Tews
|
* @author Uwe Tews
|
||||||
*
|
*
|
||||||
* @param array $params parameters
|
* @param array $params parameters
|
||||||
|
@@ -41,7 +41,7 @@ function smarty_outputfilter_trimwhitespace($source)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
// Strip all HTML-Comments
|
// Strip all HTML-Comments
|
||||||
// yes, even the ones in <script> - see http://stackoverflow.com/a/808850/515124
|
// yes, even the ones in <script> - see https://stackoverflow.com/a/808850/515124
|
||||||
$source = preg_replace('#<!--.*?-->#ms', '', $source);
|
$source = preg_replace('#<!--.*?-->#ms', '', $source);
|
||||||
// capture html elements not to be messed with
|
// capture html elements not to be messed with
|
||||||
$_offset = 0;
|
$_offset = 0;
|
||||||
|
@@ -20,13 +20,7 @@
|
|||||||
function smarty_function_escape_special_chars($string)
|
function smarty_function_escape_special_chars($string)
|
||||||
{
|
{
|
||||||
if (!is_array($string)) {
|
if (!is_array($string)) {
|
||||||
if (version_compare(PHP_VERSION, '5.2.3', '>=')) {
|
$string = htmlspecialchars($string, ENT_COMPAT, Smarty::$_CHARSET, false);
|
||||||
$string = htmlspecialchars($string, ENT_COMPAT, Smarty::$_CHARSET, false);
|
|
||||||
} else {
|
|
||||||
$string = preg_replace('!&(#?\w+);!', '%%%SMARTY_START%%%\\1%%%SMARTY_END%%%', $string);
|
|
||||||
$string = htmlspecialchars($string);
|
|
||||||
$string = str_replace(array('%%%SMARTY_START%%%', '%%%SMARTY_END%%%'), array('&', ';'), $string);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
return $string;
|
return $string;
|
||||||
}
|
}
|
||||||
|
@@ -196,11 +196,7 @@ class Smarty_Internal_CacheResource_File extends Smarty_CacheResource
|
|||||||
*/
|
*/
|
||||||
public function hasLock(Smarty $smarty, Smarty_Template_Cached $cached)
|
public function hasLock(Smarty $smarty, Smarty_Template_Cached $cached)
|
||||||
{
|
{
|
||||||
if (version_compare(PHP_VERSION, '5.3.0', '>=')) {
|
clearstatcache(true, $cached->lock_id);
|
||||||
clearstatcache(true, $cached->lock_id);
|
|
||||||
} else {
|
|
||||||
clearstatcache();
|
|
||||||
}
|
|
||||||
if (is_file($cached->lock_id)) {
|
if (is_file($cached->lock_id)) {
|
||||||
$t = filemtime($cached->lock_id);
|
$t = filemtime($cached->lock_id);
|
||||||
return $t && (time() - $t < $smarty->locking_timeout);
|
return $t && (time() - $t < $smarty->locking_timeout);
|
||||||
|
@@ -219,9 +219,9 @@ class Smarty_Internal_Compile_Foreach extends Smarty_Internal_Compile_Private_Fo
|
|||||||
if (isset($itemAttr[ 'index' ])) {
|
if (isset($itemAttr[ 'index' ])) {
|
||||||
$output .= "{$itemVar}->index = -1;\n";
|
$output .= "{$itemVar}->index = -1;\n";
|
||||||
}
|
}
|
||||||
$output .= "{$itemVar}->do_else = true;\n";
|
$output .= "{$itemVar}->do_else = true;\n";
|
||||||
$output .= "if (\$_from !== null) foreach (\$_from as {$keyTerm}{$itemVar}->value) {\n";
|
$output .= "if (\$_from !== null) foreach (\$_from as {$keyTerm}{$itemVar}->value) {\n";
|
||||||
$output .= "{$itemVar}->do_else = false;\n";
|
$output .= "{$itemVar}->do_else = false;\n";
|
||||||
if (isset($attributes[ 'key' ]) && isset($itemAttr[ 'key' ])) {
|
if (isset($attributes[ 'key' ]) && isset($itemAttr[ 'key' ])) {
|
||||||
$output .= "\$_smarty_tpl->tpl_vars['{$key}']->value = {$itemVar}->key;\n";
|
$output .= "\$_smarty_tpl->tpl_vars['{$key}']->value = {$itemVar}->key;\n";
|
||||||
}
|
}
|
||||||
|
@@ -1,110 +0,0 @@
|
|||||||
<?php
|
|
||||||
/**
|
|
||||||
* Smarty Internal Plugin Compile Include PHP
|
|
||||||
* Compiles the {include_php} tag
|
|
||||||
*
|
|
||||||
* @package Smarty
|
|
||||||
* @subpackage Compiler
|
|
||||||
* @author Uwe Tews
|
|
||||||
*/
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Smarty Internal Plugin Compile Insert Class
|
|
||||||
*
|
|
||||||
* @package Smarty
|
|
||||||
* @subpackage Compiler
|
|
||||||
*/
|
|
||||||
class Smarty_Internal_Compile_Include_Php extends Smarty_Internal_CompileBase
|
|
||||||
{
|
|
||||||
/**
|
|
||||||
* Attribute definition: Overwrites base class.
|
|
||||||
*
|
|
||||||
* @var array
|
|
||||||
* @see Smarty_Internal_CompileBase
|
|
||||||
*/
|
|
||||||
public $required_attributes = array('file');
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Attribute definition: Overwrites base class.
|
|
||||||
*
|
|
||||||
* @var array
|
|
||||||
* @see Smarty_Internal_CompileBase
|
|
||||||
*/
|
|
||||||
public $shorttag_order = array('file');
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Attribute definition: Overwrites base class.
|
|
||||||
*
|
|
||||||
* @var array
|
|
||||||
* @see Smarty_Internal_CompileBase
|
|
||||||
*/
|
|
||||||
public $optional_attributes = array('once', 'assign');
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Compiles code for the {include_php} tag
|
|
||||||
*
|
|
||||||
* @param array $args array with attributes from parser
|
|
||||||
* @param \Smarty_Internal_TemplateCompilerBase $compiler compiler object
|
|
||||||
*
|
|
||||||
* @return string
|
|
||||||
* @throws \SmartyCompilerException
|
|
||||||
* @throws \SmartyException
|
|
||||||
*/
|
|
||||||
public function compile($args, Smarty_Internal_TemplateCompilerBase $compiler)
|
|
||||||
{
|
|
||||||
if (!($compiler->smarty instanceof SmartyBC)) {
|
|
||||||
throw new SmartyException("{include_php} is deprecated, use SmartyBC class to enable");
|
|
||||||
}
|
|
||||||
// check and get attributes
|
|
||||||
$_attr = $this->getAttributes($compiler, $args);
|
|
||||||
/**
|
|
||||||
*
|
|
||||||
*
|
|
||||||
* @var Smarty_Internal_Template $_smarty_tpl
|
|
||||||
* used in evaluated code
|
|
||||||
*/
|
|
||||||
$_smarty_tpl = $compiler->template;
|
|
||||||
$_filepath = false;
|
|
||||||
$_file = null;
|
|
||||||
eval('$_file = @' . $_attr[ 'file' ] . ';');
|
|
||||||
if (!isset($compiler->smarty->security_policy) && file_exists($_file)) {
|
|
||||||
$_filepath = $compiler->smarty->_realpath($_file, true);
|
|
||||||
} else {
|
|
||||||
if (isset($compiler->smarty->security_policy)) {
|
|
||||||
$_dir = $compiler->smarty->security_policy->trusted_dir;
|
|
||||||
} else {
|
|
||||||
$_dir = $compiler->smarty->trusted_dir;
|
|
||||||
}
|
|
||||||
if (!empty($_dir)) {
|
|
||||||
foreach ((array)$_dir as $_script_dir) {
|
|
||||||
$_path = $compiler->smarty->_realpath($_script_dir . DIRECTORY_SEPARATOR . $_file, true);
|
|
||||||
if (file_exists($_path)) {
|
|
||||||
$_filepath = $_path;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if ($_filepath === false) {
|
|
||||||
$compiler->trigger_template_error("{include_php} file '{$_file}' is not readable", null, true);
|
|
||||||
}
|
|
||||||
if (isset($compiler->smarty->security_policy)) {
|
|
||||||
$compiler->smarty->security_policy->isTrustedPHPDir($_filepath);
|
|
||||||
}
|
|
||||||
if (isset($_attr[ 'assign' ])) {
|
|
||||||
// output will be stored in a smarty variable instead of being displayed
|
|
||||||
$_assign = $_attr[ 'assign' ];
|
|
||||||
}
|
|
||||||
$_once = '_once';
|
|
||||||
if (isset($_attr[ 'once' ])) {
|
|
||||||
if ($_attr[ 'once' ] === 'false') {
|
|
||||||
$_once = '';
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (isset($_assign)) {
|
|
||||||
return "<?php ob_start();\ninclude{$_once} ('{$_filepath}');\n\$_smarty_tpl->assign({$_assign},ob_get_clean());\n?>";
|
|
||||||
} else {
|
|
||||||
return "<?php include{$_once} ('{$_filepath}');?>\n";
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
@@ -89,7 +89,7 @@ class Smarty_Internal_Compile_Insert extends Smarty_Internal_CompileBase
|
|||||||
if (isset($compiler->smarty->security_policy)) {
|
if (isset($compiler->smarty->security_policy)) {
|
||||||
$_dir = $compiler->smarty->security_policy->trusted_dir;
|
$_dir = $compiler->smarty->security_policy->trusted_dir;
|
||||||
} else {
|
} else {
|
||||||
$_dir = $compiler->smarty instanceof SmartyBC ? $compiler->smarty->trusted_dir : null;
|
$_dir = null;
|
||||||
}
|
}
|
||||||
if (!empty($_dir)) {
|
if (!empty($_dir)) {
|
||||||
foreach ((array)$_dir as $_script_dir) {
|
foreach ((array)$_dir as $_script_dir) {
|
||||||
|
@@ -1,253 +0,0 @@
|
|||||||
<?php
|
|
||||||
/**
|
|
||||||
* Smarty Internal Plugin Compile PHP Expression
|
|
||||||
* Compiles any tag which will output an expression or variable
|
|
||||||
*
|
|
||||||
* @package Smarty
|
|
||||||
* @subpackage Compiler
|
|
||||||
* @author Uwe Tews
|
|
||||||
*/
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Smarty Internal Plugin Compile PHP Expression Class
|
|
||||||
*
|
|
||||||
* @package Smarty
|
|
||||||
* @subpackage Compiler
|
|
||||||
*/
|
|
||||||
class Smarty_Internal_Compile_Private_Php extends Smarty_Internal_CompileBase
|
|
||||||
{
|
|
||||||
/**
|
|
||||||
* Attribute definition: Overwrites base class.
|
|
||||||
*
|
|
||||||
* @var array
|
|
||||||
* @see Smarty_Internal_CompileBase
|
|
||||||
*/
|
|
||||||
public $required_attributes = array('code', 'type');
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Compiles code for generating output from any expression
|
|
||||||
*
|
|
||||||
* @param array $args array with attributes from parser
|
|
||||||
* @param \Smarty_Internal_TemplateCompilerBase $compiler compiler object
|
|
||||||
* @param array $parameter array with compilation parameter
|
|
||||||
*
|
|
||||||
* @return string
|
|
||||||
* @throws \SmartyException
|
|
||||||
*/
|
|
||||||
public function compile($args, Smarty_Internal_TemplateCompilerBase $compiler, $parameter)
|
|
||||||
{
|
|
||||||
// check and get attributes
|
|
||||||
$_attr = $this->getAttributes($compiler, $args);
|
|
||||||
$compiler->has_code = false;
|
|
||||||
if ($_attr[ 'type' ] === 'xml') {
|
|
||||||
$compiler->tag_nocache = true;
|
|
||||||
$output = addcslashes($_attr[ 'code' ], "'\\");
|
|
||||||
$compiler->parser->current_buffer->append_subtree(
|
|
||||||
$compiler->parser,
|
|
||||||
new Smarty_Internal_ParseTree_Tag(
|
|
||||||
$compiler->parser,
|
|
||||||
$compiler->processNocacheCode(
|
|
||||||
"<?php echo '{$output}';?>\n",
|
|
||||||
true
|
|
||||||
)
|
|
||||||
)
|
|
||||||
);
|
|
||||||
return '';
|
|
||||||
}
|
|
||||||
if ($_attr[ 'type' ] !== 'tag') {
|
|
||||||
if ($compiler->php_handling === Smarty::PHP_REMOVE) {
|
|
||||||
return '';
|
|
||||||
} elseif ($compiler->php_handling === Smarty::PHP_QUOTE) {
|
|
||||||
$output =
|
|
||||||
preg_replace_callback(
|
|
||||||
'#(<\?(?:php|=)?)|(<%)|(<script\s+language\s*=\s*["\']?\s*php\s*["\']?\s*>)|(\?>)|(%>)|(<\/script>)#i',
|
|
||||||
array($this, 'quote'),
|
|
||||||
$_attr[ 'code' ]
|
|
||||||
);
|
|
||||||
$compiler->parser->current_buffer->append_subtree(
|
|
||||||
$compiler->parser,
|
|
||||||
new Smarty_Internal_ParseTree_Text($output)
|
|
||||||
);
|
|
||||||
return '';
|
|
||||||
} elseif ($compiler->php_handling === Smarty::PHP_PASSTHRU || $_attr[ 'type' ] === 'unmatched') {
|
|
||||||
$compiler->tag_nocache = true;
|
|
||||||
$output = addcslashes($_attr[ 'code' ], "'\\");
|
|
||||||
$compiler->parser->current_buffer->append_subtree(
|
|
||||||
$compiler->parser,
|
|
||||||
new Smarty_Internal_ParseTree_Tag(
|
|
||||||
$compiler->parser,
|
|
||||||
$compiler->processNocacheCode(
|
|
||||||
"<?php echo '{$output}';?>\n",
|
|
||||||
true
|
|
||||||
)
|
|
||||||
)
|
|
||||||
);
|
|
||||||
return '';
|
|
||||||
} elseif ($compiler->php_handling === Smarty::PHP_ALLOW) {
|
|
||||||
if (!($compiler->smarty instanceof SmartyBC)) {
|
|
||||||
$compiler->trigger_template_error(
|
|
||||||
'$smarty->php_handling PHP_ALLOW not allowed. Use SmartyBC to enable it',
|
|
||||||
null,
|
|
||||||
true
|
|
||||||
);
|
|
||||||
}
|
|
||||||
$compiler->has_code = true;
|
|
||||||
return $_attr[ 'code' ];
|
|
||||||
} else {
|
|
||||||
$compiler->trigger_template_error('Illegal $smarty->php_handling value', null, true);
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
$compiler->has_code = true;
|
|
||||||
if (!($compiler->smarty instanceof SmartyBC)) {
|
|
||||||
$compiler->trigger_template_error(
|
|
||||||
'{php}{/php} tags not allowed. Use SmartyBC to enable them',
|
|
||||||
null,
|
|
||||||
true
|
|
||||||
);
|
|
||||||
}
|
|
||||||
$ldel = preg_quote($compiler->smarty->left_delimiter, '#');
|
|
||||||
$rdel = preg_quote($compiler->smarty->right_delimiter, '#');
|
|
||||||
preg_match("#^({$ldel}php\\s*)((.)*?)({$rdel})#", $_attr[ 'code' ], $match);
|
|
||||||
if (!empty($match[ 2 ])) {
|
|
||||||
if ('nocache' === trim($match[ 2 ])) {
|
|
||||||
$compiler->tag_nocache = true;
|
|
||||||
} else {
|
|
||||||
$compiler->trigger_template_error("illegal value of option flag '{$match[2]}'", null, true);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return preg_replace(
|
|
||||||
array("#^{$ldel}\\s*php\\s*(.)*?{$rdel}#", "#{$ldel}\\s*/\\s*php\\s*{$rdel}$#"),
|
|
||||||
array('<?php ', '?>'),
|
|
||||||
$_attr[ 'code' ]
|
|
||||||
);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Lexer code for PHP tags
|
|
||||||
*
|
|
||||||
* This code has been moved from lexer here fo easier debugging and maintenance
|
|
||||||
*
|
|
||||||
* @param Smarty_Internal_Templatelexer $lex
|
|
||||||
*
|
|
||||||
* @throws \SmartyCompilerException
|
|
||||||
*/
|
|
||||||
public function parsePhp(Smarty_Internal_Templatelexer $lex)
|
|
||||||
{
|
|
||||||
$lex->token = Smarty_Internal_Templateparser::TP_PHP;
|
|
||||||
$close = 0;
|
|
||||||
$lex->taglineno = $lex->line;
|
|
||||||
$closeTag = '?>';
|
|
||||||
if (strpos($lex->value, '<?xml') === 0) {
|
|
||||||
$lex->is_xml = true;
|
|
||||||
$lex->phpType = 'xml';
|
|
||||||
return;
|
|
||||||
} elseif (strpos($lex->value, '<?') === 0) {
|
|
||||||
$lex->phpType = 'php';
|
|
||||||
} elseif (strpos($lex->value, '<%') === 0) {
|
|
||||||
$lex->phpType = 'asp';
|
|
||||||
$closeTag = '%>';
|
|
||||||
} elseif (strpos($lex->value, '%>') === 0) {
|
|
||||||
$lex->phpType = 'unmatched';
|
|
||||||
} elseif (strpos($lex->value, '?>') === 0) {
|
|
||||||
if ($lex->is_xml) {
|
|
||||||
$lex->is_xml = false;
|
|
||||||
$lex->phpType = 'xml';
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
$lex->phpType = 'unmatched';
|
|
||||||
} elseif (strpos($lex->value, '<s') === 0) {
|
|
||||||
$lex->phpType = 'script';
|
|
||||||
$closeTag = '</script>';
|
|
||||||
} elseif (strpos($lex->value, $lex->smarty->left_delimiter) === 0) {
|
|
||||||
if ($lex->isAutoLiteral()) {
|
|
||||||
$lex->token = Smarty_Internal_Templateparser::TP_TEXT;
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
$closeTag = "{$lex->smarty->left_delimiter}/php{$lex->smarty->right_delimiter}";
|
|
||||||
if ($lex->value === $closeTag) {
|
|
||||||
$lex->compiler->trigger_template_error("unexpected closing tag '{$closeTag}'");
|
|
||||||
}
|
|
||||||
$lex->phpType = 'tag';
|
|
||||||
}
|
|
||||||
if ($lex->phpType === 'unmatched') {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
if (($lex->phpType === 'php' || $lex->phpType === 'asp')
|
|
||||||
&&
|
|
||||||
($lex->compiler->php_handling === Smarty::PHP_PASSTHRU ||
|
|
||||||
$lex->compiler->php_handling === Smarty::PHP_QUOTE)
|
|
||||||
) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
$start = $lex->counter + strlen($lex->value);
|
|
||||||
$body = true;
|
|
||||||
if (preg_match('~' . preg_quote($closeTag, '~') . '~i', $lex->data, $match, PREG_OFFSET_CAPTURE, $start)) {
|
|
||||||
$close = $match[ 0 ][ 1 ];
|
|
||||||
} else {
|
|
||||||
$lex->compiler->trigger_template_error("missing closing tag '{$closeTag}'");
|
|
||||||
}
|
|
||||||
while ($body) {
|
|
||||||
if (preg_match(
|
|
||||||
'~([/][*])|([/][/][^\n]*)|(\'[^\'\\\\]*(?:\\.[^\'\\\\]*)*\')|("[^"\\\\]*(?:\\.[^"\\\\]*)*")~',
|
|
||||||
$lex->data,
|
|
||||||
$match,
|
|
||||||
PREG_OFFSET_CAPTURE,
|
|
||||||
$start
|
|
||||||
)
|
|
||||||
) {
|
|
||||||
$value = $match[ 0 ][ 0 ];
|
|
||||||
$from = $pos = $match[ 0 ][ 1 ];
|
|
||||||
if ($pos > $close) {
|
|
||||||
$body = false;
|
|
||||||
} else {
|
|
||||||
$start = $pos + strlen($value);
|
|
||||||
$phpCommentStart = $value === '/*';
|
|
||||||
if ($phpCommentStart) {
|
|
||||||
$phpCommentEnd = preg_match('~([*][/])~', $lex->data, $match, PREG_OFFSET_CAPTURE, $start);
|
|
||||||
if ($phpCommentEnd) {
|
|
||||||
$pos2 = $match[ 0 ][ 1 ];
|
|
||||||
$start = $pos2 + strlen($match[ 0 ][ 0 ]);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
while ($close > $pos && $close < $start) {
|
|
||||||
if (preg_match(
|
|
||||||
'~' . preg_quote($closeTag, '~') . '~i',
|
|
||||||
$lex->data,
|
|
||||||
$match,
|
|
||||||
PREG_OFFSET_CAPTURE,
|
|
||||||
$from
|
|
||||||
)
|
|
||||||
) {
|
|
||||||
$close = $match[ 0 ][ 1 ];
|
|
||||||
$from = $close + strlen($match[ 0 ][ 0 ]);
|
|
||||||
} else {
|
|
||||||
$lex->compiler->trigger_template_error("missing closing tag '{$closeTag}'");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if ($phpCommentStart && (!$phpCommentEnd || $pos2 > $close)) {
|
|
||||||
$lex->taglineno = $lex->line + substr_count(substr($lex->data, $lex->counter, $start), "\n");
|
|
||||||
$lex->compiler->trigger_template_error("missing PHP comment closing tag '*/'");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
$body = false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
$lex->value = substr($lex->data, $lex->counter, $close + strlen($closeTag) - $lex->counter);
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Call back function for $php_handling = PHP_QUOTE
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
/**
|
|
||||||
* @param $match
|
|
||||||
*
|
|
||||||
* @return string
|
|
||||||
*/
|
|
||||||
private function quote($match)
|
|
||||||
{
|
|
||||||
return htmlspecialchars($match[ 0 ], ENT_QUOTES);
|
|
||||||
}
|
|
||||||
}
|
|
@@ -121,7 +121,7 @@ abstract class Smarty_Internal_Data
|
|||||||
* appends values to template variables
|
* appends values to template variables
|
||||||
*
|
*
|
||||||
* @api Smarty::append()
|
* @api Smarty::append()
|
||||||
* @link http://www.smarty.net/docs/en/api.append.tpl
|
* @link https://www.smarty.net/docs/en/api.append.tpl
|
||||||
*
|
*
|
||||||
* @param array|string $tpl_var the template variable name(s)
|
* @param array|string $tpl_var the template variable name(s)
|
||||||
* @param mixed $value the value to append
|
* @param mixed $value the value to append
|
||||||
@@ -182,7 +182,7 @@ abstract class Smarty_Internal_Data
|
|||||||
* Returns a single or all template variables
|
* Returns a single or all template variables
|
||||||
*
|
*
|
||||||
* @api Smarty::getTemplateVars()
|
* @api Smarty::getTemplateVars()
|
||||||
* @link http://www.smarty.net/docs/en/api.get.template.vars.tpl
|
* @link https://www.smarty.net/docs/en/api.get.template.vars.tpl
|
||||||
*
|
*
|
||||||
* @param string $varName variable name or null
|
* @param string $varName variable name or null
|
||||||
* @param \Smarty_Internal_Data|\Smarty_Internal_Template|\Smarty $_ptr optional pointer to data object
|
* @param \Smarty_Internal_Data|\Smarty_Internal_Template|\Smarty $_ptr optional pointer to data object
|
||||||
@@ -195,26 +195,6 @@ abstract class Smarty_Internal_Data
|
|||||||
return $this->ext->getTemplateVars->getTemplateVars($this, $varName, $_ptr, $searchParents);
|
return $this->ext->getTemplateVars->getTemplateVars($this, $varName, $_ptr, $searchParents);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* gets the object of a Smarty variable
|
|
||||||
*
|
|
||||||
* @param string $variable the name of the Smarty variable
|
|
||||||
* @param Smarty_Internal_Data $_ptr optional pointer to data object
|
|
||||||
* @param boolean $searchParents search also in parent data
|
|
||||||
* @param bool $error_enable
|
|
||||||
*
|
|
||||||
* @return Smarty_Variable|Smarty_Undefined_Variable the object of the variable
|
|
||||||
* @deprecated since 3.1.28 please use Smarty_Internal_Data::getTemplateVars() instead.
|
|
||||||
*/
|
|
||||||
public function getVariable(
|
|
||||||
$variable = null,
|
|
||||||
Smarty_Internal_Data $_ptr = null,
|
|
||||||
$searchParents = true,
|
|
||||||
$error_enable = true
|
|
||||||
) {
|
|
||||||
return $this->ext->getTemplateVars->_getVariable($this, $variable, $_ptr, $searchParents, $error_enable);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Follow the parent chain an merge template and config variables
|
* Follow the parent chain an merge template and config variables
|
||||||
*
|
*
|
||||||
|
@@ -1,61 +1,60 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Smarty error handler
|
* Smarty error handler to fix new error levels in PHP8 for backwards compatibility
|
||||||
*
|
*
|
||||||
* @package Smarty
|
* @package Smarty
|
||||||
* @subpackage PluginsInternal
|
* @subpackage PluginsInternal
|
||||||
* @author Uwe Tews
|
* @author Simon Wisselink
|
||||||
*
|
*
|
||||||
* @deprecated
|
|
||||||
Smarty does no longer use @filemtime()
|
|
||||||
*/
|
*/
|
||||||
class Smarty_Internal_ErrorHandler
|
class Smarty_Internal_ErrorHandler
|
||||||
{
|
{
|
||||||
/**
|
|
||||||
* contains directories outside of SMARTY_DIR that are to be muted by muteExpectedErrors()
|
|
||||||
*/
|
|
||||||
public static $mutedDirectories = array();
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* error handler returned by set_error_handler() in self::muteExpectedErrors()
|
* Allows {$foo} where foo is unset.
|
||||||
|
* @var bool
|
||||||
*/
|
*/
|
||||||
private static $previousErrorHandler = null;
|
public $allowUndefinedVars = true;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Enable error handler to mute expected messages
|
* Allows {$foo.bar} where bar is unset and {$foo.bar1.bar2} where either bar1 or bar2 is unset.
|
||||||
*
|
* @var bool
|
||||||
*/
|
*/
|
||||||
public static function muteExpectedErrors()
|
public $allowUndefinedArrayKeys = true;
|
||||||
{
|
|
||||||
|
private $previousErrorHandler = null;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Enable error handler to intercept errors
|
||||||
|
*/
|
||||||
|
public function activate() {
|
||||||
/*
|
/*
|
||||||
error muting is done because some people implemented custom error_handlers using
|
Error muting is done because some people implemented custom error_handlers using
|
||||||
http://php.net/set_error_handler and for some reason did not understand the following paragraph:
|
https://php.net/set_error_handler and for some reason did not understand the following paragraph:
|
||||||
|
|
||||||
It is important to remember that the standard PHP error handler is completely bypassed for the
|
It is important to remember that the standard PHP error handler is completely bypassed for the
|
||||||
error types specified by error_types unless the callback function returns FALSE.
|
error types specified by error_types unless the callback function returns FALSE.
|
||||||
error_reporting() settings will have no effect and your error handler will be called regardless -
|
error_reporting() settings will have no effect and your error handler will be called regardless -
|
||||||
however you are still able to read the current value of error_reporting and act appropriately.
|
however you are still able to read the current value of error_reporting and act appropriately.
|
||||||
Of particular note is that this value will be 0 if the statement that caused the error was
|
Of particular note is that this value will be 0 if the statement that caused the error was
|
||||||
prepended by the @ error-control operator.
|
prepended by the @ error-control operator.
|
||||||
|
|
||||||
Smarty deliberately uses @filemtime() over file_exists() and filemtime() in some places. Reasons include
|
|
||||||
- @filemtime() is almost twice as fast as using an additional file_exists()
|
|
||||||
- between file_exists() and filemtime() a possible race condition is opened,
|
|
||||||
which does not exist using the simple @filemtime() approach.
|
|
||||||
*/
|
*/
|
||||||
$error_handler = array('Smarty_Internal_ErrorHandler', 'mutingErrorHandler');
|
$this->previousErrorHandler = set_error_handler([$this, 'handleError']);
|
||||||
$previous = set_error_handler($error_handler);
|
}
|
||||||
// avoid dead loops
|
|
||||||
if ($previous !== $error_handler) {
|
/**
|
||||||
self::$previousErrorHandler = $previous;
|
* Disable error handler
|
||||||
}
|
*/
|
||||||
|
public function deactivate() {
|
||||||
|
restore_error_handler();
|
||||||
|
$this->previousErrorHandler = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Error Handler to mute expected messages
|
* Error Handler to mute expected messages
|
||||||
*
|
*
|
||||||
* @link http://php.net/set_error_handler
|
* @link https://php.net/set_error_handler
|
||||||
*
|
*
|
||||||
* @param integer $errno Error level
|
* @param integer $errno Error level
|
||||||
* @param $errstr
|
* @param $errstr
|
||||||
@@ -65,49 +64,21 @@ class Smarty_Internal_ErrorHandler
|
|||||||
*
|
*
|
||||||
* @return bool
|
* @return bool
|
||||||
*/
|
*/
|
||||||
public static function mutingErrorHandler($errno, $errstr, $errfile, $errline, $errcontext = array())
|
public function handleError($errno, $errstr, $errfile, $errline, $errcontext = [])
|
||||||
{
|
{
|
||||||
$_is_muted_directory = false;
|
if ($this->allowUndefinedVars && $errstr == 'Attempt to read property "value" on null') {
|
||||||
// add the SMARTY_DIR to the list of muted directories
|
return; // suppresses this error
|
||||||
if (!isset(self::$mutedDirectories[ SMARTY_DIR ])) {
|
|
||||||
$smarty_dir = realpath(SMARTY_DIR);
|
|
||||||
if ($smarty_dir !== false) {
|
|
||||||
self::$mutedDirectories[ SMARTY_DIR ] =
|
|
||||||
array('file' => $smarty_dir, 'length' => strlen($smarty_dir),);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
// walk the muted directories and test against $errfile
|
|
||||||
foreach (self::$mutedDirectories as $key => &$dir) {
|
if ($this->allowUndefinedArrayKeys && preg_match(
|
||||||
if (!$dir) {
|
'/^(Undefined array key|Trying to access array offset on value of type null)/',
|
||||||
// resolve directory and length for speedy comparisons
|
$errstr
|
||||||
$file = realpath($key);
|
)) {
|
||||||
if ($file === false) {
|
return; // suppresses this error
|
||||||
// this directory does not exist, remove and skip it
|
|
||||||
unset(self::$mutedDirectories[ $key ]);
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
$dir = array('file' => $file, 'length' => strlen($file),);
|
|
||||||
}
|
|
||||||
if (!strncmp($errfile, $dir[ 'file' ], $dir[ 'length' ])) {
|
|
||||||
$_is_muted_directory = true;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
// pass to next error handler if this error did not occur inside SMARTY_DIR
|
|
||||||
// or the error was within smarty but masked to be ignored
|
|
||||||
if (!$_is_muted_directory || ($errno && $errno & error_reporting())) {
|
|
||||||
if (self::$previousErrorHandler) {
|
|
||||||
return call_user_func(
|
|
||||||
self::$previousErrorHandler,
|
|
||||||
$errno,
|
|
||||||
$errstr,
|
|
||||||
$errfile,
|
|
||||||
$errline,
|
|
||||||
$errcontext
|
|
||||||
);
|
|
||||||
} else {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// pass all other errors through to the previous error handler or to the default PHP error handler
|
||||||
|
return $this->previousErrorHandler ?
|
||||||
|
call_user_func($this->previousErrorHandler, $errno, $errstr, $errfile, $errline, $errcontext) : false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -22,7 +22,7 @@ class Smarty_Internal_Method_Append
|
|||||||
* appends values to template variables
|
* appends values to template variables
|
||||||
*
|
*
|
||||||
* @api Smarty::append()
|
* @api Smarty::append()
|
||||||
* @link http://www.smarty.net/docs/en/api.append.tpl
|
* @link https://www.smarty.net/docs/en/api.append.tpl
|
||||||
*
|
*
|
||||||
* @param \Smarty_Internal_Data|\Smarty_Internal_Template|\Smarty $data
|
* @param \Smarty_Internal_Data|\Smarty_Internal_Template|\Smarty $data
|
||||||
* @param array|string $tpl_var the template variable name(s)
|
* @param array|string $tpl_var the template variable name(s)
|
||||||
|
@@ -15,7 +15,7 @@ class Smarty_Internal_Method_AppendByRef
|
|||||||
* appends values to template variables by reference
|
* appends values to template variables by reference
|
||||||
*
|
*
|
||||||
* @api Smarty::appendByRef()
|
* @api Smarty::appendByRef()
|
||||||
* @link http://www.smarty.net/docs/en/api.append.by.ref.tpl
|
* @link https://www.smarty.net/docs/en/api.append.by.ref.tpl
|
||||||
*
|
*
|
||||||
* @param \Smarty_Internal_Data|\Smarty_Internal_Template|\Smarty $data
|
* @param \Smarty_Internal_Data|\Smarty_Internal_Template|\Smarty $data
|
||||||
* @param string $tpl_var the template variable name
|
* @param string $tpl_var the template variable name
|
||||||
|
@@ -22,7 +22,7 @@ class Smarty_Internal_Method_ClearAllAssign
|
|||||||
* clear all the assigned template variables.
|
* clear all the assigned template variables.
|
||||||
*
|
*
|
||||||
* @api Smarty::clearAllAssign()
|
* @api Smarty::clearAllAssign()
|
||||||
* @link http://www.smarty.net/docs/en/api.clear.all.assign.tpl
|
* @link https://www.smarty.net/docs/en/api.clear.all.assign.tpl
|
||||||
*
|
*
|
||||||
* @param \Smarty_Internal_Data|\Smarty_Internal_Template|\Smarty $data
|
* @param \Smarty_Internal_Data|\Smarty_Internal_Template|\Smarty $data
|
||||||
*
|
*
|
||||||
|
@@ -22,7 +22,7 @@ class Smarty_Internal_Method_ClearAllCache
|
|||||||
* Empty cache folder
|
* Empty cache folder
|
||||||
*
|
*
|
||||||
* @api Smarty::clearAllCache()
|
* @api Smarty::clearAllCache()
|
||||||
* @link http://www.smarty.net/docs/en/api.clear.all.cache.tpl
|
* @link https://www.smarty.net/docs/en/api.clear.all.cache.tpl
|
||||||
*
|
*
|
||||||
* @param \Smarty $smarty
|
* @param \Smarty $smarty
|
||||||
* @param integer $exp_time expiration time
|
* @param integer $exp_time expiration time
|
||||||
|
@@ -22,7 +22,7 @@ class Smarty_Internal_Method_ClearAssign
|
|||||||
* clear the given assigned template variable(s).
|
* clear the given assigned template variable(s).
|
||||||
*
|
*
|
||||||
* @api Smarty::clearAssign()
|
* @api Smarty::clearAssign()
|
||||||
* @link http://www.smarty.net/docs/en/api.clear.assign.tpl
|
* @link https://www.smarty.net/docs/en/api.clear.assign.tpl
|
||||||
*
|
*
|
||||||
* @param \Smarty_Internal_Data|\Smarty_Internal_Template|\Smarty $data
|
* @param \Smarty_Internal_Data|\Smarty_Internal_Template|\Smarty $data
|
||||||
* @param string|array $tpl_var the template variable(s) to clear
|
* @param string|array $tpl_var the template variable(s) to clear
|
||||||
|
@@ -22,7 +22,7 @@ class Smarty_Internal_Method_ClearCache
|
|||||||
* Empty cache for a specific template
|
* Empty cache for a specific template
|
||||||
*
|
*
|
||||||
* @api Smarty::clearCache()
|
* @api Smarty::clearCache()
|
||||||
* @link http://www.smarty.net/docs/en/api.clear.cache.tpl
|
* @link https://www.smarty.net/docs/en/api.clear.cache.tpl
|
||||||
*
|
*
|
||||||
* @param \Smarty $smarty
|
* @param \Smarty $smarty
|
||||||
* @param string $template_name template name
|
* @param string $template_name template name
|
||||||
|
@@ -22,7 +22,7 @@ class Smarty_Internal_Method_ClearCompiledTemplate
|
|||||||
* Delete compiled template file
|
* Delete compiled template file
|
||||||
*
|
*
|
||||||
* @api Smarty::clearCompiledTemplate()
|
* @api Smarty::clearCompiledTemplate()
|
||||||
* @link http://www.smarty.net/docs/en/api.clear.compiled.template.tpl
|
* @link https://www.smarty.net/docs/en/api.clear.compiled.template.tpl
|
||||||
*
|
*
|
||||||
* @param \Smarty $smarty
|
* @param \Smarty $smarty
|
||||||
* @param string $resource_name template name
|
* @param string $resource_name template name
|
||||||
|
@@ -22,7 +22,7 @@ class Smarty_Internal_Method_ClearConfig
|
|||||||
* clear a single or all config variables
|
* clear a single or all config variables
|
||||||
*
|
*
|
||||||
* @api Smarty::clearConfig()
|
* @api Smarty::clearConfig()
|
||||||
* @link http://www.smarty.net/docs/en/api.clear.config.tpl
|
* @link https://www.smarty.net/docs/en/api.clear.config.tpl
|
||||||
*
|
*
|
||||||
* @param \Smarty_Internal_Data|\Smarty_Internal_Template|\Smarty $data
|
* @param \Smarty_Internal_Data|\Smarty_Internal_Template|\Smarty $data
|
||||||
* @param string|null $name variable name or null
|
* @param string|null $name variable name or null
|
||||||
|
@@ -22,7 +22,7 @@ class Smarty_Internal_Method_ConfigLoad
|
|||||||
* load a config file, optionally load just selected sections
|
* load a config file, optionally load just selected sections
|
||||||
*
|
*
|
||||||
* @api Smarty::configLoad()
|
* @api Smarty::configLoad()
|
||||||
* @link http://www.smarty.net/docs/en/api.config.load.tpl
|
* @link https://www.smarty.net/docs/en/api.config.load.tpl
|
||||||
*
|
*
|
||||||
* @param \Smarty_Internal_Data|\Smarty_Internal_Template|\Smarty $data
|
* @param \Smarty_Internal_Data|\Smarty_Internal_Template|\Smarty $data
|
||||||
* @param string $config_file filename
|
* @param string $config_file filename
|
||||||
@@ -42,7 +42,7 @@ class Smarty_Internal_Method_ConfigLoad
|
|||||||
* load a config file, optionally load just selected sections
|
* load a config file, optionally load just selected sections
|
||||||
*
|
*
|
||||||
* @api Smarty::configLoad()
|
* @api Smarty::configLoad()
|
||||||
* @link http://www.smarty.net/docs/en/api.config.load.tpl
|
* @link https://www.smarty.net/docs/en/api.config.load.tpl
|
||||||
*
|
*
|
||||||
* @param \Smarty|\Smarty_Internal_Data|\Smarty_Internal_Template $data
|
* @param \Smarty|\Smarty_Internal_Data|\Smarty_Internal_Template $data
|
||||||
* @param string $config_file filename
|
* @param string $config_file filename
|
||||||
|
@@ -22,7 +22,7 @@ class Smarty_Internal_Method_CreateData
|
|||||||
* creates a data object
|
* creates a data object
|
||||||
*
|
*
|
||||||
* @api Smarty::createData()
|
* @api Smarty::createData()
|
||||||
* @link http://www.smarty.net/docs/en/api.create.data.tpl
|
* @link https://www.smarty.net/docs/en/api.create.data.tpl
|
||||||
*
|
*
|
||||||
* @param \Smarty_Internal_TemplateBase|\Smarty_Internal_Template|\Smarty $obj
|
* @param \Smarty_Internal_TemplateBase|\Smarty_Internal_Template|\Smarty $obj
|
||||||
* @param \Smarty_Internal_Template|\Smarty_Internal_Data|\Smarty_Data|\Smarty $parent next higher level of Smarty
|
* @param \Smarty_Internal_Template|\Smarty_Internal_Data|\Smarty_Data|\Smarty $parent next higher level of Smarty
|
||||||
|
@@ -22,7 +22,7 @@ class Smarty_Internal_Method_GetConfigVars
|
|||||||
* Returns a single or all config variables
|
* Returns a single or all config variables
|
||||||
*
|
*
|
||||||
* @api Smarty::getConfigVars()
|
* @api Smarty::getConfigVars()
|
||||||
* @link http://www.smarty.net/docs/en/api.get.config.vars.tpl
|
* @link https://www.smarty.net/docs/en/api.get.config.vars.tpl
|
||||||
*
|
*
|
||||||
* @param \Smarty_Internal_Data|\Smarty_Internal_Template|\Smarty $data
|
* @param \Smarty_Internal_Data|\Smarty_Internal_Template|\Smarty $data
|
||||||
* @param string $varname variable name or null
|
* @param string $varname variable name or null
|
||||||
|
@@ -22,7 +22,7 @@ class Smarty_Internal_Method_GetRegisteredObject
|
|||||||
* return a reference to a registered object
|
* return a reference to a registered object
|
||||||
*
|
*
|
||||||
* @api Smarty::getRegisteredObject()
|
* @api Smarty::getRegisteredObject()
|
||||||
* @link http://www.smarty.net/docs/en/api.get.registered.object.tpl
|
* @link https://www.smarty.net/docs/en/api.get.registered.object.tpl
|
||||||
*
|
*
|
||||||
* @param \Smarty_Internal_TemplateBase|\Smarty_Internal_Template|\Smarty $obj
|
* @param \Smarty_Internal_TemplateBase|\Smarty_Internal_Template|\Smarty $obj
|
||||||
* @param string $object_name object name
|
* @param string $object_name object name
|
||||||
|
@@ -22,7 +22,7 @@ class Smarty_Internal_Method_GetTags
|
|||||||
* Return array of tag/attributes of all tags used by an template
|
* Return array of tag/attributes of all tags used by an template
|
||||||
*
|
*
|
||||||
* @api Smarty::getTags()
|
* @api Smarty::getTags()
|
||||||
* @link http://www.smarty.net/docs/en/api.get.tags.tpl
|
* @link https://www.smarty.net/docs/en/api.get.tags.tpl
|
||||||
*
|
*
|
||||||
* @param \Smarty_Internal_TemplateBase|\Smarty_Internal_Template|\Smarty $obj
|
* @param \Smarty_Internal_TemplateBase|\Smarty_Internal_Template|\Smarty $obj
|
||||||
* @param null|string|Smarty_Internal_Template $template
|
* @param null|string|Smarty_Internal_Template $template
|
||||||
|
@@ -22,7 +22,7 @@ class Smarty_Internal_Method_GetTemplateVars
|
|||||||
* Returns a single or all template variables
|
* Returns a single or all template variables
|
||||||
*
|
*
|
||||||
* @api Smarty::getTemplateVars()
|
* @api Smarty::getTemplateVars()
|
||||||
* @link http://www.smarty.net/docs/en/api.get.template.vars.tpl
|
* @link https://www.smarty.net/docs/en/api.get.template.vars.tpl
|
||||||
*
|
*
|
||||||
* @param \Smarty_Internal_Data|\Smarty_Internal_Template|\Smarty $data
|
* @param \Smarty_Internal_Data|\Smarty_Internal_Template|\Smarty $data
|
||||||
* @param string $varName variable name or null
|
* @param string $varName variable name or null
|
||||||
|
@@ -30,7 +30,7 @@ class Smarty_Internal_Method_LoadFilter
|
|||||||
*
|
*
|
||||||
* @api Smarty::loadFilter()
|
* @api Smarty::loadFilter()
|
||||||
*
|
*
|
||||||
* @link http://www.smarty.net/docs/en/api.load.filter.tpl
|
* @link https://www.smarty.net/docs/en/api.load.filter.tpl
|
||||||
*
|
*
|
||||||
* @param \Smarty_Internal_TemplateBase|\Smarty_Internal_Template|\Smarty $obj
|
* @param \Smarty_Internal_TemplateBase|\Smarty_Internal_Template|\Smarty $obj
|
||||||
* @param string $type filter type
|
* @param string $type filter type
|
||||||
|
@@ -22,7 +22,7 @@ class Smarty_Internal_Method_RegisterCacheResource
|
|||||||
* Registers a resource to fetch a template
|
* Registers a resource to fetch a template
|
||||||
*
|
*
|
||||||
* @api Smarty::registerCacheResource()
|
* @api Smarty::registerCacheResource()
|
||||||
* @link http://www.smarty.net/docs/en/api.register.cacheresource.tpl
|
* @link https://www.smarty.net/docs/en/api.register.cacheresource.tpl
|
||||||
*
|
*
|
||||||
* @param \Smarty_Internal_TemplateBase|\Smarty_Internal_Template|\Smarty $obj
|
* @param \Smarty_Internal_TemplateBase|\Smarty_Internal_Template|\Smarty $obj
|
||||||
* @param string $name name of resource type
|
* @param string $name name of resource type
|
||||||
|
@@ -22,7 +22,7 @@ class Smarty_Internal_Method_RegisterClass
|
|||||||
* Registers static classes to be used in templates
|
* Registers static classes to be used in templates
|
||||||
*
|
*
|
||||||
* @api Smarty::registerClass()
|
* @api Smarty::registerClass()
|
||||||
* @link http://www.smarty.net/docs/en/api.register.class.tpl
|
* @link https://www.smarty.net/docs/en/api.register.class.tpl
|
||||||
*
|
*
|
||||||
* @param \Smarty_Internal_TemplateBase|\Smarty_Internal_Template|\Smarty $obj
|
* @param \Smarty_Internal_TemplateBase|\Smarty_Internal_Template|\Smarty $obj
|
||||||
* @param string $class_name
|
* @param string $class_name
|
||||||
|
@@ -22,7 +22,7 @@ class Smarty_Internal_Method_RegisterDefaultPluginHandler
|
|||||||
* Registers a default plugin handler
|
* Registers a default plugin handler
|
||||||
*
|
*
|
||||||
* @api Smarty::registerDefaultPluginHandler()
|
* @api Smarty::registerDefaultPluginHandler()
|
||||||
* @link http://www.smarty.net/docs/en/api.register.default.plugin.handler.tpl
|
* @link https://www.smarty.net/docs/en/api.register.default.plugin.handler.tpl
|
||||||
*
|
*
|
||||||
* @param \Smarty_Internal_TemplateBase|\Smarty_Internal_Template|\Smarty $obj
|
* @param \Smarty_Internal_TemplateBase|\Smarty_Internal_Template|\Smarty $obj
|
||||||
* @param callable $callback class/method name
|
* @param callable $callback class/method name
|
||||||
|
@@ -30,7 +30,7 @@ class Smarty_Internal_Method_RegisterFilter
|
|||||||
*
|
*
|
||||||
* @api Smarty::registerFilter()
|
* @api Smarty::registerFilter()
|
||||||
*
|
*
|
||||||
* @link http://www.smarty.net/docs/en/api.register.filter.tpl
|
* @link https://www.smarty.net/docs/en/api.register.filter.tpl
|
||||||
*
|
*
|
||||||
* @param \Smarty_Internal_TemplateBase|\Smarty_Internal_Template|\Smarty $obj
|
* @param \Smarty_Internal_TemplateBase|\Smarty_Internal_Template|\Smarty $obj
|
||||||
* @param string $type filter type
|
* @param string $type filter type
|
||||||
|
@@ -22,7 +22,7 @@ class Smarty_Internal_Method_RegisterObject
|
|||||||
* Registers object to be used in templates
|
* Registers object to be used in templates
|
||||||
*
|
*
|
||||||
* @api Smarty::registerObject()
|
* @api Smarty::registerObject()
|
||||||
* @link http://www.smarty.net/docs/en/api.register.object.tpl
|
* @link https://www.smarty.net/docs/en/api.register.object.tpl
|
||||||
*
|
*
|
||||||
* @param \Smarty_Internal_TemplateBase|\Smarty_Internal_Template|\Smarty $obj
|
* @param \Smarty_Internal_TemplateBase|\Smarty_Internal_Template|\Smarty $obj
|
||||||
* @param string $object_name
|
* @param string $object_name
|
||||||
|
@@ -22,7 +22,7 @@ class Smarty_Internal_Method_RegisterPlugin
|
|||||||
* Registers plugin to be used in templates
|
* Registers plugin to be used in templates
|
||||||
*
|
*
|
||||||
* @api Smarty::registerPlugin()
|
* @api Smarty::registerPlugin()
|
||||||
* @link http://www.smarty.net/docs/en/api.register.plugin.tpl
|
* @link https://www.smarty.net/docs/en/api.register.plugin.tpl
|
||||||
*
|
*
|
||||||
* @param \Smarty_Internal_TemplateBase|\Smarty_Internal_Template|\Smarty $obj
|
* @param \Smarty_Internal_TemplateBase|\Smarty_Internal_Template|\Smarty $obj
|
||||||
* @param string $type plugin type
|
* @param string $type plugin type
|
||||||
|
@@ -22,25 +22,18 @@ class Smarty_Internal_Method_RegisterResource
|
|||||||
* Registers a resource to fetch a template
|
* Registers a resource to fetch a template
|
||||||
*
|
*
|
||||||
* @api Smarty::registerResource()
|
* @api Smarty::registerResource()
|
||||||
* @link http://www.smarty.net/docs/en/api.register.resource.tpl
|
* @link https://www.smarty.net/docs/en/api.register.resource.tpl
|
||||||
*
|
*
|
||||||
* @param \Smarty_Internal_TemplateBase|\Smarty_Internal_Template|\Smarty $obj
|
* @param \Smarty_Internal_TemplateBase|\Smarty_Internal_Template|\Smarty $obj
|
||||||
* @param string $name name of resource type
|
* @param string $name name of resource type
|
||||||
* @param Smarty_Resource|array $resource_handler or instance of
|
* @param Smarty_Resource $resource_handler instance of Smarty_Resource
|
||||||
* Smarty_Resource,
|
|
||||||
* or array of
|
|
||||||
* callbacks to
|
|
||||||
* handle
|
|
||||||
* resource
|
|
||||||
* (deprecated)
|
|
||||||
*
|
*
|
||||||
* @return \Smarty|\Smarty_Internal_Template
|
* @return \Smarty|\Smarty_Internal_Template
|
||||||
*/
|
*/
|
||||||
public function registerResource(Smarty_Internal_TemplateBase $obj, $name, $resource_handler)
|
public function registerResource(Smarty_Internal_TemplateBase $obj, $name, Smarty_Resource $resource_handler)
|
||||||
{
|
{
|
||||||
$smarty = $obj->_getSmartyObj();
|
$smarty = $obj->_getSmartyObj();
|
||||||
$smarty->registered_resources[ $name ] =
|
$smarty->registered_resources[ $name ] = $resource_handler;
|
||||||
$resource_handler instanceof Smarty_Resource ? $resource_handler : array($resource_handler, false);
|
|
||||||
return $obj;
|
return $obj;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -16,7 +16,7 @@ class Smarty_Internal_Method_UnloadFilter extends Smarty_Internal_Method_LoadFil
|
|||||||
*
|
*
|
||||||
* @api Smarty::unloadFilter()
|
* @api Smarty::unloadFilter()
|
||||||
*
|
*
|
||||||
* @link http://www.smarty.net/docs/en/api.unload.filter.tpl
|
* @link https://www.smarty.net/docs/en/api.unload.filter.tpl
|
||||||
*
|
*
|
||||||
* @param \Smarty_Internal_TemplateBase|\Smarty_Internal_Template|\Smarty $obj
|
* @param \Smarty_Internal_TemplateBase|\Smarty_Internal_Template|\Smarty $obj
|
||||||
* @param string $type filter type
|
* @param string $type filter type
|
||||||
|
@@ -22,7 +22,7 @@ class Smarty_Internal_Method_UnregisterCacheResource
|
|||||||
* Registers a resource to fetch a template
|
* Registers a resource to fetch a template
|
||||||
*
|
*
|
||||||
* @api Smarty::unregisterCacheResource()
|
* @api Smarty::unregisterCacheResource()
|
||||||
* @link http://www.smarty.net/docs/en/api.unregister.cacheresource.tpl
|
* @link https://www.smarty.net/docs/en/api.unregister.cacheresource.tpl
|
||||||
*
|
*
|
||||||
* @param \Smarty_Internal_TemplateBase|\Smarty_Internal_Template|\Smarty $obj
|
* @param \Smarty_Internal_TemplateBase|\Smarty_Internal_Template|\Smarty $obj
|
||||||
* @param $name
|
* @param $name
|
||||||
|
@@ -16,7 +16,7 @@ class Smarty_Internal_Method_UnregisterFilter extends Smarty_Internal_Method_Reg
|
|||||||
*
|
*
|
||||||
* @api Smarty::unregisterFilter()
|
* @api Smarty::unregisterFilter()
|
||||||
*
|
*
|
||||||
* @link http://www.smarty.net/docs/en/api.unregister.filter.tpl
|
* @link https://www.smarty.net/docs/en/api.unregister.filter.tpl
|
||||||
*
|
*
|
||||||
* @param \Smarty_Internal_TemplateBase|\Smarty_Internal_Template|\Smarty $obj
|
* @param \Smarty_Internal_TemplateBase|\Smarty_Internal_Template|\Smarty $obj
|
||||||
* @param string $type filter type
|
* @param string $type filter type
|
||||||
|
@@ -22,7 +22,7 @@ class Smarty_Internal_Method_UnregisterObject
|
|||||||
* Registers plugin to be used in templates
|
* Registers plugin to be used in templates
|
||||||
*
|
*
|
||||||
* @api Smarty::unregisterObject()
|
* @api Smarty::unregisterObject()
|
||||||
* @link http://www.smarty.net/docs/en/api.unregister.object.tpl
|
* @link https://www.smarty.net/docs/en/api.unregister.object.tpl
|
||||||
*
|
*
|
||||||
* @param \Smarty_Internal_TemplateBase|\Smarty_Internal_Template|\Smarty $obj
|
* @param \Smarty_Internal_TemplateBase|\Smarty_Internal_Template|\Smarty $obj
|
||||||
* @param string $object_name name of object
|
* @param string $object_name name of object
|
||||||
|
@@ -22,7 +22,7 @@ class Smarty_Internal_Method_UnregisterPlugin
|
|||||||
* Registers plugin to be used in templates
|
* Registers plugin to be used in templates
|
||||||
*
|
*
|
||||||
* @api Smarty::unregisterPlugin()
|
* @api Smarty::unregisterPlugin()
|
||||||
* @link http://www.smarty.net/docs/en/api.unregister.plugin.tpl
|
* @link https://www.smarty.net/docs/en/api.unregister.plugin.tpl
|
||||||
*
|
*
|
||||||
* @param \Smarty_Internal_TemplateBase|\Smarty_Internal_Template|\Smarty $obj
|
* @param \Smarty_Internal_TemplateBase|\Smarty_Internal_Template|\Smarty $obj
|
||||||
* @param string $type plugin type
|
* @param string $type plugin type
|
||||||
|
@@ -22,7 +22,7 @@ class Smarty_Internal_Method_UnregisterResource
|
|||||||
* Registers a resource to fetch a template
|
* Registers a resource to fetch a template
|
||||||
*
|
*
|
||||||
* @api Smarty::unregisterResource()
|
* @api Smarty::unregisterResource()
|
||||||
* @link http://www.smarty.net/docs/en/api.unregister.resource.tpl
|
* @link https://www.smarty.net/docs/en/api.unregister.resource.tpl
|
||||||
*
|
*
|
||||||
* @param \Smarty_Internal_TemplateBase|\Smarty_Internal_Template|\Smarty $obj
|
* @param \Smarty_Internal_TemplateBase|\Smarty_Internal_Template|\Smarty $obj
|
||||||
* @param string $type name of resource type
|
* @param string $type name of resource type
|
||||||
|
@@ -87,83 +87,83 @@ class Smarty_Internal_ParseTree_Template extends Smarty_Internal_ParseTree
|
|||||||
$code = '';
|
$code = '';
|
||||||
|
|
||||||
foreach ($this->getChunkedSubtrees() as $chunk) {
|
foreach ($this->getChunkedSubtrees() as $chunk) {
|
||||||
$text = '';
|
$text = '';
|
||||||
switch ($chunk['mode']) {
|
switch ($chunk['mode']) {
|
||||||
case 'textstripped':
|
case 'textstripped':
|
||||||
foreach ($chunk['subtrees'] as $subtree) {
|
foreach ($chunk['subtrees'] as $subtree) {
|
||||||
$text .= $subtree->to_smarty_php($parser);
|
$text .= $subtree->to_smarty_php($parser);
|
||||||
}
|
}
|
||||||
$code .= preg_replace(
|
$code .= preg_replace(
|
||||||
'/((<%)|(%>)|(<\?php)|(<\?)|(\?>)|(<\/?script))/',
|
'/((<%)|(%>)|(<\?php)|(<\?)|(\?>)|(<\/?script))/',
|
||||||
"<?php echo '\$1'; ?>\n",
|
"<?php echo '\$1'; ?>\n",
|
||||||
$parser->compiler->processText($text)
|
$parser->compiler->processText($text)
|
||||||
);
|
);
|
||||||
break;
|
break;
|
||||||
case 'text':
|
case 'text':
|
||||||
foreach ($chunk['subtrees'] as $subtree) {
|
foreach ($chunk['subtrees'] as $subtree) {
|
||||||
$text .= $subtree->to_smarty_php($parser);
|
$text .= $subtree->to_smarty_php($parser);
|
||||||
}
|
}
|
||||||
$code .= preg_replace(
|
$code .= preg_replace(
|
||||||
'/((<%)|(%>)|(<\?php)|(<\?)|(\?>)|(<\/?script))/',
|
'/((<%)|(%>)|(<\?php)|(<\?)|(\?>)|(<\/?script))/',
|
||||||
"<?php echo '\$1'; ?>\n",
|
"<?php echo '\$1'; ?>\n",
|
||||||
$text
|
$text
|
||||||
);
|
);
|
||||||
break;
|
break;
|
||||||
case 'tag':
|
case 'tag':
|
||||||
foreach ($chunk['subtrees'] as $subtree) {
|
foreach ($chunk['subtrees'] as $subtree) {
|
||||||
$text = $parser->compiler->appendCode($text, $subtree->to_smarty_php($parser));
|
$text = $parser->compiler->appendCode($text, $subtree->to_smarty_php($parser));
|
||||||
}
|
}
|
||||||
$code .= $text;
|
$code .= $text;
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
foreach ($chunk['subtrees'] as $subtree) {
|
foreach ($chunk['subtrees'] as $subtree) {
|
||||||
$text = $subtree->to_smarty_php($parser);
|
$text = $subtree->to_smarty_php($parser);
|
||||||
}
|
}
|
||||||
$code .= $text;
|
$code .= $text;
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return $code;
|
return $code;
|
||||||
}
|
}
|
||||||
|
|
||||||
private function getChunkedSubtrees() {
|
private function getChunkedSubtrees() {
|
||||||
$chunks = array();
|
$chunks = array();
|
||||||
$currentMode = null;
|
$currentMode = null;
|
||||||
$currentChunk = array();
|
$currentChunk = array();
|
||||||
for ($key = 0, $cnt = count($this->subtrees); $key < $cnt; $key++) {
|
for ($key = 0, $cnt = count($this->subtrees); $key < $cnt; $key++) {
|
||||||
|
|
||||||
if ($this->subtrees[ $key ]->data === '' && in_array($currentMode, array('textstripped', 'text', 'tag'))) {
|
if ($this->subtrees[ $key ]->data === '' && in_array($currentMode, array('textstripped', 'text', 'tag'))) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($this->subtrees[ $key ] instanceof Smarty_Internal_ParseTree_Text
|
if ($this->subtrees[ $key ] instanceof Smarty_Internal_ParseTree_Text
|
||||||
&& $this->subtrees[ $key ]->isToBeStripped()) {
|
&& $this->subtrees[ $key ]->isToBeStripped()) {
|
||||||
$newMode = 'textstripped';
|
$newMode = 'textstripped';
|
||||||
} elseif ($this->subtrees[ $key ] instanceof Smarty_Internal_ParseTree_Text) {
|
} elseif ($this->subtrees[ $key ] instanceof Smarty_Internal_ParseTree_Text) {
|
||||||
$newMode = 'text';
|
$newMode = 'text';
|
||||||
} elseif ($this->subtrees[ $key ] instanceof Smarty_Internal_ParseTree_Tag) {
|
} elseif ($this->subtrees[ $key ] instanceof Smarty_Internal_ParseTree_Tag) {
|
||||||
$newMode = 'tag';
|
$newMode = 'tag';
|
||||||
} else {
|
} else {
|
||||||
$newMode = 'other';
|
$newMode = 'other';
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($newMode == $currentMode) {
|
if ($newMode == $currentMode) {
|
||||||
$currentChunk[] = $this->subtrees[ $key ];
|
$currentChunk[] = $this->subtrees[ $key ];
|
||||||
} else {
|
} else {
|
||||||
$chunks[] = array(
|
$chunks[] = array(
|
||||||
'mode' => $currentMode,
|
'mode' => $currentMode,
|
||||||
'subtrees' => $currentChunk
|
'subtrees' => $currentChunk
|
||||||
);
|
);
|
||||||
$currentMode = $newMode;
|
$currentMode = $newMode;
|
||||||
$currentChunk = array($this->subtrees[ $key ]);
|
$currentChunk = array($this->subtrees[ $key ]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if ($currentMode && $currentChunk) {
|
if ($currentMode && $currentChunk) {
|
||||||
$chunks[] = array(
|
$chunks[] = array(
|
||||||
'mode' => $currentMode,
|
'mode' => $currentMode,
|
||||||
'subtrees' => $currentChunk
|
'subtrees' => $currentChunk
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
return $chunks;
|
return $chunks;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -17,30 +17,30 @@
|
|||||||
class Smarty_Internal_ParseTree_Text extends Smarty_Internal_ParseTree
|
class Smarty_Internal_ParseTree_Text extends Smarty_Internal_ParseTree
|
||||||
{
|
{
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Wether this section should be stripped on output to smarty php
|
* Wether this section should be stripped on output to smarty php
|
||||||
* @var bool
|
* @var bool
|
||||||
*/
|
*/
|
||||||
private $toBeStripped = false;
|
private $toBeStripped = false;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Create template text buffer
|
* Create template text buffer
|
||||||
*
|
*
|
||||||
* @param string $data text
|
* @param string $data text
|
||||||
* @param bool $toBeStripped wether this section should be stripped on output to smarty php
|
* @param bool $toBeStripped wether this section should be stripped on output to smarty php
|
||||||
*/
|
*/
|
||||||
public function __construct($data, $toBeStripped = false)
|
public function __construct($data, $toBeStripped = false)
|
||||||
{
|
{
|
||||||
$this->data = $data;
|
$this->data = $data;
|
||||||
$this->toBeStripped = $toBeStripped;
|
$this->toBeStripped = $toBeStripped;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Wether this section should be stripped on output to smarty php
|
* Wether this section should be stripped on output to smarty php
|
||||||
* @return bool
|
* @return bool
|
||||||
*/
|
*/
|
||||||
public function isToBeStripped() {
|
public function isToBeStripped() {
|
||||||
return $this->toBeStripped;
|
return $this->toBeStripped;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@@ -1,101 +0,0 @@
|
|||||||
<?php
|
|
||||||
/**
|
|
||||||
* Smarty Internal Plugin Resource Registered
|
|
||||||
*
|
|
||||||
* @package Smarty
|
|
||||||
* @subpackage TemplateResources
|
|
||||||
* @author Uwe Tews
|
|
||||||
* @author Rodney Rehm
|
|
||||||
*/
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Smarty Internal Plugin Resource Registered
|
|
||||||
* Implements the registered resource for Smarty template
|
|
||||||
*
|
|
||||||
* @package Smarty
|
|
||||||
* @subpackage TemplateResources
|
|
||||||
* @deprecated
|
|
||||||
*/
|
|
||||||
class Smarty_Internal_Resource_Registered extends Smarty_Resource
|
|
||||||
{
|
|
||||||
/**
|
|
||||||
* populate Source Object with meta data from Resource
|
|
||||||
*
|
|
||||||
* @param Smarty_Template_Source $source source object
|
|
||||||
* @param Smarty_Internal_Template $_template template object
|
|
||||||
*
|
|
||||||
* @return void
|
|
||||||
*/
|
|
||||||
public function populate(Smarty_Template_Source $source, Smarty_Internal_Template $_template = null)
|
|
||||||
{
|
|
||||||
$source->filepath = $source->type . ':' . $source->name;
|
|
||||||
$source->uid = sha1($source->filepath . $source->smarty->_joined_template_dir);
|
|
||||||
$source->timestamp = $this->getTemplateTimestamp($source);
|
|
||||||
$source->exists = !!$source->timestamp;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* populate Source Object with timestamp and exists from Resource
|
|
||||||
*
|
|
||||||
* @param Smarty_Template_Source $source source object
|
|
||||||
*
|
|
||||||
* @return void
|
|
||||||
*/
|
|
||||||
public function populateTimestamp(Smarty_Template_Source $source)
|
|
||||||
{
|
|
||||||
$source->timestamp = $this->getTemplateTimestamp($source);
|
|
||||||
$source->exists = !!$source->timestamp;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Get timestamp (epoch) the template source was modified
|
|
||||||
*
|
|
||||||
* @param Smarty_Template_Source $source source object
|
|
||||||
*
|
|
||||||
* @return integer|boolean timestamp (epoch) the template was modified, false if resources has no timestamp
|
|
||||||
*/
|
|
||||||
public function getTemplateTimestamp(Smarty_Template_Source $source)
|
|
||||||
{
|
|
||||||
// return timestamp
|
|
||||||
$time_stamp = false;
|
|
||||||
call_user_func_array(
|
|
||||||
$source->smarty->registered_resources[ $source->type ][ 0 ][ 1 ],
|
|
||||||
array($source->name, &$time_stamp, $source->smarty)
|
|
||||||
);
|
|
||||||
return is_numeric($time_stamp) ? (int)$time_stamp : $time_stamp;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Load template's source by invoking the registered callback into current template object
|
|
||||||
*
|
|
||||||
* @param Smarty_Template_Source $source source object
|
|
||||||
*
|
|
||||||
* @return string template source
|
|
||||||
* @throws SmartyException if source cannot be loaded
|
|
||||||
*/
|
|
||||||
public function getContent(Smarty_Template_Source $source)
|
|
||||||
{
|
|
||||||
// return template string
|
|
||||||
$content = null;
|
|
||||||
$t = call_user_func_array(
|
|
||||||
$source->smarty->registered_resources[ $source->type ][ 0 ][ 0 ],
|
|
||||||
array($source->name, &$content, $source->smarty)
|
|
||||||
);
|
|
||||||
if (is_bool($t) && !$t) {
|
|
||||||
throw new SmartyException("Unable to read template {$source->type} '{$source->name}'");
|
|
||||||
}
|
|
||||||
return $content;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Determine basename for compiled filename
|
|
||||||
*
|
|
||||||
* @param Smarty_Template_Source $source source object
|
|
||||||
*
|
|
||||||
* @return string resource's basename
|
|
||||||
*/
|
|
||||||
public function getBasename(Smarty_Template_Source $source)
|
|
||||||
{
|
|
||||||
return basename($source->name);
|
|
||||||
}
|
|
||||||
}
|
|
@@ -13,7 +13,7 @@
|
|||||||
* Smarty Internal Plugin Resource Stream
|
* Smarty Internal Plugin Resource Stream
|
||||||
* Implements the streams as resource for Smarty template
|
* Implements the streams as resource for Smarty template
|
||||||
*
|
*
|
||||||
* @link http://php.net/streams
|
* @link https://php.net/streams
|
||||||
* @package Smarty
|
* @package Smarty
|
||||||
* @subpackage TemplateResources
|
* @subpackage TemplateResources
|
||||||
*/
|
*/
|
||||||
|
@@ -138,7 +138,7 @@ abstract class Smarty_Internal_TemplateBase extends Smarty_Internal_Data
|
|||||||
* test if cache is valid
|
* test if cache is valid
|
||||||
*
|
*
|
||||||
* @api Smarty::isCached()
|
* @api Smarty::isCached()
|
||||||
* @link http://www.smarty.net/docs/en/api.is.cached.tpl
|
* @link https://www.smarty.net/docs/en/api.is.cached.tpl
|
||||||
*
|
*
|
||||||
* @param null|string|\Smarty_Internal_Template $template the resource handle of the template file or template
|
* @param null|string|\Smarty_Internal_Template $template the resource handle of the template file or template
|
||||||
* object
|
* object
|
||||||
@@ -199,6 +199,12 @@ abstract class Smarty_Internal_TemplateBase extends Smarty_Internal_Data
|
|||||||
try {
|
try {
|
||||||
$_smarty_old_error_level =
|
$_smarty_old_error_level =
|
||||||
isset($smarty->error_reporting) ? error_reporting($smarty->error_reporting) : null;
|
isset($smarty->error_reporting) ? error_reporting($smarty->error_reporting) : null;
|
||||||
|
|
||||||
|
if ($smarty->isMutingUndefinedOrNullWarnings()) {
|
||||||
|
$errorHandler = new Smarty_Internal_ErrorHandler();
|
||||||
|
$errorHandler->activate();
|
||||||
|
}
|
||||||
|
|
||||||
if ($this->_objType === 2) {
|
if ($this->_objType === 2) {
|
||||||
/* @var Smarty_Internal_Template $this */
|
/* @var Smarty_Internal_Template $this */
|
||||||
$template->tplFunctions = $this->tplFunctions;
|
$template->tplFunctions = $this->tplFunctions;
|
||||||
@@ -242,6 +248,11 @@ abstract class Smarty_Internal_TemplateBase extends Smarty_Internal_Data
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (isset($errorHandler)) {
|
||||||
|
$errorHandler->deactivate();
|
||||||
|
}
|
||||||
|
|
||||||
if (isset($_smarty_old_error_level)) {
|
if (isset($_smarty_old_error_level)) {
|
||||||
error_reporting($_smarty_old_error_level);
|
error_reporting($_smarty_old_error_level);
|
||||||
}
|
}
|
||||||
@@ -250,6 +261,10 @@ abstract class Smarty_Internal_TemplateBase extends Smarty_Internal_Data
|
|||||||
while (ob_get_level() > $level) {
|
while (ob_get_level() > $level) {
|
||||||
ob_end_clean();
|
ob_end_clean();
|
||||||
}
|
}
|
||||||
|
if (isset($errorHandler)) {
|
||||||
|
$errorHandler->deactivate();
|
||||||
|
}
|
||||||
|
|
||||||
if (isset($_smarty_old_error_level)) {
|
if (isset($_smarty_old_error_level)) {
|
||||||
error_reporting($_smarty_old_error_level);
|
error_reporting($_smarty_old_error_level);
|
||||||
}
|
}
|
||||||
@@ -261,7 +276,7 @@ abstract class Smarty_Internal_TemplateBase extends Smarty_Internal_Data
|
|||||||
* Registers plugin to be used in templates
|
* Registers plugin to be used in templates
|
||||||
*
|
*
|
||||||
* @api Smarty::registerPlugin()
|
* @api Smarty::registerPlugin()
|
||||||
* @link http://www.smarty.net/docs/en/api.register.plugin.tpl
|
* @link https://www.smarty.net/docs/en/api.register.plugin.tpl
|
||||||
*
|
*
|
||||||
* @param string $type plugin type
|
* @param string $type plugin type
|
||||||
* @param string $name name of template tag
|
* @param string $name name of template tag
|
||||||
@@ -281,7 +296,7 @@ abstract class Smarty_Internal_TemplateBase extends Smarty_Internal_Data
|
|||||||
* load a filter of specified type and name
|
* load a filter of specified type and name
|
||||||
*
|
*
|
||||||
* @api Smarty::loadFilter()
|
* @api Smarty::loadFilter()
|
||||||
* @link http://www.smarty.net/docs/en/api.load.filter.tpl
|
* @link https://www.smarty.net/docs/en/api.load.filter.tpl
|
||||||
*
|
*
|
||||||
* @param string $type filter type
|
* @param string $type filter type
|
||||||
* @param string $name filter name
|
* @param string $name filter name
|
||||||
@@ -298,7 +313,7 @@ abstract class Smarty_Internal_TemplateBase extends Smarty_Internal_Data
|
|||||||
* Registers a filter function
|
* Registers a filter function
|
||||||
*
|
*
|
||||||
* @api Smarty::registerFilter()
|
* @api Smarty::registerFilter()
|
||||||
* @link http://www.smarty.net/docs/en/api.register.filter.tpl
|
* @link https://www.smarty.net/docs/en/api.register.filter.tpl
|
||||||
*
|
*
|
||||||
* @param string $type filter type
|
* @param string $type filter type
|
||||||
* @param callable $callback
|
* @param callable $callback
|
||||||
@@ -316,7 +331,7 @@ abstract class Smarty_Internal_TemplateBase extends Smarty_Internal_Data
|
|||||||
* Registers object to be used in templates
|
* Registers object to be used in templates
|
||||||
*
|
*
|
||||||
* @api Smarty::registerObject()
|
* @api Smarty::registerObject()
|
||||||
* @link http://www.smarty.net/docs/en/api.register.object.tpl
|
* @link https://www.smarty.net/docs/en/api.register.object.tpl
|
||||||
*
|
*
|
||||||
* @param string $object_name
|
* @param string $object_name
|
||||||
* @param object $object the referenced PHP object to register
|
* @param object $object the referenced PHP object to register
|
||||||
|
@@ -203,13 +203,6 @@ abstract class Smarty_Internal_TemplateCompilerBase
|
|||||||
*/
|
*/
|
||||||
public $blockOrFunctionCode = '';
|
public $blockOrFunctionCode = '';
|
||||||
|
|
||||||
/**
|
|
||||||
* php_handling setting either from Smarty or security
|
|
||||||
*
|
|
||||||
* @var int
|
|
||||||
*/
|
|
||||||
public $php_handling = 0;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* flags for used modifier plugins
|
* flags for used modifier plugins
|
||||||
*
|
*
|
||||||
@@ -438,11 +431,6 @@ abstract class Smarty_Internal_TemplateCompilerBase
|
|||||||
}
|
}
|
||||||
$this->smarty->_debug->start_compile($this->template);
|
$this->smarty->_debug->start_compile($this->template);
|
||||||
}
|
}
|
||||||
if (isset($this->template->smarty->security_policy)) {
|
|
||||||
$this->php_handling = $this->template->smarty->security_policy->php_handling;
|
|
||||||
} else {
|
|
||||||
$this->php_handling = $this->template->smarty->php_handling;
|
|
||||||
}
|
|
||||||
$this->parent_compiler = $parent_compiler ? $parent_compiler : $this;
|
$this->parent_compiler = $parent_compiler ? $parent_compiler : $this;
|
||||||
$nocache = isset($nocache) ? $nocache : false;
|
$nocache = isset($nocache) ? $nocache : false;
|
||||||
if (empty($template->compiled->nocache_hash)) {
|
if (empty($template->compiled->nocache_hash)) {
|
||||||
@@ -627,11 +615,11 @@ abstract class Smarty_Internal_TemplateCompilerBase
|
|||||||
$this->trigger_template_error('Illegal number of parameter in "isset()"');
|
$this->trigger_template_error('Illegal number of parameter in "isset()"');
|
||||||
}
|
}
|
||||||
|
|
||||||
$pa = array();
|
$pa = array();
|
||||||
foreach ($parameter as $p) {
|
foreach ($parameter as $p) {
|
||||||
$pa[] = $this->syntaxMatchesVariable($p) ? 'isset(' . $p . ')' : '(' . $p . ' !== null )';
|
$pa[] = $this->syntaxMatchesVariable($p) ? 'isset(' . $p . ')' : '(' . $p . ' !== null )';
|
||||||
}
|
}
|
||||||
return '(' . implode(' && ', $pa) . ')';
|
return '(' . implode(' && ', $pa) . ')';
|
||||||
|
|
||||||
} elseif (in_array(
|
} elseif (in_array(
|
||||||
$func_name,
|
$func_name,
|
||||||
@@ -649,12 +637,8 @@ abstract class Smarty_Internal_TemplateCompilerBase
|
|||||||
$this->trigger_template_error("Illegal number of parameter in '{$func_name()}'");
|
$this->trigger_template_error("Illegal number of parameter in '{$func_name()}'");
|
||||||
}
|
}
|
||||||
if ($func_name === 'empty') {
|
if ($func_name === 'empty') {
|
||||||
if (!$this->syntaxMatchesVariable($parameter[0]) && version_compare(PHP_VERSION, '5.5.0', '<')) {
|
return $func_name . '(' .
|
||||||
return '(' . $parameter[ 0 ] . ' === false )';
|
str_replace("')->value", "',null,true,false)->value", $parameter[ 0 ]) . ')';
|
||||||
} else {
|
|
||||||
return $func_name . '(' .
|
|
||||||
str_replace("')->value", "',null,true,false)->value", $parameter[ 0 ]) . ')';
|
|
||||||
}
|
|
||||||
} else {
|
} else {
|
||||||
return $func_name . '(' . $parameter[ 0 ] . ')';
|
return $func_name . '(' . $parameter[ 0 ] . ')';
|
||||||
}
|
}
|
||||||
@@ -667,16 +651,16 @@ abstract class Smarty_Internal_TemplateCompilerBase
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Determines whether the passed string represents a valid (PHP) variable.
|
* Determines whether the passed string represents a valid (PHP) variable.
|
||||||
* This is important, because `isset()` only works on variables and `empty()` can only be passed
|
* This is important, because `isset()` only works on variables and `empty()` can only be passed
|
||||||
* a variable prior to php5.5
|
* a variable prior to php5.5
|
||||||
* @param $string
|
* @param $string
|
||||||
* @return bool
|
* @return bool
|
||||||
*/
|
*/
|
||||||
private function syntaxMatchesVariable($string) {
|
private function syntaxMatchesVariable($string) {
|
||||||
static $regex_pattern = '/^\$[a-zA-Z_\x7f-\xff][a-zA-Z0-9_\x7f-\xff]*((->)[a-zA-Z_\x7f-\xff][a-zA-Z0-9_\x7f-\xff]*|\[.*]*\])*$/';
|
static $regex_pattern = '/^\$[a-zA-Z_\x7f-\xff][a-zA-Z0-9_\x7f-\xff]*((->)[a-zA-Z_\x7f-\xff][a-zA-Z0-9_\x7f-\xff]*|\[.*]*\])*$/';
|
||||||
return 1 === preg_match($regex_pattern, trim($string));
|
return 1 === preg_match($regex_pattern, trim($string));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -691,11 +675,11 @@ abstract class Smarty_Internal_TemplateCompilerBase
|
|||||||
{
|
{
|
||||||
|
|
||||||
if (strpos($text, '<') === false) {
|
if (strpos($text, '<') === false) {
|
||||||
return preg_replace($this->stripRegEx, '', $text);
|
return preg_replace($this->stripRegEx, '', $text);
|
||||||
}
|
}
|
||||||
|
|
||||||
$store = array();
|
$store = array();
|
||||||
$_store = 0;
|
$_store = 0;
|
||||||
|
|
||||||
// capture html elements not to be messed with
|
// capture html elements not to be messed with
|
||||||
$_offset = 0;
|
$_offset = 0;
|
||||||
|
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
@@ -362,7 +362,6 @@ class Smarty_Internal_TestInstall
|
|||||||
'smarty_internal_compile_function.php' => true,
|
'smarty_internal_compile_function.php' => true,
|
||||||
'smarty_internal_compile_if.php' => true,
|
'smarty_internal_compile_if.php' => true,
|
||||||
'smarty_internal_compile_include.php' => true,
|
'smarty_internal_compile_include.php' => true,
|
||||||
'smarty_internal_compile_include_php.php' => true,
|
|
||||||
'smarty_internal_compile_insert.php' => true,
|
'smarty_internal_compile_insert.php' => true,
|
||||||
'smarty_internal_compile_ldelim.php' => true,
|
'smarty_internal_compile_ldelim.php' => true,
|
||||||
'smarty_internal_compile_make_nocache.php' => true,
|
'smarty_internal_compile_make_nocache.php' => true,
|
||||||
@@ -373,7 +372,6 @@ class Smarty_Internal_TestInstall
|
|||||||
'smarty_internal_compile_private_modifier.php' => true,
|
'smarty_internal_compile_private_modifier.php' => true,
|
||||||
'smarty_internal_compile_private_object_block_function.php' => true,
|
'smarty_internal_compile_private_object_block_function.php' => true,
|
||||||
'smarty_internal_compile_private_object_function.php' => true,
|
'smarty_internal_compile_private_object_function.php' => true,
|
||||||
'smarty_internal_compile_private_php.php' => true,
|
|
||||||
'smarty_internal_compile_private_print_expression.php' => true,
|
'smarty_internal_compile_private_print_expression.php' => true,
|
||||||
'smarty_internal_compile_private_registered_block.php' => true,
|
'smarty_internal_compile_private_registered_block.php' => true,
|
||||||
'smarty_internal_compile_private_registered_function.php' => true,
|
'smarty_internal_compile_private_registered_function.php' => true,
|
||||||
@@ -388,7 +386,6 @@ class Smarty_Internal_TestInstall
|
|||||||
'smarty_internal_config_file_compiler.php' => true,
|
'smarty_internal_config_file_compiler.php' => true,
|
||||||
'smarty_internal_data.php' => true,
|
'smarty_internal_data.php' => true,
|
||||||
'smarty_internal_debug.php' => true,
|
'smarty_internal_debug.php' => true,
|
||||||
'smarty_internal_errorhandler.php' => true,
|
|
||||||
'smarty_internal_extension_handler.php' => true,
|
'smarty_internal_extension_handler.php' => true,
|
||||||
'smarty_internal_method_addautoloadfilters.php' => true,
|
'smarty_internal_method_addautoloadfilters.php' => true,
|
||||||
'smarty_internal_method_adddefaultmodifiers.php' => true,
|
'smarty_internal_method_adddefaultmodifiers.php' => true,
|
||||||
@@ -450,7 +447,6 @@ class Smarty_Internal_TestInstall
|
|||||||
'smarty_internal_resource_extends.php' => true,
|
'smarty_internal_resource_extends.php' => true,
|
||||||
'smarty_internal_resource_file.php' => true,
|
'smarty_internal_resource_file.php' => true,
|
||||||
'smarty_internal_resource_php.php' => true,
|
'smarty_internal_resource_php.php' => true,
|
||||||
'smarty_internal_resource_registered.php' => true,
|
|
||||||
'smarty_internal_resource_stream.php' => true,
|
'smarty_internal_resource_stream.php' => true,
|
||||||
'smarty_internal_resource_string.php' => true,
|
'smarty_internal_resource_string.php' => true,
|
||||||
'smarty_internal_runtime_cachemodify.php' => true,
|
'smarty_internal_runtime_cachemodify.php' => true,
|
||||||
|
@@ -72,9 +72,7 @@ abstract class Smarty_Resource
|
|||||||
}
|
}
|
||||||
// try registered resource
|
// try registered resource
|
||||||
if (isset($smarty->registered_resources[ $type ])) {
|
if (isset($smarty->registered_resources[ $type ])) {
|
||||||
return $smarty->_cache[ 'resource_handlers' ][ $type ] =
|
return $smarty->_cache[ 'resource_handlers' ][ $type ] = $smarty->registered_resources[ $type ];
|
||||||
$smarty->registered_resources[ $type ] instanceof Smarty_Resource ?
|
|
||||||
$smarty->registered_resources[ $type ] : new Smarty_Internal_Resource_Registered();
|
|
||||||
}
|
}
|
||||||
// try sysplugins dir
|
// try sysplugins dir
|
||||||
if (isset(self::$sysplugins[ $type ])) {
|
if (isset(self::$sysplugins[ $type ])) {
|
||||||
|
@@ -21,19 +21,6 @@
|
|||||||
*/
|
*/
|
||||||
class Smarty_Security
|
class Smarty_Security
|
||||||
{
|
{
|
||||||
/**
|
|
||||||
* This determines how Smarty handles "<?php ... ?>" tags in templates.
|
|
||||||
* possible values:
|
|
||||||
* <ul>
|
|
||||||
* <li>Smarty::PHP_PASSTHRU -> echo PHP tags as they are</li>
|
|
||||||
* <li>Smarty::PHP_QUOTE -> escape tags as entities</li>
|
|
||||||
* <li>Smarty::PHP_REMOVE -> remove php tags</li>
|
|
||||||
* <li>Smarty::PHP_ALLOW -> execute php tags</li>
|
|
||||||
* </ul>
|
|
||||||
*
|
|
||||||
* @var integer
|
|
||||||
*/
|
|
||||||
public $php_handling = Smarty::PHP_PASSTHRU;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This is the list of template directories that are considered secure.
|
* This is the list of template directories that are considered secure.
|
||||||
|
@@ -1,2 +1,2 @@
|
|||||||
#! /bin/bash
|
#! /bin/bash
|
||||||
vendor/phpunit/phpunit/phpunit tests/UnitTests
|
vendor/phpunit/phpunit/phpunit
|
||||||
|
26
phpunit.xml
26
phpunit.xml
@@ -6,7 +6,6 @@
|
|||||||
backupGlobals="false"
|
backupGlobals="false"
|
||||||
backupStaticAttributes="true"
|
backupStaticAttributes="true"
|
||||||
forceCoversAnnotation="false"
|
forceCoversAnnotation="false"
|
||||||
mapTestClassNameToCoveredClassName="false"
|
|
||||||
processIsolation="false"
|
processIsolation="false"
|
||||||
stopOnError="false"
|
stopOnError="false"
|
||||||
stopOnFailure="false"
|
stopOnFailure="false"
|
||||||
@@ -17,18 +16,15 @@
|
|||||||
timeoutForMediumTests="10"
|
timeoutForMediumTests="10"
|
||||||
timeoutForLargeTests="60"
|
timeoutForLargeTests="60"
|
||||||
verbose="false">
|
verbose="false">
|
||||||
|
<testsuites>
|
||||||
<filter>
|
<testsuite name="foo">
|
||||||
<testsuites>
|
<directory>./tests/UnitTests/</directory>
|
||||||
<testsuite name="Smarty Test Suite">
|
<exclude>./tests/UnitTests/CacheResourceTests/Memcache/CacheResourceCustomMemcacheTest.php</exclude>
|
||||||
<directory>tests/UnitTests</directory>
|
<exclude>./tests/UnitTests/CacheResourceTests/Apc/CacheResourceCustomApcTest.php</exclude>
|
||||||
</testsuite>
|
<exclude>./tests/UnitTests/CacheModify/ModifiedSince/HttpModifiedSinceTest.php</exclude>
|
||||||
</testsuites>
|
</testsuite>
|
||||||
<blacklist>
|
</testsuites>
|
||||||
<directory suffix=".php">tests</directory>
|
<filter>
|
||||||
<directory suffix=".php">tests/cache</directory>
|
|
||||||
<directory suffix=".php">tests/templates_c</directory>
|
|
||||||
</blacklist>
|
|
||||||
<whitelist processUncoveredFilesFromWhitelist="true">
|
<whitelist processUncoveredFilesFromWhitelist="true">
|
||||||
<directory suffix=".php">libs</directory>
|
<directory suffix=".php">libs</directory>
|
||||||
<directory suffix=".php">libs/plugins</directory>
|
<directory suffix=".php">libs/plugins</directory>
|
||||||
@@ -36,8 +32,4 @@
|
|||||||
<directory suffix=".php">demo/plugins</directory>
|
<directory suffix=".php">demo/plugins</directory>
|
||||||
</whitelist>
|
</whitelist>
|
||||||
</filter>
|
</filter>
|
||||||
<logging>
|
|
||||||
<log type="tap" target="tests/TestResults.tap"/>
|
|
||||||
</logging>
|
|
||||||
|
|
||||||
</phpunit>
|
</phpunit>
|
||||||
|
@@ -10,14 +10,6 @@ require_once dirname(__FILE__) . '/Config.php';
|
|||||||
require_once dirname(__FILE__) . '/../vendor/autoload.php';
|
require_once dirname(__FILE__) . '/../vendor/autoload.php';
|
||||||
require_once dirname(__FILE__) . '/../libs/bootstrap.php';
|
require_once dirname(__FILE__) . '/../libs/bootstrap.php';
|
||||||
|
|
||||||
if (!class_exists('\PHPUnit_Framework_TestCase') && class_exists('\PHPUnit\Framework\TestCase')) {
|
|
||||||
class_alias('\PHPUnit\Framework\TestCase', '\PHPUnit_Framework_TestCase');
|
|
||||||
class_alias('\PHPUnit\Framework\Error\Notice', '\PHPUnit_Framework_Error_Notice');
|
|
||||||
class_alias('\PHPUnit\Framework\Error\Error', '\PHPUnit_Framework_Error_Error');
|
|
||||||
class_alias('\PHPUnit\Framework\Error\Warning', '\PHPUnit_Framework_Error_Warning');
|
|
||||||
class_alias('\PHPUnit\Framework\Error\Warning', '\PHPUnit_Framework_Error_Deprecated');
|
|
||||||
}
|
|
||||||
|
|
||||||
require_once 'PHPUnit_Smarty.php';
|
require_once 'PHPUnit_Smarty.php';
|
||||||
if (!ini_get('date.timezone')) {
|
if (!ini_get('date.timezone')) {
|
||||||
ini_set('date.timezone', 'Europe/Berlin');
|
ini_set('date.timezone', 'Europe/Berlin');
|
||||||
|
@@ -7,12 +7,10 @@
|
|||||||
* Smarty PHPUnit Config
|
* Smarty PHPUnit Config
|
||||||
*/
|
*/
|
||||||
define('individualFolders', true);
|
define('individualFolders', true);
|
||||||
define('MemCacheEnable', false);
|
|
||||||
define('ApcCacheEnable', false);
|
|
||||||
define('MysqlCacheEnable', false);
|
define('MysqlCacheEnable', false);
|
||||||
define('PdoCacheEnable', false);
|
define('PdoCacheEnable', false);
|
||||||
define('PdoGzipCacheEnable', false);
|
define('PdoGzipCacheEnable', false);
|
||||||
define('MysqlResourceEnable', false);
|
define('MysqlResourceEnable', false);
|
||||||
define('DB_DSN', "mysql:dbname=test;host=localhost");
|
define('DB_DSN', "mysql:dbname=test;host=localhost");
|
||||||
define('DB_USER', "travis");
|
define('DB_USER', "root");
|
||||||
define('DB_PASSWD', "");
|
define('DB_PASSWD', "");
|
||||||
|
@@ -7,36 +7,16 @@
|
|||||||
/**
|
/**
|
||||||
* Smarty Test Case Fixture
|
* Smarty Test Case Fixture
|
||||||
*/
|
*/
|
||||||
class PHPUnit_Smarty extends PHPUnit_Framework_TestCase
|
class PHPUnit_Smarty extends PHPUnit\Framework\TestCase
|
||||||
{
|
{
|
||||||
/**
|
|
||||||
* Smarty object
|
|
||||||
*
|
|
||||||
* @var SmartyBC
|
|
||||||
*/
|
|
||||||
public $smartyBC = null;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* SmartyBC object
|
* Smarty object
|
||||||
*
|
*
|
||||||
* @var Smarty
|
* @var Smarty
|
||||||
*/
|
*/
|
||||||
public $smarty = null;
|
public $smarty = null;
|
||||||
|
|
||||||
/**
|
|
||||||
* Flag if test is using the Smarty object
|
|
||||||
*
|
|
||||||
* @var bool
|
|
||||||
*/
|
|
||||||
public $loadSmarty = true;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Flag if test is using the SmartyBC object
|
|
||||||
*
|
|
||||||
* @var bool
|
|
||||||
*/
|
|
||||||
public $loadSmartyBC = false;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Flag for initialization at first test
|
* Flag for initialization at first test
|
||||||
*
|
*
|
||||||
@@ -86,7 +66,7 @@ class PHPUnit_Smarty extends PHPUnit_Framework_TestCase
|
|||||||
* This method is called before the first test of this test class is run.
|
* This method is called before the first test of this test class is run.
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
public static function setUpBeforeClass()
|
public static function setUpBeforeClass(): void
|
||||||
{
|
{
|
||||||
error_reporting(E_ALL & ~E_STRICT);
|
error_reporting(E_ALL & ~E_STRICT);
|
||||||
self::$init = true;
|
self::$init = true;
|
||||||
@@ -97,7 +77,7 @@ class PHPUnit_Smarty extends PHPUnit_Framework_TestCase
|
|||||||
* This method is called after the last test of this test class is run.
|
* This method is called after the last test of this test class is run.
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
public static function tearDownAfterClass()
|
public static function tearDownAfterClass(): void
|
||||||
{
|
{
|
||||||
//self::$pdo = null;
|
//self::$pdo = null;
|
||||||
self::$testNumber = 0;
|
self::$testNumber = 0;
|
||||||
@@ -161,23 +141,15 @@ class PHPUnit_Smarty extends PHPUnit_Framework_TestCase
|
|||||||
self::$init = false;
|
self::$init = false;
|
||||||
}
|
}
|
||||||
clearstatcache();
|
clearstatcache();
|
||||||
|
|
||||||
// instance Smarty class
|
// instance Smarty class
|
||||||
if ($this->loadSmarty) {
|
$this->smarty = new Smarty;
|
||||||
$this->smarty = new Smarty;
|
if (individualFolders != 'true') {
|
||||||
if (individualFolders != 'true') {
|
$this->smarty->setCompileDir(dirname(__FILE__) . '/templates_c');
|
||||||
$this->smarty->setCompileDir(dirname(__FILE__) . '/templates_c');
|
$this->smarty->setCacheDir(dirname(__FILE__) . '/cache');
|
||||||
$this->smarty->setCacheDir(dirname(__FILE__) . '/cache');
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
// instance SmartyBC class
|
|
||||||
if ($this->loadSmartyBC) {
|
$this->getSmartyObj();
|
||||||
$this->smartyBC = new SmartyBC;
|
|
||||||
if (individualFolders != 'true') {
|
|
||||||
$this->smartyBC->setCompileDir(dirname(__FILE__) . '/templates_c');
|
|
||||||
$this->smartyBC->setCacheDir(dirname(__FILE__) . '/cache');
|
|
||||||
}
|
|
||||||
}
|
|
||||||
$smarty = $this->getSmartyObj();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -658,10 +630,10 @@ KEY `name` (`name`)
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Gat Smarty object
|
* Gat Smarty object
|
||||||
* @return null|\Smarty|\SmartyBC
|
* @return null|\Smarty
|
||||||
*/
|
*/
|
||||||
public function getSmartyObj(){
|
public function getSmartyObj(){
|
||||||
return isset($this->smarty) ? $this->smarty : (isset($this->smartyBC) ? $this->smartyBC : null);
|
return $this->smarty;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static function getSmartyPluginsDir(){
|
public static function getSmartyPluginsDir(){
|
||||||
@@ -676,7 +648,7 @@ KEY `name` (`name`)
|
|||||||
* This method is called after a test is executed.
|
* This method is called after a test is executed.
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
protected function tearDown()
|
protected function tearDown(): void
|
||||||
{
|
{
|
||||||
if (class_exists('Smarty_Internal_TemplateCompilerBase') &&
|
if (class_exists('Smarty_Internal_TemplateCompilerBase') &&
|
||||||
isset(Smarty_Internal_TemplateCompilerBase::$_tag_objects)
|
isset(Smarty_Internal_TemplateCompilerBase::$_tag_objects)
|
||||||
@@ -689,11 +661,5 @@ KEY `name` (`name`)
|
|||||||
if (isset($this->smarty)) {
|
if (isset($this->smarty)) {
|
||||||
$this->smarty = null;
|
$this->smarty = null;
|
||||||
}
|
}
|
||||||
if (isset($this->smartyBC->smarty)) {
|
|
||||||
$this->smartyBC->smarty = null;
|
|
||||||
}
|
|
||||||
if (isset($this->smartyBC)) {
|
|
||||||
$this->smartyBC = null;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user