CWIS Developer Documentation

- Home
- Main Page
- Namespaces
- Classes
- Files

- Class List
- Class Index
- Class Hierarchy
- Class Members

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=NULL)
| Get/set allowed item types. More...
| SortBy ($NewValue=NULL)
| Get/set field to sort results by. More...
| SortDescending ($NewValue=NULL)
| Get/set whether to sort results will be sorted in descending (as opposed to ascending) order. 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 | $Data | Existing 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 | $SearchStrings | String or array of strings to search for.
  mixed | $Field | Field 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 | $Set | Subgroup to add.

Definition at line 333 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 | $ParameterString | Legacy url parameter string

Returns
  string converted URL parameter string

Definition at line 926 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 | $NewValue | New search parameter set data. (OPTIONAL)

Returns
  string Current search parameter set data (opaque value).

Exceptions

  InvalidArgumentException | If incoming set data appears invalid.

Definition at line 486 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 769 of file SearchParameterSet.php.

SearchParameterSet::GetFields | ( |  | ) |

Get fields used in search parameters (including subgroups).

Returns
  array list of canonical field identifiers.

Definition at line 451 of file SearchParameterSet.php.

SearchParameterSet::GetKeywordSearchStrings | ( |  | ) |

Get keyword search strings in set.

Returns
  array Array of keyword search strings.

Definition at line 433 of file SearchParameterSet.php.

SearchParameterSet::GetSearchStrings | ( |  | $IncludeSubgroups = `FALSE` | ) |

Get search strings in set.

Parameters

  bool | $IncludeSubgroups | If 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 371 of file SearchParameterSet.php.

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

Get search strings for specified field.

Parameters

  mixed | $Field | Field identifier.
  bool | $IncludeSubgroups | If 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 404 of file SearchParameterSet.php.

SearchParameterSet::GetSubgroups | ( |  | ) |

Get parameter subgroups.

Returns
  array Array of Parameter subgroup (SearchParameterSet) objects.

Definition at line 442 of file SearchParameterSet.php.

static SearchParameterSet::IsLegacyUrl | ( |  | $ParameterString | ) |
| static

Determine if a URL uses legacy format.

Parameters

  string | $ParameterString | Url parameter string

Returns
  bool True for legacy URLs, false otherwise

Definition at line 913 of file SearchParameterSet.php.

SearchParameterSet::ItemTypes | ( |  | $ItemTypes = `NULL` | ) |

Get/set allowed item types.

By default there are no restrictions on item types.

Parameters

  mixed | $ItemTypes | Allowed item type or array of item types. To clear any restrictions, pass in FALSE. (OPTIONAL)

Returns
  array|null Allowed item types, or FALSE 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 | $NewValue | New setting, either "AND" or "OR" or SearchEngine logic constants. (OPTIONAL)

Returns
  string Current logic setting..

Exceptions

  InvalidArgumentException | If 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 350 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

  string | array | null | $SearchStrings | String or array of strings to match, or NULL to remove all entries that match the specified field.
  mixed | $Field | Field 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 | $Pattern | Regular expression pattern.
  string | $Replacement | Replacement string.

Definition at line 733 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 | $Func | Function to call.

Exceptions

  InvalidArgumentException | If 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 | $SearchGroups | Legacy format search groups.

Definition at line 823 of file SearchParameterSet.php.

References AddSet().

SearchParameterSet::SetFromLegacyUrl | ( |  | $ParameterString | ) |

Set search parameters from legacy URL string.

Parameters

  string | $ParameterString | Legacy url string.

Definition at line 857 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 | $Func | Function to convert legacy URL parameter values into modern versions

Definition at line 940 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 | $Func | Function to call.

Exceptions

  InvalidArgumentException | If 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 | $Func | Function to beautify text descriptions. Must take a string as input and return a possibly modified string.

Definition at line 959 of file SearchParameterSet.php.

SearchParameterSet::SortBy | ( |  | $NewValue = `NULL` | ) |

Get/set field to sort results by.

By default results are sorted by relevance score. Subgroup values for this setting are ignored.

Parameters

  mixed | $NewValue | Field to sort by or array of fields to sort by indexed by item type, or FALSE to sort results by relevance. (OPTIONAL)

Returns
  mixed Current field to sort results by or array of fields to sort by indexed by item type, or FALSE if results will be sorted by relevance score.

Definition at line 300 of file SearchParameterSet.php.

SearchParameterSet::SortDescending | ( |  | $NewValue = `NULL` | ) |

Get/set whether to sort results will be sorted in descending (as opposed to ascending) order.

By default results are sorted in descending order. Subgroup values for this setting are ignored.

Parameters

  bool | array | $NewValue | Boolean value or array of boolean values indexed by item type. If TRUE, results will be sorted in descending order, otherwise results will be sending in ascending order. (OPTIONAL)

Returns
  boolean|array Boolean value or array of boolean values indexed by item type. If TRUE, results will be sorted in descending order otherwise if FALSE, results will be sorted in ascending order.

Definition at line 320 of file SearchParameterSet.php.

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

Get text description of search parameter set.

Parameters

  bool | $IncludeHtml | Whether to include HTML tags for formatting. (OPTIONAL, defaults to TRUE)
  bool | $StartWithBreak | Whether to start string with BR tag. (OPTIONAL, defaults to TRUE)
  int | $TruncateLongWordsTo | Number of characters to truncate long words to (use 0 for no truncation). (OPTIONAL, defaults to 0)
  string | $Indent | For internal (recursive) use only.

Returns
  string Text description of search parameters.

Definition at line 574 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 | $Field | Supplied field
  mixed | $Values | Supplied values

Returns
  array of translated values

Definition at line 977 of file SearchParameterSet.php.

SearchParameterSet::UrlParameters | ( |  | $NewValue = `NULL` | ) |

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

Parameters

  string | $NewValue | New 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 520 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 | $NewValue | New parameter set in the form of a URL parameter string or URL parameter array. (OPTIONAL)

Returns
  string URL parameter string.

Definition at line 545 of file SearchParameterSet.php.

References UrlParameters().

## Member Data Documentation

const SearchParameterSet::DEFAULT_LOGIC = "AND"

Definition at line 1004 of file SearchParameterSet.php.

const SearchParameterSet::URL_KEYWORD_INDICATOR = "K"

Definition at line 1006 of file SearchParameterSet.php.

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

Definition at line 1005 of file SearchParameterSet.php.

const SearchParameterSet::URL_LOGIC_INDICATOR = "00"

Definition at line 1007 of file SearchParameterSet.php.

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

- lib/ScoutLib/SearchParameterSet.php