--- rat/lonratedt.pm 2005/04/07 06:56:27 1.65
+++ rat/lonratedt.pm 2005/06/08 16:10:01 1.68
@@ -1,7 +1,7 @@
# The LearningOnline Network with CAPA
# Edit Handler for RAT Maps
#
-# $Id: lonratedt.pm,v 1.65 2005/04/07 06:56:27 albertel Exp $
+# $Id: lonratedt.pm,v 1.68 2005/06/08 16:10:01 www Exp $
#
# Copyright Michigan State University Board of Trustees
#
@@ -173,7 +173,7 @@ use Apache::loncommon;
use Apache::lonlocal;
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
@@ -188,9 +188,14 @@ sub mapread {
undef @resources;
undef @order;
undef @resparms;
+ undef @zombies;
+ undef %revzombies;
+
@resources=('');
@order=();
@resparms=();
+ @zombies=();
+ %revzombies=();
my ($outtext,$errtext)=&Apache::lonratsrv::loadmap($fn,'');
if ($errtext) { return ($errtext,2); }
@@ -199,7 +204,13 @@ sub mapread {
foreach (split(/\<\&\>/,$outtext)) {
my ($command,$number,$content)=split(/\<\:\>/,$_);
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') {
$links[$number]=$content;
@@ -296,7 +307,10 @@ sub attemptread {
foreach (split(/\<\&\>/,$outtext)) {
my ($command,$number,$content)=split(/\<\:\>/,$_);
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') {
$links[$number]=$content;
@@ -434,6 +448,12 @@ sub buttons {
return $output.'
';
}
+# ----------------------------------------------------- Get an unused res index
+
+sub unusedindex {
+ return 1+($#resources>$#zombies?$#resources:$#zombies);
+}
+
# ----------------------------------------------------------- Paste into target
# modifies @order, @resources
@@ -446,7 +466,7 @@ sub pastetarget {
$name=&Apache::lonnet::unescape($name);
$url=&Apache::lonnet::unescape($url);
if ($url) {
- my $idx=$#resources+1;
+ my $idx=&unusedindex();
$insertorder[$#insertorder+1]=$idx;
my $ext='false';
if ($url=~/^http\:\/\//) { $ext='true'; }
@@ -492,7 +512,7 @@ sub startfinish {
$resources[$order[0]]=$name.':'.$url.':'.$ext.':start:res';
# Make sure this has at least start and finish
if ($#order==0) {
- $resources[$#resources+1]='::false';
+ $resources[&unusedindex()]='::false';
$order[1]=$#resources;
}
# Make the last one a finish resource
@@ -733,24 +753,8 @@ sub smpedt {
}
# ---------------------------------------------------------- Process form input
- my @importselect=();
- my @targetselect=();
- 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'});
- }
- }
+ my @importselect=&Apache::loncommon::get_env_multiple('form.importsel');
+ my @targetselect=&Apache::loncommon::get_env_multiple('form.target');
# ============================================================ Process commands
my $targetdetail=$env{'form.targetdetail'};
@@ -1180,11 +1184,7 @@ sub viewmap {
'" />'.&Apache::lonratsrv::qtescape($title).
' | '.$filename.' | ');
if ($url) {
- if (-e $resfilepath) {
- $r->print(''.&mt('Resource space').'');
- } else {
- $r->print(&mt('unpublished'));
- }
+ $r->print(''.&mt('Resource space').'');
}
$r->print(' | ');
if ($url) {
|