@@ -132,7 +132,7 @@ |
||
| 132 | 132 | */ |
| 133 | 133 | public static function reorderMessages() |
| 134 | 134 | { |
| 135 | - uasort(self::$messages, function ($a, $b) { |
|
| 135 | + uasort(self::$messages, function($a, $b) { |
|
| 136 | 136 | return $a->type <= $b->type; |
| 137 | 137 | }); |
| 138 | 138 | } |
@@ -34,9 +34,9 @@ |
||
| 34 | 34 | public static function displayError($errorMessage, $fieldName = null) |
| 35 | 35 | { |
| 36 | 36 | if (!is_null($fieldName)) { |
| 37 | - return '<label for="'.$fieldName.'" class="form-error">'.$errorMessage.'</label>'; |
|
| 37 | + return '<label for="' . $fieldName . '" class="form-error">' . $errorMessage . '</label>'; |
|
| 38 | 38 | } else { |
| 39 | - return '<span class="label label-danger pull-right form-error">'.$errorMessage.'</span>'; |
|
| 39 | + return '<span class="label label-danger pull-right form-error">' . $errorMessage . '</span>'; |
|
| 40 | 40 | } |
| 41 | 41 | } |
| 42 | 42 | |
@@ -224,7 +224,7 @@ discard block |
||
| 224 | 224 | if (isset($_FIELDS[$fieldName])) { |
| 225 | 225 | $_FIELDS[$fieldName] = $fieldValue; |
| 226 | 226 | } else { |
| 227 | - throw new \Exception("No field '".$fieldName."' in global fields list."); |
|
| 227 | + throw new \Exception("No field '" . $fieldName . "' in global fields list."); |
|
| 228 | 228 | } |
| 229 | 229 | } |
| 230 | 230 | |
@@ -261,10 +261,10 @@ discard block |
||
| 261 | 261 | case 'boolean': |
| 262 | 262 | case 'bool': |
| 263 | 263 | case 'b': |
| 264 | - $_FIELDS[$fieldName] = (bool) $_FIELDS[$fieldName]; |
|
| 264 | + $_FIELDS[$fieldName] = (bool)$_FIELDS[$fieldName]; |
|
| 265 | 265 | } |
| 266 | 266 | } else { |
| 267 | - throw new \Exception("No field '".$fieldName."' in global fields list."); |
|
| 267 | + throw new \Exception("No field '" . $fieldName . "' in global fields list."); |
|
| 268 | 268 | } |
| 269 | 269 | } |
| 270 | 270 | |
@@ -281,7 +281,7 @@ discard block |
||
| 281 | 281 | global $_FIELDS; |
| 282 | 282 | |
| 283 | 283 | foreach ($fieldNames as $fieldName) { |
| 284 | - $_FIELDS[$fieldName] = (int) (bool) self::getFieldValue($fieldName); |
|
| 284 | + $_FIELDS[$fieldName] = (int)(bool)self::getFieldValue($fieldName); |
|
| 285 | 285 | } |
| 286 | 286 | } |
| 287 | 287 | |
@@ -118,7 +118,7 @@ discard block |
||
| 118 | 118 | * Detect browser version number |
| 119 | 119 | */ |
| 120 | 120 | $identifiers[] = $browserShortName; |
| 121 | - self::$pattern = '#(?<browser>'.implode('|', $identifiers). |
|
| 121 | + self::$pattern = '#(?<browser>' . implode('|', $identifiers) . |
|
| 122 | 122 | ')[/ ]+(?<version>[0-9.|a-zA-Z.]*)#'; |
| 123 | 123 | if (!preg_match_all(self::$pattern, $userAgent, $matches)) { |
| 124 | 124 | // we have no matching number just continue |
@@ -140,7 +140,7 @@ discard block |
||
| 140 | 140 | |
| 141 | 141 | // New IE version detection |
| 142 | 142 | if (isset($matches['browser'][0]) && $matches['browser'][0] == 'Trident') { |
| 143 | - $browserVersion = sprintf('%.1f', (int) $browserVersion + 4); |
|
| 143 | + $browserVersion = sprintf('%.1f', (int)$browserVersion + 4); |
|
| 144 | 144 | } |
| 145 | 145 | |
| 146 | 146 | // check if we have a number |
@@ -30,16 +30,16 @@ discard block |
||
| 30 | 30 | { |
| 31 | 31 | $paramsString = ''; |
| 32 | 32 | foreach ($params as $key => $value) { |
| 33 | - $paramsString .= '&'.$key.'='.$value; |
|
| 33 | + $paramsString .= '&' . $key . '=' . $value; |
|
| 34 | 34 | } |
| 35 | 35 | if ($session) { |
| 36 | - $paramsString .= '&'.session_name().'='.session_id(); |
|
| 36 | + $paramsString .= '&' . session_name() . '=' . session_id(); |
|
| 37 | 37 | } |
| 38 | 38 | $paramsString = substr($paramsString, 1); |
| 39 | 39 | if ($paramsString) { |
| 40 | - $paramsString = '?'.$paramsString; |
|
| 40 | + $paramsString = '?' . $paramsString; |
|
| 41 | 41 | } |
| 42 | - header('Location: '.$url.$paramsString); |
|
| 42 | + header('Location: ' . $url . $paramsString); |
|
| 43 | 43 | exit(); |
| 44 | 44 | } |
| 45 | 45 | |
@@ -72,9 +72,9 @@ discard block |
||
| 72 | 72 | } |
| 73 | 73 | } |
| 74 | 74 | if (function_exists('http_redirect')) { |
| 75 | - http_redirect('http://'.$_SERVER['SERVER_NAME'].'/'.$url); |
|
| 75 | + http_redirect('http://' . $_SERVER['SERVER_NAME'] . '/' . $url); |
|
| 76 | 76 | } else { |
| 77 | - self::http_redirect('http://'.$_SERVER['SERVER_NAME'].'/'.$url); |
|
| 77 | + self::http_redirect('http://' . $_SERVER['SERVER_NAME'] . '/' . $url); |
|
| 78 | 78 | } |
| 79 | 79 | } |
| 80 | 80 | } |
@@ -130,13 +130,13 @@ discard block |
||
| 130 | 130 | $urlParts['path'] = '/'; |
| 131 | 131 | } |
| 132 | 132 | |
| 133 | - $sock = fsockopen($urlParts['host'], (isset($urlParts['port']) ? (int) $urlParts['port'] : 80), $errno, $errstr, 30); |
|
| 133 | + $sock = fsockopen($urlParts['host'], (isset($urlParts['port']) ? (int)$urlParts['port'] : 80), $errno, $errstr, 30); |
|
| 134 | 134 | if (!$sock) { |
| 135 | 135 | throw new HttpException("$errstr ($errno)"); |
| 136 | 136 | } |
| 137 | 137 | |
| 138 | - $request = 'HEAD '.$urlParts['path'].(isset($urlParts['query']) ? '?'.$urlParts['query'] : '')." HTTP/1.1\r\n"; |
|
| 139 | - $request .= 'Host: '.$urlParts['host']."\r\n"; |
|
| 138 | + $request = 'HEAD ' . $urlParts['path'] . (isset($urlParts['query']) ? '?' . $urlParts['query'] : '') . " HTTP/1.1\r\n"; |
|
| 139 | + $request .= 'Host: ' . $urlParts['host'] . "\r\n"; |
|
| 140 | 140 | $request .= "Connection: Close\r\n\r\n"; |
| 141 | 141 | fwrite($sock, $request); |
| 142 | 142 | $response = ''; |
@@ -147,7 +147,7 @@ discard block |
||
| 147 | 147 | |
| 148 | 148 | if (preg_match('/^Location: (.+?)$/m', $response, $matches)) { |
| 149 | 149 | if (substr($matches[1], 0, 1) == '/') { |
| 150 | - return $urlParts['scheme'].'://'.$urlParts['host'].trim($matches[1]); |
|
| 150 | + return $urlParts['scheme'] . '://' . $urlParts['host'] . trim($matches[1]); |
|
| 151 | 151 | } |
| 152 | 152 | |
| 153 | 153 | return trim($matches[1]); |
@@ -212,27 +212,27 @@ discard block |
||
| 212 | 212 | if (is_array($val)) { |
| 213 | 213 | $val = implode(',', $val); |
| 214 | 214 | } |
| 215 | - $postParams[] = $key.'='.urlencode($val); |
|
| 215 | + $postParams[] = $key . '=' . urlencode($val); |
|
| 216 | 216 | } |
| 217 | 217 | $postString = implode('&', $postParams); |
| 218 | 218 | |
| 219 | 219 | $parts = parse_url($url); |
| 220 | 220 | |
| 221 | - $port = isset($parts['port']) ? (int) $parts['port'] : 80; |
|
| 221 | + $port = isset($parts['port']) ? (int)$parts['port'] : 80; |
|
| 222 | 222 | |
| 223 | 223 | $sock = fsockopen($parts['host'], $port, $errno, $errstr, $timeout); |
| 224 | 224 | |
| 225 | 225 | // Data goes in the path for a GET request |
| 226 | 226 | if ($type == self::GET) { |
| 227 | - $parts['path'] .= '?'.$postString; |
|
| 227 | + $parts['path'] .= '?' . $postString; |
|
| 228 | 228 | } |
| 229 | 229 | |
| 230 | - $request = "$type ".$parts['path']." HTTP/1.1\r\n"; |
|
| 231 | - $request .= 'Host: '.$parts['host']."\r\n"; |
|
| 230 | + $request = "$type " . $parts['path'] . " HTTP/1.1\r\n"; |
|
| 231 | + $request .= 'Host: ' . $parts['host'] . "\r\n"; |
|
| 232 | 232 | |
| 233 | 233 | if ($type == self::POST) { |
| 234 | 234 | $request .= "Content-Type: application/x-www-form-urlencoded\r\n"; |
| 235 | - $request .= 'Content-Length: '.strlen($postString)."\r\n"; |
|
| 235 | + $request .= 'Content-Length: ' . strlen($postString) . "\r\n"; |
|
| 236 | 236 | } |
| 237 | 237 | $request .= "Connection: Close\r\n"; |
| 238 | 238 | $request .= "\r\n"; |
@@ -287,7 +287,7 @@ discard block |
||
| 287 | 287 | header('HTTP/1.0 404 Not Found', true, 404); |
| 288 | 288 | break; |
| 289 | 289 | default: |
| 290 | - throw new HttpException("Invalid HTTP status code '".$code."'"); |
|
| 290 | + throw new HttpException("Invalid HTTP status code '" . $code . "'"); |
|
| 291 | 291 | } |
| 292 | 292 | if (!is_null($path)) { |
| 293 | 293 | include $path; |
@@ -310,12 +310,12 @@ discard block |
||
| 310 | 310 | public static function __callStatic($name, $arguments) |
| 311 | 311 | { |
| 312 | 312 | if (substr($name, 0, 5) === 'force') { |
| 313 | - $code = (int) substr($name, 5); |
|
| 313 | + $code = (int)substr($name, 5); |
|
| 314 | 314 | $path = isset($arguments[0]) ? $arguments[0] : null; |
| 315 | 315 | |
| 316 | 316 | return self::forceHttpStatus($code, $path); |
| 317 | 317 | } |
| 318 | - throw new HttpException("Invalid HTTP class method '".$name."'"); |
|
| 318 | + throw new HttpException("Invalid HTTP class method '" . $name . "'"); |
|
| 319 | 319 | } |
| 320 | 320 | } |
| 321 | 321 | |
@@ -63,7 +63,7 @@ |
||
| 63 | 63 | if (isset($this->titles[$code])) { |
| 64 | 64 | return $this->titles[$code]; |
| 65 | 65 | } else { |
| 66 | - throw new Exception("Invalid language code '".$code."'"); |
|
| 66 | + throw new Exception("Invalid language code '" . $code . "'"); |
|
| 67 | 67 | } |
| 68 | 68 | } |
| 69 | 69 | } |
@@ -68,7 +68,7 @@ |
||
| 68 | 68 | $type = strtoupper($chunks[0]); |
| 69 | 69 | |
| 70 | 70 | if (!self::isValidQueryType($type)) { |
| 71 | - throw new DBQueryTypeException("Invalid SQL query type '".$type."'"); |
|
| 71 | + throw new DBQueryTypeException("Invalid SQL query type '" . $type . "'"); |
|
| 72 | 72 | } |
| 73 | 73 | |
| 74 | 74 | return $type; |
@@ -89,9 +89,9 @@ discard block |
||
| 89 | 89 | case '!=': |
| 90 | 90 | $this->value = DBField::castValue($this->field->type, $value); |
| 91 | 91 | |
| 92 | - $this->sqlCondition = '`'.$field->name.'` '.$this->type.' '.DBField::sqlValue($this->field->type, $value); |
|
| 92 | + $this->sqlCondition = '`' . $field->name . '` ' . $this->type . ' ' . DBField::sqlValue($this->field->type, $value); |
|
| 93 | 93 | |
| 94 | - $this->preparedCondition = '`'.$field->name.'` '.$this->type.' ?'; |
|
| 94 | + $this->preparedCondition = '`' . $field->name . '` ' . $this->type . ' ?'; |
|
| 95 | 95 | $this->preparedTypes = $this->field->type; |
| 96 | 96 | $this->preparedData = [DBField::sqlValue($this->field->type, $value)]; |
| 97 | 97 | break; |
@@ -102,15 +102,15 @@ discard block |
||
| 102 | 102 | if ($this->field->type != 's') { |
| 103 | 103 | throw new DBQueryConditionException('Field type is not a string'); |
| 104 | 104 | } |
| 105 | - $this->sqlCondition = '`'.$field->name.'` '.$this->type.' '.DBField::sqlValue($this->field->type, $value); |
|
| 105 | + $this->sqlCondition = '`' . $field->name . '` ' . $this->type . ' ' . DBField::sqlValue($this->field->type, $value); |
|
| 106 | 106 | |
| 107 | - $this->preparedCondition = '`'.$field->name.'` '.$this->type.' ?'; |
|
| 107 | + $this->preparedCondition = '`' . $field->name . '` ' . $this->type . ' ?'; |
|
| 108 | 108 | $this->preparedTypes = $this->field->type; |
| 109 | 109 | $this->preparedData = [DBField::sqlValue($this->field->type, $value)]; |
| 110 | 110 | break; |
| 111 | 111 | case 'IN': |
| 112 | 112 | case 'NOT IN': |
| 113 | - if (is_array($value) && !empty($value)) { |
|
| 113 | + if (is_array($value) && !empty($value)) { |
|
| 114 | 114 | $dataList = []; |
| 115 | 115 | foreach ($value as $dataItem) { |
| 116 | 116 | $dataList[] = DBField::sqlValue($this->field->type, $dataItem); |
@@ -130,9 +130,9 @@ discard block |
||
| 130 | 130 | return; |
| 131 | 131 | } |
| 132 | 132 | |
| 133 | - $this->sqlCondition = '`'.$field->name.'` '.$this->type.' ('.implode(', ', $dataList).')'; |
|
| 133 | + $this->sqlCondition = '`' . $field->name . '` ' . $this->type . ' (' . implode(', ', $dataList) . ')'; |
|
| 134 | 134 | |
| 135 | - $this->preparedCondition = '`'.$field->name.'` '.$this->type.' ('.$qmStr.')'; |
|
| 135 | + $this->preparedCondition = '`' . $field->name . '` ' . $this->type . ' (' . $qmStr . ')'; |
|
| 136 | 136 | $this->preparedTypes = $tStr; |
| 137 | 137 | $this->preparedData = $dataList; |
| 138 | 138 | } else { |
@@ -143,10 +143,10 @@ discard block |
||
| 143 | 143 | if (is_array($value) && count($value) == 2 && isset($value[0]) && isset($value[1])) { |
| 144 | 144 | $from = DBField::sqlValue($this->field->type, $value[0]); |
| 145 | 145 | $to = DBField::sqlValue($this->field->type, $value[1]); |
| 146 | - $this->sqlCondition = '`'.$field->name.'` BETWEEN '.$from.' AND '.$to; |
|
| 146 | + $this->sqlCondition = '`' . $field->name . '` BETWEEN ' . $from . ' AND ' . $to; |
|
| 147 | 147 | |
| 148 | - $this->preparedCondition = '`'.$field->name.'` BETWEEN ? AND ?'; |
|
| 149 | - $this->preparedTypes = $this->field->type.$this->field->type; |
|
| 148 | + $this->preparedCondition = '`' . $field->name . '` BETWEEN ? AND ?'; |
|
| 149 | + $this->preparedTypes = $this->field->type . $this->field->type; |
|
| 150 | 150 | $this->preparedData = [$from, $to]; |
| 151 | 151 | } else { |
| 152 | 152 | throw new DBQueryConditionException("Invalid data for 'BETWEEN' condition"); |
@@ -164,7 +164,7 @@ discard block |
||
| 164 | 164 | case '!=': |
| 165 | 165 | case 'LIKE': |
| 166 | 166 | case 'NOT LIKE': |
| 167 | - $this->sqlCondition = '`'.$field1->name.'` '.$this->type.' `'.$field2->name.'`'; |
|
| 167 | + $this->sqlCondition = '`' . $field1->name . '` ' . $this->type . ' `' . $field2->name . '`'; |
|
| 168 | 168 | break; |
| 169 | 169 | case 'IN': |
| 170 | 170 | case 'NOT IN': |
@@ -198,7 +198,7 @@ discard block |
||
| 198 | 198 | } |
| 199 | 199 | |
| 200 | 200 | foreach ($queryCondition as $operation => $conditions) { |
| 201 | - $cond .= ' '.$operator.self::getSQLCondition($conditions, $operation); |
|
| 201 | + $cond .= ' ' . $operator . self::getSQLCondition($conditions, $operation); |
|
| 202 | 202 | } |
| 203 | 203 | |
| 204 | 204 | $cond .= ')'; |
@@ -215,7 +215,7 @@ discard block |
||
| 215 | 215 | ); |
| 216 | 216 | } |
| 217 | 217 | } elseif (Tools::isInstanceOf($queryCondition, "\Asymptix\db\DBQueryCondition")) { |
| 218 | - return ' '.$queryCondition->sqlCondition; |
|
| 218 | + return ' ' . $queryCondition->sqlCondition; |
|
| 219 | 219 | } |
| 220 | 220 | |
| 221 | 221 | return ''; |
@@ -280,7 +280,7 @@ discard block |
||
| 280 | 280 | if (isset($conditionTypes[$conditionType])) { |
| 281 | 281 | return $conditionTypes[$conditionType]; |
| 282 | 282 | } |
| 283 | - throw new DBQueryConditionException("Invalid SQL condition type '".$conditionType."'"); |
|
| 283 | + throw new DBQueryConditionException("Invalid SQL condition type '" . $conditionType . "'"); |
|
| 284 | 284 | } |
| 285 | 285 | } |
| 286 | 286 | |
@@ -48,8 +48,8 @@ discard block |
||
| 48 | 48 | */ |
| 49 | 49 | public function __construct($type = '', $name = '', $value = null) |
| 50 | 50 | { |
| 51 | - if (!(bool) preg_match('#^[a-zA-Z][a-zA-Z0-9_]*$#', $name)) { |
|
| 52 | - throw new DBFieldException("Can't create DBField object: invalid field name '".$name."'"); |
|
| 51 | + if (!(bool)preg_match('#^[a-zA-Z][a-zA-Z0-9_]*$#', $name)) { |
|
| 52 | + throw new DBFieldException("Can't create DBField object: invalid field name '" . $name . "'"); |
|
| 53 | 53 | } |
| 54 | 54 | $this->name = $name; |
| 55 | 55 | |
@@ -68,16 +68,16 @@ discard block |
||
| 68 | 68 | if (!is_null($value)) { |
| 69 | 69 | switch ($this->type) { |
| 70 | 70 | case 'i': |
| 71 | - $this->value = (int) $value; |
|
| 71 | + $this->value = (int)$value; |
|
| 72 | 72 | break; |
| 73 | 73 | case 'd': |
| 74 | - $this->value = (float) $value; |
|
| 74 | + $this->value = (float)$value; |
|
| 75 | 75 | break; |
| 76 | 76 | case 's': |
| 77 | - $this->value = (string) $value; |
|
| 77 | + $this->value = (string)$value; |
|
| 78 | 78 | break; |
| 79 | 79 | case 'b': |
| 80 | - $this->value = (bool) $value; |
|
| 80 | + $this->value = (bool)$value; |
|
| 81 | 81 | break; |
| 82 | 82 | } |
| 83 | 83 | } |
@@ -141,7 +141,7 @@ discard block |
||
| 141 | 141 | return 's'; |
| 142 | 142 | } else { |
| 143 | 143 | throw new DBFieldTypeException( |
| 144 | - "Can't detect field value type for value '".(string) $fieldValue."'" |
|
| 144 | + "Can't detect field value type for value '" . (string)$fieldValue . "'" |
|
| 145 | 145 | ); |
| 146 | 146 | } |
| 147 | 147 | } |
@@ -160,13 +160,13 @@ discard block |
||
| 160 | 160 | { |
| 161 | 161 | switch (self::castType($type)) { |
| 162 | 162 | case 'i': |
| 163 | - return (int) $value; |
|
| 163 | + return (int)$value; |
|
| 164 | 164 | case 'd': |
| 165 | - return (float) $value; |
|
| 165 | + return (float)$value; |
|
| 166 | 166 | case 's': |
| 167 | - return (string) $value; |
|
| 167 | + return (string)$value; |
|
| 168 | 168 | case 'b': |
| 169 | - return (bool) $value; |
|
| 169 | + return (bool)$value; |
|
| 170 | 170 | } |
| 171 | 171 | |
| 172 | 172 | throw new DBFieldTypeException('Invalid SQL type'); |
@@ -192,7 +192,7 @@ discard block |
||
| 192 | 192 | return $value; |
| 193 | 193 | case 's': |
| 194 | 194 | if (!in_array($value, ['NOW()'])) { |
| 195 | - return "'".$value."'"; |
|
| 195 | + return "'" . $value . "'"; |
|
| 196 | 196 | } else { |
| 197 | 197 | return $value; |
| 198 | 198 | } |