@@ -39,14 +39,14 @@ discard block |
||
| 39 | 39 | $p = array(); |
| 40 | 40 | |
| 41 | 41 | reset($params); |
| 42 | - while (list($k,$v) = each($params)) { |
|
| 42 | + while (list($k, $v) = each($params)) { |
|
| 43 | 43 | $v = (string) $v; |
| 44 | - if(substr($v, 0, 1) === '"' || substr($v, 0, 1) === '\'') { |
|
| 44 | + if (substr($v, 0, 1) === '"' || substr($v, 0, 1) === '\'') { |
|
| 45 | 45 | $vmod = strtolower(substr($v, 1, -1)); |
| 46 | 46 | } else { |
| 47 | 47 | $vmod = strtolower($v); |
| 48 | 48 | } |
| 49 | - switch($vmod) { |
|
| 49 | + switch ($vmod) { |
|
| 50 | 50 | |
| 51 | 51 | case 'and': |
| 52 | 52 | if ($tokens[$k] === Dwoo_Compiler::T_UNQUOTED_STRING) { |
@@ -155,7 +155,7 @@ discard block |
||
| 155 | 155 | } else { |
| 156 | 156 | $negate = false; |
| 157 | 157 | } |
| 158 | - $ptr = 1+(int)$negate; |
|
| 158 | + $ptr = 1+(int) $negate; |
|
| 159 | 159 | if ($tokens[$k+$ptr] !== Dwoo_Compiler::T_UNQUOTED_STRING) { |
| 160 | 160 | break; |
| 161 | 161 | } |
@@ -164,27 +164,27 @@ discard block |
||
| 164 | 164 | } else { |
| 165 | 165 | $params[$k+$ptr] = trim($params[$k+$ptr], '"\''); |
| 166 | 166 | } |
| 167 | - switch($params[$k+$ptr]) { |
|
| 167 | + switch ($params[$k+$ptr]) { |
|
| 168 | 168 | |
| 169 | 169 | case 'div': |
| 170 | 170 | if (isset($params[$k+$ptr+1]) && strtolower(trim($params[$k+$ptr+1], '"\'')) === 'by') { |
| 171 | - $p[] = ' % '.$params[$k+$ptr+2].' '.($negate?'!':'=').'== 0'; |
|
| 171 | + $p[] = ' % '.$params[$k+$ptr+2].' '.($negate ? '!' : '=').'== 0'; |
|
| 172 | 172 | next($params); |
| 173 | 173 | next($params); |
| 174 | 174 | next($params); |
| 175 | 175 | } else { |
| 176 | - throw new Dwoo_Compilation_Exception($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]); |
|
| 176 | + throw new Dwoo_Compilation_Exception($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]); |
|
| 177 | 177 | } |
| 178 | 178 | break; |
| 179 | 179 | case 'even': |
| 180 | 180 | $a = array_pop($p); |
| 181 | 181 | if (isset($params[$k+$ptr+1]) && strtolower(trim($params[$k+$ptr+1], '"\'')) === 'by') { |
| 182 | 182 | $b = $params[$k+$ptr+2]; |
| 183 | - $p[] = '('.$a .' / '.$b.') % 2 '.($negate?'!':'=').'== 0'; |
|
| 183 | + $p[] = '('.$a.' / '.$b.') % 2 '.($negate ? '!' : '=').'== 0'; |
|
| 184 | 184 | next($params); |
| 185 | 185 | next($params); |
| 186 | 186 | } else { |
| 187 | - $p[] = $a.' % 2 '.($negate?'!':'=').'== 0'; |
|
| 187 | + $p[] = $a.' % 2 '.($negate ? '!' : '=').'== 0'; |
|
| 188 | 188 | } |
| 189 | 189 | next($params); |
| 190 | 190 | break; |
@@ -192,11 +192,11 @@ discard block |
||
| 192 | 192 | $a = array_pop($p); |
| 193 | 193 | if (isset($params[$k+$ptr+1]) && strtolower(trim($params[$k+$ptr+1], '"\'')) === 'by') { |
| 194 | 194 | $b = $params[$k+$ptr+2]; |
| 195 | - $p[] = '('.$a .' / '.$b.') % 2 '.($negate?'=':'!').'== 0'; |
|
| 195 | + $p[] = '('.$a.' / '.$b.') % 2 '.($negate ? '=' : '!').'== 0'; |
|
| 196 | 196 | next($params); |
| 197 | 197 | next($params); |
| 198 | 198 | } else { |
| 199 | - $p[] = $a.' % 2 '.($negate?'=':'!').'== 0'; |
|
| 199 | + $p[] = $a.' % 2 '.($negate ? '=' : '!').'== 0'; |
|
| 200 | 200 | } |
| 201 | 201 | next($params); |
| 202 | 202 | break; |
@@ -231,6 +231,6 @@ discard block |
||
| 231 | 231 | $post .= $params['hasElse']; |
| 232 | 232 | } |
| 233 | 233 | |
| 234 | - return $pre . $content . $post; |
|
| 234 | + return $pre.$content.$post; |
|
| 235 | 235 | } |
| 236 | 236 | } |
@@ -46,7 +46,7 @@ discard block |
||
| 46 | 46 | { |
| 47 | 47 | $params = $compiler->getCompiledParams($params); |
| 48 | 48 | |
| 49 | - $out = $content . Dwoo_Compiler::PHP_OPEN.$prepend."\n".'$tmp = ob_get_clean();'; |
|
| 49 | + $out = $content.Dwoo_Compiler::PHP_OPEN.$prepend."\n".'$tmp = ob_get_clean();'; |
|
| 50 | 50 | if ($params['trim'] !== 'false' && $params['trim'] !== 0) { |
| 51 | 51 | $out .= "\n".'$tmp = trim($tmp);'; |
| 52 | 52 | } |
@@ -56,6 +56,6 @@ discard block |
||
| 56 | 56 | if ($params['assign'] !== 'null') { |
| 57 | 57 | $out .= "\n".'$this->scope['.$params['assign'].'] = $tmp;'; |
| 58 | 58 | } |
| 59 | - return $out . "\n".'$this->globals[\'capture\']['.$params['name'].'] = $tmp;'.$append.Dwoo_Compiler::PHP_CLOSE; |
|
| 59 | + return $out."\n".'$this->globals[\'capture\']['.$params['name'].'] = $tmp;'.$append.Dwoo_Compiler::PHP_CLOSE; |
|
| 60 | 60 | } |
| 61 | 61 | } |
@@ -31,16 +31,16 @@ discard block |
||
| 31 | 31 | */ |
| 32 | 32 | class Dwoo_Plugin_foreach extends Dwoo_Block_Plugin implements Dwoo_ICompilable_Block, Dwoo_IElseable |
| 33 | 33 | { |
| 34 | - public static $cnt=0; |
|
| 34 | + public static $cnt = 0; |
|
| 35 | 35 | |
| 36 | - public function init($from, $key=null, $item=null, $name='default', $implode=null) |
|
| 36 | + public function init($from, $key = null, $item = null, $name = 'default', $implode = null) |
|
| 37 | 37 | { |
| 38 | 38 | } |
| 39 | 39 | |
| 40 | 40 | public static function preProcessing(Dwoo_Compiler $compiler, array $params, $prepend, $append, $type) |
| 41 | 41 | { |
| 42 | 42 | // get block params and save the current template pointer to use it in the postProcessing method |
| 43 | - $currentBlock =& $compiler->getCurrentBlock(); |
|
| 43 | + $currentBlock = & $compiler->getCurrentBlock(); |
|
| 44 | 44 | $currentBlock['params']['tplPointer'] = $compiler->getPointer(); |
| 45 | 45 | |
| 46 | 46 | return ''; |
@@ -101,22 +101,22 @@ discard block |
||
| 101 | 101 | $cnt = self::$cnt++; |
| 102 | 102 | |
| 103 | 103 | // build pre content output |
| 104 | - $pre = Dwoo_Compiler::PHP_OPEN . "\n".'$_fh'.$cnt.'_data = '.$src.';'; |
|
| 104 | + $pre = Dwoo_Compiler::PHP_OPEN."\n".'$_fh'.$cnt.'_data = '.$src.';'; |
|
| 105 | 105 | // adds foreach properties |
| 106 | 106 | if ($usesAny) { |
| 107 | 107 | $pre .= "\n".'$this->globals["foreach"]['.$name.'] = array'."\n("; |
| 108 | - if ($usesIndex) $pre .="\n\t".'"index" => 0,'; |
|
| 109 | - if ($usesIteration) $pre .="\n\t".'"iteration" => 1,'; |
|
| 110 | - if ($usesFirst) $pre .="\n\t".'"first" => null,'; |
|
| 111 | - if ($usesLast) $pre .="\n\t".'"last" => null,'; |
|
| 112 | - if ($usesShow) $pre .="\n\t".'"show" => $this->isArray($_fh'.$cnt.'_data, true),'; |
|
| 113 | - if ($usesTotal) $pre .="\n\t".'"total" => $this->count($_fh'.$cnt.'_data),'; |
|
| 114 | - $pre.="\n);\n".'$_fh'.$cnt.'_glob =& $this->globals["foreach"]['.$name.'];'; |
|
| 108 | + if ($usesIndex) $pre .= "\n\t".'"index" => 0,'; |
|
| 109 | + if ($usesIteration) $pre .= "\n\t".'"iteration" => 1,'; |
|
| 110 | + if ($usesFirst) $pre .= "\n\t".'"first" => null,'; |
|
| 111 | + if ($usesLast) $pre .= "\n\t".'"last" => null,'; |
|
| 112 | + if ($usesShow) $pre .= "\n\t".'"show" => $this->isArray($_fh'.$cnt.'_data, true),'; |
|
| 113 | + if ($usesTotal) $pre .= "\n\t".'"total" => $this->count($_fh'.$cnt.'_data),'; |
|
| 114 | + $pre .= "\n);\n".'$_fh'.$cnt.'_glob =& $this->globals["foreach"]['.$name.'];'; |
|
| 115 | 115 | } |
| 116 | 116 | // checks if foreach must be looped |
| 117 | 117 | $pre .= "\n".'if ($this->isTraversable($_fh'.$cnt.'_data'.(isset($params['hasElse']) ? ', true' : '').') == true)'."\n{"; |
| 118 | 118 | // iterates over keys |
| 119 | - $pre .= "\n\t".'foreach ($_fh'.$cnt.'_data as '.(isset($key)?'$this->scope['.$key.']=>':'').'$this->scope['.$val.'])'."\n\t{"; |
|
| 119 | + $pre .= "\n\t".'foreach ($_fh'.$cnt.'_data as '.(isset($key) ? '$this->scope['.$key.']=>' : '').'$this->scope['.$val.'])'."\n\t{"; |
|
| 120 | 120 | // updates properties |
| 121 | 121 | if ($usesFirst) { |
| 122 | 122 | $pre .= "\n\t\t".'$_fh'.$cnt.'_glob["first"] = (string) ($_fh'.$cnt.'_glob["index"] === 0);'; |
@@ -127,7 +127,7 @@ discard block |
||
| 127 | 127 | $pre .= "\n/* -- foreach start output */\n".Dwoo_Compiler::PHP_CLOSE; |
| 128 | 128 | |
| 129 | 129 | // build post content output |
| 130 | - $post = Dwoo_Compiler::PHP_OPEN . "\n"; |
|
| 130 | + $post = Dwoo_Compiler::PHP_OPEN."\n"; |
|
| 131 | 131 | |
| 132 | 132 | if (isset($implode)) { |
| 133 | 133 | $post .= '/* -- implode */'."\n".'if (!$_fh'.$cnt.'_glob["last"]) {'. |
@@ -136,10 +136,10 @@ discard block |
||
| 136 | 136 | $post .= '/* -- foreach end output */'; |
| 137 | 137 | // update properties |
| 138 | 138 | if ($usesIndex) { |
| 139 | - $post.="\n\t\t".'$_fh'.$cnt.'_glob["index"]+=1;'; |
|
| 139 | + $post .= "\n\t\t".'$_fh'.$cnt.'_glob["index"]+=1;'; |
|
| 140 | 140 | } |
| 141 | 141 | if ($usesIteration) { |
| 142 | - $post.="\n\t\t".'$_fh'.$cnt.'_glob["iteration"]+=1;'; |
|
| 142 | + $post .= "\n\t\t".'$_fh'.$cnt.'_glob["iteration"]+=1;'; |
|
| 143 | 143 | } |
| 144 | 144 | // end loop |
| 145 | 145 | $post .= "\n\t}\n}".Dwoo_Compiler::PHP_CLOSE; |
@@ -147,6 +147,6 @@ discard block |
||
| 147 | 147 | $post .= $params['hasElse']; |
| 148 | 148 | } |
| 149 | 149 | |
| 150 | - return $pre . $content . $post; |
|
| 150 | + return $pre.$content.$post; |
|
| 151 | 151 | } |
| 152 | 152 | } |
@@ -105,12 +105,24 @@ |
||
| 105 | 105 | // adds foreach properties |
| 106 | 106 | if ($usesAny) { |
| 107 | 107 | $pre .= "\n".'$this->globals["foreach"]['.$name.'] = array'."\n("; |
| 108 | - if ($usesIndex) $pre .="\n\t".'"index" => 0,'; |
|
| 109 | - if ($usesIteration) $pre .="\n\t".'"iteration" => 1,'; |
|
| 110 | - if ($usesFirst) $pre .="\n\t".'"first" => null,'; |
|
| 111 | - if ($usesLast) $pre .="\n\t".'"last" => null,'; |
|
| 112 | - if ($usesShow) $pre .="\n\t".'"show" => $this->isArray($_fh'.$cnt.'_data, true),'; |
|
| 113 | - if ($usesTotal) $pre .="\n\t".'"total" => $this->count($_fh'.$cnt.'_data),'; |
|
| 108 | + if ($usesIndex) { |
|
| 109 | + $pre .="\n\t".'"index" => 0,'; |
|
| 110 | + } |
|
| 111 | + if ($usesIteration) { |
|
| 112 | + $pre .="\n\t".'"iteration" => 1,'; |
|
| 113 | + } |
|
| 114 | + if ($usesFirst) { |
|
| 115 | + $pre .="\n\t".'"first" => null,'; |
|
| 116 | + } |
|
| 117 | + if ($usesLast) { |
|
| 118 | + $pre .="\n\t".'"last" => null,'; |
|
| 119 | + } |
|
| 120 | + if ($usesShow) { |
|
| 121 | + $pre .="\n\t".'"show" => $this->isArray($_fh'.$cnt.'_data, true),'; |
|
| 122 | + } |
|
| 123 | + if ($usesTotal) { |
|
| 124 | + $pre .="\n\t".'"total" => $this->count($_fh'.$cnt.'_data),'; |
|
| 125 | + } |
|
| 114 | 126 | $pre.="\n);\n".'$_fh'.$cnt.'_glob =& $this->globals["foreach"]['.$name.'];'; |
| 115 | 127 | } |
| 116 | 128 | // checks if foreach must be looped |
@@ -18,7 +18,7 @@ |
||
| 18 | 18 | */ |
| 19 | 19 | class Dwoo_Plugin_block extends Dwoo_Block_Plugin implements Dwoo_ICompilable_Block |
| 20 | 20 | { |
| 21 | - public function init($name='') |
|
| 21 | + public function init($name = '') |
|
| 22 | 22 | { |
| 23 | 23 | } |
| 24 | 24 | |
@@ -22,7 +22,7 @@ discard block |
||
| 22 | 22 | |
| 23 | 23 | public static function preProcessing(Dwoo_Compiler $compiler, array $params, $prepend, $append, $type) |
| 24 | 24 | { |
| 25 | - $with =& $compiler->findBlock('foreach', true); |
|
| 25 | + $with = & $compiler->findBlock('foreach', true); |
|
| 26 | 26 | |
| 27 | 27 | $params['initialized'] = true; |
| 28 | 28 | $compiler->injectBlock($type, $params); |
@@ -36,8 +36,8 @@ discard block |
||
| 36 | 36 | return ''; |
| 37 | 37 | } |
| 38 | 38 | |
| 39 | - $block =& $compiler->getCurrentBlock(); |
|
| 40 | - $block['params']['hasElse'] = Dwoo_Compiler::PHP_OPEN."else {\n".Dwoo_Compiler::PHP_CLOSE . $content . Dwoo_Compiler::PHP_OPEN."\n}".Dwoo_Compiler::PHP_CLOSE; |
|
| 39 | + $block = & $compiler->getCurrentBlock(); |
|
| 40 | + $block['params']['hasElse'] = Dwoo_Compiler::PHP_OPEN."else {\n".Dwoo_Compiler::PHP_CLOSE.$content.Dwoo_Compiler::PHP_OPEN."\n}".Dwoo_Compiler::PHP_CLOSE; |
|
| 41 | 41 | return ''; |
| 42 | 42 | } |
| 43 | 43 | } |
@@ -21,16 +21,16 @@ discard block |
||
| 21 | 21 | */ |
| 22 | 22 | class Dwoo_Plugin_for extends Dwoo_Block_Plugin implements Dwoo_ICompilable_Block, Dwoo_IElseable |
| 23 | 23 | { |
| 24 | - public static $cnt=0; |
|
| 24 | + public static $cnt = 0; |
|
| 25 | 25 | |
| 26 | - public function init($name, $from, $to=null, $step=1, $skip=0) |
|
| 26 | + public function init($name, $from, $to = null, $step = 1, $skip = 0) |
|
| 27 | 27 | { |
| 28 | 28 | } |
| 29 | 29 | |
| 30 | 30 | public static function preProcessing(Dwoo_Compiler $compiler, array $params, $prepend, $append, $type) |
| 31 | 31 | { |
| 32 | 32 | // get block params and save the current template pointer to use it in the postProcessing method |
| 33 | - $currentBlock =& $compiler->getCurrentBlock(); |
|
| 33 | + $currentBlock = & $compiler->getCurrentBlock(); |
|
| 34 | 34 | $currentBlock['params']['tplPointer'] = $compiler->getPointer(); |
| 35 | 35 | |
| 36 | 36 | return ''; |
@@ -66,7 +66,7 @@ discard block |
||
| 66 | 66 | $cnt = self::$cnt++; |
| 67 | 67 | |
| 68 | 68 | // builds pre processing output for |
| 69 | - $out = Dwoo_Compiler::PHP_OPEN . "\n".'$_for'.$cnt.'_from = '.$from.';'. |
|
| 69 | + $out = Dwoo_Compiler::PHP_OPEN."\n".'$_for'.$cnt.'_from = '.$from.';'. |
|
| 70 | 70 | "\n".'$_for'.$cnt.'_to = '.$to.';'. |
| 71 | 71 | "\n".'$_for'.$cnt.'_step = abs('.$step.');'. |
| 72 | 72 | "\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>\'); }'. |
@@ -74,13 +74,13 @@ discard block |
||
| 74 | 74 | // adds for properties |
| 75 | 75 | if ($usesAny) { |
| 76 | 76 | $out .= "\n".'$this->globals["for"]['.$name.'] = array'."\n("; |
| 77 | - if ($usesIndex) $out .="\n\t".'"index" => 0,'; |
|
| 78 | - if ($usesIteration) $out .="\n\t".'"iteration" => 1,'; |
|
| 79 | - if ($usesFirst) $out .="\n\t".'"first" => null,'; |
|
| 80 | - if ($usesLast) $out .="\n\t".'"last" => null,'; |
|
| 81 | - if ($usesShow) $out .="\n\t".'"show" => $tmp_shows,'; |
|
| 82 | - if ($usesTotal) $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),'; |
|
| 83 | - $out.="\n);\n".'$_for'.$cnt.'_glob =& $this->globals["for"]['.$name.'];'; |
|
| 77 | + if ($usesIndex) $out .= "\n\t".'"index" => 0,'; |
|
| 78 | + if ($usesIteration) $out .= "\n\t".'"iteration" => 1,'; |
|
| 79 | + if ($usesFirst) $out .= "\n\t".'"first" => null,'; |
|
| 80 | + if ($usesLast) $out .= "\n\t".'"last" => null,'; |
|
| 81 | + if ($usesShow) $out .= "\n\t".'"show" => $tmp_shows,'; |
|
| 82 | + if ($usesTotal) $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),'; |
|
| 83 | + $out .= "\n);\n".'$_for'.$cnt.'_glob =& $this->globals["for"]['.$name.'];'; |
|
| 84 | 84 | } |
| 85 | 85 | // checks if for must be looped |
| 86 | 86 | $out .= "\n".'if ($tmp_shows)'."\n{"; |
@@ -117,7 +117,7 @@ discard block |
||
| 117 | 117 | $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{"; |
| 118 | 118 | // updates properties |
| 119 | 119 | if ($usesIndex) { |
| 120 | - $out .="\n\t\t".'$_for'.$cnt.'_glob["index"] = $this->scope['.$name.'];'; |
|
| 120 | + $out .= "\n\t\t".'$_for'.$cnt.'_glob["index"] = $this->scope['.$name.'];'; |
|
| 121 | 121 | } |
| 122 | 122 | if ($usesFirst) { |
| 123 | 123 | $out .= "\n\t\t".'$_for'.$cnt.'_glob["first"] = (string) ($_for'.$cnt.'_glob["iteration"] === 1);'; |
@@ -129,7 +129,7 @@ discard block |
||
| 129 | 129 | |
| 130 | 130 | |
| 131 | 131 | // build post processing output and cache it |
| 132 | - $postOut = Dwoo_Compiler::PHP_OPEN . '/* -- for end output */'; |
|
| 132 | + $postOut = Dwoo_Compiler::PHP_OPEN.'/* -- for end output */'; |
|
| 133 | 133 | // update properties |
| 134 | 134 | if ($usesIteration) { |
| 135 | 135 | $postOut .= "\n\t\t".'$_for'.$cnt.'_glob["iteration"]+=1;'; |
@@ -141,6 +141,6 @@ discard block |
||
| 141 | 141 | $postOut .= $params['hasElse']; |
| 142 | 142 | } |
| 143 | 143 | |
| 144 | - return $out . $content . $postOut; |
|
| 144 | + return $out.$content.$postOut; |
|
| 145 | 145 | } |
| 146 | 146 | } |
@@ -74,12 +74,24 @@ |
||
| 74 | 74 | // adds for properties |
| 75 | 75 | if ($usesAny) { |
| 76 | 76 | $out .= "\n".'$this->globals["for"]['.$name.'] = array'."\n("; |
| 77 | - if ($usesIndex) $out .="\n\t".'"index" => 0,'; |
|
| 78 | - if ($usesIteration) $out .="\n\t".'"iteration" => 1,'; |
|
| 79 | - if ($usesFirst) $out .="\n\t".'"first" => null,'; |
|
| 80 | - if ($usesLast) $out .="\n\t".'"last" => null,'; |
|
| 81 | - if ($usesShow) $out .="\n\t".'"show" => $tmp_shows,'; |
|
| 82 | - if ($usesTotal) $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),'; |
|
| 77 | + if ($usesIndex) { |
|
| 78 | + $out .="\n\t".'"index" => 0,'; |
|
| 79 | + } |
|
| 80 | + if ($usesIteration) { |
|
| 81 | + $out .="\n\t".'"iteration" => 1,'; |
|
| 82 | + } |
|
| 83 | + if ($usesFirst) { |
|
| 84 | + $out .="\n\t".'"first" => null,'; |
|
| 85 | + } |
|
| 86 | + if ($usesLast) { |
|
| 87 | + $out .="\n\t".'"last" => null,'; |
|
| 88 | + } |
|
| 89 | + if ($usesShow) { |
|
| 90 | + $out .="\n\t".'"show" => $tmp_shows,'; |
|
| 91 | + } |
|
| 92 | + if ($usesTotal) { |
|
| 93 | + $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),'; |
|
| 94 | + } |
|
| 83 | 95 | $out.="\n);\n".'$_for'.$cnt.'_glob =& $this->globals["for"]['.$name.'];'; |
| 84 | 96 | } |
| 85 | 97 | // checks if for must be looped |
@@ -40,7 +40,7 @@ discard block |
||
| 40 | 40 | */ |
| 41 | 41 | class Dwoo_Plugin_with extends Dwoo_Block_Plugin implements Dwoo_ICompilable_Block, Dwoo_IElseable |
| 42 | 42 | { |
| 43 | - protected static $cnt=0; |
|
| 43 | + protected static $cnt = 0; |
|
| 44 | 44 | |
| 45 | 45 | public function init($var) |
| 46 | 46 | { |
@@ -59,11 +59,11 @@ discard block |
||
| 59 | 59 | $compiler->setScope($rparams['var']); |
| 60 | 60 | |
| 61 | 61 | |
| 62 | - $pre = Dwoo_Compiler::PHP_OPEN. 'if ('.$cparams['var'].')'."\n{\n". |
|
| 62 | + $pre = Dwoo_Compiler::PHP_OPEN.'if ('.$cparams['var'].')'."\n{\n". |
|
| 63 | 63 | '$_with'.(self::$cnt).' = $this->setScope("'.$rparams['var'].'");'. |
| 64 | 64 | "\n/* -- start with output */\n".Dwoo_Compiler::PHP_CLOSE; |
| 65 | 65 | |
| 66 | - $post = Dwoo_Compiler::PHP_OPEN. "\n/* -- end with output */\n". |
|
| 66 | + $post = Dwoo_Compiler::PHP_OPEN."\n/* -- end with output */\n". |
|
| 67 | 67 | '$this->setScope($_with'.(self::$cnt++).', true);'. |
| 68 | 68 | "\n}\n".Dwoo_Compiler::PHP_CLOSE; |
| 69 | 69 | |
@@ -71,6 +71,6 @@ discard block |
||
| 71 | 71 | $post .= $params['hasElse']; |
| 72 | 72 | } |
| 73 | 73 | |
| 74 | - return $pre . $content . $post; |
|
| 74 | + return $pre.$content.$post; |
|
| 75 | 75 | } |
| 76 | 76 | } |
@@ -38,7 +38,7 @@ discard block |
||
| 38 | 38 | $preContent = ''; |
| 39 | 39 | while (true) { |
| 40 | 40 | $preContent .= $compiler->removeTopBlock(); |
| 41 | - $block =& $compiler->getCurrentBlock(); |
|
| 41 | + $block = & $compiler->getCurrentBlock(); |
|
| 42 | 42 | if (!$block) { |
| 43 | 43 | throw new Dwoo_Compilation_Exception($compiler, 'An else block was found but it was not preceded by an if or other else-able construct'); |
| 44 | 44 | } |
@@ -59,8 +59,8 @@ discard block |
||
| 59 | 59 | return ''; |
| 60 | 60 | } |
| 61 | 61 | |
| 62 | - $block =& $compiler->getCurrentBlock(); |
|
| 63 | - $block['params']['hasElse'] = Dwoo_Compiler::PHP_OPEN."else {\n".Dwoo_Compiler::PHP_CLOSE . $content . Dwoo_Compiler::PHP_OPEN."\n}".Dwoo_Compiler::PHP_CLOSE; |
|
| 62 | + $block = & $compiler->getCurrentBlock(); |
|
| 63 | + $block['params']['hasElse'] = Dwoo_Compiler::PHP_OPEN."else {\n".Dwoo_Compiler::PHP_CLOSE.$content.Dwoo_Compiler::PHP_OPEN."\n}".Dwoo_Compiler::PHP_CLOSE; |
|
| 64 | 64 | return ''; |
| 65 | 65 | } |
| 66 | 66 | } |
@@ -44,7 +44,7 @@ discard block |
||
| 44 | 44 | $params['*'] = $parsedParams; |
| 45 | 45 | $params['uuid'] = uniqid(); |
| 46 | 46 | $compiler->addTemplatePlugin($params['name'], $parsedParams, $params['uuid']); |
| 47 | - $currentBlock =& $compiler->getCurrentBlock(); |
|
| 47 | + $currentBlock = & $compiler->getCurrentBlock(); |
|
| 48 | 48 | $currentBlock['params'] = $params; |
| 49 | 49 | return ''; |
| 50 | 50 | } |
@@ -58,9 +58,9 @@ discard block |
||
| 58 | 58 | $cleanup = '/* -- template end output */ $dwoo->setScope($_scope, true);'; |
| 59 | 59 | foreach ($params['*'] as $param=>$defValue) { |
| 60 | 60 | if ($defValue === null) { |
| 61 | - $paramstr.=', $'.$param; |
|
| 61 | + $paramstr .= ', $'.$param; |
|
| 62 | 62 | } else { |
| 63 | - $paramstr.=', $'.$param.' = '.$defValue; |
|
| 63 | + $paramstr .= ', $'.$param.' = '.$defValue; |
|
| 64 | 64 | } |
| 65 | 65 | $init .= '$dwoo->scope[\''.$param.'\'] = $'.$param.";\n"; |
| 66 | 66 | } |
@@ -27,8 +27,9 @@ |
||
| 27 | 27 | { |
| 28 | 28 | $params = $compiler->getCompiledParams($params); |
| 29 | 29 | $parsedParams = array(); |
| 30 | - if (!isset($params['*'])) |
|
| 31 | - $params['*'] = array(); |
|
| 30 | + if (!isset($params['*'])) { |
|
| 31 | + $params['*'] = array(); |
|
| 32 | + } |
|
| 32 | 33 | foreach ($params['*'] as $param=>$defValue) { |
| 33 | 34 | if (is_numeric($param)) { |
| 34 | 35 | $param = $defValue; |