X-Git-Url: http://wagnertech.de/gitweb/gitweb.cgi/timetracker.git/blobdiff_plain/098a79f0819ebb89b7d48df4a6b154af4560f68e..9a23a8c0a51b7ec38a96f525484134f3cb85dc7e:/WEB-INF/lib/smarty/sysplugins/smarty_internal_compile_while.php diff --git a/WEB-INF/lib/smarty/sysplugins/smarty_internal_compile_while.php b/WEB-INF/lib/smarty/sysplugins/smarty_internal_compile_while.php new file mode 100644 index 00000000..7e87a229 --- /dev/null +++ b/WEB-INF/lib/smarty/sysplugins/smarty_internal_compile_while.php @@ -0,0 +1,82 @@ +compiler = $compiler; + // check and get attributes + $_attr = $this->_get_attributes($args); + $this->_open_tag('while', $this->compiler->nocache); + + // maybe nocache because of nocache variables + $this->compiler->nocache = $this->compiler->nocache | $this->compiler->tag_nocache; + if (is_array($parameter['if condition'])) { + if ($this->compiler->nocache) { + $_nocache = ',true'; + // create nocache var to make it know for further compiling + if (is_array($parameter['if condition']['var'])) { + $this->compiler->template->tpl_vars[trim($parameter['if condition']['var']['var'], "'")] = new Smarty_variable(null, true); + } else { + $this->compiler->template->tpl_vars[trim($parameter['if condition']['var'], "'")] = new Smarty_variable(null, true); + } + } else { + $_nocache = ''; + } + if (is_array($parameter['if condition']['var'])) { + $_output = "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"; + $_output .= "while (\$_smarty_tpl->tpl_vars[".$parameter['if condition']['var']['var']."]->value".$parameter['if condition']['var']['smarty_internal_index']." = ".$parameter['if condition']['value']."){?>"; + } else { + $_output = "tpl_vars[".$parameter['if condition']['var']."] = new Smarty_Variable(\$_smarty_tpl->getVariable(".$parameter['if condition']['var'].",null,true,false)->value{$_nocache});"; + $_output .= "while (\$_smarty_tpl->tpl_vars[".$parameter['if condition']['var']."]->value = ".$parameter['if condition']['value']."){?>"; + } + return $_output; + } else { + return ""; + } + } +} + +/** +* Smarty Internal Plugin Compile Whileclose Class +*/ +class Smarty_Internal_Compile_Whileclose extends Smarty_Internal_CompileBase { + /** + * Compiles code for the {/while} tag + * + * @param array $args array with attributes from parser + * @param object $compiler compiler object + * @return string compiled code + */ + public function compile($args, $compiler) + { + $this->compiler = $compiler; + // must endblock be nocache? + if ($this->compiler->nocache) { + $this->compiler->tag_nocache = true; + } + $this->compiler->nocache = $this->_close_tag(array('while')); + return ""; + } +} + +?> \ No newline at end of file