File:  [LON-CAPA] / loncom / interface / Attic / lonremote.pm
Revision 1.30: download - view: text, annotated - select for diffs
Sun Mar 29 22:14:12 2009 UTC (15 years, 3 months ago) by raeburn
Branches: MAIN
CVS tags: HEAD, BZ5434-fox
Bug 5930.
- Provide a "Re-launch" remote control link on the "Collapse Remote Control" page.

    1: # The LearningOnline Network
    2: # User Authentication Module
    3: #
    4: # $Id: lonremote.pm,v 1.30 2009/03/29 22:14:12 raeburn Exp $
    5: #
    6: # Copyright Michigan State University Board of Trustees
    7: #
    8: # This file is part of the LearningOnline Network with CAPA (LON-CAPA).
    9: #
   10: # LON-CAPA is free software; you can redistribute it and/or modify
   11: # it under the terms of the GNU General Public License as published by
   12: # the Free Software Foundation; either version 2 of the License, or
   13: # (at your option) any later version.
   14: #
   15: # LON-CAPA is distributed in the hope that it will be useful,
   16: # but WITHOUT ANY WARRANTY; without even the implied warranty of
   17: # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
   18: # GNU General Public License for more details.
   19: #
   20: # You should have received a copy of the GNU General Public License
   21: # along with LON-CAPA; if not, write to the Free Software
   22: # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
   23: #
   24: # /home/httpd/html/adm/gpl.txt
   25: #
   26: # http://www.lon-capa.org/
   27: #
   28: ###
   29: 
   30: package Apache::lonremote;
   31: 
   32: use strict;
   33: use Apache::Constants qw(:common);
   34: use Apache::loncommon();
   35: use Apache::lonnet;
   36: use Apache::lonmenu();
   37: use Apache::lonlocal;
   38: 
   39: sub launchremote {
   40:     my ($r,$lowerurl)=@_;
   41:     &Apache::lonnet::put('environment',{'remote' => 'on'});
   42:     &Apache::lonnet::appenv({'environment.remote' => 'on'});
   43: # -------------------------------------------------------- Menu script and info
   44:     my $windowinfo=&Apache::lonmenu::open($env{'browser.os'});
   45:     my $startupremote=&Apache::lonmenu::startupremote($lowerurl);
   46:     my $start_page = &Apache::loncommon::start_page('Page Display Settings',
   47: 						    $startupremote);
   48:     my $end_page   = &Apache::loncommon::end_page();
   49:     my $remoteinfo=&Apache::lonmenu::load_remote_msg($lowerurl);
   50:     my $setflags=&Apache::lonmenu::setflags();
   51:     my $maincall=&Apache::lonmenu::maincall();
   52:     my $message=&mt("Launching of the Remote Control menu will fail if pop-up window filters are active. To use the Remote Control, disable the filter for this site.");
   53:     $r->print(<<ENDLAUNCH);
   54: $start_page
   55: $setflags
   56: $windowinfo
   57: $message
   58: $remoteinfo
   59: $maincall
   60: $end_page
   61: ENDLAUNCH
   62: }
   63: 
   64: sub collapseremote {
   65:     my ($r,$lowerurl)=@_;
   66: # -------------------------------------------------------- Menu script and info
   67:     my $brcrum = [{href=>"/adm/preferences",text=>"Set User Preferences"},
   68:                   {href=>"/adm/remote?url=/adm/preferences&action=collapse",text=>"Collapse Remote Control"}];
   69:     my $start_page = 
   70:         &Apache::loncommon::start_page('Collapse Remote Control',
   71:                                        undef,
   72:                                        {'bread_crumbs' => $brcrum,
   73:                                         'no_inline_link' => 1,});
   74:     my $end_page  =  &Apache::loncommon::end_page();
   75:     my $windowinfo=&Apache::lonmenu::close();
   76: #    my $switch='<meta HTTP-EQUIV="Refresh" CONTENT="0.5; url='.$lowerurl.'" />';
   77:     my $message='<div class="LC_warning"><b>'.&mt('The external menu (Remote Control) has been disabled, and you will be working with the smaller inline menu.').'</b></div>'."\n".
   78:                 '<p>'.&mt('You may have either closed the Remote Control window, or it was blocked by a pop-up window filter in your browser.').'<br />'."\n".
   79:                 &mt('To use the Remote Control, disable the filter for this site, and re-launch the Remote Control.').'</p>'."\n".
   80:                 '<table><tr><td><fieldset><legend><b>'.&mt('Actions').'</b></legend><table><tr>'."\n".
   81:                 '<td class="LC_menubuttons_text" align="left">'.
   82:                 '<a class="LC_menubuttons_link" href="/adm/remote?action=launch"><img alt="Launch Remote Control" src="/res/adm/pages/network-wireless.png" class="LC_noBorder" />'.
   83:                 &mt('Re-launch Remote Control').'</a></td><td>'.('&nbsp;'x3).'</td>'.
   84:                 '<td class="LC_menubuttons_link" align="right">'.
   85:                 '<a class="LC_menubuttons_link" href="'.$lowerurl.'"><img alt="Launch Remote Control" src="/res/adm/pages/forw.png" class="LC_noBorder" />'.
   86:                 &mt('Continue without Remote Control').'</a></td></tr></table>'.
   87:                 '</fieldset></td></tr></table>'."\n".
   88:                 '<p>'.&mt('Assuming no pop-up blocking, the Remote Control can be launched at any time from the [_1]Set User Preferences[_2] page, linked to in the [_3]Main Menu[_2].','<a href="/adm/preferences">','</a>','<a href="/adm/menu">').'</span></p>';
   89:     $r->print(<<ENDCOLLAPSE);
   90: $start_page
   91: $windowinfo
   92: $message
   93: $end_page
   94: ENDCOLLAPSE
   95:     &Apache::lonnet::put('environment',{'remote' => 'off'});
   96:     &Apache::lonnet::appenv({'environment.remote' => 'off'});
   97: }
   98: 
   99: sub handler {
  100:     my $r = shift;
  101:     &Apache::loncommon::get_unprocessed_cgi($ENV{'QUERY_STRING'},
  102:                                             ['action','url']);
  103:     unless ($env{'form.action'}) {
  104: 	if ($env{'environment.remote'} ne 'off') {
  105: 	    $env{'form.action'}='collapse';
  106:         } else {
  107: 	    $env{'form.action'}='launch';
  108:         }
  109:     }
  110: 
  111:     my $lowerurl=$env{'form.url'};
  112:     unless ($lowerurl) { $lowerurl='/adm/menu'; }
  113: 
  114:     &Apache::loncommon::content_type($r,'text/html');
  115:     $r->send_http_header;
  116:     return OK if $r->header_only;
  117: 
  118:     if ($env{'form.action'} eq 'launch') {
  119: 	&launchremote($r,$lowerurl);
  120:     } else {
  121:         &collapseremote($r,$lowerurl);
  122:     }
  123:     return OK;
  124: }
  125: 
  126: 1;
  127: __END__
  128: 
  129: 

FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>