version 1.73, 2002/02/14 22:01:39
|
version 1.80, 2002/05/07 18:07:46
|
Line 68 use strict;
|
Line 68 use strict;
|
use Apache::File; |
use Apache::File; |
use File::Copy; |
use File::Copy; |
use Apache::Constants qw(:common :http :methods); |
use Apache::Constants qw(:common :http :methods); |
use HTML::TokeParser; |
use HTML::LCParser; |
use Apache::lonxml; |
use Apache::lonxml; |
use Apache::lonhomework; |
use Apache::lonhomework; |
use Apache::loncacc; |
use Apache::loncacc; |
Line 91 my $cudom;
|
Line 91 my $cudom;
|
sub metaeval { |
sub metaeval { |
my $metastring=shift; |
my $metastring=shift; |
|
|
my $parser=HTML::TokeParser->new(\$metastring); |
my $parser=HTML::LCParser->new(\$metastring); |
my $token; |
my $token; |
while ($token=$parser->get_token) { |
while ($token=$parser->get_token) { |
if ($token->[0] eq 'S') { |
if ($token->[0] eq 'S') { |
Line 257 sub publish {
|
Line 257 sub publish {
|
$content=join('',<$org>); |
$content=join('',<$org>); |
} |
} |
{ |
{ |
my $parser=HTML::TokeParser->new(\$content); |
my $parser=HTML::LCParser->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') { |
Line 288 sub publish {
|
Line 288 sub publish {
|
"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::LCParser->new(\$content); |
$parser->xml_mode(1); |
$parser->xml_mode(1); |
my $token; |
my $token; |
while ($token=$parser->get_token) { |
while ($token=$parser->get_token) { |
Line 326 sub publish {
|
Line 326 sub publish {
|
print $logfile 'URL: '.$tag.':'.$oldurl.' - '. |
print $logfile 'URL: '.$tag.':'.$oldurl.' - '. |
$newurl."\n"; |
$newurl."\n"; |
} |
} |
$allow{&absoluteurl($newurl,$target)}=1; |
if (($newurl !~ /^javascript:/i) && |
|
($newurl !~ /^mailto:/i) && |
|
($newurl !~ /^http:/i) && |
|
($newurl !~ /^\#/)) { |
|
$allow{&absoluteurl($newurl,$target)}=1; |
|
} |
} |
} |
last; |
last; |
} |
} |
Line 424 sub publish {
|
Line 429 sub publish {
|
$allowstr=~s/\n+/\n/g; |
$allowstr=~s/\n+/\n/g; |
$outstring=~s/(\<\/[^\>]+\>\s*)$/$allowstr$1/s; |
$outstring=~s/(\<\/[^\>]+\>\s*)$/$allowstr$1/s; |
|
|
|
#Encode any High ASCII characters |
|
$outstring=&HTML::Entities::encode($outstring,"\200-\377"); |
# ------------------------------------------------------------- Write modified |
# ------------------------------------------------------------- Write modified |
|
|
{ |
{ |
Line 549 sub publish {
|
Line 556 sub publish {
|
# ------------------------------------------------------- Now have all metadata |
# ------------------------------------------------------- Now have all metadata |
|
|
$scrout.= |
$scrout.= |
'<form action="/adm/publish" method="post">'. |
'<form name="pubform" action="/adm/publish" method="post">'. |
'<p><input type="submit" value="Finalize Publication" /></p>'. |
'<p><input type="submit" value="Finalize Publication" /></p>'. |
&hiddenfield('phase','two'). |
&hiddenfield('phase','two'). |
&hiddenfield('filename',$ENV{'form.filename'}). |
&hiddenfield('filename',$ENV{'form.filename'}). |
Line 561 sub publish {
|
Line 568 sub publish {
|
|
|
# --------------------------------------------------- Scan content for keywords |
# --------------------------------------------------- Scan content for keywords |
|
|
my $keywordout='<p><b>Keywords:</b><br><table border=2><tr>'; |
my $keywordout=<<"END"; |
|
<script> |
|
function checkAll(field) |
|
{ |
|
for (i = 0; i < field.length; i++) |
|
field[i].checked = true ; |
|
} |
|
|
|
function uncheckAll(field) |
|
{ |
|
for (i = 0; i < field.length; i++) |
|
field[i].checked = false ; |
|
} |
|
</script> |
|
<p><b>Keywords:</b> |
|
<input type="button" value="check all" onclick="javascript:checkAll(document.pubform.keywords)"> |
|
<input type="button" value="uncheck all" onclick="javascript:uncheckAll(document.pubform.keywords)"> |
|
<br /> |
|
END |
|
$keywordout.='<table border=2><tr>'; |
my $colcount=0; |
my $colcount=0; |
my %keywords=(); |
my %keywords=(); |
|
|
Line 587 sub publish {
|
Line 613 sub publish {
|
} |
} |
|
|
foreach (sort keys %keywords) { |
foreach (sort keys %keywords) { |
$keywordout.='<td><input type=checkbox name="key.'.$_.'"'; |
$keywordout.='<td><input type=checkbox name="keywords" value="'.$_.'"'; |
if ($metadatafields{'keywords'}) { |
if ($metadatafields{'keywords'}) { |
if ($metadatafields{'keywords'}=~/$_/) { |
if ($metadatafields{'keywords'}=~/$_/) { |
$keywordout.=' checked'; |
$keywordout.=' checked'; |
Line 662 sub phasetwo {
|
Line 688 sub phasetwo {
|
my ($source,$target,$style,$distarget)=@_; |
my ($source,$target,$style,$distarget)=@_; |
my $logfile; |
my $logfile; |
my $scrout=''; |
my $scrout=''; |
|
|
unless ($logfile=Apache::File->new('>>'.$source.'.log')) { |
unless ($logfile=Apache::File->new('>>'.$source.'.log')) { |
return |
return |
'<font color=red>No write permission to user directory, FAIL</font>'; |
'<font color=red>No write permission to user directory, FAIL</font>'; |
Line 689 sub phasetwo {
|
Line 714 sub phasetwo {
|
$metadatafields{'dependencies'}=$ENV{'form.dependencies'}; |
$metadatafields{'dependencies'}=$ENV{'form.dependencies'}; |
|
|
my $allkeywords=$ENV{'form.addkey'}; |
my $allkeywords=$ENV{'form.addkey'}; |
foreach (keys %ENV) { |
if (exists($ENV{'form.keywords'}) && (ref($ENV{'form.keywords'}))) { |
if ($_=~/^form\.key\.(\w+)/) { |
my @Keywords = @{$ENV{'form.keywords'}}; |
$allkeywords.=','.$1; |
foreach (@Keywords) { |
|
$allkeywords.=','.$_; |
} |
} |
} |
} |
$allkeywords=~s/\W+/\,/; |
$allkeywords=~s/\W+/\,/; |
Line 717 sub phasetwo {
|
Line 743 sub phasetwo {
|
$value=~s/\"/\'\'/g; |
$value=~s/\"/\'\'/g; |
print $mfh ' '.$_.'="'.$value.'"'; |
print $mfh ' '.$_.'="'.$value.'"'; |
} |
} |
print $mfh '>'.$metadatafields{$unikey}.'</'.$tag.'>'; |
print $mfh '>'. |
|
&HTML::Entities::encode($metadatafields{$unikey}) |
|
.'</'.$tag.'>'; |
} |
} |
} |
} |
$scrout.='<p>Wrote Metadata'; |
$scrout.='<p>Wrote Metadata'; |
Line 942 if (-e $target) {
|
Line 970 if (-e $target) {
|
|
|
|
|
return $warning.$scrout. |
return $warning.$scrout. |
'<hr><a href="'.$thisdistarget.'"><font size=+2>View Target</font></a>'. |
'<hr><a href="'.$thisdistarget.'"><font size=+2>View Published Version</font></a>'. |
'<p><a href="'.$thissrc.'"><font size=+2>Back to Source</font></a>'. |
'<p><a href="'.$thissrc.'"><font size=+2>Back to Source</font></a>'. |
'<p><a href="'.$thissrcdir. |
'<p><a href="'.$thissrcdir. |
'"><font size=+2>Back to Source Directory</font></a>'; |
'"><font size=+2>Back to Source Directory</font></a>'; |
Line 962 sub handler {
|
Line 990 sub handler {
|
|
|
# Get query string for limited number of parameters |
# Get query string for limited number of parameters |
|
|
foreach (split(/&/,$ENV{'QUERY_STRING'})) { |
&Apache::loncommon::get_unprocessed_cgi($ENV{'QUERY_STRING'}, |
my ($name, $value) = split(/=/,$_); |
['filename']); |
$value =~ tr/+/ /; |
|
$value =~ s/%([a-fA-F0-9][a-fA-F0-9])/pack("C",hex($1))/eg; |
|
if ($name eq 'filename') { |
|
unless ($ENV{'form.'.$name}) { |
|
$ENV{'form.'.$name}=$value; |
|
} |
|
} |
|
} |
|
|
|
|
|
# -------------------------------------------------------------- Check filename |
# -------------------------------------------------------------- Check filename |
|
|