--- loncom/publisher/lonpublisher.pm 2008/08/01 18:09:38 1.243 +++ loncom/publisher/lonpublisher.pm 2008/08/27 13:07:41 1.247 @@ -1,7 +1,7 @@ # The LearningOnline Network with CAPA # Publication Handler # -# $Id: lonpublisher.pm,v 1.243 2008/08/01 18:09:38 bisitz Exp $ +# $Id: lonpublisher.pm,v 1.247 2008/08/27 13:07:41 raeburn Exp $ # # Copyright Michigan State University Board of Trustees # @@ -118,6 +118,8 @@ use Apache::File; use File::Copy; use Apache::Constants qw(:common :http :methods); use HTML::LCParser; +use HTML::Entities; +use Encode::Encoder; use Apache::lonxml; use Apache::loncacc; use DBI; @@ -264,8 +266,9 @@ sub metaread { my ($logfile,$fn,$prefix)=@_; unless (-e $fn) { print($logfile 'No file '.$fn."\n"); - return '
'.&mt('No file').': '. - &Apache::loncfile::display($fn).''; + return '
' + .&mt('No file: [_1]' + ,' '.&Apache::loncfile::display($fn).'
'); } print($logfile 'Processing '.$fn."\n"); my $metastring; @@ -274,8 +277,9 @@ sub metaread { $metastring=join('',<$metafh>); } &metaeval($metastring,$prefix); - return '
'.&mt('Processed file').': '. - &Apache::loncfile::display($fn).'
'; + return '
' + .&mt('Processed file: [_1]' + ,' '.&Apache::loncfile::display($fn).'
'); } ######################################### @@ -843,15 +847,17 @@ sub store_metadata { # Determine if the table exists my $status = &Apache::lonmysql::check_table('metadata'); if (! defined($status)) { - $error='WARNING: Cannot connect to '. - 'database!'; + $error='' + .&mt('WARNING: Cannot connect to database!') + .''; &Apache::lonnet::logthis($error); return ($error,undef); } if ($status == 0) { # It would be nice to actually create the table.... - $error ='WARNING: The metadata table does not '. - 'exist in the LON-CAPA database.'; + $error ='' + .&mt('WARNING: The metadata table does not exist in the LON-CAPA database!') + .''; &Apache::lonnet::logthis($error); return ($error,undef); } @@ -866,8 +872,9 @@ sub store_metadata { \%metadata); } if (defined($status) && $status ne '') { - $error='Error occured saving new values in '. - 'metadata table in LON-CAPA database'; + $error='' + .&mt('Error occured saving new values in metadata table in LON-CAPA database!') + .''; &Apache::lonnet::logthis($error); &Apache::lonnet::logthis($status); return ($error,undef); @@ -983,30 +990,30 @@ sub publish { if ($error) { return ($outstring,$error); } # ------------------------------------------------------------ Construct Allows - $scrout.='

'.&mt('Dependencies').'

'; + my $outdep=''; # Collect dependencies output data my $allowstr=''; foreach my $thisdep (sort(keys(%allow))) { if ($thisdep !~ /[^\s]/) { next; } if ($thisdep =~/\$/) { - $scrout.='
' + $outdep.='
' .&mt('The resource depends on another resource with variable filename, i.e., [_1].',''.$thisdep.'').'
' .&mt('You likely need to explicitly allow access to all possible dependencies using the [_1]-tag.','<allow>') - .'
'; + ."
\n"; } unless ($style eq 'rat') { $allowstr.="\n".''; } - $scrout.='
'; + $outdep.='
'; if ($thisdep!~/[\*\$]/ && $thisdep!~m|^/adm/|) { - $scrout.=''; + $outdep.=''; } - $scrout.=''.$thisdep.''; + $outdep.=''.$thisdep.''; if ($thisdep!~/[\*\$]/ && $thisdep!~m|^/adm/|) { - $scrout.=''; + $outdep.=''; if ( &Apache::lonnet::getfile($Apache::lonnet::perlvar{'lonDocRoot'}.'/'. $thisdep.'.meta') eq '-1') { - $scrout.= ' - '.&mt('Currently not available'). + $outdep.= ' - '.&mt('Currently not available'). ''; } else { my %temphash=(&Apache::lonnet::declutter($target).'___'. @@ -1019,6 +1026,12 @@ sub publish { } } } + $outdep.='

'; + } + + if ($outdep) { + $scrout.='

'.&mt('Dependencies').'

' + .$outdep } $outstring=~s/\n*(\<\/[^\>]+\>[^<]*)$/$allowstr\n$1\n/s; @@ -1172,17 +1185,22 @@ sub publish { $textonly=~s/\//g; $textonly=~s/\[^\<]+\<\/m\>//g; $textonly=~s/\<[^\>]*\>//g; - $textonly=~tr/A-Z/a-z/; - $textonly=~s/[\$\&][a-z]\w*//g; - $textonly=~s/[^a-z\s]//g; - - foreach ($textonly=~m/(\w+)/g) { - unless ($nokey{$_}) { - $keywords{$_}=1; - } - } - } + #this is a work simplification for german authors for present + $textonly=HTML::Entities::decode($textonly); #decode HTML-character + $textonly=Encode::Encoder::encode('utf8', $textonly); #encode to perl internal unicode + $textonly=~tr/A-ZÜÄÖ/a-züäö/; #add lowercase rule for german "Umlaute" + $textonly=~s/[\$\&][a-z]\w*//g; + $textonly=~s/[^a-z^ü^ä^ö^ß\s]//g; #dont delete german "Umlaute" + + foreach ($textonly=~m/[^\s]+/g) { #match all but whitespaces + unless ($nokey{$_}) { + $keywords{$_}=1; + } + } + + + } foreach my $addkey (split(/[\"\'\,\;]/,$metadatafields{'keywords'})) { $addkey=~s/\s+/ /g; @@ -1203,7 +1221,7 @@ sub publish { my $intr_scrout.='
' .'
'; unless ($env{'form.makeobsolete'}) { - $intr_scrout.='

' + $intr_scrout.='

' .&mt('Searching for your resource will be based on the following metadata. Please provide as much data as possible.') .'

' .'

' .'' .'


' - .&Apache::loncommon::start_data_table() - .&Apache::loncommon::start_data_table_row(); - + .&Apache::loncommon::start_data_table(); + my $cols_per_row = 10; my $colcount=0; + my $wordcount=0; + my $numkeywords = scalar(keys(%keywords)); - foreach (sort keys %keywords) { - $colcount++; - $keywordout.='