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 
83 
87  protected $runSuggestion = true;
88 
93  protected $searchConfig;
94 
99  private $loadStatus;
100 
101  const NAMESPACES_CURRENT = 'sense';
102 
103  public function __construct() {
104  parent::__construct( 'Search' );
105  $this->searchConfig = MediaWikiServices::getInstance()->getSearchEngineConfig();
106  }
107 
113  public function execute( $par ) {
114  $request = $this->getRequest();
115  $out = $this->getOutput();
116 
117  // Fetch the search term
118  $term = str_replace( "\n", " ", $request->getText( 'search' ) );
119 
120  // Historically search terms have been accepted not only in the search query
121  // parameter, but also as part of the primary url. This can have PII implications
122  // in releasing page view data. As such issue a 301 redirect to the correct
123  // URL.
124  if ( $par !== null && $par !== '' && $term === '' ) {
125  $query = $request->getValues();
126  unset( $query['title'] );
127  // Strip underscores from title parameter; most of the time we'll want
128  // text form here. But don't strip underscores from actual text params!
129  $query['search'] = str_replace( '_', ' ', $par );
130  $out->redirect( $this->getPageTitle()->getFullURL( $query ), 301 );
131  return;
132  }
133 
134  // Need to load selected namespaces before handling nsRemember
135  $this->load();
136  // TODO: This performs database actions on GET request, which is going to
137  // be a problem for our multi-datacenter work.
138  if ( $request->getCheck( 'nsRemember' ) ) {
139  $this->saveNamespaces();
140  // Remove the token from the URL to prevent the user from inadvertently
141  // exposing it (e.g. by pasting it into a public wiki page) or undoing
142  // later settings changes (e.g. by reloading the page).
143  $query = $request->getValues();
144  unset( $query['title'], $query['nsRemember'] );
145  $out->redirect( $this->getPageTitle()->getFullURL( $query ) );
146  return;
147  }
148 
149  $this->searchEngineType = $request->getVal( 'srbackend' );
150  if ( !$request->getVal( 'fulltext' ) && !$request->getCheck( 'offset' ) ) {
151  $url = $this->goResult( $term );
152  if ( $url !== null ) {
153  // successful 'go'
154  $out->redirect( $url );
155  return;
156  }
157  // No match. If it could plausibly be a title
158  // run the No go match hook.
159  $title = Title::newFromText( $term );
160  if ( $title !== null ) {
161  Hooks::run( 'SpecialSearchNogomatch', [ &$title ] );
162  }
163  }
164 
165  $this->setupPage( $term );
166 
167  if ( $this->getConfig()->get( 'DisableTextSearch' ) ) {
168  $searchForwardUrl = $this->getConfig()->get( 'SearchForwardUrl' );
169  if ( $searchForwardUrl ) {
170  $url = str_replace( '$1', urlencode( $term ), $searchForwardUrl );
171  $out->redirect( $url );
172  } else {
173  $this->showGoogleSearch( $term );
174  }
175 
176  return;
177  }
178 
179  $this->showResults( $term );
180  }
181 
189  private function showGoogleSearch( $term ) {
190  $this->getOutput()->addHTML(
191  "<fieldset>" .
192  "<legend>" .
193  $this->msg( 'search-external' )->escaped() .
194  "</legend>" .
195  "<p class='mw-searchdisabled'>" .
196  $this->msg( 'searchdisabled' )->escaped() .
197  "</p>" .
198  $this->msg( 'googlesearch' )->rawParams(
199  htmlspecialchars( $term ),
200  'UTF-8',
201  $this->msg( 'searchbutton' )->escaped()
202  )->text() .
203  "</fieldset>"
204  );
205  }
206 
212  public function load() {
213  $this->loadStatus = new Status();
214 
215  $request = $this->getRequest();
216  list( $this->limit, $this->offset ) = $request->getLimitOffset( 20, '' );
217  $this->mPrefix = $request->getVal( 'prefix', '' );
218  if ( $this->mPrefix !== '' ) {
219  $this->setExtraParam( 'prefix', $this->mPrefix );
220  }
221 
222  $sort = $request->getVal( 'sort', SearchEngine::DEFAULT_SORT );
223  $validSorts = $this->getSearchEngine()->getValidSorts();
224  if ( !in_array( $sort, $validSorts ) ) {
225  $this->loadStatus->warning( 'search-invalid-sort-order', $sort,
226  implode( ', ', $validSorts ) );
227  } elseif ( $sort !== $this->sort ) {
228  $this->sort = $sort;
229  $this->setExtraParam( 'sort', $this->sort );
230  }
231 
232  $user = $this->getUser();
233 
234  # Extract manually requested namespaces
235  $nslist = $this->powerSearch( $request );
236  if ( $nslist === [] ) {
237  # Fallback to user preference
238  $nslist = $this->searchConfig->userNamespaces( $user );
239  }
240 
241  $profile = null;
242  if ( $nslist === [] ) {
243  $profile = 'default';
244  }
245 
246  $profile = $request->getVal( 'profile', $profile );
247  $profiles = $this->getSearchProfiles();
248  if ( $profile === null ) {
249  // BC with old request format
250  $profile = 'advanced';
251  foreach ( $profiles as $key => $data ) {
252  if ( $nslist === $data['namespaces'] && $key !== 'advanced' ) {
253  $profile = $key;
254  }
255  }
256  $this->namespaces = $nslist;
257  } elseif ( $profile === 'advanced' ) {
258  $this->namespaces = $nslist;
259  } elseif ( isset( $profiles[$profile]['namespaces'] ) ) {
260  $this->namespaces = $profiles[$profile]['namespaces'];
261  } else {
262  // Unknown profile requested
263  $this->loadStatus->warning( 'search-unknown-profile', $profile );
264  $profile = 'default';
265  $this->namespaces = $profiles['default']['namespaces'];
266  }
267 
268  $this->fulltext = $request->getVal( 'fulltext' );
269  $this->runSuggestion = (bool)$request->getVal( 'runsuggestion', true );
270  $this->profile = $profile;
271  }
272 
279  public function goResult( $term ) {
280  # If the string cannot be used to create a title
281  if ( Title::newFromText( $term ) === null ) {
282  return null;
283  }
284  # If there's an exact or very near match, jump right there.
285  $title = $this->getSearchEngine()
286  ->getNearMatcher( $this->getConfig() )->getNearMatch( $term );
287  if ( $title === null ) {
288  return null;
289  }
290  $url = null;
291  if ( !Hooks::run( 'SpecialSearchGoResult', [ $term, $title, &$url ] ) ) {
292  return null;
293  }
294 
295  if (
296  // If there is a preference set to NOT redirect on exact page match
297  // then return null (which prevents direction)
298  !$this->redirectOnExactMatch()
299  // BUT ...
300  // ... ignore no-redirect preference if the exact page match is an interwiki link
301  && !$title->isExternal()
302  // ... ignore no-redirect preference if the exact page match is NOT in the main
303  // namespace AND there's a namespace in the search string
304  && !( $title->getNamespace() !== NS_MAIN && strpos( $term, ':' ) > 0 )
305  ) {
306  return null;
307  }
308 
309  return $url ?? $title->getFullUrlForRedirect();
310  }
311 
312  private function redirectOnExactMatch() {
315  // If the preference for whether to redirect is disabled, use the default setting
316  $defaultOptions = $this->getUser()->getDefaultOptions();
317  return $defaultOptions['search-match-redirect'];
318  } else {
319  // Otherwise use the user's preference
320  return $this->getUser()->getOption( 'search-match-redirect' );
321  }
322  }
323 
327  public function showResults( $term ) {
328  if ( $this->searchEngineType !== null ) {
329  $this->setExtraParam( 'srbackend', $this->searchEngineType );
330  }
331 
332  $out = $this->getOutput();
333  $widgetOptions = $this->getConfig()->get( 'SpecialSearchFormOptions' );
335  $this,
336  $this->searchConfig,
337  $this->getSearchProfiles()
338  );
339  $filePrefix = MediaWikiServices::getInstance()->getContentLanguage()->
340  getFormattedNsText( NS_FILE ) . ':';
341  if ( trim( $term ) === '' || $filePrefix === trim( $term ) ) {
342  // Empty query -- straight view of search form
343  if ( !Hooks::run( 'SpecialSearchResultsPrepend', [ $this, $out, $term ] ) ) {
344  # Hook requested termination
345  return;
346  }
347  $out->enableOOUI();
348  // The form also contains the 'Showing results 0 - 20 of 1234' so we can
349  // only do the form render here for the empty $term case. Rendering
350  // the form when a search is provided is repeated below.
351  $out->addHTML( $formWidget->render(
352  $this->profile, $term, 0, 0, $this->offset, $this->isPowerSearch(), $widgetOptions
353  ) );
354  return;
355  }
356 
357  $engine = $this->getSearchEngine();
358  $engine->setFeatureData( 'rewrite', $this->runSuggestion );
359  $engine->setLimitOffset( $this->limit, $this->offset );
360  $engine->setNamespaces( $this->namespaces );
361  $engine->setSort( $this->sort );
362  $engine->prefix = $this->mPrefix;
363 
364  Hooks::run( 'SpecialSearchSetupEngine', [ $this, $this->profile, $engine ] );
365  if ( !Hooks::run( 'SpecialSearchResultsPrepend', [ $this, $out, $term ] ) ) {
366  # Hook requested termination
367  return;
368  }
369 
370  $title = Title::newFromText( $term );
371  $showSuggestion = $title === null || !$title->isKnown();
372  $engine->setShowSuggestion( $showSuggestion );
373 
374  $rewritten = $engine->replacePrefixes( $term );
375  if ( $rewritten !== $term ) {
376  wfDeprecated( 'SearchEngine::replacePrefixes() (overridden by ' .
377  get_class( $engine ) . ')', '1.32' );
378  }
379 
380  // fetch search results
381  $titleMatches = $engine->searchTitle( $rewritten );
382  $textMatches = $engine->searchText( $rewritten );
383 
384  $textStatus = null;
385  if ( $textMatches instanceof Status ) {
386  $textStatus = $textMatches;
387  $textMatches = $textStatus->getValue();
388  }
389 
390  // Get number of results
391  $titleMatchesNum = $textMatchesNum = $numTitleMatches = $numTextMatches = 0;
392  if ( $titleMatches ) {
393  $titleMatchesNum = $titleMatches->numRows();
394  $numTitleMatches = $titleMatches->getTotalHits();
395  }
396  if ( $textMatches ) {
397  $textMatchesNum = $textMatches->numRows();
398  $numTextMatches = $textMatches->getTotalHits();
399  if ( $textMatchesNum > 0 ) {
400  $engine->augmentSearchResults( $textMatches );
401  }
402  }
403  $num = $titleMatchesNum + $textMatchesNum;
404  $totalRes = $numTitleMatches + $numTextMatches;
405 
406  // start rendering the page
407  $out->enableOOUI();
408  $out->addHTML( $formWidget->render(
409  $this->profile, $term, $num, $totalRes, $this->offset, $this->isPowerSearch(), $widgetOptions
410  ) );
411 
412  // did you mean... suggestions
413  if ( $textMatches ) {
414  $dymWidget = new MediaWiki\Widget\Search\DidYouMeanWidget( $this );
415  $out->addHTML( $dymWidget->render( $term, $textMatches ) );
416  }
417 
418  $hasSearchErrors = $textStatus && $textStatus->getErrors() !== [];
419  $hasOtherResults = $textMatches &&
420  $textMatches->hasInterwikiResults( ISearchResultSet::INLINE_RESULTS );
421 
422  if ( $textMatches && $textMatches->hasInterwikiResults( ISearchResultSet::SECONDARY_RESULTS ) ) {
423  $out->addHTML( '<div class="searchresults mw-searchresults-has-iw">' );
424  } else {
425  $out->addHTML( '<div class="searchresults">' );
426  }
427 
428  if ( $hasSearchErrors || $this->loadStatus->getErrors() ) {
429  if ( $textStatus === null ) {
430  $textStatus = $this->loadStatus;
431  } else {
432  $textStatus->merge( $this->loadStatus );
433  }
434  list( $error, $warning ) = $textStatus->splitByErrorType();
435  if ( $error->getErrors() ) {
436  $out->addHTML( Html::errorBox(
437  $error->getHTML( 'search-error' )
438  ) );
439  }
440  if ( $warning->getErrors() ) {
441  $out->addHTML( Html::warningBox(
442  $warning->getHTML( 'search-warning' )
443  ) );
444  }
445  }
446 
447  // Show the create link ahead
448  $this->showCreateLink( $title, $num, $titleMatches, $textMatches );
449 
450  Hooks::run( 'SpecialSearchResults', [ $term, &$titleMatches, &$textMatches ] );
451 
452  // If we have no results and have not already displayed an error message
453  if ( $num === 0 && !$hasSearchErrors ) {
454  $out->wrapWikiMsg( "<p class=\"mw-search-nonefound\">\n$1</p>", [
455  $hasOtherResults ? 'search-nonefound-thiswiki' : 'search-nonefound',
456  wfEscapeWikiText( $term )
457  ] );
458  }
459 
460  // Although $num might be 0 there can still be secondary or inline
461  // results to display.
462  $linkRenderer = $this->getLinkRenderer();
463  $mainResultWidget = new FullSearchResultWidget( $this, $linkRenderer );
464 
465  // Default (null) on. Can be explicitly disabled.
466  if ( $engine->getFeatureData( 'enable-new-crossproject-page' ) !== false ) {
467  $sidebarResultWidget = new InterwikiSearchResultWidget( $this, $linkRenderer );
468  $sidebarResultsWidget = new InterwikiSearchResultSetWidget(
469  $this,
470  $sidebarResultWidget,
472  MediaWikiServices::getInstance()->getInterwikiLookup(),
473  $engine->getFeatureData( 'show-multimedia-search-results' )
474  );
475  } else {
476  $sidebarResultWidget = new SimpleSearchResultWidget( $this, $linkRenderer );
477  $sidebarResultsWidget = new SimpleSearchResultSetWidget(
478  $this,
479  $sidebarResultWidget,
481  MediaWikiServices::getInstance()->getInterwikiLookup()
482  );
483  }
484 
485  $widget = new BasicSearchResultSetWidget( $this, $mainResultWidget, $sidebarResultsWidget );
486 
487  $out->addHTML( $widget->render(
488  $term, $this->offset, $titleMatches, $textMatches
489  ) );
490 
491  $out->addHTML( '<div class="mw-search-visualclear"></div>' );
492 
493  // prev/next links
494  if ( $totalRes > $this->limit || $this->offset ) {
495  // Allow matches to define the correct offset, as interleaved
496  // AB testing may require a different next page offset.
497  if ( $textMatches && $textMatches->getOffset() !== null ) {
498  $offset = $textMatches->getOffset();
499  } else {
501  }
502 
503  $prevNext = $this->buildPrevNextNavigation(
504  $offset,
505  $this->limit,
506  $this->powerSearchOptions() + [ 'search' => $term ],
507  $this->limit + $this->offset >= $totalRes
508  );
509  $out->addHTML( "<p class='mw-search-pager-bottom'>{$prevNext}</p>\n" );
510  }
511 
512  // Close <div class='searchresults'>
513  $out->addHTML( "</div>" );
514 
515  Hooks::run( 'SpecialSearchResultsAppend', [ $this, $out, $term ] );
516  }
517 
524  protected function showCreateLink( $title, $num, $titleMatches, $textMatches ) {
525  // show direct page/create link if applicable
526 
527  // Check DBkey !== '' in case of fragment link only.
528  if ( $title === null || $title->getDBkey() === ''
529  || ( $titleMatches !== null && $titleMatches->searchContainedSyntax() )
530  || ( $textMatches !== null && $textMatches->searchContainedSyntax() )
531  ) {
532  // invalid title
533  // preserve the paragraph for margins etc...
534  $this->getOutput()->addHTML( '<p></p>' );
535 
536  return;
537  }
538 
539  $messageName = 'searchmenu-new-nocreate';
540  $linkClass = 'mw-search-createlink';
541 
542  if ( !$title->isExternal() ) {
543  if ( $title->isKnown() ) {
544  $messageName = 'searchmenu-exists';
545  $linkClass = 'mw-search-exists';
546  } elseif ( ContentHandler::getForTitle( $title )->supportsDirectEditing()
547  && MediaWikiServices::getInstance()->getPermissionManager()->quickUserCan( 'create',
548  $this->getUser(), $title )
549  && MediaWikiServices::getInstance()->getPermissionManager()->quickUserCan( 'edit',
550  $this->getUser(), $title )
551  ) {
552  $messageName = 'searchmenu-new';
553  }
554  }
555 
556  $params = [
557  $messageName,
558  wfEscapeWikiText( $title->getPrefixedText() ),
559  Message::numParam( $num )
560  ];
561  Hooks::run( 'SpecialSearchCreateLink', [ $title, &$params ] );
562 
563  // Extensions using the hook might still return an empty $messageName
564  if ( $messageName ) {
565  $this->getOutput()->wrapWikiMsg( "<p class=\"$linkClass\">\n$1</p>", $params );
566  } else {
567  // preserve the paragraph for margins etc...
568  $this->getOutput()->addHTML( '<p></p>' );
569  }
570  }
571 
578  protected function setupPage( $term ) {
579  $out = $this->getOutput();
580 
581  $this->setHeaders();
582  $this->outputHeader();
583  // TODO: Is this true? The namespace remember uses a user token
584  // on save.
585  $out->allowClickjacking();
586  $this->addHelpLink( 'Help:Searching' );
587 
588  if ( strval( $term ) !== '' ) {
589  $out->setPageTitle( $this->msg( 'searchresults' ) );
590  $out->setHTMLTitle( $this->msg( 'pagetitle' )
591  ->plaintextParams( $this->msg( 'searchresults-title' )->plaintextParams( $term )->text() )
592  ->inContentLanguage()->text()
593  );
594  }
595 
596  if ( $this->mPrefix !== '' ) {
597  $subtitle = $this->msg( 'search-filter-title-prefix' )->plaintextParams( $this->mPrefix );
598  $params = $this->powerSearchOptions();
599  unset( $params['prefix'] );
600  $params += [
601  'search' => $term,
602  'fulltext' => 1,
603  ];
604 
605  $subtitle .= ' (';
606  $subtitle .= Xml::element(
607  'a',
608  [
609  'href' => $this->getPageTitle()->getLocalURL( $params ),
610  'title' => $this->msg( 'search-filter-title-prefix-reset' )->text(),
611  ],
612  $this->msg( 'search-filter-title-prefix-reset' )->text()
613  );
614  $subtitle .= ')';
615  $out->setSubtitle( $subtitle );
616  }
617 
618  $out->addJsConfigVars( [ 'searchTerm' => $term ] );
619  $out->addModules( 'mediawiki.special.search' );
620  $out->addModuleStyles( [
621  'mediawiki.special', 'mediawiki.special.search.styles', 'mediawiki.ui', 'mediawiki.ui.button',
622  'mediawiki.ui.input', 'mediawiki.widgets.SearchInputWidget.styles',
623  ] );
624  }
625 
631  protected function isPowerSearch() {
632  return $this->profile === 'advanced';
633  }
634 
642  protected function powerSearch( &$request ) {
643  $arr = [];
644  foreach ( $this->searchConfig->searchableNamespaces() as $ns => $name ) {
645  if ( $request->getCheck( 'ns' . $ns ) ) {
646  $arr[] = $ns;
647  }
648  }
649 
650  return $arr;
651  }
652 
660  public function powerSearchOptions() {
661  $opt = [];
662  if ( $this->isPowerSearch() ) {
663  foreach ( $this->namespaces as $n ) {
664  $opt['ns' . $n] = 1;
665  }
666  } else {
667  $opt['profile'] = $this->profile;
668  }
669 
670  return $opt + $this->extraParams;
671  }
672 
678  protected function saveNamespaces() {
679  $user = $this->getUser();
680  $request = $this->getRequest();
681 
682  if ( $user->isLoggedIn() &&
683  $user->matchEditToken(
684  $request->getVal( 'nsRemember' ),
685  'searchnamespace',
686  $request
687  ) && !wfReadOnly()
688  ) {
689  // Reset namespace preferences: namespaces are not searched
690  // when they're not mentioned in the URL parameters.
691  foreach ( MediaWikiServices::getInstance()->getNamespaceInfo()->getValidNamespaces()
692  as $n
693  ) {
694  $user->setOption( 'searchNs' . $n, false );
695  }
696  // The request parameters include all the namespaces to be searched.
697  // Even if they're the same as an existing profile, they're not eaten.
698  foreach ( $this->namespaces as $n ) {
699  $user->setOption( 'searchNs' . $n, true );
700  }
701 
702  DeferredUpdates::addCallableUpdate( function () use ( $user ) {
703  $user->saveSettings();
704  } );
705 
706  return true;
707  }
708 
709  return false;
710  }
711 
716  protected function getSearchProfiles() {
717  // Builds list of Search Types (profiles)
718  $nsAllSet = array_keys( $this->searchConfig->searchableNamespaces() );
719  $defaultNs = $this->searchConfig->defaultNamespaces();
720  $profiles = [
721  'default' => [
722  'message' => 'searchprofile-articles',
723  'tooltip' => 'searchprofile-articles-tooltip',
724  'namespaces' => $defaultNs,
725  'namespace-messages' => $this->searchConfig->namespacesAsText(
726  $defaultNs
727  ),
728  ],
729  'images' => [
730  'message' => 'searchprofile-images',
731  'tooltip' => 'searchprofile-images-tooltip',
732  'namespaces' => [ NS_FILE ],
733  ],
734  'all' => [
735  'message' => 'searchprofile-everything',
736  'tooltip' => 'searchprofile-everything-tooltip',
737  'namespaces' => $nsAllSet,
738  ],
739  'advanced' => [
740  'message' => 'searchprofile-advanced',
741  'tooltip' => 'searchprofile-advanced-tooltip',
742  'namespaces' => self::NAMESPACES_CURRENT,
743  ]
744  ];
745 
746  Hooks::run( 'SpecialSearchProfiles', [ &$profiles ] );
747 
748  foreach ( $profiles as &$data ) {
749  if ( !is_array( $data['namespaces'] ) ) {
750  continue;
751  }
752  sort( $data['namespaces'] );
753  }
754 
755  return $profiles;
756  }
757 
763  public function getSearchEngine() {
764  if ( $this->searchEngine === null ) {
765  $services = MediaWikiServices::getInstance();
766  $this->searchEngine = $this->searchEngineType ?
767  $services->getSearchEngineFactory()->create( $this->searchEngineType ) :
768  $services->newSearchEngine();
769  }
770 
771  return $this->searchEngine;
772  }
773 
778  function getProfile() {
779  return $this->profile;
780  }
781 
786  function getNamespaces() {
787  return $this->namespaces;
788  }
789 
799  public function setExtraParam( $key, $value ) {
800  $this->extraParams[$key] = $value;
801  }
802 
811  public function getPrefix() {
812  return $this->mPrefix;
813  }
814 
815  protected function getGroupName() {
816  return 'pages';
817  }
818 }
SpecialSearch\getNamespaces
getNamespaces()
Current namespaces.
Definition: SpecialSearch.php:786
SpecialPage\getPageTitle
getPageTitle( $subpage=false)
Get a self-referential title object.
Definition: SpecialPage.php:672
SpecialPage\msg
msg( $key,... $params)
Wrapper around wfMessage that sets the current context.
Definition: SpecialPage.php:792
Title\newFromText
static newFromText( $text, $defaultNamespace=NS_MAIN)
Create a new Title from text, such as what one would find in a link.
Definition: Title.php:317
SpecialSearch\$fulltext
string $fulltext
Definition: SpecialSearch.php:77
SpecialPage\getOutput
getOutput()
Get the OutputPage being used for this instance.
Definition: SpecialPage.php:719
SpecialSearch\$sort
string $sort
Definition: SpecialSearch.php:82
MediaWiki\MediaWikiServices
MediaWikiServices is the service locator for the application scope of MediaWiki.
Definition: MediaWikiServices.php:130
SpecialSearch\$limit
int $limit
Definition: SpecialSearch.php:67
NS_FILE
const NS_FILE
Definition: Defines.php:66
wfReadOnly
wfReadOnly()
Check whether the wiki is in read-only mode.
Definition: GlobalFunctions.php:1170
SpecialSearch\$loadStatus
Status $loadStatus
Holds any parameter validation errors that should be displayed back to the user.
Definition: SpecialSearch.php:99
ContentHandler\getForTitle
static getForTitle(Title $title)
Returns the appropriate ContentHandler singleton for the given title.
Definition: ContentHandler.php:201
MediaWiki\Widget\Search\InterwikiSearchResultSetWidget
Renders one or more ISearchResultSets into a sidebar grouped by interwiki prefix.
Definition: InterwikiSearchResultSetWidget.php:18
SpecialSearch\getPrefix
getPrefix()
The prefix value send to Special:Search using the 'prefix' URI param It means that the user is willin...
Definition: SpecialSearch.php:811
MediaWiki\Widget\Search\BasicSearchResultSetWidget
Renders the search result area.
Definition: BasicSearchResultSetWidget.php:15
MediaWiki\Widget\Search\SearchFormWidget
Definition: SearchFormWidget.php:13
SpecialSearch\isPowerSearch
isPowerSearch()
Return true if current search is a power (advanced) search.
Definition: SpecialSearch.php:631
SpecialSearch\setupPage
setupPage( $term)
Sets up everything for the HTML output page including styles, javascript, page title,...
Definition: SpecialSearch.php:578
SpecialSearch\getSearchProfiles
getSearchProfiles()
Definition: SpecialSearch.php:716
SearchEngine\DEFAULT_SORT
const DEFAULT_SORT
Definition: SearchEngine.php:35
SpecialSearch\NAMESPACES_CURRENT
const NAMESPACES_CURRENT
Definition: SpecialSearch.php:101
Status
Generic operation result class Has warning/error list, boolean status and arbitrary value.
Definition: Status.php:40
NS_MAIN
const NS_MAIN
Definition: Defines.php:60
SpecialPage\addHelpLink
addHelpLink( $to, $overrideBaseUrl=false)
Adds help link with an icon via page indicators.
Definition: SpecialPage.php:828
SpecialPage\getConfig
getConfig()
Shortcut to get main config object.
Definition: SpecialPage.php:758
SpecialSearch\getGroupName
getGroupName()
Under which header this special page is listed in Special:SpecialPages See messages 'specialpages-gro...
Definition: SpecialSearch.php:815
wfDeprecated
wfDeprecated( $function, $version=false, $component=false, $callerOffset=2)
Throws a warning that $function is deprecated.
Definition: GlobalFunctions.php:1044
getPermissionManager
getPermissionManager()
SpecialSearch\$searchEngineType
string $searchEngineType
Search engine type, if not default.
Definition: SpecialSearch.php:53
MediaWiki\Widget\Search\DidYouMeanWidget
Renders a suggested search for the user, or tells the user a suggested search was run instead of the ...
Definition: DidYouMeanWidget.php:12
SpecialSearch\$runSuggestion
bool $runSuggestion
Definition: SpecialSearch.php:87
Xml\element
static element( $element, $attribs=null, $contents='', $allowShortTag=true)
Format an XML element with given attributes and, optionally, text content.
Definition: Xml.php:41
StatusValue\merge
merge( $other, $overwriteValue=false)
Merge another status object into this one.
Definition: StatusValue.php:223
$title
$title
Definition: testCompression.php:36
SpecialPage\setHeaders
setHeaders()
Sets headers - this should be called from the execute() method of all derived classes!
Definition: SpecialPage.php:537
SpecialSearch\$offset
int $offset
Definition: SpecialSearch.php:67
SpecialPage\getUser
getUser()
Shortcut to get the User executing this instance.
Definition: SpecialPage.php:729
SpecialSearch\saveNamespaces
saveNamespaces()
Save namespace preferences when we're supposed to.
Definition: SpecialSearch.php:678
SpecialSearch\__construct
__construct()
Definition: SpecialSearch.php:103
MediaWiki\Widget\Search\SimpleSearchResultSetWidget
Renders one or more ISearchResultSets into a sidebar grouped by interwiki prefix.
Definition: SimpleSearchResultSetWidget.php:19
SpecialSearch\$searchConfig
SearchEngineConfig $searchConfig
Search engine configurations.
Definition: SpecialSearch.php:93
ISearchResultSet\INLINE_RESULTS
const INLINE_RESULTS
Identifier for interwiki results that can be displayed even if no existing main wiki results exist.
Definition: ISearchResultSet.php:22
SpecialSearch\showGoogleSearch
showGoogleSearch( $term)
Output a google search form if search is disabled.
Definition: SpecialSearch.php:189
SpecialSearch\$searchEngine
SearchEngine $searchEngine
Search engine.
Definition: SpecialSearch.php:50
SpecialSearch\execute
execute( $par)
Entry point.
Definition: SpecialSearch.php:113
MediaWiki\Widget\Search\SimpleSearchResultWidget
Renders a simple one-line result.
Definition: SimpleSearchResultWidget.php:15
SpecialPage
Parent class for all special pages.
Definition: SpecialPage.php:37
SpecialPage\buildPrevNextNavigation
buildPrevNextNavigation( $offset, $limit, array $query=[], $atend=false, $subpage=false)
Generate (prev x| next x) (20|50|100...) type links for paging.
Definition: SpecialPage.php:930
SpecialSearch
implements Special:Search - Run text & title search and display the output
Definition: SpecialSearch.php:38
SpecialPage\getRequest
getRequest()
Get the WebRequest being used for this instance.
Definition: SpecialPage.php:709
SpecialSearch\$profile
null string $profile
Current search profile.
Definition: SpecialSearch.php:47
MediaWiki\Widget\Search\FullSearchResultWidget
Renders a 'full' multi-line search result with metadata.
Definition: FullSearchResultWidget.php:21
SpecialSearch\powerSearch
powerSearch(&$request)
Extract "power search" namespace settings from the request object, returning a list of index numbers ...
Definition: SpecialSearch.php:642
wfEscapeWikiText
wfEscapeWikiText( $text)
Escapes the given text so that it may be output using addWikiText() without any linking,...
Definition: GlobalFunctions.php:1550
SpecialSearch\getProfile
getProfile()
Current search profile.
Definition: SpecialSearch.php:778
SearchEngine
Contain a class for special pages.
Definition: SearchEngine.php:34
SpecialSearch\$extraParams
array $extraParams
For links.
Definition: SpecialSearch.php:56
SpecialPage\getLinkRenderer
getLinkRenderer()
Definition: SpecialPage.php:904
SpecialSearch\powerSearchOptions
powerSearchOptions()
Reconstruct the 'power search' options for links TODO: Instead of exposing this publicly,...
Definition: SpecialSearch.php:660
SpecialSearch\goResult
goResult( $term)
If an exact title match can be found, jump straight ahead to it.
Definition: SpecialSearch.php:279
SpecialSearch\$namespaces
array $namespaces
Definition: SpecialSearch.php:72
SpecialSearch\getSearchEngine
getSearchEngine()
Definition: SpecialSearch.php:763
SpecialSearch\setExtraParam
setExtraParam( $key, $value)
Users of hook SpecialSearchSetupEngine can use this to add more params to links to not lose selection...
Definition: SpecialSearch.php:799
SpecialSearch\load
load()
Set up basic search parameters from the request and user settings.
Definition: SpecialSearch.php:212
MediaWiki\Widget\Search\InterwikiSearchResultWidget
Renders an enhanced interwiki result.
Definition: InterwikiSearchResultWidget.php:14
ISearchResultSet\SECONDARY_RESULTS
const SECONDARY_RESULTS
Identifier for interwiki results that are displayed only together with existing main wiki results.
Definition: ISearchResultSet.php:16
SearchEngineConfig
Configuration handling class for SearchEngine.
Definition: SearchEngineConfig.php:9
SpecialSearch\$mPrefix
string $mPrefix
The prefix url parameter.
Definition: SpecialSearch.php:62
SpecialSearch\showCreateLink
showCreateLink( $title, $num, $titleMatches, $textMatches)
Definition: SpecialSearch.php:524
SpecialPage\$linkRenderer
MediaWiki Linker LinkRenderer null $linkRenderer
Definition: SpecialPage.php:67
DeferredUpdates\addCallableUpdate
static addCallableUpdate( $callable, $stage=self::POSTSEND, $dbw=null)
Add a callable update.
Definition: DeferredUpdates.php:125
Hooks\run
static run( $event, array $args=[], $deprecatedVersion=null)
Call hook functions defined in Hooks::register and $wgHooks.
Definition: Hooks.php:200
SpecialSearch\showResults
showResults( $term)
Definition: SpecialSearch.php:327
$wgSearchMatchRedirectPreference
bool $wgSearchMatchRedirectPreference
Set true to allow logged-in users to set a preference whether or not matches in search results should...
Definition: DefaultSettings.php:9071
SpecialPage\outputHeader
outputHeader( $summaryMessageKey='')
Outputs a summary message on top of special pages Per default the message key is the canonical name o...
Definition: SpecialPage.php:639
SpecialSearch\redirectOnExactMatch
redirectOnExactMatch()
Definition: SpecialSearch.php:312