diff --git a/ext/alias_editor/theme.php b/ext/alias_editor/theme.php index 57f8f265..14ece72e 100644 --- a/ext/alias_editor/theme.php +++ b/ext/alias_editor/theme.php @@ -4,36 +4,35 @@ declare(strict_types=1); namespace Shimmie2; +use MicroHTML\HTMLElement; + +use function MicroHTML\emptyHTML; +use function MicroHTML\{BR,INPUT}; + class AliasEditorTheme extends Themelet { /** * Show a page of aliases. - * - * Note: $can_manage = whether things like "add new alias" should be shown */ - public function display_aliases($table, $paginator): void + public function display_aliases(HTMLElement $table, HTMLElement $paginator): void { global $page, $user; - $can_manage = $user->can(Permissions::MANAGE_ALIAS_LIST); - $html = " - $table - $paginator -
- "; + $html = emptyHTML($table, BR(), $paginator, BR(), SHM_A("alias/export/aliases.csv", "Download as CSV", args: ["download"=>"aliases.csv"])); - $bulk_html = " - ".make_form(make_link("alias/import"), 'post', true)." - - - - "; + $bulk_form = SHM_FORM("alias/import", multipart: true); + $bulk_form->appendChild( + INPUT(["type"=>"file", "name"=>"alias_file"]), + SHM_SUBMIT("Upload List") + ); + $bulk_html = emptyHTML($bulk_form); $page->set_title("Alias List"); $page->set_heading("Alias List"); $page->add_block(new NavBlock()); $page->add_block(new Block("Aliases", $html)); - if ($can_manage) { + + if ($user->can(Permissions::MANAGE_ALIAS_LIST)) { $page->add_block(new Block("Bulk Upload", $bulk_html, "main", 51)); } } diff --git a/ext/approval/main.php b/ext/approval/main.php index 6f2b15ed..935091b9 100644 --- a/ext/approval/main.php +++ b/ext/approval/main.php @@ -168,10 +168,7 @@ class Approval extends Extension global $user, $config; if ($event->key===HelpPages::SEARCH) { if ($user->can(Permissions::APPROVE_IMAGE) && $config->get_bool(ApprovalConfig::IMAGES)) { - $block = new Block(); - $block->header = "Approval"; - $block->body = $this->theme->get_help_html(); - $event->add_block($block); + $event->add_block(new Block("Approval", $this->theme->get_help_html())); } } } @@ -231,7 +228,7 @@ class Approval extends Extension { global $user, $config; if ($user->can(Permissions::APPROVE_IMAGE) && $config->get_bool(ApprovalConfig::IMAGES)) { - $event->add_part($this->theme->get_image_admin_html($event->image)); + $event->add_part((string)$this->theme->get_image_admin_html($event->image)); } } diff --git a/ext/approval/theme.php b/ext/approval/theme.php index a9dde60d..07c063bd 100644 --- a/ext/approval/theme.php +++ b/ext/approval/theme.php @@ -4,43 +4,40 @@ declare(strict_types=1); namespace Shimmie2; -use function MicroHTML\BR; -use function MicroHTML\BUTTON; -use function MicroHTML\INPUT; +use MicroHTML\HTMLElement; + +use function MicroHTML\emptyHTML; + +use function MicroHTML\{BUTTON,INPUT,P}; class ApprovalTheme extends Themelet { - public function get_image_admin_html(Image $image): string + public function get_image_admin_html(Image $image): HTMLElement { if ($image->approved===true) { - $html = SHM_SIMPLE_FORM( + $form = SHM_SIMPLE_FORM( 'disapprove_image/'.$image->id, INPUT(["type"=>'hidden', "name"=>'image_id', "value"=>$image->id]), SHM_SUBMIT("Disapprove") ); } else { - $html = SHM_SIMPLE_FORM( + $form = SHM_SIMPLE_FORM( 'approve_image/'.$image->id, INPUT(["type"=>'hidden', "name"=>'image_id', "value"=>$image->id]), SHM_SUBMIT("Approve") ); } - return (string)$html; + return $form; } - public function get_help_html(): string + public function get_help_html(): HTMLElement { - return 'Search for posts that are approved/not approved.
-approved:yes-
Returns posts that have been approved.
-approved:no-
Returns posts that have not been approved.
-Search for posts with a particular artist.
-artist=leonardo-
Returns posts with the artist "leonardo".
-