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_size = get_thumbnail_max_size_scaled();
$max_width = $max_size[0]; $max_width = $max_size[0];
$max_height = $max_size[1]; $max_height = $max_size[1];
@ -201,15 +201,15 @@ function create_thumbnail_convert($hash, $input_type = ""): bool
if ($type=="webp") { if ($type=="webp") {
$bg = "none"; $bg = "none";
} }
if(!empty($input_type)) { if (!empty($input_type)) {
$input_type = $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'; $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 $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); exec($cmd, $output, $ret);
if ($ret!=0) { 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 { } else {
log_debug('imageboard/misc', "Generating thumbnail with command `$cmd`, returns $ret"); 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. * @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. * @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; $is_anim_gif = 0;
if (($fh = @fopen($image_filename, 'rb'))) { if (($fh = @fopen($image_filename, 'rb'))) {
//check if gif is animated (via http://www.php.net/manual/en/function.imagecreatefromgif.php#104473) //check if gif is animated (via http://www.php.net/manual/en/function.imagecreatefromgif.php#104473)

View File

@ -26,7 +26,8 @@
* Various other common functions are available as part of the Themelet class. * Various other common functions are available as part of the Themelet class.
*/ */
abstract class PageMode { abstract class PageMode
{
const REDIRECT = 'redirect'; const REDIRECT = 'redirect';
const DATA = 'data'; const DATA = 'data';
const PAGE = 'page'; const PAGE = 'page';

View File

@ -285,8 +285,8 @@ function path_to_tags(string $path): string
{ {
$matches = []; $matches = [];
$tags = []; $tags = [];
if(preg_match("/\d+ - (.+)\.([a-zA-Z0-9]+)/", basename($path), $matches)) { if (preg_match("/\d+ - (.+)\.([a-zA-Z0-9]+)/", basename($path), $matches)) {
$tags = explode(" ",$matches[1]); $tags = explode(" ", $matches[1]);
} }
$path = dirname($path); $path = dirname($path);
@ -295,19 +295,19 @@ function path_to_tags(string $path): string
$category = ""; $category = "";
foreach(explode("/", $path) as $dir) { foreach (explode("/", $path) as $dir) {
$category_to_inherit = ""; $category_to_inherit = "";
foreach(explode(" ", $dir) as $tag) { foreach (explode(" ", $dir) as $tag) {
$tag = trim($tag); $tag = trim($tag);
if($tag=="") { if ($tag=="") {
continue; continue;
} }
if(substr_compare($tag, ":", -1) === 0) { if (substr_compare($tag, ":", -1) === 0) {
// This indicates a tag that ends in a colon, // This indicates a tag that ends in a colon,
// which is for inheriting to tags on the subfolder // which is for inheriting to tags on the subfolder
$category_to_inherit = $tag; $category_to_inherit = $tag;
} else { } else {
if($category!=""&&strpos($tag, ":") === false) { if ($category!=""&&strpos($tag, ":") === false) {
// This indicates that category inheritance is active, // This indicates that category inheritance is active,
// and we've encountered a tag that does not specify a category. // and we've encountered a tag that does not specify a category.
// So we attach the inherited category to the tag. // So we attach the inherited category to the tag.
@ -322,7 +322,7 @@ function path_to_tags(string $path): string
$category = $category_to_inherit; $category = $category_to_inherit;
} }
return implode(" ",$tags); return implode(" ", $tags);
} }

View File

@ -333,7 +333,6 @@ class CronUploader extends Extension
$this->handle_log(); $this->handle_log();
return true; return true;
} }
private function move_uploaded($path, $filename, $output_subdir, $corrupt = false) private function move_uploaded($path, $filename, $output_subdir, $corrupt = false)
@ -374,7 +373,7 @@ class CronUploader extends Extension
assert(file_exists($tmpname)); assert(file_exists($tmpname));
$tagArray = Tag::explode($tags); $tagArray = Tag::explode($tags);
if(count($tagArray)==0) { if (count($tagArray)==0) {
$tagArray[] = "tagme"; $tagArray[] = "tagme";
} }

View File

@ -62,8 +62,6 @@ class ExtensionInfo
$this->authors[] = new ExtensionAuthor($author, null); $this->authors[] = new ExtensionAuthor($author, null);
} }
} }
} elseif (preg_match("/(.*)Description: ?(.*)/", $line, $matches)) { } elseif (preg_match("/(.*)Description: ?(.*)/", $line, $matches)) {
$this->description = $matches[2]; $this->description = $matches[2];
$start = $matches[1] . " "; $start = $matches[1] . " ";

View File

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

View File

@ -170,7 +170,7 @@ class Ratings extends Extension
global $user; global $user;
if ($user->is_admin()) { 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"));
} }
} }