File:  [LON-CAPA] / rat / lonratparms.pm
Revision 1.4: download - view: text, annotated - select for diffs
Sun Jul 1 02:21:18 2001 UTC (22 years, 10 months ago) by www
Branches: MAIN
CVS tags: HEAD
A little bit more working

    1: # The LearningOnline Network with CAPA
    2: # Set parameters inside of the RAT
    3: #
    4: # (Search Catalog
    5: #
    6: # (Internal Server Error Handler
    7: #
    8: # (Login Screen
    9: # 5/21/99,5/22,5/25,5/26,5/31,6/2,6/10,7/12,7/14,
   10: # 1/14/00,5/29,5/30,6/1,6/29,7/1,11/9 Gerd Kortemeyer)
   11: #
   12: # 3/1/1 Gerd Kortemeyer)
   13: #
   14: # 3/1 Gerd Kortemeyer)
   15: #
   16: # 03/03/01,06/15,06/25,06/26,06/30 Gerd Kortemeyer
   17: #
   18: package Apache::lonratparms;
   19: 
   20: use strict;
   21: use Apache::Constants qw(:common);
   22: 
   23: sub handler {
   24:     my $r = shift;
   25:     $r->content_type('text/html');
   26:     $r->send_http_header;
   27:     return OK if $r->header_only;
   28: 
   29: # Get query string for limited number of parameters
   30: 
   31:     map {
   32:        my ($name, $value) = split(/=/,$_);
   33:        $value =~ tr/+/ /;
   34:        $value =~ s/%([a-fA-F0-9][a-fA-F0-9])/pack("C",hex($1))/eg;
   35:        if (($name eq 'url') || ($name eq 'parms') || 
   36:            ($name eq 'resid')) {
   37:            unless ($ENV{'form.'.$name}) {
   38:               $ENV{'form.'.$name}=$value;
   39: 	   }
   40:        }
   41:     } (split(/&/,$ENV{'QUERY_STRING'}));
   42: 
   43: 
   44: # ------------------------------------------------------------------- Read file
   45: 
   46:   my $uri=$ENV{'form.url'}.'.meta';
   47:   
   48:   my %content;
   49:   my %type;
   50:   my %value;
   51:   
   52:   map {
   53:       if ($_=~/^parameter\_/) {
   54:          $content{$_}=&Apache::lonnet::metadata($uri,$_);
   55:       }
   56:   } split(/\,/,&Apache::lonnet::metadata($uri,'keys'));
   57: 
   58: # ---------------------------------------------------------- Current Parameters
   59: 
   60:   map {
   61:       my ($ptype,$pname,$pvalue)=split(/\_\_\_/,$_);
   62:       $type{$pname}=$ptype;
   63:       $value{$pname}=$pvalue;
   64:   } split(/\:/,$ENV{'form.params'});
   65:   
   66: # --------------------------------------------------- Print input screen header
   67:     $r->print(<<ENDHEADER);
   68: <html>
   69: <head>
   70: <title>The LearningOnline Network with CAPA</title>
   71: <script language="JavaScript">
   72: function setparms() {
   73: ENDHEADER
   74:     $r->print('opener.objparms['.$ENV{'form.resid'}.']="";');
   75:     map {
   76:        $r->print("\nif (document.parameters.def_".$_.
   77:        '.value=="on") { opener.objparms['.$ENV{'form.resid'}.
   78:        ']+="'.$type{$_}.'___'.$_.'___"+document.parameters.'.$_.'.value; }');       
   79:     } keys %content;
   80:     $r->print(<<ENDDOCUMENT);
   81:     window.close();
   82: }
   83: </script>
   84: </head>
   85: <body bgcolor="#FFFFFF">
   86: <h1>Set Resource Parameters in Map</h1>
   87: <form action="javascript:setparms();" method="post" name="parameters">
   88: <table border=2>
   89: <tr><th>Parameter</th><th>Default</th><th>Value</th><th>Set?</th></tr>
   90: ENDDOCUMENT
   91:     my $cur=$content{$_};
   92:     if (defined($value{$_})) { $cur=$value{$_}; }
   93:     map {
   94:         $r->print('<tr><td>'.$_.'</td><td>&nbsp;'.$content{$_}.
   95:         '</td><td><input type="text" name="'.$_.'" value="'.$cur.
   96:         '"></td><td><input type="checkbox" name="def_'.$_.
   97:         '" value="off"></td></tr>');
   98:     } keys %content;
   99:     $r->print(
  100:         '</table><br><input type="submit" value="Set"></form></body></html>');
  101:     return OK;
  102: } 
  103: 
  104: 1;
  105: __END__

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