diff options
author | Bharat Mediratta <bharat@menalto.com> | 2009-06-02 15:46:05 -0700 |
---|---|---|
committer | Bharat Mediratta <bharat@menalto.com> | 2009-06-02 15:46:05 -0700 |
commit | e834c4ca2434ff687461e39ee02926f449f49287 (patch) | |
tree | d718073b0f7ca7ce8f241a6feda1c9dee857e377 /modules/server_add/helpers | |
parent | ffb3abdcace93c8397e4660dc0e45d932903dd5a (diff) |
Have server_add turn the "Add Photo" menu option into a dropdown and
make "Add from Server" a 2nd option there.
This requires adding the Menu::remove() API function.
Diffstat (limited to 'modules/server_add/helpers')
-rw-r--r-- | modules/server_add/helpers/server_add_menu.php | 34 |
1 files changed, 29 insertions, 5 deletions
diff --git a/modules/server_add/helpers/server_add_menu.php b/modules/server_add/helpers/server_add_menu.php index 7269d952..a97a6cee 100644 --- a/modules/server_add/helpers/server_add_menu.php +++ b/modules/server_add/helpers/server_add_menu.php @@ -31,11 +31,35 @@ class server_add_menu_Core { $paths = unserialize(module::get_var("server_add", "authorized_paths")); if (user::active()->admin && $item->is_album() && !empty($paths)) { - $options_menu = $menu->get("options_menu") - ->append(Menu::factory("dialog") - ->id("server_add") - ->label(t("Add from server")) - ->url(url::site("server_add/index/$item->id"))); + // This is a little tricky. Normally there's an "Add Photo" menu option, but we want to + // turn that into a dropdown if there are two different ways to add things. Do that in a + // portable way for now. If we find ourselves duplicating this pattern, we should make an + // API method for this. + $server_add = Menu::factory("dialog") + ->id("server_add") + ->label(t("Add from server")) + ->url(url::site("server_add/index/$item->id")); + $options_menu = $menu->get("options_menu"); + $add_item = $options_menu->get("add_item"); + $add_menu = $options_menu->get("add_menu"); + + if ($add_item && !$add_menu) { + // Assuming that $add_menu is unset, create add_menu and add our item + $options_menu->add_after( + "add_item", + Menu::factory("submenu") + ->id("add_menu") + ->label(t("Add")) + ->append($add_item) + ->append($server_add)); + $options_menu->remove("add_item"); + } else if ($add_menu) { + // Append to the existing sub-menu + $add_menu->append($server_add); + } else { + // Else just add it in at the end of Options + $options_menu->append($server_add); + } } } } |