Difference between revisions of "API:EPrints/Search/Field"

From EPrints Documentation
Jump to: navigation, search
(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. -...)
 
(Removing all content from page)
Line 1: Line 1:
<!-- 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.
 
-->{{Pod2Wiki}}{{API:Source|file=EPrints/Search/Field.pm|package_name=EPrints::Search::Field}}[[Category:API|Field]]<!-- End of Pod2Wiki -->
 
<!-- Pod2Wiki=head_name -->=NAME=
 
'''EPrints::Search::Field''' - One field in a search expression.
 
  
<!-- End of Pod2Wiki -->
 
<!-- Pod2Wiki=head_description -->=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:
 
 
<!-- End of Pod2Wiki -->
 
<!-- Pod2Wiki=item_match_in -->==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.
 
 
<!-- End of Pod2Wiki -->
 
<!-- Pod2Wiki=item_eq -->==eq==
 
 
  match=EQ (equal)
 
 
Treat the value as a single string. Match only fields which have this value.
 
 
<!-- End of Pod2Wiki -->
 
<!-- Pod2Wiki=item_ex -->==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.
 
 
<!-- End of Pod2Wiki -->
 
<!-- Pod2Wiki=item_match_no -->==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.
 
 
<!-- End of Pod2Wiki -->
 
<!-- Pod2Wiki=item_merge_any -->==merge_any==
 
 
  merge=ANY
 
 
Match an item if any of the words in the value match.
 
 
<!-- End of Pod2Wiki -->
 
<!-- Pod2Wiki=item_merge_all -->==merge_all==
 
 
  merge=ALL
 
 
Match an item only if all of the words in the value match.
 
 
<!-- End of Pod2Wiki -->
 
<!-- Pod2Wiki=head_methods -->==METHODS==
 
<!-- End of Pod2Wiki -->
 
<!-- Pod2Wiki=item_new -->===new===
 
 
  $thing = EPrints::Search::Field-&gt;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.
 
 
<!-- End of Pod2Wiki -->
 
<!-- Pod2Wiki=item_clear -->===clear===
 
 
  $sf-&gt;clear
 
 
Set this searchfield's "match" to "NO" so that it always returns nothing when searched.
 
 
<!-- End of Pod2Wiki -->
 
<!-- Pod2Wiki=item_from_form -->===from_form===
 
 
  $problem = $sf-&gt;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.
 
 
<!-- End of Pod2Wiki -->
 
<!-- Pod2Wiki=item_get_conditions -->===get_conditions===
 
 
  $search_condition = $sf-&gt;get_conditions
 
 
Convert this Search::Field into an EPrints::Search::Condition object which can actually perform the search.
 
 
<!-- End of Pod2Wiki -->
 
<!-- Pod2Wiki=item_get_value -->===get_value===
 
 
  $value = $sf-&gt;get_value
 
 
Return the current value parameter of this search field.
 
 
<!-- End of Pod2Wiki -->
 
<!-- Pod2Wiki=item_get_match -->===get_match===
 
 
  $match = $sf-&gt;get_match
 
 
Return the current match parameter of this search field.
 
 
<!-- End of Pod2Wiki -->
 
<!-- Pod2Wiki=item_get_merge -->===get_merge===
 
 
  $merge = $sf-&gt;get_merge
 
 
Return the current merge parameter of this search field.
 
 
<!-- End of Pod2Wiki -->
 
<!-- Pod2Wiki=item_get_field -->===get_field===
 
 
  $field = $sf-&gt;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.
 
 
<!-- End of Pod2Wiki -->
 
<!-- Pod2Wiki=item_get_fields -->===get_fields===
 
 
  $fields = $sf-&gt;get_fields
 
 
Return a reference to an array of EPrints::MetaField objects which  this search field is going to search.
 
 
<!-- End of Pod2Wiki -->
 
<!-- Pod2Wiki=item_render -->===render===
 
 
  $xhtml = $sf-&gt;render
 
 
Returns an XHTML tree of this search field which contains all the  input boxes required to search this field.
 
 
<!-- End of Pod2Wiki -->
 
<!-- Pod2Wiki=item_get_form_prefix -->===get_form_prefix===
 
 
  $xhtml = $sf-&gt;get_form_prefix
 
 
Return the string use to prefix form field names so values don't get mixed with other search fields.
 
 
<!-- End of Pod2Wiki -->
 
<!-- Pod2Wiki=item_render_description -->===render_description===
 
 
  $xhtml = $sf-&gt;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.
 
 
<!-- End of Pod2Wiki -->
 
<!-- Pod2Wiki=item_render_name -->===render_name===
 
 
  $xhtml_name = $sf-&gt;render_name
 
 
Return XHTML object of this searchfields name.
 
 
<!-- End of Pod2Wiki -->
 
<!-- Pod2Wiki=item_render_help -->===render_help===
 
 
  $xhtml_help = $sf-&gt;render_help
 
 
Return an XHTML DOM object containing the "help" for this search field.
 
 
<!-- End of Pod2Wiki -->
 
<!-- Pod2Wiki=item_is_type -->===is_type===
 
 
  $boolean = $sf-&gt;is_type( @types )
 
 
Return true if the first metafield in the fieldlist is of any of the types in @types.
 
 
<!-- End of Pod2Wiki -->
 
<!-- Pod2Wiki=item_get_id -->===get_id===
 
 
  $id = $sf-&gt;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 "/".
 
 
<!-- End of Pod2Wiki -->
 
<!-- Pod2Wiki=item_is_set -->===is_set===
 
 
  $boolean = $sf-&gt;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.
 
 
<!-- End of Pod2Wiki -->
 
<!-- Pod2Wiki=item_serialise -->===serialise===
 
 
  $string = $sf-&gt;serialise
 
 
Serialise the parameters of this search field into a string.
 
 
<!-- End of Pod2Wiki -->
 
<!-- Pod2Wiki=item_unserialise -->===unserialise===
 
 
  $params = EPrints::Search::Field-&gt;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.
 
 
<!-- End of Pod2Wiki -->
 
<!-- Pod2Wiki=item_get_include_in_description -->===get_include_in_description===
 
 
  $boolean  = $sf-&gt;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.
 
 
<!-- End of Pod2Wiki -->
 
<!-- Pod2Wiki=item_set_include_in_description -->===set_include_in_description===
 
 
  $sf-&gt;set_include_in_description( $boolean )
 
 
If set to zero then this search field will not be included in  descriptions of the search.
 
 
<!-- End of Pod2Wiki -->
 
<!-- Pod2Wiki=item_set_dataset -->===set_dataset===
 
 
  $sf-&gt;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.
 
 
<!-- End of Pod2Wiki -->
 
<!-- Pod2Wiki=head_undocumented_methods -->=UNDOCUMENTED METHODS=
 
{{API:Undocumented Methods}}<!-- End of Pod2Wiki -->
 
<!-- Pod2Wiki=item_get_conditions_no_split -->==get_conditions_no_split==
 
 
<!-- End of Pod2Wiki -->
 
<!-- Pod2Wiki=_postamble_ --><!-- End of Pod2Wiki -->
 

Revision as of 15:41, 12 August 2009