98 parent::__construct(
'Search' );
99 $this->searchConfig = MediaWikiServices::getInstance()->getSearchEngineConfig();
112 $term = str_replace(
"\n",
" ",
$request->getText(
'search' ) );
118 if ( $par !==
null && $par !==
'' &&
$term ===
'' ) {
123 $query[
'search'] = str_replace(
'_',
' ', $par );
132 if (
$request->getCheck(
'nsRemember' ) ) {
143 $this->searchEngineType =
$request->getVal(
'srbackend' );
146 if ( $url !==
null ) {
148 $out->redirect( $url );
154 if ( !is_null(
$title ) ) {
155 Hooks::run(
'SpecialSearchNogomatch', [ &
$title ] );
161 if ( $this->
getConfig()->
get(
'DisableTextSearch' ) ) {
162 $searchForwardUrl = $this->
getConfig()->get(
'SearchForwardUrl' );
163 if ( $searchForwardUrl ) {
164 $url = str_replace(
'$1', urlencode(
$term ), $searchForwardUrl );
165 $out->redirect( $url );
187 $this->
msg(
'search-external' )->escaped() .
189 "<p class='mw-searchdisabled'>" .
190 $this->
msg(
'searchdisabled' )->escaped() .
192 $this->
msg(
'googlesearch' )->rawParams(
193 htmlspecialchars(
$term ),
195 $this->
msg(
'searchbutton' )->escaped()
208 list( $this->limit, $this->offset ) =
$request->getLimitOffset( 20,
'' );
209 $this->mPrefix =
$request->getVal(
'prefix',
'' );
210 if ( $this->mPrefix !==
'' ) {
214 $this->sort =
$request->getVal(
'sort', SearchEngine::DEFAULT_SORT );
215 if ( $this->sort !== SearchEngine::DEFAULT_SORT ) {
221 # Extract manually requested namespaces
223 if ( $nslist === [] ) {
224 # Fallback to user preference
225 $nslist = $this->searchConfig->userNamespaces(
$user );
229 if ( $nslist === [] ) {
238 foreach ( $profiles
as $key =>
$data ) {
239 if ( $nslist ===
$data[
'namespaces'] && $key !==
'advanced' ) {
244 } elseif (
$profile ===
'advanced' ) {
246 } elseif ( isset( $profiles[
$profile][
'namespaces'] ) ) {
247 $this->
namespaces = $profiles[$profile][
'namespaces'];
250 $profile =
'default';
251 $this->
namespaces = $profiles[
'default'][
'namespaces'];
254 $this->fulltext =
$request->getVal(
'fulltext' );
255 $this->runSuggestion = (bool)
$request->getVal(
'runsuggestion',
true );
256 $this->profile = $profile;
266 # If the string cannot be used to create a title
267 if ( is_null( Title::newFromText(
$term ) ) ) {
270 # If there's an exact or very near match, jump right there.
273 if ( is_null(
$title ) ) {
277 if ( !Hooks::run(
'SpecialSearchGoResult', [
$term,
$title, &$url ] ) ) {
281 return $url ??
$title->getFullUrlForRedirect();
288 if ( $this->searchEngineType !==
null ) {
289 $this->
setExtraParam(
'srbackend', $this->searchEngineType );
298 $filePrefix = MediaWikiServices::getInstance()->getContentLanguage()->
299 getFormattedNsText(
NS_FILE ) .
':';
300 if ( trim(
$term ) ===
'' || $filePrefix === trim(
$term ) ) {
302 if ( !Hooks::run(
'SpecialSearchResultsPrepend', [ $this,
$out,
$term ] ) ) {
303 # Hook requested termination
310 $out->addHTML( $formWidget->render(
311 $this->profile,
$term, 0, 0, $this->offset, $this->isPowerSearch()
317 $search->setFeatureData(
'rewrite', $this->runSuggestion );
318 $search->setLimitOffset( $this->limit, $this->offset );
320 $search->setSort( $this->sort );
321 $search->prefix = $this->mPrefix;
323 Hooks::run(
'SpecialSearchSetupEngine', [ $this, $this->profile, $search ] );
324 if ( !Hooks::run(
'SpecialSearchResultsPrepend', [ $this,
$out,
$term ] ) ) {
325 # Hook requested termination
330 $showSuggestion =
$title ===
null || !
$title->isKnown();
331 $search->setShowSuggestion( $showSuggestion );
333 $rewritten = $search->transformSearchTerm(
$term );
334 if ( $rewritten !==
$term ) {
336 wfDeprecated(
'SearchEngine::transformSearchTerm() (overridden by ' .
337 get_class( $search ) .
')',
'1.32' );
340 $rewritten = $search->replacePrefixes(
$term );
341 if ( $rewritten !==
$term ) {
342 wfDeprecated(
'SearchEngine::replacePrefixes() (overridden by ' .
343 get_class( $search ) .
')',
'1.32' );
347 $titleMatches = $search->searchTitle( $rewritten );
348 $textMatches = $search->searchText( $rewritten );
351 if ( $textMatches instanceof
Status ) {
352 $textStatus = $textMatches;
353 $textMatches = $textStatus->getValue();
357 $titleMatchesNum = $textMatchesNum = $numTitleMatches = $numTextMatches = 0;
358 if ( $titleMatches ) {
359 $titleMatchesNum = $titleMatches->numRows();
360 $numTitleMatches = $titleMatches->getTotalHits();
362 if ( $textMatches ) {
363 $textMatchesNum = $textMatches->numRows();
364 $numTextMatches = $textMatches->getTotalHits();
365 if ( $textMatchesNum > 0 ) {
366 $search->augmentSearchResults( $textMatches );
369 $num = $titleMatchesNum + $textMatchesNum;
370 $totalRes = $numTitleMatches + $numTextMatches;
374 $out->addHTML( $formWidget->render(
375 $this->profile,
$term, $num, $totalRes, $this->offset, $this->isPowerSearch()
379 if ( $textMatches ) {
381 $out->addHTML( $dymWidget->render(
$term, $textMatches ) );
384 $hasErrors = $textStatus && $textStatus->getErrors() !== [];
385 $hasOtherResults = $textMatches &&
386 $textMatches->hasInterwikiResults( SearchResultSet::INLINE_RESULTS );
388 if ( $textMatches && $textMatches->hasInterwikiResults( SearchResultSet::SECONDARY_RESULTS ) ) {
389 $out->addHTML(
'<div class="searchresults mw-searchresults-has-iw">' );
391 $out->addHTML(
'<div class="searchresults">' );
395 list( $error, $warning ) = $textStatus->splitByErrorType();
396 if ( $error->getErrors() ) {
397 $out->addHTML( Html::errorBox(
398 $error->getHTML(
'search-error' )
401 if ( $warning->getErrors() ) {
402 $out->addHTML( Html::warningBox(
403 $warning->getHTML(
'search-warning' )
411 Hooks::run(
'SpecialSearchResults', [
$term, &$titleMatches, &$textMatches ] );
415 $out->wrapWikiMsg(
"<p class=\"mw-search-nonefound\">\n$1</p>", [
416 $hasOtherResults ?
'search-nonefound-thiswiki' :
'search-nonefound',
427 if ( $search->getFeatureData(
'enable-new-crossproject-page' ) !==
false ) {
431 $sidebarResultWidget,
433 MediaWikiServices::getInstance()->getInterwikiLookup(),
434 $search->getFeatureData(
'show-multimedia-search-results' )
440 $sidebarResultWidget,
442 MediaWikiServices::getInstance()->getInterwikiLookup()
448 $out->addHTML( $widget->render(
449 $term, $this->offset, $titleMatches, $textMatches
452 if ( $titleMatches ) {
453 $titleMatches->free();
456 if ( $textMatches ) {
457 $textMatches->free();
460 $out->addHTML(
'<div class="mw-search-visualclear"></div>' );
463 if ( $totalRes > $this->limit || $this->offset ) {
466 if ( $textMatches && $textMatches->getOffset() !==
null ) {
467 $offset = $textMatches->getOffset();
469 $offset = $this->offset;
476 $this->limit + $this->offset >= $totalRes
478 $out->addHTML(
"<p class='mw-search-pager-bottom'>{$prevnext}</p>\n" );
482 $out->addHTML(
"</div>" );
484 Hooks::run(
'SpecialSearchResultsAppend', [ $this,
$out,
$term ] );
498 || ( $titleMatches !==
null && $titleMatches->searchContainedSyntax() )
499 || ( $textMatches !==
null && $textMatches->searchContainedSyntax() )
503 $this->
getOutput()->addHTML(
'<p></p>' );
508 $messageName =
'searchmenu-new-nocreate';
509 $linkClass =
'mw-search-createlink';
511 if ( !
$title->isExternal() ) {
512 if (
$title->isKnown() ) {
513 $messageName =
'searchmenu-exists';
514 $linkClass =
'mw-search-exists';
515 } elseif ( ContentHandler::getForTitle(
$title )->supportsDirectEditing()
516 &&
$title->quickUserCan(
'create', $this->getUser() )
518 $messageName =
'searchmenu-new';
525 Message::numParam( $num )
527 Hooks::run(
'SpecialSearchCreateLink', [
$title, &
$params ] );
530 if ( $messageName ) {
531 $this->
getOutput()->wrapWikiMsg(
"<p class=\"$linkClass\">\n$1</p>",
$params );
534 $this->
getOutput()->addHTML(
'<p></p>' );
551 $out->allowClickjacking();
554 if ( strval(
$term ) !==
'' ) {
555 $out->setPageTitle( $this->
msg(
'searchresults' ) );
556 $out->setHTMLTitle( $this->
msg(
'pagetitle' )
557 ->plaintextParams( $this->
msg(
'searchresults-title' )->plaintextParams(
$term )->
text() )
558 ->inContentLanguage()->
text()
562 if ( $this->mPrefix !==
'' ) {
563 $subtitle = $this->
msg(
'search-filter-title-prefix' )->plaintextParams( $this->mPrefix );
572 $subtitle .= Xml::element(
576 'title' => $this->
msg(
'search-filter-title-prefix-reset' )->
text(),
578 $this->
msg(
'search-filter-title-prefix-reset' )->
text()
581 $out->setSubtitle( $subtitle );
584 $out->addJsConfigVars( [
'searchTerm' =>
$term ] );
585 $out->addModules(
'mediawiki.special.search' );
586 $out->addModuleStyles( [
587 'mediawiki.special',
'mediawiki.special.search.styles',
'mediawiki.ui',
'mediawiki.ui.button',
588 'mediawiki.ui.input',
'mediawiki.widgets.SearchInputWidget.styles',
598 return $this->profile ===
'advanced';
610 foreach ( $this->searchConfig->searchableNamespaces()
as $ns =>
$name ) {
611 if (
$request->getCheck(
'ns' . $ns ) ) {
633 $opt[
'profile'] = $this->profile;
636 return $opt + $this->extraParams;
648 if (
$user->isLoggedIn() &&
649 $user->matchEditToken(
657 foreach ( MWNamespace::getValidNamespaces()
as $n ) {
658 $user->setOption(
'searchNs' . $n,
false );
663 $user->setOption(
'searchNs' . $n,
true );
666 DeferredUpdates::addCallableUpdate(
function ()
use (
$user ) {
667 $user->saveSettings();
681 $nsAllSet = array_keys( $this->searchConfig->searchableNamespaces() );
682 $defaultNs = $this->searchConfig->defaultNamespaces();
685 'message' =>
'searchprofile-articles',
686 'tooltip' =>
'searchprofile-articles-tooltip',
687 'namespaces' => $defaultNs,
688 'namespace-messages' => $this->searchConfig->namespacesAsText(
693 'message' =>
'searchprofile-images',
694 'tooltip' =>
'searchprofile-images-tooltip',
698 'message' =>
'searchprofile-everything',
699 'tooltip' =>
'searchprofile-everything-tooltip',
700 'namespaces' => $nsAllSet,
703 'message' =>
'searchprofile-advanced',
704 'tooltip' =>
'searchprofile-advanced-tooltip',
705 'namespaces' => self::NAMESPACES_CURRENT,
709 Hooks::run(
'SpecialSearchProfiles', [ &$profiles ] );
711 foreach ( $profiles
as &
$data ) {
712 if ( !is_array(
$data[
'namespaces'] ) ) {
715 sort(
$data[
'namespaces'] );
727 if ( $this->searchEngine ===
null ) {
728 $services = MediaWikiServices::getInstance();
729 $this->searchEngine = $this->searchEngineType ?
730 $services->getSearchEngineFactory()->create( $this->searchEngineType ) :
734 return $this->searchEngine;
742 return $this->profile;
763 $this->extraParams[$key] =
$value;
775 return $this->mPrefix;
Apache License January AND DISTRIBUTION Definitions License shall mean the terms and conditions for use
to move a page</td >< td > &*You are moving the page across namespaces
This list may contain false positives That usually means there is additional text with links below the first Each row contains links to the first and second as well as the first line of the second redirect text
wfReadOnly()
Check whether the wiki is in read-only mode.
wfEscapeWikiText( $text)
Escapes the given text so that it may be output using addWikiText() without any linking,...
wfDeprecated( $function, $version=false, $component=false, $callerOffset=2)
Throws a warning that $function is deprecated.
Configuration handling class for SearchEngine.
Contain a class for special pages.
Parent class for all special pages.
outputHeader( $summaryMessageKey='')
Outputs a summary message on top of special pages Per default the message key is the canonical name o...
setHeaders()
Sets headers - this should be called from the execute() method of all derived classes!
getOutput()
Get the OutputPage being used for this instance.
getUser()
Shortcut to get the User executing this instance.
buildPrevNextNavigation( $offset, $limit, array $query=[], $atend=false, $subpage=false)
Generate (prev x| next x) (20|50|100...) type links for paging.
msg( $key)
Wrapper around wfMessage that sets the current context.
getConfig()
Shortcut to get main config object.
getRequest()
Get the WebRequest being used for this instance.
getPageTitle( $subpage=false)
Get a self-referential title object.
addHelpLink( $to, $overrideBaseUrl=false)
Adds help link with an icon via page indicators.
implements Special:Search - Run text & title search and display the output
goResult( $term)
If an exact title match can be found, jump straight ahead to it.
setExtraParam( $key, $value)
Users of hook SpecialSearchSetupEngine can use this to add more params to links to not lose selection...
getGroupName()
Under which header this special page is listed in Special:SpecialPages See messages 'specialpages-gro...
string $mPrefix
The prefix url parameter.
null string $profile
Current search profile.
load()
Set up basic search parameters from the request and user settings.
SearchEngineConfig $searchConfig
Search engine configurations.
getPrefix()
The prefix value send to Special:Search using the 'prefix' URI param It means that the user is willin...
saveNamespaces()
Save namespace preferences when we're supposed to.
getProfile()
Current search profile.
SearchEngine $searchEngine
Search engine.
isPowerSearch()
Return true if current search is a power (advanced) search.
getNamespaces()
Current namespaces.
powerSearchOptions()
Reconstruct the 'power search' options for links TODO: Instead of exposing this publicly,...
string $searchEngineType
Search engine type, if not default.
powerSearch(&$request)
Extract "power search" namespace settings from the request object, returning a list of index numbers ...
showGoogleSearch( $term)
Output a google search form if search is disabled.
array $extraParams
For links.
execute( $par)
Entry point.
setupPage( $term)
Sets up everything for the HTML output page including styles, javascript, page title,...
showCreateLink( $title, $num, $titleMatches, $textMatches)
Generic operation result class Has warning/error list, boolean status and arbitrary value.
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 document is intended to provide useful advice for parties seeking to redistribute MediaWiki to end users It s targeted particularly at maintainers for Linux since it s been observed that distribution packages of MediaWiki often break We ve consistently had to recommend that users seeking support use official tarballs instead of their distribution s and this often solves whatever problem the user is having It would be nice if this could such as
$data
Utility to generate mapping file used in mw.Title (phpCharToUpper.json)
do that in ParserLimitReportFormat instead use this to modify the parameters of the image all existing parser cache entries will be invalid To avoid you ll need to handle that somehow(e.g. with the RejectParserCacheValue hook) because MediaWiki won 't do it for you. & $defaults also a ContextSource after deleting those rows but within the same transaction you ll probably need to make sure the header is varied on $request
this hook is for auditing only or null if authentication failed before getting that far or null if we can t even determine that When $user is not it can be in the form of< username >< more info > e g for bot passwords intended to be added to log contexts Fields it might only if the login was with a bot password it is not rendered in wiki pages or galleries in category pages allow injecting custom HTML after the section Any uses of the hook need to handle escaping see BaseTemplate::getToolbox and BaseTemplate::makeListItem for details on the format of individual items inside of this array or by returning and letting standard HTTP rendering take place modifiable or by returning false and taking over the output $out
namespace and then decline to actually register it & $namespaces
whereas SearchGetNearMatch runs after $term
namespace and then decline to actually register it file or subcat img or subcat $title
static configuration should be added through ResourceLoaderGetConfigVars instead can be used to get the real title e g db for database replication lag or jobqueue for job queue size converted to pseudo seconds It is possible to add more fields and they will be returned to the user in the API response after the basic globals have been set but before ordinary actions take place or wrap services the preferred way to define a new service is the $wgServiceWiringFiles array $services
Allows to change the fields on the form that will be generated $name
null for the local wiki Added should default to null in handler for backwards compatibility add a value to it if you want to add a cookie that have to vary cache options can modify $query
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 noclasses just before the function returns a value If you return an< a > element with HTML attributes $attribs and contents $html will be returned If you return $ret will be returned and may include noclasses after processing after in associative array form before processing starts Return false to skip default processing and return $ret $linkRenderer
return true to allow those checks to and false if checking is done & $user
injection txt This is an overview of how MediaWiki makes use of dependency injection The design described here grew from the discussion of RFC T384 The term dependency this means that anything an object needs to operate should be injected from the the object itself should only know narrow no concrete implementation of the logic it relies on The requirement to inject everything typically results in an architecture that based on two main types of and essentially stateless service objects that use other service objects to operate on the value objects As of the beginning MediaWiki is only starting to use the DI approach Much of the code still relies on global state or direct resulting in a highly cyclical dependency which acts as the top level factory for services in MediaWiki which can be used to gain access to default instances of various services MediaWikiServices however also allows new services to be defined and default services to be redefined Services are defined or redefined by providing a callback the instantiator that will return a new instance of the service When it will create an instance of MediaWikiServices and populate it with the services defined in the files listed by thereby bootstrapping the DI framework Per $wgServiceWiringFiles lists includes ServiceWiring php
The wiki should then use memcached to cache various data To use multiple just add more items to the array To increase the weight of a make its entry a array("192.168.0.1:11211", 2))
MediaWiki has optional support for a high distributed memory object caching system For general information on but for a larger site with heavy load