mirror of
https://github.com/smarty-php/smarty.git
synced 2025-08-03 18:04:26 +02:00
Add makefile, PSR-4 ModifierCompilers
This commit is contained in:
4
.gitignore
vendored
4
.gitignore
vendored
@@ -11,3 +11,7 @@ phpunit*
|
|||||||
.phpunit.result.cache
|
.phpunit.result.cache
|
||||||
vendor/*
|
vendor/*
|
||||||
composer.lock
|
composer.lock
|
||||||
|
/src/Lexer/ConfigfileLexer.php
|
||||||
|
/src/Lexer/TemplateLexer.php
|
||||||
|
/src/Parser/ConfigfileParser.php
|
||||||
|
/src/Parser/TemplateParser.php
|
||||||
|
19
Makefile
Normal file
19
Makefile
Normal file
@@ -0,0 +1,19 @@
|
|||||||
|
all: lexers parsers
|
||||||
|
|
||||||
|
lexers: src/Lexer/ConfigfileLexer.php src/Lexer/TemplateLexer.php
|
||||||
|
parsers: src/Parser/ConfigfileParser.php src/Parser/TemplateParser.php
|
||||||
|
|
||||||
|
src/Lexer/ConfigfileLexer.php: src/Lexer/ConfigfileLexer.plex
|
||||||
|
php ./utilities/make-lexer.php src/Lexer/ConfigfileLexer.plex src/Lexer/ConfigfileLexer.php
|
||||||
|
|
||||||
|
src/Lexer/TemplateLexer.php: src/Lexer/TemplateLexer.plex
|
||||||
|
php ./utilities/make-lexer.php src/Lexer/TemplateLexer.plex src/Lexer/TemplateLexer.php
|
||||||
|
|
||||||
|
src/Parser/ConfigfileParser.php: src/Parser/ConfigfileParser.y
|
||||||
|
php ./utilities/make-parser.php src/Parser/ConfigfileParser.y src/Parser/ConfigfileParser.php
|
||||||
|
|
||||||
|
src/Parser/TemplateParser.php: src/Parser/TemplateParser.y
|
||||||
|
php ./utilities/make-parser.php src/Parser/TemplateParser.y src/Parser/TemplateParser.php
|
||||||
|
|
||||||
|
clean:
|
||||||
|
rm -f src/Lexer/ConfigfileLexer.php src/Lexer/TemplateLexer.php src/Parser/ConfigfileParser.php src/Parser/TemplateParser.php
|
8
TODO.txt
8
TODO.txt
@@ -1,9 +1,7 @@
|
|||||||
- [ ] \Smarty\Cacheresource\Base::load generates classnames that are now invalid
|
## Data, TemplateBase, Smarty, Template, Debug, DataObject mess:
|
||||||
- [ ] \Smarty\Resource\BasePlugin::load generates classnames that are now invalid
|
|
||||||
- [ ] consistent ConfigFile Configfile
|
|
||||||
|
|
||||||
- [ ] review usages of ->_getSmartyObj and ->smarty: maybe change this so we can hide more
|
- [ ] review usages of ->_getSmartyObj and ->smarty: maybe change this so we can hide more
|
||||||
- [ ] ->_objType and ->objMap
|
- [ ] ->_objType and ->objMap
|
||||||
- [ ] refactor _isTplObj, _isDataObj
|
- [ ] refactor _isTplObj, _isDataObj
|
||||||
- [ ] remove `require_once` calls from tests/*, especially where they load files from the demo dir
|
|
||||||
- [ ] look for and remove @method and @property phpdoc tags
|
- [ ] look for and remove @method and @property phpdoc tags
|
||||||
|
|
||||||
|
- [ ] remove `require_once` calls from tests/*, especially where they load files from the demo dir
|
||||||
|
@@ -36,7 +36,10 @@
|
|||||||
"autoload": {
|
"autoload": {
|
||||||
"psr-4" : {
|
"psr-4" : {
|
||||||
"Smarty\\" : "src/"
|
"Smarty\\" : "src/"
|
||||||
}
|
},
|
||||||
|
"files": [
|
||||||
|
"src/functions.php"
|
||||||
|
]
|
||||||
},
|
},
|
||||||
"extra": {
|
"extra": {
|
||||||
"branch-alias": {
|
"branch-alias": {
|
||||||
@@ -45,6 +48,12 @@
|
|||||||
},
|
},
|
||||||
"require-dev": {
|
"require-dev": {
|
||||||
"phpunit/phpunit": "^8.5 || ^7.5",
|
"phpunit/phpunit": "^8.5 || ^7.5",
|
||||||
"smarty/smarty-lexer": "^3.1"
|
"smarty/smarty-lexer": "@dev"
|
||||||
|
},
|
||||||
|
"repositories": [
|
||||||
|
{
|
||||||
|
"type": "path",
|
||||||
|
"url": "../smarty-lexer/"
|
||||||
}
|
}
|
||||||
|
]
|
||||||
}
|
}
|
||||||
|
@@ -1,28 +0,0 @@
|
|||||||
<?php
|
|
||||||
/**
|
|
||||||
* Smarty plugin
|
|
||||||
*
|
|
||||||
* @package Smarty
|
|
||||||
* @subpackage PluginsModifierCompiler
|
|
||||||
*/
|
|
||||||
/**
|
|
||||||
* Smarty count_characters modifier plugin
|
|
||||||
* Type: modifier
|
|
||||||
* Name: count_characters
|
|
||||||
* Purpose: count the number of characters in a text
|
|
||||||
*
|
|
||||||
* @link https://www.smarty.net/manual/en/language.modifier.count.characters.php count_characters (Smarty online
|
|
||||||
* manual)
|
|
||||||
* @author Uwe Tews
|
|
||||||
*
|
|
||||||
* @param array $params parameters
|
|
||||||
*
|
|
||||||
* @return string with compiled code
|
|
||||||
*/
|
|
||||||
function smarty_modifiercompiler_count_characters($params)
|
|
||||||
{
|
|
||||||
if (!isset($params[ 1 ]) || $params[ 1 ] !== 'true') {
|
|
||||||
return 'preg_match_all(\'/[^\s]/' . \Smarty\Smarty::$_UTF8_MODIFIER . '\',' . $params[ 0 ] . ', $tmp)';
|
|
||||||
}
|
|
||||||
return 'mb_strlen(' . $params[ 0 ] . ', \'' . addslashes(\Smarty\Smarty::$_CHARSET) . '\')';
|
|
||||||
}
|
|
@@ -1,26 +0,0 @@
|
|||||||
<?php
|
|
||||||
/**
|
|
||||||
* Smarty plugin
|
|
||||||
*
|
|
||||||
* @package Smarty
|
|
||||||
* @subpackage PluginsModifierCompiler
|
|
||||||
*/
|
|
||||||
/**
|
|
||||||
* Smarty count_paragraphs modifier plugin
|
|
||||||
* Type: modifier
|
|
||||||
* Name: count_paragraphs
|
|
||||||
* Purpose: count the number of paragraphs in a text
|
|
||||||
*
|
|
||||||
* @link https://www.smarty.net/manual/en/language.modifier.count.paragraphs.php
|
|
||||||
* count_paragraphs (Smarty online manual)
|
|
||||||
* @author Uwe Tews
|
|
||||||
*
|
|
||||||
* @param array $params parameters
|
|
||||||
*
|
|
||||||
* @return string with compiled code
|
|
||||||
*/
|
|
||||||
function smarty_modifiercompiler_count_paragraphs($params)
|
|
||||||
{
|
|
||||||
// count \r or \n characters
|
|
||||||
return '(preg_match_all(\'#[\r\n]+#\', ' . $params[ 0 ] . ', $tmp)+1)';
|
|
||||||
}
|
|
@@ -1,26 +0,0 @@
|
|||||||
<?php
|
|
||||||
/**
|
|
||||||
* Smarty plugin
|
|
||||||
*
|
|
||||||
* @package Smarty
|
|
||||||
* @subpackage PluginsModifierCompiler
|
|
||||||
*/
|
|
||||||
/**
|
|
||||||
* Smarty count_sentences modifier plugin
|
|
||||||
* Type: modifier
|
|
||||||
* Name: count_sentences
|
|
||||||
* Purpose: count the number of sentences in a text
|
|
||||||
*
|
|
||||||
* @link https://www.smarty.net/manual/en/language.modifier.count.paragraphs.php
|
|
||||||
* count_sentences (Smarty online manual)
|
|
||||||
* @author Uwe Tews
|
|
||||||
*
|
|
||||||
* @param array $params parameters
|
|
||||||
*
|
|
||||||
* @return string with compiled code
|
|
||||||
*/
|
|
||||||
function smarty_modifiercompiler_count_sentences($params)
|
|
||||||
{
|
|
||||||
// find periods, question marks, exclamation marks with a word before but not after.
|
|
||||||
return 'preg_match_all("#\w[\.\?\!](\W|$)#S' . \Smarty\Smarty::$_UTF8_MODIFIER . '", ' . $params[ 0 ] . ', $tmp)';
|
|
||||||
}
|
|
@@ -1,26 +0,0 @@
|
|||||||
<?php
|
|
||||||
/**
|
|
||||||
* Smarty plugin
|
|
||||||
*
|
|
||||||
* @package Smarty
|
|
||||||
* @subpackage PluginsModifierCompiler
|
|
||||||
*/
|
|
||||||
/**
|
|
||||||
* Smarty count_words modifier plugin
|
|
||||||
* Type: modifier
|
|
||||||
* Name: count_words
|
|
||||||
* Purpose: count the number of words in a text
|
|
||||||
*
|
|
||||||
* @link https://www.smarty.net/manual/en/language.modifier.count.words.php count_words (Smarty online manual)
|
|
||||||
* @author Uwe Tews
|
|
||||||
*
|
|
||||||
* @param array $params parameters
|
|
||||||
*
|
|
||||||
* @return string with compiled code
|
|
||||||
*/
|
|
||||||
function smarty_modifiercompiler_count_words($params)
|
|
||||||
{
|
|
||||||
// expression taken from http://de.php.net/manual/en/function.str-word-count.php#85592
|
|
||||||
return 'preg_match_all(\'/\p{L}[\p{L}\p{Mn}\p{Pd}\\\'\x{2019}]*/' . \Smarty\Smarty::$_UTF8_MODIFIER . '\', ' .
|
|
||||||
$params[ 0 ] . ', $tmp)';
|
|
||||||
}
|
|
@@ -1,32 +0,0 @@
|
|||||||
<?php
|
|
||||||
/**
|
|
||||||
* Smarty plugin
|
|
||||||
*
|
|
||||||
* @package Smarty
|
|
||||||
* @subpackage PluginsModifierCompiler
|
|
||||||
*/
|
|
||||||
/**
|
|
||||||
* Smarty default modifier plugin
|
|
||||||
* Type: modifier
|
|
||||||
* Name: default
|
|
||||||
* Purpose: designate default value for empty variables
|
|
||||||
*
|
|
||||||
* @link https://www.smarty.net/manual/en/language.modifier.default.php default (Smarty online manual)
|
|
||||||
* @author Uwe Tews
|
|
||||||
*
|
|
||||||
* @param array $params parameters
|
|
||||||
*
|
|
||||||
* @return string with compiled code
|
|
||||||
*/
|
|
||||||
function smarty_modifiercompiler_default($params)
|
|
||||||
{
|
|
||||||
$output = $params[ 0 ];
|
|
||||||
if (!isset($params[ 1 ])) {
|
|
||||||
$params[ 1 ] = "''";
|
|
||||||
}
|
|
||||||
array_shift($params);
|
|
||||||
foreach ($params as $param) {
|
|
||||||
$output = '(($tmp = ' . $output . ' ?? null)===null||$tmp===\'\' ? ' . $param . ' ?? null : $tmp)';
|
|
||||||
}
|
|
||||||
return $output;
|
|
||||||
}
|
|
@@ -1,63 +0,0 @@
|
|||||||
<?php
|
|
||||||
/**
|
|
||||||
* Smarty plugin
|
|
||||||
*
|
|
||||||
* @package Smarty
|
|
||||||
* @subpackage PluginsModifierCompiler
|
|
||||||
*/
|
|
||||||
|
|
||||||
use Smarty\Exception;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Smarty escape modifier plugin
|
|
||||||
* Type: modifier
|
|
||||||
* Name: escape
|
|
||||||
* Purpose: escape string for output
|
|
||||||
*
|
|
||||||
* @link https://www.smarty.net/docsv2/en/language.modifier.escape count_characters (Smarty online manual)
|
|
||||||
* @author Rodney Rehm
|
|
||||||
*
|
|
||||||
* @param array $params parameters
|
|
||||||
* @param \Smarty\Compiler\Template $compiler
|
|
||||||
*
|
|
||||||
* @return string with compiled code
|
|
||||||
* @throws Exception
|
|
||||||
*/
|
|
||||||
function smarty_modifiercompiler_escape($params, \Smarty\Compiler\Template $compiler)
|
|
||||||
{
|
|
||||||
try {
|
|
||||||
$esc_type = smarty_literal_compiler_param($params, 1, 'html');
|
|
||||||
$char_set = smarty_literal_compiler_param($params, 2, \Smarty\Smarty::$_CHARSET);
|
|
||||||
$double_encode = smarty_literal_compiler_param($params, 3, true);
|
|
||||||
if (!$char_set) {
|
|
||||||
$char_set = \Smarty\Smarty::$_CHARSET;
|
|
||||||
}
|
|
||||||
switch ($esc_type) {
|
|
||||||
case 'html':
|
|
||||||
return 'htmlspecialchars((string)' . $params[ 0 ] . ', ENT_QUOTES, ' . var_export($char_set, true) . ', ' .
|
|
||||||
var_export($double_encode, true) . ')';
|
|
||||||
// no break
|
|
||||||
case 'htmlall':
|
|
||||||
return 'htmlentities(mb_convert_encoding((string)' . $params[ 0 ] . ', \'UTF-8\', ' .
|
|
||||||
var_export($char_set, true) . '), ENT_QUOTES, \'UTF-8\', ' .
|
|
||||||
var_export($double_encode, true) . ')';
|
|
||||||
// no break
|
|
||||||
case 'url':
|
|
||||||
return 'rawurlencode((string)' . $params[ 0 ] . ')';
|
|
||||||
case 'urlpathinfo':
|
|
||||||
return 'str_replace("%2F", "/", rawurlencode((string)' . $params[ 0 ] . '))';
|
|
||||||
case 'quotes':
|
|
||||||
// escape unescaped single quotes
|
|
||||||
return 'preg_replace("%(?<!\\\\\\\\)\'%", "\\\'", (string)' . $params[ 0 ] . ')';
|
|
||||||
case 'javascript':
|
|
||||||
// escape quotes and backslashes, newlines, etc.
|
|
||||||
// see https://html.spec.whatwg.org/multipage/scripting.html#restrictions-for-contents-of-script-elements
|
|
||||||
return 'strtr((string)' .
|
|
||||||
$params[ 0 ] .
|
|
||||||
', array("\\\\" => "\\\\\\\\", "\'" => "\\\\\'", "\"" => "\\\\\"", "\\r" => "\\\\r", "\\n" => "\\\n", "</" => "<\/", "<!--" => "<\!--", "<s" => "<\s", "<S" => "<\S" ))';
|
|
||||||
}
|
|
||||||
} catch (Exception $e) {
|
|
||||||
// pass through to regular plugin fallback
|
|
||||||
}
|
|
||||||
return 'smarty_modifier_escape(' . join(', ', $params) . ')';
|
|
||||||
}
|
|
@@ -1,26 +0,0 @@
|
|||||||
<?php
|
|
||||||
/**
|
|
||||||
* Smarty plugin
|
|
||||||
*
|
|
||||||
* @package Smarty
|
|
||||||
* @subpackage PluginsModifierCompiler
|
|
||||||
*/
|
|
||||||
/**
|
|
||||||
* Smarty from_charset modifier plugin
|
|
||||||
* Type: modifier
|
|
||||||
* Name: from_charset
|
|
||||||
* Purpose: convert character encoding from $charset to internal encoding
|
|
||||||
*
|
|
||||||
* @author Rodney Rehm
|
|
||||||
*
|
|
||||||
* @param array $params parameters
|
|
||||||
*
|
|
||||||
* @return string with compiled code
|
|
||||||
*/
|
|
||||||
function smarty_modifiercompiler_from_charset($params)
|
|
||||||
{
|
|
||||||
if (!isset($params[ 1 ])) {
|
|
||||||
$params[ 1 ] = '"ISO-8859-1"';
|
|
||||||
}
|
|
||||||
return 'mb_convert_encoding(' . $params[ 0 ] . ', "' . addslashes(\Smarty\Smarty::$_CHARSET) . '", ' . $params[ 1 ] . ')';
|
|
||||||
}
|
|
@@ -1,30 +0,0 @@
|
|||||||
<?php
|
|
||||||
/**
|
|
||||||
* Smarty plugin
|
|
||||||
*
|
|
||||||
* @package Smarty
|
|
||||||
* @subpackage PluginsModifierCompiler
|
|
||||||
*/
|
|
||||||
/**
|
|
||||||
* Smarty indent modifier plugin
|
|
||||||
* Type: modifier
|
|
||||||
* Name: indent
|
|
||||||
* Purpose: indent lines of text
|
|
||||||
*
|
|
||||||
* @link https://www.smarty.net/manual/en/language.modifier.indent.php indent (Smarty online manual)
|
|
||||||
* @author Uwe Tews
|
|
||||||
*
|
|
||||||
* @param array $params parameters
|
|
||||||
*
|
|
||||||
* @return string with compiled code
|
|
||||||
*/
|
|
||||||
function smarty_modifiercompiler_indent($params)
|
|
||||||
{
|
|
||||||
if (!isset($params[ 1 ])) {
|
|
||||||
$params[ 1 ] = 4;
|
|
||||||
}
|
|
||||||
if (!isset($params[ 2 ])) {
|
|
||||||
$params[ 2 ] = "' '";
|
|
||||||
}
|
|
||||||
return 'preg_replace(\'!^!m\',str_repeat(' . $params[ 2 ] . ',' . $params[ 1 ] . '),' . $params[ 0 ] . ')';
|
|
||||||
}
|
|
@@ -1,25 +0,0 @@
|
|||||||
<?php
|
|
||||||
/**
|
|
||||||
* Smarty plugin
|
|
||||||
*
|
|
||||||
* @package Smarty
|
|
||||||
* @subpackage PluginsModifierCompiler
|
|
||||||
*/
|
|
||||||
/**
|
|
||||||
* Smarty lower modifier plugin
|
|
||||||
* Type: modifier
|
|
||||||
* Name: lower
|
|
||||||
* Purpose: convert string to lowercase
|
|
||||||
*
|
|
||||||
* @link https://www.smarty.net/manual/en/language.modifier.lower.php lower (Smarty online manual)
|
|
||||||
* @author Monte Ohrt <monte at ohrt dot com>
|
|
||||||
* @author Uwe Tews
|
|
||||||
*
|
|
||||||
* @param array $params parameters
|
|
||||||
*
|
|
||||||
* @return string with compiled code
|
|
||||||
*/
|
|
||||||
function smarty_modifiercompiler_lower($params)
|
|
||||||
{
|
|
||||||
return 'mb_strtolower(' . $params[ 0 ] . ', \'' . addslashes(\Smarty\Smarty::$_CHARSET) . '\')';
|
|
||||||
}
|
|
@@ -1,23 +0,0 @@
|
|||||||
<?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) . ')';
|
|
||||||
}
|
|
@@ -1,20 +0,0 @@
|
|||||||
<?php
|
|
||||||
/**
|
|
||||||
* Smarty plugin
|
|
||||||
*
|
|
||||||
* @package Smarty
|
|
||||||
* @subpackage PluginsModifierCompiler
|
|
||||||
*/
|
|
||||||
/**
|
|
||||||
* Smarty noprint modifier plugin
|
|
||||||
* Type: modifier
|
|
||||||
* Name: noprint
|
|
||||||
* Purpose: return an empty string
|
|
||||||
*
|
|
||||||
* @author Uwe Tews
|
|
||||||
* @return string with compiled code
|
|
||||||
*/
|
|
||||||
function smarty_modifiercompiler_noprint()
|
|
||||||
{
|
|
||||||
return "''";
|
|
||||||
}
|
|
@@ -1,23 +0,0 @@
|
|||||||
<?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) . ')';
|
|
||||||
}
|
|
@@ -1,23 +0,0 @@
|
|||||||
<?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] . ')';
|
|
||||||
}
|
|
@@ -1,24 +0,0 @@
|
|||||||
<?php
|
|
||||||
/**
|
|
||||||
* Smarty plugin
|
|
||||||
*
|
|
||||||
* @package Smarty
|
|
||||||
* @subpackage PluginsModifierCompiler
|
|
||||||
*/
|
|
||||||
/**
|
|
||||||
* Smarty string_format modifier plugin
|
|
||||||
* Type: modifier
|
|
||||||
* Name: string_format
|
|
||||||
* Purpose: format strings via sprintf
|
|
||||||
*
|
|
||||||
* @link https://www.smarty.net/manual/en/language.modifier.string.format.php string_format (Smarty online manual)
|
|
||||||
* @author Uwe Tews
|
|
||||||
*
|
|
||||||
* @param array $params parameters
|
|
||||||
*
|
|
||||||
* @return string with compiled code
|
|
||||||
*/
|
|
||||||
function smarty_modifiercompiler_string_format($params)
|
|
||||||
{
|
|
||||||
return 'sprintf(' . $params[ 1 ] . ',' . $params[ 0 ] . ')';
|
|
||||||
}
|
|
@@ -1,28 +0,0 @@
|
|||||||
<?php
|
|
||||||
/**
|
|
||||||
* Smarty plugin
|
|
||||||
*
|
|
||||||
* @package Smarty
|
|
||||||
* @subpackage PluginsModifierCompiler
|
|
||||||
*/
|
|
||||||
/**
|
|
||||||
* Smarty strip_tags modifier plugin
|
|
||||||
* Type: modifier
|
|
||||||
* Name: strip_tags
|
|
||||||
* Purpose: strip html tags from text
|
|
||||||
*
|
|
||||||
* @link https://www.smarty.net/docs/en/language.modifier.strip.tags.tpl strip_tags (Smarty online manual)
|
|
||||||
* @author Uwe Tews
|
|
||||||
*
|
|
||||||
* @param array $params parameters
|
|
||||||
*
|
|
||||||
* @return string with compiled code
|
|
||||||
*/
|
|
||||||
function smarty_modifiercompiler_strip_tags($params)
|
|
||||||
{
|
|
||||||
if (!isset($params[ 1 ]) || $params[ 1 ] === true || trim($params[ 1 ], '"') === 'true') {
|
|
||||||
return "preg_replace('!<[^>]*?>!', ' ', {$params[0]} ?: '')";
|
|
||||||
} else {
|
|
||||||
return 'strip_tags((string) ' . $params[ 0 ] . ')';
|
|
||||||
}
|
|
||||||
}
|
|
@@ -1,23 +0,0 @@
|
|||||||
<?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] . ')';
|
|
||||||
}
|
|
@@ -1,26 +0,0 @@
|
|||||||
<?php
|
|
||||||
/**
|
|
||||||
* Smarty plugin
|
|
||||||
*
|
|
||||||
* @package Smarty
|
|
||||||
* @subpackage PluginsModifierCompiler
|
|
||||||
*/
|
|
||||||
/**
|
|
||||||
* Smarty to_charset modifier plugin
|
|
||||||
* Type: modifier
|
|
||||||
* Name: to_charset
|
|
||||||
* Purpose: convert character encoding from internal encoding to $charset
|
|
||||||
*
|
|
||||||
* @author Rodney Rehm
|
|
||||||
*
|
|
||||||
* @param array $params parameters
|
|
||||||
*
|
|
||||||
* @return string with compiled code
|
|
||||||
*/
|
|
||||||
function smarty_modifiercompiler_to_charset($params)
|
|
||||||
{
|
|
||||||
if (!isset($params[ 1 ])) {
|
|
||||||
$params[ 1 ] = '"ISO-8859-1"';
|
|
||||||
}
|
|
||||||
return 'mb_convert_encoding(' . $params[ 0 ] . ', ' . $params[ 1 ] . ', "' . addslashes(\Smarty\Smarty::$_CHARSET) . '")';
|
|
||||||
}
|
|
@@ -1,40 +0,0 @@
|
|||||||
<?php
|
|
||||||
/**
|
|
||||||
* Smarty plugin
|
|
||||||
*
|
|
||||||
* @package Smarty
|
|
||||||
* @subpackage PluginsModifierCompiler
|
|
||||||
*/
|
|
||||||
/**
|
|
||||||
* Smarty unescape modifier plugin
|
|
||||||
* Type: modifier
|
|
||||||
* Name: unescape
|
|
||||||
* Purpose: unescape html entities
|
|
||||||
*
|
|
||||||
* @author Rodney Rehm
|
|
||||||
*
|
|
||||||
* @param array $params parameters
|
|
||||||
* @param \Smarty\Compiler\Template $compiler
|
|
||||||
*
|
|
||||||
* @return string with compiled code
|
|
||||||
*/
|
|
||||||
function smarty_modifiercompiler_unescape($params, \Smarty\Compiler\Template $compiler)
|
|
||||||
{
|
|
||||||
$esc_type = smarty_literal_compiler_param($params, 1, 'html');
|
|
||||||
|
|
||||||
if (!isset($params[ 2 ])) {
|
|
||||||
$params[ 2 ] = '\'' . addslashes(\Smarty\Smarty::$_CHARSET) . '\'';
|
|
||||||
}
|
|
||||||
|
|
||||||
switch ($esc_type) {
|
|
||||||
case 'entity':
|
|
||||||
case 'htmlall':
|
|
||||||
return 'html_entity_decode(mb_convert_encoding(' . $params[ 0 ] . ', ' . $params[ 2 ] . ', \'UTF-8\'), ENT_QUOTES | ENT_SUBSTITUTE | ENT_HTML401, ' . $params[ 2 ] . ')';
|
|
||||||
case 'html':
|
|
||||||
return 'htmlspecialchars_decode(' . $params[ 0 ] . ', ENT_QUOTES)';
|
|
||||||
case 'url':
|
|
||||||
return 'rawurldecode(' . $params[ 0 ] . ')';
|
|
||||||
default:
|
|
||||||
return $params[ 0 ];
|
|
||||||
}
|
|
||||||
}
|
|
@@ -1,24 +0,0 @@
|
|||||||
<?php
|
|
||||||
/**
|
|
||||||
* Smarty plugin
|
|
||||||
*
|
|
||||||
* @package Smarty
|
|
||||||
* @subpackage PluginsModifierCompiler
|
|
||||||
*/
|
|
||||||
/**
|
|
||||||
* Smarty upper modifier plugin
|
|
||||||
* Type: modifier
|
|
||||||
* Name: lower
|
|
||||||
* Purpose: convert string to uppercase
|
|
||||||
*
|
|
||||||
* @link https://www.smarty.net/manual/en/language.modifier.upper.php lower (Smarty online manual)
|
|
||||||
* @author Uwe Tews
|
|
||||||
*
|
|
||||||
* @param array $params parameters
|
|
||||||
*
|
|
||||||
* @return string with compiled code
|
|
||||||
*/
|
|
||||||
function smarty_modifiercompiler_upper($params)
|
|
||||||
{
|
|
||||||
return 'mb_strtoupper(' . $params[ 0 ] . ' ?? \'\', \'' . addslashes(\Smarty\Smarty::$_CHARSET) . '\')';
|
|
||||||
}
|
|
@@ -1,36 +0,0 @@
|
|||||||
<?php
|
|
||||||
/**
|
|
||||||
* Smarty plugin
|
|
||||||
*
|
|
||||||
* @package Smarty
|
|
||||||
* @subpackage PluginsModifierCompiler
|
|
||||||
*/
|
|
||||||
/**
|
|
||||||
* Smarty wordwrap modifier plugin
|
|
||||||
* Type: modifier
|
|
||||||
* Name: wordwrap
|
|
||||||
* Purpose: wrap a string of text at a given length
|
|
||||||
*
|
|
||||||
* @link https://www.smarty.net/manual/en/language.modifier.wordwrap.php wordwrap (Smarty online manual)
|
|
||||||
* @author Uwe Tews
|
|
||||||
*
|
|
||||||
* @param array $params parameters
|
|
||||||
* @param \Smarty\Compiler\Template $compiler
|
|
||||||
*
|
|
||||||
* @return string with compiled code
|
|
||||||
* @throws \Smarty\Exception
|
|
||||||
*/
|
|
||||||
function smarty_modifiercompiler_wordwrap($params, \Smarty\Compiler\Template $compiler)
|
|
||||||
{
|
|
||||||
if (!isset($params[ 1 ])) {
|
|
||||||
$params[ 1 ] = 80;
|
|
||||||
}
|
|
||||||
if (!isset($params[ 2 ])) {
|
|
||||||
$params[ 2 ] = '"\n"';
|
|
||||||
}
|
|
||||||
if (!isset($params[ 3 ])) {
|
|
||||||
$params[ 3 ] = 'false';
|
|
||||||
}
|
|
||||||
$function = $compiler->getPlugin('mb_wordwrap', 'modifier');
|
|
||||||
return $function . '(' . $params[ 0 ] . ',' . $params[ 1 ] . ',' . $params[ 2 ] . ',' . $params[ 3 ] . ')';
|
|
||||||
}
|
|
@@ -1,38 +0,0 @@
|
|||||||
<?php
|
|
||||||
/**
|
|
||||||
* Smarty plugin
|
|
||||||
*
|
|
||||||
* @package Smarty
|
|
||||||
* @subpackage PluginsShared
|
|
||||||
*/
|
|
||||||
|
|
||||||
use Smarty\Exception;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* evaluate compiler parameter
|
|
||||||
*
|
|
||||||
* @param array $params parameter array as given to the compiler function
|
|
||||||
* @param integer $index array index of the parameter to convert
|
|
||||||
* @param mixed $default value to be returned if the parameter is not present
|
|
||||||
*
|
|
||||||
* @return mixed evaluated value of parameter or $default
|
|
||||||
* @throws Exception if parameter is not a literal (but an expression, variable, …)
|
|
||||||
* @author Rodney Rehm
|
|
||||||
*/
|
|
||||||
function smarty_literal_compiler_param($params, $index, $default = null)
|
|
||||||
{
|
|
||||||
// not set, go default
|
|
||||||
if (!isset($params[ $index ])) {
|
|
||||||
return $default;
|
|
||||||
}
|
|
||||||
// test if param is a literal
|
|
||||||
if (!preg_match('/^([\'"]?)[a-zA-Z0-9-]+(\\1)$/', $params[ $index ])) {
|
|
||||||
throw new Exception(
|
|
||||||
'$param[' . $index .
|
|
||||||
'] is not a literal and is thus not evaluatable at compile time'
|
|
||||||
);
|
|
||||||
}
|
|
||||||
$t = null;
|
|
||||||
eval("\$t = " . $params[ $index ] . ";");
|
|
||||||
return $t;
|
|
||||||
}
|
|
@@ -27,7 +27,7 @@ abstract class Base
|
|||||||
*
|
*
|
||||||
* @var array
|
* @var array
|
||||||
*/
|
*/
|
||||||
protected static $sysplugins = array('file' => 'File.php',);
|
protected static $sysplugins = ['file' => \Smarty\Cacheresource\File::class];
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* populate Cached Object with meta data from Resource
|
* populate Cached Object with meta data from Resource
|
||||||
@@ -211,7 +211,7 @@ abstract class Base
|
|||||||
}
|
}
|
||||||
// try sysplugins dir
|
// try sysplugins dir
|
||||||
if (isset(self::$sysplugins[ $type ])) {
|
if (isset(self::$sysplugins[ $type ])) {
|
||||||
$cache_resource_class = 'Smarty_Internal_CacheResource_' . \smarty_ucfirst_ascii($type);
|
$cache_resource_class = self::$sysplugins[ $type ];
|
||||||
return $smarty->_cacheresource_handlers[ $type ] = new $cache_resource_class();
|
return $smarty->_cacheresource_handlers[ $type ] = new $cache_resource_class();
|
||||||
}
|
}
|
||||||
// try plugins dir
|
// try plugins dir
|
||||||
|
@@ -1,91 +0,0 @@
|
|||||||
<?php
|
|
||||||
/**
|
|
||||||
* Smarty Internal Plugin Compile Function_Call
|
|
||||||
* Compiles the calls of user defined tags defined by {function}
|
|
||||||
*
|
|
||||||
* @package Smarty
|
|
||||||
* @subpackage Compiler
|
|
||||||
* @author Uwe Tews
|
|
||||||
*/
|
|
||||||
|
|
||||||
use Smarty\Compile\Base;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Smarty Internal Plugin Compile Function_Call Class
|
|
||||||
*
|
|
||||||
* @package Smarty
|
|
||||||
* @subpackage Compiler
|
|
||||||
*/
|
|
||||||
class Call extends Base
|
|
||||||
{
|
|
||||||
/**
|
|
||||||
* Attribute definition: Overwrites base class.
|
|
||||||
*
|
|
||||||
* @var array
|
|
||||||
* @see Base
|
|
||||||
*/
|
|
||||||
public $required_attributes = array('name');
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Attribute definition: Overwrites base class.
|
|
||||||
*
|
|
||||||
* @var array
|
|
||||||
* @see Base
|
|
||||||
*/
|
|
||||||
public $shorttag_order = array('name');
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Attribute definition: Overwrites base class.
|
|
||||||
*
|
|
||||||
* @var array
|
|
||||||
* @see Base
|
|
||||||
*/
|
|
||||||
public $optional_attributes = array('_any');
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Compiles the calls of user defined tags defined by {function}
|
|
||||||
*
|
|
||||||
* @param array $args array with attributes from parser
|
|
||||||
* @param object $compiler compiler object
|
|
||||||
*
|
|
||||||
* @return string compiled code
|
|
||||||
*/
|
|
||||||
public function compile($args, \Smarty\Compiler\Template $compiler, $parameter = array(), $tag = null, $function = null)
|
|
||||||
{
|
|
||||||
// check and get attributes
|
|
||||||
$_attr = $this->getAttributes($compiler, $args);
|
|
||||||
// save possible attributes
|
|
||||||
if (isset($_attr[ 'assign' ])) {
|
|
||||||
// output will be stored in a smarty variable instead of being displayed
|
|
||||||
$_assign = $_attr[ 'assign' ];
|
|
||||||
}
|
|
||||||
//$_name = trim($_attr['name'], "''");
|
|
||||||
$_name = $_attr[ 'name' ];
|
|
||||||
unset($_attr[ 'name' ], $_attr[ 'assign' ], $_attr[ 'nocache' ]);
|
|
||||||
// set flag (compiled code of {function} must be included in cache file
|
|
||||||
if (!$compiler->template->caching || $compiler->nocache || $compiler->tag_nocache) {
|
|
||||||
$_nocache = 'true';
|
|
||||||
} else {
|
|
||||||
$_nocache = 'false';
|
|
||||||
}
|
|
||||||
$_paramsArray = array();
|
|
||||||
foreach ($_attr as $_key => $_value) {
|
|
||||||
if (is_int($_key)) {
|
|
||||||
$_paramsArray[] = "$_key=>$_value";
|
|
||||||
} else {
|
|
||||||
$_paramsArray[] = "'$_key'=>$_value";
|
|
||||||
}
|
|
||||||
}
|
|
||||||
$_params = 'array(' . implode(',', $_paramsArray) . ')';
|
|
||||||
//$compiler->suppressNocacheProcessing = true;
|
|
||||||
// was there an assign attribute
|
|
||||||
if (isset($_assign)) {
|
|
||||||
$_output =
|
|
||||||
"<?php ob_start();\n\$_smarty_tpl->smarty->getRuntime('TplFunction')->callTemplateFunction(\$_smarty_tpl, {$_name}, {$_params}, {$_nocache});\n\$_smarty_tpl->assign({$_assign}, ob_get_clean());?>\n";
|
|
||||||
} else {
|
|
||||||
$_output =
|
|
||||||
"<?php \$_smarty_tpl->smarty->getRuntime('TplFunction')->callTemplateFunction(\$_smarty_tpl, {$_name}, {$_params}, {$_nocache});?>\n";
|
|
||||||
}
|
|
||||||
return $_output;
|
|
||||||
}
|
|
||||||
}
|
|
49
src/Compile/Modifier/Base.php
Normal file
49
src/Compile/Modifier/Base.php
Normal file
@@ -0,0 +1,49 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace Smarty\Compile\Modifier;
|
||||||
|
|
||||||
|
use Smarty\Exception;
|
||||||
|
|
||||||
|
abstract class Base {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Compiles code for the modifier
|
||||||
|
*
|
||||||
|
* @param array $params array with attributes from parser
|
||||||
|
* @param \Smarty\Compiler\Template $compiler compiler object
|
||||||
|
*
|
||||||
|
* @return string compiled code
|
||||||
|
* @throws \Smarty\CompilerException
|
||||||
|
*/
|
||||||
|
abstract public function compile($params, \Smarty\Compiler\Template $compiler);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* evaluate compiler parameter
|
||||||
|
*
|
||||||
|
* @param array $params parameter array as given to the compiler function
|
||||||
|
* @param integer $index array index of the parameter to convert
|
||||||
|
* @param mixed $default value to be returned if the parameter is not present
|
||||||
|
*
|
||||||
|
* @return mixed evaluated value of parameter or $default
|
||||||
|
* @throws Exception if parameter is not a literal (but an expression, variable, …)
|
||||||
|
* @author Rodney Rehm
|
||||||
|
*/
|
||||||
|
protected function literal_compiler_param($params, $index, $default = null)
|
||||||
|
{
|
||||||
|
// not set, go default
|
||||||
|
if (!isset($params[ $index ])) {
|
||||||
|
return $default;
|
||||||
|
}
|
||||||
|
// test if param is a literal
|
||||||
|
if (!preg_match('/^([\'"]?)[a-zA-Z0-9-]+(\\1)$/', $params[ $index ])) {
|
||||||
|
throw new Exception(
|
||||||
|
'$param[' . $index .
|
||||||
|
'] is not a literal and is thus not evaluatable at compile time'
|
||||||
|
);
|
||||||
|
}
|
||||||
|
$t = null;
|
||||||
|
eval("\$t = " . $params[ $index ] . ";");
|
||||||
|
return $t;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@@ -1,10 +1,7 @@
|
|||||||
<?php
|
<?php
|
||||||
/**
|
|
||||||
* Smarty plugin
|
namespace Smarty\Compile\Modifier;
|
||||||
*
|
|
||||||
* @package Smarty
|
|
||||||
* @subpackage PluginsModifierCompiler
|
|
||||||
*/
|
|
||||||
/**
|
/**
|
||||||
* Smarty cat modifier plugin
|
* Smarty cat modifier plugin
|
||||||
* Type: modifier
|
* Type: modifier
|
||||||
@@ -17,12 +14,14 @@
|
|||||||
* @link https://www.smarty.net/manual/en/language.modifier.cat.php cat
|
* @link https://www.smarty.net/manual/en/language.modifier.cat.php cat
|
||||||
* (Smarty online manual)
|
* (Smarty online manual)
|
||||||
* @author Uwe Tews
|
* @author Uwe Tews
|
||||||
*
|
|
||||||
* @param array $params parameters
|
|
||||||
*
|
|
||||||
* @return string with compiled code
|
|
||||||
*/
|
*/
|
||||||
function smarty_modifiercompiler_cat($params)
|
|
||||||
{
|
class CatModifierCompiler extends Base {
|
||||||
|
|
||||||
|
public function compile($params, \Smarty\Compiler\Template $compiler) {
|
||||||
return '(' . implode(').(', $params) . ')';
|
return '(' . implode(').(', $params) . ')';
|
||||||
}
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
23
src/Compile/Modifier/CountCharactersModifierCompiler.php
Normal file
23
src/Compile/Modifier/CountCharactersModifierCompiler.php
Normal file
@@ -0,0 +1,23 @@
|
|||||||
|
<?php
|
||||||
|
namespace Smarty\Compile\Modifier;
|
||||||
|
/**
|
||||||
|
* Smarty count_characters modifier plugin
|
||||||
|
* Type: modifier
|
||||||
|
* Name: count_characters
|
||||||
|
* Purpose: count the number of characters in a text
|
||||||
|
*
|
||||||
|
* @link https://www.smarty.net/manual/en/language.modifier.count.characters.php count_characters (Smarty online
|
||||||
|
* manual)
|
||||||
|
* @author Uwe Tews
|
||||||
|
*/
|
||||||
|
|
||||||
|
class CountCharactersModifierCompiler extends Base {
|
||||||
|
|
||||||
|
public function compile($params, \Smarty\Compiler\Template $compiler) {
|
||||||
|
if (!isset($params[ 1 ]) || $params[ 1 ] !== 'true') {
|
||||||
|
return 'preg_match_all(\'/[^\s]/' . \Smarty\Smarty::$_UTF8_MODIFIER . '\',' . $params[ 0 ] . ', $tmp)';
|
||||||
|
}
|
||||||
|
return 'mb_strlen(' . $params[ 0 ] . ', \'' . addslashes(\Smarty\Smarty::$_CHARSET) . '\')';
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
21
src/Compile/Modifier/CountParagraphsModifierCompiler.php
Normal file
21
src/Compile/Modifier/CountParagraphsModifierCompiler.php
Normal file
@@ -0,0 +1,21 @@
|
|||||||
|
<?php
|
||||||
|
namespace Smarty\Compile\Modifier;
|
||||||
|
/**
|
||||||
|
* Smarty count_paragraphs modifier plugin
|
||||||
|
* Type: modifier
|
||||||
|
* Name: count_paragraphs
|
||||||
|
* Purpose: count the number of paragraphs in a text
|
||||||
|
*
|
||||||
|
* @link https://www.smarty.net/manual/en/language.modifier.count.paragraphs.php
|
||||||
|
* count_paragraphs (Smarty online manual)
|
||||||
|
* @author Uwe Tews
|
||||||
|
*/
|
||||||
|
|
||||||
|
class CountParagraphsModifierCompiler extends Base {
|
||||||
|
|
||||||
|
public function compile($params, \Smarty\Compiler\Template $compiler) {
|
||||||
|
// count \r or \n characters
|
||||||
|
return '(preg_match_all(\'#[\r\n]+#\', ' . $params[ 0 ] . ', $tmp)+1)';
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
21
src/Compile/Modifier/CountSentencesModifierCompiler.php
Normal file
21
src/Compile/Modifier/CountSentencesModifierCompiler.php
Normal file
@@ -0,0 +1,21 @@
|
|||||||
|
<?php
|
||||||
|
namespace Smarty\Compile\Modifier;
|
||||||
|
/**
|
||||||
|
* Smarty count_sentences modifier plugin
|
||||||
|
* Type: modifier
|
||||||
|
* Name: count_sentences
|
||||||
|
* Purpose: count the number of sentences in a text
|
||||||
|
*
|
||||||
|
* @link https://www.smarty.net/manual/en/language.modifier.count.paragraphs.php
|
||||||
|
* count_sentences (Smarty online manual)
|
||||||
|
* @author Uwe Tews
|
||||||
|
*/
|
||||||
|
|
||||||
|
class CountSentencesModifierCompiler extends Base {
|
||||||
|
|
||||||
|
public function compile($params, \Smarty\Compiler\Template $compiler) {
|
||||||
|
// find periods, question marks, exclamation marks with a word before but not after.
|
||||||
|
return 'preg_match_all("#\w[\.\?\!](\W|$)#S' . \Smarty\Smarty::$_UTF8_MODIFIER . '", ' . $params[ 0 ] . ', $tmp)';
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
21
src/Compile/Modifier/CountWordsModifierCompiler.php
Normal file
21
src/Compile/Modifier/CountWordsModifierCompiler.php
Normal file
@@ -0,0 +1,21 @@
|
|||||||
|
<?php
|
||||||
|
namespace Smarty\Compile\Modifier;
|
||||||
|
/**
|
||||||
|
* Smarty count_words modifier plugin
|
||||||
|
* Type: modifier
|
||||||
|
* Name: count_words
|
||||||
|
* Purpose: count the number of words in a text
|
||||||
|
*
|
||||||
|
* @link https://www.smarty.net/manual/en/language.modifier.count.words.php count_words (Smarty online manual)
|
||||||
|
* @author Uwe Tews
|
||||||
|
*/
|
||||||
|
|
||||||
|
class CountWordsModifierCompiler extends Base {
|
||||||
|
|
||||||
|
public function compile($params, \Smarty\Compiler\Template $compiler) {
|
||||||
|
// expression taken from http://de.php.net/manual/en/function.str-word-count.php#85592
|
||||||
|
return 'preg_match_all(\'/\p{L}[\p{L}\p{Mn}\p{Pd}\\\'\x{2019}]*/' . \Smarty\Smarty::$_UTF8_MODIFIER . '\', ' .
|
||||||
|
$params[ 0 ] . ', $tmp)';
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
27
src/Compile/Modifier/DefaultModifierCompiler.php
Normal file
27
src/Compile/Modifier/DefaultModifierCompiler.php
Normal file
@@ -0,0 +1,27 @@
|
|||||||
|
<?php
|
||||||
|
namespace Smarty\Compile\Modifier;
|
||||||
|
/**
|
||||||
|
* Smarty default modifier plugin
|
||||||
|
* Type: modifier
|
||||||
|
* Name: default
|
||||||
|
* Purpose: designate default value for empty variables
|
||||||
|
*
|
||||||
|
* @link https://www.smarty.net/manual/en/language.modifier.default.php default (Smarty online manual)
|
||||||
|
* @author Uwe Tews
|
||||||
|
*/
|
||||||
|
|
||||||
|
class DefaultModifierCompiler extends Base {
|
||||||
|
|
||||||
|
public function compile($params, \Smarty\Compiler\Template $compiler) {
|
||||||
|
$output = $params[ 0 ];
|
||||||
|
if (!isset($params[ 1 ])) {
|
||||||
|
$params[ 1 ] = "''";
|
||||||
|
}
|
||||||
|
array_shift($params);
|
||||||
|
foreach ($params as $param) {
|
||||||
|
$output = '(($tmp = ' . $output . ' ?? null)===null||$tmp===\'\' ? ' . $param . ' ?? null : $tmp)';
|
||||||
|
}
|
||||||
|
return $output;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
55
src/Compile/Modifier/EscapeModifierCompiler.php
Normal file
55
src/Compile/Modifier/EscapeModifierCompiler.php
Normal file
@@ -0,0 +1,55 @@
|
|||||||
|
<?php
|
||||||
|
namespace Smarty\Compile\Modifier;
|
||||||
|
|
||||||
|
use Smarty\Exception;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Smarty escape modifier plugin
|
||||||
|
* Type: modifier
|
||||||
|
* Name: escape
|
||||||
|
* Purpose: escape string for output
|
||||||
|
*
|
||||||
|
* @link https://www.smarty.net/docsv2/en/language.modifier.escape count_characters (Smarty online manual)
|
||||||
|
* @author Rodney Rehm
|
||||||
|
*/
|
||||||
|
|
||||||
|
class EscapeModifierCompiler extends Base {
|
||||||
|
|
||||||
|
public function compile($params, \Smarty\Compiler\Template $compiler) {
|
||||||
|
try {
|
||||||
|
$esc_type = $this->literal_compiler_param($params, 1, 'html');
|
||||||
|
$char_set = $this->literal_compiler_param($params, 2, \Smarty\Smarty::$_CHARSET);
|
||||||
|
$double_encode = $this->literal_compiler_param($params, 3, true);
|
||||||
|
if (!$char_set) {
|
||||||
|
$char_set = \Smarty\Smarty::$_CHARSET;
|
||||||
|
}
|
||||||
|
switch ($esc_type) {
|
||||||
|
case 'html':
|
||||||
|
return 'htmlspecialchars((string)' . $params[ 0 ] . ', ENT_QUOTES, ' . var_export($char_set, true) . ', ' .
|
||||||
|
var_export($double_encode, true) . ')';
|
||||||
|
// no break
|
||||||
|
case 'htmlall':
|
||||||
|
return 'htmlentities(mb_convert_encoding((string)' . $params[ 0 ] . ', \'UTF-8\', ' .
|
||||||
|
var_export($char_set, true) . '), ENT_QUOTES, \'UTF-8\', ' .
|
||||||
|
var_export($double_encode, true) . ')';
|
||||||
|
// no break
|
||||||
|
case 'url':
|
||||||
|
return 'rawurlencode((string)' . $params[ 0 ] . ')';
|
||||||
|
case 'urlpathinfo':
|
||||||
|
return 'str_replace("%2F", "/", rawurlencode((string)' . $params[ 0 ] . '))';
|
||||||
|
case 'quotes':
|
||||||
|
// escape unescaped single quotes
|
||||||
|
return 'preg_replace("%(?<!\\\\\\\\)\'%", "\\\'", (string)' . $params[ 0 ] . ')';
|
||||||
|
case 'javascript':
|
||||||
|
// escape quotes and backslashes, newlines, etc.
|
||||||
|
// see https://html.spec.whatwg.org/multipage/scripting.html#restrictions-for-contents-of-script-elements
|
||||||
|
return 'strtr((string)' .
|
||||||
|
$params[ 0 ] .
|
||||||
|
', array("\\\\" => "\\\\\\\\", "\'" => "\\\\\'", "\"" => "\\\\\"", "\\r" => "\\\\r", "\\n" => "\\\n", "</" => "<\/", "<!--" => "<\!--", "<s" => "<\s", "<S" => "<\S" ))';
|
||||||
|
}
|
||||||
|
} catch (Exception $e) {
|
||||||
|
// pass through to regular plugin fallback
|
||||||
|
}
|
||||||
|
return 'smarty_modifier_escape(' . join(', ', $params) . ')';
|
||||||
|
}
|
||||||
|
}
|
21
src/Compile/Modifier/FromCharsetModifierCompiler.php
Normal file
21
src/Compile/Modifier/FromCharsetModifierCompiler.php
Normal file
@@ -0,0 +1,21 @@
|
|||||||
|
<?php
|
||||||
|
namespace Smarty\Compile\Modifier;
|
||||||
|
/**
|
||||||
|
* Smarty from_charset modifier plugin
|
||||||
|
* Type: modifier
|
||||||
|
* Name: from_charset
|
||||||
|
* Purpose: convert character encoding from $charset to internal encoding
|
||||||
|
*
|
||||||
|
* @author Rodney Rehm
|
||||||
|
*/
|
||||||
|
|
||||||
|
class FromCharsetModifierCompiler extends Base {
|
||||||
|
|
||||||
|
public function compile($params, \Smarty\Compiler\Template $compiler) {
|
||||||
|
if (!isset($params[ 1 ])) {
|
||||||
|
$params[ 1 ] = '"ISO-8859-1"';
|
||||||
|
}
|
||||||
|
return 'mb_convert_encoding(' . $params[ 0 ] . ', "' . addslashes(\Smarty\Smarty::$_CHARSET) . '", ' . $params[ 1 ] . ')';
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
25
src/Compile/Modifier/IndentModifierCompiler.php
Normal file
25
src/Compile/Modifier/IndentModifierCompiler.php
Normal file
@@ -0,0 +1,25 @@
|
|||||||
|
<?php
|
||||||
|
namespace Smarty\Compile\Modifier;
|
||||||
|
/**
|
||||||
|
* Smarty indent modifier plugin
|
||||||
|
* Type: modifier
|
||||||
|
* Name: indent
|
||||||
|
* Purpose: indent lines of text
|
||||||
|
*
|
||||||
|
* @link https://www.smarty.net/manual/en/language.modifier.indent.php indent (Smarty online manual)
|
||||||
|
* @author Uwe Tews
|
||||||
|
*/
|
||||||
|
|
||||||
|
class IndentModifierCompiler extends Base {
|
||||||
|
|
||||||
|
public function compile($params, \Smarty\Compiler\Template $compiler) {
|
||||||
|
if (!isset($params[ 1 ])) {
|
||||||
|
$params[ 1 ] = 4;
|
||||||
|
}
|
||||||
|
if (!isset($params[ 2 ])) {
|
||||||
|
$params[ 2 ] = "' '";
|
||||||
|
}
|
||||||
|
return 'preg_replace(\'!^!m\',str_repeat(' . $params[ 2 ] . ',' . $params[ 1 ] . '),' . $params[ 0 ] . ')';
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
20
src/Compile/Modifier/LowerModifierCompiler.php
Normal file
20
src/Compile/Modifier/LowerModifierCompiler.php
Normal file
@@ -0,0 +1,20 @@
|
|||||||
|
<?php
|
||||||
|
namespace Smarty\Compile\Modifier;
|
||||||
|
/**
|
||||||
|
* Smarty lower modifier plugin
|
||||||
|
* Type: modifier
|
||||||
|
* Name: lower
|
||||||
|
* Purpose: convert string to lowercase
|
||||||
|
*
|
||||||
|
* @link https://www.smarty.net/manual/en/language.modifier.lower.php lower (Smarty online manual)
|
||||||
|
* @author Monte Ohrt <monte at ohrt dot com>
|
||||||
|
* @author Uwe Tews
|
||||||
|
*/
|
||||||
|
|
||||||
|
class LowerModifierCompiler extends Base {
|
||||||
|
|
||||||
|
public function compile($params, \Smarty\Compiler\Template $compiler) {
|
||||||
|
return 'mb_strtolower(' . $params[ 0 ] . ', \'' . addslashes(\Smarty\Smarty::$_CHARSET) . '\')';
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
18
src/Compile/Modifier/Nl2brModifierCompiler.php
Normal file
18
src/Compile/Modifier/Nl2brModifierCompiler.php
Normal file
@@ -0,0 +1,18 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace Smarty\Compile\Modifier;
|
||||||
|
/**
|
||||||
|
* 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)
|
||||||
|
*/
|
||||||
|
|
||||||
|
class Nl2brModifierCompiler extends Base {
|
||||||
|
|
||||||
|
public function compile($params, \Smarty\Compiler\Template $compiler) {
|
||||||
|
return 'nl2br((string) ' . $params[0] . ', (bool) ' . ($params[1] ?? true) . ')';
|
||||||
|
}
|
||||||
|
}
|
18
src/Compile/Modifier/NoPrintModifierCompiler.php
Normal file
18
src/Compile/Modifier/NoPrintModifierCompiler.php
Normal file
@@ -0,0 +1,18 @@
|
|||||||
|
<?php
|
||||||
|
namespace Smarty\Compile\Modifier;
|
||||||
|
/**
|
||||||
|
* Smarty noprint modifier plugin
|
||||||
|
* Type: modifier
|
||||||
|
* Name: noprint
|
||||||
|
* Purpose: return an empty string
|
||||||
|
*
|
||||||
|
* @author Uwe Tews
|
||||||
|
*/
|
||||||
|
|
||||||
|
class NoPrintModifierCompiler extends Base {
|
||||||
|
|
||||||
|
public function compile($params, \Smarty\Compiler\Template $compiler) {
|
||||||
|
return "''";
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
19
src/Compile/Modifier/RoundModifierCompiler.php
Normal file
19
src/Compile/Modifier/RoundModifierCompiler.php
Normal file
@@ -0,0 +1,19 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace Smarty\Compile\Modifier;
|
||||||
|
/**
|
||||||
|
* 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)
|
||||||
|
*/
|
||||||
|
|
||||||
|
class RoundModifierCompiler extends Base {
|
||||||
|
|
||||||
|
public function compile($params, \Smarty\Compiler\Template $compiler) {
|
||||||
|
return 'round((float) ' . $params[0] . ', (int) ' . ($params[1] ?? 0) . ', (int) ' . ($params[2] ?? PHP_ROUND_HALF_UP) . ')';
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
18
src/Compile/Modifier/StrRepeatModifierCompiler.php
Normal file
18
src/Compile/Modifier/StrRepeatModifierCompiler.php
Normal file
@@ -0,0 +1,18 @@
|
|||||||
|
<?php
|
||||||
|
namespace Smarty\Compile\Modifier;
|
||||||
|
/**
|
||||||
|
* 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)
|
||||||
|
*/
|
||||||
|
|
||||||
|
class StrRepeatModifierCompiler extends Base {
|
||||||
|
|
||||||
|
public function compile($params, \Smarty\Compiler\Template $compiler) {
|
||||||
|
return 'str_repeat((string) ' . $params[0] . ', (int) ' . $params[1] . ')';
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
19
src/Compile/Modifier/StringFormatModifierCompiler.php
Normal file
19
src/Compile/Modifier/StringFormatModifierCompiler.php
Normal file
@@ -0,0 +1,19 @@
|
|||||||
|
<?php
|
||||||
|
namespace Smarty\Compile\Modifier;
|
||||||
|
/**
|
||||||
|
* Smarty string_format modifier plugin
|
||||||
|
* Type: modifier
|
||||||
|
* Name: string_format
|
||||||
|
* Purpose: format strings via sprintf
|
||||||
|
*
|
||||||
|
* @link https://www.smarty.net/manual/en/language.modifier.string.format.php string_format (Smarty online manual)
|
||||||
|
* @author Uwe Tews
|
||||||
|
*/
|
||||||
|
|
||||||
|
class StringFormatModifierCompiler extends Base {
|
||||||
|
|
||||||
|
public function compile($params, \Smarty\Compiler\Template $compiler) {
|
||||||
|
return 'sprintf(' . $params[ 1 ] . ',' . $params[ 0 ] . ')';
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@@ -1,10 +1,5 @@
|
|||||||
<?php
|
<?php
|
||||||
/**
|
namespace Smarty\Compile\Modifier;
|
||||||
* Smarty plugin
|
|
||||||
*
|
|
||||||
* @package Smarty
|
|
||||||
* @subpackage PluginsModifierCompiler
|
|
||||||
*/
|
|
||||||
/**
|
/**
|
||||||
* Smarty strip modifier plugin
|
* Smarty strip modifier plugin
|
||||||
* Type: modifier
|
* Type: modifier
|
||||||
@@ -16,15 +11,15 @@
|
|||||||
*
|
*
|
||||||
* @link https://www.smarty.net/manual/en/language.modifier.strip.php strip (Smarty online manual)
|
* @link https://www.smarty.net/manual/en/language.modifier.strip.php strip (Smarty online manual)
|
||||||
* @author Uwe Tews
|
* @author Uwe Tews
|
||||||
*
|
|
||||||
* @param array $params parameters
|
|
||||||
*
|
|
||||||
* @return string with compiled code
|
|
||||||
*/
|
*/
|
||||||
function smarty_modifiercompiler_strip($params)
|
|
||||||
{
|
class StripModifierCompiler extends Base {
|
||||||
|
|
||||||
|
public function compile($params, \Smarty\Compiler\Template $compiler) {
|
||||||
if (!isset($params[ 1 ])) {
|
if (!isset($params[ 1 ])) {
|
||||||
$params[ 1 ] = "' '";
|
$params[ 1 ] = "' '";
|
||||||
}
|
}
|
||||||
return "preg_replace('!\s+!" . \Smarty\Smarty::$_UTF8_MODIFIER . "', {$params[1]},{$params[0]})";
|
return "preg_replace('!\s+!" . \Smarty\Smarty::$_UTF8_MODIFIER . "', {$params[1]},{$params[0]})";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
}
|
23
src/Compile/Modifier/StripTagsModifierCompiler.php
Normal file
23
src/Compile/Modifier/StripTagsModifierCompiler.php
Normal file
@@ -0,0 +1,23 @@
|
|||||||
|
<?php
|
||||||
|
namespace Smarty\Compile\Modifier;
|
||||||
|
/**
|
||||||
|
* Smarty strip_tags modifier plugin
|
||||||
|
* Type: modifier
|
||||||
|
* Name: strip_tags
|
||||||
|
* Purpose: strip html tags from text
|
||||||
|
*
|
||||||
|
* @link https://www.smarty.net/docs/en/language.modifier.strip.tags.tpl strip_tags (Smarty online manual)
|
||||||
|
* @author Uwe Tews
|
||||||
|
*/
|
||||||
|
|
||||||
|
class StripTagsModifierCompiler extends Base {
|
||||||
|
|
||||||
|
public function compile($params, \Smarty\Compiler\Template $compiler) {
|
||||||
|
if (!isset($params[ 1 ]) || $params[ 1 ] === true || trim($params[ 1 ], '"') === 'true') {
|
||||||
|
return "preg_replace('!<[^>]*?>!', ' ', {$params[0]} ?: '')";
|
||||||
|
} else {
|
||||||
|
return 'strip_tags((string) ' . $params[ 0 ] . ')';
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
19
src/Compile/Modifier/StrlenModifierCompiler.php
Normal file
19
src/Compile/Modifier/StrlenModifierCompiler.php
Normal file
@@ -0,0 +1,19 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace Smarty\Compile\Modifier;
|
||||||
|
/**
|
||||||
|
* 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)
|
||||||
|
*/
|
||||||
|
|
||||||
|
class StrlenModifierCompiler extends Base {
|
||||||
|
|
||||||
|
public function compile($params, \Smarty\Compiler\Template $compiler) {
|
||||||
|
return 'strlen((string) ' . $params[0] . ')';
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
21
src/Compile/Modifier/ToCharsetModifierCompiler.php
Normal file
21
src/Compile/Modifier/ToCharsetModifierCompiler.php
Normal file
@@ -0,0 +1,21 @@
|
|||||||
|
<?php
|
||||||
|
namespace Smarty\Compile\Modifier;
|
||||||
|
/**
|
||||||
|
* Smarty to_charset modifier plugin
|
||||||
|
* Type: modifier
|
||||||
|
* Name: to_charset
|
||||||
|
* Purpose: convert character encoding from internal encoding to $charset
|
||||||
|
*
|
||||||
|
* @author Rodney Rehm
|
||||||
|
*/
|
||||||
|
|
||||||
|
class ToCharsetModifierCompiler extends Base {
|
||||||
|
|
||||||
|
public function compile($params, \Smarty\Compiler\Template $compiler) {
|
||||||
|
if (!isset($params[ 1 ])) {
|
||||||
|
$params[ 1 ] = '"ISO-8859-1"';
|
||||||
|
}
|
||||||
|
return 'mb_convert_encoding(' . $params[ 0 ] . ', ' . $params[ 1 ] . ', "' . addslashes(\Smarty\Smarty::$_CHARSET) . '")';
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
34
src/Compile/Modifier/UnescapeModifierCompiler.php
Normal file
34
src/Compile/Modifier/UnescapeModifierCompiler.php
Normal file
@@ -0,0 +1,34 @@
|
|||||||
|
<?php
|
||||||
|
namespace Smarty\Compile\Modifier;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Smarty unescape modifier plugin
|
||||||
|
* Type: modifier
|
||||||
|
* Name: unescape
|
||||||
|
* Purpose: unescape html entities
|
||||||
|
*
|
||||||
|
* @author Rodney Rehm
|
||||||
|
*/
|
||||||
|
|
||||||
|
class UnescapeModifierCompiler extends Base {
|
||||||
|
|
||||||
|
public function compile($params, \Smarty\Compiler\Template $compiler) {
|
||||||
|
$esc_type = $this->literal_compiler_param($params, 1, 'html');
|
||||||
|
|
||||||
|
if (!isset($params[ 2 ])) {
|
||||||
|
$params[ 2 ] = '\'' . addslashes(\Smarty\Smarty::$_CHARSET) . '\'';
|
||||||
|
}
|
||||||
|
|
||||||
|
switch ($esc_type) {
|
||||||
|
case 'entity':
|
||||||
|
case 'htmlall':
|
||||||
|
return 'html_entity_decode(mb_convert_encoding(' . $params[ 0 ] . ', ' . $params[ 2 ] . ', \'UTF-8\'), ENT_QUOTES | ENT_SUBSTITUTE | ENT_HTML401, ' . $params[ 2 ] . ')';
|
||||||
|
case 'html':
|
||||||
|
return 'htmlspecialchars_decode(' . $params[ 0 ] . ', ENT_QUOTES)';
|
||||||
|
case 'url':
|
||||||
|
return 'rawurldecode(' . $params[ 0 ] . ')';
|
||||||
|
default:
|
||||||
|
return $params[ 0 ];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
19
src/Compile/Modifier/UpperModifierCompiler.php
Normal file
19
src/Compile/Modifier/UpperModifierCompiler.php
Normal file
@@ -0,0 +1,19 @@
|
|||||||
|
<?php
|
||||||
|
namespace Smarty\Compile\Modifier;
|
||||||
|
/**
|
||||||
|
* Smarty upper modifier plugin
|
||||||
|
* Type: modifier
|
||||||
|
* Name: lower
|
||||||
|
* Purpose: convert string to uppercase
|
||||||
|
*
|
||||||
|
* @link https://www.smarty.net/manual/en/language.modifier.upper.php lower (Smarty online manual)
|
||||||
|
* @author Uwe Tews
|
||||||
|
*/
|
||||||
|
|
||||||
|
class UpperModifierCompiler extends Base {
|
||||||
|
|
||||||
|
public function compile($params, \Smarty\Compiler\Template $compiler) {
|
||||||
|
return 'mb_strtoupper(' . $params[ 0 ] . ' ?? \'\', \'' . addslashes(\Smarty\Smarty::$_CHARSET) . '\')';
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
29
src/Compile/Modifier/WordWrapModifierCompiler.php
Normal file
29
src/Compile/Modifier/WordWrapModifierCompiler.php
Normal file
@@ -0,0 +1,29 @@
|
|||||||
|
<?php
|
||||||
|
namespace Smarty\Compile\Modifier;
|
||||||
|
/**
|
||||||
|
* Smarty wordwrap modifier plugin
|
||||||
|
* Type: modifier
|
||||||
|
* Name: wordwrap
|
||||||
|
* Purpose: wrap a string of text at a given length
|
||||||
|
*
|
||||||
|
* @link https://www.smarty.net/manual/en/language.modifier.wordwrap.php wordwrap (Smarty online manual)
|
||||||
|
* @author Uwe Tews
|
||||||
|
*/
|
||||||
|
|
||||||
|
class WordWrapModifierCompiler extends Base {
|
||||||
|
|
||||||
|
public function compile($params, \Smarty\Compiler\Template $compiler) {
|
||||||
|
if (!isset($params[ 1 ])) {
|
||||||
|
$params[ 1 ] = 80;
|
||||||
|
}
|
||||||
|
if (!isset($params[ 2 ])) {
|
||||||
|
$params[ 2 ] = '"\n"';
|
||||||
|
}
|
||||||
|
if (!isset($params[ 3 ])) {
|
||||||
|
$params[ 3 ] = 'false';
|
||||||
|
}
|
||||||
|
$function = $compiler->getPlugin('mb_wordwrap', 'modifier');
|
||||||
|
return $function . '(' . $params[ 0 ] . ',' . $params[ 1 ] . ',' . $params[ 2 ] . ',' . $params[ 3 ] . ')';
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@@ -1,6 +1,6 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
namespace Smarty\Compile;
|
namespace Smarty\Compile\Tag;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Smarty Internal Plugin Compile Append
|
* Smarty Internal Plugin Compile Append
|
@@ -1,8 +1,7 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
namespace Smarty\Compile;
|
namespace Smarty\Compile\Tag;
|
||||||
|
|
||||||
use Smarty\CompileBase;
|
|
||||||
use Smarty\Smarty;
|
use Smarty\Smarty;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -20,7 +19,7 @@ use Smarty\Smarty;
|
|||||||
* @package Smarty
|
* @package Smarty
|
||||||
* @subpackage Compiler
|
* @subpackage Compiler
|
||||||
*/
|
*/
|
||||||
class Assign extends CompileBase
|
class Assign extends Base
|
||||||
{
|
{
|
||||||
/**
|
/**
|
||||||
* Attribute definition: Overwrites base class.
|
* Attribute definition: Overwrites base class.
|
@@ -1,13 +1,9 @@
|
|||||||
<?php
|
<?php
|
||||||
/**
|
/**
|
||||||
* Smarty Internal Plugin CompileBase
|
* Smarty Internal Compile Plugin Base
|
||||||
*
|
|
||||||
* @package Smarty
|
|
||||||
* @subpackage Compiler
|
|
||||||
* @author Uwe Tews
|
* @author Uwe Tews
|
||||||
*/
|
*/
|
||||||
|
namespace Smarty\Compile\Tag;
|
||||||
namespace Smarty\Compile;
|
|
||||||
/**
|
/**
|
||||||
* This class does extend all internal compile plugins
|
* This class does extend all internal compile plugins
|
||||||
*
|
*
|
@@ -8,7 +8,7 @@
|
|||||||
* file that was distributed with this source code.
|
* file that was distributed with this source code.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
namespace Smarty\Compile;
|
namespace Smarty\Compile\Tag;
|
||||||
|
|
||||||
use Smarty\ParseTree\Template;
|
use Smarty\ParseTree\Template;
|
||||||
|
|
@@ -8,7 +8,7 @@
|
|||||||
* file that was distributed with this source code.
|
* file that was distributed with this source code.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
namespace Smarty\Compile;
|
namespace Smarty\Compile\Tag;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Smarty Internal Plugin Compile Block Child Class
|
* Smarty Internal Plugin Compile Block Child Class
|
@@ -1,6 +1,6 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
namespace Smarty\Compile;
|
namespace Smarty\Compile\Tag;
|
||||||
|
|
||||||
use Smarty\ParseTree\Template;
|
use Smarty\ParseTree\Template;
|
||||||
|
|
@@ -8,7 +8,7 @@
|
|||||||
* file that was distributed with this source code.
|
* file that was distributed with this source code.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
namespace Smarty\Compile;
|
namespace Smarty\Compile\Tag;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Smarty Internal Plugin Compile Block Parent Class
|
* Smarty Internal Plugin Compile Block Parent Class
|
@@ -8,7 +8,7 @@
|
|||||||
* @author Uwe Tews
|
* @author Uwe Tews
|
||||||
*/
|
*/
|
||||||
|
|
||||||
namespace Smarty\Compile;
|
namespace Smarty\Compile\Tag;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Smarty Internal Plugin Compile Break Class
|
* Smarty Internal Plugin Compile Break Class
|
90
src/Compile/Tag/Call.php
Normal file
90
src/Compile/Tag/Call.php
Normal file
@@ -0,0 +1,90 @@
|
|||||||
|
<?php
|
||||||
|
/**
|
||||||
|
* Smarty Internal Plugin Compile Function_Call
|
||||||
|
* Compiles the calls of user defined tags defined by {function}
|
||||||
|
*
|
||||||
|
* @package Smarty
|
||||||
|
* @subpackage Compiler
|
||||||
|
* @author Uwe Tews
|
||||||
|
*/
|
||||||
|
|
||||||
|
namespace Smarty\Compile\Tag;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Smarty Internal Plugin Compile Function_Call Class
|
||||||
|
*
|
||||||
|
* @package Smarty
|
||||||
|
* @subpackage Compiler
|
||||||
|
*/
|
||||||
|
class Call extends Base {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Attribute definition: Overwrites base class.
|
||||||
|
*
|
||||||
|
* @var array
|
||||||
|
* @see Base
|
||||||
|
*/
|
||||||
|
public $required_attributes = ['name'];
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Attribute definition: Overwrites base class.
|
||||||
|
*
|
||||||
|
* @var array
|
||||||
|
* @see Base
|
||||||
|
*/
|
||||||
|
public $shorttag_order = ['name'];
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Attribute definition: Overwrites base class.
|
||||||
|
*
|
||||||
|
* @var array
|
||||||
|
* @see Base
|
||||||
|
*/
|
||||||
|
public $optional_attributes = ['_any'];
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Compiles the calls of user defined tags defined by {function}
|
||||||
|
*
|
||||||
|
* @param array $args array with attributes from parser
|
||||||
|
* @param object $compiler compiler object
|
||||||
|
*
|
||||||
|
* @return string compiled code
|
||||||
|
*/
|
||||||
|
public function compile($args, \Smarty\Compiler\Template $compiler, $parameter = [], $tag = null, $function = null) {
|
||||||
|
// check and get attributes
|
||||||
|
$_attr = $this->getAttributes($compiler, $args);
|
||||||
|
// save possible attributes
|
||||||
|
if (isset($_attr['assign'])) {
|
||||||
|
// output will be stored in a smarty variable instead of being displayed
|
||||||
|
$_assign = $_attr['assign'];
|
||||||
|
}
|
||||||
|
//$_name = trim($_attr['name'], "''");
|
||||||
|
$_name = $_attr['name'];
|
||||||
|
unset($_attr['name'], $_attr['assign'], $_attr['nocache']);
|
||||||
|
// set flag (compiled code of {function} must be included in cache file
|
||||||
|
if (!$compiler->template->caching || $compiler->nocache || $compiler->tag_nocache) {
|
||||||
|
$_nocache = 'true';
|
||||||
|
} else {
|
||||||
|
$_nocache = 'false';
|
||||||
|
}
|
||||||
|
$_paramsArray = [];
|
||||||
|
foreach ($_attr as $_key => $_value) {
|
||||||
|
if (is_int($_key)) {
|
||||||
|
$_paramsArray[] = "$_key=>$_value";
|
||||||
|
} else {
|
||||||
|
$_paramsArray[] = "'$_key'=>$_value";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
$_params = 'array(' . implode(',', $_paramsArray) . ')';
|
||||||
|
//$compiler->suppressNocacheProcessing = true;
|
||||||
|
// was there an assign attribute
|
||||||
|
if (isset($_assign)) {
|
||||||
|
$_output =
|
||||||
|
"<?php ob_start();\n\$_smarty_tpl->smarty->getRuntime('TplFunction')->callTemplateFunction(\$_smarty_tpl, {$_name}, {$_params}, {$_nocache});\n\$_smarty_tpl->assign({$_assign}, ob_get_clean());?>\n";
|
||||||
|
} else {
|
||||||
|
$_output =
|
||||||
|
"<?php \$_smarty_tpl->smarty->getRuntime('TplFunction')->callTemplateFunction(\$_smarty_tpl, {$_name}, {$_params}, {$_nocache});?>\n";
|
||||||
|
}
|
||||||
|
return $_output;
|
||||||
|
}
|
||||||
|
}
|
@@ -1,6 +1,6 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
namespace Smarty\Compile;
|
namespace Smarty\Compile\Tag;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Smarty Internal Plugin Compile Capture Class
|
* Smarty Internal Plugin Compile Capture Class
|
@@ -8,9 +8,7 @@
|
|||||||
* @author Uwe Tews
|
* @author Uwe Tews
|
||||||
*/
|
*/
|
||||||
|
|
||||||
namespace Smarty\Compile;
|
namespace Smarty\Compile\Tag;
|
||||||
|
|
||||||
use Smarty\Compiler\Template;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Smarty Internal Plugin Compile Captureclose Class
|
* Smarty Internal Plugin Compile Captureclose Class
|
@@ -8,9 +8,7 @@
|
|||||||
* file that was distributed with this source code.
|
* file that was distributed with this source code.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
namespace Smarty\Compile;
|
namespace Smarty\Compile\Tag;
|
||||||
|
|
||||||
use Smarty\Compiler\Template;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Smarty Internal Plugin Compile Child Class
|
* Smarty Internal Plugin Compile Child Class
|
@@ -8,10 +8,9 @@
|
|||||||
* @author Uwe Tews
|
* @author Uwe Tews
|
||||||
*/
|
*/
|
||||||
|
|
||||||
namespace Smarty\Compile;
|
namespace Smarty\Compile\Tag;
|
||||||
|
|
||||||
use Smarty\Smarty;
|
use Smarty\Smarty;
|
||||||
use Smarty\Compiler\Template;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Smarty Internal Plugin Compile Config Load Class
|
* Smarty Internal Plugin Compile Config Load Class
|
||||||
@@ -89,6 +88,6 @@ class ConfigLoad extends Base {
|
|||||||
$_scope = $compiler->convertScope($_attr, $this->valid_scopes);
|
$_scope = $compiler->convertScope($_attr, $this->valid_scopes);
|
||||||
}
|
}
|
||||||
// create config object
|
// create config object
|
||||||
return "<?php\n\$_smarty_tpl->_loadConfigFile({$conf_file}, {$section}, {$_scope});\n?>\n";
|
return "<?php\n\$_smarty_tpl->_loadConfigfile({$conf_file}, {$section}, {$_scope});\n?>\n";
|
||||||
}
|
}
|
||||||
}
|
}
|
@@ -8,9 +8,7 @@
|
|||||||
* @author Uwe Tews
|
* @author Uwe Tews
|
||||||
*/
|
*/
|
||||||
|
|
||||||
namespace Smarty\Compile;
|
namespace Smarty\Compile\Tag;
|
||||||
|
|
||||||
use Smarty\Compile\BreakTag;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Smarty Internal Plugin Compile Continue Class
|
* Smarty Internal Plugin Compile Continue Class
|
@@ -9,9 +9,7 @@
|
|||||||
* @author Uwe Tews
|
* @author Uwe Tews
|
||||||
*/
|
*/
|
||||||
|
|
||||||
namespace Smarty\Compile;
|
namespace Smarty\Compile\Tag;
|
||||||
|
|
||||||
use Smarty\Compiler\Template;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Smarty Internal Plugin Compile Debug Class
|
* Smarty Internal Plugin Compile Debug Class
|
@@ -1,8 +1,6 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
namespace Smarty\Compile;
|
namespace Smarty\Compile\Tag;
|
||||||
|
|
||||||
use Smarty\Compiler\Template;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Smarty Internal Plugin Compile ElseIf Class
|
* Smarty Internal Plugin Compile ElseIf Class
|
@@ -1,8 +1,6 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
namespace Smarty\Compile;
|
namespace Smarty\Compile\Tag;
|
||||||
|
|
||||||
use Smarty\Compiler\Template;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Smarty Internal Plugin Compile Else Class
|
* Smarty Internal Plugin Compile Else Class
|
@@ -8,10 +8,7 @@
|
|||||||
* @author Uwe Tews
|
* @author Uwe Tews
|
||||||
*/
|
*/
|
||||||
|
|
||||||
namespace Smarty\Compile;
|
namespace Smarty\Compile\Tag;
|
||||||
|
|
||||||
use Smarty\Compile\Base;
|
|
||||||
use Smarty\Compiler\Template;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Smarty Internal Plugin Compile Eval Class
|
* Smarty Internal Plugin Compile Eval Class
|
@@ -8,9 +8,7 @@
|
|||||||
* @author Uwe Tews
|
* @author Uwe Tews
|
||||||
*/
|
*/
|
||||||
|
|
||||||
namespace Smarty\Compile;
|
namespace Smarty\Compile\Tag;
|
||||||
|
|
||||||
use Smarty\Compiler\Template;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Smarty Internal Plugin Compile extend Class
|
* Smarty Internal Plugin Compile extend Class
|
@@ -8,9 +8,7 @@
|
|||||||
* @author Uwe Tews
|
* @author Uwe Tews
|
||||||
*/
|
*/
|
||||||
|
|
||||||
namespace Smarty\Compile;
|
namespace Smarty\Compile\Tag;
|
||||||
|
|
||||||
use Smarty\Compiler\Template;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Smarty Internal Plugin Compile Forclose Class
|
* Smarty Internal Plugin Compile Forclose Class
|
@@ -1,8 +1,6 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
namespace Smarty\Compile;
|
namespace Smarty\Compile\Tag;
|
||||||
|
|
||||||
use Smarty\Compiler\Template;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Smarty Internal Plugin Compile Forelse Class
|
* Smarty Internal Plugin Compile Forelse Class
|
@@ -1,8 +1,6 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
namespace Smarty\Compile;
|
namespace Smarty\Compile\Tag;
|
||||||
|
|
||||||
use Smarty\Compiler\Template;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Smarty Internal Plugin Compile For Class
|
* Smarty Internal Plugin Compile For Class
|
@@ -8,7 +8,7 @@
|
|||||||
* @author Uwe Tews
|
* @author Uwe Tews
|
||||||
*/
|
*/
|
||||||
|
|
||||||
namespace Smarty\Compile;
|
namespace Smarty\Compile\Tag;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Smarty Internal Plugin Compile Foreachclose Class
|
* Smarty Internal Plugin Compile Foreachclose Class
|
||||||
@@ -41,7 +41,7 @@ class ForeachClose extends Base {
|
|||||||
$output .= "{$itemVar} = {$local}saved;\n";
|
$output .= "{$itemVar} = {$local}saved;\n";
|
||||||
}
|
}
|
||||||
$output .= "}\n";
|
$output .= "}\n";
|
||||||
/* @var \Smarty\Compile\ForeachTag $foreachCompiler */
|
/* @var \Smarty\Compile\Tag\ForeachTag $foreachCompiler */
|
||||||
$foreachCompiler = $compiler->getTagCompiler('foreach');
|
$foreachCompiler = $compiler->getTagCompiler('foreach');
|
||||||
$output .= $foreachCompiler->compileRestore(1);
|
$output .= $foreachCompiler->compileRestore(1);
|
||||||
$output .= "?>";
|
$output .= "?>";
|
@@ -1,8 +1,6 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
namespace Smarty\Compile;
|
namespace Smarty\Compile\Tag;
|
||||||
|
|
||||||
use Smarty\Compiler\Template;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Smarty Internal Plugin Compile Foreachelse Class
|
* Smarty Internal Plugin Compile Foreachelse Class
|
@@ -8,9 +8,7 @@
|
|||||||
* @author Uwe Tews
|
* @author Uwe Tews
|
||||||
*/
|
*/
|
||||||
|
|
||||||
namespace Smarty\Compile;
|
namespace Smarty\Compile\Tag;
|
||||||
|
|
||||||
use Smarty\Compiler\Template;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Smarty Internal Plugin Compile ForeachSection Class
|
* Smarty Internal Plugin Compile ForeachSection Class
|
@@ -1,8 +1,6 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
namespace Smarty\Compile;
|
namespace Smarty\Compile\Tag;
|
||||||
|
|
||||||
use Smarty\Compiler\Template;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Smarty Internal Plugin Compile Foreach Class
|
* Smarty Internal Plugin Compile Foreach Class
|
@@ -8,9 +8,7 @@
|
|||||||
* @author Uwe Tews
|
* @author Uwe Tews
|
||||||
*/
|
*/
|
||||||
|
|
||||||
namespace Smarty\Compile;
|
namespace Smarty\Compile\Tag;
|
||||||
|
|
||||||
use Smarty\Compiler\Template;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Smarty Internal Plugin Compile Functionclose Class
|
* Smarty Internal Plugin Compile Functionclose Class
|
||||||
@@ -64,7 +62,7 @@ class FunctionClose extends Base {
|
|||||||
// setup buffer for template function code
|
// setup buffer for template function code
|
||||||
$compiler->parser->current_buffer = new \Smarty\ParseTree\Template();
|
$compiler->parser->current_buffer = new \Smarty\ParseTree\Template();
|
||||||
$_funcName = "smarty_template_function_{$_name}_{$compiler->template->compiled->nocache_hash}";
|
$_funcName = "smarty_template_function_{$_name}_{$compiler->template->compiled->nocache_hash}";
|
||||||
$_funcNameCaching = $_funcName . 'Smarty\Compile\Nocache';
|
$_funcNameCaching = $_funcName . 'Smarty\Compile\Tag\Nocache';
|
||||||
if ($compiler->template->compiled->has_nocache_code) {
|
if ($compiler->template->compiled->has_nocache_code) {
|
||||||
$compiler->parent_compiler->tpl_function[$_name]['call_name_caching'] = $_funcNameCaching;
|
$compiler->parent_compiler->tpl_function[$_name]['call_name_caching'] = $_funcNameCaching;
|
||||||
$output = "<?php\n";
|
$output = "<?php\n";
|
@@ -1,8 +1,6 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
namespace Smarty\Compile;
|
namespace Smarty\Compile\Tag;
|
||||||
|
|
||||||
use Smarty\Compiler\Template;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Smarty Internal Plugin Compile Function Class
|
* Smarty Internal Plugin Compile Function Class
|
@@ -8,11 +8,7 @@
|
|||||||
* @author Uwe Tews
|
* @author Uwe Tews
|
||||||
*/
|
*/
|
||||||
|
|
||||||
namespace Smarty\Compile;
|
namespace Smarty\Compile\Tag;
|
||||||
|
|
||||||
use Smarty\Compile\Assign;
|
|
||||||
use Smarty\Compile\Base;
|
|
||||||
use Smarty\Compiler\Template;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Smarty Internal Plugin Compile Ifclose Class
|
* Smarty Internal Plugin Compile Ifclose Class
|
@@ -1,8 +1,6 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
namespace Smarty\Compile;
|
namespace Smarty\Compile\Tag;
|
||||||
|
|
||||||
use Smarty\Compiler\Template;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Smarty Internal Plugin Compile If Class
|
* Smarty Internal Plugin Compile If Class
|
@@ -8,11 +8,10 @@
|
|||||||
* @author Uwe Tews
|
* @author Uwe Tews
|
||||||
*/
|
*/
|
||||||
|
|
||||||
namespace Smarty\Compile;
|
namespace Smarty\Compile\Tag;
|
||||||
|
|
||||||
use Smarty\Compiler\Template;
|
use Smarty\Compiler\Template;
|
||||||
use Smarty\Smarty;
|
use Smarty\Smarty;
|
||||||
use Smarty\Compile\Base;
|
|
||||||
use Smarty\Template\Compiled;
|
use Smarty\Template\Compiled;
|
||||||
|
|
||||||
/**
|
/**
|
@@ -1,6 +1,6 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
namespace Smarty\Compile;
|
namespace Smarty\Compile\Tag;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Smarty Internal Plugin Compile Shared Inheritance
|
* Smarty Internal Plugin Compile Shared Inheritance
|
||||||
@@ -17,7 +17,7 @@ namespace Smarty\Compile;
|
|||||||
* @package Smarty
|
* @package Smarty
|
||||||
* @subpackage Compiler
|
* @subpackage Compiler
|
||||||
*/
|
*/
|
||||||
abstract class Inheritance extends \Smarty\Compile\Base
|
abstract class Inheritance extends Base
|
||||||
{
|
{
|
||||||
/**
|
/**
|
||||||
* Compile inheritance initialization code as prefix
|
* Compile inheritance initialization code as prefix
|
@@ -8,10 +8,9 @@
|
|||||||
* @author Uwe Tews
|
* @author Uwe Tews
|
||||||
*/
|
*/
|
||||||
|
|
||||||
namespace Smarty\Compile;
|
namespace Smarty\Compile\Tag;
|
||||||
|
|
||||||
use Smarty\Variable;
|
use Smarty\Variable;
|
||||||
use Smarty\Compiler\Template;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Smarty Internal Plugin Compile Insert Class
|
* Smarty Internal Plugin Compile Insert Class
|
@@ -8,9 +8,7 @@
|
|||||||
* @author Uwe Tews
|
* @author Uwe Tews
|
||||||
*/
|
*/
|
||||||
|
|
||||||
namespace Smarty\Compile;
|
namespace Smarty\Compile\Tag;
|
||||||
|
|
||||||
use Smarty\Compiler\Template;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Smarty Internal Plugin Compile Ldelim Class
|
* Smarty Internal Plugin Compile Ldelim Class
|
@@ -8,10 +8,7 @@
|
|||||||
* @author Uwe Tews
|
* @author Uwe Tews
|
||||||
*/
|
*/
|
||||||
|
|
||||||
namespace Smarty\Compile;
|
namespace Smarty\Compile\Tag;
|
||||||
|
|
||||||
use Smarty\Compile\Base;
|
|
||||||
use Smarty\Compiler\Template;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Smarty Internal Plugin Compile Make_Nocache Class
|
* Smarty Internal Plugin Compile Make_Nocache Class
|
@@ -1,8 +1,6 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
namespace Smarty\Compile;
|
namespace Smarty\Compile\Tag;
|
||||||
|
|
||||||
use Smarty\Compiler\Template;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Smarty Internal Plugin Compile Nocache Class
|
* Smarty Internal Plugin Compile Nocache Class
|
@@ -8,9 +8,7 @@
|
|||||||
* @author Uwe Tews
|
* @author Uwe Tews
|
||||||
*/
|
*/
|
||||||
|
|
||||||
namespace Smarty\Compile;
|
namespace Smarty\Compile\Tag;
|
||||||
|
|
||||||
use Smarty\Compiler\Template;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Smarty Internal Plugin Compile Nocacheclose Class
|
* Smarty Internal Plugin Compile Nocacheclose Class
|
@@ -8,7 +8,7 @@
|
|||||||
* file that was distributed with this source code.
|
* file that was distributed with this source code.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
namespace Smarty\Compile;
|
namespace Smarty\Compile\Tag;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Smarty Internal Plugin Compile Parent Class
|
* Smarty Internal Plugin Compile Parent Class
|
@@ -8,9 +8,7 @@
|
|||||||
* @author Uwe Tews
|
* @author Uwe Tews
|
||||||
*/
|
*/
|
||||||
|
|
||||||
namespace Smarty\Compile;
|
namespace Smarty\Compile\Tag;
|
||||||
|
|
||||||
use Smarty\Compiler\Template;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Smarty Internal Plugin Compile Block Plugin Class
|
* Smarty Internal Plugin Compile Block Plugin Class
|
@@ -8,10 +8,7 @@
|
|||||||
* @author Uwe Tews
|
* @author Uwe Tews
|
||||||
*/
|
*/
|
||||||
|
|
||||||
namespace Smarty\Compile;
|
namespace Smarty\Compile\Tag;
|
||||||
|
|
||||||
use Smarty\Compile\Base;
|
|
||||||
use Smarty\Compiler\Template;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Smarty Internal Plugin Compile Function Plugin Class
|
* Smarty Internal Plugin Compile Function Plugin Class
|
@@ -8,9 +8,7 @@
|
|||||||
* @author Uwe Tews
|
* @author Uwe Tews
|
||||||
*/
|
*/
|
||||||
|
|
||||||
namespace Smarty\Compile;
|
namespace Smarty\Compile\Tag;
|
||||||
|
|
||||||
use Smarty\Compiler\Template;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Smarty Internal Plugin Compile Modifier Class
|
* Smarty Internal Plugin Compile Modifier Class
|
||||||
@@ -81,11 +79,8 @@ class PrivateModifier extends Base {
|
|||||||
case 3:
|
case 3:
|
||||||
// modifiercompiler plugin
|
// modifiercompiler plugin
|
||||||
// check if modifier allowed
|
// check if modifier allowed
|
||||||
if (!is_object($compiler->smarty->security_policy)
|
if ($compiler->getModifierCompiler($modifier)) {
|
||||||
|| $compiler->smarty->security_policy->isTrustedModifier($modifier, $compiler)
|
$output = $compiler->compileModifier($modifier, $single_modifier);
|
||||||
) {
|
|
||||||
$plugin = 'smarty_modifiercompiler_' . $modifier;
|
|
||||||
$output = $plugin($single_modifier, $compiler);
|
|
||||||
}
|
}
|
||||||
$compiler->known_modifier_type[$modifier] = $type;
|
$compiler->known_modifier_type[$modifier] = $type;
|
||||||
break 2;
|
break 2;
|
@@ -8,7 +8,7 @@
|
|||||||
* @author Uwe Tews
|
* @author Uwe Tews
|
||||||
*/
|
*/
|
||||||
|
|
||||||
namespace Smarty\Compile;
|
namespace Smarty\Compile\Tag;
|
||||||
|
|
||||||
use Smarty\Compiler\Template;
|
use Smarty\Compiler\Template;
|
||||||
|
|
@@ -8,9 +8,7 @@
|
|||||||
* @author Uwe Tews
|
* @author Uwe Tews
|
||||||
*/
|
*/
|
||||||
|
|
||||||
namespace Smarty\Compile;
|
namespace Smarty\Compile\Tag;
|
||||||
|
|
||||||
use Smarty\Compiler\Template;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Smarty Internal Plugin Compile Object Function Class
|
* Smarty Internal Plugin Compile Object Function Class
|
@@ -8,10 +8,7 @@
|
|||||||
* @author Uwe Tews
|
* @author Uwe Tews
|
||||||
*/
|
*/
|
||||||
|
|
||||||
namespace Smarty\Compile;
|
namespace Smarty\Compile\Tag;
|
||||||
|
|
||||||
use Smarty\Compile\Base;
|
|
||||||
use Smarty\Compiler\Template;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Smarty Internal Plugin Compile Print Expression Class
|
* Smarty Internal Plugin Compile Print Expression Class
|
@@ -8,7 +8,7 @@
|
|||||||
* @author Uwe Tews
|
* @author Uwe Tews
|
||||||
*/
|
*/
|
||||||
|
|
||||||
namespace Smarty\Compile;
|
namespace Smarty\Compile\Tag;
|
||||||
|
|
||||||
use Smarty\Compiler\Template;
|
use Smarty\Compiler\Template;
|
||||||
use Smarty\Smarty;
|
use Smarty\Smarty;
|
@@ -8,13 +8,7 @@
|
|||||||
* @author Uwe Tews
|
* @author Uwe Tews
|
||||||
*/
|
*/
|
||||||
|
|
||||||
namespace Smarty\Compile;
|
namespace Smarty\Compile\Tag;
|
||||||
|
|
||||||
use Smarty\Compile\Capture;
|
|
||||||
use Smarty\Compile\Base;
|
|
||||||
use Smarty\Compile\ForeachTag;
|
|
||||||
use Smarty\Compile\Section;
|
|
||||||
use Smarty\Compiler\Template;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Smarty Internal Plugin Compile special Smarty Variable Class
|
* Smarty Internal Plugin Compile special Smarty Variable Class
|
@@ -8,9 +8,7 @@
|
|||||||
* @author Uwe Tews
|
* @author Uwe Tews
|
||||||
*/
|
*/
|
||||||
|
|
||||||
namespace Smarty\Compile;
|
namespace Smarty\Compile\Tag;
|
||||||
|
|
||||||
use Smarty\Compiler\Template;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Smarty Internal Plugin Compile Rdelim Class
|
* Smarty Internal Plugin Compile Rdelim Class
|
@@ -1,8 +1,6 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
namespace Smarty\Compile;
|
namespace Smarty\Compile\Tag;
|
||||||
|
|
||||||
use Smarty\Compiler\Template;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Smarty Internal Plugin Compile Section Class
|
* Smarty Internal Plugin Compile Section Class
|
@@ -8,11 +8,7 @@
|
|||||||
* @author Uwe Tews
|
* @author Uwe Tews
|
||||||
*/
|
*/
|
||||||
|
|
||||||
namespace Smarty\Compile;
|
namespace Smarty\Compile\Tag;
|
||||||
|
|
||||||
use Smarty\Compile\ForeachSection;
|
|
||||||
use Smarty\Compile\Base;
|
|
||||||
use Smarty\Compiler\Template;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Smarty Internal Plugin Compile Sectionclose Class
|
* Smarty Internal Plugin Compile Sectionclose Class
|
@@ -1,8 +1,6 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
namespace Smarty\Compile;
|
namespace Smarty\Compile\Tag;
|
||||||
|
|
||||||
use Smarty\Compiler\Template;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Smarty Internal Plugin Compile Sectionelse Class
|
* Smarty Internal Plugin Compile Sectionelse Class
|
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user