CWIS Developer Documentation
List of all members
SearchParameterSet Class Reference

Set of parameters used to perform a search. More...

Public Member Functions

Set Construction

Get/set URL parameter prefix.

 AddParameter ($SearchStrings, $Field=NULL)
 Add search parameter to set. More...
 
 RemoveParameter ($SearchStrings, $Field=NULL)
 Remove search parameter from set. More...
 
 Logic ($NewValue=NULL)
 Get/set logic for set. More...
 
 ItemTypes ($ItemTypes=FALSE)
 Get/set allowed item types. More...
 
 AddSet (SearchParameterSet $Set)
 Add subgroup of search parameters to set. More...
 
Data Retrieval
 ParameterCount ()
 Get number of search parameters in set, including those in subgroups. More...
 
 GetSearchStrings ($IncludeSubgroups=FALSE)
 Get search strings in set. More...
 
 GetSearchStringsForField ($Field, $IncludeSubgroups=TRUE)
 Get search strings for specified field. More...
 
 GetKeywordSearchStrings ()
 Get keyword search strings in set. More...
 
 GetSubgroups ()
 Get parameter subgroups. More...
 
 GetFields ()
 Get fields used in search parameters (including subgroups). More...
 
Data Translation
 Data ($NewValue=NULL)
 Get/set search parameter set data, in the form of an opaque string. More...
 
 UrlParameters ($NewValue=NULL)
 Get/set search parameter set, in the form of URL parameters. More...
 
 UrlParameterString ($NewValue=NULL)
 Get/set search parameter set, in the form of an URL parameter string. More...
 
 TextDescription ($IncludeHtml=TRUE, $StartWithBreak=TRUE, $TruncateLongWordsTo=0, $Indent="")
 Get text description of search parameter set. More...
 
Utility Methods
 ReplaceSearchString ($Pattern, $Replacement)
 Modify all search strings with the specified regular expression. More...
 

Setup / Configuration

 __construct ($Data=NULL)
 Class constructor, used to create a new set or reload an existing set from previously-constructed data. More...
 
 __clone ()
 Class clone handler, implemented so that clones will be deep copies rather than PHP5's default shallow copy. More...
 
static SetCanonicalFieldFunction ($Func)
 Register function used to retrieve a canonical value for a field. More...
 
static SetPrintableFieldFunction ($Func)
 Register function used to retrieve a printable value for a field. More...
 

Backward Compatibility

const DEFAULT_LOGIC = "AND"
 
const URL_KEYWORDFREE_RANGE = "A-JL-Z"
 
const URL_KEYWORD_INDICATOR = "K"
 
const URL_LOGIC_INDICATOR = "00"
 
 GetAsLegacyArray ()
 Retrieve search parameters in legacy array format. More...
 
 SetFromLegacyArray ($SearchGroups)
 Set search parameters from legacy array format. More...
 
 SetFromLegacyUrl ($ParameterString)
 Set search parameters from legacy URL string. More...
 
static IsLegacyUrl ($ParameterString)
 Determine if a URL uses legacy format. More...
 
static ConvertLegacyUrl ($ParameterString)
 Convert legacy URL to the current URL format. More...
 
static SetLegacyUrlTranslationFunction ($Func)
 Register function used to converrt values from the format used in a Legacy URL string to the modern version. More...
 
static SetTextDescriptionFilterFunction ($Func)
 Register function used to filter text descriptions of searches prior to display. More...
 
static TranslateLegacySearchValues ($Field, $Values)
 Translate legacy search values to modern equivalents if possible. More...
 

Detailed Description

Set of parameters used to perform a search.

Definition at line 13 of file SearchParameterSet.php.

Constructor & Destructor Documentation

SearchParameterSet::__construct (   $Data = NULL)

Class constructor, used to create a new set or reload an existing set from previously-constructed data.

Parameters
string$DataExisting search parameter set data, previously retrieved with SearchParameterSet::Data(). (OPTIONAL)
See also
SearchParameterSet::Data()

Definition at line 26 of file SearchParameterSet.php.

Member Function Documentation

SearchParameterSet::__clone ( )

Class clone handler, implemented so that clones will be deep copies rather than PHP5's default shallow copy.

Definition at line 40 of file SearchParameterSet.php.

SearchParameterSet::AddParameter (   $SearchStrings,
  $Field = NULL 
)

Add search parameter to set.

If a canonical field function is set, the field to search can be anything accepted by that function, otherwise the $Field argument must be a type usable as an array index (e.g. an integer or a string).

Parameters
mixed$SearchStringsString or array of strings to search for.
mixed$FieldField to search. (OPTIONAL – defaults to keyword search if no field specified)
See also
SearchParameterSet::SetCanonicalFieldFunction()

Definition at line 105 of file SearchParameterSet.php.

Referenced by SetFromLegacyUrl().

Here is the caller graph for this function:

SearchParameterSet::AddSet ( SearchParameterSet  $Set)

Add subgroup of search parameters to set.

Parameters
SearchParameterSet$SetSubgroup to add.

Definition at line 288 of file SearchParameterSet.php.

References ParameterCount().

Referenced by SetFromLegacyArray(), and SetFromLegacyUrl().

Here is the caller graph for this function:

static SearchParameterSet::ConvertLegacyUrl (   $ParameterString)
static

Convert legacy URL to the current URL format.

Parameters
string$ParameterStringLegacy url parameter string
Returns
string converted URL parameter string

Definition at line 881 of file SearchParameterSet.php.

SearchParameterSet::Data (   $NewValue = NULL)

Get/set search parameter set data, in the form of an opaque string.

This method can be used to retrieve an opaque string containing set data, which can then be saved (e.g. to a database) and later used to reload a search parameter set. (Use instead of serialize() to avoid future issues with internal class changes.)

Parameters
string$NewValueNew search parameter set data. (OPTIONAL)
Returns
string Current search parameter set data (opaque value).
Exceptions
InvalidArgumentExceptionIf incoming set data appears invalid.

Definition at line 441 of file SearchParameterSet.php.

References Logic().

SearchParameterSet::GetAsLegacyArray ( )

Retrieve search parameters in legacy array format.

This method is provided for backward compatibility only, and its use is deprecated. Searches conducted using the legacy format may not return identical results because the legacy format does not support nested search groups.

Returns
array Parameters in legacy array format.
See also
SearchEngine::GroupedSearch()

Definition at line 724 of file SearchParameterSet.php.

SearchParameterSet::GetFields ( )

Get fields used in search parameters (including subgroups).

Returns
array list of canonical field identifiers.

Definition at line 406 of file SearchParameterSet.php.

SearchParameterSet::GetKeywordSearchStrings ( )

Get keyword search strings in set.

Returns
array Array of keyword search strings.

Definition at line 388 of file SearchParameterSet.php.

SearchParameterSet::GetSearchStrings (   $IncludeSubgroups = FALSE)

Get search strings in set.

Parameters
bool$IncludeSubgroupsIf TRUE, include search strings from any parameter subgroups. (OPTIONAL, defaults to FALSE)
Returns
array Array of arrays of search strings, with canonical field identifiers for the root index.

Definition at line 326 of file SearchParameterSet.php.

SearchParameterSet::GetSearchStringsForField (   $Field,
  $IncludeSubgroups = TRUE 
)

Get search strings for specified field.

Parameters
mixed$FieldField identifier.
bool$IncludeSubgroupsIf TRUE, search strings for subgroups will be returned as well. (OPTIONAL, defaults to TRUE)
Returns
array Search strings.
See also
SearchParameterSet::SetCanonicalFieldFunction()

Definition at line 359 of file SearchParameterSet.php.

SearchParameterSet::GetSubgroups ( )

Get parameter subgroups.

Returns
array Array of Parameter subgroup (SearchParameterSet) objects.

Definition at line 397 of file SearchParameterSet.php.

static SearchParameterSet::IsLegacyUrl (   $ParameterString)
static

Determine if a URL uses legacy format.

Parameters
string$ParameterStringUrl parameter string
Returns
bool True for legacy URLs, false otherwise

Definition at line 868 of file SearchParameterSet.php.

SearchParameterSet::ItemTypes (   $ItemTypes = FALSE)

Get/set allowed item types.

By default there are no restrictions on item types.

Parameters
mixed$ItemTypesAllowed item type or array of item types. To clear any restrictions, pass in NULL. (OPTIONAL)
Returns
array Allowed item types, or NULL if no restrictions on item type are set.

Definition at line 271 of file SearchParameterSet.php.

SearchParameterSet::Logic (   $NewValue = NULL)

Get/set logic for set.

Parameters
string$NewValueNew setting, either "AND" or "OR" or SearchEngine logic constants. (OPTIONAL)
Returns
string Current logic setting..
Exceptions
InvalidArgumentExceptionIf new setting is invalid.

Definition at line 236 of file SearchParameterSet.php.

References SearchEngine\LOGIC_AND, and SearchEngine\LOGIC_OR.

Referenced by Data(), and TextDescription().

Here is the caller graph for this function:

SearchParameterSet::ParameterCount ( )

Get number of search parameters in set, including those in subgroups.

Returns
int Parameter count.

Definition at line 305 of file SearchParameterSet.php.

Referenced by AddSet().

Here is the caller graph for this function:

SearchParameterSet::RemoveParameter (   $SearchStrings,
  $Field = NULL 
)

Remove search parameter from set.

Parameters
mixed$SearchStringsString or array of strings to match, or NULL to remove all entries that match the specified field.
mixed$FieldField to match. (OPTIONAL - defaults to keyword search match if no field specified)
See also
SearchParameterSet::SetCanonicalFieldFunction()

Definition at line 139 of file SearchParameterSet.php.

SearchParameterSet::ReplaceSearchString (   $Pattern,
  $Replacement 
)

Modify all search strings with the specified regular expression.

Parameters
string$PatternRegular expression pattern.
string$ReplacementReplacement string.

Definition at line 688 of file SearchParameterSet.php.

static SearchParameterSet::SetCanonicalFieldFunction (   $Func)
static

Register function used to retrieve a canonical value for a field.

This This function should accept a single mixed parameter and return a canonical integer value for the field.

Parameters
callable$FuncFunction to call.
Exceptions
InvalidArgumentExceptionIf function supplied that is not callable.

Definition at line 55 of file SearchParameterSet.php.

SearchParameterSet::SetFromLegacyArray (   $SearchGroups)

Set search parameters from legacy array format.

Parameters
array$SearchGroupsLegacy format search groups.

Definition at line 778 of file SearchParameterSet.php.

References AddSet().

SearchParameterSet::SetFromLegacyUrl (   $ParameterString)

Set search parameters from legacy URL string.

Parameters
string$ParameterStringLegacy url string.

Definition at line 812 of file SearchParameterSet.php.

References AddParameter(), and AddSet().

static SearchParameterSet::SetLegacyUrlTranslationFunction (   $Func)
static

Register function used to converrt values from the format used in a Legacy URL string to the modern version.

Parameters
callable$FuncFunction to convert legacy URL parameter values into modern versions

Definition at line 895 of file SearchParameterSet.php.

static SearchParameterSet::SetPrintableFieldFunction (   $Func)
static

Register function used to retrieve a printable value for a field.

This function should accept a single mixed parameter and return a human-readable name for the field.

Parameters
callable$FuncFunction to call.
Exceptions
InvalidArgumentExceptionIf function supplied that is not callable.

Definition at line 74 of file SearchParameterSet.php.

static SearchParameterSet::SetTextDescriptionFilterFunction (   $Func)
static

Register function used to filter text descriptions of searches prior to display.

Parameters
callable$FuncFunction to beautify text descriptions. Must take a string as input and return a possibly modified string.

Definition at line 914 of file SearchParameterSet.php.

SearchParameterSet::TextDescription (   $IncludeHtml = TRUE,
  $StartWithBreak = TRUE,
  $TruncateLongWordsTo = 0,
  $Indent = "" 
)

Get text description of search parameter set.

Parameters
bool$IncludeHtmlWhether to include HTML tags for formatting. (OPTIONAL, defaults to TRUE)
bool$StartWithBreakWhether to start string with BR tag. (OPTIONAL, defaults to TRUE)
int$TruncateLongWordsToNumber of characters to truncate long words to (use 0 for no truncation). (OPTIONAL, defaults to 0)
string$IndentFor internal (recursive) use only.
Returns
string Text description of search parameters.

Definition at line 529 of file SearchParameterSet.php.

References Logic(), and StdLib\NeatlyTruncateString().

static SearchParameterSet::TranslateLegacySearchValues (   $Field,
  $Values 
)
static

Translate legacy search values to modern equivalents if possible.

Parameters
mixed$FieldSupplied field
mixed$ValuesSupplied values
Returns
array of translated values

Definition at line 932 of file SearchParameterSet.php.

SearchParameterSet::UrlParameters (   $NewValue = NULL)

Get/set search parameter set, in the form of URL parameters.

Parameters
string$NewValueNew parameter set in the form of a URL parameter string or URL parameter array. (OPTIONAL)
Returns
array URL parameter values, with parameter names for the index..

Definition at line 475 of file SearchParameterSet.php.

Referenced by UrlParameterString().

Here is the caller graph for this function:

SearchParameterSet::UrlParameterString (   $NewValue = NULL)

Get/set search parameter set, in the form of an URL parameter string.

Parameters
string$NewValueNew parameter set in the form of a URL parameter string or URL parameter array. (OPTIONAL)
Returns
string URL parameter string.

Definition at line 500 of file SearchParameterSet.php.

References UrlParameters().

Member Data Documentation

const SearchParameterSet::DEFAULT_LOGIC = "AND"

Definition at line 957 of file SearchParameterSet.php.

const SearchParameterSet::URL_KEYWORD_INDICATOR = "K"

Definition at line 959 of file SearchParameterSet.php.

const SearchParameterSet::URL_KEYWORDFREE_RANGE = "A-JL-Z"

Definition at line 958 of file SearchParameterSet.php.

const SearchParameterSet::URL_LOGIC_INDICATOR = "00"

Definition at line 960 of file SearchParameterSet.php.


The documentation for this class was generated from the following file: