--- loncom/publisher/lonpublisher.pm 2005/01/12 20:58:26 1.183 +++ loncom/publisher/lonpublisher.pm 2005/03/03 21:14:10 1.186 @@ -1,7 +1,7 @@ # The LearningOnline Network with CAPA # Publication Handler # -# $Id: lonpublisher.pm,v 1.183 2005/01/12 20:58:26 www Exp $ +# $Id: lonpublisher.pm,v 1.186 2005/03/03 21:14:10 albertel Exp $ # # Copyright Michigan State University Board of Trustees # @@ -548,7 +548,8 @@ sub get_max_ids_indices { my $counter; if ($counter=$addid{$token->[1]}) { if ($counter eq 'id') { - if (defined($token->[2]->{'id'})) { + if (defined($token->[2]->{'id'}) && + $token->[2]->{'id'} !~ /^\s*$/) { $maxid=($token->[2]->{'id'}>$maxid)?$token->[2]->{'id'}:$maxid; if (exists($allids{$token->[2]->{'id'}})) { $duplicateids=1; @@ -560,7 +561,8 @@ sub get_max_ids_indices { $needsfixup=1; } } else { - if (defined($token->[2]->{'index'})) { + if (defined($token->[2]->{'index'}) && + $token->[2]->{'index'} !~ /^\s*$/) { $maxindex=($token->[2]->{'index'}>$maxindex)?$token->[2]->{'index'}:$maxindex; } else { $needsfixup=1; @@ -674,13 +676,15 @@ sub fix_ids_and_indices { if (!$counter) { $counter=$addid{$lctag}; } if ($counter) { if ($counter eq 'id') { - unless (defined($parms{'id'})) { + unless (defined($parms{'id'}) && + $parms{'id'}!~/^\s*$/) { $maxid++; $parms{'id'}=$maxid; print $logfile 'ID: '.$tag.':'.$maxid."\n"; } } elsif ($counter eq 'index') { - unless (defined($parms{'index'})) { + unless (defined($parms{'index'}) && + $parms{'index'}!~/^\s*$/) { $maxindex++; $parms{'index'}=$maxindex; print $logfile 'Index: '.$tag.':'.$maxindex."\n"; @@ -842,6 +846,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 @@ -1007,6 +1040,7 @@ sub publish { $scrout.=&metaread($logfile,$currentpath.'default.meta',$prefix); $prefix=~s|^\.\./||; } + # ----------------------------------------------------------- Parse file itself # read %metadatafields from file itself @@ -1693,7 +1727,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; } @@ -1978,6 +2012,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('
'.$outstring); } else {