Annotation of rat/lonratparms.pm, revision 1.7
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.7 ! www 16: # 03/03/01,06/15,06/25,06/26,06/30,07/02,07/03,07/04 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;
1.5 www 50: my %display;
1.3 www 51: my %value;
52:
1.2 www 53: map {
1.4 www 54: if ($_=~/^parameter\_/) {
55: $content{$_}=&Apache::lonnet::metadata($uri,$_);
1.5 www 56: $type{$_}=&Apache::lonnet::metadata($uri,$_.'.type');
57: $display{$_}=&Apache::lonnet::metadata($uri,$_.'.display');
1.4 www 58: }
1.2 www 59: } split(/\,/,&Apache::lonnet::metadata($uri,'keys'));
60:
1.3 www 61: # ---------------------------------------------------------- Current Parameters
1.2 www 62:
1.3 www 63: map {
64: my ($ptype,$pname,$pvalue)=split(/\_\_\_/,$_);
1.5 www 65: unless ($type{$pname}) { $type{$pname}=$ptype; }
1.3 www 66: $value{$pname}=$pvalue;
1.5 www 67: } split(/\:/,$ENV{'form.parms'});
1.3 www 68:
69: # --------------------------------------------------- Print input screen header
70: $r->print(<<ENDHEADER);
1.1 www 71: <html>
72: <head>
73: <title>The LearningOnline Network with CAPA</title>
1.3 www 74: <script language="JavaScript">
1.7 ! www 75:
! 76: function pclose() {
! 77: parmwin=window.open("/adm/rat/empty.html","LONCAPAparms",
! 78: "height=350,width=350,scrollbars=no,menubar=no");
! 79: parmwin.close();
! 80: }
! 81:
! 82: function pjump(type,dis,value,marker,ret,call) {
! 83: parmwin=window.open("/adm/rat/parameter.html?type="+escape(type)
! 84: +"&value="+escape(value)+"&marker="+escape(marker)
! 85: +"&return="+escape(ret)
! 86: +"&call="+escape(call)+"&name="+escape(dis),"LONCAPAparms",
! 87: "height=350,width=350,scrollbars=no,menubar=no");
! 88:
! 89: }
! 90:
! 91: function stpr() {
! 92: eval("document.parameters."+document.parameters.pres_marker.value+
! 93: ".value=document.parameters.pres_value.value");
! 94: pclose();
! 95: }
! 96:
! 97:
1.3 www 98: function setparms() {
99: ENDHEADER
1.6 www 100: $r->print('var colon=""; opener.objparms['.$ENV{'form.resid'}.']="";');
1.3 www 101: map {
102: $r->print("\nif (document.parameters.def_".$_.
1.5 www 103: '.checked) { opener.objparms['.$ENV{'form.resid'}.
1.6 www 104: ']+=colon+"'.$type{$_}.
105: '___'.$_.'___"+document.parameters.'.$_.'.value; colon=":"; }');
1.3 www 106: } keys %content;
107: $r->print(<<ENDDOCUMENT);
1.6 www 108: opener.save();
1.3 www 109: window.close();
110: }
111: </script>
1.1 www 112: </head>
113: <body bgcolor="#FFFFFF">
1.2 www 114: <h1>Set Resource Parameters in Map</h1>
1.4 www 115: <form action="javascript:setparms();" method="post" name="parameters">
1.7 ! www 116: <input type="hidden" value='' name="pres_value">
! 117: <input type="hidden" value='' name="pres_type">
! 118: <input type="hidden" value='' name="pres_marker">
1.4 www 119: <table border=2>
120: <tr><th>Parameter</th><th>Default</th><th>Value</th><th>Set?</th></tr>
1.1 www 121: ENDDOCUMENT
1.2 www 122: map {
1.5 www 123: my $cur=$content{$_};
124: if (defined($value{$_})) { $cur=$value{$_}; };
125: $r->print('<tr><td><b>'.$display{$_}.'</b><br><tt>'.$_.
126: '</tt></td><td> '.$content{$_}.
1.7 ! www 127: '</td><td><input type="text" size="10" name="'.$_.'" value="'.$cur.
! 128: '"> <a href='."'".'javascript:pjump("'.
! 129: $type{$_}.'","'.
! 130: $display{$_}.'",document.parameters.'.$_.
! 131: '.value,"'.$_.'","parameters.pres","stpr");'."'>Enter</a>".
! 132: '</td><td><input type="checkbox" name="def_'.$_.
! 133: '"');
1.6 www 134: if ($value{$_}) { $r->print(' checked'); }
135: $r->print('></td></tr>');
1.2 www 136: } keys %content;
1.3 www 137: $r->print(
138: '</table><br><input type="submit" value="Set"></form></body></html>');
1.1 www 139: return OK;
140: }
141:
142: 1;
143: __END__
1.7 ! www 144:
FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>