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  private 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  $this->getHookRunner()->onSpecialSearchNogomatch( $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->getLimitOffsetForUser(
217  $this->getUser(),
218  20,
219  ''
220  );
221  $this->mPrefix = $request->getVal( 'prefix', '' );
222  if ( $this->mPrefix !== '' ) {
223  $this->setExtraParam( 'prefix', $this->mPrefix );
224  }
225 
226  $sort = $request->getVal( 'sort', SearchEngine::DEFAULT_SORT );
227  $validSorts = $this->getSearchEngine()->getValidSorts();
228  if ( !in_array( $sort, $validSorts ) ) {
229  $this->loadStatus->warning( 'search-invalid-sort-order', $sort,
230  implode( ', ', $validSorts ) );
231  } elseif ( $sort !== $this->sort ) {
232  $this->sort = $sort;
233  $this->setExtraParam( 'sort', $this->sort );
234  }
235 
236  $user = $this->getUser();
237 
238  # Extract manually requested namespaces
239  $nslist = $this->powerSearch( $request );
240  if ( $nslist === [] ) {
241  # Fallback to user preference
242  $nslist = $this->searchConfig->userNamespaces( $user );
243  }
244 
245  $profile = null;
246  if ( $nslist === [] ) {
247  $profile = 'default';
248  }
249 
250  $profile = $request->getVal( 'profile', $profile );
251  $profiles = $this->getSearchProfiles();
252  if ( $profile === null ) {
253  // BC with old request format
254  $profile = 'advanced';
255  foreach ( $profiles as $key => $data ) {
256  if ( $nslist === $data['namespaces'] && $key !== 'advanced' ) {
257  $profile = $key;
258  }
259  }
260  $this->namespaces = $nslist;
261  } elseif ( $profile === 'advanced' ) {
262  $this->namespaces = $nslist;
263  } elseif ( isset( $profiles[$profile]['namespaces'] ) ) {
264  $this->namespaces = $profiles[$profile]['namespaces'];
265  } else {
266  // Unknown profile requested
267  $this->loadStatus->warning( 'search-unknown-profile', $profile );
268  $profile = 'default';
269  $this->namespaces = $profiles['default']['namespaces'];
270  }
271 
272  $this->fulltext = $request->getVal( 'fulltext' );
273  $this->runSuggestion = (bool)$request->getVal( 'runsuggestion', true );
274  $this->profile = $profile;
275  }
276 
283  public function goResult( $term ) {
284  # If the string cannot be used to create a title
285  if ( Title::newFromText( $term ) === null ) {
286  return null;
287  }
288  # If there's an exact or very near match, jump right there.
289  $title = $this->getSearchEngine()
290  ->getNearMatcher( $this->getConfig() )->getNearMatch( $term );
291  if ( $title === null ) {
292  return null;
293  }
294  $url = null;
295  if ( !$this->getHookRunner()->onSpecialSearchGoResult( $term, $title, $url ) ) {
296  return null;
297  }
298 
299  if (
300  // If there is a preference set to NOT redirect on exact page match
301  // then return null (which prevents direction)
302  !$this->redirectOnExactMatch()
303  // BUT ...
304  // ... ignore no-redirect preference if the exact page match is an interwiki link
305  && !$title->isExternal()
306  // ... ignore no-redirect preference if the exact page match is NOT in the main
307  // namespace AND there's a namespace in the search string
308  && !( $title->getNamespace() !== NS_MAIN && strpos( $term, ':' ) > 0 )
309  ) {
310  return null;
311  }
312 
313  return $url ?? $title->getFullUrlForRedirect();
314  }
315 
316  private function redirectOnExactMatch() {
319  // If the preference for whether to redirect is disabled, use the default setting
320  $defaultOptions = $this->getUser()->getDefaultOptions();
321  return $defaultOptions['search-match-redirect'];
322  } else {
323  // Otherwise use the user's preference
324  return $this->getUser()->getOption( 'search-match-redirect' );
325  }
326  }
327 
331  public function showResults( $term ) {
332  if ( $this->searchEngineType !== null ) {
333  $this->setExtraParam( 'srbackend', $this->searchEngineType );
334  }
335 
336  $out = $this->getOutput();
337  $widgetOptions = $this->getConfig()->get( 'SpecialSearchFormOptions' );
339  $this,
340  $this->searchConfig,
341  $this->getHookContainer(),
342  $this->getSearchProfiles()
343  );
344  $filePrefix = MediaWikiServices::getInstance()->getContentLanguage()->
345  getFormattedNsText( NS_FILE ) . ':';
346  if ( trim( $term ) === '' || $filePrefix === trim( $term ) ) {
347  // Empty query -- straight view of search form
348  if ( !$this->getHookRunner()->onSpecialSearchResultsPrepend( $this, $out, $term ) ) {
349  # Hook requested termination
350  return;
351  }
352  $out->enableOOUI();
353  // The form also contains the 'Showing results 0 - 20 of 1234' so we can
354  // only do the form render here for the empty $term case. Rendering
355  // the form when a search is provided is repeated below.
356  $out->addHTML( $formWidget->render(
357  $this->profile, $term, 0, 0, $this->offset, $this->isPowerSearch(), $widgetOptions
358  ) );
359  return;
360  }
361 
362  $engine = $this->getSearchEngine();
363  $engine->setFeatureData( 'rewrite', $this->runSuggestion );
364  $engine->setLimitOffset( $this->limit, $this->offset );
365  $engine->setNamespaces( $this->namespaces );
366  $engine->setSort( $this->sort );
367  $engine->prefix = $this->mPrefix;
368 
369  $this->getHookRunner()->onSpecialSearchSetupEngine( $this, $this->profile, $engine );
370  if ( !$this->getHookRunner()->onSpecialSearchResultsPrepend( $this, $out, $term ) ) {
371  # Hook requested termination
372  return;
373  }
374 
375  $title = Title::newFromText( $term );
376  $showSuggestion = $title === null || !$title->isKnown();
377  $engine->setShowSuggestion( $showSuggestion );
378 
379  $rewritten = $engine->replacePrefixes( $term );
380  if ( $rewritten !== $term ) {
381  wfDeprecatedMsg( 'SearchEngine::replacePrefixes() was overridden by ' .
382  get_class( $engine ) . ', this is deprecated since MediaWiki 1.32',
383  '1.32', false, false );
384  }
385 
386  // fetch search results
387  $titleMatches = $engine->searchTitle( $rewritten );
388  $textMatches = $engine->searchText( $rewritten );
389 
390  $textStatus = null;
391  if ( $textMatches instanceof Status ) {
392  $textStatus = $textMatches;
393  $textMatches = $textStatus->getValue();
394  }
395 
396  // Get number of results
397  $titleMatchesNum = $textMatchesNum = $numTitleMatches = $numTextMatches = 0;
398  if ( $titleMatches ) {
399  $titleMatchesNum = $titleMatches->numRows();
400  $numTitleMatches = $titleMatches->getTotalHits();
401  }
402  if ( $textMatches ) {
403  $textMatchesNum = $textMatches->numRows();
404  $numTextMatches = $textMatches->getTotalHits();
405  if ( $textMatchesNum > 0 ) {
406  $engine->augmentSearchResults( $textMatches );
407  }
408  }
409  $num = $titleMatchesNum + $textMatchesNum;
410  $totalRes = $numTitleMatches + $numTextMatches;
411 
412  // start rendering the page
413  $out->enableOOUI();
414  $out->addHTML( $formWidget->render(
415  $this->profile, $term, $num, $totalRes, $this->offset, $this->isPowerSearch(), $widgetOptions
416  ) );
417 
418  // did you mean... suggestions
419  if ( $textMatches ) {
420  $dymWidget = new MediaWiki\Search\SearchWidgets\DidYouMeanWidget( $this );
421  $out->addHTML( $dymWidget->render( $term, $textMatches ) );
422  }
423 
424  $hasSearchErrors = $textStatus && $textStatus->getErrors() !== [];
425  $hasOtherResults = $textMatches &&
426  $textMatches->hasInterwikiResults( ISearchResultSet::INLINE_RESULTS );
427 
428  if ( $textMatches && $textMatches->hasInterwikiResults( ISearchResultSet::SECONDARY_RESULTS ) ) {
429  $out->addHTML( '<div class="searchresults mw-searchresults-has-iw">' );
430  } else {
431  $out->addHTML( '<div class="searchresults">' );
432  }
433 
434  if ( $hasSearchErrors || $this->loadStatus->getErrors() ) {
435  if ( $textStatus === null ) {
436  $textStatus = $this->loadStatus;
437  } else {
438  $textStatus->merge( $this->loadStatus );
439  }
440  list( $error, $warning ) = $textStatus->splitByErrorType();
441  if ( $error->getErrors() ) {
442  $out->addHTML( Html::errorBox(
443  $error->getHTML( 'search-error' )
444  ) );
445  }
446  if ( $warning->getErrors() ) {
447  $out->addHTML( Html::warningBox(
448  $warning->getHTML( 'search-warning' )
449  ) );
450  }
451  }
452 
453  // Show the create link ahead
454  $this->showCreateLink( $title, $num, $titleMatches, $textMatches );
455 
456  $this->getHookRunner()->onSpecialSearchResults( $term, $titleMatches, $textMatches );
457 
458  // If we have no results and have not already displayed an error message
459  if ( $num === 0 && !$hasSearchErrors ) {
460  $out->wrapWikiMsg( "<p class=\"mw-search-nonefound\">\n$1</p>", [
461  $hasOtherResults ? 'search-nonefound-thiswiki' : 'search-nonefound',
462  wfEscapeWikiText( $term )
463  ] );
464  }
465 
466  // Although $num might be 0 there can still be secondary or inline
467  // results to display.
468  $linkRenderer = $this->getLinkRenderer();
469  $mainResultWidget = new FullSearchResultWidget(
470  $this, $linkRenderer, $this->getHookContainer() );
471 
472  // Default (null) on. Can be explicitly disabled.
473  if ( $engine->getFeatureData( 'enable-new-crossproject-page' ) !== false ) {
474  $sidebarResultWidget = new InterwikiSearchResultWidget( $this, $linkRenderer );
475  $sidebarResultsWidget = new InterwikiSearchResultSetWidget(
476  $this,
477  $sidebarResultWidget,
479  MediaWikiServices::getInstance()->getInterwikiLookup(),
480  $engine->getFeatureData( 'show-multimedia-search-results' )
481  );
482  } else {
483  $sidebarResultWidget = new SimpleSearchResultWidget( $this, $linkRenderer );
484  $sidebarResultsWidget = new SimpleSearchResultSetWidget(
485  $this,
486  $sidebarResultWidget,
488  MediaWikiServices::getInstance()->getInterwikiLookup()
489  );
490  }
491 
492  $widget = new BasicSearchResultSetWidget( $this, $mainResultWidget, $sidebarResultsWidget );
493 
494  $out->addHTML( $widget->render(
495  $term, $this->offset, $titleMatches, $textMatches
496  ) );
497 
498  $out->addHTML( '<div class="mw-search-visualclear"></div>' );
499 
500  // prev/next links
501  if ( $totalRes > $this->limit || $this->offset ) {
502  // Allow matches to define the correct offset, as interleaved
503  // AB testing may require a different next page offset.
504  if ( $textMatches && $textMatches->getOffset() !== null ) {
505  $offset = $textMatches->getOffset();
506  } else {
508  }
509 
510  $prevNext = $this->buildPrevNextNavigation(
511  $offset,
512  $this->limit,
513  $this->powerSearchOptions() + [ 'search' => $term ],
514  $this->limit + $this->offset >= $totalRes
515  );
516  $out->addHTML( "<p class='mw-search-pager-bottom'>{$prevNext}</p>\n" );
517  }
518 
519  // Close <div class='searchresults'>
520  $out->addHTML( "</div>" );
521 
522  $this->getHookRunner()->onSpecialSearchResultsAppend( $this, $out, $term );
523  }
524 
531  protected function showCreateLink( $title, $num, $titleMatches, $textMatches ) {
532  // show direct page/create link if applicable
533 
534  // Check DBkey !== '' in case of fragment link only.
535  if ( $title === null || $title->getDBkey() === ''
536  || ( $titleMatches !== null && $titleMatches->searchContainedSyntax() )
537  || ( $textMatches !== null && $textMatches->searchContainedSyntax() )
538  ) {
539  // invalid title
540  // preserve the paragraph for margins etc...
541  $this->getOutput()->addHTML( '<p></p>' );
542 
543  return;
544  }
545 
546  $messageName = 'searchmenu-new-nocreate';
547  $linkClass = 'mw-search-createlink';
548 
549  if ( !$title->isExternal() ) {
550  if ( $title->isKnown() ) {
551  $messageName = 'searchmenu-exists';
552  $linkClass = 'mw-search-exists';
553  } elseif (
554  MediaWikiServices::getInstance()
555  ->getContentHandlerFactory()
556  ->getContentHandler( $title->getContentModel() )
557  ->supportsDirectEditing()
558  && MediaWikiServices::getInstance()->getPermissionManager()->quickUserCan( 'create',
559  $this->getUser(), $title )
560  && MediaWikiServices::getInstance()->getPermissionManager()->quickUserCan( 'edit',
561  $this->getUser(), $title )
562  ) {
563  $messageName = 'searchmenu-new';
564  }
565  }
566 
567  $params = [
568  $messageName,
569  wfEscapeWikiText( $title->getPrefixedText() ),
570  Message::numParam( $num )
571  ];
572  $this->getHookRunner()->onSpecialSearchCreateLink( $title, $params );
573 
574  // Extensions using the hook might still return an empty $messageName
575  // @phan-suppress-next-line PhanRedundantCondition Set by hook
576  if ( $messageName ) {
577  $this->getOutput()->wrapWikiMsg( "<p class=\"$linkClass\">\n$1</p>", $params );
578  } else {
579  // preserve the paragraph for margins etc...
580  $this->getOutput()->addHTML( '<p></p>' );
581  }
582  }
583 
590  protected function setupPage( $term ) {
591  $out = $this->getOutput();
592 
593  $this->setHeaders();
594  $this->outputHeader();
595  // TODO: Is this true? The namespace remember uses a user token
596  // on save.
597  $out->allowClickjacking();
598  $this->addHelpLink( 'Help:Searching' );
599 
600  if ( strval( $term ) !== '' ) {
601  $out->setPageTitle( $this->msg( 'searchresults' ) );
602  $out->setHTMLTitle( $this->msg( 'pagetitle' )
603  ->plaintextParams( $this->msg( 'searchresults-title' )->plaintextParams( $term )->text() )
604  ->inContentLanguage()->text()
605  );
606  }
607 
608  if ( $this->mPrefix !== '' ) {
609  $subtitle = $this->msg( 'search-filter-title-prefix' )->plaintextParams( $this->mPrefix );
610  $params = $this->powerSearchOptions();
611  unset( $params['prefix'] );
612  $params += [
613  'search' => $term,
614  'fulltext' => 1,
615  ];
616 
617  $subtitle .= ' (';
618  $subtitle .= Xml::element(
619  'a',
620  [
621  'href' => $this->getPageTitle()->getLocalURL( $params ),
622  'title' => $this->msg( 'search-filter-title-prefix-reset' )->text(),
623  ],
624  $this->msg( 'search-filter-title-prefix-reset' )->text()
625  );
626  $subtitle .= ')';
627  $out->setSubtitle( $subtitle );
628  }
629 
630  $out->addJsConfigVars( [ 'searchTerm' => $term ] );
631  $out->addModules( 'mediawiki.special.search' );
632  $out->addModuleStyles( [
633  'mediawiki.special', 'mediawiki.special.search.styles', 'mediawiki.ui', 'mediawiki.ui.button',
634  'mediawiki.ui.input', 'mediawiki.widgets.SearchInputWidget.styles',
635  ] );
636  }
637 
643  protected function isPowerSearch() {
644  return $this->profile === 'advanced';
645  }
646 
654  protected function powerSearch( &$request ) {
655  $arr = [];
656  foreach ( $this->searchConfig->searchableNamespaces() as $ns => $name ) {
657  if ( $request->getCheck( 'ns' . $ns ) ) {
658  $arr[] = $ns;
659  }
660  }
661 
662  return $arr;
663  }
664 
672  public function powerSearchOptions() {
673  $opt = [];
674  if ( $this->isPowerSearch() ) {
675  foreach ( $this->namespaces as $n ) {
676  $opt['ns' . $n] = 1;
677  }
678  } else {
679  $opt['profile'] = $this->profile;
680  }
681 
682  return $opt + $this->extraParams;
683  }
684 
690  protected function saveNamespaces() {
691  $user = $this->getUser();
692  $request = $this->getRequest();
693 
694  if ( $user->isLoggedIn() &&
695  $user->matchEditToken(
696  $request->getVal( 'nsRemember' ),
697  'searchnamespace',
698  $request
699  ) && !wfReadOnly()
700  ) {
701  // Reset namespace preferences: namespaces are not searched
702  // when they're not mentioned in the URL parameters.
703  foreach ( MediaWikiServices::getInstance()->getNamespaceInfo()->getValidNamespaces()
704  as $n
705  ) {
706  $user->setOption( 'searchNs' . $n, false );
707  }
708  // The request parameters include all the namespaces to be searched.
709  // Even if they're the same as an existing profile, they're not eaten.
710  foreach ( $this->namespaces as $n ) {
711  $user->setOption( 'searchNs' . $n, true );
712  }
713 
714  DeferredUpdates::addCallableUpdate( function () use ( $user ) {
715  $user->saveSettings();
716  } );
717 
718  return true;
719  }
720 
721  return false;
722  }
723 
728  protected function getSearchProfiles() {
729  // Builds list of Search Types (profiles)
730  $nsAllSet = array_keys( $this->searchConfig->searchableNamespaces() );
731  $defaultNs = $this->searchConfig->defaultNamespaces();
732  $profiles = [
733  'default' => [
734  'message' => 'searchprofile-articles',
735  'tooltip' => 'searchprofile-articles-tooltip',
736  'namespaces' => $defaultNs,
737  'namespace-messages' => $this->searchConfig->namespacesAsText(
738  $defaultNs
739  ),
740  ],
741  'images' => [
742  'message' => 'searchprofile-images',
743  'tooltip' => 'searchprofile-images-tooltip',
744  'namespaces' => [ NS_FILE ],
745  ],
746  'all' => [
747  'message' => 'searchprofile-everything',
748  'tooltip' => 'searchprofile-everything-tooltip',
749  'namespaces' => $nsAllSet,
750  ],
751  'advanced' => [
752  'message' => 'searchprofile-advanced',
753  'tooltip' => 'searchprofile-advanced-tooltip',
754  'namespaces' => self::NAMESPACES_CURRENT,
755  ]
756  ];
757 
758  $this->getHookRunner()->onSpecialSearchProfiles( $profiles );
759 
760  foreach ( $profiles as &$data ) {
761  if ( !is_array( $data['namespaces'] ) ) {
762  continue;
763  }
764  sort( $data['namespaces'] );
765  }
766 
767  return $profiles;
768  }
769 
775  public function getSearchEngine() {
776  if ( $this->searchEngine === null ) {
777  $services = MediaWikiServices::getInstance();
778  $this->searchEngine = $this->searchEngineType ?
779  $services->getSearchEngineFactory()->create( $this->searchEngineType ) :
780  $services->newSearchEngine();
781  }
782 
783  return $this->searchEngine;
784  }
785 
790  public function getProfile() {
791  return $this->profile;
792  }
793 
798  public function getNamespaces() {
799  return $this->namespaces;
800  }
801 
811  public function setExtraParam( $key, $value ) {
812  $this->extraParams[$key] = $value;
813  }
814 
823  public function getPrefix() {
824  return $this->mPrefix;
825  }
826 
827  protected function getGroupName() {
828  return 'pages';
829  }
830 }
MediaWiki\Search\SearchWidgets\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\getNamespaces
getNamespaces()
Current namespaces.
Definition: SpecialSearch.php:798
SpecialPage\getPageTitle
getPageTitle( $subpage=false)
Get a self-referential title object.
Definition: SpecialPage.php:697
Message\numParam
static numParam( $num)
Definition: Message.php:1048
SpecialPage\msg
msg( $key,... $params)
Wrapper around wfMessage that sets the current context.
Definition: SpecialPage.php:828
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:329
MediaWiki\Search\SearchWidgets\SearchFormWidget
Definition: SearchFormWidget.php:14
SpecialSearch\$fulltext
string $fulltext
Definition: SpecialSearch.php:77
SpecialPage\getOutput
getOutput()
Get the OutputPage being used for this instance.
Definition: SpecialPage.php:744
SpecialSearch\$sort
string $sort
Definition: SpecialSearch.php:82
MediaWiki\Search\SearchWidgets\InterwikiSearchResultSetWidget
Renders one or more ISearchResultSets into a sidebar grouped by interwiki prefix.
Definition: InterwikiSearchResultSetWidget.php:18
MediaWiki\MediaWikiServices
MediaWikiServices is the service locator for the application scope of MediaWiki.
Definition: MediaWikiServices.php:154
SpecialSearch\$limit
int $limit
Definition: SpecialSearch.php:67
MediaWiki\Search\SearchWidgets\InterwikiSearchResultWidget
Renders an enhanced interwiki result.
Definition: InterwikiSearchResultWidget.php:14
NS_FILE
const NS_FILE
Definition: Defines.php:75
wfReadOnly
wfReadOnly()
Check whether the wiki is in read-only mode.
Definition: GlobalFunctions.php:1125
SpecialSearch\$loadStatus
Status $loadStatus
Holds any parameter validation errors that should be displayed back to the user.
Definition: SpecialSearch.php:99
SpecialPage\getHookContainer
getHookContainer()
Definition: SpecialPage.php:997
Html\warningBox
static warningBox( $html, $className='')
Return a warning box.
Definition: Html.php:726
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:823
SpecialSearch\isPowerSearch
isPowerSearch()
Return true if current search is a power (advanced) search.
Definition: SpecialSearch.php:643
SpecialSearch\setupPage
setupPage( $term)
Sets up everything for the HTML output page including styles, javascript, page title,...
Definition: SpecialSearch.php:590
SpecialSearch\getSearchProfiles
getSearchProfiles()
Definition: SpecialSearch.php:728
SearchEngine\DEFAULT_SORT
const DEFAULT_SORT
Definition: SearchEngine.php:38
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:44
NS_MAIN
const NS_MAIN
Definition: Defines.php:69
SpecialPage\addHelpLink
addHelpLink( $to, $overrideBaseUrl=false)
Adds help link with an icon via page indicators.
Definition: SpecialPage.php:864
wfDeprecatedMsg
wfDeprecatedMsg( $msg, $version=false, $component=false, $callerOffset=2)
Log a deprecation warning with arbitrary message text.
Definition: GlobalFunctions.php:1058
SpecialPage\getHookRunner
getHookRunner()
Definition: SpecialPage.php:1010
SpecialPage\getConfig
getConfig()
Shortcut to get main config object.
Definition: SpecialPage.php:794
SpecialSearch\getGroupName
getGroupName()
Under which header this special page is listed in Special:SpecialPages See messages 'specialpages-gro...
Definition: SpecialSearch.php:827
SpecialSearch\$searchEngineType
string $searchEngineType
Search engine type, if not default.
Definition: SpecialSearch.php:53
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:224
MediaWiki\Search\SearchWidgets\BasicSearchResultSetWidget
Renders the search result area.
Definition: BasicSearchResultSetWidget.php:15
$title
$title
Definition: testCompression.php:38
SpecialPage\setHeaders
setHeaders()
Sets headers - this should be called from the execute() method of all derived classes!...
Definition: SpecialPage.php:571
SpecialSearch\$offset
int $offset
Definition: SpecialSearch.php:67
SpecialPage\getUser
getUser()
Shortcut to get the User executing this instance.
Definition: SpecialPage.php:754
SpecialSearch\saveNamespaces
saveNamespaces()
Save namespace preferences when we're supposed to.
Definition: SpecialSearch.php:690
SpecialSearch\__construct
__construct()
Definition: SpecialSearch.php:103
Html\errorBox
static errorBox( $html, $heading='', $className='')
Return an error box.
Definition: Html.php:739
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:23
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
SpecialPage
Parent class for all special pages.
Definition: SpecialPage.php:41
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:970
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:734
SpecialSearch\$profile
null string $profile
Current search profile.
Definition: SpecialSearch.php:47
SpecialSearch\powerSearch
powerSearch(&$request)
Extract "power search" namespace settings from the request object, returning a list of index numbers ...
Definition: SpecialSearch.php:654
wfEscapeWikiText
wfEscapeWikiText( $text)
Escapes the given text so that it may be output using addWikiText() without any linking,...
Definition: GlobalFunctions.php:1487
SpecialSearch\getProfile
getProfile()
Current search profile.
Definition: SpecialSearch.php:790
MediaWiki\Search\SearchWidgets\SimpleSearchResultSetWidget
Renders one or more ISearchResultSets into a sidebar grouped by interwiki prefix.
Definition: SimpleSearchResultSetWidget.php:19
MediaWiki\Search\SearchWidgets\SimpleSearchResultWidget
Renders a simple one-line result.
Definition: SimpleSearchResultWidget.php:15
SearchEngine
Contain a class for special pages Stable to extend.
Definition: SearchEngine.php:37
SpecialSearch\$extraParams
array $extraParams
For links.
Definition: SpecialSearch.php:56
SpecialPage\getLinkRenderer
getLinkRenderer()
Definition: SpecialPage.php:944
SpecialSearch\powerSearchOptions
powerSearchOptions()
Reconstruct the 'power search' options for links TODO: Instead of exposing this publicly,...
Definition: SpecialSearch.php:672
SpecialSearch\goResult
goResult( $term)
If an exact title match can be found, jump straight ahead to it.
Definition: SpecialSearch.php:283
SpecialSearch\$namespaces
array $namespaces
Definition: SpecialSearch.php:72
SpecialSearch\getSearchEngine
getSearchEngine()
Definition: SpecialSearch.php:775
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:811
SpecialSearch\load
load()
Set up basic search parameters from the request and user settings.
Definition: SpecialSearch.php:212
ISearchResultSet\SECONDARY_RESULTS
const SECONDARY_RESULTS
Identifier for interwiki results that are displayed only together with existing main wiki results.
Definition: ISearchResultSet.php:17
SearchEngineConfig
Configuration handling class for SearchEngine.
Definition: SearchEngineConfig.php:12
SpecialSearch\$mPrefix
string $mPrefix
The prefix url parameter.
Definition: SpecialSearch.php:62
SpecialSearch\showCreateLink
showCreateLink( $title, $num, $titleMatches, $textMatches)
Definition: SpecialSearch.php:531
SpecialPage\$linkRenderer
MediaWiki Linker LinkRenderer null $linkRenderer
Definition: SpecialPage.php:71
DeferredUpdates\addCallableUpdate
static addCallableUpdate( $callable, $stage=self::POSTSEND, $dbw=null)
Add a callable update.
Definition: DeferredUpdates.php:145
SpecialSearch\showResults
showResults( $term)
Definition: SpecialSearch.php:331
$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:9538
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:662
SpecialSearch\redirectOnExactMatch
redirectOnExactMatch()
Definition: SpecialSearch.php:316
MediaWiki\Search\SearchWidgets\FullSearchResultWidget
Renders a 'full' multi-line search result with metadata.
Definition: FullSearchResultWidget.php:22