@@ -21,14 +21,13 @@ discard block |
||
| 21 | 21 | { |
| 22 | 22 | list($l, $r) = $this->compiler->getDelimiters(); |
| 23 | 23 | |
| 24 | - $rl = preg_quote($l,'/'); |
|
| 25 | - $rr = preg_quote($r,'/'); |
|
| 24 | + $rl = preg_quote($l, '/'); |
|
| 25 | + $rr = preg_quote($r, '/'); |
|
| 26 | 26 | $sectionParam = '(?:(name|loop|start|step|max|show)\s*=\s*(\S+))?\s*'; |
| 27 | 27 | $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($this, 'convertSection'), $input); |
| 28 | 28 | $input = str_replace('$smarty.section.', '$smarty.for.', $input); |
| 29 | 29 | |
| 30 | - $smarty = array |
|
| 31 | - ( |
|
| 30 | + $smarty = array( |
|
| 32 | 31 | '/'.$rl.'\s*ldelim\s*'.$rr.'/', |
| 33 | 32 | '/'.$rl.'\s*rdelim\s*'.$rr.'/', |
| 34 | 33 | '/'.$rl.'\s*\$smarty\.ldelim\s*'.$rr.'/', |
@@ -40,8 +39,7 @@ discard block |
||
| 40 | 39 | '/'.$rl.'\s*sectionelse\s*'.$rr.'/', |
| 41 | 40 | ); |
| 42 | 41 | |
| 43 | - $dwoo = array |
|
| 44 | - ( |
|
| 42 | + $dwoo = array( |
|
| 45 | 43 | '\\'.$l, |
| 46 | 44 | $r, |
| 47 | 45 | '\\'.$l, |
@@ -18,16 +18,16 @@ discard block |
||
| 18 | 18 | * @date 2008-12-24 |
| 19 | 19 | * @package Dwoo |
| 20 | 20 | */ |
| 21 | -function Dwoo_Plugin_date_format(Dwoo_Core $dwoo, $value, $format='%b %e, %Y', $default=null) |
|
| 21 | +function Dwoo_Plugin_date_format(Dwoo_Core $dwoo, $value, $format = '%b %e, %Y', $default = null) |
|
| 22 | 22 | { |
| 23 | 23 | if (!empty($value)) { |
| 24 | 24 | // convert if it's not a valid unix timestamp |
| 25 | - if (preg_match('#^-?\d{1,10}$#', $value)===0) { |
|
| 25 | + if (preg_match('#^-?\d{1,10}$#', $value) === 0) { |
|
| 26 | 26 | $value = strtotime($value); |
| 27 | 27 | } |
| 28 | 28 | } elseif (!empty($default)) { |
| 29 | 29 | // convert if it's not a valid unix timestamp |
| 30 | - if (preg_match('#^-?\d{1,10}$#', $default)===0) { |
|
| 30 | + if (preg_match('#^-?\d{1,10}$#', $default) === 0) { |
|
| 31 | 31 | $value = strtotime($default); |
| 32 | 32 | } else { |
| 33 | 33 | $value = $default; |
@@ -38,7 +38,7 @@ discard block |
||
| 38 | 38 | |
| 39 | 39 | // Credits for that windows compat block to Monte Ohrt who made smarty's date_format plugin |
| 40 | 40 | if (DIRECTORY_SEPARATOR == '\\') { |
| 41 | - $_win_from = array('%D', '%h', '%n', '%r', '%R', '%t', '%T'); |
|
| 41 | + $_win_from = array('%D', '%h', '%n', '%r', '%R', '%t', '%T'); |
|
| 42 | 42 | $_win_to = array('%m/%d/%y', '%b', "\n", '%I:%M:%S %p', '%H:%M', "\t", '%H:%M:%S'); |
| 43 | 43 | if (strpos($format, '%e') !== false) { |
| 44 | 44 | $_win_from[] = '%e'; |
@@ -52,7 +52,7 @@ discard block |
||
| 52 | 52 | |
| 53 | 53 | $out .= $this->export($var, $scope); |
| 54 | 54 | |
| 55 | - return $out .'</div></div>'; |
|
| 55 | + return $out.'</div></div>'; |
|
| 56 | 56 | } |
| 57 | 57 | |
| 58 | 58 | protected function export($var, $scope) |
@@ -60,8 +60,8 @@ discard block |
||
| 60 | 60 | $out = ''; |
| 61 | 61 | foreach ($var as $i=>$v) { |
| 62 | 62 | if (is_array($v) || (is_object($v) && $v instanceof Iterator)) { |
| 63 | - $out .= $i.' ('.(is_array($v) ? 'array':'object: '.get_class($v)).')'; |
|
| 64 | - if ($v===$scope) { |
|
| 63 | + $out .= $i.' ('.(is_array($v) ? 'array' : 'object: '.get_class($v)).')'; |
|
| 64 | + if ($v === $scope) { |
|
| 65 | 65 | $out .= ' (current scope):<div style="background:#ccc;padding-left:20px;">'.$this->export($v, $scope).'</div>'; |
| 66 | 66 | } else { |
| 67 | 67 | $out .= ':<div style="padding-left:20px;">'.$this->export($v, $scope).'</div>'; |
@@ -91,14 +91,14 @@ discard block |
||
| 91 | 91 | protected function exportObj($i, $obj) |
| 92 | 92 | { |
| 93 | 93 | if (array_search($obj, $this->outputObjects, true) !== false) { |
| 94 | - return $i . ' [recursion, skipped]<br />'; |
|
| 94 | + return $i.' [recursion, skipped]<br />'; |
|
| 95 | 95 | } |
| 96 | 96 | |
| 97 | 97 | $this->outputObjects[] = $obj; |
| 98 | 98 | |
| 99 | 99 | $list = (array) $obj; |
| 100 | 100 | |
| 101 | - $protectedLength = strlen(get_class($obj)) + 2; |
|
| 101 | + $protectedLength = strlen(get_class($obj))+2; |
|
| 102 | 102 | |
| 103 | 103 | $out = array(); |
| 104 | 104 | |
@@ -116,17 +116,17 @@ discard block |
||
| 116 | 116 | |
| 117 | 117 | $params = array(); |
| 118 | 118 | foreach ($method->getParameters() as $param) { |
| 119 | - $params[] = ($param->isPassedByReference() ? '&':'') . '$'.$param->getName() . ($param->isOptional() ? ' = '.var_export($param->getDefaultValue(), true) : ''); |
|
| 119 | + $params[] = ($param->isPassedByReference() ? '&' : '').'$'.$param->getName().($param->isOptional() ? ' = '.var_export($param->getDefaultValue(), true) : ''); |
|
| 120 | 120 | } |
| 121 | 121 | |
| 122 | - $out['method'] .= '(method) ' . $method->getName() .'('.implode(', ', $params).')<br />'; |
|
| 122 | + $out['method'] .= '(method) '.$method->getName().'('.implode(', ', $params).')<br />'; |
|
| 123 | 123 | } |
| 124 | 124 | } |
| 125 | 125 | |
| 126 | 126 | foreach ($list as $attributeName => $attributeValue) { |
| 127 | - if(property_exists($obj, $attributeName)) { |
|
| 127 | + if (property_exists($obj, $attributeName)) { |
|
| 128 | 128 | $key = 'public'; |
| 129 | - } elseif(substr($attributeName, 0, 3) === "\0*\0") { |
|
| 129 | + } elseif (substr($attributeName, 0, 3) === "\0*\0") { |
|
| 130 | 130 | $key = 'protected'; |
| 131 | 131 | $attributeName = substr($attributeName, 3); |
| 132 | 132 | } else { |
@@ -150,7 +150,7 @@ discard block |
||
| 150 | 150 | } |
| 151 | 151 | } |
| 152 | 152 | |
| 153 | - $return = $i . '<br /><div style="padding-left:20px;">'; |
|
| 153 | + $return = $i.'<br /><div style="padding-left:20px;">'; |
|
| 154 | 154 | |
| 155 | 155 | if (!empty($out['method'])) { |
| 156 | 156 | $return .= $out['method']; |
@@ -168,6 +168,6 @@ discard block |
||
| 168 | 168 | $return .= $out['private']; |
| 169 | 169 | } |
| 170 | 170 | |
| 171 | - return $return . '</div>'; |
|
| 171 | + return $return.'</div>'; |
|
| 172 | 172 | } |
| 173 | 173 | } |
| 174 | 174 | \ No newline at end of file |
@@ -17,7 +17,7 @@ |
||
| 17 | 17 | * @date 2008-10-23 |
| 18 | 18 | * @package Dwoo |
| 19 | 19 | */ |
| 20 | -function Dwoo_Plugin_spacify_compile(Dwoo_Compiler $compiler, $value, $space_char=' ') |
|
| 20 | +function Dwoo_Plugin_spacify_compile(Dwoo_Compiler $compiler, $value, $space_char = ' ') |
|
| 21 | 21 | { |
| 22 | 22 | return 'implode('.$space_char.', str_split('.$value.', 1))'; |
| 23 | 23 | } |
@@ -18,13 +18,13 @@ discard block |
||
| 18 | 18 | * @date 2008-10-23 |
| 19 | 19 | * @package Dwoo |
| 20 | 20 | */ |
| 21 | -function Dwoo_Plugin_escape(Dwoo_Core $dwoo, $value='', $format='html', $charset=null) |
|
| 21 | +function Dwoo_Plugin_escape(Dwoo_Core $dwoo, $value = '', $format = 'html', $charset = null) |
|
| 22 | 22 | { |
| 23 | 23 | if ($charset === null) { |
| 24 | 24 | $charset = $dwoo->getCharset(); |
| 25 | 25 | } |
| 26 | 26 | |
| 27 | - switch($format) |
|
| 27 | + switch ($format) |
|
| 28 | 28 | { |
| 29 | 29 | |
| 30 | 30 | case 'html': |
@@ -40,18 +40,18 @@ discard block |
||
| 40 | 40 | case 'hex': |
| 41 | 41 | $out = ''; |
| 42 | 42 | $cnt = strlen((string) $value); |
| 43 | - for ($i=0; $i < $cnt; $i++) { |
|
| 44 | - $out .= '%' . bin2hex((string) $value[$i]); |
|
| 43 | + for ($i = 0; $i < $cnt; $i++) { |
|
| 44 | + $out .= '%'.bin2hex((string) $value[$i]); |
|
| 45 | 45 | } |
| 46 | 46 | return $out; |
| 47 | 47 | case 'hexentity': |
| 48 | 48 | $out = ''; |
| 49 | 49 | $cnt = strlen((string) $value); |
| 50 | - for ($i=0; $i < $cnt; $i++) |
|
| 51 | - $out .= '&#x' . bin2hex((string) $value[$i]) . ';'; |
|
| 50 | + for ($i = 0; $i < $cnt; $i++) |
|
| 51 | + $out .= '&#x'.bin2hex((string) $value[$i]).';'; |
|
| 52 | 52 | return $out; |
| 53 | 53 | case 'javascript': |
| 54 | - return strtr((string) $value, array('\\'=>'\\\\',"'"=>"\\'",'"'=>'\\"',"\r"=>'\\r',"\n"=>'\\n','</'=>'<\/')); |
|
| 54 | + return strtr((string) $value, array('\\'=>'\\\\', "'"=>"\\'", '"'=>'\\"', "\r"=>'\\r', "\n"=>'\\n', '</'=>'<\/')); |
|
| 55 | 55 | case 'mail': |
| 56 | 56 | return str_replace(array('@', '.'), array(' (AT) ', ' (DOT) '), (string) $value); |
| 57 | 57 | default: |
@@ -47,8 +47,9 @@ |
||
| 47 | 47 | case 'hexentity': |
| 48 | 48 | $out = ''; |
| 49 | 49 | $cnt = strlen((string) $value); |
| 50 | - for ($i=0; $i < $cnt; $i++) |
|
| 51 | - $out .= '&#x' . bin2hex((string) $value[$i]) . ';'; |
|
| 50 | + for ($i=0; $i < $cnt; $i++) { |
|
| 51 | + $out .= '&#x' . bin2hex((string) $value[$i]) . ';'; |
|
| 52 | + } |
|
| 52 | 53 | return $out; |
| 53 | 54 | case 'javascript': |
| 54 | 55 | return strtr((string) $value, array('\\'=>'\\\\',"'"=>"\\'",'"'=>'\\"',"\r"=>'\\r',"\n"=>'\\n','</'=>'<\/')); |
@@ -29,13 +29,12 @@ discard block |
||
| 29 | 29 | { |
| 30 | 30 | // init counter |
| 31 | 31 | if (!isset($this->counters[$name])) { |
| 32 | - $this->counters[$name] = array |
|
| 33 | - ( |
|
| 34 | - 'count' => $start===null ? 1 : (int) $start, |
|
| 35 | - 'skip' => $skip===null ? 1 : (int) $skip, |
|
| 36 | - 'print' => $print===null ? true : (bool) $print, |
|
| 37 | - 'assign' => $assign===null ? null : (string) $assign, |
|
| 38 | - 'direction' => strtolower($direction)==='down' ? -1 : 1, |
|
| 32 | + $this->counters[$name] = array( |
|
| 33 | + 'count' => $start === null ? 1 : (int) $start, |
|
| 34 | + 'skip' => $skip === null ? 1 : (int) $skip, |
|
| 35 | + 'print' => $print === null ? true : (bool) $print, |
|
| 36 | + 'assign' => $assign === null ? null : (string) $assign, |
|
| 37 | + 'direction' => strtolower($direction) === 'down' ? -1 : 1, |
|
| 39 | 38 | ); |
| 40 | 39 | } |
| 41 | 40 | // increment |
@@ -47,7 +46,7 @@ discard block |
||
| 47 | 46 | } |
| 48 | 47 | |
| 49 | 48 | if ($direction !== null) { |
| 50 | - $this->counters[$name]['direction'] = strtolower($direction)==='down' ? -1 : 1; |
|
| 49 | + $this->counters[$name]['direction'] = strtolower($direction) === 'down' ? -1 : 1; |
|
| 51 | 50 | } |
| 52 | 51 | |
| 53 | 52 | if ($print !== null) { |
@@ -61,7 +60,7 @@ discard block |
||
| 61 | 60 | if ($start !== null) { |
| 62 | 61 | $this->counters[$name]['count'] = (int) $start; |
| 63 | 62 | } else { |
| 64 | - $this->counters[$name]['count'] += ($this->counters[$name]['skip'] * $this->counters[$name]['direction']); |
|
| 63 | + $this->counters[$name]['count'] += ($this->counters[$name]['skip']*$this->counters[$name]['direction']); |
|
| 65 | 64 | } |
| 66 | 65 | } |
| 67 | 66 | |
@@ -19,7 +19,7 @@ |
||
| 19 | 19 | * @date 2008-10-23 |
| 20 | 20 | * @package Dwoo |
| 21 | 21 | */ |
| 22 | -function Dwoo_Plugin_wordwrap_compile(Dwoo_Compiler $compiler, $value, $length=80, $break="\n", $cut=false) |
|
| 22 | +function Dwoo_Plugin_wordwrap_compile(Dwoo_Compiler $compiler, $value, $length = 80, $break = "\n", $cut = false) |
|
| 23 | 23 | { |
| 24 | 24 | return 'wordwrap('.$value.','.$length.','.$break.','.$cut.')'; |
| 25 | 25 | } |
@@ -30,7 +30,7 @@ |
||
| 30 | 30 | } |
| 31 | 31 | |
| 32 | 32 | if (preg_match('#[a-z\s]+$#is', $search[$i], $m) && (strpos($m[0], 'e') !== false)) { |
| 33 | - $search[$i] = substr($search[$i], 0, -strlen($m[0])) . str_replace(array('e', ' '), '', $m[0]); |
|
| 33 | + $search[$i] = substr($search[$i], 0, -strlen($m[0])).str_replace(array('e', ' '), '', $m[0]); |
|
| 34 | 34 | } |
| 35 | 35 | } |
| 36 | 36 | |
@@ -24,11 +24,11 @@ |
||
| 24 | 24 | } elseif(($charset=$dwoo->getCharset()) === 'iso-8859-1') { |
| 25 | 25 | return strrev((string) $value); |
| 26 | 26 | } else { |
| 27 | - $strlen = mb_strlen($value); |
|
| 28 | - $out = ''; |
|
| 29 | - while ($strlen--) { |
|
| 30 | - $out .= mb_substr($value, $strlen, 1, $charset); |
|
| 31 | - } |
|
| 27 | + $strlen = mb_strlen($value); |
|
| 28 | + $out = ''; |
|
| 29 | + while ($strlen--) { |
|
| 30 | + $out .= mb_substr($value, $strlen, 1, $charset); |
|
| 31 | + } |
|
| 32 | 32 | return $out; |
| 33 | 33 | } |
| 34 | 34 | } |
@@ -17,11 +17,11 @@ |
||
| 17 | 17 | * @date 2008-10-23 |
| 18 | 18 | * @package Dwoo |
| 19 | 19 | */ |
| 20 | -function Dwoo_Plugin_reverse(Dwoo_Core $dwoo, $value, $preserve_keys=false) |
|
| 20 | +function Dwoo_Plugin_reverse(Dwoo_Core $dwoo, $value, $preserve_keys = false) |
|
| 21 | 21 | { |
| 22 | 22 | if (is_array($value)) { |
| 23 | 23 | return array_reverse($value, $preserve_keys); |
| 24 | - } elseif(($charset=$dwoo->getCharset()) === 'iso-8859-1') { |
|
| 24 | + } elseif (($charset = $dwoo->getCharset()) === 'iso-8859-1') { |
|
| 25 | 25 | return strrev((string) $value); |
| 26 | 26 | } else { |
| 27 | 27 | $strlen = mb_strlen($value); |