diff options
author | Bharat Mediratta <bharat@menalto.com> | 2008-12-18 07:32:34 +0000 |
---|---|---|
committer | Bharat Mediratta <bharat@menalto.com> | 2008-12-18 07:32:34 +0000 |
commit | c67234974d578cacfd354b103e1f166e8ea2c426 (patch) | |
tree | 208c16cc8a8d43e60e69b497cfe193d97f885974 | |
parent | aed68bfa9f68bfbc5df09135bec371b98a579671 (diff) |
Refactor site admin menu into a theme function and build the menus in
the various modules. In the process, rename xxx_menu::site_navigation() to just
xxx_menu::site(). And add xxx_menu::admin().
The menus are the same as before, but I changed the HTML to be
consistent with the way that we do it in the regular site, and this
broke the superfish styles. I don't know how to fix this.. help me
Chad!
-rw-r--r-- | core/helpers/core_menu.php | 106 | ||||
-rw-r--r-- | core/libraries/Admin_View.php | 17 | ||||
-rw-r--r-- | core/libraries/Theme_View.php | 8 | ||||
-rw-r--r-- | modules/comment/helpers/comment_menu.php | 28 | ||||
-rw-r--r-- | modules/tag/helpers/tag_menu.php | 28 | ||||
-rw-r--r-- | modules/user/helpers/user_menu.php | 18 | ||||
-rw-r--r-- | modules/watermark/helpers/watermark_menu.php | 2 | ||||
-rw-r--r-- | themes/admin_default/views/admin.html.php | 35 | ||||
-rw-r--r-- | themes/default/views/header.html.php | 2 |
9 files changed, 169 insertions, 75 deletions
diff --git a/core/helpers/core_menu.php b/core/helpers/core_menu.php index c375e8b1..674c73e2 100644 --- a/core/helpers/core_menu.php +++ b/core/helpers/core_menu.php @@ -18,18 +18,16 @@ * Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston, MA 02110-1301, USA. */ class core_menu_Core { - public static function site_navigation($menu, $theme) { - $menu->append( - Menu::factory("link") - ->id("home") - ->label(_("Home")) - ->url(url::base())); - - $menu->append( - Menu::factory("link") - ->id("browse") - ->label(_("Browse")) - ->url(url::site("albums/1"))); + public static function site($menu, $theme) { + $menu + ->append(Menu::factory("link") + ->id("home") + ->label(_("Home")) + ->url(url::base())) + ->append(Menu::factory("link") + ->id("browse") + ->label(_("Browse")) + ->url(url::site("albums/1"))); $item = $theme->item(); @@ -41,34 +39,70 @@ class core_menu_Core { } if ($item && access::can("edit", $item)) { - $menu->append( - Menu::factory("submenu") - ->id("options_menu") - ->label(_("Options")) - ->append( - Menu::factory("dialog") - ->id("add_item") - ->label(_("Add an item")) - ->url(url::site("form/add/photos/$item->id"))) - ->append( - Menu::factory("dialog") - ->id("add_album") - ->label(_("Add album")) - ->url(url::site("form/add/albums/$item->id")))); + $menu->append(Menu::factory("submenu") + ->id("options_menu") + ->label(_("Options")) + ->append(Menu::factory("dialog") + ->id("add_item") + ->label(_("Add an item")) + ->url(url::site("form/add/photos/$item->id"))) + ->append(Menu::factory("dialog") + ->id("add_album") + ->label(_("Add album")) + ->url(url::site("form/add/albums/$item->id")))); - $admin_menu->append( - Menu::factory("dialog") - ->id("edit") - ->label(_("Edit")) - ->url(url::site("form/edit/{$item->type}s/$item->id"))); + $admin_menu->append(Menu::factory("dialog") + ->id("edit") + ->label(_("Edit")) + ->url(url::site("form/edit/{$item->type}s/$item->id"))); } if (user::active()->admin) { - $admin_menu->append( - Menu::factory("link") - ->id("site_admin") - ->label(_("Site Admin")) - ->url(url::site("admin"))); + $admin_menu->append(Menu::factory("link") + ->id("site_admin") + ->label(_("Site Admin")) + ->url(url::site("admin"))); } } + + public static function admin($menu, $theme) { + $menu + ->append(Menu::factory("link") + ->id("dashboard") + ->label(_("Dashboard")) + ->url(url::site("admin/dashboard"))) + ->append(Menu::factory("link") + ->id("general_settings") + ->label(_("General Settings")) + ->url("#")) + ->append(Menu::factory("submenu") + ->id("content_menu") + ->label(_("Content"))) + ->append(Menu::factory("link") + ->id("modules") + ->label(_("Modules")) + ->url("#")) + ->append(Menu::factory("submenu") + ->id("presentation_menu") + ->label(_("Presentation")) + ->append(Menu::factory("link") + ->id("themes") + ->label(_("Themes")) + ->url("#")) + ->append(Menu::factory("link") + ->id("image_sizes") + ->label(_("Image Sizes")) + ->url("#"))) + ->append(Menu::factory("submenu") + ->id("users_groups_menu") + ->label(_("Users/Groups"))) + ->append(Menu::factory("link") + ->id("maintenance") + ->label(_("Maintenance")) + ->url("#")) + ->append(Menu::factory("link") + ->id("statistics") + ->label(_("Statistics")) + ->url("#")); + } } diff --git a/core/libraries/Admin_View.php b/core/libraries/Admin_View.php index 37ac10d1..4957fdce 100644 --- a/core/libraries/Admin_View.php +++ b/core/libraries/Admin_View.php @@ -42,4 +42,21 @@ class Admin_View_Core extends View { public function display($page_name, $view_class="View") { return new $view_class($page_name); } + + public function admin_menu() { + $menu = new Menu(true); + core_menu::admin($menu, $this); + + foreach (module::installed() as $module) { + if ($module->name == "core") { + continue; + } + $class = "{$module->name}_menu"; + if (method_exists($class, "admin")) { + call_user_func_array(array($class, "admin"), array(&$menu, $this)); + } + } + + print $menu; + } }
\ No newline at end of file diff --git a/core/libraries/Theme_View.php b/core/libraries/Theme_View.php index 933fa2c0..02609063 100644 --- a/core/libraries/Theme_View.php +++ b/core/libraries/Theme_View.php @@ -57,17 +57,17 @@ class Theme_View_Core extends View { return new $view_class($page_name); } - public function site_navigation() { + public function site_menu() { $menu = new Menu(true); - core_menu::site_navigation($menu, $this); + core_menu::site($menu, $this); foreach (module::installed() as $module) { if ($module->name == "core") { continue; } $class = "{$module->name}_menu"; - if (method_exists($class, "site_navigation")) { - call_user_func_array(array($class, "site_navigation"), array(&$menu, $this)); + if (method_exists($class, "site")) { + call_user_func_array(array($class, "site"), array(&$menu, $this)); } } diff --git a/modules/comment/helpers/comment_menu.php b/modules/comment/helpers/comment_menu.php new file mode 100644 index 00000000..b98140a6 --- /dev/null +++ b/modules/comment/helpers/comment_menu.php @@ -0,0 +1,28 @@ +<?php defined("SYSPATH") or die("No direct script access."); +/** + * Gallery - a web based photo album viewer and editor + * Copyright (C) 2000-2008 Bharat Mediratta + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or (at + * your option) any later version. + * + * This program is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston, MA 02110-1301, USA. + */ +class comment_menu_Core { + public static function admin($menu, $theme) { + $menu->get("content_menu") + ->append(Menu::factory("link") + ->id("comments") + ->label(_("Comment Moderation")) + ->url("#")); + } +} diff --git a/modules/tag/helpers/tag_menu.php b/modules/tag/helpers/tag_menu.php new file mode 100644 index 00000000..965e66c4 --- /dev/null +++ b/modules/tag/helpers/tag_menu.php @@ -0,0 +1,28 @@ +<?php defined("SYSPATH") or die("No direct script access."); +/** + * Gallery - a web based photo album viewer and editor + * Copyright (C) 2000-2008 Bharat Mediratta + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or (at + * your option) any later version. + * + * This program is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston, MA 02110-1301, USA. + */ +class tag_menu_Core { + public static function admin($menu, $theme) { + $menu->get("content_menu") + ->append(Menu::factory("link") + ->id("tags") + ->label(_("Tags")) + ->url("#")); + } +} diff --git a/modules/user/helpers/user_menu.php b/modules/user/helpers/user_menu.php index 886a873a..654a0d89 100644 --- a/modules/user/helpers/user_menu.php +++ b/modules/user/helpers/user_menu.php @@ -18,7 +18,7 @@ * Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston, MA 02110-1301, USA. */ class user_menu_Core { - public static function site_navigation($menu, $theme) { + public static function site($menu, $theme) { $user = user::active(); if (!$user->guest) { $menu->get("admin_menu")->append( @@ -28,4 +28,20 @@ class user_menu_Core { ->url(url::site("users/form/edit/$user->id"))); } } + + public static function admin($menu, $theme) { + $menu->get("users_groups_menu") + ->append(Menu::factory("link") + ->id("list_users") + ->label(_("List Users")) + ->url(url::site("admin/users"))) + ->append(Menu::factory("link") + ->id("create_user") + ->label(_("Create new user")) + ->url("#")) + ->append(Menu::factory("link") + ->id("edit_user") + ->label(_("Edit user")) + ->url("#")); + } } diff --git a/modules/watermark/helpers/watermark_menu.php b/modules/watermark/helpers/watermark_menu.php index 71927da3..9d85319d 100644 --- a/modules/watermark/helpers/watermark_menu.php +++ b/modules/watermark/helpers/watermark_menu.php @@ -20,7 +20,7 @@ class watermark_menu_Core { // @todo this needs to get on the admin page at some point - public static function site_navigation($menu, $theme) { + public static function site($menu, $theme) { $user = user::active(); if ($user->admin) { $menu->get("admin_menu")->append( diff --git a/themes/admin_default/views/admin.html.php b/themes/admin_default/views/admin.html.php index 8b3cede3..c221612f 100644 --- a/themes/admin_default/views/admin.html.php +++ b/themes/admin_default/views/admin.html.php @@ -73,38 +73,9 @@ <li id="gLogoutLink"><a href="<?= url::site("logout?continue=albums/1") ?>">Logout</a></li> </ul> <img src="<?= $theme->url("images/logo.png") ?>" id="gLogo" alt="Gallery 3: Your Photos on Your Web Site" /> - <ul id="gSiteAdminMenu" class="sf-menu sf-navbar"> - <li id="dashboard"> - <a href="<?= url::site("admin/dashboard") ?>">Dashboard</a> - <li> - <li><a href="#">General Settings</a><li> - <li class="current"><a href="#">Content</a> - <ul> - <li><a href="#">Comments</a> - <ul> - <li><a href="#">Comment moderation</a></li> - </ul> - </li> - <li><a href="#">Tags</a><li> - </ul> - </li> - <li><a href=#>Modules</a></li> - <li><a href=#>Presentation</a> - <ul> - <li><a href="#">Themes</a></li> - <li><a href="#">Image sizes</a><li> - </ul> - </li> - <li><a href="#">Users/Groups</a> - <ul> - <li><a href="<?= url::site("admin/users") ?>">List Users</a></li> - <li><a href="#">Create new user</a><li> - <li><a href="#">Edit Profile</a></li> - </ul> - </li> - <li><a href="#">Maintenance</a><li> - <li><a href="#">Statistics</a><li> - </ul> + <div id="gSiteAdminMenu" class="gClearFix"> + <?= $theme->admin_menu() ?> + </div> <!--ul id="gBreadcrumbs" class="gClearFix"> <li><a href="#">Dashboard</a></li> </ul--> diff --git a/themes/default/views/header.html.php b/themes/default/views/header.html.php index 89d105fb..d6b055e4 100644 --- a/themes/default/views/header.html.php +++ b/themes/default/views/header.html.php @@ -3,7 +3,7 @@ <img id="gLogo" alt="<?= _("Logo") ?>" src="<?= $theme->url("images/logo.png") ?>" /> <div id="gSiteMenu" class="gClearFix"> -<?= $theme->site_navigation() ?> +<?= $theme->site_menu() ?> </div> <?= $theme->header_bottom() ?> |