@@ -24,6 +24,9 @@ |
||
24 | 24 | private $_messages = array(); |
25 | 25 | private $_errors = array(); |
26 | 26 | |
27 | + /** |
|
28 | + * @param null|Route $tpl |
|
29 | + */ |
|
27 | 30 | public function __construct($tpl) { |
28 | 31 | if (!empty($tpl)) { |
29 | 32 | if (is_string($tpl)) { |
@@ -33,7 +33,7 @@ discard block |
||
33 | 33 | $this->_tpl = $tpl; |
34 | 34 | } elseif (Tools::isInstanceOf($tpl, new Route())) { |
35 | 35 | $this->_route = $tpl; |
36 | - $this->_tpl = $this->_route->controller.'/'.$this->_route->controller.'_'.$this->_route->action; |
|
36 | + $this->_tpl = $this->_route->controller . '/' . $this->_route->controller . '_' . $this->_route->action; |
|
37 | 37 | } else { |
38 | 38 | throw new \Exception('Invalid view template'); |
39 | 39 | } |
@@ -48,7 +48,7 @@ discard block |
||
48 | 48 | throw new \Exception('View object was not initialized with template'); |
49 | 49 | } |
50 | 50 | |
51 | - require_once $path.$this->_tpl.$suffix; |
|
51 | + require_once $path . $this->_tpl . $suffix; |
|
52 | 52 | } |
53 | 53 | |
54 | 54 | public function setTpl($_tpl) |
@@ -42,6 +42,9 @@ |
||
42 | 42 | */ |
43 | 43 | private $dbObject = null; |
44 | 44 | |
45 | + /** |
|
46 | + * @param string $className |
|
47 | + */ |
|
45 | 48 | public function __construct($className) { |
46 | 49 | if (is_object($className)) { |
47 | 50 | $className = get_class($className); |
@@ -112,7 +112,7 @@ discard block |
||
112 | 112 | public function selectDBObject($debug = false) |
113 | 113 | { |
114 | 114 | $query = 'SELECT * FROM '.$this->dbObject->getTableName(). |
115 | - ($this->conditions != '' ? ' WHERE '.$this->conditions : '').' LIMIT 1'; |
|
115 | + ($this->conditions != '' ? ' WHERE '.$this->conditions : '').' LIMIT 1'; |
|
116 | 116 | |
117 | 117 | if (!$debug) { |
118 | 118 | $stmt = DBCore::doSelectQuery($query); |
@@ -411,7 +411,7 @@ discard block |
||
411 | 411 | return $this->selectDBObject(); |
412 | 412 | } |
413 | 413 | |
414 | - /* |
|
414 | + /* |
|
415 | 415 | * Try to call parent method __call() with same params by default |
416 | 416 | */ |
417 | 417 | $method = substr($methodName, 0, 3); |
@@ -66,8 +66,8 @@ discard block |
||
66 | 66 | $classNamespaceParts = explode('\\', $this->className); |
67 | 67 | if ($className != $classNamespaceParts[count($classNamespaceParts) - 1]) { |
68 | 68 | throw new DBSelectorException( |
69 | - "Invalid DB object classname '".$className."' in method name. ". |
|
70 | - "Valid classname is '".$this->className."'" |
|
69 | + "Invalid DB object classname '" . $className . "' in method name. " . |
|
70 | + "Valid classname is '" . $this->className . "'" |
|
71 | 71 | ); |
72 | 72 | } |
73 | 73 | } |
@@ -111,8 +111,8 @@ discard block |
||
111 | 111 | */ |
112 | 112 | public function selectDBObject($debug = false) |
113 | 113 | { |
114 | - $query = 'SELECT * FROM '.$this->dbObject->getTableName(). |
|
115 | - ($this->conditions != '' ? ' WHERE '.$this->conditions : '').' LIMIT 1'; |
|
114 | + $query = 'SELECT * FROM ' . $this->dbObject->getTableName() . |
|
115 | + ($this->conditions != '' ? ' WHERE ' . $this->conditions : '') . ' LIMIT 1'; |
|
116 | 116 | |
117 | 117 | if (!$debug) { |
118 | 118 | $stmt = DBCore::doSelectQuery($query); |
@@ -140,10 +140,10 @@ discard block |
||
140 | 140 | */ |
141 | 141 | public function selectDBObjectByField($fieldName, $fieldValue, $debug = false) |
142 | 142 | { |
143 | - $query = 'SELECT * FROM '.$this->dbObject->getTableName().' WHERE '.$fieldName.' = ?'; |
|
143 | + $query = 'SELECT * FROM ' . $this->dbObject->getTableName() . ' WHERE ' . $fieldName . ' = ?'; |
|
144 | 144 | |
145 | 145 | if ($this->conditions != '') { |
146 | - $query .= ' AND '.$this->conditions; |
|
146 | + $query .= ' AND ' . $this->conditions; |
|
147 | 147 | } |
148 | 148 | |
149 | 149 | $query .= $this->getQueryOrderSQL(); |
@@ -191,10 +191,10 @@ discard block |
||
191 | 191 | */ |
192 | 192 | public function selectDBObjects($debug = false) |
193 | 193 | { |
194 | - $query = 'SELECT'.($this->unique ? ' DISTINCT' : '').' * FROM '.$this->dbObject->getTableName(); |
|
194 | + $query = 'SELECT' . ($this->unique ? ' DISTINCT' : '') . ' * FROM ' . $this->dbObject->getTableName(); |
|
195 | 195 | |
196 | 196 | if ($this->conditions != '') { |
197 | - $query .= ' WHERE '.$this->conditions; |
|
197 | + $query .= ' WHERE ' . $this->conditions; |
|
198 | 198 | } |
199 | 199 | |
200 | 200 | $query .= $this->getQueryOrderSQL(); |
@@ -228,11 +228,11 @@ discard block |
||
228 | 228 | */ |
229 | 229 | public function selectDBObjectsByField($fieldName, $fieldValue, $debug = false) |
230 | 230 | { |
231 | - $query = 'SELECT * FROM '.$this->dbObject->getTableName(); |
|
232 | - $query .= ' WHERE '.$fieldName.' = ?'; |
|
231 | + $query = 'SELECT * FROM ' . $this->dbObject->getTableName(); |
|
232 | + $query .= ' WHERE ' . $fieldName . ' = ?'; |
|
233 | 233 | |
234 | 234 | if ($this->conditions != '') { |
235 | - $query .= ' AND '.$this->conditions; |
|
235 | + $query .= ' AND ' . $this->conditions; |
|
236 | 236 | } |
237 | 237 | |
238 | 238 | $query .= $this->getQueryOrderSQL(); |
@@ -263,10 +263,10 @@ discard block |
||
263 | 263 | */ |
264 | 264 | public function count() |
265 | 265 | { |
266 | - $query = 'SELECT count(*) FROM '.$this->dbObject->getTableName(); |
|
266 | + $query = 'SELECT count(*) FROM ' . $this->dbObject->getTableName(); |
|
267 | 267 | |
268 | 268 | if ($this->conditions != '') { |
269 | - $query .= ' WHERE '.$this->conditions; |
|
269 | + $query .= ' WHERE ' . $this->conditions; |
|
270 | 270 | } |
271 | 271 | |
272 | 272 | return DBCore::selectSingleValue($query); |
@@ -279,10 +279,10 @@ discard block |
||
279 | 279 | */ |
280 | 280 | public function max() |
281 | 281 | { |
282 | - $query = 'SELECT max(`'.$this->field.'`) FROM '.$this->dbObject->getTableName(); |
|
282 | + $query = 'SELECT max(`' . $this->field . '`) FROM ' . $this->dbObject->getTableName(); |
|
283 | 283 | |
284 | 284 | if ($this->conditions != '') { |
285 | - $query .= ' WHERE '.$this->conditions; |
|
285 | + $query .= ' WHERE ' . $this->conditions; |
|
286 | 286 | } |
287 | 287 | |
288 | 288 | return DBCore::selectSingleValue($query); |
@@ -295,10 +295,10 @@ discard block |
||
295 | 295 | */ |
296 | 296 | public function min() |
297 | 297 | { |
298 | - $query = 'SELECT min(`'.$this->field.'`) FROM '.$this->dbObject->getTableName(); |
|
298 | + $query = 'SELECT min(`' . $this->field . '`) FROM ' . $this->dbObject->getTableName(); |
|
299 | 299 | |
300 | 300 | if ($this->conditions != '') { |
301 | - $query .= ' WHERE '.$this->conditions; |
|
301 | + $query .= ' WHERE ' . $this->conditions; |
|
302 | 302 | } |
303 | 303 | |
304 | 304 | return DBCore::selectSingleValue($query); |
@@ -312,10 +312,10 @@ discard block |
||
312 | 312 | private function getQueryOrderSQL() |
313 | 313 | { |
314 | 314 | if ($this->order != '') { |
315 | - return ' ORDER BY '.$this->order; |
|
315 | + return ' ORDER BY ' . $this->order; |
|
316 | 316 | } |
317 | 317 | |
318 | - return ' ORDER BY '.$this->dbObject->getIdFieldName().' DESC'; |
|
318 | + return ' ORDER BY ' . $this->dbObject->getIdFieldName() . ' DESC'; |
|
319 | 319 | } |
320 | 320 | |
321 | 321 | /** |
@@ -327,10 +327,10 @@ discard block |
||
327 | 327 | { |
328 | 328 | if ($this->count !== 'all') { |
329 | 329 | if ($this->offset > 0) { |
330 | - return ' LIMIT '.$this->offset.','.$this->count; |
|
330 | + return ' LIMIT ' . $this->offset . ',' . $this->count; |
|
331 | 331 | } |
332 | 332 | |
333 | - return ' LIMIT '.$this->count; |
|
333 | + return ' LIMIT ' . $this->count; |
|
334 | 334 | } |
335 | 335 | |
336 | 336 | return ''; |
@@ -380,9 +380,9 @@ discard block |
||
380 | 380 | elseif (preg_match('#^selectAll([A-Z]{1}[[:alpha:]]+)s#', $methodName, $matches)) { |
381 | 381 | $this->validateClassName(preg_replace('#ie$#', 'y', $matches[1])); |
382 | 382 | |
383 | - $this->order = '`'.$this->dbObject->getIdFieldName().'` DESC'; |
|
383 | + $this->order = '`' . $this->dbObject->getIdFieldName() . '` DESC'; |
|
384 | 384 | if (isset($methodParams[0])) { |
385 | - $this->order = (string) $methodParams[0]; |
|
385 | + $this->order = (string)$methodParams[0]; |
|
386 | 386 | } |
387 | 387 | |
388 | 388 | $dbObjects = $this->selectDBObjects(); |
@@ -425,7 +425,7 @@ discard block |
||
425 | 425 | case 'get': |
426 | 426 | return $this->getFieldValue($fieldName); |
427 | 427 | default: |
428 | - throw new DBSelectorException("No method with name '".$methodName."'"); |
|
428 | + throw new DBSelectorException("No method with name '" . $methodName . "'"); |
|
429 | 429 | } |
430 | 430 | } |
431 | 431 | } |
@@ -110,7 +110,7 @@ |
||
110 | 110 | /** |
111 | 111 | * Count messages in POP server. |
112 | 112 | * |
113 | - * @return type |
|
113 | + * @return integer |
|
114 | 114 | */ |
115 | 115 | public function countMessages() { |
116 | 116 | fputs($this->connection, "STAT\r\n"); |
@@ -62,10 +62,10 @@ discard block |
||
62 | 62 | fgets($sock, 1024); |
63 | 63 | |
64 | 64 | // Connection accepted |
65 | - fwrite($sock, 'USER '.$username."\r\n"); |
|
65 | + fwrite($sock, 'USER ' . $username . "\r\n"); |
|
66 | 66 | $userresponse = fgets($sock, 1024); |
67 | 67 | if ($userresponse[0] == '+') { // User accepted |
68 | - fwrite($sock, 'PASS '.$password."\r\n"); |
|
68 | + fwrite($sock, 'PASS ' . $password . "\r\n"); |
|
69 | 69 | $passresponse = fgets($sock, 1024); |
70 | 70 | if ($passresponse[0] != '+') { // Wrong password |
71 | 71 | $passresponse = str_replace("\r", '', str_replace("\n", '', $passresponse)); |
@@ -76,12 +76,12 @@ discard block |
||
76 | 76 | } |
77 | 77 | } else { // Invalid username |
78 | 78 | throw new POPServerException( |
79 | - "Username '".$username."' not accepted.", 1 |
|
79 | + "Username '" . $username . "' not accepted.", 1 |
|
80 | 80 | ); |
81 | 81 | } |
82 | 82 | } else { |
83 | 83 | throw new POPServerException( |
84 | - 'Unable to Connect to '.$host.'. Network Problems could be responsible.', 2 |
|
84 | + 'Unable to Connect to ' . $host . '. Network Problems could be responsible.', 2 |
|
85 | 85 | ); |
86 | 86 | } |
87 | 87 | $this->connection = $sock; |
@@ -125,7 +125,7 @@ discard block |
||
125 | 125 | $statresponse = fgets($this->connection, 1024); |
126 | 126 | $avar = explode(' ', $statresponse); |
127 | 127 | |
128 | - return (int) $avar[1]; |
|
128 | + return (int)$avar[1]; |
|
129 | 129 | } |
130 | 130 | |
131 | 131 | /** |
@@ -373,8 +373,8 @@ discard block |
||
373 | 373 | $ret = $L2 = $L3 = null; |
374 | 374 | for ($i = 0; $i < $len; $i++) { |
375 | 375 | if (isset($avar[$i]) && isset($avar[$i][0]) && isset($avar[$i][1]) && isset($avar[$i][2])) { |
376 | - $L2 = $avar[$i][0].$avar[$i][1]; |
|
377 | - $L3 = $avar[$i][0].$avar[$i][1].$avar[$i][2]; |
|
376 | + $L2 = $avar[$i][0] . $avar[$i][1]; |
|
377 | + $L3 = $avar[$i][0] . $avar[$i][1] . $avar[$i][2]; |
|
378 | 378 | if ($L2 != ' ' && $L3 != 'Rec' && $L2 != '') { |
379 | 379 | $avar2 = explode(':', $avar[$i]); |
380 | 380 | $temp = str_replace("$avar2[0]:", '', $avar[$i]); |
@@ -62,6 +62,9 @@ |
||
62 | 62 | $this->lastPage = $this->currentPage + $this->pagesOffset; |
63 | 63 | } |
64 | 64 | |
65 | + /** |
|
66 | + * @param integer $currentPage |
|
67 | + */ |
|
65 | 68 | public function setCurrentPage($currentPage) { |
66 | 69 | if (Tools::isInteger($currentPage)) { |
67 | 70 | if ($currentPage < 0) { |
@@ -1,6 +1,6 @@ discard block |
||
1 | 1 | <?php |
2 | 2 | |
3 | -require_once realpath(dirname(__FILE__)).'/../UIControl.php'; |
|
3 | +require_once realpath(dirname(__FILE__)) . '/../UIControl.php'; |
|
4 | 4 | |
5 | 5 | /** |
6 | 6 | * Pagination UI control class. |
@@ -82,7 +82,7 @@ discard block |
||
82 | 82 | |
83 | 83 | public static function getCurrentPageNumber($page, $totalPages) |
84 | 84 | { |
85 | - $page = (int) $page; |
|
85 | + $page = (int)$page; |
|
86 | 86 | |
87 | 87 | if ($page < 1) { |
88 | 88 | return 1; |
@@ -139,9 +139,9 @@ |
||
139 | 139 | $typeByValue = DBField::getType($value); |
140 | 140 | if ($typeByValue != 's') { |
141 | 141 | if ($type != $typeByValue && !( |
142 | - ($type == 'd' && $typeByValue == 'i') || // We can put integer as double |
|
142 | + ($type == 'd' && $typeByValue == 'i') || // We can put integer as double |
|
143 | 143 | ($type == 's' && $typeByValue == 'i') // We can put integer as string |
144 | - ) |
|
144 | + ) |
|
145 | 145 | ) { |
146 | 146 | throw new DBCoreException( |
147 | 147 | "Invalid query parameters types string ('" . $value . |
@@ -140,7 +140,7 @@ discard block |
||
140 | 140 | |
141 | 141 | if (!in_array($type, ['i', 'd', 's', 'b'])) { |
142 | 142 | throw new DBCoreException( |
143 | - "Invalid query parameters types string (type '".$type. |
|
143 | + "Invalid query parameters types string (type '" . $type . |
|
144 | 144 | "' is undefined, only 'i', 'd', 's' and 'b' types are acceptable)" |
145 | 145 | ); |
146 | 146 | } |
@@ -153,30 +153,30 @@ discard block |
||
153 | 153 | ) |
154 | 154 | ) { |
155 | 155 | throw new DBCoreException( |
156 | - "Invalid query parameters types string ('".$value. |
|
157 | - "' is not '".$type."' type but '".$typeByValue."' detected)" |
|
156 | + "Invalid query parameters types string ('" . $value . |
|
157 | + "' is not '" . $type . "' type but '" . $typeByValue . "' detected)" |
|
158 | 158 | ); |
159 | 159 | } |
160 | 160 | } else { // in case if we try send non-string parameters as a string value |
161 | 161 | switch ($type) { |
162 | 162 | case 'i': |
163 | - if (!(Tools::isNumeric($value) && ((string) (int) $value === $value))) { |
|
163 | + if (!(Tools::isNumeric($value) && ((string)(int)$value === $value))) { |
|
164 | 164 | throw new DBCoreException( |
165 | - "Invalid query parameters types string ('".$value."' is not '".$type.')' |
|
165 | + "Invalid query parameters types string ('" . $value . "' is not '" . $type . ')' |
|
166 | 166 | ); |
167 | 167 | } |
168 | 168 | break; |
169 | 169 | case 'd': |
170 | 170 | if (!Tools::isDoubleString($value)) { |
171 | 171 | throw new DBCoreException( |
172 | - "Invalid query parameters types string ('".$value."' is not '".$type.')' |
|
172 | + "Invalid query parameters types string ('" . $value . "' is not '" . $type . ')' |
|
173 | 173 | ); |
174 | 174 | } |
175 | 175 | break; |
176 | 176 | case 'b': |
177 | 177 | if (!in_array(strtolower($value), ['true', 'false'])) { |
178 | 178 | throw new DBCoreException( |
179 | - "Invalid query parameters types string ('".$value."' is not '".$type.')' |
|
179 | + "Invalid query parameters types string ('" . $value . "' is not '" . $type . ')' |
|
180 | 180 | ); |
181 | 181 | } |
182 | 182 | break; |
@@ -210,7 +210,7 @@ discard block |
||
210 | 210 | $chunks = []; |
211 | 211 | foreach (array_keys($fieldsList) as $fieldName) { |
212 | 212 | if ($fieldName != $idFieldName) { |
213 | - $chunks[] = '`'.$fieldName.'` = ?'; |
|
213 | + $chunks[] = '`' . $fieldName . '` = ?'; |
|
214 | 214 | } |
215 | 215 | } |
216 | 216 | |
@@ -230,7 +230,7 @@ discard block |
||
230 | 230 | $chunks = []; |
231 | 231 | foreach ($fieldsList as $fieldName => $fieldValue) { |
232 | 232 | if ($fieldName != $idFieldName) { |
233 | - $chunks[] = '`'.$fieldName."` = '".$fieldValue."'"; |
|
233 | + $chunks[] = '`' . $fieldName . "` = '" . $fieldValue . "'"; |
|
234 | 234 | } |
235 | 235 | } |
236 | 236 | |
@@ -303,7 +303,7 @@ discard block |
||
303 | 303 | foreach ($values as $fieldName => $fieldValue) { |
304 | 304 | if (!is_array($fieldValue)) { |
305 | 305 | if (!is_null($fieldValue)) { |
306 | - $chunks[] = $fieldName.' = ?'; |
|
306 | + $chunks[] = $fieldName . ' = ?'; |
|
307 | 307 | $this->types .= DBField::getType($fieldValue); |
308 | 308 | $this->params[] = $fieldValue; |
309 | 309 | } else { |
@@ -292,7 +292,6 @@ discard block |
||
292 | 292 | * Return parameters from the statment with dynamic number of parameters. |
293 | 293 | * |
294 | 294 | * @param resource $stmt Statement. |
295 | - * @param array $params Parameters. |
|
296 | 295 | */ |
297 | 296 | public static function bindResults($stmt) |
298 | 297 | { |
@@ -495,7 +494,7 @@ discard block |
||
495 | 494 | * Returns printable field description string for table fields list generator. |
496 | 495 | * |
497 | 496 | * @param string $field Field name. |
498 | - * @param array $attributes List of field attributes. |
|
497 | + * @param string $attributes List of field attributes. |
|
499 | 498 | * |
500 | 499 | * @return string |
501 | 500 | */ |
@@ -818,7 +817,7 @@ discard block |
||
818 | 817 | /** |
819 | 818 | * Executes SQL query with single record and value result and return this value. |
820 | 819 | * |
821 | - * @param mixed $query SQL query template string or DBPreparedQuery object |
|
820 | + * @param string $query SQL query template string or DBPreparedQuery object |
|
822 | 821 | * if single parameter. |
823 | 822 | * @param string $types Types string (ex: "isdb"). |
824 | 823 | * @param array $params Parameters in the same order like types string. |
@@ -639,7 +639,7 @@ |
||
639 | 639 | { |
640 | 640 | if (!empty($dbObject) && is_object($dbObject)) { |
641 | 641 | $query = 'DELETE FROM '.$dbObject->getTableName(). |
642 | - ' WHERE '.$dbObject->getIdFieldName().' = ? LIMIT 1'; |
|
642 | + ' WHERE '.$dbObject->getIdFieldName().' = ? LIMIT 1'; |
|
643 | 643 | if (Tools::isInteger($dbObject->getId())) { |
644 | 644 | $typesString = 'i'; |
645 | 645 | } else { |
@@ -115,7 +115,7 @@ discard block |
||
115 | 115 | public function openConnection($connResource, $connName = null) |
116 | 116 | { |
117 | 117 | if ($connName !== null) { |
118 | - $connName = (string) $connName; |
|
118 | + $connName = (string)$connName; |
|
119 | 119 | if (isset($this->connections[$connName])) { |
120 | 120 | throw new DBCoreException('You trying to save a connection with an existing name'); |
121 | 121 | } |
@@ -139,7 +139,7 @@ discard block |
||
139 | 139 | public function getConnection($connName) |
140 | 140 | { |
141 | 141 | if (!isset($this->connections[$connName])) { |
142 | - throw new DBCoreException('Unknown connection: '.$connName); |
|
142 | + throw new DBCoreException('Unknown connection: ' . $connName); |
|
143 | 143 | } |
144 | 144 | |
145 | 145 | return $this->connections[$connName]; |
@@ -304,7 +304,7 @@ discard block |
||
304 | 304 | $resultSet[$field->table] = []; |
305 | 305 | } |
306 | 306 | $resultSet[$field->table][$field->name] = $fieldsCounter++; |
307 | - $parameterName = 'variable'.$fieldsCounter; //$field->name; |
|
307 | + $parameterName = 'variable' . $fieldsCounter; //$field->name; |
|
308 | 308 | $$parameterName = null; |
309 | 309 | $parameters[] = &$$parameterName; |
310 | 310 | } |
@@ -420,7 +420,7 @@ discard block |
||
420 | 420 | public static function getTableFieldsList($tableName) |
421 | 421 | { |
422 | 422 | if (!empty($tableName)) { |
423 | - $query = 'SHOW FULL COLUMNS FROM '.$tableName; |
|
423 | + $query = 'SHOW FULL COLUMNS FROM ' . $tableName; |
|
424 | 424 | $stmt = self::doSelectQuery($query); |
425 | 425 | if ($stmt !== false) { |
426 | 426 | $stmt->bind_result( |
@@ -467,7 +467,7 @@ discard block |
||
467 | 467 | || strpos($type, 'datetime') === 0 |
468 | 468 | || strpos($type, 'timestamp') === 0 |
469 | 469 | || strpos($type, 'date') === 0) { |
470 | - return '"'.$value.'"'; |
|
470 | + return '"' . $value . '"'; |
|
471 | 471 | } elseif (strpos($type, 'int') === 0 |
472 | 472 | || strpos($type, 'tinyint') === 0 |
473 | 473 | || strpos($type, 'smallint') === 0 |
@@ -504,17 +504,17 @@ discard block |
||
504 | 504 | $extra = trim($attributes['extra']); |
505 | 505 | $comment = trim($attributes['comment']); |
506 | 506 | |
507 | - $fieldStr = "'".$field."' => "; |
|
507 | + $fieldStr = "'" . $field . "' => "; |
|
508 | 508 | if ($attributes['null'] === 'YES' && is_null($attributes['default'])) { |
509 | 509 | $fieldStr .= 'null'; |
510 | 510 | } else { |
511 | 511 | $fieldStr .= self::getPrintableSQLValue($attributes['type'], $attributes['default']); |
512 | 512 | } |
513 | - $fieldStr .= ', // '.$attributes['type']. |
|
514 | - ', '.(($attributes['null'] == 'NO') ? 'not null' : 'null') |
|
515 | - .", default '".$attributes['default']."'". |
|
516 | - ($extra ? ', '.$extra : ''). |
|
517 | - ($comment ? ' ('.$comment.')' : '')."\n"; |
|
513 | + $fieldStr .= ', // ' . $attributes['type'] . |
|
514 | + ', ' . (($attributes['null'] == 'NO') ? 'not null' : 'null') |
|
515 | + .", default '" . $attributes['default'] . "'" . |
|
516 | + ($extra ? ', ' . $extra : '') . |
|
517 | + ($comment ? ' (' . $comment . ')' : '') . "\n"; |
|
518 | 518 | |
519 | 519 | return $fieldStr; |
520 | 520 | } |
@@ -572,12 +572,12 @@ discard block |
||
572 | 572 | $idFieldName = $dbObject->getIdFieldName(); |
573 | 573 | |
574 | 574 | if (Tools::isInteger($fieldsList[$idFieldName])) { |
575 | - $query = 'INSERT INTO '.$dbObject->getTableName().' |
|
575 | + $query = 'INSERT INTO ' . $dbObject->getTableName() . ' |
|
576 | 576 | SET '.DBPreparedQuery::sqlQMValuesString($fieldsList, $idFieldName); |
577 | 577 | $typesString = DBPreparedQuery::sqlTypesString($fieldsList, $idFieldName); |
578 | 578 | $valuesList = self::createValuesList($fieldsList, $idFieldName); |
579 | 579 | } else { |
580 | - $query = 'INSERT INTO '.$dbObject->getTableName().' |
|
580 | + $query = 'INSERT INTO ' . $dbObject->getTableName() . ' |
|
581 | 581 | SET '.DBPreparedQuery::sqlQMValuesString($fieldsList); |
582 | 582 | $typesString = DBPreparedQuery::sqlTypesString($fieldsList); |
583 | 583 | $valuesList = self::createValuesList($fieldsList); |
@@ -607,9 +607,9 @@ discard block |
||
607 | 607 | $fieldsList = $dbObject->getFieldsList(); |
608 | 608 | $idFieldName = $dbObject->getIdFieldName(); |
609 | 609 | |
610 | - $query = 'UPDATE '.$dbObject->getTableName().' |
|
611 | - SET '.DBPreparedQuery::sqlQMValuesString($fieldsList, $idFieldName).' |
|
612 | - WHERE '.$idFieldName.' = ? |
|
610 | + $query = 'UPDATE ' . $dbObject->getTableName() . ' |
|
611 | + SET '.DBPreparedQuery::sqlQMValuesString($fieldsList, $idFieldName) . ' |
|
612 | + WHERE '.$idFieldName . ' = ? |
|
613 | 613 | LIMIT 1'; |
614 | 614 | $typesString = DBPreparedQuery::sqlTypesString($fieldsList, $idFieldName); |
615 | 615 | if (Tools::isInteger($fieldsList[$idFieldName])) { |
@@ -638,8 +638,8 @@ discard block |
||
638 | 638 | public static function deleteDBObject($dbObject) |
639 | 639 | { |
640 | 640 | if (!empty($dbObject) && is_object($dbObject)) { |
641 | - $query = 'DELETE FROM '.$dbObject->getTableName(). |
|
642 | - ' WHERE '.$dbObject->getIdFieldName().' = ? LIMIT 1'; |
|
641 | + $query = 'DELETE FROM ' . $dbObject->getTableName() . |
|
642 | + ' WHERE ' . $dbObject->getIdFieldName() . ' = ? LIMIT 1'; |
|
643 | 643 | if (Tools::isInteger($dbObject->getId())) { |
644 | 644 | $typesString = 'i'; |
645 | 645 | } else { |
@@ -694,7 +694,7 @@ discard block |
||
694 | 694 | return; |
695 | 695 | } |
696 | 696 | } elseif ($stmt->num_rows > 1) { |
697 | - throw new DBCoreException("More than single record of '".$className."' entity selected"); |
|
697 | + throw new DBCoreException("More than single record of '" . $className . "' entity selected"); |
|
698 | 698 | } |
699 | 699 | } |
700 | 700 | |
@@ -871,7 +871,7 @@ discard block |
||
871 | 871 | public static function __callStatic($methodName, $methodParams) |
872 | 872 | { |
873 | 873 | if (strrpos($methodName, 'ies') == strlen($methodName) - 3) { |
874 | - $methodName = substr($methodName, 0, strlen($methodName) - 3).'ys'; |
|
874 | + $methodName = substr($methodName, 0, strlen($methodName) - 3) . 'ys'; |
|
875 | 875 | } |
876 | 876 | |
877 | 877 | /* |
@@ -918,12 +918,12 @@ discard block |
||
918 | 918 | $dbObject = new $className(); |
919 | 919 | |
920 | 920 | if (!isInstanceOf($dbObject, $className)) { |
921 | - throw new DBCoreException("Class with name '".$className."' is not exists"); |
|
921 | + throw new DBCoreException("Class with name '" . $className . "' is not exists"); |
|
922 | 922 | } |
923 | 923 | |
924 | - $query = 'DELETE FROM '.$dbObject->getTableName().' |
|
925 | - WHERE '.$dbObject->getIdFieldName().' |
|
926 | - IN ('.DBPreparedQuery::sqlQMString($itemsNumber).')'; |
|
924 | + $query = 'DELETE FROM ' . $dbObject->getTableName() . ' |
|
925 | + WHERE '.$dbObject->getIdFieldName() . ' |
|
926 | + IN ('.DBPreparedQuery::sqlQMString($itemsNumber) . ')'; |
|
927 | 927 | |
928 | 928 | return self::doUpdateQuery($query, $types, $idsList); |
929 | 929 | } |
@@ -936,7 +936,7 @@ discard block |
||
936 | 936 | */ |
937 | 937 | if (preg_match('#delete([a-zA-Z]+)#', $methodName, $matches)) { |
938 | 938 | return call_user_func( |
939 | - [self::getInstance(), $methodName.'s'], |
|
939 | + [self::getInstance(), $methodName . 's'], |
|
940 | 940 | [$methodParams[0]] |
941 | 941 | ); |
942 | 942 | } |
@@ -947,7 +947,7 @@ discard block |
||
947 | 947 | if (preg_match('#set([a-zA-Z]+)Activation#', $methodName, $matches)) { |
948 | 948 | $className = $matches[1]; |
949 | 949 | if (strrpos($className, 'ies') == strlen($className) - 3) { |
950 | - $className = substr($className, 0, strlen($className) - 3).'y'; |
|
950 | + $className = substr($className, 0, strlen($className) - 3) . 'y'; |
|
951 | 951 | } else { |
952 | 952 | $className = substr($className, 0, strlen($className) - 1); |
953 | 953 | } |
@@ -967,17 +967,17 @@ discard block |
||
967 | 967 | $dbObject = new $className(); |
968 | 968 | |
969 | 969 | if (!isInstanceOf($dbObject, $className)) { |
970 | - throw new DBCoreException("Class with name '".$className."' is not exists"); |
|
970 | + throw new DBCoreException("Class with name '" . $className . "' is not exists"); |
|
971 | 971 | } |
972 | 972 | |
973 | - $query = 'UPDATE '.$dbObject->getTableName().' SET `'.$activationFieldName."` = '".$activationValue."' |
|
974 | - WHERE ".$dbObject->getIdFieldName().' IN ('.DBPreparedQuery::sqlQMString($itemsNumber).')'; |
|
973 | + $query = 'UPDATE ' . $dbObject->getTableName() . ' SET `' . $activationFieldName . "` = '" . $activationValue . "' |
|
974 | + WHERE ".$dbObject->getIdFieldName() . ' IN (' . DBPreparedQuery::sqlQMString($itemsNumber) . ')'; |
|
975 | 975 | |
976 | 976 | return self::doUpdateQuery($query, $types, $idsList); |
977 | 977 | } |
978 | 978 | } |
979 | 979 | |
980 | - throw new DBCoreException('No such method "'.$methodName.'"'); |
|
980 | + throw new DBCoreException('No such method "' . $methodName . '"'); |
|
981 | 981 | } |
982 | 982 | } |
983 | 983 |
@@ -58,11 +58,11 @@ discard block |
||
58 | 58 | /** |
59 | 59 | * Sets primary key value. |
60 | 60 | * |
61 | - * @param mixed $recordId Key vaue. |
|
61 | + * @param integer $recordId Key vaue. |
|
62 | 62 | * |
63 | 63 | * @throws DBCoreException If object has no field with such name. |
64 | 64 | * |
65 | - * @return bool Success flag. |
|
65 | + * @return DBObject Success flag. |
|
66 | 66 | */ |
67 | 67 | public function setId($recordId) |
68 | 68 | { |
@@ -532,7 +532,7 @@ discard block |
||
532 | 532 | /** |
533 | 533 | * Deletes DB record for current DBObject. |
534 | 534 | * |
535 | - * @return mixed Number of affected rows (1 if some record was deleted, |
|
535 | + * @return integer Number of affected rows (1 if some record was deleted, |
|
536 | 536 | * 0 - if no) or FALSE if some error occurred. |
537 | 537 | */ |
538 | 538 | public function delete() |
@@ -98,9 +98,9 @@ discard block |
||
98 | 98 | public function saveActivationFlag() |
99 | 99 | { |
100 | 100 | return DBCore::doUpdateQuery( |
101 | - 'UPDATE '.static::TABLE_NAME.' |
|
101 | + 'UPDATE ' . static::TABLE_NAME . ' |
|
102 | 102 | SET activation = ? |
103 | - WHERE '.static::ID_FIELD_NAME.' = ? |
|
103 | + WHERE '.static::ID_FIELD_NAME . ' = ? |
|
104 | 104 | LIMIT 1', |
105 | 105 | 'ii', |
106 | 106 | [$this->activation, $this->id] |
@@ -169,9 +169,9 @@ discard block |
||
169 | 169 | public function saveRemovementFlag() |
170 | 170 | { |
171 | 171 | return DBCore::doUpdateQuery( |
172 | - 'UPDATE '.static::TABLE_NAME.' |
|
172 | + 'UPDATE ' . static::TABLE_NAME . ' |
|
173 | 173 | SET removed = ? |
174 | - WHERE '.static::ID_FIELD_NAME.' = ? |
|
174 | + WHERE '.static::ID_FIELD_NAME . ' = ? |
|
175 | 175 | LIMIT 1', |
176 | 176 | 'ii', |
177 | 177 | [$this->removed, $this->id] |
@@ -434,14 +434,14 @@ discard block |
||
434 | 434 | { |
435 | 435 | switch ($this->dbQuery->getType()) { |
436 | 436 | case DBQueryType::SELECT: |
437 | - $this->dbQuery->query = 'SELECT * FROM '.static::TABLE_NAME; |
|
437 | + $this->dbQuery->query = 'SELECT * FROM ' . static::TABLE_NAME; |
|
438 | 438 | break; |
439 | 439 | case DBQueryType::UPDATE: |
440 | - $this->dbQuery->query = 'UPDATE '.static::TABLE_NAME.' SET '; |
|
440 | + $this->dbQuery->query = 'UPDATE ' . static::TABLE_NAME . ' SET '; |
|
441 | 441 | $this->dbQuery->sqlPushValues($this->dbQuery->fields); |
442 | 442 | break; |
443 | 443 | case DBQueryType::DELETE: |
444 | - $this->dbQuery->query = 'DELETE FROM '.static::TABLE_NAME; |
|
444 | + $this->dbQuery->query = 'DELETE FROM ' . static::TABLE_NAME; |
|
445 | 445 | break; |
446 | 446 | } |
447 | 447 | |
@@ -466,11 +466,11 @@ discard block |
||
466 | 466 | $this->dbQuery->query .= ' ORDER BY'; |
467 | 467 | if (is_array($this->dbQuery->order)) { |
468 | 468 | foreach ($this->dbQuery->order as $fieldName => $ord) { |
469 | - $this->dbQuery->query .= ' '.$fieldName.' '.$ord.','; |
|
469 | + $this->dbQuery->query .= ' ' . $fieldName . ' ' . $ord . ','; |
|
470 | 470 | } |
471 | 471 | $this->dbQuery->query = substr($this->dbQuery->query, 0, strlen($this->dbQuery->query) - 1); |
472 | 472 | } elseif (is_string($this->dbQuery->order)) { |
473 | - $this->dbQuery->query .= ' '.$this->dbQuery->order; |
|
473 | + $this->dbQuery->query .= ' ' . $this->dbQuery->order; |
|
474 | 474 | } |
475 | 475 | } |
476 | 476 | } |
@@ -482,13 +482,13 @@ discard block |
||
482 | 482 | if ($this->isNewRecord()) { |
483 | 483 | if (!is_null($this->dbQuery->limit)) { |
484 | 484 | if (Tools::isInteger($this->dbQuery->limit)) { |
485 | - $this->dbQuery->query .= ' LIMIT '.$this->dbQuery->limit; |
|
485 | + $this->dbQuery->query .= ' LIMIT ' . $this->dbQuery->limit; |
|
486 | 486 | $count = $this->dbQuery->limit; |
487 | 487 | } elseif (is_array($this->dbQuery->limit) && count($this->dbQuery->limit) == 2) { |
488 | 488 | $offset = $this->dbQuery->limit[0]; |
489 | 489 | $count = $this->dbQuery->limit[1]; |
490 | 490 | if (Tools::isInteger($offset) && Tools::isInteger($count)) { |
491 | - $this->dbQuery->query .= ' LIMIT '.$offset.', '.$count; |
|
491 | + $this->dbQuery->query .= ' LIMIT ' . $offset . ', ' . $count; |
|
492 | 492 | } else { |
493 | 493 | throw new DBCoreException('Invalid LIMIT param in select() method.'); |
494 | 494 | } |
@@ -143,7 +143,7 @@ |
||
143 | 143 | * css($propertyName, $propertyValue) Set the value of a CSS property. |
144 | 144 | * |
145 | 145 | * @param string $propertyName Name of a CSS property. |
146 | - * @param mixed $propertyValue Value of a CSS property. |
|
146 | + * @param string $propertyValue Value of a CSS property. |
|
147 | 147 | * |
148 | 148 | * @return Value of the CSS property or NULL if property is not exists. |
149 | 149 | */ |
@@ -117,7 +117,7 @@ discard block |
||
117 | 117 | if (isset($this->$attributeName)) { |
118 | 118 | $this->$attributeName = $attributeValue; |
119 | 119 | } else { |
120 | - throw new \Exception("Wrong attribute '".$attributeName."' for ".get_class($this).' component'); |
|
120 | + throw new \Exception("Wrong attribute '" . $attributeName . "' for " . get_class($this) . ' component'); |
|
121 | 121 | } |
122 | 122 | } |
123 | 123 | } |
@@ -170,7 +170,7 @@ discard block |
||
170 | 170 | { |
171 | 171 | $style = ''; |
172 | 172 | foreach ($this->style as $propertyName => $propertyValue) { |
173 | - $style .= $propertyName.':'.$propertyValue.';'; |
|
173 | + $style .= $propertyName . ':' . $propertyValue . ';'; |
|
174 | 174 | } |
175 | 175 | |
176 | 176 | return $style; |
@@ -15,7 +15,7 @@ discard block |
||
15 | 15 | OutputStream::start(); |
16 | 16 | |
17 | 17 | if (!file_exists(RESULTS_PATH) || is_file(RESULTS_PATH)) { |
18 | - OutputStream::msg(OutputStream::MSG_ERROR, "Destination directory '".RESULTS_PATH."' doesn't exists."); |
|
18 | + OutputStream::msg(OutputStream::MSG_ERROR, "Destination directory '" . RESULTS_PATH . "' doesn't exists."); |
|
19 | 19 | OutputStream::close(); |
20 | 20 | exit(); |
21 | 21 | } |
@@ -26,9 +26,9 @@ discard block |
||
26 | 26 | if ($stmt !== false) { |
27 | 27 | $tpl = file_get_contents(CLASS_TPL); |
28 | 28 | while ($resultSet = DBCore::bindResults($stmt)) { |
29 | - $tableName = $resultSet['TABLE_NAMES']['Tables_in_'.conf\Config::getDBConfigParam('DBNAME')]; |
|
29 | + $tableName = $resultSet['TABLE_NAMES']['Tables_in_' . conf\Config::getDBConfigParam('DBNAME')]; |
|
30 | 30 | |
31 | - OutputStream::msg(OutputStream::MSG_INFO, "Reading structure for table '".$tableName."'..."); |
|
31 | + OutputStream::msg(OutputStream::MSG_INFO, "Reading structure for table '" . $tableName . "'..."); |
|
32 | 32 | |
33 | 33 | $idFieldName = 'id'; |
34 | 34 | $fieldsListStr = ''; |
@@ -38,7 +38,7 @@ discard block |
||
38 | 38 | if ($attributes['key'] === 'PRI') { |
39 | 39 | $idFieldName = $field; |
40 | 40 | } |
41 | - $fieldsListStr .= ' '.DBCore::getPrintableFieldString($field, $attributes); |
|
41 | + $fieldsListStr .= ' ' . DBCore::getPrintableFieldString($field, $attributes); |
|
42 | 42 | } |
43 | 43 | $fieldsListStr = substr($fieldsListStr, 0, strlen($fieldsListStr) - 1); |
44 | 44 | |
@@ -52,11 +52,11 @@ discard block |
||
52 | 52 | date('Y'), AUTHOR, EMAIL, |
53 | 53 | ], $tpl); |
54 | 54 | |
55 | - file_put_contents(RESULTS_PATH.$className.'.php', $content); |
|
55 | + file_put_contents(RESULTS_PATH . $className . '.php', $content); |
|
56 | 56 | |
57 | - OutputStream::msg(OutputStream::MSG_SUCCESS, "Class '".RESULTS_PATH.$className.".php' generated."); |
|
57 | + OutputStream::msg(OutputStream::MSG_SUCCESS, "Class '" . RESULTS_PATH . $className . ".php' generated."); |
|
58 | 58 | } else { |
59 | - OutputStream::msg(OutputStream::MSG_ERROR, "Can't read structure for table '".$tableName."'."); |
|
59 | + OutputStream::msg(OutputStream::MSG_ERROR, "Can't read structure for table '" . $tableName . "'."); |
|
60 | 60 | } |
61 | 61 | } |
62 | 62 | |
@@ -70,7 +70,7 @@ discard block |
||
70 | 70 | { |
71 | 71 | $underlinesReplaced = preg_replace_callback( |
72 | 72 | '/_([a-zA-Z]{1})/', |
73 | - function ($matches) { |
|
73 | + function($matches) { |
|
74 | 74 | return strtoupper($matches[1]); |
75 | 75 | }, |
76 | 76 | $tableName |