--- rat/lonratedt.pm 2002/10/25 13:40:52 1.39 +++ rat/lonratedt.pm 2003/04/07 20:47:06 1.44 @@ -1,7 +1,7 @@ # The LearningOnline Network with CAPA # Edit Handler for RAT Maps # -# $Id: lonratedt.pm,v 1.39 2002/10/25 13:40:52 www Exp $ +# $Id: lonratedt.pm,v 1.44 2003/04/07 20:47:06 www Exp $ # # Copyright Michigan State University Board of Trustees # @@ -318,18 +318,39 @@ sub pastetarget { # modifies @resources sub startfinish { +# Remove all start and finish foreach (@order) { my ($name,$url,$ext)=split(/\:/,$resources[$_]); if ($url=~/http\&colon\:\/\//) { $ext='true'; } $resources[$_]=$name.':'.$url.':'.$ext.':normal:res'; } +# Garbage collection + my $stillchange=1; + while (($#order>1) && ($stillchange)) { + $stillchange=0; + for (my $i=0;$i<=$#order;$i++) { + my ($name,$url,$ext)=split(/\:/,$resources[$order[$i]]); + unless ($url) { +# Take out empty resource + for (my $j=$i+1;$j<=$#order;$j++) { + $order[$j-1]=$order[$j]; + } + $#order--; + $stillchange=1; + last; + } + } + } +# Put in a start resource my ($name,$url,$ext)=split(/\:/,$resources[$order[0]]); $resources[$order[0]]=$name.':'.$url.':'.$ext.':start:res'; +# Make sure this has at least start and finish if ($#order==0) { $resources[$#resources+1]='::false'; $order[1]=$#resources; } - my ($name,$url,$ext)=split(/\:/,$resources[$order[$#order]]); +# Make the last one a finish resource + ($name,$url,$ext)=split(/\:/,$resources[$order[$#order]]); $resources[$order[$#order]]=$name.':'.$url.':'.$ext.':finish:res'; } @@ -710,8 +731,9 @@ sub smpedt { } elsif ($ENV{'form.renameres'}) { my $residx=$Apache::lonratedt::order[$ENV{'form.renameidx'}-1]; my ($name,@resrest)=split(/\:/,$Apache::lonratedt::resources[$residx]); - $name=&Apache::lonnet::escape($ENV{'form.renametitle'}); - $Apache::lonratedt::resources[$residx]=$name.':'.join(':'.@resrest); + $name=$ENV{'form.renametitle'}; + $name=~s/\:/\&colon\;/g; + $Apache::lonratedt::resources[$residx]=$name.':'.join(':',@resrest); &storemap(&Apache::lonnet::filelocation('',$url)); } # ------------------------------------------------------------ Assemble windows @@ -779,7 +801,14 @@ sub smpedt { var selidx=document.forms.simpleedit.target.selectedIndex; var entry=(document.forms.simpleedit.targetdetail.value.split('&')) [selidx]; - var newtitle=prompt('New Title',unescape((entry.split('='))[0])); + var oldname=unescape((entry.split('='))[0]); + var nameparts=oldname.split(':'); + oldname=unescape(nameparts.join(':')); + nameparts=oldname.split('"'); + oldname=unescape(nameparts.join('"')); + nameparts=oldname.split('''); + oldname=unescape(nameparts.join("'")); + newtitle=prompt('New Title',oldname); if (newtitle) { document.forms.simpleedit.renameres.value=1; document.forms.simpleedit.renameidx.value=selidx; @@ -884,6 +913,9 @@ sub viewmap { } my $idx=0; $r->print('

'.$url.'

'); + if ($adv) { + $r->print('

Map contents are not shown in order.


'); + } foreach (&attemptread(&Apache::lonnet::filelocation('',$url))) { if (defined($_)) { $idx++;