Annotation of rat/lonratsrv.pm, revision 1.41

1.1       www         1: # The LearningOnline Network with CAPA
                      2: # Server for RAT Maps
                      3: #
1.41    ! jms         4: # $Id: lonratsrv.pm,v 1.40 2008/11/20 13:51:22 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;
1.19      albertel   54:   my $lonDocRoot=$r->dir_config('lonDocRoot');
1.38      albertel   55:   if ( $fn =~ /\Q$lonDocRoot\E/ ) {
1.19      albertel   56:       #internal authentication, needs fixup.
                     57:       $fn = $url;
1.39      albertel   58:       $fn=~s{^/~($LONCAPA::username_re)}{/home/$1/public_html};
                     59:       $fn=~s{/[^/]*/ratserver$}{};
1.19      albertel   60:   }
1.2       www        61:   my $errtext='';
1.28      www        62:   my $infotext='';
1.2       www        63:   my $outtext='';
                     64: 
                     65:   if ($mode ne 'loadonly') {
1.38      albertel   66:      ($errtext,$infotext)=&LONCAPA::map::savemap($fn,$errtext);
1.2       www        67:   }
1.38      albertel   68:   ($outtext,$errtext,$infotext)=&LONCAPA::map::loadmap($fn,$errtext,$infotext);
1.1       www        69: 
1.35      albertel   70:   my $start_page =
                     71:       &Apache::loncommon::start_page('Alert',undef,
                     72: 				     {'only_body' => 1,
                     73: 				      'bgcolor'   => '#FFFFFF',});
                     74:   my $end_page =
                     75:       &Apache::loncommon::end_page();
                     76: 
1.1       www        77:   $r->print(<<ENDDOCUMENT);
1.35      albertel   78: $start_page
                     79: <form name="storage" method="post" action="$url">
                     80: <input type="hidden" name="output" value="$outtext" />
1.1       www        81: </form>
1.35      albertel   82: <script type ="text/javascript">
1.9       harris41   83:     parent.flag=1;
1.8       harris41   84: </script>
1.2       www        85: ENDDOCUMENT
1.28      www        86:     if (($errtext ne '') || ($infotext ne '')) {
1.2       www        87: 	$r->print(<<ENDSCRIPT);
1.35      albertel   88: <script type="text/javascript">
1.28      www        89:     alert("$infotext $errtext");
1.2       www        90: </script>
                     91: ENDSCRIPT
                     92:     }
1.35      albertel   93:     $r->print($end_page);
1.1       www        94: 
                     95:   return OK;
                     96: }
                     97: 
                     98: 1;
                     99: __END__
1.41    ! jms       100: 
        !           101: 
        !           102: =head1 NAME
        !           103: 
        !           104: Apache::lonratsrv
        !           105: 
        !           106: =head1 SYNOPSIS
        !           107: 
        !           108: Handler that takes output from RAT and stores
        !           109: it on disk. Handles the upper hidden frame of
        !           110: the added window that comes up in RAT. (3
        !           111: frames come up in RAT server, code, and
        !           112: output. This module handles server
        !           113: connection.)
        !           114: 
        !           115: This is part of the LearningOnline Network with CAPA project
        !           116: described at http://www.lon-capa.org.
        !           117: 
        !           118: =cut

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