@@ -68,7 +68,7 @@ discard block |
||
| 68 | 68 | // check access for API response modes |
| 69 | 69 | $this->responseBuilder = JsonBuilder::class; |
| 70 | 70 | |
| 71 | - if (in_array($this->responseBuilder, [JsonBuilder::class,JsonpBuilder::class])) { |
|
| 71 | + if (in_array($this->responseBuilder, [JsonBuilder::class, JsonpBuilder::class])) { |
|
| 72 | 72 | if (!$this->checkAPIAccess()) { |
| 73 | 73 | return $this->throwAPIUnAuthorizedError(); |
| 74 | 74 | } |
@@ -81,8 +81,7 @@ discard block |
||
| 81 | 81 | public function handleRecordsRequest($action = false): ResponseInterface |
| 82 | 82 | { |
| 83 | 83 | switch ($action ? $action : $action = $this->shiftPath()) { |
| 84 | - case 'save': |
|
| 85 | - { |
|
| 84 | + case 'save' : { |
|
| 86 | 85 | return $this->handleMultiSaveRequest(); |
| 87 | 86 | } |
| 88 | 87 | |
@@ -223,9 +222,7 @@ discard block |
||
| 223 | 222 | } |
| 224 | 223 | |
| 225 | 224 | switch ($action ? $action : $action = $this->shiftPath()) { |
| 226 | - case '': |
|
| 227 | - case false: |
|
| 228 | - { |
|
| 225 | + case '' : case false : { |
|
| 229 | 226 | $className = static::$recordClass; |
| 230 | 227 | |
| 231 | 228 | return $this->respond($this->getTemplateName($className::$singularNoun), [ |
@@ -313,7 +310,7 @@ discard block |
||
| 313 | 310 | { |
| 314 | 311 | $className = static::$recordClass; |
| 315 | 312 | |
| 316 | - $this->prepareResponseModeJSON(['POST','PUT']); |
|
| 313 | + $this->prepareResponseModeJSON(['POST', 'PUT']); |
|
| 317 | 314 | |
| 318 | 315 | if ($className::fieldExists(key($_REQUEST['data']))) { |
| 319 | 316 | $_REQUEST['data'] = [$_REQUEST['data']]; |
@@ -385,7 +382,7 @@ discard block |
||
| 385 | 382 | { |
| 386 | 383 | $className = static::$recordClass; |
| 387 | 384 | |
| 388 | - $this->prepareResponseModeJSON(['POST','PUT','DELETE']); |
|
| 385 | + $this->prepareResponseModeJSON(['POST', 'PUT', 'DELETE']); |
|
| 389 | 386 | |
| 390 | 387 | if ($className::fieldExists(key($_REQUEST['data']))) { |
| 391 | 388 | $_REQUEST['data'] = [$_REQUEST['data']]; |
@@ -447,7 +444,7 @@ discard block |
||
| 447 | 444 | return $this->throwUnauthorizedError(); |
| 448 | 445 | } |
| 449 | 446 | |
| 450 | - if (in_array($_SERVER['REQUEST_METHOD'], ['POST','PUT'])) { |
|
| 447 | + if (in_array($_SERVER['REQUEST_METHOD'], ['POST', 'PUT'])) { |
|
| 451 | 448 | if ($this->responseBuilder === JsonBuilder::class) { |
| 452 | 449 | $_REQUEST = JSON::getRequestData(); |
| 453 | 450 | if (is_array($_REQUEST['data'])) { |
@@ -597,7 +594,7 @@ discard block |
||
| 597 | 594 | |
| 598 | 595 | public function getTemplateName($noun) |
| 599 | 596 | { |
| 600 | - return preg_replace_callback('/\s+([a-zA-Z])/', function ($matches) { |
|
| 597 | + return preg_replace_callback('/\s+([a-zA-Z])/', function($matches) { |
|
| 601 | 598 | return strtoupper($matches[1]); |
| 602 | 599 | }, $noun); |
| 603 | 600 | } |
@@ -43,9 +43,9 @@ |
||
| 43 | 43 | |
| 44 | 44 | public function config($Label) |
| 45 | 45 | { |
| 46 | - $Config = $this->ApplicationPath . '/config/' . $Label . '.php'; |
|
| 46 | + $Config = $this->ApplicationPath.'/config/'.$Label.'.php'; |
|
| 47 | 47 | if (!file_exists($Config)) { |
| 48 | - throw new \Exception($Config . ' not found in '.static::class.'::config()'); |
|
| 48 | + throw new \Exception($Config.' not found in '.static::class.'::config()'); |
|
| 49 | 49 | } |
| 50 | 50 | return require $Config; |
| 51 | 51 | } |
@@ -80,7 +80,7 @@ discard block |
||
| 80 | 80 | |
| 81 | 81 | public static $searchConditions = [ |
| 82 | 82 | 'Caption' => [ |
| 83 | - 'qualifiers' => ['any','caption'], |
|
| 83 | + 'qualifiers' => ['any', 'caption'], |
|
| 84 | 84 | 'points' => 2, |
| 85 | 85 | 'sql' => 'Caption LIKE "%%%s%%"', |
| 86 | 86 | ], |
@@ -109,7 +109,7 @@ discard block |
||
| 109 | 109 | public static $defaultFilenameFormat = 'default.%s.jpg'; |
| 110 | 110 | public static $newDirectoryPermissions = 0775; |
| 111 | 111 | public static $newFilePermissions = 0664; |
| 112 | - public static $magicPath = null;//'/usr/share/misc/magic.mgc'; |
|
| 112 | + public static $magicPath = null; //'/usr/share/misc/magic.mgc'; |
|
| 113 | 113 | public static $useFaceDetection = true; |
| 114 | 114 | public static $faceDetectionTimeLimit = 10; |
| 115 | 115 | |
@@ -628,7 +628,7 @@ discard block |
||
| 628 | 628 | |
| 629 | 629 | public static function getBlankPath($contextClass) |
| 630 | 630 | { |
| 631 | - $path = ['site-root','img',sprintf(static::$defaultFilenameFormat, $contextClass)]; |
|
| 631 | + $path = ['site-root', 'img', sprintf(static::$defaultFilenameFormat, $contextClass)]; |
|
| 632 | 632 | |
| 633 | 633 | if ($node = Site::resolvePath($path)) { |
| 634 | 634 | return $node->RealPath; |
@@ -113,7 +113,7 @@ |
||
| 113 | 113 | $Session->setFields($sessionData); |
| 114 | 114 | if (function_exists('fastcgi_finish_request')) { |
| 115 | 115 | // @codeCoverageIgnoreStart |
| 116 | - register_shutdown_function(function ($Session) { |
|
| 116 | + register_shutdown_function(function($Session) { |
|
| 117 | 117 | $Session->save(); |
| 118 | 118 | }, $Session); |
| 119 | 119 | // @codeCoverageIgnoreEnd |
@@ -39,7 +39,7 @@ discard block |
||
| 39 | 39 | |
| 40 | 40 | public $searchConditions = [ |
| 41 | 41 | 'Caption' => [ |
| 42 | - 'qualifiers' => ['any','caption'] |
|
| 42 | + 'qualifiers' => ['any', 'caption'] |
|
| 43 | 43 | ,'points' => 2 |
| 44 | 44 | ,'sql' => 'Caption LIKE "%%%s%%"', |
| 45 | 45 | ] |
@@ -191,7 +191,7 @@ discard block |
||
| 191 | 191 | } elseif ($_SERVER['REQUEST_METHOD'] == 'PUT') { |
| 192 | 192 | $put = fopen(static::$inputStream, 'r'); // open input stream |
| 193 | 193 | |
| 194 | - $tmp = tempnam('/tmp', 'dvr'); // use PHP to make a temporary file |
|
| 194 | + $tmp = tempnam('/tmp', 'dvr'); // use PHP to make a temporary file |
|
| 195 | 195 | $fp = fopen($tmp, 'w'); // open write stream to temp file |
| 196 | 196 | |
| 197 | 197 | // write |
@@ -227,7 +227,7 @@ discard block |
||
| 227 | 227 | } |
| 228 | 228 | |
| 229 | 229 | return $this->respond('uploadComplete', [ |
| 230 | - 'success' => (boolean)$Media |
|
| 230 | + 'success' => (boolean) $Media |
|
| 231 | 231 | ,'data' => $Media, |
| 232 | 232 | ]); |
| 233 | 233 | } |
@@ -277,11 +277,11 @@ discard block |
||
| 277 | 277 | } |
| 278 | 278 | |
| 279 | 279 | // send caching headers |
| 280 | - $expires = 60*60*24*365; |
|
| 280 | + $expires = 60 * 60 * 24 * 365; |
|
| 281 | 281 | if (!headers_sent()) { |
| 282 | 282 | // @codeCoverageIgnoreStart |
| 283 | 283 | header("Cache-Control: public, max-age=$expires"); |
| 284 | - header('Expires: '.gmdate('D, d M Y H:i:s \G\M\T', time()+$expires)); |
|
| 284 | + header('Expires: '.gmdate('D, d M Y H:i:s \G\M\T', time() + $expires)); |
|
| 285 | 285 | header('Pragma: public'); |
| 286 | 286 | // @codeCoverageIgnoreEnd |
| 287 | 287 | } |
@@ -524,9 +524,9 @@ discard block |
||
| 524 | 524 | // send caching headers |
| 525 | 525 | if (!headers_sent()) { |
| 526 | 526 | // @codeCoverageIgnoreStart |
| 527 | - $expires = 60*60*24*365; |
|
| 527 | + $expires = 60 * 60 * 24 * 365; |
|
| 528 | 528 | header("Cache-Control: public, max-age=$expires"); |
| 529 | - header('Expires: '.gmdate('D, d M Y H:i:s \G\M\T', time()+$expires)); |
|
| 529 | + header('Expires: '.gmdate('D, d M Y H:i:s \G\M\T', time() + $expires)); |
|
| 530 | 530 | header('Pragma: public'); |
| 531 | 531 | // @codeCoverageIgnoreEnd |
| 532 | 532 | } |
@@ -28,17 +28,17 @@ |
||
| 28 | 28 | |
| 29 | 29 | public function setBooleanValue($value): bool |
| 30 | 30 | { |
| 31 | - return (boolean)$value; |
|
| 31 | + return (boolean) $value; |
|
| 32 | 32 | } |
| 33 | 33 | |
| 34 | 34 | public function setDecimalValue($value): ?float |
| 35 | 35 | { |
| 36 | - return is_null($value) ? null : (float)preg_replace('/[^-\d.]/', '', $value); |
|
| 36 | + return is_null($value) ? null : (float) preg_replace('/[^-\d.]/', '', $value); |
|
| 37 | 37 | } |
| 38 | 38 | |
| 39 | 39 | public function setIntegerValue($value): ?int |
| 40 | 40 | { |
| 41 | - return is_null($value) ? null : (int)preg_replace('/[^-\d]/', '', $value); |
|
| 41 | + return is_null($value) ? null : (int) preg_replace('/[^-\d]/', '', $value); |
|
| 42 | 42 | } |
| 43 | 43 | |
| 44 | 44 | public function setTimestampValue($value): ?string |
@@ -132,9 +132,9 @@ discard block |
||
| 132 | 132 | |
| 133 | 133 | if ($cacheIndex) { |
| 134 | 134 | $key = sprintf('%s/%s:%s', static::$tableName, $field, $value); |
| 135 | - return DB::oneRecordCached($key, $query, $params, [static::class,'handleError']); |
|
| 135 | + return DB::oneRecordCached($key, $query, $params, [static::class, 'handleError']); |
|
| 136 | 136 | } else { |
| 137 | - return DB::oneRecord($query, $params, [static::class,'handleError']); |
|
| 137 | + return DB::oneRecord($query, $params, [static::class, 'handleError']); |
|
| 138 | 138 | } |
| 139 | 139 | } |
| 140 | 140 | |
@@ -180,7 +180,7 @@ discard block |
||
| 180 | 180 | join(') AND (', $conditions), |
| 181 | 181 | $order ? 'ORDER BY '.join(',', $order) : '', |
| 182 | 182 | ], |
| 183 | - [static::class,'handleError'] |
|
| 183 | + [static::class, 'handleError'] |
|
| 184 | 184 | ); |
| 185 | 185 | } |
| 186 | 186 | |
@@ -193,7 +193,7 @@ discard block |
||
| 193 | 193 | */ |
| 194 | 194 | public static function getByQuery($query, $params = []) |
| 195 | 195 | { |
| 196 | - return static::instantiateRecord(DB::oneRecord($query, $params, [static::class,'handleError'])); |
|
| 196 | + return static::instantiateRecord(DB::oneRecord($query, $params, [static::class, 'handleError'])); |
|
| 197 | 197 | } |
| 198 | 198 | |
| 199 | 199 | /** |
@@ -295,7 +295,7 @@ discard block |
||
| 295 | 295 | ]; |
| 296 | 296 | |
| 297 | 297 | if ($options['order']) { |
| 298 | - $query .= ' ORDER BY ' . join(',', static::_mapFieldOrder($options['order'])); |
|
| 298 | + $query .= ' ORDER BY '.join(',', static::_mapFieldOrder($options['order'])); |
|
| 299 | 299 | } |
| 300 | 300 | |
| 301 | 301 | if ($options['limit']) { |
@@ -303,9 +303,9 @@ discard block |
||
| 303 | 303 | } |
| 304 | 304 | |
| 305 | 305 | if ($options['indexField']) { |
| 306 | - return DB::table(static::_cn($options['indexField']), $query, $params, null, [static::class,'handleError']); |
|
| 306 | + return DB::table(static::_cn($options['indexField']), $query, $params, null, [static::class, 'handleError']); |
|
| 307 | 307 | } else { |
| 308 | - return DB::allRecords($query, $params, [static::class,'handleError']); |
|
| 308 | + return DB::allRecords($query, $params, [static::class, 'handleError']); |
|
| 309 | 309 | } |
| 310 | 310 | } |
| 311 | 311 | |
@@ -318,12 +318,12 @@ discard block |
||
| 318 | 318 | */ |
| 319 | 319 | public static function getAllByQuery($query, $params = []) |
| 320 | 320 | { |
| 321 | - return static::instantiateRecords(DB::allRecords($query, $params, [static::class,'handleError'])); |
|
| 321 | + return static::instantiateRecords(DB::allRecords($query, $params, [static::class, 'handleError'])); |
|
| 322 | 322 | } |
| 323 | 323 | |
| 324 | 324 | public static function getTableByQuery($keyField, $query, $params = []) |
| 325 | 325 | { |
| 326 | - return static::instantiateRecords(DB::table($keyField, $query, $params, [static::class,'handleError'])); |
|
| 326 | + return static::instantiateRecords(DB::table($keyField, $query, $params, [static::class, 'handleError'])); |
|
| 327 | 327 | } |
| 328 | 328 | |
| 329 | 329 | /** |
@@ -372,7 +372,7 @@ discard block |
||
| 372 | 372 | ]; |
| 373 | 373 | |
| 374 | 374 | if ($options['order']) { |
| 375 | - $query .= ' ORDER BY ' . join(',', static::_mapFieldOrder($options['order'])); |
|
| 375 | + $query .= ' ORDER BY '.join(',', static::_mapFieldOrder($options['order'])); |
|
| 376 | 376 | } |
| 377 | 377 | |
| 378 | 378 | if ($options['limit']) { |
@@ -380,9 +380,9 @@ discard block |
||
| 380 | 380 | } |
| 381 | 381 | |
| 382 | 382 | if ($options['indexField']) { |
| 383 | - return DB::table(static::_cn($options['indexField']), $query, $params, null, [static::class,'handleError']); |
|
| 383 | + return DB::table(static::_cn($options['indexField']), $query, $params, null, [static::class, 'handleError']); |
|
| 384 | 384 | } else { |
| 385 | - return DB::allRecords($query, $params, [static::class,'handleError']); |
|
| 385 | + return DB::allRecords($query, $params, [static::class, 'handleError']); |
|
| 386 | 386 | } |
| 387 | 387 | } |
| 388 | 388 | |