--- loncom/interface/lonmenu.pm 2009/05/15 20:36:17 1.239.4.5 +++ loncom/interface/lonmenu.pm 2009/02/13 20:20:30 1.252 @@ -1,7 +1,7 @@ # The LearningOnline Network with CAPA # Routines to control the menu # -# $Id: lonmenu.pm,v 1.239.4.5 2009/05/15 20:36:17 raeburn Exp $ +# $Id: lonmenu.pm,v 1.252 2009/02/13 20:20:30 schafran Exp $ # # Copyright Michigan State University Board of Trustees # @@ -36,6 +36,105 @@ # browser.interface is 'textual' # +=head1 NAME + +Apache::lonmenu + +=head1 SYNOPSIS + +Coordinates the response to clicking an image. + +This is part of the LearningOnline Network with CAPA project +described at http://www.lon-capa.org. + +=head1 SUBROUTINES + +=over + +=item show_course() + +Little texts + +=item initlittle() + +=item menubuttons() + +This gets called at the top of the body section + +=item show_return_link() + +=item registerurl() + +This gets called in the header section + +=item innerregister() + +This gets called in order to register a URL, both with the Remote +and in the body of the document + +=item loadevents() + +=item unloadevents() + +=item startupremote() + +=item setflags() + +=item maincall() + +=item load_remote_msg() + +=item get_menu_name() + +=item reopenmenu() + +=item open() + +Open the menu + +=item clear() + +=item switch() + +Switch a button or create a link +Switch acts on the javascript that is executed when a button is clicked. +The javascript is usually similar to "go('/adm/roles')" or "cstrgo(..)". + +=item secondlevel() + +=item openmenu() + +=item inlinemenu() + +=item rawconfig() + +=item close() + +=item footer() + +=item utilityfunctions() + +=item serverform() + +=item constspaceform() + +=item get_nav_status() + +=item convert_menu_function() + +FIXME this needs to move into mydesktab and the other locations +the text is generated + +=item hidden_button_check() + +=item roles_selector() + +=item jump_to_role() + +=back + +=cut + package Apache::lonmenu; use strict; @@ -53,7 +152,6 @@ my @inlineremote; -# ================================================================ Little texts sub show_course { my $course = !$env{'user.adv'}; if (!$env{'user.adv'}) { @@ -84,8 +182,6 @@ sub initlittle { ); } -# ============================= This gets called at the top of the body section - sub menubuttons { my $forcereg=shift; my $registration=shift; @@ -111,7 +207,7 @@ sub menubuttons { my $logo=&Apache::loncommon::lonhttpdurl("/adm/lonIcons/minilogo.gif"); $logo = 'LON-CAPA Logo'; + $logo.'" alt="LON-CAPA Logo" class="LC_noBorder" />'; if ($env{'request.state'} eq 'construct') { if (($env{'request.noversionuri'} eq '') || (!defined($env{'request.noversionuri'}))) { @@ -203,7 +299,6 @@ ENDMAINMENU - ENDINLINEMENU } $roles = ''.$lt{'roles'}.''; @@ -269,8 +364,8 @@ $navmaps $docs $groups $roles -$helplink -$lt{'exit'} +$helplink +$lt{'exit'} $form @@ -297,7 +392,6 @@ sub show_return_link { )); } -# ====================================== This gets called in the header section sub registerurl { my ($forcereg) = @_; @@ -322,9 +416,6 @@ sub registerurl { return $result.$force_title; } -# =========== This gets called in order to register a URL, both with the Remote -# =========== and in the body of the document - sub innerregister { my ($forcereg, $titletable) = @_; my $result = ''; @@ -515,17 +606,18 @@ c&8&2 s&8&3&prt.gif&prepare[_1]&printout[_1]&gopost('/adm/printout',currentURL)&Prepare a printable document s&9&1&sbkm.gif&set[_1]&bookmark[_2]&set_bookmark()&Set a bookmark for this resource&&1 ENDMENUITEMS - my $currentURL = &Apache::loncommon::get_symb(); - my ($symb_old,$symb_old_enc) = &Apache::loncommon::clean_symb($currentURL); - my $annotation = &Apache::loncommon::get_annotation($symb_old,$symb_old_enc); - $menuitems.="s&9&3&"; - if (length($annotation) > 0){ - $menuitems.="anot2.gif"; - } else { - $menuitems.="anot.gif"; - } - $menuitems.="&anno-[_1]&tations[_1]&annotate()&"; - $menuitems.="Make notes and annotations about this resource&&1\n"; + +my $currentURL = &Apache::loncommon::get_symb(); +my ($symb_old,$symb_old_enc) = &Apache::loncommon::clean_symb($currentURL); +my $annotation = &Apache::loncommon::get_annotation($symb_old,$symb_old_enc); +$menuitems.="s&9&3&"; +if(length($annotation) > 0){ + $menuitems.="anot2.gif"; +}else{ + $menuitems.="anot.gif"; +} +$menuitems.="&anno-[_1]&tations[_1]&annotate()&"; +$menuitems.="Make notes and annotations about this resource&&1\n"; unless ($env{'request.noversionuri'}=~/\/(bulletinboard|smppg|navmaps|syllabus|aboutme)(\?|$)/) { if (!$env{'request.enc'}) { @@ -726,7 +818,6 @@ sub unloadevents() { return 'LONCAPAstale();'; } -# ============================================================= Start up remote sub startupremote { my ($lowerurl)=@_; @@ -840,7 +931,6 @@ sub get_menu_name { return 'LCmenu'.$hostid; } -# ================================================================= Reopen menu sub reopenmenu { if (($env{'browser.interface'} eq 'textual') || @@ -850,7 +940,6 @@ sub reopenmenu { return('window.open('.$nothing.',"'.$menuname.'","",false);'); } -# =============================================================== Open the menu sub open { my $returnval=''; @@ -938,22 +1027,22 @@ sub switch { my $pic= ''.$text.''; + '" align="'.($nobreak==3?'right':'left').'" class="LC_noBorder" />'; if ($env{'browser.interface'} eq 'faketextual') { # Accessibility if ($nobreak==3) { $inlineremote[$idx]="\n". ''.$text. - ''. + ''. ''.$pic.''; } elsif ($nobreak) { $inlineremote[$idx]="\n". - ''. + ''. ''.$pic.' '.$text.''; } else { $inlineremote[$idx]="\n". - ''. + ''. ''.$pic. ''. ''.$desc.''; @@ -1000,11 +1089,14 @@ sub inlinemenu { &rawconfig(1); my $output=''; for (my $col=1; $col<=2; $col++) { - $output.='"; @@ -1135,7 +1228,22 @@ sub rawconfig { my @tools = ('aboutme','blog','portfolio'); if (grep(/^\Q$prt\E$/,@tools)) { if (!&Apache::lonnet::usertools_access($env{'user.name'}, - $env{'user.domain'},$prt)) { + $env{'user.domain'}, + $prt,undef,'tools')) { + $output.=&clear($row,$col); + next; + } + } elsif ($prt eq 'reqcrs') { + my $showreqcrs = 0; + foreach my $type ('official','unofficial') { + if (&Apache::lonnet::usertools_access($env{'user.name'}, + $env{'user.domain'}, + $type,undef,'requestcourses')) { + $showreqcrs = 1; + last; + } + } + if (!$showreqcrs) { $output.=&clear($row,$col); next; } @@ -1366,7 +1474,7 @@ function set_bookmark() { +"type='text' name='title' size=45 value='"+clienttitle+"' />" +"
Address:

<\\/center><\\/td>" +"<\\/tr><\\/table><\\/form><\\/center>" +'$end_page_bookmark' ); @@ -1444,7 +1552,7 @@ sub hidden_button_check { sub roles_selector { my ($cdom,$cnum) = @_; my $now = time; - my (%courseroles,%seccount); + my (%courseroles,%seccount,%gotnosection); my $is_cc; my $role_selector; if ($env{'user.role.cc./'.$cdom.'/'.$cnum}) { @@ -1459,9 +1567,35 @@ sub roles_selector { } } if ($is_cc) { - &get_all_courseroles($cdom,$cnum,\%courseroles,\%seccount); + my %adv_roles = + &Apache::lonnet::get_course_adv_roles($env{'request.course.id'},1); + foreach my $role (keys(%adv_roles)) { + my ($urole,$usec) = split(/:/,$role); + if (!$gotnosection{$urole}) { + $seccount{$urole} ++; + $gotnosection{$urole} = 1; + } + if (ref($courseroles{$urole}) eq 'ARRAY') { + if ($usec ne '') { + if (!grep(/^Q$usec\E$/,@{$courseroles{$urole}})) { + push(@{$courseroles{$urole}},$usec); + $seccount{$urole} ++; + } + } + } else { + @{$courseroles{$urole}} = (); + if ($usec ne '') { + $seccount{$urole} ++; + push(@{$courseroles{$urole}},$usec); + } + } + } + my %sections_count = &Apache::loncommon::get_sections($cdom,$cnum); + @{$courseroles{'st'}} = (); + if (keys(%sections_count) > 0) { + push(@{$courseroles{'st'}},keys(%sections_count)); + } } else { - my %gotnosection; foreach my $item (keys(%env)) { if ($item =~ m-^user\.role\.([^.]+)\./\Q$cdom\E/\Q$cnum\E/?(\w*)$-) { my $role = $1; @@ -1519,61 +1653,6 @@ sub roles_selector { return $role_selector; } -sub get_all_courseroles { - my ($cdom,$cnum,$courseroles,$seccount) = @_; - unless ((ref($courseroles) eq 'HASH') && (ref($seccount) eq 'HASH')) { - return; - } - my ($result,$cached) = - &Apache::lonnet::is_cached_new('getcourseroles',$cdom.'_'.$cnum); - if (defined($cached)) { - if (ref($result) eq 'HASH') { - if ((ref($result->{'roles'}) eq 'HASH') && - (ref($result->{'seccount'}) eq 'HASH')) { - %{$courseroles} = %{$result->{'roles'}}; - %{$seccount} = %{$result->{'seccount'}}; - return; - } - } - } - my %gotnosection; - my %adv_roles = - &Apache::lonnet::get_course_adv_roles($env{'request.course.id'},1); - foreach my $role (keys(%adv_roles)) { - my ($urole,$usec) = split(/:/,$role); - if (!$gotnosection{$urole}) { - $seccount->{$urole} ++; - $gotnosection{$urole} = 1; - } - if (ref($courseroles->{$urole}) eq 'ARRAY') { - if ($usec ne '') { - if (!grep(/^\Q$usec\E$/,@{$courseroles->{$urole}})) { - push(@{$courseroles->{$urole}},$usec); - $seccount->{$urole} ++; - } - } - } else { - @{$courseroles->{$urole}} = (); - if ($usec ne '') { - $seccount->{$urole} ++; - push(@{$courseroles->{$urole}},$usec); - } - } - } - my %sections_count = &Apache::loncommon::get_sections($cdom,$cnum,['st']); - @{$courseroles->{'st'}} = (); - if (keys(%sections_count) > 0) { - push(@{$courseroles->{'st'}},keys(%sections_count)); - $seccount->{'st'} = scalar(keys(%sections_count)); - } - my $rolehash = { - 'roles' => $courseroles, - 'seccount' => $seccount, - }; - &Apache::lonnet::do_cache_new('getcourseroles',$cdom.'_'.$cnum,$rolehash); - return; -} - sub jump_to_role { my ($cdom,$cnum,$seccount,$courseroles) = @_; my %lt = &Apache::lonlocal::texthash(
'; + $output.=''; for (my $row=1; $row<=8; $row++) { foreach my $cat (keys(%category_members)) { if ($category_positions{$cat} ne "$col,$row") { next; } - $output.=''; + #$output.='
'.&mt($category_names{$cat}).'
'; + $output.='
'; + $output.='

'.&mt($category_names{$cat}).'

'; + $output.='
'.&mt($category_names{$cat}).'
'; my %active=(); foreach my $menu_item (split(/\:/,$category_members{$cat})) { if ($inlineremote[$menu_item]) { @@ -1015,6 +1107,7 @@ sub inlinemenu { $output.=$inlineremote[$item]; } $output.='
'; + $output.=''; } } $output.="