[LON-CAPA-cvs] cvs: loncom /interface lonmeta.pm

www lon-capa-cvs@mail.lon-capa.org
Fri, 25 Oct 2002 13:50:48 -0000


www		Fri Oct 25 09:50:48 2002 EDT

  Modified files:              
    /loncom/interface	lonmeta.pm 
  Log:
  Bug #492
  
  
Index: loncom/interface/lonmeta.pm
diff -u loncom/interface/lonmeta.pm:1.23 loncom/interface/lonmeta.pm:1.24
--- loncom/interface/lonmeta.pm:1.23	Sun Oct 20 14:40:00 2002
+++ loncom/interface/lonmeta.pm	Fri Oct 25 09:50:48 2002
@@ -1,7 +1,7 @@
 # The LearningOnline Network with CAPA
 # Metadata display handler
 #
-# $Id: lonmeta.pm,v 1.23 2002/10/20 18:40:00 www Exp $
+# $Id: lonmeta.pm,v 1.24 2002/10/25 13:50:48 www Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -360,13 +360,49 @@
 <html><head><title>Edit Catalog Information</title></head>
 $bodytag
 <h1>$displayfile</h1>
+<form method="post">
 ENDEDIT
-   foreach (keys %Apache::lonpublisher::metadatafields) {
-       $r->print('<br />'.$_.' '.$Apache::lonpublisher::metadatafields{$_});
+   foreach ('author','title','subject','keywords','abstract','notes',
+            'copyright','language') {
+       if ($ENV{'form.new_'.$_}) {
+	   $Apache::lonpublisher::metadatafields{$_}=$ENV{'form.new_'.$_};
+       }
+       $r->print(
+         &Apache::lonpublisher::textfield($_,'new_'.$_,
+                                 $Apache::lonpublisher::metadatafields{$_}));
    }
- }
- $r->print('</body></html>');
- return OK;
+   if ($ENV{'form.store'}) {
+      my $mfh;
+      unless ($mfh=Apache::File->new('>'.$fn)) {
+            $r->print(
+            '<p><font color=red>Could not write metadata, FAIL</font>');
+      } else {
+          foreach (sort keys %Apache::lonpublisher::metadatafields) {
+            unless ($_=~/\./) {
+                my $unikey=$_;
+                $unikey=~/^([A-Za-z]+)/;
+                my $tag=$1;
+                $tag=~tr/A-Z/a-z/;
+                print $mfh "\n\<$tag";
+                foreach 
+                  (split(/\,/,$Apache::lonpublisher::metadatakeys{$unikey})) {
+                    my $value=
+                       $Apache::lonpublisher::metadatafields{$unikey.'.'.$_};
+                    $value=~s/\"/\'\'/g;
+                    print $mfh ' '.$_.'="'.$value.'"';
+                }
+                print $mfh '>'.
+        &HTML::Entities::encode($Apache::lonpublisher::metadatafields{$unikey})
+                        .'</'.$tag.'>';
+            }
+	  }
+          $r->print('<p>Wrote Metadata');
+      }
+    }
+    $r->print(
+ '<br /><input type="submit" name="store" value="Store Catalog Information"></form></body></html>');
+    return OK;
+  }
 }
 
 1;