version 1.17, 2002/05/15 19:50:37
|
version 1.31, 2002/06/24 14:12:04
|
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 65 sub mapread {
|
Line 68 sub mapread {
|
if ($command eq 'objlinks') { |
if ($command eq 'objlinks') { |
$links[$number]=$content; |
$links[$number]=$content; |
} |
} |
|
if ($command eq 'objparms') { |
|
return('Map has resource parameters. Use advanced editor.',1); |
|
} |
} |
} |
# ------------------------------------------------------- Is this a linear map? |
# ------------------------------------------------------- Is this a linear map? |
my @starters=(); |
my @starters=(); |
Line 88 sub mapread {
|
Line 94 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 133 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 274 sub buttons {
|
Line 282 sub buttons {
|
return $output.'</form><hr>'; |
return $output.'</form><hr>'; |
} |
} |
|
|
|
# ----------------------------------------------------------- Paste into target |
|
# modifies @order, @resources |
|
|
|
sub pastetarget { |
|
my ($after,@which)=@_; |
|
my @insertorder=(); |
|
foreach (@which) { |
|
if (defined($_)) { |
|
my ($name,$url)=split(/\=/,$_); |
|
$name=&Apache::lonnet::unescape($name); |
|
$url=&Apache::lonnet::unescape($url); |
|
if ($url) { |
|
my $idx=$#resources+1; |
|
$insertorder[$#insertorder+1]=$idx; |
|
my $ext='false'; |
|
if ($url=~/^http\:\/\//) { $ext='true'; } |
|
$url=~s/\:/\:/g; |
|
$resources[$idx]=$name.':'.$url.':'.$ext.':normal:res'; |
|
} |
|
} |
|
} |
|
my @oldorder=splice(@order,$after); |
|
@order=(@order,@insertorder,@oldorder); |
|
} |
|
|
|
# ------------------------------------------------ Get start and finish correct |
|
# modifies @resources |
|
|
|
sub startfinish { |
|
foreach (@order) { |
|
my ($name,$url,$ext)=split(/\:/,$resources[$_]); |
|
if ($url=~/http\&colon\:\/\//) { $ext='true'; } |
|
$resources[$_]=$name.':'.$url.':'.$ext.':normal:res'; |
|
} |
|
my ($name,$url,$ext)=split(/\:/,$resources[$order[0]]); |
|
$resources[$order[0]]=$name.':'.$url.':'.$ext.':start:res'; |
|
my ($name,$url,$ext)=split(/\:/,$resources[$order[$#order]]); |
|
$resources[$order[$#order]]=$name.':'.$url.':'.$ext.':finish:res'; |
|
} |
|
|
|
# ------------------------------------------------------------------- Store map |
|
|
|
sub storemap { |
|
my $fn=shift; |
|
&startfinish(); |
|
my $output='graphdef<:>no'; |
|
my $k=1; |
|
for (my $i=0; $i<=$#order; $i++) { |
|
if (defined($resources[$order[$i]])) { |
|
$output.='<&>objcont<:>'.$order[$i].'<:>'.$resources[$order[$i]]; |
|
} |
|
if (defined($order[$i+1])) { |
|
if (defined($resources[$order[$i+1]])) { |
|
$output.='<&>objlinks<:>'.$k.'<:>'. |
|
$order[$i].':'.$order[$i+1].':0'; |
|
$k++; |
|
} |
|
} |
|
} |
|
$output=~s/http\&colon\;\/\///g; |
|
$ENV{'form.output'}=$output; |
|
return |
|
&Apache::lonratsrv::loadmap($fn,&Apache::lonratsrv::savemap($fn,'')); |
|
} |
|
|
|
# ------------------------------------------------------- Simple edit processor |
|
|
sub smpedt { |
sub smpedt { |
my ($r,$errtext)=@_; |
my ($r,$url,$errtext)=@_; |
my $buttons=&buttons(2); |
my $buttons=&buttons(2); |
|
|
# ---------------------------------------------------------- Process form input |
# ---------------------------------------------------------- Process form input |
Line 284 sub smpedt {
|
Line 359 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 320 sub smpedt {
|
Line 395 sub smpedt {
|
for (my $i=0;$i<=$lastsel;$i++) { |
for (my $i=0;$i<=$lastsel;$i++) { |
my ($name,$url)=split(/\=/,$curimport[$i]); |
my ($name,$url)=split(/\=/,$curimport[$i]); |
if ($url) { |
if ($url) { |
$importdetail.='&'.&Apache::lonnet::escape($name).'='. |
$importdetail.='&'.$name.'='.$url; |
&Apache::lonnet::escape($url); |
|
} |
} |
} |
} |
|
|
Line 330 sub smpedt {
|
Line 404 sub smpedt {
|
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]); |
if ($url) { |
if ($url) { |
$importdetail.='&'.&Apache::lonnet::escape($name).'='. |
$importdetail.='&'.$name.'='.$url; |
&Apache::lonnet::escape($url); |
|
} |
} |
} |
} |
$importdetail=~s/\&+/\&/g; |
$importdetail=~s/\&+/\&/g; |
Line 350 sub smpedt {
|
Line 423 sub smpedt {
|
for (my $i=0;$i<=$#curimport;$i++) { |
for (my $i=0;$i<=$#curimport;$i++) { |
my ($name,$url)=split(/\=/,$curimport[$i]); |
my ($name,$url)=split(/\=/,$curimport[$i]); |
if ($url) { |
if ($url) { |
$importdetail.='&'.&Apache::lonnet::escape($name).'='. |
$importdetail.='&'.$name.'='.$url; |
&Apache::lonnet::escape($url); |
|
} |
} |
} |
} |
# --------------------------------------------------------- Loading another map |
# --------------------------------------------------------- Loading another map |
Line 370 sub smpedt {
|
Line 442 sub smpedt {
|
for (my $i=0;$i<=$lastsel;$i++) { |
for (my $i=0;$i<=$lastsel;$i++) { |
my ($name,$url)=split(/\=/,$curimport[$i]); |
my ($name,$url)=split(/\=/,$curimport[$i]); |
if ($url) { |
if ($url) { |
$importdetail.='&'.&Apache::lonnet::escape($name).'='. |
$importdetail.='&'.$name.'='.$url; |
&Apache::lonnet::escape($url); |
|
} |
} |
} |
} |
|
|
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 387 sub smpedt {
|
Line 458 sub smpedt {
|
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]); |
if ($url) { |
if ($url) { |
|
$importdetail.='&'.$name.'='.$url; |
|
} |
|
} |
|
$importdetail=~s/\&+/\&/g; |
|
$importdetail=~s/^\&//; |
|
|
|
# ------------------------------------------------ Groupimport/search to target |
|
} elsif ($ENV{'form.importdetail'}) { |
|
my $lastsel; |
|
if (defined($targetselect[-1])) { |
|
$lastsel=$targetselect[-1]; |
|
} else { |
|
$lastsel=$#order+1; |
|
} |
|
&pastetarget($lastsel,split(/\&/,$ENV{'form.importdetail'})); |
|
&storemap(&Apache::lonnet::filelocation('',$url)); |
|
# ------------------------------------------------------------------------- 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).'='. |
$importdetail.='&'.&Apache::lonnet::escape($name).'='. |
&Apache::lonnet::escape($url); |
&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/\&+/\&/g; |
$importdetail=~s/^\&//; |
$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 |
|
} 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 412 sub smpedt {
|
Line 558 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'; } |
$targetdetail.='&'.&Apache::lonnet::escape($name).'='. |
$targetdetail.='&'.&Apache::lonnet::escape($name).'='. |
&Apache::lonnet::escape($url); |
&Apache::lonnet::escape($url); |
$idx++; |
$idx++; |
'<option value="'.$idx.'_'.$_.'">'.$name.'</option>'; |
'<option value="'.$idx.'">'.$name.'</option>'; |
} @order); |
} @order); |
|
|
# ----------------------------------------------------- Start simple RAT screen |
# ----------------------------------------------------- Start simple RAT screen |
Line 529 function idxcheck(mode) {
|
Line 677 function idxcheck(mode) {
|
editbrowser = open(url,title,options,'1'); |
editbrowser = open(url,title,options,'1'); |
editbrowser.focus(); |
editbrowser.focus(); |
} |
} |
|
|
|
function openview(entry) { |
|
var url=unescape((entry.split('='))[1]); |
|
var parts=new Array; |
|
parts=url.split(':'); |
|
url=parts.join(':'); |
|
if (url) { open(url,'cat'); } |
|
} |
|
|
|
function viewtarget() { |
|
openview((document.forms.simpleedit.targetdetail.value.split('&')) |
|
[document.forms.simpleedit.target.selectedIndex+1]); |
|
} |
|
|
|
function viewimport() { |
|
openview((document.forms.simpleedit.curimpdetail.value.split('&')) |
|
[document.forms.simpleedit.importsel.selectedIndex+1]); |
|
} |
|
|
</script> |
</script> |
</head> |
</head> |
<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 563 after selected
|
Line 731 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 571 $importwindow
|
Line 739 $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 608 sub viewmap {
|
Line 779 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 620 sub viewmap {
|
Line 793 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>'); |
Line 669 sub handler {
|
Line 842 sub handler {
|
if ($ENV{'form.forceadv'}) { |
if ($ENV{'form.forceadv'}) { |
&ratedt($r,$url); |
&ratedt($r,$url); |
} elsif ($ENV{'form.forcesmp'}) { |
} elsif ($ENV{'form.forcesmp'}) { |
&smpedt($r,$errtext); |
&smpedt($r,$url,$errtext); |
} else { |
} else { |
&viewmap($r,$url,$adv,$errtext); |
&viewmap($r,$url,$adv,$errtext); |
} |
} |