--- loncom/interface/lonmenu.pm 2003/08/28 16:43:12 1.86 +++ loncom/interface/lonmenu.pm 2004/04/01 15:29:40 1.107 @@ -1,7 +1,7 @@ # The LearningOnline Network with CAPA # Routines to control the menu # -# $Id: lonmenu.pm,v 1.86 2003/08/28 16:43:12 albertel Exp $ +# $Id: lonmenu.pm,v 1.107 2004/04/01 15:29:40 albertel Exp $ # # Copyright Michigan State University Board of Trustees # @@ -43,13 +43,25 @@ use Apache::lonnet; use Apache::Constants qw(:common); use Apache::lonhtmlcommon(); use Apache::loncommon; -use Apache::File; +use Apache::lonlocal; + use vars qw(@desklines $readdesk); + + my @inlineremote; my $font; my $tabbg; my $pgbg; +# ================================================================ Little texts + +sub initlittle { + return &Apache::lonlocal::texthash('ret' => 'Return to Last Location', + 'nav' => 'Navigate Contents', + 'main' => 'Main Menu', + 'launch' => 'Launch Remote Control'); +} + # ============================= This gets called at the top of the body section sub menubuttons { @@ -58,20 +70,24 @@ sub menubuttons { my $registration=shift; my $navmaps=''; my $reloadlink=''; - my $escurl=&Apache::lonnet::escape($ENV{'REQUEST_URI'}); + my $escurl=&Apache::lonnet::escape($ENV{'request.noversionuri'}); my $escsymb=&Apache::lonnet::escape($ENV{'request.symb'}); if ($ENV{'browser.interface'} eq 'textual') { # Textual display only + my %lt=&initlittle(); + $pgbg='#FFFFFF'; + $tabbg='#FFFFFF'; + $font='#000000'; if ($ENV{'request.course.id'}) { $navmaps=(<<ENDNAV); -<a href="/adm/navmaps?postdata=$escurl&postsymb=$escsymb" target="_top">Navigate Contents</a> +<a href="/adm/navmaps?postdata=$escurl&postsymb=$escsymb" target="_top">$lt{'nav'}</a> ENDNAV - if (($ENV{'REQUEST_URI'}=~/^\/adm\//) && - ($ENV{'REQUEST_URI'}!~/^\/adm\/wrapper\//) && - ($ENV{'REQUEST_URI'}!~/^\/adm\/.*\/(smppg|bulletinboard|aboutme)(\?|$)/)) { + if (($ENV{'request.noversionuri'}=~/^\/adm\//) && + ($ENV{'request.noversionuri'}!~/^\/adm\/wrapper\//) && + ($ENV{'request.noversionuri'}!~/^\/adm\/.*\/(smppg|bulletinboard|aboutme)(\?|$)/)) { my $escreload=&Apache::lonnet::escape('return:'); $reloadlink=(<<ENDRELOAD); -<a href="/adm/flip?postdata=$escreload" target="_top"><font color="$font">Return to Last Location</font></a> +<a href="/adm/flip?postdata=$escreload" target="_top"><font color="$font">$lt{'ret'}</font></a> ENDRELOAD } } @@ -79,7 +95,7 @@ ENDRELOAD <script> // BEGIN LON-CAPA Internal </script> -<a href="/adm/menu" target="_top">Main Menu</a> +<a href="/adm/menu" target="_top">$lt{'main'}</a> $reloadlink $navmaps<br /> <script> // END LON-CAPA Internal @@ -90,6 +106,7 @@ ENDMAINMENU } elsif ($ENV{'environment.remote'} eq 'off') { # Remote Control is switched off # figure out colors + my %lt=&initlittle(); my $function='student'; if ($ENV{'request.role'}=~/^(cc|in|ta|ep)/) { $function='coordinator'; @@ -98,7 +115,7 @@ ENDMAINMENU $function='admin'; } if (($ENV{'request.role'}=~/^(au|ca)/) || - ($ENV{'REQUEST_URI'}=~/^(\/priv|\~)/)) { + ($ENV{'request.noversionuri'}=~/^(\/priv|\~)/)) { $function='author'; } my $domain=&Apache::loncommon::determinedomain(); @@ -113,15 +130,15 @@ ENDMAINMENU if ($ENV{'request.course.id'}) { $navmaps=(<<ENDNAVREM); <td bgcolor="$tabbg"> -<a href="/adm/navmaps?postdata=$escurl&postsymb=$escsymb" target="_top"><font color="$font">Navigate Contents</font></a></td> +<a href="/adm/navmaps?postdata=$escurl&postsymb=$escsymb" target="_top"><font color="$font">$lt{'nav'}</font></a></td> ENDNAVREM - if (($ENV{'REQUEST_URI'}=~/^\/adm\//) && - ($ENV{'REQUEST_URI'}!~/^\/adm\/wrapper\//) && - ($ENV{'REQUEST_URI'}!~/^\/adm\/.*\/(smppg|bulletinboard|aboutme)(\?|$)/)) { + if (($ENV{'request.noversionuri'}=~/^\/adm\//) && + ($ENV{'request.noversionuri'}!~/^\/adm\/wrapper\//) && + ($ENV{'request.noversionuri'}!~/^\/adm\/.*\/(smppg|bulletinboard|aboutme)(\?|$)/)) { my $escreload=&Apache::lonnet::escape('return:'); $reloadlink=(<<ENDRELOAD); <td bgcolor="$tabbg"> -<a href="/adm/flip?postdata=$escreload" target="_top"><font color="$font">Return to Last Location</font></a></td> +<a href="/adm/flip?postdata=$escreload" target="_top"><font color="$font">$lt{'ret'}</font></a></td> ENDRELOAD } } @@ -133,21 +150,22 @@ ENDRELOAD <script> // BEGIN LON-CAPA Internal </script> -<table bgcolor="$pgbg" width="100%" border="0" cellpadding="3" cellspacing="3"> +<font face="Arial,Helvetica,sans-serif"><table bgcolor="$pgbg" width="100%" border="0" cellpadding="1" cellspacing="1"> <tr> <td bgcolor="$tabbg"> -<a href="/adm/menu" target="_top"><font color="$font">Main Menu</font></a> +<a href="/adm/menu" target="_top"><font color="$font">$lt{'main'}</font></a> </td> $reloadlink $navmaps <td bgcolor="$tabbg"> <a href="/adm/remote?action=launch&url=$escurl" target="_top"> -<font color="$font">Launch Remote Control</font></a></td> +<font color="$font">$lt{'launch'}</font></a></td> <td bgcolor="$tabbg"> <img align="right" src="/adm/lonIcons/minilogo.gif" /> <b>LON-CAPA</b></td> </tr> </table> +</font> <script> // END LON-CAPA Internal </script> @@ -164,7 +182,7 @@ sub registerurl { my $forcereg=shift; my $target = shift; my $result = ''; - if ($ENV{'REQUEST_URI'} eq '/res/adm/pages/menu.html') { return ''; } + if ($ENV{'request.noversionuri'} eq '/res/adm/pages/menu.html') { return ''; } my $force_title=''; if ($ENV{'request.state'} eq 'construct') { $force_title=&Apache::lonxml::display_title(); @@ -179,14 +197,16 @@ sub registerurl { ($ENV{'environment.remote'} eq 'off') || ((($ENV{'request.publicaccess'}) || (!&Apache::lonnet::is_on_map( - &Apache::lonnet::unescape($ENV{'REQUEST_URI'})))) && + &Apache::lonnet::unescape($ENV{'request.noversionuri'})))) && (!$forcereg))) { return $result. '<script type="text/javascript">function LONCAPAreg(){;} function LONCAPAstale(){}</script>'.$force_title; } # Graphical display after login only if ($Apache::lonxml::registered && !$forcereg) { return ''; } - $result.=&innerregister($forcereg,$target); + if ($target ne 'edit') { + $result.=&innerregister($forcereg,$target); + } return $result.$force_title; } @@ -197,7 +217,7 @@ sub innerregister { my $forcereg=shift; my $target = shift; my $result = ''; - if ($ENV{'REQUEST_URI'} eq '/res/adm/pages/menu.html') { return ''; } + if ($ENV{'request.noversionuri'} eq '/res/adm/pages/menu.html') { return ''; } $Apache::lonxml::registered=1; @@ -213,10 +233,10 @@ sub innerregister { my $newmail=''; if ($noremote) { - $newmail='<table bgcolor="'.$pgbg.'" border="0" cellspacing="3" cellpadding="3" width="100%"><tr><td bgcolor="'.$tabbg.'">'; + $newmail='<font face="Arial,Helvetica,sans-serif"><table bgcolor="'.$pgbg.'" border="0" cellspacing="1" cellpadding="1" width="100%"><tr><td bgcolor="'.$tabbg.'">'; } if (($textual) && ($ENV{'request.symb'}) && ($ENV{'request.course.id'})) { - my ($mapurl,$rid,$resurl)=split(/\_\_\_/,$ENV{'request.symb'}); + my ($mapurl,$rid,$resurl)=&Apache::lonnet::decode_symb($ENV{'request.symb'}); $newmail.=$ENV{'course.'.$ENV{'request.course.id'}.'.description'}; my $maptitle=&Apache::lonnet::gettitle($mapurl); my $restitle=&Apache::lonnet::gettitle($resurl); @@ -234,39 +254,38 @@ sub innerregister { 'swmenu.setstatus("you have","messages");'); } if ($noremote) { - $newmail.='</td></tr></table>'; + $newmail.='</td></tr></table></font>'; } my $timesync=($textual?'':'swmenu.syncclock(1000*'.time.');'); - my $tablestart=($noremote?'<table bgcolor="'.$pgbg.'" border="0" cellspacing="3" cellpadding="3" width="100%">':''); - my $tableend=($noremote?'</table>':''); + my $tablestart=($noremote?'<font face="Arial,Helvetica,sans-serif"><table bgcolor="'.$pgbg.'" border="0" cellspacing="1" cellpadding="1" width="100%">':'').($textinter?'<br /><a href="#content">'.&mt('Skip to Content').'</a><br />':''); + my $tableend=($noremote?'</table></font>':'').($textinter?'<a name="content" />':''); # ============================================================================= # ============================ This is for URLs that actually can be registered - if (($ENV{'REQUEST_URI'}!~/^\/(res\/)*adm\//) || ($forcereg)) { + if (($ENV{'request.noversionuri'}!~/^\/(res\/)*adm\//) || ($forcereg)) { # -- This applies to homework problems for users with grading privileges - my $hwkadd=''; - if - ($ENV{'request.filename'}=~/\.(problem|exam|quiz|assess|survey|form)$/) { - my $crs='/'.$ENV{'request.course.id'}; - if ($ENV{'request.course.sec'}) { - $crs.='_'.$ENV{'request.course.sec'}; - } - $crs=~s/\_/\//g; + my $crs='/'.$ENV{'request.course.id'}; + if ($ENV{'request.course.sec'}) { + $crs.='_'.$ENV{'request.course.sec'}; + } + $crs=~s/\_/\//g; + my $hwkadd=''; + if ($ENV{'request.filename'}=~/\.(problem|exam|quiz|assess|survey|form)$/) { if (&Apache::lonnet::allowed('vgr',$crs)) { - $hwkadd.=&switch('','',7,1,'subm.gif','view sub-','missions', + $hwkadd.=&switch('','',7,1,'subm.gif','view sub-[_1]','missions[_1]', "gocmd('/adm/grades','submission')", 'View user submissions for this assessment resource'); } if (&Apache::lonnet::allowed('mgr',$crs)) { - $hwkadd.=&switch('','',7,2,'pgrd.gif','problem','grades', + $hwkadd.=&switch('','',7,2,'pgrd.gif','problem[_1]','grades[_3]', "gocmd('/adm/grades','gradingmenu')", 'Modify user grades for this assessment resource'); } - if (&Apache::lonnet::allowed('opa',$crs)) { - $hwkadd.=&switch('','',7,3,'pparm.gif','problem','parms', - "gocmd('/adm/parmset','set')", - 'Modify deadlines, etc, for this assessment resource'); - } + } + if (&Apache::lonnet::allowed('opa',$crs)) { + $hwkadd.=&switch('','',7,3,'pparm.gif','problem[_2]','parms[_2]', + "gocmd('/adm/parmset','set')", + 'Modify deadlines, etc, for this resource'); } # -- End Homework ### @@ -317,7 +336,7 @@ sub innerregister { # Finally, turn the button on or off if ($cfile) { $editbutton=&switch - ('','',6,1,'cstr.gif','edit','resource', + ('','',6,1,'cstr.gif','edit[_1]','resource[_2]', "go('".$cfile."');","Edit this resource"); } elsif ($editbutton eq '') { $editbutton=&clear(6,1); @@ -328,20 +347,20 @@ sub innerregister { # Prepare the rest of the buttons my $menuitems=(<<ENDMENUITEMS); c&3&1 -s&2&1&back.gif&backward&&gopost('/adm/flip','back:'+currentURL)&Go to the previous resource in the course sequence&1 -s&2&3&forw.gif&forward&&gopost('/adm/flip','forward:'+currentURL)&Go to the next resource in the course sequence&3 +s&2&1&back.gif&backward[_1]&&gopost('/adm/flip','back:'+currentURL)&Go to the previous resource in the course sequence&1 +s&2&3&forw.gif&forward[_1]&&gopost('/adm/flip','forward:'+currentURL)&Go to the next resource in the course sequence&3 c&6&3 c&8&1 c&8&2 -s&8&3&prt.gif&prepare&printout&gopost('/adm/printout',currentURL)&Prepare a printable document -s&9&1&sbkm.gif&set&bookmark&set_bookmark()&Set a bookmark for this resource&2 -s&9&3&anot.gif&anno-&tations&annotate()&Make notes and annotations about this resource&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&2 +s&9&3&anot.gif&anno-[_1]&tations[_1]&annotate()&Make notes and annotations about this resource&2 ENDMENUITEMS - unless ($ENV{'REQUEST_URI'}=~/\/(bulletinboard|smppg|navmaps|syllabus|aboutme)(\?|$)/) { + unless ($ENV{'request.noversionuri'}=~/\/(bulletinboard|smppg|navmaps|syllabus|aboutme)(\?|$)/) { $menuitems.=(<<ENDREALRES); -s&6&3&catalog.gif&catalog&info&catalog_info()&Show catalog information -s&8&1&eval.gif&evaluate&this&gopost('/adm/evaluate',currentURL,1)&Provide my evaluation of this resource -s&8&2&fdbk.gif&feedback&discuss&gopost('/adm/feedback',currentURL,1)&Provide feedback messages or contribute to the course discussion about this resource +s&6&3&catalog.gif&catalog[_1]&info[_1]&catalog_info()&Show catalog information +s&8&1&eval.gif&evaluate[_1]&this[_1]&gopost('/adm/evaluate',currentURL,1)&Provide my evaluation of this resource +s&8&2&fdbk.gif&feedback[_1]&discuss[_1]&gopost('/adm/feedback',currentURL,1)&Provide feedback messages or contribute to the course discussion about this resource ENDREALRES } my $buttons=''; @@ -357,8 +376,20 @@ ENDREALRES # Registered, textual output my $utility=&utilityfunctions(); my $form=&serverform(); - my $inlinebuttons= + my $inlinebuttons=''; + + if ($ENV{'browser.interface'} eq 'textual') { + $inlinebuttons= join('',map { (defined($_)?$_:'') } @inlineremote); + } else { + $inlinebuttons=(<<ENDINLINE); +<tr><td>$inlineremote[21]</td><td> </td><td>$inlineremote[23]</td></tr> +<tr><td>$inlineremote[61]</td><td>$inlineremote[62]</td><td>$inlineremote[63]</td></tr> +<tr><td>$inlineremote[71]</td><td>$inlineremote[72]</td><td>$inlineremote[73]</td></tr> +<tr><td>$inlineremote[81]</td><td>$inlineremote[82]</td><td>$inlineremote[83]</td></tr> +<tr><td>$inlineremote[91]</td><td>$inlineremote[92]</td><td>$inlineremote[93]</td></tr> +ENDINLINE + } $result =(<<ENDREGTEXT); <script> // BEGIN LON-CAPA Internal @@ -377,7 +408,7 @@ $form ENDREGTEXT # Registered, graphical output } else { - my $requri=(split(/\?/,$ENV{'REQUEST_URI'}))[0]; + my $requri=(split(/\?/,$ENV{'request.noversionuri'}))[0]; $requri=&Apache::lonnet::unescape($requri); $result = (<<ENDREGTHIS); @@ -465,12 +496,12 @@ ENDDONOTREGTHIS } sub loadevents() { - if ($ENV{'REQUEST_URI'} eq '/res/adm/pages/menu.html') { return ''; } + if ($ENV{'request.noversionuri'} eq '/res/adm/pages/menu.html') { return ''; } return 'LONCAPAreg();'; } sub unloadevents() { - if ($ENV{'REQUEST_URI'} eq '/res/adm/pages/menu.html') { return ''; } + if ($ENV{'request.noversionuri'} eq '/res/adm/pages/menu.html') { return ''; } return 'LONCAPAstale();'; } @@ -610,6 +641,10 @@ sub switch { my ($uname,$udom,$row,$col,$img,$top,$bot,$act,$desc,$nobreak)=@_; $act=~s/\$uname/$uname/g; $act=~s/\$udom/$udom/g; + $top=&mt($top); + $bot=&mt($bot); + $desc=&mt($desc); + $img=&mt($img); unless (($ENV{'browser.interface'} eq 'textual') || ($ENV{'environment.remote'} eq 'off')) { # Remote @@ -620,21 +655,51 @@ sub switch { if ($nobreak==2) { return ''; } my $text=$top.' '.$bot; $text=~s/\s*\-\s*//gs; - $inlineremote[10*$row+$col]="\n".($nobreak?' ':'<br />'). - '<a href="javascript:'.$act.';">'.$text.'</a> '. - ($nobreak?'':$desc); + if ($nobreak) { + $inlineremote[10*$row+$col]= + '<a href="javascript:'.$act.';">'.$text.'</a>'; + } else { + $inlineremote[10*$row+$col]="\n<br />". + $desc.' <a href="javascript:'.$act.';">'.$text.'</a>'; + } } else { # Inline Remote if ($nobreak==2) { return ''; } my $text=$top.' '.$bot; $text=~s/\s*\-\s*//gs; - $inlineremote[10*$row+$col]="\n". - ($nobreak==3?'<td width="50%" colspan="2" align="right"':'<tr><td'). - ' bgcolor="'.$tabbg.'"'.($nobreak==1?' width="50%" colspan="2"':''). - '"><a href="javascript:'.$act.';"><font color="'.$font.'"'. - ($nobreak?' size="+1"':''). - '>'.$text.'</font></a></td>'. - ($nobreak?'':'<td colspan="3" width="80%"><font color="'.$font.'" size="-1">'.$desc.'</font>').($nobreak!=1?'</tr>':''); + + my $lonhttpdPort=$Apache::lonnet::perlvar{'lonhttpdPort'}; + if (!defined($lonhttpdPort)) { $lonhttpdPort='8080'; } + my $pic= + '<img border="0" alt="'.$text.'" src="http://'.$ENV{'HTTP_HOST'}. + ':'.$lonhttpdPort.'/res/adm/pages/'.$img.'" align="'. + ($nobreak==3?'right':'left').'" />'; + if (($ENV{'browser.interface'} eq 'textual') || ($ENV{'browser.interface'} eq 'faketextual')) { +# Accessibility + if ($nobreak==3) { + $inlineremote[10*$row+$col]="\n". + '<td width="40%" align="right"><font color="'.$font.'" size="+1">'.$text. + '</font></td><td width="10%" align="right" bgcolor="'.$tabbg.'">'. + '<a href="javascript:'.$act.';">'.$pic.'</a></td></tr>'; + } elsif ($nobreak) { + $inlineremote[10*$row+$col]="\n<tr>". + '<td width="10%" align="left" bgcolor="'.$tabbg.'">'. + '<a href="javascript:'.$act.';">'.$pic. + '</a></td><td width="40%" align="left"><font color="'.$font.'" size="+1">'.$text.'</font></td>'; + } else { + $inlineremote[10*$row+$col]="\n<tr>". + '<td width="10%" align="left" bgcolor="'.$tabbg.'">'. + '<a href="javascript:'.$act.';">'.$pic. + '</a></td><td colspan="3"><font color="'.$font.'">'.$desc. + '</font></td></tr>'; + } + } else { +# Inline Menu + $inlineremote[10*$row+$col]= + '<a href="javascript:'.$act.';">'.$pic. + '</a><font color="'.$font.'" size="2">'.$desc. + '</font>'; + } } return ''; } @@ -790,7 +855,7 @@ sub footer { sub utilityfunctions { unless (($ENV{'browser.interface'} eq 'textual') || ($ENV{'environment.remote'} eq 'off')) { return ''; } - my $currenturl=$ENV{'REQUEST_URI'}; + my $currenturl=$ENV{'request.noversionuri'}; my $currentsymb=$ENV{'request.symb'}; return (<<ENDUTILITY) @@ -829,11 +894,11 @@ function gocmd(url,cmd) { } function catalog_info() { - loncatinfo=window.open(window.location.pathname+'.meta',"LONcatInfo",'height=320,width=280,resizeable=yes,scrollbars=yes,location=no,menubar=no,toolbar=no'); + loncatinfo=window.open(window.location.pathname+'.meta',"LONcatInfo",'height=320,width=280,resizable=yes,scrollbars=yes,location=no,menubar=no,toolbar=no'); } function chat_win() { - lonchat=window.open('/res/adm/pages/chatroom.html',"LONchat",'height=320,width=280,resizeable=yes,location=no,menubar=no,toolbar=no'); + lonchat=window.open('/res/adm/pages/chatroom.html',"LONchat",'height=320,width=280,resizable=yes,location=no,menubar=no,toolbar=no'); } ENDUTILITY } @@ -854,7 +919,7 @@ ENDSERVERFORM sub handler { my $r = shift; - $r->content_type('text/html'); + &Apache::loncommon::content_type($r,'text/html'); $r->send_http_header; return OK if $r->header_only; @@ -868,7 +933,7 @@ sub handler { $function='admin'; } if (($ENV{'request.role'}=~/^(au|ca)/) || - ($ENV{'REQUEST_URI'}=~/^(\/priv|\~)/)) { + ($ENV{'request.noversionuri'}=~/^(\/priv|\~)/)) { $function='author'; } my $domain=&Apache::loncommon::determinedomain(); @@ -876,7 +941,8 @@ sub handler { $tabbg=&Apache::loncommon::designparm($function.'.tabbg',$domain); $font=&Apache::loncommon::designparm($function.'.font',$domain); # ---- Print the screen, pretent to be in text mode to generate text-based menu - unless ($ENV{'brower.interface'} eq 'textual') { + unless ($ENV{'browser.interface'} eq 'textual') { + $ENV{'browser.interface'}='faketextual'; $ENV{'environment.remote'}='off'; } my $utility=&utilityfunctions(); @@ -899,15 +965,17 @@ ENDHEADER BEGIN { if (! defined($readdesk)) { { - my $config=Apache::File->new($Apache::lonnet::perlvar{'lonTabDir'}. - '/mydesk.tab'); - while (my $configline=<$config>) { - $configline=(split(/\#/,$configline))[0]; - $configline=~s/^\s+//; - chomp($configline); - if ($configline) { - $desklines[$#desklines+1]=$configline; - } + my $tabfile = $Apache::lonnet::perlvar{'lonTabDir'}.'/mydesk.tab'; + if ( CORE::open( my $config,"<$tabfile") ) { + while (my $configline=<$config>) { + $configline=(split(/\#/,$configline))[0]; + $configline=~s/^\s+//; + chomp($configline); + if ($configline) { + $desklines[$#desklines+1]=$configline; + } + } + CORE::close($config); } } $readdesk='done';