--- loncom/interface/lonsearchcat.pm 2001/08/28 12:12:38 1.100 +++ loncom/interface/lonsearchcat.pm 2001/10/17 03:31:34 1.102 @@ -7,7 +7,7 @@ # Scott Harrison: 03/12/2001, 03/13/2001, 03/14/2001, 03/15/2001, 03/19/2001 # Scott Harrison: 03/20/2001, 03/21/2001, 03/22/2001, 03/26/2001, 03/27/2001 # Scott Harrison: 04/02/2001, 08/15/2001, 08/24/2001, 08/25/2001 - +# 10/12,10/14,10/15,10/16 Scott Harrison ############################################################################### ## ## ## ORGANIZATION OF THIS PERL MODULE ## @@ -110,6 +110,7 @@ use Apache::lonnet(); use Apache::File(); use CGI qw(:standard); use Text::Query; +use GDBM_File; # ---------------------------------------- variables used throughout the module @@ -127,8 +128,8 @@ my $importbutton; # button to take the s # -- miscellaneous variables my $scrout; # string that holds portions of the screen output -my $fnum; # search result counter my $yourself; # allows for quickly limiting to oneself +my %hash; # ------------------------------------------ choices for different output views # Detailed Citation View ---> sub detailed_citation_view @@ -195,6 +196,9 @@ sub BEGIN { } } +my $diropendb = ""; +my $domain = ""; + # ----------------------------- Handling routine called via Apache and mod_perl sub handler { my $r = shift; @@ -205,6 +209,22 @@ sub handler { $r->send_http_header; return OK if $r->header_only; + $domain = $r->dir_config('lonDefDomain'); + + $diropendb = "/home/httpd/perl/tmp/$domain\_$ENV{'user.name'}_indexer.db"; + + if ($ENV{'form.launch'} eq '1') { + if (tie(%hash,'GDBM_File',$diropendb,&GDBM_WRCREAT,0640)) { + &start_fresh_session(); + untie %hash; + } + else { + $r->print('Unable to tie hash to db '. + 'file'); + return OK; + } + } + # ----------------------------------- configure dynamic components of interface my $hidden=''; if ($ENV{'form.catalogmode'} eq 'interactive') { @@ -236,10 +256,10 @@ END # ----------------------------------- See if a search invocation should be done if ($ENV{'form.basicsubmit'} eq 'SEARCH') { - return &basicsearch($r,\%ENV); + untie %hash; return &basicsearch($r,\%ENV); } elsif ($ENV{'form.advancedsubmit'} eq 'SEARCH') { - return &advancedsearch($r,\%ENV); + untie %hash; return &advancedsearch($r,\%ENV); } # ----------------------------- Else, begin building search interface to output @@ -417,7 +437,7 @@ sub get_unprocessed_cgi { my ($name, $value) = split(/=/,$_); $value =~ tr/+/ /; $value =~ s/%([a-fA-F0-9][a-fA-F0-9])/pack("C",hex($1))/eg; - if ($name eq 'catalogmode') { + if ($name eq 'catalogmode' or $name eq 'launch' or $name eq 'acts') { $ENV{'form.'.$name}=$value; } } (split(/&/,$ENV{'QUERY_STRING'})); @@ -641,7 +661,7 @@ sub advancedsearch { 'lastrevisiondateend_day','lastrevisiondateend_year', 'notes','abstract','mime','language','owner', 'custommetadata','customshow') { - $ENV{"form.$field"}=~s/[^\w\s\(\)\=\-\"\']//g; + $ENV{"form.$field"}=~s/[^\w\/\s\(\)\=\-\"\']//g; } # Check to see if enough information was filled in @@ -891,11 +911,12 @@ sub build_date_queries { # gives the status of the network search (time elapsed, number of machines # contacted, etc.) sub output_results { + my $fnum; # search result counter my ($mode,$r,$envhash,$query,$replyref)=@_; my %ENV=%{$envhash}; my %rhash=%{$replyref}; my $compiledresult=''; - my $timeremain=30; + my $timeremain=300; my $elapsetime=0; my $resultflag=0; my $tflag=1; @@ -934,10 +955,10 @@ SCRIPT $r->print(< function select_data(title,url) { - alert('DEBUG: Should be storing '+title+' and '+url); +// alert('DEBUG: Should be storing '+title+' and '+url); } function queue(val) { - if (eval("document.forms."+val+".filelink.checked")) { + if (eval("document.forms.results.returnvalues["+val+"].checked")) { document.forms.results.acts.value+='1a'+val+'b'; } else { @@ -945,7 +966,8 @@ SCRIPT } } function select_group() { - alert('DEBUG: Should be moving on to group sorting stage'+' acts'); + window.location="/adm/groupsort?catalogmode=groupsearch&acts="+ + document.forms.results.acts.value; } SCRIPT @@ -959,6 +981,11 @@ SCRIPT 'scrollbars=1,width=400,height=300'); openhelpwin.focus(); } + function abortsearch(val) { + openhelpwin=open('/adm/help/searchcat.html','helpscreen', + 'scrollbars=1,width=400,height=300'); + openhelpwin.focus(); + } SCRIPT $r->rflush(); @@ -1067,7 +1094,7 @@ RESULTS '<'+'br />'+ ' <'+'input type="button" name="button"'+ ' value="abort search and view current results" '+ - ' />'+ + ' onClick="javascript:opener.abortsearch()" />'+ ' <'+'input type="button" name="button"'+ ' value="help" onClick="javascript:opener.openhelp()" />'+ '<'+'/tt>'+ @@ -1079,10 +1106,15 @@ ENDPOP $r->rflush(); my $servercount=0; - $sn=0; my $hitcountsum=0; - foreach my $rkey (sort keys %rhash) { + my $bloop=$servernum; + my %orkey; + BLOOP: while(1) { + my $sn=0; + last BLOOP unless $bloop; + RLOOP: foreach my $rkey (sort keys %rhash) { $sn++; + next RLOOP if $orkey{$rkey}; $servercount++; $tflag=1; $compiledresult=''; @@ -1098,6 +1130,8 @@ ENDPOP 'src="/adm/lonIcons/srvbad.gif";'. "\n"); $r->rflush(); + $bloop--; + $orkey{$rkey}=1; } else { $reply=~/^([\.\w]+)$/; # must do since 'use strict' checks for tainting @@ -1119,8 +1153,10 @@ ENDPOP $r->rflush(); $tflag=0; } - last WLOOP if $temp>5; + last WLOOP if $temp>1; if (-e "$replyfile.end") { + $bloop--; + $orkey{$rkey}=1; if (-s $replyfile) { $r->print('