@@ -121,8 +121,7 @@ discard block |
||
| 121 | 121 | { |
| 122 | 122 | if ($attachment = $this->getAttachment($key)) { |
| 123 | 123 | $attachment->attach($value); |
| 124 | - } |
|
| 125 | - else { |
|
| 124 | + } else { |
|
| 126 | 125 | parent::setAttribute($key, $value); |
| 127 | 126 | } |
| 128 | 127 | } |
@@ -156,8 +155,7 @@ discard block |
||
| 156 | 155 | } |
| 157 | 156 | |
| 158 | 157 | return null; |
| 159 | - } |
|
| 160 | - else { |
|
| 158 | + } else { |
|
| 161 | 159 | $attachments = new stdClass(); |
| 162 | 160 | foreach ($this->attachments as $attachment) { |
| 163 | 161 | $attachments->{$attachment->getName()} = $attachment->urls(); |
@@ -208,8 +206,7 @@ discard block |
||
| 208 | 206 | unset($array["{$name}_file_dominant_color"]); |
| 209 | 207 | unset($array["{$name}_file_format"]); |
| 210 | 208 | unset($array["{$name}_file_cover"]); |
| 211 | - } |
|
| 212 | - else { |
|
| 209 | + } else { |
|
| 213 | 210 | unset($array["{$name}_file_meta"]); |
| 214 | 211 | } |
| 215 | 212 | } |
@@ -65,8 +65,7 @@ |
||
| 65 | 65 | { |
| 66 | 66 | if ($this->internalFunctionIsCallable) { |
| 67 | 67 | parent::handleFFMpegQueue($isLastOne); |
| 68 | - } |
|
| 69 | - else { |
|
| 68 | + } else { |
|
| 70 | 69 | self::internalException(); |
| 71 | 70 | } |
| 72 | 71 | } |
@@ -361,8 +361,7 @@ |
||
| 361 | 361 | foreach ($this->output as $key => $value) { |
| 362 | 362 | $this->output[$key] = $model->{"{$this->name}_file_$key"}; |
| 363 | 363 | } |
| 364 | - } |
|
| 365 | - else { |
|
| 364 | + } else { |
|
| 366 | 365 | $meta = json_decode($model->{"{$this->name}_file_meta"}, true); |
| 367 | 366 | |
| 368 | 367 | if (is_array($meta)) { |
@@ -50,8 +50,7 @@ discard block |
||
| 50 | 50 | try { |
| 51 | 51 | if ($this->standalone) { |
| 52 | 52 | $this->standalone->handleFFMpegQueue(); |
| 53 | - } |
|
| 54 | - else { |
|
| 53 | + } else { |
|
| 55 | 54 | /** @var \Illuminate\Database\Eloquent\Model $class */ |
| 56 | 55 | $class = $this->model; |
| 57 | 56 | $modelNotSaved = true; |
@@ -76,8 +75,7 @@ discard block |
||
| 76 | 75 | } |
| 77 | 76 | |
| 78 | 77 | $this->updateStatus(true, false); |
| 79 | - } |
|
| 80 | - catch (FileNotFoundException | Exception $e) { |
|
| 78 | + } catch (FileNotFoundException | Exception $e) { |
|
| 81 | 79 | $this->updateStatus(false, false, $e->getMessage()); |
| 82 | 80 | |
| 83 | 81 | throw new Exception($e->getMessage()); |
@@ -66,8 +66,7 @@ discard block |
||
| 66 | 66 | $this->type = $this->output['type']; |
| 67 | 67 | |
| 68 | 68 | return true; |
| 69 | - } |
|
| 70 | - else { |
|
| 69 | + } else { |
|
| 71 | 70 | return false; |
| 72 | 71 | } |
| 73 | 72 | } |
@@ -85,8 +84,7 @@ discard block |
||
| 85 | 84 | $this->type = $this->output['type']; |
| 86 | 85 | |
| 87 | 86 | return true; |
| 88 | - } |
|
| 89 | - else { |
|
| 87 | + } else { |
|
| 90 | 88 | return false; |
| 91 | 89 | } |
| 92 | 90 | } |
@@ -106,8 +104,7 @@ discard block |
||
| 106 | 104 | if (isset($this->file)) { |
| 107 | 105 | if ($this->file == LARUPLOAD_NULL) { |
| 108 | 106 | $this->clean($model->id); |
| 109 | - } |
|
| 110 | - else { |
|
| 107 | + } else { |
|
| 111 | 108 | if (!$this->keepOldFiles) { |
| 112 | 109 | $this->clean($model->id); |
| 113 | 110 | } |
@@ -120,8 +117,7 @@ discard block |
||
| 120 | 117 | } |
| 121 | 118 | |
| 122 | 119 | $model = $this->setAttributes($model); |
| 123 | - } |
|
| 124 | - else if (isset($this->cover)) { |
|
| 120 | + } else if (isset($this->cover)) { |
|
| 125 | 121 | $this->setCover($model->id); |
| 126 | 122 | |
| 127 | 123 | $model = $this->setAttributes($model); |
@@ -213,8 +209,7 @@ discard block |
||
| 213 | 209 | if ($style == LaruploadEnum::COVER_FOLDER and !$this->generateCover) { |
| 214 | 210 | $styles->{$style} = null; |
| 215 | 211 | continue; |
| 216 | - } |
|
| 217 | - else if ($style == LaruploadEnum::STREAM_FOLDER and empty($this->streams)) { |
|
| 212 | + } else if ($style == LaruploadEnum::STREAM_FOLDER and empty($this->streams)) { |
|
| 218 | 213 | unset($styles->{$style}); |
| 219 | 214 | continue; |
| 220 | 215 | } |
@@ -408,8 +403,7 @@ discard block |
||
| 408 | 403 | case LaruploadEnum::VIDEO: |
| 409 | 404 | if ($this->ffmpegQueue) { |
| 410 | 405 | $this->initializeFFMpegQueue($id, $class, $standalone); |
| 411 | - } |
|
| 412 | - else { |
|
| 406 | + } else { |
|
| 413 | 407 | $this->handleVideoStyles($id); |
| 414 | 408 | } |
| 415 | 409 | |
@@ -461,8 +455,7 @@ discard block |
||
| 461 | 455 | |
| 462 | 456 | if ($maxQueueNum == 0) { |
| 463 | 457 | $flag = true; |
| 464 | - } |
|
| 465 | - else { |
|
| 458 | + } else { |
|
| 466 | 459 | $availableQueues = DB::table(LaruploadEnum::FFMPEG_QUEUE_TABLE)->where('status', 0)->count(); |
| 467 | 460 | |
| 468 | 461 | if ($availableQueues < $maxQueueNum) { |
@@ -496,8 +489,7 @@ discard block |
||
| 496 | 489 | |
| 497 | 490 | |
| 498 | 491 | ProcessFFMpeg::dispatch($queueId, $id, $this->name, $class, $serializedClass); |
| 499 | - } |
|
| 500 | - else { |
|
| 492 | + } else { |
|
| 501 | 493 | throw new HttpResponseException(redirect(URL::previous())->withErrors([ |
| 502 | 494 | 'ffmpeg_queue_max_num' => trans('larupload::messages.max-queue-num-exceeded') |
| 503 | 495 | ])); |
@@ -531,8 +523,7 @@ discard block |
||
| 531 | 523 | foreach ($this->output as $key => $value) { |
| 532 | 524 | $model->{"{$this->name}_file_$key"} = $value; |
| 533 | 525 | } |
| 534 | - } |
|
| 535 | - else { |
|
| 526 | + } else { |
|
| 536 | 527 | $model->{"{$this->name}_file_name"} = $this->output['name'] ?? null; |
| 537 | 528 | $model->{"{$this->name}_file_meta"} = json_encode($this->output); |
| 538 | 529 | } |
@@ -564,8 +555,7 @@ discard block |
||
| 564 | 555 | } |
| 565 | 556 | |
| 566 | 557 | return null; |
| 567 | - } |
|
| 568 | - else if ($name and $this->styleHasFile($style)) { |
|
| 558 | + } else if ($name and $this->styleHasFile($style)) { |
|
| 569 | 559 | $name = $this->fixExceptionNames($name, $style); |
| 570 | 560 | $path = $this->getBasePath($this->id, $style); |
| 571 | 561 | |
@@ -142,13 +142,11 @@ discard block |
||
| 142 | 142 | if ($rotate == 90 or $rotate == 270) { |
| 143 | 143 | list($meta['height'], $meta['width']) = array($meta['width'], $meta['height']); |
| 144 | 144 | } |
| 145 | - } |
|
| 146 | - else { |
|
| 145 | + } else { |
|
| 147 | 146 | $process->addErrorOutput('ffprobe output is null'); |
| 148 | 147 | throw new Exception($process->getErrorOutput()); |
| 149 | 148 | } |
| 150 | - } |
|
| 151 | - else { |
|
| 149 | + } else { |
|
| 152 | 150 | throw new Exception($process->getErrorOutput()); |
| 153 | 151 | } |
| 154 | 152 | |
@@ -187,12 +185,10 @@ discard block |
||
| 187 | 185 | if ($mode == LaruploadEnum::CROP_STYLE_MODE) { |
| 188 | 186 | if ($width and $height) { |
| 189 | 187 | $cmd = escapeshellcmd("$this->ffmpeg -ss $fromSecond -i $path -vframes 1 -filter scale=$scaleType,crop=$width:$height"); |
| 190 | - } |
|
| 191 | - else { |
|
| 188 | + } else { |
|
| 192 | 189 | $cmd = escapeshellcmd("$this->ffmpeg -ss $fromSecond -i $path -vframes 1 -filter scale=$scaleType,crop=$scale:$scale"); |
| 193 | 190 | } |
| 194 | - } |
|
| 195 | - else { |
|
| 191 | + } else { |
|
| 196 | 192 | $cmd = escapeshellcmd("$this->ffmpeg -ss $fromSecond -i $path -vframes 1 -filter scale=$scaleType"); |
| 197 | 193 | } |
| 198 | 194 | |
@@ -218,12 +214,10 @@ discard block |
||
| 218 | 214 | if ($mode == LaruploadEnum::CROP_STYLE_MODE) { |
| 219 | 215 | if ($scale) { |
| 220 | 216 | $cmd = escapeshellcmd("$this->ffmpeg -i $path -vf scale=$scale,crop=$width:$height,setsar=1"); |
| 221 | - } |
|
| 222 | - else { |
|
| 217 | + } else { |
|
| 223 | 218 | $cmd = escapeshellcmd("$this->ffmpeg -i $path -vf crop=$width:$height,setsar=1"); |
| 224 | 219 | } |
| 225 | - } |
|
| 226 | - else { |
|
| 220 | + } else { |
|
| 227 | 221 | $cmd = escapeshellcmd("$this->ffmpeg -i $path -vf scale=$scale,setsar=1"); |
| 228 | 222 | } |
| 229 | 223 | |
@@ -317,8 +311,7 @@ discard block |
||
| 317 | 311 | } |
| 318 | 312 | |
| 319 | 313 | $scale = "$scale:-2"; |
| 320 | - } |
|
| 321 | - else { |
|
| 314 | + } else { |
|
| 322 | 315 | $scale = ceil(($meta['height'] * $width) / $meta['width']); |
| 323 | 316 | |
| 324 | 317 | if ($scale < $height) { |
@@ -327,12 +320,10 @@ discard block |
||
| 327 | 320 | |
| 328 | 321 | $scale = "-2:$scale"; |
| 329 | 322 | } |
| 330 | - } |
|
| 331 | - else { |
|
| 323 | + } else { |
|
| 332 | 324 | $scale = ''; |
| 333 | 325 | } |
| 334 | - } |
|
| 335 | - else { |
|
| 326 | + } else { |
|
| 336 | 327 | $scale = $width ? "$width:-2" : ($height ? "-2:$height" : (self::DEFAULT_SCALE . ':-2')); |
| 337 | 328 | } |
| 338 | 329 | |
@@ -366,8 +357,7 @@ discard block |
||
| 366 | 357 | } |
| 367 | 358 | |
| 368 | 359 | throw new Exception($process->getErrorOutput()); |
| 369 | - } |
|
| 370 | - else { |
|
| 360 | + } else { |
|
| 371 | 361 | list($path, $name) = $this->splitPath($saveTo); |
| 372 | 362 | |
| 373 | 363 | $tempDir = $this->tempDir(); |
@@ -418,8 +408,7 @@ discard block |
||
| 418 | 408 | } |
| 419 | 409 | |
| 420 | 410 | throw new Exception($process->getErrorOutput()); |
| 421 | - } |
|
| 422 | - else { |
|
| 411 | + } else { |
|
| 423 | 412 | $name = basename($streamPath); |
| 424 | 413 | $temp = $name . '-' . time(); |
| 425 | 414 | |
@@ -117,8 +117,7 @@ discard block |
||
| 117 | 117 | |
| 118 | 118 | if ($this->driverIsLocal) { |
| 119 | 119 | $this->$method($image, $width, $height)->save($saveTo); |
| 120 | - } |
|
| 121 | - else { |
|
| 120 | + } else { |
|
| 122 | 121 | list($path, $name) = $this->splitPath($saveTo); |
| 123 | 122 | |
| 124 | 123 | $tempDir = $this->tempDir(); |
@@ -361,8 +360,7 @@ discard block |
||
| 361 | 360 | |
| 362 | 361 | if ($file instanceof UploadedFile) { |
| 363 | 362 | $path = $file->getRealPath(); |
| 364 | - } |
|
| 365 | - else if (file_exists($file)) { |
|
| 363 | + } else if (file_exists($file)) { |
|
| 366 | 364 | $path = $file; |
| 367 | 365 | } |
| 368 | 366 | |
@@ -372,8 +370,7 @@ discard block |
||
| 372 | 370 | return self::toHexString($color); |
| 373 | 371 | } |
| 374 | 372 | } |
| 375 | - } |
|
| 376 | - catch (Exception) { |
|
| 373 | + } catch (Exception) { |
|
| 377 | 374 | // do nothing |
| 378 | 375 | } |
| 379 | 376 | |
@@ -34,17 +34,13 @@ discard block |
||
| 34 | 34 | { |
| 35 | 35 | if (str_contains($mime, 'image/')) { |
| 36 | 36 | return LaruploadEnum::IMAGE; |
| 37 | - } |
|
| 38 | - else if (str_contains($mime, 'video/')) { |
|
| 37 | + } else if (str_contains($mime, 'video/')) { |
|
| 39 | 38 | return LaruploadEnum::VIDEO; |
| 40 | - } |
|
| 41 | - else if (str_contains($mime, 'audio/')) { |
|
| 39 | + } else if (str_contains($mime, 'audio/')) { |
|
| 42 | 40 | return LaruploadEnum::AUDIO; |
| 43 | - } |
|
| 44 | - else if ($mime == 'application/pdf') { |
|
| 41 | + } else if ($mime == 'application/pdf') { |
|
| 45 | 42 | return LaruploadEnum::PDF; |
| 46 | - } |
|
| 47 | - else if ($mime == 'application/zip' or $mime == 'application/x-rar-compressed') { |
|
| 43 | + } else if ($mime == 'application/zip' or $mime == 'application/x-rar-compressed') { |
|
| 48 | 44 | return LaruploadEnum::COMPRESSED; |
| 49 | 45 | } |
| 50 | 46 | |
@@ -92,11 +88,9 @@ discard block |
||
| 92 | 88 | { |
| 93 | 89 | if (ini_get('upload_tmp_dir')) { |
| 94 | 90 | $path = ini_get('upload_tmp_dir'); |
| 95 | - } |
|
| 96 | - else if (getenv('temp')) { |
|
| 91 | + } else if (getenv('temp')) { |
|
| 97 | 92 | $path = getenv('temp'); |
| 98 | - } |
|
| 99 | - else { |
|
| 93 | + } else { |
|
| 100 | 94 | $path = sys_get_temp_dir(); |
| 101 | 95 | } |
| 102 | 96 | |
@@ -30,8 +30,7 @@ |
||
| 30 | 30 | $table->string("{$name}_file_dominant_color", 7)->nullable(); |
| 31 | 31 | $table->string("{$name}_file_format", 85)->nullable(); |
| 32 | 32 | $table->string("{$name}_file_cover", 85)->nullable(); |
| 33 | - } |
|
| 34 | - else { |
|
| 33 | + } else { |
|
| 35 | 34 | $table->{self::jsonColumnType()}("{$name}_file_meta")->nullable(); |
| 36 | 35 | } |
| 37 | 36 | } |