--- loncom/interface/lonsearchcat.pm 2002/08/16 13:52:51 1.153 +++ loncom/interface/lonsearchcat.pm 2002/10/29 19:53:45 1.159 @@ -1,7 +1,7 @@ # The LearningOnline Network with CAPA # Search Catalog # -# $Id: lonsearchcat.pm,v 1.153 2002/08/16 13:52:51 matthew Exp $ +# $Id: lonsearchcat.pm,v 1.159 2002/10/29 19:53:45 matthew Exp $ # # Copyright Michigan State University Board of Trustees # @@ -115,6 +115,11 @@ that produces it. Adding a new view typ adding a line to the definition of this hash and making sure the function takes the proper parameters. +=item $bodytag + +LON-CAPA standard body tag, gotten from &Apache::lonnet::bodytag. +No title, no table, just a tag. + =back =cut @@ -136,6 +141,8 @@ my %Views = ("Detailed Citation View" => "Compact View" => \&compact_view); my %persistent_db; my $hidden_fields; +my $bodytag; + ###################################################################### ###################################################################### @@ -164,6 +171,10 @@ string that holds portions of the screen sub handler { my $r = shift; # + + my $loaderror=&Apache::lonnet::overloaderror($r); + if ($loaderror) { return $loaderror; } + my $closebutton; # button that closes the search window # This button is different for the RAT compared to # normal invocation. @@ -171,12 +182,17 @@ sub handler { $r->content_type('text/html'); $r->send_http_header; return OK if $r->header_only; + ## + ## Prevent caching of the search interface window. Hopefully this means + ## we will get the launch=1 passed in a little more. + &Apache::loncommon::no_cache($r); ## ## Pick up form fields passed in the links. ## &Apache::loncommon::get_unprocessed_cgi($ENV{'QUERY_STRING'}, ['catalogmode','launch','acts','mode','form','element','pause', - 'phase','persistent_db_id','table','start','show']); + 'phase','persistent_db_id','table','start','show', + 'cleargroupsort']); ## ## The following is a trick - we wait a few seconds if asked to so ## the daemon running the search can get ahead of the daemon @@ -201,6 +217,7 @@ sub handler { ($ENV{'form.launch'} eq '1')) { $ENV{'form.persistent_db_id'} = time; } + $bodytag=&Apache::loncommon::bodytag(undef,undef,undef,1); my $persistent_db_file = "/home/httpd/perl/tmp/". &Apache::lonnet::escape($domain). '_'.&Apache::lonnet::escape($ENV{'user.name'}). @@ -213,7 +230,7 @@ sub handler { $r->print(< LON-CAPA Search Error - +$bodytag We were unable to retrieve data describing your search. This is a serious error and has been logged. Please alert your LON-CAPA administrator. @@ -226,15 +243,18 @@ END ## Clear out old values from groupsearch database ## untie %groupsearch_db if (tied(%groupsearch_db)); - if ($ENV{'form.launch'} eq '1' && - ($ENV{'form.catalogmode'} eq 'groupsearch') && - ($ENV{'form.phase'} eq 'results')) { + if (($ENV{'form.cleargroupsort'} eq '1') || + (($ENV{'form.launch'} eq '1') && + ($ENV{'form.catalogmode'} eq 'groupsearch'))) { if (tie(%groupsearch_db,'GDBM_File',$diropendb,&GDBM_WRCREAT(),0640)) { &start_fresh_session(); untie %groupsearch_db; + delete($ENV{'form.cleargroupsort'}); } else { - $r->print('Unable to tie hash to db '. - 'file'); + # This is a stupid error to give to the user. + # It really tells them nothing. + $r->print(''.$bodytag. + 'Unable to tie hash to db file'); return OK; } } @@ -329,7 +349,7 @@ END if (! defined(&create_results_table())) { $r->print(<Search Error - +$bodytag Unable to create table in which to store search results. The search has been aborted. @@ -341,7 +361,7 @@ END if (! &make_form_data_persistent($r,$persistent_db_file)) { $r->print(<Search Error - +$bodytag Unable to properly store search information. The search has been aborted. @@ -390,6 +410,7 @@ Returns a scalar which holds html for th sub print_basic_search_form{ my ($r,$closebutton) = @_; + my $bodytag=&Apache::loncommon::bodytag('Catalog Search'); my $scrout=<<"ENDDOCUMENT"; @@ -402,13 +423,10 @@ sub print_basic_search_form{ } - - -

Search Catalog

+$bodytag
$hidden_fields -

Basic Search

Enter terms or phrases separated by AND, OR, or NOT then press SEARCH below. @@ -474,6 +492,7 @@ END if (!defined($ENV{'form.viewselect'})) { $ENV{'form.viewselect'} ="Detailed Citation View"; } + my $bodytag=&Apache::loncommon::bodytag('Advanced Catalog Search'); my $scrout=<<"ENDHEADER"; @@ -486,10 +505,7 @@ END } - - -

Advanced Catalog Search

-
+$bodytag Enter terms or phrases separated by search operators such as AND, OR, or NOT.
@@ -1671,7 +1687,7 @@ sub print_sort_form { Results - +$bodytag END @@ -1858,6 +1874,7 @@ sub revise_button { $revise_phase = 'disp_adv' if ($ENV{'form.searchmode'} eq 'advanced'); my $newloc = '/adm/searchcat'. '?persistent_db_id='.$ENV{'form.persistent_db_id'}. + '&cleargroupsort=1'. '&phase='.$revise_phase; my $result = qq{ }; @@ -1889,7 +1906,7 @@ sub run_search { $r->print(< Search Status - +$bodytag END @@ -1959,7 +1976,7 @@ END my $time_remaining = $max_time - (time - $starttime) ; my $last_time = $time_remaining; &update_seconds($r,$time_remaining); - while (($time_remaining > 0) && + while (($time_remaining > 0) && ((@Servers_to_contact) || keys(%Server_status))) { # Send out a search request if it needs to be done. if (@Servers_to_contact) { @@ -1977,7 +1994,13 @@ END # left to contact. sleep(1); } - &update_status($r,'waiting on '.(join(' ',keys(%Server_status)))); + # + if (scalar (keys(%Server_status))) { + &update_status($r,'waiting on '.(join(' ',keys(%Server_status)))); + } + # + # Loop through the servers we have contacted but do not + # have results from yet, looking for results. while (my ($server,$status) = each(%Server_status)) { last if ($connection->aborted()); if ($status eq 'con_lost') { @@ -2040,6 +2063,7 @@ END } last if ($connection->aborted()); # Finished looping through the servers + $starttime = time if (@Servers_to_contact); $time_remaining = $max_time - (time - $starttime) ; if ($last_time - $time_remaining > 0) { $last_time = $time_remaining; @@ -2131,6 +2155,10 @@ sub display_results { return; } ## + ## $checkbox_num is a count of the number of checkboxes output on the + ## page this is used only during catalogmode=groupsearch. + my $checkbox_num = 0; + ## ## Get the catalog controls setup ## my $action = "/adm/searchcat?phase=results"; @@ -2209,7 +2237,8 @@ sub display_results { } my %Fields = %{&parse_row(@$row)}; my $output="

\n"; - my $prefix=&catalogmode_output($Fields{'title'},$Fields{'url'}); + my $prefix=&catalogmode_output($Fields{'title'},$Fields{'url'}, + $Fields{'id'},$checkbox_num++); # Render the result into html $output.= &$viewfunction($prefix,%Fields); # Print them out as they come in. @@ -2240,22 +2269,18 @@ sub display_results { =pod -=item &catalogmode_output($title,$url) +=item &catalogmode_output($title,$url,$fnum,$checkbox_num) Returns html needed for the various catalog modes. Gets inputs from -$ENV{'form.catalogmode'}. Stores data in %groupsearch_db and $fnum -(local variable). +$ENV{'form.catalogmode'}. Stores data in %groupsearch_db. =cut ###################################################################### ###################################################################### -{ -my $fnum = 0; - sub catalogmode_output { my $output = ''; - my ($title,$url) = @_; + my ($title,$url,$fnum,$checkbox_num) = @_; if ($ENV{'form.catalogmode'} eq 'interactive') { $title=~ s/\'/\\\'/g; if ($ENV{'form.catalogmode'} eq 'interactive') { @@ -2271,15 +2296,12 @@ END $output.=< +onClick="javascript:queue($checkbox_num,$fnum)" /> END - $fnum++; } return $output; } - -} ###################################################################### ###################################################################### @@ -2527,8 +2549,8 @@ SCRIPT } $result.=< LON-CAPA Digital Library Search Results @@ -2827,7 +2851,7 @@ sub output_blank_field_error { BEGINNING $r->print(< - +$bodytag

Search Catalog

@@ -2874,7 +2898,7 @@ sub output_date_error { The LearningOnline Network with CAPA - +$bodytag

Search Catalog