From 9e9225acf35d37da5d2f9208d159b65cfd8b128c Mon Sep 17 00:00:00 2001 From: Shish Date: Sun, 31 Dec 2023 22:27:32 +0000 Subject: [PATCH] [core] allow SHM_POST_INFO html element to accept a link parameter --- core/microhtml.php | 9 +++++++-- ext/tag_edit/theme.php | 14 ++++++-------- 2 files changed, 13 insertions(+), 10 deletions(-) diff --git a/core/microhtml.php b/core/microhtml.php index e7f4b71e..badd4085 100644 --- a/core/microhtml.php +++ b/core/microhtml.php @@ -154,9 +154,10 @@ function SHM_OPTION(string $value, string $text, bool $selected = false): HTMLEl } function SHM_POST_INFO( - HTMLElement|string $title, + string $title, HTMLElement|string|null $view = null, HTMLElement|string|null $edit = null, + string|null $link = null, ): HTMLElement { if(!is_null($view) && !is_null($edit)) { $show = emptyHTML( @@ -170,5 +171,9 @@ function SHM_POST_INFO( } else { $show = "???"; } - return TR(TH(["width" => "50px"], $title), TD($show)); + return TR( + ["data-row"=>$title], + TH(["width" => "50px"], $link ? A(["href" => $link], $title) : $title), + TD($show) + ); } diff --git a/ext/tag_edit/theme.php b/ext/tag_edit/theme.php index 735f5bb6..37dfcc69 100644 --- a/ext/tag_edit/theme.php +++ b/ext/tag_edit/theme.php @@ -55,9 +55,7 @@ class TagEditTheme extends Themelet } return SHM_POST_INFO( - Extension::is_enabled(TagHistoryInfo::KEY) ? - A(["href" => make_link("tag_history/{$image->id}")], "Tags") : - "Tags", + "Tags", joinHTML(", ", $tag_links), $user->can(Permissions::EDIT_IMAGE_TAG) ? INPUT([ "class" => "autocomplete_tags", @@ -66,7 +64,8 @@ class TagEditTheme extends Themelet "value" => $image->get_tag_list(), "id" => "tag_editor", "autocomplete" => "off" - ]) : null + ]) : null, + link: Extension::is_enabled(TagHistoryInfo::KEY) ? make_link("tag_history/{$image->id}") : null, ); } @@ -96,14 +95,13 @@ class TagEditTheme extends Themelet { global $user; return SHM_POST_INFO( - Extension::is_enabled(SourceHistoryInfo::KEY) ? - A(["href" => make_link("source_history/{$image->id}")], rawHTML("Source Link")) : - rawHTML("Source Link"), + "Source Link", DIV( ["style" => "overflow: hidden; white-space: nowrap; max-width: 350px; text-overflow: ellipsis;"], $this->format_source($image->get_source()) ), - $user->can(Permissions::EDIT_IMAGE_SOURCE) ? INPUT(["type" => "text", "name" => "tag_edit__source", "value" => $image->get_source()]) : null + $user->can(Permissions::EDIT_IMAGE_SOURCE) ? INPUT(["type" => "text", "name" => "tag_edit__source", "value" => $image->get_source()]) : null, + link: Extension::is_enabled(SourceHistoryInfo::KEY) ? make_link("source_history/{$image->id}") : null, ); }