[LON-CAPA-cvs] cvs: loncom /interface londocs.pm /publisher lonpublisher.pm /xml lonxml.pm

www lon-capa-cvs@mail.lon-capa.org
Thu, 10 Mar 2005 02:34:59 -0000


www		Wed Mar  9 21:34:59 2005 EDT

  Modified files:              
    /loncom/interface	londocs.pm 
    /loncom/publisher	lonpublisher.pm 
    /loncom/xml	lonxml.pm 
  Log:
  Do document-checking via ssi-call
  Do not let people publish documents with errors
  
  
Index: loncom/interface/londocs.pm
diff -u loncom/interface/londocs.pm:1.169 loncom/interface/londocs.pm:1.170
--- loncom/interface/londocs.pm:1.169	Wed Mar  2 17:26:36 2005
+++ loncom/interface/londocs.pm	Wed Mar  9 21:34:58 2005
@@ -1,7 +1,7 @@
 # The LearningOnline Network
 # Documents
 #
-# $Id: londocs.pm,v 1.169 2005/03/02 22:26:36 raeburn Exp $
+# $Id: londocs.pm,v 1.170 2005/03/10 02:34:58 www Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -1501,23 +1501,19 @@
                      $r->print(' ');
                  }
                  $r->print('- '.&mt('Rendering').': ');
-                 my $oldpath=$ENV{'request.filename'};
-                 $ENV{'request.filename'}=&Apache::lonnet::filelocation('',$url);
-                 &Apache::lonxml::xmlparse($r,'web',
-                   &Apache::lonnet::getfile(
-                    &Apache::lonnet::filelocation('',$url)));
-		 undef($Apache::lonhomework::parsing_a_problem);
-		 $ENV{'request.filename'}=$oldpath;
-                 if (($Apache::lonxml::errorcount) ||
-                     ($Apache::lonxml::warningcount)) {
-		     if ($Apache::lonxml::errorcount) {
+		 my ($errorcount,$warningcount)=split(/:/,
+	       &Apache::lonnet::ssi_body($url,
+			       ('return_only_error_and_warning_counts' => 1)));
+                 if (($errorcount) ||
+                     ($warningcount)) {
+		     if ($errorcount) {
                         $r->print('<img src="/adm/lonMisc/bomb.gif" /><font color="red"><b>'.
-			  $Apache::lonxml::errorcount.' '.
+			  $errorcount.' '.
 				  &mt('error(s)').'</b></font> ');
                      }
-		     if ($Apache::lonxml::warningcount) {
+		     if ($warningcount) {
                         $r->print('<font color="blue">'.
-			  $Apache::lonxml::warningcount.' '.
+			  $warningcount.' '.
 				  &mt('warning(s)').'</font>');
                      }
                  } else {
Index: loncom/publisher/lonpublisher.pm
diff -u loncom/publisher/lonpublisher.pm:1.186 loncom/publisher/lonpublisher.pm:1.187
--- loncom/publisher/lonpublisher.pm:1.186	Thu Mar  3 16:14:10 2005
+++ loncom/publisher/lonpublisher.pm	Wed Mar  9 21:34:58 2005
@@ -1,7 +1,7 @@
 # The LearningOnline Network with CAPA
 # Publication Handler
 #
-# $Id: lonpublisher.pm,v 1.186 2005/03/03 21:14:10 albertel Exp $
+# $Id: lonpublisher.pm,v 1.187 2005/03/10 02:34:58 www Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -850,29 +850,28 @@
 
 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) {
+    my $uri=&Apache::lonnet::hreflocation($source);
+    $uri=~s/\/$//;
+    my ($errorcount,$warningcount)=split(/:/,
+	       &Apache::lonnet::ssi_body($uri,
+				('return_only_error_and_warning_counts' => 1)));
+    if (($errorcount) || ($warningcount)) {
+        $r->print('<br /><tt>'.$uri.'</tt>: ');
+	if ($errorcount) {
 	    $r->print('<img src="/adm/lonMisc/bomb.gif" /><font color="red"><b>'.
-		      $Apache::lonxml::errorcount.' '.
+		      $errorcount.' '.
 		      &mt('error(s)').'</b></font> ');
 	}
-	if ($Apache::lonxml::warningcount) {
+	if ($warningcount) {
 	    $r->print('<font color="blue">'.
-		      $Apache::lonxml::warningcount.' '.
+		      $warningcount.' '.
 		      &mt('warning(s)').'</font>');
 	}
     } else {
 	$r->print('<font color="green">'.&mt('ok').'</font>');
     }
     $r->rflush();
-    return ($Apache::lonxml::warningcount,$Apache::lonxml::errorcount);
+    return ($warningcount,$errorcount);
 }
 
 # ============================================== Parse file itself for metadata
@@ -2013,9 +2012,16 @@
 
 	unless ($ENV{'form.phase'} eq 'two') {
 # ---------------------------------------------------------- Parse for problems
-	    &checkonthis($r,$thisfn);
-	    my ($outstring,$error)=&publish($thisfn,$thistarget,$thisembstyle);
-	    $r->print('<hr />'.$outstring);
+	    my ($warningcount,$errorcount)=&checkonthis($r,$thisfn);
+            unless ($errorcount) {
+		my ($outstring,$error)=
+		    &publish($thisfn,$thistarget,$thisembstyle);
+		$r->print('<hr />'.$outstring);
+	    } else {
+                $r->print('<h3>'.
+		&mt('The document contains errors and cannot be published.').
+			  '</h3>');
+	    }
 	} else {
 	    $r->print('<hr />'.
 	    &phasetwo($r,$thisfn,$thistarget,$thisembstyle,$thisdistarget)); 
Index: loncom/xml/lonxml.pm
diff -u loncom/xml/lonxml.pm:1.360 loncom/xml/lonxml.pm:1.361
--- loncom/xml/lonxml.pm:1.360	Mon Feb 28 22:21:58 2005
+++ loncom/xml/lonxml.pm	Wed Mar  9 21:34:59 2005
@@ -1,7 +1,7 @@
 # The LearningOnline Network with CAPA
 # XML Parser Module 
 #
-# $Id: lonxml.pm,v 1.360 2005/03/01 03:21:58 albertel Exp $
+# $Id: lonxml.pm,v 1.361 2005/03/10 02:34:59 www Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -368,6 +368,9 @@
  }
  &do_registered_ssi();
  if ($Apache::lonxml::counter_changed) { &store_counter() }
+ if ($ENV{'form.return_only_error_and_warning_counts'}) {
+     return "$errorcount:$warningcount";
+ }
  return $finaloutput;
 }