--- loncom/interface/lonmenu.pm 2012/05/22 16:44:06 1.374
+++ loncom/interface/lonmenu.pm 2012/05/24 22:56:30 1.375
@@ -1,7 +1,7 @@
# The LearningOnline Network with CAPA
# Routines to control the menu
#
-# $Id: lonmenu.pm,v 1.374 2012/05/22 16:44:06 bisitz Exp $
+# $Id: lonmenu.pm,v 1.375 2012/05/24 22:56:30 raeburn Exp $
#
# Copyright Michigan State University Board of Trustees
#
@@ -115,6 +115,18 @@ entries from mydesk.tab
Same as primary_menu() but operates on @secondary_menu.
+=item create_submenu()
+
+Creates XHTML for unordered list of sub-menu items which belong to a
+particular top-level menu item. Uses hover pseudo class in css to display
+dropdown list when mouse hovers over top-level item. Support for IE6
+(no hover psuedo class) via LC_hoverable class for
tag for top-
+level item, which employs jQuery to handle behavior on mouseover.
+
+Inputs: 4 - (a) link and (b) target for anchor href in top level item,
+ (c) title for text wrapped by anchor tag in top level item.
+ (d) reference to array of arrays of sub-menu items.
+
=item innerregister()
This gets called in order to register a URL in the body of the document
@@ -225,51 +237,32 @@ sub primary_menu {
my $title = $menuitem->[3];
if (defined($primary_submenu{$title})) {
- my ($link,$target,$numsub);
+ my ($link,$target);
if ($menuitem->[0] ne '') {
$link = $menuitem->[0];
$target = '_top';
} else {
$link = '#';
}
+ my @primsub;
if (ref($primary_submenu{$title}) eq 'ARRAY') {
- $numsub = @{$primary_submenu{$title}};
- if ($numsub) {
- $title =
- ''.&mt($title).
- ''.
- '▼';
+ foreach my $item (@{$primary_submenu{$title}}) {
+ next if (($item->[2] eq 'wishlist') &&
+ ((!&Apache::lonnet::allowed('bre',"/res/$env{'user.domain'}/")) &&
+ (!&Apache::lonnet::allowed('bro',"/res/$env{'user.domain'}/"))));
+ next if (($item->[2] eq 'reqcrs') && (!&check_for_rcrs()));
+ next if ((($item->[2] eq 'portfolio') ||
+ ($item->[2] eq 'blog')) &&
+ (!&Apache::lonnet::usertools_access('','',$item->[2],
+ undef,'tools')));
+ push(@primsub,$item);
}
- }
- $menu .= ''.
- ''.$title.'';
- if ($numsub) {
- $menu .= '';
- foreach my $item (@{$primary_submenu{$menuitem->[3]}}) {
- if (ref($item) eq 'ARRAY') {
- if ($item->[2] eq 'wishlist') {
- next unless ((&Apache::lonnet::allowed('bre',"/res/$env{'user.domain'}/")) ||
- (&Apache::lonnet::allowed('bro',"/res/$env{'user.domain'}/")));
- } elsif ($item->[2] eq 'reqcrs') {
- next unless(&check_for_rcrs());
- } elsif (($item->[2] eq 'portfolio') ||
- ($item->[2] eq 'blog')) {
- if (!&Apache::lonnet::usertools_access(
- $env{'user.name'},
- $env{'user.domain'},
- $item->[2],undef,'tools')) {
- next;
- }
- }
- $menu .= '- '.
- ''.
- &mt($item->[1]).'
';
- }
+ if (@primsub > 0) {
+ $menu .= &create_submenu($link,$target,$title,\@primsub);
+ } elsif ($link) {
+ $menu .= '- '.$title.'
';
}
- $menu .= '
';
}
- $menu .= '';
} elsif ($$menuitem[3] eq 'Help') { # special treatment for helplink
if ($public) {
my $origmail = $Apache::lonnet::perlvar{'lonSupportEMail'};
@@ -405,6 +398,33 @@ sub secondary_menu {
return "";
}
+sub create_submenu {
+ my ($link,$target,$title,$submenu) = @_;
+ return unless (ref($submenu) eq 'ARRAY');
+ my $menu = ''.
+ ''.
+ ''.$title.
+ ''.
+ ' ▼'.
+ '';
+ my $count = 0;
+ my $numsub = scalar(@{$submenu});
+ foreach my $item (@{$submenu}) {
+ $count ++;
+ if (ref($item) eq 'ARRAY') {
+ my $borderbot;
+ if ($count == $numsub) {
+ $borderbot = 'border-bottom:1px solid black;';
+ }
+ $menu .= '- '.
+ $item->[1].'
';
+ }
+ }
+ $menu .= '
';
+ return $menu;
+}
+
sub innerregister {
my ($forcereg,$bread_crumbs) = @_;
my $const_space = ($env{'request.state'} eq 'construct');