3 * Smarty Internal Plugin Compile Special Smarty Variable
4 * Compiles the special $smarty variables
12 * Smarty Internal Plugin Compile special Smarty Variable Class
15 * @subpackage Compiler
17 class Smarty_Internal_Compile_Private_Special_Variable extends Smarty_Internal_CompileBase
20 * Compiles code for the special $smarty variables
22 * @param array $args array with attributes from parser
23 * @param object $compiler compiler object
26 * @return string compiled code
28 public function compile($args, $compiler, $parameter)
30 $_index = preg_split("/\]\[/", substr($parameter, 1, strlen($parameter) - 2));
32 $variable = trim($_index[0], "'");
35 return "\$_smarty_tpl->getVariable('smarty')->value$parameter";
37 return "\$_smarty_tpl->getVariable('smarty')->value$parameter";
39 return "Smarty::\$_smarty_vars$parameter";
43 if (isset($compiler->smarty->security_policy) && !$compiler->smarty->security_policy->allow_super_globals) {
44 $compiler->trigger_template_error("(secure mode) super globals not permitted");
47 $compiled_ref = '$_COOKIE';
56 if (isset($compiler->smarty->security_policy) && !$compiler->smarty->security_policy->allow_super_globals) {
57 $compiler->trigger_template_error("(secure mode) super globals not permitted");
60 $compiled_ref = '$_' . strtoupper($variable);
64 return 'basename($_smarty_tpl->source->filepath)';
66 case 'template_object':
67 return '$_smarty_tpl';
70 return 'dirname($_smarty_tpl->source->filepath)';
73 $_version = Smarty::SMARTY_VERSION;
78 if (isset($compiler->smarty->security_policy) && !$compiler->smarty->security_policy->allow_constants) {
79 $compiler->trigger_template_error("(secure mode) constants not permitted");
83 return "@constant({$_index[1]})";
86 if (isset($_index[2])) {
87 return "(is_array(\$tmp = \$_smarty_tpl->getConfigVariable($_index[1])) ? \$tmp[$_index[2]] : null)";
89 return "\$_smarty_tpl->getConfigVariable($_index[1])";
92 $_ldelim = $compiler->smarty->left_delimiter;
97 $_rdelim = $compiler->smarty->right_delimiter;
102 $compiler->trigger_template_error('$smarty.' . trim($_index[0], "'") . ' is invalid');
105 if (isset($_index[1])) {
106 array_shift($_index);
107 foreach ($_index as $_ind) {
108 $compiled_ref = $compiled_ref . "[$_ind]";
112 return $compiled_ref;