From 1159ba2fa1bcd22a73b618e8e56ed6e64b3a6694 Mon Sep 17 00:00:00 2001 From: Shish Date: Sat, 19 Sep 2020 00:18:51 +0100 Subject: [PATCH] format --- core/command_builder.php | 12 ++++++------ ext/eokm/main.php | 12 +++++------- ext/handle_video/main.php | 4 ++-- ext/media/main.php | 4 ++-- ext/media/video_codecs.php | 4 ++-- ext/transcode_video/main.php | 26 +++++++++++--------------- themes/lite/view.theme.php | 2 +- 7 files changed, 29 insertions(+), 35 deletions(-) diff --git a/core/command_builder.php b/core/command_builder.php index 5bde66e2..afc1e796 100644 --- a/core/command_builder.php +++ b/core/command_builder.php @@ -9,8 +9,9 @@ class CommandBuilder private $args = []; public $output; - function __construct(String $executable) { - if(empty($executable)) { + public function __construct(String $executable) + { + if (empty($executable)) { throw new InvalidArgumentException("executable cannot be empty"); } @@ -30,7 +31,7 @@ class CommandBuilder public function generate(): string { $command = escapeshellarg($this->executable); - if(!empty($this->args)) { + if (!empty($this->args)) { $command .= " "; $command .= join(" ", $this->args); } @@ -40,12 +41,11 @@ class CommandBuilder public function combineOutput(string $empty_output = ""): string { - if(empty($this->output)) { + if (empty($this->output)) { return $empty_output; } else { return implode("\r\n", $this->output); } - } public function execute(bool $fail_on_non_zero_return = false): int @@ -57,7 +57,7 @@ class CommandBuilder log_debug('command_builder', "Command `$cmd` returned $ret and outputted $output"); - if($fail_on_non_zero_return&&(int)$ret!==(int)0) { + if ($fail_on_non_zero_return&&(int)$ret!==(int)0) { throw new SCoreException("Command `$cmd` failed, returning $ret and outputting $output"); } return $ret; diff --git a/ext/eokm/main.php b/ext/eokm/main.php index faaffc22..2cde369f 100644 --- a/ext/eokm/main.php +++ b/ext/eokm/main.php @@ -13,7 +13,7 @@ class Eokm extends Extension $username = $config->get_string("eokm_username"); $password = $config->get_string("eokm_password"); - if($username && $password) { + if ($username && $password) { $ch = curl_init("https://api.eokmhashdb.nl/v1/check/md5"); // curl_setopt($ch, CURLOPT_HTTPHEADER, array('Content-Type: application/xml', $additionalHeaders)); curl_setopt($ch, CURLOPT_HEADER, 0); @@ -21,18 +21,16 @@ class Eokm extends Extension curl_setopt($ch, CURLOPT_TIMEOUT, 30); curl_setopt($ch, CURLOPT_POST, 1); curl_setopt($ch, CURLOPT_POSTFIELDS, $event->image->hash); - curl_setopt($ch, CURLOPT_RETURNTRANSFER, TRUE); + curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); $return = curl_exec($ch); curl_close($ch); - if($return == "false") { + if ($return == "false") { // all ok - } - elseif($return == "true") { + } elseif ($return == "true") { log_warning("eokm", "User tried to upload banned image {$event->image->hash}"); throw new UploadException("Image banned"); - } - else { + } else { log_warning("eokm", "Unexpected return from EOKM: $return"); } } diff --git a/ext/handle_video/main.php b/ext/handle_video/main.php index 403cedd3..e0134103 100644 --- a/ext/handle_video/main.php +++ b/ext/handle_video/main.php @@ -97,8 +97,8 @@ class VideoFileHandler extends DataHandlerExtension $event->image->video = $video; $event->image->video_codec = $video_codec; $event->image->audio = $audio; - if($event->image->get_mime()==MimeType::MKV && - VideoContainers::is_video_codec_supported(VideoContainers::WEBM,$event->image->video_codec)) { + if ($event->image->get_mime()==MimeType::MKV && + VideoContainers::is_video_codec_supported(VideoContainers::WEBM, $event->image->video_codec)) { // WEBMs are MKVs with the VP9 or VP8 codec // For browser-friendliness, we'll just change the mime type $event->image->set_mime(MimeType::WEBM); diff --git a/ext/media/main.php b/ext/media/main.php index 1255057d..74d7f0a7 100644 --- a/ext/media/main.php +++ b/ext/media/main.php @@ -592,8 +592,8 @@ class Media extends Extension $file_arg = "${input_ext}:\"${input_path}[0]\""; - if($resize_type===Media::RESIZE_TYPE_FIT_BLUR_PORTRAIT) { - if($new_height>$new_width) { + if ($resize_type===Media::RESIZE_TYPE_FIT_BLUR_PORTRAIT) { + if ($new_height>$new_width) { $resize_type = Media::RESIZE_TYPE_FIT_BLUR; } else { $resize_type = Media::RESIZE_TYPE_FILL; diff --git a/ext/media/video_codecs.php b/ext/media/video_codecs.php index 55731b62..d7f8af18 100644 --- a/ext/media/video_codecs.php +++ b/ext/media/video_codecs.php @@ -33,8 +33,8 @@ abstract class VideoContainers public static function is_video_codec_supported(string $container, string $codec): bool { - return array_key_exists($container,self::VIDEO_CODEC_SUPPORT) && - in_array($codec,self::VIDEO_CODEC_SUPPORT[$container]); + return array_key_exists($container, self::VIDEO_CODEC_SUPPORT) && + in_array($codec, self::VIDEO_CODEC_SUPPORT[$container]); } } diff --git a/ext/transcode_video/main.php b/ext/transcode_video/main.php index d8f11cb1..57faef4b 100644 --- a/ext/transcode_video/main.php +++ b/ext/transcode_video/main.php @@ -46,8 +46,8 @@ class TranscodeVideo extends Extension if ($event->image->video===true && $user->can(Permissions::EDIT_FILES)) { $options = self::get_output_options($event->image->get_mime(), $event->image->video_codec); - if(!empty($options)&&sizeof($options)>1) { - $event->add_part($this->theme->get_transcode_html($event->image,$options)); + if (!empty($options)&&sizeof($options)>1) { + $event->add_part($this->theme->get_transcode_html($event->image, $options)); } } } @@ -163,7 +163,7 @@ class TranscodeVideo extends Extension // transcodes recorded already, otherwise the image entries will be stuck pointing to // missing image files $database->commit(); - if($output_image!=$image) { + if ($output_image!=$image) { $total++; } } catch (Exception $e) { @@ -187,11 +187,11 @@ class TranscodeVideo extends Extension foreach (VideoContainers::ALL as $container) { - if($starting_container==$container) { + if ($starting_container==$container) { continue; } - if(!empty($starting_codec)&& - !VideoContainers::is_video_codec_supported($container,$starting_codec)) { + if (!empty($starting_codec)&& + !VideoContainers::is_video_codec_supported($container, $starting_codec)) { continue; } $description = MimeMap::get_name_for_mime($container); @@ -202,16 +202,16 @@ class TranscodeVideo extends Extension private function transcode_and_replace_video(Image $image, String $target_mime): Image { - if($image->get_mime()==$target_mime) { + if ($image->get_mime()==$target_mime) { return $image; } - if($image->video==null||($image->video===true && empty($image->video_codec))) { + if ($image->video==null||($image->video===true && empty($image->video_codec))) { // If image predates the media system, or the video codec support, run a media check send_event(new MediaCheckPropertiesEvent($image)); $image->save_to_db(); } - if(empty($image->video_codec)) { + if (empty($image->video_codec)) { throw new VideoTranscodeException("Cannot transcode item $image->id because its video codec is not known"); } @@ -237,12 +237,10 @@ class TranscodeVideo extends Extension send_event(new ImageReplaceEvent($image->id, $new_image)); return $new_image; - } finally { /* Remove temporary file */ @unlink($tmp_filename); } - } @@ -250,7 +248,7 @@ class TranscodeVideo extends Extension { global $config; - if(empty($source_video_codec)) { + if (empty($source_video_codec)) { throw new VideoTranscodeException("Cannot transcode item because it's video codec is not known"); } @@ -267,7 +265,7 @@ class TranscodeVideo extends Extension $command->add_flag("-i"); $command->add_escaped_arg($source_file); - if(!VideoContainers::is_video_codec_supported($target_mime, $source_video_codec)) { + if (!VideoContainers::is_video_codec_supported($target_mime, $source_video_codec)) { throw new VideoTranscodeException("Cannot transcode item to $target_mime because it does not support the video codec $source_video_codec"); } @@ -289,6 +287,4 @@ class TranscodeVideo extends Extension return $target_file; } - - } diff --git a/themes/lite/view.theme.php b/themes/lite/view.theme.php index 93db16d3..6b417887 100644 --- a/themes/lite/view.theme.php +++ b/themes/lite/view.theme.php @@ -34,7 +34,7 @@ class CustomViewImageTheme extends ViewImageTheme
Filesize: $h_filesize
Type: ".$h_type." "; - if($image->video_codec!=null) { + if ($image->video_codec!=null) { $html .= "
Video Codec: $image->video_codec"; } if ($image->length!=null) {