@@ -122,15 +122,15 @@ |
||
122 | 122 | |
123 | 123 | foreach ($output->streams as $stream) { |
124 | 124 | if (isset($stream->width)) { |
125 | - $meta['width'] = (int)$stream->width; |
|
125 | + $meta['width'] = (int) $stream->width; |
|
126 | 126 | } |
127 | 127 | |
128 | 128 | if (isset($stream->height)) { |
129 | - $meta['height'] = (int)$stream->height; |
|
129 | + $meta['height'] = (int) $stream->height; |
|
130 | 130 | } |
131 | 131 | |
132 | 132 | if (isset($stream->duration)) { |
133 | - $meta['duration'] = (int)$stream->duration; |
|
133 | + $meta['duration'] = (int) $stream->duration; |
|
134 | 134 | } |
135 | 135 | |
136 | 136 | if (isset($stream->tags->rotate)) { |
@@ -141,13 +141,11 @@ discard block |
||
141 | 141 | if ($rotate == 90 or $rotate == 270) { |
142 | 142 | list($meta['height'], $meta['width']) = array($meta['width'], $meta['height']); |
143 | 143 | } |
144 | - } |
|
145 | - else { |
|
144 | + } else { |
|
146 | 145 | $process->addErrorOutput('ffprobe output is null'); |
147 | 146 | throw new Exception($process->getErrorOutput()); |
148 | 147 | } |
149 | - } |
|
150 | - else { |
|
148 | + } else { |
|
151 | 149 | throw new Exception($process->getErrorOutput()); |
152 | 150 | } |
153 | 151 | |
@@ -186,12 +184,10 @@ discard block |
||
186 | 184 | if ($mode == LaruploadEnum::CROP_STYLE_MODE) { |
187 | 185 | if ($width and $height) { |
188 | 186 | $cmd = escapeshellcmd("{$this->ffmpeg} -ss $fromSecond -i $path -vframes 1 -filter scale=$scaleType,crop=$width:$height"); |
189 | - } |
|
190 | - else { |
|
187 | + } else { |
|
191 | 188 | $cmd = escapeshellcmd("{$this->ffmpeg} -ss $fromSecond -i $path -vframes 1 -filter scale=$scaleType,crop=$scale:$scale"); |
192 | 189 | } |
193 | - } |
|
194 | - else { |
|
190 | + } else { |
|
195 | 191 | $cmd = escapeshellcmd("{$this->ffmpeg} -ss $fromSecond -i $path -vframes 1 -filter scale=$scaleType"); |
196 | 192 | } |
197 | 193 | |
@@ -217,12 +213,10 @@ discard block |
||
217 | 213 | if ($mode == LaruploadEnum::CROP_STYLE_MODE) { |
218 | 214 | if ($scale) { |
219 | 215 | $cmd = escapeshellcmd("{$this->ffmpeg} -i $path -vf scale=$scale,crop=$width:$height,setsar=1"); |
220 | - } |
|
221 | - else { |
|
216 | + } else { |
|
222 | 217 | $cmd = escapeshellcmd("{$this->ffmpeg} -i $path -vf crop=$width:$height,setsar=1"); |
223 | 218 | } |
224 | - } |
|
225 | - else { |
|
219 | + } else { |
|
226 | 220 | $cmd = escapeshellcmd("{$this->ffmpeg} -i $path -vf scale=$scale,setsar=1"); |
227 | 221 | } |
228 | 222 | |
@@ -316,8 +310,7 @@ discard block |
||
316 | 310 | } |
317 | 311 | |
318 | 312 | $scale = "$scale:-2"; |
319 | - } |
|
320 | - else { |
|
313 | + } else { |
|
321 | 314 | $scale = ceil(($meta['height'] * $width) / $meta['width']); |
322 | 315 | |
323 | 316 | if ($scale < $height) { |
@@ -326,12 +319,10 @@ discard block |
||
326 | 319 | |
327 | 320 | $scale = "-2:$scale"; |
328 | 321 | } |
329 | - } |
|
330 | - else { |
|
322 | + } else { |
|
331 | 323 | $scale = ''; |
332 | 324 | } |
333 | - } |
|
334 | - else { |
|
325 | + } else { |
|
335 | 326 | $scale = $width ? "$width:-2" : ($height ? "-2:$height" : (self::DEFAULT_SCALE . ':-2')); |
336 | 327 | } |
337 | 328 | |
@@ -364,8 +355,7 @@ discard block |
||
364 | 355 | } |
365 | 356 | |
366 | 357 | throw new Exception($process->getErrorOutput()); |
367 | - } |
|
368 | - else { |
|
358 | + } else { |
|
369 | 359 | list($path, $name) = $this->splitPath($saveTo); |
370 | 360 | |
371 | 361 | $tempDir = $this->tempDir(); |
@@ -414,8 +404,7 @@ discard block |
||
414 | 404 | } |
415 | 405 | |
416 | 406 | throw new Exception($process->getErrorOutput()); |
417 | - } |
|
418 | - else { |
|
407 | + } else { |
|
419 | 408 | $name = basename($streamPath); |
420 | 409 | $temp = $name . '-' . time(); |
421 | 410 |
@@ -92,8 +92,8 @@ |
||
92 | 92 | $size = $this->image->getSize(); |
93 | 93 | |
94 | 94 | return [ |
95 | - 'width' => (int)$size->getWidth(), |
|
96 | - 'height' => (int)$size->getHeight(), |
|
95 | + 'width' => (int) $size->getWidth(), |
|
96 | + 'height' => (int) $size->getHeight(), |
|
97 | 97 | ]; |
98 | 98 | } |
99 | 99 |
@@ -115,8 +115,7 @@ discard block |
||
115 | 115 | |
116 | 116 | if ($this->driverIsLocal) { |
117 | 117 | $this->$method($image, $width, $height)->save($saveTo); |
118 | - } |
|
119 | - else { |
|
118 | + } else { |
|
120 | 119 | list($path, $name) = $this->splitPath($saveTo); |
121 | 120 | |
122 | 121 | $tempDir = $this->tempDir(); |
@@ -360,8 +359,7 @@ discard block |
||
360 | 359 | |
361 | 360 | if ($file instanceof UploadedFile) { |
362 | 361 | $path = $file->getRealPath(); |
363 | - } |
|
364 | - else if (file_exists($file)) { |
|
362 | + } else if (file_exists($file)) { |
|
365 | 363 | $path = $file; |
366 | 364 | } |
367 | 365 | |
@@ -371,8 +369,7 @@ discard block |
||
371 | 369 | return self::toHexString($color); |
372 | 370 | } |
373 | 371 | } |
374 | - } |
|
375 | - catch (Exception $e) { |
|
372 | + } catch (Exception $e) { |
|
376 | 373 | // do nothing |
377 | 374 | } |
378 | 375 |
@@ -67,8 +67,7 @@ discard block |
||
67 | 67 | $this->type = $this->output['type']; |
68 | 68 | |
69 | 69 | return true; |
70 | - } |
|
71 | - else { |
|
70 | + } else { |
|
72 | 71 | return false; |
73 | 72 | } |
74 | 73 | } |
@@ -86,8 +85,7 @@ discard block |
||
86 | 85 | $this->type = $this->output['type']; |
87 | 86 | |
88 | 87 | return true; |
89 | - } |
|
90 | - else { |
|
88 | + } else { |
|
91 | 89 | return false; |
92 | 90 | } |
93 | 91 | } |
@@ -107,8 +105,7 @@ discard block |
||
107 | 105 | if (isset($this->file)) { |
108 | 106 | if ($this->file == LARUPLOAD_NULL) { |
109 | 107 | $this->clean($model->id); |
110 | - } |
|
111 | - else { |
|
108 | + } else { |
|
112 | 109 | if (!$this->keepOldFiles) { |
113 | 110 | $this->clean($model->id); |
114 | 111 | } |
@@ -121,8 +118,7 @@ discard block |
||
121 | 118 | } |
122 | 119 | |
123 | 120 | $model = $this->setAttributes($model); |
124 | - } |
|
125 | - else if (isset($this->cover)) { |
|
121 | + } else if (isset($this->cover)) { |
|
126 | 122 | $this->setCover($model->id); |
127 | 123 | |
128 | 124 | $model = $this->setAttributes($model); |
@@ -214,8 +210,7 @@ discard block |
||
214 | 210 | if ($style == LaruploadEnum::COVER_FOLDER and $this->generateCover == false) { |
215 | 211 | $styles->{$style} = null; |
216 | 212 | continue; |
217 | - } |
|
218 | - else if ($style == LaruploadEnum::STREAM_FOLDER and empty($this->streams)) { |
|
213 | + } else if ($style == LaruploadEnum::STREAM_FOLDER and empty($this->streams)) { |
|
219 | 214 | unset($styles->{$style}); |
220 | 215 | continue; |
221 | 216 | } |
@@ -409,8 +404,7 @@ discard block |
||
409 | 404 | case LaruploadEnum::VIDEO: |
410 | 405 | if ($this->ffmpegQueue) { |
411 | 406 | $this->initializeFFMpegQueue($id, $class, $standalone); |
412 | - } |
|
413 | - else { |
|
407 | + } else { |
|
414 | 408 | $this->handleVideoStyles($id); |
415 | 409 | } |
416 | 410 | |
@@ -462,8 +456,7 @@ discard block |
||
462 | 456 | |
463 | 457 | if ($maxQueueNum == 0) { |
464 | 458 | $flag = true; |
465 | - } |
|
466 | - else { |
|
459 | + } else { |
|
467 | 460 | $availableQueues = DB::table(LaruploadEnum::FFMPEG_QUEUE_TABLE)->where('status', 0)->count(); |
468 | 461 | |
469 | 462 | if ($availableQueues < $maxQueueNum) { |
@@ -497,8 +490,7 @@ discard block |
||
497 | 490 | |
498 | 491 | |
499 | 492 | ProcessFFMpeg::dispatch($queueId, $id, $this->name, $class, $serializedClass); |
500 | - } |
|
501 | - else { |
|
493 | + } else { |
|
502 | 494 | throw new HttpResponseException(redirect(URL::previous())->withErrors([ |
503 | 495 | 'ffmpeg_queue_max_num' => trans('larupload::messages.max-queue-num-exceeded') |
504 | 496 | ])); |
@@ -532,8 +524,7 @@ discard block |
||
532 | 524 | foreach ($this->output as $key => $value) { |
533 | 525 | $model->{"{$this->name}_file_$key"} = $value; |
534 | 526 | } |
535 | - } |
|
536 | - else { |
|
527 | + } else { |
|
537 | 528 | $model->{"{$this->name}_file_name"} = $this->output['name'] ?? null; |
538 | 529 | $model->{"{$this->name}_file_meta"} = json_encode($this->output); |
539 | 530 | } |
@@ -566,8 +557,7 @@ discard block |
||
566 | 557 | } |
567 | 558 | |
568 | 559 | return null; |
569 | - } |
|
570 | - else if ($name and $this->styleHasFile($style)) { |
|
560 | + } else if ($name and $this->styleHasFile($style)) { |
|
571 | 561 | $name = $this->fixExceptionNames($name, $style); |
572 | 562 | $path = $this->getBasePath($this->id, $style); |
573 | 563 | $path = "$path/$name"; |
@@ -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 | } |
@@ -30,8 +30,7 @@ discard block |
||
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 | } |
@@ -66,8 +65,7 @@ discard block |
||
66 | 65 | $coverColumns = [ |
67 | 66 | "{$name}_file_size", "{$name}_file_type", "{$name}_file_mime_type", "{$name}_file_width", "{$name}_file_height", "{$name}_file_duration", "{$name}_file_format", "{$name}_file_cover" |
68 | 67 | ]; |
69 | - } |
|
70 | - else { |
|
68 | + } else { |
|
71 | 69 | $coverColumns = [ |
72 | 70 | "{$name}_file_size", "{$name}_file_type", "{$name}_file_mime_type", "{$name}_file_width", "{$name}_file_height", "{$name}_file_duration", "{$name}_file_format", "{$name}_file_cover" |
73 | 71 | ]; |
@@ -34,17 +34,13 @@ discard block |
||
34 | 34 | { |
35 | 35 | if (strstr($mime, 'image/')) { |
36 | 36 | return LaruploadEnum::IMAGE; |
37 | - } |
|
38 | - else if (strstr($mime, 'video/')) { |
|
37 | + } else if (strstr($mime, 'video/')) { |
|
39 | 38 | return LaruploadEnum::VIDEO; |
40 | - } |
|
41 | - else if (strstr($mime, 'audio/')) { |
|
39 | + } else if (strstr($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 |
@@ -308,8 +308,7 @@ |
||
308 | 308 | "\xE2\x80\xAF", "\xE2\x81\x9F", "\xE3\x80\x80", "\xEF\xBE\xA0" |
309 | 309 | ], |
310 | 310 | ]; |
311 | - } |
|
312 | - else { |
|
311 | + } else { |
|
313 | 312 | return $charsArray = [ |
314 | 313 | '0' => ['°', '₀', '0'], |
315 | 314 | '1' => ['¹', '₁', '1'], |
@@ -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 | } |
@@ -50,8 +50,7 @@ discard block |
||
50 | 50 | try { |
51 | 51 | if (isset($this->standalone) and $this->standalone) { |
52 | 52 | $this->standalone->handleFFMpegQueue(); |
53 | - } |
|
54 | - else { |
|
53 | + } else { |
|
55 | 54 | $class = $this->model; |
56 | 55 | $modelNotSaved = true; |
57 | 56 | |
@@ -75,8 +74,7 @@ discard block |
||
75 | 74 | } |
76 | 75 | |
77 | 76 | $this->updateStatus(true, false); |
78 | - } |
|
79 | - catch (FileNotFoundException | Exception $e) { |
|
77 | + } catch (FileNotFoundException | Exception $e) { |
|
80 | 78 | $this->updateStatus(false, false, $e->getMessage()); |
81 | 79 | |
82 | 80 | throw new Exception($e->getMessage()); |