--- loncom/publisher/lonpublisher.pm 2005/02/28 21:28:18 1.185 +++ loncom/publisher/lonpublisher.pm 2005/04/04 23:55:17 1.191 @@ -1,7 +1,7 @@ # The LearningOnline Network with CAPA # Publication Handler # -# $Id: lonpublisher.pm,v 1.185 2005/02/28 21:28:18 www Exp $ +# $Id: lonpublisher.pm,v 1.191 2005/04/04 23:55:17 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"; @@ -846,29 +850,29 @@ sub store_metadata { 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 $result=&Apache::lonnet::ssi_body($uri, + ('grade_target'=>'web', + 'return_only_error_and_warning_counts' => 1)); + my ($errorcount,$warningcount)=split(':',$result); + if (($errorcount) || ($warningcount)) { + $r->print('
'.$uri.': '); + if ($errorcount) { $r->print(''. - $Apache::lonxml::errorcount.' '. + $errorcount.' '. &mt('error(s)').' '); } - if ($Apache::lonxml::warningcount) { + if ($warningcount) { $r->print(''. - $Apache::lonxml::warningcount.' '. + $warningcount.' '. &mt('warning(s)').''); } } else { - $r->print(''.&mt('ok').''); + #$r->print(''.&mt('ok').''); } $r->rflush(); - return ($Apache::lonxml::warningcount,$Apache::lonxml::errorcount); + return ($warningcount,$errorcount); } # ============================================== Parse file itself for metadata @@ -1285,7 +1289,7 @@ END } my $copyright_help = Apache::loncommon::help_open_topic('Publishing_Copyright'); - $intr_scrout =~ s/DISTRIBUTION:/'DISTRIBUTION: ' . $copyright_help/ge; + $intr_scrout =~ s/Distribution:/'Distribution: ' . $copyright_help/ge; $intr_scrout.=&text_with_browse_field('Custom Distribution File','customdistributionfile',$metadatafields{'customdistributionfile'},'rights').$copyright_help; $intr_scrout.=&selectbox('Source Distribution','sourceavail', $defaultsourceoption, @@ -2009,9 +2013,19 @@ ENDDIFF unless ($ENV{'form.phase'} eq 'two') { # ---------------------------------------------------------- Parse for problems - &checkonthis($r,$thisfn); - my ($outstring,$error)=&publish($thisfn,$thistarget,$thisembstyle); - $r->print('
'.$outstring); + my ($warningcount,$errorcount); + if ($thisembstyle eq 'ssi') { + ($warningcount,$errorcount)=&checkonthis($r,$thisfn); + } + unless ($errorcount) { + my ($outstring,$error)= + &publish($thisfn,$thistarget,$thisembstyle); + $r->print('
'.$outstring); + } else { + $r->print('

'. + &mt('The document contains errors and cannot be published.'). + '

'); + } } else { $r->print('
'. &phasetwo($r,$thisfn,$thistarget,$thisembstyle,$thisdistarget));