version 1.22, 2002/05/20 18:54:55
|
version 1.30, 2002/06/04 13:23:54
|
Line 36 use strict;
|
Line 36 use strict;
|
use Apache::Constants qw(:common); |
use Apache::Constants qw(:common); |
use Apache::lonnet; |
use Apache::lonnet; |
use Apache::lonratsrv; |
use Apache::lonratsrv; |
|
use Apache::lonsequence; |
|
|
my @order=(); |
my @order; |
my @resources=(); |
my @resources; |
|
|
|
|
# Mapread read maps into global arrays @links and @resources, determines status |
# Mapread read maps into global arrays @links and @resources, determines status |
Line 52 sub mapread {
|
Line 53 sub mapread {
|
undef @links; |
undef @links; |
undef @resources; |
undef @resources; |
undef @order; |
undef @order; |
|
@resources=(''); |
|
@order=(); |
|
|
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 88 sub mapread {
|
Line 91 sub mapread {
|
} |
} |
|
|
} |
} |
for (my $i=0; $i<=$#resources; $i++) { |
for (my $i=1; $i<=$#resources; $i++) { |
if (defined($resources[$i])) { |
if (defined($resources[$i])) { |
unless (($starters[$i]) || ($endings[$i])) { |
unless (($starters[$i]) || ($endings[$i])) { |
return |
return |
Line 127 sub mapread {
|
Line 130 sub mapread {
|
} |
} |
|
|
# ---------------------------------------------- Read a map as well as possible |
# ---------------------------------------------- Read a map as well as possible |
|
# Also used by the sequence handler |
|
# Call lonsequence::attemptread to read from resource space |
|
# |
sub attemptread { |
sub attemptread { |
my $fn=shift; |
my $fn=shift; |
|
|
Line 295 sub pastetarget {
|
Line 300 sub pastetarget {
|
} |
} |
} |
} |
} |
} |
my @oldorder=splice(@order,$after,$#insertorder+1,@insertorder); |
my @oldorder=splice(@order,$after); |
@order=(@order,@oldorder); |
@order=(@order,@insertorder,@oldorder); |
} |
} |
|
|
# ------------------------------------------------ Get start and finish correct |
# ------------------------------------------------ Get start and finish correct |
Line 308 sub startfinish {
|
Line 313 sub startfinish {
|
if ($url=~/http\&colon\:\/\//) { $ext='true'; } |
if ($url=~/http\&colon\:\/\//) { $ext='true'; } |
$resources[$_]=$name.':'.$url.':'.$ext.':normal:res'; |
$resources[$_]=$name.':'.$url.':'.$ext.':normal:res'; |
} |
} |
my ($name,$url,$ext)=split(/\:/,$resources[0]); |
my ($name,$url,$ext)=split(/\:/,$resources[$order[0]]); |
$resources[0]=$name.':'.$url.':'.$ext.':start:res'; |
$resources[$order[0]]=$name.':'.$url.':'.$ext.':start:res'; |
my ($name,$url,$ext)=split(/\:/,$resources[$order[$#order]]); |
my ($name,$url,$ext)=split(/\:/,$resources[$order[$#order]]); |
$resources[$order[$#order]]=$name.':'.$url.':'.$ext.':finish:res'; |
$resources[$order[$#order]]=$name.':'.$url.':'.$ext.':finish:res'; |
} |
} |
Line 333 sub storemap {
|
Line 338 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 351 sub smpedt {
|
Line 356 sub smpedt {
|
my @targetselect=(); |
my @targetselect=(); |
undef @importselect; |
undef @importselect; |
undef @targetselect; |
undef @targetselect; |
if (defined($ENV{'form.import'})) { |
if (defined($ENV{'form.importsel'})) { |
if (ref($ENV{'form.import'})) { |
if (ref($ENV{'form.importsel'})) { |
@importselect=sort($ENV->{'form.import'}); |
@importselect=sort(@{$ENV{'form.importsel'}}); |
} else { |
} else { |
@importselect=($ENV{'form.import'}); |
@importselect=($ENV{'form.importsel'}); |
} |
} |
} |
} |
if (defined($ENV{'form.target'})) { |
if (defined($ENV{'form.target'})) { |
if (ref($ENV{'form.target'})) { |
if (ref($ENV{'form.target'})) { |
@targetselect=sort($ENV->{'form.target'}); |
@targetselect=sort(@{$ENV{'form.target'}}); |
} else { |
} else { |
@targetselect=($ENV{'form.target'}); |
@targetselect=($ENV{'form.target'}); |
} |
} |
Line 439 sub smpedt {
|
Line 444 sub smpedt {
|
} |
} |
|
|
foreach ( |
foreach ( |
&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 459 sub smpedt {
|
Line 464 sub smpedt {
|
# ------------------------------------------------ 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; |
$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'}) { |
} elsif (($ENV{'form.cut'}) || ($ENV{'form.copy'})) { |
|
$importdetail=''; |
|
my @curimport=split(/\&/,$ENV{'form.curimpdetail'}); |
|
|
|
my $lastsel; |
|
|
|
if (defined($importselect[-1])) { |
|
$lastsel=$importselect[-1]; |
|
} else { |
|
$lastsel=$#curimport; |
|
} |
|
|
|
for (my $i=0;$i<=$lastsel;$i++) { |
|
my ($name,$url)=split(/\=/,$curimport[$i]); |
|
if ($url) { |
|
$importdetail.='&'.$name.'='.$url; |
|
} |
|
} |
|
|
|
foreach (@targetselect) { |
|
my ($name,$url)=split(/\:/,$resources[$order[$_-1]]); |
|
if ($url) { |
|
$importdetail.='&'.&Apache::lonnet::escape($name).'='. |
|
&Apache::lonnet::escape($url); |
|
} |
|
} |
|
|
|
for (my $i=$lastsel+1;$i<=$#curimport;$i++) { |
|
my ($name,$url)=split(/\=/,$curimport[$i]); |
|
if ($url) { |
|
$importdetail.='&'.$name.'='.$url; |
|
} |
|
} |
|
$importdetail=~s/\&+/\&/g; |
|
$importdetail=~s/^\&//; |
|
|
|
if ($ENV{'form.cut'}) { |
|
my @neworder=(); |
|
for (my $i=0;$i<=$#order;$i++) { |
|
my $include=1; |
|
foreach (@targetselect) { |
|
if ($_-1==$i) { $include=0; } |
|
} |
|
if ($include) { $neworder[$#neworder+1]=$order[$i]; } |
|
} |
|
@order=@neworder; |
|
&storemap(&Apache::lonnet::filelocation('',$url)); |
|
} |
|
|
# ----------------------------------------------------------------------- Paste |
# ----------------------------------------------------------------------- Paste |
} elsif ($ENV{'form.paste'}) { |
} elsif ($ENV{'form.paste'}) { |
|
my $lastsel; |
|
if (defined($targetselect[-1])) { |
|
$lastsel=$targetselect[-1]; |
|
} else { |
|
$lastsel=$#order+1; |
|
} |
|
my @newsequence; |
|
my @curimport=split(/\&/,$ENV{'form.curimpdetail'}); |
|
foreach (@importselect) { |
|
$newsequence[$#newsequence+1]=$curimport[$_]; |
|
} |
|
&pastetarget($lastsel,@newsequence); |
|
&storemap(&Apache::lonnet::filelocation('',$url)); |
# ------------------------------------------------ |
# ------------------------------------------------ |
} |
} |
# ------------------------------------------------------------ Assemble windows |
# ------------------------------------------------------------ Assemble windows |
|
|
my $idx=-1; |
my $idx=-1; |
my $importwindow=join("\n",map { |
my $importwindow= |
|
'<option value="-1"> ---- Import and Paste Area ---- </option>'. |
|
join("\n",map { |
$idx++; |
$idx++; |
if ($_) { |
if ($_) { |
my ($name,$url)=split(/\=/,$_); |
my ($name,$url)=split(/\=/,$_); |
Line 488 sub smpedt {
|
Line 555 sub smpedt {
|
} split(/\&/,$importdetail)); |
} split(/\&/,$importdetail)); |
|
|
$idx=0; |
$idx=0; |
my $targetwindow=join("\n",map { |
my $targetwindow= |
|
'<option value="0"> ------- Target Edit Map ------- </option>'. |
|
join("\n",map { |
my ($name,$url)=split(/\:/,$resources[$_]); |
my ($name,$url)=split(/\:/,$resources[$_]); |
unless ($name) { $name=(split(/\//,$url))[-1]; } |
unless ($name) { $name=(split(/\//,$url))[-1]; } |
unless ($name) { $name='EMPTY'; } |
unless ($name) { $name='EMPTY'; } |
Line 621 function idxcheck(mode) {
|
Line 690 function idxcheck(mode) {
|
|
|
function viewimport() { |
function viewimport() { |
openview((document.forms.simpleedit.curimpdetail.value.split('&')) |
openview((document.forms.simpleedit.curimpdetail.value.split('&')) |
[document.forms.simpleedit.import.selectedIndex+1]); |
[document.forms.simpleedit.importsel.selectedIndex+1]); |
} |
} |
|
|
</script> |
</script> |
Line 629 function idxcheck(mode) {
|
Line 698 function idxcheck(mode) {
|
<body bgcolor='#FFFFFF'> |
<body bgcolor='#FFFFFF'> |
$buttons |
$buttons |
<font color=red>$errtext</font> |
<font color=red>$errtext</font> |
|
<h1>$url</h1> |
<form name=simpleedit method=post> |
<form name=simpleedit method=post> |
<input type=hidden name=forcesmp value=1> |
<input type=hidden name=forcesmp value=1> |
<table> |
<table> |
Line 658 after selected
|
Line 728 after selected
|
<hr><input type=button onClick="javascript:viewtarget()" value="View"> |
<hr><input type=button onClick="javascript:viewtarget()" value="View"> |
</td></tr> |
</td></tr> |
|
|
<tr><td bgcolor="#FFFFCC"><select name="import" multiple> |
<tr><td bgcolor="#FFFFCC"><select name="importsel" size=10 multiple> |
$importwindow |
$importwindow |
</select> |
</select> |
</td> |
</td> |
Line 666 $importwindow
|
Line 736 $importwindow
|
Cut selected<br> |
Cut selected<br> |
<input type=submit name=cut value='<<<'><p> |
<input type=submit name=cut value='<<<'><p> |
<hr> |
<hr> |
|
Copy selected<br> |
|
<input type=submit name=copy value='<--'><p> |
|
<hr> |
Paste after selected<br> |
Paste after selected<br> |
<input type=submit name=paste value='>>>'> |
<input type=submit name=paste value='-->'> |
</td> |
</td> |
<td bgcolor="#FFFFCC"><select name="target" multiple> |
<td bgcolor="#FFFFCC"><select name="target" size=10 multiple> |
$targetwindow |
$targetwindow |
</select> |
</select> |
</table> |
</table> |
Line 703 sub viewmap {
|
Line 776 sub viewmap {
|
if ($errtext) { |
if ($errtext) { |
$r->print($errtext.'<hr>'); |
$r->print($errtext.'<hr>'); |
} |
} |
|
my $idx=0; |
foreach (&attemptread(&Apache::lonnet::filelocation('',$url))) { |
foreach (&attemptread(&Apache::lonnet::filelocation('',$url))) { |
if (defined($_)) { |
if (defined($_)) { |
|
$idx++; |
my ($title,$url)=split(/\:/,$_); |
my ($title,$url)=split(/\:/,$_); |
$title=~s/\&colon\;/\:/g; |
$title=~s/\&colon\;/\:/g; |
$url=~s/\&colon\;/\:/g; |
$url=~s/\&colon\;/\:/g; |
Line 715 sub viewmap {
|
Line 790 sub viewmap {
|
} |
} |
$r->print(&Apache::lonratsrv::qtescape($title)); |
$r->print(&Apache::lonratsrv::qtescape($title)); |
if ($url) { $r->print('</a>'); } |
if ($url) { $r->print('</a>'); } |
$r->print('<br>'); |
$r->print('<br>'); |
} |
} |
} |
} |
$r->print('</body></html>'); |
$r->print('</body></html>'); |