Annotation of rat/lonratsrv.pm, revision 1.40

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

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