formatting pass

This commit is contained in:
Shish 2019-06-21 09:12:44 +01:00
parent 42a502953b
commit c24a6e9b97
7 changed files with 24 additions and 26 deletions

View file

@ -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);
}
}

View file

@ -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';

View file

@ -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);
}

View file

@ -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";
}

View file

@ -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] . " ";

View file

@ -129,7 +129,6 @@ class ExtManagerTheme extends Themelet
$author .= html_escape($auth->name);
}
}
}
$version = ($info->version) ? "<br><b>Version:</b> " . html_escape($info->version) : "";

View file

@ -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"));
}
}