Added shortcut-key support to bulk action extension
This commit is contained in:
parent
a82fb56063
commit
c4111cc948
7 changed files with 45 additions and 22 deletions
|
@ -16,22 +16,29 @@ class BulkActionBlockBuildingEvent extends Event
|
|||
|
||||
public $search_terms = [];
|
||||
|
||||
public function add_action(String $action, string $button_text, String $confirmation_message = "", String $block = "", int $position = 40)
|
||||
public function add_action(String $action, string $button_text, string $access_key = null, String $confirmation_message = "", String $block = "", int $position = 40)
|
||||
{
|
||||
if ($block == null) {
|
||||
$block = "";
|
||||
}
|
||||
|
||||
array_push(
|
||||
$this->actions,
|
||||
[
|
||||
if(!empty($access_key)) {
|
||||
assert(strlen($access_key)==1);
|
||||
foreach ($this->actions as $existing) {
|
||||
if($existing["access_key"]==$access_key) {
|
||||
throw new SCoreException("Access key $access_key is already in use");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$this->actions[] =[
|
||||
"block" => $block,
|
||||
"access_key" => $access_key,
|
||||
"confirmation_message" => $confirmation_message,
|
||||
"action" => $action,
|
||||
"button_text" => $button_text,
|
||||
"position" => $position
|
||||
]
|
||||
);
|
||||
];
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -79,15 +86,22 @@ class BulkActions extends Extension
|
|||
global $user;
|
||||
|
||||
if ($user->can("delete_image")) {
|
||||
$event->add_action("bulk_delete", "Delete", "Delete selected images?", "", 10);
|
||||
$event->add_action("bulk_delete", "(D)elete", "d", "Delete selected images?", "", 10);
|
||||
}
|
||||
|
||||
if ($user->can("bulk_edit_image_tag")) {
|
||||
$event->add_action("bulk_tag", "Tag", "", $this->theme->render_tag_input(), 10);
|
||||
|
||||
$event->add_action(
|
||||
"bulk_tag",
|
||||
"Tag",
|
||||
"t",
|
||||
"",
|
||||
$this->theme->render_tag_input(),
|
||||
10);
|
||||
}
|
||||
|
||||
if ($user->can("bulk_edit_image_source")) {
|
||||
$event->add_action("bulk_source", "Set Source", "", $this->theme->render_source_input(), 10);
|
||||
$event->add_action("bulk_source", "Set (S)ource", "s","", $this->theme->render_source_input(), 10);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -2,14 +2,14 @@
|
|||
|
||||
class BulkActionsTheme extends Themelet
|
||||
{
|
||||
public function display_selector(Page $page, $actions, $query)
|
||||
public function display_selector(Page $page, array $actions, string $query)
|
||||
{
|
||||
global $user;
|
||||
|
||||
$body = "<input type='hidden' name='bulk_selected_ids' id='bulk_selected_ids' />
|
||||
<input id='bulk_selector_activate' type='button' onclick='activate_bulk_selector();' value='Activate Selector'/>
|
||||
<input id='bulk_selector_activate' type='button' onclick='activate_bulk_selector();' value='Activate (M)anual Select' accesskey='m'/>
|
||||
<div id='bulk_selector_controls' style='display: none;'>
|
||||
<input id='bulk_selector_deactivate' type='button' onclick='deactivate_bulk_selector();' value='Deactivate Selector'/>
|
||||
<input id='bulk_selector_deactivate' type='button' onclick='deactivate_bulk_selector();' value='Deactivate (M)anual Select' accesskey='m'/>
|
||||
Click on images to mark them.
|
||||
<br />
|
||||
<table><tr><td>
|
||||
|
@ -36,7 +36,7 @@ class BulkActionsTheme extends Themelet
|
|||
"<input type='hidden' name='bulk_selected_ids' />" .
|
||||
"<input type='hidden' name='bulk_action' value='" . $action["action"] . "' />" .
|
||||
$action["block"] .
|
||||
"<input type='submit' name='submit_button' value='" . $action["button_text"] . "'/>" .
|
||||
"<input type='submit' name='submit_button' accesskey='{$action["access_key"]}' value='" . $action["button_text"] . "'/>" .
|
||||
"</form></div>";
|
||||
}
|
||||
|
||||
|
|
|
@ -415,8 +415,8 @@ class Pools extends Extension
|
|||
$pools = $database->get_all("SELECT * FROM pools ORDER BY title ");
|
||||
|
||||
|
||||
$event->add_action("bulk_pool_add_existing", "Add To Pool", "", $this->theme->get_bulk_pool_selector($pools));
|
||||
$event->add_action("bulk_pool_add_new", "Create Pool", "", $this->theme->get_bulk_pool_input());
|
||||
$event->add_action("bulk_pool_add_existing", "Add To (P)ool", "p","", $this->theme->get_bulk_pool_selector($pools));
|
||||
$event->add_action("bulk_pool_add_new", "Create Pool", "","", $this->theme->get_bulk_pool_input());
|
||||
}
|
||||
|
||||
public function onBulkAction(BulkActionEvent $event)
|
||||
|
|
|
@ -169,8 +169,8 @@ class Ratings extends Extension
|
|||
{
|
||||
global $user;
|
||||
|
||||
if ($user->is_admin()) {
|
||||
$event->add_action("bulk_rate", "Set Rating", "", $this->theme->get_selection_rater_html("u", "bulk_rating"));
|
||||
if ($user->can("bulk_edit_image_rating")) {
|
||||
$event->add_action("bulk_rate","Set (R)ating", "r","",$this->theme->get_selection_rater_html("u","bulk_rating"));
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -183,7 +183,7 @@ class Ratings extends Extension
|
|||
if (!isset($_POST['bulk_rating'])) {
|
||||
return;
|
||||
}
|
||||
if ($user->is_admin()) {
|
||||
if ($user->can("bulk_edit_image_rating")) {
|
||||
$rating = $_POST['bulk_rating'];
|
||||
$total = 0;
|
||||
foreach ($event->items as $id) {
|
||||
|
@ -206,7 +206,7 @@ class Ratings extends Extension
|
|||
global $user, $page;
|
||||
|
||||
if ($event->page_matches("admin/bulk_rate")) {
|
||||
if (!$user->is_admin()) {
|
||||
if (!$user->can("bulk_edit_image_rating")) {
|
||||
throw new PermissionDeniedException();
|
||||
} else {
|
||||
$n = 0;
|
||||
|
|
|
@ -69,7 +69,7 @@ class RegenThumb extends Extension
|
|||
global $user;
|
||||
|
||||
if ($user->can("delete_image")) {
|
||||
$event->add_action("bulk_regen", "Regen Thumbnails", "", $this->theme->bulk_html());
|
||||
$event->add_action("bulk_regen", "Regen Thumbnails", "","", $this->theme->bulk_html());
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -12,6 +12,15 @@
|
|||
* If and image is uanble to be transcoded for any reason, the upload will continue unaffected.
|
||||
*/
|
||||
|
||||
class TranscodeConfig
|
||||
{
|
||||
const ENGINE = "transcode_engine";
|
||||
const ENABLED = "transcode_enabled";
|
||||
const UPLOAD = "transcode_upload";
|
||||
const UPLOAD_PREFIX = "transcode_upload_";
|
||||
const QUALITY = "transcode_quality";
|
||||
}
|
||||
|
||||
/*
|
||||
* This is used by the image transcoding code when there is an error while transcoding
|
||||
*/
|
||||
|
@ -221,7 +230,7 @@ class TranscodeImage extends Extension
|
|||
$engine = $config->get_string("transcode_engine");
|
||||
|
||||
if ($user->is_admin()) {
|
||||
$event->add_action("bulk_transcode", "Transcode", "", $this->theme->get_transcode_picker_html($this->get_supported_output_formats($engine)));
|
||||
$event->add_action(self::ACTION_BULK_TRANSCODE, "Transcode", null,"", $this->theme->get_transcode_picker_html($this->get_supported_output_formats($engine)));
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -124,7 +124,7 @@ class Trash extends Extension
|
|||
global $user;
|
||||
|
||||
if ($user->can("view_trash")&&in_array("in:trash", $event->search_terms)) {
|
||||
$event->add_action("bulk_trash_restore","Restore From Trash");
|
||||
$event->add_action("bulk_trash_restore","(U)ndelete", "u");
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Reference in a new issue