Merge pull request #653 from sanmadjack/develop
Fixes for various issues
This commit is contained in:
commit
a1297781d5
7 changed files with 25 additions and 38 deletions
|
@ -18,7 +18,7 @@ interface Config
|
|||
/**
|
||||
* Set a configuration option to a new value, regardless of what the value is at the moment.
|
||||
*/
|
||||
public function set_int(string $name, ?int $value): void;
|
||||
public function set_int(string $name, ?string $value): void;
|
||||
|
||||
/**
|
||||
* Set a configuration option to a new value, regardless of what the value is at the moment.
|
||||
|
@ -113,7 +113,7 @@ abstract class BaseConfig implements Config
|
|||
{
|
||||
public $values = [];
|
||||
|
||||
public function set_int(string $name, ?int $value): void
|
||||
public function set_int(string $name, ?string $value): void
|
||||
{
|
||||
$this->values[$name] = parse_shorthand_int($value);
|
||||
$this->save($name);
|
||||
|
|
|
@ -570,6 +570,8 @@ class Image
|
|||
{
|
||||
global $database;
|
||||
|
||||
$unfiltered_tags = array_unique($unfiltered_tags);
|
||||
|
||||
$tags = [];
|
||||
foreach ($unfiltered_tags as $tag) {
|
||||
if (mb_strlen($tag, 'UTF-8') > 255) {
|
||||
|
|
|
@ -142,7 +142,8 @@ class CronUploader extends Extension
|
|||
{
|
||||
global $config;
|
||||
// Set default values
|
||||
if ($config->get_string("cron_uploader_key", "")) {
|
||||
$this->upload_key = $config->get_string("cron_uploader_key", "");
|
||||
if (strlen($this->upload_key)<=0) {
|
||||
$this->upload_key = $this->generate_key();
|
||||
|
||||
$config->set_default_int('cron_uploader_count', 1);
|
||||
|
@ -264,8 +265,8 @@ class CronUploader extends Extension
|
|||
shuffle($this->image_queue);
|
||||
|
||||
// Upload the file(s)
|
||||
for ($i = 0; $i < $upload_count && $i < sizeof($this->image_queue); $i++) {
|
||||
$img = $this->image_queue[$i];
|
||||
for ($i = 0; $i < $upload_count && sizeof($this->image_queue)>0; $i++) {
|
||||
$img = array_pop($this->image_queue);
|
||||
|
||||
try {
|
||||
$this->add_image($img[0], $img[1], $img[2]);
|
||||
|
@ -273,9 +274,6 @@ class CronUploader extends Extension
|
|||
} catch (Exception $e) {
|
||||
$this->move_uploaded($img[0], $img[1], true);
|
||||
}
|
||||
|
||||
// Remove img from queue array
|
||||
unset($this->image_queue[$i]);
|
||||
}
|
||||
|
||||
// Display & save upload log
|
||||
|
@ -321,7 +319,7 @@ class CronUploader extends Extension
|
|||
$metadata = [];
|
||||
$metadata ['filename'] = $pathinfo ['basename'];
|
||||
$metadata ['extension'] = $pathinfo ['extension'];
|
||||
$metadata ['tags'] = []; // = $tags; doesn't work when not logged in here
|
||||
$metadata ['tags'] = Tag::explode($tags);
|
||||
$metadata ['source'] = null;
|
||||
$event = new DataUploadEvent($tmpname, $metadata);
|
||||
send_event($event);
|
||||
|
@ -334,10 +332,7 @@ class CronUploader extends Extension
|
|||
$infomsg = "Image uploaded. ID: {$event->image_id} - Filename: {$filename} - Tags: {$tags}";
|
||||
}
|
||||
$msgNumber = $this->add_upload_info($infomsg);
|
||||
|
||||
// Set tags
|
||||
$img = Image::by_id($event->image_id);
|
||||
$img->set_tags(Tag::explode($tags));
|
||||
|
||||
}
|
||||
|
||||
private function generate_image_queue(): void
|
||||
|
@ -353,20 +348,10 @@ class CronUploader extends Extension
|
|||
foreach (new RecursiveIteratorIterator($ite) as $fullpath=>$cur) {
|
||||
if (!is_link($fullpath) && !is_dir($fullpath)) {
|
||||
$pathinfo = pathinfo($fullpath);
|
||||
$matches = [];
|
||||
|
||||
if (preg_match("/\d+ - (.*)\.([a-zA-Z]+)/", $pathinfo ["basename"], $matches)) {
|
||||
$tags = $matches [1];
|
||||
} else {
|
||||
$tags = $subdir;
|
||||
$tags = str_replace("/", " ", $tags);
|
||||
$tags = str_replace("__", " ", $tags);
|
||||
if ($tags == "") {
|
||||
$tags = " ";
|
||||
}
|
||||
$tags = trim($tags);
|
||||
}
|
||||
|
||||
|
||||
$relativePath = substr($fullpath,strlen($base));
|
||||
$tags = path_to_tags($relativePath);
|
||||
|
||||
$img = [
|
||||
0 => $fullpath,
|
||||
1 => $pathinfo ["basename"],
|
||||
|
|
|
@ -10,13 +10,13 @@ class Themelet extends BaseThemelet
|
|||
$page->add_block(new Block(null, $body, "main", 90));
|
||||
}
|
||||
|
||||
private function gen_page_link(string $base_url, string $query, string $page, string $name): string
|
||||
private function gen_page_link(string $base_url, ?string $query, string $page, string $name): string
|
||||
{
|
||||
$link = make_link("$base_url/$page", $query);
|
||||
return "<a href='$link'>$name</a>";
|
||||
}
|
||||
|
||||
private function gen_page_link_block(string $base_url, string $query, int $page, int $current_page, string $name): string
|
||||
private function gen_page_link_block(string $base_url, ?string $query, int $page, int $current_page, string $name): string
|
||||
{
|
||||
$paginator = "";
|
||||
if ($page == $current_page) {
|
||||
|
@ -27,7 +27,7 @@ class Themelet extends BaseThemelet
|
|||
return $paginator;
|
||||
}
|
||||
|
||||
private function build_paginator(int $current_page, int $total_pages, string $base_url, string $query): string
|
||||
private function build_paginator(int $current_page, int $total_pages, string $base_url, ?string $query): string
|
||||
{
|
||||
$next = $current_page + 1;
|
||||
$prev = $current_page - 1;
|
||||
|
|
|
@ -10,13 +10,13 @@ class Themelet extends BaseThemelet
|
|||
$page->add_block(new Block(null, $body, "main", 90));
|
||||
}
|
||||
|
||||
private function gen_page_link(string $base_url, string $query, string $page, string $name): string
|
||||
private function gen_page_link(string $base_url, ?string $query, string $page, string $name): string
|
||||
{
|
||||
$link = make_link("$base_url/$page", $query);
|
||||
return "<a href='$link'>$name</a>";
|
||||
}
|
||||
|
||||
private function gen_page_link_block(string $base_url, string $query, int $page, int $current_page, string $name): string
|
||||
private function gen_page_link_block(string $base_url, ?string $query, int $page, int $current_page, string $name): string
|
||||
{
|
||||
$paginator = "";
|
||||
if ($page == $current_page) {
|
||||
|
@ -27,7 +27,7 @@ class Themelet extends BaseThemelet
|
|||
return $paginator;
|
||||
}
|
||||
|
||||
private function build_paginator(int $current_page, int $total_pages, string $base_url, string $query): string
|
||||
private function build_paginator(int $current_page, int $total_pages, string $base_url, ?string $query): string
|
||||
{
|
||||
$next = $current_page + 1;
|
||||
$prev = $current_page - 1;
|
||||
|
|
|
@ -17,13 +17,13 @@ class Themelet extends BaseThemelet
|
|||
/**
|
||||
* Generate a single HTML link.
|
||||
*/
|
||||
public function futaba_gen_page_link(string $base_url, string $query, string $page, string $name): string
|
||||
public function futaba_gen_page_link(string $base_url, ?string $query, string $page, string $name): string
|
||||
{
|
||||
$link = make_link("$base_url/$page", $query);
|
||||
return "[<a href='$link'>{$name}</a>]";
|
||||
}
|
||||
|
||||
public function futaba_gen_page_link_block(string $base_url, string $query, int $page, int $current_page, string $name): string
|
||||
public function futaba_gen_page_link_block(string $base_url, ?string $query, int $page, int $current_page, string $name): string
|
||||
{
|
||||
$paginator = "";
|
||||
if ($page == $current_page) {
|
||||
|
@ -36,7 +36,7 @@ class Themelet extends BaseThemelet
|
|||
return $paginator;
|
||||
}
|
||||
|
||||
public function futaba_build_paginator(int $current_page, int $total_pages, string $base_url, string $query): string
|
||||
public function futaba_build_paginator(int $current_page, int $total_pages, string $base_url, ?string $query): string
|
||||
{
|
||||
$next = $current_page + 1;
|
||||
$prev = $current_page - 1;
|
||||
|
|
|
@ -33,7 +33,7 @@ class Themelet extends BaseThemelet
|
|||
return "<a class='$link_class' href='$link'>$name</a>";
|
||||
}
|
||||
|
||||
public function litetheme_gen_page_link_block(string $base_url, string $query, string $page, string $current_page, string $name): string
|
||||
public function litetheme_gen_page_link_block(string $base_url, ?string $query, string $page, string $current_page, string $name): string
|
||||
{
|
||||
$paginator = "";
|
||||
|
||||
|
@ -47,7 +47,7 @@ class Themelet extends BaseThemelet
|
|||
return $paginator;
|
||||
}
|
||||
|
||||
public function litetheme_build_paginator(int $current_page, int $total_pages, string $base_url, string $query, bool $show_random): string
|
||||
public function litetheme_build_paginator(int $current_page, int $total_pages, string $base_url, ?string $query, bool $show_random): string
|
||||
{
|
||||
$next = $current_page + 1;
|
||||
$prev = $current_page - 1;
|
||||
|
|
Reference in a new issue