--- loncom/interface/lonmenu.pm 2012/05/15 01:41:27 1.370 +++ loncom/interface/lonmenu.pm 2012/05/18 14:27:11 1.371 @@ -1,7 +1,7 @@ # The LearningOnline Network with CAPA # Routines to control the menu # -# $Id: lonmenu.pm,v 1.370 2012/05/15 01:41:27 raeburn Exp $ +# $Id: lonmenu.pm,v 1.371 2012/05/18 14:27:11 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 @@ -129,6 +137,9 @@ The javascript is usually similar to "go =item utilityfunctions() +Output from this routine is a number of javascript functions called by +items in the inline menu, and in some cases items in the Main Menu page. + =item serverform() =item constspaceform() @@ -159,7 +170,7 @@ use HTML::Entities(); use Apache::lonwishlist(); use vars qw(@desklines %category_names %category_members %category_positions - $readdesk @primary_menu @secondary_menu); + $readdesk @primary_menu %primary_submenu @secondary_menu); my @inlineremote; @@ -182,7 +193,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 { @@ -212,8 +223,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(); @@ -1687,6 +1743,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;