@@ -54,7 +54,7 @@ discard block |
||
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 |
||
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(); |
@@ -79,44 +79,44 @@ discard block |
||
79 | 79 | $show = $params['show']; |
80 | 80 | |
81 | 81 | // gets unique id |
82 | - $cnt = self::$cnt ++; |
|
82 | + $cnt = self::$cnt++; |
|
83 | 83 | |
84 | - $output .= '$this->globals[\'section\'][' . $name . '] = array();' . "\n" . '$_section' . $cnt . ' =& $this->globals[\'section\'][' . $name . '];' . "\n"; |
|
84 | + $output .= '$this->globals[\'section\']['.$name.'] = array();'."\n".'$_section'.$cnt.' =& $this->globals[\'section\']['.$name.'];'."\n"; |
|
85 | 85 | |
86 | 86 | if ($loop !== 'null') { |
87 | - $output .= '$_section' . $cnt . '[\'loop\'] = is_array($tmp = ' . $loop . ') ? count($tmp) : max(0, (int) $tmp);' . "\n"; |
|
87 | + $output .= '$_section'.$cnt.'[\'loop\'] = is_array($tmp = '.$loop.') ? count($tmp) : max(0, (int) $tmp);'."\n"; |
|
88 | 88 | } else { |
89 | - $output .= '$_section' . $cnt . '[\'loop\'] = 1;' . "\n"; |
|
89 | + $output .= '$_section'.$cnt.'[\'loop\'] = 1;'."\n"; |
|
90 | 90 | } |
91 | 91 | |
92 | 92 | if ($show !== 'null') { |
93 | - $output .= '$_section' . $cnt . '[\'show\'] = ' . $show . ";\n"; |
|
93 | + $output .= '$_section'.$cnt.'[\'show\'] = '.$show.";\n"; |
|
94 | 94 | } else { |
95 | - $output .= '$_section' . $cnt . '[\'show\'] = true;' . "\n"; |
|
95 | + $output .= '$_section'.$cnt.'[\'show\'] = true;'."\n"; |
|
96 | 96 | } |
97 | 97 | |
98 | 98 | if ($name !== 'null') { |
99 | - $output .= '$_section' . $cnt . '[\'name\'] = ' . $name . ";\n"; |
|
99 | + $output .= '$_section'.$cnt.'[\'name\'] = '.$name.";\n"; |
|
100 | 100 | } else { |
101 | - $output .= '$_section' . $cnt . '[\'name\'] = true;' . "\n"; |
|
101 | + $output .= '$_section'.$cnt.'[\'name\'] = true;'."\n"; |
|
102 | 102 | } |
103 | 103 | |
104 | 104 | if ($max !== 'null') { |
105 | - $output .= '$_section' . $cnt . '[\'max\'] = (int)' . $max . ";\n" . 'if($_section' . $cnt . '[\'max\'] < 0) { $_section' . $cnt . '[\'max\'] = $_section' . $cnt . '[\'loop\']; }' . "\n"; |
|
105 | + $output .= '$_section'.$cnt.'[\'max\'] = (int)'.$max.";\n".'if($_section'.$cnt.'[\'max\'] < 0) { $_section'.$cnt.'[\'max\'] = $_section'.$cnt.'[\'loop\']; }'."\n"; |
|
106 | 106 | } else { |
107 | - $output .= '$_section' . $cnt . '[\'max\'] = $_section' . $cnt . '[\'loop\'];' . "\n"; |
|
107 | + $output .= '$_section'.$cnt.'[\'max\'] = $_section'.$cnt.'[\'loop\'];'."\n"; |
|
108 | 108 | } |
109 | 109 | |
110 | 110 | if ($step !== 'null') { |
111 | - $output .= '$_section' . $cnt . '[\'step\'] = (int)' . $step . ' == 0 ? 1 : (int) ' . $step . ";\n"; |
|
111 | + $output .= '$_section'.$cnt.'[\'step\'] = (int)'.$step.' == 0 ? 1 : (int) '.$step.";\n"; |
|
112 | 112 | } else { |
113 | - $output .= '$_section' . $cnt . '[\'step\'] = 1;' . "\n"; |
|
113 | + $output .= '$_section'.$cnt.'[\'step\'] = 1;'."\n"; |
|
114 | 114 | } |
115 | 115 | |
116 | 116 | if ($start !== 'null') { |
117 | - $output .= '$_section' . $cnt . '[\'start\'] = (int)' . $start . ";\n"; |
|
117 | + $output .= '$_section'.$cnt.'[\'start\'] = (int)'.$start.";\n"; |
|
118 | 118 | } else { |
119 | - $output .= '$_section' . $cnt . '[\'start\'] = $_section' . $cnt . '[\'step\'] > 0 ? 0 : $_section' . $cnt . '[\'loop\'] - 1;' . "\n" . 'if ($_section' . $cnt . '[\'start\'] < 0) { $_section' . $cnt . '[\'start\'] = max($_section' . $cnt . '[\'step\'] > 0 ? 0 : -1, $_section' . $cnt . '[\'loop\'] + $_section' . $cnt . '[\'start\']); } ' . "\n" . 'else { $_section' . $cnt . '[\'start\'] = min($_section' . $cnt . '[\'start\'], $_section' . $cnt . '[\'step\'] > 0 ? $_section' . $cnt . '[\'loop\'] : $_section' . $cnt . '[\'loop\'] -1); }' . "\n"; |
|
119 | + $output .= '$_section'.$cnt.'[\'start\'] = $_section'.$cnt.'[\'step\'] > 0 ? 0 : $_section'.$cnt.'[\'loop\'] - 1;'."\n".'if ($_section'.$cnt.'[\'start\'] < 0) { $_section'.$cnt.'[\'start\'] = max($_section'.$cnt.'[\'step\'] > 0 ? 0 : -1, $_section'.$cnt.'[\'loop\'] + $_section'.$cnt.'[\'start\']); } '."\n".'else { $_section'.$cnt.'[\'start\'] = min($_section'.$cnt.'[\'start\'], $_section'.$cnt.'[\'step\'] > 0 ? $_section'.$cnt.'[\'loop\'] : $_section'.$cnt.'[\'loop\'] -1); }'."\n"; |
|
120 | 120 | } |
121 | 121 | |
122 | 122 | /* if ($usesAny) { |
@@ -131,24 +131,24 @@ discard block |
||
131 | 131 | } |
132 | 132 | */ |
133 | 133 | |
134 | - $output .= 'if ($_section' . $cnt . '[\'show\']) {' . "\n"; |
|
134 | + $output .= 'if ($_section'.$cnt.'[\'show\']) {'."\n"; |
|
135 | 135 | if ($start === 'null' && $step === 'null' && $max === 'null') { |
136 | - $output .= ' $_section' . $cnt . '[\'total\'] = $_section' . $cnt . '[\'loop\'];' . "\n"; |
|
136 | + $output .= ' $_section'.$cnt.'[\'total\'] = $_section'.$cnt.'[\'loop\'];'."\n"; |
|
137 | 137 | } else { |
138 | - $output .= ' $_section' . $cnt . '[\'total\'] = min(ceil(($_section' . $cnt . '[\'step\'] > 0 ? $_section' . $cnt . '[\'loop\'] - $_section' . $cnt . '[\'start\'] : $_section' . $cnt . '[\'start\'] + 1) / abs($_section' . $cnt . '[\'step\'])), $_section' . $cnt . '[\'max\']);' . "\n"; |
|
138 | + $output .= ' $_section'.$cnt.'[\'total\'] = min(ceil(($_section'.$cnt.'[\'step\'] > 0 ? $_section'.$cnt.'[\'loop\'] - $_section'.$cnt.'[\'start\'] : $_section'.$cnt.'[\'start\'] + 1) / abs($_section'.$cnt.'[\'step\'])), $_section'.$cnt.'[\'max\']);'."\n"; |
|
139 | 139 | } |
140 | - $output .= ' if ($_section' . $cnt . '[\'total\'] == 0) {' . "\n" . ' $_section' . $cnt . '[\'show\'] = false;' . "\n" . ' }' . "\n" . '} else {' . "\n" . ' $_section' . $cnt . '[\'total\'] = 0;' . "\n}\n"; |
|
141 | - $output .= 'if ($_section' . $cnt . '[\'show\']) {' . "\n"; |
|
142 | - $output .= "\t" . 'for ($this->scope[' . $name . '] = $_section' . $cnt . '[\'start\'], $_section' . $cnt . '[\'iteration\'] = 1; ' . '$_section' . $cnt . '[\'iteration\'] <= $_section' . $cnt . '[\'total\']; ' . '$this->scope[' . $name . '] += $_section' . $cnt . '[\'step\'], $_section' . $cnt . '[\'iteration\']++) {' . "\n"; |
|
143 | - $output .= "\t\t" . '$_section' . $cnt . '[\'rownum\'] = $_section' . $cnt . '[\'iteration\'];' . "\n"; |
|
144 | - $output .= "\t\t" . '$_section' . $cnt . '[\'index_prev\'] = $this->scope[' . $name . '] - $_section' . $cnt . '[\'step\'];' . "\n"; |
|
145 | - $output .= "\t\t" . '$_section' . $cnt . '[\'index_next\'] = $this->scope[' . $name . '] + $_section' . $cnt . '[\'step\'];' . "\n"; |
|
146 | - $output .= "\t\t" . '$_section' . $cnt . '[\'first\'] = ($_section' . $cnt . '[\'iteration\'] == 1);' . "\n"; |
|
147 | - $output .= "\t\t" . '$_section' . $cnt . '[\'last\'] = ($_section' . $cnt . '[\'iteration\'] == $_section' . $cnt . '[\'total\']);' . "\n"; |
|
148 | - |
|
149 | - $output .= Compiler::PHP_CLOSE . $content . Compiler::PHP_OPEN; |
|
150 | - |
|
151 | - $output .= "\n\t}\n} " . Compiler::PHP_CLOSE; |
|
140 | + $output .= ' if ($_section'.$cnt.'[\'total\'] == 0) {'."\n".' $_section'.$cnt.'[\'show\'] = false;'."\n".' }'."\n".'} else {'."\n".' $_section'.$cnt.'[\'total\'] = 0;'."\n}\n"; |
|
141 | + $output .= 'if ($_section'.$cnt.'[\'show\']) {'."\n"; |
|
142 | + $output .= "\t".'for ($this->scope['.$name.'] = $_section'.$cnt.'[\'start\'], $_section'.$cnt.'[\'iteration\'] = 1; '.'$_section'.$cnt.'[\'iteration\'] <= $_section'.$cnt.'[\'total\']; '.'$this->scope['.$name.'] += $_section'.$cnt.'[\'step\'], $_section'.$cnt.'[\'iteration\']++) {'."\n"; |
|
143 | + $output .= "\t\t".'$_section'.$cnt.'[\'rownum\'] = $_section'.$cnt.'[\'iteration\'];'."\n"; |
|
144 | + $output .= "\t\t".'$_section'.$cnt.'[\'index_prev\'] = $this->scope['.$name.'] - $_section'.$cnt.'[\'step\'];'."\n"; |
|
145 | + $output .= "\t\t".'$_section'.$cnt.'[\'index_next\'] = $this->scope['.$name.'] + $_section'.$cnt.'[\'step\'];'."\n"; |
|
146 | + $output .= "\t\t".'$_section'.$cnt.'[\'first\'] = ($_section'.$cnt.'[\'iteration\'] == 1);'."\n"; |
|
147 | + $output .= "\t\t".'$_section'.$cnt.'[\'last\'] = ($_section'.$cnt.'[\'iteration\'] == $_section'.$cnt.'[\'total\']);'."\n"; |
|
148 | + |
|
149 | + $output .= Compiler::PHP_CLOSE.$content.Compiler::PHP_OPEN; |
|
150 | + |
|
151 | + $output .= "\n\t}\n} ".Compiler::PHP_CLOSE; |
|
152 | 152 | |
153 | 153 | if (isset($params['hasElse'])) { |
154 | 154 | $output .= $params['hasElse']; |
@@ -87,54 +87,54 @@ discard block |
||
87 | 87 | $to = $params['to']; |
88 | 88 | |
89 | 89 | // evaluates which global variables have to be computed |
90 | - $varName = '$dwoo.for.' . trim($name, '"\'') . '.'; |
|
91 | - $shortVarName = '$.for.' . trim($name, '"\'') . '.'; |
|
90 | + $varName = '$dwoo.for.'.trim($name, '"\'').'.'; |
|
91 | + $shortVarName = '$.for.'.trim($name, '"\'').'.'; |
|
92 | 92 | $usesAny = strpos($tpl, $varName) !== false || strpos($tpl, $shortVarName) !== false; |
93 | - $usesFirst = strpos($tpl, $varName . 'first') !== false || strpos($tpl, $shortVarName . 'first') !== false; |
|
94 | - $usesLast = strpos($tpl, $varName . 'last') !== false || strpos($tpl, $shortVarName . 'last') !== false; |
|
95 | - $usesIndex = strpos($tpl, $varName . 'index') !== false || strpos($tpl, $shortVarName . 'index') !== false; |
|
96 | - $usesIteration = $usesFirst || $usesLast || strpos($tpl, $varName . 'iteration') !== false || strpos($tpl, $shortVarName . 'iteration') !== false; |
|
97 | - $usesShow = strpos($tpl, $varName . 'show') !== false || strpos($tpl, $shortVarName . 'show') !== false; |
|
98 | - $usesTotal = $usesLast || strpos($tpl, $varName . 'total') !== false || strpos($tpl, $shortVarName . 'total') !== false; |
|
93 | + $usesFirst = strpos($tpl, $varName.'first') !== false || strpos($tpl, $shortVarName.'first') !== false; |
|
94 | + $usesLast = strpos($tpl, $varName.'last') !== false || strpos($tpl, $shortVarName.'last') !== false; |
|
95 | + $usesIndex = strpos($tpl, $varName.'index') !== false || strpos($tpl, $shortVarName.'index') !== false; |
|
96 | + $usesIteration = $usesFirst || $usesLast || strpos($tpl, $varName.'iteration') !== false || strpos($tpl, $shortVarName.'iteration') !== false; |
|
97 | + $usesShow = strpos($tpl, $varName.'show') !== false || strpos($tpl, $shortVarName.'show') !== false; |
|
98 | + $usesTotal = $usesLast || strpos($tpl, $varName.'total') !== false || strpos($tpl, $shortVarName.'total') !== false; |
|
99 | 99 | |
100 | 100 | if (strpos($name, '$this->scope[') !== false) { |
101 | 101 | $usesAny = $usesFirst = $usesLast = $usesIndex = $usesIteration = $usesShow = $usesTotal = true; |
102 | 102 | } |
103 | 103 | |
104 | 104 | // gets foreach id |
105 | - $cnt = self::$cnt ++; |
|
105 | + $cnt = self::$cnt++; |
|
106 | 106 | |
107 | 107 | // builds pre processing output for |
108 | - $out = Compiler::PHP_OPEN . "\n" . '$_for' . $cnt . '_from = ' . $from . ';' . "\n" . '$_for' . $cnt . '_to = ' . $to . ';' . "\n" . '$_for' . $cnt . '_step = abs(' . $step . ');' . "\n" . 'if (is_numeric($_for' . $cnt . '_from) && !is_numeric($_for' . $cnt . '_to)) { $this->triggerError(\'For requires the <em>to</em> parameter when using a numerical <em>from</em>\'); }' . "\n" . '$tmp_shows = $this->isArray($_for' . $cnt . '_from, true) || (is_numeric($_for' . $cnt . '_from) && (abs(($_for' . $cnt . '_from - $_for' . $cnt . '_to)/$_for' . $cnt . '_step) !== 0 || $_for' . $cnt . '_from == $_for' . $cnt . '_to));'; |
|
108 | + $out = Compiler::PHP_OPEN."\n".'$_for'.$cnt.'_from = '.$from.';'."\n".'$_for'.$cnt.'_to = '.$to.';'."\n".'$_for'.$cnt.'_step = abs('.$step.');'."\n".'if (is_numeric($_for'.$cnt.'_from) && !is_numeric($_for'.$cnt.'_to)) { $this->triggerError(\'For requires the <em>to</em> parameter when using a numerical <em>from</em>\'); }'."\n".'$tmp_shows = $this->isArray($_for'.$cnt.'_from, true) || (is_numeric($_for'.$cnt.'_from) && (abs(($_for'.$cnt.'_from - $_for'.$cnt.'_to)/$_for'.$cnt.'_step) !== 0 || $_for'.$cnt.'_from == $_for'.$cnt.'_to));'; |
|
109 | 109 | // adds for properties |
110 | 110 | if ($usesAny) { |
111 | - $out .= "\n" . '$this->globals["for"][' . $name . '] = array' . "\n("; |
|
111 | + $out .= "\n".'$this->globals["for"]['.$name.'] = array'."\n("; |
|
112 | 112 | if ($usesIndex) { |
113 | - $out .= "\n\t" . '"index" => 0,'; |
|
113 | + $out .= "\n\t".'"index" => 0,'; |
|
114 | 114 | } |
115 | 115 | if ($usesIteration) { |
116 | - $out .= "\n\t" . '"iteration" => 1,'; |
|
116 | + $out .= "\n\t".'"iteration" => 1,'; |
|
117 | 117 | } |
118 | 118 | if ($usesFirst) { |
119 | - $out .= "\n\t" . '"first" => null,'; |
|
119 | + $out .= "\n\t".'"first" => null,'; |
|
120 | 120 | } |
121 | 121 | if ($usesLast) { |
122 | - $out .= "\n\t" . '"last" => null,'; |
|
122 | + $out .= "\n\t".'"last" => null,'; |
|
123 | 123 | } |
124 | 124 | if ($usesShow) { |
125 | - $out .= "\n\t" . '"show" => $tmp_shows,'; |
|
125 | + $out .= "\n\t".'"show" => $tmp_shows,'; |
|
126 | 126 | } |
127 | 127 | if ($usesTotal) { |
128 | - $out .= "\n\t" . '"total" => $this->isArray($_for' . $cnt . '_from) ? floor($this->count($_for' . $cnt . '_from) / $_for' . $cnt . '_step) : (is_numeric($_for' . $cnt . '_from) ? abs(($_for' . $cnt . '_to + 1 - $_for' . $cnt . '_from)/$_for' . $cnt . '_step) : 0),'; |
|
128 | + $out .= "\n\t".'"total" => $this->isArray($_for'.$cnt.'_from) ? floor($this->count($_for'.$cnt.'_from) / $_for'.$cnt.'_step) : (is_numeric($_for'.$cnt.'_from) ? abs(($_for'.$cnt.'_to + 1 - $_for'.$cnt.'_from)/$_for'.$cnt.'_step) : 0),'; |
|
129 | 129 | } |
130 | - $out .= "\n);\n" . '$_for' . $cnt . '_glob =& $this->globals["for"][' . $name . '];'; |
|
130 | + $out .= "\n);\n".'$_for'.$cnt.'_glob =& $this->globals["for"]['.$name.'];'; |
|
131 | 131 | } |
132 | 132 | // checks if for must be looped |
133 | - $out .= "\n" . 'if ($tmp_shows)' . "\n{"; |
|
133 | + $out .= "\n".'if ($tmp_shows)'."\n{"; |
|
134 | 134 | // set from/to to correct values if an array was given |
135 | - $out .= "\n\t" . 'if ($this->isArray($_for' . $cnt . '_from' . (isset($params['hasElse']) ? ', true' : '') . ') == true) { |
|
136 | - $_for' . $cnt . '_to = is_numeric($_for' . $cnt . '_to) ? $_for' . $cnt . '_to - $_for' . $cnt . '_step : $this->count($_for' . $cnt . '_from) - 1; |
|
137 | - $_for' . $cnt . '_from = 0; |
|
135 | + $out .= "\n\t".'if ($this->isArray($_for'.$cnt.'_from'.(isset($params['hasElse']) ? ', true' : '').') == true) { |
|
136 | + $_for' . $cnt.'_to = is_numeric($_for'.$cnt.'_to) ? $_for'.$cnt.'_to - $_for'.$cnt.'_step : $this->count($_for'.$cnt.'_from) - 1; |
|
137 | + $_for' . $cnt.'_from = 0; |
|
138 | 138 | }'; |
139 | 139 | |
140 | 140 | // if input are pure numbers it shouldn't reorder them, if it's variables it gets too messy though so in that case a counter should be used |
@@ -143,8 +143,8 @@ discard block |
||
143 | 143 | $incrementer = '+'; |
144 | 144 | |
145 | 145 | if (preg_match('{^(["\']?)([0-9]+)\1$}', $from, $mN1) && preg_match('{^(["\']?)([0-9]+)\1$}', $to, $mN2)) { |
146 | - $from = (int)$mN1[2]; |
|
147 | - $to = (int)$mN2[2]; |
|
146 | + $from = (int) $mN1[2]; |
|
147 | + $to = (int) $mN2[2]; |
|
148 | 148 | if ($from > $to) { |
149 | 149 | $reverse = true; |
150 | 150 | $condition = '>='; |
@@ -154,39 +154,39 @@ discard block |
||
154 | 154 | |
155 | 155 | // reverse from and to if needed |
156 | 156 | if (!$reverse) { |
157 | - $out .= "\n\t" . 'if ($_for' . $cnt . '_from > $_for' . $cnt . '_to) { |
|
158 | - $tmp = $_for' . $cnt . '_from; |
|
159 | - $_for' . $cnt . '_from = $_for' . $cnt . '_to; |
|
160 | - $_for' . $cnt . '_to = $tmp; |
|
157 | + $out .= "\n\t".'if ($_for'.$cnt.'_from > $_for'.$cnt.'_to) { |
|
158 | + $tmp = $_for' . $cnt.'_from; |
|
159 | + $_for' . $cnt.'_from = $_for'.$cnt.'_to; |
|
160 | + $_for' . $cnt.'_to = $tmp; |
|
161 | 161 | }'; |
162 | 162 | } |
163 | 163 | |
164 | - $out .= "\n\t" . 'for ($this->scope[' . $name . '] = $_for' . $cnt . '_from; $this->scope[' . $name . '] ' . $condition . ' $_for' . $cnt . '_to; $this->scope[' . $name . '] ' . $incrementer . '= $_for' . $cnt . '_step)' . "\n\t{"; |
|
164 | + $out .= "\n\t".'for ($this->scope['.$name.'] = $_for'.$cnt.'_from; $this->scope['.$name.'] '.$condition.' $_for'.$cnt.'_to; $this->scope['.$name.'] '.$incrementer.'= $_for'.$cnt.'_step)'."\n\t{"; |
|
165 | 165 | // updates properties |
166 | 166 | if ($usesIndex) { |
167 | - $out .= "\n\t\t" . '$_for' . $cnt . '_glob["index"] = $this->scope[' . $name . '];'; |
|
167 | + $out .= "\n\t\t".'$_for'.$cnt.'_glob["index"] = $this->scope['.$name.'];'; |
|
168 | 168 | } |
169 | 169 | if ($usesFirst) { |
170 | - $out .= "\n\t\t" . '$_for' . $cnt . '_glob["first"] = (string) ($_for' . $cnt . '_glob["iteration"] === 1);'; |
|
170 | + $out .= "\n\t\t".'$_for'.$cnt.'_glob["first"] = (string) ($_for'.$cnt.'_glob["iteration"] === 1);'; |
|
171 | 171 | } |
172 | 172 | if ($usesLast) { |
173 | - $out .= "\n\t\t" . '$_for' . $cnt . '_glob["last"] = (string) ($_for' . $cnt . '_glob["iteration"] === $_for' . $cnt . '_glob["total"]);'; |
|
173 | + $out .= "\n\t\t".'$_for'.$cnt.'_glob["last"] = (string) ($_for'.$cnt.'_glob["iteration"] === $_for'.$cnt.'_glob["total"]);'; |
|
174 | 174 | } |
175 | - $out .= "\n/* -- for start output */\n" . Compiler::PHP_CLOSE; |
|
175 | + $out .= "\n/* -- for start output */\n".Compiler::PHP_CLOSE; |
|
176 | 176 | |
177 | 177 | // build post processing output and cache it |
178 | - $postOut = Compiler::PHP_OPEN . '/* -- for end output */'; |
|
178 | + $postOut = Compiler::PHP_OPEN.'/* -- for end output */'; |
|
179 | 179 | // update properties |
180 | 180 | if ($usesIteration) { |
181 | - $postOut .= "\n\t\t" . '$_for' . $cnt . '_glob["iteration"]+=1;'; |
|
181 | + $postOut .= "\n\t\t".'$_for'.$cnt.'_glob["iteration"]+=1;'; |
|
182 | 182 | } |
183 | 183 | // end loop |
184 | - $postOut .= "\n\t}\n}\n" . Compiler::PHP_CLOSE; |
|
184 | + $postOut .= "\n\t}\n}\n".Compiler::PHP_CLOSE; |
|
185 | 185 | |
186 | 186 | if (isset($params['hasElse'])) { |
187 | 187 | $postOut .= $params['hasElse']; |
188 | 188 | } |
189 | 189 | |
190 | - return $out . $content . $postOut; |
|
190 | + return $out.$content.$postOut; |
|
191 | 191 | } |
192 | 192 | } |
@@ -41,7 +41,7 @@ discard block |
||
41 | 41 | */ |
42 | 42 | public static function preProcessing(Compiler $compiler, array $params, $prepend, $append, $type) |
43 | 43 | { |
44 | - return '/* end template head */ ob_start(); /* template body */ ' . Compiler::PHP_CLOSE; |
|
44 | + return '/* end template head */ ob_start(); /* template body */ '.Compiler::PHP_CLOSE; |
|
45 | 45 | } |
46 | 46 | |
47 | 47 | /** |
@@ -55,6 +55,6 @@ discard block |
||
55 | 55 | */ |
56 | 56 | public static function postProcessing(Compiler $compiler, array $params, $prepend, $append, $content) |
57 | 57 | { |
58 | - return $content . Compiler::PHP_OPEN . ' /* end template body */' . "\n" . 'return $this->buffer . ob_get_clean();'; |
|
58 | + return $content.Compiler::PHP_OPEN.' /* end template body */'."\n".'return $this->buffer . ob_get_clean();'; |
|
59 | 59 | } |
60 | 60 | } |
@@ -78,7 +78,7 @@ discard block |
||
78 | 78 | { |
79 | 79 | // textarea, pre, code tags and comments are to be left alone to avoid any non-wanted whitespace inside them so it just outputs them as they were |
80 | 80 | if (substr($input[1], 0, 9) == '<textarea' || substr($input[1], 0, 4) == '<pre' || substr($input[1], 0, 5) == '<code' || substr($input[1], 0, 4) == '<!--' || substr($input[1], 0, 9) == '<![CDATA[') { |
81 | - return $input[1] . $input[3]; |
|
81 | + return $input[1].$input[3]; |
|
82 | 82 | } |
83 | 83 | // closing textarea, code and pre tags and self-closed tags (i.e. <br />) are printed as singleTags because we didn't use openTag for the formers and the latter is a single tag |
84 | 84 | if (substr($input[1], 0, 10) == '</textarea' || substr($input[1], 0, 5) == '</pre' || substr($input[1], 0, 6) == '</code' || substr($input[1], - 2) == '/>') { |
@@ -104,20 +104,20 @@ discard block |
||
104 | 104 | */ |
105 | 105 | protected static function openTag($tag, $add, $whitespace) |
106 | 106 | { |
107 | - $tabs = str_pad('', self::$tabCount ++, "\t"); |
|
107 | + $tabs = str_pad('', self::$tabCount++, "\t"); |
|
108 | 108 | |
109 | 109 | if (preg_match('#^<(a|label|option|textarea|h1|h2|h3|h4|h5|h6|strong|b|em|i|abbr|acronym|cite|span|sub|sup|u|s|title)(?: [^>]*|)>#', $tag)) { |
110 | 110 | // if it's one of those tag it's inline so it does not require a leading line break |
111 | - $result = $tag . $whitespace . str_replace("\n", "\n" . $tabs, $add); |
|
111 | + $result = $tag.$whitespace.str_replace("\n", "\n".$tabs, $add); |
|
112 | 112 | } elseif (substr($tag, 0, 9) == '<!DOCTYPE') { |
113 | 113 | // it's the doctype declaration so no line break here either |
114 | - $result = $tabs . $tag; |
|
114 | + $result = $tabs.$tag; |
|
115 | 115 | } else { |
116 | 116 | // normal block tag |
117 | - $result = "\n" . $tabs . $tag; |
|
117 | + $result = "\n".$tabs.$tag; |
|
118 | 118 | |
119 | 119 | if (!empty($add)) { |
120 | - $result .= "\n" . $tabs . "\t" . str_replace("\n", "\n\t" . $tabs, $add); |
|
120 | + $result .= "\n".$tabs."\t".str_replace("\n", "\n\t".$tabs, $add); |
|
121 | 121 | } |
122 | 122 | } |
123 | 123 | |
@@ -141,12 +141,12 @@ discard block |
||
141 | 141 | |
142 | 142 | // if it's one of those tag it's inline so it does not require a leading line break |
143 | 143 | if (preg_match('#^</(a|label|option|textarea|h1|h2|h3|h4|h5|h6|strong|b|em|i|abbr|acronym|cite|span|sub|sup|u|s|title)>#', $tag)) { |
144 | - $result = $tag . $whitespace . str_replace("\n", "\n" . $tabs, $add); |
|
144 | + $result = $tag.$whitespace.str_replace("\n", "\n".$tabs, $add); |
|
145 | 145 | } else { |
146 | - $result = "\n" . $tabs . $tag; |
|
146 | + $result = "\n".$tabs.$tag; |
|
147 | 147 | |
148 | 148 | if (!empty($add)) { |
149 | - $result .= "\n" . $tabs . "\t" . str_replace("\n", "\n\t" . $tabs, $add); |
|
149 | + $result .= "\n".$tabs."\t".str_replace("\n", "\n\t".$tabs, $add); |
|
150 | 150 | } |
151 | 151 | } |
152 | 152 | |
@@ -170,16 +170,16 @@ discard block |
||
170 | 170 | // if it's img, br it's inline so it does not require a leading line break |
171 | 171 | // if it's a closing textarea, code or pre tag, it does not require a leading line break either or it creates whitespace at the end of those blocks |
172 | 172 | if (preg_match('#^<(img|br|/textarea|/pre|/code)(?: [^>]*|)>#', $tag)) { |
173 | - $result = $tag . $whitespace; |
|
173 | + $result = $tag.$whitespace; |
|
174 | 174 | |
175 | 175 | if (!empty($add)) { |
176 | - $result .= str_replace("\n", "\n" . $tabs, $add); |
|
176 | + $result .= str_replace("\n", "\n".$tabs, $add); |
|
177 | 177 | } |
178 | 178 | } else { |
179 | - $result = "\n" . $tabs . $tag; |
|
179 | + $result = "\n".$tabs.$tag; |
|
180 | 180 | |
181 | 181 | if (!empty($add)) { |
182 | - $result .= "\n" . $tabs . str_replace("\n", "\n" . $tabs, $add); |
|
182 | + $result .= "\n".$tabs.str_replace("\n", "\n".$tabs, $add); |
|
183 | 183 | } |
184 | 184 | } |
185 | 185 |
@@ -290,7 +290,7 @@ |
||
290 | 290 | return call_user_func_array(array($obj, $method), $args); |
291 | 291 | } |
292 | 292 | } |
293 | - $dwoo->triggerError('The current security policy prevents you from calling ' . get_class($obj) . '::' . $method . '()'); |
|
293 | + $dwoo->triggerError('The current security policy prevents you from calling '.get_class($obj).'::'.$method.'()'); |
|
294 | 294 | |
295 | 295 | return null; |
296 | 296 | } |
@@ -38,6 +38,6 @@ |
||
38 | 38 | */ |
39 | 39 | public static function compile(Compiler $compiler, $var) |
40 | 40 | { |
41 | - return '(' . $var . ' !== null)'; |
|
41 | + return '('.$var.' !== null)'; |
|
42 | 42 | } |
43 | 43 | } |
44 | 44 | \ No newline at end of file |
@@ -67,7 +67,7 @@ |
||
67 | 67 | '%t', |
68 | 68 | '%T' |
69 | 69 | ); |
70 | - $_win_to = array( |
|
70 | + $_win_to = array( |
|
71 | 71 | '%m/%d/%y', |
72 | 72 | '%b', |
73 | 73 | "\n", |
@@ -46,9 +46,9 @@ |
||
46 | 46 | { |
47 | 47 | $out = array(); |
48 | 48 | foreach ($rest as $var => $val) { |
49 | - $out[] = '$this->setReturnValue(' . var_export($var, true) . ', ' . $val . ')'; |
|
49 | + $out[] = '$this->setReturnValue('.var_export($var, true).', '.$val.')'; |
|
50 | 50 | } |
51 | 51 | |
52 | - return '(' . implode('.', $out) . ')'; |
|
52 | + return '('.implode('.', $out).')'; |
|
53 | 53 | } |
54 | 54 | } |
55 | 55 | \ No newline at end of file |