API:EPrints/Search/Field

From EPrints Documentation
Revision as of 18:29, 11 August 2009 by Tdb01r (talk | contribs) (New page: <!-- Pod2Wiki=_preamble_ This page has been automatically generated from the EPrints source. Any wiki changes made between the 'Pod2Wiki=*' and 'End of Pod2Wiki' comments will be lost. -...)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to: navigation, search

Latest Source Code (3.3, 3.2) | Revision Log | Before editing this page please read Pod2Wiki

NAME

EPrints::Search::Field - One field in a search expression.

DESCRIPTION

This class represents a single field in a search expression, and by extension a search form.

It should not be confused with MetaField.

It can search over several metadata fields, and the value of the value of the search field is usually a string containing a list of whitespace seperated words, or other search criteria.

A search field has four key parameters:

1. The list of the metadata fields it searches.

2. The value to search for.

3. The "match" parameter which can be one of:

match_in

 match=IN

Treat the value as a list of whitespace-seperated words. Search for each one in the full-text index.

In the case of subjects, match these subject ids or the those of any of their decendants in the subject tree.

eq

 match=EQ (equal)

Treat the value as a single string. Match only fields which have this value.

ex

 match=EX (exact)

If the value is an empty string then search for fields which are empty, as oppose to skipping this search field.

In the case of subjects, match the specified subjects, but not their decendants.

match_no

 match=NO

This is only really used internally, it means the search field will just fail to match anything without doing any actual searching.

merge_any

 merge=ANY 

Match an item if any of the words in the value match.

merge_all

 merge=ALL 

Match an item only if all of the words in the value match.

METHODS

new

 $thing = EPrints::Search::Field->new( $session, $dataset, $fields, $value, [$match], [$merge], [$prefix], [$show_help] )

Create a new search field object.

$prefix is used when generating HTML forms and reading values from forms.

$fields is a reference to an array of field names.

$match is one of EQ, IN, EX. default is EQ.

$merge is ANY or ALL. default is ALL

Special case - if match is "EX" and field type is name then value must be a name hash.

$show_help is used to control if the help shows up on the search form. A value of "always" shows the help without the show/hide toggle. "never" shows no help and no toggle. "toggle" shows no help, but shows the [?] icon which will reveal the help. The default is "toggle". If javascript is off, toggle will show the help and show no toggle.

clear

 $sf->clear

Set this searchfield's "match" to "NO" so that it always returns nothing when searched.

from_form

 $problem = $sf->from_form

Modify the value, merge and match parameters of this field based on results from an HTML form.

Return undef if everything is OK, otherwise return a ref to an array containing the problems as XHTML DOM objects.

get_conditions

 $search_condition = $sf->get_conditions 

Convert this Search::Field into an EPrints::Search::Condition object which can actually perform the search.

get_value

 $value = $sf->get_value

Return the current value parameter of this search field.

get_match

 $match = $sf->get_match

Return the current match parameter of this search field.

get_merge

 $merge = $sf->get_merge

Return the current merge parameter of this search field.

get_field

 $field = $sf->get_field

Return the first of the metafields which we are searching. This is used for establishing the type of the search field. If this metafield has special input rendering methods then they will be used for this search field.

get_fields

 $fields = $sf->get_fields

Return a reference to an array of EPrints::MetaField objects which this search field is going to search.

render

 $xhtml = $sf->render

Returns an XHTML tree of this search field which contains all the input boxes required to search this field.

get_form_prefix

 $xhtml = $sf->get_form_prefix

Return the string use to prefix form field names so values don't get mixed with other search fields.

render_description

 $xhtml = $sf->render_description

Returns an XHTML DOM object describing this field and its current settings. Used at the top of the search results page to describe the search.

render_name

 $xhtml_name = $sf->render_name

Return XHTML object of this searchfields name.

render_help

 $xhtml_help = $sf->render_help

Return an XHTML DOM object containing the "help" for this search field.

is_type

 $boolean = $sf->is_type( @types )

Return true if the first metafield in the fieldlist is of any of the types in @types.

get_id

 $id = $sf->get_id

Return the string ID of this searchfield. It is the "id" specified when the string was configured, or failing that the names of all the metafields it searches, joined with a slash "/".

is_set

 $boolean = $sf->is_set

Returns true if this search field has a value to search.

If the "match" parameter is set to "EX" then it always returns true, even if the value is "" because "" is a valid search value in "EX" searches.

serialise

 $string = $sf->serialise

Serialise the parameters of this search field into a string.

unserialise

 $params = EPrints::Search::Field->unserialise( $string )

Convert a serialised searchfield into a hash reference containing the params: id, merge, match, value.

Does not return a EPrints::Search::Field object.

get_include_in_description

 $boolean  = $sf->get_include_in_description

Change the dataset of this searchfield. This is probably a bad idea, except moving between two datasets with the same confid. eg. buffer and inbox.

set_include_in_description

 $sf->set_include_in_description( $boolean )

If set to zero then this search field will not be included in descriptions of the search.

set_dataset

 $sf->set_dataset( $datasetid )

Change the dataset of this searchfield. This is probably a bad idea, except moving between two datasets with the same confid. eg. buffer and inbox.

UNDOCUMENTED METHODS

Warning These methods were found in the source code but didn't have any POD associated with them. This may be because we haven't got around to documenting them yet or it could be because they are internal to the API and not intended for use by other parts of EPrints.

get_conditions_no_split