--- loncom/interface/lonmenu.pm 2003/02/20 22:04:18 1.44 +++ loncom/interface/lonmenu.pm 2003/04/03 00:52:21 1.49 @@ -1,7 +1,7 @@ # The LearningOnline Network with CAPA # Routines to control the menu # -# $Id: lonmenu.pm,v 1.44 2003/02/20 22:04:18 www Exp $ +# $Id: lonmenu.pm,v 1.49 2003/04/03 00:52:21 www Exp $ # # Copyright Michigan State University Board of Trustees # @@ -25,18 +25,23 @@ # # http://www.lon-capa.org/ # -# (TeX Conversion Module # -# 05/29/00,05/30 Gerd Kortemeyer) +# 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 +# +# 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' # -# 10/05,05/28,05/30,06/01,06/08,06/09,07/04,08/07 Gerd Kortemeyer -# 02/15/02 Matthew Hall package Apache::lonmenu; use strict; use Apache::lonnet; use Apache::Constants qw(:common); +use Apache::lonhtmlcommon(); use Apache::loncommon; use Apache::File; use vars qw(@desklines $readdesk); @@ -47,9 +52,9 @@ sub menubuttons { my $forcereg=shift; my $target =shift; my $registration=shift; - unless ($ENV{'browser.interface'} eq 'textual') { return ''; } + if ($ENV{'browser.interface'} eq 'textual') { # Textual display only - my $output=(<<ENDMAINMENU); + my $output=(<<ENDMAINMENU); <script> // BEGIN LON-CAPA Internal </script> @@ -58,8 +63,25 @@ sub menubuttons { // END LON-CAPA Internal </script> ENDMAINMENU - if ($registration) { $output.=&innerregister($forcereg,$target); } - return $output."<hr />"; + if ($registration) { $output.=&innerregister($forcereg,$target); } + return $output."<hr />"; + } elsif ($ENV{'environment.remote'} eq 'off') { +# Remote Control is switched off + my $output=(<<ENDINLINEMENU); +<script> +// BEGIN LON-CAPA Internal +</script> +<a href="/adm/menu" target="_top">Main Menu</a> +<a href="/adm/remote?action=launch" target="_top">Launch Remote Control</a> +<script> +// END LON-CAPA Internal +</script> +ENDINLINEMENU + if ($registration) { $output.=&innerregister($forcereg,$target); } + return $output."<hr />"; + } else { + return ''; + } } # ====================================== This gets called in the header section @@ -70,7 +92,7 @@ sub registerurl { my $result = ''; if ($target eq 'edit') { - $result .="<script type=\"text/javascrtipt\">\n". + $result .="<script type=\"text/javascript\">\n". "if (typeof swmenu != 'undefined') {swmenu.currentURL=null;}\n". &Apache::loncommon::browser_and_searcher_javascript(). "\n</script>\n"; @@ -98,7 +120,11 @@ sub innerregister { $Apache::lonxml::registered=1; - my $textual=($ENV{'browser.interface'} eq 'textual'); + my $textinter=($ENV{'browser.interface'} eq 'textual'); + my $noremote=($ENV{'environment.remote'} eq 'off'); + + my $textual=($textinter || $noremote); + my $reopen=&Apache::lonmenu::reopenmenu(); my $newmail=''; @@ -245,7 +271,7 @@ var swmenu=null; $newmail $buttons swmenu.currentURL=window.location.pathname; - swmenu.reloadURL=window.location.pathname; + swmenu.reloadURL=window.location.pathname+window.location.search; swmenu.currentSymb="$ENV{'request.symb'}"; swmenu.reloadSymb="$ENV{'request.symb'}"; swmenu.currentStale=0; @@ -330,9 +356,13 @@ sub unloadevents() { sub startupremote { my ($lowerurl)=@_; - if ($ENV{'browser.interface'} eq 'textual') { + if (($ENV{'browser.interface'} eq 'textual') || + ($ENV{'environment.remote'} eq 'off')) { return ('<meta HTTP-EQUIV="Refresh" CONTENT="0.5; url='.$lowerurl.'" />'); } +# +# The Remote actually gets launched! +# my $configmenu=&rawconfig(); return(<<ENDREMOTESTARTUP); <script> @@ -391,7 +421,8 @@ ENDSETFLAGS } sub maincall() { - if ($ENV{'browser.interface'} eq 'textual') { return ''; } + if (($ENV{'browser.interface'} eq 'textual') || + ($ENV{'environment.remote'} eq 'off')) { return ''; } return(<<ENDMAINCALL); <script> main(); @@ -401,18 +432,19 @@ ENDMAINCALL # ================================================================= Reopen menu sub reopenmenu { - my $nothing=''; - if ($ENV{'browser.interface'} eq 'textual') { return ''; } + if (($ENV{'browser.interface'} eq 'textual') || + ($ENV{'environment.remote'} eq 'off')) { return ''; } my $menuname='LCmenu'.$Apache::lonnet::perlvar{'lonHostID'}; - if ($ENV{'browser.type'} eq 'explorer') { $nothing='javascript:void(0);'; } - return('window.open("'.$nothing.'","'.$menuname.'","",false);'); + my $nothing = &Apache::lonhtmlcommon::javascript_nothing(); + return('window.open('.$nothing.',"'.$menuname.'","",false);'); } # =============================================================== Open the menu sub open { my $returnval=''; - if ($ENV{'browser.interface'} eq 'textual') { return ''; } + if (($ENV{'browser.interface'} eq 'textual') || + ($ENV{'environment.remote'} eq 'off')) { return ''; } my $menuname='LCmenu'.$Apache::lonnet::perlvar{'lonHostID'}; unless (shift eq 'unix') { # resizing does not work on linux because of virtual desktop sizes @@ -436,7 +468,8 @@ ENDOPEN sub clear { my ($row,$col)=@_; - unless ($ENV{'browser.interface'} eq 'textual') { + unless (($ENV{'browser.interface'} eq 'textual') || + ($ENV{'environment.remote'} eq 'off')) { return "\n".qq(window.status+='.';swmenu.clearbut($row,$col);); } else { return ''; } } @@ -449,7 +482,8 @@ sub switch { my ($uname,$udom,$row,$col,$img,$top,$bot,$act,$desc,$nobreak)=@_; $act=~s/\$uname/$uname/g; $act=~s/\$udom/$udom/g; - unless ($ENV{'browser.interface'} eq 'textual') { + unless (($ENV{'browser.interface'} eq 'textual') || + ($ENV{'environment.remote'} eq 'off')) { return "\n". qq(window.status+='.';swmenu.switchbutton($row,$col,"$img","$top","$bot","$act","$desc");); } else { @@ -478,18 +512,17 @@ sub secondlevel { sub openmenu { my $menuname='LCmenu'.$Apache::lonnet::perlvar{'lonHostID'}; - if ($ENV{'browser.interface'} eq 'textual') { return ''; } - if ($ENV{'browser.type'} eq 'explorer') { - return "window.open('javascript:void(0);','".$menuname."');"; - } else { - return "window.open('','".$menuname."');"; - } + if (($ENV{'browser.interface'} eq 'textual') || + ($ENV{'environment.remote'} eq 'off')) { return ''; } + my $nothing = &Apache::lonhtmlcommon::javascript_nothing(); + return "window.open(".$nothing.",'".$menuname."');"; } sub rawconfig { my $textualoverride=shift; my $output=''; - unless ($ENV{'browser.interface'} eq 'textual') { + unless (($ENV{'browser.interface'} eq 'textual') || + ($ENV{'environment.remote'} eq 'off')) { $output.= "window.status='Opening Remote Control';var swmenu=".&openmenu(). "\nwindow.status='Configuring Remote Control ';"; @@ -562,7 +595,8 @@ sub rawconfig { } } } - unless ($ENV{'browser.interface'} eq 'textual') { + unless (($ENV{'browser.interface'} eq 'textual') || + ($ENV{'environment.remote'} eq 'off')) { $output.="\nwindow.status='Synchronizing Time';swmenu.syncclock(1000*".time.");\nwindow.status='Remote Control Configured.';"; } return $output; @@ -571,7 +605,8 @@ sub rawconfig { # ======================================================================= Close sub close { - if ($ENV{'browser.interface'} eq 'textual') { return ''; } + if (($ENV{'browser.interface'} eq 'textual') || + ($ENV{'environment.remote'} eq 'off')) { return ''; } my $menuname='LCmenu'.$Apache::lonnet::perlvar{'lonHostID'}; return(<<ENDCLOSE); <script>