diff options
Diffstat (limited to 'modules/gallery')
-rw-r--r-- | modules/gallery/controllers/quick.php | 15 | ||||
-rw-r--r-- | modules/gallery/helpers/item.php | 18 | ||||
-rw-r--r-- | modules/gallery/js/quick.js | 4 | ||||
-rw-r--r-- | modules/gallery/views/quick_pane.html.php | 5 |
4 files changed, 34 insertions, 8 deletions
diff --git a/modules/gallery/controllers/quick.php b/modules/gallery/controllers/quick.php index d6f5213f..30383307 100644 --- a/modules/gallery/controllers/quick.php +++ b/modules/gallery/controllers/quick.php @@ -95,6 +95,21 @@ class Quick_Controller extends Controller { print json_encode(array("result" => "success", "reload" => 1)); } + public function form_delete($id) { + $item = model_cache::get("item", $id); + access::required("view", $item); + access::required("edit", $item); + + if ($item->is_album()) { + print t("Delete the album <b>%title</b>? All items within the album will also be deleted.", array("title" => $item->title)); + } else { + print t("Are you sure you want to delete <b>%title</b>?", array("title" => $item->title)); + } + + $form = item::get_delete_form($item); + print $form; + } + public function delete($id) { access::verify_csrf(); $item = model_cache::get("item", $id); diff --git a/modules/gallery/helpers/item.php b/modules/gallery/helpers/item.php index 09870b45..f40b5c97 100644 --- a/modules/gallery/helpers/item.php +++ b/modules/gallery/helpers/item.php @@ -119,4 +119,22 @@ class item_Core { $title = preg_replace("/ +/", " ", $title); return $title; } + + /** + * Display delete confirmation message and form + * @param object $item + * @return string form + */ + static function get_delete_form($item) { + if (Input::instance()->get("page_type") == "album") { + $page_type = "album"; + } else { + $page_type = "item"; + } + $form = new Forge("quick/delete/$item->id?page_type=$page_type", "", "post", array("id" => "gConfirmDelete")); + $form->hidden("_method")->value("put"); + $group = $form->group("confirm_delete")->label(t("Confirm Deletion")); + $group->submit("")->value(t("Delete")); + return $form; + } }
\ No newline at end of file diff --git a/modules/gallery/js/quick.js b/modules/gallery/js/quick.js index 8a87ed07..4ebdac47 100644 --- a/modules/gallery/js/quick.js +++ b/modules/gallery/js/quick.js @@ -39,10 +39,6 @@ var show_quick = function() { ); $("#gQuickPane a:not(.options)").click(function(e) { e.preventDefault(); - if ($(this).attr("id") == "gQuickDelete" && - !confirm($(this).attr("ref"))) { - return; - } quick_do(cont, $(this), img); }); $("#gQuickPane a.options").click(function(e) { diff --git a/modules/gallery/views/quick_pane.html.php b/modules/gallery/views/quick_pane.html.php index 95de972b..f50e1abe 100644 --- a/modules/gallery/views/quick_pane.html.php +++ b/modules/gallery/views/quick_pane.html.php @@ -67,15 +67,12 @@ <? if ($item->type == "photo"): ?> <? $title = t("Delete this photo") ?> -<? $message = t("Do you really want to delete this photo") ?> <? elseif ($item->type == "movie"): ?> <? $title = t("Delete this movie") ?> -<? $message = t("Do you really want to delete this movie") ?> <? elseif ($item->type == "album"): ?> <? $title = t("Delete this album") ?> -<? $message = t("Do you really want to delete this album") ?> <? endif ?> -<a class="gButtonLink ui-corner-all ui-state-default" href="<?= url::site("quick/delete/$item->id?csrf=$csrf&page_type=$page_type") ?>" ref="<?= $message ?>" id="gQuickDelete" title="<?= $title ?>"> +<a class="gDialogLink gButtonLink ui-corner-all ui-state-default" href="<?= url::site("quick/form_delete/$item->id?page_type=$page_type") ?>" id="gQuickDelete" title="<?= $title ?>"> <span class="ui-icon ui-icon-trash"> <?= $title ?> </span> |