aboutsummaryrefslogtreecommitdiffstats
path: root/include/smarty/libs/sysplugins/smarty_internal_compile_private_special_variable.php
diff options
context:
space:
mode:
Diffstat (limited to 'include/smarty/libs/sysplugins/smarty_internal_compile_private_special_variable.php')
-rw-r--r--include/smarty/libs/sysplugins/smarty_internal_compile_private_special_variable.php37
1 files changed, 17 insertions, 20 deletions
diff --git a/include/smarty/libs/sysplugins/smarty_internal_compile_private_special_variable.php b/include/smarty/libs/sysplugins/smarty_internal_compile_private_special_variable.php
index 5a8c54faa..b83e824af 100644
--- a/include/smarty/libs/sysplugins/smarty_internal_compile_private_special_variable.php
+++ b/include/smarty/libs/sysplugins/smarty_internal_compile_private_special_variable.php
@@ -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]";