File:  [LON-CAPA] / rat / lonratsrv.pm
Revision 1.38: download - view: text, annotated - select for diffs
Thu Nov 2 21:26:54 2006 UTC (17 years, 6 months ago) by albertel
Branches: MAIN
CVS tags: version_2_2_99_0, HEAD
- complete switch to LONCAPA::map

    1: # The LearningOnline Network with CAPA
    2: # Server for RAT Maps
    3: #
    4: # $Id: lonratsrv.pm,v 1.38 2006/11/02 21:26:54 albertel 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: package Apache::lonratsrv;
   30: 
   31: use strict;
   32: use Apache::Constants qw(:common);
   33: use LONCAPA::map();
   34: 
   35: 
   36: # ================================================================ Main Handler
   37: 
   38: sub handler {
   39:   my $r=shift;
   40:   &Apache::loncommon::content_type($r,'text/html');
   41:   $r->send_http_header;
   42: 
   43:   return OK if $r->header_only;
   44: 
   45:   my $url=$r->uri;
   46:   $url=~/\/(\w+)\/ratserver$/;
   47:   my $mode=$1;
   48: 
   49:   $url=~s/\/loadonly\/ratserver$/\/save\/ratserver/;
   50:   
   51:   my $fn=$r->filename;
   52:   my $lonDocRoot=$r->dir_config('lonDocRoot');
   53:   if ( $fn =~ /\Q$lonDocRoot\E/ ) {
   54:       #internal authentication, needs fixup.
   55:       $fn = $url;
   56:       $fn=~s|^/~(\w+)|/home/$1/public_html|;
   57:       $fn=~s|/[^/]*/ratserver$||;
   58:   }
   59:   my $errtext='';
   60:   my $infotext='';
   61:   my $outtext='';
   62: 
   63:   if ($mode ne 'loadonly') {
   64:      ($errtext,$infotext)=&LONCAPA::map::savemap($fn,$errtext);
   65:   }
   66:   ($outtext,$errtext,$infotext)=&LONCAPA::map::loadmap($fn,$errtext,$infotext);
   67: 
   68:   my $start_page =
   69:       &Apache::loncommon::start_page('Alert',undef,
   70: 				     {'only_body' => 1,
   71: 				      'bgcolor'   => '#FFFFFF',});
   72:   my $end_page =
   73:       &Apache::loncommon::end_page();
   74: 
   75:   $r->print(<<ENDDOCUMENT);
   76: $start_page
   77: <form name="storage" method="post" action="$url">
   78: <input type="hidden" name="output" value="$outtext" />
   79: </form>
   80: <script type ="text/javascript">
   81:     parent.flag=1;
   82: </script>
   83: ENDDOCUMENT
   84:     if (($errtext ne '') || ($infotext ne '')) {
   85: 	$r->print(<<ENDSCRIPT);
   86: <script type="text/javascript">
   87:     alert("$infotext $errtext");
   88: </script>
   89: ENDSCRIPT
   90:     }
   91:     $r->print($end_page);
   92: 
   93:   return OK;
   94: }
   95: 
   96: 1;
   97: __END__

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