2021-12-14 18:32:47 +00:00
|
|
|
<?php
|
|
|
|
|
|
|
|
declare(strict_types=1);
|
2023-01-10 22:44:09 +00:00
|
|
|
|
|
|
|
namespace Shimmie2;
|
|
|
|
|
2020-01-26 23:12:48 +00:00
|
|
|
use function MicroHTML\BR;
|
|
|
|
use function MicroHTML\BUTTON;
|
|
|
|
use function MicroHTML\INPUT;
|
2019-10-14 18:35:33 +00:00
|
|
|
|
|
|
|
class ApprovalTheme extends Themelet
|
|
|
|
{
|
2021-03-14 23:43:50 +00:00
|
|
|
public function get_image_admin_html(Image $image): string
|
2019-10-14 18:35:33 +00:00
|
|
|
{
|
2019-11-02 19:57:34 +00:00
|
|
|
if ($image->approved===true) {
|
2020-01-26 23:12:48 +00:00
|
|
|
$html = SHM_SIMPLE_FORM(
|
2020-01-30 10:31:11 +00:00
|
|
|
'disapprove_image/'.$image->id,
|
2020-01-26 23:12:48 +00:00
|
|
|
INPUT(["type"=>'hidden', "name"=>'image_id', "value"=>$image->id]),
|
|
|
|
SHM_SUBMIT("Disapprove")
|
|
|
|
);
|
2019-11-02 04:45:28 +00:00
|
|
|
} else {
|
2020-01-26 23:12:48 +00:00
|
|
|
$html = SHM_SIMPLE_FORM(
|
2020-01-30 10:31:11 +00:00
|
|
|
'approve_image/'.$image->id,
|
2020-01-26 23:12:48 +00:00
|
|
|
INPUT(["type"=>'hidden', "name"=>'image_id', "value"=>$image->id]),
|
|
|
|
SHM_SUBMIT("Approve")
|
|
|
|
);
|
2019-11-02 04:45:28 +00:00
|
|
|
}
|
2019-10-14 18:35:33 +00:00
|
|
|
|
2020-01-26 23:12:48 +00:00
|
|
|
return (string)$html;
|
2019-10-14 18:35:33 +00:00
|
|
|
}
|
|
|
|
|
2021-03-14 23:43:50 +00:00
|
|
|
public function get_help_html(): string
|
2019-10-14 18:35:33 +00:00
|
|
|
{
|
2020-10-26 15:16:06 +00:00
|
|
|
return '<p>Search for posts that are approved/not approved.</p>
|
2019-10-14 18:35:33 +00:00
|
|
|
<div class="command_example">
|
|
|
|
<pre>approved:yes</pre>
|
2020-10-26 15:16:06 +00:00
|
|
|
<p>Returns posts that have been approved.</p>
|
2020-01-26 23:12:48 +00:00
|
|
|
</div>
|
2019-10-14 18:35:33 +00:00
|
|
|
<div class="command_example">
|
|
|
|
<pre>approved:no</pre>
|
2020-10-26 15:16:06 +00:00
|
|
|
<p>Returns posts that have not been approved.</p>
|
2020-01-26 23:12:48 +00:00
|
|
|
</div>
|
2019-10-14 18:35:33 +00:00
|
|
|
';
|
|
|
|
}
|
|
|
|
|
2019-10-14 19:40:15 +00:00
|
|
|
public function display_admin_block(SetupBuildingEvent $event)
|
|
|
|
{
|
2020-10-26 15:13:28 +00:00
|
|
|
$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
|
|
|
|
2020-01-26 23:12:48 +00:00
|
|
|
$html = (string)SHM_SIMPLE_FORM(
|
2020-01-30 10:31:11 +00:00
|
|
|
"admin/approval",
|
2020-10-26 15:16:06 +00:00
|
|
|
BUTTON(["name"=>'approval_action', "value"=>'approve_all'], "Approve All Posts"),
|
2020-01-26 23:12:48 +00:00
|
|
|
BR(),
|
2020-10-26 15:16:06 +00:00
|
|
|
BUTTON(["name"=>'approval_action', "value"=>'disapprove_all'], "Disapprove All Posts"),
|
2020-01-26 23:12:48 +00:00
|
|
|
);
|
2019-10-14 18:35:33 +00:00
|
|
|
$page->add_block(new Block("Approval", $html));
|
|
|
|
}
|
|
|
|
}
|