Abstract base for handling different content types in search.

package XenForo_Search

 Methods

Determines if the specific search result (data from getDataForResults()) can be viewed by the given user.

canViewResult(array $result, array $viewingUser) : boolean

The user and combination ID will be the same as given to getDataForResults().

Parameters

$result

array

Data for a result

$viewingUser

array

Information about the viewing user (keys: user_id, permission_combination_id, permissions)

Returns

boolean

Creates the specified data handler.

create(string $class) : \XenForo_Search_DataHandler_Abstract
Static

Parameters

$class

string

Object to create

Returns

Deletes one or more records from the index.

deleteFromIndex(\XenForo_Search_Indexer $indexer, array $dataList) 

Wrapper around _deleteFromIndex().

Parameters

$indexer

\XenForo_Search_Indexer

Object that will will manipulate the index

$dataList

array

A list of data to remove. This may be one piece of data or multiple. Detection based on whether first element is an array.

Allow type-specific pre-constraint application filtering.

filterConstraints(\XenForo_Search_SourceHandler_Abstract $sourceHandler, array $constraints) : array

For example, a "thread only" constraint may change the searchable content types.

Parameters

$sourceHandler

\XenForo_Search_SourceHandler_Abstract

Source handler calling

$constraints

array

Unfiltered constraints

Returns

arrayFiltered constraints

Gets the additional, type-specific data for a list of results.

getDataForResults(array $ids, array $viewingUser, array $resultsGrouped) : array

If any of the given IDs are not returned from this, they will be removed from the results.

Parameters

$ids

array

List of IDs of this content type.

$viewingUser

array

Information about the viewing user (keys: user_id, permission_combination_id, permissions)

$resultsGrouped

array

List of all results grouped by content type

Returns

arrayFormat: [id] => data, IDs not returned will be removed from results

Gets the content type that will be returned when grouping results.

getGroupByType() : string

Returns

stringIf empty, grouping will not be possible

Get the data that is needed to do joins/queries against data that isn't kept in the search index itself.

getJoinStructures(array $tables) : array

Parameters

$tables

array

List of table aliases (in the keys) that are requested for this search

Returns

arrayKeys should be table aliases (to use in query). Values are arrays with keys: * table - actual table name * key - name of the field in the table that matches up with the relationship field * relationship - field to join against. Array, 0 = table of field, 1 = field name.

Gets the search order for a type-specific search.

getOrderClause(string $order) : false | array

Parameters

$order

string

Order requested by user

Returns

falsearrayFalse or or array of arrays. Child array keys: 0 = table alias, 1 = field, 2 = dir (asc/desc)

Gets the date of the result (from the result's content).

getResultDate(array $result) : integer

Parameters

$result

array

Returns

integer

Get the content types that will be searched, when doing a type-specific search for this type.

getSearchContentTypes() : array

This may be multiple types (for example, thread and post for post searches).

Returns

array

Get the controller response for the form to search this type of content specifically.

getSearchFormControllerResponse(\XenForo_ControllerPublic_Abstract $controller, \XenForo_Input $input, array $viewParams) : \XenForo_ControllerResponse_Abstract | false

Parameters

$controller

\XenForo_ControllerPublic_Abstract

Invoking controller

$input

\XenForo_Input

Input object from controller

$viewParams

array

View params prepared for general search

Returns

Get type-specific constrints from input.

getTypeConstraintsFromInput(\XenForo_Input $input) : array

Parameters

Returns

array

Inserts a new record or replaces an existing record in the index.

insertIntoIndex(\XenForo_Search_Indexer $indexer, array $data, array $parentData) 

Wrapper around _insertIntoIndex().

Parameters

$indexer

\XenForo_Search_Indexer

Object that will will manipulate the index

$data

array

Data that needs to be updated

$parentData

arraynull

Data about the parent info (eg, for a post, the parent thread)

Prepares the result for display.

prepareResult(array $result, array $viewingUser) : array

Parameters

$result

array

$viewingUser

array

Information about the viewing user (keys: user_id, permission_combination_id, permissions)

Returns

arrayPrepared result

Process a constraint, if it is known to be specific to this type.

processConstraint(\XenForo_Search_SourceHandler_Abstract $sourceHandler, string $constraint, mixed $constraintInfo, array $constraints) : array | false

If the constraint is unknown, it should simply be ignored.

Parameters

$sourceHandler

\XenForo_Search_SourceHandler_Abstract

Source handler invoking

$constraint

string

Name of the constraint

$constraintInfo

mixed

Data for the constraint; may be an array or scalar

$constraints

array

List of all constraints specified

Returns

arrayfalseIf processed, return array with possible keys: * metadata - metadata value; keys: 0 = name of metadata, 1 = scalar/array allowed value(s) for metadata * query - constraint to limit via query; keys: 0 = table alias, 1 = field, 2 = operator, 3 = scalar/array allowed value(s). Multiple for "=" operator only. Note that the metadata and query keys are assumed to be equivalent. Engines need only use one (depending on engine details).

Indexes the specified content IDs.

quickIndex(\XenForo_Search_Indexer $indexer, array $contentIds) : array

Parameters

$contentIds

array

Returns

arrayList of content IDs indexed

Rebuilds the index in bulk.

rebuildIndex(\XenForo_Search_Indexer $indexer, integer $lastId, integer $batchSize) : integer | false

Parameters

$indexer

\XenForo_Search_Indexer

Object that will will manipulate the index

$lastId

integer

The last ID that was processed. Should continue with the IDs above this.

$batchSize

integer

Number of records to process at once

Returns

integerfalseThe last ID that was processed or false if none were processed

Render a result (as HTML).

renderResult(\XenForo_View $view, array $result, array $search) : \XenForo_Template_Abstract | string

Parameters

$result

array

Data from result

$search

array

The search that was performed

Returns

Updates a record in the index.

updateIndex(\XenForo_Search_Indexer $indexer, array $data, array $fieldUpdates) 

Wrapper around _updateIndex().

Parameters

$indexer

\XenForo_Search_Indexer

Object that will will manipulate the index

$data

array

Data that needs to be updated

$fieldUpdates

array

Key-value fields to update

Deletes one or more records from the index.

_deleteFromIndex(\XenForo_Search_Indexer $indexer, array $dataList) 

Wrapper around _deleteFromIndex().

Parameters

$indexer

\XenForo_Search_Indexer

Object that will will manipulate the index

$dataList

array

A list of data to remove. Each element is an array of the data from one record or an ID.

Inserts a new record or replaces an existing record in the index.

_insertIntoIndex(\XenForo_Search_Indexer $indexer, array $data, array $parentData) 

Parameters

$indexer

\XenForo_Search_Indexer

Object that will will manipulate the index

$data

array

Data that needs to be updated

$parentData

arraynull

Data about the parent info (eg, for a post, the parent thread)

Updates a record in the index.

_updateIndex(\XenForo_Search_Indexer $indexer, array $data, array $fieldUpdates) 

Parameters

$indexer

\XenForo_Search_Indexer

Object that will will manipulate the index

$data

array

Data that needs to be updated

$fieldUpdates

array

Key-value fields to update