MediaWiki master
MediaWiki\Search\PrefixSearch Class Reference

Handles searching prefixes of titles and finding any page names that match. More...

Inherited by MediaWiki\Search\StringPrefixSearch, and MediaWiki\Search\TitlePrefixSearch.

Public Member Functions

 defaultSearchBackend ( $namespaces, $search, $limit, $offset)
 This is case-sensitive (First character may be automatically capitalized by Title::secureAndSpit() later on depending on $wgCapitalLinks)
 
 search ( $search, $limit, $namespaces=[], $offset=0)
 Do a prefix search of titles and return a list of matching page names.
 
 searchWithVariants ( $search, $limit, array $namespaces, $offset=0)
 Do a prefix search for all possible variants of the prefix.
 

Protected Member Functions

 searchBackend ( $namespaces, $search, $limit, $offset)
 Do a prefix search of titles and return a list of matching page names.
 
 specialSearch ( $search, $limit, $offset)
 Prefix search special-case for Special: namespace.
 
 strings (array $strings)
 When implemented in a descendant class, receives an array of titles as strings and returns either an unmodified array or an array of Title objects corresponding to strings received.
 
 titles (array $titles)
 When implemented in a descendant class, receives an array of Title objects and returns either an unmodified array or an array of strings corresponding to titles passed to it.
 

Detailed Description

Handles searching prefixes of titles and finding any page names that match.

Used largely by the OpenSearch implementation.

Deprecated
Since 1.27, Use SearchEngine::defaultPrefixSearch or SearchEngine::completionSearch
Stability: stable
to extend, but deprecated since 1.27, emitting warnings since 1.47

Definition at line 25 of file PrefixSearch.php.

Member Function Documentation

◆ defaultSearchBackend()

MediaWiki\Search\PrefixSearch::defaultSearchBackend ( $namespaces,
$search,
$limit,
$offset )

This is case-sensitive (First character may be automatically capitalized by Title::secureAndSpit() later on depending on $wgCapitalLinks)

Parameters
int[] | null$namespacesNamespaces to search in
string$searchTerm
int$limitMax number of items to return
int$offsetNumber of items to skip
Returns
Title[]
Deprecated
This class is deprecated. Use SearchEngine::completionSearch() instead.

Definition at line 164 of file PrefixSearch.php.

References MediaWiki\MediaWikiServices\getInstance(), NS_MAIN, NS_SPECIAL, and wfDeprecated().

Referenced by MediaWiki\Search\PrefixSearch\searchBackend().

◆ search()

MediaWiki\Search\PrefixSearch::search ( $search,
$limit,
$namespaces = [],
$offset = 0 )

Do a prefix search of titles and return a list of matching page names.

Parameters
string$search
int$limit
array$namespacesUsed if query is not explicitly prefixed
int$offsetHow many results to offset from the beginning
Returns
(Title|string)[]
Deprecated
This class is deprecated. Use SearchEngine::completionSearch() instead.

Definition at line 41 of file PrefixSearch.php.

References MediaWiki\Search\SearchEngine\parseNamespacePrefixes(), MediaWiki\Search\PrefixSearch\searchBackend(), and wfDeprecated().

Referenced by MediaWiki\Search\PrefixSearch\searchWithVariants().

◆ searchBackend()

MediaWiki\Search\PrefixSearch::searchBackend ( $namespaces,
$search,
$limit,
$offset )
protected

Do a prefix search of titles and return a list of matching page names.

Parameters
int[]$namespaces
string$search
int$limit
int$offsetHow many results to offset from the beginning
Returns
(Title|string)[]

Definition at line 118 of file PrefixSearch.php.

References MediaWiki\Search\PrefixSearch\defaultSearchBackend(), NS_FILE, NS_MEDIA, NS_SPECIAL, MediaWiki\Search\PrefixSearch\specialSearch(), and MediaWiki\Search\PrefixSearch\titles().

Referenced by MediaWiki\Search\PrefixSearch\search().

◆ searchWithVariants()

MediaWiki\Search\PrefixSearch::searchWithVariants ( $search,
$limit,
array $namespaces,
$offset = 0 )

Do a prefix search for all possible variants of the prefix.

Parameters
string$search
int$limit
array$namespaces
int$offsetHow many results to offset from the beginning
Returns
(Title|string)[]
Deprecated
This class is deprecated. Use SearchEngine::completionSearch() instead.

Definition at line 66 of file PrefixSearch.php.

References MediaWiki\MediaWikiServices\getInstance(), MediaWiki\Search\PrefixSearch\search(), and wfDeprecated().

◆ specialSearch()

MediaWiki\Search\PrefixSearch::specialSearch ( $search,
$limit,
$offset )
protected

Prefix search special-case for Special: namespace.

Parameters
string$searchTerm
int$limitMax number of items to return
int$offsetNumber of items to offset
Returns
array

Definition at line 148 of file PrefixSearch.php.

Referenced by MediaWiki\Search\PrefixSearch\searchBackend().

◆ strings()

MediaWiki\Search\PrefixSearch::strings ( array $strings)
abstractprotected

When implemented in a descendant class, receives an array of titles as strings and returns either an unmodified array or an array of Title objects corresponding to strings received.

Parameters
string[]$strings
Returns
(Title|string)[]

Reimplemented in MediaWiki\Search\StringPrefixSearch, and MediaWiki\Search\TitlePrefixSearch.

◆ titles()

MediaWiki\Search\PrefixSearch::titles ( array $titles)
abstractprotected

When implemented in a descendant class, receives an array of Title objects and returns either an unmodified array or an array of strings corresponding to titles passed to it.

Parameters
Title[]$titles
Returns
(Title|string)[]

Reimplemented in MediaWiki\Search\StringPrefixSearch, and MediaWiki\Search\TitlePrefixSearch.

Referenced by MediaWiki\Search\PrefixSearch\searchBackend().


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