--- loncom/interface/lonmenu.pm 2011/11/27 20:55:58 1.362 +++ loncom/interface/lonmenu.pm 2012/05/21 16:24:14 1.372 @@ -1,7 +1,7 @@ # The LearningOnline Network with CAPA # Routines to control the menu # -# $Id: lonmenu.pm,v 1.362 2011/11/27 20:55:58 www Exp $ +# $Id: lonmenu.pm,v 1.372 2012/05/21 16:24:14 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,54 @@ 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(); @@ -428,7 +485,7 @@ sub innerregister { "gocmd('/adm/parmset','set')", 'Content Settings'); } - if ($env{'request.symb'} ne '' && + if ($env{'request.symb'}=~/^uploaded/ && &Apache::lonnet::allowed('mdc',$crs)) { $hwkadd.=&switch('','',7,4,'docs.png','Folder/Page Content','parms[_2]', "gocmd('/adm/coursedocs','direct')", @@ -633,7 +690,7 @@ ENDMENUITEMS # wishlist is only available for users with access to resource-pool # and links can only be set for resources within the resource-pool $menuitems .= (<'; + document.getElementById('dccidtext').innerHTML ='$lt{'less'}'; return; } function hideCourseID() { document.getElementById('dccid').style.display='none'; - document.getElementById('dccidtext').innerHTML ='$lt{'more'}'; + document.getElementById('dccidtext').innerHTML ='$lt{'more'}'; return; } @@ -1132,12 +1189,14 @@ sub utilityfunctions { my $confirm_switch = &mt("Editing requires switching to the resource's home server.").'\n'. &mt('Switch server?'); + my $esc_url=&escape($currenturl); + my $esc_symb=&escape($currentsymb); return (< 'cst', '/adm/trackstudent' => 'vsa', '/adm/statistics' => 'vgr', + '/adm/setblock' => 'dcm', + '/adm/coursedocs' => 'mdc', }; unless ($env{'course.'.$env{'request.course.id'}.'.grading'} eq 'spreadsheet') { - $privs->{'/adm/classcalc'} => 'vgr', - $privs->{'/adm/assesscalc'} => 'vgr', - $privs->{'/adm/studentcalc'} => 'vgr'; + $privs->{'/adm/classcalc'} = 'vgr', + $privs->{'/adm/assesscalc'} = 'vgr', + $privs->{'/adm/studentcalc'} = 'vgr'; } return $privs; } @@ -1695,6 +1758,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;