CWIS Developer Documentation
|
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... | |
Set of parameters used to perform a search.
Definition at line 13 of file SearchParameterSet.php.
SearchParameterSet::__construct | ( | $Data = NULL | ) |
Class constructor, used to create a new set or reload an existing set from previously-constructed data.
string | $Data | Existing search parameter set data, previously retrieved with SearchParameterSet::Data(). (OPTIONAL) |
Definition at line 26 of file SearchParameterSet.php.
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).
mixed | $SearchStrings | String or array of strings to search for. |
mixed | $Field | Field to search. (OPTIONAL – defaults to keyword search if no field specified) |
Definition at line 105 of file SearchParameterSet.php.
Referenced by SetFromLegacyUrl().
SearchParameterSet::AddSet | ( | SearchParameterSet | $Set | ) |
Add subgroup of search parameters to set.
SearchParameterSet | $Set | Subgroup to add. |
Definition at line 333 of file SearchParameterSet.php.
References ParameterCount().
Referenced by SetFromLegacyArray(), and SetFromLegacyUrl().
|
static |
Convert legacy URL to the current URL format.
string | $ParameterString | Legacy 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.)
string | $NewValue | New search parameter set data. (OPTIONAL) |
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.
Definition at line 769 of file SearchParameterSet.php.
SearchParameterSet::GetFields | ( | ) |
Get fields used in search parameters (including subgroups).
Definition at line 451 of file SearchParameterSet.php.
SearchParameterSet::GetKeywordSearchStrings | ( | ) |
Get keyword search strings in set.
Definition at line 433 of file SearchParameterSet.php.
SearchParameterSet::GetSearchStrings | ( | $IncludeSubgroups = FALSE | ) |
Get search strings in set.
bool | $IncludeSubgroups | If TRUE, include search strings from any parameter subgroups. (OPTIONAL, defaults to FALSE) |
Definition at line 371 of file SearchParameterSet.php.
SearchParameterSet::GetSearchStringsForField | ( | $Field, | |
$IncludeSubgroups = TRUE |
|||
) |
Get search strings for specified field.
mixed | $Field | Field identifier. |
bool | $IncludeSubgroups | If TRUE, search strings for subgroups will be returned as well. (OPTIONAL, defaults to TRUE) |
Definition at line 404 of file SearchParameterSet.php.
SearchParameterSet::GetSubgroups | ( | ) |
Get parameter subgroups.
Definition at line 442 of file SearchParameterSet.php.
|
static |
Determine if a URL uses legacy format.
string | $ParameterString | Url parameter string |
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.
mixed | $ItemTypes | Allowed item type or array of item types. To clear any restrictions, pass in FALSE. (OPTIONAL) |
Definition at line 271 of file SearchParameterSet.php.
SearchParameterSet::Logic | ( | $NewValue = NULL | ) |
Get/set logic for set.
string | $NewValue | New setting, either "AND" or "OR" or SearchEngine logic constants. (OPTIONAL) |
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().
SearchParameterSet::ParameterCount | ( | ) |
Get number of search parameters in set, including those in subgroups.
Definition at line 350 of file SearchParameterSet.php.
Referenced by AddSet().
SearchParameterSet::RemoveParameter | ( | $SearchStrings, | |
$Field = NULL |
|||
) |
Remove search parameter from set.
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) |
Definition at line 139 of file SearchParameterSet.php.
SearchParameterSet::ReplaceSearchString | ( | $Pattern, | |
$Replacement | |||
) |
Modify all search strings with the specified regular expression.
string | $Pattern | Regular expression pattern. |
string | $Replacement | Replacement string. |
Definition at line 733 of file SearchParameterSet.php.
|
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.
callable | $Func | Function to call. |
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.
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.
string | $ParameterString | Legacy url string. |
Definition at line 857 of file SearchParameterSet.php.
References AddParameter(), and AddSet().
|
static |
Register function used to converrt values from the format used in a Legacy URL string to the modern version.
callable | $Func | Function to convert legacy URL parameter values into modern versions |
Definition at line 940 of file SearchParameterSet.php.
|
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.
callable | $Func | Function to call. |
InvalidArgumentException | If function supplied that is not callable. |
Definition at line 74 of file SearchParameterSet.php.
|
static |
Register function used to filter text descriptions of searches prior to display.
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.
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) |
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.
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) |
Definition at line 320 of file SearchParameterSet.php.
SearchParameterSet::TextDescription | ( | $IncludeHtml = TRUE , |
|
$StartWithBreak = TRUE , |
|||
$TruncateLongWordsTo = 0 , |
|||
$Indent = "" |
|||
) |
Get text description of search parameter set.
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. |
Definition at line 574 of file SearchParameterSet.php.
References Logic(), and StdLib\NeatlyTruncateString().
|
static |
Translate legacy search values to modern equivalents if possible.
mixed | $Field | Supplied field |
mixed | $Values | Supplied values |
Definition at line 977 of file SearchParameterSet.php.
SearchParameterSet::UrlParameters | ( | $NewValue = NULL | ) |
Get/set search parameter set, in the form of URL parameters.
string | $NewValue | New parameter set in the form of a URL parameter string or URL parameter array. (OPTIONAL) |
Definition at line 520 of file SearchParameterSet.php.
Referenced by UrlParameterString().
SearchParameterSet::UrlParameterString | ( | $NewValue = NULL | ) |
Get/set search parameter set, in the form of an URL parameter string.
string | $NewValue | New parameter set in the form of a URL parameter string or URL parameter array. (OPTIONAL) |
Definition at line 545 of file SearchParameterSet.php.
References UrlParameters().
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.