1: | <?php
|
2: | |
3: | |
4: | |
5: | |
6: | |
7: | |
8: | |
9: |
|
10: |
|
11: | |
12: | |
13: | |
14: | |
15: |
|
16: | class Smarty_Internal_Compile_Child extends Smarty_Internal_CompileBase
|
17: | {
|
18: | |
19: | |
20: | |
21: | |
22: | |
23: |
|
24: | public $optional_attributes = array('assign');
|
25: |
|
26: | |
27: | |
28: | |
29: | |
30: |
|
31: | public $tag = 'child';
|
32: |
|
33: | |
34: | |
35: | |
36: | |
37: |
|
38: | public $blockType = 'Child';
|
39: |
|
40: | |
41: | |
42: | |
43: | |
44: | |
45: | |
46: | |
47: | |
48: | |
49: |
|
50: | public function compile($args, Smarty_Internal_TemplateCompilerBase $compiler, $parameter)
|
51: | {
|
52: |
|
53: | $_attr = $this->getAttributes($compiler, $args);
|
54: | $tag = isset($parameter[ 0 ]) ? "'{$parameter[0]}'" : "'{{$this->tag}}'";
|
55: | if (!isset($compiler->_cache[ 'blockNesting' ])) {
|
56: | $compiler->trigger_template_error(
|
57: | "{$tag} used outside {block} tags ",
|
58: | $compiler->parser->lex->taglineno
|
59: | );
|
60: | }
|
61: | $compiler->has_code = true;
|
62: | $compiler->suppressNocacheProcessing = true;
|
63: | if ($this->blockType === 'Child') {
|
64: | $compiler->_cache[ 'blockParams' ][ $compiler->_cache[ 'blockNesting' ] ][ 'callsChild' ] = 'true';
|
65: | }
|
66: | $_assign = isset($_attr[ 'assign' ]) ? $_attr[ 'assign' ] : null;
|
67: | $output = "<?php \n";
|
68: | if (isset($_assign)) {
|
69: | $output .= "ob_start();\n";
|
70: | }
|
71: | $output .= '$_smarty_tpl->inheritance->call' . $this->blockType . '($_smarty_tpl, $this' .
|
72: | ($this->blockType === 'Child' ? '' : ", {$tag}") . ");\n";
|
73: | if (isset($_assign)) {
|
74: | $output .= "\$_smarty_tpl->assign({$_assign}, ob_get_clean());\n";
|
75: | }
|
76: | $output .= "?>\n";
|
77: | return $output;
|
78: | }
|
79: | }
|
80: | |