1<?php
2/**
3 * Smarty Internal Plugin Compile Setfilter
4 * Compiles code for setfilter tag
5 *
6 * @package    Smarty
7 * @subpackage Compiler
8 * @author     Uwe Tews
9 */
10
11/**
12 * Smarty Internal Plugin Compile Setfilter Class
13 *
14 * @package    Smarty
15 * @subpackage Compiler
16 */
17class Smarty_Internal_Compile_Setfilter extends Smarty_Internal_CompileBase
18{
19    /**
20     * Compiles code for setfilter tag
21     *
22     * @param array                                 $args      array with attributes from parser
23     * @param \Smarty_Internal_TemplateCompilerBase $compiler  compiler object
24     * @param array                                 $parameter array with compilation parameter
25     *
26     * @return string compiled code
27     */
28    public function compile($args, Smarty_Internal_TemplateCompilerBase $compiler, $parameter)
29    {
30        $compiler->variable_filter_stack[] = $compiler->variable_filters;
31        $compiler->variable_filters = $parameter[ 'modifier_list' ];
32        // this tag does not return compiled code
33        $compiler->has_code = false;
34        return true;
35    }
36}
37
38/**
39 * Smarty Internal Plugin Compile Setfilterclose Class
40 *
41 * @package    Smarty
42 * @subpackage Compiler
43 */
44class Smarty_Internal_Compile_Setfilterclose extends Smarty_Internal_CompileBase
45{
46    /**
47     * Compiles code for the {/setfilter} tag
48     * This tag does not generate compiled output. It resets variable filter.
49     *
50     * @param array                                 $args     array with attributes from parser
51     * @param \Smarty_Internal_TemplateCompilerBase $compiler compiler object
52     *
53     * @return string compiled code
54     */
55    public function compile($args, Smarty_Internal_TemplateCompilerBase $compiler)
56    {
57        $_attr = $this->getAttributes($compiler, $args);
58        // reset variable filter to previous state
59        if (count($compiler->variable_filter_stack)) {
60            $compiler->variable_filters = array_pop($compiler->variable_filter_stack);
61        } else {
62            $compiler->variable_filters = array();
63        }
64        // this tag does not return compiled code
65        $compiler->has_code = false;
66        return true;
67    }
68}
69