--- loncom/interface/lonsearchcat.pm 2002/06/19 19:40:38 1.122
+++ loncom/interface/lonsearchcat.pm 2002/07/26 16:37:58 1.144
@@ -1,7 +1,7 @@
# The LearningOnline Network with CAPA
# Search Catalog
#
-# $Id: lonsearchcat.pm,v 1.122 2002/06/19 19:40:38 matthew Exp $
+# $Id: lonsearchcat.pm,v 1.144 2002/07/26 16:37:58 matthew Exp $
#
# Copyright Michigan State University Board of Trustees
#
@@ -40,7 +40,7 @@
=head1 NAME
-lonsearchcat
+lonsearchcat - LONCAPA Search Interface
=head1 SYNOPSIS
@@ -67,14 +67,14 @@ search (on a server basis) is displayed
###############################################################################
###############################################################################
+###############################################################################
## ##
## ORGANIZATION OF THIS PERL MODULE ##
## ##
## 1. Modules used by this module ##
-## 2. Choices for different output views (detailed, summary, xml, etc) ##
-## 3. BEGIN block (to be run once after compilation) ##
-## 4. Handling routine called via Apache and mod_perl ##
-## 5. Other subroutines ##
+## 2. Variables used throughout the module ##
+## 3. handler subroutine called via Apache and mod_perl ##
+## 4. Other subroutines ##
## ##
###############################################################################
@@ -87,8 +87,10 @@ use Apache::lonnet();
use Apache::File();
use CGI qw(:standard);
use Text::Query;
+use DBI;
use GDBM_File;
use Apache::loncommon();
+use Apache::lonmysql();
# ---------------------------------------- variables used throughout the module
@@ -101,51 +103,33 @@ use Apache::loncommon();
=over 4
-=item %hostdomains
-
-matches host name to host domain
-
-=item %hostips
-
-matches host name to host ip
-
-=item %hitcount
-
-stores number of hits per host
-
=item $closebutton
button that closes the search window
=item $importbutton
-button to take the selecte results and go to group sorting
+button to take the select results and go to group sorting
-=item $hidden
-
-holds 'hidden' html forms
-
-=item $scrout
-
-string that holds portions of the screen output
+=item %groupsearch_db
-=item $yourself
+Database hash used to save values for the groupsearch RAT interface.
-allows for quickly limiting to oneself
+=item $diropendb
-=item %hash
+The full path to the (temporary) search database file. This is set and
+used in &handler() and is also used in &output_results().
-The ubiquitous database hash
+=item %Views
-=item $basicviewselect and $advancedviewselect
+Hash which associates an output view description with the function
+that produces it. Adding a new view type should be as easy as
+adding a line to the definition of this hash and making sure the function
+takes the proper parameters.
-View selection forms. These are not actually global and will be
-moved soon.
+=item $results_db
-=item $diropendb
-
-The full path to the (temporary) search database file. This is set and
-used in &handler() and is also used in &output_results().
+The name of the database results from searches are put in.
=back
@@ -154,119 +138,92 @@ used in &handler() and is also used in &
######################################################################
######################################################################
-# -- information holders
-my %hostdomains; # matches host name to host domain
-my %hostips; # matches host name to host ip
-my %hitcount; # stores number of hits per host
-
# -- dynamically rendered interface components
my $closebutton; # button that closes the search window
my $importbutton; # button to take the selected results and go to group sorting
-my $hidden; # Holds 'hidden' html forms
# -- miscellaneous variables
-my $scrout; # string that holds portions of the screen output
-my $yourself; # allows for quickly limiting to oneself
-my %hash; # database hash
-
-# ------------------------------------------ choices for different output views
-# Detailed Citation View ---> sub detailed_citation_view
-# Summary View ---> sub summary_view
-# Fielded Format ---> sub fielded_format_view
-# XML/SGML ---> sub xml_sgml_view
-my $basicviewselect=<
\n");
+ $r->rflush();
+ &run_search($r,$query,$customquery,$customshow,$libraries);
+ &display_results($r,$searchtype,$hidden,$importbutton,
+ $closebutton);
-# ----------------------------------- See if a search invocation should be done
- if ($ENV{'form.basicsubmit'} eq 'SEARCH') {
- untie %hash; return &basicsearch($r,\%ENV);
- }
- elsif ($ENV{'form.advancedsubmit'} eq 'SEARCH') {
- untie %hash; return &advancedsearch($r,\%ENV);
+ $r->rflush();
+ } else {
+ #
+ # We need to get information to search on
+ #
+ # Set the default view if it is not already set.
+ if (!defined($ENV{'form.viewselect'})) {
+ $ENV{'form.viewselect'} ="Detailed Citation View";
+ }
+ # Output the advanced interface
+ if ($ENV{'form.reqinterface'} eq 'advanced') {
+ $r->print(&advanced_search_form($closebutton,$hidden));
+ } else {
+ # Output normal search interface
+ $r->print(&basic_search_form($closebutton,$hidden));
+ }
}
+ return OK;
+}
+
+######################################################################
+######################################################################
-# ----------------------------- Else, begin building search interface to output
- $scrout=''; # building a part of screen output
- $scrout.=&searchphrasefield('Limit by title','title',
- $ENV{'form.title'});
+=pod
- $scrout.=&searchphrasefield('Limit by author','author',
- $ENV{'form.author'});
+=item &basic_search_form()
- $scrout.=&searchphrasefield('Limit by subject','subject',
- $ENV{'form.subject'});
+Returns a scalar which holds html for the basic search form.
- $scrout.=&searchphrasefield('Limit by keywords','keywords',
- $ENV{'form.keywords'});
+=cut
+
+######################################################################
+######################################################################
- $scrout.=&searchphrasefield('Limit by URL','url',
- $ENV{'form.url'});
+sub basic_search_form{
+ my ($closebutton,$hidden) = @_;
+ my $scrout=<<"ENDDOCUMENT";
+
+
+
+
Search Catalog
+
+
+$closebutton
+END
+ $scrout.=&selectbox(undef,'viewselect',
+ $ENV{'form.viewselect'},
+ undef,undef,undef,
+ sort(keys(%Views)));
+ $scrout.=<
+ + +$closebutton + +
+END + if (!defined($ENV{'form.viewselect'})) { + $ENV{'form.viewselect'} ="Detailed Citation View"; + } + my $scrout=<<"ENDHEADER"; + + +