2021-12-14 18:32:47 +00:00
|
|
|
<?php
|
|
|
|
|
|
|
|
declare(strict_types=1);
|
2019-06-05 23:03:22 +00:00
|
|
|
|
2023-01-10 22:44:09 +00:00
|
|
|
namespace Shimmie2;
|
|
|
|
|
2019-06-05 23:03:22 +00:00
|
|
|
class BulkActionsTheme extends Themelet
|
|
|
|
{
|
2024-01-20 14:10:59 +00:00
|
|
|
/**
|
|
|
|
* @param array<array{block:string,access_key:?string,confirmation_message:string,action:string,button_text:string,position:int}> $actions
|
|
|
|
*/
|
2024-01-15 14:23:00 +00:00
|
|
|
public function display_selector(Page $page, array $actions, string $query): void
|
2019-06-14 12:47:50 +00:00
|
|
|
{
|
|
|
|
$body = "<input type='hidden' name='bulk_selected_ids' id='bulk_selected_ids' />
|
2019-06-27 03:41:42 +00:00
|
|
|
<input id='bulk_selector_activate' type='button' onclick='activate_bulk_selector();' value='Activate (M)anual Select' accesskey='m'/>
|
2019-06-12 22:44:25 +00:00
|
|
|
<div id='bulk_selector_controls' style='display: none;'>
|
2019-06-27 03:41:42 +00:00
|
|
|
<input id='bulk_selector_deactivate' type='button' onclick='deactivate_bulk_selector();' value='Deactivate (M)anual Select' accesskey='m'/>
|
2020-10-26 15:12:23 +00:00
|
|
|
Click on posts to mark them.
|
2019-06-12 22:44:25 +00:00
|
|
|
<br />
|
|
|
|
<table><tr><td>
|
|
|
|
<input id='bulk_selector_select_all' type='button'
|
|
|
|
onclick='select_all();' value='All'/>
|
|
|
|
</td><td>
|
|
|
|
<input id='bulk_selector_select_invert' type='button'
|
|
|
|
onclick='select_invert();' value='Invert'/>
|
|
|
|
</td><td>
|
|
|
|
<input id='bulk)selector_select_none' type='button'
|
|
|
|
onclick='select_none();' value='Clear'/>
|
|
|
|
</td></tr></table>
|
|
|
|
";
|
|
|
|
|
2023-06-27 16:45:35 +00:00
|
|
|
$hasQuery = !empty($query);
|
2019-06-14 12:47:50 +00:00
|
|
|
|
|
|
|
if ($hasQuery) {
|
|
|
|
$body .= "</div>";
|
|
|
|
}
|
|
|
|
|
|
|
|
foreach ($actions as $action) {
|
2024-02-11 11:34:09 +00:00
|
|
|
$body .= "<div class='bulk_action'>" . make_form(make_link("bulk_action"), onsubmit: "return validate_selections(this,'" . html_escape($action["confirmation_message"]) . "');") .
|
2019-06-14 12:47:50 +00:00
|
|
|
"<input type='hidden' name='bulk_query' value='" . html_escape($query) . "'>" .
|
|
|
|
"<input type='hidden' name='bulk_selected_ids' />" .
|
|
|
|
"<input type='hidden' name='bulk_action' value='" . $action["action"] . "' />" .
|
|
|
|
$action["block"] .
|
2019-06-27 03:41:42 +00:00
|
|
|
"<input type='submit' name='submit_button' accesskey='{$action["access_key"]}' value='" . $action["button_text"] . "'/>" .
|
2019-06-14 12:47:50 +00:00
|
|
|
"</form></div>";
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!$hasQuery) {
|
|
|
|
$body .= "</div>";
|
|
|
|
}
|
|
|
|
$block = new Block("Bulk Actions", $body, "left", 30);
|
|
|
|
$page->add_block($block);
|
|
|
|
}
|
|
|
|
|
2021-03-14 23:43:50 +00:00
|
|
|
public function render_ban_reason_input(): string
|
2019-06-17 09:52:05 +00:00
|
|
|
{
|
2024-01-20 01:03:01 +00:00
|
|
|
if (Extension::is_enabled(ImageBanInfo::KEY)) {
|
2019-06-17 09:52:05 +00:00
|
|
|
return "<input type='text' name='bulk_ban_reason' placeholder='Ban reason (leave blank to not ban)' />";
|
|
|
|
} else {
|
|
|
|
return "";
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-03-14 23:43:50 +00:00
|
|
|
public function render_tag_input(): string
|
2019-06-14 12:47:50 +00:00
|
|
|
{
|
|
|
|
return "<label><input type='checkbox' style='width:13px;' name='bulk_tags_replace' value='true'/>Replace tags</label>" .
|
2023-03-27 17:04:06 +00:00
|
|
|
"<input type='text' name='bulk_tags' class='autocomplete_tags' required='required' placeholder='Enter tags here' />";
|
2019-06-14 12:47:50 +00:00
|
|
|
}
|
|
|
|
|
2021-03-14 23:43:50 +00:00
|
|
|
public function render_source_input(): string
|
2019-06-14 12:47:50 +00:00
|
|
|
{
|
2023-01-30 20:53:58 +00:00
|
|
|
return "<input type='text' name='bulk_source' placeholder='Enter source here' />";
|
2019-06-14 12:47:50 +00:00
|
|
|
}
|
2019-06-05 23:03:22 +00:00
|
|
|
}
|