@@ -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 |
@@ -32,6 +32,6 @@ |
||
| 32 | 32 | { |
| 33 | 33 | public static function compile(Compiler $compiler, $value) |
| 34 | 34 | { |
| 35 | - return 'preg_match_all(strcasecmp($this->charset, \'utf-8\')===0 ? \'#[\w\pL]+#u\' : \'#\w+#\', ' . $value . ', $tmp)'; |
|
| 35 | + return 'preg_match_all(strcasecmp($this->charset, \'utf-8\')===0 ? \'#[\w\pL]+#u\' : \'#\w+#\', '.$value.', $tmp)'; |
|
| 36 | 36 | } |
| 37 | 37 | } |
| 38 | 38 | \ No newline at end of file |
@@ -40,12 +40,12 @@ |
||
| 40 | 40 | if (is_array($value)) { |
| 41 | 41 | return array_reverse($value, $preserve_keys); |
| 42 | 42 | } elseif (($charset = $this->core->getCharset()) === 'iso-8859-1') { |
| 43 | - return strrev((string)$value); |
|
| 43 | + return strrev((string) $value); |
|
| 44 | 44 | } |
| 45 | 45 | |
| 46 | 46 | $strlen = mb_strlen($value); |
| 47 | 47 | $out = ''; |
| 48 | - while ($strlen --) { |
|
| 48 | + while ($strlen--) { |
|
| 49 | 49 | $out .= mb_substr($value, $strlen, 1, $charset); |
| 50 | 50 | } |
| 51 | 51 | |