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:
Simon Wisselink
2021-10-13 12:15:17 +02:00
committed by GitHub
parent 9d4f8309ed
commit 39b69f0142
276 changed files with 3768 additions and 6814 deletions

2
.gitattributes vendored
View File

@@ -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
View 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
View File

@@ -9,5 +9,6 @@ utilies/*.php
# Dev # Dev
phpunit* phpunit*
.phpunit.result.cache
vendor/* vendor/*
composer.lock composer.lock

View File

@@ -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

View File

@@ -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
View File

@@ -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
---- ----

View File

@@ -1,7 +1,7 @@
# Smarty 3 template engine # Smarty 3 template engine
[smarty.net](https://www.smarty.net/) [smarty.net](https://www.smarty.net/)
[![Build Status](https://travis-ci.org/smarty-php/smarty.svg?branch=master)](https://travis-ci.org/smarty-php/smarty) ![CI](https://github.com/smarty-php/smarty/workflows/CI/badge.svg)
## 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.

View File

@@ -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"
} }
} }

View File

@@ -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);

View File

@@ -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;

View File

@@ -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'));
}
} }
/** /**

View File

@@ -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;
}
} }

View File

@@ -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);
}
}

View File

@@ -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

View File

@@ -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

View File

@@ -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>

View File

@@ -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>
* *

View File

@@ -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>

View File

@@ -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>

View File

@@ -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>

View File

@@ -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>

View File

@@ -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

View File

@@ -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>

View File

@@ -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

View File

@@ -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>

View File

@@ -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>
* *

View File

@@ -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

View File

@@ -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;
} }

View File

@@ -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

View File

@@ -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>
* *

View File

@@ -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
* *

View File

@@ -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

View File

@@ -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

View File

@@ -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
* *

View File

@@ -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
* *

View File

@@ -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
* *

View File

@@ -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
* *

View File

@@ -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

View File

@@ -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;
} }

View File

@@ -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);

View File

@@ -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

View File

@@ -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
* *

View File

@@ -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

View File

@@ -14,7 +14,7 @@
* Example: {$var|strip} {$var|strip:"&nbsp;"} * Example: {$var|strip} {$var|strip:"&nbsp;"}
* 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

View File

@@ -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

View File

@@ -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

View File

@@ -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

View File

@@ -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;

View File

@@ -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;
} }

View File

@@ -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);

View File

@@ -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";
}
}
}

View File

@@ -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) {

View File

@@ -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);
}
}

View File

@@ -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
* *

View File

@@ -1,36 +1,37 @@
<?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.
@@ -38,24 +39,22 @@ class Smarty_Internal_ErrorHandler
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) { if ($this->allowUndefinedArrayKeys && preg_match(
self::$mutedDirectories[ SMARTY_DIR ] = '/^(Undefined array key|Trying to access array offset on value of type null)/',
array('file' => $smarty_dir, 'length' => strlen($smarty_dir),); $errstr
} )) {
} return; // suppresses this error
// walk the muted directories and test against $errfile }
foreach (self::$mutedDirectories as $key => &$dir) {
if (!$dir) { // pass all other errors through to the previous error handler or to the default PHP error handler
// resolve directory and length for speedy comparisons return $this->previousErrorHandler ?
$file = realpath($key); call_user_func($this->previousErrorHandler, $errno, $errstr, $errfile, $errline, $errcontext) : false;
if ($file === false) {
// 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;
}
}
} }
} }

View File

@@ -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)

View File

@@ -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

View File

@@ -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
* *

View File

@@ -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

View File

@@ -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

View File

@@ -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

View File

@@ -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

View File

@@ -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

View File

@@ -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

View File

@@ -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

View File

@@ -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

View File

@@ -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

View File

@@ -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

View File

@@ -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

View File

@@ -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

View File

@@ -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

View File

@@ -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

View File

@@ -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

View File

@@ -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

View File

@@ -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

View File

@@ -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

View File

@@ -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;
} }
} }

View File

@@ -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

View File

@@ -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

View File

@@ -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

View File

@@ -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

View File

@@ -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

View File

@@ -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

View File

@@ -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);
}
}

View File

@@ -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
*/ */

View File

@@ -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

View File

@@ -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)) {
@@ -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 '(' . $parameter[ 0 ] . ' === false )';
} else {
return $func_name . '(' . return $func_name . '(' .
str_replace("')->value", "',null,true,false)->value", $parameter[ 0 ]) . ')'; str_replace("')->value", "',null,true,false)->value", $parameter[ 0 ]) . ')';
}
} else { } else {
return $func_name . '(' . $parameter[ 0 ] . ')'; return $func_name . '(' . $parameter[ 0 ] . ')';
} }

View File

@@ -18,12 +18,6 @@
*/ */
class Smarty_Internal_Templatelexer class Smarty_Internal_Templatelexer
{ {
const TEXT = 1;
const TAG = 2;
const TAGBODY = 3;
const LITERAL = 4;
const DOUBLEQUOTEDSTRING = 5;
/** /**
* Source * Source
* *
@@ -229,10 +223,6 @@ class Smarty_Internal_Templatelexer
*/ */
private $yy_global_literal = null; private $yy_global_literal = null;
private $_yy_state = 1;
private $_yy_stack = array();
/** /**
* constructor * constructor
* *
@@ -286,7 +276,11 @@ class Smarty_Internal_Templatelexer
{ {
return $this->smarty->getAutoLiteral() && isset($this->value[ $this->compiler->getLdelLength() ]) ? return $this->smarty->getAutoLiteral() && isset($this->value[ $this->compiler->getLdelLength() ]) ?
strpos(" \n\t\r", $this->value[ $this->compiler->getLdelLength() ]) !== false : false; strpos(" \n\t\r", $this->value[ $this->compiler->getLdelLength() ]) !== false : false;
} // end function }
private $_yy_state = 1;
private $_yy_stack = array();
public function yylex() public function yylex()
{ {
@@ -296,44 +290,41 @@ class Smarty_Internal_Templatelexer
public function yypushstate($state) public function yypushstate($state)
{ {
if ($this->yyTraceFILE) { if ($this->yyTraceFILE) {
fprintf($this->yyTraceFILE, "%sState push %s\n", $this->yyTracePrompt, fprintf($this->yyTraceFILE, "%sState push %s\n", $this->yyTracePrompt, isset($this->state_name[$this->_yy_state]) ? $this->state_name[$this->_yy_state] : $this->_yy_state);
isset($this->state_name[ $this->_yy_state ]) ? $this->state_name[ $this->_yy_state ] : $this->_yy_state);
} }
array_push($this->_yy_stack, $this->_yy_state); array_push($this->_yy_stack, $this->_yy_state);
$this->_yy_state = $state; $this->_yy_state = $state;
if ($this->yyTraceFILE) { if ($this->yyTraceFILE) {
fprintf($this->yyTraceFILE, "%snew State %s\n", $this->yyTracePrompt, fprintf($this->yyTraceFILE, "%snew State %s\n", $this->yyTracePrompt, isset($this->state_name[$this->_yy_state]) ? $this->state_name[$this->_yy_state] : $this->_yy_state);
isset($this->state_name[ $this->_yy_state ]) ? $this->state_name[ $this->_yy_state ] : $this->_yy_state);
} }
} }
public function yypopstate() public function yypopstate()
{ {
if ($this->yyTraceFILE) { if ($this->yyTraceFILE) {
fprintf($this->yyTraceFILE, "%sState pop %s\n", $this->yyTracePrompt, fprintf($this->yyTraceFILE, "%sState pop %s\n", $this->yyTracePrompt, isset($this->state_name[$this->_yy_state]) ? $this->state_name[$this->_yy_state] : $this->_yy_state);
isset($this->state_name[ $this->_yy_state ]) ? $this->state_name[ $this->_yy_state ] : $this->_yy_state);
} }
$this->_yy_state = array_pop($this->_yy_stack); $this->_yy_state = array_pop($this->_yy_stack);
if ($this->yyTraceFILE) { if ($this->yyTraceFILE) {
fprintf($this->yyTraceFILE, "%snew State %s\n", $this->yyTracePrompt, fprintf($this->yyTraceFILE, "%snew State %s\n", $this->yyTracePrompt, isset($this->state_name[$this->_yy_state]) ? $this->state_name[$this->_yy_state] : $this->_yy_state);
isset($this->state_name[ $this->_yy_state ]) ? $this->state_name[ $this->_yy_state ] : $this->_yy_state);
} }
} }
public function yybegin($state) public function yybegin($state)
{ {
$this->_yy_state = $state; $this->_yy_state = $state;
if ($this->yyTraceFILE) { if ($this->yyTraceFILE) {
fprintf($this->yyTraceFILE, "%sState set %s\n", $this->yyTracePrompt, fprintf($this->yyTraceFILE, "%sState set %s\n", $this->yyTracePrompt, isset($this->state_name[$this->_yy_state]) ? $this->state_name[$this->_yy_state] : $this->_yy_state);
isset($this->state_name[ $this->_yy_state ]) ? $this->state_name[ $this->_yy_state ] : $this->_yy_state);
} }
} }
public function yylex1() public function yylex1()
{ {
if (!isset($this->yy_global_pattern1)) { if (!isset($this->yy_global_pattern1)) {
$this->yy_global_pattern1 = $this->yy_global_pattern1 = $this->replace("/\G([{][}])|\G((SMARTYldel)SMARTYal[*])|\G((SMARTYldel)SMARTYautoliteral\\s+SMARTYliteral)|\G((SMARTYldel)SMARTYalliteral\\s*SMARTYrdel)|\G((SMARTYldel)SMARTYal[\/]literal\\s*SMARTYrdel)|\G((SMARTYldel)SMARTYal)|\G([\S\s])/isS");
$this->replace("/\G([{][}])|\G((SMARTYldel)SMARTYal[*])|\G((SMARTYldel)SMARTYalphp([ ].*?)?SMARTYrdel|(SMARTYldel)SMARTYal[\/]phpSMARTYrdel)|\G((SMARTYldel)SMARTYautoliteral\\s+SMARTYliteral)|\G((SMARTYldel)SMARTYalliteral\\s*SMARTYrdel)|\G((SMARTYldel)SMARTYal[\/]literal\\s*SMARTYrdel)|\G((SMARTYldel)SMARTYal)|\G([<][?]((php\\s+|=)|\\s+)|[<][%]|[<][?]xml\\s+|[<]script\\s+language\\s*=\\s*[\"']?\\s*php\\s*[\"']?\\s*[>]|[?][>]|[%][>])|\G([\S\s])/isS");
} }
if (!isset($this->dataLength)) { if (!isset($this->dataLength)) {
$this->dataLength = strlen($this->data); $this->dataLength = strlen($this->data);
@@ -341,6 +332,7 @@ class Smarty_Internal_Templatelexer
if ($this->counter >= $this->dataLength) { if ($this->counter >= $this->dataLength) {
return false; // end of input return false; // end of input
} }
do { do {
if (preg_match($this->yy_global_pattern1,$this->data, $yymatches, 0, $this->counter)) { if (preg_match($this->yy_global_pattern1,$this->data, $yymatches, 0, $this->counter)) {
if (!isset($yymatches[ 0 ][1])) { if (!isset($yymatches[ 0 ][1])) {
@@ -374,25 +366,27 @@ class Smarty_Internal_Templatelexer
} }
// skip this token // skip this token
continue; continue;
} } } else {
} else {
throw new Exception('Unexpected input at line' . $this->line . throw new Exception('Unexpected input at line' . $this->line .
': ' . $this->data[$this->counter]); ': ' . $this->data[$this->counter]);
} }
break; break;
} while (true); } while (true);
}
} // end function
const TEXT = 1;
public function yy_r1_1() public function yy_r1_1()
{ {
$this->token = Smarty_Internal_Templateparser::TP_TEXT; $this->token = Smarty_Internal_Templateparser::TP_TEXT;
} }
public function yy_r1_2() public function yy_r1_2()
{ {
$to = $this->dataLength; $to = $this->dataLength;
preg_match("/[*]{$this->compiler->getRdelPreg()}[\n]?/", $this->data, $match, PREG_OFFSET_CAPTURE, preg_match("/[*]{$this->compiler->getRdelPreg()}[\n]?/",$this->data,$match,PREG_OFFSET_CAPTURE,$this->counter);
$this->counter);
if (isset($match[0][1])) { if (isset($match[0][1])) {
$to = $match[0][1] + strlen($match[0][0]); $to = $match[0][1] + strlen($match[0][0]);
} else { } else {
@@ -401,45 +395,34 @@ 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;
} }
public function yy_r1_4() public function yy_r1_4()
{ {
$this->compiler->getTagCompiler('private_php')->parsePhp($this);
}
public function yy_r1_8()
{
$this->token = Smarty_Internal_Templateparser::TP_TEXT; $this->token = Smarty_Internal_Templateparser::TP_TEXT;
} }
public function yy_r1_6()
public function yy_r1_10()
{ {
$this->token = Smarty_Internal_Templateparser::TP_LITERALSTART; $this->token = Smarty_Internal_Templateparser::TP_LITERALSTART;
$this->yypushstate(self::LITERAL); $this->yypushstate(self::LITERAL);
} }
public function yy_r1_8()
public function yy_r1_12()
{ {
$this->token = Smarty_Internal_Templateparser::TP_LITERALEND; $this->token = Smarty_Internal_Templateparser::TP_LITERALEND;
$this->yypushstate(self::LITERAL); $this->yypushstate(self::LITERAL);
} // end function }
public function yy_r1_10()
public function yy_r1_14()
{ {
$this->yypushstate(self::TAG); $this->yypushstate(self::TAG);
return true; return true;
} }
public function yy_r1_12()
public function yy_r1_16()
{ {
$this->compiler->getTagCompiler('private_php')->parsePhp($this);
}
public function yy_r1_19()
{
if (!isset($this->yy_global_text)) { if (!isset($this->yy_global_text)) {
$this->yy_global_text = $this->yy_global_text = $this->replace('/(SMARTYldel)SMARTYal/isS');
$this->replace('/(SMARTYldel)SMARTYal|[<][?]((php\s+|=)|\s+)|[<][%]|[<][?]xml\s+|[<]script\s+language\s*=\s*["\']?\s*php\s*["\']?\s*[>]|[?][>]|[%][>]SMARTYliteral/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);
@@ -450,11 +433,11 @@ class Smarty_Internal_Templatelexer
$this->token = Smarty_Internal_Templateparser::TP_TEXT; $this->token = Smarty_Internal_Templateparser::TP_TEXT;
} }
public function yylex2() public function yylex2()
{ {
if (!isset($this->yy_global_pattern2)) { if (!isset($this->yy_global_pattern2)) {
$this->yy_global_pattern2 = $this->yy_global_pattern2 = $this->replace("/\G((SMARTYldel)SMARTYal(if|elseif|else if|while)\\s+)|\G((SMARTYldel)SMARTYalfor\\s+)|\G((SMARTYldel)SMARTYalforeach(?![^\s]))|\G((SMARTYldel)SMARTYalsetfilter\\s+)|\G((SMARTYldel)SMARTYalmake_nocache\\s+)|\G((SMARTYldel)SMARTYal[0-9]*[a-zA-Z_]\\w*(\\s+nocache)?\\s*SMARTYrdel)|\G((SMARTYldel)SMARTYal[$]smarty\\.block\\.(child|parent)\\s*SMARTYrdel)|\G((SMARTYldel)SMARTYal[\/][0-9]*[a-zA-Z_]\\w*\\s*SMARTYrdel)|\G((SMARTYldel)SMARTYal[$][0-9]*[a-zA-Z_]\\w*(\\s+nocache)?\\s*SMARTYrdel)|\G((SMARTYldel)SMARTYal[\/])|\G((SMARTYldel)SMARTYal)/isS");
$this->replace("/\G((SMARTYldel)SMARTYal(if|elseif|else if|while)\\s+)|\G((SMARTYldel)SMARTYalfor\\s+)|\G((SMARTYldel)SMARTYalforeach(?![^\s]))|\G((SMARTYldel)SMARTYalsetfilter\\s+)|\G((SMARTYldel)SMARTYalmake_nocache\\s+)|\G((SMARTYldel)SMARTYal[0-9]*[a-zA-Z_]\\w*(\\s+nocache)?\\s*SMARTYrdel)|\G((SMARTYldel)SMARTYal[$]smarty\\.block\\.(child|parent)\\s*SMARTYrdel)|\G((SMARTYldel)SMARTYal[\/][0-9]*[a-zA-Z_]\\w*\\s*SMARTYrdel)|\G((SMARTYldel)SMARTYal[$][0-9]*[a-zA-Z_]\\w*(\\s+nocache)?\\s*SMARTYrdel)|\G((SMARTYldel)SMARTYal[\/])|\G((SMARTYldel)SMARTYal)/isS");
} }
if (!isset($this->dataLength)) { if (!isset($this->dataLength)) {
$this->dataLength = strlen($this->data); $this->dataLength = strlen($this->data);
@@ -462,6 +445,7 @@ class Smarty_Internal_Templatelexer
if ($this->counter >= $this->dataLength) { if ($this->counter >= $this->dataLength) {
return false; // end of input return false; // end of input
} }
do { do {
if (preg_match($this->yy_global_pattern2,$this->data, $yymatches, 0, $this->counter)) { if (preg_match($this->yy_global_pattern2,$this->data, $yymatches, 0, $this->counter)) {
if (!isset($yymatches[ 0 ][1])) { if (!isset($yymatches[ 0 ][1])) {
@@ -495,73 +479,76 @@ class Smarty_Internal_Templatelexer
} }
// skip this token // skip this token
continue; continue;
} } } else {
} else {
throw new Exception('Unexpected input at line' . $this->line . throw new Exception('Unexpected input at line' . $this->line .
': ' . $this->data[$this->counter]); ': ' . $this->data[$this->counter]);
} }
break; break;
} while (true); } while (true);
}
} // end function
const TAG = 2;
public function yy_r2_1() public function yy_r2_1()
{ {
$this->token = Smarty_Internal_Templateparser::TP_LDELIF; $this->token = Smarty_Internal_Templateparser::TP_LDELIF;
$this->yybegin(self::TAGBODY); $this->yybegin(self::TAGBODY);
$this->taglineno = $this->line; $this->taglineno = $this->line;
} }
public function yy_r2_4() public function yy_r2_4()
{ {
$this->token = Smarty_Internal_Templateparser::TP_LDELFOR; $this->token = Smarty_Internal_Templateparser::TP_LDELFOR;
$this->yybegin(self::TAGBODY); $this->yybegin(self::TAGBODY);
$this->taglineno = $this->line; $this->taglineno = $this->line;
} }
public function yy_r2_6() public function yy_r2_6()
{ {
$this->token = Smarty_Internal_Templateparser::TP_LDELFOREACH; $this->token = Smarty_Internal_Templateparser::TP_LDELFOREACH;
$this->yybegin(self::TAGBODY); $this->yybegin(self::TAGBODY);
$this->taglineno = $this->line; $this->taglineno = $this->line;
} }
public function yy_r2_8() public function yy_r2_8()
{ {
$this->token = Smarty_Internal_Templateparser::TP_LDELSETFILTER; $this->token = Smarty_Internal_Templateparser::TP_LDELSETFILTER;
$this->yybegin(self::TAGBODY); $this->yybegin(self::TAGBODY);
$this->taglineno = $this->line; $this->taglineno = $this->line;
} }
public function yy_r2_10() public function yy_r2_10()
{ {
$this->token = Smarty_Internal_Templateparser::TP_LDELMAKENOCACHE; $this->token = Smarty_Internal_Templateparser::TP_LDELMAKENOCACHE;
$this->yybegin(self::TAGBODY); $this->yybegin(self::TAGBODY);
$this->taglineno = $this->line; $this->taglineno = $this->line;
} }
public function yy_r2_12() public function yy_r2_12()
{ {
$this->yypopstate(); $this->yypopstate();
$this->token = Smarty_Internal_Templateparser::TP_SIMPLETAG; $this->token = Smarty_Internal_Templateparser::TP_SIMPLETAG;
$this->taglineno = $this->line; $this->taglineno = $this->line;
} }
public function yy_r2_15() public function yy_r2_15()
{ {
$this->yypopstate(); $this->yypopstate();
$this->token = Smarty_Internal_Templateparser::TP_SMARTYBLOCKCHILDPARENT; $this->token = Smarty_Internal_Templateparser::TP_SMARTYBLOCKCHILDPARENT;
$this->taglineno = $this->line; $this->taglineno = $this->line;
} }
public function yy_r2_18() public function yy_r2_18()
{ {
$this->yypopstate(); $this->yypopstate();
$this->token = Smarty_Internal_Templateparser::TP_CLOSETAG; $this->token = Smarty_Internal_Templateparser::TP_CLOSETAG;
$this->taglineno = $this->line; $this->taglineno = $this->line;
} }
public function yy_r2_20() public function yy_r2_20()
{ {
if ($this->_yy_stack[count($this->_yy_stack)-1] === self::TEXT) { if ($this->_yy_stack[count($this->_yy_stack)-1] === self::TEXT) {
$this->yypopstate(); $this->yypopstate();
$this->token = Smarty_Internal_Templateparser::TP_SIMPELOUTPUT; $this->token = Smarty_Internal_Templateparser::TP_SIMPELOUTPUT;
@@ -572,27 +559,27 @@ class Smarty_Internal_Templatelexer
$this->yybegin(self::TAGBODY); $this->yybegin(self::TAGBODY);
$this->taglineno = $this->line; $this->taglineno = $this->line;
} }
} // end function }
public function yy_r2_23() public function yy_r2_23()
{ {
$this->token = Smarty_Internal_Templateparser::TP_LDELSLASH; $this->token = Smarty_Internal_Templateparser::TP_LDELSLASH;
$this->yybegin(self::TAGBODY); $this->yybegin(self::TAGBODY);
$this->taglineno = $this->line; $this->taglineno = $this->line;
} }
public function yy_r2_25() public function yy_r2_25()
{ {
$this->token = Smarty_Internal_Templateparser::TP_LDEL; $this->token = Smarty_Internal_Templateparser::TP_LDEL;
$this->yybegin(self::TAGBODY); $this->yybegin(self::TAGBODY);
$this->taglineno = $this->line; $this->taglineno = $this->line;
} }
public function yylex3() public function yylex3()
{ {
if (!isset($this->yy_global_pattern3)) { if (!isset($this->yy_global_pattern3)) {
$this->yy_global_pattern3 = $this->yy_global_pattern3 = $this->replace("/\G(\\s*SMARTYrdel)|\G((SMARTYldel)SMARTYal)|\G([\"])|\G('[^'\\\\]*(?:\\\\.[^'\\\\]*)*')|\G([$][0-9]*[a-zA-Z_]\\w*)|\G([$])|\G(\\s+is\\s+in\\s+)|\G(\\s+as\\s+)|\G(\\s+to\\s+)|\G(\\s+step\\s+)|\G(\\s+instanceof\\s+)|\G(\\s*([!=][=]{1,2}|[<][=>]?|[>][=]?|[&|]{2})\\s*)|\G(\\s+(eq|ne|neq|gt|ge|gte|lt|le|lte|mod|and|or|xor)\\s+)|\G(\\s+is\\s+(not\\s+)?(odd|even|div)\\s+by\\s+)|\G(\\s+is\\s+(not\\s+)?(odd|even))|\G([!]\\s*|not\\s+)|\G([(](int(eger)?|bool(ean)?|float|double|real|string|binary|array|object)[)]\\s*)|\G(\\s*[(]\\s*)|\G(\\s*[)])|\G(\\[\\s*)|\G(\\s*\\])|\G(\\s*[-][>]\\s*)|\G(\\s*[=][>]\\s*)|\G(\\s*[=]\\s*)|\G(([+]|[-]){2})|\G(\\s*([+]|[-])\\s*)|\G(\\s*([*]{1,2}|[%\/^&]|[<>]{2})\\s*)|\G([@])|\G(array\\s*[(]\\s*)|\G([#])|\G(\\s+[0-9]*[a-zA-Z_][a-zA-Z0-9_\-:]*\\s*[=]\\s*)|\G(([0-9]*[a-zA-Z_]\\w*)?(\\\\[0-9]*[a-zA-Z_]\\w*)+)|\G([0-9]*[a-zA-Z_]\\w*)|\G(\\d+)|\G([`])|\G([|][@]?)|\G([.])|\G(\\s*[,]\\s*)|\G(\\s*[;]\\s*)|\G([:]{2})|\G(\\s*[:]\\s*)|\G(\\s*[?]\\s*)|\G(0[xX][0-9a-fA-F]+)|\G(\\s+)|\G([\S\s])/isS");
$this->replace("/\G(\\s*SMARTYrdel)|\G((SMARTYldel)SMARTYal)|\G([\"])|\G('[^'\\\\]*(?:\\\\.[^'\\\\]*)*')|\G([$][0-9]*[a-zA-Z_]\\w*)|\G([$])|\G(\\s+is\\s+in\\s+)|\G(\\s+as\\s+)|\G(\\s+to\\s+)|\G(\\s+step\\s+)|\G(\\s+instanceof\\s+)|\G(\\s*([!=][=]{1,2}|[<][=>]?|[>][=]?|[&|]{2})\\s*)|\G(\\s+(eq|ne|neq|gt|ge|gte|lt|le|lte|mod|and|or|xor)\\s+)|\G(\\s+is\\s+(not\\s+)?(odd|even|div)\\s+by\\s+)|\G(\\s+is\\s+(not\\s+)?(odd|even))|\G([!]\\s*|not\\s+)|\G([(](int(eger)?|bool(ean)?|float|double|real|string|binary|array|object)[)]\\s*)|\G(\\s*[(]\\s*)|\G(\\s*[)])|\G(\\[\\s*)|\G(\\s*\\])|\G(\\s*[-][>]\\s*)|\G(\\s*[=][>]\\s*)|\G(\\s*[=]\\s*)|\G(([+]|[-]){2})|\G(\\s*([+]|[-])\\s*)|\G(\\s*([*]{1,2}|[%\/^&]|[<>]{2})\\s*)|\G([@])|\G(array\\s*[(]\\s*)|\G([#])|\G(\\s+[0-9]*[a-zA-Z_][a-zA-Z0-9_\-:]*\\s*[=]\\s*)|\G(([0-9]*[a-zA-Z_]\\w*)?(\\\\[0-9]*[a-zA-Z_]\\w*)+)|\G([0-9]*[a-zA-Z_]\\w*)|\G(\\d+)|\G([`])|\G([|][@]?)|\G([.])|\G(\\s*[,]\\s*)|\G(\\s*[;]\\s*)|\G([:]{2})|\G(\\s*[:]\\s*)|\G(\\s*[?]\\s*)|\G(0[xX][0-9a-fA-F]+)|\G(\\s+)|\G([\S\s])/isS");
} }
if (!isset($this->dataLength)) { if (!isset($this->dataLength)) {
$this->dataLength = strlen($this->data); $this->dataLength = strlen($this->data);
@@ -600,6 +587,7 @@ class Smarty_Internal_Templatelexer
if ($this->counter >= $this->dataLength) { if ($this->counter >= $this->dataLength) {
return false; // end of input return false; // end of input
} }
do { do {
if (preg_match($this->yy_global_pattern3,$this->data, $yymatches, 0, $this->counter)) { if (preg_match($this->yy_global_pattern3,$this->data, $yymatches, 0, $this->counter)) {
if (!isset($yymatches[ 0 ][1])) { if (!isset($yymatches[ 0 ][1])) {
@@ -633,174 +621,176 @@ class Smarty_Internal_Templatelexer
} }
// skip this token // skip this token
continue; continue;
} } } else {
} else {
throw new Exception('Unexpected input at line' . $this->line . throw new Exception('Unexpected input at line' . $this->line .
': ' . $this->data[$this->counter]); ': ' . $this->data[$this->counter]);
} }
break; break;
} while (true); } while (true);
}
} // end function
const TAGBODY = 3;
public function yy_r3_1() public function yy_r3_1()
{ {
$this->token = Smarty_Internal_Templateparser::TP_RDEL; $this->token = Smarty_Internal_Templateparser::TP_RDEL;
$this->yypopstate(); $this->yypopstate();
} }
public function yy_r3_2() public function yy_r3_2()
{ {
$this->yypushstate(self::TAG); $this->yypushstate(self::TAG);
return true; return true;
} }
public function yy_r3_4() public function yy_r3_4()
{ {
$this->token = Smarty_Internal_Templateparser::TP_QUOTE; $this->token = Smarty_Internal_Templateparser::TP_QUOTE;
$this->yypushstate(self::DOUBLEQUOTEDSTRING); $this->yypushstate(self::DOUBLEQUOTEDSTRING);
$this->compiler->enterDoubleQuote(); $this->compiler->enterDoubleQuote();
} }
public function yy_r3_5() public function yy_r3_5()
{ {
$this->token = Smarty_Internal_Templateparser::TP_SINGLEQUOTESTRING; $this->token = Smarty_Internal_Templateparser::TP_SINGLEQUOTESTRING;
} }
public function yy_r3_6() public function yy_r3_6()
{ {
$this->token = Smarty_Internal_Templateparser::TP_DOLLARID; $this->token = Smarty_Internal_Templateparser::TP_DOLLARID;
} }
public function yy_r3_7() public function yy_r3_7()
{ {
$this->token = Smarty_Internal_Templateparser::TP_DOLLAR; $this->token = Smarty_Internal_Templateparser::TP_DOLLAR;
} }
public function yy_r3_8() public function yy_r3_8()
{ {
$this->token = Smarty_Internal_Templateparser::TP_ISIN; $this->token = Smarty_Internal_Templateparser::TP_ISIN;
} }
public function yy_r3_9() public function yy_r3_9()
{ {
$this->token = Smarty_Internal_Templateparser::TP_AS; $this->token = Smarty_Internal_Templateparser::TP_AS;
} }
public function yy_r3_10() public function yy_r3_10()
{ {
$this->token = Smarty_Internal_Templateparser::TP_TO; $this->token = Smarty_Internal_Templateparser::TP_TO;
} }
public function yy_r3_11() public function yy_r3_11()
{ {
$this->token = Smarty_Internal_Templateparser::TP_STEP; $this->token = Smarty_Internal_Templateparser::TP_STEP;
} }
public function yy_r3_12() public function yy_r3_12()
{ {
$this->token = Smarty_Internal_Templateparser::TP_INSTANCEOF; $this->token = Smarty_Internal_Templateparser::TP_INSTANCEOF;
} }
public function yy_r3_13() public function yy_r3_13()
{ {
$this->token = Smarty_Internal_Templateparser::TP_LOGOP; $this->token = Smarty_Internal_Templateparser::TP_LOGOP;
} }
public function yy_r3_15() public function yy_r3_15()
{ {
$this->token = Smarty_Internal_Templateparser::TP_SLOGOP; $this->token = Smarty_Internal_Templateparser::TP_SLOGOP;
} }
public function yy_r3_17() public function yy_r3_17()
{ {
$this->token = Smarty_Internal_Templateparser::TP_TLOGOP; $this->token = Smarty_Internal_Templateparser::TP_TLOGOP;
} }
public function yy_r3_20() public function yy_r3_20()
{ {
$this->token = Smarty_Internal_Templateparser::TP_SINGLECOND; $this->token = Smarty_Internal_Templateparser::TP_SINGLECOND;
} }
public function yy_r3_23() public function yy_r3_23()
{ {
$this->token = Smarty_Internal_Templateparser::TP_NOT; $this->token = Smarty_Internal_Templateparser::TP_NOT;
} }
public function yy_r3_24() public function yy_r3_24()
{ {
$this->token = Smarty_Internal_Templateparser::TP_TYPECAST; $this->token = Smarty_Internal_Templateparser::TP_TYPECAST;
} }
public function yy_r3_28() public function yy_r3_28()
{ {
$this->token = Smarty_Internal_Templateparser::TP_OPENP; $this->token = Smarty_Internal_Templateparser::TP_OPENP;
} }
public function yy_r3_29() public function yy_r3_29()
{ {
$this->token = Smarty_Internal_Templateparser::TP_CLOSEP; $this->token = Smarty_Internal_Templateparser::TP_CLOSEP;
} }
public function yy_r3_30() public function yy_r3_30()
{ {
$this->token = Smarty_Internal_Templateparser::TP_OPENB; $this->token = Smarty_Internal_Templateparser::TP_OPENB;
} }
public function yy_r3_31() public function yy_r3_31()
{ {
$this->token = Smarty_Internal_Templateparser::TP_CLOSEB; $this->token = Smarty_Internal_Templateparser::TP_CLOSEB;
} }
public function yy_r3_32() public function yy_r3_32()
{ {
$this->token = Smarty_Internal_Templateparser::TP_PTR; $this->token = Smarty_Internal_Templateparser::TP_PTR;
} }
public function yy_r3_33() public function yy_r3_33()
{ {
$this->token = Smarty_Internal_Templateparser::TP_APTR; $this->token = Smarty_Internal_Templateparser::TP_APTR;
} }
public function yy_r3_34() public function yy_r3_34()
{ {
$this->token = Smarty_Internal_Templateparser::TP_EQUAL; $this->token = Smarty_Internal_Templateparser::TP_EQUAL;
} }
public function yy_r3_35() public function yy_r3_35()
{ {
$this->token = Smarty_Internal_Templateparser::TP_INCDEC; $this->token = Smarty_Internal_Templateparser::TP_INCDEC;
} }
public function yy_r3_37() public function yy_r3_37()
{ {
$this->token = Smarty_Internal_Templateparser::TP_UNIMATH; $this->token = Smarty_Internal_Templateparser::TP_UNIMATH;
} }
public function yy_r3_39() public function yy_r3_39()
{ {
$this->token = Smarty_Internal_Templateparser::TP_MATH; $this->token = Smarty_Internal_Templateparser::TP_MATH;
} }
public function yy_r3_41() public function yy_r3_41()
{ {
$this->token = Smarty_Internal_Templateparser::TP_AT; $this->token = Smarty_Internal_Templateparser::TP_AT;
} }
public function yy_r3_42() public function yy_r3_42()
{ {
$this->token = Smarty_Internal_Templateparser::TP_ARRAYOPEN; $this->token = Smarty_Internal_Templateparser::TP_ARRAYOPEN;
} }
public function yy_r3_43() public function yy_r3_43()
{ {
$this->token = Smarty_Internal_Templateparser::TP_HATCH; $this->token = Smarty_Internal_Templateparser::TP_HATCH;
} }
public function yy_r3_44() public function yy_r3_44()
{ {
// resolve conflicts with shorttag and right_delimiter starting with '=' // resolve conflicts with shorttag and right_delimiter starting with '='
if (substr($this->data, $this->counter + strlen($this->value) - 1, $this->compiler->getRdelLength()) === if (substr($this->data, $this->counter + strlen($this->value) - 1, $this->compiler->getRdelLength()) === $this->smarty->getRightDelimiter()) {
$this->smarty->getRightDelimiter()) {
preg_match('/\s+/',$this->value,$match); preg_match('/\s+/',$this->value,$match);
$this->value = $match[0]; $this->value = $match[0];
$this->token = Smarty_Internal_Templateparser::TP_SPACE; $this->token = Smarty_Internal_Templateparser::TP_SPACE;
@@ -808,83 +798,84 @@ class Smarty_Internal_Templatelexer
$this->token = Smarty_Internal_Templateparser::TP_ATTR; $this->token = Smarty_Internal_Templateparser::TP_ATTR;
} }
} }
public function yy_r3_45() public function yy_r3_45()
{ {
$this->token = Smarty_Internal_Templateparser::TP_NAMESPACE; $this->token = Smarty_Internal_Templateparser::TP_NAMESPACE;
} }
public function yy_r3_48() public function yy_r3_48()
{ {
$this->token = Smarty_Internal_Templateparser::TP_ID; $this->token = Smarty_Internal_Templateparser::TP_ID;
} }
public function yy_r3_49() public function yy_r3_49()
{ {
$this->token = Smarty_Internal_Templateparser::TP_INTEGER; $this->token = Smarty_Internal_Templateparser::TP_INTEGER;
} }
public function yy_r3_50() public function yy_r3_50()
{ {
$this->token = Smarty_Internal_Templateparser::TP_BACKTICK; $this->token = Smarty_Internal_Templateparser::TP_BACKTICK;
$this->yypopstate(); $this->yypopstate();
} }
public function yy_r3_51() public function yy_r3_51()
{ {
$this->token = Smarty_Internal_Templateparser::TP_VERT; $this->token = Smarty_Internal_Templateparser::TP_VERT;
} }
public function yy_r3_52() public function yy_r3_52()
{ {
$this->token = Smarty_Internal_Templateparser::TP_DOT; $this->token = Smarty_Internal_Templateparser::TP_DOT;
} }
public function yy_r3_53() public function yy_r3_53()
{ {
$this->token = Smarty_Internal_Templateparser::TP_COMMA; $this->token = Smarty_Internal_Templateparser::TP_COMMA;
} }
public function yy_r3_54() public function yy_r3_54()
{ {
$this->token = Smarty_Internal_Templateparser::TP_SEMICOLON; $this->token = Smarty_Internal_Templateparser::TP_SEMICOLON;
} }
public function yy_r3_55() public function yy_r3_55()
{ {
$this->token = Smarty_Internal_Templateparser::TP_DOUBLECOLON; $this->token = Smarty_Internal_Templateparser::TP_DOUBLECOLON;
} }
public function yy_r3_56() public function yy_r3_56()
{ {
$this->token = Smarty_Internal_Templateparser::TP_COLON; $this->token = Smarty_Internal_Templateparser::TP_COLON;
} }
public function yy_r3_57() public function yy_r3_57()
{ {
$this->token = Smarty_Internal_Templateparser::TP_QMARK; $this->token = Smarty_Internal_Templateparser::TP_QMARK;
} }
public function yy_r3_58() public function yy_r3_58()
{ {
$this->token = Smarty_Internal_Templateparser::TP_HEX; $this->token = Smarty_Internal_Templateparser::TP_HEX;
} }
public function yy_r3_59() public function yy_r3_59()
{ {
$this->token = Smarty_Internal_Templateparser::TP_SPACE;
} // end function
$this->token = Smarty_Internal_Templateparser::TP_SPACE;
}
public function yy_r3_60() public function yy_r3_60()
{ {
$this->token = Smarty_Internal_Templateparser::TP_TEXT; $this->token = Smarty_Internal_Templateparser::TP_TEXT;
} }
public function yylex4() public function yylex4()
{ {
if (!isset($this->yy_global_pattern4)) { if (!isset($this->yy_global_pattern4)) {
$this->yy_global_pattern4 = $this->yy_global_pattern4 = $this->replace("/\G((SMARTYldel)SMARTYalliteral\\s*SMARTYrdel)|\G((SMARTYldel)SMARTYal[\/]literal\\s*SMARTYrdel)|\G([\S\s])/isS");
$this->replace("/\G((SMARTYldel)SMARTYalliteral\\s*SMARTYrdel)|\G((SMARTYldel)SMARTYal[\/]literal\\s*SMARTYrdel)|\G([\S\s])/isS");
} }
if (!isset($this->dataLength)) { if (!isset($this->dataLength)) {
$this->dataLength = strlen($this->data); $this->dataLength = strlen($this->data);
@@ -892,6 +883,7 @@ class Smarty_Internal_Templatelexer
if ($this->counter >= $this->dataLength) { if ($this->counter >= $this->dataLength) {
return false; // end of input return false; // end of input
} }
do { do {
if (preg_match($this->yy_global_pattern4,$this->data, $yymatches, 0, $this->counter)) { if (preg_match($this->yy_global_pattern4,$this->data, $yymatches, 0, $this->counter)) {
if (!isset($yymatches[ 0 ][1])) { if (!isset($yymatches[ 0 ][1])) {
@@ -925,23 +917,26 @@ class Smarty_Internal_Templatelexer
} }
// skip this token // skip this token
continue; continue;
} } } else {
} else {
throw new Exception('Unexpected input at line' . $this->line . throw new Exception('Unexpected input at line' . $this->line .
': ' . $this->data[$this->counter]); ': ' . $this->data[$this->counter]);
} }
break; break;
} while (true); } while (true);
}
} // end function
const LITERAL = 4;
public function yy_r4_1() public function yy_r4_1()
{ {
$this->literal_cnt++; $this->literal_cnt++;
$this->token = Smarty_Internal_Templateparser::TP_LITERAL; $this->token = Smarty_Internal_Templateparser::TP_LITERAL;
} }
public function yy_r4_3() public function yy_r4_3()
{ {
if ($this->literal_cnt) { if ($this->literal_cnt) {
$this->literal_cnt--; $this->literal_cnt--;
$this->token = Smarty_Internal_Templateparser::TP_LITERAL; $this->token = Smarty_Internal_Templateparser::TP_LITERAL;
@@ -950,9 +945,9 @@ class Smarty_Internal_Templatelexer
$this->yypopstate(); $this->yypopstate();
} }
} }
public function yy_r4_5() public function yy_r4_5()
{ {
if (!isset($this->yy_global_literal)) { if (!isset($this->yy_global_literal)) {
$this->yy_global_literal = $this->replace('/(SMARTYldel)SMARTYal[\/]?literalSMARTYrdel/isS'); $this->yy_global_literal = $this->replace('/(SMARTYldel)SMARTYal[\/]?literalSMARTYrdel/isS');
} }
@@ -965,13 +960,13 @@ class Smarty_Internal_Templatelexer
} }
$this->value = substr($this->data,$this->counter,$to-$this->counter); $this->value = substr($this->data,$this->counter,$to-$this->counter);
$this->token = Smarty_Internal_Templateparser::TP_LITERAL; $this->token = Smarty_Internal_Templateparser::TP_LITERAL;
} // end function }
public function yylex5() public function yylex5()
{ {
if (!isset($this->yy_global_pattern5)) { if (!isset($this->yy_global_pattern5)) {
$this->yy_global_pattern5 = $this->yy_global_pattern5 = $this->replace("/\G((SMARTYldel)SMARTYautoliteral\\s+SMARTYliteral)|\G((SMARTYldel)SMARTYalliteral\\s*SMARTYrdel)|\G((SMARTYldel)SMARTYal[\/]literal\\s*SMARTYrdel)|\G((SMARTYldel)SMARTYal[\/])|\G((SMARTYldel)SMARTYal[0-9]*[a-zA-Z_]\\w*)|\G((SMARTYldel)SMARTYal)|\G([\"])|\G([`][$])|\G([$][0-9]*[a-zA-Z_]\\w*)|\G([$])|\G(([^\"\\\\]*?)((?:\\\\.[^\"\\\\]*?)*?)(?=((SMARTYldel)SMARTYal|\\$|`\\$|\"SMARTYliteral)))|\G([\S\s])/isS");
$this->replace("/\G((SMARTYldel)SMARTYautoliteral\\s+SMARTYliteral)|\G((SMARTYldel)SMARTYalliteral\\s*SMARTYrdel)|\G((SMARTYldel)SMARTYal[\/]literal\\s*SMARTYrdel)|\G((SMARTYldel)SMARTYal[\/])|\G((SMARTYldel)SMARTYal[0-9]*[a-zA-Z_]\\w*)|\G((SMARTYldel)SMARTYal)|\G([\"])|\G([`][$])|\G([$][0-9]*[a-zA-Z_]\\w*)|\G([$])|\G(([^\"\\\\]*?)((?:\\\\.[^\"\\\\]*?)*?)(?=((SMARTYldel)SMARTYal|\\$|`\\$|\"SMARTYliteral)))|\G([\S\s])/isS");
} }
if (!isset($this->dataLength)) { if (!isset($this->dataLength)) {
$this->dataLength = strlen($this->data); $this->dataLength = strlen($this->data);
@@ -979,6 +974,7 @@ class Smarty_Internal_Templatelexer
if ($this->counter >= $this->dataLength) { if ($this->counter >= $this->dataLength) {
return false; // end of input return false; // end of input
} }
do { do {
if (preg_match($this->yy_global_pattern5,$this->data, $yymatches, 0, $this->counter)) { if (preg_match($this->yy_global_pattern5,$this->data, $yymatches, 0, $this->counter)) {
if (!isset($yymatches[ 0 ][1])) { if (!isset($yymatches[ 0 ][1])) {
@@ -1012,84 +1008,88 @@ class Smarty_Internal_Templatelexer
} }
// skip this token // skip this token
continue; continue;
} } } else {
} else {
throw new Exception('Unexpected input at line' . $this->line . throw new Exception('Unexpected input at line' . $this->line .
': ' . $this->data[$this->counter]); ': ' . $this->data[$this->counter]);
} }
break; break;
} while (true); } while (true);
}
} // end function
const DOUBLEQUOTEDSTRING = 5;
public function yy_r5_1() public function yy_r5_1()
{ {
$this->token = Smarty_Internal_Templateparser::TP_TEXT; $this->token = Smarty_Internal_Templateparser::TP_TEXT;
} }
public function yy_r5_3() public function yy_r5_3()
{ {
$this->token = Smarty_Internal_Templateparser::TP_TEXT; $this->token = Smarty_Internal_Templateparser::TP_TEXT;
} }
public function yy_r5_5() public function yy_r5_5()
{ {
$this->token = Smarty_Internal_Templateparser::TP_TEXT; $this->token = Smarty_Internal_Templateparser::TP_TEXT;
} }
public function yy_r5_7() public function yy_r5_7()
{ {
$this->yypushstate(self::TAG); $this->yypushstate(self::TAG);
return true; return true;
} }
public function yy_r5_9() public function yy_r5_9()
{ {
$this->yypushstate(self::TAG); $this->yypushstate(self::TAG);
return true; return true;
} }
public function yy_r5_11() public function yy_r5_11()
{ {
$this->token = Smarty_Internal_Templateparser::TP_LDEL; $this->token = Smarty_Internal_Templateparser::TP_LDEL;
$this->taglineno = $this->line; $this->taglineno = $this->line;
$this->yypushstate(self::TAGBODY); $this->yypushstate(self::TAGBODY);
} }
public function yy_r5_13() public function yy_r5_13()
{ {
$this->token = Smarty_Internal_Templateparser::TP_QUOTE; $this->token = Smarty_Internal_Templateparser::TP_QUOTE;
$this->yypopstate(); $this->yypopstate();
} }
public function yy_r5_14() public function yy_r5_14()
{ {
$this->token = Smarty_Internal_Templateparser::TP_BACKTICK; $this->token = Smarty_Internal_Templateparser::TP_BACKTICK;
$this->value = substr($this->value,0,-1); $this->value = substr($this->value,0,-1);
$this->yypushstate(self::TAGBODY); $this->yypushstate(self::TAGBODY);
$this->taglineno = $this->line; $this->taglineno = $this->line;
} }
public function yy_r5_15() public function yy_r5_15()
{ {
$this->token = Smarty_Internal_Templateparser::TP_DOLLARID; $this->token = Smarty_Internal_Templateparser::TP_DOLLARID;
} }
public function yy_r5_16() public function yy_r5_16()
{ {
$this->token = Smarty_Internal_Templateparser::TP_TEXT; $this->token = Smarty_Internal_Templateparser::TP_TEXT;
} }
public function yy_r5_17() public function yy_r5_17()
{ {
$this->token = Smarty_Internal_Templateparser::TP_TEXT; $this->token = Smarty_Internal_Templateparser::TP_TEXT;
} }
public function yy_r5_22() public function yy_r5_22()
{ {
$to = $this->dataLength; $to = $this->dataLength;
$this->value = substr($this->data,$this->counter,$to-$this->counter); $this->value = substr($this->data,$this->counter,$to-$this->counter);
$this->token = Smarty_Internal_Templateparser::TP_TEXT; $this->token = Smarty_Internal_Templateparser::TP_TEXT;
} }
} }

File diff suppressed because it is too large Load Diff

View File

@@ -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,

View File

@@ -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 ])) {

View File

@@ -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.

View File

@@ -1,2 +1,2 @@
#! /bin/bash #! /bin/bash
vendor/phpunit/phpunit/phpunit tests/UnitTests vendor/phpunit/phpunit/phpunit

View File

@@ -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">
<filter>
<testsuites> <testsuites>
<testsuite name="Smarty Test Suite"> <testsuite name="foo">
<directory>tests/UnitTests</directory> <directory>./tests/UnitTests/</directory>
<exclude>./tests/UnitTests/CacheResourceTests/Memcache/CacheResourceCustomMemcacheTest.php</exclude>
<exclude>./tests/UnitTests/CacheResourceTests/Apc/CacheResourceCustomApcTest.php</exclude>
<exclude>./tests/UnitTests/CacheModify/ModifiedSince/HttpModifiedSinceTest.php</exclude>
</testsuite> </testsuite>
</testsuites> </testsuites>
<blacklist> <filter>
<directory suffix=".php">tests</directory>
<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>

View File

@@ -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');

View File

@@ -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', "");

View File

@@ -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 $this->getSmartyObj();
if ($this->loadSmartyBC) {
$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;
}
} }
} }

View File

@@ -15,7 +15,7 @@ class PathNormalizationTest extends PHPUnit_Smarty
/* /*
* Setup test fixture * Setup test fixture
*/ */
public function setUp() public function setUp(): void
{ {
$this->setUpSmarty(dirname(__FILE__)); $this->setUpSmarty(dirname(__FILE__));
} }

View File

@@ -15,7 +15,7 @@ class PluginNormalizationTest extends PHPUnit_Smarty
/* /*
* Setup test fixture * Setup test fixture
*/ */
public function setUp() public function setUp(): void
{ {
$this->setUpSmarty(dirname(__FILE__)); $this->setUpSmarty(dirname(__FILE__));
} }

View File

@@ -15,7 +15,7 @@ class TemplateNormalizationTest extends PHPUnit_Smarty
/* /*
* Setup test fixture * Setup test fixture
*/ */
public function setUp() public function setUp(): void
{ {
$this->setUpSmarty(dirname(__FILE__)); $this->setUpSmarty(dirname(__FILE__));
} }

Some files were not shown because too many files have changed in this diff Show More