| 1: | <?php
|
| 2: | |
| 3: | |
| 4: | |
| 5: | |
| 6: | |
| 7: | |
| 8: | |
| 9: |
|
| 10: |
|
| 11: | |
| 12: | |
| 13: | |
| 14: | |
| 15: | |
| 16: |
|
| 17: | class Smarty_Internal_Compile_While extends Smarty_Internal_CompileBase
|
| 18: | {
|
| 19: | |
| 20: | |
| 21: | |
| 22: | |
| 23: | |
| 24: | |
| 25: | |
| 26: | |
| 27: | |
| 28: |
|
| 29: | public function compile($args, Smarty_Internal_TemplateCompilerBase $compiler, $parameter)
|
| 30: | {
|
| 31: | $compiler->loopNesting++;
|
| 32: |
|
| 33: | $_attr = $this->getAttributes($compiler, $args);
|
| 34: | $this->openTag($compiler, 'while', $compiler->nocache);
|
| 35: | if (!array_key_exists('if condition', $parameter)) {
|
| 36: | $compiler->trigger_template_error('missing while condition', null, true);
|
| 37: | }
|
| 38: |
|
| 39: | $compiler->nocache = $compiler->nocache | $compiler->tag_nocache;
|
| 40: | if (is_array($parameter[ 'if condition' ])) {
|
| 41: | if ($compiler->nocache) {
|
| 42: |
|
| 43: | if (is_array($parameter[ 'if condition' ][ 'var' ])) {
|
| 44: | $var = $parameter[ 'if condition' ][ 'var' ][ 'var' ];
|
| 45: | } else {
|
| 46: | $var = $parameter[ 'if condition' ][ 'var' ];
|
| 47: | }
|
| 48: | $compiler->setNocacheInVariable($var);
|
| 49: | }
|
| 50: | $prefixVar = $compiler->getNewPrefixVariable();
|
| 51: | $assignCompiler = new Smarty_Internal_Compile_Assign();
|
| 52: | $assignAttr = array();
|
| 53: | $assignAttr[][ 'value' ] = $prefixVar;
|
| 54: | if (is_array($parameter[ 'if condition' ][ 'var' ])) {
|
| 55: | $assignAttr[][ 'var' ] = $parameter[ 'if condition' ][ 'var' ][ 'var' ];
|
| 56: | $_output = "<?php while ({$prefixVar} = {$parameter[ 'if condition' ][ 'value' ]}) {?>";
|
| 57: | $_output .= $assignCompiler->compile(
|
| 58: | $assignAttr,
|
| 59: | $compiler,
|
| 60: | array('smarty_internal_index' => $parameter[ 'if condition' ][ 'var' ][ 'smarty_internal_index' ])
|
| 61: | );
|
| 62: | } else {
|
| 63: | $assignAttr[][ 'var' ] = $parameter[ 'if condition' ][ 'var' ];
|
| 64: | $_output = "<?php while ({$prefixVar} = {$parameter[ 'if condition' ][ 'value' ]}) {?>";
|
| 65: | $_output .= $assignCompiler->compile($assignAttr, $compiler, array());
|
| 66: | }
|
| 67: | return $_output;
|
| 68: | } else {
|
| 69: | return "<?php\n while ({$parameter['if condition']}) {?>";
|
| 70: | }
|
| 71: | }
|
| 72: | }
|
| 73: |
|
| 74: | |
| 75: | |
| 76: | |
| 77: | |
| 78: | |
| 79: |
|
| 80: | class Smarty_Internal_Compile_Whileclose extends Smarty_Internal_CompileBase
|
| 81: | {
|
| 82: | |
| 83: | |
| 84: | |
| 85: | |
| 86: | |
| 87: | |
| 88: | |
| 89: |
|
| 90: | public function compile($args, Smarty_Internal_TemplateCompilerBase $compiler)
|
| 91: | {
|
| 92: | $compiler->loopNesting--;
|
| 93: |
|
| 94: | if ($compiler->nocache) {
|
| 95: | $compiler->tag_nocache = true;
|
| 96: | }
|
| 97: | $compiler->nocache = $this->closeTag($compiler, array('while'));
|
| 98: | return "<?php }?>\n";
|
| 99: | }
|
| 100: | }
|
| 101: | |