--- loncom/interface/lonmenu.pm 2010/12/05 17:24:13 1.309.2.22 +++ loncom/interface/lonmenu.pm 2011/01/18 19:52:46 1.344 @@ -1,7 +1,7 @@ # The LearningOnline Network with CAPA # Routines to control the menu # -# $Id: lonmenu.pm,v 1.309.2.22 2010/12/05 17:24:13 raeburn Exp $ +# $Id: lonmenu.pm,v 1.344 2011/01/18 19:52:46 www Exp $ # # Copyright Michigan State University Board of Trustees # @@ -28,8 +28,6 @@ # # There is one parameter controlling the action of this module: # -# environment.remote - if this is 'on', the routines controll the remote -# control, otherwise they render the main window controls; =head1 NAME @@ -42,48 +40,76 @@ Coordinates the response to clicking an This is part of the LearningOnline Network with CAPA project described at http://www.lon-capa.org. -=head1 SUBROUTINES +=head1 GLOBAL VARIABLES =over -Little texts +=item @desklines -=item initlittle() +Each element of this array contains a line of mydesk.tab that doesn't start with +cat, prim or scnd. +It gets filled in the BEGIN block of this module. -=item menubuttons() +=item %category_names -This gets called at the top of the body section +The keys of this hash are the abbreviations used in mydesk.tab in those lines that +start with cat, the values are strings representing titles. +It gets filled in the BEGIN block of this module. -=item show_return_link() +=item %category_members -=item registerurl() +TODO -This gets called in the header section +=item %category_positions -=item innerregister() +The keys of this hash are the abbreviations used in mydesk.tab in those lines that +start with cat, its values are position vectors (column, row). +It gets filled in the BEGIN block of this module. + +=item $readdesk + +Indicates that mydesk.tab has been read. +It is set to 'done' in the BEGIN block of this module. + +=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. +It is used by primary_menu() to generate the corresponding menu. +It gets filled in the BEGIN block of this module. + +=item @secondary_menu + +The elements of this array reference arrays that are made up of the components +of those lines of mydesk.tab that start with scnd. +It is used by secondary_menu() to generate the corresponding menu. +It gets filled in the BEGIN block of this module. -This gets called in order to register a URL, both with the Remote -and in the body of the document +=back -=item loadevents() +=head1 SUBROUTINES -=item unloadevents() +=over -=item startupremote() +=item prep_menuitems(\@menuitem) -=item setflags() +This routine wraps a menuitem in proper HTML. It is used by primary_menu() and +secondary_menu(). -=item maincall() +=item primary_menu() -=item load_remote_msg() +This routine evaluates @primary_menu and returns XHTML for the menu +that contains following links: About, Message, Roles, Help, Logout +@primary_menu is filled within the BEGIN block of this module with +entries from mydesk.tab -=item get_menu_name() +=item secondary_menu() -=item reopenmenu() +Same as primary_menu() but operates on @secondary_menu. -=item open() +=item innerregister() -Open the menu +This gets called in order to register a URL in the body of the document =item clear() @@ -101,10 +127,6 @@ The javascript is usually similar to "go =item rawconfig() -=item close() - -=item footer() - =item utilityfunctions() =item serverform() @@ -131,7 +153,6 @@ use Apache::lonhtmlcommon(); use Apache::loncommon(); use Apache::lonenc(); use Apache::lonlocal; -use Apache::loncoursequeueadmin; use LONCAPA qw(:DEFAULT :match); use HTML::Entities(); @@ -164,17 +185,12 @@ sub prep_menuitem { # entries from mydesk.tab sub primary_menu { my $menu; - my $custommenu = &Apache::loncommon::needs_gci_custom(); - my $numdc = &Apache::loncommon::check_for_gci_dc(); - my %allnums = &Apache::loncommon::get_faculty_cnums(); # each element of @primary contains following array: # (link url, icon path, alt text, link text, condition) - my ($public,$faculty); + my $public; if ((($env{'user.name'} eq 'public') && ($env{'user.domain'} eq 'public')) || (($env{'user.name'} eq '') && ($env{'user.domain'} eq ''))) { $public = 1; - } elsif (ref($allnums{$env{'user.domain'}}) eq 'HASH') { - $faculty = 1; } foreach my $menuitem (@primary_menu) { # evaluate conditions @@ -183,23 +199,12 @@ sub primary_menu { && &Apache::lonmsg::mynewmail(); # whether a new msg next if $$menuitem[4] eq 'newmsg' # arrived or not && !&Apache::lonmsg::mynewmail(); # - next if $$menuitem[4] !~ /public/ ##we've a public user, - && $public; ##who should not see all + next if $$menuitem[4] !~ /public/ ##we've a public user, + && $public; ##who should not see all ##links next if $$menuitem[4] eq 'onlypublic'# hide links which are && !$public; # only visible to public # users - next if $$menuitem[4] eq 'ci' - && (!$custommenu || $env{'request.role'} =~ m{^st\./\w+citest/}); - next if $$menuitem[4] eq 'home' - && (($custommenu) || ($env{'user.domain'} =~ /^\w+citest$/) || - ($faculty && !$numdc)); - next if $$menuitem[4] eq 'citest' - && ($faculty || ($env{'request.role'} eq 'cm')); - next if $$menuitem[4] eq 'roles' # hide links which are - && $custommenu; # not visible when GCI - next if $$menuitem[4] eq 'courses' # tabbed interface in use - && $custommenu; # next if $$menuitem[4] eq 'roles' ##show links depending on && &Apache::loncommon::show_course(); ##term 'Courses' or next if $$menuitem[4] eq 'courses' ##'Roles' wanted @@ -214,67 +219,98 @@ sub primary_menu { 'helpdeskmail', $defdom,$origmail); if ($to ne '') { - $menu .= &prep_menuitem($menuitem); + $menu .= &prep_menuitem($menuitem); } } else { $menu .= '
$link
-ENDREMOTEFORM -} - -sub get_menu_name { - my $hostid = $Apache::lonnet::perlvar{'lonHostID'}; - $hostid =~ s/\W//g; - return 'LCmenu'.$hostid; -} - - -sub reopenmenu { - if ($env{'environment.remote'} eq 'off') { return ''; } - my $menuname = &get_menu_name(); - my $nothing = &Apache::lonhtmlcommon::javascript_nothing(); - return('window.open('.$nothing.',"'.$menuname.'","",false);'); -} - - -sub open { - my $returnval=''; - if ($env{'environment.remote'} eq 'off') { - return - ''; - } - my $menuname = &get_menu_name(); - -# unless (shift eq 'unix') { -# resizing does not work on linux because of virtual desktop sizes -# $returnval.=(<';
+ for (my $row=1; $row<=8; $row++) {
+ foreach my $cat (keys(%category_members)) {
+ if ($category_positions{$cat} ne "$col,$row") { next; }
+ #$output.='
'.
- ' '.&mt('Management').''. - ''.
- ' '.
- '
'; - } else { - my $navtext = &mt('Table of Contents'); - my $navdesc = &mt('Display Table of Contents for Geoscience Concept Inventory'); - if ($env{'request.role.domain'} =~ /^\w+citest$/) { - $navtext = &mt('Display Test Contents'); - $navdesc = &mt('Display the table of contents for this Concept Test'); - } - my $navlink; - if ($env{'environment.remotenavmap'} eq 'on') { - $navlink = "javascript:gonav('/adm/navmaps');" - } else { - $navlink = '/adm/navmaps'; - } - $output .= - ' '.
- ' '.&mt('Utilities').''. - ''.
- ' ';
- if ($canreq) {
- $output .= '
'.
- ' ';
- }
- $output .= '
'; - } - } elsif ($switcher || $canreq) { - $output .= ' '. - ' '.
- ' '.&mt('Utilities').''. - ''.
- ' ';
- if ($switcher) {
- $output .= '
'.
- ' ';
- }
- $output .= '
'; - } - } elsif ($context eq 'gcinorole') { - my $queued = &Apache::loncoursequeueadmin::queued_selfenrollment('notitle'); - if ($queued) { - $output .= - ' '.
- ' ';
- }
- } else {
- # calling rawconfig with "1" will evaluate mydesk.tab,
- # even if there is no active remote control
- &rawconfig(1);
- $output=''.&mt('Pending Enrollment Requests').''. - $queued. - '
'.&mt('Set a link to wishlist').''. + ''; + + # remove all \n for inserting on javascript document.write + $in_page_wishlistlink1 =~ s/\n//g; + $in_page_wishlistlink2 =~ s/\n//g; + $in_page_wishlistlink3 =~ s/\n//g; + + my $end_page_wishlistlink = &Apache::loncommon::end_page({'js_ready' => 1}); return (< |