update to Smarty 3.1.29
This commit is contained in:
parent
4914643559
commit
d33051cb72
31 changed files with 1420 additions and 1398 deletions
|
@ -21,17 +21,17 @@ Smarty 3.1.28
|
|||
fetch() and display()
|
||||
=====================
|
||||
The fetch() and display() methods of the template object accept now optionally the same parameter
|
||||
as the corresponding Smarty methods to get tne content of another template.
|
||||
as the corresponding Smarty methods to get the content of another template.
|
||||
Example:
|
||||
$template->display(); Does display template of template object
|
||||
$template->dispaly('foo.tpl'); Does display template 'foo.bar'
|
||||
$template->display('foo.tpl'); Does display template 'foo.bar'
|
||||
|
||||
File: resource
|
||||
==============
|
||||
Multiple template_dir entries can now be selected by a comma separated list of indices.
|
||||
The template_dir array is searched in the order of the indices. (Could be used to change the default search order)
|
||||
Example:
|
||||
$smarty->display([1],[0]foo.bar');
|
||||
$smarty->display('[1],[0]foo.bar');
|
||||
|
||||
Filter support
|
||||
==============
|
||||
|
@ -130,4 +130,4 @@ Smarty 3.1.22
|
|||
Smarty::DEBUG_INDIVIDUAL will create for each display() and fetch() call an individual debug window.
|
||||
|
||||
.
|
||||
|
||||
|
||||
|
|
|
@ -1,14 +1,50 @@
|
|||
===== 3.1.28 ===== (13.12.2015)
|
||||
===== 3.1.29 ===== (21.12.2015)
|
||||
21.12.2015
|
||||
- optimization improve speed of filetime checks on extends and extendsall resource
|
||||
|
||||
20.12.2015
|
||||
- bugfix failure when the default resource type was set to 'extendsall' https://github.com/smarty-php/smarty/issues/123
|
||||
- update compilation of Smarty special variables
|
||||
- bugfix add addition check for OS type on normalizaition of file path https://github.com/smarty-php/smarty/issues/134
|
||||
- bugfix the source uid of the extendsall resource must contain $template_dir settings https://github.com/smarty-php/smarty/issues/123
|
||||
|
||||
19.12.2015
|
||||
- bugfix using $smarty.capture.foo in expressions could fail https://github.com/smarty-php/smarty/pull/138
|
||||
- bugfix broken PHP 5.2 compatibility https://github.com/smarty-php/smarty/issues/139
|
||||
- remove no longer used code
|
||||
- improvement make sure that compiled and cache templates never can contain a trailing '?>?
|
||||
|
||||
18.12.2015
|
||||
- bugfix regression when modifier parameter was follow by math https://github.com/smarty-php/smarty/issues/132
|
||||
|
||||
17.12.2015
|
||||
- bugfix {$smarty.capture.nameFail} did lowercase capture name https://github.com/smarty-php/smarty/issues/135
|
||||
- bugfix using {block append/prepend} on same block in multiple levels of inheritance templates could fail (forum topic 25827)
|
||||
- bugfix text content consisting of just a single '0' like in {if true}0{/if} was suppressed (forum topic 25834)
|
||||
|
||||
16.12.2015
|
||||
- bugfix {foreach} did fail if from atrribute is a Generator class https://github.com/smarty-php/smarty/issues/128
|
||||
- bugfix direct access $smarty->template_dir = 'foo'; should call Smarty::setTemplateDir() https://github.com/smarty-php/smarty/issues/121
|
||||
|
||||
15.12.2015
|
||||
- bugfix {$smarty.cookies.foo} did return the $_COOKIE array not the 'foo' value https://github.com/smarty-php/smarty/issues/122
|
||||
- bugfix a call to clearAllCache() and other should clear all internal template object caches (forum topic 25828)
|
||||
|
||||
14.12.2015
|
||||
- bugfix {$smarty.config.foo} broken in 3.1.28 https://github.com/smarty-php/smarty/issues/120
|
||||
- bugfix multiple calls of {section} with same name droped E_NOTICE error https://github.com/smarty-php/smarty/issues/118
|
||||
|
||||
===== 3.1.28 ===== (13.12.2015)
|
||||
13.12.2015
|
||||
- bugfix {foreach} and {section} with uppercase characters in name attribute did not work (forum topic 25819)
|
||||
- bugfix $smarty->debugging_ctrl = 'URL' did not work (forum topic 25811)
|
||||
- bugfix Debug Console could display incorrect data when using subtemplates
|
||||
|
||||
09.12.2015
|
||||
- bugix Smarty did fail under PHP 7.0.0 with use_include_path = true;
|
||||
- bugfix Smarty did fail under PHP 7.0.0 with use_include_path = true;
|
||||
|
||||
09.12.2015
|
||||
-bugfix {strip} should exclude some html tags from stripping, related to fix for https://github.com/smarty-php/smarty/issues/111
|
||||
- bugfix {strip} should exclude some html tags from stripping, related to fix for https://github.com/smarty-php/smarty/issues/111
|
||||
|
||||
08.12.2015
|
||||
- bugfix internal template function data got stored in wrong compiled file https://github.com/smarty-php/smarty/issues/114
|
||||
|
|
|
@ -352,26 +352,18 @@ tag(res) ::= LDEL variable(e). {
|
|||
res = $this->compiler->compileTag('private_print_expression',array(),array('value'=>e));
|
||||
}
|
||||
|
||||
tag(res) ::= LDEL variable(e) modifierlist(l) attributes(a). {
|
||||
res = $this->compiler->compileTag('private_print_expression',a,array('value'=>e, 'modifierlist'=>l));
|
||||
}
|
||||
|
||||
tag(res) ::= LDEL variable(e) attributes(a). {
|
||||
res = $this->compiler->compileTag('private_print_expression',a,array('value'=>e));
|
||||
}
|
||||
tag(res) ::= LDEL value(e). {
|
||||
res = $this->compiler->compileTag('private_print_expression',array(),array('value'=>e));
|
||||
}
|
||||
tag(res) ::= LDEL value(e) modifierlist(l) attributes(a). {
|
||||
res = $this->compiler->compileTag('private_print_expression',a,array('value'=>e, 'modifierlist'=>l));
|
||||
}
|
||||
|
||||
tag(res) ::= LDEL value(e) attributes(a). {
|
||||
res = $this->compiler->compileTag('private_print_expression',a,array('value'=>e));
|
||||
}
|
||||
|
||||
tag(res) ::= LDEL expr(e) modifierlist(l) attributes(a). {
|
||||
res = $this->compiler->compileTag('private_print_expression',a,array('value'=>e,'modifierlist'=>l));
|
||||
tag(res) ::= LDEL expr(e). {
|
||||
res = $this->compiler->compileTag('private_print_expression',array(),array('value'=>e));
|
||||
}
|
||||
|
||||
tag(res) ::= LDEL expr(e) attributes(a). {
|
||||
|
|
|
@ -27,7 +27,7 @@
|
|||
* @author Uwe Tews
|
||||
* @author Rodney Rehm
|
||||
* @package Smarty
|
||||
* @version 3.1.28
|
||||
* @version 3.1.29
|
||||
*/
|
||||
|
||||
/**
|
||||
|
@ -118,7 +118,7 @@ class Smarty extends Smarty_Internal_TemplateBase
|
|||
/**
|
||||
* smarty version
|
||||
*/
|
||||
const SMARTY_VERSION = '3.1.28';
|
||||
const SMARTY_VERSION = '3.1.29';
|
||||
|
||||
/**
|
||||
* define variable scopes
|
||||
|
@ -677,15 +677,20 @@ class Smarty extends Smarty_Internal_TemplateBase
|
|||
/**
|
||||
* removed properties
|
||||
*
|
||||
* @var array
|
||||
* @var string[]
|
||||
*/
|
||||
private static $obsoleteProperties = array('resource_caching', 'template_resource_caching',
|
||||
'direct_access_security', '_dir_perms', '_file_perms',
|
||||
'plugin_search_order', 'inheritance_merge_compiled_includes');
|
||||
|
||||
private static $accessMap = array('template_dir' => 'getTemplateDir', 'config_dir' => 'getConfigDir',
|
||||
'plugins_dir' => 'getPluginsDir', 'compile_dir' => 'getCompileDir',
|
||||
'cache_dir' => 'getCacheDir',);
|
||||
/**
|
||||
* List of private properties which will call getter/setter ona direct access
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
private static $accessMap = array('template_dir' => 'TemplateDir', 'config_dir' => 'ConfigDir',
|
||||
'plugins_dir' => 'PluginsDir', 'compile_dir' => 'CompileDir',
|
||||
'cache_dir' => 'CacheDir',);
|
||||
|
||||
/**#@-*/
|
||||
|
||||
|
@ -1173,7 +1178,7 @@ class Smarty extends Smarty_Internal_TemplateBase
|
|||
$path = str_replace($nds, DS, $path);
|
||||
}
|
||||
|
||||
if ($realpath === true && $path[0] !== '/' && $path[1] !== ':') {
|
||||
if ($realpath === true && (($path[0] !== '/' && DS == '/') || ($path[1] !== ':' && DS != '/'))) {
|
||||
$path = getcwd() . DS . $path;
|
||||
}
|
||||
while ((strpos($path, '.' . DS) !== false) || (strpos($path, DS . DS) !== false)) {
|
||||
|
@ -1344,7 +1349,8 @@ class Smarty extends Smarty_Internal_TemplateBase
|
|||
{
|
||||
|
||||
if (isset(self::$accessMap[$name])) {
|
||||
return $this->{self::$accessMap[$name]}();
|
||||
$method = 'get' . self::$accessMap[$name];
|
||||
return $this->{$method}();
|
||||
} elseif (in_array($name, self::$obsoleteProperties)) {
|
||||
return null;
|
||||
} else {
|
||||
|
@ -1363,7 +1369,8 @@ class Smarty extends Smarty_Internal_TemplateBase
|
|||
public function __set($name, $value)
|
||||
{
|
||||
if (isset(self::$accessMap[$name])) {
|
||||
$this->{self::$accessMap[$name]}($value);
|
||||
$method = 'set' . self::$accessMap[$name];
|
||||
$this->{$method}($value);
|
||||
} elseif (in_array($name, self::$obsoleteProperties)) {
|
||||
return;
|
||||
} else {
|
||||
|
|
|
@ -215,12 +215,9 @@ abstract class Smarty_CacheResource
|
|||
*/
|
||||
public function invalidLoadedCache(Smarty $smarty)
|
||||
{
|
||||
if (isset($smarty->_cache['template_objects'])) {
|
||||
foreach ($smarty->_cache['template_objects'] as $key => $tpl) {
|
||||
if (isset($tpl->cached)) {
|
||||
unset ($smarty->_cache['template_objects'][$key]);
|
||||
}
|
||||
}
|
||||
$smarty->_cache['isCached'] = array();
|
||||
if (isset($smarty->ext->_subtemplate)) {
|
||||
$smarty->ext->_subtemplate->tplObjects = array();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -142,7 +142,7 @@ class Smarty_Internal_Compile_Block extends Smarty_Internal_Compile_Shared_Inher
|
|||
}
|
||||
$compiler->suppressNocacheProcessing = true;
|
||||
$compiler->has_code = true;
|
||||
$output = "<?php \n\$_smarty_tpl->ext->_inheritance->processBlock(\$_smarty_tpl, 3, {$compiler->_cache['blockName'][$compiler->_cache['blockNesting']]}, null, \$_blockParentStack);\n?>\n";
|
||||
$output = "<?php \n\$_smarty_tpl->ext->_inheritance->processBlock(\$_smarty_tpl, 4, {$compiler->_cache['blockName'][$compiler->_cache['blockNesting']]}, null, \$_blockParentStack);\n?>\n";
|
||||
return $output;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -69,13 +69,12 @@ class Smarty_Internal_Compile_Capture extends Smarty_Internal_CompileBase
|
|||
*/
|
||||
public static function compileSpecialVariable($args, Smarty_Internal_TemplateCompilerBase $compiler, $parameter)
|
||||
{
|
||||
// make all lower case
|
||||
$parameter = array_map('strtolower', $parameter);
|
||||
$tag = trim($parameter[0], '"\'');
|
||||
if (!isset($parameter[1]) || false === $name = $compiler->getId($parameter[1])) {
|
||||
$tag = strtolower(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);
|
||||
}
|
||||
return "isset(\$_smarty_tpl->_cache['__smarty_capture']['{$name}']) ? \$_smarty_tpl->_cache['__smarty_capture']['{$name}'] : null";
|
||||
return "(isset(\$_smarty_tpl->_cache['__smarty_capture']['{$name}']) ? \$_smarty_tpl->_cache['__smarty_capture']['{$name}'] : null)";
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -59,7 +59,7 @@ class Smarty_Internal_Compile_Foreach extends Smarty_Internal_Compile_Private_Fo
|
|||
*
|
||||
* @var array
|
||||
*/
|
||||
public static $nameProperties = array('first', 'last', 'index', 'iteration', 'show', 'total');
|
||||
public $nameProperties = array('first', 'last', 'index', 'iteration', 'show', 'total');
|
||||
|
||||
/**
|
||||
* Valid properties of $item@xxx variable
|
||||
|
@ -183,8 +183,10 @@ class Smarty_Internal_Compile_Foreach extends Smarty_Internal_Compile_Private_Fo
|
|||
foreach ($saveVars as $k => $code) {
|
||||
$output .= "{$local}{$k} = {$code}\n";
|
||||
}
|
||||
if (isset($itemAttr['show']) || isset($itemAttr['total']) || isset($namedAttr['total']) || isset($namedAttr['show']) || isset($itemAttr['last']) || isset($namedAttr['last'])) {
|
||||
$output .= "{$local}total = \$_smarty_tpl->smarty->ext->_foreach->count(\$_from);\n";
|
||||
}
|
||||
$output .= "{$itemVar} = new Smarty_Variable();\n";
|
||||
$output .= "{$local}total = \$_smarty_tpl->smarty->ext->_foreach->count(\$_from);\n";
|
||||
if (isset($itemAttr['show'])) {
|
||||
$output .= "{$itemVar}->show = ({$local}total > 0);\n";
|
||||
}
|
||||
|
@ -210,7 +212,6 @@ class Smarty_Internal_Compile_Foreach extends Smarty_Internal_Compile_Private_Fo
|
|||
$output .= "{$foreachVar} = new Smarty_Variable({$_vars});\n";
|
||||
}
|
||||
}
|
||||
$output .= "if ({$local}total) {\n";
|
||||
if (isset($attributes['key'])) {
|
||||
$output .= "\$_smarty_tpl->tpl_vars['{$key}'] = new Smarty_Variable();\n";
|
||||
}
|
||||
|
@ -226,7 +227,9 @@ class Smarty_Internal_Compile_Foreach extends Smarty_Internal_Compile_Private_Fo
|
|||
if ($needIteration) {
|
||||
$output .= "{$local}iteration=0;\n";
|
||||
}
|
||||
$output .= "{$itemVar}->_loop = false;\n";
|
||||
$output .= "foreach (\$_from as {$keyTerm}{$itemVar}->value) {\n";
|
||||
$output .= "{$itemVar}->_loop = true;\n";
|
||||
if (isset($attributes['key']) && isset($itemAttr['key'])) {
|
||||
$output .= "\$_smarty_tpl->tpl_vars['{$key}']->value = {$itemVar}->key;\n";
|
||||
}
|
||||
|
@ -296,7 +299,7 @@ class Smarty_Internal_Compile_Foreachelse extends Smarty_Internal_CompileBase
|
|||
$output = "<?php\n";
|
||||
$output .= "{$itemVar} = {$local}saved_local_item;\n";
|
||||
$output .= "}\n";
|
||||
$output .= "} else {\n?>";
|
||||
$output .= "if (!{$itemVar}->_loop) {\n?>";
|
||||
return $output;
|
||||
}
|
||||
}
|
||||
|
@ -332,7 +335,6 @@ class Smarty_Internal_Compile_Foreachclose extends Smarty_Internal_CompileBase
|
|||
|
||||
if ($restore) {
|
||||
$output .= "{$itemVar} = {$local}saved_local_item;\n";
|
||||
$output .= "}\n";
|
||||
}
|
||||
$output .= "}\n";
|
||||
foreach ($restoreVars as $restore) {
|
||||
|
|
|
@ -50,7 +50,7 @@ class Smarty_Internal_Compile_Private_ForeachSection extends Smarty_Internal_Com
|
|||
*
|
||||
* @var array
|
||||
*/
|
||||
public static $nameProperties = array();
|
||||
public $nameProperties = array();
|
||||
|
||||
/**
|
||||
* {section} tag has no item properties
|
||||
|
@ -112,8 +112,7 @@ class Smarty_Internal_Compile_Private_ForeachSection extends Smarty_Internal_Com
|
|||
if ($named) {
|
||||
$this->resultOffsets['named'] = $this->startOffset + 3;
|
||||
$this->propertyPreg .= "([\$]smarty[.]{$this->tagName}[.]{$attributes['name']}[.](";
|
||||
$className = get_class($this);
|
||||
$properties = $className::$nameProperties;
|
||||
$properties = $this->nameProperties;
|
||||
} else {
|
||||
$this->resultOffsets['item'] = $this->startOffset + 3;
|
||||
$this->propertyPreg .= "([\$]{$attributes['item']}[@](";
|
||||
|
@ -204,17 +203,15 @@ class Smarty_Internal_Compile_Private_ForeachSection extends Smarty_Internal_Com
|
|||
* @return string compiled code
|
||||
* @throws \SmartyCompilerException
|
||||
*/
|
||||
public static function compileSpecialVariable($args, Smarty_Internal_TemplateCompilerBase $compiler, $parameter)
|
||||
public function compileSpecialVariable($args, Smarty_Internal_TemplateCompilerBase $compiler, $parameter)
|
||||
{
|
||||
$tag = strtolower(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);
|
||||
}
|
||||
/* @var Smarty_Internal_Compile_Foreach|Smarty_Internal_Compile_Section $className */
|
||||
$className = 'Smarty_Internal_Compile_' . ucfirst($tag);
|
||||
$property = isset($parameter[ 2 ]) ? strtolower($compiler->getId($parameter[ 2 ])) : false;
|
||||
if (!$property || !in_array($property, $className::$nameProperties)) {
|
||||
if (!$property || !in_array($property, $this->nameProperties)) {
|
||||
$compiler->trigger_template_error("missing or illegal \$smarty.{$tag} property attribute", null, true);
|
||||
}
|
||||
$tagVar = "'__smarty_{$tag}_{$name}'";
|
||||
|
|
|
@ -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 = strtolower($compiler->getId($_index[ 0 ]));
|
||||
if ($variable === false) {
|
||||
$compiler->trigger_template_error("special \$Smarty variable name index can not be variable", null, true);
|
||||
}
|
||||
|
@ -39,7 +39,11 @@ class Smarty_Internal_Compile_Private_Special_Variable extends Smarty_Internal_C
|
|||
switch ($variable) {
|
||||
case 'foreach':
|
||||
case 'section':
|
||||
return Smarty_Internal_Compile_Private_ForeachSection::compileSpecialVariable(array(), $compiler, $_index);
|
||||
if (!isset($compiler->_tag_objects[ $variable ])) {
|
||||
$class = 'Smarty_Internal_Compile_' . ucfirst($variable);
|
||||
$compiler->_tag_objects[ $variable ] = new $class;
|
||||
}
|
||||
return $compiler->_tag_objects[ $variable ]->compileSpecialVariable(array(), $compiler, $_index);
|
||||
case 'capture':
|
||||
if (class_exists('Smarty_Internal_Compile_Capture')) {
|
||||
return Smarty_Internal_Compile_Capture::compileSpecialVariable(array(), $compiler, $_index);
|
||||
|
@ -54,7 +58,8 @@ class Smarty_Internal_Compile_Private_Special_Variable extends Smarty_Internal_C
|
|||
$compiler->trigger_template_error("(secure mode) super globals not permitted");
|
||||
break;
|
||||
}
|
||||
return '$_COOKIE';
|
||||
$compiled_ref = '$_COOKIE';
|
||||
break;
|
||||
case 'get':
|
||||
case 'post':
|
||||
case 'env':
|
||||
|
@ -80,9 +85,7 @@ class Smarty_Internal_Compile_Private_Special_Variable extends Smarty_Internal_C
|
|||
return 'dirname($_smarty_tpl->source->filepath)';
|
||||
|
||||
case 'version':
|
||||
$_version = Smarty::SMARTY_VERSION;
|
||||
|
||||
return "'$_version'";
|
||||
return "Smarty::SMARTY_VERSION";
|
||||
|
||||
case 'const':
|
||||
if (isset($compiler->smarty->security_policy) &&
|
||||
|
@ -91,33 +94,27 @@ class Smarty_Internal_Compile_Private_Special_Variable extends Smarty_Internal_C
|
|||
$compiler->trigger_template_error("(secure mode) constants not permitted");
|
||||
break;
|
||||
}
|
||||
if (strpos($_index[1], '$') === false && strpos($_index[1], '\'') === false) {
|
||||
if (strpos($_index[ 1 ], '$') === false && strpos($_index[ 1 ], '\'') === false) {
|
||||
return "@constant('{$_index[1]}')";
|
||||
} else {
|
||||
return "@constant({$_index[1]})";
|
||||
}
|
||||
|
||||
case 'config':
|
||||
if (isset($_index[2])) {
|
||||
return "(is_array(\$tmp = \$_smarty_tpl->smarty->ext->_config->_getConfigVariable(\$_smarty_tpl, $_index[1])) ? \$tmp[$_index[2]] : null)";
|
||||
if (isset($_index[ 2 ])) {
|
||||
return "(is_array(\$tmp = \$_smarty_tpl->smarty->ext->configload->_getConfigVariable(\$_smarty_tpl, $_index[1])) ? \$tmp[$_index[2]] : null)";
|
||||
} else {
|
||||
return "\$_smarty_tpl->smarty->ext->_config->_getConfigVariable(\$_smarty_tpl, $_index[1])";
|
||||
return "\$_smarty_tpl->smarty->ext->configload->_getConfigVariable(\$_smarty_tpl, $_index[1])";
|
||||
}
|
||||
case 'ldelim':
|
||||
$_ldelim = $compiler->smarty->left_delimiter;
|
||||
|
||||
return "'$_ldelim'";
|
||||
|
||||
return "\$_smarty_tpl->smarty->left_delimiter";
|
||||
case 'rdelim':
|
||||
$_rdelim = $compiler->smarty->right_delimiter;
|
||||
|
||||
return "'$_rdelim'";
|
||||
|
||||
return "\$_smarty_tpl->smarty->right_delimiter";
|
||||
default:
|
||||
$compiler->trigger_template_error('$smarty.' . trim($_index[0], "'") . ' is invalid');
|
||||
$compiler->trigger_template_error('$smarty.' . trim($_index[ 0 ], "'") . ' is not defined');
|
||||
break;
|
||||
}
|
||||
if (isset($_index[1])) {
|
||||
if (isset($_index[ 1 ])) {
|
||||
array_shift($_index);
|
||||
foreach ($_index as $_ind) {
|
||||
$compiled_ref = $compiled_ref . "[$_ind]";
|
||||
|
|
|
@ -59,7 +59,7 @@ class Smarty_Internal_Compile_Section extends Smarty_Internal_Compile_Private_Fo
|
|||
*
|
||||
* @var array
|
||||
*/
|
||||
public static $nameProperties = array('first', 'last', 'index', 'iteration', 'show', 'total', 'rownum',
|
||||
public $nameProperties = array('first', 'last', 'index', 'iteration', 'show', 'total', 'rownum',
|
||||
'index_prev', 'index_next');
|
||||
|
||||
/**
|
||||
|
@ -103,7 +103,7 @@ class Smarty_Internal_Compile_Section extends Smarty_Internal_Compile_Private_Fo
|
|||
// maybe nocache because of nocache variables
|
||||
$compiler->nocache = $compiler->nocache | $compiler->tag_nocache;
|
||||
|
||||
$initLocal = array('saved' => "isset(\$_smarty_tpl->tpl_vars['__smarty_section_{$attributes['name']}']) ? \$_smarty_tpl->tpl_vars['__section_{$attributes['name']}'] : false",);
|
||||
$initLocal = array('saved' => "isset(\$_smarty_tpl->tpl_vars['__smarty_section_{$attributes['name']}']) ? \$_smarty_tpl->tpl_vars['__smarty_section_{$attributes['name']}'] : false",);
|
||||
$initNamedProperty = array();
|
||||
$initFor = array();
|
||||
$incFor = array();
|
||||
|
|
|
@ -187,6 +187,21 @@ class Smarty_Internal_Data
|
|||
return $this->ext->getTemplateVars->getTemplateVars($this, $varName, $_ptr, $searchParents);
|
||||
}
|
||||
|
||||
/**
|
||||
* gets the object of a Smarty variable
|
||||
*
|
||||
* @param string $variable the name of the Smarty variable
|
||||
* @param Smarty_Internal_Data $_ptr optional pointer to data object
|
||||
* @param boolean $searchParents search also in parent data
|
||||
* @param bool $error_enable
|
||||
*
|
||||
* @return Smarty_Variable|Smarty_Undefined_Variable the object of the variable
|
||||
* @deprecated since 3.1.28 please use Smarty_Internal_Data::getTemplateVars() instead.
|
||||
*/
|
||||
public function getVariable($variable = null, Smarty_Internal_Data $_ptr = null, $searchParents = true, $error_enable = true){
|
||||
return $this->ext->getTemplateVars->_getVariable($this, $variable, $_ptr, $searchParents, $error_enable);
|
||||
}
|
||||
|
||||
/**
|
||||
* Follow the parent chain an merge template and config variables
|
||||
*
|
||||
|
|
|
@ -114,14 +114,6 @@ class Smarty_Internal_Extension_Clear
|
|||
}
|
||||
}
|
||||
}
|
||||
// remove from template cache
|
||||
if (isset($smarty->_cache['template_objects'])) {
|
||||
foreach ($smarty->_cache['template_objects'] as $key => $tpl) {
|
||||
if (isset($tpl->cached) && $tpl->cached->filepath == (string) $_file) {
|
||||
unset($smarty->_cache['template_objects'][$key]);
|
||||
}
|
||||
}
|
||||
}
|
||||
$_count += @unlink((string) $_file) ? 1 : 0;
|
||||
if (function_exists('opcache_invalidate')) {
|
||||
opcache_invalidate((string) $_file);
|
||||
|
|
|
@ -34,10 +34,7 @@ class Smarty_Internal_Method_ClearAllCache
|
|||
{
|
||||
// load cache resource and call clearAll
|
||||
$_cache_resource = Smarty_CacheResource::load($smarty, $type);
|
||||
if ($smarty->caching_type != 'file') {
|
||||
$_cache_resource->invalidLoadedCache($smarty);
|
||||
}
|
||||
|
||||
$_cache_resource->invalidLoadedCache($smarty);
|
||||
return $_cache_resource->clearAll($smarty, $exp_time);
|
||||
}
|
||||
}
|
|
@ -37,10 +37,7 @@ class Smarty_Internal_Method_ClearCache
|
|||
{
|
||||
// load cache resource and call clear
|
||||
$_cache_resource = Smarty_CacheResource::load($smarty, $type);
|
||||
if ($smarty->caching_type != 'file' && !isset($template_name)) {
|
||||
$_cache_resource->invalidLoadedCache($smarty);
|
||||
}
|
||||
|
||||
$_cache_resource->invalidLoadedCache($smarty);
|
||||
return $_cache_resource->clear($smarty, $template_name, $cache_id, $compile_id, $exp_time);
|
||||
}
|
||||
}
|
|
@ -107,13 +107,6 @@ class Smarty_Internal_Method_ClearCompiledTemplate
|
|||
}
|
||||
|
||||
if ($unlink && @unlink($_filepath)) {
|
||||
if (isset($smarty->_cache['template_objects'])) {
|
||||
foreach ($smarty->_cache['template_objects'] as $key => $tpl) {
|
||||
if (isset($tpl->compiled) && $tpl->compiled->filepath == $_filepath) {
|
||||
unset($smarty->_cache['template_objects'][$key]);
|
||||
}
|
||||
}
|
||||
}
|
||||
$_count ++;
|
||||
if (function_exists('opcache_invalidate')) {
|
||||
opcache_invalidate($_filepath);
|
||||
|
@ -121,11 +114,10 @@ class Smarty_Internal_Method_ClearCompiledTemplate
|
|||
}
|
||||
}
|
||||
}
|
||||
// clear compiled cache
|
||||
if (!isset($resource_name) && isset($smarty->_cache['source_objects'])) {
|
||||
foreach ($smarty->_cache['source_objects'] as $source) {
|
||||
$source->compileds = array();
|
||||
}
|
||||
// clear template objects cache
|
||||
$smarty->_cache['isCached'] = array();
|
||||
if (isset($smarty->ext->_subtemplate)) {
|
||||
$smarty->ext->_subtemplate->tplObjects = array();
|
||||
}
|
||||
return $_count;
|
||||
}
|
||||
|
|
|
@ -162,7 +162,7 @@ class Smarty_Internal_Method_ConfigLoad
|
|||
*
|
||||
* @return mixed the value of the config variable
|
||||
*/
|
||||
public function _getConfigVariable(\Smarty_Internal_Template $tpl, $varName, $errorEnable = true)
|
||||
public function _getConfigVariable(Smarty_Internal_Template $tpl, $varName, $errorEnable = true)
|
||||
{
|
||||
$_ptr = $tpl;
|
||||
while ($_ptr !== null) {
|
||||
|
|
|
@ -44,7 +44,7 @@ class Smarty_Internal_Resource_Extends extends Smarty_Resource
|
|||
if ($_s->type == 'php') {
|
||||
throw new SmartyException("Resource type {$_s->type} cannot be used with the extends resource type");
|
||||
}
|
||||
$sources[$_s->uid] = $_s;
|
||||
$sources[ $_s->uid ] = $_s;
|
||||
$uid .= $_s->filepath;
|
||||
if ($_template) {
|
||||
$exists = $exists && $_s->exists;
|
||||
|
@ -110,4 +110,15 @@ class Smarty_Internal_Resource_Extends extends Smarty_Resource
|
|||
{
|
||||
return str_replace(':', '.', basename($source->filepath));
|
||||
}
|
||||
|
||||
/*
|
||||
* Disable timestamp checks for extends resource.
|
||||
* The individual source components will be checked.
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function checkTimestamps()
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -89,6 +89,6 @@ class Smarty_Internal_Runtime_CodeFrame
|
|||
$output .= $functions;
|
||||
$output .= "<?php }\n";
|
||||
// remove unneeded PHP tags
|
||||
return preg_replace('/\s*\?>[\n]?<\?php\s*/', "\n", $output);
|
||||
return preg_replace(array('/\s*\?>[\n]?<\?php\s*/', '/\?>\s*$/'), array("\n", ''), $output);
|
||||
}
|
||||
}
|
|
@ -60,11 +60,7 @@ class Smarty_Internal_Runtime_FilterHandler
|
|||
// loop over registered filters of specified type
|
||||
if (!empty($template->smarty->registered_filters[$type])) {
|
||||
foreach ($template->smarty->registered_filters[$type] as $key => $name) {
|
||||
if (is_array($template->smarty->registered_filters[$type][$key])) {
|
||||
$content = call_user_func($template->smarty->registered_filters[$type][$key], $content, $template);
|
||||
} else {
|
||||
$content = $template->smarty->registered_filters[$type][$key]($content, $template);
|
||||
}
|
||||
$content = call_user_func($template->smarty->registered_filters[$type][$key], $content, $template);
|
||||
}
|
||||
}
|
||||
// return filtered output
|
||||
|
|
|
@ -27,6 +27,9 @@ class Smarty_Internal_Runtime_Foreach
|
|||
// thus rewind() and valid() methods may not be present
|
||||
return iterator_count($value->getIterator());
|
||||
} elseif ($value instanceof Iterator) {
|
||||
if ($value instanceof Generator) {
|
||||
return 1;
|
||||
}
|
||||
return iterator_count($value);
|
||||
} elseif ($value instanceof PDOStatement) {
|
||||
return $value->rowCount();
|
||||
|
|
|
@ -127,8 +127,11 @@ class Smarty_Internal_Runtime_Inheritance
|
|||
* - search in inheritance template hierarchy for child blocks
|
||||
* if found call it, otherwise ignore
|
||||
*
|
||||
* $type 3 = {$smarty.block.parent}:
|
||||
* - get block id from parent stack and call parent block
|
||||
* $type 3 = {block append} {block prepend}:
|
||||
* - call parent block
|
||||
*
|
||||
* $type 4 = {$smarty.block.parent}:
|
||||
* - call parent block
|
||||
*
|
||||
* @param \Smarty_Internal_Template $tpl template object of caller
|
||||
* @param int $type call type see above
|
||||
|
@ -140,16 +143,22 @@ class Smarty_Internal_Runtime_Inheritance
|
|||
*/
|
||||
public function processBlock(Smarty_Internal_Template $tpl, $type = 0, $name, $block, $callStack = array())
|
||||
{
|
||||
if (!isset($this->blockParameter[$name])) {
|
||||
$this->blockParameter[$name] = array();
|
||||
if (!isset($this->blockParameter[ $name ])) {
|
||||
$this->blockParameter[ $name ] = array();
|
||||
}
|
||||
if ($this->state == 1) {
|
||||
$block[2] = count($this->blockParameter[$name]);
|
||||
$block[3] = $this->tplIndex;
|
||||
$this->blockParameter[$name][] = $block;
|
||||
$block[ 2 ] = count($this->blockParameter[ $name ]);
|
||||
$block[ 3 ] = $this->tplIndex;
|
||||
$this->blockParameter[ $name ][] = $block;
|
||||
return;
|
||||
}
|
||||
if ($type == 3) {
|
||||
if (!empty($callStack)) {
|
||||
$block = array_shift($callStack);
|
||||
} else {
|
||||
return;
|
||||
}
|
||||
} elseif ($type == 4) {
|
||||
if (!empty($callStack)) {
|
||||
array_shift($callStack);
|
||||
if (empty($callStack)) {
|
||||
|
@ -160,23 +169,23 @@ class Smarty_Internal_Runtime_Inheritance
|
|||
return;
|
||||
}
|
||||
} else {
|
||||
$blockParameter = &$this->blockParameter[$name];
|
||||
$index = 0;
|
||||
$blockParameter = &$this->blockParameter[ $name ];
|
||||
if ($type == 0) {
|
||||
$index = $block[2] = count($blockParameter);
|
||||
$block[3] = $this->tplIndex;
|
||||
$index = $block[ 2 ] = count($blockParameter);
|
||||
$block[ 3 ] = $this->tplIndex;
|
||||
$callStack = array(&$block);
|
||||
} elseif ($type == 1) {
|
||||
$block[3] = $callStack[0][3];
|
||||
$index = 0;
|
||||
$block[ 3 ] = $callStack[ 0 ][ 3 ];
|
||||
for ($i = 0; $i < count($blockParameter); $i ++) {
|
||||
if ($blockParameter[$i][3] <= $block[3]) {
|
||||
$index = $blockParameter[$i][2];
|
||||
if ($blockParameter[ $i ][ 3 ] <= $block[ 3 ]) {
|
||||
$index = $blockParameter[ $i ][ 2 ];
|
||||
}
|
||||
}
|
||||
$block[2] = $index;
|
||||
$block[ 2 ] = $index;
|
||||
$callStack = array(&$block);
|
||||
} else {
|
||||
$index = $callStack[0][2];
|
||||
} elseif ($type == 2) {
|
||||
$index = $callStack[ 0 ][ 2 ];
|
||||
if ($index == 0) {
|
||||
return;
|
||||
}
|
||||
|
@ -184,29 +193,40 @@ class Smarty_Internal_Runtime_Inheritance
|
|||
}
|
||||
$index --;
|
||||
// find lowest level child block
|
||||
while ($index >= 0 && ($type || !$block[1])) {
|
||||
$block = &$blockParameter[$index];
|
||||
while ($index >= 0 && ($type || !$block[ 1 ])) {
|
||||
$block = &$blockParameter[ $index ];
|
||||
array_unshift($callStack, $block);
|
||||
if ($block[1]) {
|
||||
if ($block[ 1 ]) {
|
||||
break;
|
||||
}
|
||||
$index --;
|
||||
}
|
||||
if (isset($block['hide']) && $index <= 0) {
|
||||
if (isset($block[ 'hide' ]) && $index <= 0) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
$this->blockNesting ++;
|
||||
if (isset($block['append'])) {
|
||||
$this->processBlock($tpl, 3, $name, null, $callStack);
|
||||
// {block append} ?
|
||||
if (isset($block[ 'append' ])) {
|
||||
$appendStack = $callStack;
|
||||
if ($type == 0) {
|
||||
array_shift($appendStack);
|
||||
}
|
||||
$this->processBlock($tpl, 3, $name, null, $appendStack);
|
||||
}
|
||||
// call block of current stack level
|
||||
if (isset($block[6])) {
|
||||
$block[6]($tpl, $callStack);
|
||||
} else {
|
||||
$block[0]($tpl, $callStack);
|
||||
}
|
||||
if (isset($block['prepend'])) {
|
||||
$this->processBlock($tpl, 3, $name, null, $callStack);
|
||||
// {block prepend} ?
|
||||
if (isset($block[ 'prepend' ])) {
|
||||
$prependStack = $callStack;
|
||||
if ($type == 0) {
|
||||
array_shift($prependStack);
|
||||
}
|
||||
$this->processBlock($tpl, 3, $name, null, $prependStack);
|
||||
}
|
||||
$this->blockNesting --;
|
||||
}
|
||||
|
|
|
@ -20,7 +20,7 @@ class Smarty_Internal_Runtime_TplFunction
|
|||
*
|
||||
* @throws \SmartyException
|
||||
*/
|
||||
public function callTemplateFunction(\Smarty_Internal_Template $tpl, $name, $params, $nocache)
|
||||
public function callTemplateFunction(Smarty_Internal_Template $tpl, $name, $params, $nocache)
|
||||
{
|
||||
if (isset($tpl->tpl_function[$name])) {
|
||||
if (!$tpl->caching || ($tpl->caching && $nocache)) {
|
||||
|
|
|
@ -73,7 +73,7 @@ class Smarty_Internal_Runtime_UpdateCache
|
|||
|
||||
/**
|
||||
* Cache was invalid , so render from compiled and write to cache
|
||||
*
|
||||
*
|
||||
* @param \Smarty_Template_Cached $cached
|
||||
* @param \Smarty_Internal_Template $_template
|
||||
* @param $no_output_filter
|
||||
|
@ -129,20 +129,6 @@ class Smarty_Internal_Runtime_UpdateCache
|
|||
return false;
|
||||
}
|
||||
$content = $_template->smarty->ext->_codeFrame->create($_template, $content, '', true);
|
||||
if (!empty($_template->cached->tpl_function)) {
|
||||
foreach ($_template->cached->tpl_function as $funcParam) {
|
||||
if (is_file($funcParam['compiled_filepath'])) {
|
||||
// read compiled file
|
||||
$code = file_get_contents($funcParam['compiled_filepath']);
|
||||
// grab template function
|
||||
if (preg_match("/\/\* {$funcParam['call_name']} \*\/([\S\s]*?)\/\*\/ {$funcParam['call_name']} \*\//",
|
||||
$code, $match)) {
|
||||
unset($code);
|
||||
$content .= "<?php " . $match[0] . "?>\n";
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return $this->write($cached, $_template, $content);
|
||||
}
|
||||
|
||||
|
|
|
@ -17,7 +17,7 @@ class Smarty_Internal_Runtime_UpdateScope
|
|||
* @param string $varName variable name
|
||||
* @param int $scope scope to which bubble up variable value
|
||||
*/
|
||||
public function updateScope(\Smarty_Internal_Template $tpl, $varName, $scope = Smarty::SCOPE_LOCAL)
|
||||
public function updateScope(Smarty_Internal_Template $tpl, $varName, $scope = Smarty::SCOPE_LOCAL)
|
||||
{
|
||||
if (!$scope && !$tpl->scope) {
|
||||
return;
|
||||
|
|
|
@ -43,8 +43,13 @@ class Smarty_Internal_Runtime_ValidateCompiled
|
|||
} elseif ($_file_to_check[2] == 'string') {
|
||||
continue;
|
||||
} else {
|
||||
$source = Smarty_Template_Source::load(null, $tpl->smarty, $_file_to_check[0]);
|
||||
$mtime = $source->getTimeStamp();
|
||||
$handler = Smarty_Resource::load($tpl->smarty, $_file_to_check[2]);
|
||||
if ($handler->checkTimestamps()) {
|
||||
$source = Smarty_Template_Source::load($tpl, $tpl->smarty, $_file_to_check[ 0 ]);
|
||||
$mtime = $source->getTimeStamp();
|
||||
} else {
|
||||
continue;
|
||||
}
|
||||
}
|
||||
if (!$mtime || $mtime > $_file_to_check[1]) {
|
||||
$is_valid = false;
|
||||
|
|
|
@ -17,7 +17,7 @@ class Smarty_Internal_Runtime_Var
|
|||
* @param string $varName template variable name
|
||||
* @param bool $nocache cache mode of variable
|
||||
*/
|
||||
public function createLocalArrayVariable(\Smarty_Internal_Template $tpl, $varName, $nocache = false)
|
||||
public function createLocalArrayVariable(Smarty_Internal_Template $tpl, $varName, $nocache = false)
|
||||
{
|
||||
if (!isset($tpl->tpl_vars[$varName])) {
|
||||
$tpl->tpl_vars[$varName] = new Smarty_Variable(array(), $nocache);
|
||||
|
|
|
@ -328,7 +328,8 @@ abstract class Smarty_Internal_TemplateCompilerBase
|
|||
$this->compileTemplateSource($template, $nocache,
|
||||
$parent_compiler),
|
||||
$this->postFilter($this->blockOrFunctionCode) .
|
||||
join('', $this->mergedSubTemplatesCode), false, $this);
|
||||
join('', $this->mergedSubTemplatesCode), false,
|
||||
$this);
|
||||
return $_compiled_code;
|
||||
}
|
||||
|
||||
|
@ -374,7 +375,7 @@ abstract class Smarty_Internal_TemplateCompilerBase
|
|||
$this->has_variable_string = false;
|
||||
$this->prefix_code = array();
|
||||
// add file dependency
|
||||
$this->parent_compiler->template->compiled->file_dependency[$this->template->source->uid] =
|
||||
$this->parent_compiler->template->compiled->file_dependency[ $this->template->source->uid ] =
|
||||
array($this->template->source->filepath, $this->template->source->getTimeStamp(),
|
||||
$this->template->source->type);
|
||||
$this->smarty->_current_file = $this->template->source->filepath;
|
||||
|
@ -423,7 +424,7 @@ abstract class Smarty_Internal_TemplateCompilerBase
|
|||
{
|
||||
// run post filter if on code
|
||||
if (!empty($code) &&
|
||||
(isset($this->smarty->autoload_filters['post']) || isset($this->smarty->registered_filters['post']))
|
||||
(isset($this->smarty->autoload_filters[ 'post' ]) || isset($this->smarty->registered_filters[ 'post' ]))
|
||||
) {
|
||||
return $this->smarty->ext->_filterHandler->runFilter('post', $code, $this->template);
|
||||
} else {
|
||||
|
@ -443,7 +444,7 @@ abstract class Smarty_Internal_TemplateCompilerBase
|
|||
{
|
||||
// run pre filter if required
|
||||
if ($_content != '' &&
|
||||
((isset($this->smarty->autoload_filters['pre']) || isset($this->smarty->registered_filters['pre'])))
|
||||
((isset($this->smarty->autoload_filters[ 'pre' ]) || isset($this->smarty->registered_filters[ 'pre' ])))
|
||||
) {
|
||||
return $this->smarty->ext->_filterHandler->runFilter('pre', $_content, $this->template);
|
||||
} else {
|
||||
|
@ -496,8 +497,8 @@ abstract class Smarty_Internal_TemplateCompilerBase
|
|||
$this->has_code = true;
|
||||
$this->has_output = false;
|
||||
// log tag/attributes
|
||||
if (isset($this->smarty->_cache['get_used_tags'])) {
|
||||
$this->template->_cache['used_tags'][] = array($tag, $args);
|
||||
if (isset($this->smarty->_cache[ 'get_used_tags' ])) {
|
||||
$this->template->_cache[ 'used_tags' ][] = array($tag, $args);
|
||||
}
|
||||
// check nocache option flag
|
||||
if (in_array("'nocache'", $args) || in_array(array('nocache' => 'true'), $args) ||
|
||||
|
@ -507,9 +508,9 @@ abstract class Smarty_Internal_TemplateCompilerBase
|
|||
}
|
||||
// compile the smarty tag (required compile classes to compile the tag are auto loaded)
|
||||
if (($_output = $this->callTagCompiler($tag, $args, $parameter)) === false) {
|
||||
if (isset($this->parent_compiler->template->tpl_function[$tag])) {
|
||||
if (isset($this->parent_compiler->template->tpl_function[ $tag ])) {
|
||||
// template defined by {template} tag
|
||||
$args['_attr']['name'] = "'" . $tag . "'";
|
||||
$args[ '_attr' ][ 'name' ] = "'" . $tag . "'";
|
||||
$_output = $this->callTagCompiler('call', $args, $parameter);
|
||||
}
|
||||
}
|
||||
|
@ -529,8 +530,8 @@ abstract class Smarty_Internal_TemplateCompilerBase
|
|||
return null;
|
||||
} else {
|
||||
// map_named attributes
|
||||
if (isset($args['_attr'])) {
|
||||
foreach ($args['_attr'] as $key => $attribute) {
|
||||
if (isset($args[ '_attr' ])) {
|
||||
foreach ($args[ '_attr' ] as $key => $attribute) {
|
||||
if (is_array($attribute)) {
|
||||
$args = array_merge($args, $attribute);
|
||||
}
|
||||
|
@ -539,14 +540,14 @@ abstract class Smarty_Internal_TemplateCompilerBase
|
|||
// not an internal compiler tag
|
||||
if (strlen($tag) < 6 || substr($tag, - 5) != 'close') {
|
||||
// check if tag is a registered object
|
||||
if (isset($this->smarty->registered_objects[$tag]) && isset($parameter['object_method'])) {
|
||||
$method = $parameter['object_method'];
|
||||
if (!in_array($method, $this->smarty->registered_objects[$tag][3]) &&
|
||||
(empty($this->smarty->registered_objects[$tag][1]) ||
|
||||
in_array($method, $this->smarty->registered_objects[$tag][1]))
|
||||
if (isset($this->smarty->registered_objects[ $tag ]) && isset($parameter[ 'object_method' ])) {
|
||||
$method = $parameter[ 'object_method' ];
|
||||
if (!in_array($method, $this->smarty->registered_objects[ $tag ][ 3 ]) &&
|
||||
(empty($this->smarty->registered_objects[ $tag ][ 1 ]) ||
|
||||
in_array($method, $this->smarty->registered_objects[ $tag ][ 1 ]))
|
||||
) {
|
||||
return $this->callTagCompiler('private_object_function', $args, $parameter, $tag, $method);
|
||||
} elseif (in_array($method, $this->smarty->registered_objects[$tag][3])) {
|
||||
} elseif (in_array($method, $this->smarty->registered_objects[ $tag ][ 3 ])) {
|
||||
return $this->callTagCompiler('private_object_block_function', $args, $parameter, $tag,
|
||||
$method);
|
||||
} else {
|
||||
|
@ -558,7 +559,7 @@ abstract class Smarty_Internal_TemplateCompilerBase
|
|||
// check if tag is registered
|
||||
foreach (array(Smarty::PLUGIN_COMPILER, Smarty::PLUGIN_FUNCTION, Smarty::PLUGIN_BLOCK) as $plugin_type)
|
||||
{
|
||||
if (isset($this->smarty->registered_plugins[$plugin_type][$tag])) {
|
||||
if (isset($this->smarty->registered_plugins[ $plugin_type ][ $tag ])) {
|
||||
// if compiler function plugin call it now
|
||||
if ($plugin_type == Smarty::PLUGIN_COMPILER) {
|
||||
$new_args = array();
|
||||
|
@ -566,18 +567,18 @@ abstract class Smarty_Internal_TemplateCompilerBase
|
|||
if (is_array($mixed)) {
|
||||
$new_args = array_merge($new_args, $mixed);
|
||||
} else {
|
||||
$new_args[$key] = $mixed;
|
||||
$new_args[ $key ] = $mixed;
|
||||
}
|
||||
}
|
||||
if (!$this->smarty->registered_plugins[$plugin_type][$tag][1]) {
|
||||
if (!$this->smarty->registered_plugins[ $plugin_type ][ $tag ][ 1 ]) {
|
||||
$this->tag_nocache = true;
|
||||
}
|
||||
$function = $this->smarty->registered_plugins[$plugin_type][$tag][0];
|
||||
$function = $this->smarty->registered_plugins[ $plugin_type ][ $tag ][ 0 ];
|
||||
if (!is_array($function)) {
|
||||
return $function($new_args, $this);
|
||||
} elseif (is_object($function[0])) {
|
||||
return $this->smarty->registered_plugins[$plugin_type][$tag][0][0]->{$function[1]}($new_args,
|
||||
$this);
|
||||
} elseif (is_object($function[ 0 ])) {
|
||||
return $this->smarty->registered_plugins[ $plugin_type ][ $tag ][ 0 ][ 0 ]->{$function[ 1 ]}($new_args,
|
||||
$this);
|
||||
} else {
|
||||
return call_user_func_array($function, array($new_args, $this));
|
||||
}
|
||||
|
@ -604,7 +605,7 @@ abstract class Smarty_Internal_TemplateCompilerBase
|
|||
if (is_array($mixed)) {
|
||||
$new_args = array_merge($new_args, $mixed);
|
||||
} else {
|
||||
$new_args[$key] = $mixed;
|
||||
$new_args[ $key ] = $mixed;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -632,7 +633,7 @@ abstract class Smarty_Internal_TemplateCompilerBase
|
|||
$found = false;
|
||||
// look for already resolved tags
|
||||
foreach ($this->plugin_search_order as $plugin_type) {
|
||||
if (isset($this->default_handler_plugins[$plugin_type][$tag])) {
|
||||
if (isset($this->default_handler_plugins[ $plugin_type ][ $tag ])) {
|
||||
$found = true;
|
||||
break;
|
||||
}
|
||||
|
@ -653,12 +654,12 @@ abstract class Smarty_Internal_TemplateCompilerBase
|
|||
foreach ($args as $mixed) {
|
||||
$new_args = array_merge($new_args, $mixed);
|
||||
}
|
||||
$function = $this->default_handler_plugins[$plugin_type][$tag][0];
|
||||
$function = $this->default_handler_plugins[ $plugin_type ][ $tag ][ 0 ];
|
||||
if (!is_array($function)) {
|
||||
return $function($new_args, $this);
|
||||
} elseif (is_object($function[0])) {
|
||||
return $this->default_handler_plugins[$plugin_type][$tag][0][0]->$function[1]($new_args,
|
||||
$this);
|
||||
} elseif (is_object($function[ 0 ])) {
|
||||
return $this->default_handler_plugins[ $plugin_type ][ $tag ][ 0 ][ 0 ]->$function[ 1 ]($new_args,
|
||||
$this);
|
||||
} else {
|
||||
return call_user_func_array($function, array($new_args, $this));
|
||||
}
|
||||
|
@ -672,9 +673,9 @@ abstract class Smarty_Internal_TemplateCompilerBase
|
|||
// compile closing tag of block function
|
||||
$base_tag = substr($tag, 0, - 5);
|
||||
// check if closing tag is a registered object
|
||||
if (isset($this->smarty->registered_objects[$base_tag]) && isset($parameter['object_method'])) {
|
||||
$method = $parameter['object_method'];
|
||||
if (in_array($method, $this->smarty->registered_objects[$base_tag][3])) {
|
||||
if (isset($this->smarty->registered_objects[ $base_tag ]) && isset($parameter[ 'object_method' ])) {
|
||||
$method = $parameter[ 'object_method' ];
|
||||
if (in_array($method, $this->smarty->registered_objects[ $base_tag ][ 3 ])) {
|
||||
return $this->callTagCompiler('private_object_block_function', $args, $parameter, $tag,
|
||||
$method);
|
||||
} else {
|
||||
|
@ -684,13 +685,13 @@ abstract class Smarty_Internal_TemplateCompilerBase
|
|||
}
|
||||
}
|
||||
// registered block tag ?
|
||||
if (isset($this->smarty->registered_plugins[Smarty::PLUGIN_BLOCK][$base_tag]) ||
|
||||
isset($this->default_handler_plugins[Smarty::PLUGIN_BLOCK][$base_tag])
|
||||
if (isset($this->smarty->registered_plugins[ Smarty::PLUGIN_BLOCK ][ $base_tag ]) ||
|
||||
isset($this->default_handler_plugins[ Smarty::PLUGIN_BLOCK ][ $base_tag ])
|
||||
) {
|
||||
return $this->callTagCompiler('private_registered_block', $args, $parameter, $tag);
|
||||
}
|
||||
// registered function tag ?
|
||||
if (isset($this->smarty->registered_plugins[Smarty::PLUGIN_FUNCTION][$tag])) {
|
||||
if (isset($this->smarty->registered_plugins[ Smarty::PLUGIN_FUNCTION ][ $tag ])) {
|
||||
return $this->callTagCompiler('private_registered_function', $args, $parameter, $tag);
|
||||
}
|
||||
// block plugin?
|
||||
|
@ -706,18 +707,18 @@ abstract class Smarty_Internal_TemplateCompilerBase
|
|||
}
|
||||
}
|
||||
// registered compiler plugin ?
|
||||
if (isset($this->smarty->registered_plugins[Smarty::PLUGIN_COMPILER][$tag])) {
|
||||
if (isset($this->smarty->registered_plugins[ Smarty::PLUGIN_COMPILER ][ $tag ])) {
|
||||
// if compiler function plugin call it now
|
||||
$args = array();
|
||||
if (!$this->smarty->registered_plugins[Smarty::PLUGIN_COMPILER][$tag][1]) {
|
||||
if (!$this->smarty->registered_plugins[ Smarty::PLUGIN_COMPILER ][ $tag ][ 1 ]) {
|
||||
$this->tag_nocache = true;
|
||||
}
|
||||
$function = $this->smarty->registered_plugins[Smarty::PLUGIN_COMPILER][$tag][0];
|
||||
$function = $this->smarty->registered_plugins[ Smarty::PLUGIN_COMPILER ][ $tag ][ 0 ];
|
||||
if (!is_array($function)) {
|
||||
return $function($args, $this);
|
||||
} elseif (is_object($function[0])) {
|
||||
return $this->smarty->registered_plugins[Smarty::PLUGIN_COMPILER][$tag][0][0]->$function[1]($args,
|
||||
$this);
|
||||
} elseif (is_object($function[ 0 ])) {
|
||||
return $this->smarty->registered_plugins[ Smarty::PLUGIN_COMPILER ][ $tag ][ 0 ][ 0 ]->$function[ 1 ]($args,
|
||||
$this);
|
||||
} else {
|
||||
return call_user_func_array($function, array($args, $this));
|
||||
}
|
||||
|
@ -783,58 +784,57 @@ abstract class Smarty_Internal_TemplateCompilerBase
|
|||
*/
|
||||
public function processText($text)
|
||||
{
|
||||
$store = array();
|
||||
$_store = 0;
|
||||
$_offset = 0;
|
||||
if ($this->parser->strip) {
|
||||
if (strpos($text, '<') !== false) {
|
||||
// capture html elements not to be messed with
|
||||
$_offset = 0;
|
||||
if (preg_match_all('#(<script[^>]*>.*?</script[^>]*>)|(<textarea[^>]*>.*?</textarea[^>]*>)|(<pre[^>]*>.*?</pre[^>]*>)#is',
|
||||
$text, $matches, PREG_OFFSET_CAPTURE | PREG_SET_ORDER)) {
|
||||
foreach ($matches as $match) {
|
||||
$store[] = $match[ 0 ][ 0 ];
|
||||
$_length = strlen($match[ 0 ][ 0 ]);
|
||||
$replace = '@!@SMARTY:' . $_store . ':SMARTY@!@';
|
||||
$text = substr_replace($text, $replace, $match[ 0 ][ 1 ] - $_offset, $_length);
|
||||
if ((string) $text != '') {
|
||||
$store = array();
|
||||
$_store = 0;
|
||||
$_offset = 0;
|
||||
if ($this->parser->strip) {
|
||||
if (strpos($text, '<') !== false) {
|
||||
// capture html elements not to be messed with
|
||||
$_offset = 0;
|
||||
if (preg_match_all('#(<script[^>]*>.*?</script[^>]*>)|(<textarea[^>]*>.*?</textarea[^>]*>)|(<pre[^>]*>.*?</pre[^>]*>)#is',
|
||||
$text, $matches, PREG_OFFSET_CAPTURE | PREG_SET_ORDER)) {
|
||||
foreach ($matches as $match) {
|
||||
$store[] = $match[ 0 ][ 0 ];
|
||||
$_length = strlen($match[ 0 ][ 0 ]);
|
||||
$replace = '@!@SMARTY:' . $_store . ':SMARTY@!@';
|
||||
$text = substr_replace($text, $replace, $match[ 0 ][ 1 ] - $_offset, $_length);
|
||||
|
||||
$_offset += $_length - strlen($replace);
|
||||
$_store ++;
|
||||
$_offset += $_length - strlen($replace);
|
||||
$_store ++;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$expressions = array(// replace multiple spaces between tags by a single space
|
||||
// can't remove them entirely, becaue that might break poorly implemented CSS display:inline-block elements
|
||||
'#(:SMARTY@!@|>)\s+(?=@!@SMARTY:|<)#s' => '\1 \2',
|
||||
// remove spaces between attributes (but not in attribute values!)
|
||||
'#(([a-z0-9]\s*=\s*("[^"]*?")|(\'[^\']*?\'))|<[a-z0-9_]+)\s+([a-z/>])#is' => '\1 \5',
|
||||
'#^\s+<#Ss' => '<',
|
||||
'#>\s+$#Ss' => '>',
|
||||
$this->stripRegEx => ''
|
||||
);
|
||||
$expressions = array(// replace multiple spaces between tags by a single space
|
||||
// can't remove them entirely, becaue that might break poorly implemented CSS display:inline-block elements
|
||||
'#(:SMARTY@!@|>)\s+(?=@!@SMARTY:|<)#s' => '\1 \2',
|
||||
// remove spaces between attributes (but not in attribute values!)
|
||||
'#(([a-z0-9]\s*=\s*("[^"]*?")|(\'[^\']*?\'))|<[a-z0-9_]+)\s+([a-z/>])#is' => '\1 \5',
|
||||
'#^\s+<#Ss' => '<',
|
||||
'#>\s+$#Ss' => '>',
|
||||
$this->stripRegEx => '');
|
||||
|
||||
$text = preg_replace(array_keys($expressions), array_values($expressions), $text);
|
||||
$_offset = 0;
|
||||
if (preg_match_all('#@!@SMARTY:([0-9]+):SMARTY@!@#is', $text, $matches,
|
||||
PREG_OFFSET_CAPTURE | PREG_SET_ORDER)) {
|
||||
foreach ($matches as $match) {
|
||||
$_length = strlen($match[ 0 ][ 0 ]);
|
||||
$replace = $store[ $match[ 1 ][ 0 ] ];
|
||||
$text = substr_replace($text, $replace, $match[ 0 ][ 1 ] + $_offset, $_length);
|
||||
$text = preg_replace(array_keys($expressions), array_values($expressions), $text);
|
||||
$_offset = 0;
|
||||
if (preg_match_all('#@!@SMARTY:([0-9]+):SMARTY@!@#is', $text, $matches,
|
||||
PREG_OFFSET_CAPTURE | PREG_SET_ORDER)) {
|
||||
foreach ($matches as $match) {
|
||||
$_length = strlen($match[ 0 ][ 0 ]);
|
||||
$replace = $store[ $match[ 1 ][ 0 ] ];
|
||||
$text = substr_replace($text, $replace, $match[ 0 ][ 1 ] + $_offset, $_length);
|
||||
|
||||
$_offset += strlen($replace) - $_length;
|
||||
$_store ++;
|
||||
$_offset += strlen($replace) - $_length;
|
||||
$_store ++;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
$text = preg_replace($this->stripRegEx, '', $text);
|
||||
}
|
||||
} else {
|
||||
$text = preg_replace($this->stripRegEx, '', $text);
|
||||
}
|
||||
}
|
||||
if ($text) {
|
||||
return new Smarty_Internal_ParseTree_Text($text);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* lazy loads internal compile plugin for tag and calls the compile method
|
||||
|
@ -853,7 +853,7 @@ abstract class Smarty_Internal_TemplateCompilerBase
|
|||
public function callTagCompiler($tag, $args, $param1 = null, $param2 = null, $param3 = null)
|
||||
{
|
||||
// re-use object if already exists
|
||||
if (!isset($this->_tag_objects[$tag])) {
|
||||
if (!isset($this->_tag_objects[ $tag ])) {
|
||||
// lazy load internal compiler plugin
|
||||
$_tag = explode('_', $tag);
|
||||
$_tag = array_map('ucfirst', $_tag);
|
||||
|
@ -861,15 +861,15 @@ abstract class Smarty_Internal_TemplateCompilerBase
|
|||
if (class_exists($class_name) &&
|
||||
(!isset($this->smarty->security_policy) || $this->smarty->security_policy->isTrustedTag($tag, $this))
|
||||
) {
|
||||
$this->_tag_objects[$tag] = new $class_name;
|
||||
$this->_tag_objects[ $tag ] = new $class_name;
|
||||
} else {
|
||||
$this->_tag_objects[$tag] = false;
|
||||
$this->_tag_objects[ $tag ] = false;
|
||||
return false;
|
||||
}
|
||||
}
|
||||
// compile this tag
|
||||
return $this->_tag_objects[$tag] === false ? false :
|
||||
$this->_tag_objects[$tag]->compile($args, $this, $param1, $param2, $param3);
|
||||
return $this->_tag_objects[ $tag ] === false ? false :
|
||||
$this->_tag_objects[ $tag ]->compile($args, $this, $param1, $param2, $param3);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -884,29 +884,29 @@ abstract class Smarty_Internal_TemplateCompilerBase
|
|||
{
|
||||
$function = null;
|
||||
if ($this->template->caching && ($this->nocache || $this->tag_nocache)) {
|
||||
if (isset($this->parent_compiler->template->compiled->required_plugins['nocache'][$plugin_name][$plugin_type])) {
|
||||
if (isset($this->parent_compiler->template->compiled->required_plugins[ 'nocache' ][ $plugin_name ][ $plugin_type ])) {
|
||||
$function =
|
||||
$this->parent_compiler->template->compiled->required_plugins['nocache'][$plugin_name][$plugin_type]['function'];
|
||||
} elseif (isset($this->parent_compiler->template->compiled->required_plugins['compiled'][$plugin_name][$plugin_type])) {
|
||||
$this->parent_compiler->template->compiled->required_plugins['nocache'][$plugin_name][$plugin_type] =
|
||||
$this->parent_compiler->template->compiled->required_plugins['compiled'][$plugin_name][$plugin_type];
|
||||
$this->parent_compiler->template->compiled->required_plugins[ 'nocache' ][ $plugin_name ][ $plugin_type ][ 'function' ];
|
||||
} elseif (isset($this->parent_compiler->template->compiled->required_plugins[ 'compiled' ][ $plugin_name ][ $plugin_type ])) {
|
||||
$this->parent_compiler->template->compiled->required_plugins[ 'nocache' ][ $plugin_name ][ $plugin_type ] =
|
||||
$this->parent_compiler->template->compiled->required_plugins[ 'compiled' ][ $plugin_name ][ $plugin_type ];
|
||||
$function =
|
||||
$this->parent_compiler->template->compiled->required_plugins['nocache'][$plugin_name][$plugin_type]['function'];
|
||||
$this->parent_compiler->template->compiled->required_plugins[ 'nocache' ][ $plugin_name ][ $plugin_type ][ 'function' ];
|
||||
}
|
||||
} else {
|
||||
if (isset($this->parent_compiler->template->compiled->required_plugins['compiled'][$plugin_name][$plugin_type])) {
|
||||
if (isset($this->parent_compiler->template->compiled->required_plugins[ 'compiled' ][ $plugin_name ][ $plugin_type ])) {
|
||||
$function =
|
||||
$this->parent_compiler->template->compiled->required_plugins['compiled'][$plugin_name][$plugin_type]['function'];
|
||||
} elseif (isset($this->parent_compiler->template->compiled->required_plugins['nocache'][$plugin_name][$plugin_type])) {
|
||||
$this->parent_compiler->template->compiled->required_plugins['compiled'][$plugin_name][$plugin_type] =
|
||||
$this->parent_compiler->template->compiled->required_plugins['nocache'][$plugin_name][$plugin_type];
|
||||
$this->parent_compiler->template->compiled->required_plugins[ 'compiled' ][ $plugin_name ][ $plugin_type ][ 'function' ];
|
||||
} elseif (isset($this->parent_compiler->template->compiled->required_plugins[ 'nocache' ][ $plugin_name ][ $plugin_type ])) {
|
||||
$this->parent_compiler->template->compiled->required_plugins[ 'compiled' ][ $plugin_name ][ $plugin_type ] =
|
||||
$this->parent_compiler->template->compiled->required_plugins[ 'nocache' ][ $plugin_name ][ $plugin_type ];
|
||||
$function =
|
||||
$this->parent_compiler->template->compiled->required_plugins['compiled'][$plugin_name][$plugin_type]['function'];
|
||||
$this->parent_compiler->template->compiled->required_plugins[ 'compiled' ][ $plugin_name ][ $plugin_type ][ 'function' ];
|
||||
}
|
||||
}
|
||||
if (isset($function)) {
|
||||
if ($plugin_type == 'modifier') {
|
||||
$this->modifier_plugins[$plugin_name] = true;
|
||||
$this->modifier_plugins[ $plugin_name ] = true;
|
||||
}
|
||||
|
||||
return $function;
|
||||
|
@ -917,18 +917,18 @@ abstract class Smarty_Internal_TemplateCompilerBase
|
|||
|
||||
if (is_string($file)) {
|
||||
if ($this->template->caching && ($this->nocache || $this->tag_nocache)) {
|
||||
$this->parent_compiler->template->compiled->required_plugins['nocache'][$plugin_name][$plugin_type]['file'] =
|
||||
$this->parent_compiler->template->compiled->required_plugins[ 'nocache' ][ $plugin_name ][ $plugin_type ][ 'file' ] =
|
||||
$file;
|
||||
$this->parent_compiler->template->compiled->required_plugins['nocache'][$plugin_name][$plugin_type]['function'] =
|
||||
$this->parent_compiler->template->compiled->required_plugins[ 'nocache' ][ $plugin_name ][ $plugin_type ][ 'function' ] =
|
||||
$function;
|
||||
} else {
|
||||
$this->parent_compiler->template->compiled->required_plugins['compiled'][$plugin_name][$plugin_type]['file'] =
|
||||
$this->parent_compiler->template->compiled->required_plugins[ 'compiled' ][ $plugin_name ][ $plugin_type ][ 'file' ] =
|
||||
$file;
|
||||
$this->parent_compiler->template->compiled->required_plugins['compiled'][$plugin_name][$plugin_type]['function'] =
|
||||
$this->parent_compiler->template->compiled->required_plugins[ 'compiled' ][ $plugin_name ][ $plugin_type ][ 'function' ] =
|
||||
$function;
|
||||
}
|
||||
if ($plugin_type == 'modifier') {
|
||||
$this->modifier_plugins[$plugin_name] = true;
|
||||
$this->modifier_plugins[ $plugin_name ] = true;
|
||||
}
|
||||
|
||||
return $function;
|
||||
|
@ -961,14 +961,14 @@ abstract class Smarty_Internal_TemplateCompilerBase
|
|||
if ($script !== null) {
|
||||
if (is_file($script)) {
|
||||
if ($this->template->caching && ($this->nocache || $this->tag_nocache)) {
|
||||
$this->parent_compiler->template->compiled->required_plugins['nocache'][$tag][$plugin_type]['file'] =
|
||||
$this->parent_compiler->template->compiled->required_plugins[ 'nocache' ][ $tag ][ $plugin_type ][ 'file' ] =
|
||||
$script;
|
||||
$this->parent_compiler->template->compiled->required_plugins['nocache'][$tag][$plugin_type]['function'] =
|
||||
$this->parent_compiler->template->compiled->required_plugins[ 'nocache' ][ $tag ][ $plugin_type ][ 'function' ] =
|
||||
$callback;
|
||||
} else {
|
||||
$this->parent_compiler->template->compiled->required_plugins['compiled'][$tag][$plugin_type]['file'] =
|
||||
$this->parent_compiler->template->compiled->required_plugins[ 'compiled' ][ $tag ][ $plugin_type ][ 'file' ] =
|
||||
$script;
|
||||
$this->parent_compiler->template->compiled->required_plugins['compiled'][$tag][$plugin_type]['function'] =
|
||||
$this->parent_compiler->template->compiled->required_plugins[ 'compiled' ][ $tag ][ $plugin_type ][ 'function' ] =
|
||||
$callback;
|
||||
}
|
||||
require_once $script;
|
||||
|
@ -976,11 +976,13 @@ abstract class Smarty_Internal_TemplateCompilerBase
|
|||
$this->trigger_template_error("Default plugin handler: Returned script file \"{$script}\" for \"{$tag}\" not found");
|
||||
}
|
||||
}
|
||||
if (!is_string($callback) && !(is_array($callback) && is_string($callback[0]) && is_string($callback[1]))) {
|
||||
if (!is_string($callback) &&
|
||||
!(is_array($callback) && is_string($callback[ 0 ]) && is_string($callback[ 1 ]))
|
||||
) {
|
||||
$this->trigger_template_error("Default plugin handler: Returned callback for \"{$tag}\" must be a static function name or array of class and function name");
|
||||
}
|
||||
if (is_callable($callback)) {
|
||||
$this->default_handler_plugins[$plugin_type][$tag] = array($callback, true, array());
|
||||
$this->default_handler_plugins[ $plugin_type ][ $tag ] = array($callback, true, array());
|
||||
|
||||
return true;
|
||||
} else {
|
||||
|
@ -1036,9 +1038,9 @@ abstract class Smarty_Internal_TemplateCompilerBase
|
|||
"/*/%%SmartyNocache:{$this->nocache_hash}%%*/';?>\n";
|
||||
// make sure we include modifier plugins for nocache code
|
||||
foreach ($this->modifier_plugins as $plugin_name => $dummy) {
|
||||
if (isset($this->parent_compiler->template->compiled->required_plugins['compiled'][$plugin_name]['modifier'])) {
|
||||
$this->parent_compiler->template->compiled->required_plugins['nocache'][$plugin_name]['modifier'] =
|
||||
$this->parent_compiler->template->compiled->required_plugins['compiled'][$plugin_name]['modifier'];
|
||||
if (isset($this->parent_compiler->template->compiled->required_plugins[ 'compiled' ][ $plugin_name ][ 'modifier' ])) {
|
||||
$this->parent_compiler->template->compiled->required_plugins[ 'nocache' ][ $plugin_name ][ 'modifier' ] =
|
||||
$this->parent_compiler->template->compiled->required_plugins[ 'compiled' ][ $plugin_name ][ 'modifier' ];
|
||||
}
|
||||
}
|
||||
} else {
|
||||
|
@ -1064,7 +1066,7 @@ abstract class Smarty_Internal_TemplateCompilerBase
|
|||
public function getId($input)
|
||||
{
|
||||
if (preg_match('~^[\'"]*([0-9]*[a-zA-Z_]\w*)[\'"]*$~', $input, $match)) {
|
||||
return $match[1];
|
||||
return $match[ 1 ];
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
@ -1079,7 +1081,7 @@ abstract class Smarty_Internal_TemplateCompilerBase
|
|||
public function getVariableName($input)
|
||||
{
|
||||
if (preg_match('~^[$]_smarty_tpl->tpl_vars\[[\'"]*([0-9]*[a-zA-Z_]\w*)[\'"]*\]->value$~', $input, $match)) {
|
||||
return $match[1];
|
||||
return $match[ 1 ];
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
@ -1136,7 +1138,7 @@ abstract class Smarty_Internal_TemplateCompilerBase
|
|||
$error_text =
|
||||
'Syntax error in template "' . (empty($this->trace_filepath) ? $templateName : $this->trace_filepath) .
|
||||
'" on line ' . ($line + $this->trace_line_offset) . ' "' .
|
||||
trim(preg_replace('![\t\r\n]+!', ' ', $match[$line - 1])) . '" ';
|
||||
trim(preg_replace('![\t\r\n]+!', ' ', $match[ $line - 1 ])) . '" ';
|
||||
if (isset($args)) {
|
||||
// individual error message
|
||||
$error_text .= $args;
|
||||
|
@ -1146,13 +1148,13 @@ abstract class Smarty_Internal_TemplateCompilerBase
|
|||
$error_text .= ' - Unexpected "' . $lex->value . '"';
|
||||
if (count($this->parser->yy_get_expected_tokens($this->parser->yymajor)) <= 4) {
|
||||
foreach ($this->parser->yy_get_expected_tokens($this->parser->yymajor) as $token) {
|
||||
$exp_token = $this->parser->yyTokenName[$token];
|
||||
if (isset($lex->smarty_token_names[$exp_token])) {
|
||||
$exp_token = $this->parser->yyTokenName[ $token ];
|
||||
if (isset($lex->smarty_token_names[ $exp_token ])) {
|
||||
// token type from lexer
|
||||
$expect[] = '"' . $lex->smarty_token_names[$exp_token] . '"';
|
||||
$expect[] = '"' . $lex->smarty_token_names[ $exp_token ] . '"';
|
||||
} else {
|
||||
// otherwise internal token name
|
||||
$expect[] = $this->parser->yyTokenName[$token];
|
||||
$expect[] = $this->parser->yyTokenName[ $token ];
|
||||
}
|
||||
}
|
||||
$error_text .= ', expected one of: ' . implode(' , ', $expect);
|
||||
|
@ -1160,7 +1162,7 @@ abstract class Smarty_Internal_TemplateCompilerBase
|
|||
}
|
||||
$e = new SmartyCompilerException($error_text);
|
||||
$e->line = $line;
|
||||
$e->source = trim(preg_replace('![\t\r\n]+!', ' ', $match[$line - 1]));
|
||||
$e->source = trim(preg_replace('![\t\r\n]+!', ' ', $match[ $line - 1 ]));
|
||||
$e->desc = $args;
|
||||
$e->template = $this->template->source->filepath;
|
||||
throw $e;
|
||||
|
|
File diff suppressed because it is too large
Load diff
|
@ -240,6 +240,16 @@ abstract class Smarty_Resource
|
|||
return $resource->buildUniqueResourceName($smarty, $name);
|
||||
}
|
||||
|
||||
/*
|
||||
* Check if resource must check time stamps when when loading complied or cached templates.
|
||||
* Resources like 'extends' which use source components my disable timestamp checks on own resource.
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function checkTimestamps() {
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* initialize Source Object for given resource
|
||||
* wrapper for backward compatibility to versions < 3.1.22
|
||||
|
|
|
@ -79,13 +79,6 @@ abstract class Smarty_Template_Resource_Base
|
|||
*/
|
||||
public $required_plugins = array();
|
||||
|
||||
/**
|
||||
* Known template functions
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
public $tpl_function = array();
|
||||
|
||||
/**
|
||||
* Included subtemplates
|
||||
*
|
||||
|
|
Loading…
Add table
Reference in a new issue