93 parent::__construct(
'Search' );
94 $this->searchConfig = MediaWikiServices::getInstance()->getSearchEngineConfig();
107 $term = str_replace(
"\n",
" ",
$request->getText(
'search' ) );
113 if ( strlen( $par ) && !strlen(
$term ) ) {
118 $query[
'search'] = str_replace(
'_',
' ', $par );
127 if ( !is_null(
$request->getVal(
'nsRemember' ) ) ) {
138 $this->searchEngineType =
$request->getVal(
'srbackend' );
141 $request->getVal(
'offset' ) ===
null
144 if ( $url !==
null ) {
146 $out->redirect( $url );
152 if ( !is_null(
$title ) ) {
153 Hooks::run(
'SpecialSearchNogomatch', [ &
$title ] );
159 if ( $this->
getConfig()->
get(
'DisableTextSearch' ) ) {
160 $searchForwardUrl = $this->
getConfig()->get(
'SearchForwardUrl' );
161 if ( $searchForwardUrl ) {
162 $url = str_replace(
'$1', urlencode(
$term ), $searchForwardUrl );
163 $out->redirect( $url );
168 $this->
msg(
'search-external' )->escaped() .
170 "<p class='mw-searchdisabled'>" .
171 $this->
msg(
'searchdisabled' )->escaped() .
173 $this->
msg(
'googlesearch' )->rawParams(
174 htmlspecialchars(
$term ),
176 $this->
msg(
'searchbutton' )->escaped()
195 list( $this->limit, $this->offset ) =
$request->getLimitOffset( 20,
'' );
196 $this->mPrefix =
$request->getVal(
'prefix',
'' );
200 # Extract manually requested namespaces
202 if ( !count( $nslist ) ) {
203 # Fallback to user preference
204 $nslist = $this->searchConfig->userNamespaces(
$user );
208 if ( !count( $nslist ) ) {
217 foreach ( $profiles
as $key => $data ) {
218 if ( $nslist === $data[
'namespaces'] && $key !==
'advanced' ) {
223 } elseif (
$profile ===
'advanced' ) {
226 if ( isset( $profiles[
$profile][
'namespaces'] ) ) {
227 $this->
namespaces = $profiles[$profile][
'namespaces'];
230 $profile =
'default';
231 $this->
namespaces = $profiles[
'default'][
'namespaces'];
235 $this->fulltext =
$request->getVal(
'fulltext' );
236 $this->runSuggestion = (bool)
$request->getVal(
'runsuggestion',
true );
247 # If the string cannot be used to create a title
248 if ( is_null( Title::newFromText(
$term ) ) ) {
251 # If there's an exact or very near match, jump right there.
254 if ( is_null(
$title ) ) {
258 if ( !Hooks::run(
'SpecialSearchGoResult', [
$term,
$title, &$url ] ) ) {
262 return $url ===
null ?
$title->getFullUrlForRedirect() : $url;
271 if ( $this->searchEngineType !==
null ) {
272 $this->
setExtraParam(
'srbackend', $this->searchEngineType );
282 if ( trim(
$term ) ===
'' || $filePrefix === trim(
$term ) ) {
284 if ( !Hooks::run(
'SpecialSearchResultsPrepend', [ $this,
$out,
$term ] ) ) {
285 # Hook requested termination
292 $out->addHTML( $formWidget->render(
293 $this->profile,
$term, 0, 0, $this->offset, $this->isPowerSearch()
299 $search->setFeatureData(
'rewrite', $this->runSuggestion );
300 $search->setLimitOffset( $this->limit, $this->offset );
302 $search->prefix = $this->mPrefix;
303 $term = $search->transformSearchTerm(
$term );
305 Hooks::run(
'SpecialSearchSetupEngine', [ $this, $this->profile, $search ] );
306 if ( !Hooks::run(
'SpecialSearchResultsPrepend', [ $this,
$out,
$term ] ) ) {
307 # Hook requested termination
312 $showSuggestion =
$title ===
null || !
$title->isKnown();
313 $search->setShowSuggestion( $showSuggestion );
316 $rewritten = $search->replacePrefixes(
$term );
318 $titleMatches = $search->searchTitle( $rewritten );
319 $textMatches = $search->searchText( $rewritten );
322 if ( $textMatches instanceof
Status ) {
323 $textStatus = $textMatches;
324 $textMatches = $textStatus->getValue();
328 $titleMatchesNum = $textMatchesNum = $numTitleMatches = $numTextMatches = 0;
329 if ( $titleMatches ) {
330 $titleMatchesNum = $titleMatches->numRows();
331 $numTitleMatches = $titleMatches->getTotalHits();
333 if ( $textMatches ) {
334 $textMatchesNum = $textMatches->numRows();
335 $numTextMatches = $textMatches->getTotalHits();
336 if ( $textMatchesNum > 0 ) {
337 $search->augmentSearchResults( $textMatches );
340 $num = $titleMatchesNum + $textMatchesNum;
341 $totalRes = $numTitleMatches + $numTextMatches;
345 $out->addHTML( $formWidget->render(
346 $this->profile,
$term, $num, $totalRes, $this->offset, $this->isPowerSearch()
350 if ( $textMatches ) {
352 $out->addHTML( $dymWidget->render(
$term, $textMatches ) );
355 $hasErrors = $textStatus && $textStatus->getErrors() !== [];
356 $hasOtherResults = $textMatches &&
357 $textMatches->hasInterwikiResults( SearchResultSet::INLINE_RESULTS );
359 if ( $textMatches && $textMatches->hasInterwikiResults( SearchResultSet::SECONDARY_RESULTS ) ) {
360 $out->addHTML(
'<div class="searchresults mw-searchresults-has-iw">' );
362 $out->addHTML(
'<div class="searchresults">' );
366 list( $error, $warning ) = $textStatus->splitByErrorType();
367 if ( $error->getErrors() ) {
368 $out->addHTML( Html::rawElement(
370 [
'class' =>
'errorbox' ],
371 $error->getHTML(
'search-error' )
374 if ( $warning->getErrors() ) {
375 $out->addHTML( Html::rawElement(
377 [
'class' =>
'warningbox' ],
378 $warning->getHTML(
'search-warning' )
386 Hooks::run(
'SpecialSearchResults', [
$term, &$titleMatches, &$textMatches ] );
390 $out->wrapWikiMsg(
"<p class=\"mw-search-nonefound\">\n$1</p>", [
391 $hasOtherResults ?
'search-nonefound-thiswiki' :
'search-nonefound',
401 if ( $search->getFeatureData(
'enable-new-crossproject-page' ) ) {
405 $sidebarResultWidget,
407 MediaWikiServices::getInstance()->getInterwikiLookup(),
408 $search->getFeatureData(
'show-multimedia-search-results' )
414 $sidebarResultWidget,
416 MediaWikiServices::getInstance()->getInterwikiLookup()
422 $out->addHTML( $widget->render(
423 $term, $this->offset, $titleMatches, $textMatches
426 if ( $titleMatches ) {
427 $titleMatches->free();
430 if ( $textMatches ) {
431 $textMatches->free();
434 $out->addHTML(
'<div class="mw-search-visualclear"></div>' );
437 if ( $totalRes > $this->limit || $this->offset ) {
440 if ( $textMatches && $textMatches->getOffset() !==
null ) {
441 $offset = $textMatches->getOffset();
443 $offset = $this->offset;
451 $this->limit + $this->offset >= $totalRes
453 $out->addHTML(
"<p class='mw-search-pager-bottom'>{$prevnext}</p>\n" );
457 $out->addHTML(
"</div>" );
459 Hooks::run(
'SpecialSearchResultsAppend', [ $this,
$out,
$term ] );
473 || ( $titleMatches !==
null && $titleMatches->searchContainedSyntax() )
474 || ( $textMatches !==
null && $textMatches->searchContainedSyntax() )
478 $this->
getOutput()->addHTML(
'<p></p>' );
483 $messageName =
'searchmenu-new-nocreate';
484 $linkClass =
'mw-search-createlink';
486 if ( !
$title->isExternal() ) {
487 if (
$title->isKnown() ) {
488 $messageName =
'searchmenu-exists';
489 $linkClass =
'mw-search-exists';
491 &&
$title->quickUserCan(
'create', $this->getUser() )
493 $messageName =
'searchmenu-new';
500 Message::numParam( $num )
502 Hooks::run(
'SpecialSearchCreateLink', [
$title, &
$params ] );
505 if ( $messageName ) {
506 $this->
getOutput()->wrapWikiMsg(
"<p class=\"$linkClass\">\n$1</p>",
$params );
509 $this->
getOutput()->addHTML(
'<p></p>' );
526 $out->allowClickjacking();
529 if ( strval(
$term ) !==
'' ) {
530 $out->setPageTitle( $this->
msg(
'searchresults' ) );
531 $out->setHTMLTitle( $this->
msg(
'pagetitle' )
532 ->rawParams( $this->
msg(
'searchresults-title' )->rawParams(
$term )->
text() )
533 ->inContentLanguage()->
text()
537 $out->addJsConfigVars( [
'searchTerm' =>
$term ] );
538 $out->addModules(
'mediawiki.special.search' );
539 $out->addModuleStyles( [
540 'mediawiki.special',
'mediawiki.special.search.styles',
'mediawiki.ui',
'mediawiki.ui.button',
541 'mediawiki.ui.input',
'mediawiki.widgets.SearchInputWidget.styles',
551 return $this->profile ===
'advanced';
563 foreach ( $this->searchConfig->searchableNamespaces()
as $ns =>
$name ) {
564 if (
$request->getCheck(
'ns' . $ns ) ) {
586 $opt[
'profile'] = $this->profile;
589 return $opt + $this->extraParams;
601 if (
$user->isLoggedIn() &&
602 $user->matchEditToken(
610 foreach ( MWNamespace::getValidNamespaces()
as $n ) {
611 $user->setOption(
'searchNs' . $n,
false );
616 $user->setOption(
'searchNs' . $n,
true );
619 DeferredUpdates::addCallableUpdate(
function ()
use (
$user ) {
620 $user->saveSettings();
634 $nsAllSet = array_keys( $this->searchConfig->searchableNamespaces() );
635 $defaultNs = $this->searchConfig->defaultNamespaces();
638 'message' =>
'searchprofile-articles',
639 'tooltip' =>
'searchprofile-articles-tooltip',
640 'namespaces' => $defaultNs,
641 'namespace-messages' => $this->searchConfig->namespacesAsText(
646 'message' =>
'searchprofile-images',
647 'tooltip' =>
'searchprofile-images-tooltip',
651 'message' =>
'searchprofile-everything',
652 'tooltip' =>
'searchprofile-everything-tooltip',
653 'namespaces' => $nsAllSet,
656 'message' =>
'searchprofile-advanced',
657 'tooltip' =>
'searchprofile-advanced-tooltip',
658 'namespaces' => self::NAMESPACES_CURRENT,
662 Hooks::run(
'SpecialSearchProfiles', [ &$profiles ] );
664 foreach ( $profiles
as &$data ) {
665 if ( !is_array( $data[
'namespaces'] ) ) {
668 sort( $data[
'namespaces'] );
680 if ( $this->searchEngine ===
null ) {
681 $this->searchEngine = $this->searchEngineType ?
682 MediaWikiServices::getInstance()->getSearchEngineFactory()->create( $this->searchEngineType ) :
683 MediaWikiServices::getInstance()->newSearchEngine();
686 return $this->searchEngine;
694 return $this->profile;
715 $this->extraParams[$key] =
$value;
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
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,...
static getForTitle(Title $title)
Returns the appropriate ContentHandler singleton for the given title.
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.
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.
getLanguage()
Shortcut to get user's language.
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.
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 ...
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 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
when a variable name is used in a it is silently declared as a new local masking the global
design txt This is a brief overview of the new design More thorough and up to date information is available on the documentation wiki at etc Handles the details of getting and saving to the user table of the and dealing with sessions and cookies OutputPage Encapsulates the entire HTML page that will be sent in response to any server request It is used by calling its functions to add text
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
external whereas SearchGetNearMatch runs after $term
the array() calling protocol came about after MediaWiki 1.4rc1.
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
namespace and then decline to actually register it & $namespaces
namespace and then decline to actually register it file or subcat img or subcat $title
this hook is for auditing only or null if authentication failed before getting that far or null if we can t even determine that probably a stub 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
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
please add to it if you re going to add events to the MediaWiki code where normally authentication against an external auth plugin would be creating a local account $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
MediaWiki has optional support for a high distributed memory object caching system For general information on but for a larger site with heavy load