From c24a6e9b978b0137bd96a9101ad8bdc47fd9f303 Mon Sep 17 00:00:00 2001 From: Shish Date: Fri, 21 Jun 2019 09:12:44 +0100 Subject: [PATCH] formatting pass --- core/imageboard/misc.php | 13 +++++++------ core/page.php | 3 ++- core/util.php | 26 +++++++++++++------------- ext/cron_uploader/main.php | 3 +-- ext/ext_manager/main.php | 2 -- ext/ext_manager/theme.php | 1 - ext/rating/main.php | 2 +- 7 files changed, 24 insertions(+), 26 deletions(-) diff --git a/core/imageboard/misc.php b/core/imageboard/misc.php index d08daf2b..865a1c65 100644 --- a/core/imageboard/misc.php +++ b/core/imageboard/misc.php @@ -125,7 +125,7 @@ function get_thumbnail_size(int $orig_width, int $orig_height, bool $use_dpi_sca } - if($use_dpi_scaling) { + if ($use_dpi_scaling) { $max_size = get_thumbnail_max_size_scaled(); $max_width = $max_size[0]; $max_height = $max_size[1]; @@ -201,15 +201,15 @@ function create_thumbnail_convert($hash, $input_type = ""): bool if ($type=="webp") { $bg = "none"; } - if(!empty($input_type)) { + if (!empty($input_type)) { $input_type = $input_type.":"; } $format = '"%s" -flatten -strip -thumbnail %ux%u%s -quality %u -background %s %s"%s[0]" %s:"%s" 2>&1'; - $cmd = sprintf($format, $convert, $w, $h, $options, $q, $bg,$input_type, $inname, $type, $outname); + $cmd = sprintf($format, $convert, $w, $h, $options, $q, $bg, $input_type, $inname, $type, $outname); $cmd = str_replace("\"convert\"", "convert", $cmd); // quotes are only needed if the path to convert contains a space; some other times, quotes break things, see github bug #27 exec($cmd, $output, $ret); if ($ret!=0) { - log_warning('imageboard/misc', "Generating thumbnail with command `$cmd`, returns $ret, outputting ".implode("\r\n",$output)); + log_warning('imageboard/misc', "Generating thumbnail with command `$cmd`, returns $ret, outputting ".implode("\r\n", $output)); } else { log_debug('imageboard/misc', "Generating thumbnail with command `$cmd`, returns $ret"); } @@ -489,7 +489,8 @@ function image_resize_gd( * @param String $image_filename The path of the file to check. * @return bool true if the file is an animated gif, false if it is not. */ -function is_animated_gif(String $image_filename) { +function is_animated_gif(String $image_filename) +{ $is_anim_gif = 0; if (($fh = @fopen($image_filename, 'rb'))) { //check if gif is animated (via http://www.php.net/manual/en/function.imagecreatefromgif.php#104473) @@ -499,4 +500,4 @@ function is_animated_gif(String $image_filename) { } } return ($is_anim_gif == 0); -} \ No newline at end of file +} diff --git a/core/page.php b/core/page.php index 998adc7d..12189999 100644 --- a/core/page.php +++ b/core/page.php @@ -26,7 +26,8 @@ * Various other common functions are available as part of the Themelet class. */ -abstract class PageMode { +abstract class PageMode +{ const REDIRECT = 'redirect'; const DATA = 'data'; const PAGE = 'page'; diff --git a/core/util.php b/core/util.php index ca50a728..b16dbb8e 100644 --- a/core/util.php +++ b/core/util.php @@ -284,30 +284,30 @@ function manual_include(string $fname): ?string function path_to_tags(string $path): string { $matches = []; - $tags = []; - if(preg_match("/\d+ - (.+)\.([a-zA-Z0-9]+)/", basename($path), $matches)) { - $tags = explode(" ",$matches[1]); - } + $tags = []; + if (preg_match("/\d+ - (.+)\.([a-zA-Z0-9]+)/", basename($path), $matches)) { + $tags = explode(" ", $matches[1]); + } - $path = dirname($path); + $path = dirname($path); $path = str_replace(";", ":", $path); - $path = str_replace("__", " ", $path); + $path = str_replace("__", " ", $path); $category = ""; - foreach(explode("/", $path) as $dir) { + foreach (explode("/", $path) as $dir) { $category_to_inherit = ""; - foreach(explode(" ", $dir) as $tag) { + foreach (explode(" ", $dir) as $tag) { $tag = trim($tag); - if($tag=="") { + if ($tag=="") { continue; } - if(substr_compare($tag, ":", -1) === 0) { + if (substr_compare($tag, ":", -1) === 0) { // This indicates a tag that ends in a colon, // which is for inheriting to tags on the subfolder $category_to_inherit = $tag; } else { - if($category!=""&&strpos($tag, ":") === false) { + if ($category!=""&&strpos($tag, ":") === false) { // This indicates that category inheritance is active, // and we've encountered a tag that does not specify a category. // So we attach the inherited category to the tag. @@ -316,13 +316,13 @@ function path_to_tags(string $path): string $tags[] = $tag; } } - // Category inheritance only works on the immediate subfolder, + // Category inheritance only works on the immediate subfolder, // so we hold a category until the next iteration, and then set // it back to an empty string after that iteration $category = $category_to_inherit; } - return implode(" ",$tags); + return implode(" ", $tags); } diff --git a/ext/cron_uploader/main.php b/ext/cron_uploader/main.php index 560a15a3..99ed9697 100644 --- a/ext/cron_uploader/main.php +++ b/ext/cron_uploader/main.php @@ -333,7 +333,6 @@ class CronUploader extends Extension $this->handle_log(); return true; - } private function move_uploaded($path, $filename, $output_subdir, $corrupt = false) @@ -374,7 +373,7 @@ class CronUploader extends Extension assert(file_exists($tmpname)); $tagArray = Tag::explode($tags); - if(count($tagArray)==0) { + if (count($tagArray)==0) { $tagArray[] = "tagme"; } diff --git a/ext/ext_manager/main.php b/ext/ext_manager/main.php index b41b53dd..07bad29c 100644 --- a/ext/ext_manager/main.php +++ b/ext/ext_manager/main.php @@ -62,8 +62,6 @@ class ExtensionInfo $this->authors[] = new ExtensionAuthor($author, null); } } - - } elseif (preg_match("/(.*)Description: ?(.*)/", $line, $matches)) { $this->description = $matches[2]; $start = $matches[1] . " "; diff --git a/ext/ext_manager/theme.php b/ext/ext_manager/theme.php index 58bd79ab..9a326ffc 100644 --- a/ext/ext_manager/theme.php +++ b/ext/ext_manager/theme.php @@ -129,7 +129,6 @@ class ExtManagerTheme extends Themelet $author .= html_escape($auth->name); } } - } $version = ($info->version) ? "
Version: " . html_escape($info->version) : ""; diff --git a/ext/rating/main.php b/ext/rating/main.php index a5e173a1..092223f3 100644 --- a/ext/rating/main.php +++ b/ext/rating/main.php @@ -170,7 +170,7 @@ class Ratings extends Extension global $user; if ($user->is_admin()) { - $event->add_action("bulk_rate","Set Rating","",$this->theme->get_selection_rater_html("u","bulk_rating")); + $event->add_action("bulk_rate", "Set Rating", "", $this->theme->get_selection_rater_html("u", "bulk_rating")); } }