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 -

Download as CSV

- "; + $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.

-
- '; + return emptyHTML( + P("Search for posts that are approved/not approved."), + SHM_COMMAND_EXAMPLE("approved:yes", "Returns posts that have been approved."), + SHM_COMMAND_EXAMPLE("approved:no", "Returns posts that have not been approved.") + ); } public function display_admin_block(SetupBuildingEvent $event) @@ -53,12 +50,13 @@ class ApprovalTheme extends Themelet { global $page; - $html = (string)SHM_SIMPLE_FORM( + $form = SHM_SIMPLE_FORM( "admin/approval", BUTTON(["name"=>'approval_action', "value"=>'approve_all'], "Approve All Posts"), - BR(), + " ", BUTTON(["name"=>'approval_action', "value"=>'disapprove_all'], "Disapprove All Posts"), ); - $page->add_block(new Block("Approval", $html)); + + $page->add_block(new Block("Approval", $form)); } } diff --git a/ext/artists/main.php b/ext/artists/main.php index 929eb7f6..0c1cb158 100644 --- a/ext/artists/main.php +++ b/ext/artists/main.php @@ -57,10 +57,7 @@ class Artists extends Extension public function onHelpPageBuilding(HelpPageBuildingEvent $event) { if ($event->key===HelpPages::SEARCH) { - $block = new Block(); - $block->header = "Artist"; - $block->body = $this->theme->get_help_html(); - $event->add_block($block); + $event->add_block(new Block("Artist", $this->theme->get_help_html())); } } diff --git a/ext/artists/theme.php b/ext/artists/theme.php index 51f6eff3..c367518f 100644 --- a/ext/artists/theme.php +++ b/ext/artists/theme.php @@ -4,20 +4,20 @@ declare(strict_types=1); namespace Shimmie2; +use MicroHTML\HTMLElement; + +use function MicroHTML\emptyHTML; +use function MicroHTML\{INPUT,P,SPAN,TD,TH,TR}; + class ArtistsTheme extends Themelet { public function get_author_editor_html(string $author): string { $h_author = html_escape($author); - return " - - Author - - $h_author - - - - "; + return (string)TR(TH("Author", TD( + SPAN(["class"=>"view"], $h_author), + INPUT(["class"=>"edit", "type"=>"text", "name"=>"tag_edit__author", "value"=>$h_author]) + ))); } public function sidebar_options(string $mode, ?int $artistID=null, $is_admin=false): void @@ -554,13 +554,11 @@ class ArtistsTheme extends Themelet return $html; } - public function get_help_html(): string + public function get_help_html(): HTMLElement { - return '

Search for posts with a particular artist.

-
-
artist=leonardo
-

Returns posts with the artist "leonardo".

-
- '; + return emptyHTML( + P("Search for posts with a particular artist."), + SHM_COMMAND_EXAMPLE("artist=leonardo", "Returns posts with the artist \"leonardo\".") + ); } } diff --git a/ext/rating/theme.php b/ext/rating/theme.php index 690df702..929a5288 100644 --- a/ext/rating/theme.php +++ b/ext/rating/theme.php @@ -7,7 +7,7 @@ namespace Shimmie2; use MicroHTML\HTMLElement; use function MicroHTML\emptyHTML; -use function MicroHTML\{DIV,INPUT,P,PRE,SPAN,TABLE,TD,TH,TR}; +use function MicroHTML\{P,SPAN,TABLE,TD,TH,TR}; class RatingsTheme extends Themelet {