| 1: | <?php
|
| 2: | |
| 3: | |
| 4: | |
| 5: | |
| 6: | |
| 7: | |
| 8: | |
| 9: |
|
| 10: |
|
| 11: | |
| 12: | |
| 13: | |
| 14: | |
| 15: | |
| 16: |
|
| 17: | class Smarty_Internal_Compile_Private_Block_Plugin extends Smarty_Internal_CompileBase
|
| 18: | {
|
| 19: | |
| 20: | |
| 21: | |
| 22: | |
| 23: | |
| 24: |
|
| 25: | public $optional_attributes = array('_any');
|
| 26: |
|
| 27: | |
| 28: | |
| 29: | |
| 30: | |
| 31: |
|
| 32: | public $nesting = 0;
|
| 33: |
|
| 34: | |
| 35: | |
| 36: | |
| 37: | |
| 38: | |
| 39: | |
| 40: | |
| 41: | |
| 42: | |
| 43: | |
| 44: | |
| 45: | |
| 46: |
|
| 47: | public function compile($args, Smarty_Internal_TemplateCompilerBase $compiler, $parameter, $tag, $function = null)
|
| 48: | {
|
| 49: | if (!isset($tag[ 5 ]) || substr($tag, -5) !== 'close') {
|
| 50: |
|
| 51: |
|
| 52: | $_attr = $this->getAttributes($compiler, $args);
|
| 53: | $this->nesting++;
|
| 54: | unset($_attr[ 'nocache' ]);
|
| 55: | list($callback, $_paramsArray, $callable) = $this->setup($compiler, $_attr, $tag, $function);
|
| 56: | $_params = 'array(' . implode(',', $_paramsArray) . ')';
|
| 57: |
|
| 58: | $output = "<?php ";
|
| 59: | if (is_array($callback)) {
|
| 60: | $output .= "\$_block_plugin{$this->nesting} = isset({$callback[0]}) ? {$callback[0]} : null;\n";
|
| 61: | $callback = "\$_block_plugin{$this->nesting}{$callback[1]}";
|
| 62: | }
|
| 63: | if (isset($callable)) {
|
| 64: | $output .= "if (!is_callable({$callable})) {\nthrow new SmartyException('block tag \'{$tag}\' not callable or registered');\n}\n";
|
| 65: | }
|
| 66: | $output .= "\$_smarty_tpl->smarty->_cache['_tag_stack'][] = array('{$tag}', {$_params});\n";
|
| 67: | $output .= "\$_block_repeat=true;\necho {$callback}({$_params}, null, \$_smarty_tpl, \$_block_repeat);\nwhile (\$_block_repeat) {\nob_start();?>";
|
| 68: | $this->openTag($compiler, $tag, array($_params, $compiler->nocache, $callback));
|
| 69: |
|
| 70: | $compiler->nocache = $compiler->nocache | $compiler->tag_nocache;
|
| 71: | } else {
|
| 72: |
|
| 73: | if ($compiler->nocache) {
|
| 74: | $compiler->tag_nocache = true;
|
| 75: | }
|
| 76: |
|
| 77: | list($_params, $compiler->nocache, $callback) = $this->closeTag($compiler, substr($tag, 0, -5));
|
| 78: |
|
| 79: | if (!isset($parameter[ 'modifier_list' ])) {
|
| 80: | $mod_pre = $mod_post = $mod_content = '';
|
| 81: | $mod_content2 = 'ob_get_clean()';
|
| 82: | } else {
|
| 83: | $mod_content2 = "\$_block_content{$this->nesting}";
|
| 84: | $mod_content = "\$_block_content{$this->nesting} = ob_get_clean();\n";
|
| 85: | $mod_pre = "ob_start();\n";
|
| 86: | $mod_post = 'echo ' . $compiler->compileTag(
|
| 87: | 'private_modifier',
|
| 88: | array(),
|
| 89: | array(
|
| 90: | 'modifierlist' => $parameter[ 'modifier_list' ],
|
| 91: | 'value' => 'ob_get_clean()'
|
| 92: | )
|
| 93: | ) . ";\n";
|
| 94: | }
|
| 95: | $output =
|
| 96: | "<?php {$mod_content}\$_block_repeat=false;\n{$mod_pre}echo {$callback}({$_params}, {$mod_content2}, \$_smarty_tpl, \$_block_repeat);\n{$mod_post}}\n";
|
| 97: | $output .= 'array_pop($_smarty_tpl->smarty->_cache[\'_tag_stack\']);?>';
|
| 98: | }
|
| 99: | return $output;
|
| 100: | }
|
| 101: |
|
| 102: | |
| 103: | |
| 104: | |
| 105: | |
| 106: | |
| 107: | |
| 108: | |
| 109: | |
| 110: | |
| 111: |
|
| 112: | public function setup(Smarty_Internal_TemplateCompilerBase $compiler, $_attr, $tag, $function)
|
| 113: | {
|
| 114: | $_paramsArray = array();
|
| 115: | foreach ($_attr as $_key => $_value) {
|
| 116: | if (is_int($_key)) {
|
| 117: | $_paramsArray[] = "$_key=>$_value";
|
| 118: | } else {
|
| 119: | $_paramsArray[] = "'$_key'=>$_value";
|
| 120: | }
|
| 121: | }
|
| 122: | return array($function, $_paramsArray, null);
|
| 123: | }
|
| 124: | }
|
| 125: | |