--- loncom/publisher/lonpublisher.pm 2005/01/12 16:18:54 1.182
+++ loncom/publisher/lonpublisher.pm 2005/02/28 21:28:18 1.185
@@ -1,7 +1,7 @@
# The LearningOnline Network with CAPA
# Publication Handler
#
-# $Id: lonpublisher.pm,v 1.182 2005/01/12 16:18:54 www Exp $
+# $Id: lonpublisher.pm,v 1.185 2005/02/28 21:28:18 www Exp $
#
# Copyright Michigan State University Board of Trustees
#
@@ -139,6 +139,7 @@ my $cuname;
my $cudom;
my $registered_cleanup;
+my $modified_urls;
=pod
@@ -841,6 +842,35 @@ sub store_metadata {
}
+# ========================================== Parse file for errors and warnings
+
+sub checkonthis {
+ my ($r,$source)=@_;
+ my $oldpath=$ENV{'request.filename'};
+ $ENV{'request.filename'}=$source;
+ &Apache::lonxml::xmlparse($r,'web',
+ &Apache::lonnet::getfile($source));
+ undef($Apache::lonhomework::parsing_a_problem);
+ $ENV{'request.filename'}=$oldpath;
+ if (($Apache::lonxml::errorcount) ||
+ ($Apache::lonxml::warningcount)) {
+ if ($Apache::lonxml::errorcount) {
+ $r->print(''.
+ $Apache::lonxml::errorcount.' '.
+ &mt('error(s)').' ');
+ }
+ if ($Apache::lonxml::warningcount) {
+ $r->print(''.
+ $Apache::lonxml::warningcount.' '.
+ &mt('warning(s)').'');
+ }
+ } else {
+ $r->print(''.&mt('ok').'');
+ }
+ $r->rflush();
+ return ($Apache::lonxml::warningcount,$Apache::lonxml::errorcount);
+}
+
# ============================================== Parse file itself for metadata
#
# parses a file with target meta, sets global %metadatafields %metadatakeys
@@ -1006,6 +1036,7 @@ sub publish {
$scrout.=&metaread($logfile,$currentpath.'default.meta',$prefix);
$prefix=~s|^\.\./||;
}
+
# ----------------------------------------------------------- Parse file itself
# read %metadatafields from file itself
@@ -1545,10 +1576,8 @@ sub phasetwo {
$r->rflush;
# ------------------------------------------------------------- Trigger updates
- print $logfile("\nRegistering for notifications: $target $source\n");
- push(@{$ENV{'internal.publication.targetsource'}},[$target,$source]);
+ push(@{$modified_urls},[$target,$source]);
unless ($registered_cleanup) {
- &Apache::lonnet::logthis('Cleanup handler registered');
$r->register_cleanup(\¬ify);
$registered_cleanup=1;
}
@@ -1580,8 +1609,7 @@ sub phasetwo {
# =============================================================== Notifications
sub notify {
# --------------------------------------------------- Send update notifications
- &Apache::lonnet::logthis('Cleanup Phase Publication Handler');
- foreach my $targetsource (@{$ENV{'internal.publication.targetsource'}}){
+ foreach my $targetsource (@{$modified_urls}){
my ($target,$source)=@{$targetsource};
my $logfile=Apache::File->new('>>'.$source.'.log');
print $logfile "\nCleanup phase: Notifications\n";
@@ -1695,7 +1723,7 @@ sub publishdirectory {
$ruid,$rgid,$rrdev,$rsize,
$ratime,$rmtime,$rctime,
$rblksize,$rblocks)=stat($resdir.'/'.$filename);
- if (($rmtime<$cmtime) || ($ENV{'form.forcerepub'})) {
+ if (($rmtime<$cmtime) || ($ENV{'form.forcerepub'} eq 'ON')) {
# previously published, modified now
$publishthis=1;
}
@@ -1824,8 +1852,9 @@ sub handler {
&Apache::loncommon::get_unprocessed_cgi($ENV{'QUERY_STRING'},
['filename']);
-# ------------------------------------------------- Flag for registered cleanup
+# -------------------------------------- Flag and buffer for registered cleanup
$registered_cleanup=0;
+ @{$modified_urls}=();
# -------------------------------------------------------------- Check filename
my $fn=&Apache::lonnet::unescape($ENV{'form.filename'});
@@ -1979,6 +2008,8 @@ ENDDIFF
# ------------------ Publishing from $thisfn to $thistarget with $thisembstyle.
unless ($ENV{'form.phase'} eq 'two') {
+# ---------------------------------------------------------- Parse for problems
+ &checkonthis($r,$thisfn);
my ($outstring,$error)=&publish($thisfn,$thistarget,$thisembstyle);
$r->print('