version 1.31, 2001/06/23 18:26:40
|
version 1.34, 2001/08/11 18:06:25
|
Line 11
|
Line 11
|
# 04/16/2001 Scott Harrison |
# 04/16/2001 Scott Harrison |
# 05/03,05/05,05/07 Gerd Kortemeyer |
# 05/03,05/05,05/07 Gerd Kortemeyer |
# 05/28/2001 Scott Harrison |
# 05/28/2001 Scott Harrison |
# 06/23 Gerd Kortemeyer |
# 06/23,08/07,08/11 Gerd Kortemeyer |
|
|
package Apache::lonpublisher; |
package Apache::lonpublisher; |
|
|
Line 49 sub metaeval {
|
Line 49 sub metaeval {
|
if ($token->[0] eq 'S') { |
if ($token->[0] eq 'S') { |
my $entry=$token->[1]; |
my $entry=$token->[1]; |
my $unikey=$entry; |
my $unikey=$entry; |
|
if (defined($token->[2]->{'package'})) { |
|
$unikey.='_package_'.$token->[2]->{'package'}; |
|
} |
if (defined($token->[2]->{'part'})) { |
if (defined($token->[2]->{'part'})) { |
$unikey.='_'.$token->[2]->{'part'}; |
$unikey.='_'.$token->[2]->{'part'}; |
} |
} |
|
if (defined($token->[2]->{'id'})) { |
|
$unikey.='_'.$token->[2]->{'id'}; |
|
} |
if (defined($token->[2]->{'name'})) { |
if (defined($token->[2]->{'name'})) { |
$unikey.='_'.$token->[2]->{'name'}; |
$unikey.='_'.$token->[2]->{'name'}; |
} |
} |
Line 127 sub selectbox {
|
Line 133 sub selectbox {
|
|
|
# -------------------------------------------------------- Publication Step One |
# -------------------------------------------------------- Publication Step One |
|
|
|
sub makeallowed { |
|
} |
|
|
|
sub urlfixup { |
|
return shift; |
|
} |
|
|
sub publish { |
sub publish { |
|
|
my ($source,$target,$style)=@_; |
my ($source,$target,$style)=@_; |
Line 194 sub publish {
|
Line 207 sub publish {
|
print $logfile "Needs ID and/or index fixup\n". |
print $logfile "Needs ID and/or index fixup\n". |
"Max ID : $maxid (min 10)\n". |
"Max ID : $maxid (min 10)\n". |
"Max Index: $maxindex (min 10)\n"; |
"Max Index: $maxindex (min 10)\n"; |
|
} |
my $outstring=''; |
my $outstring=''; |
my $parser=HTML::TokeParser->new(\$content); |
my $parser=HTML::TokeParser->new(\$content); |
my $token; |
my $token; |
while ($token=$parser->get_token) { |
while ($token=$parser->get_token) { |
if ($token->[0] eq 'S') { |
if ($token->[0] eq 'S') { |
my $counter; |
my $counter; |
if ($counter=$addid{$token->[1]}) { |
my $tag=$token->[1]; |
|
unless ($tag eq 'allow') { |
|
my %parms=%{$token->[2]}; |
|
if ($counter=$addid{$tag}) { |
if ($counter eq 'id') { |
if ($counter eq 'id') { |
if (defined($token->[2]->{'id'})) { |
unless (defined($parms{'id'})) { |
$outstring.=$token->[4]; |
|
} else { |
|
$maxid++; |
$maxid++; |
my $thisid=' id="'.$maxid.'"'; |
$parms{'id'}=$maxid; |
my $fixup=$token->[4]; |
print $logfile 'ID: '.$tag.':'.$maxid."\n"; |
$fixup=~s/(\<\w+)/$1$thisid/; |
|
$outstring.=$fixup; |
|
print $logfile 'ID: '.$fixup."\n"; |
|
} |
} |
} else { |
} elsif ($counter eq 'index') { |
if (defined($token->[2]->{'index'})) { |
unless (defined($parms{'index'})) { |
$outstring.=$token->[4]; |
|
} else { |
|
$maxindex++; |
$maxindex++; |
my $thisindex=' index="'.$maxindex.'"'; |
$parms{'index'}=$maxindex; |
my $fixup=$token->[4]; |
print $logfile 'Index: '.$tag.':'.$maxindex."\n"; |
$fixup=~s/(\<\w+)/$1$thisindex/; |
|
$outstring.=$fixup; |
|
print $logfile 'Index: '.$fixup."\n"; |
|
} |
} |
} |
} |
} else { |
} |
$outstring.=$token->[4]; |
|
} |
map { |
|
if (defined($parms{$_})) { |
|
my $oldurl=$parms{$_}; |
|
my $newurl=&urlfixup($oldurl); |
|
if ($newurl ne $oldurl) { |
|
$parms{$_}=$newurl; |
|
print $logfile 'URL: '.$tag.':'.$oldurl.' - '. |
|
$newurl."\n"; |
|
} |
|
&makeallowed($newurl); |
|
} |
|
} ('src','href','codebase'); |
|
|
|
my $newparmstring=''; |
|
my $endtag=''; |
|
map { |
|
if ($_ eq '/') { |
|
$endtag=' /'; |
|
} else { |
|
my $quote=($parms{$_}=~/\"/?"'":'"'); |
|
$newparmstring.=' '.$_.'='.$quote.$parms{$_}.$quote; |
|
} |
|
} keys %parms; |
|
|
|
$outstring.='<'.$tag.$newparmstring.$endtag.'>'; |
|
} |
} elsif ($token->[0] eq 'E') { |
} elsif ($token->[0] eq 'E') { |
$outstring.=$token->[2]; |
unless ($token->[1] eq 'allow') { |
|
$outstring.=$token->[2]; |
|
} |
} else { |
} else { |
$outstring.=$token->[1]; |
$outstring.=$token->[1]; |
} |
} |
Line 244 sub publish {
|
Line 277 sub publish {
|
print $org $outstring; |
print $org $outstring; |
} |
} |
$content=$outstring; |
$content=$outstring; |
|
|
|
if ($needsfixup) { |
print $logfile "End of ID and/or index fixup\n". |
print $logfile "End of ID and/or index fixup\n". |
"Max ID : $maxid (min 10)\n". |
"Max ID : $maxid (min 10)\n". |
"Max Index: $maxindex (min 10)\n"; |
"Max Index: $maxindex (min 10)\n"; |
Line 310 sub publish {
|
Line 345 sub publish {
|
# -------------------------------------------------- Parse content for metadata |
# -------------------------------------------------- Parse content for metadata |
|
|
$allmeta=Apache::lonxml::xmlparse('meta',$content); |
$allmeta=Apache::lonxml::xmlparse('meta',$content); |
|
|
&metaeval($allmeta); |
&metaeval($allmeta); |
|
|
# ---------------- Find and document discrepancies in the parameters and stores |
# ---------------- Find and document discrepancies in the parameters and stores |
Line 333 sub publish {
|
Line 369 sub publish {
|
my $chparms=''; |
my $chparms=''; |
map { |
map { |
if (($_=~/^parameter/) || ($_=~/^stores/)) { |
if (($_=~/^parameter/) || ($_=~/^stores/)) { |
unless (($metadatafields{$_.'.name'}) || ($_=~/\.\w+$/)) { |
unless (($metadatafields{$_.'.name'}) || |
|
($metadatafields{$_.'.package'}) || ($_=~/\.\w+$/)) { |
print $logfile 'Obsolete: '.$_."\n"; |
print $logfile 'Obsolete: '.$_."\n"; |
$chparms.=$_.' '; |
$chparms.=$_.' '; |
} |
} |