summaryrefslogtreecommitdiff
path: root/modules/gallery/helpers/gallery_event.php
diff options
context:
space:
mode:
Diffstat (limited to 'modules/gallery/helpers/gallery_event.php')
-rw-r--r--modules/gallery/helpers/gallery_event.php91
1 files changed, 85 insertions, 6 deletions
diff --git a/modules/gallery/helpers/gallery_event.php b/modules/gallery/helpers/gallery_event.php
index 2416f2e5..272fd205 100644
--- a/modules/gallery/helpers/gallery_event.php
+++ b/modules/gallery/helpers/gallery_event.php
@@ -98,6 +98,15 @@ class gallery_event_Core {
static function item_deleted($item) {
access::delete_item($item);
+ // Find any other albums that had the deleted item as the album cover and null it out.
+ // In some cases this may leave us with a missing album cover up in this item's parent
+ // hierarchy, but in most cases it'll work out fine.
+ foreach (ORM::factory("item")
+ ->where("album_cover_item_id", "=", $item->id)
+ ->find_all() as $parent) {
+ item::remove_album_cover($parent);
+ }
+
$parent = $item->parent();
if (!$parent->album_cover_item_id) {
// Assume we deleted the album cover and pick a new one. Choosing the first photo in the
@@ -157,17 +166,28 @@ class gallery_event_Core {
->view("login_current_user.html")
->url(user_profile::url($user->id))
->label($user->display_name()));
+
+ if (isset($theme->item)) {
+ if (access::user_can(identity::guest(), "view", $theme->item)) {
+ $continue_url = $theme->item->abs_url();
+ } else {
+ $continue_url = item::root()->abs_url();
+ }
+ } else {
+ $continue_url = url::abs_current();
+ }
+
$menu->append(Menu::factory("link")
->id("user_menu_logout")
->css_id("g-logout-link")
- ->url(url::site("logout?csrf=$csrf&continue=" .
- urlencode(url::abs_current())))
+ ->url(url::site("logout?csrf=$csrf&continue_url=" .
+ urlencode($continue_url)))
->label(t("Logout")));
}
}
}
- static function site_menu($menu, $theme) {
+ static function site_menu($menu, $theme, $item_css_selector) {
if ($theme->page_subtype != "login") {
$menu->append(Menu::factory("link")
->id("home")
@@ -191,7 +211,7 @@ class gallery_event_Core {
$add_menu->append(Menu::factory("dialog")
->id("add_photos_item")
->label(t("Add photos"))
- ->url(url::site("simple_uploader/app/$item->id")));
+ ->url(url::site("flash_uploader/app/$item->id")));
if ($item->is_album()) {
$add_menu->append(Menu::factory("dialog")
->id("add_album_item")
@@ -208,14 +228,17 @@ class gallery_event_Core {
case "album":
$option_text = t("Album options");
$edit_text = t("Edit album");
+ $delete_text = t("Delete album");
break;
case "movie":
$option_text = t("Movie options");
$edit_text = t("Edit movie");
+ $delete_text = t("Delete movie");
break;
default:
$option_text = t("Photo options");
$edit_text = t("Edit photo");
+ $delete_text = t("Delete photo");
}
$menu->append($options_menu = Menu::factory("submenu")
@@ -238,6 +261,63 @@ class gallery_event_Core {
}
}
}
+
+ $csrf = access::csrf_token();
+ $theme_item = $theme->item();
+ $page_type = $theme->page_type();
+ if ($can_edit && $item->is_photo() && graphics::can("rotate")) {
+ $options_menu
+ ->append(
+ Menu::factory("ajax_link")
+ ->id("rotate_ccw")
+ ->label(t("Rotate 90° counter clockwise"))
+ ->css_class("ui-icon-rotate-ccw")
+ ->ajax_handler("function(data) { " .
+ "\$.gallery_replace_image(data, \$('$item_css_selector')) }")
+ ->url(url::site("quick/rotate/$item->id/ccw?csrf=$csrf&from_id=$theme_item->id&page_type=$page_type")))
+ ->append(
+ Menu::factory("ajax_link")
+ ->id("rotate_cw")
+ ->label(t("Rotate 90° clockwise"))
+ ->css_class("ui-icon-rotate-cw")
+ ->ajax_handler("function(data) { " .
+ "\$.gallery_replace_image(data, \$('$item_css_selector')) }")
+ ->url(url::site("quick/rotate/$item->id/cw?csrf=$csrf&from_id=$theme_item->id&page_type=$page_type")));
+ }
+
+ if ($item->id != item::root()->id) {
+ $parent = $item->parent();
+ if (access::can("edit", $parent)) {
+ // We can't make this item the highlight if it's an album with no album cover, or if it's
+ // already the album cover.
+ if (($item->type == "album" && empty($item->album_cover_item_id)) ||
+ ($item->type == "album" && $parent->album_cover_item_id == $item->album_cover_item_id) ||
+ $parent->album_cover_item_id == $item->id) {
+ $disabledState = " ui-state-disabled";
+ } else {
+ $disabledState = " ";
+ }
+
+ if ($item->parent()->id != 1) {
+ $options_menu
+ ->append(
+ Menu::factory("ajax_link")
+ ->id("make_album_cover")
+ ->label(t("Choose as the album cover"))
+ ->css_class("ui-icon-star")
+ ->ajax_handler("function(data) { window.location.reload() }")
+ ->url(url::site("quick/make_album_cover/$item->id?csrf=$csrf")));
+ }
+ $options_menu
+ ->append(
+ Menu::factory("dialog")
+ ->id("delete")
+ ->label($delete_text)
+ ->css_class("ui-icon-trash")
+ ->css_class("g-quick-delete")
+ ->url(url::site("quick/form_delete/$item->id?csrf=$csrf&from_id=$theme_item->id&page_type=$page_type")));
+ }
+ }
}
if (identity::active_user()->admin) {
@@ -394,7 +474,6 @@ class gallery_event_Core {
->id("delete")
->label($delete_title)
->css_class("ui-icon-trash")
- ->css_class("g-quick-delete")
->url(url::site("quick/form_delete/$item->id?csrf=$csrf&from_id=$theme_item->id&page_type=$page_type")));
}
@@ -404,7 +483,7 @@ class gallery_event_Core {
->id("add_item")
->label(t("Add a photo"))
->css_class("ui-icon-plus")
- ->url(url::site("simple_uploader/app/$item->id")))
+ ->url(url::site("flash_uploader/app/$item->id")))
->append(Menu::factory("dialog")
->id("add_album")
->label(t("Add an album"))