diff options
author | Bharat Mediratta <bharat@menalto.com> | 2008-12-08 06:14:34 +0000 |
---|---|---|
committer | Bharat Mediratta <bharat@menalto.com> | 2008-12-08 06:14:34 +0000 |
commit | b878ed174d9e8628098931156d526b3fc028d905 (patch) | |
tree | ae355456ce164d46a36d1a01b93f9c46a758d780 /core/helpers/core_menu.php | |
parent | 655581f3c996a6404f07486ade64d30cab335e8e (diff) |
Refactor Menu code to create allow you to create menus using a
chainable factory interface and retrieve them by ids. Streamlined the
HTML creation code a little bit in the process, moved the basic menu
functionality into Theme_View and created the option to have different
menus other than site_navigation().
Diffstat (limited to 'core/helpers/core_menu.php')
-rw-r--r-- | core/helpers/core_menu.php | 49 |
1 files changed, 35 insertions, 14 deletions
diff --git a/core/helpers/core_menu.php b/core/helpers/core_menu.php index a20f96a2..3f0c5024 100644 --- a/core/helpers/core_menu.php +++ b/core/helpers/core_menu.php @@ -18,31 +18,52 @@ * Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston, MA 02110-1301, USA. */ class core_menu_Core { - public static function items($menus, $theme) { - $menus->append(new Menu_Link(_("HOME"), url::base())); - $menus->append(new Menu_Link(_("BROWSE"), url::site("albums/1"))); + 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"))); $item = $theme->item(); $user = Session::instance()->get("user", null); if ($user) { - // @todo guard with permissions - $upload_menu = new Menu(_("UPLOAD")); - $upload_menu->append( - new Menu_Dialog(_("Add Photos"), url::site("form/add/photos/$item->id"))); - $menus->append($upload_menu); + // @todo need to do a permission check here + $menu->append( + Menu::factory("submenu") + ->id("upload_menu") + ->label(_("Upload")) + ->append( + Menu::factory("dialog") + ->id("add_photos") + ->label(_("Add Photos")) + ->url(url::site("form/add/photos/$item->id")))); - $admin_menu = new Menu(_("ADMIN")); + $admin_menu = Menu::factory("submenu") + ->id("admin_menu") + ->label(_("Admin")); + $menu->append($admin_menu); // @todo need to do a permission check here $admin_menu->append( - new Menu_Dialog(_("Edit Item"), url::site("form/edit/{$item->type}s/$item->id"))); + Menu::factory("dialog") + ->id("edit") + ->label(_("Edit")) + ->url(url::site("form/edit/{$item->type}s/$item->id"))); if ($user->admin) { - $admin_menu->append(new Menu_Link(_("Site Admin"), url::site("admin"))); + $admin_menu->append( + Menu::factory("link") + ->id("site_admin") + ->label(_("Site Admin")) + ->url(url::site("admin"))); } - - $menus->append($admin_menu); } } - } |