NAME

lonsearchcat


SYNOPSIS

Search interface to LON-CAPAs digital library


DESCRIPTION

This module enables searching for a distributed browseable catalog.

This is part of the LearningOnline Network with CAPA project described at http://www.lon-capa.org.

lonsearchcat presents the user with an interface to search the LON-CAPA digital library. lonsearchcat also initiates the execution of a search by sending the search parameters to LON-CAPA servers. The progress of search (on a server basis) is displayed to the user in a seperate window.


Internals

Global variables
$closebutton
button that closes the search window

$importbutton
button to take the select results and go to group sorting

%hash
The ubiquitous database hash

$diropendb
The full path to the (temporary) search database file. This is set and used in &handler() and is also used in &output_results().

&handler() - main handler invoked by httpd child
Variables
$hidden
holds 'hidden' html forms

$scrout
string that holds portions of the screen output

&basic_search_form()
Returns a scalar which holds html for the basic search form.

&advanced_search_form()
Returns a scalar which holds html for the advanced search form.

&make_persistent()
Returns a scalar which holds the current ENV{'form.*'} values in a 'hidden' html input tag. This allows search interface information to be somewhat persistent.

HTML form building functions
&simpletextfield()
Inputs: $name,$value,$size

Returns a text input field with the given name, value, and size. If size is not specified, a value of 20 is used.

&simplecheckbox()
Inputs: $name,$value

Returns a simple check box with the given $name. If $value eq 'on' the box is checked.

&searchphrasefield()
Inputs: $title,$name,$value

Returns html for a title line and an input field for entering search terms. the instructions ``Enter terms or phrases separated by search operators such as AND, OR, or NOT.'' are given following the title. The entry field (which is where the $name and $value are used) is an 80 column simpletextfield.

&dateboxes()
Returns html selection form elements for the specification of the day, month, and year.

&selectbox()
Returns a scalar containing an html <select> form.

Inputs:

$title
Printed above the select box, in uppercase.

$name
The name element of the <select> tag.

$default
The default value of the form. Can be $anyvalue or in @idlist.

$anyvalue
The <option value=``...''> used to indicate a default of none of the values.

$anytag
The text associate with $anyvalue above.

$functionref
Each element in @idlist will be passed as a parameter to the function referenced here. The return value of the function should be a scalar description of the items. If this value is undefined the description of each item in @idlist will be the item name.

@idlist
The items to be selected from. One of these or $anyvalue will be the value returned by the form element, $ENV{form.$name}.

&parse_advanced_search()
Parse advanced search form and return the following:
$query Scalar containing an SQL query.
$customquery Scalar containing a custom query.
$customshow Scalar containing commands to show custom metadata.
$libraries_to_query Reference to array of domains to search.
&parse_basic_search()
Parse the basic search form and return a scalar containing an sql query.

&build_SQL_query()
Builds a SQL query string from a logical expression with AND/OR keywords using Text::Query and &recursive_SQL_query_builder()

&build_custommetadata_query()
Constructs a custom metadata query using a rather heinous regular expression.

&recursive_SQL_query_build()
Recursively constructs an SQL query. Takes as input $dkey and $pattern.

&build_date_queries()
Builds a SQL logic query to check time/date entries. Also reports errors (check for /^Incorrect/).

&output_results()
Format and output results based on a reply list. There are two windows that this function writes to. The main search window (``srch'') has a listing of the results. A secondary window (``popwin'') gives the status of the network search (time elapsed, number of machines contacted, etc.)

&parse_raw_result()
Takes a line from the file of results and parse it. Returns a hash with keys for the following fields: 'title', 'author', 'subject', 'url', 'keywords', 'version', 'notes', 'abstract', 'mime', 'lang', 'owner', 'copyright', 'creationdate', 'lastrevisiondate'.

In addition, the following tags are set by calling the appropriate lonnet function: 'language', 'cprtag', 'mimetag'.

The 'title' field is set to ``Untitled'' if the title field is blank.

'abstract' and 'keywords' are truncated to 200 characters.

&handle_custom_fields()
&search_results_header
Output the proper html headers and javascript code to deal with different calling modes.

Takes most inputs directly from %ENV, except $mode.

$mode is either (at this writing) 'Basic' or 'Advanced'

The following environment variables are checked:

'form.catalogmode'
Checked for 'interactive' and 'groupsearch'.

'form.mode'
Checked for existance & 'edit' mode.

'form.form'
'form.element'
&make_popwin()
Returns html with javascript in it to open up the status window.

Metadata Viewing Functions
Output is a HTML-ified string. Input arguments are title, author, subject, url, keywords, version, notes, short abstract, mime, language, creation date, last revision date, owner, copyright, hostname, and extra custom metadata to show.
&detailed_citation_view()
&summary_view()
&fielded_format_view()
&xml_sgml_view()
&filled() see if field is filled.
&output_blank_field_error()
&output_date_error()
Output a full html page with an error message.

&start_fresh_session()
Cleans the global %hash by removing all fields which begin with 'pre_' or 'store'.

&popwin_js() send javascript to popwin
&popwin_imgupdate()
Send a given image (and its location) out to the browser. Takes as input $r, loncapa server id, and an icon URL.