3 * Smarty Internal Plugin Compile Special Smarty Variable
5 * Compiles the special $smarty variables
13 * Smarty Internal Plugin Compile special Smarty Variable Class
16 * @subpackage Compiler
18 class Smarty_Internal_Compile_Private_Special_Variable extends Smarty_Internal_CompileBase {
21 * Compiles code for the speical $smarty variables
23 * @param array $args array with attributes from parser
24 * @param object $compiler compiler object
25 * @return string compiled code
27 public function compile($args, $compiler, $parameter)
29 $_index = preg_split("/\]\[/",substr($parameter, 1, strlen($parameter)-2));
31 $variable = trim($_index[0], "'");
34 return "\$_smarty_tpl->getVariable('smarty')->value$parameter";
36 return "\$_smarty_tpl->getVariable('smarty')->value$parameter";
38 return "Smarty::\$_smarty_vars$parameter";
42 if (isset($compiler->smarty->security_policy) && !$compiler->smarty->security_policy->allow_super_globals) {
43 $compiler->trigger_template_error("(secure mode) super globals not permitted");
46 $compiled_ref = '$_COOKIE';
55 if (isset($compiler->smarty->security_policy) && !$compiler->smarty->security_policy->allow_super_globals) {
56 $compiler->trigger_template_error("(secure mode) super globals not permitted");
59 $compiled_ref = '$_'.strtoupper($variable);
63 return 'basename($_smarty_tpl->source->filepath)';
65 case 'template_object':
66 return '$_smarty_tpl';
69 return 'dirname($_smarty_tpl->source->filepath)';
72 $_version = Smarty::SMARTY_VERSION;
76 if (isset($compiler->smarty->security_policy) && !$compiler->smarty->security_policy->allow_constants) {
77 $compiler->trigger_template_error("(secure mode) constants not permitted");
80 return '@' . trim($_index[1], "'");
83 return "\$_smarty_tpl->getConfigVariable($_index[1])";
85 $_ldelim = $compiler->smarty->left_delimiter;
89 $_rdelim = $compiler->smarty->right_delimiter;
93 $compiler->trigger_template_error('$smarty.' . trim($_index[0], "'") . ' is invalid');
96 if (isset($_index[1])) {
98 foreach ($_index as $_ind) {
99 $compiled_ref = $compiled_ref . "[$_ind]";
102 return $compiled_ref;