--- loncom/interface/lonmenu.pm 2008/03/10 23:47:35 1.235 +++ loncom/interface/lonmenu.pm 2008/12/04 08:56:28 1.246 @@ -1,7 +1,7 @@ # The LearningOnline Network with CAPA # Routines to control the menu # -# $Id: lonmenu.pm,v 1.235 2008/03/10 23:47:35 raeburn Exp $ +# $Id: lonmenu.pm,v 1.246 2008/12/04 08:56:28 tempelho 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; @@ -203,7 +299,6 @@ ENDMAINMENU - ENDINLINEMENU } $roles = ''.$lt{'roles'}.''; @@ -251,10 +346,6 @@ ENDCRELOAD } my $form=&serverform(); my $utility=&utilityfunctions(); - my $remote; - if ($env{'user.adv'}) { - $remote = ''.$lt{'launch'}.'' - } my $helplink=&Apache::loncommon::top_nav_help('Help'); return (<$helplink -$lt{'exit'} +$helplink +$lt{'exit'} $form @@ -302,7 +392,6 @@ sub show_return_link { )); } -# ====================================== This gets called in the header section sub registerurl { my ($forcereg) = @_; @@ -327,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 = ''; @@ -434,7 +520,7 @@ sub innerregister { my $action = "go('/priv/".$env{'user.name'}."');"; my $cadom = $env{'request.role.domain'}; my $caname = $env{'user.name'}; - my $desc = "Enter my resource construction space"; + my $desc = "Enter my construction space"; # Set defaults for co-authors if ($env{'request.role'} =~ /^ca/) { ($cadom,$caname)=($env{'request.role'}=~/($match_domain)\/($match_username)$/); @@ -519,9 +605,20 @@ c&8&1 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 -s&9&3&anot.gif&anno-[_1]&tations[_1]&annotate()&Make notes and annotations about 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"; + unless ($env{'request.noversionuri'}=~/\/(bulletinboard|smppg|navmaps|syllabus|aboutme)(\?|$)/) { if (!$env{'request.enc'}) { $menuitems.=(<'; + #$output.=''; + $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]) { @@ -1007,8 +1105,10 @@ sub inlinemenu { } foreach my $item (sort(keys(%active))) { $output.=$inlineremote[$item]; + &Apache::lonnet::logthis("item=$item output=$inlineremote[$item]"); } $output.='
'; + $output.=''; } } $output.=""; @@ -1426,7 +1526,7 @@ sub hidden_button_check { sub roles_selector { my ($cdom,$cnum) = @_; my $now = time; - my %courseroles; + my (%courseroles,%seccount,%gotnosection); my $is_cc; my $role_selector; if ($env{'user.role.cc./'.$cdom.'/'.$cnum}) { @@ -1443,37 +1543,69 @@ sub roles_selector { if ($is_cc) { my %adv_roles = &Apache::lonnet::get_course_adv_roles($env{'request.course.id'},1); - foreach my $role (keys(%adv_roles),'st') { + foreach my $role (keys(%adv_roles)) { my ($urole,$usec) = split(/:/,$role); - @{$courseroles{$urole}} = 'none'; + 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 { foreach my $item (keys(%env)) { - if ($item =~ m-^user\.role\.([^.]+)\./\Q$cdom\E/\Q$cnum\E(/?\w*)$-) { + if ($item =~ m-^user\.role\.([^.]+)\./\Q$cdom\E/\Q$cnum\E/?(\w*)$-) { my $role = $1; my $sec = $2; next if ($role eq 'gr'); my ($start,$end) = split(/\./,$env{$item}); next if (($start && $start > $now) || ($end && $end < $now)); if ($sec eq '') { - $sec = 'none'; + if (!$gotnosection{$role}) { + $seccount{$role} ++; + $gotnosection{$role} = 1; + } } if (ref($courseroles{$role}) eq 'ARRAY') { - if (!grep(/^Q$sec\E$/,@{$courseroles{$role}})) { - push(@{$courseroles{$role}},$sec); + if ($sec ne '') { + if (!grep(/^Q$sec\E$/,@{$courseroles{$role}})) { + push(@{$courseroles{$role}},$sec); + $seccount{$role} ++; + } } } else { - @{$courseroles{$role}} = ($sec); + @{$courseroles{$role}} = (); + if ($sec ne '') { + $seccount{$role} ++; + push(@{$courseroles{$role}},$sec); + } } } } } my @roles_order = ('cc','in','ta','ep','ad','st'); if (keys(%courseroles) > 1) { - $role_selector = &jump_to_role($cdom,$cnum); + $role_selector = &jump_to_role($cdom,$cnum,\%seccount,\%courseroles); $role_selector .= '