cleanup
This commit is contained in:
parent
66df295ec1
commit
8612a07a5a
@ -9,36 +9,40 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
|
|
||||||
class BulkActionBlockBuildingEvent extends Event {
|
class BulkActionBlockBuildingEvent extends Event
|
||||||
|
{
|
||||||
/** @var array */
|
/** @var array */
|
||||||
public $actions = array();
|
public $actions = array();
|
||||||
/**
|
|
||||||
* @param string $name
|
public function add_action(String $action, String $confirmation_message = "", String $block = "", int $position = 40)
|
||||||
*/
|
{
|
||||||
public function add_action(String $action, String $confirmation_message = "", String $block = "", int $position = 40) {
|
|
||||||
if ($block == null)
|
if ($block == null)
|
||||||
$block = "";
|
$block = "";
|
||||||
|
|
||||||
array_push($this->actions, array(
|
array_push(
|
||||||
|
$this->actions,
|
||||||
|
array(
|
||||||
"block" => $block,
|
"block" => $block,
|
||||||
"confirmation_message" => $confirmation_message,
|
"confirmation_message" => $confirmation_message,
|
||||||
"action" => $action,
|
"action" => $action,
|
||||||
"position"=>$position)
|
"position" => $position
|
||||||
|
)
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
class BulkActionEvent extends Event {
|
class BulkActionEvent extends Event
|
||||||
|
{
|
||||||
public $action;
|
public $action;
|
||||||
public $items;
|
public $items;
|
||||||
public $page_request;
|
public $page_request;
|
||||||
|
|
||||||
function __construct (String $action, PageRequestEvent $pageRequestEvent, array $items) {
|
function __construct(String $action, PageRequestEvent $pageRequestEvent, array $items)
|
||||||
|
{
|
||||||
$this->action = $action;
|
$this->action = $action;
|
||||||
$this->page_request = $pageRequestEvent;
|
$this->page_request = $pageRequestEvent;
|
||||||
$this->items = $items;
|
$this->items = $items;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
class BulkActions extends Extension
|
class BulkActions extends Extension
|
||||||
@ -65,7 +69,6 @@ class BulkActions extends Extension
|
|||||||
if ($user->can("bulk_edit_image_source")) {
|
if ($user->can("bulk_edit_image_source")) {
|
||||||
$event->add_action("Set Source", "", $this->theme->render_source_input(), 10);
|
$event->add_action("Set Source", "", $this->theme->render_source_input(), 10);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public function onBulkAction(BulkActionEvent $event)
|
public function onBulkAction(BulkActionEvent $event)
|
||||||
@ -102,7 +105,6 @@ class BulkActions extends Extension
|
|||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public function onPageRequest(PageRequestEvent $event)
|
public function onPageRequest(PageRequestEvent $event)
|
||||||
@ -160,7 +162,8 @@ class BulkActions extends Extension
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private function delete_items(array $items) {
|
private function delete_items(array $items)
|
||||||
|
{
|
||||||
$total = 0;
|
$total = 0;
|
||||||
foreach ($items as $item) {
|
foreach ($items as $item) {
|
||||||
try {
|
try {
|
||||||
@ -172,10 +175,10 @@ class BulkActions extends Extension
|
|||||||
}
|
}
|
||||||
|
|
||||||
flash_message("Deleted $total items");
|
flash_message("Deleted $total items");
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private function tag_items(array $items, string $tags, bool $replace) {
|
private function tag_items(array $items, string $tags, bool $replace)
|
||||||
|
{
|
||||||
$tags = Tag::explode($tags);
|
$tags = Tag::explode($tags);
|
||||||
|
|
||||||
$pos_tag_array = [];
|
$pos_tag_array = [];
|
||||||
@ -211,7 +214,8 @@ class BulkActions extends Extension
|
|||||||
flash_message("Tagged $total items");
|
flash_message("Tagged $total items");
|
||||||
}
|
}
|
||||||
|
|
||||||
private function set_source(array $items, String $source) {
|
private function set_source(array $items, String $source)
|
||||||
|
{
|
||||||
$total = 0;
|
$total = 0;
|
||||||
foreach ($items as $item) {
|
foreach ($items as $item) {
|
||||||
try {
|
try {
|
||||||
@ -223,6 +227,5 @@ class BulkActions extends Extension
|
|||||||
}
|
}
|
||||||
|
|
||||||
flash_message("Set source for $total items");
|
flash_message("Set source for $total items");
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -62,13 +62,14 @@ class BulkActionsTheme extends Themelet
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public function render_tag_input() {
|
public function render_tag_input()
|
||||||
|
{
|
||||||
return "<label><input type='checkbox' style='width:13px;' name='bulk_tags_replace' value='true'/>Replace tags</label>" .
|
return "<label><input type='checkbox' style='width:13px;' name='bulk_tags_replace' value='true'/>Replace tags</label>" .
|
||||||
"<input type='text' name='bulk_tags' required='required' placeholder='Enter tags here' />";
|
"<input type='text' name='bulk_tags' required='required' placeholder='Enter tags here' />";
|
||||||
}
|
}
|
||||||
|
|
||||||
public function render_source_input() {
|
public function render_source_input()
|
||||||
|
{
|
||||||
return "<input type='text' name='bulk_source' required='required' placeholder='Enter source here' />";
|
return "<input type='text' name='bulk_source' required='required' placeholder='Enter source here' />";
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user