Annotation of rat/lonratparms.pm, revision 1.3

1.1       www         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: #
1.3     ! www        16: # 03/03/01,06/15,06/25,06/26 Gerd Kortemeyer
1.1       www        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: 
1.2       www        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';
1.3     ! www        47:   
        !            48:   my %content;
        !            49:   my %type;
        !            50:   my %value;
        !            51:   
1.2       www        52:   map {
                     53:       $content{$_}=&Apache::lonnet::metadata($uri,$_);
                     54:   } split(/\,/,&Apache::lonnet::metadata($uri,'keys'));
                     55: 
1.3     ! www        56: # ---------------------------------------------------------- Current Parameters
1.2       www        57: 
1.3     ! www        58:   map {
        !            59:       my ($ptype,$pname,$pvalue)=split(/\_\_\_/,$_);
        !            60:       $type{$pname}=$ptype;
        !            61:       $value{$pname}=$pvalue;
        !            62:   } split(/\:/,$ENV{'form.params'});
        !            63:   
        !            64: # --------------------------------------------------- Print input screen header
        !            65:     $r->print(<<ENDHEADER);
1.1       www        66: <html>
                     67: <head>
                     68: <title>The LearningOnline Network with CAPA</title>
1.3     ! www        69: <script language="JavaScript">
        !            70: function setparms() {
        !            71: ENDHEADER
        !            72:     $r->print('opener.parent.objparms['.$ENV{'form.resid'}.']="";');
        !            73:     map {
        !            74:        $r->print("\nif (document.parameters.def_".$_.
        !            75:        '.value=="on") { opener.parent.objparms['.$ENV{'form.resid'}.
        !            76:        ']+="'.$type{$_}.'___'.$_.'___"+document.parameters.'.$_.'.value; }');       
        !            77:     } keys %content;
        !            78:     $r->print(<<ENDDOCUMENT);
        !            79:     window.close();
        !            80: }
        !            81: </script>
1.1       www        82: </head>
                     83: <body bgcolor="#FFFFFF">
1.2       www        84: <h1>Set Resource Parameters in Map</h1>
1.3     ! www        85: <form action="javascript:setparms();" name="parameters">
        !            86: <table>
        !            87: <tr><th>Parameter</th><th>Value</th><th>Set?</th></tr>
1.1       www        88: ENDDOCUMENT
1.3     ! www        89:     my $cur=$content{$_};
        !            90:     if (defined($value{$_})) { $cur=$value{$_}; }
1.2       www        91:     map {
1.3     ! www        92:         $r->print('<tr><td>'.$_.
        !            93:         '</td><td><input type="text" name="'.$_.'" value="'.$cur.
        !            94:         '"></td><td><input type="checkbox" name="def_'.$_.
        !            95:         '" value="off"></td></tr>');
1.2       www        96:     } keys %content;
1.3     ! www        97:     $r->print(
        !            98:         '</table><br><input type="submit" value="Set"></form></body></html>');
1.1       www        99:     return OK;
                    100: } 
                    101: 
                    102: 1;
                    103: __END__

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