К новейшей редакции | Содержимое файла | Последнее изменение | Открыть журнал | RSS
Редакция | Автор | № строки | Строка |
---|---|---|---|
304 | alex-w | 1 | <?php |
2 | /** |
||
3 | * Smarty Internal Plugin Compile Object Block Function |
||
4 | * |
||
5 | * Compiles code for registered objects as block function |
||
6 | * |
||
7 | * @package Smarty |
||
8 | * @subpackage Compiler |
||
9 | * @author Uwe Tews |
||
10 | */ |
||
11 | /** |
||
12 | * Smarty Internal Plugin Compile Object Block Function Class |
||
13 | */ |
||
14 | class Smarty_Internal_Compile_Object_Block_Function extends Smarty_Internal_CompileBase { |
||
15 | /** |
||
16 | * Compiles code for the execution of block plugin |
||
17 | * |
||
18 | * @param array $args array with attributes from parser |
||
19 | * @param string $tag name of block function |
||
20 | * @param string $methode name of methode to call |
||
21 | * @param object $compiler compiler object |
||
22 | * @return string compiled code |
||
23 | */ |
||
24 | public function compile($args, $tag, $methode, $compiler) |
||
25 | { |
||
26 | $this->compiler = $compiler; |
||
27 | if (strlen($tag) < 5 || substr_compare($tag, 'close', -5, 5) != 0) { |
||
28 | // opening tag of block plugin |
||
29 | $this->required_attributes = array(); |
||
30 | $this->optional_attributes = array('_any'); |
||
31 | |||
32 | // check and get attributes |
||
33 | $_attr = $this->_get_attributes($args); |
||
34 | |||
35 | // convert attributes into parameter array string |
||
36 | $_paramsArray = array(); |
||
37 | foreach ($_attr as $_key => $_value) { |
||
38 | $_paramsArray[] = "'$_key'=>$_value"; |
||
39 | } |
||
40 | $_params = 'array(' . implode(",", $_paramsArray) . ')'; |
||
41 | |||
42 | $this->_open_tag($tag.'->'.$methode, $_params); |
||
43 | |||
44 | // compile code |
||
45 | $output = '<?php $_block_repeat=true; $_smarty_tpl->smarty->registered_objects[\''.$tag.'\'][0]->' . $methode . '(' . $_params . ', null, $_smarty_tpl->smarty, $_block_repeat, $_smarty_tpl);while ($_block_repeat) { ob_start();?>'; |
||
46 | } else { |
||
47 | // closing tag of block plugin |
||
48 | $_params = $this->_close_tag(substr($tag,0,-5).'->'.$methode); |
||
49 | // This tag does create output |
||
50 | $this->compiler->has_output = true; |
||
51 | // compile code |
||
52 | $output = '<?php $_block_content = ob_get_contents(); ob_end_clean(); $_block_repeat=false; echo $_smarty_tpl->smarty->registered_objects[\''.substr($tag,0,-5).'\'][0]->' . $methode . '(' . $_params . ', $_block_content, $_smarty_tpl->smarty, $_block_repeat, $_smarty_tpl); }?>'; |
||
53 | } |
||
54 | return $output; |
||
55 | } |
||
56 | } |
||
57 | |||
58 | ?> |