version 1.65, 2005/04/07 06:56:27
|
version 1.74, 2005/06/10 21:45:46
|
Line 33 package Apache::lonratedt;
|
Line 33 package Apache::lonratedt;
|
|
|
=head1 NAME |
=head1 NAME |
|
|
Apache::lonratedt: advanced resource assembly tool |
Apache::lonratedt: simple resource assembly tool |
|
|
=head1 SYNOPSIS |
=head1 SYNOPSIS |
|
|
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); |
|
|
|
|
# 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; |
|
|
@resources=(''); |
@resources=(''); |
@order=(); |
@order=(); |
@resparms=(); |
@resparms=(); |
|
@zombies=(); |
|
|
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 202 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 ($ext eq 'cond') { next; } |
|
if ($type ne 'zombie') { |
|
$resources[$number]=$content; |
|
} else { |
|
$zombies[$number]=$content; |
|
} |
} |
} |
if ($command eq 'objlinks') { |
if ($command eq 'objlinks') { |
$links[$number]=$content; |
$links[$number]=$content; |
Line 296 sub attemptread {
|
Line 305 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 434 sub buttons {
|
Line 446 sub buttons {
|
return $output.'</form><hr>'; |
return $output.'</form><hr>'; |
} |
} |
|
|
|
# ------------------------------------- Revive zombie idx or get unused number |
|
|
|
sub getresidx { |
|
my $url=shift; |
|
my $max=1+($#resources>$#zombies?$#resources:$#zombies); |
|
unless ($url) { return $max; } |
|
for (my $i=0; $i<=$#zombies; $i++) { |
|
my ($title,$src,$ext,$type)=split(/\:/,$zombies[$i]); |
|
if ($src eq $url) { |
|
undef $zombies[$i]; |
|
return $i; |
|
} |
|
} |
|
return $max; |
|
} |
|
|
|
# --------------------------------------------------------------- Make a zombie |
|
|
|
sub makezombie { |
|
my $idx=shift; |
|
my ($name,$url,$ext)=split(/\:/,$resources[$idx]); |
|
my $now=time; |
|
$zombies[$idx]=$name. |
|
' [('.$now.','.$env{'user.name'}.','.$env{'user.domain'}.')]:'. |
|
$url.':'.$ext.':zombie'; |
|
} |
|
|
# ----------------------------------------------------------- Paste into target |
# ----------------------------------------------------------- Paste into target |
# modifies @order, @resources |
# modifies @order, @resources |
|
|
Line 446 sub pastetarget {
|
Line 485 sub pastetarget {
|
$name=&Apache::lonnet::unescape($name); |
$name=&Apache::lonnet::unescape($name); |
$url=&Apache::lonnet::unescape($url); |
$url=&Apache::lonnet::unescape($url); |
if ($url) { |
if ($url) { |
my $idx=$#resources+1; |
my $idx=&getresidx($url); |
$insertorder[$#insertorder+1]=$idx; |
$insertorder[$#insertorder+1]=$idx; |
my $ext='false'; |
my $ext='false'; |
if ($url=~/^http\:\/\//) { $ext='true'; } |
if ($url=~/^http\:\/\//) { $ext='true'; } |
Line 492 sub startfinish {
|
Line 531 sub startfinish {
|
$resources[$order[0]]=$name.':'.$url.':'.$ext.':start:res'; |
$resources[$order[0]]=$name.':'.$url.':'.$ext.':start:res'; |
# Make sure this has at least start and finish |
# Make sure this has at least start and finish |
if ($#order==0) { |
if ($#order==0) { |
$resources[$#resources+1]='::false'; |
$resources[&getresidx()]='::false'; |
$order[1]=$#resources; |
$order[1]=$#resources; |
} |
} |
# Make the last one a finish resource |
# Make the last one a finish resource |
Line 536 sub storemap {
|
Line 575 sub storemap {
|
} |
} |
} |
} |
} |
} |
|
for (my $i=0; $i<=$#zombies; $i++) { |
|
if (defined($zombies[$i])) { |
|
$output.='<&>objcont<:>'.$i.'<:>'.$zombies[$i]; |
|
} |
|
} |
$output=~s/http\&colon\;\/\///g; |
$output=~s/http\&colon\;\/\///g; |
$env{'form.output'}=$output; |
$env{'form.output'}=$output; |
return |
return |
Line 645 function idxopen(mode) {
|
Line 689 function idxopen(mode) {
|
idx.focus(); |
idx.focus(); |
} |
} |
|
|
|
// ------------------------------------------------------ Open groupsort window |
|
function groupopen(url,recover) { |
|
var options="scrollbars=1,resizable=1,menubar=0"; |
|
idxflag=1; |
|
idx=open("/adm/groupsort?mode=$mode&recover="+recover+"&readfile="+url,"idxout",options); |
|
idx.focus(); |
|
} |
|
|
// --------------------------------------------------------- Open search window |
// --------------------------------------------------------- Open search window |
function srchopen(mode) { |
function srchopen(mode) { |
var options="scrollbars=1,resizable=1,menubar=0"; |
var options="scrollbars=1,resizable=1,menubar=0"; |
Line 661 function groupsearch() {
|
Line 713 function groupsearch() {
|
function groupimport() { |
function groupimport() { |
idxcheck('groupimport'); |
idxcheck('groupimport'); |
} |
} |
|
|
// ------------------------------------------------------- Do srch status check |
// ------------------------------------------------------- Do srch status check |
function srchcheck(mode) { |
function srchcheck(mode) { |
if (!srch || srch.closed || srchmode!=mode) { |
if (!srch || srch.closed || srchmode!=mode) { |
Line 733 sub smpedt {
|
Line 786 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'}; |
Line 896 sub smpedt {
|
Line 933 sub smpedt {
|
foreach (@targetselect) { |
foreach (@targetselect) { |
if ($_-1==$i) { $include=0; } |
if ($_-1==$i) { $include=0; } |
} |
} |
if ($include) { $neworder[$#neworder+1]=$order[$i]; } |
if ($include) { |
|
$neworder[$#neworder+1]=$order[$i]; |
|
} else { |
|
&makezombie($order[$i]); |
|
} |
} |
} |
@order=@neworder; |
@order=@neworder; |
&storemap(&Apache::lonnet::filelocation('',$url)); |
&storemap(&Apache::lonnet::filelocation('',$url)); |
Line 1003 sub smpedt {
|
Line 1044 sub smpedt {
|
'cs' => 'Cut selected', |
'cs' => 'Cut selected', |
'ps' => 'Copy selected', |
'ps' => 'Copy selected', |
'pas' => 'Paste after selected', |
'pas' => 'Paste after selected', |
|
'reco' => 'Recover Deleted' |
); |
); |
$r->print(<<ENDSMPHEAD); |
$r->print(<<ENDSMPHEAD); |
<html> |
<html> |
Line 1082 value="Select Map"><input type=submit na
|
Line 1124 value="Select Map"><input type=submit na
|
"javascript:impfortarget.value=1;groupsearch()" value="$lt{'se'}"> |
"javascript:impfortarget.value=1;groupsearch()" value="$lt{'se'}"> |
<input type=button onClick= |
<input type=button onClick= |
"javascript:impfortarget.value=1;groupimport();" value="$lt{'im'}"> |
"javascript:impfortarget.value=1;groupimport();" value="$lt{'im'}"> |
|
<input type=button onClick= |
|
"javascript:impfortarget.value=1;javascript:groupopen('$url',1);" value="$lt{'reco'}"> |
$lt{'as'} |
$lt{'as'} |
<hr> |
<hr> |
<input type=submit name="moveup" value="$lt{'mu'}"> |
<input type=submit name="moveup" value="$lt{'mu'}"> |
Line 1180 sub viewmap {
|
Line 1224 sub viewmap {
|
'" /></td><td>'.&Apache::lonratsrv::qtescape($title). |
'" /></td><td>'.&Apache::lonratsrv::qtescape($title). |
'</td><td>'.$filename.'</td><td>'); |
'</td><td>'.$filename.'</td><td>'); |
if ($url) { |
if ($url) { |
if (-e $resfilepath) { |
$r->print('<a href="'.$resurl.'">'.&mt('Resource space').'</a>'); |
$r->print('<a href="'.$resurl.'">'.&mt('Resource space').'</a>'); |
|
} else { |
|
$r->print(&mt('unpublished')); |
|
} |
|
} |
} |
$r->print('</td><td>'); |
$r->print('</td><td>'); |
if ($url) { |
if ($url) { |