--- loncom/publisher/lonpublisher.pm 2003/11/08 11:20:22 1.145
+++ loncom/publisher/lonpublisher.pm 2003/12/26 18:25:29 1.151
@@ -1,7 +1,7 @@
# The LearningOnline Network with CAPA
# Publication Handler
#
-# $Id: lonpublisher.pm,v 1.145 2003/11/08 11:20:22 albertel Exp $
+# $Id: lonpublisher.pm,v 1.151 2003/12/26 18:25:29 www Exp $
#
# Copyright Michigan State University Board of Trustees
#
@@ -25,24 +25,6 @@
#
# http://www.lon-capa.org/
#
-#
-# (TeX Content Handler
-#
-# 05/29/00,05/30,10/11 Gerd Kortemeyer)
-#
-# 11/28,11/29,11/30,12/01,12/02,12/04,12/23 Gerd Kortemeyer
-# 03/23 Guy Albertelli
-# 03/24,03/29,04/03 Gerd Kortemeyer
-# 05/03,05/05,05/07 Gerd Kortemeyer
-# 06/23,08/07,08/11,8/13,8/17,8/18,8/24,9/26,10/16 Gerd Kortemeyer
-# 12/04,12/05 Guy Albertelli
-# 12/05 Gerd Kortemeyer
-# 12/05 Guy Albertelli
-# 12/06,12/07 Gerd Kortemeyer
-# 12/25 Gerd Kortemeyer
-# YEAR=2002
-# 1/17 Gerd Kortemeyer
-#
###
###############################################################################
@@ -219,9 +201,8 @@ sub metaeval {
$newentry=~s/^\s*//;
if ($newentry !~m|^/res|) { $newentry=$prefix.$newentry; }
}
- unless ($metadatafields{$unikey}=~/\w/) {
- $metadatafields{$unikey}=$newentry;
- }
+# actually store
+ $metadatafields{$unikey}=$newentry;
}
}
}
@@ -267,7 +248,7 @@ sub metaread {
my ($logfile,$fn,$prefix)=@_;
unless (-e $fn) {
print($logfile 'No file '.$fn."\n");
- return '
No file: '.
+ return '
'.&mt('No file').': '.
&Apache::loncfile::display($fn).'';
}
print($logfile 'Processing '.$fn."\n");
@@ -277,7 +258,7 @@ sub metaread {
$metastring=join('',<$metafh>);
}
&metaeval($metastring,$prefix);
- return '
Processed file: '.
+ return '
'.&mt('Processed file').': '.
&Apache::loncfile::display($fn).'';
}
@@ -628,7 +609,7 @@ sub fix_ids_and_indices {
join(', ',@duplicatedids));
if ($duplicateids) {
print $logfile "Duplicate ID(s) exist, ".join(', ',@duplicatedids)."\n";
- my $outstring='Unable to publish file, it contains duplicated ID(s), ID(s) need to be unique. The duplicated ID(s) are: '.join(', ',@duplicatedids).'';
+ my $outstring=''.&mt('Unable to publish file, it contains duplicated ID(s), ID(s) need to be unique. The duplicated ID(s) are').': '.join(', ',@duplicatedids).'';
return ($outstring,1);
}
if ($needsfixup) {
@@ -693,8 +674,15 @@ sub fix_ids_and_indices {
}
if ($lctag eq 'applet') {
my $codebase='';
- if (defined($parms{'codebase'})) {
- my $oldcodebase=$parms{'codebase'};
+ my $havecodebase=0;
+ foreach my $key (keys(%parms)) {
+ if (lc($key) eq 'codebase') {
+ $codebase=$parms{$key};
+ $havecodebase=1;
+ }
+ }
+ if ($havecodebase) {
+ my $oldcodebase=$codebase;
unless ($oldcodebase=~/\/$/) {
$oldcodebase.='/';
}
@@ -708,14 +696,13 @@ sub fix_ids_and_indices {
}
$allow{&absoluteurl($codebase,$target).'/*'}=1;
} else {
- foreach ('archive','code','object') {
- if (defined($parms{$_})) {
- my $oldurl=$parms{$_};
+ foreach my $key (keys(%parms)) {
+ if ($key =~ /(archive|code|object)/i) {
+ my $oldurl=$parms{$key};
my $newurl=&urlfixup($oldurl,$target);
$newurl=~s/\/[^\/]+$/\/\*/;
- print $logfile 'Allow: applet '.$_.':'.
- $oldurl.' allows '.
- $newurl."\n";
+ print $logfile 'Allow: applet '.lc($key).':'.
+ $oldurl.' allows '.$newurl."\n";
$allow{&absoluteurl($newurl,$target)}=1;
}
}
@@ -780,7 +767,7 @@ Returns: (error,status). error is undef
#########################################
#########################################
sub store_metadata {
- my %metadata = %{shift()};
+ my %metadata = @_;
my $error;
# Determine if the table exists
my $status = &Apache::lonmysql::check_table('metadata');
@@ -797,16 +784,6 @@ sub store_metadata {
&Apache::lonnet::logthis($error);
return ($error,undef);
}
- # Remove old value from table
- $status = &Apache::lonmysql::remove_from_table
- ('metadata','url',$metadata{'url'});
- if (! defined($status)) {
- $error = 'Error when removing old values from '.
- 'metadata table in LON-CAPA database.';
- &Apache::lonnet::logthis($error);
- return ($error,undef);
- }
- # Store data in table.
$status = &Apache::lonmysql::store_row('metadata',\%metadata);
if (! defined($status)) {
$error='Error occured storing new values in '.
@@ -868,7 +845,7 @@ sub publish {
my %allow=();
unless ($logfile=Apache::File->new('>>'.$source.'.log')) {
- return ('No write permission to user directory, FAIL',1);
+ return (''.&mt('No write permission to user directory, FAIL').'',1);
}
print $logfile
"\n\n================= Publish ".localtime()." Phase One ================\n".$ENV{'user.name'}.'@'.$ENV{'user.domain'}."\n";
@@ -892,7 +869,7 @@ sub publish {
if ($error) { return ($outstring,$error); }
# ------------------------------------------------------------ Construct Allows
- $scrout.='Dependencies
';
+ $scrout.=''.&mt('Dependencies').'
';
my $allowstr='';
foreach (sort(keys(%allow))) {
my $thisdep=$_;
@@ -910,7 +887,7 @@ sub publish {
if (
&Apache::lonnet::getfile($Apache::lonnet::perlvar{'lonDocRoot'}.'/'.
$thisdep.'.meta') eq '-1') {
- $scrout.= ' - Currently not available'.
+ $scrout.= ' - '.&mt('Currently not available').
'';
} else {
my %temphash=(&Apache::lonnet::declutter($target).'___'.
@@ -975,10 +952,6 @@ 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;
@@ -995,6 +968,10 @@ sub publish {
$scrout.=&metaread($logfile,$currentpath.'default.meta',$prefix);
$prefix=~s|^\.\./||;
}
+# ----------------------------------------------------------- Parse file itself
+# read %metadatafields from file itself
+
+ $allmeta=&parseformeta($source,$style);
# ------------------- Clear out parameters and stores (there should not be any)
@@ -1087,7 +1064,7 @@ sub publish {
unless ($batch) {
$scrout.=
'
'.&mt('Done').'
'; } ######################################### @@ -1852,8 +1857,8 @@ ENDDIFF my ($outstring,$error)=&publish($thisfn,$thistarget,$thisembstyle); $r->print('