libs/sysplugins/smarty_internal_compile_private_special_variable.php Quellcode

smarty_internal_compile_private_special_variable.php
gehe zur Dokumentation dieser Datei
1 <?php
18 {
28  public function compile($args, $compiler, $parameter)
29  {
30  $_index = preg_split("/\]\[/", substr($parameter, 1, strlen($parameter) - 2));
31  $compiled_ref = ' ';
32  $variable = trim($_index[0], "'");
33  if (!isset($compiler->smarty->security_policy) || $compiler->smarty->security_policy->isTrustedSpecialSmartyVar($variable, $compiler)) {
34  switch ($variable) {
35  case 'foreach':
36  $name = trim($_index[1], "'");
37  $foreachVar = "'__foreach_{$name}'";
38  return "(isset(\$_smarty_tpl->tpl_vars[$foreachVar]->value[{$_index[2]}]) ? \$_smarty_tpl->tpl_vars[$foreachVar]->value[{$_index[2]}] : null)";
39  case 'section':
40  return "\$_smarty_tpl->getVariable('smarty')->value$parameter";
41  case 'capture':
42  return "Smarty::\$_smarty_vars$parameter";
43  case 'now':
44  return 'time()';
45  case 'cookies':
46  if (isset($compiler->smarty->security_policy) && !$compiler->smarty->security_policy->allow_super_globals) {
47  $compiler->trigger_template_error("(secure mode) super globals not permitted");
48  break;
49  }
50  $compiled_ref = '$_COOKIE';
51  break;
52 
53  case 'get':
54  case 'post':
55  case 'env':
56  case 'server':
57  case 'session':
58  case 'request':
59  if (isset($compiler->smarty->security_policy) && !$compiler->smarty->security_policy->allow_super_globals) {
60  $compiler->trigger_template_error("(secure mode) super globals not permitted");
61  break;
62  }
63  $compiled_ref = '$_' . strtoupper($variable);
64  break;
65 
66  case 'template':
67  return 'basename($_smarty_tpl->source->filepath)';
68 
69  case 'template_object':
70  return '$_smarty_tpl';
71 
72  case 'current_dir':
73  return 'dirname($_smarty_tpl->source->filepath)';
74 
75  case 'version':
76  $_version = Smarty::SMARTY_VERSION;
77 
78  return "'$_version'";
79 
80  case 'const':
81  if (isset($compiler->smarty->security_policy) && !$compiler->smarty->security_policy->allow_constants) {
82  $compiler->trigger_template_error("(secure mode) constants not permitted");
83  break;
84  }
85  if (strpos($_index[1], '$') === false && strpos($_index[1], '\'') === false ) {
86  return "@constant('{$_index[1]}')";
87  } else {
88  return "@constant({$_index[1]})";
89  }
90 
91  case 'config':
92  if (isset($_index[2])) {
93  return "(is_array(\$tmp = \$_smarty_tpl->getConfigVariable($_index[1])) ? \$tmp[$_index[2]] : null)";
94  } else {
95  return "\$_smarty_tpl->getConfigVariable($_index[1])";
96  }
97  case 'ldelim':
98  $_ldelim = $compiler->smarty->left_delimiter;
99 
100  return "'$_ldelim'";
101 
102  case 'rdelim':
103  $_rdelim = $compiler->smarty->right_delimiter;
104 
105  return "'$_rdelim'";
106 
107  default:
108  $compiler->trigger_template_error('$smarty.' . trim($_index[0], "'") . ' is invalid');
109  break;
110  }
111  if (isset($_index[1])) {
112  array_shift($_index);
113  foreach ($_index as $_ind) {
114  $compiled_ref = $compiled_ref . "[$_ind]";
115  }
116  }
117  }
118  return $compiled_ref;
119  }
120 }




Korrekturen, Hinweise und Ergänzungen

Bitte scheuen Sie sich nicht und melden Sie, was auf dieser Seite sachlich falsch oder irreführend ist, was ergänzt werden sollte, was fehlt usw. Dazu bitte oben aus dem Menü Seite den Eintrag Support Forum wählen. Es ist eine kostenlose Anmeldung erforderlich, um Anmerkungen zu posten. Unpassende Postings, Spam usw. werden kommentarlos entfernt.