--- loncom/interface/lonmenu.pm 2006/03/29 20:07:00 1.169 +++ loncom/interface/lonmenu.pm 2006/04/21 22:00:56 1.177 @@ -1,7 +1,7 @@ # The LearningOnline Network with CAPA # Routines to control the menu # -# $Id: lonmenu.pm,v 1.169 2006/03/29 20:07:00 raeburn Exp $ +# $Id: lonmenu.pm,v 1.177 2006/04/21 22:00:56 albertel Exp $ # # Copyright Michigan State University Board of Trustees # @@ -40,7 +40,6 @@ package Apache::lonmenu; use strict; use Apache::lonnet; -use Apache::Constants qw(:common); use Apache::lonhtmlcommon(); use Apache::loncommon(); use Apache::lonenc(); @@ -50,9 +49,6 @@ use vars qw(@desklines $readdesk); my @inlineremote; -my $font; -my $tabbg; -my $pgbg; # ================================================================ Little texts @@ -72,13 +68,15 @@ sub initlittle { sub menubuttons { my $forcereg=shift; - my $target =shift; my $registration=shift; my $titletable=shift; &Apache::loncommon::get_unprocessed_cgi($ENV{'QUERY_STRING'}, ['inhibitmenu']); if (($env{'form.inhibitmenu'} eq 'yes') || ($ENV{'REQUEST_URI'} eq '/adm/logout')) { return ''; } + + if ($env{'request.noversionuri'} =~ m{^/res/adm/pages/}) { return ''; } + my %lt=&initlittle(); my $navmaps=''; my $reloadlink=''; @@ -87,7 +85,7 @@ sub menubuttons { my $showgroups=0; my $escurl=&Apache::lonnet::escape(&Apache::lonenc::check_encrypt($env{'request.noversionuri'})); my $escsymb=&Apache::lonnet::escape(&Apache::lonenc::check_encrypt($env{'request.symb'})); - my $face= 'face="Arial,Helvetica,sans-serif"'; + if ($env{'request.state'} eq 'construct') { if (($env{'request.noversionuri'} eq '') || (!defined($env{'request.noversionuri'}))) { my $returnurl = $env{'request.filename'}; @@ -109,9 +107,6 @@ sub menubuttons { if ($env{'browser.interface'} eq 'textual') { # Textual display only - $pgbg='#FFFFFF'; - $tabbg='#FFFFFF'; - $font='#000000'; if ($env{'request.course.id'}) { $navmaps=(<<ENDNAV); <a href="/adm/navmaps?postdata=$escurl&postsymb=$escsymb" target="_top">$lt{'nav'}</a> @@ -121,18 +116,17 @@ ENDNAV ($env{'request.noversionuri'}!~/^\/adm\/.*\/(smppg|bulletinboard|aboutme)(\?|$)/)) { my $escreload=&Apache::lonnet::escape('return:'); $reloadlink=(<<ENDRELOAD); -<a href="/adm/flip?postdata=$escreload" target="_top"><font $face color="$font">$lt{'ret'}</font></a> +<a href="/adm/flip?postdata=$escreload" target="_top">$lt{'ret'}</a> ENDRELOAD } if (&Apache::lonnet::allowed('mdc',$env{'request.course.id'})) { $docs=(<<ENDDOCS); -<a href="/adm/coursedocs" target="_top"><font $face color="$font">$lt{'docs'}</font></a> +<a href="/adm/coursedocs" target="_top">$lt{'docs'}</a> ENDDOCS } if ($showgroups) { $groups =(<<ENDGROUPS); -<td bgcolor="$tabbg"> -<a href="/adm/coursegroups" target="_top"><font $face color="$font">$lt{'groups'}</font></a></td> +<a href="/adm/coursegroups" target="_top">$lt{'groups'}</a></td> ENDGROUPS } } @@ -143,37 +137,27 @@ ENDGROUPS // BEGIN LON-CAPA Internal $utility </script> +<div id="LC_top_nav"> <a href="/adm/menu" target="_top">$lt{'main'}</a> $reloadlink $navmaps $docs $groups -<a href="/adm/roles" target="_top"><font $face color="$font">$lt{'roles'}</font></a> -<a href="/adm/logout" target="_top"><font $face color="$font">$lt{'exit'}</font></a> +<a href="/adm/roles" target="_top">$lt{'roles'}</a> +<a href="/adm/logout" target="_top">$lt{'exit'}</a> +</div> <br /> <script type="text/javascript"> // END LON-CAPA Internal </script> $form ENDMAINMENU - if ($registration) { $output.=&innerregister($forcereg,$target); } + if ($registration) { $output.=&innerregister($forcereg); } return $output."<hr />"; } 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'; - } - if ($env{'request.role'}=~/^(su|dc|ad|li)/) { - $function='admin'; - } - if (($env{'request.role'}=~/^(au|ca)/) || - ($env{'request.noversionuri'}=~/^(\/priv|\~)/)) { - $function='author'; - } + my $domain=&Apache::loncommon::determinedomain(); - $pgbg=&Apache::loncommon::designparm($function.'.pgbg',$domain); - $tabbg=&Apache::loncommon::designparm($function.'.tabbg',$domain); - $font=&Apache::loncommon::designparm($function.'.font',$domain); + 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); @@ -181,13 +165,12 @@ ENDMAINMENU if ($env{'user.name'} eq 'public' && $env{'user.domain'} eq 'public') { my $logo=&Apache::loncommon::lonhttpdurl("/adm/lonIcons/minilogo.gif"); return (<<ENDINLINEMENU); -<font face="Arial,Helvetica,sans-serif"> - <table bgcolor="$pgbg" width="100%" border="0" cellpadding="1" cellspacing="1"> + <table id="LC_top_nav"> <tr> - <td bgcolor="$tabbg"> - <a href="/adm/logout" target="_top"><font color="$font">$lt{'exit'}</font></a> + <td> + <a href="/adm/logout" target="_top">$lt{'exit'}</a> </td> - <td align="right" bgcolor="$tabbg"> + <td align="right"> <img align="right" src="$logo" alt="Logo" /> <b>LON-CAPA</b> </td> @@ -204,19 +187,16 @@ ENDINLINEMENU $link="javascript:gonav('".$link."')"; } $navmaps=(<<ENDNAV); -<td bgcolor="$tabbg"> -<a href="$link" target="_top"><font $face color="$font">$lt{'nav'}</font></a></td> +<td><a href="$link" target="_top">$lt{'nav'}</a></td> ENDNAV if (&Apache::lonnet::allowed('mdc',$env{'request.course.id'})) { $docs=(<<ENDDOCS); -<td bgcolor="$tabbg"> -<a href="/adm/coursedocs" target="_top"><font $face color="$font">$lt{'docs'}</font></a></td> +<td><a href="/adm/coursedocs" target="_top">$lt{'docs'}</a></td> ENDDOCS } if ($showgroups) { $groups =(<<ENDGROUPS); -<td bgcolor="$tabbg"> -<a href="/adm/coursegroups" target="_top"><font $face color="$font">$lt{'groups'}</font></a></td> +<td><a href="/adm/coursegroups" target="_top">$lt{'groups'}</a></td> ENDGROUPS } if ( @@ -231,21 +211,19 @@ ENDGROUPS ) { my $escreload=&Apache::lonnet::escape('return:'); $reloadlink=(<<ENDRELOAD); -<td bgcolor="$tabbg"> -<a href="/adm/flip?postdata=$escreload" target="_top"><font $face color="$font">$lt{'ret'}</font></a></td> +<td><a href="/adm/flip?postdata=$escreload" target="_top">$lt{'ret'}</a></td> ENDRELOAD } } if (($env{'request.state'} eq 'construct') && ($env{'request.course.id'})) { my $escreload=&Apache::lonnet::escape('return:'); $reloadlink=(<<ENDCRELOAD); -<td bgcolor="$tabbg"> -<a href="/adm/flip?postdata=$escreload" target="_top"><font $face color="$font">$lt{'ret'}</font></a></td> +<td><a href="/adm/flip?postdata=$escreload" target="_top">$lt{'ret'}</a></td> ENDCRELOAD } my $reg=''; if ($registration) { - $reg=&innerregister($forcereg,$target,$titletable); + $reg=&innerregister($forcereg,$titletable); } my $form=&serverform(); my $utility=&utilityfunctions(); @@ -258,27 +236,17 @@ ENDCRELOAD $utility // ]]> </script> -<table bgcolor="$pgbg" width="100%" border="0" cellpadding="1" cellspacing="1"> +<table id="LC_top_nav"> <tr> -<td bgcolor="$tabbg"> -<a href="/adm/menu" target="_top"><font $face color="$font">$lt{'main'}</font></a> -</td> +<td><a href="/adm/menu" target="_top">$lt{'main'}</a></td> $reloadlink $navmaps $docs $groups -<td bgcolor="$tabbg"> -<a href="/adm/remote?action=launch&url=$escurl" target="_top"> -<font $face color="$font">$lt{'launch'}</font></a></td> -<td bgcolor="$tabbg"> -<a href="/adm/roles" target="_top"><font $face color="$font">$lt{'roles'}</font></a> -</td> -<td bgcolor="$tabbg"> -<a href="/adm/logout" target="_top"><font $face color="$font">$lt{'exit'}</font></a> -</td> -<td bgcolor="$tabbg"> -<img align="right" src="$logo" alt="Logo" /> -<b>LON-CAPA</b></td> +<td><a href="/adm/remote?action=launch&url=$escurl" target="_top">$lt{'launch'}</td> +<td><a href="/adm/roles" target="_top">$lt{'roles'}</a></td> +<td><a href="/adm/logout" target="_top">$lt{'exit'}</a></td> +<td><img align="right" src="$logo" alt="Logo" /><b>LON-CAPA</b></td> </tr> </table> $form @@ -295,20 +263,13 @@ ENDINLINEMENU # ====================================== This gets called in the header section sub registerurl { - my $forcereg=shift; - my $target = shift; + my ($forcereg) = @_; my $result = ''; - if ($env{'request.noversionuri'} eq '/res/adm/pages/menu.html') { return ''; } + if ($env{'request.noversionuri'} =~ m{^/res/adm/pages/}) { return ''; } my $force_title=''; if ($env{'request.state'} eq 'construct') { $force_title=&Apache::lonxml::display_title(); } - if ($target eq 'edit') { - $result .="<script type=\"text/javascript\">\n". - "if (typeof swmenu != 'undefined') {swmenu.currentURL=null;}\n". - &Apache::loncommon::browser_and_searcher_javascript(). - "\n</script>\n"; - } if (($env{'browser.interface'} eq 'textual') || ($env{'environment.remote'} eq 'off') || ((($env{'request.publicaccess'}) || @@ -319,10 +280,8 @@ sub registerurl { '<script type="text/javascript">function LONCAPAreg(){;} function LONCAPAstale(){}</script>'.$force_title; } # Graphical display after login only - if ($Apache::lonxml::registered && !$forcereg) { return ''; } - if ($target ne 'edit') { - $result.=&innerregister($forcereg,$target); - } + if ($env{'request.registered'} && !$forcereg) { return ''; } + $result.=&innerregister($forcereg); return $result.$force_title; } @@ -330,33 +289,41 @@ sub registerurl { # =========== and in the body of the document sub innerregister { - my $forcereg=shift; - my $target = shift; - my $titletable = shift; + my ($forcereg, $titletable) = @_; my $result = ''; my ($uname,$thisdisfn); my $const_space = ($env{'request.state'} eq 'construct'); my $is_const_dir = 0; - if ($env{'request.noversionuri'} eq '/res/adm/pages/menu.html') { return ''; } + if ($env{'request.noversionuri'} =~ m{^/res/adm/pages/}) { return ''; } - $Apache::lonxml::registered=1; + $env{'request.registered'} = 1; my $textinter=($env{'browser.interface'} eq 'textual'); my $noremote=($env{'environment.remote'} eq 'off'); my $textual=($textinter || $noremote); - @inlineremote=(); - undef @inlineremote; + undef(@inlineremote); my $reopen=&Apache::lonmenu::reopenmenu(); my $newmail=''; if ($noremote) { - $newmail='<table bgcolor="'.$pgbg.'" border="0" cellspacing="1" cellpadding="1" width="100%"><tr><td bgcolor="'.$tabbg.'"><font face="Arial,Helvetica,sans-serif">'; + $newmail='<table id="LC_nav_location"><tr>'; } - if (($textual) && ($env{'request.symb'}) && ($env{'request.course.id'})) { + if (&Apache::lonmsg::newmail()) { + if ($textual) { + $newmail.= '<td class="LC_new_mail"> + <a href="/adm/communicate" target="_top">'. + &mt('You have new messages').'</a></td>'; + } else { + $newmail= 'swmenu.setstatus("you have","messages");'; + } + } elsif (($textual) + && ($env{'request.symb'}) + && ($env{'request.course.id'})) { + $newmail.= '<td class="LC_current_location">'; my ($mapurl,$rid,$resurl)= &Apache::lonnet::decode_symb(&Apache::lonnet::symbread()); $newmail.=$env{'course.'.$env{'request.course.id'}.'.description'}; @@ -368,23 +335,19 @@ sub innerregister { if ($restitle) { $newmail.=': '.$restitle; } - $newmail.=' '; - } - if (&Apache::lonmsg::newmail()) { - $newmail=($textual? - '<b><a href="/adm/communicate" target="_top">You have new messages</a></b><br />': - 'swmenu.setstatus("you have","messages");'); + $newmail.=' </td>'; } if ($env{'request.state'} eq 'construct') { $newmail = $titletable; } else { if ($noremote) { - $newmail.='</font></td></tr></table>'; + $newmail.='</td></tr></table>'; } } my $timesync=($textual?'':'swmenu.syncclock(1000*'.time.');'); - 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" />':''); + my $tablestart=($noremote?'<table id="LC_menubuttons">':''). + ($textinter?'<br /><a href="#content">'.&mt('Skip to Content').'</a><br />':''); + my $tableend=($noremote?'</table>':'').($textinter?'<a name="content" />':''); # ============================================================================= # ============================ This is for URLs that actually can be registered if (($env{'request.noversionuri'}!~m|^/(res/)*adm/|) || ($forcereg)) { @@ -507,8 +470,8 @@ c&6&3 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&2 -s&9&3&anot.gif&anno-[_1]&tations[_1]&annotate()&Make notes and annotations about this resource&2 +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 unless ($env{'request.noversionuri'}=~/\/(bulletinboard|smppg|navmaps|syllabus|aboutme)(\?|$)/) { $menuitems.=(<<ENDREALRES); @@ -658,13 +621,13 @@ ENDDONOTREGTHIS sub loadevents() { if ($env{'request.state'} eq 'construct' || - $env{'request.noversionuri'} eq '/res/adm/pages/menu.html') { return ''; } + $env{'request.noversionuri'} =~ m{^/res/adm/pages/}) { return ''; } return 'LONCAPAreg();'; } sub unloadevents() { if ($env{'request.state'} eq 'construct' || - $env{'request.noversionuri'} eq '/res/adm/pages/menu.html') { return ''; } + $env{'request.noversionuri'} =~ m{^/res/adm/pages/}) { return ''; } return 'LONCAPAstale();'; } @@ -838,6 +801,7 @@ sub switch { $bot=&mt($bot); $desc=&mt($desc); $img=&mt($img); + unless (($env{'browser.interface'} eq 'textual') || ($env{'environment.remote'} eq 'off')) { # Remote @@ -864,34 +828,33 @@ sub switch { my $lonhttpdPort=$Apache::lonnet::perlvar{'lonhttpdPort'}; if (!defined($lonhttpdPort)) { $lonhttpdPort='8080'; } my $pic= - '<img border="0" alt="'.$text.'" src="http://'.$ENV{'HTTP_HOST'}. + '<img 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')) { + if ($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.'">'. + '<td class="LC_menubuttons_text" align="right">'.$text. + '</td><td class="LC_menubuttons_img" align="left">'. '<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>'; + '<td class="LC_menubuttons_img" align="left">'. + '<a href="javascript:'.$act.';">'.$pic.'</a></td> + <td class="LC_menubuttons_text" align="left">'.$text.'</td>'; } else { $inlineremote[10*$row+$col]="\n<tr>". - '<td width="10%" align="left" bgcolor="'.$tabbg.'">'. + '<td class="LC_menubuttons_img" align="left">'. '<a href="javascript:'.$act.';">'.$pic. - '</a></td><td colspan="3"><font color="'.$font.'">'.$desc. - '</font></td></tr>'; + '</a></td><td class="LC_menubuttons_text" colspan="3">'. + $desc.'</td></tr>'; } } else { # Inline Menu $inlineremote[10*$row+$col]= '<a href="javascript:'.$act.';">'.$pic. - '</a><font color="'.$font.'" size="2">'.$desc. - '</font>'; + '</a><span class="LC_menubuttons_inline_text">'.$desc.'</span>'; } } return ''; @@ -1083,6 +1046,24 @@ sub utilityfunctions { my $currentsymb=&Apache::lonenc::check_encrypt($env{'request.symb'}); my $nav_control=&nav_control_js(); + + my $start_page_annotate = + &Apache::loncommon::start_page('Annotator',undef, + {'only_body' => 1, + 'js_ready' => 1, + 'bgcolor' => '#BBBBBB', + 'add_entries' => { + 'onload' => 'javascript:document.goannotate.submit();'}}); + + my $start_page_bookmark = + &Apache::loncommon::start_page('Bookmarks',undef, + {'only_body' => 1, + 'js_ready' => 1, + 'bgcolor' => '#BBBBBB',}); + + my $end_page = + &Apache::loncommon::end_page({'js_ready' => 1}); + return (<<ENDUTILITY) var currentURL="$currenturl"; @@ -1183,12 +1164,55 @@ function group_chat(group) { var winName = 'LONchat_'+group; grpchat=window.open(url,winName,'height=320,width=280,resizable=yes,location=no,menubar=no,toolbar=no'); } + +function edit_bookmarks() { + go(''); + w_BookmarkPal_flag=1; + bookmarkpal=window.open("/adm/bookmarks", + "BookmarkPal", "width=400,height=505,scrollbars=0"); +} + +function annotate() { + w_Annotator_flag=1; + annotator=window.open('','Annotator','width=365,height=265,scrollbars=0'); + annotator.document.write( + '$start_page_annotate' + +"<form name='goannotate' target='Annotator' method='post' " + +"action='/adm/annotations'>" + +"<input type='hidden' name='urlnew' value='"+currentURL+"' />" + +"</form>" + +'$end_page'); + annotator.document.close(); +} + +function set_bookmark() { + go(''); + clienttitle=document.title; + clienthref=location.pathname; + w_bmquery_flag=1; + bmquery=window.open('','bmquery','width=365,height=165,scrollbars=0'); + bmquery.document.write( + '$start_page_bookmark' + +"<center><form method='post'" + +" name='newlink' action='/adm/bookmarks' target='bmquery' " + +">\\n <table width=340 height=150 " + +"bgcolor='ffffff' align=center><tr><td>Link Name:<br><input " + +"type='text' name='title' size=45 value='"+clienttitle+"'>" + +"<br>Address:<br><input type='text' name='address' size='45' " + +"value='"+clienthref+"'><br><center><input type='submit' " + +"value='Save'> <input type='button' value='Close (no save)' " + +"onclick='javascript:window.close();'></center></td>" + +"</tr></table></form></center>" + +'$end_page' ); + bmquery.document.close(); +} + ENDUTILITY } sub serverform { return(<<ENDSERVERFORM); -<form name="server" action="/adm/logout" method="post" target="_top"> +<form name="server" action="/adm/logout" method="POST" target="_top"> <input type="hidden" name="postdata" value="none" /> <input type="hidden" name="command" value="none" /> <input type="hidden" name="url" value="none" /> @@ -1199,14 +1223,14 @@ ENDSERVERFORM sub constspaceform { return(<<ENDCONSTSPACEFORM); -<form name="constspace" action="/adm/logout" method="post" target="_top"> +<form name="constspace" action="/adm/logout" method="POST" target="_top"> <input type="hidden" name="filename" value="" /> </form> -<form name="cstrdelete" action="/adm/cfile" method="post" target="_top"> +<form name="cstrdelete" action="/adm/cfile" method="POST" target="_top"> <input type="hidden" name="action" value="delete" /> <input type="hidden" name="filename" value="" /> </form> -<form name="cstrprint" action="/adm/printout" target="_parent" method="post"> +<form name="cstrprint" action="/adm/printout" target="_parent" method="POST"> <input type="hidden" name="postdata" value="" /> <input type="hidden" name="curseed" value="" /> <input type="hidden" name="problemtype" value="" /> @@ -1226,56 +1250,6 @@ sub get_nav_status { return $navstatus; } -# ================================================ Handler when called directly - - -sub handler { - my $r = shift; - &Apache::loncommon::no_cache($r); - &Apache::loncommon::content_type($r,'text/html'); - $r->send_http_header; - return OK if $r->header_only; - - my $form; - if ($env{'environment.remote'} ne 'off' && - $env{'browser.interface'} ne 'textual') { - $form=&serverform(); - } - my $function='student'; - if ($env{'request.role'}=~/^(cc|in|ta|ep)/) { - $function='coordinator'; - } - if ($env{'request.role'}=~/^(su|dc|ad|li)/) { - $function='admin'; - } - if (($env{'request.role'}=~/^(au|ca)/) || - ($env{'request.noversionuri'}=~/^(\/priv|\~)/)) { - $function='author'; - } - my $domain=&Apache::loncommon::determinedomain(); - $pgbg=&Apache::loncommon::designparm($function.'.pgbg',$domain); - $tabbg=&Apache::loncommon::designparm($function.'.tabbg',$domain); - $font=&Apache::loncommon::designparm($function.'.font',$domain); - my $script_tag; - if ($env{'environment.remote'} ne 'off') { - my $utility=&utilityfunctions('/adm/menu'); - $script_tag=(<<ENDSCRIPT); -<script type="text/javascript"> -$utility -</script> -ENDSCRIPT - } -# ---- Print the screen, pretend to be in text mode to generate text-based menu - unless ($env{'browser.interface'} eq 'textual') { - $env{'browser.interface'}='faketextual'; - $env{'environment.remote'}='off'; - } - $r->print(&Apache::loncommon::start_page('Main Menu',$script_tag)); - $r->print('<table>'.&inlinemenu().'</table>'.$form); - $r->print(&Apache::loncommon::end_page()); - return OK; -} - # ================================================================ Main Program BEGIN {