[LON-CAPA-cvs] cvs: loncom /publisher lonpublisher.pm
www
lon-capa-cvs@mail.lon-capa.org
Mon, 28 Feb 2005 21:28:18 -0000
www Mon Feb 28 16:28:18 2005 EDT
Modified files:
/loncom/publisher lonpublisher.pm
Log:
Eventually, we have to stop people from publishing broken stuff.
Index: loncom/publisher/lonpublisher.pm
diff -u loncom/publisher/lonpublisher.pm:1.184 loncom/publisher/lonpublisher.pm:1.185
--- loncom/publisher/lonpublisher.pm:1.184 Mon Jan 24 16:55:20 2005
+++ loncom/publisher/lonpublisher.pm Mon Feb 28 16:28:18 2005
@@ -1,7 +1,7 @@
# The LearningOnline Network with CAPA
# Publication Handler
#
-# $Id: lonpublisher.pm,v 1.184 2005/01/24 21:55:20 albertel Exp $
+# $Id: lonpublisher.pm,v 1.185 2005/02/28 21:28:18 www Exp $
#
# Copyright Michigan State University Board of Trustees
#
@@ -842,6 +842,35 @@
}
+# ========================================== 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('<img src="/adm/lonMisc/bomb.gif" /><font color="red"><b>'.
+ $Apache::lonxml::errorcount.' '.
+ &mt('error(s)').'</b></font> ');
+ }
+ if ($Apache::lonxml::warningcount) {
+ $r->print('<font color="blue">'.
+ $Apache::lonxml::warningcount.' '.
+ &mt('warning(s)').'</font>');
+ }
+ } else {
+ $r->print('<font color="green">'.&mt('ok').'</font>');
+ }
+ $r->rflush();
+ return ($Apache::lonxml::warningcount,$Apache::lonxml::errorcount);
+}
+
# ============================================== Parse file itself for metadata
#
# parses a file with target meta, sets global %metadatafields %metadatakeys
@@ -1007,6 +1036,7 @@
$scrout.=&metaread($logfile,$currentpath.'default.meta',$prefix);
$prefix=~s|^\.\./||;
}
+
# ----------------------------------------------------------- Parse file itself
# read %metadatafields from file itself
@@ -1978,6 +2008,8 @@
# ------------------ 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('<hr />'.$outstring);
} else {