This repository has been archived on 2024-09-05. You can view files and clone it, but cannot push or open issues or pull requests.
shimmie2/ext/approval/theme.php

63 lines
1.8 KiB
PHP
Raw Normal View History

2021-12-14 18:32:47 +00:00
<?php
declare(strict_types=1);
namespace Shimmie2;
2023-07-10 18:03:54 +00:00
use MicroHTML\HTMLElement;
use function MicroHTML\emptyHTML;
use function MicroHTML\{BUTTON,INPUT,P};
2019-10-14 18:35:33 +00:00
class ApprovalTheme extends Themelet
{
2023-07-10 18:03:54 +00:00
public function get_image_admin_html(Image $image): HTMLElement
2019-10-14 18:35:33 +00:00
{
2023-11-11 21:49:12 +00:00
if ($image->approved === true) {
2023-07-10 18:03:54 +00:00
$form = SHM_SIMPLE_FORM(
2020-01-30 10:31:11 +00:00
'disapprove_image/'.$image->id,
2023-11-11 21:49:12 +00:00
INPUT(["type" => 'hidden', "name" => 'image_id', "value" => $image->id]),
2020-01-26 23:12:48 +00:00
SHM_SUBMIT("Disapprove")
);
} else {
2023-07-10 18:03:54 +00:00
$form = SHM_SIMPLE_FORM(
2020-01-30 10:31:11 +00:00
'approve_image/'.$image->id,
2023-11-11 21:49:12 +00:00
INPUT(["type" => 'hidden', "name" => 'image_id', "value" => $image->id]),
2020-01-26 23:12:48 +00:00
SHM_SUBMIT("Approve")
);
}
2019-10-14 18:35:33 +00:00
2023-07-10 18:03:54 +00:00
return $form;
2019-10-14 18:35:33 +00:00
}
2023-07-10 18:03:54 +00:00
public function get_help_html(): HTMLElement
2019-10-14 18:35:33 +00:00
{
2023-07-10 18:03:54 +00:00
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.")
);
2019-10-14 18:35:33 +00:00
}
2019-10-14 19:40:15 +00:00
public function display_admin_block(SetupBuildingEvent $event)
{
$sb = $event->panel->create_new_block("Approval");
2020-10-26 15:16:06 +00:00
$sb->add_bool_option(ApprovalConfig::IMAGES, "Posts: ");
2019-10-14 19:40:15 +00:00
}
2019-10-14 18:35:33 +00:00
public function display_admin_form()
{
global $page;
2019-10-14 19:40:15 +00:00
2023-07-10 18:03:54 +00:00
$form = SHM_SIMPLE_FORM(
2020-01-30 10:31:11 +00:00
"admin/approval",
2023-11-11 21:49:12 +00:00
BUTTON(["name" => 'approval_action', "value" => 'approve_all'], "Approve All Posts"),
2023-07-10 18:03:54 +00:00
" ",
2023-11-11 21:49:12 +00:00
BUTTON(["name" => 'approval_action', "value" => 'disapprove_all'], "Disapprove All Posts"),
2020-01-26 23:12:48 +00:00
);
2023-07-10 18:03:54 +00:00
$page->add_block(new Block("Approval", $form));
2019-10-14 18:35:33 +00:00
}
}