CSItemSearchFilter
in package
Tags
Table of Contents
- CONNECTOR_AND = ' AND '
- CONNECTOR_OR = ' OR '
- SIMPLE_SEARCH = 'simplesearch'
- VALUE_ATTRIBUTES = 'attrs'
- VALUE_COMPARATOR = 'comp'
- VALUE_VALUES = 'values'
- $SEARCH_COLLATION : array<string|int, mixed>
- array with utf8 umlauts as key, should be replaced by the value
- __clone() : void
- Clones the item search filter recursively
- __construct() : mixed
- instanciate a search filter
- addFilter() : CSItemSearchFilter
- add a search filter as either specified by the search operation or by attaching another CSItemSearchFilter
- andFilter() : CSItemSearchFilter
- Returns an empty AND SubFilter
- createFromArray() : CSItemSearchFilter
- Creates a CSItemSearchFilter object based on the array representation. For the structure documentation please refer to CSItemSearchFilter::createFromJson
- createFromJson() : CSItemSearchFilter
- Creates a CSItemSearchFilter object based on the json representation. The structure has to follow these rules:
- getIsNegated() : bool
- Checks whether this filter is negated for a search
- getOriginalSubFilter() : array<string|int, mixed>
- Returns the original filters with the original ("unformatted") filter details.
- getOriginalSubFilterByIndex() : CSItemSearchFilter|array<string|int, mixed>|null
- Returns an original ("unformatted") sub filter for a given filter index.
- getPageNumber() : mixed
- Get page number to fetch the values as per page number
- getPageSize() : int
- Get page size to fetch that much data as results
- getSearchFilterForConfiguration() : CSItemSearchFilter
- Converts the old format of CSType::getSearch as array to the new format using CSItemSearchFilters
- getSubFilter() : array<string|int, mixed>
- Returns the formatted filters.
- getSubFilterByIndex() : CSItemSearchFilter|array<string|int, mixed>|null
- Returns a sub filter for a given filter index.
- getTrackTotalHits() : bool
- Return whether the search should track the total hits, which costs performance or use the default setting of ElasticSearch which are 10.000 hits.
- isAndFilter() : mixed
- isEmpty() : mixed
- isPaginationEnabled() : bool
- Returns boolean value whether results are requested as per page or not.
- matchesSearchCriterias() : mixes
- This method can be used by the CSTypes to determine, whether a database query condition defined for a comparator matches an explicit value or a database type
- orFilter() : CSItemSearchFilter
- Returns an empty OR SubFilter
- paginateResults() : array<string|int, mixed>
- This method paginate the result ids as per set parameters
- registerDelegate() : bool
- Registers a given object as a delegate.
- removeFilterByIndex() : bool
- Removes an existing filter by index.
- resolveSortingFields() : array<string|int, mixed>
- Resolve a list of sorting fields configuration to the corresponding syntax to build a MySQL ORDER BY clause.
- searchContent() : CSItemSearchResult|array<string|int, int>
- Searches all items matching a given search criteria
- searchInLabel() : array<string|int, mixed>
- Enter description here .
- setIsNegated() : mixed
- Sets this filter to be negated for a search like " NOT ( ... ) "
- setPageNumber() : mixed
- Sets page number to fetch the values as per page number
- setPageSize() : mixed
- Sets page size to fetch that much data as results
- setTrackTotalHits() : void
- This method is used to define whether the search should track the total hits, which costs performance or use the default setting of ElasticSearch which are 10.000 hits.
- toArray() : array<string|int, mixed>
- Creates an array representation of the current item filter in the following format:
- toCSql() : mixed
- unregisterDelegate() : bool
- Removes the given object as a delegate if it was set as a delegate before.
Constants
CONNECTOR_AND
public
mixed
CONNECTOR_AND
= ' AND '
Tags
CONNECTOR_OR
public
mixed
CONNECTOR_OR
= ' OR '
Tags
SIMPLE_SEARCH
public
mixed
SIMPLE_SEARCH
= 'simplesearch'
Tags
VALUE_ATTRIBUTES
public
mixed
VALUE_ATTRIBUTES
= 'attrs'
Tags
VALUE_COMPARATOR
public
mixed
VALUE_COMPARATOR
= 'comp'
Tags
VALUE_VALUES
public
mixed
VALUE_VALUES
= 'values'
Tags
Properties
$SEARCH_COLLATION
array with utf8 umlauts as key, should be replaced by the value
public
static array<string|int, mixed>
$SEARCH_COLLATION
Tags
Methods
__clone()
Clones the item search filter recursively
public
__clone() : void
Sets a flag "_bCloned" to the cloned filter object to avoid a second excessive clone run if the filter exists in the instance variable "filters" and "_aOriginalFilters"
Tags
Return values
void —__construct()
instanciate a search filter
public
__construct([string $type = CS_SEARCH_WITH_AND ]) : mixed
Parameters
- $type : string = CS_SEARCH_WITH_AND
-
type of the search filter based on constants CS_SEARCH_WITH_OR for "OR" filters and CS_SEARCH_WITH_AND for "AND" filters
Tags
Return values
mixed —addFilter()
add a search filter as either specified by the search operation or by attaching another CSItemSearchFilter
public
addFilter([mixed $values = '' ][, string $compOp = '' ][, mixed $attrs = array() ]) : CSItemSearchFilter
Parameters
- $values : mixed = ''
-
either a CSItemSearchFilter or a search value as string. If $values is a CSItemSearchFilter object, the other arguments are ignored.
- $compOp : string = ''
-
comparison operator like has, hasnot, regex, notregex, like, notlike, beginswith, endswith, = , <, ... or boolean for a boolean mode search like google supporting the characters: - + " *
- $attrs : mixed = array()
-
array of fields that shall be used on the following search, or '*' for searching all fields of the given table. If CSItemSearch::SIMPLE_SEARCH is used all simple searchable attributes are used.
Tags
Return values
CSItemSearchFilter —current filter for chaining
andFilter()
Returns an empty AND SubFilter
public
static andFilter() : CSItemSearchFilter
Tags
Return values
CSItemSearchFilter —which concats with AND
createFromArray()
Creates a CSItemSearchFilter object based on the array representation. For the structure documentation please refer to CSItemSearchFilter::createFromJson
public
static createFromArray(array<string|int, mixed> $aFilter) : CSItemSearchFilter
Parameters
- $aFilter : array<string|int, mixed>
Tags
Return values
CSItemSearchFilter —The CSItemSearchFilter object based on the array representation
createFromJson()
Creates a CSItemSearchFilter object based on the json representation. The structure has to follow these rules:
public
static createFromJson(string $sFilter) : CSItemSearchFilter
array( 'connector' => ' OR '/' AND ', filters: array( EITHER (new sub filter): array( 'connector' => ' OR '/' AND ', filters: ... ) OR (condition): 'attributes' => array(123, 'Label'...), 'comparator' => '=', 'values' => array('value1', 'value2'...) ) ... );
Parameters
- $sFilter : string
Tags
Return values
CSItemSearchFilter —The CSItemSearchFilter object based on the json string
getIsNegated()
Checks whether this filter is negated for a search
public
getIsNegated() : bool
Tags
Return values
bool —whether this filter is negated
getOriginalSubFilter()
Returns the original filters with the original ("unformatted") filter details.
public
getOriginalSubFilter() : array<string|int, mixed>
Tags
Return values
array<string|int, mixed> —with the original filters with the original ("unformatted") filter details.
getOriginalSubFilterByIndex()
Returns an original ("unformatted") sub filter for a given filter index.
public
getOriginalSubFilterByIndex(int $iIndex) : CSItemSearchFilter|array<string|int, mixed>|null
Parameters
- $iIndex : int
-
The filter index for the required original filter.
Tags
Return values
CSItemSearchFilter|array<string|int, mixed>|null —The original ("unformatted") sub filter for the given filter index.
getPageNumber()
Get page number to fetch the values as per page number
public
getPageNumber() : mixed
Tags
Return values
mixed —page number for which results requested in filter object
getPageSize()
Get page size to fetch that much data as results
public
getPageSize() : int
Tags
Return values
int —size of results for a page
getSearchFilterForConfiguration()
Converts the old format of CSType::getSearch as array to the new format using CSItemSearchFilters
public
static getSearchFilterForConfiguration(Itemconfiguration $oConfiguration, array<string|int, mixed> $aAttributeValues, string $sComparator) : CSItemSearchFilter
Parameters
- $oConfiguration : Itemconfiguration
-
the search filter as array representation
- $aAttributeValues : array<string|int, mixed>
-
the attribute name
- $sComparator : string
-
the comparator for the attribute
Tags
Return values
CSItemSearchFilter —the transformed filter
getSubFilter()
Returns the formatted filters.
public
getSubFilter() : array<string|int, mixed>
Tags
Return values
array<string|int, mixed> —with the formatted filters.
getSubFilterByIndex()
Returns a sub filter for a given filter index.
public
getSubFilterByIndex(int $iIndex) : CSItemSearchFilter|array<string|int, mixed>|null
Parameters
- $iIndex : int
-
The filter index for the required filter.
Tags
Return values
CSItemSearchFilter|array<string|int, mixed>|null —The sub filter for the given filter index.
getTrackTotalHits()
Return whether the search should track the total hits, which costs performance or use the default setting of ElasticSearch which are 10.000 hits.
public
getTrackTotalHits() : bool
Tags
Return values
bool —isAndFilter()
public
isAndFilter() : mixed
Tags
Return values
mixed —isEmpty()
public
isEmpty() : mixed
Tags
Return values
mixed —isPaginationEnabled()
Returns boolean value whether results are requested as per page or not.
public
isPaginationEnabled() : bool
If $_iPageNumber value is 0 then pagination is disabled, else enabled with provided page size
Tags
Return values
bool —matchesSearchCriterias()
This method can be used by the CSTypes to determine, whether a database query condition defined for a comparator matches an explicit value or a database type
public
static matchesSearchCriterias(mixed $valueConditions, string $comparator[, mixed $explicitValues = '' ][, int $databaseType = SQL_TYPE_TEXT ]) : mixes
Parameters
- $valueConditions : mixed
- $comparator : string
-
an sql comparator created from this filter
- $explicitValues : mixed = ''
-
a value or an array of values which should be checked, whether it matches the criteria
- $databaseType : int = SQL_TYPE_TEXT
-
can be SQL_TYPE_NUMERIC, SQL_TYPE_DATE, SQL_TYPE_BINARY, SQL_TYPE_TEXT
Tags
Return values
mixes —Returns null , if arguments are not (yet) supported. If $explicitValues are set the result is an array of all matching values. Otherwise it returns true if matches or false if the match failed.
orFilter()
Returns an empty OR SubFilter
public
static orFilter() : CSItemSearchFilter
Tags
Return values
CSItemSearchFilter —which concats with OR
paginateResults()
This method paginate the result ids as per set parameters
public
paginateResults(array<string|int, mixed> $aIds) : array<string|int, mixed>
Parameters
- $aIds : array<string|int, mixed>
-
array of ids to paginate
Tags
Return values
array<string|int, mixed> —registerDelegate()
Registers a given object as a delegate.
public
static registerDelegate(mixed $oDelegate) : bool
A delegate can implement following methods : +----------------------------+------------------------------------+-----------------------------------------------+ | Purpose | Delegate Method | Delegate Method Params | +----------------------------|------------------------------------|-----------------------------------------------+ | Triggers before starting | searchFilterWillExecuteWithParams | $oItemSearchFilter, $oItem, $aRootIDs, $bDepth| | the search | | $bCheckInheritance, $aSortFields, $iLimit, | | | | $iCacheTime | +----------------------------|------------------------------------|-----------------------------------------------+ | Triggers after search | searchFilterDidExecuteWithParams | $oItemSearchFilter, $aResultItemIds, $oItem, | | has been executed | | $aRootIDs, $bDepth, $bCheckInheritance, | | | | $aSortFields, $iLimit, $iCacheTime, | +----------------------------+------------------------------------+-----------------------------------------------+
Note: Only CSItemSearchFilter object can be updated to change the course of execution of search.
Parameters
- $oDelegate : mixed
Tags
Return values
bool —TRUE in case the object got registered as delegate FALSE, otherwise
removeFilterByIndex()
Removes an existing filter by index.
public
removeFilterByIndex(int $iFilterIndex) : bool
The filter array will be reindexed after removing the filter.
Parameters
- $iFilterIndex : int
-
The index of the filter which should be removed.
Tags
Return values
bool —whether the filter has been removed or not.
resolveSortingFields()
Resolve a list of sorting fields configuration to the corresponding syntax to build a MySQL ORDER BY clause.
public
static resolveSortingFields(array<string|int, mixed> $sortFields) : array<string|int, mixed>
Parameters
- $sortFields : array<string|int, mixed>
-
The sorting configuration, as an array with the field name as key and a CS_SORT constant as value (e.g. CS_SORT_STRING_ASC or CS_SORT_NUMERICAL_DESC).
Tags
Return values
array<string|int, mixed> —Sorting fields with MySQL syntax for an ORDER BY clause.
searchContent()
Searches all items matching a given search criteria
public
searchContent(Item $item[, mixed $rootIDs = null ][, mixed $depth = true ][, bool $checkInheritance = true ][, array<string|int, mixed> $sortFields = array() ][, string $limit = '' ], int $cacheTime[, bool $bExtendedResult = false ]) : CSItemSearchResult|array<string|int, int>
Parameters
- $item : Item
-
the item object which should be searched
- $rootIDs : mixed = null
-
either an integer or an array of integers describing the folders which should be searched. If set to NULL the ID of the current item is used.
- $depth : mixed = true
-
the depth of searching children. Either an integer or true to get the values of all children
- $checkInheritance : bool = true
-
whether inherited fields should be included into the search result or not. IMPORTANT: if this parameter is false, indexed searches are disabled and search is executed on Master DB level.
- $sortFields : array<string|int, mixed> = array()
-
the fields the result should be sorted by, with the field name as key and a CS_SORT constant as value (e.g. CS_SORT_STRING_ASC or CS_SORT_NUMERICAL_DESC)
- $limit : string = ''
-
SQL limit condition in the form [Amount] or [Start],[Amount] as integers where [Start] is beginning with the index 0.
Note: If limit is provided as argument then $_iPageNumber will be reset and $_iPageSize will be $limit.
- $cacheTime : int
-
the time in minutes a search result may be cached to increase performance
- $bExtendedResult : bool = false
-
If true, this API method returns an object of type CSItemSearchResult containing more information than only a list of ids. For backward compatibility this defaults to false and returns a list of results only.
Tags
Return values
CSItemSearchResult|array<string|int, int> —An array of itemIDs matching the search with the given criteria if $bExtendedResult is false, otherwise an instance of CSItemSearchResult.
searchInLabel()
Enter description here .
public
static searchInLabel(Item $item, string $comparator, array<string|int, mixed> $values[, array<string|int, mixed> $cacheType = null ]) : array<string|int, mixed>
..
Parameters
- $item : Item
- $comparator : string
- $values : array<string|int, mixed>
- $cacheType : array<string|int, mixed> = null
Tags
Return values
array<string|int, mixed> —an array with the ids of the found items
setIsNegated()
Sets this filter to be negated for a search like " NOT ( ... ) "
public
setIsNegated([bool $isNegated = true ]) : mixed
Parameters
- $isNegated : bool = true
-
whether this filter is negated
Tags
Return values
mixed —setPageNumber()
Sets page number to fetch the values as per page number
public
setPageNumber(int $iPageNumber) : mixed
Parameters
- $iPageNumber : int
Tags
Return values
mixed —setPageSize()
Sets page size to fetch that much data as results
public
setPageSize(int $iPageSize) : mixed
Parameters
- $iPageSize : int
Tags
Return values
mixed —setTrackTotalHits()
This method is used to define whether the search should track the total hits, which costs performance or use the default setting of ElasticSearch which are 10.000 hits.
public
setTrackTotalHits(bool $bTrackTotalHits) : void
Parameters
- $bTrackTotalHits : bool
Tags
Return values
void —toArray()
Creates an array representation of the current item filter in the following format:
public
toArray() : array<string|int, mixed>
array( 'connector' => ' OR '/' AND ', filters: array( EITHER (new sub filter): array( 'connector' => ' OR '/' AND ', filters: ... ) OR (condition): 'attributes' => array(123, 'Label'...), 'comparator' => '=', 'values' => array('value1', 'value2'...) ) ... );
Tags
Return values
array<string|int, mixed> —The CSItemSearchFilter's array representation
toCSql()
public
toCSql() : mixed
Tags
Return values
mixed —unregisterDelegate()
Removes the given object as a delegate if it was set as a delegate before.
public
static unregisterDelegate(mixed $oDelegate) : bool
Parameters
- $oDelegate : mixed
Tags
Return values
bool —TRUE, If the delegate is removed FALSE, Otherwise.
