Dutch translation improved.
[timetracker.git] / WEB-INF / lib / smarty / sysplugins / smarty_internal_compile_private_special_variable.php
1 <?php
2 /**
3  * Smarty Internal Plugin Compile Special Smarty Variable
4  * 
5  * Compiles the special $smarty variables
6  * 
7  * @package Smarty
8  * @subpackage Compiler
9  * @author Uwe Tews 
10  */
11
12 /**
13  * Smarty Internal Plugin Compile special Smarty Variable Class
14  */
15 class Smarty_Internal_Compile_Private_Special_Variable extends Smarty_Internal_CompileBase {
16     /**
17      * Compiles code for the speical $smarty variables
18      * 
19      * @param array $args array with attributes from parser
20      * @param object $compiler compiler object
21      * @return string compiled code
22      */
23     public function compile($args, $compiler, $parameter)
24     {
25         $_index = preg_split("/\]\[/",substr($parameter, 1, strlen($parameter)-2));
26         $compiled_ref = ' ';
27         $variable = trim($_index[0], "'");
28         switch ($variable) {
29             case 'foreach':
30                 return "\$_smarty_tpl->getVariable('smarty')->value$parameter";
31             case 'section':
32                 return "\$_smarty_tpl->getVariable('smarty')->value$parameter";
33             case 'capture':
34                 return "Smarty::\$_smarty_vars$parameter";
35             case 'now':
36                 return 'time()';
37             case 'cookies':
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");
40                     break;
41                 } 
42                 $compiled_ref = '$_COOKIE';
43                 break;
44
45             case 'get':
46             case 'post':
47             case 'env':
48             case 'server':
49             case 'session':
50             case 'request':
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");
53                     break;
54                 } 
55                 $compiled_ref = '$_'.strtoupper($variable);
56                 break;
57
58             case 'template':
59                 return 'basename($_smarty_tpl->getTemplateFilepath())';
60
61             case 'current_dir':
62                 return 'dirname($_smarty_tpl->getTemplateFilepath())';
63
64             case 'version':
65                 $_version = Smarty::SMARTY_VERSION;
66                 return "'$_version'";
67
68             case 'const':
69                 if (isset($compiler->smarty->security_policy) && !$compiler->smarty->security_policy->allow_constants) {
70                     $compiler->trigger_template_error("(secure mode) constants not permitted");
71                     break;
72                 } 
73                 return '@' . trim($_index[1], "'");
74
75             case 'config':
76                 return "\$_smarty_tpl->getConfigVariable($_index[1])";
77             case 'ldelim':
78                 $_ldelim = $compiler->smarty->left_delimiter;
79                 return "'$_ldelim'";
80
81             case 'rdelim':
82                 $_rdelim = $compiler->smarty->right_delimiter;
83                 return "'$_rdelim'";
84
85             default:
86                 $compiler->trigger_template_error('$smarty.' . trim($_index[0], "'") . ' is invalid');
87                 break;
88         } 
89         if (isset($_index[1])) {
90             array_shift($_index);
91             foreach ($_index as $_ind) {
92                 $compiled_ref = $compiled_ref . "[$_ind]";
93             } 
94         } 
95         return $compiled_ref;
96     } 
97
98
99 ?>