Хранилища Subversion ant

Редакция

Содержимое файла | Последнее изменение | Открыть журнал | RSS

Редакция Автор № строки Строка
304 alex-w 1
<?php
2
/**
3
* Smarty Internal Plugin Compile Block Plugin
4
*
5
* Compiles code for the execution of block plugin
6
*
7
* @package Smarty
8
* @subpackage Compiler
9
* @author Uwe Tews
10
*/
11
/**
12
* Smarty Internal Plugin Compile Block Plugin Class
13
*/
14
class Smarty_Internal_Compile_Block_Plugin 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 object $compiler compiler object
21
    * @return string compiled code
22
    */
23
    public function compile($args, $tag, $compiler)
24
    {
25
        $this->compiler = $compiler;
26
        if (strlen($tag) < 6 || substr_compare($tag, 'close', -5, 5) != 0) {
27
            // opening tag of block plugin
28
            $this->required_attributes = array();
29
            $this->optional_attributes = array('_any');
30
            // check and get attributes
31
            $_attr = $this->_get_attributes($args);
32
            // convert attributes into parameter array string
33
            $_paramsArray = array();
34
            foreach ($_attr as $_key => $_value) {
35
                $_paramsArray[] = "'$_key'=>$_value";
36
            }
37
            $_params = 'array(' . implode(",", $_paramsArray) . ')';
38
 
39
            $this->_open_tag($tag, array($_params, $this->compiler->nocache));
40
            // not cachable?
41
            if (isset($this->compiler->smarty->registered_plugins[$tag]) && !$this->compiler->smarty->registered_plugins[$tag][2]) {
42
                $this->compiler->nocache = true;
43
            }
44
            // compile code
45
            $output = '<?php $_block_repeat=true; $_smarty_tpl->smarty->plugin_handler->' . $tag . '(array(' . $_params . ', null, $_smarty_tpl->smarty, &$_block_repeat, $_smarty_tpl),\'block\');while ($_block_repeat) { ob_start();?>';
46
        } else {
47
            if ($this->compiler->nocache) {
48
                 $this->compiler->tag_nocache = true;
49
            }
50
            // closing tag of block plugin
51
            list($_params, $this->compiler->nocache) = $this->_close_tag(substr($tag, 0, -5));
52
            // This tag does create output
53
            $this->compiler->has_output = true;
54
            // compile code
55
            $output = '<?php $_block_content = ob_get_clean(); $_block_repeat=false; echo $_smarty_tpl->smarty->plugin_handler->' . substr($tag, 0, -5) . '(array(' . $_params . ', $_block_content, $_smarty_tpl->smarty, &$_block_repeat, $_smarty_tpl),\'block\'); }?>';
56
        }
57
        return $output;
58
    }
59
}
60
 
61
?>