diff options
author | Bharat Mediratta <bharat@menalto.com> | 2009-05-29 22:28:48 -0700 |
---|---|---|
committer | Bharat Mediratta <bharat@menalto.com> | 2009-05-29 22:28:48 -0700 |
commit | f660eb55aa9535c10f91ad2812fa073589fcae2b (patch) | |
tree | 11d8727061378408bbc16ede888a058ba20542fb /modules/gallery/helpers | |
parent | 0097803efc1c71711bf9ccf5015fe43e75f8f28d (diff) | |
parent | ce285b8feba2f9c495fb153517c2a582421f50e0 (diff) |
Merge branch 'master' of git://github.com/gallery/gallery3
Diffstat (limited to 'modules/gallery/helpers')
-rw-r--r-- | modules/gallery/helpers/MY_url.php | 20 | ||||
-rw-r--r-- | modules/gallery/helpers/gallery_installer.php | 3 | ||||
-rw-r--r-- | modules/gallery/helpers/gallery_menu.php | 25 | ||||
-rw-r--r-- | modules/gallery/helpers/gallery_theme.php | 4 |
4 files changed, 35 insertions, 17 deletions
diff --git a/modules/gallery/helpers/MY_url.php b/modules/gallery/helpers/MY_url.php index 5e8bfc9e..019e416f 100644 --- a/modules/gallery/helpers/MY_url.php +++ b/modules/gallery/helpers/MY_url.php @@ -38,13 +38,19 @@ class url extends url_Core { return; } - $count = count(Router::$segments); - foreach (ORM::factory("item") - ->where("name", html_entity_decode(Router::$segments[$count - 1], ENT_QUOTES)) - ->where("level", $count + 1) - ->find_all() as $match) { - if ($match->relative_path() == html_entity_decode(Router::$current_uri, ENT_QUOTES)) { - $item = $match; + $current_uri = html_entity_decode(Router::$current_uri, ENT_QUOTES); + $item = ORM::factory("item")->where("relative_path_cache", $current_uri)->find(); + if (!$item->loaded) { + // It's possible that the relative path cache for the item we're looking for is out of date, + // so find it the hard way. + $count = count(Router::$segments); + foreach (ORM::factory("item") + ->where("name", html_entity_decode(Router::$segments[$count - 1], ENT_QUOTES)) + ->where("level", $count + 1) + ->find_all() as $match) { + if ($match->relative_path() == $current_uri) { + $item = $match; + } } } diff --git a/modules/gallery/helpers/gallery_installer.php b/modules/gallery/helpers/gallery_installer.php index fbbee194..b97adcd0 100644 --- a/modules/gallery/helpers/gallery_installer.php +++ b/modules/gallery/helpers/gallery_installer.php @@ -251,6 +251,9 @@ class gallery_installer { module::set_version("gallery", 1); module::set_var("gallery", "version", "3.0 pre-beta git"); module::set_var("gallery", "choose_default_tookit", 1); + + // @todo this string needs to be picked up by l10n_scanner + module::set_var("gallery", "credits", "Powered by <a href=\"%url\">Gallery %version</a>"); } } diff --git a/modules/gallery/helpers/gallery_menu.php b/modules/gallery/helpers/gallery_menu.php index 1dc9cb41..1f5151a3 100644 --- a/modules/gallery/helpers/gallery_menu.php +++ b/modules/gallery/helpers/gallery_menu.php @@ -19,7 +19,8 @@ */ class gallery_menu_Core { static function site($menu, $theme) { - if (file_exists(MODPATH . "gallery/controllers/scaffold.php") && user::active()->admin) { + $is_admin = user::active()->admin; + if (file_exists(MODPATH . "gallery/controllers/scaffold.php") && $is_admin) { $menu->append($scaffold_menu = Menu::factory("submenu") ->id("scaffold") ->label("Scaffold")); @@ -36,21 +37,25 @@ class gallery_menu_Core { $item = $theme->item(); - if (user::active()->admin || ($item && access::can("edit", $item))) { + $can_edit = access::can("edit", $item) || $is_admin; + $can_add = access::can("add", $item) || $is_admin; + + if ($item && $can_edit || $can_add) { $menu->append($options_menu = Menu::factory("submenu") ->id("options_menu") ->label(t("Options"))); - if ($item && access::can("edit", $item)) { + if ($can_edit) { $options_menu ->append(Menu::factory("dialog") ->id("edit_item") ->label($item->is_album() ? t("Edit album") : t("Edit photo")) ->url(url::site("form/edit/{$item->type}s/$item->id"))); + } - // @todo Move album options menu to the album quick edit pane - // @todo Create resized item quick edit pane menu - if ($item->is_album()) { + // @todo Move album options menu to the album quick edit pane + if ($item->is_album()) { + if ($can_add) { $options_menu ->append(Menu::factory("dialog") ->id("add_item") @@ -59,7 +64,11 @@ class gallery_menu_Core { ->append(Menu::factory("dialog") ->id("add_album") ->label(t("Add an album")) - ->url(url::site("form/add/albums/$item->id?type=album"))) + ->url(url::site("form/add/albums/$item->id?type=album"))); + } + + if ($can_edit) { + $options_menu ->append(Menu::factory("dialog") ->id("edit_permissions") ->label(t("Edit permissions")) @@ -68,7 +77,7 @@ class gallery_menu_Core { } } - if (user::active()->admin) { + if ($is_admin) { $menu->append($admin_menu = Menu::factory("submenu") ->id("admin_menu") ->label(t("Admin"))); diff --git a/modules/gallery/helpers/gallery_theme.php b/modules/gallery/helpers/gallery_theme.php index d45e1b98..f955e8f7 100644 --- a/modules/gallery/helpers/gallery_theme.php +++ b/modules/gallery/helpers/gallery_theme.php @@ -124,8 +124,8 @@ class gallery_theme_Core { } static function credits() { - return "<li class=\"first\">" . - t("Powered by <a href=\"%url\">Gallery %version</a>", + return "<li class=\"first\">" . + t(module::get_var("gallery", "credits"), array("url" => "http://gallery.menalto.com", "version" => module::get_var("gallery", "version"))) . "</li>"; |