MediaWiki  master
SpecialSearch.php
Go to the documentation of this file.
1 <?php
33 
38 class SpecialSearch extends SpecialPage {
47  protected $profile;
48 
50  protected $searchEngine;
51 
53  protected $searchEngineType;
54 
56  protected $extraParams = [];
57 
62  protected $mPrefix;
63 
67  protected $limit, $offset;
68 
72  protected $namespaces;
73 
77  protected $fulltext;
78 
82  protected $sort;
83 
87  protected $runSuggestion = true;
88 
93  protected $searchConfig;
94 
95  const NAMESPACES_CURRENT = 'sense';
96 
97  public function __construct() {
98  parent::__construct( 'Search' );
99  $this->searchConfig = MediaWikiServices::getInstance()->getSearchEngineConfig();
100  }
101 
107  public function execute( $par ) {
108  $request = $this->getRequest();
109  $out = $this->getOutput();
110 
111  // Fetch the search term
112  $term = str_replace( "\n", " ", $request->getText( 'search' ) );
113 
114  // Historically search terms have been accepted not only in the search query
115  // parameter, but also as part of the primary url. This can have PII implications
116  // in releasing page view data. As such issue a 301 redirect to the correct
117  // URL.
118  if ( $par !== null && $par !== '' && $term === '' ) {
119  $query = $request->getValues();
120  unset( $query['title'] );
121  // Strip underscores from title parameter; most of the time we'll want
122  // text form here. But don't strip underscores from actual text params!
123  $query['search'] = str_replace( '_', ' ', $par );
124  $out->redirect( $this->getPageTitle()->getFullURL( $query ), 301 );
125  return;
126  }
127 
128  // Need to load selected namespaces before handling nsRemember
129  $this->load();
130  // TODO: This performs database actions on GET request, which is going to
131  // be a problem for our multi-datacenter work.
132  if ( $request->getCheck( 'nsRemember' ) ) {
133  $this->saveNamespaces();
134  // Remove the token from the URL to prevent the user from inadvertently
135  // exposing it (e.g. by pasting it into a public wiki page) or undoing
136  // later settings changes (e.g. by reloading the page).
137  $query = $request->getValues();
138  unset( $query['title'], $query['nsRemember'] );
139  $out->redirect( $this->getPageTitle()->getFullURL( $query ) );
140  return;
141  }
142 
143  $this->searchEngineType = $request->getVal( 'srbackend' );
144  if ( !$request->getVal( 'fulltext' ) && !$request->getCheck( 'offset' ) ) {
145  $url = $this->goResult( $term );
146  if ( $url !== null ) {
147  // successful 'go'
148  $out->redirect( $url );
149  return;
150  }
151  // No match. If it could plausibly be a title
152  // run the No go match hook.
154  if ( !is_null( $title ) ) {
155  Hooks::run( 'SpecialSearchNogomatch', [ &$title ] );
156  }
157  }
158 
159  $this->setupPage( $term );
160 
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 );
166  } else {
167  $this->showGoogleSearch( $term );
168  }
169 
170  return;
171  }
172 
173  $this->showResults( $term );
174  }
175 
183  private function showGoogleSearch( $term ) {
184  $this->getOutput()->addHTML(
185  "<fieldset>" .
186  "<legend>" .
187  $this->msg( 'search-external' )->escaped() .
188  "</legend>" .
189  "<p class='mw-searchdisabled'>" .
190  $this->msg( 'searchdisabled' )->escaped() .
191  "</p>" .
192  $this->msg( 'googlesearch' )->rawParams(
193  htmlspecialchars( $term ),
194  'UTF-8',
195  $this->msg( 'searchbutton' )->escaped()
196  )->text() .
197  "</fieldset>"
198  );
199  }
200 
206  public function load() {
207  $request = $this->getRequest();
208  list( $this->limit, $this->offset ) = $request->getLimitOffset( 20, '' );
209  $this->mPrefix = $request->getVal( 'prefix', '' );
210  if ( $this->mPrefix !== '' ) {
211  $this->setExtraParam( 'prefix', $this->mPrefix );
212  }
213 
214  $this->sort = $request->getVal( 'sort', SearchEngine::DEFAULT_SORT );
215  if ( $this->sort !== SearchEngine::DEFAULT_SORT ) {
216  $this->setExtraParam( 'sort', $this->sort );
217  }
218 
219  $user = $this->getUser();
220 
221  # Extract manually requested namespaces
222  $nslist = $this->powerSearch( $request );
223  if ( $nslist === [] ) {
224  # Fallback to user preference
225  $nslist = $this->searchConfig->userNamespaces( $user );
226  }
227 
228  $profile = null;
229  if ( $nslist === [] ) {
230  $profile = 'default';
231  }
232 
233  $profile = $request->getVal( 'profile', $profile );
234  $profiles = $this->getSearchProfiles();
235  if ( $profile === null ) {
236  // BC with old request format
237  $profile = 'advanced';
238  foreach ( $profiles as $key => $data ) {
239  if ( $nslist === $data['namespaces'] && $key !== 'advanced' ) {
240  $profile = $key;
241  }
242  }
243  $this->namespaces = $nslist;
244  } elseif ( $profile === 'advanced' ) {
245  $this->namespaces = $nslist;
246  } elseif ( isset( $profiles[$profile]['namespaces'] ) ) {
247  $this->namespaces = $profiles[$profile]['namespaces'];
248  } else {
249  // Unknown profile requested
250  $profile = 'default';
251  $this->namespaces = $profiles['default']['namespaces'];
252  }
253 
254  $this->fulltext = $request->getVal( 'fulltext' );
255  $this->runSuggestion = (bool)$request->getVal( 'runsuggestion', true );
256  $this->profile = $profile;
257  }
258 
265  public function goResult( $term ) {
266  # If the string cannot be used to create a title
267  if ( is_null( Title::newFromText( $term ) ) ) {
268  return null;
269  }
270  # If there's an exact or very near match, jump right there.
271  $title = $this->getSearchEngine()
272  ->getNearMatcher( $this->getConfig() )->getNearMatch( $term );
273  if ( is_null( $title ) ) {
274  return null;
275  }
276  $url = null;
277  if ( !Hooks::run( 'SpecialSearchGoResult', [ $term, $title, &$url ] ) ) {
278  return null;
279  }
280 
281  return $url ?? $title->getFullUrlForRedirect();
282  }
283 
287  public function showResults( $term ) {
288  if ( $this->searchEngineType !== null ) {
289  $this->setExtraParam( 'srbackend', $this->searchEngineType );
290  }
291 
292  $out = $this->getOutput();
294  $this,
295  $this->searchConfig,
296  $this->getSearchProfiles()
297  );
298  $filePrefix = MediaWikiServices::getInstance()->getContentLanguage()->
299  getFormattedNsText( NS_FILE ) . ':';
300  if ( trim( $term ) === '' || $filePrefix === trim( $term ) ) {
301  // Empty query -- straight view of search form
302  if ( !Hooks::run( 'SpecialSearchResultsPrepend', [ $this, $out, $term ] ) ) {
303  # Hook requested termination
304  return;
305  }
306  $out->enableOOUI();
307  // The form also contains the 'Showing results 0 - 20 of 1234' so we can
308  // only do the form render here for the empty $term case. Rendering
309  // the form when a search is provided is repeated below.
310  $out->addHTML( $formWidget->render(
311  $this->profile, $term, 0, 0, $this->offset, $this->isPowerSearch()
312  ) );
313  return;
314  }
315 
316  $search = $this->getSearchEngine();
317  $search->setFeatureData( 'rewrite', $this->runSuggestion );
318  $search->setLimitOffset( $this->limit, $this->offset );
319  $search->setNamespaces( $this->namespaces );
320  $search->setSort( $this->sort );
321  $search->prefix = $this->mPrefix;
322 
323  Hooks::run( 'SpecialSearchSetupEngine', [ $this, $this->profile, $search ] );
324  if ( !Hooks::run( 'SpecialSearchResultsPrepend', [ $this, $out, $term ] ) ) {
325  # Hook requested termination
326  return;
327  }
328 
330  $showSuggestion = $title === null || !$title->isKnown();
331  $search->setShowSuggestion( $showSuggestion );
332 
333  $rewritten = $search->transformSearchTerm( $term );
334  if ( $rewritten !== $term ) {
335  $term = $rewritten;
336  wfDeprecated( 'SearchEngine::transformSearchTerm() (overridden by ' .
337  get_class( $search ) . ')', '1.32' );
338  }
339 
340  $rewritten = $search->replacePrefixes( $term );
341  if ( $rewritten !== $term ) {
342  wfDeprecated( 'SearchEngine::replacePrefixes() (overridden by ' .
343  get_class( $search ) . ')', '1.32' );
344  }
345 
346  // fetch search results
347  $titleMatches = $search->searchTitle( $rewritten );
348  $textMatches = $search->searchText( $rewritten );
349 
350  $textStatus = null;
351  if ( $textMatches instanceof Status ) {
352  $textStatus = $textMatches;
353  $textMatches = $textStatus->getValue();
354  }
355 
356  // Get number of results
357  $titleMatchesNum = $textMatchesNum = $numTitleMatches = $numTextMatches = 0;
358  if ( $titleMatches ) {
359  $titleMatchesNum = $titleMatches->numRows();
360  $numTitleMatches = $titleMatches->getTotalHits();
361  }
362  if ( $textMatches ) {
363  $textMatchesNum = $textMatches->numRows();
364  $numTextMatches = $textMatches->getTotalHits();
365  if ( $textMatchesNum > 0 ) {
366  $search->augmentSearchResults( $textMatches );
367  }
368  }
369  $num = $titleMatchesNum + $textMatchesNum;
370  $totalRes = $numTitleMatches + $numTextMatches;
371 
372  // start rendering the page
373  $out->enableOOUI();
374  $out->addHTML( $formWidget->render(
375  $this->profile, $term, $num, $totalRes, $this->offset, $this->isPowerSearch()
376  ) );
377 
378  // did you mean... suggestions
379  if ( $textMatches ) {
380  $dymWidget = new MediaWiki\Widget\Search\DidYouMeanWidget( $this );
381  $out->addHTML( $dymWidget->render( $term, $textMatches ) );
382  }
383 
384  $hasErrors = $textStatus && $textStatus->getErrors() !== [];
385  $hasOtherResults = $textMatches &&
386  $textMatches->hasInterwikiResults( SearchResultSet::INLINE_RESULTS );
387 
388  if ( $textMatches && $textMatches->hasInterwikiResults( SearchResultSet::SECONDARY_RESULTS ) ) {
389  $out->addHTML( '<div class="searchresults mw-searchresults-has-iw">' );
390  } else {
391  $out->addHTML( '<div class="searchresults">' );
392  }
393 
394  if ( $hasErrors ) {
395  list( $error, $warning ) = $textStatus->splitByErrorType();
396  if ( $error->getErrors() ) {
397  $out->addHTML( Html::errorBox(
398  $error->getHTML( 'search-error' )
399  ) );
400  }
401  if ( $warning->getErrors() ) {
402  $out->addHTML( Html::warningBox(
403  $warning->getHTML( 'search-warning' )
404  ) );
405  }
406  }
407 
408  // Show the create link ahead
409  $this->showCreateLink( $title, $num, $titleMatches, $textMatches );
410 
411  Hooks::run( 'SpecialSearchResults', [ $term, &$titleMatches, &$textMatches ] );
412 
413  // If we have no results and have not already displayed an error message
414  if ( $num === 0 && !$hasErrors ) {
415  $out->wrapWikiMsg( "<p class=\"mw-search-nonefound\">\n$1</p>", [
416  $hasOtherResults ? 'search-nonefound-thiswiki' : 'search-nonefound',
418  ] );
419  }
420 
421  // Although $num might be 0 there can still be secondary or inline
422  // results to display.
423  $linkRenderer = $this->getLinkRenderer();
424  $mainResultWidget = new FullSearchResultWidget( $this, $linkRenderer );
425 
426  // Default (null) on. Can be explicitly disabled.
427  if ( $search->getFeatureData( 'enable-new-crossproject-page' ) !== false ) {
428  $sidebarResultWidget = new InterwikiSearchResultWidget( $this, $linkRenderer );
429  $sidebarResultsWidget = new InterwikiSearchResultSetWidget(
430  $this,
431  $sidebarResultWidget,
433  MediaWikiServices::getInstance()->getInterwikiLookup(),
434  $search->getFeatureData( 'show-multimedia-search-results' )
435  );
436  } else {
437  $sidebarResultWidget = new SimpleSearchResultWidget( $this, $linkRenderer );
438  $sidebarResultsWidget = new SimpleSearchResultSetWidget(
439  $this,
440  $sidebarResultWidget,
442  MediaWikiServices::getInstance()->getInterwikiLookup()
443  );
444  }
445 
446  $widget = new BasicSearchResultSetWidget( $this, $mainResultWidget, $sidebarResultsWidget );
447 
448  $out->addHTML( $widget->render(
449  $term, $this->offset, $titleMatches, $textMatches
450  ) );
451 
452  if ( $titleMatches ) {
453  $titleMatches->free();
454  }
455 
456  if ( $textMatches ) {
457  $textMatches->free();
458  }
459 
460  $out->addHTML( '<div class="mw-search-visualclear"></div>' );
461 
462  // prev/next links
463  if ( $totalRes > $this->limit || $this->offset ) {
464  // Allow matches to define the correct offset, as interleaved
465  // AB testing may require a different next page offset.
466  if ( $textMatches && $textMatches->getOffset() !== null ) {
467  $offset = $textMatches->getOffset();
468  } else {
469  $offset = $this->offset;
470  }
471 
472  $prevnext = $this->buildPrevNextNavigation(
473  $offset,
474  $this->limit,
475  $this->powerSearchOptions() + [ 'search' => $term ],
476  $this->limit + $this->offset >= $totalRes
477  );
478  $out->addHTML( "<p class='mw-search-pager-bottom'>{$prevnext}</p>\n" );
479  }
480 
481  // Close <div class='searchresults'>
482  $out->addHTML( "</div>" );
483 
484  Hooks::run( 'SpecialSearchResultsAppend', [ $this, $out, $term ] );
485  }
486 
493  protected function showCreateLink( $title, $num, $titleMatches, $textMatches ) {
494  // show direct page/create link if applicable
495 
496  // Check DBkey !== '' in case of fragment link only.
497  if ( is_null( $title ) || $title->getDBkey() === ''
498  || ( $titleMatches !== null && $titleMatches->searchContainedSyntax() )
499  || ( $textMatches !== null && $textMatches->searchContainedSyntax() )
500  ) {
501  // invalid title
502  // preserve the paragraph for margins etc...
503  $this->getOutput()->addHTML( '<p></p>' );
504 
505  return;
506  }
507 
508  $messageName = 'searchmenu-new-nocreate';
509  $linkClass = 'mw-search-createlink';
510 
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() )
517  ) {
518  $messageName = 'searchmenu-new';
519  }
520  }
521 
522  $params = [
523  $messageName,
524  wfEscapeWikiText( $title->getPrefixedText() ),
525  Message::numParam( $num )
526  ];
527  Hooks::run( 'SpecialSearchCreateLink', [ $title, &$params ] );
528 
529  // Extensions using the hook might still return an empty $messageName
530  if ( $messageName ) {
531  $this->getOutput()->wrapWikiMsg( "<p class=\"$linkClass\">\n$1</p>", $params );
532  } else {
533  // preserve the paragraph for margins etc...
534  $this->getOutput()->addHTML( '<p></p>' );
535  }
536  }
537 
544  protected function setupPage( $term ) {
545  $out = $this->getOutput();
546 
547  $this->setHeaders();
548  $this->outputHeader();
549  // TODO: Is this true? The namespace remember uses a user token
550  // on save.
551  $out->allowClickjacking();
552  $this->addHelpLink( 'Help:Searching' );
553 
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()
559  );
560  }
561 
562  if ( $this->mPrefix !== '' ) {
563  $subtitle = $this->msg( 'search-filter-title-prefix' )->plaintextParams( $this->mPrefix );
564  $params = $this->powerSearchOptions();
565  unset( $params['prefix'] );
566  $params += [
567  'search' => $term,
568  'fulltext' => 1,
569  ];
570 
571  $subtitle .= ' (';
572  $subtitle .= Xml::element(
573  'a',
574  [
575  'href' => $this->getPageTitle()->getLocalURL( $params ),
576  'title' => $this->msg( 'search-filter-title-prefix-reset' )->text(),
577  ],
578  $this->msg( 'search-filter-title-prefix-reset' )->text()
579  );
580  $subtitle .= ')';
581  $out->setSubtitle( $subtitle );
582  }
583 
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',
589  ] );
590  }
591 
597  protected function isPowerSearch() {
598  return $this->profile === 'advanced';
599  }
600 
608  protected function powerSearch( &$request ) {
609  $arr = [];
610  foreach ( $this->searchConfig->searchableNamespaces() as $ns => $name ) {
611  if ( $request->getCheck( 'ns' . $ns ) ) {
612  $arr[] = $ns;
613  }
614  }
615 
616  return $arr;
617  }
618 
626  public function powerSearchOptions() {
627  $opt = [];
628  if ( $this->isPowerSearch() ) {
629  foreach ( $this->namespaces as $n ) {
630  $opt['ns' . $n] = 1;
631  }
632  } else {
633  $opt['profile'] = $this->profile;
634  }
635 
636  return $opt + $this->extraParams;
637  }
638 
644  protected function saveNamespaces() {
645  $user = $this->getUser();
646  $request = $this->getRequest();
647 
648  if ( $user->isLoggedIn() &&
649  $user->matchEditToken(
650  $request->getVal( 'nsRemember' ),
651  'searchnamespace',
652  $request
653  ) && !wfReadOnly()
654  ) {
655  // Reset namespace preferences: namespaces are not searched
656  // when they're not mentioned in the URL parameters.
657  foreach ( MWNamespace::getValidNamespaces() as $n ) {
658  $user->setOption( 'searchNs' . $n, false );
659  }
660  // The request parameters include all the namespaces to be searched.
661  // Even if they're the same as an existing profile, they're not eaten.
662  foreach ( $this->namespaces as $n ) {
663  $user->setOption( 'searchNs' . $n, true );
664  }
665 
666  DeferredUpdates::addCallableUpdate( function () use ( $user ) {
667  $user->saveSettings();
668  } );
669 
670  return true;
671  }
672 
673  return false;
674  }
675 
679  protected function getSearchProfiles() {
680  // Builds list of Search Types (profiles)
681  $nsAllSet = array_keys( $this->searchConfig->searchableNamespaces() );
682  $defaultNs = $this->searchConfig->defaultNamespaces();
683  $profiles = [
684  'default' => [
685  'message' => 'searchprofile-articles',
686  'tooltip' => 'searchprofile-articles-tooltip',
687  'namespaces' => $defaultNs,
688  'namespace-messages' => $this->searchConfig->namespacesAsText(
689  $defaultNs
690  ),
691  ],
692  'images' => [
693  'message' => 'searchprofile-images',
694  'tooltip' => 'searchprofile-images-tooltip',
695  'namespaces' => [ NS_FILE ],
696  ],
697  'all' => [
698  'message' => 'searchprofile-everything',
699  'tooltip' => 'searchprofile-everything-tooltip',
700  'namespaces' => $nsAllSet,
701  ],
702  'advanced' => [
703  'message' => 'searchprofile-advanced',
704  'tooltip' => 'searchprofile-advanced-tooltip',
705  'namespaces' => self::NAMESPACES_CURRENT,
706  ]
707  ];
708 
709  Hooks::run( 'SpecialSearchProfiles', [ &$profiles ] );
710 
711  foreach ( $profiles as &$data ) {
712  if ( !is_array( $data['namespaces'] ) ) {
713  continue;
714  }
715  sort( $data['namespaces'] );
716  }
717 
718  return $profiles;
719  }
720 
726  public function getSearchEngine() {
727  if ( $this->searchEngine === null ) {
728  $services = MediaWikiServices::getInstance();
729  $this->searchEngine = $this->searchEngineType ?
730  $services->getSearchEngineFactory()->create( $this->searchEngineType ) :
731  $services->newSearchEngine();
732  }
733 
734  return $this->searchEngine;
735  }
736 
741  function getProfile() {
742  return $this->profile;
743  }
744 
749  function getNamespaces() {
750  return $this->namespaces;
751  }
752 
762  public function setExtraParam( $key, $value ) {
763  $this->extraParams[$key] = $value;
764  }
765 
774  public function getPrefix() {
775  return $this->mPrefix;
776  }
777 
778  protected function getGroupName() {
779  return 'pages';
780  }
781 }
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
Definition: deferred.txt:11
Renders one or more SearchResultSets into a sidebar grouped by interwiki prefix.
wfEscapeWikiText( $text)
Escapes the given text so that it may be output using addWikiText() without any linking, formatting, etc.
setupPage( $term)
Sets up everything for the HTML output page including styles, javascript, page title, etc.
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
Definition: hooks.txt:1585
$data
Utility to generate mapping file used in mw.Title (phpCharToUpper.json)
whereas SearchGetNearMatch runs after $term
Definition: hooks.txt:2875
SearchEngineConfig $searchConfig
Search engine configurations.
to move a page</td >< td > &*You are moving the page across namespaces
processing should stop and the error should be shown to the user * false
Definition: hooks.txt:187
Apache License January AND DISTRIBUTION Definitions License shall mean the terms and conditions for use
getNamespaces()
Current namespaces.
string $searchEngineType
Search engine type, if not default.
static warningBox( $html)
Return a warning box.
Definition: Html.php:725
$value
addHelpLink( $to, $overrideBaseUrl=false)
Adds help link with an icon via page indicators.
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 MediaWikiServices
Definition: injection.txt:23
saveNamespaces()
Save namespace preferences when we&#39;re supposed to.
getOutput()
Get the OutputPage being used for this instance.
static numParam( $num)
Definition: Message.php:1049
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
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
Definition: hooks.txt:780
Renders one or more SearchResultSets into a sidebar grouped by interwiki prefix.
buildPrevNextNavigation( $offset, $limit, array $query=[], $atend=false, $subpage=false)
Generate (prev x| next x) (20|50|100...) type links for paging.
static addCallableUpdate( $callable, $stage=self::POSTSEND, $dbw=null)
Add a callable update.
isPowerSearch()
Return true if current search is a power (advanced) search.
Renders a &#39;full&#39; multi-line search result with metadata.
getProfile()
Current search profile.
wfReadOnly()
Check whether the wiki is in read-only mode.
array $extraParams
For links.
const NAMESPACES_CURRENT
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
Definition: hooks.txt:2217
goResult( $term)
If an exact title match can be found, jump straight ahead to it.
showResults( $term)
const SECONDARY_RESULTS
Identifier for interwiki results that are displayed only together with existing main wiki results...
load()
Set up basic search parameters from the request and user settings.
$params
string $mPrefix
The prefix url parameter.
showGoogleSearch( $term)
Output a google search form if search is disabled.
setHeaders()
Sets headers - this should be called from the execute() method of all derived classes! ...
const DEFAULT_SORT
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 null
Definition: hooks.txt:780
namespace and then decline to actually register it file or subcat img or subcat $title
Definition: hooks.txt:925
const NS_FILE
Definition: Defines.php:70
static getForTitle(Title $title)
Returns the appropriate ContentHandler singleton for the given title.
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
Definition: distributors.txt:9
powerSearchOptions()
Reconstruct the &#39;power search&#39; options for links TODO: Instead of exposing this publicly, could we instead expose a function for creating search links?
static errorBox( $html, $heading='')
Return an error box.
Definition: Html.php:736
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
Definition: injection.txt:35
setExtraParam( $key, $value)
Users of hook SpecialSearchSetupEngine can use this to add more params to links to not lose selection...
getUser()
Shortcut to get the User executing this instance.
wfDeprecated( $function, $version=false, $component=false, $callerOffset=2)
Throws a warning that $function is deprecated.
getConfig()
Shortcut to get main config object.
static element( $element, $attribs=null, $contents='', $allowShortTag=true)
Format an XML element with given attributes and, optionally, text content.
Definition: Xml.php:41
getPrefix()
The prefix value send to Special:Search using the &#39;prefix&#39; URI param It means that the user is willin...
msg( $key)
Wrapper around wfMessage that sets the current context.
null string $profile
Current search profile.
Allows to change the fields on the form that will be generated $name
Definition: hooks.txt:271
getRequest()
Get the WebRequest being used for this instance.
SearchEngine $searchEngine
Search engine.
execute( $par)
Entry point.
static getValidNamespaces()
Returns an array of the namespaces (by integer id) that exist on the wiki.
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
Definition: hooks.txt:2633
Renders a suggested search for the user, or tells the user a suggested search was run instead of the ...
outputHeader( $summaryMessageKey='')
Outputs a summary message on top of special pages Per default the message key is the canonical name o...
getPageTitle( $subpage=false)
Get a self-referential title object.
return true to allow those checks to and false if checking is done & $user
Definition: hooks.txt:1473
const INLINE_RESULTS
Identifier for interwiki results that can be displayed even if no existing main wiki results exist...
powerSearch(&$request)
Extract "power search" namespace settings from the request object, returning a list of index numbers ...
static run( $event, array $args=[], $deprecatedVersion=null)
Call hook functions defined in Hooks::register and $wgHooks.
Definition: Hooks.php:200
showCreateLink( $title, $num, $titleMatches, $textMatches)
MediaWiki Linker LinkRenderer null $linkRenderer
Definition: SpecialPage.php:66
static newFromText( $text, $defaultNamespace=NS_MAIN)
Create a new Title from text, such as what one would find in a link.
Definition: Title.php:319