--- loncom/publisher/lonpublisher.pm 2002/09/10 14:52:35 1.94
+++ loncom/publisher/lonpublisher.pm 2002/09/17 15:01:36 1.96
@@ -1,7 +1,7 @@
# The LearningOnline Network with CAPA
# Publication Handler
#
-# $Id: lonpublisher.pm,v 1.94 2002/09/10 14:52:35 harris41 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 @@ the server's attempts at publication.
#########################################
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 @@ if (-e $target) {
}
# ------------------------------------------------ Provide link to new resource
-
+ unless ($batch) {
my $thisdistarget=$target;
$thisdistarget=~s/^$docroot//;
@@ -1385,11 +1385,83 @@ if (-e $target) {
'
Back to Source'.
'
Back to Source Directory';
-
+ }
}
+#########################################
+
+sub batchpublish {
+ my ($r,$srcfile)=@_;
+ my $thisdisfn=$srcfile;
+ $thisdisfn=~s/\/home\/korte\/public_html\///;
+ $srcfile=~s/\/+/\//g;
+
+
+ undef %metadatafields;
+ undef %metadatakeys;
+ %metadatafields=();
+ %metadatakeys=();
+
+ $r->print('
Publishing '.$thisdisfn.'
');
+# phase two takes
+# my ($source,$target,$style,$distarget,batch)=@_;
+# $ENV{'form.allmeta'}
+
+}
#########################################
+
+sub publishdirectory {
+ my ($r,$fn,$thisdisfn)=@_;
+ my $resdir=
+ $Apache::lonnet::perlvar{'lonDocRoot'}.'/res/'.$cudom.'/'.$cuname.
+ $thisdisfn;
+ $r->print('Directory '.$thisdisfn.'/
'.
+ 'Target: '.$resdir.'
');
+
+ my $dirptr=16384; # Mask indicating a directory in stat.cmode.
+
+ opendir(DIR,$fn);
+ my @files=sort(readdir(DIR));
+ foreach my $filename (@files) {
+ my ($cdev,$cino,$cmode,$cnlink,
+ $cuid,$cgid,$crdev,$csize,
+ $catime,$cmtime,$cctime,
+ $cblksize,$cblocks)=stat($fn.'/'.$filename);
+
+ my $extension='';
+ if ($filename=~/\.(\w+)$/) { $extension=$1; }
+ if ($cmode&$dirptr) {
+ if (($filename!~/^\./) && ($ENV{'form.pubrec'})) {
+ &publishdirectory($r,$fn.'/'.$filename,$thisdisfn.'/'.$filename);
+ }
+ } elsif ((&Apache::loncommon::fileembstyle($extension) ne 'hdn') &&
+ ($filename!~/^[\#\.]/) && ($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('
Skipping '.$filename.'
');
+ }
+ $r->rflush();
+ }
+ }
+ closedir(DIR);
+}
#########################################
=pod
@@ -1531,31 +1603,34 @@ unless ($ENV{'form.phase'} eq 'two') {
$r->send_http_header;
$r->print('LON-CAPA Publishing');
- $r->print(
- '');
+ $r->print(&Apache::loncommon::bodytag('Resource Publication'));
my $thisfn=$fn;
-
-# ---------------------- Evaluate individual file, and then output information.
- {
- $thisfn=~/\.(\w+)$/;
- my $thistype=$1;
- my $thisembstyle=&Apache::loncommon::fileembstyle($thistype);
- my $thistarget=$thisfn;
+ my $thistarget=$thisfn;
- $thistarget=~s/^\/home/$targetdir/;
- $thistarget=~s/\/public\_html//;
+ $thistarget=~s/^\/home/$targetdir/;
+ $thistarget=~s/\/public\_html//;
- my $thisdistarget=$thistarget;
- $thisdistarget=~s/^$docroot//;
+ my $thisdistarget=$thistarget;
+ $thisdistarget=~s/^$docroot//;
- my $thisdisfn=$thisfn;
- $thisdisfn=~s/^\/home\/$cuname\/public_html\///;
+ my $thisdisfn=$thisfn;
+ $thisdisfn=~s/^\/home\/$cuname\/public_html\///;
+
+ if ($fn=~/\/$/) {
+# -------------------------------------------------------- This is a directory
+ &publishdirectory($r,$fn,$thisdisfn);
+
+ } else {
+# ---------------------- Evaluate individual file, and then output information.
+ $thisfn=~/\.(\w+)$/;
+ my $thistype=$1;
+ my $thisembstyle=&Apache::loncommon::fileembstyle($thistype);
$r->print('Publishing '.
&Apache::loncommon::filedescription($thistype).' '.
- $thisdisfn.'
Target: '.$thisdistarget.'');
+ ''.$thisdisfn.
+ 'Target: '.$thisdistarget.'
');
if (($cuname ne $ENV{'user.name'}) || ($cudom ne $ENV{'user.domain'})) {
$r->print('
Co-Author: '.$cuname.' at '.$cudom.