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

www lon-capa-cvs@mail.lon-capa.org
Tue, 17 Sep 2002 15:01:36 -0000


www		Tue Sep 17 11:01:36 2002 EDT

  Modified files:              
    /loncom/publisher	lonpublisher.pm 
  Log:
  Continuing work on mass publication.
  
  
Index: loncom/publisher/lonpublisher.pm
diff -u loncom/publisher/lonpublisher.pm:1.95 loncom/publisher/lonpublisher.pm:1.96
--- loncom/publisher/lonpublisher.pm:1.95	Mon Sep 16 09:05:50 2002
+++ loncom/publisher/lonpublisher.pm	Tue Sep 17 11:01:36 2002
@@ -1,7 +1,7 @@
 # The LearningOnline Network with CAPA
 # Publication Handler
 #
-# $Id: lonpublisher.pm,v 1.95 2002/09/16 13:05:50 www Exp $
+# $Id: lonpublisher.pm,v 1.96 2002/09/17 15:01:36 www Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -1164,7 +1164,7 @@
 #########################################
 sub phasetwo {
 
-    my ($source,$target,$style,$distarget)=@_;
+    my ($source,$target,$style,$distarget,$batch)=@_;
     my $logfile;
     my $scrout='';
     unless ($logfile=Apache::File->new('>>'.$source.'.log')) {
@@ -1368,7 +1368,7 @@
     }
 
 # ------------------------------------------------ Provide link to new resource
-
+  unless ($batch) {
     my $thisdistarget=$target;
     $thisdistarget=~s/^$docroot//;
 
@@ -1385,7 +1385,7 @@
       '<p><a href="'.$thissrc.'"><font size=+2>Back to Source</font></a>'.
       '<p><a href="'.$thissrcdir.
       '"><font size="+2">Back to Source Directory</font></a>';
-
+  }
 }
 
 #########################################
@@ -1395,14 +1395,29 @@
     my $thisdisfn=$srcfile;
     $thisdisfn=~s/\/home\/korte\/public_html\///;
     $srcfile=~s/\/+/\//g;
+
+
+    undef %metadatafields;
+    undef %metadatakeys;
+     %metadatafields=();
+     %metadatakeys=();
+     
     $r->print('<h2>Publishing <tt>'.$thisdisfn.'</tt></h2>');
+# phase two takes
+# my ($source,$target,$style,$distarget,batch)=@_;
+# $ENV{'form.allmeta'}
+
 }
 
 #########################################
 
 sub publishdirectory {
     my ($r,$fn,$thisdisfn)=@_;
-      $r->print('<h1>Directory <tt>'.$thisdisfn.'/</tt></h1>');
+    my $resdir=
+    $Apache::lonnet::perlvar{'lonDocRoot'}.'/res/'.$cudom.'/'.$cuname.
+      $thisdisfn;
+      $r->print('<h1>Directory <tt>'.$thisdisfn.'/</tt></h1>'.
+                'Target: <tt>'.$resdir.'</tt><br />');
 
       my $dirptr=16384;		# Mask indicating a directory in stat.cmode.
 
@@ -1422,7 +1437,26 @@
 	   }
          } elsif ((&Apache::loncommon::fileembstyle($extension) ne 'hdn') &&
                   ($filename!~/^[\#\.]/) && ($filename!~/\~$/)) {
-             &batchpublish($r,$fn.'/'.$filename);
+# find out publication status and/or exiting metadata
+	     my $publishthis=0;
+             if (-e $resdir.'/'.$filename) {
+	        my ($rdev,$rino,$rmode,$rnlink,
+	        $ruid,$rgid,$rrdev,$rsize,
+	        $ratime,$rmtime,$rctime,
+	        $rblksize,$rblocks)=stat($resdir.'/'.$filename);
+	        if ($rmtime<$cmtime) {
+# previously published, modified now
+		    $publishthis=1;
+                }
+	     } else {
+# never published
+		 $publishthis=1;
+	     }
+             if ($publishthis) {
+                &batchpublish($r,$fn.'/'.$filename);
+	     } else {
+                 $r->print('<br />Skipping '.$filename.'<br />');
+             }
              $r->rflush();
          }
       }