summaryrefslogtreecommitdiff
path: root/libs/sysplugins/smarty_internal_compile_private_print_expression.php
blob: 850917d4b02ae3928053b1340549a5b5c4d34fbe (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
<?php
/**
 * Smarty Internal Plugin Compile Print Expression
 * 
 * Compiles any tag which will output an expression or variable
 * 
 * @package Smarty
 * @subpackage Compiler
 * @author Uwe Tews 
 */

/**
 * Smarty Internal Plugin Compile Print Expression Class
 */
class Smarty_Internal_Compile_Private_Print_Expression extends Smarty_Internal_CompileBase {
    /**
     * Compiles code for gererting output from any expression
     * 
     * @param array $args array with attributes from parser
     * @param object $compiler compiler object
     * @return string compiled code
     */
    public function compile($args, $compiler)
    {
        $this->compiler = $compiler;
        $this->required_attributes = array('value');
        $this->optional_attributes = array('assign', 'nocache', 'filter', 'nofilter', 'modifierlist'); 
        // check and get attributes
        $_attr = $this->_get_attributes($args);

        if (isset($_attr['nocache'])) {
            if ($_attr['nocache'] == 'true') {
                $this->compiler->tag_nocache = true;
            } 
        } 

        if (!isset($_attr['filter'])) {
            $_attr['filter'] = 'null';
        } 
        if (isset($_attr['nofilter'])) {
            if ($_attr['nofilter'] == 'true') {
                $_attr['filter'] = 'false';
            } 
        } 

        if (isset($_attr['assign'])) {
            // assign output to variable
            $output = '<?php $_smarty_tpl->assign(' . $_attr['assign'] . ',' . $_attr['value'] . ');?>';
        } else {
            // display value
            if (isset($this->compiler->smarty->registered_filters['variable'])) {
                $output = 'Smarty_Internal_Filter_Handler::runFilter(\'variable\', ' . $_attr['value'] . ',$_smarty_tpl->smarty, $_smarty_tpl, ' . $_attr['filter'] . ')';
            } else {
                $output = $_attr['value'];
            } 
            if (!isset($_attr['nofilter']) && isset($this->compiler->smarty->default_modifiers)) {
                $output = $this->compiler->compileTag('private_modifier', array('modifierlist' => $this->compiler->smarty->default_modifiers, 'value' => $output));
            } 
            if (isset($_attr['modifierlist'])) {
                $output = $this->compiler->compileTag('private_modifier', array('modifierlist' => $_attr['modifierlist'], 'value' => $output));
            } 
      $this->compiler->has_output = true;
           $output = '<?php echo ' . $output . ';?>';
        } 
        return $output;
    } 
} 

?>