3 * Smarty Internal Plugin Compile Special Smarty Variable
5 * Compiles the special $smarty variables
13 * Smarty Internal Plugin Compile special Smarty Variable Class
15 class Smarty_Internal_Compile_Private_Special_Variable extends Smarty_Internal_CompileBase {
17 * Compiles code for the speical $smarty variables
19 * @param array $args array with attributes from parser
20 * @param object $compiler compiler object
21 * @return string compiled code
23 public function compile($args, $compiler, $parameter)
25 $_index = preg_split("/\]\[/",substr($parameter, 1, strlen($parameter)-2));
27 $variable = trim($_index[0], "'");
30 return "\$_smarty_tpl->getVariable('smarty')->value$parameter";
32 return "\$_smarty_tpl->getVariable('smarty')->value$parameter";
34 return "Smarty::\$_smarty_vars$parameter";
38 if (isset($compiler->smarty->security_policy) && !$compiler->smarty->security_policy->allow_super_globals) {
39 $compiler->trigger_template_error("(secure mode) super globals not permitted");
42 $compiled_ref = '$_COOKIE';
51 if (isset($compiler->smarty->security_policy) && !$compiler->smarty->security_policy->allow_super_globals) {
52 $compiler->trigger_template_error("(secure mode) super globals not permitted");
55 $compiled_ref = '$_'.strtoupper($variable);
59 return 'basename($_smarty_tpl->getTemplateFilepath())';
62 return 'dirname($_smarty_tpl->getTemplateFilepath())';
65 $_version = Smarty::SMARTY_VERSION;
69 if (isset($compiler->smarty->security_policy) && !$compiler->smarty->security_policy->allow_constants) {
70 $compiler->trigger_template_error("(secure mode) constants not permitted");
73 return '@' . trim($_index[1], "'");
76 return "\$_smarty_tpl->getConfigVariable($_index[1])";
78 $_ldelim = $compiler->smarty->left_delimiter;
82 $_rdelim = $compiler->smarty->right_delimiter;
86 $compiler->trigger_template_error('$smarty.' . trim($_index[0], "'") . ' is invalid');
89 if (isset($_index[1])) {
91 foreach ($_index as $_ind) {
92 $compiled_ref = $compiled_ref . "[$_ind]";