version 1.124, 2002/06/20 14:31:31
|
version 1.125, 2002/06/20 19:43:50
|
Line 524 a 'hidden' html input tag.
|
Line 524 a 'hidden' html input tag.
|
|
|
sub make_persistent { |
sub make_persistent { |
my $persistent=''; |
my $persistent=''; |
|
|
foreach (keys %ENV) { |
foreach (keys %ENV) { |
if (/^form\./ && !/submit/) { |
if (/^form\./ && !/submit/) { |
my $name=$_; |
my $name=$_; |
Line 532 sub make_persistent {
|
Line 531 sub make_persistent {
|
$ENV{$key}=~s/\'//g; # do not mess with html field syntax |
$ENV{$key}=~s/\'//g; # do not mess with html field syntax |
$name=~s/^form\.//; |
$name=~s/^form\.//; |
$persistent.=<<END; |
$persistent.=<<END; |
<input type='hidden' name='$name' value='$ENV{$key}' /> |
<input type="hidden" name="$name" value="$ENV{$key}" /> |
END |
END |
} |
} |
} |
} |
Line 1029 sub output_results {
|
Line 1028 sub output_results {
|
my %ENV=%{$envhash}; |
my %ENV=%{$envhash}; |
my %rhash=%{$replyref}; |
my %rhash=%{$replyref}; |
my $compiledresult=''; |
my $compiledresult=''; |
my $timeremain=300; |
my $timeremain=300; # (seconds) |
my $elapsetime=0; |
my $elapsetime=0; |
my $resultflag=0; |
my $resultflag=0; |
my $tflag=1; |
my $tflag=1; |
|
# |
# make query information persistent to allow for subsequent revision |
# make query information persistent to allow for subsequent revision |
my $persistent=&make_persistent(); |
my $persistent=&make_persistent(); |
|
# spit out the generic header |
# output beginning of search page |
$r->print(&search_results_header()); |
$r->print(<<BEGINNING); |
|
<html> |
|
<head> |
|
<title>The LearningOnline Network with CAPA</title> |
|
BEGINNING |
|
|
|
# conditional output of script functions dependent on the mode in |
|
# which the search was invoked |
|
if ($ENV{'form.catalogmode'} eq 'interactive'){ |
|
if (! exists($ENV{'form.mode'}) || $ENV{'form.mode'} ne 'edit') { |
|
$r->print(<<SCRIPT) |
|
<script type="text/javascript"> |
|
function select_data(title,url) { |
|
changeTitle(title); |
|
changeURL(url); |
|
self.close(); |
|
} |
|
function changeTitle(val) { |
|
if (opener.inf.document.forms.resinfo.elements.t) { |
|
opener.inf.document.forms.resinfo.elements.t.value=val; |
|
} |
|
} |
|
function changeURL(val) { |
|
if (opener.inf.document.forms.resinfo.elements.u) { |
|
opener.inf.document.forms.resinfo.elements.u.value=val; |
|
} |
|
} |
|
</script> |
|
SCRIPT |
|
} elsif ($ENV{'form.mode'} eq 'edit') { |
|
my $form = $ENV{'form.form'}; |
|
my $element = $ENV{'form.element'}; |
|
$r->print(<<SCRIPT) |
|
<script type="text/javascript"> |
|
function select_data(title,url) { |
|
changeURL(url); |
|
self.close(); |
|
} |
|
function changeTitle(val) { |
|
} |
|
function changeURL(val) { |
|
if (window.opener.document) { |
|
window.opener.document.forms["$form"].elements["$element"].value=val; |
|
} else { |
|
var url = 'forms[\"$form\"].elements[\"$element\"].value'; |
|
alert("Unable to transfer data to "+url); |
|
} |
|
} |
|
</script> |
|
SCRIPT |
|
} |
|
} |
|
$r->print(<<SCRIPT) if $ENV{'form.catalogmode'} eq 'groupsearch'; |
|
<script type="text/javascript"> |
|
function select_data(title,url) { |
|
// alert('DEBUG: Should be storing '+title+' and '+url); |
|
} |
|
function queue(val) { |
|
if (eval("document.forms.results.returnvalues["+val+"].checked")) { |
|
document.forms.results.acts.value+='1a'+val+'b'; |
|
} |
|
else { |
|
document.forms.results.acts.value+='0a'+val+'b'; |
|
} |
|
} |
|
function select_group() { |
|
window.location= |
|
"/adm/groupsort?mode=$ENV{'form.mode'}&catalogmode=groupsearch&acts="+ |
|
document.forms.results.acts.value; |
|
} |
|
</script> |
|
SCRIPT |
|
$r->print(<<SCRIPT); |
|
<script type="text/javascript"> |
|
function displayinfo(val) { |
|
popwin.document.forms.popremain.sdetails.value=val; |
|
} |
|
function openhelp(val) { |
|
openhelpwin=open('/adm/help/searchcat.html','helpscreen', |
|
'scrollbars=1,width=400,height=300'); |
|
openhelpwin.focus(); |
|
} |
|
function abortsearch(val) { |
|
popwin.close(); |
|
} |
|
</script> |
|
SCRIPT |
|
$r->rflush(); |
$r->rflush(); |
|
|
# begin showing the cataloged results |
# begin showing the cataloged results |
$r->print(<<CATALOGBEGIN); |
$r->print(<<CATALOGBEGIN); |
</head> |
</head> |
Line 1146 $persistent
|
Line 1057 $persistent
|
<hr /> |
<hr /> |
<h3>Search Query</h3> |
<h3>Search Query</h3> |
CATALOGCONTROLS |
CATALOGCONTROLS |
|
# |
|
# Remind them what they searched for |
|
# |
if ($mode eq 'Basic') { |
if ($mode eq 'Basic') { |
$r->print(<<RESULTS); |
$r->print('<p><b>Basic search:</b> '.$ENV{'form.basicexp'}.'</p>'); |
<p> |
} elsif ($mode eq 'Advanced') { |
<b>Basic search:</b> $ENV{'form.basicexp'} |
$r->print('<p><b>Advanced search</b> '.$query.'</p>'); |
</p> |
|
RESULTS |
|
} |
|
elsif ($mode eq 'Advanced') { |
|
$r->print(<<RESULTS); |
|
<p> |
|
<b>Advanced search</b> |
|
$query |
|
</p> |
|
RESULTS |
|
} |
} |
$r->print('<h3>Search Results</h3>'); |
$r->print('<h3>Search Results</h3>'); |
$r->rflush(); |
$r->rflush(); |
my $servernum=(keys %rhash)+0; |
# |
|
# make the pop-up window for status |
# define server grid (shows status of multiple machines) |
# |
my $hcinit; |
$r->print(&make_popwin(%rhash)); |
my $grid="'<br />'+"; |
|
$grid.="\n"; |
|
my $sn=1; |
|
for my $sk (sort keys %rhash) { |
|
# '<a href=" |
|
$grid.="'<a href=\""; |
|
# javascript:displayinfo('+ |
|
$grid.="javascript:opener.displayinfo('+"; |
|
# "'"+'key |
|
$grid.="\"'\"+'"; |
|
$grid.=$sk; |
|
my $hc; |
|
if ($rhash{$sk} eq 'con_lost') { |
|
$hc="BAD CONNECTION, CONTACT SYSTEM ADMINISTRATOR "; |
|
} |
|
else { |
|
$hc="'+\"'\"+\"+hc['$sk']+\"+\"'\"+'"; |
|
$hcinit.="hc[\"$sk\"]=\"not yet connected...\";"; |
|
} |
|
$grid.=" hitcount=".$hc; |
|
$grid.=" domain=".$hostdomains{$sk}; |
|
$grid.=" IP=".$hostips{$sk}; |
|
# '+"'"+'">'+ |
|
$grid.="'+\"'\"+')\">'+"; |
|
$grid.="\n"; |
|
$grid.="'<img border=\"0\" name=\"img".$sn."\"". |
|
" src=\"/adm/lonIcons/srvnull.gif\" alt=\"".$sk."\" /></a>'+\n"; |
|
$grid.="'<br />'+\n" unless $sn%10; |
|
$sn++; |
|
} |
|
$r->print(<<ENDPOP); |
|
<script type="text/javascript"> |
|
popwin=open('','popwin','scrollbars=1,width=400,height=220'); |
|
popwin.focus(); |
|
popwin.document.writeln('<'+'html>'); |
|
popwin.document.writeln('<'+'head>'); |
|
popwin.document.writeln('<'+'script>'); |
|
popwin.document.writeln('hc=new Array();$hcinit'); |
|
popwin.document.writeln('<'+'/script>'); |
|
popwin.document.writeln('<'+'/head>'+ |
|
'<'+'body bgcolor="#FFFFFF">'+ |
|
'<'+'image name="whirly" align="right" src="/adm/lonIcons/'+ |
|
'lonanim.gif" '+ |
|
'alt="animated logo" />'+ |
|
'<'+'h3>Search Results Progress<'+'/h3>'+ |
|
'<'+'form name="popremain">'+ |
|
'<'+'tt>'+ |
|
'<'+'br clear="all"/><i>PLEASE BE PATIENT</i>'+ |
|
'<'+'br />SCANNING $servernum SERVERS'+ |
|
'<'+'br clear="all" />Number of record hits found '+ |
|
'<'+'input type="text" size="10" name="numhits"'+ |
|
' value="0" />'+ |
|
'<'+'br clear="all" />Time elapsed '+ |
|
'<'+'input type="text" size="10" name="elapsetime"'+ |
|
' value="0" />'+ |
|
'<'+'br />'+ |
|
'SERVER GRID (click on any cell for details)'+ |
|
$grid |
|
'<'+'br />'+ |
|
'Server details '+ |
|
'<'+'input type="text" size="35" name="sdetails"'+ |
|
' value="" />'+ |
|
'<'+'br />'+ |
|
' <'+'input type="button" name="button"'+ |
|
' value="close this window" '+ |
|
' onClick="javascript:opener.abortsearch()" />'+ |
|
' <'+'input type="button" name="button"'+ |
|
' value="help" onClick="javascript:opener.openhelp()" />'+ |
|
'<'+'/tt>'+ |
|
'<'+'/form>'+ |
|
'<'+'/body><'+'/html>'); |
|
popwin.document.close(); |
|
</script> |
|
ENDPOP |
|
$r->rflush(); |
$r->rflush(); |
|
## |
|
## Prepare for the main loop below |
|
## |
my $servercount=0; |
my $servercount=0; |
my $hitcountsum=0; |
my $hitcountsum=0; |
my $bloop=$servernum; |
my $servernum=(keys %rhash); |
my %orkey; |
my $serversleft=$servernum; |
BLOOP: while(1) { |
## |
my $sn=0; |
## Run until we run out of time or we run out of servers |
last BLOOP unless $bloop; |
## |
last BLOOP unless $timeremain; |
while($serversleft && $timeremain) { |
RLOOP: foreach my $rkey (sort keys %rhash) { |
## |
$sn++; |
## %rhash has servers deleted from it as results come in |
next RLOOP if $orkey{$rkey}; |
## (within the foreach loop below). |
|
## |
|
foreach my $rkey (sort keys %rhash) { |
$servercount++; |
$servercount++; |
$tflag=1; |
$tflag=1; |
$compiledresult=''; |
$compiledresult=''; |
my $hostname=$rkey; |
my $hostname=$rkey; |
my $reply=$rhash{$rkey}; |
my $reply=$rhash{$rkey}; |
my @results; |
my @results; |
|
|
my $replyfile=''; |
|
|
|
if ($reply eq 'con_lost') { |
if ($reply eq 'con_lost') { |
&popwin_imgupdate($r,$sn,"srvbad.gif"); |
&popwin_imgupdate($r,$rkey,"srvbad.gif"); |
$bloop--; |
$serversleft--; |
$orkey{$rkey}=1; |
delete $rhash{$rkey}; |
} |
} else { |
else { |
# must do since 'use strict' checks for tainting |
$reply=~/^([\.\w]+)$/; # must do since 'use strict' checks for tainting |
$reply=~/^([\.\w]+)$/; |
$replyfile=$r->dir_config('lonDaemons').'/tmp/'.$1; |
my $replyfile=$r->dir_config('lonDaemons').'/tmp/'.$1; |
$reply=~/(.*?)\_/; |
$reply=~/(.*?)\_/; |
{ |
{ |
my $temp=0; |
my $temp=0; |
WLOOP: while (1) { |
WLOOP: while (1) { |
if (-e $replyfile && $tflag) { |
if (-e $replyfile && $tflag) { |
&popwin_imgupdate($r,$sn,"srvhalf.gif"); |
&popwin_imgupdate($r,$rkey,"srvhalf.gif"); |
&popwin_js($r,'popwin.hc["'.$rkey.'"]='. |
&popwin_js($r,'popwin.hc["'.$rkey.'"]='. |
'"still transferring..."'.';'); |
'"still transferring..."'.';'); |
$tflag=0; |
$tflag=0; |
} |
} |
if (-e "$replyfile.end") { |
if (-e "$replyfile.end") { |
$bloop--; |
$serversleft--; |
$orkey{$rkey}=1; |
delete $rhash{$rkey}; |
if (-s $replyfile) { |
if (-s $replyfile) { |
&popwin_imgupdate($r,$sn,"srvgood.gif"); |
&popwin_imgupdate($r,$rkey,"srvgood.gif"); |
my $fh=Apache::File->new($replyfile) or |
my $fh=Apache::File->new($replyfile) or |
($r->print('ERROR: file '. |
($r->print('ERROR: file '. |
$replyfile.' cannot be opened') and |
$replyfile.' cannot be opened') and |
Line 1299 ENDPOP
|
Line 1130 ENDPOP
|
'numhits.value='.$hitcountsum.';'); |
'numhits.value='.$hitcountsum.';'); |
} |
} |
else { |
else { |
&popwin_imgupdate($r,$sn,"srvempty.gif"); |
&popwin_imgupdate($r,$rkey,"srvempty.gif"); |
&popwin_js($r,'popwin.hc["'.$rkey.'"]=0;'); |
&popwin_js($r,'popwin.hc["'.$rkey.'"]=0;'); |
} |
} |
last WLOOP; |
last WLOOP; |
} |
} # end of if ( -e "$replyfile.end") |
if ($temp>1) { |
|
sleep 1; |
|
$timeremain--; |
|
$elapsetime++; |
|
last WLOOP; |
|
} |
|
last WLOOP unless $timeremain; |
last WLOOP unless $timeremain; |
sleep 1; |
sleep 1; # wait for daemons to write files? |
$timeremain--; |
$timeremain--; |
$elapsetime++; |
$elapsetime++; |
|
last WLOOP if ($temp>1); |
&popwin_js($r,"popwin.document.popremain.". |
&popwin_js($r,"popwin.document.popremain.". |
"elapsetime.value=$elapsetime;"); |
"elapsetime.value=$elapsetime;"); |
$temp++; |
$temp++; |
Line 1321 ENDPOP
|
Line 1147 ENDPOP
|
} |
} |
&popwin_js($r,'popwin.document.whirly.'. |
&popwin_js($r,'popwin.document.whirly.'. |
'src="/adm/lonIcons/lonanimend.gif";'); |
'src="/adm/lonIcons/lonanimend.gif";'); |
} |
} # end of if ($reply eq 'con_lost') else statement |
my $customshow=''; |
my $customshow=''; |
my $extrashow=''; |
my $extrashow=''; |
my @customfields; |
my @customfields; |
Line 1484 RESULTS
|
Line 1310 RESULTS
|
###################################################################### |
###################################################################### |
###################################################################### |
###################################################################### |
|
|
|
=pod |
|
|
|
=item &search_results_header |
|
|
|
=cut |
|
|
|
###################################################################### |
|
###################################################################### |
|
sub search_results_header { |
|
my $result = ''; |
|
# output beginning of search page |
|
$result.=<<BEGINNING; |
|
<html> |
|
<head> |
|
<title>The LearningOnline Network with CAPA</title> |
|
BEGINNING |
|
# conditional output of script functions dependent on the mode in |
|
# which the search was invoked |
|
if ($ENV{'form.catalogmode'} eq 'interactive'){ |
|
if (! exists($ENV{'form.mode'}) || $ENV{'form.mode'} ne 'edit') { |
|
$result.=<<SCRIPT; |
|
<script type="text/javascript"> |
|
function select_data(title,url) { |
|
changeTitle(title); |
|
changeURL(url); |
|
self.close(); |
|
} |
|
function changeTitle(val) { |
|
if (opener.inf.document.forms.resinfo.elements.t) { |
|
opener.inf.document.forms.resinfo.elements.t.value=val; |
|
} |
|
} |
|
function changeURL(val) { |
|
if (opener.inf.document.forms.resinfo.elements.u) { |
|
opener.inf.document.forms.resinfo.elements.u.value=val; |
|
} |
|
} |
|
</script> |
|
SCRIPT |
|
} elsif ($ENV{'form.mode'} eq 'edit') { |
|
my $form = $ENV{'form.form'}; |
|
my $element = $ENV{'form.element'}; |
|
$result.=<<SCRIPT; |
|
<script type="text/javascript"> |
|
function select_data(title,url) { |
|
changeURL(url); |
|
self.close(); |
|
} |
|
function changeTitle(val) { |
|
} |
|
function changeURL(val) { |
|
if (window.opener.document) { |
|
window.opener.document.forms["$form"].elements["$element"].value=val; |
|
} else { |
|
var url = 'forms[\"$form\"].elements[\"$element\"].value'; |
|
alert("Unable to transfer data to "+url); |
|
} |
|
} |
|
</script> |
|
SCRIPT |
|
} |
|
} |
|
$result.=<<SCRIPT if $ENV{'form.catalogmode'} eq 'groupsearch'; |
|
<script type="text/javascript"> |
|
function select_data(title,url) { |
|
// alert('DEBUG: Should be storing '+title+' and '+url); |
|
} |
|
function queue(val) { |
|
if (eval("document.forms.results.returnvalues["+val+"].checked")) { |
|
document.forms.results.acts.value+='1a'+val+'b'; |
|
} |
|
else { |
|
document.forms.results.acts.value+='0a'+val+'b'; |
|
} |
|
} |
|
function select_group() { |
|
window.location= |
|
"/adm/groupsort?mode=$ENV{'form.mode'}&catalogmode=groupsearch&acts="+ |
|
document.forms.results.acts.value; |
|
} |
|
</script> |
|
SCRIPT |
|
$result.=<<SCRIPT; |
|
<script type="text/javascript"> |
|
function displayinfo(val) { |
|
popwin.document.forms.popremain.sdetails.value=val; |
|
} |
|
function openhelp(val) { |
|
openhelpwin=open('/adm/help/searchcat.html','helpscreen', |
|
'scrollbars=1,width=400,height=300'); |
|
openhelpwin.focus(); |
|
} |
|
function abortsearch(val) { |
|
popwin.close(); |
|
} |
|
</script> |
|
SCRIPT |
|
return $result; |
|
} |
|
|
|
###################################################################### |
|
###################################################################### |
|
|
|
=pod |
|
|
|
=item &make_popwin() |
|
|
|
Returns html with javascript in it to open up the status window. |
|
|
|
=cut |
|
|
|
###################################################################### |
|
###################################################################### |
|
sub make_popwin { |
|
my %rhash = @_; |
|
my $servernum=(keys %rhash); |
|
my $hcinit; |
|
my $grid="'<br />'+\n"; |
|
# $sn is the server number, used ONLY to make sure we have |
|
# rows of 10 each. No longer used to index images. |
|
my $sn=1; |
|
foreach my $sk (sort keys %rhash) { |
|
# '<a href=" |
|
$grid.="'<a href=\""; |
|
# javascript:displayinfo('+ |
|
$grid.="javascript:opener.displayinfo('+"; |
|
# "'"+'key |
|
$grid.="\"'\"+'"; |
|
$grid.=$sk; |
|
my $hc; |
|
if ($rhash{$sk} eq 'con_lost') { |
|
$hc="BAD CONNECTION, CONTACT SYSTEM ADMINISTRATOR "; |
|
} |
|
else { |
|
$hc="'+\"'\"+\"+hc['$sk']+\"+\"'\"+'"; |
|
$hcinit.="hc[\"$sk\"]=\"not yet connected...\";"; |
|
} |
|
$grid.=" hitcount=".$hc; |
|
$grid.=" domain=".$hostdomains{$sk}; |
|
$grid.=" IP=".$hostips{$sk}; |
|
# '+"'"+'">'+ |
|
$grid.="'+\"'\"+')\">'+"; |
|
$grid.="\n"; |
|
$grid.="'<img border=\"0\" name=\"img_".$hostdomains{$sk}.'_'.$sk."\"". |
|
" src=\"/adm/lonIcons/srvnull.gif\" alt=\"".$sk."\" /></a>'+\n"; |
|
$grid.="'<br />'+\n" unless $sn%10; |
|
$sn++; |
|
} |
|
my $result.=<<ENDPOP; |
|
<script type="text/javascript"> |
|
popwin=open('','popwin','scrollbars=1,width=400,height=220'); |
|
popwin.focus(); |
|
popwin.document.writeln('<'+'html>'); |
|
popwin.document.writeln('<'+'head>'); |
|
popwin.document.writeln('<'+'script>'); |
|
popwin.document.writeln('hc=new Array();$hcinit'); |
|
popwin.document.writeln('<'+'/script>'); |
|
popwin.document.writeln('<'+'/head>'+ |
|
'<'+'body bgcolor="#FFFFFF">'+ |
|
'<'+'image name="whirly" align="right" src="/adm/lonIcons/'+ |
|
'lonanim.gif" '+ |
|
'alt="animated logo" />'+ |
|
'<'+'h3>Search Results Progress<'+'/h3>'+ |
|
'<'+'form name="popremain">'+ |
|
'<'+'tt>'+ |
|
'<'+'br clear="all"/><i>PLEASE BE PATIENT</i>'+ |
|
'<'+'br />SCANNING $servernum SERVERS'+ |
|
'<'+'br clear="all" />Number of record hits found '+ |
|
'<'+'input type="text" size="10" name="numhits"'+ |
|
' value="0" />'+ |
|
'<'+'br clear="all" />Time elapsed '+ |
|
'<'+'input type="text" size="10" name="elapsetime"'+ |
|
' value="0" />'+ |
|
'<'+'br />'+ |
|
'SERVER GRID (click on any cell for details)'+ |
|
$grid |
|
'<'+'br />'+ |
|
'Server details '+ |
|
'<'+'input type="text" size="35" name="sdetails"'+ |
|
' value="" />'+ |
|
'<'+'br />'+ |
|
' <'+'input type="button" name="button"'+ |
|
' value="close this window" '+ |
|
' onClick="javascript:opener.abortsearch()" />'+ |
|
' <'+'input type="button" name="button"'+ |
|
' value="help" onClick="javascript:opener.openhelp()" />'+ |
|
'<'+'/tt>'+ |
|
'<'+'/form>'+ |
|
'<'+'/body><'+'/html>'); |
|
popwin.document.close(); |
|
</script> |
|
ENDPOP |
|
return $result; |
|
} |
|
|
|
###################################################################### |
|
###################################################################### |
|
|
=pod |
=pod |
|
|
=item Metadata Viewing Functions |
=item Metadata Viewing Functions |
Line 1827 END
|
Line 1851 END
|
|
|
=item &popwin_imgupdate() |
=item &popwin_imgupdate() |
|
|
|
Send a given image (and its location) out to the browser. Takes as |
|
input $r, loncapa server id, and an icon URL. |
|
|
=cut |
=cut |
|
|
###################################################################### |
###################################################################### |
###################################################################### |
###################################################################### |
sub popwin_imgupdate { |
sub popwin_imgupdate { |
my ($r,$imgnum,$icon) = @_; |
my ($r,$server,$icon) = @_; |
&popwin_js($r,'popwin.document.img'.$imgnum.'.'. |
&popwin_js($r,'popwin.document.img_'.$hostdomains{$server}.'_'.$server.'.'. |
'src="/adm/lonIcons/'.$icon.'";'); |
'src="/adm/lonIcons/'.$icon.'";'); |
} |
} |
|
|