--- loncom/publisher/lonpublisher.pm 2003/11/01 17:09:52 1.141 +++ loncom/publisher/lonpublisher.pm 2003/12/08 18:26:01 1.146 @@ -1,7 +1,7 @@ # The LearningOnline Network with CAPA # Publication Handler # -# $Id: lonpublisher.pm,v 1.141 2003/11/01 17:09:52 www Exp $ +# $Id: lonpublisher.pm,v 1.146 2003/12/08 18:26:01 sakharuk Exp $ # # Copyright Michigan State University Board of Trustees # @@ -143,6 +143,7 @@ use Apache::lonnet(); use Apache::loncommon(); use Apache::lonmysql; use Apache::lonlocal; +use Apache::loncfile; use vars qw(%metadatafields %metadatakeys); my %addid; @@ -180,6 +181,10 @@ nothing ######################################### ######################################### +# +# Modifies global %metadatafields %metadatakeys +# + sub metaeval { my ($metastring,$prefix)=@_; @@ -214,12 +219,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; } } @@ -267,7 +267,8 @@ sub metaread { my ($logfile,$fn,$prefix)=@_; unless (-e $fn) { print($logfile 'No file '.$fn."\n"); - return '
No file: '.$fn.''; + return '
'.&mt('No file').': '. + &Apache::loncfile::display($fn).''; } print($logfile 'Processing '.$fn."\n"); my $metastring; @@ -276,7 +277,8 @@ sub metaread { $metastring=join('',<$metafh>); } &metaeval($metastring,$prefix); - return '
Processed file: '.$fn.''; + return '
Processed file: '. + &Apache::loncfile::display($fn).''; } ######################################### @@ -815,6 +817,26 @@ sub store_metadata { return (undef,$status); } + +# ============================================== Parse file itself for metadata +# +# parses a file with target meta, sets global %metadatafields %metadatakeys + +sub parseformeta { + my ($source,$style)=@_; + my $allmeta=''; + 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); + } + return $allmeta; +} + ######################################### ######################################### @@ -870,7 +892,7 @@ sub publish { if ($error) { return ($outstring,$error); } # ------------------------------------------------------------ Construct Allows - $scrout.='

Dependencies

'; + $scrout.='

'.&mt('Dependencies').'

'; my $allowstr=''; foreach (sort(keys(%allow))) { my $thisdep=$_; @@ -927,7 +949,8 @@ sub publish { # -------------------------------------------- Initial step done, now metadata. # --------------------------------------- Storage for metadata keys and fields. - +# these are globals +# %metadatafields=(); %metadatakeys=(); @@ -952,6 +975,10 @@ sub publish { $ENV{'user.domain'}; $metadatafields{'authorspace'}=$cuname.'@'.$cudom; +# ----------------------------------------------------------- Parse file itself +# read %metadatafields from file itself + + $allmeta=&parseformeta($source,$style); # ------------------------------------------------ Check out directory hierachy my $thisdisfn=$source; @@ -988,20 +1015,12 @@ sub publish { delete $metadatafields{$_}; } } - - } +# ------------------------------------------ See if anything new in file itself + + $allmeta=&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=''; @@ -1032,7 +1051,9 @@ sub publish { } if ($chparms) { $scrout.='

'.&mt('Obsolete parameters or stored values').': '. - $chparms.'

'; + $chparms.'

'.&mt('Warning!'). + '

'. + &mt('If this resource is in active use, student performance data from the previous version may become inaccessible.').'


'; } # ------------------------------------------------------- Now have all metadata @@ -1066,7 +1087,7 @@ sub publish { unless ($batch) { $scrout.= '
'. - '

'. + '

'. &hiddenfield('phase','two'). &hiddenfield('filename',$ENV{'form.filename'}). &hiddenfield('allmeta',&Apache::lonnet::escape($allmeta)). @@ -1078,6 +1099,9 @@ sub publish { # --------------------------------------------------- Scan content for keywords my $keywords_help = Apache::loncommon::help_open_topic("Publishing_Keywords"); + my $KEYWORDS=&mt('KEYWORDS'); + my $CheckAll=&mt('check all'); + my $UncheckAll=&mt('uncheck all'); my $keywordout=<<"END"; -

KEYWORDS: +

$KEYWORDS: $keywords_help - - + +


END @@ -1126,7 +1150,7 @@ END $scrout.=&textfield('Notes','notes',$metadatafields{'notes'}); $scrout.= - "\n

ABSTRACT:". + "\n

".&mt('ABSTRACT').":". "


". '

';