Completed
Pull Request — master (#56)
by David
05:43
created
lib/Dwoo/Plugins/Blocks/PluginCapture.php 2 patches
Indentation   +46 added lines, -46 removed lines patch added patch discarded remove patch
@@ -42,54 +42,54 @@
 block discarded – undo
42 42
  */
43 43
 class PluginCapture extends BlockPlugin implements ICompilableBlock
44 44
 {
45
-    /**
46
-     * @param string $name
47
-     * @param null   $assign
48
-     * @param bool   $cat
49
-     * @param bool   $trim
50
-     */
51
-    public function init($name = 'default', $assign = null, $cat = false, $trim = false)
52
-    {
53
-    }
45
+	/**
46
+	 * @param string $name
47
+	 * @param null   $assign
48
+	 * @param bool   $cat
49
+	 * @param bool   $trim
50
+	 */
51
+	public function init($name = 'default', $assign = null, $cat = false, $trim = false)
52
+	{
53
+	}
54 54
 
55
-    /**
56
-     * @param Compiler $compiler
57
-     * @param array    $params
58
-     * @param string   $prepend
59
-     * @param string   $append
60
-     * @param string   $type
61
-     *
62
-     * @return string
63
-     */
64
-    public static function preProcessing(Compiler $compiler, array $params, $prepend, $append, $type)
65
-    {
66
-        return Compiler::PHP_OPEN . $prepend . 'ob_start();' . $append . Compiler::PHP_CLOSE;
67
-    }
55
+	/**
56
+	 * @param Compiler $compiler
57
+	 * @param array    $params
58
+	 * @param string   $prepend
59
+	 * @param string   $append
60
+	 * @param string   $type
61
+	 *
62
+	 * @return string
63
+	 */
64
+	public static function preProcessing(Compiler $compiler, array $params, $prepend, $append, $type)
65
+	{
66
+		return Compiler::PHP_OPEN . $prepend . 'ob_start();' . $append . Compiler::PHP_CLOSE;
67
+	}
68 68
 
69
-    /**
70
-     * @param Compiler $compiler
71
-     * @param array    $params
72
-     * @param string   $prepend
73
-     * @param string   $append
74
-     * @param string   $content
75
-     *
76
-     * @return string
77
-     */
78
-    public static function postProcessing(Compiler $compiler, array $params, $prepend, $append, $content)
79
-    {
80
-        $params = $compiler->getCompiledParams($params);
69
+	/**
70
+	 * @param Compiler $compiler
71
+	 * @param array    $params
72
+	 * @param string   $prepend
73
+	 * @param string   $append
74
+	 * @param string   $content
75
+	 *
76
+	 * @return string
77
+	 */
78
+	public static function postProcessing(Compiler $compiler, array $params, $prepend, $append, $content)
79
+	{
80
+		$params = $compiler->getCompiledParams($params);
81 81
 
82
-        $out = $content . Compiler::PHP_OPEN . $prepend . "\n" . '$tmp = ob_get_clean();';
83
-        if ($params['trim'] !== 'false' && $params['trim'] !== 0) {
84
-            $out .= "\n" . '$tmp = trim($tmp);';
85
-        }
86
-        if ($params['cat'] === 'true' || $params['cat'] === 1) {
87
-            $out .= "\n" . '$tmp = $this->readVar(\'dwoo.capture.\'.' . $params['name'] . ') . $tmp;';
88
-        }
89
-        if ($params['assign'] !== 'null') {
90
-            $out .= "\n" . '$this->scope[' . $params['assign'] . '] = $tmp;';
91
-        }
82
+		$out = $content . Compiler::PHP_OPEN . $prepend . "\n" . '$tmp = ob_get_clean();';
83
+		if ($params['trim'] !== 'false' && $params['trim'] !== 0) {
84
+			$out .= "\n" . '$tmp = trim($tmp);';
85
+		}
86
+		if ($params['cat'] === 'true' || $params['cat'] === 1) {
87
+			$out .= "\n" . '$tmp = $this->readVar(\'dwoo.capture.\'.' . $params['name'] . ') . $tmp;';
88
+		}
89
+		if ($params['assign'] !== 'null') {
90
+			$out .= "\n" . '$this->scope[' . $params['assign'] . '] = $tmp;';
91
+		}
92 92
 
93
-        return $out . "\n" . '$this->globals[\'capture\'][' . $params['name'] . '] = $tmp;' . $append . Compiler::PHP_CLOSE;
94
-    }
93
+		return $out . "\n" . '$this->globals[\'capture\'][' . $params['name'] . '] = $tmp;' . $append . Compiler::PHP_CLOSE;
94
+	}
95 95
 }
Please login to merge, or discard this patch.
Spacing   +6 added lines, -6 removed lines patch added patch discarded remove patch
@@ -63,7 +63,7 @@  discard block
 block discarded – undo
63 63
      */
64 64
     public static function preProcessing(Compiler $compiler, array $params, $prepend, $append, $type)
65 65
     {
66
-        return Compiler::PHP_OPEN . $prepend . 'ob_start();' . $append . Compiler::PHP_CLOSE;
66
+        return Compiler::PHP_OPEN.$prepend.'ob_start();'.$append.Compiler::PHP_CLOSE;
67 67
     }
68 68
 
69 69
     /**
@@ -79,17 +79,17 @@  discard block
 block discarded – undo
79 79
     {
80 80
         $params = $compiler->getCompiledParams($params);
81 81
 
82
-        $out = $content . Compiler::PHP_OPEN . $prepend . "\n" . '$tmp = ob_get_clean();';
82
+        $out = $content.Compiler::PHP_OPEN.$prepend."\n".'$tmp = ob_get_clean();';
83 83
         if ($params['trim'] !== 'false' && $params['trim'] !== 0) {
84
-            $out .= "\n" . '$tmp = trim($tmp);';
84
+            $out .= "\n".'$tmp = trim($tmp);';
85 85
         }
86 86
         if ($params['cat'] === 'true' || $params['cat'] === 1) {
87
-            $out .= "\n" . '$tmp = $this->readVar(\'dwoo.capture.\'.' . $params['name'] . ') . $tmp;';
87
+            $out .= "\n".'$tmp = $this->readVar(\'dwoo.capture.\'.'.$params['name'].') . $tmp;';
88 88
         }
89 89
         if ($params['assign'] !== 'null') {
90
-            $out .= "\n" . '$this->scope[' . $params['assign'] . '] = $tmp;';
90
+            $out .= "\n".'$this->scope['.$params['assign'].'] = $tmp;';
91 91
         }
92 92
 
93
-        return $out . "\n" . '$this->globals[\'capture\'][' . $params['name'] . '] = $tmp;' . $append . Compiler::PHP_CLOSE;
93
+        return $out."\n".'$this->globals[\'capture\']['.$params['name'].'] = $tmp;'.$append.Compiler::PHP_CLOSE;
94 94
     }
95 95
 }
Please login to merge, or discard this patch.
lib/Dwoo/Plugins/Blocks/PluginElseif.php 2 patches
Indentation   +55 added lines, -55 removed lines patch added patch discarded remove patch
@@ -28,68 +28,68 @@
 block discarded – undo
28 28
  */
29 29
 class PluginElseif extends PluginIf implements ICompilableBlock, IElseable
30 30
 {
31
-    /**
32
-     * @param array $rest
33
-     */
34
-    public function init(array $rest)
35
-    {
36
-    }
31
+	/**
32
+	 * @param array $rest
33
+	 */
34
+	public function init(array $rest)
35
+	{
36
+	}
37 37
 
38
-    /**
39
-     * @param Compiler $compiler
40
-     * @param array    $params
41
-     * @param string   $prepend
42
-     * @param string   $append
43
-     * @param string   $type
44
-     *
45
-     * @return string
46
-     */
47
-    public static function preProcessing(Compiler $compiler, array $params, $prepend, $append, $type)
48
-    {
49
-        $preContent = '';
50
-        while (true) {
51
-            $preContent .= $compiler->removeTopBlock();
52
-            $block      = &$compiler->getCurrentBlock();
53
-            $interfaces = class_implements($block['class']);
54
-            if (in_array('Dwoo\IElseable', $interfaces) !== false) {
55
-                break;
56
-            }
57
-        }
38
+	/**
39
+	 * @param Compiler $compiler
40
+	 * @param array    $params
41
+	 * @param string   $prepend
42
+	 * @param string   $append
43
+	 * @param string   $type
44
+	 *
45
+	 * @return string
46
+	 */
47
+	public static function preProcessing(Compiler $compiler, array $params, $prepend, $append, $type)
48
+	{
49
+		$preContent = '';
50
+		while (true) {
51
+			$preContent .= $compiler->removeTopBlock();
52
+			$block      = &$compiler->getCurrentBlock();
53
+			$interfaces = class_implements($block['class']);
54
+			if (in_array('Dwoo\IElseable', $interfaces) !== false) {
55
+				break;
56
+			}
57
+		}
58 58
 
59
-        $params['initialized'] = true;
60
-        $compiler->injectBlock($type, $params);
59
+		$params['initialized'] = true;
60
+		$compiler->injectBlock($type, $params);
61 61
 
62
-        return $preContent;
63
-    }
62
+		return $preContent;
63
+	}
64 64
 
65
-    /**
66
-     * @param Compiler $compiler
67
-     * @param array    $params
68
-     * @param string   $prepend
69
-     * @param string   $append
70
-     * @param string   $content
71
-     *
72
-     * @return string
73
-     */
74
-    public static function postProcessing(Compiler $compiler, array $params, $prepend, $append, $content)
75
-    {
76
-        if (!isset($params['initialized'])) {
77
-            return '';
78
-        }
65
+	/**
66
+	 * @param Compiler $compiler
67
+	 * @param array    $params
68
+	 * @param string   $prepend
69
+	 * @param string   $append
70
+	 * @param string   $content
71
+	 *
72
+	 * @return string
73
+	 */
74
+	public static function postProcessing(Compiler $compiler, array $params, $prepend, $append, $content)
75
+	{
76
+		if (!isset($params['initialized'])) {
77
+			return '';
78
+		}
79 79
 
80
-        $tokens = $compiler->getParamTokens($params);
81
-        $params = $compiler->getCompiledParams($params);
80
+		$tokens = $compiler->getParamTokens($params);
81
+		$params = $compiler->getCompiledParams($params);
82 82
 
83
-        $pre  = Compiler::PHP_OPEN . 'elseif (' . implode(' ', self::replaceKeywords($params['*'], $tokens['*'], $compiler)) . ") {\n" . Compiler::PHP_CLOSE;
84
-        $post = Compiler::PHP_OPEN . "\n}" . Compiler::PHP_CLOSE;
83
+		$pre  = Compiler::PHP_OPEN . 'elseif (' . implode(' ', self::replaceKeywords($params['*'], $tokens['*'], $compiler)) . ") {\n" . Compiler::PHP_CLOSE;
84
+		$post = Compiler::PHP_OPEN . "\n}" . Compiler::PHP_CLOSE;
85 85
 
86
-        if (isset($params['hasElse'])) {
87
-            $post .= $params['hasElse'];
88
-        }
86
+		if (isset($params['hasElse'])) {
87
+			$post .= $params['hasElse'];
88
+		}
89 89
 
90
-        $block                      = &$compiler->getCurrentBlock();
91
-        $block['params']['hasElse'] = $pre . $content . $post;
90
+		$block                      = &$compiler->getCurrentBlock();
91
+		$block['params']['hasElse'] = $pre . $content . $post;
92 92
 
93
-        return '';
94
-    }
93
+		return '';
94
+	}
95 95
 }
Please login to merge, or discard this patch.
Spacing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -80,15 +80,15 @@
 block discarded – undo
80 80
         $tokens = $compiler->getParamTokens($params);
81 81
         $params = $compiler->getCompiledParams($params);
82 82
 
83
-        $pre  = Compiler::PHP_OPEN . 'elseif (' . implode(' ', self::replaceKeywords($params['*'], $tokens['*'], $compiler)) . ") {\n" . Compiler::PHP_CLOSE;
84
-        $post = Compiler::PHP_OPEN . "\n}" . Compiler::PHP_CLOSE;
83
+        $pre  = Compiler::PHP_OPEN.'elseif ('.implode(' ', self::replaceKeywords($params['*'], $tokens['*'], $compiler)).") {\n".Compiler::PHP_CLOSE;
84
+        $post = Compiler::PHP_OPEN."\n}".Compiler::PHP_CLOSE;
85 85
 
86 86
         if (isset($params['hasElse'])) {
87 87
             $post .= $params['hasElse'];
88 88
         }
89 89
 
90 90
         $block                      = &$compiler->getCurrentBlock();
91
-        $block['params']['hasElse'] = $pre . $content . $post;
91
+        $block['params']['hasElse'] = $pre.$content.$post;
92 92
 
93 93
         return '';
94 94
     }
Please login to merge, or discard this patch.
lib/Dwoo/Plugins/Blocks/PluginForeach.php 2 patches
Indentation   +155 added lines, -155 removed lines patch added patch discarded remove patch
@@ -43,159 +43,159 @@
 block discarded – undo
43 43
  */
44 44
 class PluginForeach extends BlockPlugin implements ICompilableBlock, IElseable
45 45
 {
46
-    public static $cnt = 0;
47
-
48
-    /**
49
-     * @param        $from
50
-     * @param null   $key
51
-     * @param null   $item
52
-     * @param string $name
53
-     * @param null   $implode
54
-     */
55
-    public function init($from, $key = null, $item = null, $name = 'default', $implode = null)
56
-    {
57
-    }
58
-
59
-    /**
60
-     * @param Compiler $compiler
61
-     * @param array    $params
62
-     * @param string   $prepend
63
-     * @param string   $append
64
-     * @param string   $type
65
-     *
66
-     * @return string
67
-     */
68
-    public static function preProcessing(Compiler $compiler, array $params, $prepend, $append, $type)
69
-    {
70
-        // get block params and save the current template pointer to use it in the postProcessing method
71
-        $currentBlock                         = &$compiler->getCurrentBlock();
72
-        $currentBlock['params']['tplPointer'] = $compiler->getPointer();
73
-
74
-        return '';
75
-    }
76
-
77
-    /**
78
-     * @param Compiler $compiler
79
-     * @param array    $params
80
-     * @param string   $prepend
81
-     * @param string   $append
82
-     * @param string   $content
83
-     *
84
-     * @return string
85
-     * @throws CompilationException
86
-     */
87
-    public static function postProcessing(Compiler $compiler, array $params, $prepend, $append, $content)
88
-    {
89
-        $params = $compiler->getCompiledParams($params);
90
-        $tpl    = $compiler->getTemplateSource($params['tplPointer']);
91
-
92
-        // assigns params
93
-        $src = $params['from'];
94
-
95
-        if ($params['item'] !== 'null') {
96
-            if ($params['key'] !== 'null') {
97
-                $key = $params['key'];
98
-            }
99
-            $val = $params['item'];
100
-        } elseif ($params['key'] !== 'null') {
101
-            $val = $params['key'];
102
-        } else {
103
-            throw new CompilationException($compiler, 'Foreach <em>item</em> parameter missing');
104
-        }
105
-        $name = $params['name'];
106
-
107
-        if (substr($val, 0, 1) !== '"' && substr($val, 0, 1) !== '\'') {
108
-            throw new CompilationException($compiler, 'Foreach <em>item</em> parameter must be of type string');
109
-        }
110
-        if (isset($key) && substr($val, 0, 1) !== '"' && substr($val, 0, 1) !== '\'') {
111
-            throw new CompilationException($compiler, 'Foreach <em>key</em> parameter must be of type string');
112
-        }
113
-
114
-        // evaluates which global variables have to be computed
115
-        $varName       = '$dwoo.foreach.' . trim($name, '"\'') . '.';
116
-        $shortVarName  = '$.foreach.' . trim($name, '"\'') . '.';
117
-        $usesAny       = strpos($tpl, $varName) !== false || strpos($tpl, $shortVarName) !== false;
118
-        $usesFirst     = strpos($tpl, $varName . 'first') !== false || strpos($tpl, $shortVarName . 'first') !== false;
119
-        $usesLast      = strpos($tpl, $varName . 'last') !== false || strpos($tpl, $shortVarName . 'last') !== false;
120
-        $usesIndex     = $usesFirst || strpos($tpl, $varName . 'index') !== false || strpos($tpl, $shortVarName . 'index') !== false;
121
-        $usesIteration = $usesLast || strpos($tpl, $varName . 'iteration') !== false || strpos($tpl, $shortVarName . 'iteration') !== false;
122
-        $usesShow      = strpos($tpl, $varName . 'show') !== false || strpos($tpl, $shortVarName . 'show') !== false;
123
-        $usesTotal     = $usesLast || strpos($tpl, $varName . 'total') !== false || strpos($tpl, $shortVarName . 'total') !== false;
124
-
125
-        if (strpos($name, '$this->scope[') !== false) {
126
-            $usesAny = $usesFirst = $usesLast = $usesIndex = $usesIteration = $usesShow = $usesTotal = true;
127
-        }
128
-
129
-        // override globals vars if implode is used
130
-        if ($params['implode'] !== 'null') {
131
-            $implode       = $params['implode'];
132
-            $usesAny       = true;
133
-            $usesLast      = true;
134
-            $usesIteration = true;
135
-            $usesTotal     = true;
136
-        }
137
-
138
-        // gets foreach id
139
-        $cnt = self::$cnt ++;
140
-
141
-        // build pre content output
142
-        $pre = Compiler::PHP_OPEN . "\n" . '$_fh' . $cnt . '_data = ' . $src . ';';
143
-        // adds foreach properties
144
-        if ($usesAny) {
145
-            $pre .= "\n" . '$this->globals["foreach"][' . $name . '] = array' . "\n(";
146
-            if ($usesIndex) {
147
-                $pre .= "\n\t" . '"index"		=> 0,';
148
-            }
149
-            if ($usesIteration) {
150
-                $pre .= "\n\t" . '"iteration"		=> 1,';
151
-            }
152
-            if ($usesFirst) {
153
-                $pre .= "\n\t" . '"first"		=> null,';
154
-            }
155
-            if ($usesLast) {
156
-                $pre .= "\n\t" . '"last"		=> null,';
157
-            }
158
-            if ($usesShow) {
159
-                $pre .= "\n\t" . '"show"		=> $this->isArray($_fh' . $cnt . '_data, true),';
160
-            }
161
-            if ($usesTotal) {
162
-                $pre .= "\n\t" . '"total"		=> $this->count($_fh' . $cnt . '_data),';
163
-            }
164
-            $pre .= "\n);\n" . '$_fh' . $cnt . '_glob =& $this->globals["foreach"][' . $name . '];';
165
-        }
166
-        // checks if foreach must be looped
167
-        $pre .= "\n" . 'if ($this->isTraversable($_fh' . $cnt . '_data' . (isset($params['hasElse']) ? ', true' : '') . ') == true)' . "\n{";
168
-        // iterates over keys
169
-        $pre .= "\n\t" . 'foreach ($_fh' . $cnt . '_data as ' . (isset($key) ? '$this->scope[' . $key . ']=>' : '') . '$this->scope[' . $val . '])' . "\n\t{";
170
-        // updates properties
171
-        if ($usesFirst) {
172
-            $pre .= "\n\t\t" . '$_fh' . $cnt . '_glob["first"] = (string) ($_fh' . $cnt . '_glob["index"] === 0);';
173
-        }
174
-        if ($usesLast) {
175
-            $pre .= "\n\t\t" . '$_fh' . $cnt . '_glob["last"] = (string) ($_fh' . $cnt . '_glob["iteration"] === $_fh' . $cnt . '_glob["total"]);';
176
-        }
177
-        $pre .= "\n/* -- foreach start output */\n" . Compiler::PHP_CLOSE;
178
-
179
-        // build post content output
180
-        $post = Compiler::PHP_OPEN . "\n";
181
-
182
-        if (isset($implode)) {
183
-            $post .= '/* -- implode */' . "\n" . 'if (!$_fh' . $cnt . '_glob["last"]) {' . "\n\t" . 'echo ' . $implode . ";\n}\n";
184
-        }
185
-        $post .= '/* -- foreach end output */';
186
-        // update properties
187
-        if ($usesIndex) {
188
-            $post .= "\n\t\t" . '$_fh' . $cnt . '_glob["index"]+=1;';
189
-        }
190
-        if ($usesIteration) {
191
-            $post .= "\n\t\t" . '$_fh' . $cnt . '_glob["iteration"]+=1;';
192
-        }
193
-        // end loop
194
-        $post .= "\n\t}\n}" . Compiler::PHP_CLOSE;
195
-        if (isset($params['hasElse'])) {
196
-            $post .= $params['hasElse'];
197
-        }
198
-
199
-        return $pre . $content . $post;
200
-    }
46
+	public static $cnt = 0;
47
+
48
+	/**
49
+	 * @param        $from
50
+	 * @param null   $key
51
+	 * @param null   $item
52
+	 * @param string $name
53
+	 * @param null   $implode
54
+	 */
55
+	public function init($from, $key = null, $item = null, $name = 'default', $implode = null)
56
+	{
57
+	}
58
+
59
+	/**
60
+	 * @param Compiler $compiler
61
+	 * @param array    $params
62
+	 * @param string   $prepend
63
+	 * @param string   $append
64
+	 * @param string   $type
65
+	 *
66
+	 * @return string
67
+	 */
68
+	public static function preProcessing(Compiler $compiler, array $params, $prepend, $append, $type)
69
+	{
70
+		// get block params and save the current template pointer to use it in the postProcessing method
71
+		$currentBlock                         = &$compiler->getCurrentBlock();
72
+		$currentBlock['params']['tplPointer'] = $compiler->getPointer();
73
+
74
+		return '';
75
+	}
76
+
77
+	/**
78
+	 * @param Compiler $compiler
79
+	 * @param array    $params
80
+	 * @param string   $prepend
81
+	 * @param string   $append
82
+	 * @param string   $content
83
+	 *
84
+	 * @return string
85
+	 * @throws CompilationException
86
+	 */
87
+	public static function postProcessing(Compiler $compiler, array $params, $prepend, $append, $content)
88
+	{
89
+		$params = $compiler->getCompiledParams($params);
90
+		$tpl    = $compiler->getTemplateSource($params['tplPointer']);
91
+
92
+		// assigns params
93
+		$src = $params['from'];
94
+
95
+		if ($params['item'] !== 'null') {
96
+			if ($params['key'] !== 'null') {
97
+				$key = $params['key'];
98
+			}
99
+			$val = $params['item'];
100
+		} elseif ($params['key'] !== 'null') {
101
+			$val = $params['key'];
102
+		} else {
103
+			throw new CompilationException($compiler, 'Foreach <em>item</em> parameter missing');
104
+		}
105
+		$name = $params['name'];
106
+
107
+		if (substr($val, 0, 1) !== '"' && substr($val, 0, 1) !== '\'') {
108
+			throw new CompilationException($compiler, 'Foreach <em>item</em> parameter must be of type string');
109
+		}
110
+		if (isset($key) && substr($val, 0, 1) !== '"' && substr($val, 0, 1) !== '\'') {
111
+			throw new CompilationException($compiler, 'Foreach <em>key</em> parameter must be of type string');
112
+		}
113
+
114
+		// evaluates which global variables have to be computed
115
+		$varName       = '$dwoo.foreach.' . trim($name, '"\'') . '.';
116
+		$shortVarName  = '$.foreach.' . trim($name, '"\'') . '.';
117
+		$usesAny       = strpos($tpl, $varName) !== false || strpos($tpl, $shortVarName) !== false;
118
+		$usesFirst     = strpos($tpl, $varName . 'first') !== false || strpos($tpl, $shortVarName . 'first') !== false;
119
+		$usesLast      = strpos($tpl, $varName . 'last') !== false || strpos($tpl, $shortVarName . 'last') !== false;
120
+		$usesIndex     = $usesFirst || strpos($tpl, $varName . 'index') !== false || strpos($tpl, $shortVarName . 'index') !== false;
121
+		$usesIteration = $usesLast || strpos($tpl, $varName . 'iteration') !== false || strpos($tpl, $shortVarName . 'iteration') !== false;
122
+		$usesShow      = strpos($tpl, $varName . 'show') !== false || strpos($tpl, $shortVarName . 'show') !== false;
123
+		$usesTotal     = $usesLast || strpos($tpl, $varName . 'total') !== false || strpos($tpl, $shortVarName . 'total') !== false;
124
+
125
+		if (strpos($name, '$this->scope[') !== false) {
126
+			$usesAny = $usesFirst = $usesLast = $usesIndex = $usesIteration = $usesShow = $usesTotal = true;
127
+		}
128
+
129
+		// override globals vars if implode is used
130
+		if ($params['implode'] !== 'null') {
131
+			$implode       = $params['implode'];
132
+			$usesAny       = true;
133
+			$usesLast      = true;
134
+			$usesIteration = true;
135
+			$usesTotal     = true;
136
+		}
137
+
138
+		// gets foreach id
139
+		$cnt = self::$cnt ++;
140
+
141
+		// build pre content output
142
+		$pre = Compiler::PHP_OPEN . "\n" . '$_fh' . $cnt . '_data = ' . $src . ';';
143
+		// adds foreach properties
144
+		if ($usesAny) {
145
+			$pre .= "\n" . '$this->globals["foreach"][' . $name . '] = array' . "\n(";
146
+			if ($usesIndex) {
147
+				$pre .= "\n\t" . '"index"		=> 0,';
148
+			}
149
+			if ($usesIteration) {
150
+				$pre .= "\n\t" . '"iteration"		=> 1,';
151
+			}
152
+			if ($usesFirst) {
153
+				$pre .= "\n\t" . '"first"		=> null,';
154
+			}
155
+			if ($usesLast) {
156
+				$pre .= "\n\t" . '"last"		=> null,';
157
+			}
158
+			if ($usesShow) {
159
+				$pre .= "\n\t" . '"show"		=> $this->isArray($_fh' . $cnt . '_data, true),';
160
+			}
161
+			if ($usesTotal) {
162
+				$pre .= "\n\t" . '"total"		=> $this->count($_fh' . $cnt . '_data),';
163
+			}
164
+			$pre .= "\n);\n" . '$_fh' . $cnt . '_glob =& $this->globals["foreach"][' . $name . '];';
165
+		}
166
+		// checks if foreach must be looped
167
+		$pre .= "\n" . 'if ($this->isTraversable($_fh' . $cnt . '_data' . (isset($params['hasElse']) ? ', true' : '') . ') == true)' . "\n{";
168
+		// iterates over keys
169
+		$pre .= "\n\t" . 'foreach ($_fh' . $cnt . '_data as ' . (isset($key) ? '$this->scope[' . $key . ']=>' : '') . '$this->scope[' . $val . '])' . "\n\t{";
170
+		// updates properties
171
+		if ($usesFirst) {
172
+			$pre .= "\n\t\t" . '$_fh' . $cnt . '_glob["first"] = (string) ($_fh' . $cnt . '_glob["index"] === 0);';
173
+		}
174
+		if ($usesLast) {
175
+			$pre .= "\n\t\t" . '$_fh' . $cnt . '_glob["last"] = (string) ($_fh' . $cnt . '_glob["iteration"] === $_fh' . $cnt . '_glob["total"]);';
176
+		}
177
+		$pre .= "\n/* -- foreach start output */\n" . Compiler::PHP_CLOSE;
178
+
179
+		// build post content output
180
+		$post = Compiler::PHP_OPEN . "\n";
181
+
182
+		if (isset($implode)) {
183
+			$post .= '/* -- implode */' . "\n" . 'if (!$_fh' . $cnt . '_glob["last"]) {' . "\n\t" . 'echo ' . $implode . ";\n}\n";
184
+		}
185
+		$post .= '/* -- foreach end output */';
186
+		// update properties
187
+		if ($usesIndex) {
188
+			$post .= "\n\t\t" . '$_fh' . $cnt . '_glob["index"]+=1;';
189
+		}
190
+		if ($usesIteration) {
191
+			$post .= "\n\t\t" . '$_fh' . $cnt . '_glob["iteration"]+=1;';
192
+		}
193
+		// end loop
194
+		$post .= "\n\t}\n}" . Compiler::PHP_CLOSE;
195
+		if (isset($params['hasElse'])) {
196
+			$post .= $params['hasElse'];
197
+		}
198
+
199
+		return $pre . $content . $post;
200
+	}
201 201
 }
Please login to merge, or discard this patch.
Spacing   +29 added lines, -29 removed lines patch added patch discarded remove patch
@@ -112,15 +112,15 @@  discard block
 block discarded – undo
112 112
         }
113 113
 
114 114
         // evaluates which global variables have to be computed
115
-        $varName       = '$dwoo.foreach.' . trim($name, '"\'') . '.';
116
-        $shortVarName  = '$.foreach.' . trim($name, '"\'') . '.';
115
+        $varName       = '$dwoo.foreach.'.trim($name, '"\'').'.';
116
+        $shortVarName  = '$.foreach.'.trim($name, '"\'').'.';
117 117
         $usesAny       = strpos($tpl, $varName) !== false || strpos($tpl, $shortVarName) !== false;
118
-        $usesFirst     = strpos($tpl, $varName . 'first') !== false || strpos($tpl, $shortVarName . 'first') !== false;
119
-        $usesLast      = strpos($tpl, $varName . 'last') !== false || strpos($tpl, $shortVarName . 'last') !== false;
120
-        $usesIndex     = $usesFirst || strpos($tpl, $varName . 'index') !== false || strpos($tpl, $shortVarName . 'index') !== false;
121
-        $usesIteration = $usesLast || strpos($tpl, $varName . 'iteration') !== false || strpos($tpl, $shortVarName . 'iteration') !== false;
122
-        $usesShow      = strpos($tpl, $varName . 'show') !== false || strpos($tpl, $shortVarName . 'show') !== false;
123
-        $usesTotal     = $usesLast || strpos($tpl, $varName . 'total') !== false || strpos($tpl, $shortVarName . 'total') !== false;
118
+        $usesFirst     = strpos($tpl, $varName.'first') !== false || strpos($tpl, $shortVarName.'first') !== false;
119
+        $usesLast      = strpos($tpl, $varName.'last') !== false || strpos($tpl, $shortVarName.'last') !== false;
120
+        $usesIndex     = $usesFirst || strpos($tpl, $varName.'index') !== false || strpos($tpl, $shortVarName.'index') !== false;
121
+        $usesIteration = $usesLast || strpos($tpl, $varName.'iteration') !== false || strpos($tpl, $shortVarName.'iteration') !== false;
122
+        $usesShow      = strpos($tpl, $varName.'show') !== false || strpos($tpl, $shortVarName.'show') !== false;
123
+        $usesTotal     = $usesLast || strpos($tpl, $varName.'total') !== false || strpos($tpl, $shortVarName.'total') !== false;
124 124
 
125 125
         if (strpos($name, '$this->scope[') !== false) {
126 126
             $usesAny = $usesFirst = $usesLast = $usesIndex = $usesIteration = $usesShow = $usesTotal = true;
@@ -136,66 +136,66 @@  discard block
 block discarded – undo
136 136
         }
137 137
 
138 138
         // gets foreach id
139
-        $cnt = self::$cnt ++;
139
+        $cnt = self::$cnt++;
140 140
 
141 141
         // build pre content output
142
-        $pre = Compiler::PHP_OPEN . "\n" . '$_fh' . $cnt . '_data = ' . $src . ';';
142
+        $pre = Compiler::PHP_OPEN."\n".'$_fh'.$cnt.'_data = '.$src.';';
143 143
         // adds foreach properties
144 144
         if ($usesAny) {
145
-            $pre .= "\n" . '$this->globals["foreach"][' . $name . '] = array' . "\n(";
145
+            $pre .= "\n".'$this->globals["foreach"]['.$name.'] = array'."\n(";
146 146
             if ($usesIndex) {
147
-                $pre .= "\n\t" . '"index"		=> 0,';
147
+                $pre .= "\n\t".'"index"		=> 0,';
148 148
             }
149 149
             if ($usesIteration) {
150
-                $pre .= "\n\t" . '"iteration"		=> 1,';
150
+                $pre .= "\n\t".'"iteration"		=> 1,';
151 151
             }
152 152
             if ($usesFirst) {
153
-                $pre .= "\n\t" . '"first"		=> null,';
153
+                $pre .= "\n\t".'"first"		=> null,';
154 154
             }
155 155
             if ($usesLast) {
156
-                $pre .= "\n\t" . '"last"		=> null,';
156
+                $pre .= "\n\t".'"last"		=> null,';
157 157
             }
158 158
             if ($usesShow) {
159
-                $pre .= "\n\t" . '"show"		=> $this->isArray($_fh' . $cnt . '_data, true),';
159
+                $pre .= "\n\t".'"show"		=> $this->isArray($_fh'.$cnt.'_data, true),';
160 160
             }
161 161
             if ($usesTotal) {
162
-                $pre .= "\n\t" . '"total"		=> $this->count($_fh' . $cnt . '_data),';
162
+                $pre .= "\n\t".'"total"		=> $this->count($_fh'.$cnt.'_data),';
163 163
             }
164
-            $pre .= "\n);\n" . '$_fh' . $cnt . '_glob =& $this->globals["foreach"][' . $name . '];';
164
+            $pre .= "\n);\n".'$_fh'.$cnt.'_glob =& $this->globals["foreach"]['.$name.'];';
165 165
         }
166 166
         // checks if foreach must be looped
167
-        $pre .= "\n" . 'if ($this->isTraversable($_fh' . $cnt . '_data' . (isset($params['hasElse']) ? ', true' : '') . ') == true)' . "\n{";
167
+        $pre .= "\n".'if ($this->isTraversable($_fh'.$cnt.'_data'.(isset($params['hasElse']) ? ', true' : '').') == true)'."\n{";
168 168
         // iterates over keys
169
-        $pre .= "\n\t" . 'foreach ($_fh' . $cnt . '_data as ' . (isset($key) ? '$this->scope[' . $key . ']=>' : '') . '$this->scope[' . $val . '])' . "\n\t{";
169
+        $pre .= "\n\t".'foreach ($_fh'.$cnt.'_data as '.(isset($key) ? '$this->scope['.$key.']=>' : '').'$this->scope['.$val.'])'."\n\t{";
170 170
         // updates properties
171 171
         if ($usesFirst) {
172
-            $pre .= "\n\t\t" . '$_fh' . $cnt . '_glob["first"] = (string) ($_fh' . $cnt . '_glob["index"] === 0);';
172
+            $pre .= "\n\t\t".'$_fh'.$cnt.'_glob["first"] = (string) ($_fh'.$cnt.'_glob["index"] === 0);';
173 173
         }
174 174
         if ($usesLast) {
175
-            $pre .= "\n\t\t" . '$_fh' . $cnt . '_glob["last"] = (string) ($_fh' . $cnt . '_glob["iteration"] === $_fh' . $cnt . '_glob["total"]);';
175
+            $pre .= "\n\t\t".'$_fh'.$cnt.'_glob["last"] = (string) ($_fh'.$cnt.'_glob["iteration"] === $_fh'.$cnt.'_glob["total"]);';
176 176
         }
177
-        $pre .= "\n/* -- foreach start output */\n" . Compiler::PHP_CLOSE;
177
+        $pre .= "\n/* -- foreach start output */\n".Compiler::PHP_CLOSE;
178 178
 
179 179
         // build post content output
180
-        $post = Compiler::PHP_OPEN . "\n";
180
+        $post = Compiler::PHP_OPEN."\n";
181 181
 
182 182
         if (isset($implode)) {
183
-            $post .= '/* -- implode */' . "\n" . 'if (!$_fh' . $cnt . '_glob["last"]) {' . "\n\t" . 'echo ' . $implode . ";\n}\n";
183
+            $post .= '/* -- implode */'."\n".'if (!$_fh'.$cnt.'_glob["last"]) {'."\n\t".'echo '.$implode.";\n}\n";
184 184
         }
185 185
         $post .= '/* -- foreach end output */';
186 186
         // update properties
187 187
         if ($usesIndex) {
188
-            $post .= "\n\t\t" . '$_fh' . $cnt . '_glob["index"]+=1;';
188
+            $post .= "\n\t\t".'$_fh'.$cnt.'_glob["index"]+=1;';
189 189
         }
190 190
         if ($usesIteration) {
191
-            $post .= "\n\t\t" . '$_fh' . $cnt . '_glob["iteration"]+=1;';
191
+            $post .= "\n\t\t".'$_fh'.$cnt.'_glob["iteration"]+=1;';
192 192
         }
193 193
         // end loop
194
-        $post .= "\n\t}\n}" . Compiler::PHP_CLOSE;
194
+        $post .= "\n\t}\n}".Compiler::PHP_CLOSE;
195 195
         if (isset($params['hasElse'])) {
196 196
             $post .= $params['hasElse'];
197 197
         }
198 198
 
199
-        return $pre . $content . $post;
199
+        return $pre.$content.$post;
200 200
     }
201 201
 }
Please login to merge, or discard this patch.
lib/Dwoo/Plugins/Blocks/PluginTemplate.php 2 patches
Indentation   +73 added lines, -73 removed lines patch added patch discarded remove patch
@@ -33,83 +33,83 @@
 block discarded – undo
33 33
  */
34 34
 class PluginTemplate extends BlockPlugin implements ICompilableBlock
35 35
 {
36
-    /**
37
-     * @param Compiler $compiler
38
-     * @param array    $params
39
-     * @param string   $prepend
40
-     * @param string   $append
41
-     * @param string   $type
42
-     *
43
-     * @return string
44
-     * @throws CompilationException
45
-     */
46
-    public static function preProcessing(Compiler $compiler, array $params, $prepend, $append, $type)
47
-    {
48
-        $params       = $compiler->getCompiledParams($params);
49
-        $parsedParams = array();
50
-        if (!isset($params['*'])) {
51
-            $params['*'] = array();
52
-        }
53
-        foreach ($params['*'] as $param => $defValue) {
54
-            if (is_numeric($param)) {
55
-                $param    = $defValue;
56
-                $defValue = null;
57
-            }
58
-            $param = trim($param, '\'"');
59
-            if (!preg_match('#^[a-z0-9_]+$#i', $param)) {
60
-                throw new CompilationException($compiler, 'Function : parameter names must contain only A-Z, 0-9 or _');
61
-            }
62
-            $parsedParams[$param] = $defValue;
63
-        }
64
-        $params['name'] = substr($params['name'], 1, - 1);
65
-        $params['*']    = $parsedParams;
66
-        $params['uuid'] = uniqid();
67
-        $compiler->addTemplatePlugin($params['name'], $parsedParams, $params['uuid']);
68
-        $currentBlock           = &$compiler->getCurrentBlock();
69
-        $currentBlock['params'] = $params;
36
+	/**
37
+	 * @param Compiler $compiler
38
+	 * @param array    $params
39
+	 * @param string   $prepend
40
+	 * @param string   $append
41
+	 * @param string   $type
42
+	 *
43
+	 * @return string
44
+	 * @throws CompilationException
45
+	 */
46
+	public static function preProcessing(Compiler $compiler, array $params, $prepend, $append, $type)
47
+	{
48
+		$params       = $compiler->getCompiledParams($params);
49
+		$parsedParams = array();
50
+		if (!isset($params['*'])) {
51
+			$params['*'] = array();
52
+		}
53
+		foreach ($params['*'] as $param => $defValue) {
54
+			if (is_numeric($param)) {
55
+				$param    = $defValue;
56
+				$defValue = null;
57
+			}
58
+			$param = trim($param, '\'"');
59
+			if (!preg_match('#^[a-z0-9_]+$#i', $param)) {
60
+				throw new CompilationException($compiler, 'Function : parameter names must contain only A-Z, 0-9 or _');
61
+			}
62
+			$parsedParams[$param] = $defValue;
63
+		}
64
+		$params['name'] = substr($params['name'], 1, - 1);
65
+		$params['*']    = $parsedParams;
66
+		$params['uuid'] = uniqid();
67
+		$compiler->addTemplatePlugin($params['name'], $parsedParams, $params['uuid']);
68
+		$currentBlock           = &$compiler->getCurrentBlock();
69
+		$currentBlock['params'] = $params;
70 70
 
71
-        return '';
72
-    }
71
+		return '';
72
+	}
73 73
 
74
-    /**
75
-     * @param Compiler $compiler
76
-     * @param array    $params
77
-     * @param string   $prepend
78
-     * @param string   $append
79
-     * @param string   $content
80
-     *
81
-     * @return string|void
82
-     */
83
-    public static function postProcessing(Compiler $compiler, array $params, $prepend, $append, $content)
84
-    {
85
-        $paramstr = 'Dwoo\Core $dwoo';
86
-        $init     = 'static $_callCnt = 0;' . "\n" . '$dwoo->scope[\' ' . $params['uuid'] . '\'.$_callCnt] = array();' . "\n" . '$_scope = $dwoo->setScope(array(\' ' . $params['uuid'] . '\'.($_callCnt++)));' . "\n";
87
-        $cleanup  = '/* -- template end output */ $dwoo->setScope($_scope, true);';
88
-        foreach ($params['*'] as $param => $defValue) {
89
-            if ($defValue === null) {
90
-                $paramstr .= ', $' . $param;
91
-            } else {
92
-                $paramstr .= ', $' . $param . ' = ' . $defValue;
93
-            }
94
-            $init .= '$dwoo->scope[\'' . $param . '\'] = $' . $param . ";\n";
95
-        }
96
-        $init .= '/* -- template start output */';
74
+	/**
75
+	 * @param Compiler $compiler
76
+	 * @param array    $params
77
+	 * @param string   $prepend
78
+	 * @param string   $append
79
+	 * @param string   $content
80
+	 *
81
+	 * @return string|void
82
+	 */
83
+	public static function postProcessing(Compiler $compiler, array $params, $prepend, $append, $content)
84
+	{
85
+		$paramstr = 'Dwoo\Core $dwoo';
86
+		$init     = 'static $_callCnt = 0;' . "\n" . '$dwoo->scope[\' ' . $params['uuid'] . '\'.$_callCnt] = array();' . "\n" . '$_scope = $dwoo->setScope(array(\' ' . $params['uuid'] . '\'.($_callCnt++)));' . "\n";
87
+		$cleanup  = '/* -- template end output */ $dwoo->setScope($_scope, true);';
88
+		foreach ($params['*'] as $param => $defValue) {
89
+			if ($defValue === null) {
90
+				$paramstr .= ', $' . $param;
91
+			} else {
92
+				$paramstr .= ', $' . $param . ' = ' . $defValue;
93
+			}
94
+			$init .= '$dwoo->scope[\'' . $param . '\'] = $' . $param . ";\n";
95
+		}
96
+		$init .= '/* -- template start output */';
97 97
 
98
-        $funcName = 'Plugin' . Core::toCamelCase($params['name']) . Core::toCamelCase($params['uuid']);
98
+		$funcName = 'Plugin' . Core::toCamelCase($params['name']) . Core::toCamelCase($params['uuid']);
99 99
 
100
-        $search      = array('$this->charset', '$this->', '$this,',);
101
-        $replacement = array('$dwoo->getCharset()', '$dwoo->', '$dwoo,',);
102
-        $content     = str_replace($search, $replacement, $content);
100
+		$search      = array('$this->charset', '$this->', '$this,',);
101
+		$replacement = array('$dwoo->getCharset()', '$dwoo->', '$dwoo,',);
102
+		$content     = str_replace($search, $replacement, $content);
103 103
 
104
-        $body = 'if (!function_exists(\'' . $funcName . "')) {\nfunction " . $funcName . '(' . $paramstr . ') {' . "\n$init" . Compiler::PHP_CLOSE . $prepend . $content . $append . Compiler::PHP_OPEN . $cleanup . "\n}\n}";
105
-        $compiler->addTemplatePlugin($params['name'], $params['*'], $params['uuid'], $body);
106
-    }
104
+		$body = 'if (!function_exists(\'' . $funcName . "')) {\nfunction " . $funcName . '(' . $paramstr . ') {' . "\n$init" . Compiler::PHP_CLOSE . $prepend . $content . $append . Compiler::PHP_OPEN . $cleanup . "\n}\n}";
105
+		$compiler->addTemplatePlugin($params['name'], $params['*'], $params['uuid'], $body);
106
+	}
107 107
 
108
-    /**
109
-     * @param       $name
110
-     * @param array $rest
111
-     */
112
-    public function init($name, array $rest = array())
113
-    {
114
-    }
108
+	/**
109
+	 * @param       $name
110
+	 * @param array $rest
111
+	 */
112
+	public function init($name, array $rest = array())
113
+	{
114
+	}
115 115
 }
Please login to merge, or discard this patch.
Spacing   +6 added lines, -6 removed lines patch added patch discarded remove patch
@@ -83,25 +83,25 @@
 block discarded – undo
83 83
     public static function postProcessing(Compiler $compiler, array $params, $prepend, $append, $content)
84 84
     {
85 85
         $paramstr = 'Dwoo\Core $dwoo';
86
-        $init     = 'static $_callCnt = 0;' . "\n" . '$dwoo->scope[\' ' . $params['uuid'] . '\'.$_callCnt] = array();' . "\n" . '$_scope = $dwoo->setScope(array(\' ' . $params['uuid'] . '\'.($_callCnt++)));' . "\n";
86
+        $init     = 'static $_callCnt = 0;'."\n".'$dwoo->scope[\' '.$params['uuid'].'\'.$_callCnt] = array();'."\n".'$_scope = $dwoo->setScope(array(\' '.$params['uuid'].'\'.($_callCnt++)));'."\n";
87 87
         $cleanup  = '/* -- template end output */ $dwoo->setScope($_scope, true);';
88 88
         foreach ($params['*'] as $param => $defValue) {
89 89
             if ($defValue === null) {
90
-                $paramstr .= ', $' . $param;
90
+                $paramstr .= ', $'.$param;
91 91
             } else {
92
-                $paramstr .= ', $' . $param . ' = ' . $defValue;
92
+                $paramstr .= ', $'.$param.' = '.$defValue;
93 93
             }
94
-            $init .= '$dwoo->scope[\'' . $param . '\'] = $' . $param . ";\n";
94
+            $init .= '$dwoo->scope[\''.$param.'\'] = $'.$param.";\n";
95 95
         }
96 96
         $init .= '/* -- template start output */';
97 97
 
98
-        $funcName = 'Plugin' . Core::toCamelCase($params['name']) . Core::toCamelCase($params['uuid']);
98
+        $funcName = 'Plugin'.Core::toCamelCase($params['name']).Core::toCamelCase($params['uuid']);
99 99
 
100 100
         $search      = array('$this->charset', '$this->', '$this,',);
101 101
         $replacement = array('$dwoo->getCharset()', '$dwoo->', '$dwoo,',);
102 102
         $content     = str_replace($search, $replacement, $content);
103 103
 
104
-        $body = 'if (!function_exists(\'' . $funcName . "')) {\nfunction " . $funcName . '(' . $paramstr . ') {' . "\n$init" . Compiler::PHP_CLOSE . $prepend . $content . $append . Compiler::PHP_OPEN . $cleanup . "\n}\n}";
104
+        $body = 'if (!function_exists(\''.$funcName."')) {\nfunction ".$funcName.'('.$paramstr.') {'."\n$init".Compiler::PHP_CLOSE.$prepend.$content.$append.Compiler::PHP_OPEN.$cleanup."\n}\n}";
105 105
         $compiler->addTemplatePlugin($params['name'], $params['*'], $params['uuid'], $body);
106 106
     }
107 107
 
Please login to merge, or discard this patch.
lib/Dwoo/Plugins/Blocks/PluginWith.php 2 patches
Indentation   +41 added lines, -41 removed lines patch added patch discarded remove patch
@@ -47,53 +47,53 @@
 block discarded – undo
47 47
  */
48 48
 class PluginWith extends BlockPlugin implements ICompilableBlock, IElseable
49 49
 {
50
-    protected static $cnt = 0;
50
+	protected static $cnt = 0;
51 51
 
52
-    /**
53
-     * @param $var
54
-     */
55
-    public function init($var)
56
-    {
57
-    }
52
+	/**
53
+	 * @param $var
54
+	 */
55
+	public function init($var)
56
+	{
57
+	}
58 58
 
59
-    /**
60
-     * @param Compiler $compiler
61
-     * @param array    $params
62
-     * @param string   $prepend
63
-     * @param string   $append
64
-     * @param string   $type
65
-     *
66
-     * @return string
67
-     */
68
-    public static function preProcessing(Compiler $compiler, array $params, $prepend, $append, $type)
69
-    {
70
-        return '';
71
-    }
59
+	/**
60
+	 * @param Compiler $compiler
61
+	 * @param array    $params
62
+	 * @param string   $prepend
63
+	 * @param string   $append
64
+	 * @param string   $type
65
+	 *
66
+	 * @return string
67
+	 */
68
+	public static function preProcessing(Compiler $compiler, array $params, $prepend, $append, $type)
69
+	{
70
+		return '';
71
+	}
72 72
 
73
-    /**
74
-     * @param Compiler $compiler
75
-     * @param array    $params
76
-     * @param string   $prepend
77
-     * @param string   $append
78
-     * @param string   $content
79
-     *
80
-     * @return string
81
-     */
82
-    public static function postProcessing(Compiler $compiler, array $params, $prepend, $append, $content)
83
-    {
84
-        $rparams = $compiler->getRealParams($params);
85
-        $cparams = $compiler->getCompiledParams($params);
73
+	/**
74
+	 * @param Compiler $compiler
75
+	 * @param array    $params
76
+	 * @param string   $prepend
77
+	 * @param string   $append
78
+	 * @param string   $content
79
+	 *
80
+	 * @return string
81
+	 */
82
+	public static function postProcessing(Compiler $compiler, array $params, $prepend, $append, $content)
83
+	{
84
+		$rparams = $compiler->getRealParams($params);
85
+		$cparams = $compiler->getCompiledParams($params);
86 86
 
87
-        $compiler->setScope($rparams['var']);
87
+		$compiler->setScope($rparams['var']);
88 88
 
89
-        $pre = Compiler::PHP_OPEN . 'if (' . $cparams['var'] . ')' . "\n{\n" . '$_with' . (self::$cnt) . ' = $this->setScope("' . $rparams['var'] . '");' . "\n/* -- start with output */\n" . Compiler::PHP_CLOSE;
89
+		$pre = Compiler::PHP_OPEN . 'if (' . $cparams['var'] . ')' . "\n{\n" . '$_with' . (self::$cnt) . ' = $this->setScope("' . $rparams['var'] . '");' . "\n/* -- start with output */\n" . Compiler::PHP_CLOSE;
90 90
 
91
-        $post = Compiler::PHP_OPEN . "\n/* -- end with output */\n" . '$this->setScope($_with' . (self::$cnt ++) . ', true);' . "\n}\n" . Compiler::PHP_CLOSE;
91
+		$post = Compiler::PHP_OPEN . "\n/* -- end with output */\n" . '$this->setScope($_with' . (self::$cnt ++) . ', true);' . "\n}\n" . Compiler::PHP_CLOSE;
92 92
 
93
-        if (isset($params['hasElse'])) {
94
-            $post .= $params['hasElse'];
95
-        }
93
+		if (isset($params['hasElse'])) {
94
+			$post .= $params['hasElse'];
95
+		}
96 96
 
97
-        return $pre . $content . $post;
98
-    }
97
+		return $pre . $content . $post;
98
+	}
99 99
 }
Please login to merge, or discard this patch.
Spacing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -86,14 +86,14 @@
 block discarded – undo
86 86
 
87 87
         $compiler->setScope($rparams['var']);
88 88
 
89
-        $pre = Compiler::PHP_OPEN . 'if (' . $cparams['var'] . ')' . "\n{\n" . '$_with' . (self::$cnt) . ' = $this->setScope("' . $rparams['var'] . '");' . "\n/* -- start with output */\n" . Compiler::PHP_CLOSE;
89
+        $pre = Compiler::PHP_OPEN.'if ('.$cparams['var'].')'."\n{\n".'$_with'.(self::$cnt).' = $this->setScope("'.$rparams['var'].'");'."\n/* -- start with output */\n".Compiler::PHP_CLOSE;
90 90
 
91
-        $post = Compiler::PHP_OPEN . "\n/* -- end with output */\n" . '$this->setScope($_with' . (self::$cnt ++) . ', true);' . "\n}\n" . Compiler::PHP_CLOSE;
91
+        $post = Compiler::PHP_OPEN."\n/* -- end with output */\n".'$this->setScope($_with'.(self::$cnt++).', true);'."\n}\n".Compiler::PHP_CLOSE;
92 92
 
93 93
         if (isset($params['hasElse'])) {
94 94
             $post .= $params['hasElse'];
95 95
         }
96 96
 
97
-        return $pre . $content . $post;
97
+        return $pre.$content.$post;
98 98
     }
99 99
 }
Please login to merge, or discard this patch.
lib/Dwoo/Plugins/Blocks/PluginA.php 2 patches
Indentation   +46 added lines, -46 removed lines patch added patch discarded remove patch
@@ -39,57 +39,57 @@
 block discarded – undo
39 39
  */
40 40
 class PluginA extends BlockPlugin implements ICompilableBlock
41 41
 {
42
-    /**
43
-     * @param       $href
44
-     * @param array $rest
45
-     */
46
-    public function init($href, array $rest = array())
47
-    {
48
-    }
42
+	/**
43
+	 * @param       $href
44
+	 * @param array $rest
45
+	 */
46
+	public function init($href, array $rest = array())
47
+	{
48
+	}
49 49
 
50
-    /**
51
-     * @param Compiler $compiler
52
-     * @param array    $params
53
-     * @param string   $prepend
54
-     * @param string   $append
55
-     * @param string   $type
56
-     *
57
-     * @return string
58
-     */
59
-    public static function preProcessing(Compiler $compiler, array $params, $prepend, $append, $type)
60
-    {
61
-        $p = $compiler->getCompiledParams($params);
50
+	/**
51
+	 * @param Compiler $compiler
52
+	 * @param array    $params
53
+	 * @param string   $prepend
54
+	 * @param string   $append
55
+	 * @param string   $type
56
+	 *
57
+	 * @return string
58
+	 */
59
+	public static function preProcessing(Compiler $compiler, array $params, $prepend, $append, $type)
60
+	{
61
+		$p = $compiler->getCompiledParams($params);
62 62
 
63
-        $out = Compiler::PHP_OPEN . 'echo \'<a ' . self::paramsToAttributes($p, "'", $compiler);
63
+		$out = Compiler::PHP_OPEN . 'echo \'<a ' . self::paramsToAttributes($p, "'", $compiler);
64 64
 
65
-        return $out . '>\';' . Compiler::PHP_CLOSE;
66
-    }
65
+		return $out . '>\';' . Compiler::PHP_CLOSE;
66
+	}
67 67
 
68
-    /**
69
-     * @param Compiler $compiler
70
-     * @param array    $params
71
-     * @param string   $prepend
72
-     * @param string   $append
73
-     * @param string   $content
74
-     *
75
-     * @return string
76
-     */
77
-    public static function postProcessing(Compiler $compiler, array $params, $prepend, $append, $content)
78
-    {
79
-        $p = $compiler->getCompiledParams($params);
68
+	/**
69
+	 * @param Compiler $compiler
70
+	 * @param array    $params
71
+	 * @param string   $prepend
72
+	 * @param string   $append
73
+	 * @param string   $content
74
+	 *
75
+	 * @return string
76
+	 */
77
+	public static function postProcessing(Compiler $compiler, array $params, $prepend, $append, $content)
78
+	{
79
+		$p = $compiler->getCompiledParams($params);
80 80
 
81
-        // no content was provided so use the url as display text
82
-        if ($content == '') {
83
-            // merge </a> into the href if href is a string
84
-            if (substr($p['href'], - 1) === '"' || substr($p['href'], - 1) === '\'') {
85
-                return Compiler::PHP_OPEN . 'echo ' . substr($p['href'], 0, - 1) . '</a>' . substr($p['href'], - 1) . ';' . Compiler::PHP_CLOSE;
86
-            }
81
+		// no content was provided so use the url as display text
82
+		if ($content == '') {
83
+			// merge </a> into the href if href is a string
84
+			if (substr($p['href'], - 1) === '"' || substr($p['href'], - 1) === '\'') {
85
+				return Compiler::PHP_OPEN . 'echo ' . substr($p['href'], 0, - 1) . '</a>' . substr($p['href'], - 1) . ';' . Compiler::PHP_CLOSE;
86
+			}
87 87
 
88
-            // otherwise append
89
-            return Compiler::PHP_OPEN . 'echo ' . $p['href'] . '.\'</a>\';' . Compiler::PHP_CLOSE;
90
-        }
88
+			// otherwise append
89
+			return Compiler::PHP_OPEN . 'echo ' . $p['href'] . '.\'</a>\';' . Compiler::PHP_CLOSE;
90
+		}
91 91
 
92
-        // return content
93
-        return $content . '</a>';
94
-    }
92
+		// return content
93
+		return $content . '</a>';
94
+	}
95 95
 }
Please login to merge, or discard this patch.
Spacing   +5 added lines, -5 removed lines patch added patch discarded remove patch
@@ -60,9 +60,9 @@  discard block
 block discarded – undo
60 60
     {
61 61
         $p = $compiler->getCompiledParams($params);
62 62
 
63
-        $out = Compiler::PHP_OPEN . 'echo \'<a ' . self::paramsToAttributes($p, "'", $compiler);
63
+        $out = Compiler::PHP_OPEN.'echo \'<a '.self::paramsToAttributes($p, "'", $compiler);
64 64
 
65
-        return $out . '>\';' . Compiler::PHP_CLOSE;
65
+        return $out.'>\';'.Compiler::PHP_CLOSE;
66 66
     }
67 67
 
68 68
     /**
@@ -82,14 +82,14 @@  discard block
 block discarded – undo
82 82
         if ($content == '') {
83 83
             // merge </a> into the href if href is a string
84 84
             if (substr($p['href'], - 1) === '"' || substr($p['href'], - 1) === '\'') {
85
-                return Compiler::PHP_OPEN . 'echo ' . substr($p['href'], 0, - 1) . '</a>' . substr($p['href'], - 1) . ';' . Compiler::PHP_CLOSE;
85
+                return Compiler::PHP_OPEN.'echo '.substr($p['href'], 0, - 1).'</a>'.substr($p['href'], - 1).';'.Compiler::PHP_CLOSE;
86 86
             }
87 87
 
88 88
             // otherwise append
89
-            return Compiler::PHP_OPEN . 'echo ' . $p['href'] . '.\'</a>\';' . Compiler::PHP_CLOSE;
89
+            return Compiler::PHP_OPEN.'echo '.$p['href'].'.\'</a>\';'.Compiler::PHP_CLOSE;
90 90
         }
91 91
 
92 92
         // return content
93
-        return $content . '</a>';
93
+        return $content.'</a>';
94 94
     }
95 95
 }
Please login to merge, or discard this patch.
lib/Dwoo/Plugins/Blocks/PluginForelse.php 2 patches
Indentation   +37 added lines, -37 removed lines patch added patch discarded remove patch
@@ -27,47 +27,47 @@
 block discarded – undo
27 27
  */
28 28
 class PluginForelse extends BlockPlugin implements ICompilableBlock
29 29
 {
30
-    public function init()
31
-    {
32
-    }
30
+	public function init()
31
+	{
32
+	}
33 33
 
34
-    /**
35
-     * @param Compiler $compiler
36
-     * @param array    $params
37
-     * @param string   $prepend
38
-     * @param string   $append
39
-     * @param string   $type
40
-     *
41
-     * @return string
42
-     */
43
-    public static function preProcessing(Compiler $compiler, array $params, $prepend, $append, $type)
44
-    {
45
-        $with = &$compiler->findBlock('for', true);
34
+	/**
35
+	 * @param Compiler $compiler
36
+	 * @param array    $params
37
+	 * @param string   $prepend
38
+	 * @param string   $append
39
+	 * @param string   $type
40
+	 *
41
+	 * @return string
42
+	 */
43
+	public static function preProcessing(Compiler $compiler, array $params, $prepend, $append, $type)
44
+	{
45
+		$with = &$compiler->findBlock('for', true);
46 46
 
47
-        $params['initialized'] = true;
48
-        $compiler->injectBlock($type, $params);
47
+		$params['initialized'] = true;
48
+		$compiler->injectBlock($type, $params);
49 49
 
50
-        return '';
51
-    }
50
+		return '';
51
+	}
52 52
 
53
-    /**
54
-     * @param Compiler $compiler
55
-     * @param array    $params
56
-     * @param string   $prepend
57
-     * @param string   $append
58
-     * @param string   $content
59
-     *
60
-     * @return string
61
-     */
62
-    public static function postProcessing(Compiler $compiler, array $params, $prepend, $append, $content)
63
-    {
64
-        if (!isset($params['initialized'])) {
65
-            return '';
66
-        }
53
+	/**
54
+	 * @param Compiler $compiler
55
+	 * @param array    $params
56
+	 * @param string   $prepend
57
+	 * @param string   $append
58
+	 * @param string   $content
59
+	 *
60
+	 * @return string
61
+	 */
62
+	public static function postProcessing(Compiler $compiler, array $params, $prepend, $append, $content)
63
+	{
64
+		if (!isset($params['initialized'])) {
65
+			return '';
66
+		}
67 67
 
68
-        $block                      = &$compiler->getCurrentBlock();
69
-        $block['params']['hasElse'] = Compiler::PHP_OPEN . "else {\n" . Compiler::PHP_CLOSE . $content . Compiler::PHP_OPEN . "\n}" . Compiler::PHP_CLOSE;
68
+		$block                      = &$compiler->getCurrentBlock();
69
+		$block['params']['hasElse'] = Compiler::PHP_OPEN . "else {\n" . Compiler::PHP_CLOSE . $content . Compiler::PHP_OPEN . "\n}" . Compiler::PHP_CLOSE;
70 70
 
71
-        return '';
72
-    }
71
+		return '';
72
+	}
73 73
 }
Please login to merge, or discard this patch.
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -89,7 +89,7 @@
 block discarded – undo
89 89
         }
90 90
 
91 91
         $block                      = &$compiler->getCurrentBlock();
92
-        $block['params']['hasElse'] = Compiler::PHP_OPEN . "else {\n" . Compiler::PHP_CLOSE . $content . Compiler::PHP_OPEN . "\n}" . Compiler::PHP_CLOSE;
92
+        $block['params']['hasElse'] = Compiler::PHP_OPEN."else {\n".Compiler::PHP_CLOSE.$content.Compiler::PHP_OPEN."\n}".Compiler::PHP_CLOSE;
93 93
 
94 94
         return '';
95 95
     }
Please login to merge, or discard this patch.
lib/Dwoo/Plugins/Blocks/PluginLoop.php 2 patches
Indentation   +108 added lines, -108 removed lines patch added patch discarded remove patch
@@ -48,123 +48,123 @@
 block discarded – undo
48 48
  */
49 49
 class PluginLoop extends BlockPlugin implements ICompilableBlock, IElseable
50 50
 {
51
-    public static $cnt = 0;
51
+	public static $cnt = 0;
52 52
 
53
-    /**
54
-     * @param        $from
55
-     * @param string $name
56
-     */
57
-    public function init($from, $name = 'default')
58
-    {
59
-    }
53
+	/**
54
+	 * @param        $from
55
+	 * @param string $name
56
+	 */
57
+	public function init($from, $name = 'default')
58
+	{
59
+	}
60 60
 
61
-    /**
62
-     * @param Compiler $compiler
63
-     * @param array    $params
64
-     * @param string   $prepend
65
-     * @param string   $append
66
-     * @param string   $type
67
-     *
68
-     * @return string
69
-     */
70
-    public static function preProcessing(Compiler $compiler, array $params, $prepend, $append, $type)
71
-    {
72
-        // get block params and save the current template pointer to use it in the postProcessing method
73
-        $currentBlock                         = &$compiler->getCurrentBlock();
74
-        $currentBlock['params']['tplPointer'] = $compiler->getPointer();
61
+	/**
62
+	 * @param Compiler $compiler
63
+	 * @param array    $params
64
+	 * @param string   $prepend
65
+	 * @param string   $append
66
+	 * @param string   $type
67
+	 *
68
+	 * @return string
69
+	 */
70
+	public static function preProcessing(Compiler $compiler, array $params, $prepend, $append, $type)
71
+	{
72
+		// get block params and save the current template pointer to use it in the postProcessing method
73
+		$currentBlock                         = &$compiler->getCurrentBlock();
74
+		$currentBlock['params']['tplPointer'] = $compiler->getPointer();
75 75
 
76
-        return '';
77
-    }
76
+		return '';
77
+	}
78 78
 
79
-    /**
80
-     * @param Compiler $compiler
81
-     * @param array    $params
82
-     * @param string   $prepend
83
-     * @param string   $append
84
-     * @param string   $content
85
-     *
86
-     * @return string
87
-     */
88
-    public static function postProcessing(Compiler $compiler, array $params, $prepend, $append, $content)
89
-    {
90
-        $params = $compiler->getCompiledParams($params);
91
-        $tpl    = $compiler->getTemplateSource($params['tplPointer']);
79
+	/**
80
+	 * @param Compiler $compiler
81
+	 * @param array    $params
82
+	 * @param string   $prepend
83
+	 * @param string   $append
84
+	 * @param string   $content
85
+	 *
86
+	 * @return string
87
+	 */
88
+	public static function postProcessing(Compiler $compiler, array $params, $prepend, $append, $content)
89
+	{
90
+		$params = $compiler->getCompiledParams($params);
91
+		$tpl    = $compiler->getTemplateSource($params['tplPointer']);
92 92
 
93
-        // assigns params
94
-        $src  = $params['from'];
95
-        $name = $params['name'];
93
+		// assigns params
94
+		$src  = $params['from'];
95
+		$name = $params['name'];
96 96
 
97
-        // evaluates which global variables have to be computed
98
-        $varName       = '$dwoo.loop.' . trim($name, '"\'') . '.';
99
-        $shortVarName  = '$.loop.' . trim($name, '"\'') . '.';
100
-        $usesAny       = strpos($tpl, $varName) !== false || strpos($tpl, $shortVarName) !== false;
101
-        $usesFirst     = strpos($tpl, $varName . 'first') !== false || strpos($tpl, $shortVarName . 'first') !== false;
102
-        $usesLast      = strpos($tpl, $varName . 'last') !== false || strpos($tpl, $shortVarName . 'last') !== false;
103
-        $usesIndex     = $usesFirst || strpos($tpl, $varName . 'index') !== false || strpos($tpl, $shortVarName . 'index') !== false;
104
-        $usesIteration = $usesLast || strpos($tpl, $varName . 'iteration') !== false || strpos($tpl, $shortVarName . 'iteration') !== false;
105
-        $usesShow      = strpos($tpl, $varName . 'show') !== false || strpos($tpl, $shortVarName . 'show') !== false;
106
-        $usesTotal     = $usesLast || strpos($tpl, $varName . 'total') !== false || strpos($tpl, $shortVarName . 'total') !== false;
97
+		// evaluates which global variables have to be computed
98
+		$varName       = '$dwoo.loop.' . trim($name, '"\'') . '.';
99
+		$shortVarName  = '$.loop.' . trim($name, '"\'') . '.';
100
+		$usesAny       = strpos($tpl, $varName) !== false || strpos($tpl, $shortVarName) !== false;
101
+		$usesFirst     = strpos($tpl, $varName . 'first') !== false || strpos($tpl, $shortVarName . 'first') !== false;
102
+		$usesLast      = strpos($tpl, $varName . 'last') !== false || strpos($tpl, $shortVarName . 'last') !== false;
103
+		$usesIndex     = $usesFirst || strpos($tpl, $varName . 'index') !== false || strpos($tpl, $shortVarName . 'index') !== false;
104
+		$usesIteration = $usesLast || strpos($tpl, $varName . 'iteration') !== false || strpos($tpl, $shortVarName . 'iteration') !== false;
105
+		$usesShow      = strpos($tpl, $varName . 'show') !== false || strpos($tpl, $shortVarName . 'show') !== false;
106
+		$usesTotal     = $usesLast || strpos($tpl, $varName . 'total') !== false || strpos($tpl, $shortVarName . 'total') !== false;
107 107
 
108
-        if (strpos($name, '$this->scope[') !== false) {
109
-            $usesAny = $usesFirst = $usesLast = $usesIndex = $usesIteration = $usesShow = $usesTotal = true;
110
-        }
108
+		if (strpos($name, '$this->scope[') !== false) {
109
+			$usesAny = $usesFirst = $usesLast = $usesIndex = $usesIteration = $usesShow = $usesTotal = true;
110
+		}
111 111
 
112
-        // gets foreach id
113
-        $cnt = self::$cnt ++;
112
+		// gets foreach id
113
+		$cnt = self::$cnt ++;
114 114
 
115
-        // builds pre processing output
116
-        $pre = Compiler::PHP_OPEN . "\n" . '$_loop' . $cnt . '_data = ' . $src . ';';
117
-        // adds foreach properties
118
-        if ($usesAny) {
119
-            $pre .= "\n" . '$this->globals["loop"][' . $name . '] = array' . "\n(";
120
-            if ($usesIndex) {
121
-                $pre .= "\n\t" . '"index"		=> 0,';
122
-            }
123
-            if ($usesIteration) {
124
-                $pre .= "\n\t" . '"iteration"		=> 1,';
125
-            }
126
-            if ($usesFirst) {
127
-                $pre .= "\n\t" . '"first"		=> null,';
128
-            }
129
-            if ($usesLast) {
130
-                $pre .= "\n\t" . '"last"		=> null,';
131
-            }
132
-            if ($usesShow) {
133
-                $pre .= "\n\t" . '"show"		=> $this->isTraversable($_loop' . $cnt . '_data, true),';
134
-            }
135
-            if ($usesTotal) {
136
-                $pre .= "\n\t" . '"total"		=> $this->count($_loop' . $cnt . '_data),';
137
-            }
138
-            $pre .= "\n);\n" . '$_loop' . $cnt . '_glob =& $this->globals["loop"][' . $name . '];';
139
-        }
140
-        // checks if the loop must be looped
141
-        $pre .= "\n" . 'if ($this->isTraversable($_loop' . $cnt . '_data' . (isset($params['hasElse']) ? ', true' : '') . ') == true)' . "\n{";
142
-        // iterates over keys
143
-        $pre .= "\n\t" . 'foreach ($_loop' . $cnt . '_data as $tmp_key => $this->scope["-loop-"])' . "\n\t{";
144
-        // updates properties
145
-        if ($usesFirst) {
146
-            $pre .= "\n\t\t" . '$_loop' . $cnt . '_glob["first"] = (string) ($_loop' . $cnt . '_glob["index"] === 0);';
147
-        }
148
-        if ($usesLast) {
149
-            $pre .= "\n\t\t" . '$_loop' . $cnt . '_glob["last"] = (string) ($_loop' . $cnt . '_glob["iteration"] === $_loop' . $cnt . '_glob["total"]);';
150
-        }
151
-        $pre .= "\n\t\t" . '$_loop' . $cnt . '_scope = $this->setScope(array("-loop-"));' . "\n/* -- loop start output */\n" . Compiler::PHP_CLOSE;
115
+		// builds pre processing output
116
+		$pre = Compiler::PHP_OPEN . "\n" . '$_loop' . $cnt . '_data = ' . $src . ';';
117
+		// adds foreach properties
118
+		if ($usesAny) {
119
+			$pre .= "\n" . '$this->globals["loop"][' . $name . '] = array' . "\n(";
120
+			if ($usesIndex) {
121
+				$pre .= "\n\t" . '"index"		=> 0,';
122
+			}
123
+			if ($usesIteration) {
124
+				$pre .= "\n\t" . '"iteration"		=> 1,';
125
+			}
126
+			if ($usesFirst) {
127
+				$pre .= "\n\t" . '"first"		=> null,';
128
+			}
129
+			if ($usesLast) {
130
+				$pre .= "\n\t" . '"last"		=> null,';
131
+			}
132
+			if ($usesShow) {
133
+				$pre .= "\n\t" . '"show"		=> $this->isTraversable($_loop' . $cnt . '_data, true),';
134
+			}
135
+			if ($usesTotal) {
136
+				$pre .= "\n\t" . '"total"		=> $this->count($_loop' . $cnt . '_data),';
137
+			}
138
+			$pre .= "\n);\n" . '$_loop' . $cnt . '_glob =& $this->globals["loop"][' . $name . '];';
139
+		}
140
+		// checks if the loop must be looped
141
+		$pre .= "\n" . 'if ($this->isTraversable($_loop' . $cnt . '_data' . (isset($params['hasElse']) ? ', true' : '') . ') == true)' . "\n{";
142
+		// iterates over keys
143
+		$pre .= "\n\t" . 'foreach ($_loop' . $cnt . '_data as $tmp_key => $this->scope["-loop-"])' . "\n\t{";
144
+		// updates properties
145
+		if ($usesFirst) {
146
+			$pre .= "\n\t\t" . '$_loop' . $cnt . '_glob["first"] = (string) ($_loop' . $cnt . '_glob["index"] === 0);';
147
+		}
148
+		if ($usesLast) {
149
+			$pre .= "\n\t\t" . '$_loop' . $cnt . '_glob["last"] = (string) ($_loop' . $cnt . '_glob["iteration"] === $_loop' . $cnt . '_glob["total"]);';
150
+		}
151
+		$pre .= "\n\t\t" . '$_loop' . $cnt . '_scope = $this->setScope(array("-loop-"));' . "\n/* -- loop start output */\n" . Compiler::PHP_CLOSE;
152 152
 
153
-        // build post processing output and cache it
154
-        $post = Compiler::PHP_OPEN . "\n" . '/* -- loop end output */' . "\n\t\t" . '$this->setScope($_loop' . $cnt . '_scope, true);';
155
-        // update properties
156
-        if ($usesIndex) {
157
-            $post .= "\n\t\t" . '$_loop' . $cnt . '_glob["index"]+=1;';
158
-        }
159
-        if ($usesIteration) {
160
-            $post .= "\n\t\t" . '$_loop' . $cnt . '_glob["iteration"]+=1;';
161
-        }
162
-        // end loop
163
-        $post .= "\n\t}\n}\n" . Compiler::PHP_CLOSE;
164
-        if (isset($params['hasElse'])) {
165
-            $post .= $params['hasElse'];
166
-        }
153
+		// build post processing output and cache it
154
+		$post = Compiler::PHP_OPEN . "\n" . '/* -- loop end output */' . "\n\t\t" . '$this->setScope($_loop' . $cnt . '_scope, true);';
155
+		// update properties
156
+		if ($usesIndex) {
157
+			$post .= "\n\t\t" . '$_loop' . $cnt . '_glob["index"]+=1;';
158
+		}
159
+		if ($usesIteration) {
160
+			$post .= "\n\t\t" . '$_loop' . $cnt . '_glob["iteration"]+=1;';
161
+		}
162
+		// end loop
163
+		$post .= "\n\t}\n}\n" . Compiler::PHP_CLOSE;
164
+		if (isset($params['hasElse'])) {
165
+			$post .= $params['hasElse'];
166
+		}
167 167
 
168
-        return $pre . $content . $post;
169
-    }
168
+		return $pre . $content . $post;
169
+	}
170 170
 }
Please login to merge, or discard this patch.
Spacing   +28 added lines, -28 removed lines patch added patch discarded remove patch
@@ -95,76 +95,76 @@
 block discarded – undo
95 95
         $name = $params['name'];
96 96
 
97 97
         // evaluates which global variables have to be computed
98
-        $varName       = '$dwoo.loop.' . trim($name, '"\'') . '.';
99
-        $shortVarName  = '$.loop.' . trim($name, '"\'') . '.';
98
+        $varName       = '$dwoo.loop.'.trim($name, '"\'').'.';
99
+        $shortVarName  = '$.loop.'.trim($name, '"\'').'.';
100 100
         $usesAny       = strpos($tpl, $varName) !== false || strpos($tpl, $shortVarName) !== false;
101
-        $usesFirst     = strpos($tpl, $varName . 'first') !== false || strpos($tpl, $shortVarName . 'first') !== false;
102
-        $usesLast      = strpos($tpl, $varName . 'last') !== false || strpos($tpl, $shortVarName . 'last') !== false;
103
-        $usesIndex     = $usesFirst || strpos($tpl, $varName . 'index') !== false || strpos($tpl, $shortVarName . 'index') !== false;
104
-        $usesIteration = $usesLast || strpos($tpl, $varName . 'iteration') !== false || strpos($tpl, $shortVarName . 'iteration') !== false;
105
-        $usesShow      = strpos($tpl, $varName . 'show') !== false || strpos($tpl, $shortVarName . 'show') !== false;
106
-        $usesTotal     = $usesLast || strpos($tpl, $varName . 'total') !== false || strpos($tpl, $shortVarName . 'total') !== false;
101
+        $usesFirst     = strpos($tpl, $varName.'first') !== false || strpos($tpl, $shortVarName.'first') !== false;
102
+        $usesLast      = strpos($tpl, $varName.'last') !== false || strpos($tpl, $shortVarName.'last') !== false;
103
+        $usesIndex     = $usesFirst || strpos($tpl, $varName.'index') !== false || strpos($tpl, $shortVarName.'index') !== false;
104
+        $usesIteration = $usesLast || strpos($tpl, $varName.'iteration') !== false || strpos($tpl, $shortVarName.'iteration') !== false;
105
+        $usesShow      = strpos($tpl, $varName.'show') !== false || strpos($tpl, $shortVarName.'show') !== false;
106
+        $usesTotal     = $usesLast || strpos($tpl, $varName.'total') !== false || strpos($tpl, $shortVarName.'total') !== false;
107 107
 
108 108
         if (strpos($name, '$this->scope[') !== false) {
109 109
             $usesAny = $usesFirst = $usesLast = $usesIndex = $usesIteration = $usesShow = $usesTotal = true;
110 110
         }
111 111
 
112 112
         // gets foreach id
113
-        $cnt = self::$cnt ++;
113
+        $cnt = self::$cnt++;
114 114
 
115 115
         // builds pre processing output
116
-        $pre = Compiler::PHP_OPEN . "\n" . '$_loop' . $cnt . '_data = ' . $src . ';';
116
+        $pre = Compiler::PHP_OPEN."\n".'$_loop'.$cnt.'_data = '.$src.';';
117 117
         // adds foreach properties
118 118
         if ($usesAny) {
119
-            $pre .= "\n" . '$this->globals["loop"][' . $name . '] = array' . "\n(";
119
+            $pre .= "\n".'$this->globals["loop"]['.$name.'] = array'."\n(";
120 120
             if ($usesIndex) {
121
-                $pre .= "\n\t" . '"index"		=> 0,';
121
+                $pre .= "\n\t".'"index"		=> 0,';
122 122
             }
123 123
             if ($usesIteration) {
124
-                $pre .= "\n\t" . '"iteration"		=> 1,';
124
+                $pre .= "\n\t".'"iteration"		=> 1,';
125 125
             }
126 126
             if ($usesFirst) {
127
-                $pre .= "\n\t" . '"first"		=> null,';
127
+                $pre .= "\n\t".'"first"		=> null,';
128 128
             }
129 129
             if ($usesLast) {
130
-                $pre .= "\n\t" . '"last"		=> null,';
130
+                $pre .= "\n\t".'"last"		=> null,';
131 131
             }
132 132
             if ($usesShow) {
133
-                $pre .= "\n\t" . '"show"		=> $this->isTraversable($_loop' . $cnt . '_data, true),';
133
+                $pre .= "\n\t".'"show"		=> $this->isTraversable($_loop'.$cnt.'_data, true),';
134 134
             }
135 135
             if ($usesTotal) {
136
-                $pre .= "\n\t" . '"total"		=> $this->count($_loop' . $cnt . '_data),';
136
+                $pre .= "\n\t".'"total"		=> $this->count($_loop'.$cnt.'_data),';
137 137
             }
138
-            $pre .= "\n);\n" . '$_loop' . $cnt . '_glob =& $this->globals["loop"][' . $name . '];';
138
+            $pre .= "\n);\n".'$_loop'.$cnt.'_glob =& $this->globals["loop"]['.$name.'];';
139 139
         }
140 140
         // checks if the loop must be looped
141
-        $pre .= "\n" . 'if ($this->isTraversable($_loop' . $cnt . '_data' . (isset($params['hasElse']) ? ', true' : '') . ') == true)' . "\n{";
141
+        $pre .= "\n".'if ($this->isTraversable($_loop'.$cnt.'_data'.(isset($params['hasElse']) ? ', true' : '').') == true)'."\n{";
142 142
         // iterates over keys
143
-        $pre .= "\n\t" . 'foreach ($_loop' . $cnt . '_data as $tmp_key => $this->scope["-loop-"])' . "\n\t{";
143
+        $pre .= "\n\t".'foreach ($_loop'.$cnt.'_data as $tmp_key => $this->scope["-loop-"])'."\n\t{";
144 144
         // updates properties
145 145
         if ($usesFirst) {
146
-            $pre .= "\n\t\t" . '$_loop' . $cnt . '_glob["first"] = (string) ($_loop' . $cnt . '_glob["index"] === 0);';
146
+            $pre .= "\n\t\t".'$_loop'.$cnt.'_glob["first"] = (string) ($_loop'.$cnt.'_glob["index"] === 0);';
147 147
         }
148 148
         if ($usesLast) {
149
-            $pre .= "\n\t\t" . '$_loop' . $cnt . '_glob["last"] = (string) ($_loop' . $cnt . '_glob["iteration"] === $_loop' . $cnt . '_glob["total"]);';
149
+            $pre .= "\n\t\t".'$_loop'.$cnt.'_glob["last"] = (string) ($_loop'.$cnt.'_glob["iteration"] === $_loop'.$cnt.'_glob["total"]);';
150 150
         }
151
-        $pre .= "\n\t\t" . '$_loop' . $cnt . '_scope = $this->setScope(array("-loop-"));' . "\n/* -- loop start output */\n" . Compiler::PHP_CLOSE;
151
+        $pre .= "\n\t\t".'$_loop'.$cnt.'_scope = $this->setScope(array("-loop-"));'."\n/* -- loop start output */\n".Compiler::PHP_CLOSE;
152 152
 
153 153
         // build post processing output and cache it
154
-        $post = Compiler::PHP_OPEN . "\n" . '/* -- loop end output */' . "\n\t\t" . '$this->setScope($_loop' . $cnt . '_scope, true);';
154
+        $post = Compiler::PHP_OPEN."\n".'/* -- loop end output */'."\n\t\t".'$this->setScope($_loop'.$cnt.'_scope, true);';
155 155
         // update properties
156 156
         if ($usesIndex) {
157
-            $post .= "\n\t\t" . '$_loop' . $cnt . '_glob["index"]+=1;';
157
+            $post .= "\n\t\t".'$_loop'.$cnt.'_glob["index"]+=1;';
158 158
         }
159 159
         if ($usesIteration) {
160
-            $post .= "\n\t\t" . '$_loop' . $cnt . '_glob["iteration"]+=1;';
160
+            $post .= "\n\t\t".'$_loop'.$cnt.'_glob["iteration"]+=1;';
161 161
         }
162 162
         // end loop
163
-        $post .= "\n\t}\n}\n" . Compiler::PHP_CLOSE;
163
+        $post .= "\n\t}\n}\n".Compiler::PHP_CLOSE;
164 164
         if (isset($params['hasElse'])) {
165 165
             $post .= $params['hasElse'];
166 166
         }
167 167
 
168
-        return $pre . $content . $post;
168
+        return $pre.$content.$post;
169 169
     }
170 170
 }
Please login to merge, or discard this patch.
lib/Dwoo/Plugins/Blocks/PluginAutoEscape.php 3 patches
Indentation   +56 added lines, -56 removed lines patch added patch discarded remove patch
@@ -32,67 +32,67 @@
 block discarded – undo
32 32
  */
33 33
 class PluginAutoEscape extends BlockPlugin implements ICompilableBlock
34 34
 {
35
-    protected static $stack = array();
35
+	protected static $stack = array();
36 36
 
37
-    /**
38
-     * @param $enabled
39
-     */
40
-    public function init($enabled)
41
-    {
42
-    }
37
+	/**
38
+	 * @param $enabled
39
+	 */
40
+	public function init($enabled)
41
+	{
42
+	}
43 43
 
44
-    /**
45
-     * @param Compiler $compiler
46
-     * @param array    $params
47
-     * @param string   $prepend
48
-     * @param string   $append
49
-     * @param string   $type
50
-     *
51
-     * @return string
52
-     * @throws CompilationException
53
-     */
54
-    public static function preProcessing(Compiler $compiler, array $params, $prepend, $append, $type)
55
-    {
56
-        $params = $compiler->getCompiledParams($params);
57
-        switch (strtolower(trim((string)$params['enabled'], '"\''))) {
44
+	/**
45
+	 * @param Compiler $compiler
46
+	 * @param array    $params
47
+	 * @param string   $prepend
48
+	 * @param string   $append
49
+	 * @param string   $type
50
+	 *
51
+	 * @return string
52
+	 * @throws CompilationException
53
+	 */
54
+	public static function preProcessing(Compiler $compiler, array $params, $prepend, $append, $type)
55
+	{
56
+		$params = $compiler->getCompiledParams($params);
57
+		switch (strtolower(trim((string)$params['enabled'], '"\''))) {
58 58
 
59
-            case 'on':
60
-            case 'true':
61
-            case 'enabled':
62
-            case 'enable':
63
-            case '1':
64
-                $enable = true;
65
-                break;
66
-            case 'off':
67
-            case 'false':
68
-            case 'disabled':
69
-            case 'disable':
70
-            case '0':
71
-                $enable = false;
72
-                break;
73
-            default:
74
-                throw new CompilationException($compiler, 'Auto_Escape : Invalid parameter (' . $params['enabled'] . '), valid parameters are "enable"/true or "disable"/false');
75
-        }
59
+			case 'on':
60
+			case 'true':
61
+			case 'enabled':
62
+			case 'enable':
63
+			case '1':
64
+				$enable = true;
65
+				break;
66
+			case 'off':
67
+			case 'false':
68
+			case 'disabled':
69
+			case 'disable':
70
+			case '0':
71
+				$enable = false;
72
+				break;
73
+			default:
74
+				throw new CompilationException($compiler, 'Auto_Escape : Invalid parameter (' . $params['enabled'] . '), valid parameters are "enable"/true or "disable"/false');
75
+		}
76 76
 
77
-        self::$stack[] = $compiler->getAutoEscape();
78
-        $compiler->setAutoEscape($enable);
77
+		self::$stack[] = $compiler->getAutoEscape();
78
+		$compiler->setAutoEscape($enable);
79 79
 
80
-        return '';
81
-    }
80
+		return '';
81
+	}
82 82
 
83
-    /**
84
-     * @param Compiler $compiler
85
-     * @param array    $params
86
-     * @param string   $prepend
87
-     * @param string   $append
88
-     * @param string   $content
89
-     *
90
-     * @return string
91
-     */
92
-    public static function postProcessing(Compiler $compiler, array $params, $prepend, $append, $content)
93
-    {
94
-        $compiler->setAutoEscape(array_pop(self::$stack));
83
+	/**
84
+	 * @param Compiler $compiler
85
+	 * @param array    $params
86
+	 * @param string   $prepend
87
+	 * @param string   $append
88
+	 * @param string   $content
89
+	 *
90
+	 * @return string
91
+	 */
92
+	public static function postProcessing(Compiler $compiler, array $params, $prepend, $append, $content)
93
+	{
94
+		$compiler->setAutoEscape(array_pop(self::$stack));
95 95
 
96
-        return $content;
97
-    }
96
+		return $content;
97
+	}
98 98
 }
Please login to merge, or discard this patch.
Switch Indentation   +16 added lines, -16 removed lines patch added patch discarded remove patch
@@ -56,22 +56,22 @@
 block discarded – undo
56 56
         $params = $compiler->getCompiledParams($params);
57 57
         switch (strtolower(trim((string)$params['enabled'], '"\''))) {
58 58
 
59
-            case 'on':
60
-            case 'true':
61
-            case 'enabled':
62
-            case 'enable':
63
-            case '1':
64
-                $enable = true;
65
-                break;
66
-            case 'off':
67
-            case 'false':
68
-            case 'disabled':
69
-            case 'disable':
70
-            case '0':
71
-                $enable = false;
72
-                break;
73
-            default:
74
-                throw new CompilationException($compiler, 'Auto_Escape : Invalid parameter (' . $params['enabled'] . '), valid parameters are "enable"/true or "disable"/false');
59
+        case 'on':
60
+        case 'true':
61
+        case 'enabled':
62
+        case 'enable':
63
+        case '1':
64
+            $enable = true;
65
+            break;
66
+        case 'off':
67
+        case 'false':
68
+        case 'disabled':
69
+        case 'disable':
70
+        case '0':
71
+            $enable = false;
72
+            break;
73
+        default:
74
+            throw new CompilationException($compiler, 'Auto_Escape : Invalid parameter (' . $params['enabled'] . '), valid parameters are "enable"/true or "disable"/false');
75 75
         }
76 76
 
77 77
         self::$stack[] = $compiler->getAutoEscape();
Please login to merge, or discard this patch.
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -54,7 +54,7 @@  discard block
 block discarded – undo
54 54
     public static function preProcessing(Compiler $compiler, array $params, $prepend, $append, $type)
55 55
     {
56 56
         $params = $compiler->getCompiledParams($params);
57
-        switch (strtolower(trim((string)$params['enabled'], '"\''))) {
57
+        switch (strtolower(trim((string) $params['enabled'], '"\''))) {
58 58
 
59 59
             case 'on':
60 60
             case 'true':
@@ -71,7 +71,7 @@  discard block
 block discarded – undo
71 71
                 $enable = false;
72 72
                 break;
73 73
             default:
74
-                throw new CompilationException($compiler, 'Auto_Escape : Invalid parameter (' . $params['enabled'] . '), valid parameters are "enable"/true or "disable"/false');
74
+                throw new CompilationException($compiler, 'Auto_Escape : Invalid parameter ('.$params['enabled'].'), valid parameters are "enable"/true or "disable"/false');
75 75
         }
76 76
 
77 77
         self::$stack[] = $compiler->getAutoEscape();
Please login to merge, or discard this patch.