version 1.27, 2004/04/23 17:30:33
|
version 1.28, 2004/04/23 19:59:01
|
Line 25
|
Line 25
|
# |
# |
# http://www.lon-capa.org/ |
# http://www.lon-capa.org/ |
# |
# |
|
# (Edit Handler for RAT Maps |
|
# (TeX Content Handler |
|
# |
|
# 05/29/00,05/30 Gerd Kortemeyer) |
|
# 7/1 Gerd Kortemeyer) |
|
# 7/1,7/3,7/4,7/7,7/8,7/10,7/26,10/2 Gerd Kortemeyer |
|
# 5/3,06/25,07/03,07/04,07/05 Gerd Kortemeyer |
|
|
package Apache::lonratsrv; |
package Apache::lonratsrv; |
|
|
Line 60 sub qtunescape {
|
Line 66 sub qtunescape {
|
# --------------------------------------------------------- Loads map from disk |
# --------------------------------------------------------- Loads map from disk |
|
|
sub loadmap { |
sub loadmap { |
my ($fn,$errtext)=@_; |
my ($fn,$errtext,$infotext)=@_; |
|
if ($errtext) { return('',$errtext); } |
my $outstr=''; |
my $outstr=''; |
my @obj=(); |
my @obj=(); |
my @links=(); |
my @links=(); |
Line 190 sub loadmap {
|
Line 197 sub loadmap {
|
} else { |
} else { |
$errtext.='Map not loaded: The file does not exist. '; |
$errtext.='Map not loaded: The file does not exist. '; |
} |
} |
return($outstr,$errtext); |
return($outstr,$errtext,$infotext); |
} |
} |
|
|
|
|
Line 198 sub loadmap {
|
Line 205 sub loadmap {
|
|
|
sub savemap { |
sub savemap { |
my ($fn,$errtext)=@_; |
my ($fn,$errtext)=@_; |
|
my $infotext=''; |
my %alltypes; |
my %alltypes; |
my %allvalues; |
my %allvalues; |
if (($fn=~/\.sequence(\.tmp)*$/) || |
if (($fn=~/\.sequence(\.tmp)*$/) || |
Line 298 sub savemap {
|
Line 306 sub savemap {
|
my $fh; |
my $fh; |
if ($fh=Apache::File->new(">$fn")) { |
if ($fh=Apache::File->new(">$fn")) { |
print $fh $outstr; |
print $fh $outstr; |
$errtext.="Map saved as $fn. "; |
$infotext.="Map saved as $fn. "; |
} else { |
} else { |
$errtext.='Could not write file '.$fn.'. Map not saved. '; |
$errtext.='Could not write file '.$fn.'. Map not saved. '; |
} |
} |
Line 307 sub savemap {
|
Line 315 sub savemap {
|
# -------------------------------------------- Cannot write to that file, error |
# -------------------------------------------- Cannot write to that file, error |
$errtext.='Map not saved: The specified path does not exist. '; |
$errtext.='Map not saved: The specified path does not exist. '; |
} |
} |
return $errtext; |
return ($errtext,$infotext); |
} |
} |
|
|
# ================================================================ Main Handler |
# ================================================================ Main Handler |
Line 334 sub handler {
|
Line 342 sub handler {
|
$fn=~s|/[^/]*/ratserver$||; |
$fn=~s|/[^/]*/ratserver$||; |
} |
} |
my $errtext=''; |
my $errtext=''; |
|
my $infotext=''; |
my $outtext=''; |
my $outtext=''; |
|
|
if ($mode ne 'loadonly') { |
if ($mode ne 'loadonly') { |
$errtext=&savemap($fn,$errtext); |
($errtext,$infotext)=&savemap($fn,$errtext); |
} |
} |
($outtext,$errtext)=&loadmap($fn,$errtext); |
($outtext,$errtext,$infotext)=&loadmap($fn,$errtext,$infotext); |
|
|
$r->print(<<ENDDOCUMENT); |
$r->print(<<ENDDOCUMENT); |
<html> |
<html> |
Line 351 sub handler {
|
Line 360 sub handler {
|
parent.flag=1; |
parent.flag=1; |
</script> |
</script> |
ENDDOCUMENT |
ENDDOCUMENT |
if ($errtext ne '') { |
if (($errtext ne '') || ($infotext ne '')) { |
$r->print(<<ENDSCRIPT); |
$r->print(<<ENDSCRIPT); |
<script> |
<script> |
alert("$errtext"); |
alert("$infotext $errtext"); |
</script> |
</script> |
ENDSCRIPT |
ENDSCRIPT |
} |
} |