--- loncom/interface/lonsearchcat.pm 2002/07/28 20:02:14 1.145 +++ loncom/interface/lonsearchcat.pm 2003/01/06 13:54:25 1.162 @@ -1,7 +1,7 @@ # The LearningOnline Network with CAPA # Search Catalog # -# $Id: lonsearchcat.pm,v 1.145 2002/07/28 20:02:14 matthew Exp $ +# $Id: lonsearchcat.pm,v 1.162 2003/01/06 13:54:25 www Exp $ # # Copyright Michigan State University Board of Trustees # @@ -25,14 +25,6 @@ # # http://www.lon-capa.org/ # -# YEAR=2001 -# 3/8, 3/12, 3/13, 3/14, 3/15, 3/19 Scott Harrison -# 3/20, 3/21, 3/22, 3/26, 3/27, 4/2, 8/15, 8/24, 8/25 Scott Harrison -# 10/12,10/14,10/15,10/16,11/28,11/29,12/10,12/12,12/16 Scott Harrison -# YEAR=2002 -# 1/17 Scott Harrison -# 6/17 Matthew Hall -# ############################################################################### ############################################################################### @@ -123,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 @@ -140,10 +137,12 @@ my $diropendb = ""; # db file my %Views = ("Detailed Citation View" => \&detailed_citation_view, "Summary View" => \&summary_view, "Fielded Format" => \&fielded_format_view, - "XML/SGML" => \&xml_sgml_view ); -my $persistent_db_file; + "XML/SGML" => \&xml_sgml_view, + "Compact View" => \&compact_view); my %persistent_db; my $hidden_fields; +my $bodytag; + ###################################################################### ###################################################################### @@ -172,8 +171,10 @@ string that holds portions of the screen sub handler { my $r = shift; # - untie %groupsearch_db if (tied(%groupsearch_db)); - # + + 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. @@ -181,12 +182,27 @@ 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', - 'reqinterface','persistent_db_id','table']); + ['catalogmode','launch','acts','mode','form','element','pause', + '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 + ## printing the results. We only need (theoretically) to do + ## this once, so the pause indicator is deleted + ## + if (exists($ENV{'form.pause'})) { + sleep(3); + delete($ENV{'form.pause'}); + } ## ## Initialize global variables ## @@ -195,118 +211,186 @@ sub handler { "\_".&Apache::lonnet::escape($ENV{'user.name'})."_searchcat.db"; # # set the name of the persistent database - # $ENV{'form.persistent_db_id'} can only have digits in it. + # $ENV{'form.persistent_db_id'} can only have digits in it. if (! exists($ENV{'form.persistent_db_id'}) || - $ENV{'form.persistent_db_id'} =~ /\D/ ) { + ($ENV{'form.persistent_db_id'} =~ /\D/) || + ($ENV{'form.launch'} eq '1')) { $ENV{'form.persistent_db_id'} = time; } - $persistent_db_file = "/home/httpd/perl/tmp/". + $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'}). '_'.$ENV{'form.persistent_db_id'}.'_persistent_search.db'; - # - # Read in the database. It should (hopefully) not be catastrophic to - # fail in this exercise. - if (-e $persistent_db_file) { - # Read in the previous values, if we can. - if (tie(%persistent_db,'GDBM_File',$persistent_db_file, - &GDBM_READER,0640)) { - &reconstruct_persistent_form_data($r); - untie (%persistent_db); - } + ## + if (! &get_persistent_form_data($persistent_db_file)) { + if ($ENV{'form.phase'} =~ /(run_search|results)/) { + &Apache::lonnet::logthis("lonsearchcat:Unable to recover data ". + "from $persistent_db_file"); + $r->print(<