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

www lon-capa-cvs@mail.lon-capa.org
Sun, 28 Dec 2003 20:13:00 -0000


www		Sun Dec 28 15:13:00 2003 EDT

  Modified files:              
    /loncom/interface	lonmeta.pm lonsearchcat.pm 
    /loncom/publisher	lonpublisher.pm 
  Log:
  Start consolidating metadata-related subroutines into lonmeta using
  lonmysql
  
  
Index: loncom/interface/lonmeta.pm
diff -u loncom/interface/lonmeta.pm:1.43 loncom/interface/lonmeta.pm:1.44
--- loncom/interface/lonmeta.pm:1.43	Fri Dec 26 16:17:37 2003
+++ loncom/interface/lonmeta.pm	Sun Dec 28 15:12:59 2003
@@ -1,7 +1,7 @@
 # The LearningOnline Network with CAPA
 # Metadata display handler
 #
-# $Id: lonmeta.pm,v 1.43 2003/12/26 21:17:37 www Exp $
+# $Id: lonmeta.pm,v 1.44 2003/12/28 20:12:59 www Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -24,12 +24,7 @@
 # /home/httpd/html/adm/gpl.txt
 #
 # http://www.lon-capa.org/
-#
-# (TeX Content Handler
-#
-# 05/29/00,05/30,10/11 Gerd Kortemeyer)
-#
-# 10/19,10/21,10/23,11/27,08/09/01,12/22,12/24,12/25 Gerd Kortemeyer
+
 
 package Apache::lonmeta;
 
@@ -42,6 +37,10 @@
 use Apache::lonlocal;
 use Apache::lonmysql;
 
+# MySQL table columns
+
+my @columns;
+
 # ----------------------------------------- Fetch and evaluate dynamic metadata
 
 sub dynamicmeta {
@@ -191,6 +190,17 @@
     return $output;
 }
 
+# ==================================================== Turn MySQL row into hash
+
+sub metadata_col_to_hash {
+    my @cols=@_;
+    my %hash=();
+    for (my $i=0; $i<=$#columns; $i++) {
+	$hash{$columns[$i]}=$cols[$i];
+    }
+    return %hash;
+}
+
 # ================================================================ Main Handler
 
 sub handler {
@@ -550,6 +560,11 @@
   }
 }
 
+# ================================================================= BEGIN Block
+BEGIN {
+# Get columns of MySQL metadata table
+    @columns=&Apache::lonmysql::col_order('metadata');
+}
 1;
 __END__
 
Index: loncom/interface/lonsearchcat.pm
diff -u loncom/interface/lonsearchcat.pm:1.198 loncom/interface/lonsearchcat.pm:1.199
--- loncom/interface/lonsearchcat.pm:1.198	Sat Dec 27 18:04:28 2003
+++ loncom/interface/lonsearchcat.pm	Sun Dec 28 15:12:59 2003
@@ -1,7 +1,7 @@
 # The LearningOnline Network with CAPA
 # Search Catalog
 #
-# $Id: lonsearchcat.pm,v 1.198 2003/12/27 23:04:28 www Exp $
+# $Id: lonsearchcat.pm,v 1.199 2003/12/28 20:12:59 www Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -2530,18 +2530,15 @@
     # Check for a comma - if it is there then we do not need to unescape the
     # string.  There seems to be some kind of problem with some items in
     # the database - the entire string gets sent out unescaped...?
-    unless ($result =~ /,/) {
-        $result = &Apache::lonnet::unescape($result);
-    }
-    my @fields=map {
-        &Apache::lonnet::unescape($_);
-    } (split(/\,/,$result));
+#    unless ($result =~ /,/) {
+#        $result = &Apache::lonnet::unescape($result);
+#    }
 # conclude from self to others regarding fields
-    my @columns=&Apache::lonmysql::col_order('metadata');
-    my %Fields=();
-    for (my $i=0; $i<=$#columns; $i++) {
-	$Fields{$columns[$i]}=$fields[$i];
-    }
+    my %Fields=&Apache::lonmeta::metadata_col_to_hash(
+						map {
+						 &Apache::lonnet::unescape($_);
+						} (split(/\,/,$result))
+						      );
 # prettier display
     $Fields{'language'} = 
         &Apache::loncommon::languagedescription($Fields{'language'});
Index: loncom/publisher/lonpublisher.pm
diff -u loncom/publisher/lonpublisher.pm:1.155 loncom/publisher/lonpublisher.pm:1.156
--- loncom/publisher/lonpublisher.pm:1.155	Sat Dec 27 11:58:36 2003
+++ loncom/publisher/lonpublisher.pm	Sun Dec 28 15:12:59 2003
@@ -1,7 +1,7 @@
 # The LearningOnline Network with CAPA
 # Publication Handler
 #
-# $Id: lonpublisher.pm,v 1.155 2003/12/27 16:58:36 www Exp $
+# $Id: lonpublisher.pm,v 1.156 2003/12/28 20:12:59 www Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -126,6 +126,7 @@
 use Apache::lonmysql;
 use Apache::lonlocal;
 use Apache::loncfile;
+use Apache::lonmeta;
 use vars qw(%metadatafields %metadatakeys);
 
 my %addid;
@@ -799,17 +800,13 @@
 	$metadata{'sequsage'}=$metadata{'usage'};
 	$metadata{'sequsage_list'}=$metadata{'usage_list'};
 	my %newmetadata=();
-# retrieve current database column names
-	my @columns=&Apache::lonmysql::col_order('metadata');
 # see if we have old entries
 	my @oldmeta=&Apache::lonmysql::get_rows('metadata',
 						"url LIKE BINARY '".
 						$metadata{'url'}."'");
 	if ($#oldmeta==0) {
-# there is an old value
-	    for (my $i=0; $i<=$#columns; $i++) {
-		$newmetadata{$columns[$i]}=$oldmeta[0]->[$i];
-	    }
+# yes, there is one old entry, transfer to newmetadata
+	    %newmetadata=&Apache::lonmeta::metadata_col_to_hash(@{$oldmeta[0]});
 # remove old entry
 	    $status=&Apache::lonmysql::remove_from_table
 		('metadata','url',$metadata{'url'});
@@ -1652,8 +1649,8 @@
     my $resdir=
 	$Apache::lonnet::perlvar{'lonDocRoot'}.'/res/'.$cudom.'/'.$cuname.'/'.
 	$thisdisfn;
-    $r->print('<h1>Directory <tt>'.$thisdisfn.'</tt></h1>'.
-	      'Target: <tt>'.$resdir.'</tt><br />');
+    $r->print('<h1>'.&mt('Directory').' <tt>'.$thisdisfn.'</tt></h1>'.
+	      &mt('Target').': <tt>'.$resdir.'</tt><br />');
 
     my $dirptr=16384;		# Mask indicating a directory in stat.cmode.
 
@@ -1691,7 +1688,7 @@
 	    if ($publishthis) {
                 &batchpublish($r,$fn.'/'.$filename,$resdir.'/'.$filename);
 	    } else {
-		$r->print('<br />Skipping '.$filename.'<br />');
+		$r->print('<br />'.&mt('Skipping').' '.$filename.'<br />');
 	    }
 	    $r->rflush();
 	}