56 $search = trim( $search );
57 if ( $search ==
'' ) {
62 if ( $hasNamespace ) {
63 list( $namespace, $search ) = $hasNamespace;
67 Hooks::run(
'PrefixSearchExtractNamespace', [ &
$namespaces, &$search ] );
80 if ( strpos(
$input,
':' ) ===
false ) {
85 $title = Title::newFromText(
$input .
'Dummy' );
88 $title->getText() ===
'Dummy' &&
89 !$title->inNamespace(
NS_MAIN ) &&
92 return [ $title->getNamespace(),
'' ];
96 $title = Title::newFromText(
$input );
99 !$title->inNamespace(
NS_MAIN ) &&
100 !$title->isExternal()
103 return [ $title->getNamespace(), $title->getText() ];
122 $fallbackLimit = $limit - count( $searches );
123 if ( $fallbackLimit > 0 ) {
126 $fallbackSearches =
$wgContLang->autoConvertToAllVariants( $search );
127 $fallbackSearches = array_diff( array_unique( $fallbackSearches ), [ $search ] );
129 foreach ( $fallbackSearches as $fbs ) {
131 $searches = array_merge( $searches, $fallbackSearchResult );
132 $fallbackLimit -= count( $fallbackSearchResult );
134 if ( $fallbackLimit == 0 ) {
159 abstract protected function strings( array $strings );
180 'PrefixSearchBackend',
181 [
$namespaces, $search, $limit, &$srchres, $offset ]
190 if ( $offset === 0 ) {
196 $srchres = $rescorer->rescore( $search,
$namespaces, $srchres, $limit );
212 $searchParts = explode(
'/', $search, 2 );
213 $searchKey = $searchParts[0];
214 $subpageSearch = isset( $searchParts[1] ) ? $searchParts[1] :
null;
217 if ( $subpageSearch !==
null ) {
219 $specialTitle = Title::makeTitleSafe(
NS_SPECIAL, $searchKey );
220 if ( !$specialTitle ) {
225 $subpages = $special->prefixSearchSubpages( $subpageSearch, $limit, $offset );
226 return array_map(
function ( $sub ) use ( $specialTitle ) {
227 return $specialTitle->getSubpage( $sub );
234 # normalize searchKey, so aliases with spaces can be found - T27675
235 $searchKey = str_replace(
' ',
'_', $searchKey );
245 foreach (
$wgContLang->getSpecialPageAliases() as $page => $aliases ) {
250 foreach ( $aliases as $key => $alias ) {
251 $keys[
$wgContLang->caseFold( $alias )] = [
'page' => $alias,
'rank' => $key ];
257 foreach (
$keys as $pageKey => $page ) {
258 if ( $searchKey ===
'' || strpos( $pageKey, $searchKey ) === 0 ) {
278 return array_slice(
$matches, $offset, $limit );
311 $title = Title::makeTitleSafe( $namespace, $search );
313 $prefix = $title ? $title->getDBkey() :
'';
314 $prefixes[$prefix][] = $namespace;
324 'page_title' .
$dbr->buildLike( $prefix,
$dbr->anyString() ),
330 $fields = [
'page_id',
'page_namespace',
'page_title' ];
334 'ORDER BY' => [
'page_title',
'page_namespace' ],
357 if ( is_numeric( $ns ) && array_key_exists( $ns, $validNamespaces ) ) {
361 if ( count( $valid ) > 0 ) {
381 protected function strings( array $strings ) {
382 $titles = array_map(
'Title::newFromText', $strings );
384 $lb->setCaller( __METHOD__ );
398 return array_map(
function (
Title $t ) {
399 return $t->getPrefixedText();
403 protected function strings( array $strings ) {
wfGetDB( $db, $groups=[], $wiki=false)
Get a Database object.
Class representing a list of titles The execute() method checks them all for existence and adds them ...
Handles searching prefixes of titles and finding any page names that match.
searchWithVariants( $search, $limit, array $namespaces, $offset=0)
Do a prefix search for all possible variants of the prefix.
search( $search, $limit, $namespaces=[], $offset=0)
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.
validateNamespaces( $namespaces)
Validate an array of numerical namespace indexes.
titles(array $titles)
When implemented in a descendant class, receives an array of Title objects and returns either an unmo...
extractNamespace( $input)
Figure out if given input contains an explicit namespace.
defaultSearchBackend( $namespaces, $search, $limit, $offset)
Unless overridden by PrefixSearchBackend hook... This is case-sensitive (First character may be autom...
static titleSearch( $search, $limit, $namespaces=[], $offset=0)
Do a prefix search of titles and return a list of matching page names.
strings(array $strings)
When implemented in a descendant class, receives an array of titles as strings and returns either an ...
handleResultFromHook( $srchres, $namespaces, $search, $limit, $offset)
searchBackend( $namespaces, $search, $limit, $offset)
Do a prefix search of titles and return a list of matching page names.
An utility class to rescore search results by looking for an exact match in the db and add the page f...
static getPage( $name)
Find the object with a given name and return it (or NULL)
static getNames()
Returns a list of canonical special page names.
Performs prefix search, returning strings.
strings(array $strings)
When implemented in a descendant class, receives an array of titles as strings and returns either an ...
titles(array $titles)
When implemented in a descendant class, receives an array of Title objects and returns either an unmo...
static newFromResult( $res)
Performs prefix search, returning Title objects.
titles(array $titles)
When implemented in a descendant class, receives an array of Title objects and returns either an unmo...
strings(array $strings)
When implemented in a descendant class, receives an array of titles as strings and returns either an ...
Represents a title within MediaWiki.
deferred txt A few of the database updates required by various functions here can be deferred until after the result page is displayed to the user For updating the view updating the linked to tables after a etc PHP does not yet have any way to tell the server to actually return and disconnect while still running these but it might have such a feature in the future We handle these by creating a deferred update object and putting those objects on a global list
this class mediates it Skin Encapsulates a look and feel for the wiki All of the functions that render HTML and make choices about how to render it are here and are called from various other places when and is meant to be subclassed with other skins that may override some of its functions The User object contains a reference to a and so rather than having a global skin object we just rely on the global User and get the skin with $wgUser and also has some character encoding functions and other locale stuff The current user interface language is instantiated as and the local content language as $wgContLang
it sets a lot of them automatically from query strings
namespace and then decline to actually register it & $namespaces
null means default in associative array with keys and values unescaped Should be merged with default with a value of false meaning to suppress the attribute in associative array with keys and values unescaped & $options
linkcache txt The LinkCache class maintains a list of article titles and the information about whether or not the article exists in the database This is used to mark up links when displaying a page If the same link appears more than once on any page then it only has to be looked up once In most cases link lookups are done in batches with the LinkBatch class or the equivalent in so the link cache is mostly useful for short snippets of parsed and for links in the navigation areas of the skin The link cache was formerly used to track links used in a document for the purposes of updating the link tables This application is now deprecated To create a you can use the following $titles
if(is_array($mode)) switch( $mode) $input