File:  [LON-CAPA] / rat / lonratparms.pm
Revision 1.8: download - view: text, annotated - select for diffs
Thu Nov 29 19:23:49 2001 UTC (22 years, 5 months ago) by www
Branches: MAIN
CVS tags: stable_2002_spring, HEAD
GPL

    1: # The LearningOnline Network with CAPA
    2: # Set parameters inside of the RAT
    3: #
    4: # $Id: lonratparms.pm,v 1.8 2001/11/29 19:23:49 www 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: # (Search Catalog
   29: #
   30: # (Internal Server Error Handler
   31: #
   32: # (Login Screen
   33: # 5/21/99,5/22,5/25,5/26,5/31,6/2,6/10,7/12,7/14,
   34: # 1/14/00,5/29,5/30,6/1,6/29,7/1,11/9 Gerd Kortemeyer)
   35: #
   36: # 3/1/1 Gerd Kortemeyer)
   37: #
   38: # 3/1 Gerd Kortemeyer)
   39: #
   40: # 03/03/01,06/15,06/25,06/26,06/30,07/02,07/03,07/04 Gerd Kortemeyer
   41: #
   42: package Apache::lonratparms;
   43: 
   44: use strict;
   45: use Apache::Constants qw(:common);
   46: 
   47: sub handler {
   48:     my $r = shift;
   49:     $r->content_type('text/html');
   50:     $r->send_http_header;
   51:     return OK if $r->header_only;
   52: 
   53: # Get query string for limited number of parameters
   54: 
   55:     map {
   56:        my ($name, $value) = split(/=/,$_);
   57:        $value =~ tr/+/ /;
   58:        $value =~ s/%([a-fA-F0-9][a-fA-F0-9])/pack("C",hex($1))/eg;
   59:        if (($name eq 'url') || ($name eq 'parms') || 
   60:            ($name eq 'resid')) {
   61:            unless ($ENV{'form.'.$name}) {
   62:               $ENV{'form.'.$name}=$value;
   63: 	   }
   64:        }
   65:     } (split(/&/,$ENV{'QUERY_STRING'}));
   66: 
   67: 
   68: # ------------------------------------------------------------------- Read file
   69: 
   70:   my $uri=$ENV{'form.url'}.'.meta';
   71:   
   72:   my %content;
   73:   my %type;
   74:   my %display;
   75:   my %value;
   76:   
   77:   map {
   78:       if ($_=~/^parameter\_/) {
   79:          $content{$_}=&Apache::lonnet::metadata($uri,$_);
   80:          $type{$_}=&Apache::lonnet::metadata($uri,$_.'.type');
   81:          $display{$_}=&Apache::lonnet::metadata($uri,$_.'.display');
   82:       }
   83:   } split(/\,/,&Apache::lonnet::metadata($uri,'keys'));
   84: 
   85: # ---------------------------------------------------------- Current Parameters
   86: 
   87:   map {
   88:       my ($ptype,$pname,$pvalue)=split(/\_\_\_/,$_);
   89:       unless ($type{$pname}) { $type{$pname}=$ptype; }
   90:       $value{$pname}=$pvalue;
   91:   } split(/\:/,$ENV{'form.parms'});
   92:   
   93: # --------------------------------------------------- Print input screen header
   94:     $r->print(<<ENDHEADER);
   95: <html>
   96: <head>
   97: <title>The LearningOnline Network with CAPA</title>
   98: <script language="JavaScript">
   99: 
  100:     function pclose() {
  101:         parmwin=window.open("/adm/rat/empty.html","LONCAPAparms",
  102:                  "height=350,width=350,scrollbars=no,menubar=no");
  103:         parmwin.close();
  104:     }
  105: 
  106:     function pjump(type,dis,value,marker,ret,call) {
  107:         parmwin=window.open("/adm/rat/parameter.html?type="+escape(type)
  108:                  +"&value="+escape(value)+"&marker="+escape(marker)
  109:                  +"&return="+escape(ret)
  110:                  +"&call="+escape(call)+"&name="+escape(dis),"LONCAPAparms",
  111:                  "height=350,width=350,scrollbars=no,menubar=no");
  112: 
  113:     }
  114: 
  115:     function stpr() {
  116:         eval("document.parameters."+document.parameters.pres_marker.value+
  117:             ".value=document.parameters.pres_value.value");
  118:         pclose();
  119:     }
  120: 
  121: 
  122: function setparms() {
  123: ENDHEADER
  124:     $r->print('var colon=""; opener.objparms['.$ENV{'form.resid'}.']="";');
  125:     map {
  126:        $r->print("\nif (document.parameters.def_".$_.
  127:        '.checked) { opener.objparms['.$ENV{'form.resid'}.
  128:        ']+=colon+"'.$type{$_}.
  129:        '___'.$_.'___"+document.parameters.'.$_.'.value; colon=":"; }'); 
  130:     } keys %content;
  131:     $r->print(<<ENDDOCUMENT);
  132:     opener.save();
  133:     window.close();
  134: }
  135: </script>
  136: </head>
  137: <body bgcolor="#FFFFFF">
  138: <h1>Set Resource Parameters in Map</h1>
  139: <form action="javascript:setparms();" method="post" name="parameters">
  140: <input type="hidden" value='' name="pres_value">
  141: <input type="hidden" value='' name="pres_type">
  142: <input type="hidden" value='' name="pres_marker">
  143: <table border=2>
  144: <tr><th>Parameter</th><th>Default</th><th>Value</th><th>Set?</th></tr>
  145: ENDDOCUMENT
  146:     map {
  147:         my $cur=$content{$_};
  148:         if (defined($value{$_})) { $cur=$value{$_}; };
  149:         $r->print('<tr><td><b>'.$display{$_}.'</b><br><tt>'.$_.
  150:         '</tt></td><td>&nbsp;'.$content{$_}.
  151:         '</td><td><input type="text" size="10" name="'.$_.'" value="'.$cur.
  152:         '">&nbsp;<a href='."'".'javascript:pjump("'.
  153: 		  $type{$_}.'","'.
  154:                   $display{$_}.'",document.parameters.'.$_.
  155:                   '.value,"'.$_.'","parameters.pres","stpr");'."'>Enter</a>".
  156:         '</td><td><input type="checkbox" name="def_'.$_.
  157:         '"');
  158:         if ($value{$_}) { $r->print(' checked'); }
  159:         $r->print('></td></tr>');
  160:     } keys %content;
  161:     $r->print(
  162:         '</table><br><input type="submit" value="Set"></form></body></html>');
  163:     return OK;
  164: } 
  165: 
  166: 1;
  167: __END__
  168: 

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