--- loncom/interface/lonsearchcat.pm 2002/08/01 14:11:57 1.150
+++ loncom/interface/lonsearchcat.pm 2002/09/16 20:09:45 1.157
@@ -1,7 +1,7 @@
# The LearningOnline Network with CAPA
# Search Catalog
#
-# $Id: lonsearchcat.pm,v 1.150 2002/08/01 14:11:57 matthew Exp $
+# $Id: lonsearchcat.pm,v 1.157 2002/09/16 20:09:45 www 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,6 +182,10 @@ 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.
##
@@ -201,19 +216,20 @@ 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'}).
'_'.$ENV{'form.persistent_db_id'}.'_persistent_search.db';
##
- if (! &get_persistent_form_data($r,$persistent_db_file)) {
+ 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(<
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 +242,16 @@ 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.launch'} eq '1') &&
+ ($ENV{'form.catalogmode'} eq 'groupsearch')) {
if (tie(%groupsearch_db,'GDBM_File',$diropendb,&GDBM_WRCREAT(),0640)) {
&start_fresh_session();
untie %groupsearch_db;
} 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;
}
}
@@ -298,6 +315,7 @@ END
}
}
$ENV{'form.phase'} = 'disp_basic' if (! exists($ENV{'form.phase'}));
+ $ENV{'form.show'} = 20 if (! exists($ENV{'form.show'}));
##
## Switch on the phase
##
@@ -307,20 +325,28 @@ END
&print_advanced_search_form($r,$closebutton);
} elsif ($ENV{'form.phase'} eq 'results') {
&display_results($r,$importbutton,$closebutton);
- } elsif($ENV{'form.phase'} eq 'run_search') {
+ } elsif ($ENV{'form.phase'} =~ /^(sort|run_search)$/) {
my ($query,$customquery,$customshow,$libraries,$pretty_string) =
&get_persistent_data($persistent_db_file,
['query','customquery','customshow',
'libraries','pretty_string']);
- &run_search($r,$query,$customquery,$customshow,
- $libraries,$pretty_string);
+ if ($ENV{'form.phase'} eq 'sort') {
+ &print_sort_form($r,$pretty_string);
+ } elsif ($ENV{'form.phase'} eq 'run_search') {
+ &run_search($r,$query,$customquery,$customshow,
+ $libraries,$pretty_string);
+ }
} elsif(($ENV{'form.phase'} eq 'basic_search') ||
($ENV{'form.phase'} eq 'adv_search')) {
+ $ENV{'form.searchmode'} = 'basic';
+ if ($ENV{'form.phase'} eq 'adv_search') {
+ $ENV{'form.searchmode'} = 'advanced';
+ }
# Set up table
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.
@@ -332,7 +358,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.