From: Michael M Slusarz Date: Thu, 9 Sep 2010 17:59:33 +0000 (-0600) Subject: Add Horde::menu() X-Git-Url: https://git.internetallee.de/?a=commitdiff_plain;h=7277728730e6ab11d05f3a5f0c7133315a350917;p=horde.git Add Horde::menu() Add Horde_Registry_Application#menu(), which replaces Horde_Registry_Application#prefsMenu(), and can now be used by any application call, not just prefs. If an application does not extend the menubar, all that is needed for menu creation is to define app-specific menu elements in menu() and then call 'echo Horde::menu()' within the app. --- diff --git a/agora/ban.php b/agora/ban.php index 006a55f0a..e8d057f62 100644 --- a/agora/ban.php +++ b/agora/ban.php @@ -58,7 +58,7 @@ $vars->set('action', 'add'); $form->addVariable(_("User"), 'user', 'text', true); $view = new Agora_View(); -$view->menu = Agora::getMenu('string'); +$view->menu = Horde::menu(); Horde::startBuffer(); $form->renderActive(null, null, 'ban.php', 'post'); diff --git a/agora/deleteforum.php b/agora/deleteforum.php index 81bacb9ed..cb429d6c0 100644 --- a/agora/deleteforum.php +++ b/agora/deleteforum.php @@ -69,7 +69,7 @@ if ($form->validate()) { /* Set up template variables. */ $view = new Agora_View(); -$view->menu = Agora::getMenu('string'); +$view->menu = Horde::menu(); Horde::startBuffer() $form->renderActive(null, $vars, 'deleteforum.php', 'post'); diff --git a/agora/editforum.php b/agora/editforum.php index acc012a86..7185cac4d 100644 --- a/agora/editforum.php +++ b/agora/editforum.php @@ -57,7 +57,7 @@ if ($forum_id) { /* Set up template variables. */ $view = new Agora_View(); -$view->menu = Agora::getMenu('string'); +$view->menu = Horde::menu(); Horde::startBuffer(); $form->renderActive(null, null, 'editforum.php', 'post'); diff --git a/agora/forums.php b/agora/forums.php index 7fe577fff..331ed5473 100644 --- a/agora/forums.php +++ b/agora/forums.php @@ -57,7 +57,7 @@ $col_headers = Agora::formatColumnHeaders($col_headers, $sort_by, $sort_dir, 'fo $view = new Agora_View(); $view->col_headers = $col_headers; $view->forums_list = $forums_list; -$view->menu = Agora::getMenu('string'); +$view->menu = Horde::menu(); Horde::startBuffer(); $notification->notify(array('listeners' => 'status')); diff --git a/agora/lib/Agora.php b/agora/lib/Agora.php index 60e2a0d19..174a12afc 100644 --- a/agora/lib/Agora.php +++ b/agora/lib/Agora.php @@ -233,48 +233,6 @@ class Agora { } } - function getMenu($returnType = 'object') - { - $menu = new Horde_Menu(); - $img_dir = Horde_Themes::img(); - $scope = Horde_Util::getGet('scope', 'agora'); - - /* Agora Home. */ - $url = Horde_Util::addParameter(Horde::url('forums.php'), 'scope', $scope); - $menu->add($url, _("_Forums"), 'forums.png', $img_dir, null, null, - dirname($_SERVER['PHP_SELF']) == $GLOBALS['registry']->get('webroot') && basename($_SERVER['PHP_SELF']) == 'index.php' ? 'current' : null); - - /* Thread list, if applicable. */ - if (isset($GLOBALS['forum_id'])) { - $menu->add(Agora::setAgoraId($GLOBALS['forum_id'], null, Horde::url('threads.php')), _("_Threads"), 'threads.png', Horde_Themes::img()); - if ($scope == 'agora' && $GLOBALS['registry']->getAuth()) { - $menu->add(Agora::setAgoraId($GLOBALS['forum_id'], null, Horde::url('messages/edit.php')), _("New Thread"), 'newmessage.png', Horde_Themes::img()); - } - } - - if ($scope == 'agora' && Agora_Messages::hasPermission(Horde_Perms::DELETE, 0, $scope)) { - $menu->add(Horde::url('editforum.php'), _("_New Forum"), 'newforum.png', $img_dir, null, null, Horde_Util::getFormData('agora') ? '__noselection' : null); - } - - if (Agora_Messages::hasPermission(Horde_Perms::DELETE, 0, $scope)) { - $url = Horde_Util::addParameter(Horde::url('moderate.php'), 'scope', $scope); - $menu->add($url, _("_Moderate"), 'moderate.png', $img_dir); - } - - if ($GLOBALS['registry']->isAdmin()) { - $menu->add(Horde::url('moderators.php'), _("_Moderators"), 'hot.png', $img_dir); - } - - $url = Horde_Util::addParameter(Horde::url('search.php'), 'scope', $scope); - $menu->add($url, _("_Search"), 'search.png', Horde_Themes::img(null, 'horde')); - - if ($returnType == 'object') { - return $menu; - } else { - return $menu->render(); - } - } - function validateAvatar($avatar_path) { if (!$GLOBALS['conf']['avatar']['allow_avatars'] || !$avatar_path) { diff --git a/agora/lib/Application.php b/agora/lib/Application.php index ef0f8f4cd..f5b47470c 100644 --- a/agora/lib/Application.php +++ b/agora/lib/Application.php @@ -74,6 +74,47 @@ class Agora_Application extends Horde_Registry_Application } /** + * Add additional items to the menu. + * + * @param Horde_Menu $menu The menu object. + */ + public function menu($menu) + { + $img_dir = Horde_Themes::img(); + $scope = Horde_Util::getGet('scope', 'agora'); + + /* Agora Home. */ + $url = Horde::url('forums.php')->add('scope', $scope); + $menu->add($url, _("_Forums"), 'forums.png', $img_dir, null, null, + dirname($_SERVER['PHP_SELF']) == $GLOBALS['registry']->get('webroot') && basename($_SERVER['PHP_SELF']) == 'index.php' ? 'current' : null); + + /* Thread list, if applicable. */ + if (isset($GLOBALS['forum_id'])) { + $menu->add(Agora::setAgoraId($GLOBALS['forum_id'], null, Horde::url('threads.php')), _("_Threads"), 'threads.png', Horde_Themes::img()); + if ($scope == 'agora' && $GLOBALS['registry']->getAuth()) { + $menu->add(Agora::setAgoraId($GLOBALS['forum_id'], null, Horde::url('messages/edit.php')), _("New Thread"), 'newmessage.png', Horde_Themes::img()); + } + } + + if ($scope == 'agora' && + Agora_Messages::hasPermission(Horde_Perms::DELETE, 0, $scope)) { + $menu->add(Horde::url('editforum.php'), _("_New Forum"), 'newforum.png', $img_dir, null, null, Horde_Util::getFormData('agora') ? '__noselection' : null); + } + + if (Agora_Messages::hasPermission(Horde_Perms::DELETE, 0, $scope)) { + $url = Horde::url('moderate.php')->add('scope', $scope); + $menu->add($url, _("_Moderate"), 'moderate.png', $img_dir); + } + + if ($GLOBALS['registry']->isAdmin()) { + $menu->add(Horde::url('moderators.php'), _("_Moderators"), 'hot.png', $img_dir); + } + + $url = Horde::url('search.php')->add('scope', $scope); + $menu->add($url, _("_Search"), 'search.png', Horde_Themes::img(null, 'horde')); + } + + /** * Code to run on init when viewing prefs for this application. * * @param Horde_Core_Prefs_Ui $ui The UI object. @@ -117,14 +158,4 @@ class Agora_Application extends Horde_Registry_Application return ''; } - /** - * Generate the menu to use on the prefs page. - * - * @return Horde_Menu A Horde_Menu object. - */ - public function prefsMenu() - { - return Agora::getMenu(); - } - } diff --git a/agora/messages/abuse.php b/agora/messages/abuse.php index 1ccd29b64..d1e4f44e4 100644 --- a/agora/messages/abuse.php +++ b/agora/messages/abuse.php @@ -83,7 +83,7 @@ if ($form->validate()) { /* Set up template data. */ $view = new Agora_View(); -$view->menu = Agora::getMenu('string'); +$view->menu = Horde::menu(); Horde::startBuffer(); $form->renderActive(null, $vars, 'abuse.php', 'post'); diff --git a/agora/messages/delete.php b/agora/messages/delete.php index 4d7b530d1..d5d6ca61e 100644 --- a/agora/messages/delete.php +++ b/agora/messages/delete.php @@ -73,7 +73,7 @@ $view->message_subject = $message['message_subject']; $view->message_author = $message['message_author']; $view->message_date = $messages->dateFormat($message['message_timestamp']); $view->message_body = Agora_Messages::formatBody($message['body']); -$view->menu = Agora::getMenu('string'); +$view->menu = Horde::menu(); Horde::startBuffer(); $notification->notify(array('listeners' => 'status')); diff --git a/agora/messages/edit.php b/agora/messages/edit.php index efce15603..817489c54 100644 --- a/agora/messages/edit.php +++ b/agora/messages/edit.php @@ -112,7 +112,7 @@ if ($message_parent_id) { } $view->replying = $message_parent_id; -$view->menu = Agora::getMenu('string'); +$view->menu = Horde::menu(); Horde::startBuffer(); $notification->notify(array('listeners' => 'status')); diff --git a/agora/messages/index.php b/agora/messages/index.php index 23c3771ad..991c608ee 100644 --- a/agora/messages/index.php +++ b/agora/messages/index.php @@ -180,7 +180,7 @@ default: } /* Set up the main template tags. */ -$view->menu = Agora::getMenu('string'); +$view->menu = Horde::menu(); Horde::startBuffer(); $notification->notify(array('listeners' => 'status')); diff --git a/agora/messages/lock.php b/agora/messages/lock.php index b6ffb7b10..c39eb31d0 100644 --- a/agora/messages/lock.php +++ b/agora/messages/lock.php @@ -65,7 +65,7 @@ if ($form->validate()) { /* Set up template data. */ $view = new Agora_View(); -$view->menu = Agora::getMenu('string'); +$view->menu = Horde::menu(); Horde::startBuffer(); $form->renderActive(null, $vars, 'lock.php', 'post'); diff --git a/agora/messages/merge.php b/agora/messages/merge.php index 672e8e471..bff29491f 100644 --- a/agora/messages/merge.php +++ b/agora/messages/merge.php @@ -77,7 +77,7 @@ if ($form->validate()) { /* Template object. */ $view = new Agora_View(); -$view->menu = Agora::getMenu('string'); +$view->menu = Horde::menu(); Horde::startBuffer(); $form->renderActive(null, $vars, 'merge.php', 'post'); diff --git a/agora/messages/move.php b/agora/messages/move.php index a4d72c1e5..a90ed94a4 100644 --- a/agora/messages/move.php +++ b/agora/messages/move.php @@ -63,7 +63,7 @@ if ($form->validate()) { /* Template object. */ $view = new Agora_View(); -$view->menu = Agora::getMenu('string'); +$view->menu = Horde::menu(); Horde::startBuffer(); $form->renderActive(null, $vars, 'move.php', 'post'); diff --git a/agora/messages/split.php b/agora/messages/split.php index 487c64aff..7f78a6338 100644 --- a/agora/messages/split.php +++ b/agora/messages/split.php @@ -59,7 +59,7 @@ if ($form->validate()) { /* Template object. */ $view = new Agora_View(); -$view->menu = Agora::getMenu('string'); +$view->menu = Horde::menu(); Horde::startBuffer(); $form->renderActive(null, $vars, 'split.php', 'post'); diff --git a/agora/moderate.php b/agora/moderate.php index ac002a14d..28f777846 100644 --- a/agora/moderate.php +++ b/agora/moderate.php @@ -78,7 +78,7 @@ if (isset($api_call)) { return $view->render('moderate.html.php'); } else { $title = _("Messages Awaiting Moderation"); - $view->menu = Agora::getMenu('string'); + $view->menu = Horde::menu(); Horde::addScriptFile('stripe.js', 'horde', true); require AGORA_TEMPLATES . '/common-header.inc'; echo $view->render('moderate.html.php'); diff --git a/agora/moderators.php b/agora/moderators.php index 3d431e701..903d69ac3 100644 --- a/agora/moderators.php +++ b/agora/moderators.php @@ -75,7 +75,7 @@ if ($messages->countForums() > 50) { /* Set up template data. */ $view = new Agora_View(); -$view->menu = Agora::getMenu('string'); +$view->menu = Horde::menu(); Horde::startBuffer(); $form->renderActive(null, null, 'moderators.php', 'post'); diff --git a/agora/owner.php b/agora/owner.php index 9c4d5a54a..02bafe3b3 100644 --- a/agora/owner.php +++ b/agora/owner.php @@ -23,7 +23,7 @@ $sort_dir = Agora::getSortDir('threads'); require AGORA_TEMPLATES . '/common-header.inc'; -echo ''; +echo Horde::menu(); $notification->notify(array('listeners' => 'status')); echo '

' . sprintf(_("Last posts in forums owned by %s"), $owner) . '

'; diff --git a/agora/search.php b/agora/search.php index 2a663721f..18081b757 100644 --- a/agora/search.php +++ b/agora/search.php @@ -60,7 +60,7 @@ if ($form->isSubmitted() || $thread_page != null) { $view->searchResults = $searchResults['results']; } -$view->menu = Agora::getMenu('string'); +$view->menu = Horde::menu(); Horde::startBuffer(); $notification->notify(array('listeners' => 'status')); diff --git a/agora/templates/ban.html.php b/agora/templates/ban.html.php index 0b85372bf..878be985e 100644 --- a/agora/templates/ban.html.php +++ b/agora/templates/ban.html.php @@ -1,4 +1,4 @@ - +menu; ?> notify; ?>

_arrays['forum']['forum_name']; ?>

diff --git a/agora/templates/forums.html.php b/agora/templates/forums.html.php index adf392b55..22adfdfda 100644 --- a/agora/templates/forums.html.php +++ b/agora/templates/forums.html.php @@ -1,4 +1,4 @@ - +menu; ?> notify; ?>

diff --git a/agora/templates/main.html.php b/agora/templates/main.html.php index f46a0cb77..b0a43fe59 100644 --- a/agora/templates/main.html.php +++ b/agora/templates/main.html.php @@ -1,3 +1,3 @@ - +menu; ?> notify; ?> main; ?> diff --git a/agora/templates/messages/edit.html.php b/agora/templates/messages/edit.html.php index 40f96fb72..0b17aed4a 100644 --- a/agora/templates/messages/edit.html.php +++ b/agora/templates/messages/edit.html.php @@ -1,4 +1,4 @@ - +menu; ?> notify; ?> formbox; ?> diff --git a/agora/templates/messages/form.html.php b/agora/templates/messages/form.html.php index 945b5c7c3..06a2dfa43 100644 --- a/agora/templates/messages/form.html.php +++ b/agora/templates/messages/form.html.php @@ -1,4 +1,4 @@ - +menu; ?> notify; ?> formbox; ?> diff --git a/agora/templates/messages/index.html.php b/agora/templates/messages/index.html.php index fa1ce730f..88d08f890 100644 --- a/agora/templates/messages/index.html.php +++ b/agora/templates/messages/index.html.php @@ -1,5 +1,5 @@ " href="rss ?>" type="application/rss+xml" /> - +menu; ?> notify; ?>
@@ -19,4 +19,4 @@ pager_link; ?>
-form; ?> \ No newline at end of file +form; ?> diff --git a/agora/templates/messages/message.html.php b/agora/templates/messages/message.html.php index 227b11743..f671f483d 100644 --- a/agora/templates/messages/message.html.php +++ b/agora/templates/messages/message.html.php @@ -1,4 +1,4 @@ - +menu; ?> notify; ?>
diff --git a/agora/templates/moderate.html.php b/agora/templates/moderate.html.php index 05dadc287..d8e7eacc6 100644 --- a/agora/templates/moderate.html.php +++ b/agora/templates/moderate.html.php @@ -1,5 +1,5 @@ menu)): ?> - +menu; ?> notify; ?> diff --git a/agora/templates/moderators.html.php b/agora/templates/moderators.html.php index 09944503b..126d3addc 100644 --- a/agora/templates/moderators.html.php +++ b/agora/templates/moderators.html.php @@ -1,4 +1,4 @@ - +menu; ?> notify; ?>

diff --git a/agora/templates/search.html.php b/agora/templates/search.html.php index b77618ee4..cce477561 100644 --- a/agora/templates/search.html.php +++ b/agora/templates/search.html.php @@ -1,4 +1,4 @@ - +menu; ?> notify; ?> searchResults)): ?> diff --git a/agora/templates/threads.html.php b/agora/templates/threads.html.php index 9eea3d9dd..393da5c01 100644 --- a/agora/templates/threads.html.php +++ b/agora/templates/threads.html.php @@ -1,5 +1,5 @@ " href="rss ?>" type="application/rss+xml" /> - +menu; ?> notify; ?>
diff --git a/agora/threads.php b/agora/threads.php index 08e95a3c4..b80ca5a7b 100644 --- a/agora/threads.php +++ b/agora/threads.php @@ -61,7 +61,7 @@ $view->threads = $threads_list; $view->forum_name = sprintf(_("Threads in %s"), $forum_array['forum_name']); $view->forum_description = Agora_Messages::formatBody($forum_array['forum_description']); $view->actions = $threads->getThreadActions(); -$view->menu = Agora::getMenu('string'); +$view->menu = Horde::menu(); Horde::startBuffer(); $notification->notify(array('listeners' => 'status')); diff --git a/ansel/browse.php b/ansel/browse.php index 9d671286b..ae017addb 100644 --- a/ansel/browse.php +++ b/ansel/browse.php @@ -19,7 +19,8 @@ $layout_html = $layout->toHtml(); $title = _("Photo Galleries"); Ansel_Search_Tag::clearSearch(); require ANSEL_BASE . '/templates/common-header.inc'; -require ANSEL_TEMPLATES . '/menu.inc'; +echo Horde::menu(); +$notification->notify(array('listeners' => 'status')); echo '
 
'; echo $layout_html; require $registry->get('templates', 'horde') . '/common-footer.inc'; diff --git a/ansel/browse_edit.php b/ansel/browse_edit.php index 4fab2b530..4cfaa48c8 100644 --- a/ansel/browse_edit.php +++ b/ansel/browse_edit.php @@ -24,7 +24,7 @@ if ($layout->updated()) { $title = _("My Photos :: Add Content"); require ANSEL_TEMPLATES . '/common-header.inc'; -echo ''; +echo Horde::menu(); $notification->notify(array('listeners' => 'status')); require $registry->get('templates', 'horde') . '/portal/edit.inc'; require $registry->get('templates', 'horde') . '/common-footer.inc'; diff --git a/ansel/disclamer.php b/ansel/disclamer.php index ce35904fb..eb38eb242 100644 --- a/ansel/disclamer.php +++ b/ansel/disclamer.php @@ -42,6 +42,7 @@ if ($form->isSubmitted()) { } require ANSEL_TEMPLATES . '/common-header.inc'; -require ANSEL_TEMPLATES . '/menu.inc'; +echo Horde::menu(); +$notification->notify(array('listeners' => 'status')); $form->renderActive(null, null, null, 'post'); require $registry->get('templates', 'horde') . '/common-footer.inc'; diff --git a/ansel/faces/claim.php b/ansel/faces/claim.php index b89a9e904..16600206a 100644 --- a/ansel/faces/claim.php +++ b/ansel/faces/claim.php @@ -63,6 +63,7 @@ if ($form->validate()) { } require ANSEL_TEMPLATES . '/common-header.inc'; -require ANSEL_TEMPLATES . '/menu.inc'; +echo Horde::menu(); +$notification->notify(array('listeners' => 'status')); $form->renderActive(null, null, null, 'post'); require $registry->get('templates', 'horde') . '/common-footer.inc'; diff --git a/ansel/faces/custom.php b/ansel/faces/custom.php index 9d862d9d9..623a3ac55 100644 --- a/ansel/faces/custom.php +++ b/ansel/faces/custom.php @@ -74,6 +74,7 @@ Horde::addScriptFile('cropper.js'); Horde::addScriptFile('stripe.js', 'horde'); require ANSEL_TEMPLATES . '/common-header.inc'; -require ANSEL_TEMPLATES . '/menu.inc'; +echo Horde::menu(); +$notification->notify(array('listeners' => 'status')); require ANSEL_TEMPLATES . '/faces/custom.inc'; require $registry->get('templates', 'horde') . '/common-footer.inc'; diff --git a/ansel/faces/face.php b/ansel/faces/face.php index 9c6197f62..4c4e53488 100644 --- a/ansel/faces/face.php +++ b/ansel/faces/face.php @@ -29,6 +29,7 @@ try { $title = _("Face") . ' :: ' . $face['face_name']; $facename = htmlspecialchars($face['face_name']); require ANSEL_TEMPLATES . '/common-header.inc'; -require ANSEL_TEMPLATES . '/menu.inc'; +echo Horde::menu(); +$notification->notify(array('listeners' => 'status')); require_once ANSEL_TEMPLATES . '/faces/face.inc'; require $registry->get('templates', 'horde') . '/common-footer.inc'; diff --git a/ansel/faces/gallery.php b/ansel/faces/gallery.php index f3abe8a83..044a3c4d4 100644 --- a/ansel/faces/gallery.php +++ b/ansel/faces/gallery.php @@ -60,6 +60,7 @@ $title = sprintf(_("Searching for faces in %s"),Ansel::getUrlFor('view', array(' Horde::addScriptFile('stripe.js', 'horde'); Horde::addScriptFile('popup.js', 'horde'); require ANSEL_TEMPLATES . '/common-header.inc'; -require ANSEL_TEMPLATES . '/menu.inc'; +echo Horde::menu(); +$notification->notify(array('listeners' => 'status')); require ANSEL_TEMPLATES . '/faces/gallery.inc'; require $registry->get('templates', 'horde') . '/common-footer.inc'; diff --git a/ansel/faces/report.php b/ansel/faces/report.php index 6d60fddc4..c5ef49eb5 100644 --- a/ansel/faces/report.php +++ b/ansel/faces/report.php @@ -66,8 +66,7 @@ if ($form->validate()) { } require ANSEL_TEMPLATES . '/common-header.inc'; -require ANSEL_TEMPLATES . '/menu.inc'; - +echo Horde::menu(); +$notification->notify(array('listeners' => 'status')); $form->renderActive(null, null, null, 'post'); - require $registry->get('templates', 'horde') . '/common-footer.inc'; diff --git a/ansel/faces/search/all.php b/ansel/faces/search/all.php index 4bc49be40..34df0359d 100644 --- a/ansel/faces/search/all.php +++ b/ansel/faces/search/all.php @@ -34,6 +34,7 @@ $pager = new Horde_Core_Ui_Pager( ); require ANSEL_TEMPLATES . '/common-header.inc'; -require ANSEL_TEMPLATES . '/menu.inc'; +echo Horde::menu(); +$notification->notify(array('listeners' => 'status')); include ANSEL_TEMPLATES . '/faces/faces.inc'; require $registry->get('templates', 'horde') . '/common-footer.inc'; diff --git a/ansel/faces/search/image.php b/ansel/faces/search/image.php index 909ed2bd6..3fb3bdb64 100644 --- a/ansel/faces/search/image.php +++ b/ansel/faces/search/image.php @@ -60,8 +60,8 @@ if ($form->validate()) { $title = _("Upload face photo"); require ANSEL_TEMPLATES . '/common-header.inc'; -require ANSEL_TEMPLATES . '/menu.inc'; - +echo Horde::menu(); +$notification->notify(array('listeners' => 'status')); echo $tabs->render(Horde_Util::getGet('search_faces', 'image')); $form->renderActive(null, null, null, 'post'); diff --git a/ansel/faces/search/image_define.php b/ansel/faces/search/image_define.php index 7398c935b..a6f5e789f 100644 --- a/ansel/faces/search/image_define.php +++ b/ansel/faces/search/image_define.php @@ -53,7 +53,8 @@ Horde::addScriptFile('cropper.js', 'ansel'); Horde::addScriptFile('stripe.js', 'horde'); require ANSEL_TEMPLATES . '/common-header.inc'; -require ANSEL_TEMPLATES . '/menu.inc'; +echo Horde::menu(); +$notification->notify(array('listeners' => 'status')); require ANSEL_TEMPLATES . '/faces/define.inc'; require $registry->get('templates', 'horde') . '/common-footer.inc'; diff --git a/ansel/faces/search/image_search.php b/ansel/faces/search/image_search.php index 3a59f0c2a..24a8a90c7 100644 --- a/ansel/faces/search/image_search.php +++ b/ansel/faces/search/image_search.php @@ -52,6 +52,7 @@ $pager = new Horde_Core_Ui_Pager( ); require ANSEL_TEMPLATES . '/common-header.inc'; -require ANSEL_TEMPLATES . '/menu.inc'; +echo Horde::menu(); +$notification->notify(array('listeners' => 'status')); require ANSEL_TEMPLATES . '/faces/search.inc'; require $registry->get('templates', 'horde') . '/common-footer.inc'; diff --git a/ansel/faces/search/name.php b/ansel/faces/search/name.php index 817659542..0e0387be0 100644 --- a/ansel/faces/search/name.php +++ b/ansel/faces/search/name.php @@ -42,8 +42,8 @@ $pager = new Horde_Core_Ui_Pager( $title = _("Search by name"); require ANSEL_TEMPLATES . '/common-header.inc'; -require ANSEL_TEMPLATES . '/menu.inc'; - +echo Horde::menu(); +$notification->notify(array('listeners' => 'status')); include ANSEL_TEMPLATES . '/faces/faces.inc'; require $registry->get('templates', 'horde') . '/common-footer.inc'; diff --git a/ansel/faces/search/named.php b/ansel/faces/search/named.php index c2b25289b..f225a1fe7 100644 --- a/ansel/faces/search/named.php +++ b/ansel/faces/search/named.php @@ -34,6 +34,7 @@ $pager = new Horde_Core_Ui_Pager( ); require ANSEL_TEMPLATES . '/common-header.inc'; -require ANSEL_TEMPLATES . '/menu.inc'; +echo Horde::menu(); +$notification->notify(array('listeners' => 'status')); include ANSEL_TEMPLATES . '/faces/faces.inc'; require $registry->get('templates', 'horde') . '/common-footer.inc'; diff --git a/ansel/faces/search/owner.php b/ansel/faces/search/owner.php index ba4c4c1ce..d4788cdb9 100644 --- a/ansel/faces/search/owner.php +++ b/ansel/faces/search/owner.php @@ -43,6 +43,7 @@ $pager = new Horde_Core_Ui_Pager( ); $pager->preserve('owner', $owner); require ANSEL_TEMPLATES . '/common-header.inc'; -require ANSEL_TEMPLATES . '/menu.inc'; +echo Horde::menu(); +$notification->notify(array('listeners' => 'status')); include ANSEL_TEMPLATES . '/faces/faces.inc'; require $registry->get('templates', 'horde') . '/common-footer.inc'; diff --git a/ansel/gallery.php b/ansel/gallery.php index 54e597b88..6cc9a1c29 100644 --- a/ansel/gallery.php +++ b/ansel/gallery.php @@ -287,7 +287,8 @@ case 'empty': try { $gallery = $GLOBALS['injector']->getInstance('Ansel_Storage')->getScope()->getGallery($galleryId); require ANSEL_TEMPLATES . '/common-header.inc'; - require ANSEL_TEMPLATES . '/menu.inc'; + echo Horde::menu(); + $notification->notify(array('listeners' => 'status')); require ANSEL_TEMPLATES . '/gallery/delete_confirmation.inc'; require $registry->get('templates', 'horde') . '/common-footer.inc'; exit; @@ -359,6 +360,7 @@ $injector->getInstance('Horde_Ajax_Imple')->getImple(array('ansel', 'GallerySlug 'slug' => $gallery_slug )); Horde::addScriptFile('popup.js', 'horde'); -require ANSEL_TEMPLATES . '/menu.inc'; +echo Horde::menu(); +$notification->notify(array('listeners' => 'status')); require ANSEL_TEMPLATES . '/gallery/gallery.inc'; require $registry->get('templates', 'horde') . '/common-footer.inc'; diff --git a/ansel/gallery/captions.php b/ansel/gallery/captions.php index 3657a3abd..cbf277206 100644 --- a/ansel/gallery/captions.php +++ b/ansel/gallery/captions.php @@ -58,6 +58,7 @@ case 'save': $title = _("Caption Editor"); require ANSEL_TEMPLATES . '/common-header.inc'; -require ANSEL_TEMPLATES . '/menu.inc'; +echo Horde::menu(); +$notification->notify(array('listeners' => 'status')); require ANSEL_TEMPLATES . '/captions/captions.inc'; require $registry->get('templates', 'horde') . '/common-footer.inc'; diff --git a/ansel/gallery/sort.php b/ansel/gallery/sort.php index e743d90d2..9d455ad23 100644 --- a/ansel/gallery/sort.php +++ b/ansel/gallery/sort.php @@ -66,7 +66,8 @@ Horde::addScriptFile('dragdrop.js', 'horde'); $title = sprintf(_("%s :: Sort"), $gallery->get('name')); require ANSEL_TEMPLATES . '/common-header.inc'; -require ANSEL_TEMPLATES . '/menu.inc'; +echo Horde::menu(); +$notification->notify(array('listeners' => 'status')); ?>

getCharset()) ?>

diff --git a/ansel/group.php b/ansel/group.php index 673b4924d..30f704952 100644 --- a/ansel/group.php +++ b/ansel/group.php @@ -83,7 +83,8 @@ if ($groupby !== 'none') { } require ANSEL_TEMPLATES . '/common-header.inc'; -require ANSEL_TEMPLATES . '/menu.inc'; +echo Horde::menu(); +$notification->notify(array('listeners' => 'status')); require ANSEL_TEMPLATES . '/group/header.inc'; foreach ($groups as $group) { require ANSEL_TEMPLATES . '/group/' . $groupby . '.inc'; diff --git a/ansel/image.php b/ansel/image.php index 178bbbc61..b8bcfd709 100644 --- a/ansel/image.php +++ b/ansel/image.php @@ -336,7 +336,8 @@ case 'resizeedit': } require ANSEL_TEMPLATES . '/common-header.inc'; - require ANSEL_TEMPLATES . '/menu.inc'; + echo Horde::menu(); + $notification->notify(array('listeners' => 'status')); if ($actionID == 'cropedit') { require ANSEL_TEMPLATES . '/image/crop_image.inc'; diff --git a/ansel/img/upload.php b/ansel/img/upload.php index 4a87ca209..ebb871cc9 100644 --- a/ansel/img/upload.php +++ b/ansel/img/upload.php @@ -244,6 +244,7 @@ if ($gallery->countImages() && $browser->hasFeature('javascript')) { $breadcrumbs = Ansel::getBreadCrumbs($gallery); $title = _("Add Photo"); require ANSEL_TEMPLATES . '/common-header.inc'; -require ANSEL_TEMPLATES . '/menu.inc'; +echo Horde::menu(); +$notification->notify(array('listeners' => 'status')); require ANSEL_TEMPLATES . '/image/upload.inc'; require $registry->get('templates', 'horde') . '/common-footer.inc'; diff --git a/ansel/lib/Ansel.php b/ansel/lib/Ansel.php index cba141af7..814f5be48 100644 --- a/ansel/lib/Ansel.php +++ b/ansel/lib/Ansel.php @@ -530,71 +530,6 @@ class Ansel } /** - * Build Ansel's list of menu items. - * - * @return Horde_Menu - */ - static public function getMenu() - { - global $conf, $registry; - - $menu = new Horde_Menu(); - - /* Browse/Search */ - $menu->add(Horde::url('browse.php'), _("_Browse"), - 'browse.png', null, null, null, - (($GLOBALS['prefs']->getValue('defaultview') == 'browse' && - basename($_SERVER['PHP_SELF']) == 'index.php') || - (basename($_SERVER['PHP_SELF']) == 'browse.php')) - ? 'current' - : '__noselection'); - - $menu->add(Ansel::getUrlFor('view', array('view' => 'List')), _("_Galleries"), - 'galleries.png', null, null, null, - (($GLOBALS['prefs']->getValue('defaultview') == 'galleries' && - basename($_SERVER['PHP_SELF']) == 'index.php') || - ((basename($_SERVER['PHP_SELF']) == 'group.php') && - Horde_Util::getFormData('owner') !== $GLOBALS['registry']->getAuth()) - ? 'current' - : '__noselection')); - if ($GLOBALS['registry']->getAuth()) { - $url = Ansel::getUrlFor('view', array('owner' => $GLOBALS['registry']->getAuth(), - 'groupby' => 'owner', - 'view' => 'List')); - $menu->add($url, _("_My Galleries"), 'mygalleries.png', null, null, - null, - (Horde_Util::getFormData('owner', false) == $GLOBALS['registry']->getAuth()) - ? 'current' : - '__noselection'); - } - - /* Let authenticated users create new galleries. */ - if ($GLOBALS['registry']->isAdmin() || - (!$GLOBALS['injector']->getInstance('Horde_Perms')->exists('ansel') && $GLOBALS['registry']->getAuth()) || - $GLOBALS['injector']->getInstance('Horde_Perms')->hasPermission('ansel', $GLOBALS['registry']->getAuth(), Horde_Perms::EDIT)) { - $menu->add(Horde::url('gallery.php')->add('actionID', 'add'), - _("_New Gallery"), 'add.png', null, null, null, - (basename($_SERVER['PHP_SELF']) == 'gallery.php' && - Horde_Util::getFormData('actionID') == 'add') - ? 'current' - : '__noselection'); - } - - if ($conf['faces']['driver'] && $registry->isAuthenticated()) { - $menu->add(Horde::url('faces/search/all.php'), _("_Faces"), 'user.png', Horde_Themes::img(null, 'horde')); - } - - /* Print. */ - if ($conf['menu']['print'] && ($pl = Horde_Util::nonInputVar('print_link'))) { - $menu->add($pl, _("_Print"), 'print.png', - Horde_Themes::img(null, 'horde'), '_blank', - Horde::popupJs($pl, array('urlencode' => true)) . 'return false;'); - } - - return $menu; - } - - /** * Generate a list of breadcrumbs showing where we are in the gallery * tree. * diff --git a/ansel/lib/Application.php b/ansel/lib/Application.php index f3c0a397a..c5baf8d0f 100644 --- a/ansel/lib/Application.php +++ b/ansel/lib/Application.php @@ -99,6 +99,69 @@ class Ansel_Application extends Horde_Registry_Application } /** + * Add additional items to the menu. + * + * @param Horde_Menu $menu The menu object. + */ + public function menu($menu) + { + global $conf, $registry; + + /* Browse/Search */ + $menu->add(Horde::url('browse.php'), _("_Browse"), + 'browse.png', null, null, null, + (($GLOBALS['prefs']->getValue('defaultview') == 'browse' && + basename($_SERVER['PHP_SELF']) == 'index.php') || + (basename($_SERVER['PHP_SELF']) == 'browse.php')) + ? 'current' + : '__noselection'); + + $menu->add(Ansel::getUrlFor('view', array('view' => 'List')), _("_Galleries"), + 'galleries.png', null, null, null, + (($GLOBALS['prefs']->getValue('defaultview') == 'galleries' && + basename($_SERVER['PHP_SELF']) == 'index.php') || + ((basename($_SERVER['PHP_SELF']) == 'group.php') && + Horde_Util::getFormData('owner') !== $GLOBALS['registry']->getAuth()) + ? 'current' + : '__noselection')); + + if ($GLOBALS['registry']->getAuth()) { + $url = Ansel::getUrlFor('view', array('owner' => $GLOBALS['registry']->getAuth(), + 'groupby' => 'owner', + 'view' => 'List')); + $menu->add($url, _("_My Galleries"), 'mygalleries.png', null, null, + null, + (Horde_Util::getFormData('owner', false) == $GLOBALS['registry']->getAuth()) + ? 'current' : + '__noselection'); + } + + /* Let authenticated users create new galleries. */ + if ($GLOBALS['registry']->isAdmin() || + (!$GLOBALS['injector']->getInstance('Horde_Perms')->exists('ansel') && $GLOBALS['registry']->getAuth()) || + $GLOBALS['injector']->getInstance('Horde_Perms')->hasPermission('ansel', $GLOBALS['registry']->getAuth(), Horde_Perms::EDIT)) { + $menu->add(Horde::url('gallery.php')->add('actionID', 'add'), + _("_New Gallery"), 'add.png', null, null, null, + (basename($_SERVER['PHP_SELF']) == 'gallery.php' && + Horde_Util::getFormData('actionID') == 'add') + ? 'current' + : '__noselection'); + } + + if ($conf['faces']['driver'] && $registry->isAuthenticated()) { + $menu->add(Horde::url('faces/search/all.php'), _("_Faces"), 'user.png', Horde_Themes::img(null, 'horde')); + } + + /* Print. */ + if ($conf['menu']['print'] && + ($pl = Horde_Util::nonInputVar('print_link'))) { + $menu->add($pl, _("_Print"), 'print.png', + Horde_Themes::img(null, 'horde'), '_blank', + Horde::popupJs($pl, array('urlencode' => true)) . 'return false;'); + } + } + + /** * Populate dynamically-generated preference values. * * @param Horde_Core_Prefs_Ui $ui The UI object. @@ -162,14 +225,4 @@ class Ansel_Application extends Horde_Registry_Application return false; } - /** - * Generate the menu to use on the prefs page. - * - * @return Horde_Menu A Horde_Menu object. - */ - public function prefsMenu() - { - return Ansel::getMenu(); - } - } diff --git a/ansel/protect.php b/ansel/protect.php index 875edde0a..09eab390c 100644 --- a/ansel/protect.php +++ b/ansel/protect.php @@ -39,7 +39,8 @@ if ($form->validate()) { } } require ANSEL_TEMPLATES . '/common-header.inc'; -require ANSEL_TEMPLATES . '/menu.inc'; +echo Horde::menu(); +$notification->notify(array('listeners' => 'status')); echo '
' . Ansel::getBreadCrumbs() . '
'; $form->renderActive(null, null, null, 'post'); require $registry->get('templates', 'horde') . '/common-footer.inc'; diff --git a/ansel/report.php b/ansel/report.php index f613cdfbe..2940d34cd 100644 --- a/ansel/report.php +++ b/ansel/report.php @@ -83,6 +83,7 @@ if ($form->validate()) { } require ANSEL_TEMPLATES . '/common-header.inc'; -require ANSEL_TEMPLATES . '/menu.inc'; +echo Horde::menu(); +$notification->notify(array('listeners' => 'status')); $form->renderActive(null, null, null, 'post'); require $registry->get('templates', 'horde') . '/common-footer.inc'; diff --git a/ansel/templates/menu.inc b/ansel/templates/menu.inc deleted file mode 100644 index 5a8f3cea0..000000000 --- a/ansel/templates/menu.inc +++ /dev/null @@ -1,7 +0,0 @@ - - - -notify(array('listeners' => 'status')); diff --git a/ansel/view.php b/ansel/view.php index 5c6b653c0..3f35d98ed 100644 --- a/ansel/view.php +++ b/ansel/view.php @@ -38,7 +38,8 @@ try { $view = new $view($params); } catch (Horde_Exception $e) { require ANSEL_TEMPLATES . '/common-header.inc'; - require ANSEL_TEMPLATES . '/menu.inc'; + echo Horde::menu(); + $notification->notify(array('listeners' => 'status')); echo '
' . htmlspecialchars($e->getMessage()) . ''; require $registry->get('templates', 'horde') . '/common-footer.inc'; exit; @@ -46,7 +47,8 @@ try { $title = $view->getTitle(); require ANSEL_TEMPLATES . '/common-header.inc'; -require ANSEL_TEMPLATES . '/menu.inc'; +echo Horde::menu(); +$notification->notify(array('listeners' => 'status')); $view_html = $view->html(); echo $view_html; require $registry->get('templates', 'horde') . '/common-footer.inc'; diff --git a/beatnik/lib/Application.php b/beatnik/lib/Application.php index 132fdcf0c..1b95ccaf4 100644 --- a/beatnik/lib/Application.php +++ b/beatnik/lib/Application.php @@ -97,12 +97,13 @@ class Beatnik_Application extends Horde_Registry_Application } /** - * Generate the menu to use on the prefs page. + * Add additional items to the menu. * - * @return Horde_Menu A Horde_Menu object. + * @param Horde_Menu $menu The menu object. */ - public function prefsMenu() + public function menu($menu) { return Beatnik::getMenu(); } + } diff --git a/chora/lib/Application.php b/chora/lib/Application.php index 45384746a..1fbe936e5 100644 --- a/chora/lib/Application.php +++ b/chora/lib/Application.php @@ -183,13 +183,13 @@ class Chora_Application extends Horde_Registry_Application } /** - * Generate the menu to use on the prefs page. + * Add additional items to the menu. * - * @return Horde_Menu A Horde_Menu object. + * @param Horde_Menu $menu The menu object. */ - public function prefsMenu() + public function menu($menu) { - return Chora::getMenu(); + $menu->add(Chora::url('browsedir'), _("_Browse"), 'chora.png'); } /* Sidebar method. */ diff --git a/chora/lib/Chora.php b/chora/lib/Chora.php index 76980aab6..ded0390e8 100644 --- a/chora/lib/Chora.php +++ b/chora/lib/Chora.php @@ -292,18 +292,6 @@ class Chora } /** - * Build Chora's list of menu items. - * - * @return string The menu HTML code. - */ - static public function getMenu() - { - $menu = new Horde_Menu(); - $menu->add(self::url('browsedir'), _("_Browse"), 'chora.png'); - return $menu; - } - - /** * Generate the link used for various file-based views. * * @param string $where The current file path. diff --git a/chora/templates/menu.inc b/chora/templates/menu.inc index 4e778493a..258866ff1 100644 --- a/chora/templates/menu.inc +++ b/chora/templates/menu.inc @@ -2,7 +2,7 @@
- render() ?> + true))->render() ?>
notify(array('listeners' => 'status')) ?> diff --git a/crumb/lib/Application.php b/crumb/lib/Application.php index 09040462d..d9510ec54 100644 --- a/crumb/lib/Application.php +++ b/crumb/lib/Application.php @@ -4,11 +4,11 @@ class Crumb_Application extends Horde_Registry_Application public $version = 'H4 (0.1-git)'; /** - * Generate the menu to use on the prefs page. + * Add additional items to the menu. * - * @return Horde_Menu A Horde_Menu object. + * @param Horde_Menu $menu The menu object. */ - public function prefsMenu() + public function menu($menu) { return Crumb::getMenu(); } diff --git a/fima/lib/Application.php b/fima/lib/Application.php index d969fce92..8182bc5ff 100644 --- a/fima/lib/Application.php +++ b/fima/lib/Application.php @@ -4,6 +4,16 @@ class Fima_Application extends Horde_Regsitry_Application public $version = '1.0.1'; /** + * Add additional items to the menu. + * + * @param Horde_Menu $menu The menu object. + */ + public function menu($menu) + { + return Fima::getMenu(); + } + + /** * Populate dynamically-generated preference values. * * @param Horde_Core_Prefs_Ui $ui The UI object. @@ -61,14 +71,4 @@ class Fima_Application extends Horde_Regsitry_Application } } - /** - * Generate the menu to use on the prefs page. - * - * @return Horde_Menu A Horde_Menu object. - */ - public function prefsMenu() - { - return Fima::getMenu(); - } - } diff --git a/folks/lib/Application.php b/folks/lib/Application.php index d9bca5812..afedc3325 100644 --- a/folks/lib/Application.php +++ b/folks/lib/Application.php @@ -12,11 +12,11 @@ class Folks_Application extends Horde_Registry_Application public $version = 'H4 (0.1-git)'; /** - * Generate the menu to use on the prefs page. + * Add additional items to the menu. * - * @return Horde_Menu A Horde_Menu object. + * @param Horde_Menu $menu The menu object. */ - public function prefsMenu() + public function menu($menu) { return Folks::getMenu(); } diff --git a/framework/Core/lib/Horde.php b/framework/Core/lib/Horde.php index 6cadbac2a..e0fcc2dc0 100644 --- a/framework/Core/lib/Horde.php +++ b/framework/Core/lib/Horde.php @@ -2040,4 +2040,52 @@ HTML; (!$browser->hasFeature('issafari') || $browser->getMajor() >= 2); } + /** + * Generates the menu output. + * + * @param array $opts Additional options: + *
+     * 'app' - (string) The application to generate the menu for.
+     *         DEFAULT: current application
+     * 'mask' - (integer) The Horde_Menu mask to use.
+     *          DEFAULT: Horde_Menu::MASK_ALL
+     * 'menu_ob' - (boolean) If true, returns the menu object
+     *               DEFAULT: false (renders menu)
+     * 
+ * @param string $app The application to generate the menu for. Defaults + * to the current app. + * + * @return string|Horde_Menu The menu output, or the menu object if + * 'menu_ob' is true. + */ + static public function menu(array $opts = array()) + { + global $injector, $registry; + + if (empty($opts['app'])) { + $opts['app'] = $registry->getApp(); + } + if (!isset($opts['mask'])) { + $opts['mask'] = Horde_Menu::MASK_ALL; + } + + $menu = new Horde_Menu(isset($opts['mask']) ? $opts['mask'] : Horde_Menu::MASK_ALL); + + if (!in_array($registry->get('status', 'horde'), array('notoolbar', 'hidden', 'inactive'))) { + $menu->add(Horde::url('services/portal/', false, array('app' => 'horde')), _("_Home"), 'horde.png'); + } + + $registry->callAppMethod($opts['app'], 'menu', array( + 'args' => array($menu) + )); + + if (!empty($opts['menu_ob'])) { + return $menu; + } + + self::startBuffer(); + require $registry->get('templates', 'horde') . '/menu/menu.inc'; + return self::endBuffer(); + } + } diff --git a/framework/Core/lib/Horde/Core/Prefs/Ui.php b/framework/Core/lib/Horde/Core/Prefs/Ui.php index 01a59667f..5c22625e1 100644 --- a/framework/Core/lib/Horde/Core/Prefs/Ui.php +++ b/framework/Core/lib/Horde/Core/Prefs/Ui.php @@ -529,19 +529,12 @@ class Horde_Core_Prefs_Ui /* Get the menu output before we start to output the page. * Again, this will catch any javascript inserted into the page. */ - if ($this->vars->ajaxui) { - $menu_out = ''; - } else { - if ($registry->hasAppMethod($this->app, 'prefsMenu')) { - $menu = $registry->callAppMethod($this->app, 'prefsMenu', array('args' => array($this))); - } - - /* Buffer this, as it may add javascript/stylesheets/meta tags to - * the document HEAD. */ - Horde::startBuffer(); - require $h_templates . '/menu/menu.inc'; - $menu_out = Horde::endBuffer(); - } + $menu_out = $this->vars->ajaxui + ? '' + : Horde::menu(array( + 'app' => $this->app, + 'mask' => Horde_Menu::MASK_HELP | Horde_Menu::MASK_LOGIN | Horde_Menu::MASK_PROBLEM + )); /* Get list of accessible applications. */ $apps = array(); diff --git a/framework/Core/lib/Horde/Registry/Application.php b/framework/Core/lib/Horde/Registry/Application.php index 73162a92c..197eb5eab 100644 --- a/framework/Core/lib/Horde/Registry/Application.php +++ b/framework/Core/lib/Horde/Registry/Application.php @@ -96,6 +96,15 @@ class Horde_Registry_Application { } + /** + * Add additional items to the menu. + * + * @param Horde_Menu $menu The menu object. + */ + public function menu($menu) + { + } + // Functions called from Horde's API. @@ -224,15 +233,6 @@ class Horde_Registry_Application // public function prefsCallback($ui) {} /** - * Generate the menu to use on the prefs page. - * - * @param Horde_Core_Prefs_Ui $ui The UI object. - * - * @return Horde_Menu The Horde_Menu object to display. - */ - // public function prefsMenu($ui) {} - - /** * Generate code used to display a special preference. * * @param Horde_Core_Prefs_Ui $ui The UI object. diff --git a/gollem/clipboard.php b/gollem/clipboard.php index b0fdf4da5..405dc1b6a 100644 --- a/gollem/clipboard.php +++ b/gollem/clipboard.php @@ -43,9 +43,9 @@ $template->set('entry', $entry, true); $title = _("Clipboard"); Horde::addScriptFile('tables.js', 'horde'); -Gollem::prepareMenu(); +$menu = Gollem::menu(); require GOLLEM_TEMPLATES . '/common-header.inc'; -Gollem::menu(); +echo $menu; Gollem::status(); echo $template->fetch(GOLLEM_TEMPLATES . '/clipboard/clipboard.html'); require $registry->get('templates', 'horde') . '/common-footer.inc'; diff --git a/gollem/lib/Application.php b/gollem/lib/Application.php index b1c6483b2..0032bdb81 100644 --- a/gollem/lib/Application.php +++ b/gollem/lib/Application.php @@ -159,13 +159,29 @@ class Gollem_Application extends Horde_Registry_Application } /** - * Generate the menu to use on the prefs page. + * Add additional items to the menu. * - * @return Horde_Menu A Horde_Menu object. + * @param Horde_Menu $menu The menu object. */ - public function prefsMenu() + public function menu($menu) { - return Gollem::getMenu(); + $menu->add(Horde::url('manager.php')->add('dir', Gollem::getHome()), _("_My Home"), 'folder_home.png'); + + if (!empty($_SESSION['gollem'])) { + $backend_key = $_SESSION['gollem']['backend_key']; + if ($GLOBALS['registry']->isAdmin()) { + $menu->add(Horde::url('permissions.php')->add('backend', $backend_key), _("_Permissions"), 'perms.png'); + } + + if ($_SESSION['gollem']['backends'][$backend_key]['quota_val'] != -1) { + if ($GLOBALS['browser']->hasFeature('javascript')) { + $quota_url = 'javascript:' . Horde::popupJs(Horde::url('quota.php'), array('params' => array('backend' => $backend_key), 'height' => 300, 'width' => 300, 'urlencode' => true)); + } else { + $quota_url = Horde::url('quota.php')->add('backend', $backend_key); + } + $menu->add($quota_url, _("Check Quota"), 'info_icon.png'); + } + } } /* Sidebar method. */ diff --git a/gollem/lib/Gollem.php b/gollem/lib/Gollem.php index e054245fe..ea01bd7f3 100644 --- a/gollem/lib/Gollem.php +++ b/gollem/lib/Gollem.php @@ -26,13 +26,6 @@ class Gollem const SORT_DESCEND = 1; /** - * prepareMenu() cache. - * - * @var array - */ - static private $_menu = null; - - /** * Changes the current directory of the Gollem session to the supplied * value. * @@ -646,44 +639,12 @@ class Gollem } /** - * Build Gollem's list of menu items. + * Build Gollem's menu. * - * @return Horde_Menu A Horde_Menu object. + * @return string Menu. */ - static public function getMenu() - { - $menu = new Horde_Menu(); - - $menu->add(Horde::url('manager.php')->add('dir', Gollem::getHome()), _("_My Home"), 'folder_home.png'); - - if (!empty($_SESSION['gollem'])) { - $backend_key = $_SESSION['gollem']['backend_key']; - if ($GLOBALS['registry']->isAdmin()) { - $menu->add(Horde::url('permissions.php')->add('backend', $backend_key), _("_Permissions"), 'perms.png'); - } - - if ($_SESSION['gollem']['backends'][$backend_key]['quota_val'] != -1) { - if ($GLOBALS['browser']->hasFeature('javascript')) { - $quota_url = 'javascript:' . Horde::popupJs(Horde::url('quota.php'), array('params' => array('backend' => $backend_key), 'height' => 300, 'width' => 300, 'urlencode' => true)); - } else { - $quota_url = Horde::url('quota.php')->add('backend', $backend_key); - } - $menu->add($quota_url, _("Check Quota"), 'info_icon.png'); - } - } - - return $menu; - } - - /** - * Build Gollem's list of menu items. - */ - static public function prepareMenu() + static public function menu() { - if (isset(self::$_menu)) { - return; - } - $t = $GLOBALS['injector']->createInstance('Horde_Template'); $t->set('forminput', Horde_Util::formInput()); @@ -694,24 +655,15 @@ class Gollem $link = Horde::link('#', _("Change Server"), '', '', 'serverSubmit(true);return false;'); $t->set('slink', sprintf('
  • %s%s
    %s
', $link, ($menu_view != 'text') ? Horde::img('gollem.png') : '', ($menu_view != 'icon') ? Horde::highlightAccessKey(_("_Change Server"), $t->get('accesskey')) : '')); } - $t->set('menu_string', self::getMenu()->render()); + $t->set('menu_string', Horde::menu(array('menu_ob' => true))->render()); - self::$_menu = $t->fetch(GOLLEM_TEMPLATES . '/menu/menu.html'); + $menu = $t->fetch(GOLLEM_TEMPLATES . '/menu/menu.html'); /* Need to buffer sidebar output here, because it may add things like * cookies which need to be sent before output begins. */ Horde::startBuffer(); require HORDE_BASE . '/services/sidebar.php'; - self::$_menu .= Horde::endBuffer(); - } - - /** - * Outputs Gollem's menu to the current output stream. - */ - static public function menu() - { - self::prepareMenu(); - echo self::$_menu; + return $menu .= Horde::endBuffer(); } /** diff --git a/gollem/manager.php b/gollem/manager.php index 8fb6ba701..478768e3b 100644 --- a/gollem/manager.php +++ b/gollem/manager.php @@ -584,9 +584,9 @@ Horde::addInlineJsVars(array( '-warn_recursive' => intval($prefs->getValue('recursive_deletes') == 'warn') )); -Gollem::prepareMenu(); +$menu = Gollem::menu(); require GOLLEM_TEMPLATES . '/common-header.inc'; -Gollem::menu(); +echo $menu; Gollem::status(); echo $template->fetch(GOLLEM_TEMPLATES . '/manager/manager.html'); require $registry->get('templates', 'horde') . '/common-footer.inc'; diff --git a/gollem/permissions.php b/gollem/permissions.php index ba629e4f9..0021031df 100644 --- a/gollem/permissions.php +++ b/gollem/permissions.php @@ -20,9 +20,9 @@ if (!Gollem::getBackends('all')) { $notification->push(_("You need at least one backend defined to set permissions."), 'horde.error'); $title = _("Gollem Backend Permissions Administration"); - Gollem::prepareMenu(); + $menu = Gollem::menu(); require GOLLEM_TEMPLATES . '/common-header.inc'; - Gollem::menu(); + echo $menu; Gollem::status(); require $registry->get('templates', 'horde') . '/common-footer.inc'; exit; diff --git a/horde/services/portal/edit.php b/horde/services/portal/edit.php index 95c6e5299..2de9abf83 100644 --- a/horde/services/portal/edit.php +++ b/horde/services/portal/edit.php @@ -35,7 +35,7 @@ if ($layout->updated()) { $title = _("My Portal Layout"); require HORDE_TEMPLATES . '/common-header.inc'; -require HORDE_TEMPLATES . '/menu/menu.inc'; +echo Horde::menu(); $notification->notify(array('listeners' => 'status')); require HORDE_TEMPLATES . '/portal/edit.inc'; require HORDE_TEMPLATES . '/common-footer.inc'; diff --git a/horde/services/portal/index.php b/horde/services/portal/index.php index 78c15cfc2..e2eb0c7ef 100644 --- a/horde/services/portal/index.php +++ b/horde/services/portal/index.php @@ -61,7 +61,7 @@ $linkTags = $view->getLinkTags(); Horde::addScriptFile('prototype.js', 'horde'); $title = _("My Portal"); require HORDE_TEMPLATES . '/common-header.inc'; -require HORDE_TEMPLATES . '/menu/menu.inc'; +echo Horde::menu(); echo '