--- loncom/interface/lonmeta.pm	2004/06/17 18:22:13	1.82
+++ loncom/interface/lonmeta.pm	2005/03/16 22:52:04	1.93
@@ -1,7 +1,7 @@
 # The LearningOnline Network with CAPA
 # Metadata display handler
 #
-# $Id: lonmeta.pm,v 1.82 2004/06/17 18:22:13 www Exp $
+# $Id: lonmeta.pm,v 1.93 2005/03/16 22:52:04 matthew Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -71,11 +71,12 @@ sub get_dynamic_metadata_from_sql {
     if (! defined($authordom) || ! defined($author)) {
         return ();
     }
-    my @Fields = ('url',
+    my @Fields = ('url','count','course',
                   'goto','goto_list',
                   'comefrom','comefrom_list',
                   'sequsage','sequsage_list',
                   'stdno','stdno_list',
+		  'dependencies',
                   'avetries','avetries_list',
                   'difficulty','difficulty_list',
                   'disc','disc_list',
@@ -235,9 +236,9 @@ sub diffgraph {
 
 # The field names
 sub fieldnames {
-    return &Apache::lonlocal::texthash
-        (
-         'title' => 'Title',
+    my $file_type=shift;
+    my %fields = 
+        ('title' => 'Title',
          'author' =>'Author(s)',
          'authorspace' => 'Author Space',
          'modifyinguser' => 'Last Modifying User',
@@ -246,7 +247,11 @@ sub fieldnames {
          'notes' => 'Notes',
          'abstract' => 'Abstract',
          'lowestgradelevel' => 'Lowest Grade Level',
-         'highestgradelevel' => 'Highest Grade Level',
+         'highestgradelevel' => 'Highest Grade Level');
+    if (! defined($file_type) || $file_type ne 'portfolio') {
+        %fields = 
+        (%fields,
+         'domain' => 'Domain',
          'standards' => 'Standards',
          'mime' => 'MIME Type',
          'language' => 'Language',
@@ -255,7 +260,7 @@ sub fieldnames {
          'owner' => 'Publisher/Owner',
          'copyright' => 'Copyright/Distribution',
          'customdistributionfile' => 'Custom Distribution File',
-         'sourceavail' => 'Source Availible',
+         'sourceavail' => 'Source Available',
          'sourcerights' => 'Source Custom Distribution File',
          'obsolete' => 'Obsolete',
          'obsoletereplacement' => 'Suggested Replacement for Obsolete File',
@@ -277,7 +282,10 @@ sub fieldnames {
          'stdno'      => 'Total number of students who have worked on this problem',
          'difficulty' => 'Degree of difficulty',
          'disc'       => 'Degree of discrimination',
+	 'dependencies' => 'Resources used by this resource',
          );
+    }
+    return &Apache::lonlocal::texthash(%fields);
 }
 
 # Pretty printing of metadata field
@@ -339,7 +347,7 @@ sub prettyprint {
 	($type eq 'goto_list') ||
 	($type eq 'comefrom_list') ||
 	($type eq 'sequsage_list') ||
-	($type eq 'linkto_list')) {
+	($type eq 'dependencies')) {
 	return '<ul><font size="-1">'.join("\n",map {
             my $url = &Apache::lonnet::clutter($_);
             my $title = &Apache::lonnet::gettitle($url);
@@ -528,13 +536,19 @@ sub handler {
     #
     my ($resdomain,$resuser)=
         (&Apache::lonnet::declutter($uri)=~/^(\w+)\/(\w+)\//);
-    $r->print('<html><head><title>'.
+    my $html=&Apache::lonxml::xmlbegin();
+    $r->print($html.'<head><title>'.
               'Catalog Information'.
               '</title></head>');
     if ($uri=~m:/adm/bombs/(.*)$:) {
         $r->print(&Apache::loncommon::bodytag('Error Messages'));
         # Looking for all bombs?
         &report_bombs($r,$uri);
+    } elsif ($uri=~/\/portfolio\//) {
+        $r->print(&Apache::loncommon::bodytag
+          ('Edit Portfolio File Information','','','',$resdomain));
+        &present_editable_metadata($r,$uri,'portfolio');
+        
     } elsif ($uri=~/^\/\~/) { 
         # Construction space
         $r->print(&Apache::loncommon::bodytag
@@ -542,7 +556,7 @@ sub handler {
         &present_editable_metadata($r,$uri);
     } else {
         $r->print(&Apache::loncommon::bodytag
-                  ('Catalog Information','','','',$resdomain));
+		  ('Catalog Information','','','',$resdomain));
         &present_uneditable_metadata($r,$uri);
     }
     $r->print('</body></html>');
@@ -663,7 +677,7 @@ $disuri<br />
 $obsoletewarning
 $versiondisplay
 </p>
-<table cellspacing=2 border=0>
+<table cellspacing="2" border="0">
 $table
 </table>
 ENDHEAD
@@ -693,7 +707,7 @@ sub print_dynamic_metadata {
         exists($dynmeta{'goto'}) ||
         exists($dynmeta{'course'})) {
         $r->print('<h4>'.&mt('Access and Usage Statistics').'</h4>'.
-                  '<table cellspacing=2 border=0>');
+                  '<table cellspacing="2" border="0">');
         foreach ('count',
                  'sequsage','sequsage_list',
                  'comefrom','comefrom_list',
@@ -718,7 +732,7 @@ sub print_dynamic_metadata {
             $r->print('<h4>'.
                       &mt('Overall Assessment Statistical Data').
                       '</h4>'.
-                      '<table cellspacing=2 border=0>');
+                      '<table cellspacing="2" border="0">');
             $r->print('<tr><td bgcolor="#AAAAAA">'.$lt{'stdno'}.'</td>'.
                       '<td bgcolor="#CCCCCC">'.
                       &prettyprint('stdno',$dynmeta{'stdno'}).
@@ -737,7 +751,7 @@ sub print_dynamic_metadata {
             $r->print('<h4>'.
                       &mt('Detailed Assessment Statistical Data').
                       '</h4>');
-            my $table = '<table cellspacing=2 border=0>'.
+            my $table = '<table cellspacing="2" border="0">'.
                 '<tr>'.
                 '<th>Course</th>'.
                 '<th>Section(s)</th>'.
@@ -797,7 +811,7 @@ sub print_dynamic_metadata {
         exists($dynmeta{'correct'}) || 
         exists($dynmeta{'technical'})){ 
         $r->print('<h4>'.&mt('Evaluation Data').'</h4>'.
-                  '<table cellspacing=2 border=0>');
+                  '<table cellspacing="2" border="0">');
         foreach ('clear','depth','helpful','correct','technical') {
             $r->print('<tr><td bgcolor="#AAAAAA">'.$lt{$_}.'</td>'.
                       '<td bgcolor="#CCCCCC">'.
@@ -868,7 +882,7 @@ sub print_dynamic_metadata {
 #####################################################
 #####################################################
 sub present_editable_metadata {
-    my ($r,$uri) = @_;
+    my ($r,$uri, $file_type) = @_;
     # Construction Space Call
     # Header
     my $disuri=$uri;
@@ -903,26 +917,30 @@ ENDBOMBS
                 &mt('Default Cataloging Information for Directory').' '.
                 $dir;
         }
-        my $bodytag=
-            &Apache::loncommon::bodytag('Edit Catalog Information');
         %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>
 <form method="post" name="defaultmeta">
 ENDEDIT
         $r->print('<script language="JavaScript">'.
-                  &Apache::loncommon::browser_and_searcher_javascript.
+                  &Apache::loncommon::browser_and_searcher_javascript().
                   '</script>');
-        my %lt=&fieldnames();
-        foreach ('author','title','subject','keywords','abstract','notes',
+        my %lt=&fieldnames($file_type);
+	my $output;
+	my @fields;
+	if ($file_type eq 'portfolio') {
+	    @fields =  ('author','title','subject','keywords','abstract','notes','lowestgradelevel',
+	                'highestgradelevel');
+	} else {
+	    @fields = ('author','title','subject','keywords','abstract','notes',
                  'copyright','customdistributionfile','language',
                  'standards',
                  'lowestgradelevel','highestgradelevel','sourceavail','sourcerights',
-                 'obsolete','obsoletereplacement') {
+                 'obsolete','obsoletereplacement');
+        }
+        foreach (@fields) {
             if (defined($ENV{'form.new_'.$_})) {
                 $Apache::lonpublisher::metadatafields{$_}=
                     $ENV{'form.new_'.$_};
@@ -931,17 +949,17 @@ ENDEDIT
                 $Apache::lonpublisher::metadatafields{'copyright'}=
                     'default';
             }
-            $r->print('<p>'.$lt{$_}.': '.
-                      &prettyinput
-                      ($_,$Apache::lonpublisher::metadatafields{$_},
-                       'new_'.$_,'defaultmeta').'</p>');
+            $output.=('<p>'.$lt{$_}.': '.
+                      &prettyinput($_,
+				   $Apache::lonpublisher::metadatafields{$_},
+				   'new_'.$_,'defaultmeta').'</p>');
         }
         if ($ENV{'form.store'}) {
             my $mfh;
             if (!  ($mfh=Apache::File->new('>'.$fn))) {
-                $r->print('<p><font color=red>'.
+                $r->print('<p><font color="red">'.
                           &mt('Could not write metadata').', '.
-                          &mt('FAIL').'</font>');
+                          &mt('FAIL').'</font></p>');
             } else {
                 foreach (sort keys %Apache::lonpublisher::metadatafields) {
                     next if ($_ =~ /\./);
@@ -964,10 +982,12 @@ ENDEDIT
                          '<>&"').
                          '</'.$tag.'>';
                 }
-                $r->print('<p>'.&mt('Wrote Metadata'));
+                $r->print('<p><font color="blue">'.&mt('Wrote Metadata').
+			  ' '.&Apache::lonlocal::locallocaltime(time).
+			  '</font></p>');
             }
         }
-        $r->print('<br /><input type="submit" name="store" value="'.
+	$r->print($output.'<br /><input type="submit" name="store" value="'.
                   &mt('Store Catalog Information').'">');
     }
     $r->print('</form>');