version 1.61, 2004/11/13 21:17:55
|
version 1.67, 2005/06/08 15:44:51
|
Line 173 use Apache::loncommon;
|
Line 173 use Apache::loncommon;
|
use Apache::lonlocal; |
use Apache::lonlocal; |
use File::Copy; |
use File::Copy; |
|
|
use vars qw(@order @resources @resparms); |
use vars qw(@order @resources @resparms @zombies %revzombies); |
|
|
|
|
# Mapread read maps into global arrays @links and @resources, determines status |
# Mapread read maps into global arrays @links and @resources, determines status |
Line 188 sub mapread {
|
Line 188 sub mapread {
|
undef @resources; |
undef @resources; |
undef @order; |
undef @order; |
undef @resparms; |
undef @resparms; |
|
undef @zombies; |
|
undef %revzombies; |
|
|
@resources=(''); |
@resources=(''); |
@order=(); |
@order=(); |
@resparms=(); |
@resparms=(); |
|
@zombies=(); |
|
%revzombies=(); |
|
|
my ($outtext,$errtext)=&Apache::lonratsrv::loadmap($fn,''); |
my ($outtext,$errtext)=&Apache::lonratsrv::loadmap($fn,''); |
if ($errtext) { return ($errtext,2); } |
if ($errtext) { return ($errtext,2); } |
Line 199 sub mapread {
|
Line 204 sub mapread {
|
foreach (split(/\<\&\>/,$outtext)) { |
foreach (split(/\<\&\>/,$outtext)) { |
my ($command,$number,$content)=split(/\<\:\>/,$_); |
my ($command,$number,$content)=split(/\<\:\>/,$_); |
if ($command eq 'objcont') { |
if ($command eq 'objcont') { |
$resources[$number]=$content; |
my ($title,$src,$ext,$type)=split(/\:/,$content); |
|
if ($type ne 'zombie') { |
|
$resources[$number]=$content; |
|
} else { |
|
$zombies[$number]=$content; |
|
$revzombies{$src}=$number; |
|
} |
} |
} |
if ($command eq 'objlinks') { |
if ($command eq 'objlinks') { |
$links[$number]=$content; |
$links[$number]=$content; |
Line 296 sub attemptread {
|
Line 307 sub attemptread {
|
foreach (split(/\<\&\>/,$outtext)) { |
foreach (split(/\<\&\>/,$outtext)) { |
my ($command,$number,$content)=split(/\<\:\>/,$_); |
my ($command,$number,$content)=split(/\<\:\>/,$_); |
if ($command eq 'objcont') { |
if ($command eq 'objcont') { |
$theseres[$number]=$content; |
my ($title,$src,$ext,$type)=split(/\:/,$content); |
|
unless ($type eq 'zombie') { |
|
$theseres[$number]=$content; |
|
} |
} |
} |
if ($command eq 'objlinks') { |
if ($command eq 'objlinks') { |
$links[$number]=$content; |
$links[$number]=$content; |
Line 393 sub attemptread {
|
Line 407 sub attemptread {
|
# --------------------------------------------------------- Build up RAT screen |
# --------------------------------------------------------- Build up RAT screen |
sub ratedt { |
sub ratedt { |
my ($r,$url)=@_; |
my ($r,$url)=@_; |
|
my $frameset = '<frameset rows="1,70,*" border="0">'; |
|
if ($env{'environment.remote'} eq 'off') { |
|
$frameset = '<frameset rows="1,250,*" border="0">'; |
|
} |
$r->print(<<ENDDOCUMENT); |
$r->print(<<ENDDOCUMENT); |
|
|
<html> |
<html> |
Line 401 sub ratedt {
|
Line 419 sub ratedt {
|
var flag=0; |
var flag=0; |
</script> |
</script> |
</head> |
</head> |
<frameset rows="1,50,*" border=0> |
$frameset |
<frame name=server src="$url/loadonly/ratserver" noresize noscroll> |
<frame name=server src="$url/loadonly/ratserver" noresize noscroll> |
<frame name=code src="/adm/rat/code.html"> |
<frame name=code src="$url/loadonly/adveditmenu"> |
<frame name=mapout src="/adm/rat/map.html"> |
<frame name=mapout src="/adm/rat/map.html"> |
</frameset> |
</frameset> |
</html> |
</html> |
Line 533 sub storemap {
|
Line 551 sub storemap {
|
} |
} |
} |
} |
$output=~s/http\&colon\;\/\///g; |
$output=~s/http\&colon\;\/\///g; |
$ENV{'form.output'}=$output; |
$env{'form.output'}=$output; |
return |
return |
&Apache::lonratsrv::loadmap($fn,&Apache::lonratsrv::savemap($fn,'')); |
&Apache::lonratsrv::loadmap($fn,&Apache::lonratsrv::savemap($fn,'')); |
} |
} |
Line 705 sub smpedt {
|
Line 723 sub smpedt {
|
my $buttons=&buttons(2); |
my $buttons=&buttons(2); |
my $tmpfn=&Apache::lonnet::filelocation('',$url).'.tmp'; |
my $tmpfn=&Apache::lonnet::filelocation('',$url).'.tmp'; |
my $targetmsg=''; |
my $targetmsg=''; |
if ($ENV{'form.save'}) { |
if ($env{'form.save'}) { |
copy($tmpfn,&Apache::lonnet::filelocation('',$url)); |
copy($tmpfn,&Apache::lonnet::filelocation('',$url)); |
unlink($tmpfn); |
unlink($tmpfn); |
my ($errtext,$fatal)= |
my ($errtext,$fatal)= |
Line 716 sub smpedt {
|
Line 734 sub smpedt {
|
$targetmsg='<b>'.&mt('An error occured while saving.').'</b><br />'; |
$targetmsg='<b>'.&mt('An error occured while saving.').'</b><br />'; |
} |
} |
} |
} |
if ($ENV{'form.revert'}) { |
if ($env{'form.revert'}) { |
$targetmsg='<b>'.&mt('Reverted.').'</b><br />'; |
$targetmsg='<b>'.&mt('Reverted.').'</b><br />'; |
unlink($tmpfn); |
unlink($tmpfn); |
my ($errtext,$fatal)= |
my ($errtext,$fatal)= |
Line 729 sub smpedt {
|
Line 747 sub smpedt {
|
} |
} |
# ---------------------------------------------------------- Process form input |
# ---------------------------------------------------------- Process form input |
|
|
my @importselect=(); |
my @importselect=&Apache::loncommon::get_env_multiple('form.importsel'); |
my @targetselect=(); |
my @targetselect=&Apache::loncommon::get_env_multiple('form.target'); |
undef @importselect; |
|
undef @targetselect; |
|
if (defined($ENV{'form.importsel'})) { |
|
if (ref($ENV{'form.importsel'})) { |
|
@importselect=sort(@{$ENV{'form.importsel'}}); |
|
} else { |
|
@importselect=($ENV{'form.importsel'}); |
|
} |
|
} |
|
if (defined($ENV{'form.target'})) { |
|
if (ref($ENV{'form.target'})) { |
|
@targetselect=sort(@{$ENV{'form.target'}}); |
|
} else { |
|
@targetselect=($ENV{'form.target'}); |
|
} |
|
} |
|
# ============================================================ Process commands |
# ============================================================ Process commands |
|
|
my $targetdetail=$ENV{'form.targetdetail'}; |
my $targetdetail=$env{'form.targetdetail'}; |
my $importdetail=$ENV{'form.curimpdetail'}; |
my $importdetail=$env{'form.curimpdetail'}; |
|
|
# ---------------------------------------------------- Importing from groupsort |
# ---------------------------------------------------- Importing from groupsort |
if (($ENV{'form.importdetail'}) && (!$ENV{'form.impfortarget'})) { |
if (($env{'form.importdetail'}) && (!$env{'form.impfortarget'})) { |
|
|
$importdetail=''; |
$importdetail=''; |
my @curimport=split(/\&/,$ENV{'form.curimpdetail'}); |
my @curimport=split(/\&/,$env{'form.curimpdetail'}); |
|
|
my $lastsel; |
my $lastsel; |
|
|
Line 773 sub smpedt {
|
Line 775 sub smpedt {
|
} |
} |
} |
} |
|
|
$importdetail.='&'.$ENV{'form.importdetail'}; |
$importdetail.='&'.$env{'form.importdetail'}; |
|
|
for (my $i=$lastsel+1;$i<=$#curimport;$i++) { |
for (my $i=$lastsel+1;$i<=$#curimport;$i++) { |
my ($name,$url)=split(/\=/,$curimport[$i]); |
my ($name,$url)=split(/\=/,$curimport[$i]); |
Line 785 sub smpedt {
|
Line 787 sub smpedt {
|
$importdetail=~s/^\&//; |
$importdetail=~s/^\&//; |
|
|
# ------------------------------------------------------------------- Clear all |
# ------------------------------------------------------------------- Clear all |
} elsif ($ENV{'form.clear'}) { |
} elsif ($env{'form.clear'}) { |
$importdetail=''; |
$importdetail=''; |
# ------------------------------------------------------------ Discard selected |
# ------------------------------------------------------------ Discard selected |
} elsif ($ENV{'form.discard'}) { |
} elsif ($env{'form.discard'}) { |
$importdetail=''; |
$importdetail=''; |
my @curimport=split(/\&/,$ENV{'form.curimpdetail'}); |
my @curimport=split(/\&/,$env{'form.curimpdetail'}); |
foreach (@importselect) { |
foreach (@importselect) { |
$curimport[$_]=''; |
$curimport[$_]=''; |
} |
} |
Line 801 sub smpedt {
|
Line 803 sub smpedt {
|
} |
} |
} |
} |
# --------------------------------------------------------- Loading another map |
# --------------------------------------------------------- Loading another map |
} elsif ($ENV{'form.loadmap'}) { |
} elsif ($env{'form.loadmap'}) { |
$importdetail=''; |
$importdetail=''; |
my @curimport=split(/\&/,$ENV{'form.curimpdetail'}); |
my @curimport=split(/\&/,$env{'form.curimpdetail'}); |
|
|
my $lastsel; |
my $lastsel; |
|
|
Line 821 sub smpedt {
|
Line 823 sub smpedt {
|
} |
} |
|
|
foreach ( |
foreach ( |
&Apache::lonsequence::attemptread(&Apache::lonnet::filelocation('',$ENV{'form.importmap'}))) { |
&Apache::lonsequence::attemptread(&Apache::lonnet::filelocation('',$env{'form.importmap'}))) { |
my ($name,$url)=split(/\:/,$_); |
my ($name,$url)=split(/\:/,$_); |
if ($url) { |
if ($url) { |
$importdetail.='&'.&Apache::lonnet::escape($name).'='. |
$importdetail.='&'.&Apache::lonnet::escape($name).'='. |
Line 839 sub smpedt {
|
Line 841 sub smpedt {
|
$importdetail=~s/^\&//; |
$importdetail=~s/^\&//; |
|
|
# ------------------------------------------------ Groupimport/search to target |
# ------------------------------------------------ Groupimport/search to target |
} elsif ($ENV{'form.importdetail'}) { |
} elsif ($env{'form.importdetail'}) { |
my $lastsel; |
my $lastsel; |
if (defined($targetselect[-1])) { |
if (defined($targetselect[-1])) { |
$lastsel=$targetselect[-1]; |
$lastsel=$targetselect[-1]; |
} else { |
} else { |
$lastsel=$#order+1; |
$lastsel=$#order+1; |
} |
} |
&pastetarget($lastsel,split(/\&/,$ENV{'form.importdetail'})); |
&pastetarget($lastsel,split(/\&/,$env{'form.importdetail'})); |
&storemap(&Apache::lonnet::filelocation('',$url)); |
&storemap(&Apache::lonnet::filelocation('',$url)); |
# ------------------------------------------------------------------------- Cut |
# ------------------------------------------------------------------------- Cut |
} elsif (($ENV{'form.cut'}) || ($ENV{'form.copy'})) { |
} elsif (($env{'form.cut'}) || ($env{'form.copy'})) { |
$importdetail=''; |
$importdetail=''; |
my @curimport=split(/\&/,$ENV{'form.curimpdetail'}); |
my @curimport=split(/\&/,$env{'form.curimpdetail'}); |
|
|
my $lastsel; |
my $lastsel; |
|
|
Line 885 sub smpedt {
|
Line 887 sub smpedt {
|
$importdetail=~s/\&+/\&/g; |
$importdetail=~s/\&+/\&/g; |
$importdetail=~s/^\&//; |
$importdetail=~s/^\&//; |
|
|
if ($ENV{'form.cut'}) { |
if ($env{'form.cut'}) { |
my @neworder=(); |
my @neworder=(); |
for (my $i=0;$i<=$#order;$i++) { |
for (my $i=0;$i<=$#order;$i++) { |
my $include=1; |
my $include=1; |
Line 899 sub smpedt {
|
Line 901 sub smpedt {
|
} |
} |
|
|
# ----------------------------------------------------------------------- Paste |
# ----------------------------------------------------------------------- Paste |
} elsif ($ENV{'form.paste'}) { |
} elsif ($env{'form.paste'}) { |
my $lastsel; |
my $lastsel; |
if (defined($targetselect[-1])) { |
if (defined($targetselect[-1])) { |
$lastsel=$targetselect[-1]; |
$lastsel=$targetselect[-1]; |
Line 907 sub smpedt {
|
Line 909 sub smpedt {
|
$lastsel=$#order+1; |
$lastsel=$#order+1; |
} |
} |
my @newsequence; |
my @newsequence; |
my @curimport=split(/\&/,$ENV{'form.curimpdetail'}); |
my @curimport=split(/\&/,$env{'form.curimpdetail'}); |
foreach (@importselect) { |
foreach (@importselect) { |
$newsequence[$#newsequence+1]=$curimport[$_]; |
$newsequence[$#newsequence+1]=$curimport[$_]; |
} |
} |
&pastetarget($lastsel,@newsequence); |
&pastetarget($lastsel,@newsequence); |
&storemap(&Apache::lonnet::filelocation('',$url)); |
&storemap(&Apache::lonnet::filelocation('',$url)); |
# -------------------------------------------------------------------- Move up |
# -------------------------------------------------------------------- Move up |
} elsif ($ENV{'form.moveup'}) { |
} elsif ($env{'form.moveup'}) { |
foreach (sort @targetselect) { |
foreach (sort @targetselect) { |
if ($_-1>0) { |
if ($_-1>0) { |
my $movethis=$order[$_-1]; |
my $movethis=$order[$_-1]; |
Line 924 sub smpedt {
|
Line 926 sub smpedt {
|
} |
} |
&storemap(&Apache::lonnet::filelocation('',$url)); |
&storemap(&Apache::lonnet::filelocation('',$url)); |
# ------------------------------------------------------------------ Move down |
# ------------------------------------------------------------------ Move down |
} elsif ($ENV{'form.movedown'}) { |
} elsif ($env{'form.movedown'}) { |
foreach (reverse sort @targetselect) { |
foreach (reverse sort @targetselect) { |
if ($_-1<$#order) { |
if ($_-1<$#order) { |
my $movethis=$order[$_-1]; |
my $movethis=$order[$_-1]; |
Line 934 sub smpedt {
|
Line 936 sub smpedt {
|
} |
} |
&storemap(&Apache::lonnet::filelocation('',$url)); |
&storemap(&Apache::lonnet::filelocation('',$url)); |
# --------------------------------------------------------------------- Rename |
# --------------------------------------------------------------------- Rename |
} elsif ($ENV{'form.renameres'}) { |
} elsif ($env{'form.renameres'}) { |
my $residx=$Apache::lonratedt::order[$ENV{'form.renameidx'}-1]; |
my $residx=$Apache::lonratedt::order[$env{'form.renameidx'}-1]; |
my ($name,@resrest)=split(/\:/,$Apache::lonratedt::resources[$residx]); |
my ($name,@resrest)=split(/\:/,$Apache::lonratedt::resources[$residx]); |
$name=$ENV{'form.renametitle'}; |
$name=$env{'form.renametitle'}; |
$name=~s/\:/\&colon\;/g; |
$name=~s/\:/\&colon\;/g; |
$Apache::lonratedt::resources[$residx]=$name.':'.join(':',@resrest); |
$Apache::lonratedt::resources[$residx]=$name.':'.join(':',@resrest); |
&storemap(&Apache::lonnet::filelocation('',$url)); |
&storemap(&Apache::lonnet::filelocation('',$url)); |
Line 978 sub smpedt {
|
Line 980 sub smpedt {
|
# ----------------------------------------------------- Start simple RAT screen |
# ----------------------------------------------------- Start simple RAT screen |
my $editscript=&editscript('simple'); |
my $editscript=&editscript('simple'); |
my $bodytag=&Apache::loncommon::bodytag(undef,undef,undef, |
my $bodytag=&Apache::loncommon::bodytag(undef,undef,undef, |
($ENV{'environment.remote'} ne 'off')). |
($env{'environment.remote'} ne 'off')). |
&Apache::loncommon::help_open_menu('','Sequence_Simple_Editor_Creation','Sequence_Simple_Editor_Creation','',6,'RAT'); |
&Apache::loncommon::help_open_menu('','Sequence_Simple_Editor_Creation','Sequence_Simple_Editor_Creation','',6,'RAT'); |
my %lt=&Apache::lonlocal::texthash( |
my %lt=&Apache::lonlocal::texthash( |
'sa' => 'Save', |
'sa' => 'Save', |
Line 1145 sub viewmap {
|
Line 1147 sub viewmap {
|
if ($adv) { |
if ($adv) { |
$r->print('<p><b><font color="red">'.&mt('Map contents are not shown in order.').'</font></b></p><br />'); |
$r->print('<p><b><font color="red">'.&mt('Map contents are not shown in order.').'</font></b></p><br />'); |
} |
} |
|
$r->print( '<table border="0" cellspacing="2" cellpadding="4">'. |
|
'<tr bgcolor="#DDDDDD"><th>'.&mt('Type').'</th>'. |
|
'<th>'.&mt('Title in map').'</th>'. |
|
'<th>'.&mt('Filename of resource').'</th>'. |
|
'<th>'.&mt('Link to published resource').'</th>'. |
|
'<th>'.&mt('Link to resource in Construction Space').'</th>'. |
|
'</tr>'); |
|
my @backgroundColors = ("#FFFFFF", "#F6F6F6"); |
foreach (&attemptread(&Apache::lonnet::filelocation('',$url))) { |
foreach (&attemptread(&Apache::lonnet::filelocation('',$url))) { |
if (defined($_)) { |
if (defined($_)) { |
$idx++; |
$idx++; |
my ($title,$url)=split(/\:/,$_); |
my ($title,$url,$cond)=split(/\:/,$_); |
|
if ($cond eq 'cond') { next; } |
$title=~s/\&colon\;/\:/g; |
$title=~s/\&colon\;/\:/g; |
$url=~s/\&colon\;/\:/g; |
$url=~s/\&colon\;/\:/g; |
unless ($title) { $title=(split(/\//,$url))[-1] }; |
unless ($title) { $title=(split(/\//,$url))[-1] }; |
unless ($title) { $title='<i>Empty</i>'; } |
unless ($title) { $title='<i>'.&mt('Empty').'</i>'; } |
|
my $resurl = &Apache::lonratsrv::qtescape($url); |
|
my $resfilepath = $Apache::lonnet::perlvar{'lonDocRoot'}.$resurl; |
|
my $filename; |
|
if ($resurl =~ m#/([^/]+)$#) { |
|
$filename = $1; |
|
} |
|
my $cstrurl = $resurl; |
|
$cstrurl =~ s#^/res/[^/]+/([^/]+)/#/priv/$1/#; |
|
my $bgcol = $idx%2; |
|
$r->print('<tr bgcolor='.$backgroundColors[$bgcol].'><td>'. |
|
'<img src="'.&Apache::loncommon::icon($resfilepath). |
|
'" /></td><td>'.&Apache::lonratsrv::qtescape($title). |
|
'</td><td>'.$filename.'</td><td>'); |
|
if ($url) { |
|
if (-e $resfilepath) { |
|
$r->print('<a href="'.$resurl.'">'.&mt('Resource space').'</a>'); |
|
} else { |
|
$r->print(&mt('unpublished')); |
|
} |
|
} |
|
$r->print('</td><td>'); |
if ($url) { |
if ($url) { |
$r->print('<a href="'.&Apache::lonratsrv::qtescape($url).'">'); |
$r->print('<a href="'.$cstrurl.'">'. |
|
&mt('Construction space').'</a>'); |
} |
} |
$r->print(&Apache::lonratsrv::qtescape($title)); |
$r->print('</td></tr>'."\n"); |
if ($url) { $r->print('</a>'); } |
|
$r->print('<br>'); |
|
} |
} |
} |
} |
|
$r->print('</table>'); |
$r->print('</body></html>'); |
$r->print('</body></html>'); |
} |
} |
|
|
Line 1172 sub handler {
|
Line 1204 sub handler {
|
$r->send_http_header; |
$r->send_http_header; |
|
|
return OK if $r->header_only; |
return OK if $r->header_only; |
my $target = $ENV{'form.grade_target'}; |
my $target = $env{'form.grade_target'}; |
if ($target eq 'meta') { |
if ($target eq 'meta') { |
&Apache::loncommon::content_type($r,'text/html'); |
&Apache::loncommon::content_type($r,'text/html'); |
$r->send_http_header; |
$r->send_http_header; |
Line 1191 sub handler {
|
Line 1223 sub handler {
|
# ------------------------------------------- Determine which tools can be used |
# ------------------------------------------- Determine which tools can be used |
my $adv=0; |
my $adv=0; |
|
|
unless ($ENV{'form.forcesmp'}) { |
unless ($env{'form.forcesmp'}) { |
if ($ENV{'form.forceadv'}) { |
if ($env{'form.forceadv'}) { |
$adv=1; |
$adv=1; |
} elsif (my $fh=Apache::File->new($fn)) { |
} elsif (my $fh=Apache::File->new($fn)) { |
my $allmap=join('',<$fh>); |
my $allmap=join('',<$fh>); |
Line 1210 sub handler {
|
Line 1242 sub handler {
|
|
|
# ----------------------------------- adv==1 now means "graphical MUST be used" |
# ----------------------------------- adv==1 now means "graphical MUST be used" |
|
|
if ($ENV{'form.forceadv'}) { |
if ($env{'form.forceadv'}) { |
&ratedt($r,$url); |
&ratedt($r,$url); |
} elsif ($ENV{'form.forcesmp'}) { |
} elsif ($env{'form.forcesmp'}) { |
&smpedt($r,$url,$errtext); |
&smpedt($r,$url,$errtext); |
} else { |
} else { |
&viewmap($r,$url,$adv,$errtext); |
&viewmap($r,$url,$adv,$errtext); |