--- loncom/interface/lonmenu.pm 2012/05/14 13:58:04 1.369.2.2 +++ loncom/interface/lonmenu.pm 2012/05/18 16:54:56 1.369.2.3 @@ -1,7 +1,7 @@ # The LearningOnline Network with CAPA # Routines to control the menu # -# $Id: lonmenu.pm,v 1.369.2.2 2012/05/14 13:58:04 raeburn Exp $ +# $Id: lonmenu.pm,v 1.369.2.3 2012/05/18 16:54:56 raeburn Exp $ # # Copyright Michigan State University Board of Trustees # @@ -26,8 +26,6 @@ # http://www.lon-capa.org/ # # -# There is one parameter controlling the action of this module: -# =head1 NAME @@ -35,7 +33,8 @@ Apache::lonmenu =head1 SYNOPSIS -Coordinates the response to clicking an image. +Loads contents of /home/httpd/lonTabs/mydesk.tab, +used to generate inline menu, and Main Menu page. This is part of the LearningOnline Network with CAPA project described at http://www.lon-capa.org. @@ -74,10 +73,19 @@ It is set to 'done' in the BEGIN block o =item @primary_menu The elements of this array reference arrays that are made up of the components -of those lines of mydesk.tab that start with prim. +of those lines of mydesk.tab that start with prim:. It is used by primary_menu() to generate the corresponding menu. It gets filled in the BEGIN block of this module. +=item %primary_sub_menu + +The keys of this hash reference are the names of items in the primary_menu array +which have sub-menus. For each key, the corresponding value is a reference to +an array containing components extracted from lines in mydesk.tab which begin +with primsub:. +This hash, which is used by primary_menu to generate sub-menus, is populated in +the BEGIN block. + =item @secondary_menu The elements of this array reference arrays that are made up of the components @@ -158,7 +166,7 @@ use LONCAPA qw(:DEFAULT :match); use HTML::Entities(); use vars qw(@desklines %category_names %category_members %category_positions - $readdesk @primary_menu @secondary_menu); + $readdesk @primary_menu %primary_submenu @secondary_menu); my @inlineremote; @@ -181,7 +189,7 @@ sub prep_menuitem { # primary_menu() evaluates @primary_menu and returns XHTML for the menu # that contains following links: -# About, Message, Roles, Help, Logout +# About, Message, Personal, Roles, Help, Logout # @primary_menu is filled within the BEGIN block of this module with # entries from mydesk.tab sub primary_menu { @@ -211,8 +219,53 @@ sub primary_menu { next if $$menuitem[4] eq 'courses' ##'Roles' wanted && !&Apache::loncommon::show_course(); ## - - if ($$menuitem[3] eq 'Help') { # special treatment for helplink + my $title = $menuitem->[3]; + if (defined($primary_submenu{$title})) { + my ($link,$target,$numsub); + if ($menuitem->[0] ne '') { + $link = $menuitem->[0]; + $target = '_top'; + } else { + $link = '#'; + } + if (ref($primary_submenu{$title}) eq 'ARRAY') { + $numsub = @{$primary_submenu{$title}}; + if ($numsub) { + $title = + ''.$title. + ''. + '▼'; + } + } + $menu .= '
  • '.$title.''; + if ($numsub) { + $menu .= ''; + } + $menu .= '
  • '; + } elsif ($$menuitem[3] eq 'Help') { # special treatment for helplink if ($public) { my $origmail = $Apache::lonnet::perlvar{'lonSupportEMail'}; my $defdom = &Apache::lonnet::default_login_domain(); @@ -1880,6 +1933,9 @@ BEGIN { } elsif ($configline=~/^prim\:/) { my @entries = (split(/\:/, $configline))[1..5]; push @primary_menu, \@entries; + } elsif ($configline=~/^primsub\:/) { + my ($parent,@entries) = (split(/\:/, $configline))[1..4]; + push (@{$primary_submenu{$parent}},\@entries); } elsif ($configline=~/^scnd\:/) { my @entries = (split(/\:/, $configline))[1..5]; push @secondary_menu, \@entries;