mirror of
https://github.com/smarty-php/smarty.git
synced 2025-09-25 20:00:54 +02:00
Merge branch 'master' into 420upd
This commit is contained in:
3
.gitattributes
vendored
3
.gitattributes
vendored
@@ -7,11 +7,10 @@
|
||||
|
||||
# exclude from git export
|
||||
/tests export-ignore
|
||||
/demo export-ignore
|
||||
/docs export-ignore
|
||||
/utilities export-ignore
|
||||
/docker-compose.yml export-ignore
|
||||
/.github export-ignore
|
||||
/run_tests_for_all_php_versions.sh export-ignore
|
||||
/.gitattributes export-ignore
|
||||
/.gitignore export-ignore
|
||||
/make-release.sh export-ignore
|
||||
|
12
.github/workflows/ci.yml
vendored
12
.github/workflows/ci.yml
vendored
@@ -1,8 +1,10 @@
|
||||
# https://help.github.com/en/categories/automating-your-workflow-with-github-actions
|
||||
|
||||
on:
|
||||
- pull_request
|
||||
- push
|
||||
pull_request:
|
||||
push:
|
||||
branches:
|
||||
- 'master'
|
||||
|
||||
name: CI
|
||||
|
||||
@@ -69,9 +71,5 @@ jobs:
|
||||
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
|
||||
run: ./run-tests.sh
|
||||
|
26
CHANGELOG.md
26
CHANGELOG.md
@@ -6,6 +6,32 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
||||
|
||||
## [Unreleased]
|
||||
|
||||
### Changed
|
||||
- Include docs and demo in the releases [#799](https://github.com/smarty-php/smarty/issues/799)
|
||||
- Using PHP functions as modifiers now triggers a deprecation notice because we will drop support for this in the next major release [#813](https://github.com/smarty-php/smarty/issues/813)
|
||||
- Dropped remaining references to removed PHP-support in Smarty 4 from docs, lexer and security class. [#816](https://github.com/smarty-php/smarty/issues/816)
|
||||
|
||||
### Fixed
|
||||
- Output buffer is now cleaned for internal PHP errors as well, not just for Exceptions [#514](https://github.com/smarty-php/smarty/issues/514)
|
||||
- Fixed recursion and out of memory errors when caching in complicated template set-ups using inheritance and includes [#801](https://github.com/smarty-php/smarty/pull/801)
|
||||
- Fixed PHP8.1 deprecation errors in strip_tags
|
||||
- Fix Variable Usage in Exception message when unable to load subtemplate [#808](https://github.com/smarty-php/smarty/pull/808)
|
||||
- Fixed PHP8.1 deprecation notices for strftime [#672](https://github.com/smarty-php/smarty/issues/672)
|
||||
- Fixed PHP8.1 deprecation errors passing null to parameter in trim [#807](https://github.com/smarty-php/smarty/pull/807)
|
||||
- Adapt Smarty upper/lower functions to be codesafe (e.g. for Turkish locale) [#586](https://github.com/smarty-php/smarty/pull/586)
|
||||
- Bug fix for underscore and limited length in template name in custom resources [#581](https://github.com/smarty-php/smarty/pull/581)
|
||||
|
||||
## [4.2.1] - 2022-09-14
|
||||
|
||||
### Security
|
||||
- Applied appropriate javascript and html escaping in mailto plugin to counter injection attacks [#454](https://github.com/smarty-php/smarty/issues/454)
|
||||
|
||||
### Fixed
|
||||
- Fixed PHP8.1 deprecation notices in modifiers (upper, explode, number_format and replace) [#755](https://github.com/smarty-php/smarty/pull/755) and [#788](https://github.com/smarty-php/smarty/pull/788)
|
||||
- Fixed PHP8.1 deprecation notices in capitalize modifier [#789](https://github.com/smarty-php/smarty/issues/789)
|
||||
- Fixed use of `rand()` without a parameter in math function [#794](https://github.com/smarty-php/smarty/issues/794)
|
||||
- Fixed unselected year/month/day not working in html_select_date [#395](https://github.com/smarty-php/smarty/issues/395)
|
||||
|
||||
## [4.2.0] - 2022-08-01
|
||||
|
||||
### Fixed
|
||||
|
@@ -2,7 +2,7 @@
|
||||
|
||||
## Supported Versions
|
||||
|
||||
Smarty currently supports the latest minor version of Smarty 3 and Smarty 4. (Smarty 4 has not been released yet.)
|
||||
Smarty currently supports the latest minor version of Smarty 3 and Smarty 4.
|
||||
|
||||
| Version | Supported |
|
||||
| ------- | ------------------ |
|
||||
|
@@ -3,10 +3,11 @@ services:
|
||||
base:
|
||||
build:
|
||||
context: .
|
||||
dockerfile: ./utilities/testrunners/php71/Dockerfile
|
||||
volumes:
|
||||
- .:/app
|
||||
working_dir: /app
|
||||
entrypoint: sh ./utilities/testrunners/run-test.sh
|
||||
entrypoint: sh ./run-tests.sh
|
||||
php71:
|
||||
extends:
|
||||
service: base
|
||||
|
@@ -188,67 +188,6 @@ See also [`{html_select_date}`](#language.function.html.select.date),
|
||||
[`date_format`](#language.modifier.date.format) and
|
||||
[`$smarty.now`](#language.variables.smarty.now),
|
||||
|
||||
WAP/WML {#tips.wap}
|
||||
=======
|
||||
|
||||
WAP/WML templates require a php [Content-Type
|
||||
header](&url.php-manual;header) to be passed along with the template.
|
||||
The easist way to do this would be to write a custom function that
|
||||
prints the header. If you are using [caching](#caching), that won\'t
|
||||
work so we\'ll do it using the [`{insert}`](#language.function.insert)
|
||||
tag; remember `{insert}` tags are not cached! Be sure that there is
|
||||
nothing output to the browser before the template, or else the header
|
||||
may fail.
|
||||
|
||||
|
||||
<?php
|
||||
|
||||
// be sure apache is configure for the .wml extensions!
|
||||
// put this function somewhere in your application, or in Smarty.addons.php
|
||||
function insert_header($params)
|
||||
{
|
||||
// this function expects $content argument
|
||||
if (empty($params['content'])) {
|
||||
return;
|
||||
}
|
||||
header($params['content']);
|
||||
return;
|
||||
}
|
||||
|
||||
?>
|
||||
|
||||
|
||||
|
||||
your Smarty template *must* begin with the insert tag :
|
||||
|
||||
|
||||
{insert name=header content="Content-Type: text/vnd.wap.wml"}
|
||||
|
||||
<?xml version="1.0"?>
|
||||
<!DOCTYPE wml PUBLIC "-//WAPFORUM//DTD WML 1.1//EN" "http://www.wapforum.org/DTD/wml_1.1.xml">
|
||||
|
||||
<!-- begin new wml deck -->
|
||||
<wml>
|
||||
<!-- begin first card -->
|
||||
<card>
|
||||
<do type="accept">
|
||||
<go href="#two"/>
|
||||
</do>
|
||||
<p>
|
||||
Welcome to WAP with Smarty!
|
||||
Press OK to continue...
|
||||
</p>
|
||||
</card>
|
||||
<!-- begin second card -->
|
||||
<card id="two">
|
||||
<p>
|
||||
Pretty easy isn't it?
|
||||
</p>
|
||||
</card>
|
||||
</wml>
|
||||
|
||||
|
||||
|
||||
Componentized Templates {#tips.componentized.templates}
|
||||
=======================
|
||||
|
||||
@@ -259,7 +198,7 @@ Smarty object, [`assign()`](#api.assign) the variables and
|
||||
[`display()`](#api.display) the template. So lets say for example we
|
||||
have a stock ticker on our template. We would collect the stock data in
|
||||
our application, then assign these variables in the template and display
|
||||
it. Now wouldn\'t it be nice if you could add this stock ticker to any
|
||||
it. Now wouldn't it be nice if you could add this stock ticker to any
|
||||
application by merely including the template, and not worry about
|
||||
fetching the data up front?
|
||||
|
||||
@@ -301,9 +240,7 @@ assigning it to a template variable.
|
||||
|
||||
|
||||
|
||||
See also [`{include_php}`](#language.function.include.php),
|
||||
[`{include}`](#language.function.include) and
|
||||
[`{php}`](#language.function.php).
|
||||
See also: [`{include}`](#language.function.include).
|
||||
|
||||
Obfuscating E-mail Addresses {#tips.obfuscating.email}
|
||||
============================
|
||||
|
@@ -3,7 +3,7 @@ Attributes {#language.syntax.attributes}
|
||||
|
||||
Most of the [functions](#language.syntax.functions) take attributes that
|
||||
specify or modify their behavior. Attributes to Smarty functions are
|
||||
much like HTML attributes. Static values don\'t have to be enclosed in
|
||||
much like HTML attributes. Static values don't have to be enclosed in
|
||||
quotes, but it is required for literal strings. Variables with or
|
||||
without modifiers may also be used, and should not be in quotes. You can
|
||||
even use PHP function results, plugin results and complex expressions.
|
||||
|
@@ -16,7 +16,6 @@ Built-in Functions {#language.builtin.functions}
|
||||
- [{function}](./language-builtin-functions/language-function-function.md)
|
||||
- [{if},{elseif},{else}](./language-builtin-functions/language-function-if.md)
|
||||
- [{include}](./language-builtin-functions/language-function-include.md)
|
||||
- [{include_php}](./language-builtin-functions/language-function-include.php)
|
||||
- [{insert}](./language-builtin-functions/language-function-insert.md)
|
||||
- [{ldelim},{rdelim}](./language-builtin-functions/language-function-ldelim.md)
|
||||
- [{literal}](./language-builtin-functions/language-function-literal.md)
|
||||
|
@@ -135,7 +135,6 @@ The following functions can also *optionally* assign template variables.
|
||||
|
||||
[`{capture}`](#language.function.capture),
|
||||
[`{include}`](#language.function.include),
|
||||
[`{include_php}`](#language.function.include.php),
|
||||
[`{insert}`](#language.function.insert),
|
||||
[`{counter}`](#language.function.counter),
|
||||
[`{cycle}`](#language.function.cycle),
|
||||
|
@@ -1,74 +0,0 @@
|
||||
{include\_php} {#language.function.include.php}
|
||||
==============
|
||||
|
||||
> **Note**
|
||||
>
|
||||
> `{include_php}` is deprecated from Smarty, use registered plugins to
|
||||
> properly insulate presentation from the application code. As of Smarty
|
||||
> 3.1 the `{include_php}` tags are only available from [SmartyBC](#bc).
|
||||
|
||||
Attribute Name Type Required Default Description
|
||||
---------------- --------- ---------- --------- ----------------------------------------------------------------------------------
|
||||
file string Yes *n/a* The name of the php file to include as absolute path
|
||||
once boolean No *TRUE* whether or not to include the php file more than once if included multiple times
|
||||
assign string No *n/a* The name of the variable that the output of include\_php will be assigned to
|
||||
|
||||
**Option Flags:**
|
||||
|
||||
Name Description
|
||||
--------- ----------------------------------------
|
||||
nocache Disables caching of inluded PHP script
|
||||
|
||||
`{include_php}` tags are used to include a php script in your template.
|
||||
The path of the attribute `file` can be either absolute, or relative to
|
||||
[`$trusted_dir`](#variable.trusted.dir). If security is enabled, then
|
||||
the script must be located in the `$trusted_dir` path of the securty
|
||||
policy. See the [Security](#advanced.features.security) section for
|
||||
details.
|
||||
|
||||
By default, php files are only included once even if called multiple
|
||||
times in the template. You can specify that it should be included every
|
||||
time with the `once` attribute. Setting once to FALSE will include the
|
||||
php script each time it is included in the template.
|
||||
|
||||
You can optionally pass the `assign` attribute, which will specify a
|
||||
template variable name that the output of `{include_php}` will be
|
||||
assigned to instead of displayed.
|
||||
|
||||
The smarty object is available as `$_smarty_tpl->smarty` within the PHP
|
||||
script that you include.
|
||||
|
||||
The `load_nav.php` file:
|
||||
|
||||
|
||||
<?php
|
||||
|
||||
// load in variables from a mysql db and assign them to the template
|
||||
require_once('database.class.php');
|
||||
$db = new Db();
|
||||
$db->query('select url, name from navigation order by name');
|
||||
$this->assign('navigation', $db->getRows());
|
||||
|
||||
?>
|
||||
|
||||
|
||||
|
||||
where the template is:
|
||||
|
||||
|
||||
{* absolute path, or relative to $trusted_dir *}
|
||||
{include_php file='/path/to/load_nav.php'}
|
||||
{include_php '/path/to/load_nav.php'} {* short-hand *}
|
||||
|
||||
{foreach item='nav' from=$navigation}
|
||||
<a href="{$nav.url}">{$nav.name}</a><br />
|
||||
{/foreach}
|
||||
|
||||
|
||||
|
||||
See also [`{include}`](#language.function.include),
|
||||
[`$trusted_dir`](#variable.trusted.dir),
|
||||
[`{php}`](#language.function.php),
|
||||
[`{capture}`](#language.function.capture), [template
|
||||
resources](#resources) and [componentized
|
||||
templates](#tips.componentized.templates)
|
@@ -188,7 +188,5 @@ current template.
|
||||
|
||||
|
||||
|
||||
See also [`{include_php}`](#language.function.include.php),
|
||||
[`{insert}`](#language.function.insert),
|
||||
[`{php}`](#language.function.php), [template resources](#resources) and
|
||||
See also [`{insert}`](#language.function.insert), [template resources](#resources) and
|
||||
[componentized templates](#tips.componentized.templates).
|
||||
|
@@ -8,22 +8,6 @@ security compromises through the template language.
|
||||
The settings of the security policy are defined by properties of an
|
||||
instance of the Smarty\_Security class. These are the possible settings:
|
||||
|
||||
- `$php_handling` determines how Smarty to handle PHP code embedded in
|
||||
templates. Possible values are:
|
||||
|
||||
- Smarty::PHP\_PASSTHRU -\> echo PHP tags as they are
|
||||
|
||||
- Smarty::PHP\_QUOTE -\> escape tags as entities
|
||||
|
||||
- Smarty::PHP\_REMOVE -\> remove php tags
|
||||
|
||||
- Smarty::PHP\_ALLOW -\> execute php tags
|
||||
|
||||
The default value is Smarty::PHP\_PASSTHRU.
|
||||
|
||||
If security is enabled the [`$php_handling`](#variable.php.handling)
|
||||
setting of the Smarty object is not checked for security.
|
||||
|
||||
- `$secure_dir` is an array of template directories that are
|
||||
considered secure. [`$template_dir`](#variable.template.dir)
|
||||
concidered secure implicitly. The default is an empty array.
|
||||
@@ -31,7 +15,7 @@ instance of the Smarty\_Security class. These are the possible settings:
|
||||
- `$trusted_dir` is an array of all directories that are considered
|
||||
trusted. Trusted directories are where you keep php scripts that are
|
||||
executed directly from the templates with
|
||||
[`{include_php}`](#language.function.include.php). The default is an
|
||||
[`{insert}`](#language.function.insert.php). The default is an
|
||||
empty array.
|
||||
|
||||
- `$trusted_uri` is an array of regular expressions matching URIs that
|
||||
@@ -110,12 +94,8 @@ instance of the Smarty\_Security class. These are the possible settings:
|
||||
super globals can be accessed by the template. The default is
|
||||
\"true\".
|
||||
|
||||
- `$allow_php_tag` is a boolean flag which controls if {php} and
|
||||
{include\_php} tags can be used by the template. The default is
|
||||
\"false\".
|
||||
|
||||
If security is enabled, no private methods, functions or properties of
|
||||
static classes or assigned objects can be accessed (beginningwith
|
||||
static classes or assigned objects can be accessed (beginning with
|
||||
\'\_\') by the template.
|
||||
|
||||
To customize the security policy settings you can extend the
|
||||
@@ -128,8 +108,6 @@ Smarty\_Security class or create an instance of it.
|
||||
class My_Security_Policy extends Smarty_Security {
|
||||
// disable all PHP functions
|
||||
public $php_functions = null;
|
||||
// remove PHP tags
|
||||
public $php_handling = Smarty::PHP_REMOVE;
|
||||
// allow everthing as modifier
|
||||
public $php_modifiers = array();
|
||||
}
|
||||
@@ -145,8 +123,6 @@ Smarty\_Security class or create an instance of it.
|
||||
$my_security_policy = new Smarty_Security($smarty);
|
||||
// disable all PHP functions
|
||||
$my_security_policy->php_functions = null;
|
||||
// remove PHP tags
|
||||
$my_security_policy->php_handling = Smarty::PHP_REMOVE;
|
||||
// allow everthing as modifier
|
||||
$my_security_policy->php_modifiers = array();
|
||||
// enable security
|
||||
|
@@ -39,7 +39,6 @@ them directly, or use the corresponding setter/getter methods.
|
||||
- [$left_delimiter](./api-variables/variable-left-delimiter.md)
|
||||
- [$locking_timeout](./api-variables/variable-locking-timeout.md)
|
||||
- [$merge_compiled_includes](./api-variables/variable-merge-compiled-includes.md)
|
||||
- [$php_handling](./api-variables/variable-php-handling.md)
|
||||
- [$plugins_dir](./api-variables/variable-plugins-dir.md)
|
||||
- [$right_delimiter](./api-variables/variable-right-delimiter.md)
|
||||
- [$smarty_debug_id](./api-variables/variable-smarty-debug-id.md)
|
||||
|
@@ -1,21 +0,0 @@
|
||||
\$php\_handling {#variable.php.handling}
|
||||
===============
|
||||
|
||||
This tells Smarty how to handle PHP code embedded in the templates.
|
||||
There are four possible settings, the default being
|
||||
`Smarty::PHP_PASSTHRU`. Note that this does NOT affect php code within
|
||||
[`{php}{/php}`](#language.function.php) tags in the template.
|
||||
|
||||
- `Smarty::PHP_PASSTHRU` - Smarty echos tags as-is.
|
||||
|
||||
- `Smarty::PHP_QUOTE` - Smarty quotes the tags as html entities.
|
||||
|
||||
- `Smarty::PHP_REMOVE` - Smarty removes the tags from the templates.
|
||||
|
||||
- `Smarty::PHP_ALLOW` - Smarty will execute the tags as PHP code.
|
||||
|
||||
> **Note**
|
||||
>
|
||||
> Embedding PHP code into templates is highly discouraged. Use [custom
|
||||
> functions](#plugins.functions) or [modifiers](#plugins.modifiers)
|
||||
> instead.
|
@@ -5,4 +5,4 @@
|
||||
array of all directories that are considered trusted. Trusted
|
||||
directories are where you keep php scripts that are executed directly
|
||||
from the templates with
|
||||
[`{include_php}`](#language.function.include.php).
|
||||
[`{insert}`](#language.function.insert.php).
|
||||
|
@@ -23,5 +23,4 @@ to determine the appropriate value automatically. If defined, the path
|
||||
|
||||
|
||||
|
||||
See also [`$smarty.const`](../designers/language-variables/language-variables-smarty.md) and
|
||||
[`$php_handling constants`](./api-variables/variable-php-handling.md)
|
||||
See also [`$smarty.const`](../designers/language-variables/language-variables-smarty.md).
|
||||
|
@@ -161,7 +161,6 @@ class Smarty_Internal_Templatelexer
|
||||
'COMMENT' => 'comment',
|
||||
'AS' => 'as',
|
||||
'TO' => 'to',
|
||||
'PHP' => '"<?php", "<%", "{php}" tag',
|
||||
'LOGOP' => '"<", "==" ... logical operator',
|
||||
'TLOGOP' => '"lt", "eq" ... logical operator; "is div by" ... if condition',
|
||||
'SCOND' => '"is even" ... if condition',
|
||||
|
@@ -5,6 +5,11 @@
|
||||
* @package Smarty
|
||||
*/
|
||||
|
||||
|
||||
if (!defined('SMARTY_HELPER_FUNCTIONS_LOADED')) {
|
||||
include __DIR__ . '/functions.php';
|
||||
}
|
||||
|
||||
/**
|
||||
* Smarty Autoloader
|
||||
*
|
||||
@@ -48,7 +53,7 @@ class Smarty_Autoloader
|
||||
*/
|
||||
public static function register($prepend = false)
|
||||
{
|
||||
self::$SMARTY_DIR = defined('SMARTY_DIR') ? SMARTY_DIR : dirname(__FILE__) . DIRECTORY_SEPARATOR;
|
||||
self::$SMARTY_DIR = defined('SMARTY_DIR') ? SMARTY_DIR : __DIR__ . DIRECTORY_SEPARATOR;
|
||||
self::$SMARTY_SYSPLUGINS_DIR = defined('SMARTY_SYSPLUGINS_DIR') ? SMARTY_SYSPLUGINS_DIR :
|
||||
self::$SMARTY_DIR . 'sysplugins' . DIRECTORY_SEPARATOR;
|
||||
spl_autoload_register(array(__CLASS__, 'autoload'), true, $prepend);
|
||||
@@ -64,7 +69,7 @@ class Smarty_Autoloader
|
||||
if ($class[ 0 ] !== 'S' || strpos($class, 'Smarty') !== 0) {
|
||||
return;
|
||||
}
|
||||
$_class = strtolower($class);
|
||||
$_class = smarty_strtolower_ascii($class);
|
||||
if (isset(self::$rootClasses[ $_class ])) {
|
||||
$file = self::$SMARTY_DIR . self::$rootClasses[ $_class ];
|
||||
if (is_file($file)) {
|
||||
|
@@ -36,7 +36,7 @@ if (!defined('SMARTY_DIR')) {
|
||||
/**
|
||||
*
|
||||
*/
|
||||
define('SMARTY_DIR', dirname(__FILE__) . DIRECTORY_SEPARATOR);
|
||||
define('SMARTY_DIR', __DIR__ . DIRECTORY_SEPARATOR);
|
||||
}
|
||||
/**
|
||||
* set SMARTY_SYSPLUGINS_DIR to absolute path to Smarty internal plugins.
|
||||
@@ -60,12 +60,21 @@ if (!defined('SMARTY_MBSTRING')) {
|
||||
*/
|
||||
define('SMARTY_MBSTRING', function_exists('mb_get_info'));
|
||||
}
|
||||
|
||||
/**
|
||||
* Load helper functions
|
||||
*/
|
||||
if (!defined('SMARTY_HELPER_FUNCTIONS_LOADED')) {
|
||||
include __DIR__ . '/functions.php';
|
||||
}
|
||||
|
||||
/**
|
||||
* Load Smarty_Autoloader
|
||||
*/
|
||||
if (!class_exists('Smarty_Autoloader')) {
|
||||
include dirname(__FILE__) . '/bootstrap.php';
|
||||
include __DIR__ . '/bootstrap.php';
|
||||
}
|
||||
|
||||
/**
|
||||
* Load always needed external class files
|
||||
*/
|
||||
@@ -98,7 +107,7 @@ class Smarty extends Smarty_Internal_TemplateBase
|
||||
/**
|
||||
* smarty version
|
||||
*/
|
||||
const SMARTY_VERSION = '4.2.0';
|
||||
const SMARTY_VERSION = '4.2.1';
|
||||
/**
|
||||
* define variable scopes
|
||||
*/
|
||||
|
@@ -11,6 +11,6 @@
|
||||
* Load and register Smarty Autoloader
|
||||
*/
|
||||
if (!class_exists('Smarty_Autoloader')) {
|
||||
include dirname(__FILE__) . '/Autoloader.php';
|
||||
include __DIR__ . '/Autoloader.php';
|
||||
}
|
||||
Smarty_Autoloader::register(true);
|
||||
|
51
libs/functions.php
Normal file
51
libs/functions.php
Normal file
@@ -0,0 +1,51 @@
|
||||
<?php
|
||||
/**
|
||||
* This file is part of the Smarty package.
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
/**
|
||||
* Registers some helper/polyfill functions.
|
||||
*/
|
||||
|
||||
const SMARTY_HELPER_FUNCTIONS_LOADED = true;
|
||||
|
||||
/**
|
||||
* Converts the first characters in $string to uppercase (A-Z) if it is an ASCII lowercase character (a-z).
|
||||
*
|
||||
* May not be required when running PHP8.2+: https://wiki.php.net/rfc/strtolower-ascii
|
||||
*
|
||||
* @param $string
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
function smarty_ucfirst_ascii($string): string {
|
||||
return smarty_strtoupper_ascii(substr($string, 0, 1)) . substr($string, 1);
|
||||
}
|
||||
|
||||
/**
|
||||
* Converts all uppercase ASCII characters (A-Z) in $string to lowercase (a-z).
|
||||
*
|
||||
* May not be required when running PHP8.2+: https://wiki.php.net/rfc/strtolower-ascii
|
||||
*
|
||||
* @param $string
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
function smarty_strtolower_ascii($string): string {
|
||||
return strtr($string, 'ABCDEFGHIJKLMNOPQRSTUVWXYZ', 'abcdefghijklmnopqrstuvwxyz');
|
||||
}
|
||||
|
||||
/**
|
||||
* Converts all lowercase ASCII characters (a-z) in $string to uppercase (A-Z).
|
||||
*
|
||||
* May not be required when running PHP8.2+: https://wiki.php.net/rfc/strtolower-ascii
|
||||
*
|
||||
* @param $string
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
function smarty_strtoupper_ascii($string): string {
|
||||
return strtr($string, 'abcdefghijklmnopqrstuvwxyz', 'ABCDEFGHIJKLMNOPQRSTUVWXYZ');
|
||||
}
|
@@ -101,6 +101,7 @@ function smarty_function_html_select_date($params, Smarty_Internal_Template $tem
|
||||
$field_separator = "\n";
|
||||
$option_separator = "\n";
|
||||
$time = null;
|
||||
|
||||
// $all_empty = null;
|
||||
// $day_empty = null;
|
||||
// $month_empty = null;
|
||||
@@ -113,17 +114,7 @@ function smarty_function_html_select_date($params, Smarty_Internal_Template $tem
|
||||
foreach ($params as $_key => $_value) {
|
||||
switch ($_key) {
|
||||
case 'time':
|
||||
if (!is_array($_value) && $_value !== null) {
|
||||
$template->_checkPlugins(
|
||||
array(
|
||||
array(
|
||||
'function' => 'smarty_make_timestamp',
|
||||
'file' => SMARTY_PLUGINS_DIR . 'shared.make_timestamp.php'
|
||||
)
|
||||
)
|
||||
);
|
||||
$time = smarty_make_timestamp($_value);
|
||||
}
|
||||
$$_key = $_value; // we'll handle conversion below
|
||||
break;
|
||||
case 'month_names':
|
||||
if (is_array($_value) && count($_value) === 12) {
|
||||
@@ -178,41 +169,57 @@ function smarty_function_html_select_date($params, Smarty_Internal_Template $tem
|
||||
}
|
||||
// Note: date() is faster than strftime()
|
||||
// Note: explode(date()) is faster than date() date() date()
|
||||
if (isset($params[ 'time' ]) && is_array($params[ 'time' ])) {
|
||||
if (isset($params[ 'time' ][ $prefix . 'Year' ])) {
|
||||
|
||||
if (isset($time) && is_array($time)) {
|
||||
if (isset($time[$prefix . 'Year'])) {
|
||||
// $_REQUEST[$field_array] given
|
||||
foreach (array(
|
||||
foreach ([
|
||||
'Y' => 'Year',
|
||||
'm' => 'Month',
|
||||
'd' => 'Day'
|
||||
) as $_elementKey => $_elementName) {
|
||||
] as $_elementKey => $_elementName) {
|
||||
$_variableName = '_' . strtolower($_elementName);
|
||||
$$_variableName = $params[ 'time' ][ $prefix . $_elementName ] ?? date($_elementKey);
|
||||
}
|
||||
} elseif (isset($params[ 'time' ][ $field_array ][ $prefix . 'Year' ])) {
|
||||
} elseif (isset($time[$field_array][$prefix . 'Year'])) {
|
||||
// $_REQUEST given
|
||||
foreach (array(
|
||||
foreach ([
|
||||
'Y' => 'Year',
|
||||
'm' => 'Month',
|
||||
'd' => 'Day'
|
||||
) as $_elementKey => $_elementName) {
|
||||
] as $_elementKey => $_elementName) {
|
||||
$_variableName = '_' . strtolower($_elementName);
|
||||
$$_variableName = isset($params[ 'time' ][ $field_array ][ $prefix . $_elementName ]) ?
|
||||
$params[ 'time' ][ $field_array ][ $prefix . $_elementName ] : date($_elementKey);
|
||||
$$_variableName = isset($time[$field_array][$prefix . $_elementName]) ?
|
||||
$time[$field_array][$prefix . $_elementName] : date($_elementKey);
|
||||
}
|
||||
} else {
|
||||
// no date found, use NOW
|
||||
list($_year, $_month, $_day) = $time = explode('-', date('Y-m-d'));
|
||||
[$_year, $_month, $_day] = explode('-', date('Y-m-d'));
|
||||
}
|
||||
} elseif (isset($time) && preg_match("/(\d*)-(\d*)-(\d*)/", $time, $matches)) {
|
||||
$_year = $_month = $_day = null;
|
||||
if ($matches[1] > '') $_year = (int) $matches[1];
|
||||
if ($matches[2] > '') $_month = (int) $matches[2];
|
||||
if ($matches[3] > '') $_day = (int) $matches[3];
|
||||
} elseif ($time === null) {
|
||||
if (array_key_exists('time', $params)) {
|
||||
$_year = $_month = $_day = $time = null;
|
||||
$_year = $_month = $_day = null;
|
||||
} else {
|
||||
list($_year, $_month, $_day) = $time = explode('-', date('Y-m-d'));
|
||||
[$_year, $_month, $_day] = explode('-', date('Y-m-d'));
|
||||
}
|
||||
} else {
|
||||
list($_year, $_month, $_day) = $time = explode('-', date('Y-m-d', $time));
|
||||
$template->_checkPlugins(
|
||||
array(
|
||||
array(
|
||||
'function' => 'smarty_make_timestamp',
|
||||
'file' => SMARTY_PLUGINS_DIR . 'shared.make_timestamp.php'
|
||||
)
|
||||
)
|
||||
);
|
||||
$time = smarty_make_timestamp($time);
|
||||
[$_year, $_month, $_day] = explode('-', date('Y-m-d', $time));
|
||||
}
|
||||
|
||||
// make syntax "+N" or "-N" work with $start_year and $end_year
|
||||
// Note preg_match('!^(\+|\-)\s*(\d+)$!', $end_year, $match) is slower than trim+substr
|
||||
foreach (array(
|
||||
|
@@ -48,8 +48,13 @@
|
||||
*/
|
||||
function smarty_function_mailto($params)
|
||||
{
|
||||
static $_allowed_encoding =
|
||||
array('javascript' => true, 'javascript_charcode' => true, 'hex' => true, 'none' => true);
|
||||
static $_allowed_encoding = [
|
||||
'javascript' => true,
|
||||
'javascript_charcode' => true,
|
||||
'hex' => true,
|
||||
'none' => true
|
||||
];
|
||||
|
||||
$extra = '';
|
||||
if (empty($params[ 'address' ])) {
|
||||
trigger_error("mailto: missing 'address' parameter", E_USER_WARNING);
|
||||
@@ -57,19 +62,19 @@ function smarty_function_mailto($params)
|
||||
} else {
|
||||
$address = $params[ 'address' ];
|
||||
}
|
||||
|
||||
$text = $address;
|
||||
|
||||
// netscape and mozilla do not decode %40 (@) in BCC field (bug?)
|
||||
// so, don't encode it.
|
||||
$search = array('%40', '%2C');
|
||||
$replace = array('@', ',');
|
||||
$mail_parms = array();
|
||||
$mail_parms = [];
|
||||
foreach ($params as $var => $value) {
|
||||
switch ($var) {
|
||||
case 'cc':
|
||||
case 'bcc':
|
||||
case 'followupto':
|
||||
if (!empty($value)) {
|
||||
$mail_parms[] = $var . '=' . str_replace($search, $replace, rawurlencode($value));
|
||||
$mail_parms[] = $var . '=' . str_replace(['%40', '%2C'], ['@', ','], rawurlencode($value));
|
||||
}
|
||||
break;
|
||||
case 'subject':
|
||||
@@ -83,6 +88,7 @@ function smarty_function_mailto($params)
|
||||
default:
|
||||
}
|
||||
}
|
||||
|
||||
if ($mail_parms) {
|
||||
$address .= '?' . join('&', $mail_parms);
|
||||
}
|
||||
@@ -94,15 +100,17 @@ function smarty_function_mailto($params)
|
||||
);
|
||||
return;
|
||||
}
|
||||
|
||||
$string = '<a href="mailto:' . htmlspecialchars($address, ENT_QUOTES | ENT_SUBSTITUTE | ENT_HTML401, Smarty::$_CHARSET) .
|
||||
'" ' . $extra . '>' . htmlspecialchars($text, ENT_QUOTES | ENT_SUBSTITUTE | ENT_HTML401, Smarty::$_CHARSET) . '</a>';
|
||||
|
||||
if ($encode === 'javascript') {
|
||||
$string = '<a href="mailto:' . $address . '" ' . $extra . '>' . $text . '</a>';
|
||||
$js_encode = '';
|
||||
for ($x = 0, $_length = strlen($string); $x < $_length; $x++) {
|
||||
$js_encode .= '%' . bin2hex($string[ $x ]);
|
||||
}
|
||||
return '<script type="text/javascript">document.write(unescape(\'' . $js_encode . '\'))</script>';
|
||||
} elseif ($encode === 'javascript_charcode') {
|
||||
$string = '<a href="mailto:' . $address . '" ' . $extra . '>' . $text . '</a>';
|
||||
for ($x = 0, $_length = strlen($string); $x < $_length; $x++) {
|
||||
$ord[] = ord($string[ $x ]);
|
||||
}
|
||||
@@ -129,6 +137,6 @@ function smarty_function_mailto($params)
|
||||
return '<a href="' . $mailto . $address_encode . '" ' . $extra . '>' . $text_encode . '</a>';
|
||||
} else {
|
||||
// no encoding
|
||||
return '<a href="mailto:' . $address . '" ' . $extra . '>' . $text . '</a>';
|
||||
return $string;
|
||||
}
|
||||
}
|
||||
|
@@ -70,7 +70,7 @@ function smarty_function_math($params, $template)
|
||||
$number = '(?:\d+(?:[,.]\d+)?|pi|π)'; // What is a number
|
||||
$functionsOrVars = '((?:0x[a-fA-F0-9]+)|([a-zA-Z_\x7f-\xff][a-zA-Z0-9_\x7f-\xff]*))';
|
||||
$operators = '[,+\/*\^%-]'; // Allowed math operators
|
||||
$regexp = '/^(('.$number.'|'.$functionsOrVars.'|('.$functionsOrVars.'\s*\((?1)+\)|\((?1)+\)))(?:'.$operators.'(?1))?)+$/';
|
||||
$regexp = '/^(('.$number.'|'.$functionsOrVars.'|('.$functionsOrVars.'\s*\((?1)*\)|\((?1)*\)))(?:'.$operators.'(?1))?)+$/';
|
||||
|
||||
if (!preg_match($regexp, $equation)) {
|
||||
trigger_error("math: illegal characters", E_USER_WARNING);
|
||||
|
@@ -22,6 +22,8 @@
|
||||
*/
|
||||
function smarty_modifier_capitalize($string, $uc_digits = false, $lc_rest = false)
|
||||
{
|
||||
$string = (string) $string;
|
||||
|
||||
if (Smarty::$_MBSTRING) {
|
||||
if ($lc_rest) {
|
||||
// uppercase (including hyphenated words)
|
||||
|
36
libs/plugins/modifier.count.php
Normal file
36
libs/plugins/modifier.count.php
Normal file
@@ -0,0 +1,36 @@
|
||||
<?php
|
||||
/**
|
||||
* Smarty plugin
|
||||
*
|
||||
* @package Smarty
|
||||
* @subpackage PluginsModifier
|
||||
*/
|
||||
/**
|
||||
* Smarty count modifier plugin
|
||||
* Type: modifier
|
||||
* Name: count
|
||||
* Purpose: counts all elements in an array or in a Countable object
|
||||
* Input:
|
||||
* - Countable|array: array or object to count
|
||||
* - mode: int defaults to 0 for normal count mode, if set to 1 counts recursive
|
||||
*
|
||||
* @param mixed $arrayOrObject input array/object
|
||||
* @param int $mode count mode
|
||||
*
|
||||
* @return int
|
||||
*/
|
||||
function smarty_modifier_count($arrayOrObject, $mode = 0)
|
||||
{
|
||||
/*
|
||||
* @see https://www.php.net/count
|
||||
* > Prior to PHP 8.0.0, if the parameter was neither an array nor an object that implements the Countable interface,
|
||||
* > 1 would be returned, unless value was null, in which case 0 would be returned.
|
||||
*/
|
||||
|
||||
if ($arrayOrObject instanceof Countable || is_array($arrayOrObject)) {
|
||||
return count($arrayOrObject, (int) $mode);
|
||||
} elseif ($arrayOrObject === null) {
|
||||
return 0;
|
||||
}
|
||||
return 1;
|
||||
}
|
@@ -79,6 +79,7 @@ function smarty_modifier_date_format($string, $format = null, $default_date = ''
|
||||
}
|
||||
$format = str_replace($_win_from, $_win_to, $format);
|
||||
}
|
||||
// @ to suppress deprecation errors when running in PHP8.1 or higher.
|
||||
return @strftime($format, $timestamp);
|
||||
} else {
|
||||
return date($format, $timestamp);
|
||||
|
25
libs/plugins/modifier.explode.php
Normal file
25
libs/plugins/modifier.explode.php
Normal file
@@ -0,0 +1,25 @@
|
||||
<?php
|
||||
/**
|
||||
* Smarty plugin
|
||||
*
|
||||
* @package Smarty
|
||||
* @subpackage PluginsModifier
|
||||
*/
|
||||
|
||||
/**
|
||||
* Smarty explode modifier plugin
|
||||
* Type: modifier
|
||||
* Name: explode
|
||||
* Purpose: split a string by a string
|
||||
*
|
||||
* @param string $separator
|
||||
* @param string $string
|
||||
* @param int|null $limit
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
function smarty_modifier_explode($separator, $string, ?int $limit = null)
|
||||
{
|
||||
// provide $string default to prevent deprecation errors in PHP >=8.1
|
||||
return explode($separator, $string ?? '', $limit ?? PHP_INT_MAX);
|
||||
}
|
26
libs/plugins/modifier.number_format.php
Normal file
26
libs/plugins/modifier.number_format.php
Normal file
@@ -0,0 +1,26 @@
|
||||
<?php
|
||||
/**
|
||||
* Smarty plugin
|
||||
*
|
||||
* @package Smarty
|
||||
* @subpackage PluginsModifier
|
||||
*/
|
||||
|
||||
/**
|
||||
* Smarty number_format modifier plugin
|
||||
* Type: modifier
|
||||
* Name: number_format
|
||||
* Purpose: Format a number with grouped thousands
|
||||
*
|
||||
* @param float|null $num
|
||||
* @param int $decimals
|
||||
* @param string|null $decimal_separator
|
||||
* @param string|null $thousands_separator
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
function smarty_modifier_number_format(?float $num, int $decimals = 0, ?string $decimal_separator = ".", ?string $thousands_separator = ",")
|
||||
{
|
||||
// provide $num default to prevent deprecation errors in PHP >=8.1
|
||||
return number_format($num ?? 0.0, $decimals, $decimal_separator, $thousands_separator);
|
||||
}
|
23
libs/plugins/modifiercompiler.nl2br.php
Normal file
23
libs/plugins/modifiercompiler.nl2br.php
Normal file
@@ -0,0 +1,23 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* Smarty plugin
|
||||
*
|
||||
* @package Smarty
|
||||
* @subpackage PluginsModifierCompiler
|
||||
*/
|
||||
/**
|
||||
* Smarty nl2br modifier plugin
|
||||
* Type: modifier
|
||||
* Name: nl2br
|
||||
* Purpose: insert HTML line breaks before all newlines in a string
|
||||
*
|
||||
* @link https://www.smarty.net/docs/en/language.modifier.nl2br.tpl nl2br (Smarty online manual)
|
||||
*
|
||||
* @param array $params parameters
|
||||
*
|
||||
* @return string with compiled code
|
||||
*/
|
||||
function smarty_modifiercompiler_nl2br($params) {
|
||||
return 'nl2br((string) ' . $params[0] . ', (bool) ' . ($params[1] ?? true) . ')';
|
||||
}
|
23
libs/plugins/modifiercompiler.round.php
Normal file
23
libs/plugins/modifiercompiler.round.php
Normal file
@@ -0,0 +1,23 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* Smarty plugin
|
||||
*
|
||||
* @package Smarty
|
||||
* @subpackage PluginsModifierCompiler
|
||||
*/
|
||||
/**
|
||||
* Smarty round modifier plugin
|
||||
* Type: modifier
|
||||
* Name: round
|
||||
* Purpose: Returns the rounded value of num to specified precision (number of digits after the decimal point)
|
||||
*
|
||||
* @link https://www.smarty.net/docs/en/language.modifier.round.tpl round (Smarty online manual)
|
||||
*
|
||||
* @param array $params parameters
|
||||
*
|
||||
* @return string with compiled code
|
||||
*/
|
||||
function smarty_modifiercompiler_round($params) {
|
||||
return 'round((float) ' . $params[0] . ', (int) ' . ($params[1] ?? 0) . ', (int) ' . ($params[2] ?? PHP_ROUND_HALF_UP) . ')';
|
||||
}
|
23
libs/plugins/modifiercompiler.str_repeat.php
Normal file
23
libs/plugins/modifiercompiler.str_repeat.php
Normal file
@@ -0,0 +1,23 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* Smarty plugin
|
||||
*
|
||||
* @package Smarty
|
||||
* @subpackage PluginsModifierCompiler
|
||||
*/
|
||||
/**
|
||||
* Smarty str_repeat modifier plugin
|
||||
* Type: modifier
|
||||
* Name: str_repeat
|
||||
* Purpose: returns string repeated times times
|
||||
*
|
||||
* @link https://www.smarty.net/docs/en/language.modifier.str_repeat.tpl str_repeat (Smarty online manual)
|
||||
*
|
||||
* @param array $params parameters
|
||||
*
|
||||
* @return string with compiled code
|
||||
*/
|
||||
function smarty_modifiercompiler_str_repeat($params) {
|
||||
return 'str_repeat((string) ' . $params[0] . ', (int) ' . $params[1] . ')';
|
||||
}
|
@@ -21,8 +21,8 @@
|
||||
function smarty_modifiercompiler_strip_tags($params)
|
||||
{
|
||||
if (!isset($params[ 1 ]) || $params[ 1 ] === true || trim($params[ 1 ], '"') === 'true') {
|
||||
return "preg_replace('!<[^>]*?>!', ' ', {$params[0]})";
|
||||
return "preg_replace('!<[^>]*?>!', ' ', {$params[0]} ?: '')";
|
||||
} else {
|
||||
return 'strip_tags(' . $params[ 0 ] . ')';
|
||||
return 'strip_tags((string) ' . $params[ 0 ] . ')';
|
||||
}
|
||||
}
|
||||
|
23
libs/plugins/modifiercompiler.strlen.php
Normal file
23
libs/plugins/modifiercompiler.strlen.php
Normal file
@@ -0,0 +1,23 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* Smarty plugin
|
||||
*
|
||||
* @package Smarty
|
||||
* @subpackage PluginsModifierCompiler
|
||||
*/
|
||||
/**
|
||||
* Smarty strlen modifier plugin
|
||||
* Type: modifier
|
||||
* Name: strlen
|
||||
* Purpose: return the length of the given string
|
||||
*
|
||||
* @link https://www.smarty.net/docs/en/language.modifier.strlen.tpl strlen (Smarty online manual)
|
||||
*
|
||||
* @param array $params parameters
|
||||
*
|
||||
* @return string with compiled code
|
||||
*/
|
||||
function smarty_modifiercompiler_strlen($params) {
|
||||
return 'strlen((string) ' . $params[0] . ')';
|
||||
}
|
@@ -22,8 +22,8 @@
|
||||
function smarty_modifiercompiler_upper($params)
|
||||
{
|
||||
if (Smarty::$_MBSTRING) {
|
||||
return 'mb_strtoupper(' . $params[ 0 ] . ', \'' . addslashes(Smarty::$_CHARSET) . '\')';
|
||||
return 'mb_strtoupper(' . $params[ 0 ] . ' ?? \'\', \'' . addslashes(Smarty::$_CHARSET) . '\')';
|
||||
}
|
||||
// no MBString fallback
|
||||
return 'strtoupper(' . $params[ 0 ] . ')';
|
||||
return 'strtoupper(' . $params[ 0 ] . ' ?? \'\')';
|
||||
}
|
||||
|
@@ -62,7 +62,7 @@ if (!function_exists('smarty_mb_str_replace')) {
|
||||
$replace = mb_convert_encoding($replace, $current_charset, Smarty::$_CHARSET);
|
||||
}
|
||||
|
||||
$parts = mb_split(preg_quote($search), $subject) ?: array();
|
||||
$parts = mb_split(preg_quote($search), $subject ?? "") ?: array();
|
||||
|
||||
// If original regex encoding was not unicode...
|
||||
if(!$reg_is_unicode) {
|
||||
|
@@ -205,11 +205,11 @@ abstract class Smarty_CacheResource
|
||||
}
|
||||
// try sysplugins dir
|
||||
if (isset(self::$sysplugins[ $type ])) {
|
||||
$cache_resource_class = 'Smarty_Internal_CacheResource_' . ucfirst($type);
|
||||
$cache_resource_class = 'Smarty_Internal_CacheResource_' . smarty_ucfirst_ascii($type);
|
||||
return $smarty->_cache[ 'cacheresource_handlers' ][ $type ] = new $cache_resource_class();
|
||||
}
|
||||
// try plugins dir
|
||||
$cache_resource_class = 'Smarty_CacheResource_' . ucfirst($type);
|
||||
$cache_resource_class = 'Smarty_CacheResource_' . smarty_ucfirst_ascii($type);
|
||||
if ($smarty->loadPlugin($cache_resource_class)) {
|
||||
return $smarty->_cache[ 'cacheresource_handlers' ][ $type ] = new $cache_resource_class();
|
||||
}
|
||||
|
@@ -244,7 +244,7 @@ abstract class Smarty_CacheResource_KeyValueStore extends Smarty_CacheResource
|
||||
*/
|
||||
protected function sanitize($string)
|
||||
{
|
||||
$string = trim($string, '|');
|
||||
$string = trim((string)$string, '|');
|
||||
if (!$string) {
|
||||
return '';
|
||||
}
|
||||
@@ -428,7 +428,7 @@ abstract class Smarty_CacheResource_KeyValueStore extends Smarty_CacheResource
|
||||
$t[] = 'IVK#COMPILE' . $_compile;
|
||||
}
|
||||
$_name .= '#';
|
||||
$cid = trim($cache_id, '|');
|
||||
$cid = trim((string)$cache_id, '|');
|
||||
if (!$cid) {
|
||||
return $t;
|
||||
}
|
||||
|
@@ -143,7 +143,7 @@ class Smarty_Internal_Compile_Private_ForeachSection extends Smarty_Internal_Com
|
||||
foreach ($this->resultOffsets as $key => $offset) {
|
||||
foreach ($match[ $offset ] as $m) {
|
||||
if (!empty($m)) {
|
||||
$this->matchResults[ $key ][ strtolower($m) ] = true;
|
||||
$this->matchResults[ $key ][ smarty_strtolower_ascii($m) ] = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -213,12 +213,12 @@ class Smarty_Internal_Compile_Private_ForeachSection extends Smarty_Internal_Com
|
||||
*/
|
||||
public function compileSpecialVariable($args, Smarty_Internal_TemplateCompilerBase $compiler, $parameter)
|
||||
{
|
||||
$tag = strtolower(trim($parameter[ 0 ], '"\''));
|
||||
$tag = smarty_strtolower_ascii(trim($parameter[ 0 ], '"\''));
|
||||
$name = isset($parameter[ 1 ]) ? $compiler->getId($parameter[ 1 ]) : false;
|
||||
if (!$name) {
|
||||
$compiler->trigger_template_error("missing or illegal \$smarty.{$tag} name attribute", null, true);
|
||||
}
|
||||
$property = isset($parameter[ 2 ]) ? strtolower($compiler->getId($parameter[ 2 ])) : false;
|
||||
$property = isset($parameter[ 2 ]) ? smarty_strtolower_ascii($compiler->getId($parameter[ 2 ])) : false;
|
||||
if (!$property || !in_array($property, $this->nameProperties)) {
|
||||
$compiler->trigger_template_error("missing or illegal \$smarty.{$tag} property attribute", null, true);
|
||||
}
|
||||
|
@@ -109,6 +109,9 @@ class Smarty_Internal_Compile_Private_Modifier extends Smarty_Internal_CompileBa
|
||||
if (!is_object($compiler->smarty->security_policy)
|
||||
|| $compiler->smarty->security_policy->isTrustedPhpModifier($modifier, $compiler)
|
||||
) {
|
||||
trigger_error('Using php-function "' . $modifier . '" as a modifier is deprecated and will be ' .
|
||||
'removed in a future release. Use Smarty::registerPlugin to explicitly register ' .
|
||||
'a custom modifier.', E_USER_DEPRECATED);
|
||||
$output = "{$modifier}({$params})";
|
||||
}
|
||||
$compiler->known_modifier_type[ $modifier ] = $type;
|
||||
|
@@ -29,7 +29,7 @@ class Smarty_Internal_Compile_Private_Special_Variable extends Smarty_Internal_C
|
||||
public function compile($args, Smarty_Internal_TemplateCompilerBase $compiler, $parameter)
|
||||
{
|
||||
$_index = preg_split("/\]\[/", substr($parameter, 1, strlen($parameter) - 2));
|
||||
$variable = strtolower($compiler->getId($_index[ 0 ]));
|
||||
$variable = smarty_strtolower_ascii($compiler->getId($_index[ 0 ]));
|
||||
if ($variable === false) {
|
||||
$compiler->trigger_template_error("special \$Smarty variable name index can not be variable", null, true);
|
||||
}
|
||||
@@ -40,7 +40,7 @@ class Smarty_Internal_Compile_Private_Special_Variable extends Smarty_Internal_C
|
||||
case 'foreach':
|
||||
case 'section':
|
||||
if (!isset(Smarty_Internal_TemplateCompilerBase::$_tag_objects[ $variable ])) {
|
||||
$class = 'Smarty_Internal_Compile_' . ucfirst($variable);
|
||||
$class = 'Smarty_Internal_Compile_' . smarty_ucfirst_ascii($variable);
|
||||
Smarty_Internal_TemplateCompilerBase::$_tag_objects[ $variable ] = new $class;
|
||||
}
|
||||
return Smarty_Internal_TemplateCompilerBase::$_tag_objects[ $variable ]->compileSpecialVariable(
|
||||
@@ -76,7 +76,7 @@ class Smarty_Internal_Compile_Private_Special_Variable extends Smarty_Internal_C
|
||||
$compiler->trigger_template_error("(secure mode) super globals not permitted");
|
||||
break;
|
||||
}
|
||||
$compiled_ref = '$_' . strtoupper($variable);
|
||||
$compiled_ref = '$_' . smarty_strtoupper_ascii($variable);
|
||||
break;
|
||||
case 'template':
|
||||
return 'basename($_smarty_tpl->source->filepath)';
|
||||
|
@@ -212,7 +212,7 @@ class Smarty_Internal_Debug extends Smarty_Internal_Data
|
||||
// copy the working dirs from application
|
||||
$debObj->setCompileDir($smarty->getCompileDir());
|
||||
// init properties by hand as user may have edited the original Smarty class
|
||||
$debObj->setPluginsDir(is_dir(dirname(__FILE__) . '/../plugins') ? dirname(__FILE__) .
|
||||
$debObj->setPluginsDir(is_dir(__DIR__ . '/../plugins') ? __DIR__ .
|
||||
'/../plugins' : $smarty->getPluginsDir());
|
||||
$debObj->force_compile = false;
|
||||
$debObj->compile_check = Smarty::COMPILECHECK_ON;
|
||||
|
@@ -88,9 +88,8 @@ class Smarty_Internal_Extension_Handler
|
||||
$objType = $data->_objType;
|
||||
$propertyType = false;
|
||||
if (!isset($this->resolvedProperties[ $match[ 0 ] ][ $objType ])) {
|
||||
$property = isset($this->resolvedProperties[ 'property' ][ $basename ]) ?
|
||||
$this->resolvedProperties[ 'property' ][ $basename ] :
|
||||
$property = $this->resolvedProperties[ 'property' ][ $basename ] = strtolower(
|
||||
$property = $this->resolvedProperties['property'][$basename] ??
|
||||
$this->resolvedProperties['property'][$basename] = smarty_strtolower_ascii(
|
||||
join(
|
||||
'_',
|
||||
preg_split(
|
||||
@@ -145,7 +144,7 @@ class Smarty_Internal_Extension_Handler
|
||||
public function upperCase($name)
|
||||
{
|
||||
$_name = explode('_', $name);
|
||||
$_name = array_map('ucfirst', $_name);
|
||||
$_name = array_map('smarty_ucfirst_ascii', $_name);
|
||||
return implode('_', $_name);
|
||||
}
|
||||
|
||||
|
@@ -40,7 +40,7 @@ class Smarty_Internal_Method_LoadPlugin
|
||||
throw new SmartyException("plugin {$plugin_name} is not a valid name format");
|
||||
}
|
||||
if (!empty($match[ 2 ])) {
|
||||
$file = SMARTY_SYSPLUGINS_DIR . strtolower($plugin_name) . '.php';
|
||||
$file = SMARTY_SYSPLUGINS_DIR . smarty_strtolower_ascii($plugin_name) . '.php';
|
||||
if (isset($this->plugin_files[ $file ])) {
|
||||
if ($this->plugin_files[ $file ] !== false) {
|
||||
return $this->plugin_files[ $file ];
|
||||
@@ -60,7 +60,7 @@ class Smarty_Internal_Method_LoadPlugin
|
||||
}
|
||||
// plugin filename is expected to be: [type].[name].php
|
||||
$_plugin_filename = "{$match[1]}.{$match[4]}.php";
|
||||
$_lower_filename = strtolower($_plugin_filename);
|
||||
$_lower_filename = smarty_strtolower_ascii($_plugin_filename);
|
||||
if (isset($this->plugin_files)) {
|
||||
if (isset($this->plugin_files[ 'plugins_dir' ][ $_lower_filename ])) {
|
||||
if (!$smarty->use_include_path || $this->plugin_files[ 'plugins_dir' ][ $_lower_filename ] !== false) {
|
||||
|
@@ -32,7 +32,7 @@ class Smarty_Internal_Method_MustCompile
|
||||
{
|
||||
if (!$_template->source->exists) {
|
||||
if ($_template->_isSubTpl()) {
|
||||
$parent_resource = " in '$_template->parent->template_resource}'";
|
||||
$parent_resource = " in '{$_template->parent->template_resource}'";
|
||||
} else {
|
||||
$parent_resource = '';
|
||||
}
|
||||
|
@@ -358,7 +358,7 @@ class Smarty_Internal_Template extends Smarty_Internal_TemplateBase
|
||||
}
|
||||
if ($tpl->caching === 9999) {
|
||||
if (!isset($tpl->compiled)) {
|
||||
$this->loadCompiled(true);
|
||||
$tpl->loadCompiled(true);
|
||||
}
|
||||
if ($tpl->compiled->has_nocache_code) {
|
||||
$this->cached->hashes[ $tpl->compiled->nocache_hash ] = true;
|
||||
|
@@ -257,7 +257,7 @@ abstract class Smarty_Internal_TemplateBase extends Smarty_Internal_Data
|
||||
error_reporting($_smarty_old_error_level);
|
||||
}
|
||||
return $result;
|
||||
} catch (Exception $e) {
|
||||
} catch (Throwable $e) {
|
||||
while (ob_get_level() > $level) {
|
||||
ob_end_clean();
|
||||
}
|
||||
|
@@ -605,7 +605,7 @@ abstract class Smarty_Internal_TemplateCompilerBase
|
||||
if (strcasecmp($name, 'isset') === 0 || strcasecmp($name, 'empty') === 0
|
||||
|| strcasecmp($name, 'array') === 0 || is_callable($name)
|
||||
) {
|
||||
$func_name = strtolower($name);
|
||||
$func_name = smarty_strtolower_ascii($name);
|
||||
|
||||
if ($func_name === 'isset') {
|
||||
if (count($parameter) === 0) {
|
||||
@@ -765,7 +765,7 @@ abstract class Smarty_Internal_TemplateCompilerBase
|
||||
if (!isset(self::$_tag_objects[ $tag ])) {
|
||||
// lazy load internal compiler plugin
|
||||
$_tag = explode('_', $tag);
|
||||
$_tag = array_map('ucfirst', $_tag);
|
||||
$_tag = array_map('smarty_ucfirst_ascii', $_tag);
|
||||
$class_name = 'Smarty_Internal_Compile_' . implode('_', $_tag);
|
||||
if (class_exists($class_name)
|
||||
&& (!isset($this->smarty->security_policy) || $this->smarty->security_policy->isTrustedTag($tag, $this))
|
||||
|
@@ -144,7 +144,7 @@ class Smarty_Internal_TestInstall
|
||||
}
|
||||
// test if all registered plugins_dir are accessible
|
||||
// and if core plugins directory is still registered
|
||||
$_core_plugins_dir = realpath(dirname(__FILE__) . '/../plugins');
|
||||
$_core_plugins_dir = realpath(__DIR__ . '/../plugins');
|
||||
$_core_plugins_available = false;
|
||||
foreach ($smarty->getPluginsDir() as $plugin_dir) {
|
||||
$_plugin_dir = $plugin_dir;
|
||||
|
@@ -76,11 +76,11 @@ abstract class Smarty_Resource
|
||||
}
|
||||
// try sysplugins dir
|
||||
if (isset(self::$sysplugins[ $type ])) {
|
||||
$_resource_class = 'Smarty_Internal_Resource_' . ucfirst($type);
|
||||
$_resource_class = 'Smarty_Internal_Resource_' . smarty_ucfirst_ascii($type);
|
||||
return $smarty->_cache[ 'resource_handlers' ][ $type ] = new $_resource_class();
|
||||
}
|
||||
// try plugins dir
|
||||
$_resource_class = 'Smarty_Resource_' . ucfirst($type);
|
||||
$_resource_class = 'Smarty_Resource_' . smarty_ucfirst_ascii($type);
|
||||
if ($smarty->loadPlugin($_resource_class)) {
|
||||
if (class_exists($_resource_class, false)) {
|
||||
return $smarty->_cache[ 'resource_handlers' ][ $type ] = new $_resource_class();
|
||||
|
@@ -47,7 +47,7 @@ abstract class Smarty_Resource_Custom extends Smarty_Resource
|
||||
*/
|
||||
public function populate(Smarty_Template_Source $source, Smarty_Internal_Template $_template = null)
|
||||
{
|
||||
$source->filepath = $source->type . ':' . substr(preg_replace('/[^A-Za-z0-9.]/', '', $source->name), 0, 25);
|
||||
$source->filepath = $source->type . ':' . $this->generateSafeName($source->name);
|
||||
$source->uid = sha1($source->type . ':' . $source->name);
|
||||
$mtime = $this->fetchTimestamp($source->name);
|
||||
if ($mtime !== null) {
|
||||
@@ -88,6 +88,17 @@ abstract class Smarty_Resource_Custom extends Smarty_Resource
|
||||
*/
|
||||
public function getBasename(Smarty_Template_Source $source)
|
||||
{
|
||||
return basename(substr(preg_replace('/[^A-Za-z0-9.]/', '', $source->name), 0, 25));
|
||||
return basename($this->generateSafeName($source->name));
|
||||
}
|
||||
|
||||
/**
|
||||
* Removes special characters from $name and limits its length to 127 characters.
|
||||
*
|
||||
* @param $name
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
private function generateSafeName($name): string {
|
||||
return substr(preg_replace('/[^A-Za-z0-9._]/', '', (string) $name), 0, 127);
|
||||
}
|
||||
}
|
||||
|
@@ -104,7 +104,7 @@ class Smarty_Security
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
public $php_modifiers = array('escape', 'count', 'nl2br',);
|
||||
public $php_modifiers = array('escape', 'count', 'sizeof', 'nl2br',);
|
||||
|
||||
/**
|
||||
* This is an array of allowed tags.
|
||||
@@ -327,7 +327,7 @@ class Smarty_Security
|
||||
*
|
||||
* @param string $modifier_name
|
||||
* @param object $compiler compiler object
|
||||
*
|
||||
* @deprecated
|
||||
* @return boolean true if modifier is trusted
|
||||
*/
|
||||
public function isTrustedPhpModifier($modifier_name, $compiler)
|
||||
@@ -554,35 +554,6 @@ class Smarty_Security
|
||||
throw new SmartyException("URI '{$uri}' not allowed by security setting");
|
||||
}
|
||||
|
||||
/**
|
||||
* Check if directory of file resource is trusted.
|
||||
*
|
||||
* @param string $filepath
|
||||
*
|
||||
* @return boolean true if directory is trusted
|
||||
* @throws SmartyException if PHP directory is not trusted
|
||||
*/
|
||||
public function isTrustedPHPDir($filepath)
|
||||
{
|
||||
if (empty($this->trusted_dir)) {
|
||||
throw new SmartyException("directory '{$filepath}' not allowed by security setting (no trusted_dir specified)");
|
||||
}
|
||||
// check if index is outdated
|
||||
if (!$this->_trusted_dir || $this->_trusted_dir !== $this->trusted_dir) {
|
||||
$this->_php_resource_dir = array();
|
||||
$this->_trusted_dir = $this->trusted_dir;
|
||||
foreach ((array)$this->trusted_dir as $directory) {
|
||||
$directory = $this->smarty->_realpath($directory . '/', true);
|
||||
$this->_php_resource_dir[ $directory ] = true;
|
||||
}
|
||||
}
|
||||
$addPath = $this->_checkDir($filepath, $this->_php_resource_dir);
|
||||
if ($addPath !== false) {
|
||||
$this->_php_resource_dir = array_merge($this->_php_resource_dir, $addPath);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Remove old directories and its sub folders, add new directories
|
||||
*
|
||||
|
@@ -1,2 +0,0 @@
|
||||
#! /bin/bash
|
||||
vendor/phpunit/phpunit/phpunit
|
44
run-tests-for-all-php-versions.sh
Executable file
44
run-tests-for-all-php-versions.sh
Executable file
@@ -0,0 +1,44 @@
|
||||
#!/bin/bash
|
||||
Help()
|
||||
{
|
||||
# Display Help
|
||||
echo "Runs PHPUnit tests for all PHP versions supported by this version of Smarty."
|
||||
echo
|
||||
echo "Syntax: $0 [-e|h]"
|
||||
echo "options:"
|
||||
echo "e Exclude a group of unit tests, e.g. -e 'slow'"
|
||||
echo "h Print this Help."
|
||||
echo
|
||||
}
|
||||
|
||||
Exclude=""
|
||||
|
||||
# Get the options
|
||||
while getopts ":he:" option; do
|
||||
case $option in
|
||||
e) # Exclude
|
||||
echo $OPTARG
|
||||
Exclude=$OPTARG;;
|
||||
h) # display Help
|
||||
Help
|
||||
exit;;
|
||||
\?) # Invalid option
|
||||
echo "Error: Invalid option"
|
||||
exit;;
|
||||
esac
|
||||
done
|
||||
|
||||
if [ -z $Exclude ];
|
||||
then
|
||||
Entrypoint="./run-tests.sh"
|
||||
else
|
||||
Entrypoint="./run-tests.sh $Exclude"
|
||||
fi
|
||||
|
||||
# Runs tests for all supported PHP versions
|
||||
docker-compose run --entrypoint "$Entrypoint" php71 && \
|
||||
docker-compose run --entrypoint "$Entrypoint" php72 && \
|
||||
docker-compose run --entrypoint "$Entrypoint" php73 && \
|
||||
docker-compose run --entrypoint "$Entrypoint" php74 && \
|
||||
docker-compose run --entrypoint "$Entrypoint" php80 && \
|
||||
docker-compose run --entrypoint "$Entrypoint" php81
|
13
run-tests.sh
Executable file
13
run-tests.sh
Executable file
@@ -0,0 +1,13 @@
|
||||
#!/bin/sh
|
||||
composer update
|
||||
|
||||
php -r 'echo "\nPHP version " . phpversion() . ". ";';
|
||||
|
||||
if [ -z $1 ];
|
||||
then
|
||||
echo "Running all unit tests.\n"
|
||||
php ./vendor/phpunit/phpunit/phpunit
|
||||
else
|
||||
echo "Running all unit tests, except tests marked with @group $1.\n"
|
||||
php ./vendor/phpunit/phpunit/phpunit --exclude-group $1
|
||||
fi
|
@@ -6,9 +6,9 @@
|
||||
/*
|
||||
* Smarty PHPUnit Bootstrap
|
||||
*/
|
||||
require_once dirname(__FILE__) . '/Config.php';
|
||||
require_once dirname(__FILE__) . '/../vendor/autoload.php';
|
||||
require_once dirname(__FILE__) . '/../libs/bootstrap.php';
|
||||
require_once __DIR__ . '/Config.php';
|
||||
require_once __DIR__ . '/../vendor/autoload.php';
|
||||
require_once __DIR__ . '/../libs/bootstrap.php';
|
||||
|
||||
require_once 'PHPUnit_Smarty.php';
|
||||
if (!ini_get('date.timezone')) {
|
||||
|
@@ -128,7 +128,7 @@ class PHPUnit_Smarty extends PHPUnit\Framework\TestCase
|
||||
}
|
||||
$s_dir[ $dir ] = true;
|
||||
}
|
||||
$dir = dirname(__FILE__);
|
||||
$dir = __DIR__;
|
||||
}
|
||||
if (!is_dir($dir . '/templates_c')) {
|
||||
mkdir($dir . '/templates_c');
|
||||
@@ -145,8 +145,8 @@ class PHPUnit_Smarty extends PHPUnit\Framework\TestCase
|
||||
// instance Smarty class
|
||||
$this->smarty = new Smarty;
|
||||
if (individualFolders != 'true') {
|
||||
$this->smarty->setCompileDir(dirname(__FILE__) . '/templates_c');
|
||||
$this->smarty->setCacheDir(dirname(__FILE__) . '/cache');
|
||||
$this->smarty->setCompileDir(__DIR__ . '/templates_c');
|
||||
$this->smarty->setCacheDir(__DIR__ . '/cache');
|
||||
}
|
||||
|
||||
$this->getSmartyObj();
|
||||
@@ -637,10 +637,10 @@ KEY `name` (`name`)
|
||||
}
|
||||
|
||||
public static function getSmartyPluginsDir(){
|
||||
if (is_dir(dirname(__FILE__) . '/../smarty/libs/plugins')) {
|
||||
return dirname(__FILE__) . '/../smarty/libs/plugins';
|
||||
} else if(is_dir(dirname(__FILE__) . '/../libs/plugins')) {
|
||||
return dirname(__FILE__) . '/../libs/plugins';
|
||||
if (is_dir(__DIR__ . '/../smarty/libs/plugins')) {
|
||||
return __DIR__ . '/../smarty/libs/plugins';
|
||||
} else if(is_dir(__DIR__ . '/../libs/plugins')) {
|
||||
return __DIR__ . '/../libs/plugins';
|
||||
}
|
||||
}
|
||||
/**
|
||||
|
@@ -17,7 +17,7 @@ class PathNormalizationTest extends PHPUnit_Smarty
|
||||
*/
|
||||
public function setUp(): void
|
||||
{
|
||||
$this->setUpSmarty(dirname(__FILE__));
|
||||
$this->setUpSmarty(__DIR__);
|
||||
}
|
||||
|
||||
public function testNormalizeToAbsolute() {
|
||||
|
@@ -17,7 +17,7 @@ class PluginNormalizationTest extends PHPUnit_Smarty
|
||||
*/
|
||||
public function setUp(): void
|
||||
{
|
||||
$this->setUpSmarty(dirname(__FILE__));
|
||||
$this->setUpSmarty(__DIR__);
|
||||
}
|
||||
|
||||
public function testGetPluginsDefaultDir()
|
||||
|
@@ -17,7 +17,7 @@ class TemplateNormalizationTest extends PHPUnit_Smarty
|
||||
*/
|
||||
public function setUp(): void
|
||||
{
|
||||
$this->setUpSmarty(dirname(__FILE__));
|
||||
$this->setUpSmarty(__DIR__);
|
||||
}
|
||||
|
||||
public function testGetTemplateDir()
|
||||
|
@@ -17,7 +17,7 @@ class ProtectedFolderVarsTest extends PHPUnit_Smarty
|
||||
*/
|
||||
public function setUp(): void
|
||||
{
|
||||
$this->setUpSmarty(dirname(__FILE__));
|
||||
$this->setUpSmarty(__DIR__);
|
||||
}
|
||||
|
||||
/*
|
||||
@@ -29,7 +29,7 @@ class ProtectedFolderVarsTest extends PHPUnit_Smarty
|
||||
$s = new Smarty();
|
||||
$s->template_dir = './foo';
|
||||
$d = $s->getTemplateDir();
|
||||
$this->assertEquals(dirname(__FILE__) . DIRECTORY_SEPARATOR . 'foo' . DIRECTORY_SEPARATOR, $d[ 0 ]);
|
||||
$this->assertEquals(__DIR__ . DIRECTORY_SEPARATOR . 'foo' . DIRECTORY_SEPARATOR, $d[ 0 ]);
|
||||
}
|
||||
|
||||
public function testTemplateDirDirectRelativeArray()
|
||||
@@ -37,8 +37,8 @@ class ProtectedFolderVarsTest extends PHPUnit_Smarty
|
||||
$s = new Smarty();
|
||||
$s->template_dir = array('./foo', './bar/');
|
||||
$d = $s->template_dir;
|
||||
$this->assertEquals(dirname(__FILE__) . DIRECTORY_SEPARATOR . 'foo' . DIRECTORY_SEPARATOR, $d[ 0 ]);
|
||||
$this->assertEquals(dirname(__FILE__) . DIRECTORY_SEPARATOR . 'bar' . DIRECTORY_SEPARATOR, $d[ 1 ]);
|
||||
$this->assertEquals(__DIR__ . DIRECTORY_SEPARATOR . 'foo' . DIRECTORY_SEPARATOR, $d[ 0 ]);
|
||||
$this->assertEquals(__DIR__ . DIRECTORY_SEPARATOR . 'bar' . DIRECTORY_SEPARATOR, $d[ 1 ]);
|
||||
}
|
||||
|
||||
public function testTemplateDirDirectRelativeArrayAdd()
|
||||
@@ -47,15 +47,15 @@ class ProtectedFolderVarsTest extends PHPUnit_Smarty
|
||||
$s->template_dir = './foo';
|
||||
$s->addTemplateDir('./bar/');
|
||||
$d = $s->getTemplateDir();
|
||||
$this->assertEquals(dirname(__FILE__) . DIRECTORY_SEPARATOR . 'foo' . DIRECTORY_SEPARATOR, $d[ 0 ]);
|
||||
$this->assertEquals(dirname(__FILE__) . DIRECTORY_SEPARATOR . 'bar' . DIRECTORY_SEPARATOR, $d[ 1 ]);
|
||||
$this->assertEquals(__DIR__ . DIRECTORY_SEPARATOR . 'foo' . DIRECTORY_SEPARATOR, $d[ 0 ]);
|
||||
$this->assertEquals(__DIR__ . DIRECTORY_SEPARATOR . 'bar' . DIRECTORY_SEPARATOR, $d[ 1 ]);
|
||||
}
|
||||
|
||||
public function testTemplateDirDirectRelativeExtends()
|
||||
{
|
||||
$s = new FolderT();
|
||||
$d = $s->getTemplateDir();
|
||||
$this->assertEquals(dirname(__FILE__) . DIRECTORY_SEPARATOR . 'foo' . DIRECTORY_SEPARATOR, $d[ 0 ]);
|
||||
$this->assertEquals(__DIR__ . DIRECTORY_SEPARATOR . 'foo' . DIRECTORY_SEPARATOR, $d[ 0 ]);
|
||||
}
|
||||
|
||||
public function testTemplateDirDirectRelativeExtends2()
|
||||
@@ -63,7 +63,7 @@ class ProtectedFolderVarsTest extends PHPUnit_Smarty
|
||||
$s = new FolderT();
|
||||
$s->template_dir = './bar';
|
||||
$d = $s->getTemplateDir();
|
||||
$this->assertEquals(dirname(__FILE__) . DIRECTORY_SEPARATOR . 'bar' . DIRECTORY_SEPARATOR, $d[ 0 ]);
|
||||
$this->assertEquals(__DIR__ . DIRECTORY_SEPARATOR . 'bar' . DIRECTORY_SEPARATOR, $d[ 0 ]);
|
||||
}
|
||||
|
||||
/*
|
||||
@@ -75,7 +75,7 @@ class ProtectedFolderVarsTest extends PHPUnit_Smarty
|
||||
$s = new Smarty();
|
||||
$s->config_dir = './foo';
|
||||
$d = $s->getConfigDir();
|
||||
$this->assertEquals(dirname(__FILE__) . DIRECTORY_SEPARATOR . 'foo' . DIRECTORY_SEPARATOR, $d[ 0 ]);
|
||||
$this->assertEquals(__DIR__ . DIRECTORY_SEPARATOR . 'foo' . DIRECTORY_SEPARATOR, $d[ 0 ]);
|
||||
}
|
||||
|
||||
public function testConfigDirDirectRelativeArray()
|
||||
@@ -83,8 +83,8 @@ class ProtectedFolderVarsTest extends PHPUnit_Smarty
|
||||
$s = new Smarty();
|
||||
$s->config_dir = array('./foo', './bar/');
|
||||
$d = $s->config_dir;
|
||||
$this->assertEquals(dirname(__FILE__) . DIRECTORY_SEPARATOR . 'foo' . DIRECTORY_SEPARATOR, $d[ 0 ]);
|
||||
$this->assertEquals(dirname(__FILE__) . DIRECTORY_SEPARATOR . 'bar' . DIRECTORY_SEPARATOR, $d[ 1 ]);
|
||||
$this->assertEquals(__DIR__ . DIRECTORY_SEPARATOR . 'foo' . DIRECTORY_SEPARATOR, $d[ 0 ]);
|
||||
$this->assertEquals(__DIR__ . DIRECTORY_SEPARATOR . 'bar' . DIRECTORY_SEPARATOR, $d[ 1 ]);
|
||||
}
|
||||
|
||||
public function testConfigDirDirectRelativeArrayAdd()
|
||||
@@ -93,15 +93,15 @@ class ProtectedFolderVarsTest extends PHPUnit_Smarty
|
||||
$s->config_dir = './foo';
|
||||
$s->addConfigDir('./bar/');
|
||||
$d = $s->getConfigDir();
|
||||
$this->assertEquals(dirname(__FILE__) . DIRECTORY_SEPARATOR . 'foo' . DIRECTORY_SEPARATOR, $d[ 0 ]);
|
||||
$this->assertEquals(dirname(__FILE__) . DIRECTORY_SEPARATOR . 'bar' . DIRECTORY_SEPARATOR, $d[ 1 ]);
|
||||
$this->assertEquals(__DIR__ . DIRECTORY_SEPARATOR . 'foo' . DIRECTORY_SEPARATOR, $d[ 0 ]);
|
||||
$this->assertEquals(__DIR__ . DIRECTORY_SEPARATOR . 'bar' . DIRECTORY_SEPARATOR, $d[ 1 ]);
|
||||
}
|
||||
|
||||
public function testConfigDirDirectRelativeExtends()
|
||||
{
|
||||
$s = new FolderT();
|
||||
$d = $s->getConfigDir();
|
||||
$this->assertEquals(dirname(__FILE__) . DIRECTORY_SEPARATOR . 'conf' . DIRECTORY_SEPARATOR, $d[ 0 ]);
|
||||
$this->assertEquals(__DIR__ . DIRECTORY_SEPARATOR . 'conf' . DIRECTORY_SEPARATOR, $d[ 0 ]);
|
||||
}
|
||||
|
||||
public function testConfigDirDirectRelativeExtends2()
|
||||
@@ -109,7 +109,7 @@ class ProtectedFolderVarsTest extends PHPUnit_Smarty
|
||||
$s = new FolderT();
|
||||
$s->config_dir = './bar';
|
||||
$d = $s->getConfigDir();
|
||||
$this->assertEquals(dirname(__FILE__) . DIRECTORY_SEPARATOR . 'bar' . DIRECTORY_SEPARATOR, $d[ 0 ]);
|
||||
$this->assertEquals(__DIR__ . DIRECTORY_SEPARATOR . 'bar' . DIRECTORY_SEPARATOR, $d[ 0 ]);
|
||||
}
|
||||
|
||||
/*
|
||||
@@ -121,7 +121,7 @@ class ProtectedFolderVarsTest extends PHPUnit_Smarty
|
||||
$s = new Smarty();
|
||||
$s->plugins_dir = './foo';
|
||||
$d = $s->getPluginsDir();
|
||||
$this->assertEquals(dirname(__FILE__) . DIRECTORY_SEPARATOR . 'foo' . DIRECTORY_SEPARATOR, $d[ 0 ]);
|
||||
$this->assertEquals(__DIR__ . DIRECTORY_SEPARATOR . 'foo' . DIRECTORY_SEPARATOR, $d[ 0 ]);
|
||||
}
|
||||
|
||||
public function testPluginDirDirectRelativeArray()
|
||||
@@ -129,8 +129,8 @@ class ProtectedFolderVarsTest extends PHPUnit_Smarty
|
||||
$s = new Smarty();
|
||||
$s->plugins_dir = array('./foo', './bar/');
|
||||
$d = $s->plugins_dir;
|
||||
$this->assertEquals(dirname(__FILE__) . DIRECTORY_SEPARATOR . 'foo' . DIRECTORY_SEPARATOR, $d[ 0 ]);
|
||||
$this->assertEquals(dirname(__FILE__) . DIRECTORY_SEPARATOR . 'bar' . DIRECTORY_SEPARATOR, $d[ 1 ]);
|
||||
$this->assertEquals(__DIR__ . DIRECTORY_SEPARATOR . 'foo' . DIRECTORY_SEPARATOR, $d[ 0 ]);
|
||||
$this->assertEquals(__DIR__ . DIRECTORY_SEPARATOR . 'bar' . DIRECTORY_SEPARATOR, $d[ 1 ]);
|
||||
}
|
||||
|
||||
public function testPluginDirDirectRelativeArrayAdd()
|
||||
@@ -139,15 +139,15 @@ class ProtectedFolderVarsTest extends PHPUnit_Smarty
|
||||
$s->plugins_dir = './foo';
|
||||
$s->addPluginsDir('./bar/');
|
||||
$d = $s->getPluginsDir();
|
||||
$this->assertEquals(dirname(__FILE__) . DIRECTORY_SEPARATOR . 'foo' . DIRECTORY_SEPARATOR, $d[ 0 ]);
|
||||
$this->assertEquals(dirname(__FILE__) . DIRECTORY_SEPARATOR . 'bar' . DIRECTORY_SEPARATOR, $d[ 1 ]);
|
||||
$this->assertEquals(__DIR__ . DIRECTORY_SEPARATOR . 'foo' . DIRECTORY_SEPARATOR, $d[ 0 ]);
|
||||
$this->assertEquals(__DIR__ . DIRECTORY_SEPARATOR . 'bar' . DIRECTORY_SEPARATOR, $d[ 1 ]);
|
||||
}
|
||||
|
||||
public function testPluginDirDirectRelativeExtends()
|
||||
{
|
||||
$s = new FolderT();
|
||||
$d = $s->getPluginsDir();
|
||||
$this->assertEquals(dirname(__FILE__) . DIRECTORY_SEPARATOR . 'plug' . DIRECTORY_SEPARATOR, $d[ 0 ]);
|
||||
$this->assertEquals(__DIR__ . DIRECTORY_SEPARATOR . 'plug' . DIRECTORY_SEPARATOR, $d[ 0 ]);
|
||||
}
|
||||
|
||||
public function testPluginDirDirectRelativeExtends2()
|
||||
@@ -155,7 +155,7 @@ class ProtectedFolderVarsTest extends PHPUnit_Smarty
|
||||
$s = new FolderT();
|
||||
$s->plugins_dir = './bar';
|
||||
$d = $s->getPluginsDir();
|
||||
$this->assertEquals(dirname(__FILE__) . DIRECTORY_SEPARATOR . 'bar' . DIRECTORY_SEPARATOR, $d[ 0 ]);
|
||||
$this->assertEquals(__DIR__ . DIRECTORY_SEPARATOR . 'bar' . DIRECTORY_SEPARATOR, $d[ 0 ]);
|
||||
}
|
||||
/*
|
||||
* compile_dir
|
||||
@@ -166,14 +166,14 @@ class ProtectedFolderVarsTest extends PHPUnit_Smarty
|
||||
$s = new Smarty();
|
||||
$s->compile_dir = './foo';
|
||||
$d = $s->getCompileDir();
|
||||
$this->assertEquals(dirname(__FILE__) . DIRECTORY_SEPARATOR . 'foo' . DIRECTORY_SEPARATOR, $d);
|
||||
$this->assertEquals(__DIR__ . DIRECTORY_SEPARATOR . 'foo' . DIRECTORY_SEPARATOR, $d);
|
||||
}
|
||||
|
||||
public function testCompileDirDirectRelativeExtends()
|
||||
{
|
||||
$s = new FolderT();
|
||||
$d = $s->getCompileDir();
|
||||
$this->assertEquals(dirname(__FILE__) . DIRECTORY_SEPARATOR . 'comp' . DIRECTORY_SEPARATOR, $d);
|
||||
$this->assertEquals(__DIR__ . DIRECTORY_SEPARATOR . 'comp' . DIRECTORY_SEPARATOR, $d);
|
||||
}
|
||||
|
||||
public function testCompileDirDirectRelativeExtends2()
|
||||
@@ -181,7 +181,7 @@ class ProtectedFolderVarsTest extends PHPUnit_Smarty
|
||||
$s = new FolderT();
|
||||
$s->compile_dir = './bar';
|
||||
$d = $s->getCompileDir();
|
||||
$this->assertEquals(dirname(__FILE__) . DIRECTORY_SEPARATOR . 'bar' . DIRECTORY_SEPARATOR, $d);
|
||||
$this->assertEquals(__DIR__ . DIRECTORY_SEPARATOR . 'bar' . DIRECTORY_SEPARATOR, $d);
|
||||
}
|
||||
/*
|
||||
* cache_dir
|
||||
@@ -192,14 +192,14 @@ class ProtectedFolderVarsTest extends PHPUnit_Smarty
|
||||
$s = new Smarty();
|
||||
$s->cache_dir = './foo';
|
||||
$d = $s->getCacheDir();
|
||||
$this->assertEquals(dirname(__FILE__) . DIRECTORY_SEPARATOR . 'foo' . DIRECTORY_SEPARATOR, $d);
|
||||
$this->assertEquals(__DIR__ . DIRECTORY_SEPARATOR . 'foo' . DIRECTORY_SEPARATOR, $d);
|
||||
}
|
||||
|
||||
public function testCacheDirDirectRelativeExtends()
|
||||
{
|
||||
$s = new FolderT();
|
||||
$d = $s->getCacheDir();
|
||||
$this->assertEquals(dirname(__FILE__) . DIRECTORY_SEPARATOR . 'cache' . DIRECTORY_SEPARATOR, $d);
|
||||
$this->assertEquals(__DIR__ . DIRECTORY_SEPARATOR . 'cache' . DIRECTORY_SEPARATOR, $d);
|
||||
}
|
||||
|
||||
public function testCacheDirDirectRelativeExtends2()
|
||||
@@ -207,7 +207,7 @@ class ProtectedFolderVarsTest extends PHPUnit_Smarty
|
||||
$s = new FolderT();
|
||||
$s->cache_dir = './bar';
|
||||
$d = $s->getCacheDir();
|
||||
$this->assertEquals(dirname(__FILE__) . DIRECTORY_SEPARATOR . 'bar' . DIRECTORY_SEPARATOR, $d);
|
||||
$this->assertEquals(__DIR__ . DIRECTORY_SEPARATOR . 'bar' . DIRECTORY_SEPARATOR, $d);
|
||||
}
|
||||
}
|
||||
|
||||
|
@@ -15,7 +15,7 @@ class UndefinedTemplateVarTest extends PHPUnit_Smarty
|
||||
*/
|
||||
public function setUp(): void
|
||||
{
|
||||
$this->setUpSmarty(dirname(__FILE__));
|
||||
$this->setUpSmarty(__DIR__);
|
||||
}
|
||||
|
||||
public function testInit()
|
||||
|
@@ -17,7 +17,7 @@ class AutoEscapeTest extends PHPUnit_Smarty
|
||||
*/
|
||||
public function setUp(): void
|
||||
{
|
||||
$this->setUpSmarty(dirname(__FILE__));
|
||||
$this->setUpSmarty(__DIR__);
|
||||
$this->smarty->setEscapeHtml(true);
|
||||
}
|
||||
|
||||
|
@@ -18,7 +18,7 @@ class FilterTest extends PHPUnit_Smarty
|
||||
|
||||
public function setUp(): void
|
||||
{
|
||||
$this->setUpSmarty(dirname(__FILE__));
|
||||
$this->setUpSmarty(__DIR__);
|
||||
}
|
||||
|
||||
public function testInit()
|
||||
|
@@ -17,7 +17,7 @@ class LoadFilterTest extends PHPUnit_Smarty
|
||||
{
|
||||
public function setUp(): void
|
||||
{
|
||||
$this->setUpSmarty(dirname(__FILE__));
|
||||
$this->setUpSmarty(__DIR__);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@@ -17,7 +17,7 @@ class RegisterFilterTest extends PHPUnit_Smarty
|
||||
{
|
||||
public function setUp(): void
|
||||
{
|
||||
$this->setUpSmarty(dirname(__FILE__));
|
||||
$this->setUpSmarty(__DIR__);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@@ -17,7 +17,7 @@ class GetterSetterTest extends PHPUnit_Smarty
|
||||
{
|
||||
public function setUp(): void
|
||||
{
|
||||
$this->setUpSmarty(dirname(__FILE__));
|
||||
$this->setUpSmarty(__DIR__);
|
||||
}
|
||||
|
||||
public function testInit()
|
||||
|
@@ -17,7 +17,7 @@ class DefaultPluginHandlerTest extends PHPUnit_Smarty
|
||||
{
|
||||
public function setUp(): void
|
||||
{
|
||||
$this->setUpSmarty(dirname(__FILE__));
|
||||
$this->setUpSmarty(__DIR__);
|
||||
$this->smarty->setForceCompile(true);
|
||||
$this->smarty->disableSecurity();
|
||||
$this->smarty->registerDefaultPluginHandler('my_plugin_handler');
|
||||
|
@@ -13,12 +13,12 @@ class IncludePathTest extends PHPUnit_Smarty
|
||||
{
|
||||
public function setUp(): void
|
||||
{
|
||||
$this->setUpSmarty(dirname(__FILE__));
|
||||
$this->setUpSmarty(__DIR__);
|
||||
$this->smarty->use_include_path = true;
|
||||
$this->smarty->setPluginsDir(array('./include','./include1'));
|
||||
$this->smarty->enableSecurity();
|
||||
$ds = DIRECTORY_SEPARATOR;
|
||||
set_include_path($this->smarty->_realpath(dirname(__FILE__) . "{$ds}..{$ds}..{$ds}..{$ds}Include_Path{$ds}Plugins{$ds}", true) . PATH_SEPARATOR . get_include_path());
|
||||
set_include_path($this->smarty->_realpath(__DIR__ . "{$ds}..{$ds}..{$ds}..{$ds}Include_Path{$ds}Plugins{$ds}", true) . PATH_SEPARATOR . get_include_path());
|
||||
}
|
||||
|
||||
/**
|
||||
|
@@ -17,7 +17,7 @@ class LoadPluginTest extends PHPUnit_Smarty
|
||||
{
|
||||
public function setUp(): void
|
||||
{
|
||||
$this->setUpSmarty(dirname(__FILE__));
|
||||
$this->setUpSmarty(__DIR__);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@@ -17,7 +17,7 @@ class PluginChainedLoadTest extends PHPUnit_Smarty
|
||||
{
|
||||
public function setUp(): void
|
||||
{
|
||||
$this->setUpSmarty(dirname(__FILE__));
|
||||
$this->setUpSmarty(__DIR__);
|
||||
}
|
||||
|
||||
public function testInit()
|
||||
@@ -27,7 +27,7 @@ class PluginChainedLoadTest extends PHPUnit_Smarty
|
||||
|
||||
public function testPluginChainedLoad()
|
||||
{
|
||||
$this->smarty->addPluginsDir(dirname(__FILE__) . "/PHPunitplugins/");
|
||||
$this->smarty->addPluginsDir(__DIR__ . "/PHPunitplugins/");
|
||||
$this->assertStringContainsString('from chain3', $this->smarty->fetch('test_plugin_chained_load.tpl'));
|
||||
}
|
||||
}
|
||||
|
@@ -13,7 +13,7 @@ class SharedFunctionsTest extends PHPUnit_Smarty
|
||||
{
|
||||
public function setUp(): void
|
||||
{
|
||||
$this->setUpSmarty(dirname(__FILE__));
|
||||
$this->setUpSmarty(__DIR__);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@@ -18,7 +18,7 @@ class HttpModifiedSinceTest extends PHPUnit_Smarty
|
||||
|
||||
public function setUp(): void
|
||||
{
|
||||
$this->setUpSmarty(dirname(__FILE__));
|
||||
$this->setUpSmarty(__DIR__);
|
||||
}
|
||||
|
||||
public function testInit()
|
||||
|
@@ -5,7 +5,7 @@
|
||||
* @package PHPunit
|
||||
* @author Uwe Tews
|
||||
*/
|
||||
include_once dirname(__FILE__) . '/../Memcache/CacheResourceCustomMemcacheTest.php';
|
||||
include_once __DIR__ . '/../Memcache/CacheResourceCustomMemcacheTest.php';
|
||||
|
||||
/**
|
||||
* class for cache resource file tests
|
||||
@@ -21,7 +21,7 @@ class CacheResourceCustomApcTest extends CacheResourceCustomMemcacheTest
|
||||
if (!function_exists('apc_cache_info') || ini_get('apc.enable_cli')) {
|
||||
$this->markTestSkipped('APC cache not available');
|
||||
}
|
||||
$this->setUpSmarty(dirname(__FILE__));
|
||||
$this->setUpSmarty(__DIR__);
|
||||
parent::setUp();
|
||||
$this->smarty->setCachingType('apc');
|
||||
$this->smarty->addPluginsDir(SMARTY_DIR . '../demo/plugins/');
|
||||
|
@@ -6,7 +6,7 @@
|
||||
* @author Uwe Tews
|
||||
*/
|
||||
|
||||
include_once dirname(__FILE__) . '/../_shared/CacheResourceTestCommon.php';
|
||||
include_once __DIR__ . '/../_shared/CacheResourceTestCommon.php';
|
||||
|
||||
/**
|
||||
* class for cache resource file tests
|
||||
@@ -20,7 +20,7 @@ class CacheResourceFileTest extends CacheResourceTestCommon
|
||||
|
||||
public function setUp(): void
|
||||
{
|
||||
$this->setUpSmarty(dirname(__FILE__));
|
||||
$this->setUpSmarty(__DIR__);
|
||||
parent::setUp();
|
||||
$this->smarty->setCachingType('filetest');
|
||||
}
|
||||
|
@@ -6,7 +6,7 @@
|
||||
* @author Uwe Tews
|
||||
*/
|
||||
|
||||
include_once dirname(__FILE__) . '/../_shared/CacheResourceTestCommon.php';
|
||||
include_once __DIR__ . '/../_shared/CacheResourceTestCommon.php';
|
||||
|
||||
/**
|
||||
* class for cache resource memcache tests
|
||||
@@ -27,7 +27,7 @@ class CacheResourceCustomMemcacheTest extends CacheResourceTestCommon
|
||||
if (!class_exists('Memcache')) {
|
||||
$this->markTestSkipped('Memcache not available');
|
||||
}
|
||||
$this->setUpSmarty(dirname(__FILE__));
|
||||
$this->setUpSmarty(__DIR__);
|
||||
parent::setUp();
|
||||
$this->smarty->setCachingType('memcachetest');
|
||||
}
|
||||
|
@@ -7,7 +7,7 @@
|
||||
*/
|
||||
if (MysqlCacheEnable == true) {
|
||||
|
||||
include_once dirname(__FILE__) . '/../_shared/CacheResourceTestCommon.php';
|
||||
include_once __DIR__ . '/../_shared/CacheResourceTestCommon.php';
|
||||
|
||||
/**
|
||||
* class for cache resource file tests
|
||||
@@ -28,7 +28,7 @@ if (MysqlCacheEnable == true) {
|
||||
if (self::$init) {
|
||||
$this->getConnection();
|
||||
}
|
||||
$this->setUpSmarty(dirname(__FILE__));
|
||||
$this->setUpSmarty(__DIR__);
|
||||
parent::setUp();
|
||||
$this->smarty->setCachingType('mysqltest');
|
||||
}
|
||||
|
@@ -7,7 +7,7 @@
|
||||
*/
|
||||
if (PdoCacheEnable == true) {
|
||||
|
||||
include_once dirname(__FILE__) . '/../_shared/CacheResourceTestCommon.php';
|
||||
include_once __DIR__ . '/../_shared/CacheResourceTestCommon.php';
|
||||
|
||||
/**
|
||||
* class for cache resource file tests
|
||||
@@ -27,7 +27,7 @@ if (PdoCacheEnable == true) {
|
||||
if (self::$init) {
|
||||
$this->getConnection();
|
||||
}
|
||||
$this->setUpSmarty(dirname(__FILE__));
|
||||
$this->setUpSmarty(__DIR__);
|
||||
parent::setUp();
|
||||
$this->smarty->setCachingType('pdo');
|
||||
$this->smarty->addPluginsDir(SMARTY_DIR . '../demo/plugins/');
|
||||
|
@@ -7,7 +7,7 @@
|
||||
*/
|
||||
if (PdoGzipCacheEnable == true) {
|
||||
|
||||
include_once dirname(__FILE__) . '/../_shared/CacheResourceTestCommon.php';
|
||||
include_once __DIR__ . '/../_shared/CacheResourceTestCommon.php';
|
||||
|
||||
/**
|
||||
* class for cache resource file tests
|
||||
@@ -25,7 +25,7 @@ if (PdoGzipCacheEnable == true) {
|
||||
if (self::$init) {
|
||||
$this->getConnection();
|
||||
}
|
||||
$this->setUpSmarty(dirname(__FILE__));
|
||||
$this->setUpSmarty(__DIR__);
|
||||
parent::setUp();
|
||||
$this->smarty->setCachingType('pdo');
|
||||
$this->smarty->addPluginsDir(SMARTY_DIR . '../demo/plugins/');
|
||||
|
@@ -6,7 +6,7 @@
|
||||
* @author Uwe Tews
|
||||
*/
|
||||
if (MysqlCacheEnable == true) {
|
||||
include_once dirname(__FILE__) . '/../_shared/CacheResourceTestCommon.php';
|
||||
include_once __DIR__ . '/../_shared/CacheResourceTestCommon.php';
|
||||
|
||||
/**
|
||||
* class for cache resource file tests
|
||||
@@ -25,10 +25,10 @@ if (MysqlCacheEnable == true) {
|
||||
if (self::$init) {
|
||||
$this->getConnection();
|
||||
}
|
||||
$this->setUpSmarty(dirname(__FILE__));
|
||||
$this->setUpSmarty(__DIR__);
|
||||
parent::setUp();
|
||||
if (!class_exists('Smarty_CacheResource_Mysqltest', false)) {
|
||||
require_once(dirname(__FILE__) . "/../_shared/PHPunitplugins/cacheresource.mysqltest.php");
|
||||
require_once(__DIR__ . "/../_shared/PHPunitplugins/cacheresource.mysqltest.php");
|
||||
}
|
||||
$this->smarty->setCachingType('foobar');
|
||||
$this->smarty->registerCacheResource('foobar', new Smarty_CacheResource_Mysqltest());
|
||||
|
@@ -17,8 +17,8 @@ class CacheResourceTestCommon extends PHPUnit_Smarty
|
||||
|
||||
public function setUp(): void
|
||||
{
|
||||
$this->smarty->setTemplateDir(dirname(__FILE__) . '/templates');
|
||||
$this->smarty->addPluginsDir(dirname(__FILE__) . '/PHPunitplugins');
|
||||
$this->smarty->setTemplateDir(__DIR__ . '/templates');
|
||||
$this->smarty->addPluginsDir(__DIR__ . '/PHPunitplugins');
|
||||
$this->smarty->registerFilter('pre', array($this, 'compiledPrefilter'));
|
||||
}
|
||||
|
||||
@@ -543,9 +543,9 @@ class CacheResourceTestCommon extends PHPUnit_Smarty
|
||||
{
|
||||
$this->smarty->setCaching(true);
|
||||
if ($folder == 0) {
|
||||
$this->smarty->setTemplateDir(array(dirname(__FILE__) . '/../_shared/templates', dirname(__FILE__) . '/../_shared/templates/a'));
|
||||
$this->smarty->setTemplateDir(array(__DIR__ . '/../_shared/templates', __DIR__ . '/../_shared/templates/a'));
|
||||
} else {
|
||||
$this->smarty->setTemplateDir(array(dirname(__FILE__) . '/../_shared/templates', dirname(__FILE__) . '/../_shared/templates/b'));
|
||||
$this->smarty->setTemplateDir(array(__DIR__ . '/../_shared/templates', __DIR__ . '/../_shared/templates/b'));
|
||||
}
|
||||
if ($merge) {
|
||||
$this->smarty->setCompileId(1);
|
||||
|
@@ -17,7 +17,7 @@ class CompileCompilerPluginTest extends PHPUnit_Smarty
|
||||
{
|
||||
public function setUp(): void
|
||||
{
|
||||
$this->setUpSmarty(dirname(__FILE__));
|
||||
$this->setUpSmarty(__DIR__);
|
||||
}
|
||||
|
||||
public function testInit()
|
||||
|
@@ -16,7 +16,7 @@ class AutoliteralTest extends PHPUnit_Smarty
|
||||
{
|
||||
public function setUp(): void
|
||||
{
|
||||
$this->setUpSmarty(dirname(__FILE__));
|
||||
$this->setUpSmarty(__DIR__);
|
||||
$this->smarty->addPluginsDir("../../__shared/PHPunitplugins/");
|
||||
}
|
||||
|
||||
|
@@ -17,7 +17,7 @@ class DelimiterTest extends PHPUnit_Smarty
|
||||
{
|
||||
public function setUp(): void
|
||||
{
|
||||
$this->setUpSmarty(dirname(__FILE__));
|
||||
$this->setUpSmarty(__DIR__);
|
||||
}
|
||||
|
||||
public function testInit()
|
||||
|
@@ -20,7 +20,7 @@ class UserliteralTest extends PHPUnit_Smarty
|
||||
if (!property_exists('Smarty', 'literals')) {
|
||||
$this->markTestSkipped('user literal support');
|
||||
} else {
|
||||
$this->setUpSmarty(dirname(__FILE__));
|
||||
$this->setUpSmarty(__DIR__);
|
||||
}
|
||||
}
|
||||
|
||||
|
@@ -23,7 +23,7 @@ class DefaultConfigHandlerTest extends PHPUnit_Smarty
|
||||
*/
|
||||
public function setUp(): void
|
||||
{
|
||||
$this->setUpSmarty(dirname(__FILE__));
|
||||
$this->setUpSmarty(__DIR__);
|
||||
$this->smarty->setForceCompile(true);
|
||||
}
|
||||
|
||||
|
@@ -22,7 +22,7 @@ class ConfigVarTest extends PHPUnit_Smarty
|
||||
*/
|
||||
public function setUp(): void
|
||||
{
|
||||
$this->setUpSmarty(dirname(__FILE__));
|
||||
$this->setUpSmarty(__DIR__);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -387,7 +387,7 @@ class ConfigVarTest extends PHPUnit_Smarty
|
||||
|
||||
public function testConfigResourceDb4()
|
||||
{
|
||||
$this->smarty->addPluginsDir(dirname(__FILE__) . "/PHPunitplugins/");
|
||||
$this->smarty->addPluginsDir(__DIR__ . "/PHPunitplugins/");
|
||||
$this->smarty->configLoad('db4:foo.conf');
|
||||
$this->assertEquals("bar", $this->smarty->fetch('foo.tpl'));
|
||||
}
|
||||
|
@@ -19,8 +19,8 @@ class CustomResourceAmbiguousTest extends PHPUnit_Smarty
|
||||
|
||||
public function setUp(): void
|
||||
{
|
||||
$this->setUpSmarty(dirname(__FILE__));
|
||||
require_once dirname(__FILE__) . '/PHPunitplugins/resource.ambiguous.php';
|
||||
$this->setUpSmarty(__DIR__);
|
||||
require_once __DIR__ . '/PHPunitplugins/resource.ambiguous.php';
|
||||
|
||||
// empty the template dir
|
||||
$this->smarty->setTemplateDir(array());
|
||||
@@ -36,7 +36,7 @@ class CustomResourceAmbiguousTest extends PHPUnit_Smarty
|
||||
|
||||
protected function relative($path)
|
||||
{
|
||||
$path = str_replace(dirname(__FILE__), '.', $path);
|
||||
$path = str_replace(__DIR__, '.', $path);
|
||||
if (DIRECTORY_SEPARATOR == "\\") {
|
||||
$path = str_replace("\\", "/", $path);
|
||||
}
|
||||
@@ -46,7 +46,7 @@ class CustomResourceAmbiguousTest extends PHPUnit_Smarty
|
||||
|
||||
public function testNone()
|
||||
{
|
||||
$resource_handler = new Smarty_Resource_Ambiguous(dirname(__FILE__) . '/templates/ambiguous/');
|
||||
$resource_handler = new Smarty_Resource_Ambiguous(__DIR__ . '/templates/ambiguous/');
|
||||
$this->smarty->registerResource('ambiguous', $resource_handler);
|
||||
$this->smarty->setDefaultResourceType('ambiguous');
|
||||
$this->smarty->setAllowAmbiguousResources(true);
|
||||
@@ -63,7 +63,7 @@ class CustomResourceAmbiguousTest extends PHPUnit_Smarty
|
||||
*/
|
||||
public function testCase1()
|
||||
{
|
||||
$resource_handler = new Smarty_Resource_Ambiguous(dirname(__FILE__) . '/templates/ambiguous/');
|
||||
$resource_handler = new Smarty_Resource_Ambiguous(__DIR__ . '/templates/ambiguous/');
|
||||
$this->smarty->registerResource('ambiguous', $resource_handler);
|
||||
$this->smarty->setDefaultResourceType('ambiguous');
|
||||
$this->smarty->setAllowAmbiguousResources(true);
|
||||
@@ -83,7 +83,7 @@ class CustomResourceAmbiguousTest extends PHPUnit_Smarty
|
||||
*/
|
||||
public function testCase2()
|
||||
{
|
||||
$resource_handler = new Smarty_Resource_Ambiguous(dirname(__FILE__) . '/templates/ambiguous/');
|
||||
$resource_handler = new Smarty_Resource_Ambiguous(__DIR__ . '/templates/ambiguous/');
|
||||
$this->smarty->registerResource('ambiguous', $resource_handler);
|
||||
$this->smarty->setDefaultResourceType('ambiguous');
|
||||
$this->smarty->setAllowAmbiguousResources(true);
|
||||
@@ -103,7 +103,7 @@ class CustomResourceAmbiguousTest extends PHPUnit_Smarty
|
||||
*/
|
||||
public function testCaseSwitching()
|
||||
{
|
||||
$resource_handler = new Smarty_Resource_Ambiguous(dirname(__FILE__) . '/templates/ambiguous/');
|
||||
$resource_handler = new Smarty_Resource_Ambiguous(__DIR__ . '/templates/ambiguous/');
|
||||
$this->smarty->registerResource('ambiguous', $resource_handler);
|
||||
$this->smarty->setDefaultResourceType('ambiguous');
|
||||
$this->smarty->setAllowAmbiguousResources(true);
|
||||
|
@@ -17,7 +17,7 @@ class ResourceExtendsAllPluginTest extends PHPUnit_Smarty
|
||||
{
|
||||
public function setUp(): void
|
||||
{
|
||||
$this->setUpSmarty(dirname(__FILE__));
|
||||
$this->setUpSmarty(__DIR__);
|
||||
}
|
||||
|
||||
public function testInit()
|
||||
|
@@ -23,7 +23,7 @@ if (MysqlResourceEnable == true) {
|
||||
if (self::$init) {
|
||||
$this->getConnection();
|
||||
}
|
||||
$this->setUpSmarty(dirname(__FILE__));
|
||||
$this->setUpSmarty(__DIR__);
|
||||
$this->smarty->addPluginsDir("./PHPunitplugins/");
|
||||
}
|
||||
|
||||
|
@@ -17,7 +17,7 @@ class DefaultTemplateHandlerTest extends PHPUnit_Smarty
|
||||
{
|
||||
public function setUp(): void
|
||||
{
|
||||
$this->setUpSmarty(dirname(__FILE__));
|
||||
$this->setUpSmarty(__DIR__);
|
||||
$this->smarty->setForceCompile(true);
|
||||
$this->smarty->disableSecurity();
|
||||
}
|
||||
|
@@ -17,7 +17,7 @@ class EvalResourceTest extends PHPUnit_Smarty
|
||||
{
|
||||
public function setUp(): void
|
||||
{
|
||||
$this->setUpSmarty(dirname(__FILE__));
|
||||
$this->setUpSmarty(__DIR__);
|
||||
}
|
||||
|
||||
|
||||
|
@@ -17,7 +17,7 @@ class ExtendsResourceTest extends PHPUnit_Smarty
|
||||
{
|
||||
public function setUp(): void
|
||||
{
|
||||
$this->setUpSmarty(dirname(__FILE__));
|
||||
$this->setUpSmarty(__DIR__);
|
||||
$this->smarty->enableSecurity();
|
||||
}
|
||||
|
||||
|
@@ -17,7 +17,7 @@ class FileResourceTest extends PHPUnit_Smarty
|
||||
{
|
||||
public function setUp(): void
|
||||
{
|
||||
$this->setUpSmarty(dirname(__FILE__));
|
||||
$this->setUpSmarty(__DIR__);
|
||||
$this->smarty->enableSecurity();
|
||||
}
|
||||
|
||||
@@ -28,7 +28,7 @@ class FileResourceTest extends PHPUnit_Smarty
|
||||
|
||||
protected function relative($path)
|
||||
{
|
||||
$path = str_replace(str_replace("\\", "/", dirname(__FILE__)), '.', str_replace("\\", "/", $path));
|
||||
$path = str_replace(str_replace("\\", "/", __DIR__), '.', str_replace("\\", "/", $path));
|
||||
|
||||
return $path;
|
||||
}
|
||||
@@ -249,8 +249,8 @@ class FileResourceTest extends PHPUnit_Smarty
|
||||
public function testRelativeFetch()
|
||||
{
|
||||
$this->smarty->setTemplateDir(array(
|
||||
dirname(__FILE__) . '/does-not-exist/',
|
||||
dirname(__FILE__) . '/templates/sub/',
|
||||
__DIR__ . '/does-not-exist/',
|
||||
__DIR__ . '/templates/sub/',
|
||||
));
|
||||
$this->smarty->security_policy = null;
|
||||
$this->assertEquals('hello world', $this->smarty->fetch('./relative.tpl'));
|
||||
@@ -265,8 +265,8 @@ class FileResourceTest extends PHPUnit_Smarty
|
||||
public function testRelativeFetch2()
|
||||
{
|
||||
$this->smarty->setTemplateDir(array(
|
||||
dirname(__FILE__) . '/does-not-exist/',
|
||||
dirname(__FILE__) . '/templates/sub/',
|
||||
__DIR__ . '/does-not-exist/',
|
||||
__DIR__ . '/templates/sub/',
|
||||
));
|
||||
$this->smarty->security_policy = null;
|
||||
$this->assertEquals('hello world', $this->smarty->fetch('../helloworld.tpl'));
|
||||
@@ -281,12 +281,12 @@ class FileResourceTest extends PHPUnit_Smarty
|
||||
public function testRelativeFetchCwd()
|
||||
{
|
||||
$cwd = getcwd();
|
||||
chdir(dirname(__FILE__) . '/templates/sub/');
|
||||
$dn = dirname(__FILE__);
|
||||
chdir(__DIR__ . '/templates/sub/');
|
||||
$dn = __DIR__;
|
||||
$this->smarty->setCompileDir($dn . '/templates_c/');
|
||||
$this->smarty->setCacheDir($dn . '/cache/');
|
||||
$this->smarty->setTemplateDir(array(
|
||||
dirname(__FILE__) . '/does-not-exist/',
|
||||
__DIR__ . '/does-not-exist/',
|
||||
));
|
||||
$this->smarty->security_policy = null;
|
||||
$this->assertEquals('hello world', $this->smarty->fetch('./relative.tpl'));
|
||||
@@ -302,12 +302,12 @@ class FileResourceTest extends PHPUnit_Smarty
|
||||
public function testRelativeFetchCwd2()
|
||||
{
|
||||
$cwd = getcwd();
|
||||
chdir(dirname(__FILE__) . '/templates/sub/');
|
||||
$dn = dirname(__FILE__);
|
||||
chdir(__DIR__ . '/templates/sub/');
|
||||
$dn = __DIR__;
|
||||
$this->smarty->setCompileDir($dn . '/templates_c/');
|
||||
$this->smarty->setCacheDir($dn . '/cache/');
|
||||
$this->smarty->setTemplateDir(array(
|
||||
dirname(__FILE__) . '/does-not-exist/',
|
||||
__DIR__ . '/does-not-exist/',
|
||||
));
|
||||
$this->smarty->security_policy = null;
|
||||
$this->assertEquals('hello world', $this->smarty->fetch('../helloworld.tpl'));
|
||||
@@ -359,7 +359,7 @@ class FileResourceTest extends PHPUnit_Smarty
|
||||
$this->smarty->security_policy = null;
|
||||
|
||||
$cwd = getcwd();
|
||||
$dn = dirname(__FILE__);
|
||||
$dn = __DIR__;
|
||||
$this->smarty->setCompileDir($dn . '/templates_c/');
|
||||
$this->smarty->setCacheDir($dn . '/cache/');
|
||||
$this->smarty->setTemplateDir(array($dn . '/templates/relativity/theory/',));
|
||||
@@ -378,7 +378,7 @@ class FileResourceTest extends PHPUnit_Smarty
|
||||
$this->smarty->security_policy = null;
|
||||
|
||||
$cwd = getcwd();
|
||||
$dn = dirname(__FILE__);
|
||||
$dn = __DIR__;
|
||||
$this->smarty->setCompileDir($dn . '/templates_c/');
|
||||
$this->smarty->setCacheDir($dn . '/cache/');
|
||||
|
||||
@@ -409,7 +409,7 @@ class FileResourceTest extends PHPUnit_Smarty
|
||||
$this->smarty->security_policy = null;
|
||||
|
||||
$cwd = getcwd();
|
||||
$dn = dirname(__FILE__);
|
||||
$dn = __DIR__;
|
||||
|
||||
$this->smarty->setCompileDir($dn . '/templates_c/');
|
||||
$this->smarty->setCacheDir($dn . '/cache/');
|
||||
@@ -438,7 +438,7 @@ class FileResourceTest extends PHPUnit_Smarty
|
||||
$this->smarty->security_policy = null;
|
||||
|
||||
$cwd = getcwd();
|
||||
$dn = dirname(__FILE__);
|
||||
$dn = __DIR__;
|
||||
|
||||
$this->smarty->setCompileDir($dn . '/templates_c/');
|
||||
$this->smarty->setCacheDir($dn . '/cache/');
|
||||
@@ -458,7 +458,7 @@ class FileResourceTest extends PHPUnit_Smarty
|
||||
$this->smarty->security_policy = null;
|
||||
|
||||
$cwd = getcwd();
|
||||
$dn = dirname(__FILE__);
|
||||
$dn = __DIR__;
|
||||
|
||||
$this->smarty->setCompileDir($dn . '/templates_c/');
|
||||
$this->smarty->setCacheDir($dn . '/cache/');
|
||||
@@ -489,7 +489,7 @@ class FileResourceTest extends PHPUnit_Smarty
|
||||
$this->smarty->security_policy = null;
|
||||
|
||||
$cwd = getcwd();
|
||||
$dn = dirname(__FILE__);
|
||||
$dn = __DIR__;
|
||||
|
||||
$this->smarty->setCompileDir($dn . '/templates_c/');
|
||||
$this->smarty->setCacheDir($dn . '/cache/');
|
||||
@@ -507,7 +507,7 @@ class FileResourceTest extends PHPUnit_Smarty
|
||||
$this->smarty->security_policy = null;
|
||||
|
||||
$cwd = getcwd();
|
||||
$dn = dirname(__FILE__);
|
||||
$dn = __DIR__;
|
||||
|
||||
$this->smarty->setCompileDir($dn . '/templates_c/');
|
||||
$this->smarty->setCacheDir($dn . '/cache/');
|
||||
@@ -526,7 +526,7 @@ class FileResourceTest extends PHPUnit_Smarty
|
||||
$this->smarty->security_policy = null;
|
||||
|
||||
$cwd = getcwd();
|
||||
$dn = dirname(__FILE__);
|
||||
$dn = __DIR__;
|
||||
|
||||
$this->smarty->setCompileDir($dn . '/templates_c/');
|
||||
$this->smarty->setCacheDir($dn . '/cache/');
|
||||
@@ -560,7 +560,7 @@ class FileResourceTest extends PHPUnit_Smarty
|
||||
$this->smarty->security_policy = null;
|
||||
|
||||
$cwd = getcwd();
|
||||
$dn = dirname(__FILE__);
|
||||
$dn = __DIR__;
|
||||
$this->smarty->setCompileDir($dn . '/templates_c/');
|
||||
$this->smarty->setCacheDir($dn . '/cache/');
|
||||
$this->smarty->setTemplateDir(array(
|
||||
@@ -599,7 +599,7 @@ class FileResourceTest extends PHPUnit_Smarty
|
||||
*
|
||||
*/
|
||||
public function testSmartyCurrentDir() {
|
||||
$dirname = dirname(__FILE__) . DIRECTORY_SEPARATOR . 'templates';
|
||||
$dirname = __DIR__ . DIRECTORY_SEPARATOR . 'templates';
|
||||
$this->assertEquals('current_dir = ' . $dirname, $this->smarty->fetch('001_smarty_current_dir.tpl'));
|
||||
}
|
||||
}
|
||||
|
@@ -13,12 +13,12 @@ class FileIncludePathTest extends PHPUnit_Smarty
|
||||
{
|
||||
public function setUp(): void
|
||||
{
|
||||
$this->setUpSmarty(dirname(__FILE__));
|
||||
$this->setUpSmarty(__DIR__);
|
||||
$this->smarty->use_include_path = true;
|
||||
$this->smarty->setTemplateDir(array('./templates', './templates_2', './include'));
|
||||
$this->smarty->enableSecurity();
|
||||
$ds = DIRECTORY_SEPARATOR;
|
||||
set_include_path($this->smarty->_realpath(dirname(__FILE__) . "{$ds}..{$ds}..{$ds}..{$ds}Include_Path{$ds}Tpl{$ds}", true) . PATH_SEPARATOR . get_include_path());
|
||||
set_include_path($this->smarty->_realpath(__DIR__ . "{$ds}..{$ds}..{$ds}..{$ds}Include_Path{$ds}Tpl{$ds}", true) . PATH_SEPARATOR . get_include_path());
|
||||
}
|
||||
|
||||
/**
|
||||
|
@@ -13,11 +13,11 @@ class FileResourceIndexedTest extends PHPUnit_Smarty
|
||||
{
|
||||
public function setUp(): void
|
||||
{
|
||||
$this->setUpSmarty(dirname(__FILE__));
|
||||
$this->smarty->addTemplateDir(dirname(__FILE__) . '/templates_2');
|
||||
$this->setUpSmarty(__DIR__);
|
||||
$this->smarty->addTemplateDir(__DIR__ . '/templates_2');
|
||||
// note that 10 is a string!
|
||||
$this->smarty->addTemplateDir(dirname(__FILE__) . '/templates_3', '10');
|
||||
$this->smarty->addTemplateDir(dirname(__FILE__) . '/templates_4', 'foo');
|
||||
$this->smarty->addTemplateDir(__DIR__ . '/templates_3', '10');
|
||||
$this->smarty->addTemplateDir(__DIR__ . '/templates_4', 'foo');
|
||||
}
|
||||
|
||||
public function testInit()
|
||||
|
@@ -17,7 +17,7 @@ class PhpResourceTest extends PHPUnit_Smarty
|
||||
{
|
||||
public function setUp(): void
|
||||
{
|
||||
$this->setUpSmarty(dirname(__FILE__));
|
||||
$this->setUpSmarty(__DIR__);
|
||||
}
|
||||
|
||||
public function testInit()
|
||||
@@ -27,7 +27,7 @@ class PhpResourceTest extends PHPUnit_Smarty
|
||||
|
||||
protected function relative($path)
|
||||
{
|
||||
$path = str_replace(str_replace("\\", "/", dirname(__FILE__)), '.', str_replace("\\", "/", $path));
|
||||
$path = str_replace(str_replace("\\", "/", __DIR__), '.', str_replace("\\", "/", $path));
|
||||
|
||||
return $path;
|
||||
}
|
||||
|
@@ -18,7 +18,7 @@ class RegisteredResourceTest extends PHPUnit_Smarty
|
||||
|
||||
public function setUp(): void
|
||||
{
|
||||
$this->setUpSmarty(dirname(__FILE__));
|
||||
$this->setUpSmarty(__DIR__);
|
||||
|
||||
$this->smarty->registerResource("rr", new RegisteredResourceTest_Resource1());
|
||||
}
|
||||
|
@@ -17,7 +17,7 @@ class ResourcePluginTest extends PHPUnit_Smarty
|
||||
{
|
||||
public function setUp(): void
|
||||
{
|
||||
$this->setUpSmarty(dirname(__FILE__));
|
||||
$this->setUpSmarty(__DIR__);
|
||||
}
|
||||
|
||||
public function testInit()
|
||||
|
@@ -17,7 +17,7 @@ class StreamResourceTest extends PHPUnit_Smarty
|
||||
{
|
||||
public function setUp(): void
|
||||
{
|
||||
$this->setUpSmarty(dirname(__FILE__));
|
||||
$this->setUpSmarty(__DIR__);
|
||||
|
||||
$this->smarty->assign('foo', 'bar');
|
||||
stream_wrapper_register("global", "ResourceStream")
|
||||
|
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user