--- loncom/interface/lonmenu.pm 2009/05/20 20:11:35 1.244.2.1 +++ loncom/interface/lonmenu.pm 2009/07/13 08:24:21 1.275 @@ -1,7 +1,7 @@ # The LearningOnline Network with CAPA # Routines to control the menu # -# $Id: lonmenu.pm,v 1.244.2.1 2009/05/20 20:11:35 raeburn Exp $ +# $Id: lonmenu.pm,v 1.275 2009/07/13 08:24:21 www Exp $ # # Copyright Michigan State University Board of Trustees # @@ -26,15 +26,10 @@ # http://www.lon-capa.org/ # # -# There are two parameters controlling the action of this module: -# -# browser.interface - if this is 'textual', it overrides the second parameter -# and goes to screen reader PDA mode +# 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; ignored it -# browser.interface is 'textual' -# +# control, otherwise they render the main window controls; =head1 NAME @@ -51,8 +46,6 @@ described at http://www.lon-capa.org. =over -=item show_course() - Little texts =item initlittle() @@ -150,21 +143,9 @@ use vars qw(@desklines %category_names % my @inlineremote; - - -sub show_course { - my $course = !$env{'user.adv'}; - if (!$env{'user.adv'}) { - foreach my $env (keys(%env)) { - next if ($env !~ m/^user\.priv\./); - if ($env !~ m/^user\.priv\.(?:st|cm)/) { - $course = 0; - last; - } - } - } - return $course; -} +# +# This routine returns a translated hash for the menu items in the top inline menu row +# Probably should be in mydesk.tab sub initlittle { return &Apache::lonlocal::texthash('ret' => 'Return to Last Location', @@ -186,6 +167,9 @@ sub menubuttons { my $forcereg=shift; my $registration=shift; my $titletable=shift; +# +# Early-out for pages that should not have a menu, triggered by query string "inhibitmenu=yes" +# &Apache::loncommon::get_unprocessed_cgi($ENV{'QUERY_STRING'}, ['inhibitmenu']); if (($env{'form.inhibitmenu'} eq 'yes') || @@ -202,14 +186,20 @@ sub menubuttons { my $role_selector; my $showgroups=0; my ($cnum,$cdom); +# +# if the URL is hidden, symbs and the non-versioned version of the URL would be encrypted +# my $escurl=&escape(&Apache::lonenc::check_encrypt($env{'request.noversionuri'})); my $escsymb=&escape(&Apache::lonenc::check_encrypt($env{'request.symb'})); my $logo=&Apache::loncommon::lonhttpdurl("/adm/lonIcons/minilogo.gif"); - $logo = 'LON-CAPA Logo'; + $logo = 'LON-CAPA Logo'; if ($env{'request.state'} eq 'construct') { +# +# We are in construction space +# if (($env{'request.noversionuri'} eq '') || (!defined($env{'request.noversionuri'}))) { my $returnurl = $env{'request.filename'}; $returnurl =~ s:^/home/([^/]+)/public_html/(.*)$:/priv/$1/$2:; @@ -217,6 +207,9 @@ sub menubuttons { } } if ($env{'request.course.id'}) { +# +# We are in a course +# $cnum = $env{'course.'.$env{'request.course.id'}.'.num'}; $cdom = $env{'course.'.$env{'request.course.id'}.'.domain'}; my %coursegroups; @@ -234,75 +227,28 @@ sub menubuttons { } } - if ($env{'browser.interface'} eq 'textual') { -# Textual display only - if ($env{'request.course.id'}) { - $navmaps=(<$lt{'nav'} -ENDNAV - if (&show_return_link()) { - my $escreload=&escape('return:'); - $reloadlink=(<$lt{'ret'} -ENDRELOAD - } - if (&Apache::lonnet::allowed('mdc',$env{'request.course.id'})) { - $docs=(<$lt{'docs'} -ENDDOCS - } - if ($showgroups) { - $groups =(<$lt{'groups'} -ENDGROUPS - } - } - my $form=&serverform(); - my $utility=&utilityfunctions(); - my $output=(< -// BEGIN LON-CAPA Internal -$utility - -
-$lt{'main'} -$reloadlink $navmaps $docs $groups $roles -$lt{'exit'} -
-
- -$form -ENDMAINMENU - if ($registration) { $output.=&innerregister($forcereg); } - return $output."
"; - } elsif ($env{'environment.remote'} eq 'off') { + if ($env{'environment.remote'} eq 'off') { # Remote Control is switched off # figure out colors - my %lt=&initlittle(); + my %lt=&initlittle(); my $domain=&Apache::loncommon::determinedomain(); - my $function =&Apache::loncommon::get_users_function(); + my $function =&Apache::loncommon::get_users_function(); my $link=&Apache::loncommon::designparm($function.'.link',$domain); my $alink=&Apache::loncommon::designparm($function.'.alink',$domain); my $vlink=&Apache::loncommon::designparm($function.'.vlink',$domain); my $sidebg=&Apache::loncommon::designparm($function.'.sidebg',$domain); - if ($env{'user.name'} eq 'public' && $env{'user.domain'} eq 'public') { - return (< - - $logo - - - $lt{'login'} - - - - + + if ($env{'user.name'} eq 'public' && $env{'user.domain'} eq 'public') { + return (< +
  • $logo
  • +
  • $lt{'login'}
  • + +
    ENDINLINEMENU } - $roles = ''.$lt{'roles'}.''; + $roles = ''.$lt{'roles'}.''; # Do we have a NAV link? if ($env{'request.course.id'}) { my $link='/adm/navmaps?postdata='.$escurl.'&postsymb='. @@ -311,34 +257,35 @@ ENDINLINEMENU $link="javascript:gonav('".$link."')"; } $navmaps=(<$lt{'nav'} +
  • $lt{'nav'}
  • ENDNAV my $is_group = (&Apache::loncommon::course_type() eq 'Group'); if (&Apache::lonnet::allowed('mdc',$env{'request.course.id'})) { my $text = ($is_group) ? $lt{'gdoc'} : $lt{'docs'}; $docs=(<$text +
  • $text
  • ENDDOCS } if ($showgroups) { $groups =(<$lt{'groups'} +
  • $lt{'groups'}
  • ENDGROUPS } if (&show_return_link()) { my $escreload=&escape('return:'); $reloadlink=(<$lt{'ret'} +
  • $lt{'ret'}
  • ENDRELOAD } if ($role_selector) { - $roles = ''.$role_selector.''.$lt{'other'}.''; + #$roles = ''.$role_selector.''.$lt{'other'}.''; + $role_selector = '
  • '.$role_selector.'
  • '; } } if (($env{'request.state'} eq 'construct') && ($env{'request.course.id'})) { my $escreload=&escape('return:'); $reloadlink=(<$lt{'ret'} +
  • $lt{'ret'}
  • ENDCRELOAD } my $reg=''; @@ -348,6 +295,12 @@ ENDCRELOAD my $form=&serverform(); my $utility=&utilityfunctions(); + my $messagelink = ""; + if(&Apache::lonmsg::mynewmail()){ + $messagelink = 'Message(new)' + }else{ + $messagelink = 'Message' + } my $helplink=&Apache::loncommon::top_nav_help('Help'); return (< @@ -356,19 +309,21 @@ ENDCRELOAD $utility // ]]> - - -$logo - +
      +
    1. $logo
    2. +
    3. $messagelink
    4. +
    5. $roles
    6. +
    7. $helplink
    8. +
    9. $lt{'exit'}
    10. +
    +
      +
    • $lt{'main'}
    • $reloadlink $navmaps $docs $groups -$roles -
    - - -
    $lt{'main'}$helplink$lt{'exit'}
    +$role_selector + $form $timesync +$breadcrumb $tablestart $inlinebuttons $tableend @@ -791,9 +757,9 @@ ENDREGTHIS # ============================================================================= } else { # ========================================== This can or will not be registered - if ($textual) { -# Not registered, textual - $result= (<'); } # @@ -959,8 +924,7 @@ ENDSETFLAGS } sub maincall() { - if (($env{'browser.interface'} eq 'textual') || - ($env{'environment.remote'} eq 'off')) { return ''; } + if ($env{'environment.remote'} eq 'off') { return ''; } return(< main(); @@ -971,13 +935,12 @@ ENDMAINCALL sub load_remote_msg { my ($lowerurl)=@_; - if (($env{'browser.interface'} eq 'textual') || - ($env{'environment.remote'} eq 'off')) { return ''; } + if ($env{'environment.remote'} eq 'off') { return ''; } my $esclowerurl=&escape($lowerurl); - my $link=&mt('[_1]Continue[_2] on in Inline Menu mode', - '', - ''); + my $link=&mt('[_1]Continue[_2] on in Inline Menu mode' + ,'' + ,''); return(<
    @@ -996,8 +959,7 @@ sub get_menu_name { sub reopenmenu { - if (($env{'browser.interface'} eq 'textual') || - ($env{'environment.remote'} eq 'off')) { return ''; } + if ($env{'environment.remote'} eq 'off') { return ''; } my $menuname = &get_menu_name(); my $nothing = &Apache::lonhtmlcommon::javascript_nothing(); return('window.open('.$nothing.',"'.$menuname.'","",false);'); @@ -1006,8 +968,7 @@ sub reopenmenu { sub open { my $returnval=''; - if (($env{'browser.interface'} eq 'textual') || - ($env{'environment.remote'} eq 'off')) { + if ($env{'environment.remote'} eq 'off') { return ''; } my $menuname = &get_menu_name(); @@ -1023,7 +984,7 @@ sub open { # } $returnval.=(<13)) { return ''; } return "\n".qq(window.status+='.';swmenu.clearbut($row,$col);); } else { $inlineremote[10*$row+$col]=''; @@ -1061,23 +1022,11 @@ sub switch { my $idx=10*$row+$col; $category_members{$cat}.=':'.$idx; - unless (($env{'browser.interface'} eq 'textual') || - ($env{'environment.remote'} eq 'off')) { + unless ($env{'environment.remote'} eq 'off') { + if (($row<1) || ($row>13)) { return ''; } # Remote return "\n". qq(window.status+='.';swmenu.switchbutton($row,$col,"$img","$top","$bot","$act","$desc");); - } elsif ($env{'browser.interface'} eq 'textual') { -# Accessibility - if ($nobreak==2) { return ''; } - my $text=$top.' '.$bot; - $text=~s/\s*\-\s*//gs; - if ($nobreak) { - $inlineremote[$idx]= - ''.$text.''; - } else { - $inlineremote[$idx]="\n
    ". - $desc.' '.$text.''; - } } else { # Inline Remote if ($env{'environment.icons'} ne 'classic') { @@ -1090,22 +1039,22 @@ sub switch { my $pic= ''.$text.''; + '" align="'.($nobreak==3?'right':'left').'" class="LC_noBorder" />'; if ($env{'browser.interface'} eq 'faketextual') { -# Accessibility +# Main Menu if ($nobreak==3) { $inlineremote[$idx]="\n". ''.$text. - ''. + ''. ''.$pic.''; } elsif ($nobreak) { $inlineremote[$idx]="\n". - ''. + ''. ''.$pic.' '.$text.''; } else { $inlineremote[$idx]="\n". - ''. + ''. ''.$pic. ''. ''.$desc.''; @@ -1140,8 +1089,7 @@ sub secondlevel { sub openmenu { my $menuname = &get_menu_name(); - if (($env{'browser.interface'} eq 'textual') || - ($env{'environment.remote'} eq 'off')) { return ''; } + if ($env{'environment.remote'} eq 'off') { return ''; } my $nothing = &Apache::lonhtmlcommon::javascript_nothing(); return "window.open(".$nothing.",'".$menuname."');"; } @@ -1149,6 +1097,7 @@ sub openmenu { sub inlinemenu { undef(@inlineremote); undef(%category_members); +# calling rawconfig with "1" will evaluate mydesk.tab, even if there is no active remote control &rawconfig(1); my $output=''; for (my $col=1; $col<=2; $col++) { @@ -1156,10 +1105,10 @@ sub inlinemenu { for (my $row=1; $row<=8; $row++) { foreach my $cat (keys(%category_members)) { if ($category_positions{$cat} ne "$col,$row") { next; } - #$output.='
    '; - $output.='
    '; - $output.=''.&mt($category_names{$cat}).''; - $output.='
    '.&mt($category_names{$cat}).'
    '; + #$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]) { @@ -1168,10 +1117,9 @@ sub inlinemenu { } foreach my $item (sort(keys(%active))) { $output.=$inlineremote[$item]; - &Apache::lonnet::logthis("item=$item output=$inlineremote[$item]"); } $output.='
    '; - $output.=''; + $output.=''; } } $output.=""; @@ -1181,10 +1129,14 @@ sub inlinemenu { } sub rawconfig { +# +# This evaluates mydesk.tab +# Need to add more positions and more privileges to deal with all +# menu items. +# my $textualoverride=shift; my $output=''; - unless (($env{'browser.interface'} eq 'textual') || - ($env{'environment.remote'} eq 'off')) { + unless ($env{'environment.remote'} eq 'off') { $output.= "window.status='Opening Remote Control';var swmenu=".&openmenu(). "\nwindow.status='Configuring Remote Control ';"; @@ -1216,9 +1168,12 @@ sub rawconfig { $prt=~s/\$requested_domain/$requested_domain/g; if ($category_names{$cat}!~/\w/) { $cat='oth'; } my $type = &Apache::loncommon::course_type(); - if ($type eq 'Group') { - $desc = &convert_menu_function($desc,$type); - } +# +# I don't think we support this +# +# if ($type eq 'Group') { +# $desc = &convert_menu_function($desc,$type); +# } if ($pro eq 'clear') { $output.=&clear($row,$col); } elsif ($pro eq 'any') { @@ -1315,11 +1270,9 @@ sub rawconfig { $prt='any'; $output.=&secondlevel( $uname,$udom,$rol,$crs,$pub,$con,$row,$col,$prt,$img,$top,$bot,$act,$desc,$cat); - } } - unless (($env{'browser.interface'} eq 'textual') || - ($env{'environment.remote'} eq 'off')) { + unless ($env{'environment.remote'} eq 'off') { $output.="\nwindow.status='Synchronizing Time';swmenu.syncclock(1000*".time.");\nwindow.status='Remote Control Configured.';"; if (&Apache::lonmsg::newmail()) { $output.='swmenu.setstatus("you have","messages");'; @@ -1332,8 +1285,7 @@ sub rawconfig { # ======================================================================= Close sub close { - if (($env{'browser.interface'} eq 'textual') || - ($env{'environment.remote'} eq 'off')) { return ''; } + if ($env{'environment.remote'} eq 'off') { return ''; } my $menuname = &get_menu_name(); return(< @@ -1375,8 +1327,10 @@ NAVCONTROL sub utilityfunctions { my $caller = shift; - unless (($env{'browser.interface'} eq 'textual') || - ($env{'environment.remote'} eq 'off') || ($caller eq '/adm/menu')) { return ''; } + unless ($env{'environment.remote'} eq 'off' || + $caller eq '/adm/menu') { + return ''; } + my $currenturl=&Apache::lonnet::clutter(&Apache::lonnet::fixversion((split(/\?/,$env{'request.noversionuri'}))[0])); $currenturl=&Apache::lonenc::check_encrypt(&unescape($currenturl)); @@ -1535,7 +1489,7 @@ function set_bookmark() { +'
    Link Name:
    Link Name:
    ' +'
    Address:

    {'roles'}) eq 'HASH') && + if ((ref($result->{'roles'}) eq 'HASH') && (ref($result->{'seccount'}) eq 'HASH')) { %{$courseroles} = %{$result->{'roles'}}; %{$seccount} = %{$result->{'seccount'}}; @@ -1720,7 +1677,7 @@ sub get_all_courseroles { } if (ref($courseroles->{$urole}) eq 'ARRAY') { if ($usec ne '') { - if (!grep(/^\Q$usec\E$/,@{$courseroles->{$urole}})) { + if (!grep(/^Q$usec\E$/,@{$courseroles->{$urole}})) { push(@{$courseroles->{$urole}},$usec); $seccount->{$urole} ++; } @@ -1737,7 +1694,7 @@ sub get_all_courseroles { @{$courseroles->{'st'}} = (); if (keys(%sections_count) > 0) { push(@{$courseroles->{'st'}},keys(%sections_count)); - $seccount->{'st'} = scalar(keys(%sections_count)); + $seccount->{'st'} = scalar(keys(%sections_count)); } my $rolehash = { 'roles' => $courseroles, @@ -1778,8 +1735,9 @@ sub jump_to_role { ' numsec['.$i.'] = "'.$seccount->{$items[$i]}.'";'."\n"; } } - my $output = <<"END"; + return <<"END"; END - return $output; }