SearchApiInterface
in
Interface SearchApiInterface
Table of Contents
Methods
- compressParams() : string
- Compresses $this->params to a string for use as an URL parameter.
- formContext() : void
- Lets APIs interact with Utils::$context when setting up the search form.
- getAdminSubactions() : array<string|int, mixed>
- Gets info about sub-actions to support in the admin panel for this API.
- getDescription() : string
- Returns the expected Lang::$txt key for this API's localized description.
- getLabel() : string
- Returns the expected Lang::$txt key for this API's localized label.
- getSize() : int
- Gets the size, in bytes, of this API's search index.
- getStatus() : string
- Gets whether the index for this API exists.
- indexedWordQuery() : mixed
- Search for indexed words.
- initializeSearch() : void
- Sets whatever properties are necessary in order to perform the search.
- isValid() : bool
- Whether this method is valid for implementation or not.
- postCreated() : void
- Callback when a post is created.
- postModified() : void
- Callback when a post is modified.
- postRemoved() : void
- Callback when a post is removed.
- prepareIndexes() : void
- Callback while preparing indexes for searching.
- resultsContext() : void
- Lets APIs interact with Utils::$context when setting up the results page.
- searchQuery() : mixed
- Callback for actually performing the search query.
- searchSort() : int
- Callback function for usort used to sort the fulltext results.
- setParticipants() : void
- Figures out which search result topics the user participated in.
- supportsMethod() : bool
- Check whether the specific search operation can be performed by this API.
- topicMerge() : void
- Callback when a topic is merged.
- topicsMoved() : void
- Callback when a topic is moved.
- topicSplit() : void
- Callback when a topic is merged.
- topicsRemoved() : void
- Callback when a topic is removed.
Methods
compressParams()
Compresses $this->params to a string for use as an URL parameter.
public
compressParams() : string
Return values
string —URL-safe variant of a Base64 string.
formContext()
Lets APIs interact with Utils::$context when setting up the search form.
public
formContext() : void
getAdminSubactions()
Gets info about sub-actions to support in the admin panel for this API.
public
getAdminSubactions() : array<string|int, mixed>
Keys of the returned array are action types (e.g. build, resume, remove).
Values are sub-arrays with 'func', 'sa', and 'extra_params' elements:
- The 'func' element is the callable to execute for the sub-action.
- The 'sa' element is the value to use for the 'sa' URL parameter.
- The 'extra_params' element contains extra URL parameters to add to the URL for the sub-action.
Return values
array<string|int, mixed> —Info about sub-actions.
getDescription()
Returns the expected Lang::$txt key for this API's localized description.
public
getDescription() : string
Return values
string —Localized description for this API.
getLabel()
Returns the expected Lang::$txt key for this API's localized label.
public
getLabel() : string
Return values
string —Localized label for this API.
getSize()
Gets the size, in bytes, of this API's search index.
public
getSize() : int
Return values
int —Size of the index.
getStatus()
Gets whether the index for this API exists.
public
getStatus() : string
Return values
string —Either 'exists', 'partial', 'none', or null for APIs that don't use an index.
indexedWordQuery()
Search for indexed words.
public
indexedWordQuery(array<string|int, mixed> $words, array<string|int, mixed> $search_data) : mixed
Parameters
- $words : array<string|int, mixed>
-
An array of words
- $search_data : array<string|int, mixed>
-
An array of search data
initializeSearch()
Sets whatever properties are necessary in order to perform the search.
public
initializeSearch() : void
This is separate from the constructor because there are a number of other places where the search API will be loaded for other purposes.
isValid()
Whether this method is valid for implementation or not.
public
isValid() : bool
Return values
bool —Whether or not this method is valid
postCreated()
Callback when a post is created.
public
postCreated(array<string|int, mixed> &$msgOptions, array<string|int, mixed> &$topicOptions, array<string|int, mixed> &$posterOptions) : void
Parameters
- $msgOptions : array<string|int, mixed>
-
An array of post data
- $topicOptions : array<string|int, mixed>
-
An array of topic data
- $posterOptions : array<string|int, mixed>
-
An array of info about the person who made this post
Tags
postModified()
Callback when a post is modified.
public
postModified(array<string|int, mixed> &$msgOptions, array<string|int, mixed> &$topicOptions, array<string|int, mixed> &$posterOptions) : void
Parameters
- $msgOptions : array<string|int, mixed>
-
An array of post data
- $topicOptions : array<string|int, mixed>
-
An array of topic data
- $posterOptions : array<string|int, mixed>
-
An array of info about the person who made this post
Tags
postRemoved()
Callback when a post is removed.
public
postRemoved(int $id_msg) : void
Parameters
- $id_msg : int
-
The ID of the post that was removed
prepareIndexes()
Callback while preparing indexes for searching.
public
prepareIndexes(string $word, array<string|int, mixed> &$wordsSearch, array<string|int, mixed> &$wordsExclude, bool $isExcluded) : void
Parameters
- $word : string
-
A word to index
- $wordsSearch : array<string|int, mixed>
-
Search words
- $wordsExclude : array<string|int, mixed>
-
Words to exclude
- $isExcluded : bool
-
Whether the specified word should be excluded
resultsContext()
Lets APIs interact with Utils::$context when setting up the results page.
public
resultsContext() : void
searchQuery()
Callback for actually performing the search query.
public
searchQuery(array<string|int, mixed> $query_params, array<string|int, mixed> $searchWords, array<string|int, mixed> $excludedIndexWords, array<string|int, mixed> &$participants, array<string|int, mixed> &$searchArray) : mixed
All of the arguments for this method are deprecated as of SMF 3.0. The relevant data is directly accessible in the properties of SearchApi.
Parameters
- $query_params : array<string|int, mixed>
-
An array of parameters for the query
- $searchWords : array<string|int, mixed>
-
The words that were searched for
- $excludedIndexWords : array<string|int, mixed>
-
Indexed words that should be excluded
- $participants : array<string|int, mixed>
- $searchArray : array<string|int, mixed>
searchSort()
Callback function for usort used to sort the fulltext results.
public
searchSort(string $a, string $b) : int
the order of sorting is: large words, small words, large words that are excluded from the search, small words that are excluded.
Parameters
- $a : string
-
Word A
- $b : string
-
Word B
Return values
int —An integer indicating how the words should be sorted
setParticipants()
Figures out which search result topics the user participated in.
public
setParticipants() : void
supportsMethod()
Check whether the specific search operation can be performed by this API.
public
supportsMethod(string $methodName[, array<string|int, mixed> $query_params = [] ]) : bool
The operations are the functions listed in the interface, if not supported they need not be declared
Parameters
- $methodName : string
-
The method
- $query_params : array<string|int, mixed> = []
-
Any parameters for the query
Return values
bool —Whether or not the specified method is supported
topicMerge()
Callback when a topic is merged.
public
topicMerge(int $id_topic, array<string|int, mixed> $topics, array<string|int, mixed> $affected_msgs, string|null $subject) : void
Parameters
- $id_topic : int
-
The ID of the topic that messages where merged into
- $topics : array<string|int, mixed>
-
The ID(s) of the merged topic(s)
- $affected_msgs : array<string|int, mixed>
- $subject : string|null
topicsMoved()
Callback when a topic is moved.
public
topicsMoved(array<string|int, mixed> $topics, int $board_to) : void
Parameters
- $topics : array<string|int, mixed>
-
The ID(s) of the moved topic(s)
- $board_to : int
-
The board that the topics were moved to
topicSplit()
Callback when a topic is merged.
public
topicSplit(int $id_topic, array<string|int, mixed> $affected_msgs) : void
Parameters
- $id_topic : int
-
The ID of the topic that messages where merged into
- $affected_msgs : array<string|int, mixed>
topicsRemoved()
Callback when a topic is removed.
public
topicsRemoved(array<string|int, mixed> $topics) : void
Parameters
- $topics : array<string|int, mixed>
-
The ID(s) of the removed topic(s)