Completed
Push — developer ( 7f46f3...3f66fa )
by Błażej
134:52 queued 72:56
created
libraries/Smarty/libs/sysplugins/smarty_internal_compile_for.php 2 patches
Indentation   +125 added lines, -125 removed lines patch added patch discarded remove patch
@@ -16,90 +16,90 @@  discard block
 block discarded – undo
16 16
  */
17 17
 class Smarty_Internal_Compile_For extends Smarty_Internal_CompileBase
18 18
 {
19
-    /**
20
-     * Compiles code for the {for} tag
21
-     * Smarty 3 does implement two different syntax's:
22
-     * - {for $var in $array}
23
-     * For looping over arrays or iterators
24
-     * - {for $x=0; $x<$y; $x++}
25
-     * For general loops
26
-     * The parser is generating different sets of attribute by which this compiler can
27
-     * determine which syntax is used.
28
-     *
29
-     * @param  array  $args      array with attributes from parser
30
-     * @param  object $compiler  compiler object
31
-     * @param  array  $parameter array with compilation parameter
32
-     *
33
-     * @return string compiled code
34
-     */
35
-    public function compile($args, $compiler, $parameter)
36
-    {
37
-        $compiler->loopNesting ++;
38
-        if ($parameter == 0) {
39
-            $this->required_attributes = array('start', 'to');
40
-            $this->optional_attributes = array('max', 'step');
41
-        } else {
42
-            $this->required_attributes = array('start', 'ifexp', 'var', 'step');
43
-            $this->optional_attributes = array();
44
-        }
45
-        $this->mapCache = array();
46
-        // check and get attributes
47
-        $_attr = $this->getAttributes($compiler, $args);
19
+	/**
20
+	 * Compiles code for the {for} tag
21
+	 * Smarty 3 does implement two different syntax's:
22
+	 * - {for $var in $array}
23
+	 * For looping over arrays or iterators
24
+	 * - {for $x=0; $x<$y; $x++}
25
+	 * For general loops
26
+	 * The parser is generating different sets of attribute by which this compiler can
27
+	 * determine which syntax is used.
28
+	 *
29
+	 * @param  array  $args      array with attributes from parser
30
+	 * @param  object $compiler  compiler object
31
+	 * @param  array  $parameter array with compilation parameter
32
+	 *
33
+	 * @return string compiled code
34
+	 */
35
+	public function compile($args, $compiler, $parameter)
36
+	{
37
+		$compiler->loopNesting ++;
38
+		if ($parameter == 0) {
39
+			$this->required_attributes = array('start', 'to');
40
+			$this->optional_attributes = array('max', 'step');
41
+		} else {
42
+			$this->required_attributes = array('start', 'ifexp', 'var', 'step');
43
+			$this->optional_attributes = array();
44
+		}
45
+		$this->mapCache = array();
46
+		// check and get attributes
47
+		$_attr = $this->getAttributes($compiler, $args);
48 48
 
49
-        $output = "<?php\n";
50
-        if ($parameter == 1) {
51
-            foreach ($_attr[ 'start' ] as $_statement) {
52
-                if (is_array($_statement[ 'var' ])) {
53
-                    $var = $_statement[ 'var' ][ 'var' ];
54
-                    $index = $_statement[ 'var' ][ 'smarty_internal_index' ];
55
-                } else {
56
-                    $var = $_statement[ 'var' ];
57
-                    $index = '';
58
-                }
59
-                $output .= "\$_smarty_tpl->tpl_vars[$var] = new Smarty_Variable(null, \$_smarty_tpl->isRenderingCache);\n";
60
-                $output .= "\$_smarty_tpl->tpl_vars[$var]->value{$index} = {$_statement['value']};\n";
61
-            }
62
-            if (is_array($_attr[ 'var' ])) {
63
-                $var = $_attr[ 'var' ][ 'var' ];
64
-                $index = $_attr[ 'var' ][ 'smarty_internal_index' ];
65
-            } else {
66
-                $var = $_attr[ 'var' ];
67
-                $index = '';
68
-            }
69
-            $output .= "if ($_attr[ifexp]) {\nfor (\$_foo=true;$_attr[ifexp]; \$_smarty_tpl->tpl_vars[$var]->value{$index}$_attr[step]) {\n";
70
-        } else {
71
-            $_statement = $_attr[ 'start' ];
72
-            if (is_array($_statement[ 'var' ])) {
73
-                $var = $_statement[ 'var' ][ 'var' ];
74
-                $index = $_statement[ 'var' ][ 'smarty_internal_index' ];
75
-            } else {
76
-                $var = $_statement[ 'var' ];
77
-                $index = '';
78
-            }
79
-            $output .= "\$_smarty_tpl->tpl_vars[$var] = new Smarty_Variable(null, \$_smarty_tpl->isRenderingCache);";
80
-            if (isset($_attr[ 'step' ])) {
81
-                $output .= "\$_smarty_tpl->tpl_vars[$var]->step = $_attr[step];";
82
-            } else {
83
-                $output .= "\$_smarty_tpl->tpl_vars[$var]->step = 1;";
84
-            }
85
-            if (isset($_attr[ 'max' ])) {
86
-                $output .= "\$_smarty_tpl->tpl_vars[$var]->total = (int) min(ceil((\$_smarty_tpl->tpl_vars[$var]->step > 0 ? $_attr[to]+1 - ($_statement[value]) : $_statement[value]-($_attr[to])+1)/abs(\$_smarty_tpl->tpl_vars[$var]->step)),$_attr[max]);\n";
87
-            } else {
88
-                $output .= "\$_smarty_tpl->tpl_vars[$var]->total = (int) ceil((\$_smarty_tpl->tpl_vars[$var]->step > 0 ? $_attr[to]+1 - ($_statement[value]) : $_statement[value]-($_attr[to])+1)/abs(\$_smarty_tpl->tpl_vars[$var]->step));\n";
89
-            }
90
-            $output .= "if (\$_smarty_tpl->tpl_vars[$var]->total > 0) {\n";
91
-            $output .= "for (\$_smarty_tpl->tpl_vars[$var]->value{$index} = $_statement[value], \$_smarty_tpl->tpl_vars[$var]->iteration = 1;\$_smarty_tpl->tpl_vars[$var]->iteration <= \$_smarty_tpl->tpl_vars[$var]->total;\$_smarty_tpl->tpl_vars[$var]->value{$index} += \$_smarty_tpl->tpl_vars[$var]->step, \$_smarty_tpl->tpl_vars[$var]->iteration++) {\n";
92
-            $output .= "\$_smarty_tpl->tpl_vars[$var]->first = \$_smarty_tpl->tpl_vars[$var]->iteration == 1;";
93
-            $output .= "\$_smarty_tpl->tpl_vars[$var]->last = \$_smarty_tpl->tpl_vars[$var]->iteration == \$_smarty_tpl->tpl_vars[$var]->total;";
94
-        }
95
-        $output .= "?>";
49
+		$output = "<?php\n";
50
+		if ($parameter == 1) {
51
+			foreach ($_attr[ 'start' ] as $_statement) {
52
+				if (is_array($_statement[ 'var' ])) {
53
+					$var = $_statement[ 'var' ][ 'var' ];
54
+					$index = $_statement[ 'var' ][ 'smarty_internal_index' ];
55
+				} else {
56
+					$var = $_statement[ 'var' ];
57
+					$index = '';
58
+				}
59
+				$output .= "\$_smarty_tpl->tpl_vars[$var] = new Smarty_Variable(null, \$_smarty_tpl->isRenderingCache);\n";
60
+				$output .= "\$_smarty_tpl->tpl_vars[$var]->value{$index} = {$_statement['value']};\n";
61
+			}
62
+			if (is_array($_attr[ 'var' ])) {
63
+				$var = $_attr[ 'var' ][ 'var' ];
64
+				$index = $_attr[ 'var' ][ 'smarty_internal_index' ];
65
+			} else {
66
+				$var = $_attr[ 'var' ];
67
+				$index = '';
68
+			}
69
+			$output .= "if ($_attr[ifexp]) {\nfor (\$_foo=true;$_attr[ifexp]; \$_smarty_tpl->tpl_vars[$var]->value{$index}$_attr[step]) {\n";
70
+		} else {
71
+			$_statement = $_attr[ 'start' ];
72
+			if (is_array($_statement[ 'var' ])) {
73
+				$var = $_statement[ 'var' ][ 'var' ];
74
+				$index = $_statement[ 'var' ][ 'smarty_internal_index' ];
75
+			} else {
76
+				$var = $_statement[ 'var' ];
77
+				$index = '';
78
+			}
79
+			$output .= "\$_smarty_tpl->tpl_vars[$var] = new Smarty_Variable(null, \$_smarty_tpl->isRenderingCache);";
80
+			if (isset($_attr[ 'step' ])) {
81
+				$output .= "\$_smarty_tpl->tpl_vars[$var]->step = $_attr[step];";
82
+			} else {
83
+				$output .= "\$_smarty_tpl->tpl_vars[$var]->step = 1;";
84
+			}
85
+			if (isset($_attr[ 'max' ])) {
86
+				$output .= "\$_smarty_tpl->tpl_vars[$var]->total = (int) min(ceil((\$_smarty_tpl->tpl_vars[$var]->step > 0 ? $_attr[to]+1 - ($_statement[value]) : $_statement[value]-($_attr[to])+1)/abs(\$_smarty_tpl->tpl_vars[$var]->step)),$_attr[max]);\n";
87
+			} else {
88
+				$output .= "\$_smarty_tpl->tpl_vars[$var]->total = (int) ceil((\$_smarty_tpl->tpl_vars[$var]->step > 0 ? $_attr[to]+1 - ($_statement[value]) : $_statement[value]-($_attr[to])+1)/abs(\$_smarty_tpl->tpl_vars[$var]->step));\n";
89
+			}
90
+			$output .= "if (\$_smarty_tpl->tpl_vars[$var]->total > 0) {\n";
91
+			$output .= "for (\$_smarty_tpl->tpl_vars[$var]->value{$index} = $_statement[value], \$_smarty_tpl->tpl_vars[$var]->iteration = 1;\$_smarty_tpl->tpl_vars[$var]->iteration <= \$_smarty_tpl->tpl_vars[$var]->total;\$_smarty_tpl->tpl_vars[$var]->value{$index} += \$_smarty_tpl->tpl_vars[$var]->step, \$_smarty_tpl->tpl_vars[$var]->iteration++) {\n";
92
+			$output .= "\$_smarty_tpl->tpl_vars[$var]->first = \$_smarty_tpl->tpl_vars[$var]->iteration == 1;";
93
+			$output .= "\$_smarty_tpl->tpl_vars[$var]->last = \$_smarty_tpl->tpl_vars[$var]->iteration == \$_smarty_tpl->tpl_vars[$var]->total;";
94
+		}
95
+		$output .= "?>";
96 96
 
97
-        $this->openTag($compiler, 'for', array('for', $compiler->nocache));
98
-        // maybe nocache because of nocache variables
99
-        $compiler->nocache = $compiler->nocache | $compiler->tag_nocache;
100
-        // return compiled code
101
-        return $output;
102
-    }
97
+		$this->openTag($compiler, 'for', array('for', $compiler->nocache));
98
+		// maybe nocache because of nocache variables
99
+		$compiler->nocache = $compiler->nocache | $compiler->tag_nocache;
100
+		// return compiled code
101
+		return $output;
102
+	}
103 103
 }
104 104
 
105 105
 /**
@@ -110,25 +110,25 @@  discard block
 block discarded – undo
110 110
  */
111 111
 class Smarty_Internal_Compile_Forelse extends Smarty_Internal_CompileBase
112 112
 {
113
-    /**
114
-     * Compiles code for the {forelse} tag
115
-     *
116
-     * @param  array  $args      array with attributes from parser
117
-     * @param  object $compiler  compiler object
118
-     * @param  array  $parameter array with compilation parameter
119
-     *
120
-     * @return string compiled code
121
-     */
122
-    public function compile($args, $compiler, $parameter)
123
-    {
124
-        // check and get attributes
125
-        $_attr = $this->getAttributes($compiler, $args);
113
+	/**
114
+	 * Compiles code for the {forelse} tag
115
+	 *
116
+	 * @param  array  $args      array with attributes from parser
117
+	 * @param  object $compiler  compiler object
118
+	 * @param  array  $parameter array with compilation parameter
119
+	 *
120
+	 * @return string compiled code
121
+	 */
122
+	public function compile($args, $compiler, $parameter)
123
+	{
124
+		// check and get attributes
125
+		$_attr = $this->getAttributes($compiler, $args);
126 126
 
127
-        list($openTag, $nocache) = $this->closeTag($compiler, array('for'));
128
-        $this->openTag($compiler, 'forelse', array('forelse', $nocache));
127
+		list($openTag, $nocache) = $this->closeTag($compiler, array('for'));
128
+		$this->openTag($compiler, 'forelse', array('forelse', $nocache));
129 129
 
130
-        return "<?php }} else { ?>";
131
-    }
130
+		return "<?php }} else { ?>";
131
+	}
132 132
 }
133 133
 
134 134
 /**
@@ -139,32 +139,32 @@  discard block
 block discarded – undo
139 139
  */
140 140
 class Smarty_Internal_Compile_Forclose extends Smarty_Internal_CompileBase
141 141
 {
142
-    /**
143
-     * Compiles code for the {/for} tag
144
-     *
145
-     * @param  array  $args      array with attributes from parser
146
-     * @param  object $compiler  compiler object
147
-     * @param  array  $parameter array with compilation parameter
148
-     *
149
-     * @return string compiled code
150
-     */
151
-    public function compile($args, $compiler, $parameter)
152
-    {
153
-        $compiler->loopNesting --;
154
-        // check and get attributes
155
-        $_attr = $this->getAttributes($compiler, $args);
156
-        // must endblock be nocache?
157
-        if ($compiler->nocache) {
158
-            $compiler->tag_nocache = true;
159
-        }
142
+	/**
143
+	 * Compiles code for the {/for} tag
144
+	 *
145
+	 * @param  array  $args      array with attributes from parser
146
+	 * @param  object $compiler  compiler object
147
+	 * @param  array  $parameter array with compilation parameter
148
+	 *
149
+	 * @return string compiled code
150
+	 */
151
+	public function compile($args, $compiler, $parameter)
152
+	{
153
+		$compiler->loopNesting --;
154
+		// check and get attributes
155
+		$_attr = $this->getAttributes($compiler, $args);
156
+		// must endblock be nocache?
157
+		if ($compiler->nocache) {
158
+			$compiler->tag_nocache = true;
159
+		}
160 160
 
161
-        list($openTag, $compiler->nocache) = $this->closeTag($compiler, array('for', 'forelse'));
161
+		list($openTag, $compiler->nocache) = $this->closeTag($compiler, array('for', 'forelse'));
162 162
 
163
-        $output = "<?php }\n";
164
-        if ($openTag != 'forelse') {
165
-            $output .= "}\n";
166
-        }
167
-        $output .= "?>\n";
168
-        return $output;
169
-    }
163
+		$output = "<?php }\n";
164
+		if ($openTag != 'forelse') {
165
+			$output .= "}\n";
166
+		}
167
+		$output .= "?>\n";
168
+		return $output;
169
+	}
170 170
 }
Please login to merge, or discard this patch.
Spacing   +18 added lines, -18 removed lines patch added patch discarded remove patch
@@ -34,7 +34,7 @@  discard block
 block discarded – undo
34 34
      */
35 35
     public function compile($args, $compiler, $parameter)
36 36
     {
37
-        $compiler->loopNesting ++;
37
+        $compiler->loopNesting++;
38 38
         if ($parameter == 0) {
39 39
             $this->required_attributes = array('start', 'to');
40 40
             $this->optional_attributes = array('max', 'step');
@@ -48,41 +48,41 @@  discard block
 block discarded – undo
48 48
 
49 49
         $output = "<?php\n";
50 50
         if ($parameter == 1) {
51
-            foreach ($_attr[ 'start' ] as $_statement) {
52
-                if (is_array($_statement[ 'var' ])) {
53
-                    $var = $_statement[ 'var' ][ 'var' ];
54
-                    $index = $_statement[ 'var' ][ 'smarty_internal_index' ];
51
+            foreach ($_attr['start'] as $_statement) {
52
+                if (is_array($_statement['var'])) {
53
+                    $var = $_statement['var']['var'];
54
+                    $index = $_statement['var']['smarty_internal_index'];
55 55
                 } else {
56
-                    $var = $_statement[ 'var' ];
56
+                    $var = $_statement['var'];
57 57
                     $index = '';
58 58
                 }
59 59
                 $output .= "\$_smarty_tpl->tpl_vars[$var] = new Smarty_Variable(null, \$_smarty_tpl->isRenderingCache);\n";
60 60
                 $output .= "\$_smarty_tpl->tpl_vars[$var]->value{$index} = {$_statement['value']};\n";
61 61
             }
62
-            if (is_array($_attr[ 'var' ])) {
63
-                $var = $_attr[ 'var' ][ 'var' ];
64
-                $index = $_attr[ 'var' ][ 'smarty_internal_index' ];
62
+            if (is_array($_attr['var'])) {
63
+                $var = $_attr['var']['var'];
64
+                $index = $_attr['var']['smarty_internal_index'];
65 65
             } else {
66
-                $var = $_attr[ 'var' ];
66
+                $var = $_attr['var'];
67 67
                 $index = '';
68 68
             }
69 69
             $output .= "if ($_attr[ifexp]) {\nfor (\$_foo=true;$_attr[ifexp]; \$_smarty_tpl->tpl_vars[$var]->value{$index}$_attr[step]) {\n";
70 70
         } else {
71
-            $_statement = $_attr[ 'start' ];
72
-            if (is_array($_statement[ 'var' ])) {
73
-                $var = $_statement[ 'var' ][ 'var' ];
74
-                $index = $_statement[ 'var' ][ 'smarty_internal_index' ];
71
+            $_statement = $_attr['start'];
72
+            if (is_array($_statement['var'])) {
73
+                $var = $_statement['var']['var'];
74
+                $index = $_statement['var']['smarty_internal_index'];
75 75
             } else {
76
-                $var = $_statement[ 'var' ];
76
+                $var = $_statement['var'];
77 77
                 $index = '';
78 78
             }
79 79
             $output .= "\$_smarty_tpl->tpl_vars[$var] = new Smarty_Variable(null, \$_smarty_tpl->isRenderingCache);";
80
-            if (isset($_attr[ 'step' ])) {
80
+            if (isset($_attr['step'])) {
81 81
                 $output .= "\$_smarty_tpl->tpl_vars[$var]->step = $_attr[step];";
82 82
             } else {
83 83
                 $output .= "\$_smarty_tpl->tpl_vars[$var]->step = 1;";
84 84
             }
85
-            if (isset($_attr[ 'max' ])) {
85
+            if (isset($_attr['max'])) {
86 86
                 $output .= "\$_smarty_tpl->tpl_vars[$var]->total = (int) min(ceil((\$_smarty_tpl->tpl_vars[$var]->step > 0 ? $_attr[to]+1 - ($_statement[value]) : $_statement[value]-($_attr[to])+1)/abs(\$_smarty_tpl->tpl_vars[$var]->step)),$_attr[max]);\n";
87 87
             } else {
88 88
                 $output .= "\$_smarty_tpl->tpl_vars[$var]->total = (int) ceil((\$_smarty_tpl->tpl_vars[$var]->step > 0 ? $_attr[to]+1 - ($_statement[value]) : $_statement[value]-($_attr[to])+1)/abs(\$_smarty_tpl->tpl_vars[$var]->step));\n";
@@ -150,7 +150,7 @@  discard block
 block discarded – undo
150 150
      */
151 151
     public function compile($args, $compiler, $parameter)
152 152
     {
153
-        $compiler->loopNesting --;
153
+        $compiler->loopNesting--;
154 154
         // check and get attributes
155 155
         $_attr = $this->getAttributes($compiler, $args);
156 156
         // must endblock be nocache?
Please login to merge, or discard this patch.
libraries/Smarty/libs/sysplugins/smarty_internal_runtime_inheritance.php 2 patches
Indentation   +195 added lines, -195 removed lines patch added patch discarded remove patch
@@ -11,212 +11,212 @@
 block discarded – undo
11 11
 class Smarty_Internal_Runtime_Inheritance
12 12
 {
13 13
 
14
-    /**
15
-     * State machine
16
-     * - 0 idle next extends will create a new inheritance tree
17
-     * - 1 processing child template
18
-     * - 2 wait for next inheritance template
19
-     * - 3 assume parent template, if child will loaded goto state 1
20
-     *     a call to a sub template resets the state to 0
21
-     *
22
-     * @var int
23
-     */
24
-    public $state = 0;
14
+	/**
15
+	 * State machine
16
+	 * - 0 idle next extends will create a new inheritance tree
17
+	 * - 1 processing child template
18
+	 * - 2 wait for next inheritance template
19
+	 * - 3 assume parent template, if child will loaded goto state 1
20
+	 *     a call to a sub template resets the state to 0
21
+	 *
22
+	 * @var int
23
+	 */
24
+	public $state = 0;
25 25
 
26
-    /**
27
-     * Array of root child {block} objects
28
-     *
29
-     * @var Smarty_Internal_Block[]
30
-     */
31
-    public $childRoot = array();
26
+	/**
27
+	 * Array of root child {block} objects
28
+	 *
29
+	 * @var Smarty_Internal_Block[]
30
+	 */
31
+	public $childRoot = array();
32 32
 
33
-    /**
34
-     * inheritance template nesting level
35
-     *
36
-     * @var int
37
-     */
38
-    public $inheritanceLevel = 0;
33
+	/**
34
+	 * inheritance template nesting level
35
+	 *
36
+	 * @var int
37
+	 */
38
+	public $inheritanceLevel = 0;
39 39
 
40
-    /**
41
-     * inheritance template index
42
-     *
43
-     * @var int
44
-     */
45
-    public $tplIndex = - 1;
40
+	/**
41
+	 * inheritance template index
42
+	 *
43
+	 * @var int
44
+	 */
45
+	public $tplIndex = - 1;
46 46
 
47
-    /**
48
-     * Array of template source objects
49
-     * - key template index
50
-     *
51
-     * @var Smarty_Template_Source[]
52
-     */
53
-    public $sources = array();
47
+	/**
48
+	 * Array of template source objects
49
+	 * - key template index
50
+	 *
51
+	 * @var Smarty_Template_Source[]
52
+	 */
53
+	public $sources = array();
54 54
 
55
-    /**
56
-     * Stack of source objects while executing block code
57
-     *
58
-     * @var Smarty_Template_Source[]
59
-     */
60
-    public $sourceStack = array();
55
+	/**
56
+	 * Stack of source objects while executing block code
57
+	 *
58
+	 * @var Smarty_Template_Source[]
59
+	 */
60
+	public $sourceStack = array();
61 61
 
62
-    /**
63
-     * Initialize inheritance
64
-     *
65
-     * @param \Smarty_Internal_Template $tpl        template object of caller
66
-     * @param bool                      $initChild  if true init for child template
67
-     * @param array                     $blockNames outer level block name
68
-     *
69
-     */
70
-    public function init(Smarty_Internal_Template $tpl, $initChild, $blockNames = array())
71
-    {
72
-        // if called while executing parent template it must be a sub-template with new inheritance root
73
-        if ($initChild && $this->state == 3 && (strpos($tpl->template_resource, 'extendsall') === false)) {
74
-            $tpl->inheritance = new Smarty_Internal_Runtime_Inheritance();
75
-            $tpl->inheritance->init($tpl, $initChild, $blockNames);
76
-            return;
77
-        }
78
-        $this->tplIndex ++;
79
-        $this->sources[ $this->tplIndex ] = $tpl->source;
62
+	/**
63
+	 * Initialize inheritance
64
+	 *
65
+	 * @param \Smarty_Internal_Template $tpl        template object of caller
66
+	 * @param bool                      $initChild  if true init for child template
67
+	 * @param array                     $blockNames outer level block name
68
+	 *
69
+	 */
70
+	public function init(Smarty_Internal_Template $tpl, $initChild, $blockNames = array())
71
+	{
72
+		// if called while executing parent template it must be a sub-template with new inheritance root
73
+		if ($initChild && $this->state == 3 && (strpos($tpl->template_resource, 'extendsall') === false)) {
74
+			$tpl->inheritance = new Smarty_Internal_Runtime_Inheritance();
75
+			$tpl->inheritance->init($tpl, $initChild, $blockNames);
76
+			return;
77
+		}
78
+		$this->tplIndex ++;
79
+		$this->sources[ $this->tplIndex ] = $tpl->source;
80 80
 
81
-        // start of child sub template(s)
82
-        if ($initChild) {
83
-            $this->state = 1;
84
-            if (!$this->inheritanceLevel) {
85
-                //grab any output of child templates
86
-                ob_start();
87
-            }
88
-            $this->inheritanceLevel ++;
89
-            //           $tpl->startRenderCallbacks[ 'inheritance' ] = array($this, 'subTemplateStart');
90
-            //           $tpl->endRenderCallbacks[ 'inheritance' ] = array($this, 'subTemplateEnd');
91
-        }
92
-        // if state was waiting for parent change state to parent
93
-        if ($this->state == 2) {
94
-            $this->state = 3;
95
-        }
96
-    }
81
+		// start of child sub template(s)
82
+		if ($initChild) {
83
+			$this->state = 1;
84
+			if (!$this->inheritanceLevel) {
85
+				//grab any output of child templates
86
+				ob_start();
87
+			}
88
+			$this->inheritanceLevel ++;
89
+			//           $tpl->startRenderCallbacks[ 'inheritance' ] = array($this, 'subTemplateStart');
90
+			//           $tpl->endRenderCallbacks[ 'inheritance' ] = array($this, 'subTemplateEnd');
91
+		}
92
+		// if state was waiting for parent change state to parent
93
+		if ($this->state == 2) {
94
+			$this->state = 3;
95
+		}
96
+	}
97 97
 
98
-    /**
99
-     * End of child template(s)
100
-     * - if outer level is reached flush output buffer and switch to wait for parent template state
101
-     *
102
-     */
103
-    public function endChild()
104
-    {
105
-        $this->inheritanceLevel --;
106
-        if (!$this->inheritanceLevel) {
107
-            ob_end_clean();
108
-            $this->state = 2;
109
-        }
110
-    }
98
+	/**
99
+	 * End of child template(s)
100
+	 * - if outer level is reached flush output buffer and switch to wait for parent template state
101
+	 *
102
+	 */
103
+	public function endChild()
104
+	{
105
+		$this->inheritanceLevel --;
106
+		if (!$this->inheritanceLevel) {
107
+			ob_end_clean();
108
+			$this->state = 2;
109
+		}
110
+	}
111 111
 
112
-    /**
113
-     * Smarty_Internal_Block constructor.
114
-     * - if outer level {block} of child template ($state == 1) save it as child root block
115
-     * - otherwise process inheritance and render
116
-     *
117
-     * @param \Smarty_Internal_Template $tpl
118
-     * @param                           $className
119
-     * @param string                    $name
120
-     * @param int|null                  $tplIndex index of outer level {block} if nested
121
-     */
122
-    public function instanceBlock(Smarty_Internal_Template $tpl, $className, $name, $tplIndex = null)
123
-    {
124
-        $block = new $className($name, $tplIndex ? $tplIndex : $this->tplIndex);
125
-        if (isset($this->childRoot[ $name ])) {
126
-            $block->child = $this->childRoot[ $name ];
127
-        }
128
-        if ($this->state == 1) {
129
-            $this->childRoot[ $name ] = $block;
130
-            return;
131
-        }
132
-        // make sure we got child block of child template of current block
133
-        while ($block->child && $block->tplIndex <= $block->child->tplIndex) {
134
-            $block->child = $block->child->child;
135
-        }
136
-        $this->process($tpl, $block);
137
-    }
112
+	/**
113
+	 * Smarty_Internal_Block constructor.
114
+	 * - if outer level {block} of child template ($state == 1) save it as child root block
115
+	 * - otherwise process inheritance and render
116
+	 *
117
+	 * @param \Smarty_Internal_Template $tpl
118
+	 * @param                           $className
119
+	 * @param string                    $name
120
+	 * @param int|null                  $tplIndex index of outer level {block} if nested
121
+	 */
122
+	public function instanceBlock(Smarty_Internal_Template $tpl, $className, $name, $tplIndex = null)
123
+	{
124
+		$block = new $className($name, $tplIndex ? $tplIndex : $this->tplIndex);
125
+		if (isset($this->childRoot[ $name ])) {
126
+			$block->child = $this->childRoot[ $name ];
127
+		}
128
+		if ($this->state == 1) {
129
+			$this->childRoot[ $name ] = $block;
130
+			return;
131
+		}
132
+		// make sure we got child block of child template of current block
133
+		while ($block->child && $block->tplIndex <= $block->child->tplIndex) {
134
+			$block->child = $block->child->child;
135
+		}
136
+		$this->process($tpl, $block);
137
+	}
138 138
 
139
-    /**
140
-     * Goto child block or render this
141
-     *
142
-     * @param \Smarty_Internal_Template   $tpl
143
-     * @param \Smarty_Internal_Block      $block
144
-     * @param \Smarty_Internal_Block|null $parent
145
-     *
146
-     * @throws \SmartyException
147
-     */
148
-    public function process(Smarty_Internal_Template $tpl, Smarty_Internal_Block $block,
149
-                            Smarty_Internal_Block $parent = null)
150
-    {
151
-        if ($block->hide && !isset($block->child)) {
152
-            return;
153
-        }
154
-        if (isset($block->child) && $block->child->hide && !isset($block->child->child)) {
155
-            $block->child = null;
156
-        }
157
-        $block->parent = $parent;
158
-        if ($block->append && !$block->prepend && isset($parent)) {
159
-            $this->callParent($tpl, $block);
160
-        }
161
-        if ($block->callsChild || !isset($block->child) || ($block->child->hide && !isset($block->child->child))) {
162
-            $this->callBlock($block, $tpl);
163
-        } else {
164
-            $this->process($tpl, $block->child, $block);
165
-        }
166
-        if ($block->prepend && isset($parent)) {
167
-            $this->callParent($tpl, $block);
168
-            if ($block->append) {
169
-                if ($block->callsChild || !isset($block->child) ||
170
-                    ($block->child->hide && !isset($block->child->child))
171
-                ) {
172
-                    $this->callBlock($block, $tpl);
173
-                } else {
174
-                    $this->process($tpl, $block->child, $block);
175
-                }
176
-            }
177
-        }
178
-        $block->parent = null;
179
-    }
139
+	/**
140
+	 * Goto child block or render this
141
+	 *
142
+	 * @param \Smarty_Internal_Template   $tpl
143
+	 * @param \Smarty_Internal_Block      $block
144
+	 * @param \Smarty_Internal_Block|null $parent
145
+	 *
146
+	 * @throws \SmartyException
147
+	 */
148
+	public function process(Smarty_Internal_Template $tpl, Smarty_Internal_Block $block,
149
+							Smarty_Internal_Block $parent = null)
150
+	{
151
+		if ($block->hide && !isset($block->child)) {
152
+			return;
153
+		}
154
+		if (isset($block->child) && $block->child->hide && !isset($block->child->child)) {
155
+			$block->child = null;
156
+		}
157
+		$block->parent = $parent;
158
+		if ($block->append && !$block->prepend && isset($parent)) {
159
+			$this->callParent($tpl, $block);
160
+		}
161
+		if ($block->callsChild || !isset($block->child) || ($block->child->hide && !isset($block->child->child))) {
162
+			$this->callBlock($block, $tpl);
163
+		} else {
164
+			$this->process($tpl, $block->child, $block);
165
+		}
166
+		if ($block->prepend && isset($parent)) {
167
+			$this->callParent($tpl, $block);
168
+			if ($block->append) {
169
+				if ($block->callsChild || !isset($block->child) ||
170
+					($block->child->hide && !isset($block->child->child))
171
+				) {
172
+					$this->callBlock($block, $tpl);
173
+				} else {
174
+					$this->process($tpl, $block->child, $block);
175
+				}
176
+			}
177
+		}
178
+		$block->parent = null;
179
+	}
180 180
 
181
-    /**
182
-     * Render child on {$smarty.block.child}
183
-     *
184
-     * @param \Smarty_Internal_Template $tpl
185
-     * @param \Smarty_Internal_Block    $block
186
-     */
187
-    public function callChild(Smarty_Internal_Template $tpl, Smarty_Internal_Block $block)
188
-    {
189
-        if (isset($block->child)) {
190
-            $this->process($tpl, $block->child, $block);
191
-        }
192
-    }
181
+	/**
182
+	 * Render child on {$smarty.block.child}
183
+	 *
184
+	 * @param \Smarty_Internal_Template $tpl
185
+	 * @param \Smarty_Internal_Block    $block
186
+	 */
187
+	public function callChild(Smarty_Internal_Template $tpl, Smarty_Internal_Block $block)
188
+	{
189
+		if (isset($block->child)) {
190
+			$this->process($tpl, $block->child, $block);
191
+		}
192
+	}
193 193
 
194
-    /**
195
-     * Render parent on {$smarty.block.parent} or {block append/prepend}     *
196
-     *
197
-     * @param \Smarty_Internal_Template $tpl
198
-     * @param \Smarty_Internal_Block    $block
199
-     *
200
-     * @throws \SmartyException
201
-     */
202
-    public function callParent(Smarty_Internal_Template $tpl, Smarty_Internal_Block $block)
203
-    {
204
-        if (isset($block->parent)) {
205
-            $this->callBlock($block->parent, $tpl);
206
-        } else {
207
-            throw new SmartyException("inheritance: illegal {\$smarty.block.parent} or {block append/prepend} used in parent template '{$tpl->inheritance->sources[$block->tplIndex]->filepath}' block '{$block->name}'");
208
-        }
209
-    }
194
+	/**
195
+	 * Render parent on {$smarty.block.parent} or {block append/prepend}     *
196
+	 *
197
+	 * @param \Smarty_Internal_Template $tpl
198
+	 * @param \Smarty_Internal_Block    $block
199
+	 *
200
+	 * @throws \SmartyException
201
+	 */
202
+	public function callParent(Smarty_Internal_Template $tpl, Smarty_Internal_Block $block)
203
+	{
204
+		if (isset($block->parent)) {
205
+			$this->callBlock($block->parent, $tpl);
206
+		} else {
207
+			throw new SmartyException("inheritance: illegal {\$smarty.block.parent} or {block append/prepend} used in parent template '{$tpl->inheritance->sources[$block->tplIndex]->filepath}' block '{$block->name}'");
208
+		}
209
+	}
210 210
 
211
-    /**
212
-     * @param \Smarty_Internal_Block    $block
213
-     * @param \Smarty_Internal_Template $tpl
214
-     */
215
-    public function callBlock(Smarty_Internal_Block $block, Smarty_Internal_Template $tpl)
216
-    {
217
-        $this->sourceStack[] = $tpl->source;
218
-        $tpl->source = $this->sources[ $block->tplIndex ];
219
-        $block->callBlock($tpl);
220
-        $tpl->source = array_pop($this->sourceStack);
221
-    }
211
+	/**
212
+	 * @param \Smarty_Internal_Block    $block
213
+	 * @param \Smarty_Internal_Template $tpl
214
+	 */
215
+	public function callBlock(Smarty_Internal_Block $block, Smarty_Internal_Template $tpl)
216
+	{
217
+		$this->sourceStack[] = $tpl->source;
218
+		$tpl->source = $this->sources[ $block->tplIndex ];
219
+		$block->callBlock($tpl);
220
+		$tpl->source = array_pop($this->sourceStack);
221
+	}
222 222
 }
Please login to merge, or discard this patch.
Spacing   +8 added lines, -8 removed lines patch added patch discarded remove patch
@@ -75,8 +75,8 @@  discard block
 block discarded – undo
75 75
             $tpl->inheritance->init($tpl, $initChild, $blockNames);
76 76
             return;
77 77
         }
78
-        $this->tplIndex ++;
79
-        $this->sources[ $this->tplIndex ] = $tpl->source;
78
+        $this->tplIndex++;
79
+        $this->sources[$this->tplIndex] = $tpl->source;
80 80
 
81 81
         // start of child sub template(s)
82 82
         if ($initChild) {
@@ -85,7 +85,7 @@  discard block
 block discarded – undo
85 85
                 //grab any output of child templates
86 86
                 ob_start();
87 87
             }
88
-            $this->inheritanceLevel ++;
88
+            $this->inheritanceLevel++;
89 89
             //           $tpl->startRenderCallbacks[ 'inheritance' ] = array($this, 'subTemplateStart');
90 90
             //           $tpl->endRenderCallbacks[ 'inheritance' ] = array($this, 'subTemplateEnd');
91 91
         }
@@ -102,7 +102,7 @@  discard block
 block discarded – undo
102 102
      */
103 103
     public function endChild()
104 104
     {
105
-        $this->inheritanceLevel --;
105
+        $this->inheritanceLevel--;
106 106
         if (!$this->inheritanceLevel) {
107 107
             ob_end_clean();
108 108
             $this->state = 2;
@@ -122,11 +122,11 @@  discard block
 block discarded – undo
122 122
     public function instanceBlock(Smarty_Internal_Template $tpl, $className, $name, $tplIndex = null)
123 123
     {
124 124
         $block = new $className($name, $tplIndex ? $tplIndex : $this->tplIndex);
125
-        if (isset($this->childRoot[ $name ])) {
126
-            $block->child = $this->childRoot[ $name ];
125
+        if (isset($this->childRoot[$name])) {
126
+            $block->child = $this->childRoot[$name];
127 127
         }
128 128
         if ($this->state == 1) {
129
-            $this->childRoot[ $name ] = $block;
129
+            $this->childRoot[$name] = $block;
130 130
             return;
131 131
         }
132 132
         // make sure we got child block of child template of current block
@@ -215,7 +215,7 @@  discard block
 block discarded – undo
215 215
     public function callBlock(Smarty_Internal_Block $block, Smarty_Internal_Template $tpl)
216 216
     {
217 217
         $this->sourceStack[] = $tpl->source;
218
-        $tpl->source = $this->sources[ $block->tplIndex ];
218
+        $tpl->source = $this->sources[$block->tplIndex];
219 219
         $block->callBlock($tpl);
220 220
         $tpl->source = array_pop($this->sourceStack);
221 221
     }
Please login to merge, or discard this patch.
libraries/Smarty/libs/sysplugins/smarty_internal_parsetree_tag.php 1 patch
Indentation   +43 added lines, -43 removed lines patch added patch discarded remove patch
@@ -19,51 +19,51 @@
 block discarded – undo
19 19
 class Smarty_Internal_ParseTree_Tag extends Smarty_Internal_ParseTree
20 20
 {
21 21
 
22
-    /**
23
-     * Saved block nesting level
24
-     *
25
-     * @var int
26
-     */
27
-    public $saved_block_nesting;
22
+	/**
23
+	 * Saved block nesting level
24
+	 *
25
+	 * @var int
26
+	 */
27
+	public $saved_block_nesting;
28 28
 
29
-    /**
30
-     * Create parse tree buffer for Smarty tag
31
-     *
32
-     * @param \Smarty_Internal_Templateparser $parser parser object
33
-     * @param string                          $data   content
34
-     */
35
-    public function __construct(Smarty_Internal_Templateparser $parser, $data)
36
-    {
37
-        $this->data = $data;
38
-        $this->saved_block_nesting = $parser->block_nesting_level;
39
-    }
29
+	/**
30
+	 * Create parse tree buffer for Smarty tag
31
+	 *
32
+	 * @param \Smarty_Internal_Templateparser $parser parser object
33
+	 * @param string                          $data   content
34
+	 */
35
+	public function __construct(Smarty_Internal_Templateparser $parser, $data)
36
+	{
37
+		$this->data = $data;
38
+		$this->saved_block_nesting = $parser->block_nesting_level;
39
+	}
40 40
 
41
-    /**
42
-     * Return buffer content
43
-     *
44
-     * @param \Smarty_Internal_Templateparser $parser
45
-     *
46
-     * @return string content
47
-     */
48
-    public function to_smarty_php(Smarty_Internal_Templateparser $parser)
49
-    {
50
-        return $this->data;
51
-    }
41
+	/**
42
+	 * Return buffer content
43
+	 *
44
+	 * @param \Smarty_Internal_Templateparser $parser
45
+	 *
46
+	 * @return string content
47
+	 */
48
+	public function to_smarty_php(Smarty_Internal_Templateparser $parser)
49
+	{
50
+		return $this->data;
51
+	}
52 52
 
53
-    /**
54
-     * Return complied code that loads the evaluated output of buffer content into a temporary variable
55
-     *
56
-     * @param \Smarty_Internal_Templateparser $parser
57
-     *
58
-     * @return string template code
59
-     */
60
-    public function assign_to_var(Smarty_Internal_Templateparser $parser)
61
-    {
62
-        $var = $parser->compiler->getNewPrefixVariable();
63
-        $tmp = $parser->compiler->appendCode('<?php ob_start();?>', $this->data);
64
-        $tmp = $parser->compiler->appendCode($tmp, "<?php {$var}=ob_get_clean();?>");
65
-        $parser->compiler->prefix_code[] = sprintf("%s", $tmp);
53
+	/**
54
+	 * Return complied code that loads the evaluated output of buffer content into a temporary variable
55
+	 *
56
+	 * @param \Smarty_Internal_Templateparser $parser
57
+	 *
58
+	 * @return string template code
59
+	 */
60
+	public function assign_to_var(Smarty_Internal_Templateparser $parser)
61
+	{
62
+		$var = $parser->compiler->getNewPrefixVariable();
63
+		$tmp = $parser->compiler->appendCode('<?php ob_start();?>', $this->data);
64
+		$tmp = $parser->compiler->appendCode($tmp, "<?php {$var}=ob_get_clean();?>");
65
+		$parser->compiler->prefix_code[] = sprintf("%s", $tmp);
66 66
 
67
-        return $var;
68
-    }
67
+		return $var;
68
+	}
69 69
 }
Please login to merge, or discard this patch.
libraries/Smarty/libs/sysplugins/smarty_internal_runtime_codeframe.php 2 patches
Indentation   +80 added lines, -80 removed lines patch added patch discarded remove patch
@@ -14,85 +14,85 @@
 block discarded – undo
14 14
  */
15 15
 class Smarty_Internal_Runtime_CodeFrame
16 16
 {
17
-    /**
18
-     * Create code frame for compiled and cached templates
19
-     *
20
-     * @param Smarty_Internal_Template              $_template
21
-     * @param string                                $content   optional template content
22
-     * @param string                                $functions compiled template function and block code
23
-     * @param bool                                  $cache     flag for cache file
24
-     * @param \Smarty_Internal_TemplateCompilerBase $compiler
25
-     *
26
-     * @return string
27
-     */
28
-    public function create(Smarty_Internal_Template $_template, $content = '', $functions = '', $cache = false,
29
-                           Smarty_Internal_TemplateCompilerBase $compiler = null)
30
-    {
31
-        // build property code
32
-        $properties[ 'version' ] = Smarty::SMARTY_VERSION;
33
-        $properties[ 'unifunc' ] = 'content_' . str_replace(array('.', ','), '_', uniqid('', true));
34
-        if (!$cache) {
35
-            $properties[ 'has_nocache_code' ] = $_template->compiled->has_nocache_code;
36
-            $properties[ 'file_dependency' ] = $_template->compiled->file_dependency;
37
-            $properties[ 'includes' ] = $_template->compiled->includes;
38
-         } else {
39
-            $properties[ 'has_nocache_code' ] = $_template->cached->has_nocache_code;
40
-            $properties[ 'file_dependency' ] = $_template->cached->file_dependency;
41
-            $properties[ 'cache_lifetime' ] = $_template->cache_lifetime;
42
-        }
43
-        $output = "<?php\n";
44
-        $output .= "/* Smarty version " . Smarty::SMARTY_VERSION . ", created on " . strftime("%Y-%m-%d %H:%M:%S") .
45
-                   "\n  from \"" . $_template->source->filepath . "\" */\n\n";
46
-        $output .= "/* @var Smarty_Internal_Template \$_smarty_tpl */\n";
47
-        $dec = "\$_smarty_tpl->_decodeProperties(\$_smarty_tpl, " . var_export($properties, true) . ',' .
48
-               ($cache ? 'true' : 'false') . ")";
49
-        $output .= "if ({$dec}) {\n";
50
-        $output .= "function {$properties['unifunc']} (Smarty_Internal_Template \$_smarty_tpl) {\n";
51
-        if (!$cache && !empty($compiler->tpl_function)) {
52
-            $output .= "\$_smarty_tpl->ext->_tplFunction->registerTplFunctions(\$_smarty_tpl, " .
53
-                       var_export($compiler->tpl_function, true) . ");\n";
54
-        }
55
-        if ($cache && isset($_template->ext->_tplFunction)) {
56
-            $output .= "\$_smarty_tpl->ext->_tplFunction->registerTplFunctions(\$_smarty_tpl, " .
57
-                       var_export($_template->ext->_tplFunction->getTplFunction(), true) . ");\n";
17
+	/**
18
+	 * Create code frame for compiled and cached templates
19
+	 *
20
+	 * @param Smarty_Internal_Template              $_template
21
+	 * @param string                                $content   optional template content
22
+	 * @param string                                $functions compiled template function and block code
23
+	 * @param bool                                  $cache     flag for cache file
24
+	 * @param \Smarty_Internal_TemplateCompilerBase $compiler
25
+	 *
26
+	 * @return string
27
+	 */
28
+	public function create(Smarty_Internal_Template $_template, $content = '', $functions = '', $cache = false,
29
+						   Smarty_Internal_TemplateCompilerBase $compiler = null)
30
+	{
31
+		// build property code
32
+		$properties[ 'version' ] = Smarty::SMARTY_VERSION;
33
+		$properties[ 'unifunc' ] = 'content_' . str_replace(array('.', ','), '_', uniqid('', true));
34
+		if (!$cache) {
35
+			$properties[ 'has_nocache_code' ] = $_template->compiled->has_nocache_code;
36
+			$properties[ 'file_dependency' ] = $_template->compiled->file_dependency;
37
+			$properties[ 'includes' ] = $_template->compiled->includes;
38
+		 } else {
39
+			$properties[ 'has_nocache_code' ] = $_template->cached->has_nocache_code;
40
+			$properties[ 'file_dependency' ] = $_template->cached->file_dependency;
41
+			$properties[ 'cache_lifetime' ] = $_template->cache_lifetime;
42
+		}
43
+		$output = "<?php\n";
44
+		$output .= "/* Smarty version " . Smarty::SMARTY_VERSION . ", created on " . strftime("%Y-%m-%d %H:%M:%S") .
45
+				   "\n  from \"" . $_template->source->filepath . "\" */\n\n";
46
+		$output .= "/* @var Smarty_Internal_Template \$_smarty_tpl */\n";
47
+		$dec = "\$_smarty_tpl->_decodeProperties(\$_smarty_tpl, " . var_export($properties, true) . ',' .
48
+			   ($cache ? 'true' : 'false') . ")";
49
+		$output .= "if ({$dec}) {\n";
50
+		$output .= "function {$properties['unifunc']} (Smarty_Internal_Template \$_smarty_tpl) {\n";
51
+		if (!$cache && !empty($compiler->tpl_function)) {
52
+			$output .= "\$_smarty_tpl->ext->_tplFunction->registerTplFunctions(\$_smarty_tpl, " .
53
+					   var_export($compiler->tpl_function, true) . ");\n";
54
+		}
55
+		if ($cache && isset($_template->ext->_tplFunction)) {
56
+			$output .= "\$_smarty_tpl->ext->_tplFunction->registerTplFunctions(\$_smarty_tpl, " .
57
+					   var_export($_template->ext->_tplFunction->getTplFunction(), true) . ");\n";
58 58
 
59
-        }
60
-        // include code for plugins
61
-        if (!$cache) {
62
-            if (!empty($_template->compiled->required_plugins[ 'compiled' ])) {
63
-                foreach ($_template->compiled->required_plugins[ 'compiled' ] as $tmp) {
64
-                    foreach ($tmp as $data) {
65
-                        $file = addslashes($data[ 'file' ]);
66
-                        if (is_array($data[ 'function' ])) {
67
-                            $output .= "if (!is_callable(array('{$data['function'][0]}','{$data['function'][1]}'))) require_once '{$file}';\n";
68
-                        } else {
69
-                            $output .= "if (!is_callable('{$data['function']}')) require_once '{$file}';\n";
70
-                        }
71
-                    }
72
-                }
73
-            }
74
-            if ($_template->caching && !empty($_template->compiled->required_plugins[ 'nocache' ])) {
75
-                $_template->compiled->has_nocache_code = true;
76
-                $output .= "echo '/*%%SmartyNocache:{$_template->compiled->nocache_hash}%%*/<?php \$_smarty = \$_smarty_tpl->smarty; ";
77
-                foreach ($_template->compiled->required_plugins[ 'nocache' ] as $tmp) {
78
-                    foreach ($tmp as $data) {
79
-                        $file = addslashes($data[ 'file' ]);
80
-                        if (is_array($data[ 'function' ])) {
81
-                            $output .= addslashes("if (!is_callable(array('{$data['function'][0]}','{$data['function'][1]}'))) require_once '{$file}';\n");
82
-                        } else {
83
-                            $output .= addslashes("if (!is_callable('{$data['function']}')) require_once '{$file}';\n");
84
-                        }
85
-                    }
86
-                }
87
-                $output .= "?>/*/%%SmartyNocache:{$_template->compiled->nocache_hash}%%*/';\n";
88
-            }
89
-        }
90
-        $output .= "?>\n";
91
-        $output .= $content;
92
-        $output .= "<?php }\n?>";
93
-        $output .= $functions;
94
-        $output .= "<?php }\n";
95
-        // remove unneeded PHP tags
96
-        return preg_replace(array('/\s*\?>[\n]?<\?php\s*/', '/\?>\s*$/'), array("\n", ''), $output);
97
-    }
59
+		}
60
+		// include code for plugins
61
+		if (!$cache) {
62
+			if (!empty($_template->compiled->required_plugins[ 'compiled' ])) {
63
+				foreach ($_template->compiled->required_plugins[ 'compiled' ] as $tmp) {
64
+					foreach ($tmp as $data) {
65
+						$file = addslashes($data[ 'file' ]);
66
+						if (is_array($data[ 'function' ])) {
67
+							$output .= "if (!is_callable(array('{$data['function'][0]}','{$data['function'][1]}'))) require_once '{$file}';\n";
68
+						} else {
69
+							$output .= "if (!is_callable('{$data['function']}')) require_once '{$file}';\n";
70
+						}
71
+					}
72
+				}
73
+			}
74
+			if ($_template->caching && !empty($_template->compiled->required_plugins[ 'nocache' ])) {
75
+				$_template->compiled->has_nocache_code = true;
76
+				$output .= "echo '/*%%SmartyNocache:{$_template->compiled->nocache_hash}%%*/<?php \$_smarty = \$_smarty_tpl->smarty; ";
77
+				foreach ($_template->compiled->required_plugins[ 'nocache' ] as $tmp) {
78
+					foreach ($tmp as $data) {
79
+						$file = addslashes($data[ 'file' ]);
80
+						if (is_array($data[ 'function' ])) {
81
+							$output .= addslashes("if (!is_callable(array('{$data['function'][0]}','{$data['function'][1]}'))) require_once '{$file}';\n");
82
+						} else {
83
+							$output .= addslashes("if (!is_callable('{$data['function']}')) require_once '{$file}';\n");
84
+						}
85
+					}
86
+				}
87
+				$output .= "?>/*/%%SmartyNocache:{$_template->compiled->nocache_hash}%%*/';\n";
88
+			}
89
+		}
90
+		$output .= "?>\n";
91
+		$output .= $content;
92
+		$output .= "<?php }\n?>";
93
+		$output .= $functions;
94
+		$output .= "<?php }\n";
95
+		// remove unneeded PHP tags
96
+		return preg_replace(array('/\s*\?>[\n]?<\?php\s*/', '/\?>\s*$/'), array("\n", ''), $output);
97
+	}
98 98
 }
99 99
\ No newline at end of file
Please login to merge, or discard this patch.
Spacing   +16 added lines, -16 removed lines patch added patch discarded remove patch
@@ -29,16 +29,16 @@  discard block
 block discarded – undo
29 29
                            Smarty_Internal_TemplateCompilerBase $compiler = null)
30 30
     {
31 31
         // build property code
32
-        $properties[ 'version' ] = Smarty::SMARTY_VERSION;
33
-        $properties[ 'unifunc' ] = 'content_' . str_replace(array('.', ','), '_', uniqid('', true));
32
+        $properties['version'] = Smarty::SMARTY_VERSION;
33
+        $properties['unifunc'] = 'content_' . str_replace(array('.', ','), '_', uniqid('', true));
34 34
         if (!$cache) {
35
-            $properties[ 'has_nocache_code' ] = $_template->compiled->has_nocache_code;
36
-            $properties[ 'file_dependency' ] = $_template->compiled->file_dependency;
37
-            $properties[ 'includes' ] = $_template->compiled->includes;
35
+            $properties['has_nocache_code'] = $_template->compiled->has_nocache_code;
36
+            $properties['file_dependency'] = $_template->compiled->file_dependency;
37
+            $properties['includes'] = $_template->compiled->includes;
38 38
          } else {
39
-            $properties[ 'has_nocache_code' ] = $_template->cached->has_nocache_code;
40
-            $properties[ 'file_dependency' ] = $_template->cached->file_dependency;
41
-            $properties[ 'cache_lifetime' ] = $_template->cache_lifetime;
39
+            $properties['has_nocache_code'] = $_template->cached->has_nocache_code;
40
+            $properties['file_dependency'] = $_template->cached->file_dependency;
41
+            $properties['cache_lifetime'] = $_template->cache_lifetime;
42 42
         }
43 43
         $output = "<?php\n";
44 44
         $output .= "/* Smarty version " . Smarty::SMARTY_VERSION . ", created on " . strftime("%Y-%m-%d %H:%M:%S") .
@@ -59,11 +59,11 @@  discard block
 block discarded – undo
59 59
         }
60 60
         // include code for plugins
61 61
         if (!$cache) {
62
-            if (!empty($_template->compiled->required_plugins[ 'compiled' ])) {
63
-                foreach ($_template->compiled->required_plugins[ 'compiled' ] as $tmp) {
62
+            if (!empty($_template->compiled->required_plugins['compiled'])) {
63
+                foreach ($_template->compiled->required_plugins['compiled'] as $tmp) {
64 64
                     foreach ($tmp as $data) {
65
-                        $file = addslashes($data[ 'file' ]);
66
-                        if (is_array($data[ 'function' ])) {
65
+                        $file = addslashes($data['file']);
66
+                        if (is_array($data['function'])) {
67 67
                             $output .= "if (!is_callable(array('{$data['function'][0]}','{$data['function'][1]}'))) require_once '{$file}';\n";
68 68
                         } else {
69 69
                             $output .= "if (!is_callable('{$data['function']}')) require_once '{$file}';\n";
@@ -71,13 +71,13 @@  discard block
 block discarded – undo
71 71
                     }
72 72
                 }
73 73
             }
74
-            if ($_template->caching && !empty($_template->compiled->required_plugins[ 'nocache' ])) {
74
+            if ($_template->caching && !empty($_template->compiled->required_plugins['nocache'])) {
75 75
                 $_template->compiled->has_nocache_code = true;
76 76
                 $output .= "echo '/*%%SmartyNocache:{$_template->compiled->nocache_hash}%%*/<?php \$_smarty = \$_smarty_tpl->smarty; ";
77
-                foreach ($_template->compiled->required_plugins[ 'nocache' ] as $tmp) {
77
+                foreach ($_template->compiled->required_plugins['nocache'] as $tmp) {
78 78
                     foreach ($tmp as $data) {
79
-                        $file = addslashes($data[ 'file' ]);
80
-                        if (is_array($data[ 'function' ])) {
79
+                        $file = addslashes($data['file']);
80
+                        if (is_array($data['function'])) {
81 81
                             $output .= addslashes("if (!is_callable(array('{$data['function'][0]}','{$data['function'][1]}'))) require_once '{$file}';\n");
82 82
                         } else {
83 83
                             $output .= addslashes("if (!is_callable('{$data['function']}')) require_once '{$file}';\n");
Please login to merge, or discard this patch.
libraries/Smarty/libs/sysplugins/smarty_internal_config_file_compiler.php 2 patches
Indentation   +165 added lines, -165 removed lines patch added patch discarded remove patch
@@ -17,183 +17,183 @@
 block discarded – undo
17 17
  */
18 18
 class Smarty_Internal_Config_File_Compiler
19 19
 {
20
-    /**
21
-     * Lexer class name
22
-     *
23
-     * @var string
24
-     */
25
-    public $lexer_class;
20
+	/**
21
+	 * Lexer class name
22
+	 *
23
+	 * @var string
24
+	 */
25
+	public $lexer_class;
26 26
 
27
-    /**
28
-     * Parser class name
29
-     *
30
-     * @var string
31
-     */
32
-    public $parser_class;
27
+	/**
28
+	 * Parser class name
29
+	 *
30
+	 * @var string
31
+	 */
32
+	public $parser_class;
33 33
 
34
-    /**
35
-     * Lexer object
36
-     *
37
-     * @var object
38
-     */
39
-    public $lex;
34
+	/**
35
+	 * Lexer object
36
+	 *
37
+	 * @var object
38
+	 */
39
+	public $lex;
40 40
 
41
-    /**
42
-     * Parser object
43
-     *
44
-     * @var object
45
-     */
46
-    public $parser;
41
+	/**
42
+	 * Parser object
43
+	 *
44
+	 * @var object
45
+	 */
46
+	public $parser;
47 47
 
48
-    /**
49
-     * Smarty object
50
-     *
51
-     * @var Smarty object
52
-     */
53
-    public $smarty;
48
+	/**
49
+	 * Smarty object
50
+	 *
51
+	 * @var Smarty object
52
+	 */
53
+	public $smarty;
54 54
 
55
-    /**
56
-     * Smarty object
57
-     *
58
-     * @var Smarty_Internal_Template object
59
-     */
60
-    public $template;
55
+	/**
56
+	 * Smarty object
57
+	 *
58
+	 * @var Smarty_Internal_Template object
59
+	 */
60
+	public $template;
61 61
 
62
-    /**
63
-     * Compiled config data sections and variables
64
-     *
65
-     * @var array
66
-     */
67
-    public $config_data = array();
62
+	/**
63
+	 * Compiled config data sections and variables
64
+	 *
65
+	 * @var array
66
+	 */
67
+	public $config_data = array();
68 68
 
69
-    /**
70
-     * compiled config data must always be written
71
-     *
72
-     * @var bool
73
-     */
74
-    public $write_compiled_code = true;
69
+	/**
70
+	 * compiled config data must always be written
71
+	 *
72
+	 * @var bool
73
+	 */
74
+	public $write_compiled_code = true;
75 75
 
76
-    /**
77
-     * Initialize compiler
78
-     *
79
-     * @param string $lexer_class  class name
80
-     * @param string $parser_class class name
81
-     * @param Smarty $smarty       global instance
82
-     */
83
-    public function __construct($lexer_class, $parser_class, Smarty $smarty)
84
-    {
85
-        $this->smarty = $smarty;
86
-        // get required plugins
87
-        $this->lexer_class = $lexer_class;
88
-        $this->parser_class = $parser_class;
89
-        $this->smarty = $smarty;
90
-        $this->config_data[ 'sections' ] = array();
91
-        $this->config_data[ 'vars' ] = array();
92
-    }
76
+	/**
77
+	 * Initialize compiler
78
+	 *
79
+	 * @param string $lexer_class  class name
80
+	 * @param string $parser_class class name
81
+	 * @param Smarty $smarty       global instance
82
+	 */
83
+	public function __construct($lexer_class, $parser_class, Smarty $smarty)
84
+	{
85
+		$this->smarty = $smarty;
86
+		// get required plugins
87
+		$this->lexer_class = $lexer_class;
88
+		$this->parser_class = $parser_class;
89
+		$this->smarty = $smarty;
90
+		$this->config_data[ 'sections' ] = array();
91
+		$this->config_data[ 'vars' ] = array();
92
+	}
93 93
 
94
-    /**
95
-     * Method to compile Smarty config source.
96
-     *
97
-     * @param Smarty_Internal_Template $template
98
-     *
99
-     * @return bool true if compiling succeeded, false if it failed
100
-     */
101
-    public function compileTemplate(Smarty_Internal_Template $template)
102
-    {
103
-        $this->template = $template;
104
-        $this->template->compiled->file_dependency[ $this->template->source->uid ] =
105
-            array($this->template->source->filepath, $this->template->source->getTimeStamp(),
106
-                  $this->template->source->type);
107
-        if ($this->smarty->debugging) {
108
-            if (!isset( $this->smarty->_debug)) {
109
-                $this->smarty->_debug  = new Smarty_Internal_Debug();
110
-            }
111
-            $this->smarty->_debug->start_compile($this->template);
112
-        }
113
-        // init the lexer/parser to compile the config file
114
-        /* @var Smarty_Internal_ConfigFileLexer $lex */
115
-        $lex = new $this->lexer_class(str_replace(array("\r\n", "\r"), "\n", $template->source->getContent()) . "\n",
116
-                                      $this);
117
-        /* @var Smarty_Internal_ConfigFileParser $parser */
118
-        $parser = new $this->parser_class($lex, $this);
94
+	/**
95
+	 * Method to compile Smarty config source.
96
+	 *
97
+	 * @param Smarty_Internal_Template $template
98
+	 *
99
+	 * @return bool true if compiling succeeded, false if it failed
100
+	 */
101
+	public function compileTemplate(Smarty_Internal_Template $template)
102
+	{
103
+		$this->template = $template;
104
+		$this->template->compiled->file_dependency[ $this->template->source->uid ] =
105
+			array($this->template->source->filepath, $this->template->source->getTimeStamp(),
106
+				  $this->template->source->type);
107
+		if ($this->smarty->debugging) {
108
+			if (!isset( $this->smarty->_debug)) {
109
+				$this->smarty->_debug  = new Smarty_Internal_Debug();
110
+			}
111
+			$this->smarty->_debug->start_compile($this->template);
112
+		}
113
+		// init the lexer/parser to compile the config file
114
+		/* @var Smarty_Internal_ConfigFileLexer $lex */
115
+		$lex = new $this->lexer_class(str_replace(array("\r\n", "\r"), "\n", $template->source->getContent()) . "\n",
116
+									  $this);
117
+		/* @var Smarty_Internal_ConfigFileParser $parser */
118
+		$parser = new $this->parser_class($lex, $this);
119 119
 
120
-        if (function_exists('mb_internal_encoding') && ((int) ini_get('mbstring.func_overload')) & 2) {
121
-            $mbEncoding = mb_internal_encoding();
122
-            mb_internal_encoding('ASCII');
123
-        } else {
124
-            $mbEncoding = null;
125
-        }
120
+		if (function_exists('mb_internal_encoding') && ((int) ini_get('mbstring.func_overload')) & 2) {
121
+			$mbEncoding = mb_internal_encoding();
122
+			mb_internal_encoding('ASCII');
123
+		} else {
124
+			$mbEncoding = null;
125
+		}
126 126
 
127
-        if ($this->smarty->_parserdebug) {
128
-            $parser->PrintTrace();
129
-        }
130
-        // get tokens from lexer and parse them
131
-        while ($lex->yylex()) {
132
-            if ($this->smarty->_parserdebug) {
133
-                echo "<br>Parsing  {$parser->yyTokenName[$lex->token]} Token {$lex->value} Line {$lex->line} \n";
134
-            }
135
-            $parser->doParse($lex->token, $lex->value);
136
-        }
137
-        // finish parsing process
138
-        $parser->doParse(0, 0);
127
+		if ($this->smarty->_parserdebug) {
128
+			$parser->PrintTrace();
129
+		}
130
+		// get tokens from lexer and parse them
131
+		while ($lex->yylex()) {
132
+			if ($this->smarty->_parserdebug) {
133
+				echo "<br>Parsing  {$parser->yyTokenName[$lex->token]} Token {$lex->value} Line {$lex->line} \n";
134
+			}
135
+			$parser->doParse($lex->token, $lex->value);
136
+		}
137
+		// finish parsing process
138
+		$parser->doParse(0, 0);
139 139
 
140
-        if ($mbEncoding) {
141
-            mb_internal_encoding($mbEncoding);
142
-        }
143
-        if ($this->smarty->debugging) {
144
-            $this->smarty->_debug->end_compile($this->template);
145
-        }
146
-        // template header code
147
-        $template_header =
148
-            "<?php /* Smarty version " . Smarty::SMARTY_VERSION . ", created on " . strftime("%Y-%m-%d %H:%M:%S") .
149
-            "\n";
150
-        $template_header .= "         compiled from \"" . $this->template->source->filepath . "\" */ ?>\n";
140
+		if ($mbEncoding) {
141
+			mb_internal_encoding($mbEncoding);
142
+		}
143
+		if ($this->smarty->debugging) {
144
+			$this->smarty->_debug->end_compile($this->template);
145
+		}
146
+		// template header code
147
+		$template_header =
148
+			"<?php /* Smarty version " . Smarty::SMARTY_VERSION . ", created on " . strftime("%Y-%m-%d %H:%M:%S") .
149
+			"\n";
150
+		$template_header .= "         compiled from \"" . $this->template->source->filepath . "\" */ ?>\n";
151 151
 
152
-        $code = '<?php $_smarty_tpl->smarty->ext->configLoad->_loadConfigVars($_smarty_tpl, ' .
153
-                var_export($this->config_data, true) . '); ?>';
154
-        return $template_header . $this->template->smarty->ext->_codeFrame->create($this->template, $code);
155
-    }
152
+		$code = '<?php $_smarty_tpl->smarty->ext->configLoad->_loadConfigVars($_smarty_tpl, ' .
153
+				var_export($this->config_data, true) . '); ?>';
154
+		return $template_header . $this->template->smarty->ext->_codeFrame->create($this->template, $code);
155
+	}
156 156
 
157
-    /**
158
-     * display compiler error messages without dying
159
-     * If parameter $args is empty it is a parser detected syntax error.
160
-     * In this case the parser is called to obtain information about expected tokens.
161
-     * If parameter $args contains a string this is used as error message
162
-     *
163
-     * @param string $args individual error message or null
164
-     *
165
-     * @throws SmartyCompilerException
166
-     */
167
-    public function trigger_config_file_error($args = null)
168
-    {
169
-        $this->lex = Smarty_Internal_Configfilelexer::instance();
170
-        $this->parser = Smarty_Internal_Configfileparser::instance();
171
-        // get config source line which has error
172
-        $line = $this->lex->line;
173
-        if (isset($args)) {
174
-            // $line--;
175
-        }
176
-        $match = preg_split("/\n/", $this->lex->data);
177
-        $error_text =
178
-            "Syntax error in config file '{$this->template->source->filepath}' on line {$line} '{$match[$line - 1]}' ";
179
-        if (isset($args)) {
180
-            // individual error message
181
-            $error_text .= $args;
182
-        } else {
183
-            // expected token from parser
184
-            foreach ($this->parser->yy_get_expected_tokens($this->parser->yymajor) as $token) {
185
-                $exp_token = $this->parser->yyTokenName[ $token ];
186
-                if (isset($this->lex->smarty_token_names[ $exp_token ])) {
187
-                    // token type from lexer
188
-                    $expect[] = '"' . $this->lex->smarty_token_names[ $exp_token ] . '"';
189
-                } else {
190
-                    // otherwise internal token name
191
-                    $expect[] = $this->parser->yyTokenName[ $token ];
192
-                }
193
-            }
194
-            // output parser error message
195
-            $error_text .= ' - Unexpected "' . $this->lex->value . '", expected one of: ' . implode(' , ', $expect);
196
-        }
197
-        throw new SmartyCompilerException($error_text);
198
-    }
157
+	/**
158
+	 * display compiler error messages without dying
159
+	 * If parameter $args is empty it is a parser detected syntax error.
160
+	 * In this case the parser is called to obtain information about expected tokens.
161
+	 * If parameter $args contains a string this is used as error message
162
+	 *
163
+	 * @param string $args individual error message or null
164
+	 *
165
+	 * @throws SmartyCompilerException
166
+	 */
167
+	public function trigger_config_file_error($args = null)
168
+	{
169
+		$this->lex = Smarty_Internal_Configfilelexer::instance();
170
+		$this->parser = Smarty_Internal_Configfileparser::instance();
171
+		// get config source line which has error
172
+		$line = $this->lex->line;
173
+		if (isset($args)) {
174
+			// $line--;
175
+		}
176
+		$match = preg_split("/\n/", $this->lex->data);
177
+		$error_text =
178
+			"Syntax error in config file '{$this->template->source->filepath}' on line {$line} '{$match[$line - 1]}' ";
179
+		if (isset($args)) {
180
+			// individual error message
181
+			$error_text .= $args;
182
+		} else {
183
+			// expected token from parser
184
+			foreach ($this->parser->yy_get_expected_tokens($this->parser->yymajor) as $token) {
185
+				$exp_token = $this->parser->yyTokenName[ $token ];
186
+				if (isset($this->lex->smarty_token_names[ $exp_token ])) {
187
+					// token type from lexer
188
+					$expect[] = '"' . $this->lex->smarty_token_names[ $exp_token ] . '"';
189
+				} else {
190
+					// otherwise internal token name
191
+					$expect[] = $this->parser->yyTokenName[ $token ];
192
+				}
193
+			}
194
+			// output parser error message
195
+			$error_text .= ' - Unexpected "' . $this->lex->value . '", expected one of: ' . implode(' , ', $expect);
196
+		}
197
+		throw new SmartyCompilerException($error_text);
198
+	}
199 199
 }
Please login to merge, or discard this patch.
Spacing   +9 added lines, -9 removed lines patch added patch discarded remove patch
@@ -87,8 +87,8 @@  discard block
 block discarded – undo
87 87
         $this->lexer_class = $lexer_class;
88 88
         $this->parser_class = $parser_class;
89 89
         $this->smarty = $smarty;
90
-        $this->config_data[ 'sections' ] = array();
91
-        $this->config_data[ 'vars' ] = array();
90
+        $this->config_data['sections'] = array();
91
+        $this->config_data['vars'] = array();
92 92
     }
93 93
 
94 94
     /**
@@ -101,12 +101,12 @@  discard block
 block discarded – undo
101 101
     public function compileTemplate(Smarty_Internal_Template $template)
102 102
     {
103 103
         $this->template = $template;
104
-        $this->template->compiled->file_dependency[ $this->template->source->uid ] =
104
+        $this->template->compiled->file_dependency[$this->template->source->uid] =
105 105
             array($this->template->source->filepath, $this->template->source->getTimeStamp(),
106 106
                   $this->template->source->type);
107 107
         if ($this->smarty->debugging) {
108
-            if (!isset( $this->smarty->_debug)) {
109
-                $this->smarty->_debug  = new Smarty_Internal_Debug();
108
+            if (!isset($this->smarty->_debug)) {
109
+                $this->smarty->_debug = new Smarty_Internal_Debug();
110 110
             }
111 111
             $this->smarty->_debug->start_compile($this->template);
112 112
         }
@@ -182,13 +182,13 @@  discard block
 block discarded – undo
182 182
         } else {
183 183
             // expected token from parser
184 184
             foreach ($this->parser->yy_get_expected_tokens($this->parser->yymajor) as $token) {
185
-                $exp_token = $this->parser->yyTokenName[ $token ];
186
-                if (isset($this->lex->smarty_token_names[ $exp_token ])) {
185
+                $exp_token = $this->parser->yyTokenName[$token];
186
+                if (isset($this->lex->smarty_token_names[$exp_token])) {
187 187
                     // token type from lexer
188
-                    $expect[] = '"' . $this->lex->smarty_token_names[ $exp_token ] . '"';
188
+                    $expect[] = '"' . $this->lex->smarty_token_names[$exp_token] . '"';
189 189
                 } else {
190 190
                     // otherwise internal token name
191
-                    $expect[] = $this->parser->yyTokenName[ $token ];
191
+                    $expect[] = $this->parser->yyTokenName[$token];
192 192
                 }
193 193
             }
194 194
             // output parser error message
Please login to merge, or discard this patch.
libraries/Smarty/libs/sysplugins/smarty_internal_runtime_getincludepath.php 2 patches
Indentation   +154 added lines, -154 removed lines patch added patch discarded remove patch
@@ -15,168 +15,168 @@
 block discarded – undo
15 15
  */
16 16
 class Smarty_Internal_Runtime_GetIncludePath
17 17
 {
18
-    /**
19
-     * include path cache
20
-     *
21
-     * @var string
22
-     */
23
-    public $_include_path = '';
18
+	/**
19
+	 * include path cache
20
+	 *
21
+	 * @var string
22
+	 */
23
+	public $_include_path = '';
24 24
 
25
-    /**
26
-     * include path directory cache
27
-     *
28
-     * @var array
29
-     */
30
-    public $_include_dirs = array();
25
+	/**
26
+	 * include path directory cache
27
+	 *
28
+	 * @var array
29
+	 */
30
+	public $_include_dirs = array();
31 31
 
32
-    /**
33
-     * include path directory cache
34
-     *
35
-     * @var array
36
-     */
37
-    public $_user_dirs = array();
32
+	/**
33
+	 * include path directory cache
34
+	 *
35
+	 * @var array
36
+	 */
37
+	public $_user_dirs = array();
38 38
 
39
-    /**
40
-     * stream cache
41
-     *
42
-     * @var string[]
43
-     */
44
-    public $isFile = array();
39
+	/**
40
+	 * stream cache
41
+	 *
42
+	 * @var string[]
43
+	 */
44
+	public $isFile = array();
45 45
 
46
-    /**
47
-     * stream cache
48
-     *
49
-     * @var string[]
50
-     */
51
-    public $isPath = array();
46
+	/**
47
+	 * stream cache
48
+	 *
49
+	 * @var string[]
50
+	 */
51
+	public $isPath = array();
52 52
 
53
-    /**
54
-     * stream cache
55
-     *
56
-     * @var int[]
57
-     */
58
-    public $number = array();
53
+	/**
54
+	 * stream cache
55
+	 *
56
+	 * @var int[]
57
+	 */
58
+	public $number = array();
59 59
 
60
-    /**
61
-     * status cache
62
-     *
63
-     * @var bool
64
-     */
65
-    public $_has_stream_include = null;
60
+	/**
61
+	 * status cache
62
+	 *
63
+	 * @var bool
64
+	 */
65
+	public $_has_stream_include = null;
66 66
 
67
-    /**
68
-     * Number for array index
69
-     *
70
-     * @var int
71
-     */
72
-    public $counter = 0;
67
+	/**
68
+	 * Number for array index
69
+	 *
70
+	 * @var int
71
+	 */
72
+	public $counter = 0;
73 73
 
74
-    /**
75
-     * Check if include path was updated
76
-     *
77
-     * @param \Smarty $smarty
78
-     *
79
-     * @return bool
80
-     */
81
-    public function isNewIncludePath(Smarty $smarty)
82
-    {
83
-        $_i_path = get_include_path();
84
-        if ($this->_include_path != $_i_path) {
85
-            $this->_include_dirs = array();
86
-            $this->_include_path = $_i_path;
87
-            $_dirs = (array) explode(PATH_SEPARATOR, $_i_path);
88
-            foreach ($_dirs as $_path) {
89
-                if (is_dir($_path)) {
90
-                    $this->_include_dirs[] = $smarty->_realpath($_path . DS, true);
91
-                }
92
-            }
93
-            return true;
94
-        }
95
-        return false;
96
-    }
74
+	/**
75
+	 * Check if include path was updated
76
+	 *
77
+	 * @param \Smarty $smarty
78
+	 *
79
+	 * @return bool
80
+	 */
81
+	public function isNewIncludePath(Smarty $smarty)
82
+	{
83
+		$_i_path = get_include_path();
84
+		if ($this->_include_path != $_i_path) {
85
+			$this->_include_dirs = array();
86
+			$this->_include_path = $_i_path;
87
+			$_dirs = (array) explode(PATH_SEPARATOR, $_i_path);
88
+			foreach ($_dirs as $_path) {
89
+				if (is_dir($_path)) {
90
+					$this->_include_dirs[] = $smarty->_realpath($_path . DS, true);
91
+				}
92
+			}
93
+			return true;
94
+		}
95
+		return false;
96
+	}
97 97
 
98
-    /**
99
-     * return array with include path directories
100
-     *
101
-     * @param \Smarty $smarty
102
-     *
103
-     * @return array
104
-     */
105
-    public function getIncludePathDirs(Smarty $smarty)
106
-    {
107
-        $this->isNewIncludePath($smarty);
108
-        return $this->_include_dirs;
109
-    }
98
+	/**
99
+	 * return array with include path directories
100
+	 *
101
+	 * @param \Smarty $smarty
102
+	 *
103
+	 * @return array
104
+	 */
105
+	public function getIncludePathDirs(Smarty $smarty)
106
+	{
107
+		$this->isNewIncludePath($smarty);
108
+		return $this->_include_dirs;
109
+	}
110 110
 
111
-    /**
112
-     * Return full file path from PHP include_path
113
-     *
114
-     * @param  string[] $dirs
115
-     * @param  string   $file
116
-     * @param \Smarty   $smarty
117
-     *
118
-     * @return bool|string full filepath or false
119
-     *
120
-     */
121
-    public function getIncludePath($dirs, $file, Smarty $smarty)
122
-    {
123
-        //if (!(isset($this->_has_stream_include) ? $this->_has_stream_include : $this->_has_stream_include = false)) {
124
-        if (!(isset($this->_has_stream_include) ? $this->_has_stream_include :
125
-            $this->_has_stream_include = function_exists('stream_resolve_include_path'))
126
-        ) {
127
-            $this->isNewIncludePath($smarty);
128
-        }
129
-        // try PHP include_path
130
-        foreach ($dirs as $dir) {
131
-            $dir_n = isset($this->number[ $dir ]) ? $this->number[ $dir ] : $this->number[ $dir ] = $this->counter ++;
132
-            if (isset($this->isFile[ $dir_n ][ $file ])) {
133
-                if ($this->isFile[ $dir_n ][ $file ]) {
134
-                    return $this->isFile[ $dir_n ][ $file ];
135
-                } else {
136
-                    continue;
137
-                }
138
-            }
139
-            if (isset($this->_user_dirs[ $dir_n ])) {
140
-                if (false === $this->_user_dirs[ $dir_n ]) {
141
-                    continue;
142
-                } else {
143
-                    $dir = $this->_user_dirs[ $dir_n ];
144
-                }
145
-            } else {
146
-                if ($dir[ 0 ] == '/' || $dir[ 1 ] == ':') {
147
-                    $dir = str_ireplace(getcwd(), '.', $dir);
148
-                    if ($dir[ 0 ] == '/' || $dir[ 1 ] == ':') {
149
-                        $this->_user_dirs[ $dir_n ] = false;
150
-                        continue;
151
-                    }
152
-                }
153
-                $dir = substr($dir, 2);
154
-                $this->_user_dirs[ $dir_n ] = $dir;
155
-            }
156
-            if ($this->_has_stream_include) {
157
-                $path = stream_resolve_include_path($dir . (isset($file) ? $file : ''));
158
-                if ($path) {
159
-                    return $this->isFile[ $dir_n ][ $file ] = $path;
160
-                }
161
-            } else {
162
-                foreach ($this->_include_dirs as $key => $_i_path) {
163
-                    $path = isset($this->isPath[ $key ][ $dir_n ]) ? $this->isPath[ $key ][ $dir_n ] :
164
-                        $this->isPath[ $key ][ $dir_n ] = is_dir($_dir_path = $_i_path . $dir) ? $_dir_path : false;
165
-                    if ($path === false) {
166
-                        continue;
167
-                    }
168
-                    if (isset($file)) {
169
-                        $_file = $this->isFile[ $dir_n ][ $file ] = (is_file($path . $file)) ? $path . $file : false;
170
-                        if ($_file) {
171
-                            return $_file;
172
-                        }
173
-                    } else {
174
-                        // no file was given return directory path
175
-                        return $path;
176
-                    }
177
-                }
178
-            }
179
-        }
180
-        return false;
181
-    }
111
+	/**
112
+	 * Return full file path from PHP include_path
113
+	 *
114
+	 * @param  string[] $dirs
115
+	 * @param  string   $file
116
+	 * @param \Smarty   $smarty
117
+	 *
118
+	 * @return bool|string full filepath or false
119
+	 *
120
+	 */
121
+	public function getIncludePath($dirs, $file, Smarty $smarty)
122
+	{
123
+		//if (!(isset($this->_has_stream_include) ? $this->_has_stream_include : $this->_has_stream_include = false)) {
124
+		if (!(isset($this->_has_stream_include) ? $this->_has_stream_include :
125
+			$this->_has_stream_include = function_exists('stream_resolve_include_path'))
126
+		) {
127
+			$this->isNewIncludePath($smarty);
128
+		}
129
+		// try PHP include_path
130
+		foreach ($dirs as $dir) {
131
+			$dir_n = isset($this->number[ $dir ]) ? $this->number[ $dir ] : $this->number[ $dir ] = $this->counter ++;
132
+			if (isset($this->isFile[ $dir_n ][ $file ])) {
133
+				if ($this->isFile[ $dir_n ][ $file ]) {
134
+					return $this->isFile[ $dir_n ][ $file ];
135
+				} else {
136
+					continue;
137
+				}
138
+			}
139
+			if (isset($this->_user_dirs[ $dir_n ])) {
140
+				if (false === $this->_user_dirs[ $dir_n ]) {
141
+					continue;
142
+				} else {
143
+					$dir = $this->_user_dirs[ $dir_n ];
144
+				}
145
+			} else {
146
+				if ($dir[ 0 ] == '/' || $dir[ 1 ] == ':') {
147
+					$dir = str_ireplace(getcwd(), '.', $dir);
148
+					if ($dir[ 0 ] == '/' || $dir[ 1 ] == ':') {
149
+						$this->_user_dirs[ $dir_n ] = false;
150
+						continue;
151
+					}
152
+				}
153
+				$dir = substr($dir, 2);
154
+				$this->_user_dirs[ $dir_n ] = $dir;
155
+			}
156
+			if ($this->_has_stream_include) {
157
+				$path = stream_resolve_include_path($dir . (isset($file) ? $file : ''));
158
+				if ($path) {
159
+					return $this->isFile[ $dir_n ][ $file ] = $path;
160
+				}
161
+			} else {
162
+				foreach ($this->_include_dirs as $key => $_i_path) {
163
+					$path = isset($this->isPath[ $key ][ $dir_n ]) ? $this->isPath[ $key ][ $dir_n ] :
164
+						$this->isPath[ $key ][ $dir_n ] = is_dir($_dir_path = $_i_path . $dir) ? $_dir_path : false;
165
+					if ($path === false) {
166
+						continue;
167
+					}
168
+					if (isset($file)) {
169
+						$_file = $this->isFile[ $dir_n ][ $file ] = (is_file($path . $file)) ? $path . $file : false;
170
+						if ($_file) {
171
+							return $_file;
172
+						}
173
+					} else {
174
+						// no file was given return directory path
175
+						return $path;
176
+					}
177
+				}
178
+			}
179
+		}
180
+		return false;
181
+	}
182 182
 }
Please login to merge, or discard this patch.
Spacing   +15 added lines, -17 removed lines patch added patch discarded remove patch
@@ -121,52 +121,50 @@
 block discarded – undo
121 121
     public function getIncludePath($dirs, $file, Smarty $smarty)
122 122
     {
123 123
         //if (!(isset($this->_has_stream_include) ? $this->_has_stream_include : $this->_has_stream_include = false)) {
124
-        if (!(isset($this->_has_stream_include) ? $this->_has_stream_include :
125
-            $this->_has_stream_include = function_exists('stream_resolve_include_path'))
124
+        if (!(isset($this->_has_stream_include) ? $this->_has_stream_include : $this->_has_stream_include = function_exists('stream_resolve_include_path'))
126 125
         ) {
127 126
             $this->isNewIncludePath($smarty);
128 127
         }
129 128
         // try PHP include_path
130 129
         foreach ($dirs as $dir) {
131
-            $dir_n = isset($this->number[ $dir ]) ? $this->number[ $dir ] : $this->number[ $dir ] = $this->counter ++;
132
-            if (isset($this->isFile[ $dir_n ][ $file ])) {
133
-                if ($this->isFile[ $dir_n ][ $file ]) {
134
-                    return $this->isFile[ $dir_n ][ $file ];
130
+            $dir_n = isset($this->number[$dir]) ? $this->number[$dir] : $this->number[$dir] = $this->counter++;
131
+            if (isset($this->isFile[$dir_n][$file])) {
132
+                if ($this->isFile[$dir_n][$file]) {
133
+                    return $this->isFile[$dir_n][$file];
135 134
                 } else {
136 135
                     continue;
137 136
                 }
138 137
             }
139
-            if (isset($this->_user_dirs[ $dir_n ])) {
140
-                if (false === $this->_user_dirs[ $dir_n ]) {
138
+            if (isset($this->_user_dirs[$dir_n])) {
139
+                if (false === $this->_user_dirs[$dir_n]) {
141 140
                     continue;
142 141
                 } else {
143
-                    $dir = $this->_user_dirs[ $dir_n ];
142
+                    $dir = $this->_user_dirs[$dir_n];
144 143
                 }
145 144
             } else {
146
-                if ($dir[ 0 ] == '/' || $dir[ 1 ] == ':') {
145
+                if ($dir[0] == '/' || $dir[1] == ':') {
147 146
                     $dir = str_ireplace(getcwd(), '.', $dir);
148
-                    if ($dir[ 0 ] == '/' || $dir[ 1 ] == ':') {
149
-                        $this->_user_dirs[ $dir_n ] = false;
147
+                    if ($dir[0] == '/' || $dir[1] == ':') {
148
+                        $this->_user_dirs[$dir_n] = false;
150 149
                         continue;
151 150
                     }
152 151
                 }
153 152
                 $dir = substr($dir, 2);
154
-                $this->_user_dirs[ $dir_n ] = $dir;
153
+                $this->_user_dirs[$dir_n] = $dir;
155 154
             }
156 155
             if ($this->_has_stream_include) {
157 156
                 $path = stream_resolve_include_path($dir . (isset($file) ? $file : ''));
158 157
                 if ($path) {
159
-                    return $this->isFile[ $dir_n ][ $file ] = $path;
158
+                    return $this->isFile[$dir_n][$file] = $path;
160 159
                 }
161 160
             } else {
162 161
                 foreach ($this->_include_dirs as $key => $_i_path) {
163
-                    $path = isset($this->isPath[ $key ][ $dir_n ]) ? $this->isPath[ $key ][ $dir_n ] :
164
-                        $this->isPath[ $key ][ $dir_n ] = is_dir($_dir_path = $_i_path . $dir) ? $_dir_path : false;
162
+                    $path = isset($this->isPath[$key][$dir_n]) ? $this->isPath[$key][$dir_n] : $this->isPath[$key][$dir_n] = is_dir($_dir_path = $_i_path . $dir) ? $_dir_path : false;
165 163
                     if ($path === false) {
166 164
                         continue;
167 165
                     }
168 166
                     if (isset($file)) {
169
-                        $_file = $this->isFile[ $dir_n ][ $file ] = (is_file($path . $file)) ? $path . $file : false;
167
+                        $_file = $this->isFile[$dir_n][$file] = (is_file($path . $file)) ? $path . $file : false;
170 168
                         if ($_file) {
171 169
                             return $_file;
172 170
                         }
Please login to merge, or discard this patch.
libraries/Smarty/libs/sysplugins/smarty_internal_templatecompilerbase.php 3 patches
Indentation   +1268 added lines, -1268 removed lines patch added patch discarded remove patch
@@ -23,1273 +23,1273 @@
 block discarded – undo
23 23
 abstract class Smarty_Internal_TemplateCompilerBase
24 24
 {
25 25
 
26
-    /**
27
-     * Smarty object
28
-     *
29
-     * @var Smarty
30
-     */
31
-    public $smarty = null;
32
-
33
-    /**
34
-     * Parser object
35
-     *
36
-     * @var Smarty_Internal_Templateparser
37
-     */
38
-    public $parser = null;
39
-
40
-    /**
41
-     * hash for nocache sections
42
-     *
43
-     * @var mixed
44
-     */
45
-    public $nocache_hash = null;
46
-
47
-    /**
48
-     * suppress generation of nocache code
49
-     *
50
-     * @var bool
51
-     */
52
-    public $suppressNocacheProcessing = false;
53
-
54
-    /**
55
-     * compile tag objects cache
56
-     *
57
-     * @var array
58
-     */
59
-    static $_tag_objects = array();
60
-
61
-    /**
62
-     * tag stack
63
-     *
64
-     * @var array
65
-     */
66
-    public $_tag_stack = array();
67
-
68
-    /**
69
-     * current template
70
-     *
71
-     * @var Smarty_Internal_Template
72
-     */
73
-    public $template = null;
74
-
75
-    /**
76
-     * merged included sub template data
77
-     *
78
-     * @var array
79
-     */
80
-    public $mergedSubTemplatesData = array();
81
-
82
-    /**
83
-     * merged sub template code
84
-     *
85
-     * @var array
86
-     */
87
-    public $mergedSubTemplatesCode = array();
88
-
89
-    /**
90
-     * collected template properties during compilation
91
-     *
92
-     * @var array
93
-     */
94
-    public $templateProperties = array();
95
-
96
-    /**
97
-     * source line offset for error messages
98
-     *
99
-     * @var int
100
-     */
101
-    public $trace_line_offset = 0;
102
-
103
-    /**
104
-     * trace uid
105
-     *
106
-     * @var string
107
-     */
108
-    public $trace_uid = '';
109
-
110
-    /**
111
-     * trace file path
112
-     *
113
-     * @var string
114
-     */
115
-    public $trace_filepath = '';
116
-
117
-    /**
118
-     * stack for tracing file and line of nested {block} tags
119
-     *
120
-     * @var array
121
-     */
122
-    public $trace_stack = array();
123
-
124
-    /**
125
-     * plugins loaded by default plugin handler
126
-     *
127
-     * @var array
128
-     */
129
-    public $default_handler_plugins = array();
130
-
131
-    /**
132
-     * saved preprocessed modifier list
133
-     *
134
-     * @var mixed
135
-     */
136
-    public $default_modifier_list = null;
137
-
138
-    /**
139
-     * force compilation of complete template as nocache
140
-     *
141
-     * @var boolean
142
-     */
143
-    public $forceNocache = false;
144
-
145
-    /**
146
-     * flag if compiled template file shall we written
147
-     *
148
-     * @var bool
149
-     */
150
-    public $write_compiled_code = true;
151
-
152
-    /**
153
-     * Template functions
154
-     *
155
-     * @var array
156
-     */
157
-    public $tpl_function = array();
158
-
159
-    /**
160
-     * called sub functions from template function
161
-     *
162
-     * @var array
163
-     */
164
-    public $called_functions = array();
165
-
166
-    /**
167
-     * compiled template or block function code
168
-     *
169
-     * @var string
170
-     */
171
-    public $blockOrFunctionCode = '';
172
-
173
-    /**
174
-     * php_handling setting either from Smarty or security
175
-     *
176
-     * @var int
177
-     */
178
-    public $php_handling = 0;
179
-
180
-    /**
181
-     * flags for used modifier plugins
182
-     *
183
-     * @var array
184
-     */
185
-    public $modifier_plugins = array();
186
-
187
-    /**
188
-     * type of already compiled modifier
189
-     *
190
-     * @var array
191
-     */
192
-    public $known_modifier_type = array();
193
-
194
-    /**
195
-     * parent compiler object for merged subtemplates and template functions
196
-     *
197
-     * @var Smarty_Internal_TemplateCompilerBase
198
-     */
199
-    public $parent_compiler = null;
200
-
201
-    /**
202
-     * Flag true when compiling nocache section
203
-     *
204
-     * @var bool
205
-     */
206
-    public $nocache = false;
207
-
208
-    /**
209
-     * Flag true when tag is compiled as nocache
210
-     *
211
-     * @var bool
212
-     */
213
-    public $tag_nocache = false;
214
-
215
-    /**
216
-     * Compiled tag prefix code
217
-     *
218
-     * @var array
219
-     */
220
-    public $prefix_code = array();
221
-
222
-    /**
223
-     * Prefix code  stack
224
-     *
225
-     * @var array
226
-     */
227
-    public $prefixCodeStack = array();
228
-
229
-    /**
230
-     * Tag has compiled code
231
-     *
232
-     * @var bool
233
-     */
234
-    public $has_code = false;
235
-
236
-    /**
237
-     * A variable string was compiled
238
-     *
239
-     * @var bool
240
-     */
241
-    public $has_variable_string = false;
242
-
243
-    /**
244
-     * Tag creates output
245
-     *
246
-     * @var bool
247
-     */
248
-    public $has_output = false;
249
-
250
-    /**
251
-     * Stack for {setfilter} {/setfilter}
252
-     *
253
-     * @var array
254
-     */
255
-    public $variable_filter_stack = array();
256
-
257
-    /**
258
-     * variable filters for {setfilter} {/setfilter}
259
-     *
260
-     * @var array
261
-     */
262
-    public $variable_filters = array();
263
-
264
-    /**
265
-     * Nesting count of looping tags like {foreach}, {for}, {section}, {while}
266
-     *
267
-     * @var int
268
-     */
269
-    public $loopNesting = 0;
270
-
271
-    /**
272
-     * Strip preg pattern
273
-     *
274
-     * @var string
275
-     */
276
-    public $stripRegEx = '![\t ]*[\r\n]+[\t ]*!';
277
-
278
-    /**
279
-     * plugin search order
280
-     *
281
-     * @var array
282
-     */
283
-    public $plugin_search_order = array('function', 'block', 'compiler', 'class');
284
-
285
-    /**
286
-     * General storage area for tag compiler plugins
287
-     *
288
-     * @var array
289
-     */
290
-    public $_cache = array();
291
-
292
-    /**
293
-     * counter for prefix variable number
294
-     *
295
-     * @var int
296
-     */
297
-    public static $prefixVariableNumber = 0;
298
-
299
-    /**
300
-     * method to compile a Smarty template
301
-     *
302
-     * @param mixed $_content template source
303
-     * @param bool  $isTemplateSource
304
-     *
305
-     * @return bool true if compiling succeeded, false if it failed
306
-     */
307
-    abstract protected function doCompile($_content, $isTemplateSource = false);
308
-
309
-    /**
310
-     * Initialize compiler
311
-     *
312
-     * @param Smarty $smarty global instance
313
-     */
314
-    public function __construct(Smarty $smarty)
315
-    {
316
-        $this->smarty = $smarty;
317
-        $this->nocache_hash = str_replace(array('.', ','), '_', uniqid(rand(), true));
318
-    }
319
-
320
-    /**
321
-     * Method to compile a Smarty template
322
-     *
323
-     * @param  Smarty_Internal_Template                 $template template object to compile
324
-     * @param  bool                                     $nocache  true is shall be compiled in nocache mode
325
-     * @param null|Smarty_Internal_TemplateCompilerBase $parent_compiler
326
-     *
327
-     * @return bool true if compiling succeeded, false if it failed
328
-     * @throws \Exception
329
-     */
330
-    public function compileTemplate(Smarty_Internal_Template $template, $nocache = null,
331
-                                    Smarty_Internal_TemplateCompilerBase $parent_compiler = null)
332
-    {
333
-        // get code frame of compiled template
334
-        $_compiled_code = $template->smarty->ext->_codeFrame->create($template,
335
-                                                                     $this->compileTemplateSource($template, $nocache,
336
-                                                                                                  $parent_compiler),
337
-                                                                     $this->postFilter($this->blockOrFunctionCode) .
338
-                                                                     join('', $this->mergedSubTemplatesCode), false,
339
-                                                                     $this);
340
-        return $_compiled_code;
341
-    }
342
-
343
-    /**
344
-     * Compile template source and run optional post filter
345
-     *
346
-     * @param \Smarty_Internal_Template             $template
347
-     * @param null|bool                             $nocache flag if template must be compiled in nocache mode
348
-     * @param \Smarty_Internal_TemplateCompilerBase $parent_compiler
349
-     *
350
-     * @return string
351
-     * @throws \Exception
352
-     */
353
-    public function compileTemplateSource(Smarty_Internal_Template $template, $nocache = null,
354
-                                          Smarty_Internal_TemplateCompilerBase $parent_compiler = null)
355
-    {
356
-        try {
357
-            // save template object in compiler class
358
-            $this->template = $template;
359
-            if (property_exists($this->template->smarty, 'plugin_search_order')) {
360
-                $this->plugin_search_order = $this->template->smarty->plugin_search_order;
361
-            }
362
-            if ($this->smarty->debugging) {
363
-                if (!isset($this->smarty->_debug)) {
364
-                    $this->smarty->_debug = new Smarty_Internal_Debug();
365
-                }
366
-                $this->smarty->_debug->start_compile($this->template);
367
-            }
368
-            if (isset($this->template->smarty->security_policy)) {
369
-                $this->php_handling = $this->template->smarty->security_policy->php_handling;
370
-            } else {
371
-                $this->php_handling = $this->template->smarty->php_handling;
372
-            }
373
-            $this->parent_compiler = $parent_compiler ? $parent_compiler : $this;
374
-            $nocache = isset($nocache) ? $nocache : false;
375
-            if (empty($template->compiled->nocache_hash)) {
376
-                $template->compiled->nocache_hash = $this->nocache_hash;
377
-            } else {
378
-                $this->nocache_hash = $template->compiled->nocache_hash;
379
-            }
380
-            // flag for nocache sections
381
-            $this->nocache = $nocache;
382
-            $this->tag_nocache = false;
383
-            // reset has nocache code flag
384
-            $this->template->compiled->has_nocache_code = false;
385
-            $this->has_variable_string = false;
386
-            $this->prefix_code = array();
387
-            // add file dependency
388
-            if ($this->smarty->merge_compiled_includes || $this->template->source->handler->checkTimestamps()) {
389
-                $this->parent_compiler->template->compiled->file_dependency[ $this->template->source->uid ] =
390
-                    array($this->template->source->filepath, $this->template->source->getTimeStamp(),
391
-                          $this->template->source->type,);
392
-            }
393
-            $this->smarty->_current_file = $this->template->source->filepath;
394
-            // get template source
395
-            if (!empty($this->template->source->components)) {
396
-                // we have array of inheritance templates by extends: resource
397
-                // generate corresponding source code sequence
398
-                $_content =
399
-                    Smarty_Internal_Compile_Extends::extendsSourceArrayCode($this->template->source->components);
400
-            } else {
401
-                // get template source
402
-                $_content = $this->template->source->getContent();
403
-            }
404
-            $_compiled_code = $this->postFilter($this->doCompile($this->preFilter($_content), true));
405
-        }
406
-        catch (Exception $e) {
407
-            if ($this->smarty->debugging) {
408
-                $this->smarty->_debug->end_compile($this->template);
409
-            }
410
-            $this->_tag_stack = array();
411
-            // free memory
412
-            $this->parent_compiler = null;
413
-            $this->template = null;
414
-            $this->parser = null;
415
-            throw $e;
416
-        }
417
-        if ($this->smarty->debugging) {
418
-            $this->smarty->_debug->end_compile($this->template);
419
-        }
420
-        $this->parent_compiler = null;
421
-        $this->parser = null;
422
-        return $_compiled_code;
423
-    }
424
-
425
-    /**
426
-     * Optionally process compiled code by post filter
427
-     *
428
-     * @param string $code compiled code
429
-     *
430
-     * @return string
431
-     * @throws \SmartyException
432
-     */
433
-    public function postFilter($code)
434
-    {
435
-        // run post filter if on code
436
-        if (!empty($code) &&
437
-            (isset($this->smarty->autoload_filters[ 'post' ]) || isset($this->smarty->registered_filters[ 'post' ]))
438
-        ) {
439
-            return $this->smarty->ext->_filterHandler->runFilter('post', $code, $this->template);
440
-        } else {
441
-            return $code;
442
-        }
443
-    }
444
-
445
-    /**
446
-     * Run optional prefilter
447
-     *
448
-     * @param string $_content template source
449
-     *
450
-     * @return string
451
-     * @throws \SmartyException
452
-     */
453
-    public function preFilter($_content)
454
-    {
455
-        // run pre filter if required
456
-        if ($_content != '' &&
457
-            ((isset($this->smarty->autoload_filters[ 'pre' ]) || isset($this->smarty->registered_filters[ 'pre' ])))
458
-        ) {
459
-            return $this->smarty->ext->_filterHandler->runFilter('pre', $_content, $this->template);
460
-        } else {
461
-            return $_content;
462
-        }
463
-    }
464
-
465
-    /**
466
-     * Compile Tag
467
-     * This is a call back from the lexer/parser
468
-     *
469
-     * Save current prefix code
470
-     * Compile tag
471
-     * Merge tag prefix code with saved one
472
-     * (required nested tags in attributes)
473
-     *
474
-     * @param  string $tag       tag name
475
-     * @param  array  $args      array with tag attributes
476
-     * @param  array  $parameter array with compilation parameter
477
-     *
478
-     * @throws SmartyCompilerException
479
-     * @throws SmartyException
480
-     * @return string compiled code
481
-     */
482
-    public function compileTag($tag, $args, $parameter = array())
483
-    {
484
-        $this->prefixCodeStack[] = $this->prefix_code;
485
-        $this->prefix_code = array();
486
-        $result = $this->compileTag2($tag, $args, $parameter);
487
-        $this->prefix_code = array_merge($this->prefix_code, array_pop($this->prefixCodeStack));
488
-        return $result;
489
-    }
490
-
491
-    /**
492
-     * Compile Tag
493
-     *
494
-     * @param  string $tag       tag name
495
-     * @param  array  $args      array with tag attributes
496
-     * @param  array  $parameter array with compilation parameter
497
-     *
498
-     * @throws SmartyCompilerException
499
-     * @throws SmartyException
500
-     * @return string compiled code
501
-     */
502
-    private function compileTag2($tag, $args, $parameter)
503
-    {
504
-        $plugin_type = '';
505
-        // $args contains the attributes parsed and compiled by the lexer/parser
506
-        // assume that tag does compile into code, but creates no HTML output
507
-        $this->has_code = true;
508
-        $this->has_output = false;
509
-        // log tag/attributes
510
-        if (isset($this->smarty->_cache[ 'get_used_tags' ])) {
511
-            $this->template->_cache[ 'used_tags' ][] = array($tag, $args);
512
-        }
513
-        // check nocache option flag
514
-        foreach ($args as $arg) {
515
-            if (!is_array($arg)) {
516
-                if ($arg == "'nocache'") {
517
-                    $this->tag_nocache = true;
518
-                }
519
-            } else {
520
-                foreach ($arg as $k => $v) {
521
-                    if ($k == "'nocache'" && (trim($v, "'\" ") == 'true')) {
522
-                        $this->tag_nocache = true;
523
-                    }
524
-                }
525
-            }
526
-        }
527
-        // compile the smarty tag (required compile classes to compile the tag are auto loaded)
528
-        if (($_output = $this->callTagCompiler($tag, $args, $parameter)) === false) {
529
-            if (isset($this->parent_compiler->tpl_function[ $tag ])) {
530
-                // template defined by {template} tag
531
-                $args[ '_attr' ][ 'name' ] = "'" . $tag . "'";
532
-                $_output = $this->callTagCompiler('call', $args, $parameter);
533
-            }
534
-        }
535
-        if ($_output !== false) {
536
-            if ($_output !== true) {
537
-                // did we get compiled code
538
-                if ($this->has_code) {
539
-                    // Does it create output?
540
-                    if ($this->has_output) {
541
-                        $_output .= "\n";
542
-                    }
543
-                    // return compiled code
544
-                    return $_output;
545
-                }
546
-            }
547
-            // tag did not produce compiled code
548
-            return null;
549
-        } else {
550
-            // map_named attributes
551
-            if (isset($args[ '_attr' ])) {
552
-                foreach ($args[ '_attr' ] as $key => $attribute) {
553
-                    if (is_array($attribute)) {
554
-                        $args = array_merge($args, $attribute);
555
-                    }
556
-                }
557
-            }
558
-            // not an internal compiler tag
559
-            if (strlen($tag) < 6 || substr($tag, - 5) != 'close') {
560
-                // check if tag is a registered object
561
-                if (isset($this->smarty->registered_objects[ $tag ]) && isset($parameter[ 'object_method' ])) {
562
-                    $method = $parameter[ 'object_method' ];
563
-                    if (!in_array($method, $this->smarty->registered_objects[ $tag ][ 3 ]) &&
564
-                        (empty($this->smarty->registered_objects[ $tag ][ 1 ]) ||
565
-                         in_array($method, $this->smarty->registered_objects[ $tag ][ 1 ]))
566
-                    ) {
567
-                        return $this->callTagCompiler('private_object_function', $args, $parameter, $tag, $method);
568
-                    } elseif (in_array($method, $this->smarty->registered_objects[ $tag ][ 3 ])) {
569
-                        return $this->callTagCompiler('private_object_block_function', $args, $parameter, $tag,
570
-                                                      $method);
571
-                    } else {
572
-                        // throw exception
573
-                        $this->trigger_template_error('not allowed method "' . $method . '" in registered object "' .
574
-                                                      $tag . '"', null, true);
575
-                    }
576
-                }
577
-                // check if tag is registered
578
-                foreach (array(Smarty::PLUGIN_COMPILER, Smarty::PLUGIN_FUNCTION, Smarty::PLUGIN_BLOCK,) as $plugin_type)
579
-                {
580
-                    if (isset($this->smarty->registered_plugins[ $plugin_type ][ $tag ])) {
581
-                        // if compiler function plugin call it now
582
-                        if ($plugin_type == Smarty::PLUGIN_COMPILER) {
583
-                            $new_args = array();
584
-                            foreach ($args as $key => $mixed) {
585
-                                if (is_array($mixed)) {
586
-                                    $new_args = array_merge($new_args, $mixed);
587
-                                } else {
588
-                                    $new_args[ $key ] = $mixed;
589
-                                }
590
-                            }
591
-                            if (!$this->smarty->registered_plugins[ $plugin_type ][ $tag ][ 1 ]) {
592
-                                $this->tag_nocache = true;
593
-                            }
594
-                            return call_user_func_array($this->smarty->registered_plugins[ $plugin_type ][ $tag ][ 0 ],
595
-                                                        array($new_args, $this));
596
-                        }
597
-                        // compile registered function or block function
598
-                        if ($plugin_type == Smarty::PLUGIN_FUNCTION || $plugin_type == Smarty::PLUGIN_BLOCK) {
599
-                            return $this->callTagCompiler('private_registered_' . $plugin_type, $args, $parameter,
600
-                                                          $tag);
601
-                        }
602
-                    }
603
-                }
604
-                // check plugins from plugins folder
605
-                foreach ($this->plugin_search_order as $plugin_type) {
606
-                    if ($plugin_type == Smarty::PLUGIN_COMPILER &&
607
-                        $this->smarty->loadPlugin('smarty_compiler_' . $tag) &&
608
-                        (!isset($this->smarty->security_policy) ||
609
-                         $this->smarty->security_policy->isTrustedTag($tag, $this))
610
-                    ) {
611
-                        $plugin = 'smarty_compiler_' . $tag;
612
-                        if (is_callable($plugin)) {
613
-                            // convert arguments format for old compiler plugins
614
-                            $new_args = array();
615
-                            foreach ($args as $key => $mixed) {
616
-                                if (is_array($mixed)) {
617
-                                    $new_args = array_merge($new_args, $mixed);
618
-                                } else {
619
-                                    $new_args[ $key ] = $mixed;
620
-                                }
621
-                            }
622
-
623
-                            return $plugin($new_args, $this->smarty);
624
-                        }
625
-                        if (class_exists($plugin, false)) {
626
-                            $plugin_object = new $plugin;
627
-                            if (method_exists($plugin_object, 'compile')) {
628
-                                return $plugin_object->compile($args, $this);
629
-                            }
630
-                        }
631
-                        throw new SmartyException("Plugin \"{$tag}\" not callable");
632
-                    } else {
633
-                        if ($function = $this->getPlugin($tag, $plugin_type)) {
634
-                            if (!isset($this->smarty->security_policy) ||
635
-                                $this->smarty->security_policy->isTrustedTag($tag, $this)
636
-                            ) {
637
-                                return $this->callTagCompiler('private_' . $plugin_type . '_plugin', $args, $parameter,
638
-                                                              $tag, $function);
639
-                            }
640
-                        }
641
-                    }
642
-                }
643
-                if (is_callable($this->smarty->default_plugin_handler_func)) {
644
-                    $found = false;
645
-                    // look for already resolved tags
646
-                    foreach ($this->plugin_search_order as $plugin_type) {
647
-                        if (isset($this->default_handler_plugins[ $plugin_type ][ $tag ])) {
648
-                            $found = true;
649
-                            break;
650
-                        }
651
-                    }
652
-                    if (!$found) {
653
-                        // call default handler
654
-                        foreach ($this->plugin_search_order as $plugin_type) {
655
-                            if ($this->getPluginFromDefaultHandler($tag, $plugin_type)) {
656
-                                $found = true;
657
-                                break;
658
-                            }
659
-                        }
660
-                    }
661
-                    if ($found) {
662
-                        // if compiler function plugin call it now
663
-                        if ($plugin_type == Smarty::PLUGIN_COMPILER) {
664
-                            $new_args = array();
665
-                            foreach ($args as $mixed) {
666
-                                $new_args = array_merge($new_args, $mixed);
667
-                            }
668
-                            return call_user_func_array($this->default_handler_plugins[ $plugin_type ][ $tag ][ 0 ],
669
-                                                        array($new_args, $this));
670
-                        } else {
671
-                            return $this->callTagCompiler('private_registered_' . $plugin_type, $args, $parameter,
672
-                                                          $tag);
673
-                        }
674
-                    }
675
-                }
676
-            } else {
677
-                // compile closing tag of block function
678
-                $base_tag = substr($tag, 0, - 5);
679
-                // check if closing tag is a registered object
680
-                if (isset($this->smarty->registered_objects[ $base_tag ]) && isset($parameter[ 'object_method' ])) {
681
-                    $method = $parameter[ 'object_method' ];
682
-                    if (in_array($method, $this->smarty->registered_objects[ $base_tag ][ 3 ])) {
683
-                        return $this->callTagCompiler('private_object_block_function', $args, $parameter, $tag,
684
-                                                      $method);
685
-                    } else {
686
-                        // throw exception
687
-                        $this->trigger_template_error('not allowed closing tag method "' . $method .
688
-                                                      '" in registered object "' . $base_tag . '"', null, true);
689
-                    }
690
-                }
691
-                // registered block tag ?
692
-                if (isset($this->smarty->registered_plugins[ Smarty::PLUGIN_BLOCK ][ $base_tag ]) ||
693
-                    isset($this->default_handler_plugins[ Smarty::PLUGIN_BLOCK ][ $base_tag ])
694
-                ) {
695
-                    return $this->callTagCompiler('private_registered_block', $args, $parameter, $tag);
696
-                }
697
-                // registered function tag ?
698
-                if (isset($this->smarty->registered_plugins[ Smarty::PLUGIN_FUNCTION ][ $tag ])) {
699
-                    return $this->callTagCompiler('private_registered_function', $args, $parameter, $tag);
700
-                }
701
-                // block plugin?
702
-                if ($function = $this->getPlugin($base_tag, Smarty::PLUGIN_BLOCK)) {
703
-                    return $this->callTagCompiler('private_block_plugin', $args, $parameter, $tag, $function);
704
-                }
705
-                // function plugin?
706
-                if ($function = $this->getPlugin($tag, Smarty::PLUGIN_FUNCTION)) {
707
-                    if (!isset($this->smarty->security_policy) ||
708
-                        $this->smarty->security_policy->isTrustedTag($tag, $this)
709
-                    ) {
710
-                        return $this->callTagCompiler('private_function_plugin', $args, $parameter, $tag, $function);
711
-                    }
712
-                }
713
-                // registered compiler plugin ?
714
-                if (isset($this->smarty->registered_plugins[ Smarty::PLUGIN_COMPILER ][ $tag ])) {
715
-                    // if compiler function plugin call it now
716
-                    $args = array();
717
-                    if (!$this->smarty->registered_plugins[ Smarty::PLUGIN_COMPILER ][ $tag ][ 1 ]) {
718
-                        $this->tag_nocache = true;
719
-                    }
720
-                    return call_user_func_array($this->smarty->registered_plugins[ Smarty::PLUGIN_COMPILER ][ $tag ][ 0 ],
721
-                                                array($args, $this));
722
-                }
723
-                if ($this->smarty->loadPlugin('smarty_compiler_' . $tag)) {
724
-                    $plugin = 'smarty_compiler_' . $tag;
725
-                    if (is_callable($plugin)) {
726
-                        return $plugin($args, $this->smarty);
727
-                    }
728
-                    if (class_exists($plugin, false)) {
729
-                        $plugin_object = new $plugin;
730
-                        if (method_exists($plugin_object, 'compile')) {
731
-                            return $plugin_object->compile($args, $this);
732
-                        }
733
-                    }
734
-                    throw new SmartyException("Plugin \"{$tag}\" not callable");
735
-                }
736
-            }
737
-            $this->trigger_template_error("unknown tag \"" . $tag . "\"", null, true);
738
-        }
739
-    }
740
-
741
-    /**
742
-     * compile variable
743
-     *
744
-     * @param string $variable
745
-     *
746
-     * @return string
747
-     */
748
-    public function compileVariable($variable)
749
-    {
750
-        if (strpos($variable, '(') == 0) {
751
-            // not a variable variable
752
-            $var = trim($variable, '\'');
753
-            $this->tag_nocache = $this->tag_nocache |
754
-                                 $this->template->ext->getTemplateVars->_getVariable($this->template, $var, null, true,
755
-                                                                                     false)->nocache;
756
-            // todo $this->template->compiled->properties['variables'][$var] = $this->tag_nocache | $this->nocache;
757
-        }
758
-        return '$_smarty_tpl->tpl_vars[' . $variable . ']->value';
759
-    }
760
-
761
-    /**
762
-     * compile config variable
763
-     *
764
-     * @param string $variable
765
-     *
766
-     * @return string
767
-     */
768
-    public function compileConfigVariable($variable)
769
-    {
770
-        // return '$_smarty_tpl->config_vars[' . $variable . ']';
771
-        return '$_smarty_tpl->smarty->ext->configLoad->_getConfigVariable($_smarty_tpl, ' . $variable . ')';
772
-    }
773
-
774
-    /**
775
-     * This method is called from parser to process a text content section
776
-     * - remove text from inheritance child templates as they may generate output
777
-     * - strip text if strip is enabled
778
-     *
779
-     * @param string $text
780
-     *
781
-     * @return null|\Smarty_Internal_ParseTree_Text
782
-     */
783
-    public function processText($text)
784
-    {
785
-        if ((string) $text != '') {
786
-            $store = array();
787
-            $_store = 0;
788
-            if ($this->parser->strip) {
789
-                if (strpos($text, '<') !== false) {
790
-                    // capture html elements not to be messed with
791
-                    $_offset = 0;
792
-                    if (preg_match_all('#(<script[^>]*>.*?</script[^>]*>)|(<textarea[^>]*>.*?</textarea[^>]*>)|(<pre[^>]*>.*?</pre[^>]*>)#is',
793
-                                       $text, $matches, PREG_OFFSET_CAPTURE | PREG_SET_ORDER)) {
794
-                        foreach ($matches as $match) {
795
-                            $store[] = $match[ 0 ][ 0 ];
796
-                            $_length = strlen($match[ 0 ][ 0 ]);
797
-                            $replace = '@!@SMARTY:' . $_store . ':SMARTY@!@';
798
-                            $text = substr_replace($text, $replace, $match[ 0 ][ 1 ] - $_offset, $_length);
799
-
800
-                            $_offset += $_length - strlen($replace);
801
-                            $_store ++;
802
-                        }
803
-                    }
804
-                    $expressions = array(// replace multiple spaces between tags by a single space
805
-                                         '#(:SMARTY@!@|>)[\040\011]+(?=@!@SMARTY:|<)#s' => '\1 \2',
806
-                                         // remove newline between tags
807
-                                         '#(:SMARTY@!@|>)[\040\011]*[\n]\s*(?=@!@SMARTY:|<)#s' => '\1\2',
808
-                                         // remove multiple spaces between attributes (but not in attribute values!)
809
-                                         '#(([a-z0-9]\s*=\s*("[^"]*?")|(\'[^\']*?\'))|<[a-z0-9_]+)\s+([a-z/>])#is' => '\1 \5',
810
-                                         '#>[\040\011]+$#Ss' => '> ', '#>[\040\011]*[\n]\s*$#Ss' => '>',
811
-                                         $this->stripRegEx => '',);
812
-
813
-                    $text = preg_replace(array_keys($expressions), array_values($expressions), $text);
814
-                    $_offset = 0;
815
-                    if (preg_match_all('#@!@SMARTY:([0-9]+):SMARTY@!@#is', $text, $matches,
816
-                                       PREG_OFFSET_CAPTURE | PREG_SET_ORDER)) {
817
-                        foreach ($matches as $match) {
818
-                            $_length = strlen($match[ 0 ][ 0 ]);
819
-                            $replace = $store[ $match[ 1 ][ 0 ] ];
820
-                            $text = substr_replace($text, $replace, $match[ 0 ][ 1 ] + $_offset, $_length);
821
-
822
-                            $_offset += strlen($replace) - $_length;
823
-                            $_store ++;
824
-                        }
825
-                    }
826
-                } else {
827
-                    $text = preg_replace($this->stripRegEx, '', $text);
828
-                }
829
-            }
830
-            return new Smarty_Internal_ParseTree_Text($text);
831
-        }
832
-        return null;
833
-    }
834
-
835
-    /**
836
-     * lazy loads internal compile plugin for tag and calls the compile method
837
-     * compile objects cached for reuse.
838
-     * class name format:  Smarty_Internal_Compile_TagName
839
-     * plugin filename format: Smarty_Internal_TagName.php
840
-     *
841
-     * @param  string $tag    tag name
842
-     * @param  array  $args   list of tag attributes
843
-     * @param  mixed  $param1 optional parameter
844
-     * @param  mixed  $param2 optional parameter
845
-     * @param  mixed  $param3 optional parameter
846
-     *
847
-     * @return string compiled code
848
-     */
849
-    public function callTagCompiler($tag, $args, $param1 = null, $param2 = null, $param3 = null)
850
-    {
851
-        // re-use object if already exists
852
-        if (!isset(self::$_tag_objects[ $tag ])) {
853
-            // lazy load internal compiler plugin
854
-            $_tag = explode('_', $tag);
855
-            $_tag = array_map('ucfirst', $_tag);
856
-            $class_name = 'Smarty_Internal_Compile_' . implode('_', $_tag);
857
-            if (class_exists($class_name) &&
858
-                (!isset($this->smarty->security_policy) || $this->smarty->security_policy->isTrustedTag($tag, $this))
859
-            ) {
860
-                self::$_tag_objects[ $tag ] = new $class_name;
861
-            } else {
862
-                self::$_tag_objects[ $tag ] = false;
863
-                return false;
864
-            }
865
-        }
866
-        // compile this tag
867
-        return self::$_tag_objects[ $tag ] === false ? false :
868
-            self::$_tag_objects[ $tag ]->compile($args, $this, $param1, $param2, $param3);
869
-    }
870
-
871
-    /**
872
-     * Check for plugins and return function name
873
-     *
874
-     * @param         $plugin_name
875
-     * @param  string $plugin_type type of plugin
876
-     *
877
-     * @return string call name of function
878
-     */
879
-    public function getPlugin($plugin_name, $plugin_type)
880
-    {
881
-        $function = null;
882
-        if ($this->template->caching && ($this->nocache || $this->tag_nocache)) {
883
-            if (isset($this->parent_compiler->template->compiled->required_plugins[ 'nocache' ][ $plugin_name ][ $plugin_type ])) {
884
-                $function =
885
-                    $this->parent_compiler->template->compiled->required_plugins[ 'nocache' ][ $plugin_name ][ $plugin_type ][ 'function' ];
886
-            } elseif (isset($this->parent_compiler->template->compiled->required_plugins[ 'compiled' ][ $plugin_name ][ $plugin_type ])) {
887
-                $this->parent_compiler->template->compiled->required_plugins[ 'nocache' ][ $plugin_name ][ $plugin_type ] =
888
-                    $this->parent_compiler->template->compiled->required_plugins[ 'compiled' ][ $plugin_name ][ $plugin_type ];
889
-                $function =
890
-                    $this->parent_compiler->template->compiled->required_plugins[ 'nocache' ][ $plugin_name ][ $plugin_type ][ 'function' ];
891
-            }
892
-        } else {
893
-            if (isset($this->parent_compiler->template->compiled->required_plugins[ 'compiled' ][ $plugin_name ][ $plugin_type ])) {
894
-                $function =
895
-                    $this->parent_compiler->template->compiled->required_plugins[ 'compiled' ][ $plugin_name ][ $plugin_type ][ 'function' ];
896
-            } elseif (isset($this->parent_compiler->template->compiled->required_plugins[ 'nocache' ][ $plugin_name ][ $plugin_type ])) {
897
-                $this->parent_compiler->template->compiled->required_plugins[ 'compiled' ][ $plugin_name ][ $plugin_type ] =
898
-                    $this->parent_compiler->template->compiled->required_plugins[ 'nocache' ][ $plugin_name ][ $plugin_type ];
899
-                $function =
900
-                    $this->parent_compiler->template->compiled->required_plugins[ 'compiled' ][ $plugin_name ][ $plugin_type ][ 'function' ];
901
-            }
902
-        }
903
-        if (isset($function)) {
904
-            if ($plugin_type == 'modifier') {
905
-                $this->modifier_plugins[ $plugin_name ] = true;
906
-            }
907
-
908
-            return $function;
909
-        }
910
-        // loop through plugin dirs and find the plugin
911
-        $function = 'smarty_' . $plugin_type . '_' . $plugin_name;
912
-        $file = $this->smarty->loadPlugin($function, false);
913
-
914
-        if (is_string($file)) {
915
-            if ($this->template->caching && ($this->nocache || $this->tag_nocache)) {
916
-                $this->parent_compiler->template->compiled->required_plugins[ 'nocache' ][ $plugin_name ][ $plugin_type ][ 'file' ] =
917
-                    $file;
918
-                $this->parent_compiler->template->compiled->required_plugins[ 'nocache' ][ $plugin_name ][ $plugin_type ][ 'function' ] =
919
-                    $function;
920
-            } else {
921
-                $this->parent_compiler->template->compiled->required_plugins[ 'compiled' ][ $plugin_name ][ $plugin_type ][ 'file' ] =
922
-                    $file;
923
-                $this->parent_compiler->template->compiled->required_plugins[ 'compiled' ][ $plugin_name ][ $plugin_type ][ 'function' ] =
924
-                    $function;
925
-            }
926
-            if ($plugin_type == 'modifier') {
927
-                $this->modifier_plugins[ $plugin_name ] = true;
928
-            }
929
-
930
-            return $function;
931
-        }
932
-        if (is_callable($function)) {
933
-            // plugin function is defined in the script
934
-            return $function;
935
-        }
936
-
937
-        return false;
938
-    }
939
-
940
-    /**
941
-     * Check for plugins by default plugin handler
942
-     *
943
-     * @param  string $tag         name of tag
944
-     * @param  string $plugin_type type of plugin
945
-     *
946
-     * @return boolean true if found
947
-     */
948
-    public function getPluginFromDefaultHandler($tag, $plugin_type)
949
-    {
950
-        $callback = null;
951
-        $script = null;
952
-        $cacheable = true;
953
-        $result = call_user_func_array($this->smarty->default_plugin_handler_func,
954
-                                       array($tag, $plugin_type, $this->template, &$callback, &$script, &$cacheable,));
955
-        if ($result) {
956
-            $this->tag_nocache = $this->tag_nocache || !$cacheable;
957
-            if ($script !== null) {
958
-                if (is_file($script)) {
959
-                    if ($this->template->caching && ($this->nocache || $this->tag_nocache)) {
960
-                        $this->parent_compiler->template->compiled->required_plugins[ 'nocache' ][ $tag ][ $plugin_type ][ 'file' ] =
961
-                            $script;
962
-                        $this->parent_compiler->template->compiled->required_plugins[ 'nocache' ][ $tag ][ $plugin_type ][ 'function' ] =
963
-                            $callback;
964
-                    } else {
965
-                        $this->parent_compiler->template->compiled->required_plugins[ 'compiled' ][ $tag ][ $plugin_type ][ 'file' ] =
966
-                            $script;
967
-                        $this->parent_compiler->template->compiled->required_plugins[ 'compiled' ][ $tag ][ $plugin_type ][ 'function' ] =
968
-                            $callback;
969
-                    }
970
-                    require_once $script;
971
-                } else {
972
-                    $this->trigger_template_error("Default plugin handler: Returned script file \"{$script}\" for \"{$tag}\" not found");
973
-                }
974
-            }
975
-            if (is_callable($callback)) {
976
-                $this->default_handler_plugins[ $plugin_type ][ $tag ] = array($callback, true, array());
977
-
978
-                return true;
979
-            } else {
980
-                $this->trigger_template_error("Default plugin handler: Returned callback for \"{$tag}\" not callable");
981
-            }
982
-        }
983
-
984
-        return false;
985
-    }
986
-
987
-    /**
988
-     * Append code segments and remove unneeded ?> <?php transitions
989
-     *
990
-     * @param string $left
991
-     * @param string $right
992
-     *
993
-     * @return string
994
-     */
995
-    public function appendCode($left, $right)
996
-    {
997
-        if (preg_match('/\s*\?>\s*$/', $left) && preg_match('/^\s*<\?php\s+/', $right)) {
998
-            $left = preg_replace('/\s*\?>\s*$/', "\n", $left);
999
-            $left .= preg_replace('/^\s*<\?php\s+/', '', $right);
1000
-        } else {
1001
-            $left .= $right;
1002
-        }
1003
-        return $left;
1004
-    }
1005
-
1006
-    /**
1007
-     * Inject inline code for nocache template sections
1008
-     * This method gets the content of each template element from the parser.
1009
-     * If the content is compiled code and it should be not cached the code is injected
1010
-     * into the rendered output.
1011
-     *
1012
-     * @param  string  $content content of template element
1013
-     * @param  boolean $is_code true if content is compiled code
1014
-     *
1015
-     * @return string  content
1016
-     */
1017
-    public function processNocacheCode($content, $is_code)
1018
-    {
1019
-        // If the template is not evaluated and we have a nocache section and or a nocache tag
1020
-        if ($is_code && !empty($content)) {
1021
-            // generate replacement code
1022
-            if ((!($this->template->source->handler->recompiled) || $this->forceNocache) && $this->template->caching &&
1023
-                !$this->suppressNocacheProcessing && ($this->nocache || $this->tag_nocache)
1024
-            ) {
1025
-                $this->template->compiled->has_nocache_code = true;
1026
-                $_output = addcslashes($content, '\'\\');
1027
-                $_output = str_replace("^#^", "'", $_output);
1028
-                $_output = "<?php echo '/*%%SmartyNocache:{$this->nocache_hash}%%*/" . $_output .
1029
-                           "/*/%%SmartyNocache:{$this->nocache_hash}%%*/';?>\n";
1030
-                // make sure we include modifier plugins for nocache code
1031
-                foreach ($this->modifier_plugins as $plugin_name => $dummy) {
1032
-                    if (isset($this->parent_compiler->template->compiled->required_plugins[ 'compiled' ][ $plugin_name ][ 'modifier' ])) {
1033
-                        $this->parent_compiler->template->compiled->required_plugins[ 'nocache' ][ $plugin_name ][ 'modifier' ] =
1034
-                            $this->parent_compiler->template->compiled->required_plugins[ 'compiled' ][ $plugin_name ][ 'modifier' ];
1035
-                    }
1036
-                }
1037
-            } else {
1038
-                $_output = $content;
1039
-            }
1040
-        } else {
1041
-            $_output = $content;
1042
-        }
1043
-        $this->modifier_plugins = array();
1044
-        $this->suppressNocacheProcessing = false;
1045
-        $this->tag_nocache = false;
1046
-
1047
-        return $_output;
1048
-    }
1049
-
1050
-    /**
1051
-     * Get Id
1052
-     *
1053
-     * @param string $input
1054
-     *
1055
-     * @return bool|string
1056
-     */
1057
-    public function getId($input)
1058
-    {
1059
-        if (preg_match('~^([\'"]*)([0-9]*[a-zA-Z_]\w*)\1$~', $input, $match)) {
1060
-            return $match[ 2 ];
1061
-        }
1062
-        return false;
1063
-    }
1064
-
1065
-    /**
1066
-     * Get variable name from string
1067
-     *
1068
-     * @param string $input
1069
-     *
1070
-     * @return bool|string
1071
-     */
1072
-    public function getVariableName($input)
1073
-    {
1074
-        if (preg_match('~^[$]_smarty_tpl->tpl_vars\[[\'"]*([0-9]*[a-zA-Z_]\w*)[\'"]*\]->value$~', $input, $match)) {
1075
-            return $match[ 1 ];
1076
-        }
1077
-        return false;
1078
-    }
1079
-
1080
-    /**
1081
-     * Set nocache flag in variable or create new variable
1082
-     *
1083
-     * @param string $varName
1084
-     */
1085
-    public function setNocacheInVariable($varName)
1086
-    {
1087
-        // create nocache var to make it know for further compiling
1088
-        if ($_var = $this->getId($varName)) {
1089
-            if (isset($this->template->tpl_vars[ $_var ])) {
1090
-                $this->template->tpl_vars[ $_var ] = clone $this->template->tpl_vars[ $_var ];
1091
-                $this->template->tpl_vars[ $_var ]->nocache = true;
1092
-            } else {
1093
-                $this->template->tpl_vars[ $_var ] = new Smarty_Variable(null, true);
1094
-            }
1095
-        }
1096
-    }
1097
-
1098
-    /**
1099
-     * @param array $_attr tag attributes
1100
-     * @param array $validScopes
1101
-     *
1102
-     * @return int|string
1103
-     * @throws \SmartyCompilerException
1104
-     */
1105
-    public function convertScope($_attr, $validScopes)
1106
-    {
1107
-        $_scope = 0;
1108
-        if (isset($_attr[ 'scope' ])) {
1109
-            $_scopeName = trim($_attr[ 'scope' ], "'\"");
1110
-            if (is_numeric($_scopeName) && in_array($_scopeName, $validScopes)) {
1111
-                $_scope = $_scopeName;
1112
-            } elseif (is_string($_scopeName)) {
1113
-                $_scopeName = trim($_scopeName, "'\"");
1114
-                $_scope = isset($validScopes[ $_scopeName ]) ? $validScopes[ $_scopeName ] : false;
1115
-            } else {
1116
-                $_scope = false;
1117
-            }
1118
-            if ($_scope === false) {
1119
-                $err = var_export($_scopeName, true);
1120
-                $this->trigger_template_error("illegal value '{$err}' for \"scope\" attribute", null, true);
1121
-            }
1122
-        }
1123
-        return $_scope;
1124
-    }
1125
-
1126
-    /**
1127
-     * Generate nocache code string
1128
-     *
1129
-     * @param string $code PHP code
1130
-     *
1131
-     * @return string
1132
-     */
1133
-    public function makeNocacheCode($code)
1134
-    {
1135
-        return "echo '/*%%SmartyNocache:{$this->nocache_hash}%%*/<?php " .
1136
-               str_replace("^#^", "'", addcslashes($code, '\'\\')) .
1137
-               "?>/*/%%SmartyNocache:{$this->nocache_hash}%%*/';\n";
1138
-    }
1139
-
1140
-    /**
1141
-     * display compiler error messages without dying
1142
-     * If parameter $args is empty it is a parser detected syntax error.
1143
-     * In this case the parser is called to obtain information about expected tokens.
1144
-     * If parameter $args contains a string this is used as error message
1145
-     *
1146
-     * @param  string   $args    individual error message or null
1147
-     * @param  string   $line    line-number
1148
-     * @param null|bool $tagline if true the line number of last tag
1149
-     *
1150
-     * @throws \SmartyCompilerException when an unexpected token is found
1151
-     */
1152
-    public function trigger_template_error($args = null, $line = null, $tagline = null)
1153
-    {
1154
-        $lex = $this->parser->lex;
1155
-        if ($tagline === true) {
1156
-            // get line number of Tag
1157
-            $line = $lex->taglineno;
1158
-        } elseif (!isset($line)) {
1159
-            // get template source line which has error
1160
-            $line = $lex->line;
1161
-        } else {
1162
-            $line = (int) $line;
1163
-        }
1164
-
1165
-        if (in_array($this->template->source->type, array('eval', 'string'))) {
1166
-            $templateName = $this->template->source->type . ':' . trim(preg_replace('![\t\r\n]+!', ' ',
1167
-                                                                                    strlen($lex->data) > 40 ?
1168
-                                                                                        substr($lex->data, 0, 40) .
1169
-                                                                                        '...' : $lex->data));
1170
-        } else {
1171
-            $templateName = $this->template->source->type . ':' . $this->template->source->filepath;
1172
-        }
1173
-
1174
-        //        $line += $this->trace_line_offset;
1175
-        $match = preg_split("/\n/", $lex->data);
1176
-        $error_text =
1177
-            'Syntax error in template "' . (empty($this->trace_filepath) ? $templateName : $this->trace_filepath) .
1178
-            '"  on line ' . ($line + $this->trace_line_offset) . ' "' .
1179
-            trim(preg_replace('![\t\r\n]+!', ' ', $match[ $line - 1 ])) . '" ';
1180
-        if (isset($args)) {
1181
-            // individual error message
1182
-            $error_text .= $args;
1183
-        } else {
1184
-            $expect = array();
1185
-            // expected token from parser
1186
-            $error_text .= ' - Unexpected "' . $lex->value . '"';
1187
-            if (count($this->parser->yy_get_expected_tokens($this->parser->yymajor)) <= 4) {
1188
-                foreach ($this->parser->yy_get_expected_tokens($this->parser->yymajor) as $token) {
1189
-                    $exp_token = $this->parser->yyTokenName[ $token ];
1190
-                    if (isset($lex->smarty_token_names[ $exp_token ])) {
1191
-                        // token type from lexer
1192
-                        $expect[] = '"' . $lex->smarty_token_names[ $exp_token ] . '"';
1193
-                    } else {
1194
-                        // otherwise internal token name
1195
-                        $expect[] = $this->parser->yyTokenName[ $token ];
1196
-                    }
1197
-                }
1198
-                $error_text .= ', expected one of: ' . implode(' , ', $expect);
1199
-            }
1200
-        }
1201
-        $e = new SmartyCompilerException($error_text);
1202
-        $e->line = $line;
1203
-        $e->source = trim(preg_replace('![\t\r\n]+!', ' ', $match[ $line - 1 ]));
1204
-        $e->desc = $args;
1205
-        $e->template = $this->template->source->filepath;
1206
-        throw $e;
1207
-    }
1208
-
1209
-    /**
1210
-     * Return var_export() value with all white spaces removed
1211
-     *
1212
-     * @param  mixed $value
1213
-     *
1214
-     * @return string
1215
-     */
1216
-    public function getVarExport($value)
1217
-    {
1218
-        return preg_replace('/\s/', '', var_export($value, true));
1219
-    }
1220
-
1221
-    /**
1222
-     * Check if $value contains variable elements
1223
-     *
1224
-     * @param mixed $value
1225
-     *
1226
-     * @return bool|int
1227
-     */
1228
-    public function isVariable($value)
1229
-    {
1230
-        if (is_string($value)) {
1231
-            return preg_match('/[$(]/', $value);
1232
-        }
1233
-        if (is_bool($value) || is_numeric($value)) {
1234
-            return false;
1235
-        }
1236
-        if (is_array($value)) {
1237
-            foreach ($value as $k => $v) {
1238
-                if ($this->isVariable($k) || $this->isVariable($v)) {
1239
-                    return true;
1240
-                }
1241
-            }
1242
-            return false;
1243
-        }
1244
-        return false;
1245
-    }
1246
-
1247
-    /**
1248
-     * Get new prefix variable name
1249
-     *
1250
-     * @return string
1251
-     */
1252
-    public function getNewPrefixVariable()
1253
-    {
1254
-        self::$prefixVariableNumber ++;
1255
-        return $this->getPrefixVariable();
1256
-    }
1257
-
1258
-    /**
1259
-     * Get current prefix variable name
1260
-     *
1261
-     * @return string
1262
-     */
1263
-    public function getPrefixVariable()
1264
-    {
1265
-        return '$_prefixVariable' . self::$prefixVariableNumber;
1266
-    }
1267
-
1268
-    /**
1269
-     * append  code to prefix buffer
1270
-     *
1271
-     * @param string $code
1272
-     */
1273
-    public function appendPrefixCode($code)
1274
-    {
1275
-        $this->prefix_code[] = $code;
1276
-    }
1277
-
1278
-    /**
1279
-     * get prefix code string
1280
-     *
1281
-     * @return string
1282
-     */
1283
-    public function getPrefixCode()
1284
-    {
1285
-        $code = '';
1286
-        $prefixArray = array_merge($this->prefix_code, array_pop($this->prefixCodeStack));
1287
-        $this->prefixCodeStack[] = array();
1288
-        foreach ($prefixArray as $c) {
1289
-            $code = $this->appendCode($code, $c);
1290
-        }
1291
-        $this->prefix_code = array();
1292
-        return $code;
1293
-    }
26
+	/**
27
+	 * Smarty object
28
+	 *
29
+	 * @var Smarty
30
+	 */
31
+	public $smarty = null;
32
+
33
+	/**
34
+	 * Parser object
35
+	 *
36
+	 * @var Smarty_Internal_Templateparser
37
+	 */
38
+	public $parser = null;
39
+
40
+	/**
41
+	 * hash for nocache sections
42
+	 *
43
+	 * @var mixed
44
+	 */
45
+	public $nocache_hash = null;
46
+
47
+	/**
48
+	 * suppress generation of nocache code
49
+	 *
50
+	 * @var bool
51
+	 */
52
+	public $suppressNocacheProcessing = false;
53
+
54
+	/**
55
+	 * compile tag objects cache
56
+	 *
57
+	 * @var array
58
+	 */
59
+	static $_tag_objects = array();
60
+
61
+	/**
62
+	 * tag stack
63
+	 *
64
+	 * @var array
65
+	 */
66
+	public $_tag_stack = array();
67
+
68
+	/**
69
+	 * current template
70
+	 *
71
+	 * @var Smarty_Internal_Template
72
+	 */
73
+	public $template = null;
74
+
75
+	/**
76
+	 * merged included sub template data
77
+	 *
78
+	 * @var array
79
+	 */
80
+	public $mergedSubTemplatesData = array();
81
+
82
+	/**
83
+	 * merged sub template code
84
+	 *
85
+	 * @var array
86
+	 */
87
+	public $mergedSubTemplatesCode = array();
88
+
89
+	/**
90
+	 * collected template properties during compilation
91
+	 *
92
+	 * @var array
93
+	 */
94
+	public $templateProperties = array();
95
+
96
+	/**
97
+	 * source line offset for error messages
98
+	 *
99
+	 * @var int
100
+	 */
101
+	public $trace_line_offset = 0;
102
+
103
+	/**
104
+	 * trace uid
105
+	 *
106
+	 * @var string
107
+	 */
108
+	public $trace_uid = '';
109
+
110
+	/**
111
+	 * trace file path
112
+	 *
113
+	 * @var string
114
+	 */
115
+	public $trace_filepath = '';
116
+
117
+	/**
118
+	 * stack for tracing file and line of nested {block} tags
119
+	 *
120
+	 * @var array
121
+	 */
122
+	public $trace_stack = array();
123
+
124
+	/**
125
+	 * plugins loaded by default plugin handler
126
+	 *
127
+	 * @var array
128
+	 */
129
+	public $default_handler_plugins = array();
130
+
131
+	/**
132
+	 * saved preprocessed modifier list
133
+	 *
134
+	 * @var mixed
135
+	 */
136
+	public $default_modifier_list = null;
137
+
138
+	/**
139
+	 * force compilation of complete template as nocache
140
+	 *
141
+	 * @var boolean
142
+	 */
143
+	public $forceNocache = false;
144
+
145
+	/**
146
+	 * flag if compiled template file shall we written
147
+	 *
148
+	 * @var bool
149
+	 */
150
+	public $write_compiled_code = true;
151
+
152
+	/**
153
+	 * Template functions
154
+	 *
155
+	 * @var array
156
+	 */
157
+	public $tpl_function = array();
158
+
159
+	/**
160
+	 * called sub functions from template function
161
+	 *
162
+	 * @var array
163
+	 */
164
+	public $called_functions = array();
165
+
166
+	/**
167
+	 * compiled template or block function code
168
+	 *
169
+	 * @var string
170
+	 */
171
+	public $blockOrFunctionCode = '';
172
+
173
+	/**
174
+	 * php_handling setting either from Smarty or security
175
+	 *
176
+	 * @var int
177
+	 */
178
+	public $php_handling = 0;
179
+
180
+	/**
181
+	 * flags for used modifier plugins
182
+	 *
183
+	 * @var array
184
+	 */
185
+	public $modifier_plugins = array();
186
+
187
+	/**
188
+	 * type of already compiled modifier
189
+	 *
190
+	 * @var array
191
+	 */
192
+	public $known_modifier_type = array();
193
+
194
+	/**
195
+	 * parent compiler object for merged subtemplates and template functions
196
+	 *
197
+	 * @var Smarty_Internal_TemplateCompilerBase
198
+	 */
199
+	public $parent_compiler = null;
200
+
201
+	/**
202
+	 * Flag true when compiling nocache section
203
+	 *
204
+	 * @var bool
205
+	 */
206
+	public $nocache = false;
207
+
208
+	/**
209
+	 * Flag true when tag is compiled as nocache
210
+	 *
211
+	 * @var bool
212
+	 */
213
+	public $tag_nocache = false;
214
+
215
+	/**
216
+	 * Compiled tag prefix code
217
+	 *
218
+	 * @var array
219
+	 */
220
+	public $prefix_code = array();
221
+
222
+	/**
223
+	 * Prefix code  stack
224
+	 *
225
+	 * @var array
226
+	 */
227
+	public $prefixCodeStack = array();
228
+
229
+	/**
230
+	 * Tag has compiled code
231
+	 *
232
+	 * @var bool
233
+	 */
234
+	public $has_code = false;
235
+
236
+	/**
237
+	 * A variable string was compiled
238
+	 *
239
+	 * @var bool
240
+	 */
241
+	public $has_variable_string = false;
242
+
243
+	/**
244
+	 * Tag creates output
245
+	 *
246
+	 * @var bool
247
+	 */
248
+	public $has_output = false;
249
+
250
+	/**
251
+	 * Stack for {setfilter} {/setfilter}
252
+	 *
253
+	 * @var array
254
+	 */
255
+	public $variable_filter_stack = array();
256
+
257
+	/**
258
+	 * variable filters for {setfilter} {/setfilter}
259
+	 *
260
+	 * @var array
261
+	 */
262
+	public $variable_filters = array();
263
+
264
+	/**
265
+	 * Nesting count of looping tags like {foreach}, {for}, {section}, {while}
266
+	 *
267
+	 * @var int
268
+	 */
269
+	public $loopNesting = 0;
270
+
271
+	/**
272
+	 * Strip preg pattern
273
+	 *
274
+	 * @var string
275
+	 */
276
+	public $stripRegEx = '![\t ]*[\r\n]+[\t ]*!';
277
+
278
+	/**
279
+	 * plugin search order
280
+	 *
281
+	 * @var array
282
+	 */
283
+	public $plugin_search_order = array('function', 'block', 'compiler', 'class');
284
+
285
+	/**
286
+	 * General storage area for tag compiler plugins
287
+	 *
288
+	 * @var array
289
+	 */
290
+	public $_cache = array();
291
+
292
+	/**
293
+	 * counter for prefix variable number
294
+	 *
295
+	 * @var int
296
+	 */
297
+	public static $prefixVariableNumber = 0;
298
+
299
+	/**
300
+	 * method to compile a Smarty template
301
+	 *
302
+	 * @param mixed $_content template source
303
+	 * @param bool  $isTemplateSource
304
+	 *
305
+	 * @return bool true if compiling succeeded, false if it failed
306
+	 */
307
+	abstract protected function doCompile($_content, $isTemplateSource = false);
308
+
309
+	/**
310
+	 * Initialize compiler
311
+	 *
312
+	 * @param Smarty $smarty global instance
313
+	 */
314
+	public function __construct(Smarty $smarty)
315
+	{
316
+		$this->smarty = $smarty;
317
+		$this->nocache_hash = str_replace(array('.', ','), '_', uniqid(rand(), true));
318
+	}
319
+
320
+	/**
321
+	 * Method to compile a Smarty template
322
+	 *
323
+	 * @param  Smarty_Internal_Template                 $template template object to compile
324
+	 * @param  bool                                     $nocache  true is shall be compiled in nocache mode
325
+	 * @param null|Smarty_Internal_TemplateCompilerBase $parent_compiler
326
+	 *
327
+	 * @return bool true if compiling succeeded, false if it failed
328
+	 * @throws \Exception
329
+	 */
330
+	public function compileTemplate(Smarty_Internal_Template $template, $nocache = null,
331
+									Smarty_Internal_TemplateCompilerBase $parent_compiler = null)
332
+	{
333
+		// get code frame of compiled template
334
+		$_compiled_code = $template->smarty->ext->_codeFrame->create($template,
335
+																	 $this->compileTemplateSource($template, $nocache,
336
+																								  $parent_compiler),
337
+																	 $this->postFilter($this->blockOrFunctionCode) .
338
+																	 join('', $this->mergedSubTemplatesCode), false,
339
+																	 $this);
340
+		return $_compiled_code;
341
+	}
342
+
343
+	/**
344
+	 * Compile template source and run optional post filter
345
+	 *
346
+	 * @param \Smarty_Internal_Template             $template
347
+	 * @param null|bool                             $nocache flag if template must be compiled in nocache mode
348
+	 * @param \Smarty_Internal_TemplateCompilerBase $parent_compiler
349
+	 *
350
+	 * @return string
351
+	 * @throws \Exception
352
+	 */
353
+	public function compileTemplateSource(Smarty_Internal_Template $template, $nocache = null,
354
+										  Smarty_Internal_TemplateCompilerBase $parent_compiler = null)
355
+	{
356
+		try {
357
+			// save template object in compiler class
358
+			$this->template = $template;
359
+			if (property_exists($this->template->smarty, 'plugin_search_order')) {
360
+				$this->plugin_search_order = $this->template->smarty->plugin_search_order;
361
+			}
362
+			if ($this->smarty->debugging) {
363
+				if (!isset($this->smarty->_debug)) {
364
+					$this->smarty->_debug = new Smarty_Internal_Debug();
365
+				}
366
+				$this->smarty->_debug->start_compile($this->template);
367
+			}
368
+			if (isset($this->template->smarty->security_policy)) {
369
+				$this->php_handling = $this->template->smarty->security_policy->php_handling;
370
+			} else {
371
+				$this->php_handling = $this->template->smarty->php_handling;
372
+			}
373
+			$this->parent_compiler = $parent_compiler ? $parent_compiler : $this;
374
+			$nocache = isset($nocache) ? $nocache : false;
375
+			if (empty($template->compiled->nocache_hash)) {
376
+				$template->compiled->nocache_hash = $this->nocache_hash;
377
+			} else {
378
+				$this->nocache_hash = $template->compiled->nocache_hash;
379
+			}
380
+			// flag for nocache sections
381
+			$this->nocache = $nocache;
382
+			$this->tag_nocache = false;
383
+			// reset has nocache code flag
384
+			$this->template->compiled->has_nocache_code = false;
385
+			$this->has_variable_string = false;
386
+			$this->prefix_code = array();
387
+			// add file dependency
388
+			if ($this->smarty->merge_compiled_includes || $this->template->source->handler->checkTimestamps()) {
389
+				$this->parent_compiler->template->compiled->file_dependency[ $this->template->source->uid ] =
390
+					array($this->template->source->filepath, $this->template->source->getTimeStamp(),
391
+						  $this->template->source->type,);
392
+			}
393
+			$this->smarty->_current_file = $this->template->source->filepath;
394
+			// get template source
395
+			if (!empty($this->template->source->components)) {
396
+				// we have array of inheritance templates by extends: resource
397
+				// generate corresponding source code sequence
398
+				$_content =
399
+					Smarty_Internal_Compile_Extends::extendsSourceArrayCode($this->template->source->components);
400
+			} else {
401
+				// get template source
402
+				$_content = $this->template->source->getContent();
403
+			}
404
+			$_compiled_code = $this->postFilter($this->doCompile($this->preFilter($_content), true));
405
+		}
406
+		catch (Exception $e) {
407
+			if ($this->smarty->debugging) {
408
+				$this->smarty->_debug->end_compile($this->template);
409
+			}
410
+			$this->_tag_stack = array();
411
+			// free memory
412
+			$this->parent_compiler = null;
413
+			$this->template = null;
414
+			$this->parser = null;
415
+			throw $e;
416
+		}
417
+		if ($this->smarty->debugging) {
418
+			$this->smarty->_debug->end_compile($this->template);
419
+		}
420
+		$this->parent_compiler = null;
421
+		$this->parser = null;
422
+		return $_compiled_code;
423
+	}
424
+
425
+	/**
426
+	 * Optionally process compiled code by post filter
427
+	 *
428
+	 * @param string $code compiled code
429
+	 *
430
+	 * @return string
431
+	 * @throws \SmartyException
432
+	 */
433
+	public function postFilter($code)
434
+	{
435
+		// run post filter if on code
436
+		if (!empty($code) &&
437
+			(isset($this->smarty->autoload_filters[ 'post' ]) || isset($this->smarty->registered_filters[ 'post' ]))
438
+		) {
439
+			return $this->smarty->ext->_filterHandler->runFilter('post', $code, $this->template);
440
+		} else {
441
+			return $code;
442
+		}
443
+	}
444
+
445
+	/**
446
+	 * Run optional prefilter
447
+	 *
448
+	 * @param string $_content template source
449
+	 *
450
+	 * @return string
451
+	 * @throws \SmartyException
452
+	 */
453
+	public function preFilter($_content)
454
+	{
455
+		// run pre filter if required
456
+		if ($_content != '' &&
457
+			((isset($this->smarty->autoload_filters[ 'pre' ]) || isset($this->smarty->registered_filters[ 'pre' ])))
458
+		) {
459
+			return $this->smarty->ext->_filterHandler->runFilter('pre', $_content, $this->template);
460
+		} else {
461
+			return $_content;
462
+		}
463
+	}
464
+
465
+	/**
466
+	 * Compile Tag
467
+	 * This is a call back from the lexer/parser
468
+	 *
469
+	 * Save current prefix code
470
+	 * Compile tag
471
+	 * Merge tag prefix code with saved one
472
+	 * (required nested tags in attributes)
473
+	 *
474
+	 * @param  string $tag       tag name
475
+	 * @param  array  $args      array with tag attributes
476
+	 * @param  array  $parameter array with compilation parameter
477
+	 *
478
+	 * @throws SmartyCompilerException
479
+	 * @throws SmartyException
480
+	 * @return string compiled code
481
+	 */
482
+	public function compileTag($tag, $args, $parameter = array())
483
+	{
484
+		$this->prefixCodeStack[] = $this->prefix_code;
485
+		$this->prefix_code = array();
486
+		$result = $this->compileTag2($tag, $args, $parameter);
487
+		$this->prefix_code = array_merge($this->prefix_code, array_pop($this->prefixCodeStack));
488
+		return $result;
489
+	}
490
+
491
+	/**
492
+	 * Compile Tag
493
+	 *
494
+	 * @param  string $tag       tag name
495
+	 * @param  array  $args      array with tag attributes
496
+	 * @param  array  $parameter array with compilation parameter
497
+	 *
498
+	 * @throws SmartyCompilerException
499
+	 * @throws SmartyException
500
+	 * @return string compiled code
501
+	 */
502
+	private function compileTag2($tag, $args, $parameter)
503
+	{
504
+		$plugin_type = '';
505
+		// $args contains the attributes parsed and compiled by the lexer/parser
506
+		// assume that tag does compile into code, but creates no HTML output
507
+		$this->has_code = true;
508
+		$this->has_output = false;
509
+		// log tag/attributes
510
+		if (isset($this->smarty->_cache[ 'get_used_tags' ])) {
511
+			$this->template->_cache[ 'used_tags' ][] = array($tag, $args);
512
+		}
513
+		// check nocache option flag
514
+		foreach ($args as $arg) {
515
+			if (!is_array($arg)) {
516
+				if ($arg == "'nocache'") {
517
+					$this->tag_nocache = true;
518
+				}
519
+			} else {
520
+				foreach ($arg as $k => $v) {
521
+					if ($k == "'nocache'" && (trim($v, "'\" ") == 'true')) {
522
+						$this->tag_nocache = true;
523
+					}
524
+				}
525
+			}
526
+		}
527
+		// compile the smarty tag (required compile classes to compile the tag are auto loaded)
528
+		if (($_output = $this->callTagCompiler($tag, $args, $parameter)) === false) {
529
+			if (isset($this->parent_compiler->tpl_function[ $tag ])) {
530
+				// template defined by {template} tag
531
+				$args[ '_attr' ][ 'name' ] = "'" . $tag . "'";
532
+				$_output = $this->callTagCompiler('call', $args, $parameter);
533
+			}
534
+		}
535
+		if ($_output !== false) {
536
+			if ($_output !== true) {
537
+				// did we get compiled code
538
+				if ($this->has_code) {
539
+					// Does it create output?
540
+					if ($this->has_output) {
541
+						$_output .= "\n";
542
+					}
543
+					// return compiled code
544
+					return $_output;
545
+				}
546
+			}
547
+			// tag did not produce compiled code
548
+			return null;
549
+		} else {
550
+			// map_named attributes
551
+			if (isset($args[ '_attr' ])) {
552
+				foreach ($args[ '_attr' ] as $key => $attribute) {
553
+					if (is_array($attribute)) {
554
+						$args = array_merge($args, $attribute);
555
+					}
556
+				}
557
+			}
558
+			// not an internal compiler tag
559
+			if (strlen($tag) < 6 || substr($tag, - 5) != 'close') {
560
+				// check if tag is a registered object
561
+				if (isset($this->smarty->registered_objects[ $tag ]) && isset($parameter[ 'object_method' ])) {
562
+					$method = $parameter[ 'object_method' ];
563
+					if (!in_array($method, $this->smarty->registered_objects[ $tag ][ 3 ]) &&
564
+						(empty($this->smarty->registered_objects[ $tag ][ 1 ]) ||
565
+						 in_array($method, $this->smarty->registered_objects[ $tag ][ 1 ]))
566
+					) {
567
+						return $this->callTagCompiler('private_object_function', $args, $parameter, $tag, $method);
568
+					} elseif (in_array($method, $this->smarty->registered_objects[ $tag ][ 3 ])) {
569
+						return $this->callTagCompiler('private_object_block_function', $args, $parameter, $tag,
570
+													  $method);
571
+					} else {
572
+						// throw exception
573
+						$this->trigger_template_error('not allowed method "' . $method . '" in registered object "' .
574
+													  $tag . '"', null, true);
575
+					}
576
+				}
577
+				// check if tag is registered
578
+				foreach (array(Smarty::PLUGIN_COMPILER, Smarty::PLUGIN_FUNCTION, Smarty::PLUGIN_BLOCK,) as $plugin_type)
579
+				{
580
+					if (isset($this->smarty->registered_plugins[ $plugin_type ][ $tag ])) {
581
+						// if compiler function plugin call it now
582
+						if ($plugin_type == Smarty::PLUGIN_COMPILER) {
583
+							$new_args = array();
584
+							foreach ($args as $key => $mixed) {
585
+								if (is_array($mixed)) {
586
+									$new_args = array_merge($new_args, $mixed);
587
+								} else {
588
+									$new_args[ $key ] = $mixed;
589
+								}
590
+							}
591
+							if (!$this->smarty->registered_plugins[ $plugin_type ][ $tag ][ 1 ]) {
592
+								$this->tag_nocache = true;
593
+							}
594
+							return call_user_func_array($this->smarty->registered_plugins[ $plugin_type ][ $tag ][ 0 ],
595
+														array($new_args, $this));
596
+						}
597
+						// compile registered function or block function
598
+						if ($plugin_type == Smarty::PLUGIN_FUNCTION || $plugin_type == Smarty::PLUGIN_BLOCK) {
599
+							return $this->callTagCompiler('private_registered_' . $plugin_type, $args, $parameter,
600
+														  $tag);
601
+						}
602
+					}
603
+				}
604
+				// check plugins from plugins folder
605
+				foreach ($this->plugin_search_order as $plugin_type) {
606
+					if ($plugin_type == Smarty::PLUGIN_COMPILER &&
607
+						$this->smarty->loadPlugin('smarty_compiler_' . $tag) &&
608
+						(!isset($this->smarty->security_policy) ||
609
+						 $this->smarty->security_policy->isTrustedTag($tag, $this))
610
+					) {
611
+						$plugin = 'smarty_compiler_' . $tag;
612
+						if (is_callable($plugin)) {
613
+							// convert arguments format for old compiler plugins
614
+							$new_args = array();
615
+							foreach ($args as $key => $mixed) {
616
+								if (is_array($mixed)) {
617
+									$new_args = array_merge($new_args, $mixed);
618
+								} else {
619
+									$new_args[ $key ] = $mixed;
620
+								}
621
+							}
622
+
623
+							return $plugin($new_args, $this->smarty);
624
+						}
625
+						if (class_exists($plugin, false)) {
626
+							$plugin_object = new $plugin;
627
+							if (method_exists($plugin_object, 'compile')) {
628
+								return $plugin_object->compile($args, $this);
629
+							}
630
+						}
631
+						throw new SmartyException("Plugin \"{$tag}\" not callable");
632
+					} else {
633
+						if ($function = $this->getPlugin($tag, $plugin_type)) {
634
+							if (!isset($this->smarty->security_policy) ||
635
+								$this->smarty->security_policy->isTrustedTag($tag, $this)
636
+							) {
637
+								return $this->callTagCompiler('private_' . $plugin_type . '_plugin', $args, $parameter,
638
+															  $tag, $function);
639
+							}
640
+						}
641
+					}
642
+				}
643
+				if (is_callable($this->smarty->default_plugin_handler_func)) {
644
+					$found = false;
645
+					// look for already resolved tags
646
+					foreach ($this->plugin_search_order as $plugin_type) {
647
+						if (isset($this->default_handler_plugins[ $plugin_type ][ $tag ])) {
648
+							$found = true;
649
+							break;
650
+						}
651
+					}
652
+					if (!$found) {
653
+						// call default handler
654
+						foreach ($this->plugin_search_order as $plugin_type) {
655
+							if ($this->getPluginFromDefaultHandler($tag, $plugin_type)) {
656
+								$found = true;
657
+								break;
658
+							}
659
+						}
660
+					}
661
+					if ($found) {
662
+						// if compiler function plugin call it now
663
+						if ($plugin_type == Smarty::PLUGIN_COMPILER) {
664
+							$new_args = array();
665
+							foreach ($args as $mixed) {
666
+								$new_args = array_merge($new_args, $mixed);
667
+							}
668
+							return call_user_func_array($this->default_handler_plugins[ $plugin_type ][ $tag ][ 0 ],
669
+														array($new_args, $this));
670
+						} else {
671
+							return $this->callTagCompiler('private_registered_' . $plugin_type, $args, $parameter,
672
+														  $tag);
673
+						}
674
+					}
675
+				}
676
+			} else {
677
+				// compile closing tag of block function
678
+				$base_tag = substr($tag, 0, - 5);
679
+				// check if closing tag is a registered object
680
+				if (isset($this->smarty->registered_objects[ $base_tag ]) && isset($parameter[ 'object_method' ])) {
681
+					$method = $parameter[ 'object_method' ];
682
+					if (in_array($method, $this->smarty->registered_objects[ $base_tag ][ 3 ])) {
683
+						return $this->callTagCompiler('private_object_block_function', $args, $parameter, $tag,
684
+													  $method);
685
+					} else {
686
+						// throw exception
687
+						$this->trigger_template_error('not allowed closing tag method "' . $method .
688
+													  '" in registered object "' . $base_tag . '"', null, true);
689
+					}
690
+				}
691
+				// registered block tag ?
692
+				if (isset($this->smarty->registered_plugins[ Smarty::PLUGIN_BLOCK ][ $base_tag ]) ||
693
+					isset($this->default_handler_plugins[ Smarty::PLUGIN_BLOCK ][ $base_tag ])
694
+				) {
695
+					return $this->callTagCompiler('private_registered_block', $args, $parameter, $tag);
696
+				}
697
+				// registered function tag ?
698
+				if (isset($this->smarty->registered_plugins[ Smarty::PLUGIN_FUNCTION ][ $tag ])) {
699
+					return $this->callTagCompiler('private_registered_function', $args, $parameter, $tag);
700
+				}
701
+				// block plugin?
702
+				if ($function = $this->getPlugin($base_tag, Smarty::PLUGIN_BLOCK)) {
703
+					return $this->callTagCompiler('private_block_plugin', $args, $parameter, $tag, $function);
704
+				}
705
+				// function plugin?
706
+				if ($function = $this->getPlugin($tag, Smarty::PLUGIN_FUNCTION)) {
707
+					if (!isset($this->smarty->security_policy) ||
708
+						$this->smarty->security_policy->isTrustedTag($tag, $this)
709
+					) {
710
+						return $this->callTagCompiler('private_function_plugin', $args, $parameter, $tag, $function);
711
+					}
712
+				}
713
+				// registered compiler plugin ?
714
+				if (isset($this->smarty->registered_plugins[ Smarty::PLUGIN_COMPILER ][ $tag ])) {
715
+					// if compiler function plugin call it now
716
+					$args = array();
717
+					if (!$this->smarty->registered_plugins[ Smarty::PLUGIN_COMPILER ][ $tag ][ 1 ]) {
718
+						$this->tag_nocache = true;
719
+					}
720
+					return call_user_func_array($this->smarty->registered_plugins[ Smarty::PLUGIN_COMPILER ][ $tag ][ 0 ],
721
+												array($args, $this));
722
+				}
723
+				if ($this->smarty->loadPlugin('smarty_compiler_' . $tag)) {
724
+					$plugin = 'smarty_compiler_' . $tag;
725
+					if (is_callable($plugin)) {
726
+						return $plugin($args, $this->smarty);
727
+					}
728
+					if (class_exists($plugin, false)) {
729
+						$plugin_object = new $plugin;
730
+						if (method_exists($plugin_object, 'compile')) {
731
+							return $plugin_object->compile($args, $this);
732
+						}
733
+					}
734
+					throw new SmartyException("Plugin \"{$tag}\" not callable");
735
+				}
736
+			}
737
+			$this->trigger_template_error("unknown tag \"" . $tag . "\"", null, true);
738
+		}
739
+	}
740
+
741
+	/**
742
+	 * compile variable
743
+	 *
744
+	 * @param string $variable
745
+	 *
746
+	 * @return string
747
+	 */
748
+	public function compileVariable($variable)
749
+	{
750
+		if (strpos($variable, '(') == 0) {
751
+			// not a variable variable
752
+			$var = trim($variable, '\'');
753
+			$this->tag_nocache = $this->tag_nocache |
754
+								 $this->template->ext->getTemplateVars->_getVariable($this->template, $var, null, true,
755
+																					 false)->nocache;
756
+			// todo $this->template->compiled->properties['variables'][$var] = $this->tag_nocache | $this->nocache;
757
+		}
758
+		return '$_smarty_tpl->tpl_vars[' . $variable . ']->value';
759
+	}
760
+
761
+	/**
762
+	 * compile config variable
763
+	 *
764
+	 * @param string $variable
765
+	 *
766
+	 * @return string
767
+	 */
768
+	public function compileConfigVariable($variable)
769
+	{
770
+		// return '$_smarty_tpl->config_vars[' . $variable . ']';
771
+		return '$_smarty_tpl->smarty->ext->configLoad->_getConfigVariable($_smarty_tpl, ' . $variable . ')';
772
+	}
773
+
774
+	/**
775
+	 * This method is called from parser to process a text content section
776
+	 * - remove text from inheritance child templates as they may generate output
777
+	 * - strip text if strip is enabled
778
+	 *
779
+	 * @param string $text
780
+	 *
781
+	 * @return null|\Smarty_Internal_ParseTree_Text
782
+	 */
783
+	public function processText($text)
784
+	{
785
+		if ((string) $text != '') {
786
+			$store = array();
787
+			$_store = 0;
788
+			if ($this->parser->strip) {
789
+				if (strpos($text, '<') !== false) {
790
+					// capture html elements not to be messed with
791
+					$_offset = 0;
792
+					if (preg_match_all('#(<script[^>]*>.*?</script[^>]*>)|(<textarea[^>]*>.*?</textarea[^>]*>)|(<pre[^>]*>.*?</pre[^>]*>)#is',
793
+									   $text, $matches, PREG_OFFSET_CAPTURE | PREG_SET_ORDER)) {
794
+						foreach ($matches as $match) {
795
+							$store[] = $match[ 0 ][ 0 ];
796
+							$_length = strlen($match[ 0 ][ 0 ]);
797
+							$replace = '@!@SMARTY:' . $_store . ':SMARTY@!@';
798
+							$text = substr_replace($text, $replace, $match[ 0 ][ 1 ] - $_offset, $_length);
799
+
800
+							$_offset += $_length - strlen($replace);
801
+							$_store ++;
802
+						}
803
+					}
804
+					$expressions = array(// replace multiple spaces between tags by a single space
805
+										 '#(:SMARTY@!@|>)[\040\011]+(?=@!@SMARTY:|<)#s' => '\1 \2',
806
+										 // remove newline between tags
807
+										 '#(:SMARTY@!@|>)[\040\011]*[\n]\s*(?=@!@SMARTY:|<)#s' => '\1\2',
808
+										 // remove multiple spaces between attributes (but not in attribute values!)
809
+										 '#(([a-z0-9]\s*=\s*("[^"]*?")|(\'[^\']*?\'))|<[a-z0-9_]+)\s+([a-z/>])#is' => '\1 \5',
810
+										 '#>[\040\011]+$#Ss' => '> ', '#>[\040\011]*[\n]\s*$#Ss' => '>',
811
+										 $this->stripRegEx => '',);
812
+
813
+					$text = preg_replace(array_keys($expressions), array_values($expressions), $text);
814
+					$_offset = 0;
815
+					if (preg_match_all('#@!@SMARTY:([0-9]+):SMARTY@!@#is', $text, $matches,
816
+									   PREG_OFFSET_CAPTURE | PREG_SET_ORDER)) {
817
+						foreach ($matches as $match) {
818
+							$_length = strlen($match[ 0 ][ 0 ]);
819
+							$replace = $store[ $match[ 1 ][ 0 ] ];
820
+							$text = substr_replace($text, $replace, $match[ 0 ][ 1 ] + $_offset, $_length);
821
+
822
+							$_offset += strlen($replace) - $_length;
823
+							$_store ++;
824
+						}
825
+					}
826
+				} else {
827
+					$text = preg_replace($this->stripRegEx, '', $text);
828
+				}
829
+			}
830
+			return new Smarty_Internal_ParseTree_Text($text);
831
+		}
832
+		return null;
833
+	}
834
+
835
+	/**
836
+	 * lazy loads internal compile plugin for tag and calls the compile method
837
+	 * compile objects cached for reuse.
838
+	 * class name format:  Smarty_Internal_Compile_TagName
839
+	 * plugin filename format: Smarty_Internal_TagName.php
840
+	 *
841
+	 * @param  string $tag    tag name
842
+	 * @param  array  $args   list of tag attributes
843
+	 * @param  mixed  $param1 optional parameter
844
+	 * @param  mixed  $param2 optional parameter
845
+	 * @param  mixed  $param3 optional parameter
846
+	 *
847
+	 * @return string compiled code
848
+	 */
849
+	public function callTagCompiler($tag, $args, $param1 = null, $param2 = null, $param3 = null)
850
+	{
851
+		// re-use object if already exists
852
+		if (!isset(self::$_tag_objects[ $tag ])) {
853
+			// lazy load internal compiler plugin
854
+			$_tag = explode('_', $tag);
855
+			$_tag = array_map('ucfirst', $_tag);
856
+			$class_name = 'Smarty_Internal_Compile_' . implode('_', $_tag);
857
+			if (class_exists($class_name) &&
858
+				(!isset($this->smarty->security_policy) || $this->smarty->security_policy->isTrustedTag($tag, $this))
859
+			) {
860
+				self::$_tag_objects[ $tag ] = new $class_name;
861
+			} else {
862
+				self::$_tag_objects[ $tag ] = false;
863
+				return false;
864
+			}
865
+		}
866
+		// compile this tag
867
+		return self::$_tag_objects[ $tag ] === false ? false :
868
+			self::$_tag_objects[ $tag ]->compile($args, $this, $param1, $param2, $param3);
869
+	}
870
+
871
+	/**
872
+	 * Check for plugins and return function name
873
+	 *
874
+	 * @param         $plugin_name
875
+	 * @param  string $plugin_type type of plugin
876
+	 *
877
+	 * @return string call name of function
878
+	 */
879
+	public function getPlugin($plugin_name, $plugin_type)
880
+	{
881
+		$function = null;
882
+		if ($this->template->caching && ($this->nocache || $this->tag_nocache)) {
883
+			if (isset($this->parent_compiler->template->compiled->required_plugins[ 'nocache' ][ $plugin_name ][ $plugin_type ])) {
884
+				$function =
885
+					$this->parent_compiler->template->compiled->required_plugins[ 'nocache' ][ $plugin_name ][ $plugin_type ][ 'function' ];
886
+			} elseif (isset($this->parent_compiler->template->compiled->required_plugins[ 'compiled' ][ $plugin_name ][ $plugin_type ])) {
887
+				$this->parent_compiler->template->compiled->required_plugins[ 'nocache' ][ $plugin_name ][ $plugin_type ] =
888
+					$this->parent_compiler->template->compiled->required_plugins[ 'compiled' ][ $plugin_name ][ $plugin_type ];
889
+				$function =
890
+					$this->parent_compiler->template->compiled->required_plugins[ 'nocache' ][ $plugin_name ][ $plugin_type ][ 'function' ];
891
+			}
892
+		} else {
893
+			if (isset($this->parent_compiler->template->compiled->required_plugins[ 'compiled' ][ $plugin_name ][ $plugin_type ])) {
894
+				$function =
895
+					$this->parent_compiler->template->compiled->required_plugins[ 'compiled' ][ $plugin_name ][ $plugin_type ][ 'function' ];
896
+			} elseif (isset($this->parent_compiler->template->compiled->required_plugins[ 'nocache' ][ $plugin_name ][ $plugin_type ])) {
897
+				$this->parent_compiler->template->compiled->required_plugins[ 'compiled' ][ $plugin_name ][ $plugin_type ] =
898
+					$this->parent_compiler->template->compiled->required_plugins[ 'nocache' ][ $plugin_name ][ $plugin_type ];
899
+				$function =
900
+					$this->parent_compiler->template->compiled->required_plugins[ 'compiled' ][ $plugin_name ][ $plugin_type ][ 'function' ];
901
+			}
902
+		}
903
+		if (isset($function)) {
904
+			if ($plugin_type == 'modifier') {
905
+				$this->modifier_plugins[ $plugin_name ] = true;
906
+			}
907
+
908
+			return $function;
909
+		}
910
+		// loop through plugin dirs and find the plugin
911
+		$function = 'smarty_' . $plugin_type . '_' . $plugin_name;
912
+		$file = $this->smarty->loadPlugin($function, false);
913
+
914
+		if (is_string($file)) {
915
+			if ($this->template->caching && ($this->nocache || $this->tag_nocache)) {
916
+				$this->parent_compiler->template->compiled->required_plugins[ 'nocache' ][ $plugin_name ][ $plugin_type ][ 'file' ] =
917
+					$file;
918
+				$this->parent_compiler->template->compiled->required_plugins[ 'nocache' ][ $plugin_name ][ $plugin_type ][ 'function' ] =
919
+					$function;
920
+			} else {
921
+				$this->parent_compiler->template->compiled->required_plugins[ 'compiled' ][ $plugin_name ][ $plugin_type ][ 'file' ] =
922
+					$file;
923
+				$this->parent_compiler->template->compiled->required_plugins[ 'compiled' ][ $plugin_name ][ $plugin_type ][ 'function' ] =
924
+					$function;
925
+			}
926
+			if ($plugin_type == 'modifier') {
927
+				$this->modifier_plugins[ $plugin_name ] = true;
928
+			}
929
+
930
+			return $function;
931
+		}
932
+		if (is_callable($function)) {
933
+			// plugin function is defined in the script
934
+			return $function;
935
+		}
936
+
937
+		return false;
938
+	}
939
+
940
+	/**
941
+	 * Check for plugins by default plugin handler
942
+	 *
943
+	 * @param  string $tag         name of tag
944
+	 * @param  string $plugin_type type of plugin
945
+	 *
946
+	 * @return boolean true if found
947
+	 */
948
+	public function getPluginFromDefaultHandler($tag, $plugin_type)
949
+	{
950
+		$callback = null;
951
+		$script = null;
952
+		$cacheable = true;
953
+		$result = call_user_func_array($this->smarty->default_plugin_handler_func,
954
+									   array($tag, $plugin_type, $this->template, &$callback, &$script, &$cacheable,));
955
+		if ($result) {
956
+			$this->tag_nocache = $this->tag_nocache || !$cacheable;
957
+			if ($script !== null) {
958
+				if (is_file($script)) {
959
+					if ($this->template->caching && ($this->nocache || $this->tag_nocache)) {
960
+						$this->parent_compiler->template->compiled->required_plugins[ 'nocache' ][ $tag ][ $plugin_type ][ 'file' ] =
961
+							$script;
962
+						$this->parent_compiler->template->compiled->required_plugins[ 'nocache' ][ $tag ][ $plugin_type ][ 'function' ] =
963
+							$callback;
964
+					} else {
965
+						$this->parent_compiler->template->compiled->required_plugins[ 'compiled' ][ $tag ][ $plugin_type ][ 'file' ] =
966
+							$script;
967
+						$this->parent_compiler->template->compiled->required_plugins[ 'compiled' ][ $tag ][ $plugin_type ][ 'function' ] =
968
+							$callback;
969
+					}
970
+					require_once $script;
971
+				} else {
972
+					$this->trigger_template_error("Default plugin handler: Returned script file \"{$script}\" for \"{$tag}\" not found");
973
+				}
974
+			}
975
+			if (is_callable($callback)) {
976
+				$this->default_handler_plugins[ $plugin_type ][ $tag ] = array($callback, true, array());
977
+
978
+				return true;
979
+			} else {
980
+				$this->trigger_template_error("Default plugin handler: Returned callback for \"{$tag}\" not callable");
981
+			}
982
+		}
983
+
984
+		return false;
985
+	}
986
+
987
+	/**
988
+	 * Append code segments and remove unneeded ?> <?php transitions
989
+	 *
990
+	 * @param string $left
991
+	 * @param string $right
992
+	 *
993
+	 * @return string
994
+	 */
995
+	public function appendCode($left, $right)
996
+	{
997
+		if (preg_match('/\s*\?>\s*$/', $left) && preg_match('/^\s*<\?php\s+/', $right)) {
998
+			$left = preg_replace('/\s*\?>\s*$/', "\n", $left);
999
+			$left .= preg_replace('/^\s*<\?php\s+/', '', $right);
1000
+		} else {
1001
+			$left .= $right;
1002
+		}
1003
+		return $left;
1004
+	}
1005
+
1006
+	/**
1007
+	 * Inject inline code for nocache template sections
1008
+	 * This method gets the content of each template element from the parser.
1009
+	 * If the content is compiled code and it should be not cached the code is injected
1010
+	 * into the rendered output.
1011
+	 *
1012
+	 * @param  string  $content content of template element
1013
+	 * @param  boolean $is_code true if content is compiled code
1014
+	 *
1015
+	 * @return string  content
1016
+	 */
1017
+	public function processNocacheCode($content, $is_code)
1018
+	{
1019
+		// If the template is not evaluated and we have a nocache section and or a nocache tag
1020
+		if ($is_code && !empty($content)) {
1021
+			// generate replacement code
1022
+			if ((!($this->template->source->handler->recompiled) || $this->forceNocache) && $this->template->caching &&
1023
+				!$this->suppressNocacheProcessing && ($this->nocache || $this->tag_nocache)
1024
+			) {
1025
+				$this->template->compiled->has_nocache_code = true;
1026
+				$_output = addcslashes($content, '\'\\');
1027
+				$_output = str_replace("^#^", "'", $_output);
1028
+				$_output = "<?php echo '/*%%SmartyNocache:{$this->nocache_hash}%%*/" . $_output .
1029
+						   "/*/%%SmartyNocache:{$this->nocache_hash}%%*/';?>\n";
1030
+				// make sure we include modifier plugins for nocache code
1031
+				foreach ($this->modifier_plugins as $plugin_name => $dummy) {
1032
+					if (isset($this->parent_compiler->template->compiled->required_plugins[ 'compiled' ][ $plugin_name ][ 'modifier' ])) {
1033
+						$this->parent_compiler->template->compiled->required_plugins[ 'nocache' ][ $plugin_name ][ 'modifier' ] =
1034
+							$this->parent_compiler->template->compiled->required_plugins[ 'compiled' ][ $plugin_name ][ 'modifier' ];
1035
+					}
1036
+				}
1037
+			} else {
1038
+				$_output = $content;
1039
+			}
1040
+		} else {
1041
+			$_output = $content;
1042
+		}
1043
+		$this->modifier_plugins = array();
1044
+		$this->suppressNocacheProcessing = false;
1045
+		$this->tag_nocache = false;
1046
+
1047
+		return $_output;
1048
+	}
1049
+
1050
+	/**
1051
+	 * Get Id
1052
+	 *
1053
+	 * @param string $input
1054
+	 *
1055
+	 * @return bool|string
1056
+	 */
1057
+	public function getId($input)
1058
+	{
1059
+		if (preg_match('~^([\'"]*)([0-9]*[a-zA-Z_]\w*)\1$~', $input, $match)) {
1060
+			return $match[ 2 ];
1061
+		}
1062
+		return false;
1063
+	}
1064
+
1065
+	/**
1066
+	 * Get variable name from string
1067
+	 *
1068
+	 * @param string $input
1069
+	 *
1070
+	 * @return bool|string
1071
+	 */
1072
+	public function getVariableName($input)
1073
+	{
1074
+		if (preg_match('~^[$]_smarty_tpl->tpl_vars\[[\'"]*([0-9]*[a-zA-Z_]\w*)[\'"]*\]->value$~', $input, $match)) {
1075
+			return $match[ 1 ];
1076
+		}
1077
+		return false;
1078
+	}
1079
+
1080
+	/**
1081
+	 * Set nocache flag in variable or create new variable
1082
+	 *
1083
+	 * @param string $varName
1084
+	 */
1085
+	public function setNocacheInVariable($varName)
1086
+	{
1087
+		// create nocache var to make it know for further compiling
1088
+		if ($_var = $this->getId($varName)) {
1089
+			if (isset($this->template->tpl_vars[ $_var ])) {
1090
+				$this->template->tpl_vars[ $_var ] = clone $this->template->tpl_vars[ $_var ];
1091
+				$this->template->tpl_vars[ $_var ]->nocache = true;
1092
+			} else {
1093
+				$this->template->tpl_vars[ $_var ] = new Smarty_Variable(null, true);
1094
+			}
1095
+		}
1096
+	}
1097
+
1098
+	/**
1099
+	 * @param array $_attr tag attributes
1100
+	 * @param array $validScopes
1101
+	 *
1102
+	 * @return int|string
1103
+	 * @throws \SmartyCompilerException
1104
+	 */
1105
+	public function convertScope($_attr, $validScopes)
1106
+	{
1107
+		$_scope = 0;
1108
+		if (isset($_attr[ 'scope' ])) {
1109
+			$_scopeName = trim($_attr[ 'scope' ], "'\"");
1110
+			if (is_numeric($_scopeName) && in_array($_scopeName, $validScopes)) {
1111
+				$_scope = $_scopeName;
1112
+			} elseif (is_string($_scopeName)) {
1113
+				$_scopeName = trim($_scopeName, "'\"");
1114
+				$_scope = isset($validScopes[ $_scopeName ]) ? $validScopes[ $_scopeName ] : false;
1115
+			} else {
1116
+				$_scope = false;
1117
+			}
1118
+			if ($_scope === false) {
1119
+				$err = var_export($_scopeName, true);
1120
+				$this->trigger_template_error("illegal value '{$err}' for \"scope\" attribute", null, true);
1121
+			}
1122
+		}
1123
+		return $_scope;
1124
+	}
1125
+
1126
+	/**
1127
+	 * Generate nocache code string
1128
+	 *
1129
+	 * @param string $code PHP code
1130
+	 *
1131
+	 * @return string
1132
+	 */
1133
+	public function makeNocacheCode($code)
1134
+	{
1135
+		return "echo '/*%%SmartyNocache:{$this->nocache_hash}%%*/<?php " .
1136
+			   str_replace("^#^", "'", addcslashes($code, '\'\\')) .
1137
+			   "?>/*/%%SmartyNocache:{$this->nocache_hash}%%*/';\n";
1138
+	}
1139
+
1140
+	/**
1141
+	 * display compiler error messages without dying
1142
+	 * If parameter $args is empty it is a parser detected syntax error.
1143
+	 * In this case the parser is called to obtain information about expected tokens.
1144
+	 * If parameter $args contains a string this is used as error message
1145
+	 *
1146
+	 * @param  string   $args    individual error message or null
1147
+	 * @param  string   $line    line-number
1148
+	 * @param null|bool $tagline if true the line number of last tag
1149
+	 *
1150
+	 * @throws \SmartyCompilerException when an unexpected token is found
1151
+	 */
1152
+	public function trigger_template_error($args = null, $line = null, $tagline = null)
1153
+	{
1154
+		$lex = $this->parser->lex;
1155
+		if ($tagline === true) {
1156
+			// get line number of Tag
1157
+			$line = $lex->taglineno;
1158
+		} elseif (!isset($line)) {
1159
+			// get template source line which has error
1160
+			$line = $lex->line;
1161
+		} else {
1162
+			$line = (int) $line;
1163
+		}
1164
+
1165
+		if (in_array($this->template->source->type, array('eval', 'string'))) {
1166
+			$templateName = $this->template->source->type . ':' . trim(preg_replace('![\t\r\n]+!', ' ',
1167
+																					strlen($lex->data) > 40 ?
1168
+																						substr($lex->data, 0, 40) .
1169
+																						'...' : $lex->data));
1170
+		} else {
1171
+			$templateName = $this->template->source->type . ':' . $this->template->source->filepath;
1172
+		}
1173
+
1174
+		//        $line += $this->trace_line_offset;
1175
+		$match = preg_split("/\n/", $lex->data);
1176
+		$error_text =
1177
+			'Syntax error in template "' . (empty($this->trace_filepath) ? $templateName : $this->trace_filepath) .
1178
+			'"  on line ' . ($line + $this->trace_line_offset) . ' "' .
1179
+			trim(preg_replace('![\t\r\n]+!', ' ', $match[ $line - 1 ])) . '" ';
1180
+		if (isset($args)) {
1181
+			// individual error message
1182
+			$error_text .= $args;
1183
+		} else {
1184
+			$expect = array();
1185
+			// expected token from parser
1186
+			$error_text .= ' - Unexpected "' . $lex->value . '"';
1187
+			if (count($this->parser->yy_get_expected_tokens($this->parser->yymajor)) <= 4) {
1188
+				foreach ($this->parser->yy_get_expected_tokens($this->parser->yymajor) as $token) {
1189
+					$exp_token = $this->parser->yyTokenName[ $token ];
1190
+					if (isset($lex->smarty_token_names[ $exp_token ])) {
1191
+						// token type from lexer
1192
+						$expect[] = '"' . $lex->smarty_token_names[ $exp_token ] . '"';
1193
+					} else {
1194
+						// otherwise internal token name
1195
+						$expect[] = $this->parser->yyTokenName[ $token ];
1196
+					}
1197
+				}
1198
+				$error_text .= ', expected one of: ' . implode(' , ', $expect);
1199
+			}
1200
+		}
1201
+		$e = new SmartyCompilerException($error_text);
1202
+		$e->line = $line;
1203
+		$e->source = trim(preg_replace('![\t\r\n]+!', ' ', $match[ $line - 1 ]));
1204
+		$e->desc = $args;
1205
+		$e->template = $this->template->source->filepath;
1206
+		throw $e;
1207
+	}
1208
+
1209
+	/**
1210
+	 * Return var_export() value with all white spaces removed
1211
+	 *
1212
+	 * @param  mixed $value
1213
+	 *
1214
+	 * @return string
1215
+	 */
1216
+	public function getVarExport($value)
1217
+	{
1218
+		return preg_replace('/\s/', '', var_export($value, true));
1219
+	}
1220
+
1221
+	/**
1222
+	 * Check if $value contains variable elements
1223
+	 *
1224
+	 * @param mixed $value
1225
+	 *
1226
+	 * @return bool|int
1227
+	 */
1228
+	public function isVariable($value)
1229
+	{
1230
+		if (is_string($value)) {
1231
+			return preg_match('/[$(]/', $value);
1232
+		}
1233
+		if (is_bool($value) || is_numeric($value)) {
1234
+			return false;
1235
+		}
1236
+		if (is_array($value)) {
1237
+			foreach ($value as $k => $v) {
1238
+				if ($this->isVariable($k) || $this->isVariable($v)) {
1239
+					return true;
1240
+				}
1241
+			}
1242
+			return false;
1243
+		}
1244
+		return false;
1245
+	}
1246
+
1247
+	/**
1248
+	 * Get new prefix variable name
1249
+	 *
1250
+	 * @return string
1251
+	 */
1252
+	public function getNewPrefixVariable()
1253
+	{
1254
+		self::$prefixVariableNumber ++;
1255
+		return $this->getPrefixVariable();
1256
+	}
1257
+
1258
+	/**
1259
+	 * Get current prefix variable name
1260
+	 *
1261
+	 * @return string
1262
+	 */
1263
+	public function getPrefixVariable()
1264
+	{
1265
+		return '$_prefixVariable' . self::$prefixVariableNumber;
1266
+	}
1267
+
1268
+	/**
1269
+	 * append  code to prefix buffer
1270
+	 *
1271
+	 * @param string $code
1272
+	 */
1273
+	public function appendPrefixCode($code)
1274
+	{
1275
+		$this->prefix_code[] = $code;
1276
+	}
1277
+
1278
+	/**
1279
+	 * get prefix code string
1280
+	 *
1281
+	 * @return string
1282
+	 */
1283
+	public function getPrefixCode()
1284
+	{
1285
+		$code = '';
1286
+		$prefixArray = array_merge($this->prefix_code, array_pop($this->prefixCodeStack));
1287
+		$this->prefixCodeStack[] = array();
1288
+		foreach ($prefixArray as $c) {
1289
+			$code = $this->appendCode($code, $c);
1290
+		}
1291
+		$this->prefix_code = array();
1292
+		return $code;
1293
+	}
1294 1294
 
1295 1295
 }
Please login to merge, or discard this patch.
Spacing   +85 added lines, -86 removed lines patch added patch discarded remove patch
@@ -386,7 +386,7 @@  discard block
 block discarded – undo
386 386
             $this->prefix_code = array();
387 387
             // add file dependency
388 388
             if ($this->smarty->merge_compiled_includes || $this->template->source->handler->checkTimestamps()) {
389
-                $this->parent_compiler->template->compiled->file_dependency[ $this->template->source->uid ] =
389
+                $this->parent_compiler->template->compiled->file_dependency[$this->template->source->uid] =
390 390
                     array($this->template->source->filepath, $this->template->source->getTimeStamp(),
391 391
                           $this->template->source->type,);
392 392
             }
@@ -434,7 +434,7 @@  discard block
 block discarded – undo
434 434
     {
435 435
         // run post filter if on code
436 436
         if (!empty($code) &&
437
-            (isset($this->smarty->autoload_filters[ 'post' ]) || isset($this->smarty->registered_filters[ 'post' ]))
437
+            (isset($this->smarty->autoload_filters['post']) || isset($this->smarty->registered_filters['post']))
438 438
         ) {
439 439
             return $this->smarty->ext->_filterHandler->runFilter('post', $code, $this->template);
440 440
         } else {
@@ -454,7 +454,7 @@  discard block
 block discarded – undo
454 454
     {
455 455
         // run pre filter if required
456 456
         if ($_content != '' &&
457
-            ((isset($this->smarty->autoload_filters[ 'pre' ]) || isset($this->smarty->registered_filters[ 'pre' ])))
457
+            ((isset($this->smarty->autoload_filters['pre']) || isset($this->smarty->registered_filters['pre'])))
458 458
         ) {
459 459
             return $this->smarty->ext->_filterHandler->runFilter('pre', $_content, $this->template);
460 460
         } else {
@@ -507,8 +507,8 @@  discard block
 block discarded – undo
507 507
         $this->has_code = true;
508 508
         $this->has_output = false;
509 509
         // log tag/attributes
510
-        if (isset($this->smarty->_cache[ 'get_used_tags' ])) {
511
-            $this->template->_cache[ 'used_tags' ][] = array($tag, $args);
510
+        if (isset($this->smarty->_cache['get_used_tags'])) {
511
+            $this->template->_cache['used_tags'][] = array($tag, $args);
512 512
         }
513 513
         // check nocache option flag
514 514
         foreach ($args as $arg) {
@@ -526,9 +526,9 @@  discard block
 block discarded – undo
526 526
         }
527 527
         // compile the smarty tag (required compile classes to compile the tag are auto loaded)
528 528
         if (($_output = $this->callTagCompiler($tag, $args, $parameter)) === false) {
529
-            if (isset($this->parent_compiler->tpl_function[ $tag ])) {
529
+            if (isset($this->parent_compiler->tpl_function[$tag])) {
530 530
                 // template defined by {template} tag
531
-                $args[ '_attr' ][ 'name' ] = "'" . $tag . "'";
531
+                $args['_attr']['name'] = "'" . $tag . "'";
532 532
                 $_output = $this->callTagCompiler('call', $args, $parameter);
533 533
             }
534 534
         }
@@ -548,8 +548,8 @@  discard block
 block discarded – undo
548 548
             return null;
549 549
         } else {
550 550
             // map_named attributes
551
-            if (isset($args[ '_attr' ])) {
552
-                foreach ($args[ '_attr' ] as $key => $attribute) {
551
+            if (isset($args['_attr'])) {
552
+                foreach ($args['_attr'] as $key => $attribute) {
553 553
                     if (is_array($attribute)) {
554 554
                         $args = array_merge($args, $attribute);
555 555
                     }
@@ -558,14 +558,14 @@  discard block
 block discarded – undo
558 558
             // not an internal compiler tag
559 559
             if (strlen($tag) < 6 || substr($tag, - 5) != 'close') {
560 560
                 // check if tag is a registered object
561
-                if (isset($this->smarty->registered_objects[ $tag ]) && isset($parameter[ 'object_method' ])) {
562
-                    $method = $parameter[ 'object_method' ];
563
-                    if (!in_array($method, $this->smarty->registered_objects[ $tag ][ 3 ]) &&
564
-                        (empty($this->smarty->registered_objects[ $tag ][ 1 ]) ||
565
-                         in_array($method, $this->smarty->registered_objects[ $tag ][ 1 ]))
561
+                if (isset($this->smarty->registered_objects[$tag]) && isset($parameter['object_method'])) {
562
+                    $method = $parameter['object_method'];
563
+                    if (!in_array($method, $this->smarty->registered_objects[$tag][3]) &&
564
+                        (empty($this->smarty->registered_objects[$tag][1]) ||
565
+                         in_array($method, $this->smarty->registered_objects[$tag][1]))
566 566
                     ) {
567 567
                         return $this->callTagCompiler('private_object_function', $args, $parameter, $tag, $method);
568
-                    } elseif (in_array($method, $this->smarty->registered_objects[ $tag ][ 3 ])) {
568
+                    } elseif (in_array($method, $this->smarty->registered_objects[$tag][3])) {
569 569
                         return $this->callTagCompiler('private_object_block_function', $args, $parameter, $tag,
570 570
                                                       $method);
571 571
                     } else {
@@ -577,7 +577,7 @@  discard block
 block discarded – undo
577 577
                 // check if tag is registered
578 578
                 foreach (array(Smarty::PLUGIN_COMPILER, Smarty::PLUGIN_FUNCTION, Smarty::PLUGIN_BLOCK,) as $plugin_type)
579 579
                 {
580
-                    if (isset($this->smarty->registered_plugins[ $plugin_type ][ $tag ])) {
580
+                    if (isset($this->smarty->registered_plugins[$plugin_type][$tag])) {
581 581
                         // if compiler function plugin call it now
582 582
                         if ($plugin_type == Smarty::PLUGIN_COMPILER) {
583 583
                             $new_args = array();
@@ -585,13 +585,13 @@  discard block
 block discarded – undo
585 585
                                 if (is_array($mixed)) {
586 586
                                     $new_args = array_merge($new_args, $mixed);
587 587
                                 } else {
588
-                                    $new_args[ $key ] = $mixed;
588
+                                    $new_args[$key] = $mixed;
589 589
                                 }
590 590
                             }
591
-                            if (!$this->smarty->registered_plugins[ $plugin_type ][ $tag ][ 1 ]) {
591
+                            if (!$this->smarty->registered_plugins[$plugin_type][$tag][1]) {
592 592
                                 $this->tag_nocache = true;
593 593
                             }
594
-                            return call_user_func_array($this->smarty->registered_plugins[ $plugin_type ][ $tag ][ 0 ],
594
+                            return call_user_func_array($this->smarty->registered_plugins[$plugin_type][$tag][0],
595 595
                                                         array($new_args, $this));
596 596
                         }
597 597
                         // compile registered function or block function
@@ -616,7 +616,7 @@  discard block
 block discarded – undo
616 616
                                 if (is_array($mixed)) {
617 617
                                     $new_args = array_merge($new_args, $mixed);
618 618
                                 } else {
619
-                                    $new_args[ $key ] = $mixed;
619
+                                    $new_args[$key] = $mixed;
620 620
                                 }
621 621
                             }
622 622
 
@@ -644,7 +644,7 @@  discard block
 block discarded – undo
644 644
                     $found = false;
645 645
                     // look for already resolved tags
646 646
                     foreach ($this->plugin_search_order as $plugin_type) {
647
-                        if (isset($this->default_handler_plugins[ $plugin_type ][ $tag ])) {
647
+                        if (isset($this->default_handler_plugins[$plugin_type][$tag])) {
648 648
                             $found = true;
649 649
                             break;
650 650
                         }
@@ -665,7 +665,7 @@  discard block
 block discarded – undo
665 665
                             foreach ($args as $mixed) {
666 666
                                 $new_args = array_merge($new_args, $mixed);
667 667
                             }
668
-                            return call_user_func_array($this->default_handler_plugins[ $plugin_type ][ $tag ][ 0 ],
668
+                            return call_user_func_array($this->default_handler_plugins[$plugin_type][$tag][0],
669 669
                                                         array($new_args, $this));
670 670
                         } else {
671 671
                             return $this->callTagCompiler('private_registered_' . $plugin_type, $args, $parameter,
@@ -677,9 +677,9 @@  discard block
 block discarded – undo
677 677
                 // compile closing tag of block function
678 678
                 $base_tag = substr($tag, 0, - 5);
679 679
                 // check if closing tag is a registered object
680
-                if (isset($this->smarty->registered_objects[ $base_tag ]) && isset($parameter[ 'object_method' ])) {
681
-                    $method = $parameter[ 'object_method' ];
682
-                    if (in_array($method, $this->smarty->registered_objects[ $base_tag ][ 3 ])) {
680
+                if (isset($this->smarty->registered_objects[$base_tag]) && isset($parameter['object_method'])) {
681
+                    $method = $parameter['object_method'];
682
+                    if (in_array($method, $this->smarty->registered_objects[$base_tag][3])) {
683 683
                         return $this->callTagCompiler('private_object_block_function', $args, $parameter, $tag,
684 684
                                                       $method);
685 685
                     } else {
@@ -689,13 +689,13 @@  discard block
 block discarded – undo
689 689
                     }
690 690
                 }
691 691
                 // registered block tag ?
692
-                if (isset($this->smarty->registered_plugins[ Smarty::PLUGIN_BLOCK ][ $base_tag ]) ||
693
-                    isset($this->default_handler_plugins[ Smarty::PLUGIN_BLOCK ][ $base_tag ])
692
+                if (isset($this->smarty->registered_plugins[Smarty::PLUGIN_BLOCK][$base_tag]) ||
693
+                    isset($this->default_handler_plugins[Smarty::PLUGIN_BLOCK][$base_tag])
694 694
                 ) {
695 695
                     return $this->callTagCompiler('private_registered_block', $args, $parameter, $tag);
696 696
                 }
697 697
                 // registered function tag ?
698
-                if (isset($this->smarty->registered_plugins[ Smarty::PLUGIN_FUNCTION ][ $tag ])) {
698
+                if (isset($this->smarty->registered_plugins[Smarty::PLUGIN_FUNCTION][$tag])) {
699 699
                     return $this->callTagCompiler('private_registered_function', $args, $parameter, $tag);
700 700
                 }
701 701
                 // block plugin?
@@ -711,13 +711,13 @@  discard block
 block discarded – undo
711 711
                     }
712 712
                 }
713 713
                 // registered compiler plugin ?
714
-                if (isset($this->smarty->registered_plugins[ Smarty::PLUGIN_COMPILER ][ $tag ])) {
714
+                if (isset($this->smarty->registered_plugins[Smarty::PLUGIN_COMPILER][$tag])) {
715 715
                     // if compiler function plugin call it now
716 716
                     $args = array();
717
-                    if (!$this->smarty->registered_plugins[ Smarty::PLUGIN_COMPILER ][ $tag ][ 1 ]) {
717
+                    if (!$this->smarty->registered_plugins[Smarty::PLUGIN_COMPILER][$tag][1]) {
718 718
                         $this->tag_nocache = true;
719 719
                     }
720
-                    return call_user_func_array($this->smarty->registered_plugins[ Smarty::PLUGIN_COMPILER ][ $tag ][ 0 ],
720
+                    return call_user_func_array($this->smarty->registered_plugins[Smarty::PLUGIN_COMPILER][$tag][0],
721 721
                                                 array($args, $this));
722 722
                 }
723 723
                 if ($this->smarty->loadPlugin('smarty_compiler_' . $tag)) {
@@ -792,13 +792,13 @@  discard block
 block discarded – undo
792 792
                     if (preg_match_all('#(<script[^>]*>.*?</script[^>]*>)|(<textarea[^>]*>.*?</textarea[^>]*>)|(<pre[^>]*>.*?</pre[^>]*>)#is',
793 793
                                        $text, $matches, PREG_OFFSET_CAPTURE | PREG_SET_ORDER)) {
794 794
                         foreach ($matches as $match) {
795
-                            $store[] = $match[ 0 ][ 0 ];
796
-                            $_length = strlen($match[ 0 ][ 0 ]);
795
+                            $store[] = $match[0][0];
796
+                            $_length = strlen($match[0][0]);
797 797
                             $replace = '@!@SMARTY:' . $_store . ':SMARTY@!@';
798
-                            $text = substr_replace($text, $replace, $match[ 0 ][ 1 ] - $_offset, $_length);
798
+                            $text = substr_replace($text, $replace, $match[0][1] - $_offset, $_length);
799 799
 
800 800
                             $_offset += $_length - strlen($replace);
801
-                            $_store ++;
801
+                            $_store++;
802 802
                         }
803 803
                     }
804 804
                     $expressions = array(// replace multiple spaces between tags by a single space
@@ -815,12 +815,12 @@  discard block
 block discarded – undo
815 815
                     if (preg_match_all('#@!@SMARTY:([0-9]+):SMARTY@!@#is', $text, $matches,
816 816
                                        PREG_OFFSET_CAPTURE | PREG_SET_ORDER)) {
817 817
                         foreach ($matches as $match) {
818
-                            $_length = strlen($match[ 0 ][ 0 ]);
819
-                            $replace = $store[ $match[ 1 ][ 0 ] ];
820
-                            $text = substr_replace($text, $replace, $match[ 0 ][ 1 ] + $_offset, $_length);
818
+                            $_length = strlen($match[0][0]);
819
+                            $replace = $store[$match[1][0]];
820
+                            $text = substr_replace($text, $replace, $match[0][1] + $_offset, $_length);
821 821
 
822 822
                             $_offset += strlen($replace) - $_length;
823
-                            $_store ++;
823
+                            $_store++;
824 824
                         }
825 825
                     }
826 826
                 } else {
@@ -849,7 +849,7 @@  discard block
 block discarded – undo
849 849
     public function callTagCompiler($tag, $args, $param1 = null, $param2 = null, $param3 = null)
850 850
     {
851 851
         // re-use object if already exists
852
-        if (!isset(self::$_tag_objects[ $tag ])) {
852
+        if (!isset(self::$_tag_objects[$tag])) {
853 853
             // lazy load internal compiler plugin
854 854
             $_tag = explode('_', $tag);
855 855
             $_tag = array_map('ucfirst', $_tag);
@@ -857,15 +857,14 @@  discard block
 block discarded – undo
857 857
             if (class_exists($class_name) &&
858 858
                 (!isset($this->smarty->security_policy) || $this->smarty->security_policy->isTrustedTag($tag, $this))
859 859
             ) {
860
-                self::$_tag_objects[ $tag ] = new $class_name;
860
+                self::$_tag_objects[$tag] = new $class_name;
861 861
             } else {
862
-                self::$_tag_objects[ $tag ] = false;
862
+                self::$_tag_objects[$tag] = false;
863 863
                 return false;
864 864
             }
865 865
         }
866 866
         // compile this tag
867
-        return self::$_tag_objects[ $tag ] === false ? false :
868
-            self::$_tag_objects[ $tag ]->compile($args, $this, $param1, $param2, $param3);
867
+        return self::$_tag_objects[$tag] === false ? false : self::$_tag_objects[$tag]->compile($args, $this, $param1, $param2, $param3);
869 868
     }
870 869
 
871 870
     /**
@@ -880,29 +879,29 @@  discard block
 block discarded – undo
880 879
     {
881 880
         $function = null;
882 881
         if ($this->template->caching && ($this->nocache || $this->tag_nocache)) {
883
-            if (isset($this->parent_compiler->template->compiled->required_plugins[ 'nocache' ][ $plugin_name ][ $plugin_type ])) {
882
+            if (isset($this->parent_compiler->template->compiled->required_plugins['nocache'][$plugin_name][$plugin_type])) {
884 883
                 $function =
885
-                    $this->parent_compiler->template->compiled->required_plugins[ 'nocache' ][ $plugin_name ][ $plugin_type ][ 'function' ];
886
-            } elseif (isset($this->parent_compiler->template->compiled->required_plugins[ 'compiled' ][ $plugin_name ][ $plugin_type ])) {
887
-                $this->parent_compiler->template->compiled->required_plugins[ 'nocache' ][ $plugin_name ][ $plugin_type ] =
888
-                    $this->parent_compiler->template->compiled->required_plugins[ 'compiled' ][ $plugin_name ][ $plugin_type ];
884
+                    $this->parent_compiler->template->compiled->required_plugins['nocache'][$plugin_name][$plugin_type]['function'];
885
+            } elseif (isset($this->parent_compiler->template->compiled->required_plugins['compiled'][$plugin_name][$plugin_type])) {
886
+                $this->parent_compiler->template->compiled->required_plugins['nocache'][$plugin_name][$plugin_type] =
887
+                    $this->parent_compiler->template->compiled->required_plugins['compiled'][$plugin_name][$plugin_type];
889 888
                 $function =
890
-                    $this->parent_compiler->template->compiled->required_plugins[ 'nocache' ][ $plugin_name ][ $plugin_type ][ 'function' ];
889
+                    $this->parent_compiler->template->compiled->required_plugins['nocache'][$plugin_name][$plugin_type]['function'];
891 890
             }
892 891
         } else {
893
-            if (isset($this->parent_compiler->template->compiled->required_plugins[ 'compiled' ][ $plugin_name ][ $plugin_type ])) {
892
+            if (isset($this->parent_compiler->template->compiled->required_plugins['compiled'][$plugin_name][$plugin_type])) {
894 893
                 $function =
895
-                    $this->parent_compiler->template->compiled->required_plugins[ 'compiled' ][ $plugin_name ][ $plugin_type ][ 'function' ];
896
-            } elseif (isset($this->parent_compiler->template->compiled->required_plugins[ 'nocache' ][ $plugin_name ][ $plugin_type ])) {
897
-                $this->parent_compiler->template->compiled->required_plugins[ 'compiled' ][ $plugin_name ][ $plugin_type ] =
898
-                    $this->parent_compiler->template->compiled->required_plugins[ 'nocache' ][ $plugin_name ][ $plugin_type ];
894
+                    $this->parent_compiler->template->compiled->required_plugins['compiled'][$plugin_name][$plugin_type]['function'];
895
+            } elseif (isset($this->parent_compiler->template->compiled->required_plugins['nocache'][$plugin_name][$plugin_type])) {
896
+                $this->parent_compiler->template->compiled->required_plugins['compiled'][$plugin_name][$plugin_type] =
897
+                    $this->parent_compiler->template->compiled->required_plugins['nocache'][$plugin_name][$plugin_type];
899 898
                 $function =
900
-                    $this->parent_compiler->template->compiled->required_plugins[ 'compiled' ][ $plugin_name ][ $plugin_type ][ 'function' ];
899
+                    $this->parent_compiler->template->compiled->required_plugins['compiled'][$plugin_name][$plugin_type]['function'];
901 900
             }
902 901
         }
903 902
         if (isset($function)) {
904 903
             if ($plugin_type == 'modifier') {
905
-                $this->modifier_plugins[ $plugin_name ] = true;
904
+                $this->modifier_plugins[$plugin_name] = true;
906 905
             }
907 906
 
908 907
             return $function;
@@ -913,18 +912,18 @@  discard block
 block discarded – undo
913 912
 
914 913
         if (is_string($file)) {
915 914
             if ($this->template->caching && ($this->nocache || $this->tag_nocache)) {
916
-                $this->parent_compiler->template->compiled->required_plugins[ 'nocache' ][ $plugin_name ][ $plugin_type ][ 'file' ] =
915
+                $this->parent_compiler->template->compiled->required_plugins['nocache'][$plugin_name][$plugin_type]['file'] =
917 916
                     $file;
918
-                $this->parent_compiler->template->compiled->required_plugins[ 'nocache' ][ $plugin_name ][ $plugin_type ][ 'function' ] =
917
+                $this->parent_compiler->template->compiled->required_plugins['nocache'][$plugin_name][$plugin_type]['function'] =
919 918
                     $function;
920 919
             } else {
921
-                $this->parent_compiler->template->compiled->required_plugins[ 'compiled' ][ $plugin_name ][ $plugin_type ][ 'file' ] =
920
+                $this->parent_compiler->template->compiled->required_plugins['compiled'][$plugin_name][$plugin_type]['file'] =
922 921
                     $file;
923
-                $this->parent_compiler->template->compiled->required_plugins[ 'compiled' ][ $plugin_name ][ $plugin_type ][ 'function' ] =
922
+                $this->parent_compiler->template->compiled->required_plugins['compiled'][$plugin_name][$plugin_type]['function'] =
924 923
                     $function;
925 924
             }
926 925
             if ($plugin_type == 'modifier') {
927
-                $this->modifier_plugins[ $plugin_name ] = true;
926
+                $this->modifier_plugins[$plugin_name] = true;
928 927
             }
929 928
 
930 929
             return $function;
@@ -957,14 +956,14 @@  discard block
 block discarded – undo
957 956
             if ($script !== null) {
958 957
                 if (is_file($script)) {
959 958
                     if ($this->template->caching && ($this->nocache || $this->tag_nocache)) {
960
-                        $this->parent_compiler->template->compiled->required_plugins[ 'nocache' ][ $tag ][ $plugin_type ][ 'file' ] =
959
+                        $this->parent_compiler->template->compiled->required_plugins['nocache'][$tag][$plugin_type]['file'] =
961 960
                             $script;
962
-                        $this->parent_compiler->template->compiled->required_plugins[ 'nocache' ][ $tag ][ $plugin_type ][ 'function' ] =
961
+                        $this->parent_compiler->template->compiled->required_plugins['nocache'][$tag][$plugin_type]['function'] =
963 962
                             $callback;
964 963
                     } else {
965
-                        $this->parent_compiler->template->compiled->required_plugins[ 'compiled' ][ $tag ][ $plugin_type ][ 'file' ] =
964
+                        $this->parent_compiler->template->compiled->required_plugins['compiled'][$tag][$plugin_type]['file'] =
966 965
                             $script;
967
-                        $this->parent_compiler->template->compiled->required_plugins[ 'compiled' ][ $tag ][ $plugin_type ][ 'function' ] =
966
+                        $this->parent_compiler->template->compiled->required_plugins['compiled'][$tag][$plugin_type]['function'] =
968 967
                             $callback;
969 968
                     }
970 969
                     require_once $script;
@@ -973,7 +972,7 @@  discard block
 block discarded – undo
973 972
                 }
974 973
             }
975 974
             if (is_callable($callback)) {
976
-                $this->default_handler_plugins[ $plugin_type ][ $tag ] = array($callback, true, array());
975
+                $this->default_handler_plugins[$plugin_type][$tag] = array($callback, true, array());
977 976
 
978 977
                 return true;
979 978
             } else {
@@ -1029,9 +1028,9 @@  discard block
 block discarded – undo
1029 1028
                            "/*/%%SmartyNocache:{$this->nocache_hash}%%*/';?>\n";
1030 1029
                 // make sure we include modifier plugins for nocache code
1031 1030
                 foreach ($this->modifier_plugins as $plugin_name => $dummy) {
1032
-                    if (isset($this->parent_compiler->template->compiled->required_plugins[ 'compiled' ][ $plugin_name ][ 'modifier' ])) {
1033
-                        $this->parent_compiler->template->compiled->required_plugins[ 'nocache' ][ $plugin_name ][ 'modifier' ] =
1034
-                            $this->parent_compiler->template->compiled->required_plugins[ 'compiled' ][ $plugin_name ][ 'modifier' ];
1031
+                    if (isset($this->parent_compiler->template->compiled->required_plugins['compiled'][$plugin_name]['modifier'])) {
1032
+                        $this->parent_compiler->template->compiled->required_plugins['nocache'][$plugin_name]['modifier'] =
1033
+                            $this->parent_compiler->template->compiled->required_plugins['compiled'][$plugin_name]['modifier'];
1035 1034
                     }
1036 1035
                 }
1037 1036
             } else {
@@ -1057,7 +1056,7 @@  discard block
 block discarded – undo
1057 1056
     public function getId($input)
1058 1057
     {
1059 1058
         if (preg_match('~^([\'"]*)([0-9]*[a-zA-Z_]\w*)\1$~', $input, $match)) {
1060
-            return $match[ 2 ];
1059
+            return $match[2];
1061 1060
         }
1062 1061
         return false;
1063 1062
     }
@@ -1072,7 +1071,7 @@  discard block
 block discarded – undo
1072 1071
     public function getVariableName($input)
1073 1072
     {
1074 1073
         if (preg_match('~^[$]_smarty_tpl->tpl_vars\[[\'"]*([0-9]*[a-zA-Z_]\w*)[\'"]*\]->value$~', $input, $match)) {
1075
-            return $match[ 1 ];
1074
+            return $match[1];
1076 1075
         }
1077 1076
         return false;
1078 1077
     }
@@ -1086,11 +1085,11 @@  discard block
 block discarded – undo
1086 1085
     {
1087 1086
         // create nocache var to make it know for further compiling
1088 1087
         if ($_var = $this->getId($varName)) {
1089
-            if (isset($this->template->tpl_vars[ $_var ])) {
1090
-                $this->template->tpl_vars[ $_var ] = clone $this->template->tpl_vars[ $_var ];
1091
-                $this->template->tpl_vars[ $_var ]->nocache = true;
1088
+            if (isset($this->template->tpl_vars[$_var])) {
1089
+                $this->template->tpl_vars[$_var] = clone $this->template->tpl_vars[$_var];
1090
+                $this->template->tpl_vars[$_var]->nocache = true;
1092 1091
             } else {
1093
-                $this->template->tpl_vars[ $_var ] = new Smarty_Variable(null, true);
1092
+                $this->template->tpl_vars[$_var] = new Smarty_Variable(null, true);
1094 1093
             }
1095 1094
         }
1096 1095
     }
@@ -1105,13 +1104,13 @@  discard block
 block discarded – undo
1105 1104
     public function convertScope($_attr, $validScopes)
1106 1105
     {
1107 1106
         $_scope = 0;
1108
-        if (isset($_attr[ 'scope' ])) {
1109
-            $_scopeName = trim($_attr[ 'scope' ], "'\"");
1107
+        if (isset($_attr['scope'])) {
1108
+            $_scopeName = trim($_attr['scope'], "'\"");
1110 1109
             if (is_numeric($_scopeName) && in_array($_scopeName, $validScopes)) {
1111 1110
                 $_scope = $_scopeName;
1112 1111
             } elseif (is_string($_scopeName)) {
1113 1112
                 $_scopeName = trim($_scopeName, "'\"");
1114
-                $_scope = isset($validScopes[ $_scopeName ]) ? $validScopes[ $_scopeName ] : false;
1113
+                $_scope = isset($validScopes[$_scopeName]) ? $validScopes[$_scopeName] : false;
1115 1114
             } else {
1116 1115
                 $_scope = false;
1117 1116
             }
@@ -1176,7 +1175,7 @@  discard block
 block discarded – undo
1176 1175
         $error_text =
1177 1176
             'Syntax error in template "' . (empty($this->trace_filepath) ? $templateName : $this->trace_filepath) .
1178 1177
             '"  on line ' . ($line + $this->trace_line_offset) . ' "' .
1179
-            trim(preg_replace('![\t\r\n]+!', ' ', $match[ $line - 1 ])) . '" ';
1178
+            trim(preg_replace('![\t\r\n]+!', ' ', $match[$line - 1])) . '" ';
1180 1179
         if (isset($args)) {
1181 1180
             // individual error message
1182 1181
             $error_text .= $args;
@@ -1186,13 +1185,13 @@  discard block
 block discarded – undo
1186 1185
             $error_text .= ' - Unexpected "' . $lex->value . '"';
1187 1186
             if (count($this->parser->yy_get_expected_tokens($this->parser->yymajor)) <= 4) {
1188 1187
                 foreach ($this->parser->yy_get_expected_tokens($this->parser->yymajor) as $token) {
1189
-                    $exp_token = $this->parser->yyTokenName[ $token ];
1190
-                    if (isset($lex->smarty_token_names[ $exp_token ])) {
1188
+                    $exp_token = $this->parser->yyTokenName[$token];
1189
+                    if (isset($lex->smarty_token_names[$exp_token])) {
1191 1190
                         // token type from lexer
1192
-                        $expect[] = '"' . $lex->smarty_token_names[ $exp_token ] . '"';
1191
+                        $expect[] = '"' . $lex->smarty_token_names[$exp_token] . '"';
1193 1192
                     } else {
1194 1193
                         // otherwise internal token name
1195
-                        $expect[] = $this->parser->yyTokenName[ $token ];
1194
+                        $expect[] = $this->parser->yyTokenName[$token];
1196 1195
                     }
1197 1196
                 }
1198 1197
                 $error_text .= ', expected one of: ' . implode(' , ', $expect);
@@ -1200,7 +1199,7 @@  discard block
 block discarded – undo
1200 1199
         }
1201 1200
         $e = new SmartyCompilerException($error_text);
1202 1201
         $e->line = $line;
1203
-        $e->source = trim(preg_replace('![\t\r\n]+!', ' ', $match[ $line - 1 ]));
1202
+        $e->source = trim(preg_replace('![\t\r\n]+!', ' ', $match[$line - 1]));
1204 1203
         $e->desc = $args;
1205 1204
         $e->template = $this->template->source->filepath;
1206 1205
         throw $e;
@@ -1251,7 +1250,7 @@  discard block
 block discarded – undo
1251 1250
      */
1252 1251
     public function getNewPrefixVariable()
1253 1252
     {
1254
-        self::$prefixVariableNumber ++;
1253
+        self::$prefixVariableNumber++;
1255 1254
         return $this->getPrefixVariable();
1256 1255
     }
1257 1256
 
Please login to merge, or discard this patch.
Braces   +1 added lines, -2 removed lines patch added patch discarded remove patch
@@ -213,8 +213,7 @@
 block discarded – undo
213 213
                 error_reporting($_smarty_old_error_level);
214 214
             }
215 215
             return $result;
216
-        }
217
-        catch (Exception $e) {
216
+        } catch (Exception $e) {
218 217
             while (ob_get_level() > $level) {
219 218
                 ob_end_clean();
220 219
             }
Please login to merge, or discard this patch.
Smarty/libs/sysplugins/smarty_internal_method_clearcompiledtemplate.php 3 patches
Indentation   +101 added lines, -101 removed lines patch added patch discarded remove patch
@@ -11,110 +11,110 @@
 block discarded – undo
11 11
  */
12 12
 class Smarty_Internal_Method_ClearCompiledTemplate
13 13
 {
14
-    /**
15
-     * Valid for Smarty object
16
-     *
17
-     * @var int
18
-     */
19
-    public $objMap = 1;
14
+	/**
15
+	 * Valid for Smarty object
16
+	 *
17
+	 * @var int
18
+	 */
19
+	public $objMap = 1;
20 20
 
21
-    /**
22
-     * Delete compiled template file
23
-     *
24
-     * @api  Smarty::clearCompiledTemplate()
25
-     * @link http://www.smarty.net/docs/en/api.clear.compiled.template.tpl
26
-     *
27
-     * @param \Smarty  $smarty
28
-     * @param  string  $resource_name template name
29
-     * @param  string  $compile_id    compile id
30
-     * @param  integer $exp_time      expiration time
31
-     *
32
-     * @return integer number of template files deleted
33
-     */
34
-    public function clearCompiledTemplate(Smarty $smarty, $resource_name = null, $compile_id = null, $exp_time = null)
35
-    {
36
-        // clear template objects cache
37
-        $smarty->_clearTemplateCache();
21
+	/**
22
+	 * Delete compiled template file
23
+	 *
24
+	 * @api  Smarty::clearCompiledTemplate()
25
+	 * @link http://www.smarty.net/docs/en/api.clear.compiled.template.tpl
26
+	 *
27
+	 * @param \Smarty  $smarty
28
+	 * @param  string  $resource_name template name
29
+	 * @param  string  $compile_id    compile id
30
+	 * @param  integer $exp_time      expiration time
31
+	 *
32
+	 * @return integer number of template files deleted
33
+	 */
34
+	public function clearCompiledTemplate(Smarty $smarty, $resource_name = null, $compile_id = null, $exp_time = null)
35
+	{
36
+		// clear template objects cache
37
+		$smarty->_clearTemplateCache();
38 38
 
39
-        $_compile_dir = $smarty->getCompileDir();
40
-        if ($_compile_dir == '/') { //We should never want to delete this!
41
-            return 0;
42
-        }
43
-        $_compile_id = isset($compile_id) ? preg_replace('![^\w]+!', '_', $compile_id) : null;
44
-        $_dir_sep = $smarty->use_sub_dirs ? DS : '^';
45
-        if (isset($resource_name)) {
46
-            $_save_stat = $smarty->caching;
47
-            $smarty->caching = false;
48
-            /* @var Smarty_Internal_Template $tpl */
49
-            $tpl = new $smarty->template_class($resource_name, $smarty);
50
-            $smarty->caching = $_save_stat;
51
-            if (!$tpl->source->handler->uncompiled && !$tpl->source->handler->recompiled && $tpl->source->exists) {
52
-                $_resource_part_1 = basename(str_replace('^', DS, $tpl->compiled->filepath));
53
-                $_resource_part_1_length = strlen($_resource_part_1);
54
-            } else {
55
-                return 0;
56
-            }
57
-            $_resource_part_2 = str_replace('.php', '.cache.php', $_resource_part_1);
58
-            $_resource_part_2_length = strlen($_resource_part_2);
59
-        }
60
-        $_dir = $_compile_dir;
61
-        if ($smarty->use_sub_dirs && isset($_compile_id)) {
62
-            $_dir .= $_compile_id . $_dir_sep;
63
-        }
64
-        if (isset($_compile_id)) {
65
-            $_compile_id_part = $_compile_dir . $_compile_id . $_dir_sep;
66
-            $_compile_id_part_length = strlen($_compile_id_part);
67
-        }
68
-        $_count = 0;
69
-        try {
70
-            $_compileDirs = new RecursiveDirectoryIterator($_dir);
71
-            // NOTE: UnexpectedValueException thrown for PHP >= 5.3
72
-        }
73
-        catch (Exception $e) {
74
-            return 0;
75
-        }
76
-        $_compile = new RecursiveIteratorIterator($_compileDirs, RecursiveIteratorIterator::CHILD_FIRST);
77
-        foreach ($_compile as $_file) {
78
-            if (substr(basename($_file->getPathname()), 0, 1) == '.' || strpos($_file, '.svn') !== false) {
79
-                continue;
80
-            }
39
+		$_compile_dir = $smarty->getCompileDir();
40
+		if ($_compile_dir == '/') { //We should never want to delete this!
41
+			return 0;
42
+		}
43
+		$_compile_id = isset($compile_id) ? preg_replace('![^\w]+!', '_', $compile_id) : null;
44
+		$_dir_sep = $smarty->use_sub_dirs ? DS : '^';
45
+		if (isset($resource_name)) {
46
+			$_save_stat = $smarty->caching;
47
+			$smarty->caching = false;
48
+			/* @var Smarty_Internal_Template $tpl */
49
+			$tpl = new $smarty->template_class($resource_name, $smarty);
50
+			$smarty->caching = $_save_stat;
51
+			if (!$tpl->source->handler->uncompiled && !$tpl->source->handler->recompiled && $tpl->source->exists) {
52
+				$_resource_part_1 = basename(str_replace('^', DS, $tpl->compiled->filepath));
53
+				$_resource_part_1_length = strlen($_resource_part_1);
54
+			} else {
55
+				return 0;
56
+			}
57
+			$_resource_part_2 = str_replace('.php', '.cache.php', $_resource_part_1);
58
+			$_resource_part_2_length = strlen($_resource_part_2);
59
+		}
60
+		$_dir = $_compile_dir;
61
+		if ($smarty->use_sub_dirs && isset($_compile_id)) {
62
+			$_dir .= $_compile_id . $_dir_sep;
63
+		}
64
+		if (isset($_compile_id)) {
65
+			$_compile_id_part = $_compile_dir . $_compile_id . $_dir_sep;
66
+			$_compile_id_part_length = strlen($_compile_id_part);
67
+		}
68
+		$_count = 0;
69
+		try {
70
+			$_compileDirs = new RecursiveDirectoryIterator($_dir);
71
+			// NOTE: UnexpectedValueException thrown for PHP >= 5.3
72
+		}
73
+		catch (Exception $e) {
74
+			return 0;
75
+		}
76
+		$_compile = new RecursiveIteratorIterator($_compileDirs, RecursiveIteratorIterator::CHILD_FIRST);
77
+		foreach ($_compile as $_file) {
78
+			if (substr(basename($_file->getPathname()), 0, 1) == '.' || strpos($_file, '.svn') !== false) {
79
+				continue;
80
+			}
81 81
 
82
-            $_filepath = (string) $_file;
82
+			$_filepath = (string) $_file;
83 83
 
84
-            if ($_file->isDir()) {
85
-                if (!$_compile->isDot()) {
86
-                    // delete folder if empty
87
-                    @rmdir($_file->getPathname());
88
-                }
89
-            } else {
90
-                $unlink = false;
91
-                if ((!isset($_compile_id) || (isset($_filepath[ $_compile_id_part_length ]) && $a =
92
-                                !strncmp($_filepath, $_compile_id_part, $_compile_id_part_length))) &&
93
-                    (!isset($resource_name) || (isset($_filepath[ $_resource_part_1_length ]) &&
94
-                                                substr_compare($_filepath, $_resource_part_1,
95
-                                                               - $_resource_part_1_length, $_resource_part_1_length) ==
96
-                                                0) || (isset($_filepath[ $_resource_part_2_length ]) &&
97
-                                                       substr_compare($_filepath, $_resource_part_2,
98
-                                                                      - $_resource_part_2_length,
99
-                                                                      $_resource_part_2_length) == 0))
100
-                ) {
101
-                    if (isset($exp_time)) {
102
-                        if (time() - @filemtime($_filepath) >= $exp_time) {
103
-                            $unlink = true;
104
-                        }
105
-                    } else {
106
-                        $unlink = true;
107
-                    }
108
-                }
84
+			if ($_file->isDir()) {
85
+				if (!$_compile->isDot()) {
86
+					// delete folder if empty
87
+					@rmdir($_file->getPathname());
88
+				}
89
+			} else {
90
+				$unlink = false;
91
+				if ((!isset($_compile_id) || (isset($_filepath[ $_compile_id_part_length ]) && $a =
92
+								!strncmp($_filepath, $_compile_id_part, $_compile_id_part_length))) &&
93
+					(!isset($resource_name) || (isset($_filepath[ $_resource_part_1_length ]) &&
94
+												substr_compare($_filepath, $_resource_part_1,
95
+															   - $_resource_part_1_length, $_resource_part_1_length) ==
96
+												0) || (isset($_filepath[ $_resource_part_2_length ]) &&
97
+													   substr_compare($_filepath, $_resource_part_2,
98
+																	  - $_resource_part_2_length,
99
+																	  $_resource_part_2_length) == 0))
100
+				) {
101
+					if (isset($exp_time)) {
102
+						if (time() - @filemtime($_filepath) >= $exp_time) {
103
+							$unlink = true;
104
+						}
105
+					} else {
106
+						$unlink = true;
107
+					}
108
+				}
109 109
 
110
-                if ($unlink && @unlink($_filepath)) {
111
-                    $_count ++;
112
-                    if (function_exists('opcache_invalidate') && strlen(ini_get("opcache.restrict_api")) < 1) {
113
-                        opcache_invalidate($_filepath, true);
114
-                    }
115
-                }
116
-            }
117
-        }
118
-        return $_count;
119
-    }
110
+				if ($unlink && @unlink($_filepath)) {
111
+					$_count ++;
112
+					if (function_exists('opcache_invalidate') && strlen(ini_get("opcache.restrict_api")) < 1) {
113
+						opcache_invalidate($_filepath, true);
114
+					}
115
+				}
116
+			}
117
+		}
118
+		return $_count;
119
+	}
120 120
 }
121 121
\ No newline at end of file
Please login to merge, or discard this patch.
Spacing   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -88,12 +88,12 @@  discard block
 block discarded – undo
88 88
                 }
89 89
             } else {
90 90
                 $unlink = false;
91
-                if ((!isset($_compile_id) || (isset($_filepath[ $_compile_id_part_length ]) && $a =
91
+                if ((!isset($_compile_id) || (isset($_filepath[$_compile_id_part_length]) && $a =
92 92
                                 !strncmp($_filepath, $_compile_id_part, $_compile_id_part_length))) &&
93
-                    (!isset($resource_name) || (isset($_filepath[ $_resource_part_1_length ]) &&
93
+                    (!isset($resource_name) || (isset($_filepath[$_resource_part_1_length]) &&
94 94
                                                 substr_compare($_filepath, $_resource_part_1,
95 95
                                                                - $_resource_part_1_length, $_resource_part_1_length) ==
96
-                                                0) || (isset($_filepath[ $_resource_part_2_length ]) &&
96
+                                                0) || (isset($_filepath[$_resource_part_2_length]) &&
97 97
                                                        substr_compare($_filepath, $_resource_part_2,
98 98
                                                                       - $_resource_part_2_length,
99 99
                                                                       $_resource_part_2_length) == 0))
@@ -108,7 +108,7 @@  discard block
 block discarded – undo
108 108
                 }
109 109
 
110 110
                 if ($unlink && @unlink($_filepath)) {
111
-                    $_count ++;
111
+                    $_count++;
112 112
                     if (function_exists('opcache_invalidate') && strlen(ini_get("opcache.restrict_api")) < 1) {
113 113
                         opcache_invalidate($_filepath, true);
114 114
                     }
Please login to merge, or discard this patch.
Braces   +1 added lines, -2 removed lines patch added patch discarded remove patch
@@ -213,8 +213,7 @@
 block discarded – undo
213 213
                 error_reporting($_smarty_old_error_level);
214 214
             }
215 215
             return $result;
216
-        }
217
-        catch (Exception $e) {
216
+        } catch (Exception $e) {
218 217
             while (ob_get_level() > $level) {
219 218
                 ob_end_clean();
220 219
             }
Please login to merge, or discard this patch.
libraries/Smarty/libs/sysplugins/smarty_internal_compile_config_load.php 2 patches
Indentation   +70 added lines, -70 removed lines patch added patch discarded remove patch
@@ -16,83 +16,83 @@
 block discarded – undo
16 16
  */
17 17
 class Smarty_Internal_Compile_Config_Load extends Smarty_Internal_CompileBase
18 18
 {
19
-    /**
20
-     * Attribute definition: Overwrites base class.
21
-     *
22
-     * @var array
23
-     * @see Smarty_Internal_CompileBase
24
-     */
25
-    public $required_attributes = array('file');
19
+	/**
20
+	 * Attribute definition: Overwrites base class.
21
+	 *
22
+	 * @var array
23
+	 * @see Smarty_Internal_CompileBase
24
+	 */
25
+	public $required_attributes = array('file');
26 26
 
27
-    /**
28
-     * Attribute definition: Overwrites base class.
29
-     *
30
-     * @var array
31
-     * @see Smarty_Internal_CompileBase
32
-     */
33
-    public $shorttag_order = array('file', 'section');
27
+	/**
28
+	 * Attribute definition: Overwrites base class.
29
+	 *
30
+	 * @var array
31
+	 * @see Smarty_Internal_CompileBase
32
+	 */
33
+	public $shorttag_order = array('file', 'section');
34 34
 
35
-    /**
36
-     * Attribute definition: Overwrites base class.
37
-     *
38
-     * @var array
39
-     * @see Smarty_Internal_CompileBase
40
-     */
41
-    public $optional_attributes = array('section', 'scope');
35
+	/**
36
+	 * Attribute definition: Overwrites base class.
37
+	 *
38
+	 * @var array
39
+	 * @see Smarty_Internal_CompileBase
40
+	 */
41
+	public $optional_attributes = array('section', 'scope');
42 42
 
43
-    /**
44
-     * Attribute definition: Overwrites base class.
45
-     *
46
-     * @var array
47
-     * @see Smarty_Internal_CompileBase
48
-     */
49
-    public $option_flags = array('nocache', 'noscope');
43
+	/**
44
+	 * Attribute definition: Overwrites base class.
45
+	 *
46
+	 * @var array
47
+	 * @see Smarty_Internal_CompileBase
48
+	 */
49
+	public $option_flags = array('nocache', 'noscope');
50 50
 
51
-    /**
52
-     * Valid scope names
53
-     *
54
-     * @var array
55
-     */
56
-    public $valid_scopes = array('local' => Smarty::SCOPE_LOCAL, 'parent' => Smarty::SCOPE_PARENT,
57
-                                 'root' => Smarty::SCOPE_ROOT, 'tpl_root' => Smarty::SCOPE_TPL_ROOT,
58
-                                 'smarty' => Smarty::SCOPE_SMARTY);
51
+	/**
52
+	 * Valid scope names
53
+	 *
54
+	 * @var array
55
+	 */
56
+	public $valid_scopes = array('local' => Smarty::SCOPE_LOCAL, 'parent' => Smarty::SCOPE_PARENT,
57
+								 'root' => Smarty::SCOPE_ROOT, 'tpl_root' => Smarty::SCOPE_TPL_ROOT,
58
+								 'smarty' => Smarty::SCOPE_SMARTY);
59 59
 
60
-    /**
61
-     * Compiles code for the {config_load} tag
62
-     *
63
-     * @param  array                                $args     array with attributes from parser
64
-     * @param \Smarty_Internal_TemplateCompilerBase $compiler compiler object
65
-     *
66
-     * @return string compiled code
67
-     * @throws \SmartyCompilerException
68
-     */
69
-    public function compile($args, Smarty_Internal_TemplateCompilerBase $compiler)
70
-    {
71
-        // check and get attributes
72
-        $_attr = $this->getAttributes($compiler, $args);
60
+	/**
61
+	 * Compiles code for the {config_load} tag
62
+	 *
63
+	 * @param  array                                $args     array with attributes from parser
64
+	 * @param \Smarty_Internal_TemplateCompilerBase $compiler compiler object
65
+	 *
66
+	 * @return string compiled code
67
+	 * @throws \SmartyCompilerException
68
+	 */
69
+	public function compile($args, Smarty_Internal_TemplateCompilerBase $compiler)
70
+	{
71
+		// check and get attributes
72
+		$_attr = $this->getAttributes($compiler, $args);
73 73
 
74
-        if ($_attr[ 'nocache' ] === true) {
75
-            $compiler->trigger_template_error('nocache option not allowed', null, true);
76
-        }
74
+		if ($_attr[ 'nocache' ] === true) {
75
+			$compiler->trigger_template_error('nocache option not allowed', null, true);
76
+		}
77 77
 
78
-        // save possible attributes
79
-        $conf_file = $_attr[ 'file' ];
80
-        if (isset($_attr[ 'section' ])) {
81
-            $section = $_attr[ 'section' ];
82
-        } else {
83
-            $section = 'null';
84
-        }
85
-        // scope setup
86
-        if ($_attr[ 'noscope' ]) {
87
-            $_scope = - 1;
88
-        } else {
89
-            $_scope = $compiler->convertScope($_attr, $this->valid_scopes);
90
-        }
78
+		// save possible attributes
79
+		$conf_file = $_attr[ 'file' ];
80
+		if (isset($_attr[ 'section' ])) {
81
+			$section = $_attr[ 'section' ];
82
+		} else {
83
+			$section = 'null';
84
+		}
85
+		// scope setup
86
+		if ($_attr[ 'noscope' ]) {
87
+			$_scope = - 1;
88
+		} else {
89
+			$_scope = $compiler->convertScope($_attr, $this->valid_scopes);
90
+		}
91 91
 
92
-        // create config object
93
-        $_output =
94
-            "<?php\n\$_smarty_tpl->smarty->ext->configLoad->_loadConfigFile(\$_smarty_tpl, {$conf_file}, {$section}, {$_scope});\n?>\n";
92
+		// create config object
93
+		$_output =
94
+			"<?php\n\$_smarty_tpl->smarty->ext->configLoad->_loadConfigFile(\$_smarty_tpl, {$conf_file}, {$section}, {$_scope});\n?>\n";
95 95
 
96
-        return $_output;
97
-    }
96
+		return $_output;
97
+	}
98 98
 }
Please login to merge, or discard this patch.
Spacing   +5 added lines, -5 removed lines patch added patch discarded remove patch
@@ -71,19 +71,19 @@
 block discarded – undo
71 71
         // check and get attributes
72 72
         $_attr = $this->getAttributes($compiler, $args);
73 73
 
74
-        if ($_attr[ 'nocache' ] === true) {
74
+        if ($_attr['nocache'] === true) {
75 75
             $compiler->trigger_template_error('nocache option not allowed', null, true);
76 76
         }
77 77
 
78 78
         // save possible attributes
79
-        $conf_file = $_attr[ 'file' ];
80
-        if (isset($_attr[ 'section' ])) {
81
-            $section = $_attr[ 'section' ];
79
+        $conf_file = $_attr['file'];
80
+        if (isset($_attr['section'])) {
81
+            $section = $_attr['section'];
82 82
         } else {
83 83
             $section = 'null';
84 84
         }
85 85
         // scope setup
86
-        if ($_attr[ 'noscope' ]) {
86
+        if ($_attr['noscope']) {
87 87
             $_scope = - 1;
88 88
         } else {
89 89
             $_scope = $compiler->convertScope($_attr, $this->valid_scopes);
Please login to merge, or discard this patch.