mirror of
https://github.com/smarty-php/smarty.git
synced 2026-05-05 12:14:12 +02:00
code cleanup and optimizations 3.1.32-dev-34
This commit is contained in:
@@ -500,7 +500,7 @@ abstract class Smarty_Internal_TemplateCompilerBase
|
||||
*/
|
||||
public function compileVariable($variable)
|
||||
{
|
||||
if (strpos($variable, '(') == 0) {
|
||||
if (!strpos($variable, '(')) {
|
||||
// not a variable variable
|
||||
$var = trim($variable, '\'');
|
||||
$this->tag_nocache = $this->tag_nocache |
|
||||
@@ -554,11 +554,11 @@ abstract class Smarty_Internal_TemplateCompilerBase
|
||||
foreach ($parameter as $p) {
|
||||
$pa[] = (strpos($p, '(') === false) ? ('isset(' . $p . ')') : ('(' . $p . ' !== null )');
|
||||
}
|
||||
return "(" . implode(' && ', $pa) . ")";
|
||||
return '(' . implode(' && ', $pa) . ')';
|
||||
} else {
|
||||
$isset_par = str_replace("')->value", "',null,true,false)->value", $par);
|
||||
}
|
||||
return $name . "(" . $isset_par . ")";
|
||||
return $name . '(' . $isset_par . ')';
|
||||
} else if (in_array($func_name,
|
||||
array('empty',
|
||||
'reset',
|
||||
@@ -571,7 +571,7 @@ abstract class Smarty_Internal_TemplateCompilerBase
|
||||
}
|
||||
if ($func_name === 'empty') {
|
||||
if ($parHasFuction && version_compare(PHP_VERSION, '5.5.0', '<')) {
|
||||
return '(' . $parameter[ 0 ] . ' == false )';
|
||||
return '(' . $parameter[ 0 ] . ' === false )';
|
||||
} else {
|
||||
return $func_name . '(' .
|
||||
str_replace("')->value", "',null,true,false)->value", $parameter[ 0 ]) . ')';
|
||||
@@ -580,10 +580,10 @@ abstract class Smarty_Internal_TemplateCompilerBase
|
||||
return $func_name . '(' . $parameter[ 0 ] . ')';
|
||||
}
|
||||
} else {
|
||||
return $name . "(" . implode(',', $parameter) . ")";
|
||||
return $name . '(' . implode(',', $parameter) . ')';
|
||||
}
|
||||
} else {
|
||||
$this->trigger_template_error("unknown function \"" . $name . "\"");
|
||||
$this->trigger_template_error("unknown function '{$name}'");
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -808,7 +808,7 @@ abstract class Smarty_Internal_TemplateCompilerBase
|
||||
}
|
||||
require_once $script;
|
||||
} else {
|
||||
$this->trigger_template_error("Default plugin handler: Returned script file \"{$script}\" for \"{$tag}\" not found");
|
||||
$this->trigger_template_error("Default plugin handler: Returned script file '{$script}' for '{$tag}' not found");
|
||||
}
|
||||
}
|
||||
if (is_callable($callback)) {
|
||||
@@ -817,7 +817,7 @@ abstract class Smarty_Internal_TemplateCompilerBase
|
||||
array());
|
||||
return true;
|
||||
} else {
|
||||
$this->trigger_template_error("Default plugin handler: Returned callback for \"{$tag}\" not callable");
|
||||
$this->trigger_template_error("Default plugin handler: Returned callback for '{$tag}' not callable");
|
||||
}
|
||||
}
|
||||
return false;
|
||||
@@ -863,9 +863,8 @@ abstract class Smarty_Internal_TemplateCompilerBase
|
||||
) {
|
||||
$this->template->compiled->has_nocache_code = true;
|
||||
$_output = addcslashes($content, '\'\\');
|
||||
$_output = str_replace("^#^", "'", $_output);
|
||||
$_output = "<?php echo '/*%%SmartyNocache:{$this->nocache_hash}%%*/" . $_output .
|
||||
"/*/%%SmartyNocache:{$this->nocache_hash}%%*/';?>\n";
|
||||
$_output = str_replace('^#^', '\'', $_output);
|
||||
$_output = "<?php echo '/*%%SmartyNocache:{$this->nocache_hash}%%*/{$_output}/*/%%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' ])) {
|
||||
@@ -944,11 +943,11 @@ abstract class Smarty_Internal_TemplateCompilerBase
|
||||
{
|
||||
$_scope = 0;
|
||||
if (isset($_attr[ 'scope' ])) {
|
||||
$_scopeName = trim($_attr[ 'scope' ], "'\"");
|
||||
$_scopeName = trim($_attr[ 'scope' ], '\'"');
|
||||
if (is_numeric($_scopeName) && in_array($_scopeName, $validScopes)) {
|
||||
$_scope = $_scopeName;
|
||||
} else if (is_string($_scopeName)) {
|
||||
$_scopeName = trim($_scopeName, "'\"");
|
||||
$_scopeName = trim($_scopeName, '\'"');
|
||||
$_scope = isset($validScopes[ $_scopeName ]) ? $validScopes[ $_scopeName ] : false;
|
||||
} else {
|
||||
$_scope = false;
|
||||
@@ -971,7 +970,7 @@ abstract class Smarty_Internal_TemplateCompilerBase
|
||||
public function makeNocacheCode($code)
|
||||
{
|
||||
return "echo '/*%%SmartyNocache:{$this->nocache_hash}%%*/<?php " .
|
||||
str_replace("^#^", "'", addcslashes($code, '\'\\')) .
|
||||
str_replace('^#^', '\'', addcslashes($code, '\'\\')) .
|
||||
"?>/*/%%SmartyNocache:{$this->nocache_hash}%%*/';\n";
|
||||
}
|
||||
|
||||
@@ -1137,7 +1136,7 @@ abstract class Smarty_Internal_TemplateCompilerBase
|
||||
{
|
||||
if (array_pop($this->_tag_stack_count) !== $this->getTagStackCount()) {
|
||||
$tag = $this->getOpenBlockTag();
|
||||
$this->trigger_template_error("unclosed \"{{$tag}}\" in doubled quoted string",
|
||||
$this->trigger_template_error("unclosed '{{$tag}}' in doubled quoted string",
|
||||
null,
|
||||
true);
|
||||
}
|
||||
@@ -1326,7 +1325,7 @@ abstract class Smarty_Internal_TemplateCompilerBase
|
||||
$this->template->smarty->ext->_tplFunction->getTplFunction($this->template, $tag) !== false)
|
||||
) {
|
||||
// template defined by {template} tag
|
||||
$args[ '_attr' ][ 'name' ] = "'" . $tag . "'";
|
||||
$args[ '_attr' ][ 'name' ] = "'{$tag}'";
|
||||
$_output = $this->callTagCompiler('call', $args, $parameter);
|
||||
}
|
||||
}
|
||||
@@ -1434,7 +1433,7 @@ abstract class Smarty_Internal_TemplateCompilerBase
|
||||
return $plugin_object->compile($args, $this);
|
||||
}
|
||||
}
|
||||
throw new SmartyException("Plugin \"{$tag}\" not callable");
|
||||
throw new SmartyException("Plugin '{$tag}' not callable");
|
||||
} else {
|
||||
if ($function = $this->getPlugin($tag, $plugin_type)) {
|
||||
if (!isset($this->smarty->security_policy) ||
|
||||
@@ -1553,10 +1552,10 @@ abstract class Smarty_Internal_TemplateCompilerBase
|
||||
return $plugin_object->compile($args, $this);
|
||||
}
|
||||
}
|
||||
throw new SmartyException("Plugin \"{$tag}\" not callable");
|
||||
throw new SmartyException("Plugin '{$tag}' not callable");
|
||||
}
|
||||
}
|
||||
$this->trigger_template_error("unknown tag \"" . $tag . "\"", null, true);
|
||||
$this->trigger_template_error("unknown tag '{$tag}'", null, true);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user