@@ -63,12 +63,12 @@ discard block |
||
| 63 | 63 | } |
| 64 | 64 | if (array_key_exists($p, $this->compat['properties']) !== false) { |
| 65 | 65 | if ($this->show_compat_errors) { |
| 66 | - $this->triggerError('Property ' . $p . ' is not available in the Dwoo\Smarty\Adapter, however it might be implemented in the future, check out http://wiki.dwoo.org/index.php/SmartySupport for more details.', E_USER_NOTICE); |
|
| 66 | + $this->triggerError('Property '.$p.' is not available in the Dwoo\Smarty\Adapter, however it might be implemented in the future, check out http://wiki.dwoo.org/index.php/SmartySupport for more details.', E_USER_NOTICE); |
|
| 67 | 67 | } |
| 68 | 68 | $this->compat['properties'][$p] = $v; |
| 69 | 69 | } else { |
| 70 | 70 | if ($this->show_compat_errors) { |
| 71 | - $this->triggerError('Property ' . $p . ' is not available in the Dwoo\Smarty\Adapter, but it is not listed as such, so you might want to tell me about it at [email protected]', E_USER_NOTICE); |
|
| 71 | + $this->triggerError('Property '.$p.' is not available in the Dwoo\Smarty\Adapter, but it is not listed as such, so you might want to tell me about it at [email protected]', E_USER_NOTICE); |
|
| 72 | 72 | } |
| 73 | 73 | } |
| 74 | 74 | } |
@@ -82,13 +82,13 @@ discard block |
||
| 82 | 82 | { |
| 83 | 83 | if (array_key_exists($p, $this->compat['properties']) !== false) { |
| 84 | 84 | if ($this->show_compat_errors) { |
| 85 | - $this->triggerError('Property ' . $p . ' is not available in the Dwoo\Smarty\Adapter, however it might be implemented in the future, check out http://wiki.dwoo.org/index.php/SmartySupport for more details.', E_USER_NOTICE); |
|
| 85 | + $this->triggerError('Property '.$p.' is not available in the Dwoo\Smarty\Adapter, however it might be implemented in the future, check out http://wiki.dwoo.org/index.php/SmartySupport for more details.', E_USER_NOTICE); |
|
| 86 | 86 | } |
| 87 | 87 | |
| 88 | 88 | return $this->compat['properties'][$p]; |
| 89 | 89 | } else { |
| 90 | 90 | if ($this->show_compat_errors) { |
| 91 | - $this->triggerError('Property ' . $p . ' is not available in the Dwoo\Smarty\Adapter, but it is not listed as such, so you might want to tell me about it at [email protected]', E_USER_NOTICE); |
|
| 91 | + $this->triggerError('Property '.$p.' is not available in the Dwoo\Smarty\Adapter, but it is not listed as such, so you might want to tell me about it at [email protected]', E_USER_NOTICE); |
|
| 92 | 92 | } |
| 93 | 93 | } |
| 94 | 94 | } |
@@ -110,9 +110,9 @@ discard block |
||
| 110 | 110 | ); |
| 111 | 111 | } elseif ($this->show_compat_errors) { |
| 112 | 112 | if (array_search($m, $this->compat['methods']) !== false) { |
| 113 | - $this->triggerError('Method ' . $m . ' is not available in the Dwoo\Smarty\Adapter, however it might be implemented in the future, check out http://wiki.dwoo.org/index.php/SmartySupport for more details.', E_USER_NOTICE); |
|
| 113 | + $this->triggerError('Method '.$m.' is not available in the Dwoo\Smarty\Adapter, however it might be implemented in the future, check out http://wiki.dwoo.org/index.php/SmartySupport for more details.', E_USER_NOTICE); |
|
| 114 | 114 | } else { |
| 115 | - $this->triggerError('Method ' . $m . ' is not available in the Dwoo\Smarty\Adapter, but it is not listed as such, so you might want to tell me about it at [email protected]', E_USER_NOTICE); |
|
| 115 | + $this->triggerError('Method '.$m.' is not available in the Dwoo\Smarty\Adapter, but it is not listed as such, so you might want to tell me about it at [email protected]', E_USER_NOTICE); |
|
| 116 | 116 | } |
| 117 | 117 | } |
| 118 | 118 | } |
@@ -525,7 +525,7 @@ discard block |
||
| 525 | 525 | if (isset($data[$name]) && is_object($data[$name])) { |
| 526 | 526 | return $data[$name]; |
| 527 | 527 | } else { |
| 528 | - trigger_error('Dwoo_Compiler: object "' . $name . '" was not registered or is not an object', E_USER_ERROR); |
|
| 528 | + trigger_error('Dwoo_Compiler: object "'.$name.'" was not registered or is not an object', E_USER_ERROR); |
|
| 529 | 529 | } |
| 530 | 530 | } |
| 531 | 531 | |
@@ -537,10 +537,10 @@ discard block |
||
| 537 | 537 | public function template_exists($filename) |
| 538 | 538 | { |
| 539 | 539 | if (!is_array($this->template_dir)) { |
| 540 | - return file_exists($this->template_dir . DIRECTORY_SEPARATOR . $filename); |
|
| 540 | + return file_exists($this->template_dir.DIRECTORY_SEPARATOR.$filename); |
|
| 541 | 541 | } else { |
| 542 | 542 | foreach ($this->template_dir as $tpl_dir) { |
| 543 | - if (file_exists($tpl_dir . DIRECTORY_SEPARATOR . $filename)) { |
|
| 543 | + if (file_exists($tpl_dir.DIRECTORY_SEPARATOR.$filename)) { |
|
| 544 | 544 | return true; |
| 545 | 545 | } |
| 546 | 546 | } |
@@ -669,7 +669,7 @@ discard block |
||
| 669 | 669 | $compileId = $this->compile_id; |
| 670 | 670 | } |
| 671 | 671 | |
| 672 | - $hash = bin2hex(md5($file . $cacheId . $compileId, true)); |
|
| 672 | + $hash = bin2hex(md5($file.$cacheId.$compileId, true)); |
|
| 673 | 673 | if (!isset(self::$tplCache[$hash])) { |
| 674 | 674 | // abs path |
| 675 | 675 | if (substr($file, 0, 1) === '/' || substr($file, 1, 1) === ':') { |
@@ -677,7 +677,7 @@ discard block |
||
| 677 | 677 | } elseif (is_string($this->template_dir) || is_array($this->template_dir)) { |
| 678 | 678 | self::$tplCache[$hash] = new TemplateFile($file, null, $cacheId, $compileId, $this->template_dir); |
| 679 | 679 | } else { |
| 680 | - throw new Exception('Unable to load "' . $file . '", check the template_dir'); |
|
| 680 | + throw new Exception('Unable to load "'.$file.'", check the template_dir'); |
|
| 681 | 681 | } |
| 682 | 682 | } |
| 683 | 683 | |
@@ -693,6 +693,6 @@ discard block |
||
| 693 | 693 | if (is_object($this->template)) { |
| 694 | 694 | parent::triggerError($message, $level); |
| 695 | 695 | } |
| 696 | - trigger_error('Dwoo error : ' . $message, $level); |
|
| 696 | + trigger_error('Dwoo error : '.$message, $level); |
|
| 697 | 697 | } |
| 698 | 698 | } |
@@ -79,24 +79,24 @@ |
||
| 79 | 79 | |
| 80 | 80 | $out = ''; |
| 81 | 81 | foreach ($params as $attr => $val) { |
| 82 | - $out .= ' ' . $attr . '='; |
|
| 82 | + $out .= ' '.$attr.'='; |
|
| 83 | 83 | if (trim($val, '"\'') == '' || $val == 'null') { |
| 84 | - $out .= str_replace($delim, '\\' . $delim, '""'); |
|
| 84 | + $out .= str_replace($delim, '\\'.$delim, '""'); |
|
| 85 | 85 | } elseif (substr($val, 0, 1) === $delim && substr($val, - 1) === $delim) { |
| 86 | - $out .= str_replace($delim, '\\' . $delim, '"' . substr($val, 1, - 1) . '"'); |
|
| 86 | + $out .= str_replace($delim, '\\'.$delim, '"'.substr($val, 1, - 1).'"'); |
|
| 87 | 87 | } else { |
| 88 | 88 | if (!$compiler) { |
| 89 | 89 | // disable double encoding since it can not be determined if it was encoded |
| 90 | - $escapedVal = '.(is_string($tmp2=' . $val . ') ? htmlspecialchars($tmp2, ENT_QUOTES, $this->charset, false) : $tmp2).'; |
|
| 90 | + $escapedVal = '.(is_string($tmp2='.$val.') ? htmlspecialchars($tmp2, ENT_QUOTES, $this->charset, false) : $tmp2).'; |
|
| 91 | 91 | } elseif (!$compiler->getAutoEscape() || false === strpos($val, 'isset($this->scope')) { |
| 92 | 92 | // escape if auto escaping is disabled, or there was no variable in the string |
| 93 | - $escapedVal = '.(is_string($tmp2=' . $val . ') ? htmlspecialchars($tmp2, ENT_QUOTES, $this->charset) : $tmp2).'; |
|
| 93 | + $escapedVal = '.(is_string($tmp2='.$val.') ? htmlspecialchars($tmp2, ENT_QUOTES, $this->charset) : $tmp2).'; |
|
| 94 | 94 | } else { |
| 95 | 95 | // print as is |
| 96 | - $escapedVal = '.' . $val . '.'; |
|
| 96 | + $escapedVal = '.'.$val.'.'; |
|
| 97 | 97 | } |
| 98 | 98 | |
| 99 | - $out .= str_replace($delim, '\\' . $delim, '"') . $delim . $escapedVal . $delim . str_replace($delim, '\\' . $delim, '"'); |
|
| 99 | + $out .= str_replace($delim, '\\'.$delim, '"').$delim.$escapedVal.$delim.str_replace($delim, '\\'.$delim, '"'); |
|
| 100 | 100 | } |
| 101 | 101 | } |
| 102 | 102 | |
@@ -88,7 +88,7 @@ discard block |
||
| 88 | 88 | */ |
| 89 | 89 | public static function preProcessing(DwooCompiler $compiler, array $params, $prepend, $append, $type) |
| 90 | 90 | { |
| 91 | - return DwooCompiler::PHP_OPEN . $prepend . '$this->addStack("' . $type . '", array(' . DwooCompiler::implode_r($compiler->getCompiledParams($params)) . '));' . $append . DwooCompiler::PHP_CLOSE; |
|
| 91 | + return DwooCompiler::PHP_OPEN.$prepend.'$this->addStack("'.$type.'", array('.DwooCompiler::implode_r($compiler->getCompiledParams($params)).'));'.$append.DwooCompiler::PHP_CLOSE; |
|
| 92 | 92 | } |
| 93 | 93 | |
| 94 | 94 | /** |
@@ -114,6 +114,6 @@ discard block |
||
| 114 | 114 | */ |
| 115 | 115 | public static function postProcessing(DwooCompiler $compiler, array $params, $prepend, $append, $content) |
| 116 | 116 | { |
| 117 | - return $content . DwooCompiler::PHP_OPEN . $prepend . '$this->delStack();' . $append . DwooCompiler::PHP_CLOSE; |
|
| 117 | + return $content.DwooCompiler::PHP_OPEN.$prepend.'$this->delStack();'.$append.DwooCompiler::PHP_CLOSE; |
|
| 118 | 118 | } |
| 119 | 119 | } |
@@ -38,38 +38,38 @@ discard block |
||
| 38 | 38 | $rl = preg_quote($l, '/'); |
| 39 | 39 | $rr = preg_quote($r, '/'); |
| 40 | 40 | $sectionParam = '(?:(name|loop|start|step|max|show)\s*=\s*(\S+))?\s*'; |
| 41 | - $input = preg_replace_callback('/' . $rl . '\s*section ' . str_repeat($sectionParam, 6) . '\s*' . $rr . '(.+?)(?:' . $rl . '\s*sectionelse\s*' . $rr . '(.+?))?' . $rl . '\s*\/section\s*' . $rr . '/is', array( |
|
| 41 | + $input = preg_replace_callback('/'.$rl.'\s*section '.str_repeat($sectionParam, 6).'\s*'.$rr.'(.+?)(?:'.$rl.'\s*sectionelse\s*'.$rr.'(.+?))?'.$rl.'\s*\/section\s*'.$rr.'/is', array( |
|
| 42 | 42 | $this, |
| 43 | 43 | 'convertSection' |
| 44 | 44 | ), $input); |
| 45 | - $input = str_replace('$smarty.section.', '$smarty.for.', $input); |
|
| 45 | + $input = str_replace('$smarty.section.', '$smarty.for.', $input); |
|
| 46 | 46 | |
| 47 | 47 | $smarty = array( |
| 48 | - '/' . $rl . '\s*ldelim\s*' . $rr . '/', |
|
| 49 | - '/' . $rl . '\s*rdelim\s*' . $rr . '/', |
|
| 50 | - '/' . $rl . '\s*\$smarty\.ldelim\s*' . $rr . '/', |
|
| 51 | - '/' . $rl . '\s*\$smarty\.rdelim\s*' . $rr . '/', |
|
| 48 | + '/'.$rl.'\s*ldelim\s*'.$rr.'/', |
|
| 49 | + '/'.$rl.'\s*rdelim\s*'.$rr.'/', |
|
| 50 | + '/'.$rl.'\s*\$smarty\.ldelim\s*'.$rr.'/', |
|
| 51 | + '/'.$rl.'\s*\$smarty\.rdelim\s*'.$rr.'/', |
|
| 52 | 52 | '/\$smarty\./', |
| 53 | - '/' . $rl . '\s*php\s*' . $rr . '/', |
|
| 54 | - '/' . $rl . '\s*\/php\s*' . $rr . '/', |
|
| 55 | - '/\|(@?)strip(\||' . $rr . ')/', |
|
| 56 | - '/' . $rl . '\s*sectionelse\s*' . $rr . '/', |
|
| 53 | + '/'.$rl.'\s*php\s*'.$rr.'/', |
|
| 54 | + '/'.$rl.'\s*\/php\s*'.$rr.'/', |
|
| 55 | + '/\|(@?)strip(\||'.$rr.')/', |
|
| 56 | + '/'.$rl.'\s*sectionelse\s*'.$rr.'/', |
|
| 57 | 57 | ); |
| 58 | 58 | |
| 59 | 59 | $dwoo = array( |
| 60 | - '\\' . $l, |
|
| 60 | + '\\'.$l, |
|
| 61 | 61 | $r, |
| 62 | - '\\' . $l, |
|
| 62 | + '\\'.$l, |
|
| 63 | 63 | $r, |
| 64 | 64 | '$dwoo.', |
| 65 | 65 | '<?php ', |
| 66 | 66 | ' ?>', |
| 67 | 67 | '|$1whitespace$2', |
| 68 | - $l . 'else' . $r, |
|
| 68 | + $l.'else'.$r, |
|
| 69 | 69 | ); |
| 70 | 70 | |
| 71 | 71 | if (preg_match('{\|@([a-z][a-z0-9_]*)}i', $input, $matches)) { |
| 72 | - trigger_error('The Smarty Compatibility Module has detected that you use |@' . $matches[1] . ' in your template, this might lead to problems as Dwoo interprets the @ operator differently than Smarty, see http://wiki.dwoo.org/index.php/Syntax#The_.40_Operator', E_USER_NOTICE); |
|
| 72 | + trigger_error('The Smarty Compatibility Module has detected that you use |@'.$matches[1].' in your template, this might lead to problems as Dwoo interprets the @ operator differently than Smarty, see http://wiki.dwoo.org/index.php/Syntax#The_.40_Operator', E_USER_NOTICE); |
|
| 73 | 73 | } |
| 74 | 74 | |
| 75 | 75 | return preg_replace($smarty, $dwoo, $input); |
@@ -85,10 +85,10 @@ discard block |
||
| 85 | 85 | $params = array(); |
| 86 | 86 | $index = 1; |
| 87 | 87 | while (!empty($matches[$index]) && $index < 13) { |
| 88 | - $params[$matches[$index]] = $matches[$index + 1]; |
|
| 88 | + $params[$matches[$index]] = $matches[$index+1]; |
|
| 89 | 89 | $index += 2; |
| 90 | 90 | } |
| 91 | 91 | |
| 92 | - return str_replace('[' . trim($params['name'], '"\'') . ']', '[$' . trim($params['name'], '"\'') . ']', $matches[0]); |
|
| 92 | + return str_replace('['.trim($params['name'], '"\'').']', '[$'.trim($params['name'], '"\'').']', $matches[0]); |
|
| 93 | 93 | } |
| 94 | 94 | } |
@@ -74,10 +74,10 @@ |
||
| 74 | 74 | } |
| 75 | 75 | |
| 76 | 76 | if ($advance) { |
| 77 | - if ($this->cycles[$name]['index'] >= count($values) - 1) { |
|
| 77 | + if ($this->cycles[$name]['index'] >= count($values)-1) { |
|
| 78 | 78 | $this->cycles[$name]['index'] = 0; |
| 79 | 79 | } else { |
| 80 | - ++ $this->cycles[$name]['index']; |
|
| 80 | + ++$this->cycles[$name]['index']; |
|
| 81 | 81 | } |
| 82 | 82 | } |
| 83 | 83 | |
@@ -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 | |
@@ -66,7 +66,7 @@ |
||
| 66 | 66 | } |
| 67 | 67 | |
| 68 | 68 | $block = &$compiler->getCurrentBlock(); |
| 69 | - $block['params']['hasElse'] = Compiler::PHP_OPEN . "else {\n" . Compiler::PHP_CLOSE . $content . Compiler::PHP_OPEN . "\n}" . Compiler::PHP_CLOSE; |
|
| 69 | + $block['params']['hasElse'] = Compiler::PHP_OPEN."else {\n".Compiler::PHP_CLOSE.$content.Compiler::PHP_OPEN."\n}".Compiler::PHP_CLOSE; |
|
| 70 | 70 | |
| 71 | 71 | return ''; |
| 72 | 72 | } |
@@ -70,164 +70,164 @@ |
||
| 70 | 70 | } |
| 71 | 71 | switch ($vmod) { |
| 72 | 72 | |
| 73 | - case 'and': |
|
| 74 | - if ($tokens[$k] === Compiler::T_UNQUOTED_STRING) { |
|
| 75 | - $p[] = '&&'; |
|
| 76 | - } else { |
|
| 77 | - $p[] = $v; |
|
| 78 | - } |
|
| 79 | - break; |
|
| 80 | - case 'or': |
|
| 81 | - if ($tokens[$k] === Compiler::T_UNQUOTED_STRING) { |
|
| 82 | - $p[] = '||'; |
|
| 83 | - } else { |
|
| 84 | - $p[] = $v; |
|
| 85 | - } |
|
| 86 | - break; |
|
| 87 | - case 'xor': |
|
| 88 | - if ($tokens[$k] === Compiler::T_UNQUOTED_STRING) { |
|
| 89 | - $p[] = '^'; |
|
| 90 | - } else { |
|
| 91 | - $p[] = $v; |
|
| 92 | - } |
|
| 93 | - break; |
|
| 94 | - case 'eq': |
|
| 95 | - if ($tokens[$k] === Compiler::T_UNQUOTED_STRING) { |
|
| 96 | - $p[] = '=='; |
|
| 97 | - } else { |
|
| 98 | - $p[] = $v; |
|
| 99 | - } |
|
| 100 | - break; |
|
| 101 | - case 'ne': |
|
| 102 | - case 'neq': |
|
| 103 | - if ($tokens[$k] === Compiler::T_UNQUOTED_STRING) { |
|
| 104 | - $p[] = '!='; |
|
| 105 | - } else { |
|
| 106 | - $p[] = $v; |
|
| 107 | - } |
|
| 108 | - break; |
|
| 109 | - case 'gte': |
|
| 110 | - case 'ge': |
|
| 111 | - if ($tokens[$k] === Compiler::T_UNQUOTED_STRING) { |
|
| 112 | - $p[] = '>='; |
|
| 113 | - } else { |
|
| 114 | - $p[] = $v; |
|
| 115 | - } |
|
| 116 | - break; |
|
| 117 | - case 'lte': |
|
| 118 | - case 'le': |
|
| 119 | - if ($tokens[$k] === Compiler::T_UNQUOTED_STRING) { |
|
| 120 | - $p[] = '<='; |
|
| 121 | - } else { |
|
| 122 | - $p[] = $v; |
|
| 123 | - } |
|
| 124 | - break; |
|
| 125 | - case 'gt': |
|
| 126 | - if ($tokens[$k] === Compiler::T_UNQUOTED_STRING) { |
|
| 127 | - $p[] = '>'; |
|
| 128 | - } else { |
|
| 129 | - $p[] = $v; |
|
| 130 | - } |
|
| 131 | - break; |
|
| 132 | - case 'lt': |
|
| 133 | - if ($tokens[$k] === Compiler::T_UNQUOTED_STRING) { |
|
| 134 | - $p[] = '<'; |
|
| 135 | - } else { |
|
| 136 | - $p[] = $v; |
|
| 137 | - } |
|
| 138 | - break; |
|
| 139 | - case 'mod': |
|
| 140 | - if ($tokens[$k] === Compiler::T_UNQUOTED_STRING) { |
|
| 141 | - $p[] = '%'; |
|
| 142 | - } else { |
|
| 143 | - $p[] = $v; |
|
| 144 | - } |
|
| 145 | - break; |
|
| 146 | - case 'not': |
|
| 147 | - if ($tokens[$k] === Compiler::T_UNQUOTED_STRING) { |
|
| 148 | - $p[] = '!'; |
|
| 149 | - } else { |
|
| 150 | - $p[] = $v; |
|
| 151 | - } |
|
| 152 | - break; |
|
| 153 | - case '<>': |
|
| 73 | + case 'and': |
|
| 74 | + if ($tokens[$k] === Compiler::T_UNQUOTED_STRING) { |
|
| 75 | + $p[] = '&&'; |
|
| 76 | + } else { |
|
| 77 | + $p[] = $v; |
|
| 78 | + } |
|
| 79 | + break; |
|
| 80 | + case 'or': |
|
| 81 | + if ($tokens[$k] === Compiler::T_UNQUOTED_STRING) { |
|
| 82 | + $p[] = '||'; |
|
| 83 | + } else { |
|
| 84 | + $p[] = $v; |
|
| 85 | + } |
|
| 86 | + break; |
|
| 87 | + case 'xor': |
|
| 88 | + if ($tokens[$k] === Compiler::T_UNQUOTED_STRING) { |
|
| 89 | + $p[] = '^'; |
|
| 90 | + } else { |
|
| 91 | + $p[] = $v; |
|
| 92 | + } |
|
| 93 | + break; |
|
| 94 | + case 'eq': |
|
| 95 | + if ($tokens[$k] === Compiler::T_UNQUOTED_STRING) { |
|
| 96 | + $p[] = '=='; |
|
| 97 | + } else { |
|
| 98 | + $p[] = $v; |
|
| 99 | + } |
|
| 100 | + break; |
|
| 101 | + case 'ne': |
|
| 102 | + case 'neq': |
|
| 103 | + if ($tokens[$k] === Compiler::T_UNQUOTED_STRING) { |
|
| 154 | 104 | $p[] = '!='; |
| 105 | + } else { |
|
| 106 | + $p[] = $v; |
|
| 107 | + } |
|
| 108 | + break; |
|
| 109 | + case 'gte': |
|
| 110 | + case 'ge': |
|
| 111 | + if ($tokens[$k] === Compiler::T_UNQUOTED_STRING) { |
|
| 112 | + $p[] = '>='; |
|
| 113 | + } else { |
|
| 114 | + $p[] = $v; |
|
| 115 | + } |
|
| 116 | + break; |
|
| 117 | + case 'lte': |
|
| 118 | + case 'le': |
|
| 119 | + if ($tokens[$k] === Compiler::T_UNQUOTED_STRING) { |
|
| 120 | + $p[] = '<='; |
|
| 121 | + } else { |
|
| 122 | + $p[] = $v; |
|
| 123 | + } |
|
| 124 | + break; |
|
| 125 | + case 'gt': |
|
| 126 | + if ($tokens[$k] === Compiler::T_UNQUOTED_STRING) { |
|
| 127 | + $p[] = '>'; |
|
| 128 | + } else { |
|
| 129 | + $p[] = $v; |
|
| 130 | + } |
|
| 131 | + break; |
|
| 132 | + case 'lt': |
|
| 133 | + if ($tokens[$k] === Compiler::T_UNQUOTED_STRING) { |
|
| 134 | + $p[] = '<'; |
|
| 135 | + } else { |
|
| 136 | + $p[] = $v; |
|
| 137 | + } |
|
| 138 | + break; |
|
| 139 | + case 'mod': |
|
| 140 | + if ($tokens[$k] === Compiler::T_UNQUOTED_STRING) { |
|
| 141 | + $p[] = '%'; |
|
| 142 | + } else { |
|
| 143 | + $p[] = $v; |
|
| 144 | + } |
|
| 145 | + break; |
|
| 146 | + case 'not': |
|
| 147 | + if ($tokens[$k] === Compiler::T_UNQUOTED_STRING) { |
|
| 148 | + $p[] = '!'; |
|
| 149 | + } else { |
|
| 150 | + $p[] = $v; |
|
| 151 | + } |
|
| 152 | + break; |
|
| 153 | + case '<>': |
|
| 154 | + $p[] = '!='; |
|
| 155 | + break; |
|
| 156 | + case '==': |
|
| 157 | + case '!=': |
|
| 158 | + case '>=': |
|
| 159 | + case '<=': |
|
| 160 | + case '>': |
|
| 161 | + case '<': |
|
| 162 | + case '===': |
|
| 163 | + case '!==': |
|
| 164 | + case '%': |
|
| 165 | + case '!': |
|
| 166 | + case '^': |
|
| 167 | + $p[] = $vmod; |
|
| 168 | + break; |
|
| 169 | + case 'is': |
|
| 170 | + if ($tokens[$k] !== Compiler::T_UNQUOTED_STRING) { |
|
| 171 | + $p[] = $v; |
|
| 155 | 172 | break; |
| 156 | - case '==': |
|
| 157 | - case '!=': |
|
| 158 | - case '>=': |
|
| 159 | - case '<=': |
|
| 160 | - case '>': |
|
| 161 | - case '<': |
|
| 162 | - case '===': |
|
| 163 | - case '!==': |
|
| 164 | - case '%': |
|
| 165 | - case '!': |
|
| 166 | - case '^': |
|
| 167 | - $p[] = $vmod; |
|
| 173 | + } |
|
| 174 | + if (isset($params[$k + 1]) && strtolower(trim($params[$k + 1], '"\'')) === 'not' && $tokens[$k + 1] === Compiler::T_UNQUOTED_STRING) { |
|
| 175 | + $negate = true; |
|
| 176 | + next($params); |
|
| 177 | + } else { |
|
| 178 | + $negate = false; |
|
| 179 | + } |
|
| 180 | + $ptr = 1 + (int)$negate; |
|
| 181 | + if ($tokens[$k + $ptr] !== Compiler::T_UNQUOTED_STRING) { |
|
| 168 | 182 | break; |
| 169 | - case 'is': |
|
| 170 | - if ($tokens[$k] !== Compiler::T_UNQUOTED_STRING) { |
|
| 171 | - $p[] = $v; |
|
| 172 | - break; |
|
| 173 | - } |
|
| 174 | - if (isset($params[$k + 1]) && strtolower(trim($params[$k + 1], '"\'')) === 'not' && $tokens[$k + 1] === Compiler::T_UNQUOTED_STRING) { |
|
| 175 | - $negate = true; |
|
| 176 | - next($params); |
|
| 177 | - } else { |
|
| 178 | - $negate = false; |
|
| 179 | - } |
|
| 180 | - $ptr = 1 + (int)$negate; |
|
| 181 | - if ($tokens[$k + $ptr] !== Compiler::T_UNQUOTED_STRING) { |
|
| 182 | - break; |
|
| 183 | - } |
|
| 184 | - if (!isset($params[$k + $ptr])) { |
|
| 185 | - $params[$k + $ptr] = ''; |
|
| 186 | - } else { |
|
| 187 | - $params[$k + $ptr] = trim($params[$k + $ptr], '"\''); |
|
| 188 | - } |
|
| 189 | - switch ($params[$k + $ptr]) { |
|
| 183 | + } |
|
| 184 | + if (!isset($params[$k + $ptr])) { |
|
| 185 | + $params[$k + $ptr] = ''; |
|
| 186 | + } else { |
|
| 187 | + $params[$k + $ptr] = trim($params[$k + $ptr], '"\''); |
|
| 188 | + } |
|
| 189 | + switch ($params[$k + $ptr]) { |
|
| 190 | 190 | |
| 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'; |
|
| 194 | - next($params); |
|
| 195 | - next($params); |
|
| 196 | - next($params); |
|
| 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]); |
|
| 199 | - } |
|
| 200 | - break; |
|
| 201 | - case 'even': |
|
| 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'; |
|
| 206 | - next($params); |
|
| 207 | - next($params); |
|
| 208 | - } else { |
|
| 209 | - $p[] = $a . ' % 2 ' . ($negate ? '!' : '=') . '== 0'; |
|
| 210 | - } |
|
| 211 | - next($params); |
|
| 212 | - break; |
|
| 213 | - case 'odd': |
|
| 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'; |
|
| 218 | - next($params); |
|
| 219 | - next($params); |
|
| 220 | - } else { |
|
| 221 | - $p[] = $a . ' % 2 ' . ($negate ? '=' : '!') . '== 0'; |
|
| 222 | - } |
|
| 223 | - next($params); |
|
| 224 | - break; |
|
| 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]); |
|
| 227 | - } |
|
| 228 | - break; |
|
| 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'; |
|
| 194 | + next($params); |
|
| 195 | + next($params); |
|
| 196 | + next($params); |
|
| 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]); |
|
| 199 | + } |
|
| 200 | + break; |
|
| 201 | + case 'even': |
|
| 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'; |
|
| 206 | + next($params); |
|
| 207 | + next($params); |
|
| 208 | + } else { |
|
| 209 | + $p[] = $a . ' % 2 ' . ($negate ? '!' : '=') . '== 0'; |
|
| 210 | + } |
|
| 211 | + next($params); |
|
| 212 | + break; |
|
| 213 | + case 'odd': |
|
| 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'; |
|
| 218 | + next($params); |
|
| 219 | + next($params); |
|
| 220 | + } else { |
|
| 221 | + $p[] = $a . ' % 2 ' . ($negate ? '=' : '!') . '== 0'; |
|
| 222 | + } |
|
| 223 | + next($params); |
|
| 224 | + break; |
|
| 229 | 225 | default: |
| 230 | - $p[] = $v; |
|
| 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 | + } |
|
| 228 | + break; |
|
| 229 | + default: |
|
| 230 | + $p[] = $v; |
|
| 231 | 231 | } |
| 232 | 232 | } |
| 233 | 233 | |
@@ -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 | } |