@@ -16,14 +16,14 @@ discard block |
||
| 16 | 16 | $image = $item->uploadImage(); |
| 17 | 17 | |
| 18 | 18 | if (is_object($image)) { |
| 19 | - $response['type'] = 'success'; |
|
| 20 | - $response['url'] = $image->url; |
|
| 21 | - $response['path'] = $image->name; |
|
| 22 | - $response['width'] = $item->getImageWidth("default"); |
|
| 23 | - $response['height'] = $item->getImageHeight("default"); |
|
| 19 | + $response[ 'type' ] = 'success'; |
|
| 20 | + $response[ 'url' ] = $image->url; |
|
| 21 | + $response[ 'path' ] = $image->name; |
|
| 22 | + $response[ 'width' ] = $item->getImageWidth("default"); |
|
| 23 | + $response[ 'height' ] = $item->getImageHeight("default"); |
|
| 24 | 24 | } |
| 25 | 25 | |
| 26 | - $response['message'] = $item->errors['upload']; |
|
| 26 | + $response[ 'message' ] = $item->errors[ 'upload' ]; |
|
| 27 | 27 | $this->setResponseValues($response); |
| 28 | 28 | } |
| 29 | 29 | |
@@ -40,9 +40,9 @@ discard block |
||
| 40 | 40 | $image = $item->cropImages($_POST); |
| 41 | 41 | |
| 42 | 42 | if ($image) { |
| 43 | - $response['type'] = 'success'; |
|
| 44 | - $response['url'] = $image->url; |
|
| 45 | - $response['name'] = $image->name; |
|
| 43 | + $response[ 'type' ] = 'success'; |
|
| 44 | + $response[ 'url' ] = $image->url; |
|
| 45 | + $response[ 'name' ] = $image->name; |
|
| 46 | 46 | } |
| 47 | 47 | $this->setResponseValues($response); |
| 48 | 48 | } |
@@ -53,7 +53,7 @@ discard block |
||
| 53 | 53 | |
| 54 | 54 | if ($item->setDefaultImage($_POST)) { |
| 55 | 55 | $item->update(); |
| 56 | - $response['type'] = 'success'; |
|
| 56 | + $response[ 'type' ] = 'success'; |
|
| 57 | 57 | } |
| 58 | 58 | } |
| 59 | 59 | |
@@ -62,7 +62,7 @@ discard block |
||
| 62 | 62 | $item = $this->getModelFromRequest(); |
| 63 | 63 | |
| 64 | 64 | if ($item->removeImage($_POST)) { |
| 65 | - $response['type'] = 'success'; |
|
| 65 | + $response[ 'type' ] = 'success'; |
|
| 66 | 66 | } |
| 67 | 67 | $this->setResponseValues($response); |
| 68 | 68 | } |
@@ -16,14 +16,14 @@ discard block |
||
| 16 | 16 | $cover = $item->uploadCover(); |
| 17 | 17 | |
| 18 | 18 | if (is_object($cover)) { |
| 19 | - $response['type'] = 'success'; |
|
| 20 | - $response['url'] = $cover->url; |
|
| 21 | - $response['path'] = $cover->name; |
|
| 22 | - $response['width'] = $cover->cropWidth; |
|
| 23 | - $response['height'] = $cover->cropHeight; |
|
| 19 | + $response[ 'type' ] = 'success'; |
|
| 20 | + $response[ 'url' ] = $cover->url; |
|
| 21 | + $response[ 'path' ] = $cover->name; |
|
| 22 | + $response[ 'width' ] = $cover->cropWidth; |
|
| 23 | + $response[ 'height' ] = $cover->cropHeight; |
|
| 24 | 24 | } |
| 25 | 25 | |
| 26 | - $response['message'] = $item->errors['upload']; |
|
| 26 | + $response[ 'message' ] = $item->errors[ 'upload' ]; |
|
| 27 | 27 | $this->setResponseValues($response); |
| 28 | 28 | } |
| 29 | 29 | |
@@ -40,9 +40,9 @@ discard block |
||
| 40 | 40 | $cover = $item->cropCovers($_POST); |
| 41 | 41 | |
| 42 | 42 | if ($cover) { |
| 43 | - $response['type'] = 'success'; |
|
| 44 | - $response['url'] = $cover->url; |
|
| 45 | - $response['name'] = $cover->name; |
|
| 43 | + $response[ 'type' ] = 'success'; |
|
| 44 | + $response[ 'url' ] = $cover->url; |
|
| 45 | + $response[ 'name' ] = $cover->name; |
|
| 46 | 46 | } |
| 47 | 47 | $this->setResponseValues($response); |
| 48 | 48 | } |
@@ -52,7 +52,7 @@ discard block |
||
| 52 | 52 | $item = $this->getModelFromRequest(); |
| 53 | 53 | |
| 54 | 54 | if ($item->setDefaultCover($_POST)) { |
| 55 | - $response['type'] = 'success'; |
|
| 55 | + $response[ 'type' ] = 'success'; |
|
| 56 | 56 | } |
| 57 | 57 | $this->setResponseValues($response); |
| 58 | 58 | } |
@@ -62,7 +62,7 @@ discard block |
||
| 62 | 62 | $item = $this->getModelFromRequest(); |
| 63 | 63 | |
| 64 | 64 | if ($item->removeCover($_POST)) { |
| 65 | - $response['type'] = 'success'; |
|
| 65 | + $response[ 'type' ] = 'success'; |
|
| 66 | 66 | } |
| 67 | 67 | $this->setResponseValues($response); |
| 68 | 68 | } |
@@ -13,18 +13,18 @@ discard block |
||
| 13 | 13 | { |
| 14 | 14 | $item = $this->getModelFromRequest(); |
| 15 | 15 | |
| 16 | - $type = $_REQUEST['type']; |
|
| 16 | + $type = $_REQUEST[ 'type' ]; |
|
| 17 | 17 | if (in_array($type, $item->logoTypes)) { |
| 18 | 18 | $image = $item->uploadLogo($type); |
| 19 | 19 | |
| 20 | 20 | if (is_object($image)) { |
| 21 | - $response['type'] = 'success'; |
|
| 22 | - $response['url'] = $image->getUrl(); |
|
| 23 | - $response['path'] = $image->getPath(); |
|
| 24 | - $response['imageType'] = $image->getImageType(); |
|
| 21 | + $response[ 'type' ] = 'success'; |
|
| 22 | + $response[ 'url' ] = $image->getUrl(); |
|
| 23 | + $response[ 'path' ] = $image->getPath(); |
|
| 24 | + $response[ 'imageType' ] = $image->getImageType(); |
|
| 25 | 25 | $this->setResponseValues($response); |
| 26 | 26 | } else { |
| 27 | - $this->sendError($item->errors['upload']); |
|
| 27 | + $this->sendError($item->errors[ 'upload' ]); |
|
| 28 | 28 | } |
| 29 | 29 | } else { |
| 30 | 30 | $this->sendError('bad logo type'); |
@@ -42,15 +42,15 @@ discard block |
||
| 42 | 42 | $item = $this->getModelFromRequest(); |
| 43 | 43 | |
| 44 | 44 | if ($item->removeLogo($_REQUEST)) { |
| 45 | - $response['message'] = 'Logo sters'; |
|
| 45 | + $response[ 'message' ] = 'Logo sters'; |
|
| 46 | 46 | } else { |
| 47 | - $response['message'] = 'Logo-ul convertit la default'; |
|
| 47 | + $response[ 'message' ] = 'Logo-ul convertit la default'; |
|
| 48 | 48 | } |
| 49 | 49 | |
| 50 | - $image = $item->getLogo($_REQUEST['type']); |
|
| 51 | - $response['type'] = 'success'; |
|
| 52 | - $response['url'] = $image->getUrl(); |
|
| 53 | - $response['path'] = $image->getPath(); |
|
| 50 | + $image = $item->getLogo($_REQUEST[ 'type' ]); |
|
| 51 | + $response[ 'type' ] = 'success'; |
|
| 52 | + $response[ 'url' ] = $image->getUrl(); |
|
| 53 | + $response[ 'path' ] = $image->getPath(); |
|
| 54 | 54 | $this->setResponseValues($response); |
| 55 | 55 | } |
| 56 | 56 | } |
@@ -12,17 +12,17 @@ discard block |
||
| 12 | 12 | { |
| 13 | 13 | $item = $this->getModelFromRequest(); |
| 14 | 14 | |
| 15 | - $file = $item->uploadFile($_FILES['Filedata']); |
|
| 15 | + $file = $item->uploadFile($_FILES[ 'Filedata' ]); |
|
| 16 | 16 | |
| 17 | 17 | if ($file) { |
| 18 | - $response['type'] = 'success'; |
|
| 19 | - $response['url'] = $file->getURL(); |
|
| 20 | - $response['name'] = $file->getName(); |
|
| 21 | - $response['extension'] = $file->getExtension(); |
|
| 22 | - $response['size'] = $file->formatSize(); |
|
| 23 | - $response['time'] = date("d.m.Y H:i", $file->getTime()); |
|
| 18 | + $response[ 'type' ] = 'success'; |
|
| 19 | + $response[ 'url' ] = $file->getURL(); |
|
| 20 | + $response[ 'name' ] = $file->getName(); |
|
| 21 | + $response[ 'extension' ] = $file->getExtension(); |
|
| 22 | + $response[ 'size' ] = $file->formatSize(); |
|
| 23 | + $response[ 'time' ] = date("d.m.Y H:i", $file->getTime()); |
|
| 24 | 24 | } else { |
| 25 | - $response['type'] = 'error'; |
|
| 25 | + $response[ 'type' ] = 'error'; |
|
| 26 | 26 | } |
| 27 | 27 | $this->setResponseValues($response); |
| 28 | 28 | } |
@@ -38,7 +38,7 @@ discard block |
||
| 38 | 38 | $item = $this->getModelFromRequest(); |
| 39 | 39 | |
| 40 | 40 | if ($item->removeFile($_POST)) { |
| 41 | - $response['type'] = 'success'; |
|
| 41 | + $response[ 'type' ] = 'success'; |
|
| 42 | 42 | } |
| 43 | 43 | $this->setResponseValues($response); |
| 44 | 44 | } |
@@ -113,7 +113,7 @@ discard block |
||
| 113 | 113 | return false; |
| 114 | 114 | } |
| 115 | 115 | |
| 116 | - switch (@$_POST['action']) { |
|
| 116 | + switch (@$_POST[ 'action' ]) { |
|
| 117 | 117 | case 'upload': |
| 118 | 118 | $this->upload(); |
| 119 | 119 | break; |
@@ -127,7 +127,7 @@ discard block |
||
| 127 | 127 | break; |
| 128 | 128 | } |
| 129 | 129 | |
| 130 | - switch (@$_GET['action']) { |
|
| 130 | + switch (@$_GET[ 'action' ]) { |
|
| 131 | 131 | case 'preview': |
| 132 | 132 | $this->preview(); |
| 133 | 133 | break; |
@@ -145,11 +145,11 @@ discard block |
||
| 145 | 145 | */ |
| 146 | 146 | protected function load() |
| 147 | 147 | { |
| 148 | - if (!isset($this->options['load'])) { |
|
| 148 | + if (!isset($this->options[ 'load' ])) { |
|
| 149 | 149 | return; |
| 150 | 150 | } |
| 151 | 151 | |
| 152 | - $files = call_user_func($this->options['load'], $this); |
|
| 152 | + $files = call_user_func($this->options[ 'load' ], $this); |
|
| 153 | 153 | |
| 154 | 154 | if (!$files) { |
| 155 | 155 | return; |
@@ -176,13 +176,13 @@ discard block |
||
| 176 | 176 | |
| 177 | 177 | list($image->width, $image->height) = @getimagesize($image->path); |
| 178 | 178 | |
| 179 | - foreach ($this->options['versions'] as $version => $options) { |
|
| 179 | + foreach ($this->options[ 'versions' ] as $version => $options) { |
|
| 180 | 180 | $filename = $this->getVersionFilename($image->name, $version); |
| 181 | 181 | $filepath = $this->getUploadPath($filename, $version); |
| 182 | 182 | |
| 183 | 183 | list($width, $height) = @getimagesize($filepath); |
| 184 | 184 | |
| 185 | - $image->versions[$version] = array( |
|
| 185 | + $image->versions[ $version ] = array( |
|
| 186 | 186 | 'url' => $this->getUploadUrl($filename, $version), |
| 187 | 187 | 'width' => $width, |
| 188 | 188 | 'height' => $height, |
@@ -194,7 +194,7 @@ discard block |
||
| 194 | 194 | if (isset($single)) { |
| 195 | 195 | $images = $image; |
| 196 | 196 | } else { |
| 197 | - $images[] = $image; |
|
| 197 | + $images[ ] = $image; |
|
| 198 | 198 | } |
| 199 | 199 | } |
| 200 | 200 | |
@@ -208,9 +208,9 @@ discard block |
||
| 208 | 208 | */ |
| 209 | 209 | protected function preview() |
| 210 | 210 | { |
| 211 | - $filename = basename(@$_GET['file']); |
|
| 212 | - $width = @$_GET['width']; |
|
| 213 | - $rotate = @$_GET['rotate']; |
|
| 211 | + $filename = basename(@$_GET[ 'file' ]); |
|
| 212 | + $width = @$_GET[ 'width' ]; |
|
| 213 | + $rotate = @$_GET[ 'rotate' ]; |
|
| 214 | 214 | |
| 215 | 215 | $filepath = $this->getUploadPath($filename); |
| 216 | 216 | $filetype = $this->getFileExtension($filename); |
@@ -249,15 +249,15 @@ discard block |
||
| 249 | 249 | */ |
| 250 | 250 | protected function delete() |
| 251 | 251 | { |
| 252 | - if (!isset($this->options['delete'])) { |
|
| 252 | + if (!isset($this->options[ 'delete' ])) { |
|
| 253 | 253 | return; |
| 254 | 254 | } |
| 255 | 255 | |
| 256 | - $filename = basename(@$_POST['file']); |
|
| 256 | + $filename = basename(@$_POST[ 'file' ]); |
|
| 257 | 257 | $filepath = $this->getUploadPath($filename); |
| 258 | 258 | |
| 259 | - if (file_exists($filepath) && call_user_func($this->options['delete'], $filename, $this)) { |
|
| 260 | - foreach ($this->options['versions'] as $version => $options) { |
|
| 259 | + if (file_exists($filepath) && call_user_func($this->options[ 'delete' ], $filename, $this)) { |
|
| 260 | + foreach ($this->options[ 'versions' ] as $version => $options) { |
|
| 261 | 261 | $name = $this->getVersionFilename($filename, $version); |
| 262 | 262 | $path = $this->getUploadPath($name, $version); |
| 263 | 263 | } |
@@ -272,13 +272,13 @@ discard block |
||
| 272 | 272 | */ |
| 273 | 273 | protected function upload() |
| 274 | 274 | { |
| 275 | - $upload = isset($_FILES['file']) ? $_FILES['file'] : null; |
|
| 275 | + $upload = isset($_FILES[ 'file' ]) ? $_FILES[ 'file' ] : null; |
|
| 276 | 276 | |
| 277 | 277 | $file = $this->handleFileUpload( |
| 278 | - @$upload['tmp_name'], |
|
| 279 | - @$upload['name'] == 'blob' ? $this->getRandFilename() . '.jpg' : @$upload['name'], |
|
| 280 | - @$upload['size'], |
|
| 281 | - @$upload['error'] |
|
| 278 | + @$upload[ 'tmp_name' ], |
|
| 279 | + @$upload[ 'name' ] == 'blob' ? $this->getRandFilename() . '.jpg' : @$upload[ 'name' ], |
|
| 280 | + @$upload[ 'size' ], |
|
| 281 | + @$upload[ 'error' ] |
|
| 282 | 282 | ); |
| 283 | 283 | |
| 284 | 284 | $this->generateResponse($file); |
@@ -309,12 +309,12 @@ discard block |
||
| 309 | 309 | |
| 310 | 310 | $upload_dir = $this->getUploadPath(); |
| 311 | 311 | if (!is_dir($upload_dir)) { |
| 312 | - mkdir($upload_dir, $this->options['mkdir_mode'], true); |
|
| 312 | + mkdir($upload_dir, $this->options[ 'mkdir_mode' ], true); |
|
| 313 | 313 | } |
| 314 | 314 | |
| 315 | 315 | //Upload start callback |
| 316 | - if (isset($this->options['upload_start'])) { |
|
| 317 | - call_user_func($this->options['upload_start'], $image, $this); |
|
| 316 | + if (isset($this->options[ 'upload_start' ])) { |
|
| 317 | + call_user_func($this->options[ 'upload_start' ], $image, $this); |
|
| 318 | 318 | } |
| 319 | 319 | |
| 320 | 320 | $image->path = $this->getUploadPath($image->name); |
@@ -327,7 +327,7 @@ discard block |
||
| 327 | 327 | } |
| 328 | 328 | |
| 329 | 329 | // Orient the image |
| 330 | - if (!empty($this->options['auto_orient'])) { |
|
| 330 | + if (!empty($this->options[ 'auto_orient' ])) { |
|
| 331 | 331 | $this->orientImage($image->path); |
| 332 | 332 | } |
| 333 | 333 | |
@@ -335,8 +335,8 @@ discard block |
||
| 335 | 335 | $image->versions = $this->generateVersions($image, true); |
| 336 | 336 | |
| 337 | 337 | // Upload complete callback |
| 338 | - if (isset($this->options['upload_complete'])) { |
|
| 339 | - call_user_func($this->options['upload_complete'], $image, $this); |
|
| 338 | + if (isset($this->options[ 'upload_complete' ])) { |
|
| 339 | + call_user_func($this->options[ 'upload_complete' ], $image, $this); |
|
| 340 | 340 | } |
| 341 | 341 | |
| 342 | 342 | unset($image->path); |
@@ -351,8 +351,8 @@ discard block |
||
| 351 | 351 | */ |
| 352 | 352 | protected function crop() |
| 353 | 353 | { |
| 354 | - $filename = basename(@$_POST['image']); |
|
| 355 | - $rotate = @$_POST['rotate']; |
|
| 354 | + $filename = basename(@$_POST[ 'image' ]); |
|
| 355 | + $rotate = @$_POST[ 'rotate' ]; |
|
| 356 | 356 | |
| 357 | 357 | $image = new stdClass(); |
| 358 | 358 | $image->name = $filename; |
@@ -364,16 +364,16 @@ discard block |
||
| 364 | 364 | return $this->generateResponse(array('error' => $this->getErrorMessage('not_exists'))); |
| 365 | 365 | } |
| 366 | 366 | |
| 367 | - if (!preg_match('/.(' . $this->options['accept_file_types'] . ')+$/i', $image->name)) { |
|
| 367 | + if (!preg_match('/.(' . $this->options[ 'accept_file_types' ] . ')+$/i', $image->name)) { |
|
| 368 | 368 | return; |
| 369 | 369 | } |
| 370 | 370 | |
| 371 | 371 | list($image->width, $image->height) = @getimagesize($image->path); |
| 372 | 372 | |
| 373 | - @list($src_x, $src_y, $x2, $y2, $src_w, $src_h) = @array_values(@$_POST['coords']); |
|
| 373 | + @list($src_x, $src_y, $x2, $y2, $src_w, $src_h) = @array_values(@$_POST[ 'coords' ]); |
|
| 374 | 374 | |
| 375 | - if (isset($this->options['crop_start'])) { |
|
| 376 | - call_user_func($this->options['crop_start'], $image, $this); |
|
| 375 | + if (isset($this->options[ 'crop_start' ])) { |
|
| 376 | + call_user_func($this->options[ 'crop_start' ], $image, $this); |
|
| 377 | 377 | } |
| 378 | 378 | |
| 379 | 379 | $image->url = $this->getUploadUrl($image->name); |
@@ -408,22 +408,22 @@ discard block |
||
| 408 | 408 | |
| 409 | 409 | @unlink($tmp->path); |
| 410 | 410 | |
| 411 | - if (!isset($this->options['versions'][''])) { |
|
| 411 | + if (!isset($this->options[ 'versions' ][ '' ])) { |
|
| 412 | 412 | @rename($image->path, $this->getUploadPath($image->name)); |
| 413 | 413 | } |
| 414 | 414 | |
| 415 | 415 | list($image->width, $image->height) = @getimagesize($this->getUploadPath($image->name)); |
| 416 | 416 | |
| 417 | 417 | if ($image->path != $this->getUploadPath($image->name)) { |
| 418 | - foreach ($this->options['versions'] as $version => $options) { |
|
| 418 | + foreach ($this->options[ 'versions' ] as $version => $options) { |
|
| 419 | 419 | $filename = $this->getVersionFilename(basename($image->path), $version); |
| 420 | 420 | @unlink($this->getUploadPath($filename, $version)); |
| 421 | 421 | } |
| 422 | 422 | } |
| 423 | 423 | |
| 424 | 424 | // Crop complete callback |
| 425 | - if (isset($this->options['crop_complete'])) { |
|
| 426 | - call_user_func($this->options['crop_complete'], $image, $this); |
|
| 425 | + if (isset($this->options[ 'crop_complete' ])) { |
|
| 426 | + call_user_func($this->options[ 'crop_complete' ], $image, $this); |
|
| 427 | 427 | } |
| 428 | 428 | |
| 429 | 429 | unset($image->path); |
@@ -442,14 +442,14 @@ discard block |
||
| 442 | 442 | protected function generateVersions($image, $is_upload = false) |
| 443 | 443 | { |
| 444 | 444 | $versions = array(); |
| 445 | - foreach ($this->options['versions'] as $version => $options) { |
|
| 445 | + foreach ($this->options[ 'versions' ] as $version => $options) { |
|
| 446 | 446 | $dst_w = $src_w = $image->width; |
| 447 | 447 | $dst_h = $src_h = $image->height; |
| 448 | 448 | $src_x = $src_y = 0; |
| 449 | 449 | |
| 450 | - $max_width = @$options['max_width']; |
|
| 451 | - $max_height = @$options['max_height']; |
|
| 452 | - $crop = isset($options['crop']) && $options['crop'] === true; |
|
| 450 | + $max_width = @$options[ 'max_width' ]; |
|
| 451 | + $max_height = @$options[ 'max_height' ]; |
|
| 452 | + $crop = isset($options[ 'crop' ]) && $options[ 'crop' ] === true; |
|
| 453 | 453 | |
| 454 | 454 | if ($crop) { |
| 455 | 455 | $min = min($src_w, $src_h); |
@@ -473,7 +473,7 @@ discard block |
||
| 473 | 473 | $upload_dir = $this->getUploadPath('', $version); |
| 474 | 474 | |
| 475 | 475 | if (!is_dir($upload_dir)) { |
| 476 | - mkdir($upload_dir, $this->options['mkdir_mode'], true); |
|
| 476 | + mkdir($upload_dir, $this->options[ 'mkdir_mode' ], true); |
|
| 477 | 477 | } |
| 478 | 478 | |
| 479 | 479 | if (!$is_upload || ($is_upload && $version != '')) { |
@@ -482,7 +482,7 @@ discard block |
||
| 482 | 482 | } |
| 483 | 483 | |
| 484 | 484 | if (!empty($success)) { |
| 485 | - $versions[$version] = array( |
|
| 485 | + $versions[ $version ] = array( |
|
| 486 | 486 | 'url' => $this->getUploadUrl($filename, $version), |
| 487 | 487 | 'width' => $dst_w, |
| 488 | 488 | 'height' => $dst_h, |
@@ -515,7 +515,7 @@ discard block |
||
| 515 | 515 | return false; |
| 516 | 516 | } |
| 517 | 517 | |
| 518 | - $content_length = $this->fixIntOverflow(intval($_SERVER['CONTENT_LENGTH'])); |
|
| 518 | + $content_length = $this->fixIntOverflow(intval($_SERVER[ 'CONTENT_LENGTH' ])); |
|
| 519 | 519 | $post_max_size = $this->getConfigBytes(ini_get('post_max_size')); |
| 520 | 520 | |
| 521 | 521 | if ($post_max_size && $content_length > $post_max_size) { |
@@ -524,19 +524,19 @@ discard block |
||
| 524 | 524 | return false; |
| 525 | 525 | } |
| 526 | 526 | |
| 527 | - if ($this->options['max_file_size'] && $file->size > $this->options['max_file_size']) { |
|
| 527 | + if ($this->options[ 'max_file_size' ] && $file->size > $this->options[ 'max_file_size' ]) { |
|
| 528 | 528 | $file->error = $this->getErrorMessage('max_file_size'); |
| 529 | 529 | |
| 530 | 530 | return false; |
| 531 | 531 | } |
| 532 | 532 | |
| 533 | - if ($this->options['min_file_size'] && $file->size < $this->options['min_file_size']) { |
|
| 533 | + if ($this->options[ 'min_file_size' ] && $file->size < $this->options[ 'min_file_size' ]) { |
|
| 534 | 534 | $file->error = $this->getErrorMessage('min_file_size'); |
| 535 | 535 | |
| 536 | 536 | return false; |
| 537 | 537 | } |
| 538 | 538 | |
| 539 | - if (!preg_match('/.(' . $this->options['accept_file_types'] . ')+$/i', $file->name)) { |
|
| 539 | + if (!preg_match('/.(' . $this->options[ 'accept_file_types' ] . ')+$/i', $file->name)) { |
|
| 540 | 540 | $file->error = $this->getErrorMessage('accept_file_types'); |
| 541 | 541 | |
| 542 | 542 | return false; |
@@ -548,10 +548,10 @@ discard block |
||
| 548 | 548 | return false; |
| 549 | 549 | } |
| 550 | 550 | |
| 551 | - $max_width = @$this->options['max_width']; |
|
| 552 | - $max_height = @$this->options['max_height']; |
|
| 553 | - $min_width = @$this->options['min_width']; |
|
| 554 | - $min_height = @$this->options['min_height']; |
|
| 551 | + $max_width = @$this->options[ 'max_width' ]; |
|
| 552 | + $max_height = @$this->options[ 'max_height' ]; |
|
| 553 | + $min_width = @$this->options[ 'min_width' ]; |
|
| 554 | + $min_height = @$this->options[ 'min_height' ]; |
|
| 555 | 555 | |
| 556 | 556 | if ($max_width || $max_height || $min_width || $min_height) { |
| 557 | 557 | if ($max_width && $file->width > $max_width) { |
@@ -588,10 +588,10 @@ discard block |
||
| 588 | 588 | */ |
| 589 | 589 | public function getUploadPath($filename = '', $version = '') |
| 590 | 590 | { |
| 591 | - $upload_dir = $this->options['upload_dir']; |
|
| 591 | + $upload_dir = $this->options[ 'upload_dir' ]; |
|
| 592 | 592 | |
| 593 | 593 | if ($version != '') { |
| 594 | - $dir = @$this->options['versions'][$version]['upload_dir']; |
|
| 594 | + $dir = @$this->options[ 'versions' ][ $version ][ 'upload_dir' ]; |
|
| 595 | 595 | if (!empty($dir)) { |
| 596 | 596 | $upload_dir = $dir; |
| 597 | 597 | } |
@@ -609,10 +609,10 @@ discard block |
||
| 609 | 609 | */ |
| 610 | 610 | public function getUploadUrl($filename = '', $version = '') |
| 611 | 611 | { |
| 612 | - $upload_url = $this->options['upload_url']; |
|
| 612 | + $upload_url = $this->options[ 'upload_url' ]; |
|
| 613 | 613 | |
| 614 | 614 | if ($version != '') { |
| 615 | - $url = @$this->options['versions'][$version]['upload_url']; |
|
| 615 | + $url = @$this->options[ 'versions' ][ $version ][ 'upload_url' ]; |
|
| 616 | 616 | if (!empty($url)) { |
| 617 | 617 | $upload_url = $url; |
| 618 | 618 | } |
@@ -628,15 +628,15 @@ discard block |
||
| 628 | 628 | */ |
| 629 | 629 | protected function getFullUrl() |
| 630 | 630 | { |
| 631 | - $https = !empty($_SERVER['HTTPS']) && strcasecmp($_SERVER['HTTPS'], 'on') === 0; |
|
| 631 | + $https = !empty($_SERVER[ 'HTTPS' ]) && strcasecmp($_SERVER[ 'HTTPS' ], 'on') === 0; |
|
| 632 | 632 | |
| 633 | 633 | return |
| 634 | 634 | ($https ? 'https://' : 'http://') . |
| 635 | - (!empty($_SERVER['REMOTE_USER']) ? $_SERVER['REMOTE_USER'] . '@' : '') . |
|
| 636 | - (isset($_SERVER['HTTP_HOST']) ? $_SERVER['HTTP_HOST'] : ($_SERVER['SERVER_NAME'] . |
|
| 637 | - ($https && $_SERVER['SERVER_PORT'] === 443 || |
|
| 638 | - $_SERVER['SERVER_PORT'] === 80 ? '' : ':' . $_SERVER['SERVER_PORT']))) . |
|
| 639 | - substr($_SERVER['SCRIPT_NAME'], 0, strrpos($_SERVER['SCRIPT_NAME'], '/')); |
|
| 635 | + (!empty($_SERVER[ 'REMOTE_USER' ]) ? $_SERVER[ 'REMOTE_USER' ] . '@' : '') . |
|
| 636 | + (isset($_SERVER[ 'HTTP_HOST' ]) ? $_SERVER[ 'HTTP_HOST' ] : ($_SERVER[ 'SERVER_NAME' ] . |
|
| 637 | + ($https && $_SERVER[ 'SERVER_PORT' ] === 443 || |
|
| 638 | + $_SERVER[ 'SERVER_PORT' ] === 80 ? '' : ':' . $_SERVER[ 'SERVER_PORT' ]))) . |
|
| 639 | + substr($_SERVER[ 'SCRIPT_NAME' ], 0, strrpos($_SERVER[ 'SCRIPT_NAME' ], '/')); |
|
| 640 | 640 | } |
| 641 | 641 | |
| 642 | 642 | /** |
@@ -725,7 +725,7 @@ discard block |
||
| 725 | 725 | public function getErrorMessage($error) |
| 726 | 726 | { |
| 727 | 727 | return array_key_exists($error, $this->error_messages) ? |
| 728 | - $this->error_messages[$error] : $error; |
|
| 728 | + $this->error_messages[ $error ] : $error; |
|
| 729 | 729 | } |
| 730 | 730 | |
| 731 | 731 | /** |
@@ -852,8 +852,8 @@ discard block |
||
| 852 | 852 | } |
| 853 | 853 | |
| 854 | 854 | $exif = @exif_read_data($filepath); |
| 855 | - if (!empty($exif['Orientation'])) { |
|
| 856 | - switch ($exif['Orientation']) { |
|
| 855 | + if (!empty($exif[ 'Orientation' ])) { |
|
| 856 | + switch ($exif[ 'Orientation' ]) { |
|
| 857 | 857 | case 3: |
| 858 | 858 | $angle = 180; |
| 859 | 859 | break; |
@@ -883,8 +883,8 @@ discard block |
||
| 883 | 883 | |
| 884 | 884 | protected function upcountNameCallback($matches) |
| 885 | 885 | { |
| 886 | - $index = isset($matches[1]) ? intval($matches[1]) + 1 : 1; |
|
| 887 | - $ext = isset($matches[2]) ? $matches[2] : ''; |
|
| 886 | + $index = isset($matches[ 1 ]) ? intval($matches[ 1 ]) + 1 : 1; |
|
| 887 | + $ext = isset($matches[ 2 ]) ? $matches[ 2 ] : ''; |
|
| 888 | 888 | |
| 889 | 889 | return ' (' . $index . ')' . $ext; |
| 890 | 890 | } |
@@ -892,7 +892,7 @@ discard block |
||
| 892 | 892 | protected function getConfigBytes($val) |
| 893 | 893 | { |
| 894 | 894 | $val = trim($val); |
| 895 | - $last = strtolower($val[strlen($val) - 1]); |
|
| 895 | + $last = strtolower($val[ strlen($val) - 1 ]); |
|
| 896 | 896 | switch ($last) { |
| 897 | 897 | case 'g': |
| 898 | 898 | $val *= 1024; |
@@ -59,7 +59,7 @@ discard block |
||
| 59 | 59 | * @param ImgPicker $instance |
| 60 | 60 | * @return string|array |
| 61 | 61 | */ |
| 62 | - 'load' => function ($instance) { |
|
| 62 | + 'load' => function($instance) { |
|
| 63 | 63 | //return 'avatar.jpg'; |
| 64 | 64 | }, |
| 65 | 65 | |
@@ -70,7 +70,7 @@ discard block |
||
| 70 | 70 | * @param ImgPicker $instance |
| 71 | 71 | * @return boolean |
| 72 | 72 | */ |
| 73 | - 'delete' => function ($filename, $instance) { |
|
| 73 | + 'delete' => function($filename, $instance) { |
|
| 74 | 74 | return true; |
| 75 | 75 | }, |
| 76 | 76 | |
@@ -81,7 +81,7 @@ discard block |
||
| 81 | 81 | * @param ImgPicker $instance |
| 82 | 82 | * @return void |
| 83 | 83 | */ |
| 84 | - 'upload_start' => function ($image, $instance) { |
|
| 84 | + 'upload_start' => function($image, $instance) { |
|
| 85 | 85 | $image->name = '~toCropFP' . $item->ID . '-' . rand(1000, 4000) . '.' . $image->type; |
| 86 | 86 | }, |
| 87 | 87 | |
@@ -92,7 +92,7 @@ discard block |
||
| 92 | 92 | * @param ImgPicker $instance |
| 93 | 93 | * @return void |
| 94 | 94 | */ |
| 95 | - 'upload_complete' => function ($image, $instance) { |
|
| 95 | + 'upload_complete' => function($image, $instance) { |
|
| 96 | 96 | }, |
| 97 | 97 | |
| 98 | 98 | /** |
@@ -102,7 +102,7 @@ discard block |
||
| 102 | 102 | * @param ImgPicker $instance |
| 103 | 103 | * @return void |
| 104 | 104 | */ |
| 105 | - 'crop_start' => function ($image, $instance) { |
|
| 105 | + 'crop_start' => function($image, $instance) { |
|
| 106 | 106 | $image->name = sha1(microtime()) . '.' . $image->type; |
| 107 | 107 | }, |
| 108 | 108 | |
@@ -113,19 +113,19 @@ discard block |
||
| 113 | 113 | * @param ImgPicker $instance |
| 114 | 114 | * @return void |
| 115 | 115 | */ |
| 116 | - 'crop_complete' => function ($image, $instance) { |
|
| 117 | - foreach (['full', 'default'] as $version) { |
|
| 116 | + 'crop_complete' => function($image, $instance) { |
|
| 117 | + foreach ([ 'full', 'default' ] as $version) { |
|
| 118 | 118 | $filename = $instance->getVersionFilename($image->name, $version); |
| 119 | 119 | $filepath = $instance->getUploadPath($filename, $version); |
| 120 | 120 | rename($filepath, str_replace('-' . $version . '.', '.', $filepath)); |
| 121 | 121 | } |
| 122 | 122 | }, |
| 123 | 123 | ]; |
| 124 | - if (@$_POST['action'] == 'crop') { |
|
| 124 | + if (@$_POST[ 'action' ] == 'crop') { |
|
| 125 | 125 | $filesystem = $item->getMedia('images')->getFilesystem(); |
| 126 | 126 | $rootPath = $filesystem->getAdapter()->getPathPrefix(); |
| 127 | 127 | // Image versions: |
| 128 | - $options['versions'] = [ |
|
| 128 | + $options[ 'versions' ] = [ |
|
| 129 | 129 | 'full' => [ |
| 130 | 130 | 'upload_dir' => $rootPath . $newMedia->getBasePath('full') . DIRECTORY_SEPARATOR, |
| 131 | 131 | 'upload_url' => $filesystem->getUrl($newMedia->getBasePath('full')), |
@@ -141,9 +141,9 @@ discard block |
||
| 141 | 141 | ]; |
| 142 | 142 | } |
| 143 | 143 | |
| 144 | - if (intval($_SERVER['CONTENT_LENGTH']) > 0 && count($_POST) === 0) { |
|
| 144 | + if (intval($_SERVER[ 'CONTENT_LENGTH' ]) > 0 && count($_POST) === 0) { |
|
| 145 | 145 | $maxSize = round(($this->getRequest()->server->getMaxFileSize() / 1048576), 2) . 'MB'; |
| 146 | - $this->response['error'] = 'File to big. Max size [' . $maxSize . ']'; |
|
| 146 | + $this->response[ 'error' ] = 'File to big. Max size [' . $maxSize . ']'; |
|
| 147 | 147 | |
| 148 | 148 | return $this->_output(); |
| 149 | 149 | } |
@@ -69,7 +69,7 @@ discard block |
||
| 69 | 69 | |
| 70 | 70 | return self::loadView( |
| 71 | 71 | '/admin/gallery/' . $type . '-grid', |
| 72 | - ['item' => $item, 'images' => $images] |
|
| 72 | + [ 'item' => $item, 'images' => $images ] |
|
| 73 | 73 | ); |
| 74 | 74 | } |
| 75 | 75 | |
@@ -98,7 +98,7 @@ discard block |
||
| 98 | 98 | * |
| 99 | 99 | * @return null|string |
| 100 | 100 | */ |
| 101 | - public static function loadView($path, $variables = []) |
|
| 101 | + public static function loadView($path, $variables = [ ]) |
|
| 102 | 102 | { |
| 103 | 103 | return View::instance()->load($path, $variables, true); |
| 104 | 104 | } |
@@ -54,9 +54,9 @@ |
||
| 54 | 54 | } catch (FileCannotBeAdded $exception) { |
| 55 | 55 | http_response_code(415); |
| 56 | 56 | header('Content-Type: application/json; charset=utf-8'); |
| 57 | - $output = ['error' => $exception->getMessage()]; |
|
| 57 | + $output = [ 'error' => $exception->getMessage() ]; |
|
| 58 | 58 | if ($exception instanceof FileUnacceptableForCollection) { |
| 59 | - $output['error'] .= ': ' . $exception->violations->getMessageString(); |
|
| 59 | + $output[ 'error' ] .= ': ' . $exception->violations->getMessageString(); |
|
| 60 | 60 | } |
| 61 | 61 | echo json_encode($output); |
| 62 | 62 | } |
@@ -15,7 +15,7 @@ |
||
| 15 | 15 | */ |
| 16 | 16 | public function provides() |
| 17 | 17 | { |
| 18 | - return []; |
|
| 18 | + return [ ]; |
|
| 19 | 19 | } |
| 20 | 20 | |
| 21 | 21 | /** |