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

www lon-capa-cvs@mail.lon-capa.org
Sun, 20 Oct 2002 18:40:00 -0000


www		Sun Oct 20 14:40:00 2002 EDT

  Modified files:              
    /loncom/interface	lonmeta.pm 
  Log:
  Toward bug 492
  
  
Index: loncom/interface/lonmeta.pm
diff -u loncom/interface/lonmeta.pm:1.22 loncom/interface/lonmeta.pm:1.23
--- loncom/interface/lonmeta.pm:1.22	Fri Oct 18 09:49:49 2002
+++ loncom/interface/lonmeta.pm	Sun Oct 20 14:40:00 2002
@@ -1,7 +1,7 @@
 # The LearningOnline Network with CAPA
 # Metadata display handler
 #
-# $Id: lonmeta.pm,v 1.22 2002/10/18 13:49:49 www Exp $
+# $Id: lonmeta.pm,v 1.23 2002/10/20 18:40:00 www Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -37,6 +37,8 @@
 use Apache::Constants qw(:common);
 use Apache::lonnet();
 use Apache::loncommon();
+use Apache::lonmsg;
+use Apache::lonpublisher;
 
 # ----------------------------------------- Fetch and evaluate dynamic metadata
 
@@ -149,6 +151,8 @@
 
     my $uri=$r->uri;
 
+  unless ($uri=~/^\/\~/) { 
+# =========================================== This is not in construction space
     my ($resdomain,$resuser)=
            (&Apache::lonnet::declutter($uri)=~/^(\w+)\/(\w+)\//);
 
@@ -179,7 +183,7 @@
   }
 
 # --------------------------------------------------------------- Render Output
-  my ($thisversion)=($uri=~/\.(\d+)\.(\w+)\.meta/);
+  my ($thisversion)=($uri=~/\.(\d+)\.(\w+)\.meta$/);
 my $creationdate=localtime(
  &Apache::loncommon::unsqltime($content{'creationdate'}));
 my $lastrevisiondate=localtime(
@@ -294,7 +298,17 @@
        || ($ENV{'user.role.ca./'.$1.'/'.$2})) {
       $r->print(
   '<h4>Evaluation Comments (visible to author and co-authors only)</h4>'.
-      '<blockquote>'.$dynmeta{'comments'}.'</blockquote>');      
+      '<blockquote>'.$dynmeta{'comments'}.'</blockquote>');
+      $r->print(
+   '<h4>Error Messages (visible to author and co-authors only)</h4>');
+      my %errormsgs=&Apache::lonnet::dump('nohist_res_msgs',$1,$2);
+      foreach (keys %errormsgs) {
+	if ($_=~/^$disuri\_\d+$/) {
+          my %content=&Apache::lonmsg::unpackagemsg($errormsgs{$_});
+	  $r->print('<b>'.$content{'time'}.'</b>: '.$content{'message'}.
+                    '<br />');
+        }
+      }      
    }
 # ------------------------------------------------------------- All other stuff
    $r->print(
@@ -317,8 +331,42 @@
       $r->print("<br>\n");
    }
   }
-  $r->print('</body></html>');
-  return OK;
+# ===================================================== End Resource Space Call
+ } else {
+# ===================================================== Construction Space Call
+
+# ----------------------------------------------------------- Set document type
+
+  $r->content_type('text/html');
+  $r->send_http_header;
+
+  return OK if $r->header_only;
+# ---------------------------------------------------------------------- Header
+  my $bodytag=&Apache::loncommon::bodytag('Edit Catalog Information');
+  my $disuri=$uri;
+  my $fn=&Apache::lonnet::filelocation('',$uri);
+  $disuri=~s/^\/\~\w+//;
+  $disuri=~s/\.meta$//;
+  my $displayfile='Catalog Information for '.$disuri;
+  if ($disuri=~/\/default$/) {
+      my $dir=$disuri;
+      $dir=~s/default$//;
+      $displayfile='Default Cataloging Information for Directory '.$dir;
+  }
+  %Apache::lonpublisher::metadatafields=();
+  %Apache::lonpublisher::metadatakeys=();
+  &Apache::lonpublisher::metaeval(&Apache::lonnet::getfile($fn));
+  $r->print(<<ENDEDIT);
+<html><head><title>Edit Catalog Information</title></head>
+$bodytag
+<h1>$displayfile</h1>
+ENDEDIT
+   foreach (keys %Apache::lonpublisher::metadatafields) {
+       $r->print('<br />'.$_.' '.$Apache::lonpublisher::metadatafields{$_});
+   }
+ }
+ $r->print('</body></html>');
+ return OK;
 }
 
 1;