version 1.2, 2006/12/04 14:59:55
|
version 1.9, 2007/12/01 01:59:54
|
Line 29
|
Line 29
|
package LONCAPA::map; |
package LONCAPA::map; |
|
|
use HTML::TokeParser; |
use HTML::TokeParser; |
|
use HTML::Entities(); |
use Apache::lonnet; |
use Apache::lonnet; |
use Apache::lonlocal; |
use Apache::lonlocal; |
use File::Copy; |
use File::Copy; |
Line 144 sub mapread {
|
Line 145 sub mapread {
|
# Call lonsequence::attemptread to read from resource space |
# Call lonsequence::attemptread to read from resource space |
# |
# |
sub attemptread { |
sub attemptread { |
my $fn=shift; |
my ($fn,$unsorted)=@_; |
|
|
my @links; |
my @links; |
my @theseres; |
my @theseres; |
Line 165 sub attemptread {
|
Line 166 sub attemptread {
|
$links[$number]=$content; |
$links[$number]=$content; |
} |
} |
} |
} |
|
if ($unsorted) { |
|
return @theseres; |
|
} |
|
|
# --------------------------------------------------------------- Sort, sort of |
# --------------------------------------------------------------- Sort, sort of |
|
|
Line 244 sub attemptread {
|
Line 248 sub attemptread {
|
# ------------------------------------- Revive zombie idx or get unused number |
# ------------------------------------- Revive zombie idx or get unused number |
|
|
sub getresidx { |
sub getresidx { |
my $url=shift; |
my ($url,$residx)= @_; |
my $max=1+($#resources>$#zombies?$#resources:$#zombies); |
my $max=1+($#resources>$#zombies?$#resources:$#zombies); |
unless ($url) { return $max; } |
unless ($url) { return $max; } |
for (my $i=0; $i<=$#zombies; $i++) { |
for (my $i=0; $i<=$#zombies; $i++) { |
my ($title,$src,$ext,$type)=split(/\:/,$zombies[$i]); |
my ($title,$src,$ext,$type)=split(/\:/,$zombies[$i]); |
if ($src eq $url) { |
if ($src eq $url) { |
undef($zombies[$i]); |
if ($residx) { |
return $i; |
if ($i == $residx) { |
|
undef($zombies[$i]); |
|
return $i; |
|
} |
|
} else { |
|
undef($zombies[$i]); |
|
return $i; |
|
} |
} |
} |
} |
} |
return $max; |
return $max; |
Line 276 sub pastetarget {
|
Line 287 sub pastetarget {
|
my @insertorder=(); |
my @insertorder=(); |
foreach (@which) { |
foreach (@which) { |
if (defined($_)) { |
if (defined($_)) { |
my ($name,$url)=split(/\=/,$_); |
my ($name,$url,$residx)=split(/\=/,$_); |
$name=&unescape($name); |
$name=&unescape($name); |
$url=&unescape($url); |
$url=&unescape($url); |
if ($url) { |
if ($url) { |
my $idx=&getresidx($url); |
my $idx=&getresidx($url,$residx); |
$insertorder[$#insertorder+1]=$idx; |
$insertorder[$#insertorder+1]=$idx; |
my $ext='false'; |
my $ext='false'; |
if ($url=~/^http\:\/\//) { $ext='true'; } |
if ($url=~/^http\:\/\//) { $ext='true'; } |
Line 439 sub qtescape {
|
Line 450 sub qtescape {
|
$str=~s/\&\#58\;/\:/g; |
$str=~s/\&\#58\;/\:/g; |
$str=~s/\&\#39\;/\'/g; |
$str=~s/\&\#39\;/\'/g; |
$str=~s/\&\#44\;/\,/g; |
$str=~s/\&\#44\;/\,/g; |
$str=~s/\"/\&\#34\;/g; |
$str=~s/\&\#34\;/\"/g; |
return $str; |
return $str; |
} |
} |
|
|
Line 476 sub loadmap {
|
Line 487 sub loadmap {
|
if ($instr eq -2) { |
if ($instr eq -2) { |
$errtext.='Map not loaded: An error occured while trying to load the map.'; |
$errtext.='Map not loaded: An error occured while trying to load the map.'; |
} elsif ($instr eq '-1') { |
} elsif ($instr eq '-1') { |
$errtext.=&mt('Map not loaded: The file [_1] does not exist.',$fn); |
# Map doesn't exist |
} elsif ($instr) { |
} elsif ($instr) { |
my $parser = HTML::TokeParser->new(\$instr); |
my $parser = HTML::TokeParser->new(\$instr); |
my $token; |
my $token; |
Line 625 sub savemap {
|
Line 636 sub savemap {
|
# --------------------------------------------------------------- Logical input |
# --------------------------------------------------------------- Logical input |
if (($comp[$#comp] eq 'res') || ($comp[$#comp] eq 'zombie')) { |
if (($comp[$#comp] eq 'res') || ($comp[$#comp] eq 'zombie')) { |
$comp[0]=qtescape($comp[0]); |
$comp[0]=qtescape($comp[0]); |
|
$comp[0] = &HTML::Entities::encode($comp[0],'&<>"'); |
|
|
$comp[1]=qtescape($comp[1]); |
$comp[1]=qtescape($comp[1]); |
if ($comp[2] eq 'true') { |
if ($comp[2] eq 'true') { |
if ($comp[1]!~/^http\:\/\//) { |
if ($comp[1]!~/^http\:\/\//) { |
Line 690 sub savemap {
|
Line 703 sub savemap {
|
} |
} |
} |
} |
$outstr.="</map>\n"; |
$outstr.="</map>\n"; |
if ($fn=~/^\/*uploaded\/(\w+)\/(\w+)\/(.*)$/) { |
if ($fn=~m{^/*uploaded/($LONCAPA::domain_re)/($LONCAPA::courseid_re)/(.*)$}) { |
$env{'form.output'}=$outstr; |
$env{'form.output'}=$outstr; |
my $result=&Apache::lonnet::finishuserfileupload($2,$1, |
my $result=&Apache::lonnet::finishuserfileupload($2,$1, |
'output',$3); |
'output',$3); |