--- loncom/publisher/lonpublisher.pm 2003/10/21 20:18:45 1.140 +++ loncom/publisher/lonpublisher.pm 2003/11/01 17:38:58 1.142 @@ -1,7 +1,7 @@ # The LearningOnline Network with CAPA # Publication Handler # -# $Id: lonpublisher.pm,v 1.140 2003/10/21 20:18:45 albertel Exp $ +# $Id: lonpublisher.pm,v 1.142 2003/11/01 17:38:58 www Exp $ # # Copyright Michigan State University Board of Trustees # @@ -214,12 +214,7 @@ sub metaeval { $newentry=~s/^\s*//; if ($newentry !~m|^/res|) { $newentry=$prefix.$newentry; } } - if ($metadatafields{$unikey}) { - unless (($metadatafields{$unikey}=~/\Q$newentry\E/) || - ($newentry eq '')) { - $metadatafields{$unikey}.=', '.$newentry; - } - } else { + unless ($metadatafields{$unikey}=~/\w/) { $metadatafields{$unikey}=$newentry; } } @@ -329,6 +324,9 @@ string which presents the form field (fo ######################################### sub textfield { my ($title,$name,$value)=@_; + $value=~s/^\s+//gs; + $value=~s/\s+$//gs; + $value=~s/\s+/ /gs; $title=&mt($title); my $uctitle=uc($title); return "\n

$uctitle:". @@ -812,6 +810,23 @@ sub store_metadata { return (undef,$status); } + +# ============================================== Parse file itself for metadata + + +sub parseformeta { + my ($source,$style)=@_; + if (($style eq 'ssi') || ($style eq 'prv')) { + my $dir=$source; + $dir=~s-/[^/]*$--; + my $file=$source; + $file=(split('/',$file))[-1]; + $source=&Apache::lonnet::hreflocation($dir,$file); + my $allmeta=&Apache::lonnet::ssi_body($source,('grade_target' => 'meta')); + &metaeval($allmeta); + } +} + ######################################### ######################################### @@ -949,6 +964,9 @@ sub publish { $ENV{'user.domain'}; $metadatafields{'authorspace'}=$cuname.'@'.$cudom; +# ----------------------------------------------------------- Parse file itself + + &parseformeta($source,$style); # ------------------------------------------------ Check out directory hierachy my $thisdisfn=$source; @@ -987,18 +1005,10 @@ sub publish { } } +# ------------------------------------------ See if anything new in file itself + + &parseformeta($source,$style); -# -------------------------------------------------- Parse content for metadata - if (($style eq 'ssi') || ($style eq 'prv')) { - my $dir=$source; - $dir=~s-/[^/]*$--; - my $file=$source; - $file=(split('/',$file))[-1]; - $source=&Apache::lonnet::hreflocation($dir,$file); - $allmeta=&Apache::lonnet::ssi_body($source,('grade_target' => 'meta')); - - &metaeval($allmeta); - } # ---------------- Find and document discrepancies in the parameters and stores my $chparms='';