version 1.67, 2005/06/08 15:44:51
|
version 1.81, 2006/06/26 22:47:35
|
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 172 use Apache::lonsequence;
|
Line 172 use Apache::lonsequence;
|
use Apache::loncommon; |
use Apache::loncommon; |
use Apache::lonlocal; |
use Apache::lonlocal; |
use File::Copy; |
use File::Copy; |
|
use lib '/home/httpd/lib/perl/'; |
|
use LONCAPA; |
|
|
|
|
use vars qw(@order @resources @resparms @zombies %revzombies); |
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 189 sub mapread {
|
Line 192 sub mapread {
|
undef @order; |
undef @order; |
undef @resparms; |
undef @resparms; |
undef @zombies; |
undef @zombies; |
undef %revzombies; |
|
|
|
@resources=(''); |
@resources=(''); |
@order=(); |
@order=(); |
@resparms=(); |
@resparms=(); |
@zombies=(); |
@zombies=(); |
%revzombies=(); |
|
|
|
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 205 sub mapread {
|
Line 206 sub mapread {
|
my ($command,$number,$content)=split(/\<\:\>/,$_); |
my ($command,$number,$content)=split(/\<\:\>/,$_); |
if ($command eq 'objcont') { |
if ($command eq 'objcont') { |
my ($title,$src,$ext,$type)=split(/\:/,$content); |
my ($title,$src,$ext,$type)=split(/\:/,$content); |
|
if ($ext eq 'cond') { next; } |
if ($type ne 'zombie') { |
if ($type ne 'zombie') { |
$resources[$number]=$content; |
$resources[$number]=$content; |
} else { |
} else { |
$zombies[$number]=$content; |
$zombies[$number]=$content; |
$revzombies{$src}=$number; |
|
} |
} |
} |
} |
if ($command eq 'objlinks') { |
if ($command eq 'objlinks') { |
Line 407 sub attemptread {
|
Line 408 sub attemptread {
|
# --------------------------------------------------------- Build up RAT screen |
# --------------------------------------------------------- Build up RAT screen |
sub ratedt { |
sub ratedt { |
my ($r,$url)=@_; |
my ($r,$url)=@_; |
my $frameset = '<frameset rows="1,70,*" border="0">'; |
my %layout = ('border' => "0"); |
if ($env{'environment.remote'} eq 'off') { |
if ($env{'environment.remote'} eq 'off') { |
$frameset = '<frameset rows="1,250,*" border="0">'; |
$layout{'rows'} = "1,250,*"; |
|
} else { |
|
$layout{'rows'} = "1,70,*"; |
} |
} |
$r->print(<<ENDDOCUMENT); |
my $js =' |
|
<script type="text/javascript"> |
<html> |
|
<head> |
|
<script language="JavaScript"> |
|
var flag=0; |
var flag=0; |
</script> |
</script>'; |
</head> |
|
$frameset |
my $start_page = |
<frame name=server src="$url/loadonly/ratserver" noresize noscroll> |
&Apache::loncommon::start_page('Edit Sequence',$js, |
<frame name=code src="$url/loadonly/adveditmenu"> |
{'frameset' => 1, |
<frame name=mapout src="/adm/rat/map.html"> |
'add_entries' => \%layout}); |
</frameset> |
my $end_page = |
</html> |
&Apache::loncommon::end_page({'frameset' => 1}); |
|
|
|
$r->print(<<ENDDOCUMENT); |
|
$start_page |
|
<frame name="server" src="$url/loadonly/ratserver" noresize="noresize" |
|
noscroll="noscroll" /> |
|
<frame name="code" src="$url/loadonly/adveditmenu" /> |
|
<frame name="mapout" src="/adm/rat/map.html" /> |
|
$end_page |
ENDDOCUMENT |
ENDDOCUMENT |
} |
} |
|
|
Line 448 sub buttons {
|
Line 455 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 457 sub pastetarget {
|
Line 491 sub pastetarget {
|
foreach (@which) { |
foreach (@which) { |
if (defined($_)) { |
if (defined($_)) { |
my ($name,$url)=split(/\=/,$_); |
my ($name,$url)=split(/\=/,$_); |
$name=&Apache::lonnet::unescape($name); |
$name=&unescape($name); |
$url=&Apache::lonnet::unescape($url); |
$url=&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 506 sub startfinish {
|
Line 540 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 550 sub storemap {
|
Line 584 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 652 function srchclose() {
|
Line 691 function srchclose() {
|
|
|
// -------------------------------------------------------- Open indexer window |
// -------------------------------------------------------- Open indexer window |
function idxopen(mode) { |
function idxopen(mode) { |
var options="scrollbars=1,resizable=1,menubar=0"; |
var options="scrollbars=1,resizable=1,menubar=0,location=1,toolbar=1"; |
idxmode=mode; |
idxmode=mode; |
idxflag=1; |
idxflag=1; |
idx=open("$resurl/?launch=1&mode=$mode&catalogmode="+mode,"idxout",options); |
idx=open("$resurl/?launch=1&mode=$mode&catalogmode="+mode,"idxout",options); |
idx.focus(); |
idx.focus(); |
} |
} |
|
|
|
// ------------------------------------------------------ Open groupsort window |
|
function groupopen(url,recover,bookmarks) { |
|
var options="scrollbars=1,resizable=1,menubar=0"; |
|
idxflag=1; |
|
idx=open("/adm/groupsort?mode=$mode&recover="+recover+"&readfile="+url+"&bookmarks="+bookmarks,"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 669 function srchopen(mode) {
|
Line 716 function srchopen(mode) {
|
} |
} |
// ----------------------------------------------------- launch indexer browser |
// ----------------------------------------------------- launch indexer browser |
function groupsearch() { |
function groupsearch() { |
srchcheck('groupsearch'); |
srchcheck('import'); |
} |
} |
|
|
function groupimport() { |
function groupimport() { |
idxcheck('groupimport'); |
idxcheck('import'); |
} |
} |
|
|
// ------------------------------------------------------- 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 826 sub smpedt {
|
Line 874 sub smpedt {
|
&Apache::lonsequence::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.='&'.&escape($name).'='. |
&Apache::lonnet::escape($url); |
&escape($url); |
} |
} |
} |
} |
|
|
Line 873 sub smpedt {
|
Line 921 sub smpedt {
|
foreach (@targetselect) { |
foreach (@targetselect) { |
my ($name,$url)=split(/\:/,$resources[$order[$_-1]]); |
my ($name,$url)=split(/\:/,$resources[$order[$_-1]]); |
if ($url) { |
if ($url) { |
$importdetail.='&'.&Apache::lonnet::escape($name).'='. |
$importdetail.='&'.&escape($name).'='. |
&Apache::lonnet::escape($url); |
&escape($url); |
} |
} |
} |
} |
|
|
Line 894 sub smpedt {
|
Line 942 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 957 sub smpedt {
|
Line 1009 sub smpedt {
|
my ($name,$url)=split(/\=/,$_); |
my ($name,$url)=split(/\=/,$_); |
unless ($name) { $name=(split(/\//,$url))[-1]; } |
unless ($name) { $name=(split(/\//,$url))[-1]; } |
unless ($name) { $name='EMPTY'; } |
unless ($name) { $name='EMPTY'; } |
'<option value="'.$idx.'">'.&Apache::lonnet::unescape($name). |
'<option value="'.$idx.'">'.&unescape($name). |
'</option>'; |
'</option>'; |
} |
} |
} split(/\&/,$importdetail)); |
} split(/\&/,$importdetail)); |
Line 970 sub smpedt {
|
Line 1022 sub smpedt {
|
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.='&'.&escape($name).'='. |
&Apache::lonnet::escape($url); |
&escape($url); |
$idx++; |
$idx++; |
$name=~s/\:/\:/g; |
$name=~s/\:/\:/g; |
'<option value="'.$idx.'">'.$name.'</option>'; |
'<option value="'.$idx.'">'.$name.'</option>'; |
Line 979 sub smpedt {
|
Line 1031 sub smpedt {
|
|
|
# ----------------------------------------------------- Start simple RAT screen |
# ----------------------------------------------------- Start simple RAT screen |
my $editscript=&editscript('simple'); |
my $editscript=&editscript('simple'); |
my $bodytag=&Apache::loncommon::bodytag(undef,undef,undef, |
|
($env{'environment.remote'} ne 'off')). |
|
&Apache::loncommon::help_open_menu('','Sequence_Simple_Editor_Creation','Sequence_Simple_Editor_Creation','',6,'RAT'); |
|
my %lt=&Apache::lonlocal::texthash( |
my %lt=&Apache::lonlocal::texthash( |
'sa' => 'Save', |
'sa' => 'Save', |
'nt' => 'New Title', |
'nt' => 'New Title', |
'se' => 'Search', |
'se' => 'Search', |
'im' => 'Import', |
'im' => 'Import', |
|
'bk' => 'Import Bookmarks', |
'vi' => 'View', |
'vi' => 'View', |
'lm' => 'Load Map', |
'lm' => 'Load Map', |
'ds' => 'Discard Selected', |
'ds' => 'Discard Selected', |
Line 1001 sub smpedt {
|
Line 1052 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); |
my $js=<<ENDJS; |
<html> |
<script type="text/javascript"> |
<head> |
|
<script> |
|
|
|
$editscript |
$editscript |
|
|
Line 1048 sub smpedt {
|
Line 1098 sub smpedt {
|
} |
} |
|
|
</script> |
</script> |
</head> |
ENDJS |
$bodytag |
|
|
my $start_page = &Apache::loncommon::start_page(undef,$js). |
|
&Apache::loncommon::help_open_menu('Sequence_Simple_Editor_Creation', |
|
'Sequence_Simple_Editor_Creation', |
|
6,'RAT'); |
|
my $end_page = &Apache::loncommon::end_page(); |
|
|
|
$r->print(<<ENDSMPHEAD); |
|
$start_page |
$buttons |
$buttons |
<font color=red>$errtext</font> |
<font color=red>$errtext</font> |
<form name=simpleedit method=post> |
<form name=simpleedit method=post> |
Line 1080 value="Select Map"><input type=submit na
|
Line 1138 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;groupopen(0,1,1);" value="$lt{'bk'}"> |
|
<input type=button onClick= |
|
"javascript:impfortarget.value=1;groupopen('$url',1,0);" 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 1114 $targetwindow
|
Line 1176 $targetwindow
|
<input type=hidden name=targetdetail value="$targetdetail"> |
<input type=hidden name=targetdetail value="$targetdetail"> |
<input type=hidden name=impfortarget value="0"> |
<input type=hidden name=impfortarget value="0"> |
</form> |
</form> |
</body></html> |
$end_page |
ENDSMPHEAD |
ENDSMPHEAD |
} |
} |
|
|
# ----------------------------------------------------------------- No such dir |
# ----------------------------------------------------------------- No such dir |
sub nodir { |
sub nodir { |
my ($r,$dir)=@_; |
my ($r,$dir)=@_; |
$dir=~s/^\/home\/\w+\/public\_html//; |
$dir=~s{^/home/\w+/public_html}{}; |
$r->print(<<ENDNODIR); |
$r->print(&Apache::loncommon::start_page(undef,undef, |
<html> |
{'only_body' => 1, |
<body bgcolor='#FFFFFF'> |
'bgcolor' => '#FFFFFF',}). |
<h1>No such directory: $dir</h1> |
"<h1>No such directory: $dir</h1>". |
</body> |
&Apache::loncommon::end_page()); |
</html> |
|
ENDNODIR |
|
} |
} |
|
|
# ---------------------------------------------------------------- View Handler |
# ---------------------------------------------------------------- View Handler |
|
|
sub viewmap { |
sub viewmap { |
my ($r,$url,$adv,$errtext)=@_; |
my ($r,$url,$adv,$errtext)=@_; |
$r->print('<html>'. |
$r->print( |
&Apache::loncommon::bodytag('Edit Content of a Map'). |
&Apache::loncommon::start_page('Edit Content of a Map'). |
&Apache::loncommon::help_open_menu('','','','',6,'RAT'). |
&Apache::loncommon::help_open_menu('','',6,'RAT'). |
&buttons($adv)); |
&buttons($adv)); |
if ($errtext) { |
if ($errtext) { |
$r->print($errtext.'<hr />'); |
$r->print($errtext.'<hr />'); |
Line 1178 sub viewmap {
|
Line 1238 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) { |
Line 1193 sub viewmap {
|
Line 1249 sub viewmap {
|
} |
} |
} |
} |
$r->print('</table>'); |
$r->print('</table>'); |
$r->print('</body></html>'); |
$r->print(&Apache::loncommon::end_page()); |
} |
} |
|
|
# ================================================================ Main Handler |
# ================================================================ Main Handler |