Annotation of rat/lonratsrv.pm, revision 1.42

1.1       www         1: # The LearningOnline Network with CAPA
                      2: # Server for RAT Maps
                      3: #
1.42    ! www         4: # $Id: lonratsrv.pm,v 1.41 2008/11/20 15:19:05 jms Exp $
1.16      www         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: #
1.1       www        28: 
1.40      jms        29: 
1.1       www        30: package Apache::lonratsrv;
                     31: 
                     32: use strict;
                     33: use Apache::Constants qw(:common);
1.39      albertel   34: use LONCAPA();
1.38      albertel   35: use LONCAPA::map();
1.2       www        36: 
1.1       www        37: 
                     38: # ================================================================ Main Handler
                     39: 
                     40: sub handler {
                     41:   my $r=shift;
1.29      albertel   42:   &Apache::loncommon::content_type($r,'text/html');
1.1       www        43:   $r->send_http_header;
                     44: 
                     45:   return OK if $r->header_only;
                     46: 
                     47:   my $url=$r->uri;
1.39      albertel   48:   $url=~m{/(\w+)/ratserver$};
1.2       www        49:   my $mode=$1;
                     50: 
1.39      albertel   51:   $url=~s{/loadonly/ratserver$}{/save/ratserver};
1.2       www        52:   
                     53:   my $fn=$r->filename;
                     54:   my $errtext='';
1.28      www        55:   my $infotext='';
1.2       www        56:   my $outtext='';
                     57: 
                     58:   if ($mode ne 'loadonly') {
1.38      albertel   59:      ($errtext,$infotext)=&LONCAPA::map::savemap($fn,$errtext);
1.2       www        60:   }
1.38      albertel   61:   ($outtext,$errtext,$infotext)=&LONCAPA::map::loadmap($fn,$errtext,$infotext);
1.1       www        62: 
1.35      albertel   63:   my $start_page =
                     64:       &Apache::loncommon::start_page('Alert',undef,
                     65: 				     {'only_body' => 1,
                     66: 				      'bgcolor'   => '#FFFFFF',});
                     67:   my $end_page =
                     68:       &Apache::loncommon::end_page();
                     69: 
1.1       www        70:   $r->print(<<ENDDOCUMENT);
1.35      albertel   71: $start_page
                     72: <form name="storage" method="post" action="$url">
                     73: <input type="hidden" name="output" value="$outtext" />
1.1       www        74: </form>
1.35      albertel   75: <script type ="text/javascript">
1.9       harris41   76:     parent.flag=1;
1.8       harris41   77: </script>
1.2       www        78: ENDDOCUMENT
1.28      www        79:     if (($errtext ne '') || ($infotext ne '')) {
1.2       www        80: 	$r->print(<<ENDSCRIPT);
1.35      albertel   81: <script type="text/javascript">
1.28      www        82:     alert("$infotext $errtext");
1.2       www        83: </script>
                     84: ENDSCRIPT
                     85:     }
1.35      albertel   86:     $r->print($end_page);
1.1       www        87: 
                     88:   return OK;
                     89: }
                     90: 
                     91: 1;
                     92: __END__
1.41      jms        93: 
                     94: 
                     95: =head1 NAME
                     96: 
                     97: Apache::lonratsrv
                     98: 
                     99: =head1 SYNOPSIS
                    100: 
                    101: Handler that takes output from RAT and stores
                    102: it on disk. Handles the upper hidden frame of
                    103: the added window that comes up in RAT. (3
                    104: frames come up in RAT server, code, and
                    105: output. This module handles server
                    106: connection.)
                    107: 
                    108: This is part of the LearningOnline Network with CAPA project
                    109: described at http://www.lon-capa.org.
                    110: 
1.42    ! www       111: =cut

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