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

## 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 | 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 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 | $ParameterString | Legacy url parameter string

Returns
  string converted URL parameter string

Definition at line 825 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 444 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 668 of file SearchParameterSet.php.

SearchParameterSet::GetFields | ( |  | ) |

Get fields used in search parameters (including subgroups).

Returns
  array list of canonical field identifiers.

Definition at line 409 of file SearchParameterSet.php.

SearchParameterSet::GetKeywordSearchStrings | ( |  | ) |

Get keyword search strings in set.

Returns
  array Array of keyword search strings.

Definition at line 391 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 329 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 362 of file SearchParameterSet.php.

SearchParameterSet::GetSubgroups | ( |  | ) |

Get parameter subgroups.

Returns
  array Array of Parameter subgroup (SearchParameterSet) objects.

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

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

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 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 | $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 308 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 | $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.

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 722 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 756 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 839 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.

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 532 of file SearchParameterSet.php.

References Logic().

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 857 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 478 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 503 of file SearchParameterSet.php.

References UrlParameters().

## Member Data Documentation

const SearchParameterSet::DEFAULT_LOGIC = "AND"

Definition at line 881 of file SearchParameterSet.php.

const SearchParameterSet::URL_KEYWORD_INDICATOR = "K"

Definition at line 883 of file SearchParameterSet.php.

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

Definition at line 882 of file SearchParameterSet.php.

const SearchParameterSet::URL_LOGIC_INDICATOR = "00"

Definition at line 884 of file SearchParameterSet.php.

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

- lib/ScoutLib/SearchParameterSet.php