Subversion Repositories ALCASAR

Rev

Go to most recent revision | Details | Last modification | View Log

Rev Author Line No. Line
2809 rexy 1
<?php
2
/**
3
 * Smarty Internal Plugin Compile Capture
4
 * Compiles the {capture} tag
5
 *
6
 * @package    Smarty
7
 * @subpackage Compiler
8
 * @author     Uwe Tews
9
 */
10
 
11
/**
12
 * Smarty Internal Plugin Compile Capture Class
13
 *
14
 * @package    Smarty
15
 * @subpackage Compiler
16
 */
17
class Smarty_Internal_Compile_Capture extends Smarty_Internal_CompileBase
18
{
19
    /**
20
     * Attribute definition: Overwrites base class.
21
     *
22
     * @var array
23
     * @see Smarty_Internal_CompileBase
24
     */
25
    public $shorttag_order = array('name');
26
 
27
    /**
28
     * Attribute definition: Overwrites base class.
29
     *
30
     * @var array
31
     * @see Smarty_Internal_CompileBase
32
     */
33
    public $optional_attributes = array('name', 'assign', 'append');
34
 
35
    /**
36
     * Compiles code for the {$smarty.capture.xxx}
37
     *
38
     * @param array                                 $args      array with attributes from parser
39
     * @param \Smarty_Internal_TemplateCompilerBase $compiler  compiler object
40
     * @param array                                 $parameter array with compilation parameter
41
     *
42
     * @return string compiled code
43
     */
44
    public static function compileSpecialVariable(
45
        $args,
46
        Smarty_Internal_TemplateCompilerBase $compiler,
47
        $parameter = null
48
    ) {
49
        return '$_smarty_tpl->smarty->ext->_capture->getBuffer($_smarty_tpl' .
50
               (isset($parameter[ 1 ]) ? ", {$parameter[ 1 ]})" : ')');
51
    }
52
 
53
    /**
54
     * Compiles code for the {capture} tag
55
     *
56
     * @param array                                 $args     array with attributes from parser
57
     * @param \Smarty_Internal_TemplateCompilerBase $compiler compiler object
58
     * @param null                                  $parameter
59
     *
60
     * @return string compiled code
61
     */
62
    public function compile($args, Smarty_Internal_TemplateCompilerBase $compiler, $parameter = null)
63
    {
64
        // check and get attributes
65
        $_attr = $this->getAttributes($compiler, $args, $parameter, 'capture');
66
        $buffer = isset($_attr[ 'name' ]) ? $_attr[ 'name' ] : "'default'";
67
        $assign = isset($_attr[ 'assign' ]) ? $_attr[ 'assign' ] : 'null';
68
        $append = isset($_attr[ 'append' ]) ? $_attr[ 'append' ] : 'null';
69
        $compiler->_cache[ 'capture_stack' ][] = array($compiler->nocache);
70
        // maybe nocache because of nocache variables
71
        $compiler->nocache = $compiler->nocache | $compiler->tag_nocache;
72
        $_output = "<?php \$_smarty_tpl->smarty->ext->_capture->open(\$_smarty_tpl, $buffer, $assign, $append);?>";
73
        return $_output;
74
    }
75
}
76
 
77
/**
78
 * Smarty Internal Plugin Compile Captureclose Class
79
 *
80
 * @package    Smarty
81
 * @subpackage Compiler
82
 */
83
class Smarty_Internal_Compile_CaptureClose extends Smarty_Internal_CompileBase
84
{
85
    /**
86
     * Compiles code for the {/capture} tag
87
     *
88
     * @param array                                 $args     array with attributes from parser
89
     * @param \Smarty_Internal_TemplateCompilerBase $compiler compiler object
90
     * @param null                                  $parameter
91
     *
92
     * @return string compiled code
93
     */
94
    public function compile($args, Smarty_Internal_TemplateCompilerBase $compiler, $parameter)
95
    {
96
        // check and get attributes
97
        $_attr = $this->getAttributes($compiler, $args, $parameter, '/capture');
98
        // must endblock be nocache?
99
        if ($compiler->nocache) {
100
            $compiler->tag_nocache = true;
101
        }
102
        list($compiler->nocache) = array_pop($compiler->_cache[ 'capture_stack' ]);
103
        return "<?php \$_smarty_tpl->smarty->ext->_capture->close(\$_smarty_tpl);?>";
104
    }
105
}