NAME

lonsearchcat - LONCAPA Search Interface


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 separate window.


Internals

&print_basic_search_form()

Prints the form for the basic search. Sorry the name is so cryptic.

&advanced_search_form()

Prints the advanced search form.

&titlefield()

Inputs: title text

Outputs: titletext with font wrapper

viewoptiontext()

Inputs: codename for view option

Outputs: displayed text

viewoptions()

Inputs: none

Outputs: text for box with view options

searchhelp()

Inputs: none

Outputs: return little blurb on how to enter searches

&get_persistent_form_data()

Inputs: filename of database

Outputs: returns undef on database errors.

This function is the reverse of &make_persistent() for form data. Retrieve persistent data from %persistent_db. Retrieved items will have their values unescaped. If a form value already exists in $env, it will not be overwritten. Form values that are array references may have values appended to them.

&get_persistent_data()

Inputs: filename of database, ref to array of values to recover.

Outputs: array of values. Returns undef on error.

This function is the reverse of &make_persistent(); Retrieve persistent data from %persistent_db. Retrieved items will have their values unescaped. If the item contains commas (before unescaping), the returned value will be an array pointer.

&make_persistent()

Inputs: Hash of values to save, filename of persistent database.

Store variables away to the %persistent_db. Values will be escaped. Values that are array pointers will have their elements escaped and concatenated in a comma separated string.

&make_form_data_persistent()

Inputs: filename of persistent database.

Store most form variables away to the %persistent_db. Values will be escaped. Values that are array pointers will have their elements escaped and concatenated in a comma separated string.

&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.

&related_version()

Modifies an input string to include related words. Words in the string are replaced with parenthesized lists of 'OR'd words. For example ``torque'' is replaced with ``(torque OR word1 OR word2 OR ...)''.

Note: Using this twice on a string is probably silly.

&build_custommetadata_query()

Constructs a custom metadata query using a rather heinous regular expression.

&build_date_queries()

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

&copyright_check()

Inputs: $Metadata, a hash pointer of metadata for a resource.

Returns: 1 if the resource is available to the user making the query, 0 otherwise.

&ensure_db_and_table()

Ensure we can get lonmysql to connect to the database and the table we need exists.

Inputs: $r, table id

Returns: undef on error, 1 if the table exists.

&print_sort_form()

The sort feature is not implemented at this time. This form just prints a link to change the search query.

MySQL Table Description

MySQL table creation requires a precise description of the data to be stored. The use of the correct types to hold data is vital to efficient storage and quick retrieval of records. The columns must be described in the following format:

&create_results_table()

Creates the table of search results by calling lonmysql. Stores the table id in $env{'form.table'}

Inputs: search area - either res or portfolio

Returns: the identifier of the table on success, undef on error.

Search Status update functions

Each of the following functions changes the values of one of the input fields used to display the search status to the user. The names should be explanatory.

Inputs: Apache request handler ($r), text to display.

Returns: Nothing.

&update_count_status()
&update_status()
&update_seconds()
&revise_button()

Inputs: None

Returns: html string for a 'revise search' button.

&run_search()

Executes a search query by sending it the the other servers and putting the results into MySQL.

&prev_next_buttons()

Returns html for the previous and next buttons on the search results page.

&display_results()

Prints the results out for selection and perusal.

&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.

&parse_row()

Parse a row returned from the database.

&parse_raw_result()

Takes a line from the file of results and parse it. Returns a hash with keys according to column labels

In addition, the following tags are set by calling the appropriate lonnet function: 'language', 'copyrighttag', '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 'import'.

'form.mode'

Checked for existance & 'edit' mode.

'form.form'

Contains the name of the form that has the input fields to set

'form.element'

the name of the input field to put the URL into

'form.titleelement'

the name of the input field to put the title into

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()
&compact_view()
&fielded_format_view()
&xml_sgml_view()
&filled() see if field is filled.
&output_unparsed_phrase_error()
&output_blank_field_error()

Output a complete page that indicates the user has not filled in enough information to do a search.

Inputs: $r (Apache request handle), $closebutton, $parms.

Returns: nothing

$parms is extra information to include in the 'Revise search request' link.

&output_date_error()

Output a full html page with an error message.

Inputs:

    $r, the request pointer.
    $message, the error message for the user.
    $closebutton, the specialized close button needed for groupsearch.
&start_fresh_session()

Cleans the global %groupsearch_db by removing all fields which begin with 'pre_' or 'store'.