@@ -62,7 +62,7 @@ discard block |
||
62 | 62 | |
63 | 63 | $out .= $this->export($var, $scope); |
64 | 64 | |
65 | - return $out . '</div></div>'; |
|
65 | + return $out.'</div></div>'; |
|
66 | 66 | } |
67 | 67 | |
68 | 68 | protected function export($var, $scope) |
@@ -70,16 +70,16 @@ discard block |
||
70 | 70 | $out = ''; |
71 | 71 | foreach ($var as $i => $v) { |
72 | 72 | if (is_array($v) || (is_object($v) && $v instanceof Iterator)) { |
73 | - $out .= $i . ' (' . (is_array($v) ? 'array' : 'object: ' . get_class($v)) . ')'; |
|
73 | + $out .= $i.' ('.(is_array($v) ? 'array' : 'object: '.get_class($v)).')'; |
|
74 | 74 | if ($v === $scope) { |
75 | - $out .= ' (current scope):<div style="background:#ccc;padding-left:20px;">' . $this->export($v, $scope) . '</div>'; |
|
75 | + $out .= ' (current scope):<div style="background:#ccc;padding-left:20px;">'.$this->export($v, $scope).'</div>'; |
|
76 | 76 | } else { |
77 | - $out .= ':<div style="padding-left:20px;">' . $this->export($v, $scope) . '</div>'; |
|
77 | + $out .= ':<div style="padding-left:20px;">'.$this->export($v, $scope).'</div>'; |
|
78 | 78 | } |
79 | 79 | } elseif (is_object($v)) { |
80 | - $out .= $this->exportObj($i . ' (object: ' . get_class($v) . '):', $v); |
|
80 | + $out .= $this->exportObj($i.' (object: '.get_class($v).'):', $v); |
|
81 | 81 | } else { |
82 | - $out .= $this->exportVar($i . ' = ', $v); |
|
82 | + $out .= $this->exportVar($i.' = ', $v); |
|
83 | 83 | } |
84 | 84 | } |
85 | 85 | |
@@ -89,27 +89,27 @@ discard block |
||
89 | 89 | protected function exportVar($i, $v) |
90 | 90 | { |
91 | 91 | if (is_string($v) || is_bool($v) || is_numeric($v)) { |
92 | - return $i . htmlentities(var_export($v, true)) . '<br />'; |
|
92 | + return $i.htmlentities(var_export($v, true)).'<br />'; |
|
93 | 93 | } elseif (is_null($v)) { |
94 | - return $i . 'null<br />'; |
|
94 | + return $i.'null<br />'; |
|
95 | 95 | } elseif (is_resource($v)) { |
96 | - return $i . 'resource(' . get_resource_type($v) . ')<br />'; |
|
96 | + return $i.'resource('.get_resource_type($v).')<br />'; |
|
97 | 97 | } else { |
98 | - return $i . htmlentities(var_export($v, true)) . '<br />'; |
|
98 | + return $i.htmlentities(var_export($v, true)).'<br />'; |
|
99 | 99 | } |
100 | 100 | } |
101 | 101 | |
102 | 102 | protected function exportObj($i, $obj) |
103 | 103 | { |
104 | 104 | if (array_search($obj, $this->outputObjects, true) !== false) { |
105 | - return $i . ' [recursion, skipped]<br />'; |
|
105 | + return $i.' [recursion, skipped]<br />'; |
|
106 | 106 | } |
107 | 107 | |
108 | 108 | $this->outputObjects[] = $obj; |
109 | 109 | |
110 | - $list = (array)$obj; |
|
110 | + $list = (array) $obj; |
|
111 | 111 | |
112 | - $protectedLength = strlen(get_class($obj)) + 2; |
|
112 | + $protectedLength = strlen(get_class($obj))+2; |
|
113 | 113 | |
114 | 114 | $out = array(); |
115 | 115 | |
@@ -127,10 +127,10 @@ discard block |
||
127 | 127 | |
128 | 128 | $params = array(); |
129 | 129 | foreach ($method->getParameters() as $param) { |
130 | - $params[] = ($param->isPassedByReference() ? '&' : '') . '$' . $param->getName() . ($param->isOptional() ? ' = ' . var_export($param->getDefaultValue(), true) : ''); |
|
130 | + $params[] = ($param->isPassedByReference() ? '&' : '').'$'.$param->getName().($param->isOptional() ? ' = '.var_export($param->getDefaultValue(), true) : ''); |
|
131 | 131 | } |
132 | 132 | |
133 | - $out['method'] .= '(method) ' . $method->getName() . '(' . implode(', ', $params) . ')<br />'; |
|
133 | + $out['method'] .= '(method) '.$method->getName().'('.implode(', ', $params).')<br />'; |
|
134 | 134 | } |
135 | 135 | } |
136 | 136 | |
@@ -149,19 +149,19 @@ discard block |
||
149 | 149 | $out[$key] = ''; |
150 | 150 | } |
151 | 151 | |
152 | - $out[$key] .= '(' . $key . ') '; |
|
152 | + $out[$key] .= '('.$key.') '; |
|
153 | 153 | |
154 | 154 | if (is_array($attributeValue)) { |
155 | - $out[$key] .= $attributeName . ' (array):<br /> |
|
156 | - <div style="padding-left:20px;">' . $this->export($attributeValue, false) . '</div>'; |
|
155 | + $out[$key] .= $attributeName.' (array):<br /> |
|
156 | + <div style="padding-left:20px;">' . $this->export($attributeValue, false).'</div>'; |
|
157 | 157 | } elseif (is_object($attributeValue)) { |
158 | - $out[$key] .= $this->exportObj($attributeName . ' (object: ' . get_class($attributeValue) . '):', $attributeValue); |
|
158 | + $out[$key] .= $this->exportObj($attributeName.' (object: '.get_class($attributeValue).'):', $attributeValue); |
|
159 | 159 | } else { |
160 | - $out[$key] .= $this->exportVar($attributeName . ' = ', $attributeValue); |
|
160 | + $out[$key] .= $this->exportVar($attributeName.' = ', $attributeValue); |
|
161 | 161 | } |
162 | 162 | } |
163 | 163 | |
164 | - $return = $i . '<br /><div style="padding-left:20px;">'; |
|
164 | + $return = $i.'<br /><div style="padding-left:20px;">'; |
|
165 | 165 | |
166 | 166 | if (!empty($out['method'])) { |
167 | 167 | $return .= $out['method']; |
@@ -179,6 +179,6 @@ discard block |
||
179 | 179 | $return .= $out['private']; |
180 | 180 | } |
181 | 181 | |
182 | - return $return . '</div>'; |
|
182 | + return $return.'</div>'; |
|
183 | 183 | } |
184 | 184 | } |
@@ -51,35 +51,35 @@ |
||
51 | 51 | // init counter |
52 | 52 | if (!isset($this->counters[$name])) { |
53 | 53 | $this->counters[$name] = array( |
54 | - 'count' => $start === null ? 1 : (int)$start, |
|
55 | - 'skip' => $skip === null ? 1 : (int)$skip, |
|
56 | - 'print' => $print === null ? true : (bool)$print, |
|
57 | - 'assign' => $assign === null ? null : (string)$assign, |
|
58 | - 'direction' => strtolower($direction) === 'down' ? - 1 : 1, |
|
54 | + 'count' => $start === null ? 1 : (int) $start, |
|
55 | + 'skip' => $skip === null ? 1 : (int) $skip, |
|
56 | + 'print' => $print === null ? true : (bool) $print, |
|
57 | + 'assign' => $assign === null ? null : (string) $assign, |
|
58 | + 'direction' => strtolower($direction) === 'down' ? -1 : 1, |
|
59 | 59 | ); |
60 | 60 | } // increment |
61 | 61 | else { |
62 | 62 | // override setting if present |
63 | 63 | if ($skip !== null) { |
64 | - $this->counters[$name]['skip'] = (int)$skip; |
|
64 | + $this->counters[$name]['skip'] = (int) $skip; |
|
65 | 65 | } |
66 | 66 | |
67 | 67 | if ($direction !== null) { |
68 | - $this->counters[$name]['direction'] = strtolower($direction) === 'down' ? - 1 : 1; |
|
68 | + $this->counters[$name]['direction'] = strtolower($direction) === 'down' ? -1 : 1; |
|
69 | 69 | } |
70 | 70 | |
71 | 71 | if ($print !== null) { |
72 | - $this->counters[$name]['print'] = (bool)$print; |
|
72 | + $this->counters[$name]['print'] = (bool) $print; |
|
73 | 73 | } |
74 | 74 | |
75 | 75 | if ($assign !== null) { |
76 | - $this->counters[$name]['assign'] = (string)$assign; |
|
76 | + $this->counters[$name]['assign'] = (string) $assign; |
|
77 | 77 | } |
78 | 78 | |
79 | 79 | if ($start !== null) { |
80 | - $this->counters[$name]['count'] = (int)$start; |
|
80 | + $this->counters[$name]['count'] = (int) $start; |
|
81 | 81 | } else { |
82 | - $this->counters[$name]['count'] += ($this->counters[$name]['skip'] * $this->counters[$name]['direction']); |
|
82 | + $this->counters[$name]['count'] += ($this->counters[$name]['skip']*$this->counters[$name]['direction']); |
|
83 | 83 | } |
84 | 84 | } |
85 | 85 |
@@ -62,7 +62,7 @@ discard block |
||
62 | 62 | |
63 | 63 | reset($params); |
64 | 64 | while (list($k, $v) = each($params)) { |
65 | - $v = (string)$v; |
|
65 | + $v = (string) $v; |
|
66 | 66 | if (substr($v, 0, 1) === '"' || substr($v, 0, 1) === '\'') { |
67 | 67 | $vmod = strtolower(substr($v, 1, - 1)); |
68 | 68 | } else { |
@@ -171,59 +171,59 @@ discard block |
||
171 | 171 | $p[] = $v; |
172 | 172 | break; |
173 | 173 | } |
174 | - if (isset($params[$k + 1]) && strtolower(trim($params[$k + 1], '"\'')) === 'not' && $tokens[$k + 1] === Compiler::T_UNQUOTED_STRING) { |
|
174 | + if (isset($params[$k+1]) && strtolower(trim($params[$k+1], '"\'')) === 'not' && $tokens[$k+1] === Compiler::T_UNQUOTED_STRING) { |
|
175 | 175 | $negate = true; |
176 | 176 | next($params); |
177 | 177 | } else { |
178 | 178 | $negate = false; |
179 | 179 | } |
180 | - $ptr = 1 + (int)$negate; |
|
181 | - if ($tokens[$k + $ptr] !== Compiler::T_UNQUOTED_STRING) { |
|
180 | + $ptr = 1+(int) $negate; |
|
181 | + if ($tokens[$k+$ptr] !== Compiler::T_UNQUOTED_STRING) { |
|
182 | 182 | break; |
183 | 183 | } |
184 | - if (!isset($params[$k + $ptr])) { |
|
185 | - $params[$k + $ptr] = ''; |
|
184 | + if (!isset($params[$k+$ptr])) { |
|
185 | + $params[$k+$ptr] = ''; |
|
186 | 186 | } else { |
187 | - $params[$k + $ptr] = trim($params[$k + $ptr], '"\''); |
|
187 | + $params[$k+$ptr] = trim($params[$k+$ptr], '"\''); |
|
188 | 188 | } |
189 | - switch ($params[$k + $ptr]) { |
|
189 | + switch ($params[$k+$ptr]) { |
|
190 | 190 | |
191 | 191 | case 'div': |
192 | - if (isset($params[$k + $ptr + 1]) && strtolower(trim($params[$k + $ptr + 1], '"\'')) === 'by') { |
|
193 | - $p[] = ' % ' . $params[$k + $ptr + 2] . ' ' . ($negate ? '!' : '=') . '== 0'; |
|
192 | + if (isset($params[$k+$ptr+1]) && strtolower(trim($params[$k+$ptr+1], '"\'')) === 'by') { |
|
193 | + $p[] = ' % '.$params[$k+$ptr+2].' '.($negate ? '!' : '=').'== 0'; |
|
194 | 194 | next($params); |
195 | 195 | next($params); |
196 | 196 | next($params); |
197 | 197 | } else { |
198 | - throw new CompilationException($compiler, 'If : Syntax error : syntax should be "if $a is [not] div by $b", found ' . $params[$k - 1] . ' is ' . ($negate ? 'not ' : '') . 'div ' . $params[$k + $ptr + 1] . ' ' . $params[$k + $ptr + 2]); |
|
198 | + throw new CompilationException($compiler, 'If : Syntax error : syntax should be "if $a is [not] div by $b", found '.$params[$k-1].' is '.($negate ? 'not ' : '').'div '.$params[$k+$ptr+1].' '.$params[$k+$ptr+2]); |
|
199 | 199 | } |
200 | 200 | break; |
201 | 201 | case 'even': |
202 | 202 | $a = array_pop($p); |
203 | - if (isset($params[$k + $ptr + 1]) && strtolower(trim($params[$k + $ptr + 1], '"\'')) === 'by') { |
|
204 | - $b = $params[$k + $ptr + 2]; |
|
205 | - $p[] = '(' . $a . ' / ' . $b . ') % 2 ' . ($negate ? '!' : '=') . '== 0'; |
|
203 | + if (isset($params[$k+$ptr+1]) && strtolower(trim($params[$k+$ptr+1], '"\'')) === 'by') { |
|
204 | + $b = $params[$k+$ptr+2]; |
|
205 | + $p[] = '('.$a.' / '.$b.') % 2 '.($negate ? '!' : '=').'== 0'; |
|
206 | 206 | next($params); |
207 | 207 | next($params); |
208 | 208 | } else { |
209 | - $p[] = $a . ' % 2 ' . ($negate ? '!' : '=') . '== 0'; |
|
209 | + $p[] = $a.' % 2 '.($negate ? '!' : '=').'== 0'; |
|
210 | 210 | } |
211 | 211 | next($params); |
212 | 212 | break; |
213 | 213 | case 'odd': |
214 | 214 | $a = array_pop($p); |
215 | - if (isset($params[$k + $ptr + 1]) && strtolower(trim($params[$k + $ptr + 1], '"\'')) === 'by') { |
|
216 | - $b = $params[$k + $ptr + 2]; |
|
217 | - $p[] = '(' . $a . ' / ' . $b . ') % 2 ' . ($negate ? '=' : '!') . '== 0'; |
|
215 | + if (isset($params[$k+$ptr+1]) && strtolower(trim($params[$k+$ptr+1], '"\'')) === 'by') { |
|
216 | + $b = $params[$k+$ptr+2]; |
|
217 | + $p[] = '('.$a.' / '.$b.') % 2 '.($negate ? '=' : '!').'== 0'; |
|
218 | 218 | next($params); |
219 | 219 | next($params); |
220 | 220 | } else { |
221 | - $p[] = $a . ' % 2 ' . ($negate ? '=' : '!') . '== 0'; |
|
221 | + $p[] = $a.' % 2 '.($negate ? '=' : '!').'== 0'; |
|
222 | 222 | } |
223 | 223 | next($params); |
224 | 224 | break; |
225 | 225 | default: |
226 | - throw new CompilationException($compiler, 'If : Syntax error : syntax should be "if $a is [not] (div|even|odd) [by $b]", found ' . $params[$k - 1] . ' is ' . $params[$k + $ptr + 1]); |
|
226 | + throw new CompilationException($compiler, 'If : Syntax error : syntax should be "if $a is [not] (div|even|odd) [by $b]", found '.$params[$k-1].' is '.$params[$k+$ptr+1]); |
|
227 | 227 | } |
228 | 228 | break; |
229 | 229 | default: |
@@ -261,14 +261,14 @@ discard block |
||
261 | 261 | { |
262 | 262 | $tokens = $compiler->getParamTokens($params); |
263 | 263 | $params = $compiler->getCompiledParams($params); |
264 | - $pre = Compiler::PHP_OPEN . 'if (' . implode(' ', self::replaceKeywords($params['*'], $tokens['*'], $compiler)) . ") {\n" . Compiler::PHP_CLOSE; |
|
264 | + $pre = Compiler::PHP_OPEN.'if ('.implode(' ', self::replaceKeywords($params['*'], $tokens['*'], $compiler)).") {\n".Compiler::PHP_CLOSE; |
|
265 | 265 | |
266 | - $post = Compiler::PHP_OPEN . "\n}" . Compiler::PHP_CLOSE; |
|
266 | + $post = Compiler::PHP_OPEN."\n}".Compiler::PHP_CLOSE; |
|
267 | 267 | |
268 | 268 | if (isset($params['hasElse'])) { |
269 | 269 | $post .= $params['hasElse']; |
270 | 270 | } |
271 | 271 | |
272 | - return $pre . $content . $post; |
|
272 | + return $pre.$content.$post; |
|
273 | 273 | } |
274 | 274 | } |
@@ -58,26 +58,26 @@ discard block |
||
58 | 58 | $callback = $customPlugins[$func]['callback']; |
59 | 59 | if (is_array($callback)) { |
60 | 60 | if (is_object($callback[0])) { |
61 | - $callback = '$this->customPlugins[\'' . $func . '\'][0]->' . $callback[1] . '('; |
|
61 | + $callback = '$this->customPlugins[\''.$func.'\'][0]->'.$callback[1].'('; |
|
62 | 62 | } else { |
63 | - $callback = '' . $callback[0] . '::' . $callback[1] . '('; |
|
63 | + $callback = ''.$callback[0].'::'.$callback[1].'('; |
|
64 | 64 | } |
65 | 65 | } else { |
66 | - $callback = $callback . '('; |
|
66 | + $callback = $callback.'('; |
|
67 | 67 | } |
68 | 68 | } else { |
69 | - $callback = 'smarty_block_' . $func . '('; |
|
69 | + $callback = 'smarty_block_'.$func.'('; |
|
70 | 70 | } |
71 | 71 | |
72 | 72 | $paramsOut = ''; |
73 | 73 | foreach ($params as $i => $p) { |
74 | - $paramsOut .= var_export($i, true) . ' => ' . $p . ','; |
|
74 | + $paramsOut .= var_export($i, true).' => '.$p.','; |
|
75 | 75 | } |
76 | 76 | |
77 | 77 | $curBlock = &$compiler->getCurrentBlock(); |
78 | - $curBlock['params']['postOut'] = Compiler::PHP_OPEN . ' $_block_content = ob_get_clean(); $_block_repeat=false; echo ' . $callback . '$_tag_stack[count($_tag_stack)-1], $_block_content, $this, $_block_repeat); } array_pop($_tag_stack);' . Compiler::PHP_CLOSE; |
|
78 | + $curBlock['params']['postOut'] = Compiler::PHP_OPEN.' $_block_content = ob_get_clean(); $_block_repeat=false; echo '.$callback.'$_tag_stack[count($_tag_stack)-1], $_block_content, $this, $_block_repeat); } array_pop($_tag_stack);'.Compiler::PHP_CLOSE; |
|
79 | 79 | |
80 | - return Compiler::PHP_OPEN . $prepend . ' if (!isset($_tag_stack)){ $_tag_stack = array(); } $_tag_stack[] = array(' . $paramsOut . '); $_block_repeat=true; ' . $callback . '$_tag_stack[count($_tag_stack)-1], null, $this, $_block_repeat); while ($_block_repeat) { ob_start();' . Compiler::PHP_CLOSE; |
|
80 | + return Compiler::PHP_OPEN.$prepend.' if (!isset($_tag_stack)){ $_tag_stack = array(); } $_tag_stack[] = array('.$paramsOut.'); $_block_repeat=true; '.$callback.'$_tag_stack[count($_tag_stack)-1], null, $this, $_block_repeat); while ($_block_repeat) { ob_start();'.Compiler::PHP_CLOSE; |
|
81 | 81 | } |
82 | 82 | |
83 | 83 | /** |
@@ -91,6 +91,6 @@ discard block |
||
91 | 91 | */ |
92 | 92 | public static function postProcessing(Compiler $compiler, array $params, $prepend, $append, $content) |
93 | 93 | { |
94 | - return $content . $params['postOut']; |
|
94 | + return $content.$params['postOut']; |
|
95 | 95 | } |
96 | 96 | } |
@@ -67,18 +67,18 @@ discard block |
||
67 | 67 | } |
68 | 68 | catch (CompilationException $e) { |
69 | 69 | } |
70 | - $output = Compiler::PHP_OPEN . 'if($doCache) {' . "\n\t" . 'echo \'<dwoo:dynamic_\'.$dynamicId.\'>' . str_replace('\'', '\\\'', $content) . '</dwoo:dynamic_\'.$dynamicId.\'>\';' . "\n} else {\n\t"; |
|
70 | + $output = Compiler::PHP_OPEN.'if($doCache) {'."\n\t".'echo \'<dwoo:dynamic_\'.$dynamicId.\'>'.str_replace('\'', '\\\'', $content).'</dwoo:dynamic_\'.$dynamicId.\'>\';'."\n} else {\n\t"; |
|
71 | 71 | if (substr($content, 0, strlen(Compiler::PHP_OPEN)) == Compiler::PHP_OPEN) { |
72 | 72 | $output .= substr($content, strlen(Compiler::PHP_OPEN)); |
73 | 73 | } else { |
74 | - $output .= Compiler::PHP_CLOSE . $content; |
|
74 | + $output .= Compiler::PHP_CLOSE.$content; |
|
75 | 75 | } |
76 | 76 | if (substr($output, - strlen(Compiler::PHP_CLOSE)) == Compiler::PHP_CLOSE) { |
77 | 77 | $output = substr($output, 0, - strlen(Compiler::PHP_CLOSE)); |
78 | 78 | } else { |
79 | 79 | $output .= Compiler::PHP_OPEN; |
80 | 80 | } |
81 | - $output .= "\n}" . Compiler::PHP_CLOSE; |
|
81 | + $output .= "\n}".Compiler::PHP_CLOSE; |
|
82 | 82 | |
83 | 83 | return $output; |
84 | 84 | } |
@@ -92,13 +92,13 @@ discard block |
||
92 | 92 | */ |
93 | 93 | public static function unescape($output, $dynamicId, $compiledFile) |
94 | 94 | { |
95 | - $output = preg_replace_callback('/<dwoo:dynamic_(' . $dynamicId . ')>(.+?)<\/dwoo:dynamic_' . $dynamicId . '>/s', array( |
|
95 | + $output = preg_replace_callback('/<dwoo:dynamic_('.$dynamicId.')>(.+?)<\/dwoo:dynamic_'.$dynamicId.'>/s', array( |
|
96 | 96 | 'self', |
97 | 97 | 'unescapePhp' |
98 | 98 | ), $output, - 1, $count); |
99 | 99 | // re-add the includes on top of the file |
100 | 100 | if ($count && preg_match('#/\* template head \*/(.+?)/\* end template head \*/#s', file_get_contents($compiledFile), $m)) { |
101 | - $output = '<?php ' . $m[1] . ' ?>' . $output; |
|
101 | + $output = '<?php '.$m[1].' ?>'.$output; |
|
102 | 102 | } |
103 | 103 | |
104 | 104 | return $output; |
@@ -111,6 +111,6 @@ discard block |
||
111 | 111 | */ |
112 | 112 | public static function unescapePhp($match) |
113 | 113 | { |
114 | - return preg_replace('{<\?php /\*' . $match[1] . '\*/ echo \'(.+?)\'; \?>}s', '$1', $match[2]); |
|
114 | + return preg_replace('{<\?php /\*'.$match[1].'\*/ echo \'(.+?)\'; \?>}s', '$1', $match[2]); |
|
115 | 115 | } |
116 | 116 | } |
@@ -64,8 +64,7 @@ |
||
64 | 64 | $compiler->findBlock('dynamic'); |
65 | 65 | |
66 | 66 | return $content; |
67 | - } |
|
68 | - catch (CompilationException $e) { |
|
67 | + } catch (CompilationException $e) { |
|
69 | 68 | } |
70 | 69 | $output = Compiler::PHP_OPEN . 'if($doCache) {' . "\n\t" . 'echo \'<dwoo:dynamic_\'.$dynamicId.\'>' . str_replace('\'', '\\\'', $content) . '</dwoo:dynamic_\'.$dynamicId.\'>\';' . "\n} else {\n\t"; |
71 | 70 | if (substr($content, 0, strlen(Compiler::PHP_OPEN)) == Compiler::PHP_OPEN) { |
@@ -72,13 +72,13 @@ discard block |
||
72 | 72 | break; |
73 | 73 | } |
74 | 74 | |
75 | - $this->wrap = (int)$wrap; |
|
76 | - $this->wrapChar = (string)$wrap_char; |
|
77 | - $this->wrapCut = (bool)$wrap_cut; |
|
78 | - $this->indent = (int)$indent; |
|
79 | - $this->indChar = (string)$indent_char; |
|
80 | - $this->indFirst = (int)$indent_first + $this->indent; |
|
81 | - $this->assign = (string)$assign; |
|
75 | + $this->wrap = (int) $wrap; |
|
76 | + $this->wrapChar = (string) $wrap_char; |
|
77 | + $this->wrapCut = (bool) $wrap_cut; |
|
78 | + $this->indent = (int) $indent; |
|
79 | + $this->indChar = (string) $indent_char; |
|
80 | + $this->indFirst = (int) $indent_first+$this->indent; |
|
81 | + $this->assign = (string) $assign; |
|
82 | 82 | } |
83 | 83 | |
84 | 84 | /** |
@@ -107,13 +107,13 @@ discard block |
||
107 | 107 | ), str_replace("\n", '', $pgs[$i])); |
108 | 108 | |
109 | 109 | // wordwraps + indents lines |
110 | - $pgs[$i] = str_repeat($this->indChar, $this->indFirst) . wordwrap($pgs[$i], max($this->wrap - $this->indent, 1), $this->wrapChar . str_repeat($this->indChar, $this->indent), $this->wrapCut); |
|
110 | + $pgs[$i] = str_repeat($this->indChar, $this->indFirst).wordwrap($pgs[$i], max($this->wrap-$this->indent, 1), $this->wrapChar.str_repeat($this->indChar, $this->indent), $this->wrapCut); |
|
111 | 111 | } |
112 | 112 | |
113 | 113 | if ($this->assign !== '') { |
114 | - $this->core->assignInScope(implode($this->wrapChar . $this->wrapChar, $pgs), $this->assign); |
|
114 | + $this->core->assignInScope(implode($this->wrapChar.$this->wrapChar, $pgs), $this->assign); |
|
115 | 115 | } else { |
116 | - return implode($this->wrapChar . $this->wrapChar, $pgs); |
|
116 | + return implode($this->wrapChar.$this->wrapChar, $pgs); |
|
117 | 117 | } |
118 | 118 | } |
119 | 119 | } |
@@ -63,7 +63,7 @@ discard block |
||
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 |
||
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 | } |
@@ -80,15 +80,15 @@ |
||
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 | } |
@@ -112,15 +112,15 @@ discard block |
||
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 |
||
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 | } |