libs/sysplugins/smarty_internal_compile_while.php Quellcode

smarty_internal_compile_while.php
gehe zur Dokumentation dieser Datei
1 <?php
18 {
28  public function compile($args, $compiler, $parameter)
29  {
30  // check and get attributes
31  $_attr = $this->getAttributes($compiler, $args);
32  $this->openTag($compiler, 'while', $compiler->nocache);
33 
34  if (!array_key_exists("if condition", $parameter)) {
35  $compiler->trigger_template_error("missing while condition", $compiler->lex->taglineno);
36  }
37 
38  // maybe nocache because of nocache variables
39  $compiler->nocache = $compiler->nocache | $compiler->tag_nocache;
40  if (is_array($parameter['if condition'])) {
41  if ($compiler->nocache) {
42  $_nocache = ',true';
43  // create nocache var to make it know for further compiling
44  if (is_array($parameter['if condition']['var'])) {
45  $var = trim($parameter['if condition']['var']['var'], "'");
46  } else {
47  $var = trim($parameter['if condition']['var'], "'");
48  }
49  if (isset($compiler->template->tpl_vars[$var])) {
50  $compiler->template->tpl_vars[$var]->nocache = true;
51  } else {
52  $compiler->template->tpl_vars[$var] = new Smarty_Variable(null, true);
53  }
54  } else {
55  $_nocache = '';
56  }
57  if (is_array($parameter['if condition']['var'])) {
58  $_output = "<?php if (!isset(\$_smarty_tpl->tpl_vars[" . $parameter['if condition']['var']['var'] . "]) || !is_array(\$_smarty_tpl->tpl_vars[" . $parameter['if condition']['var']['var'] . "]->value)) \$_smarty_tpl->createLocalArrayVariable(" . $parameter['if condition']['var']['var'] . "$_nocache);\n";
59  $_output .= "while (\$_smarty_tpl->tpl_vars[" . $parameter['if condition']['var']['var'] . "]->value" . $parameter['if condition']['var']['smarty_internal_index'] . " = " . $parameter['if condition']['value'] . ") {?>";
60  } else {
61  $_output = "<?php if (!isset(\$_smarty_tpl->tpl_vars[" . $parameter['if condition']['var'] . "])) \$_smarty_tpl->tpl_vars[" . $parameter['if condition']['var'] . "] = new Smarty_Variable(null{$_nocache});";
62  $_output .= "while (\$_smarty_tpl->tpl_vars[" . $parameter['if condition']['var'] . "]->value = " . $parameter['if condition']['value'] . ") {?>";
63  }
64 
65  return $_output;
66  } else {
67  return "<?php while ({$parameter['if condition']}) {?>";
68  }
69  }
70 }
71 
79 {
88  public function compile($args, $compiler)
89  {
90  // must endblock be nocache?
91  if ($compiler->nocache) {
92  $compiler->tag_nocache = true;
93  }
94  $compiler->nocache = $this->closeTag($compiler, array('while'));
95 
96  return "<?php }?>";
97  }
98 }




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.