MediaWiki  master
SpecialSearch.php
Go to the documentation of this file.
1 <?php
36 
41 class SpecialSearch extends SpecialPage {
50  protected $profile;
51 
53  protected $searchEngine;
54 
56  protected $searchEngineType = null;
57 
59  protected $extraParams = [];
60 
65  protected $mPrefix;
66 
70  protected $limit, $offset;
71 
75  protected $namespaces;
76 
80  protected $fulltext;
81 
86 
90  protected $runSuggestion = true;
91 
96  protected $searchConfig;
97 
100 
103 
105  private $nsInfo;
106 
109 
112 
114  private $readOnlyMode;
115 
118 
123  private $loadStatus;
124 
125  private const NAMESPACES_CURRENT = 'sense';
126 
137  public function __construct(
146  ) {
147  parent::__construct( 'Search' );
148  $this->searchConfig = $searchConfig;
149  $this->searchEngineFactory = $searchEngineFactory;
150  $this->permissionManager = $permissionManager;
151  $this->nsInfo = $nsInfo;
152  $this->contentHandlerFactory = $contentHandlerFactory;
153  $this->interwikiLookup = $interwikiLookup;
154  $this->readOnlyMode = $readOnlyMode;
155  $this->userOptionsManager = $userOptionsManager;
156  }
157 
163  public function execute( $par ) {
164  $request = $this->getRequest();
165  $out = $this->getOutput();
166 
167  // Fetch the search term
168  $term = str_replace( "\n", " ", $request->getText( 'search' ) );
169 
170  // Historically search terms have been accepted not only in the search query
171  // parameter, but also as part of the primary url. This can have PII implications
172  // in releasing page view data. As such issue a 301 redirect to the correct
173  // URL.
174  if ( $par !== null && $par !== '' && $term === '' ) {
175  $query = $request->getValues();
176  unset( $query['title'] );
177  // Strip underscores from title parameter; most of the time we'll want
178  // text form here. But don't strip underscores from actual text params!
179  $query['search'] = str_replace( '_', ' ', $par );
180  $out->redirect( $this->getPageTitle()->getFullURL( $query ), 301 );
181  return;
182  }
183 
184  // Need to load selected namespaces before handling nsRemember
185  $this->load();
186  // TODO: This performs database actions on GET request, which is going to
187  // be a problem for our multi-datacenter work.
188  if ( $request->getCheck( 'nsRemember' ) ) {
189  $this->saveNamespaces();
190  // Remove the token from the URL to prevent the user from inadvertently
191  // exposing it (e.g. by pasting it into a public wiki page) or undoing
192  // later settings changes (e.g. by reloading the page).
193  $query = $request->getValues();
194  unset( $query['title'], $query['nsRemember'] );
195  $out->redirect( $this->getPageTitle()->getFullURL( $query ) );
196  return;
197  }
198 
199  $this->searchEngineType = $request->getVal( 'srbackend' );
200  if ( !$request->getVal( 'fulltext' ) && !$request->getCheck( 'offset' ) ) {
201  $url = $this->goResult( $term );
202  if ( $url !== null ) {
203  // successful 'go'
204  $out->redirect( $url );
205  return;
206  }
207  // No match. If it could plausibly be a title
208  // run the No go match hook.
209  $title = Title::newFromText( $term );
210  if ( $title !== null ) {
211  $this->getHookRunner()->onSpecialSearchNogomatch( $title );
212  }
213  }
214 
215  $this->setupPage( $term );
216 
217  if ( $this->getConfig()->get( 'DisableTextSearch' ) ) {
218  $searchForwardUrl = $this->getConfig()->get( 'SearchForwardUrl' );
219  if ( $searchForwardUrl ) {
220  $url = str_replace( '$1', urlencode( $term ), $searchForwardUrl );
221  $out->redirect( $url );
222  } else {
223  $this->showGoogleSearch( $term );
224  }
225 
226  return;
227  }
228 
229  $this->showResults( $term );
230  }
231 
239  private function showGoogleSearch( $term ) {
240  $this->getOutput()->addHTML(
241  "<fieldset>" .
242  "<legend>" .
243  $this->msg( 'search-external' )->escaped() .
244  "</legend>" .
245  "<p class='mw-searchdisabled'>" .
246  $this->msg( 'searchdisabled' )->escaped() .
247  "</p>" .
248  $this->msg( 'googlesearch' )->rawParams(
249  htmlspecialchars( $term ),
250  'UTF-8',
251  $this->msg( 'searchbutton' )->escaped()
252  )->text() .
253  "</fieldset>"
254  );
255  }
256 
262  public function load() {
263  $this->loadStatus = new Status();
264 
265  $request = $this->getRequest();
266  list( $this->limit, $this->offset ) = $request->getLimitOffsetForUser(
267  $this->getUser(),
268  20,
269  ''
270  );
271  $this->mPrefix = $request->getVal( 'prefix', '' );
272  if ( $this->mPrefix !== '' ) {
273  $this->setExtraParam( 'prefix', $this->mPrefix );
274  }
275 
276  $sort = $request->getVal( 'sort', SearchEngine::DEFAULT_SORT );
277  $validSorts = $this->getSearchEngine()->getValidSorts();
278  if ( !in_array( $sort, $validSorts ) ) {
279  $this->loadStatus->warning( 'search-invalid-sort-order', $sort,
280  implode( ', ', $validSorts ) );
281  } elseif ( $sort !== $this->sort ) {
282  $this->sort = $sort;
283  $this->setExtraParam( 'sort', $this->sort );
284  }
285 
286  $user = $this->getUser();
287 
288  # Extract manually requested namespaces
289  $nslist = $this->powerSearch( $request );
290  if ( $nslist === [] ) {
291  # Fallback to user preference
292  $nslist = $this->searchConfig->userNamespaces( $user );
293  }
294 
295  $profile = null;
296  if ( $nslist === [] ) {
297  $profile = 'default';
298  }
299 
300  $profile = $request->getVal( 'profile', $profile );
301  $profiles = $this->getSearchProfiles();
302  if ( $profile === null ) {
303  // BC with old request format
304  $profile = 'advanced';
305  foreach ( $profiles as $key => $data ) {
306  if ( $nslist === $data['namespaces'] && $key !== 'advanced' ) {
307  $profile = $key;
308  }
309  }
310  $this->namespaces = $nslist;
311  } elseif ( $profile === 'advanced' ) {
312  $this->namespaces = $nslist;
313  } elseif ( isset( $profiles[$profile]['namespaces'] ) ) {
314  $this->namespaces = $profiles[$profile]['namespaces'];
315  } else {
316  // Unknown profile requested
317  $this->loadStatus->warning( 'search-unknown-profile', $profile );
318  $profile = 'default';
319  $this->namespaces = $profiles['default']['namespaces'];
320  }
321 
322  $this->fulltext = $request->getVal( 'fulltext' );
323  $this->runSuggestion = (bool)$request->getVal( 'runsuggestion', true );
324  $this->profile = $profile;
325  }
326 
333  public function goResult( $term ) {
334  # If the string cannot be used to create a title
335  if ( Title::newFromText( $term ) === null ) {
336  return null;
337  }
338  # If there's an exact or very near match, jump right there.
339  $title = $this->getSearchEngine()
340  ->getNearMatcher( $this->getConfig() )->getNearMatch( $term );
341  if ( $title === null ) {
342  return null;
343  }
344  $url = null;
345  if ( !$this->getHookRunner()->onSpecialSearchGoResult( $term, $title, $url ) ) {
346  return null;
347  }
348 
349  if (
350  // If there is a preference set to NOT redirect on exact page match
351  // then return null (which prevents direction)
352  !$this->redirectOnExactMatch()
353  // BUT ...
354  // ... ignore no-redirect preference if the exact page match is an interwiki link
355  && !$title->isExternal()
356  // ... ignore no-redirect preference if the exact page match is NOT in the main
357  // namespace AND there's a namespace in the search string
358  && !( $title->getNamespace() !== NS_MAIN && strpos( $term, ':' ) > 0 )
359  ) {
360  return null;
361  }
362 
363  return $url ?? $title->getFullUrlForRedirect();
364  }
365 
366  private function redirectOnExactMatch() {
369  // If the preference for whether to redirect is disabled, use the default setting
370  $defaultOptions = $this->userOptionsManager->getDefaultOptions();
371  return $defaultOptions['search-match-redirect'];
372  } else {
373  // Otherwise use the user's preference
374  return $this->userOptionsManager->getOption( $this->getUser(), 'search-match-redirect' );
375  }
376  }
377 
381  public function showResults( $term ) {
382  if ( $this->searchEngineType !== null ) {
383  $this->setExtraParam( 'srbackend', $this->searchEngineType );
384  }
385 
386  $out = $this->getOutput();
387  $widgetOptions = $this->getConfig()->get( 'SpecialSearchFormOptions' );
389  $this,
390  $this->searchConfig,
391  $this->getHookContainer(),
392  $this->getSearchProfiles()
393  );
394  $filePrefix = $this->getContentLanguage()->getFormattedNsText( NS_FILE ) . ':';
395  if ( trim( $term ) === '' || $filePrefix === trim( $term ) ) {
396  // Empty query -- straight view of search form
397  if ( !$this->getHookRunner()->onSpecialSearchResultsPrepend( $this, $out, $term ) ) {
398  # Hook requested termination
399  return;
400  }
401  $out->enableOOUI();
402  // The form also contains the 'Showing results 0 - 20 of 1234' so we can
403  // only do the form render here for the empty $term case. Rendering
404  // the form when a search is provided is repeated below.
405  $out->addHTML( $formWidget->render(
406  $this->profile, $term, 0, 0, $this->offset, $this->isPowerSearch(), $widgetOptions
407  ) );
408  return;
409  }
410 
411  $engine = $this->getSearchEngine();
412  $engine->setFeatureData( 'rewrite', $this->runSuggestion );
413  $engine->setLimitOffset( $this->limit, $this->offset );
414  $engine->setNamespaces( $this->namespaces );
415  $engine->setSort( $this->sort );
416  $engine->prefix = $this->mPrefix;
417 
418  $this->getHookRunner()->onSpecialSearchSetupEngine( $this, $this->profile, $engine );
419  if ( !$this->getHookRunner()->onSpecialSearchResultsPrepend( $this, $out, $term ) ) {
420  # Hook requested termination
421  return;
422  }
423 
424  $title = Title::newFromText( $term );
425  $showSuggestion = $title === null || !$title->isKnown();
426  $engine->setShowSuggestion( $showSuggestion );
427 
428  $rewritten = $engine->replacePrefixes( $term );
429  if ( $rewritten !== $term ) {
430  wfDeprecatedMsg( 'SearchEngine::replacePrefixes() was overridden by ' .
431  get_class( $engine ) . ', this is deprecated since MediaWiki 1.32',
432  '1.32', false, false );
433  }
434 
435  // fetch search results
436  $titleMatches = $engine->searchTitle( $rewritten );
437  $textMatches = $engine->searchText( $rewritten );
438 
439  $textStatus = null;
440  if ( $textMatches instanceof Status ) {
441  $textStatus = $textMatches;
442  $textMatches = $textStatus->getValue();
443  }
444 
445  // Get number of results
446  $titleMatchesNum = $textMatchesNum = $numTitleMatches = $numTextMatches = 0;
447  if ( $titleMatches ) {
448  $titleMatchesNum = $titleMatches->numRows();
449  $numTitleMatches = $titleMatches->getTotalHits();
450  }
451  if ( $textMatches ) {
452  $textMatchesNum = $textMatches->numRows();
453  $numTextMatches = $textMatches->getTotalHits();
454  if ( $textMatchesNum > 0 ) {
455  $engine->augmentSearchResults( $textMatches );
456  }
457  }
458  $num = $titleMatchesNum + $textMatchesNum;
459  $totalRes = $numTitleMatches + $numTextMatches;
460 
461  // start rendering the page
462  $out->enableOOUI();
463  $out->addHTML( $formWidget->render(
464  $this->profile, $term, $num, $totalRes, $this->offset, $this->isPowerSearch(), $widgetOptions
465  ) );
466 
467  // did you mean... suggestions
468  if ( $textMatches ) {
469  $dymWidget = new MediaWiki\Search\SearchWidgets\DidYouMeanWidget( $this );
470  $out->addHTML( $dymWidget->render( $term, $textMatches ) );
471  }
472 
473  $hasSearchErrors = $textStatus && $textStatus->getErrors() !== [];
474  $hasOtherResults = $textMatches &&
475  $textMatches->hasInterwikiResults( ISearchResultSet::INLINE_RESULTS );
476 
477  if ( $textMatches && $textMatches->hasInterwikiResults( ISearchResultSet::SECONDARY_RESULTS ) ) {
478  $out->addHTML( '<div class="searchresults mw-searchresults-has-iw">' );
479  } else {
480  $out->addHTML( '<div class="searchresults">' );
481  }
482 
483  if ( $hasSearchErrors || $this->loadStatus->getErrors() ) {
484  if ( $textStatus === null ) {
485  $textStatus = $this->loadStatus;
486  } else {
487  $textStatus->merge( $this->loadStatus );
488  }
489  list( $error, $warning ) = $textStatus->splitByErrorType();
490  if ( $error->getErrors() ) {
491  $out->addHTML( Html::errorBox(
492  $error->getHTML( 'search-error' )
493  ) );
494  }
495  if ( $warning->getErrors() ) {
496  $out->addHTML( Html::warningBox(
497  $warning->getHTML( 'search-warning' )
498  ) );
499  }
500  }
501 
502  // Show the create link ahead
503  $this->showCreateLink( $title, $num, $titleMatches, $textMatches );
504 
505  $this->getHookRunner()->onSpecialSearchResults( $term, $titleMatches, $textMatches );
506 
507  // If we have no results and have not already displayed an error message
508  if ( $num === 0 && !$hasSearchErrors ) {
509  $out->wrapWikiMsg( "<p class=\"mw-search-nonefound\">\n$1</p>", [
510  $hasOtherResults ? 'search-nonefound-thiswiki' : 'search-nonefound',
511  wfEscapeWikiText( $term )
512  ] );
513  }
514 
515  // Although $num might be 0 there can still be secondary or inline
516  // results to display.
517  $linkRenderer = $this->getLinkRenderer();
518  $mainResultWidget = new FullSearchResultWidget(
519  $this, $linkRenderer, $this->getHookContainer() );
520 
521  // Default (null) on. Can be explicitly disabled.
522  if ( $engine->getFeatureData( 'enable-new-crossproject-page' ) !== false ) {
523  $sidebarResultWidget = new InterwikiSearchResultWidget( $this, $linkRenderer );
524  $sidebarResultsWidget = new InterwikiSearchResultSetWidget(
525  $this,
526  $sidebarResultWidget,
528  $this->interwikiLookup,
529  $engine->getFeatureData( 'show-multimedia-search-results' )
530  );
531  } else {
532  $sidebarResultWidget = new SimpleSearchResultWidget( $this, $linkRenderer );
533  $sidebarResultsWidget = new SimpleSearchResultSetWidget(
534  $this,
535  $sidebarResultWidget,
537  $this->interwikiLookup
538  );
539  }
540 
541  $widget = new BasicSearchResultSetWidget( $this, $mainResultWidget, $sidebarResultsWidget );
542 
543  $out->addHTML( $widget->render(
544  $term, $this->offset, $titleMatches, $textMatches
545  ) );
546 
547  $out->addHTML( '<div class="mw-search-visualclear"></div>' );
548 
549  // prev/next links
550  if ( $totalRes > $this->limit || $this->offset ) {
551  // Allow matches to define the correct offset, as interleaved
552  // AB testing may require a different next page offset.
553  if ( $textMatches && $textMatches->getOffset() !== null ) {
554  $offset = $textMatches->getOffset();
555  } else {
557  }
558 
559  $prevNext = $this->buildPrevNextNavigation(
560  $offset,
561  $this->limit,
562  $this->powerSearchOptions() + [ 'search' => $term ],
563  $this->limit + $this->offset >= $totalRes
564  );
565  $out->addHTML( "<p class='mw-search-pager-bottom'>{$prevNext}</p>\n" );
566  }
567 
568  // Close <div class='searchresults'>
569  $out->addHTML( "</div>" );
570 
571  $this->getHookRunner()->onSpecialSearchResultsAppend( $this, $out, $term );
572  }
573 
580  protected function showCreateLink( $title, $num, $titleMatches, $textMatches ) {
581  // show direct page/create link if applicable
582 
583  // Check DBkey !== '' in case of fragment link only.
584  if ( $title === null || $title->getDBkey() === ''
585  || ( $titleMatches !== null && $titleMatches->searchContainedSyntax() )
586  || ( $textMatches !== null && $textMatches->searchContainedSyntax() )
587  ) {
588  // invalid title
589  // preserve the paragraph for margins etc...
590  $this->getOutput()->addHTML( '<p></p>' );
591 
592  return;
593  }
594 
595  $messageName = 'searchmenu-new-nocreate';
596  $linkClass = 'mw-search-createlink';
597 
598  if ( !$title->isExternal() ) {
599  if ( $title->isKnown() ) {
600  $messageName = 'searchmenu-exists';
601  $linkClass = 'mw-search-exists';
602  } elseif (
603  $this->contentHandlerFactory->getContentHandler( $title->getContentModel() )
604  ->supportsDirectEditing()
605  && $this->permissionManager->quickUserCan( 'create', $this->getUser(), $title )
606  && $this->permissionManager->quickUserCan( 'edit', $this->getUser(), $title )
607  ) {
608  $messageName = 'searchmenu-new';
609  }
610  }
611 
612  $params = [
613  $messageName,
614  wfEscapeWikiText( $title->getPrefixedText() ),
615  Message::numParam( $num )
616  ];
617  $this->getHookRunner()->onSpecialSearchCreateLink( $title, $params );
618 
619  // Extensions using the hook might still return an empty $messageName
620  // @phan-suppress-next-line PhanRedundantCondition Set by hook
621  if ( $messageName ) {
622  $this->getOutput()->wrapWikiMsg( "<p class=\"$linkClass\">\n$1</p>", $params );
623  } else {
624  // preserve the paragraph for margins etc...
625  $this->getOutput()->addHTML( '<p></p>' );
626  }
627  }
628 
635  protected function setupPage( $term ) {
636  $out = $this->getOutput();
637 
638  $this->setHeaders();
639  $this->outputHeader();
640  // TODO: Is this true? The namespace remember uses a user token
641  // on save.
642  $out->allowClickjacking();
643  $this->addHelpLink( 'Help:Searching' );
644 
645  if ( strval( $term ) !== '' ) {
646  $out->setPageTitle( $this->msg( 'searchresults' ) );
647  $out->setHTMLTitle( $this->msg( 'pagetitle' )
648  ->plaintextParams( $this->msg( 'searchresults-title' )->plaintextParams( $term )->text() )
649  ->inContentLanguage()->text()
650  );
651  }
652 
653  if ( $this->mPrefix !== '' ) {
654  $subtitle = $this->msg( 'search-filter-title-prefix' )->plaintextParams( $this->mPrefix );
655  $params = $this->powerSearchOptions();
656  unset( $params['prefix'] );
657  $params += [
658  'search' => $term,
659  'fulltext' => 1,
660  ];
661 
662  $subtitle .= ' (';
663  $subtitle .= Xml::element(
664  'a',
665  [
666  'href' => $this->getPageTitle()->getLocalURL( $params ),
667  'title' => $this->msg( 'search-filter-title-prefix-reset' )->text(),
668  ],
669  $this->msg( 'search-filter-title-prefix-reset' )->text()
670  );
671  $subtitle .= ')';
672  $out->setSubtitle( $subtitle );
673  }
674 
675  $out->addJsConfigVars( [ 'searchTerm' => $term ] );
676  $out->addModules( 'mediawiki.special.search' );
677  $out->addModuleStyles( [
678  'mediawiki.special', 'mediawiki.special.search.styles', 'mediawiki.ui', 'mediawiki.ui.button',
679  'mediawiki.ui.input', 'mediawiki.widgets.SearchInputWidget.styles',
680  ] );
681  }
682 
688  protected function isPowerSearch() {
689  return $this->profile === 'advanced';
690  }
691 
699  protected function powerSearch( &$request ) {
700  $arr = [];
701  foreach ( $this->searchConfig->searchableNamespaces() as $ns => $name ) {
702  if ( $request->getCheck( 'ns' . $ns ) ) {
703  $arr[] = $ns;
704  }
705  }
706 
707  return $arr;
708  }
709 
717  public function powerSearchOptions() {
718  $opt = [];
719  if ( $this->isPowerSearch() ) {
720  foreach ( $this->namespaces as $n ) {
721  $opt['ns' . $n] = 1;
722  }
723  } else {
724  $opt['profile'] = $this->profile;
725  }
726 
727  return $opt + $this->extraParams;
728  }
729 
735  protected function saveNamespaces() {
736  $user = $this->getUser();
737  $request = $this->getRequest();
738 
739  if ( $user->isLoggedIn() &&
740  $user->matchEditToken(
741  $request->getVal( 'nsRemember' ),
742  'searchnamespace',
743  $request
744  ) && !$this->readOnlyMode->isReadOnly()
745  ) {
746  // Reset namespace preferences: namespaces are not searched
747  // when they're not mentioned in the URL parameters.
748  foreach ( $this->nsInfo->getValidNamespaces() as $n ) {
749  $this->userOptionsManager->setOption( $user, 'searchNs' . $n, false );
750  }
751  // The request parameters include all the namespaces to be searched.
752  // Even if they're the same as an existing profile, they're not eaten.
753  foreach ( $this->namespaces as $n ) {
754  $this->userOptionsManager->setOption( $user, 'searchNs' . $n, true );
755  }
756 
757  DeferredUpdates::addCallableUpdate( function () use ( $user ) {
758  $user->saveSettings();
759  } );
760 
761  return true;
762  }
763 
764  return false;
765  }
766 
771  protected function getSearchProfiles() {
772  // Builds list of Search Types (profiles)
773  $nsAllSet = array_keys( $this->searchConfig->searchableNamespaces() );
774  $defaultNs = $this->searchConfig->defaultNamespaces();
775  $profiles = [
776  'default' => [
777  'message' => 'searchprofile-articles',
778  'tooltip' => 'searchprofile-articles-tooltip',
779  'namespaces' => $defaultNs,
780  'namespace-messages' => $this->searchConfig->namespacesAsText(
781  $defaultNs
782  ),
783  ],
784  'images' => [
785  'message' => 'searchprofile-images',
786  'tooltip' => 'searchprofile-images-tooltip',
787  'namespaces' => [ NS_FILE ],
788  ],
789  'all' => [
790  'message' => 'searchprofile-everything',
791  'tooltip' => 'searchprofile-everything-tooltip',
792  'namespaces' => $nsAllSet,
793  ],
794  'advanced' => [
795  'message' => 'searchprofile-advanced',
796  'tooltip' => 'searchprofile-advanced-tooltip',
797  'namespaces' => self::NAMESPACES_CURRENT,
798  ]
799  ];
800 
801  $this->getHookRunner()->onSpecialSearchProfiles( $profiles );
802 
803  foreach ( $profiles as &$data ) {
804  if ( !is_array( $data['namespaces'] ) ) {
805  continue;
806  }
807  sort( $data['namespaces'] );
808  }
809 
810  return $profiles;
811  }
812 
818  public function getSearchEngine() {
819  if ( $this->searchEngine === null ) {
820  $this->searchEngine = $this->searchEngineFactory->create( $this->searchEngineType );
821  }
822 
823  return $this->searchEngine;
824  }
825 
830  public function getProfile() {
831  return $this->profile;
832  }
833 
838  public function getNamespaces() {
839  return $this->namespaces;
840  }
841 
851  public function setExtraParam( $key, $value ) {
852  $this->extraParams[$key] = $value;
853  }
854 
863  public function getPrefix() {
864  return $this->mPrefix;
865  }
866 
867  protected function getGroupName() {
868  return 'pages';
869  }
870 }
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\__construct
__construct(SearchEngineConfig $searchConfig, SearchEngineFactory $searchEngineFactory, PermissionManager $permissionManager, NamespaceInfo $nsInfo, IContentHandlerFactory $contentHandlerFactory, InterwikiLookup $interwikiLookup, ReadOnlyMode $readOnlyMode, UserOptionsManager $userOptionsManager)
Definition: SpecialSearch.php:137
SpecialPage\$linkRenderer
LinkRenderer null $linkRenderer
Definition: SpecialPage.php:79
SpecialSearch\getNamespaces
getNamespaces()
Current namespaces.
Definition: SpecialSearch.php:838
SpecialPage\getPageTitle
getPageTitle( $subpage=false)
Get a self-referential title object.
Definition: SpecialPage.php:742
Message\numParam
static numParam( $num)
Definition: Message.php:1035
SpecialPage\msg
msg( $key,... $params)
Wrapper around wfMessage that sets the current context.
Definition: SpecialPage.php:900
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:328
MediaWiki\Search\SearchWidgets\SearchFormWidget
Definition: SearchFormWidget.php:14
SpecialSearch\$fulltext
string $fulltext
Definition: SpecialSearch.php:80
SpecialPage\getOutput
getOutput()
Get the OutputPage being used for this instance.
Definition: SpecialPage.php:788
SpecialSearch\$sort
string $sort
Definition: SpecialSearch.php:85
MediaWiki\Search\SearchWidgets\InterwikiSearchResultSetWidget
Renders one or more ISearchResultSets into a sidebar grouped by interwiki prefix.
Definition: InterwikiSearchResultSetWidget.php:18
SpecialSearch\$limit
int $limit
Definition: SpecialSearch.php:70
MediaWiki\Search\SearchWidgets\InterwikiSearchResultWidget
Renders an enhanced interwiki result.
Definition: InterwikiSearchResultWidget.php:14
ReadOnlyMode
A service class for fetching the wiki's current read-only mode.
Definition: ReadOnlyMode.php:11
NS_FILE
const NS_FILE
Definition: Defines.php:75
SearchEngineFactory
Factory class for SearchEngine.
Definition: SearchEngineFactory.php:13
SpecialSearch\$loadStatus
Status $loadStatus
Holds any parameter validation errors that should be displayed back to the user.
Definition: SpecialSearch.php:123
SpecialPage\getHookContainer
getHookContainer()
Definition: SpecialPage.php:1070
Html\warningBox
static warningBox( $html, $className='')
Return a warning box.
Definition: Html.php:729
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:863
SpecialSearch\isPowerSearch
isPowerSearch()
Return true if current search is a power (advanced) search.
Definition: SpecialSearch.php:688
SpecialSearch\setupPage
setupPage( $term)
Sets up everything for the HTML output page including styles, javascript, page title,...
Definition: SpecialSearch.php:635
SpecialSearch\getSearchProfiles
getSearchProfiles()
Definition: SpecialSearch.php:771
SearchEngine\DEFAULT_SORT
const DEFAULT_SORT
Definition: SearchEngine.php:38
SpecialSearch\NAMESPACES_CURRENT
const NAMESPACES_CURRENT
Definition: SpecialSearch.php:125
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:936
wfDeprecatedMsg
wfDeprecatedMsg( $msg, $version=false, $component=false, $callerOffset=2)
Log a deprecation warning with arbitrary message text.
Definition: GlobalFunctions.php:1059
SpecialPage\getHookRunner
getHookRunner()
Definition: SpecialPage.php:1083
SpecialPage\getConfig
getConfig()
Shortcut to get main config object.
Definition: SpecialPage.php:866
SpecialSearch\getGroupName
getGroupName()
Under which header this special page is listed in Special:SpecialPages See messages 'specialpages-gro...
Definition: SpecialSearch.php:867
SpecialSearch\$runSuggestion
bool $runSuggestion
Definition: SpecialSearch.php:90
MediaWiki\Interwiki\InterwikiLookup
Service interface for looking up Interwiki records.
Definition: InterwikiLookup.php:32
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:616
SpecialSearch\$offset
int $offset
Definition: SpecialSearch.php:70
SpecialPage\getUser
getUser()
Shortcut to get the User executing this instance.
Definition: SpecialPage.php:798
SpecialSearch\$permissionManager
PermissionManager $permissionManager
Definition: SpecialSearch.php:102
SpecialSearch\saveNamespaces
saveNamespaces()
Save namespace preferences when we're supposed to.
Definition: SpecialSearch.php:735
SpecialSearch\$interwikiLookup
InterwikiLookup $interwikiLookup
Definition: SpecialSearch.php:111
Html\errorBox
static errorBox( $html, $heading='', $className='')
Return an error box.
Definition: Html.php:742
SpecialSearch\$searchConfig
SearchEngineConfig $searchConfig
Search engine configurations.
Definition: SpecialSearch.php:96
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:239
SpecialSearch\$searchEngine
SearchEngine $searchEngine
Search engine.
Definition: SpecialSearch.php:53
SpecialSearch\execute
execute( $par)
Entry point.
Definition: SpecialSearch.php:163
MediaWiki\Permissions\PermissionManager
A service class for checking permissions To obtain an instance, use MediaWikiServices::getInstance()-...
Definition: PermissionManager.php:50
MediaWiki\Content\IContentHandlerFactory
Definition: IContentHandlerFactory.php:10
SpecialPage
Parent class for all special pages.
Definition: SpecialPage.php:42
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:1043
SpecialSearch
implements Special:Search - Run text & title search and display the output
Definition: SpecialSearch.php:41
SpecialPage\getRequest
getRequest()
Get the WebRequest being used for this instance.
Definition: SpecialPage.php:778
SpecialSearch\$profile
null string $profile
Current search profile.
Definition: SpecialSearch.php:50
SpecialSearch\powerSearch
powerSearch(&$request)
Extract "power search" namespace settings from the request object, returning a list of index numbers ...
Definition: SpecialSearch.php:699
wfEscapeWikiText
wfEscapeWikiText( $text)
Escapes the given text so that it may be output using addWikiText() without any linking,...
Definition: GlobalFunctions.php:1494
SpecialSearch\getProfile
getProfile()
Current search profile.
Definition: SpecialSearch.php:830
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\$contentHandlerFactory
IContentHandlerFactory $contentHandlerFactory
Definition: SpecialSearch.php:108
MediaWiki\User\UserOptionsManager
A service class to control user options.
Definition: UserOptionsManager.php:44
SpecialSearch\$extraParams
array $extraParams
For links.
Definition: SpecialSearch.php:59
SpecialPage\getLinkRenderer
getLinkRenderer()
Definition: SpecialPage.php:1016
SpecialSearch\$userOptionsManager
UserOptionsManager $userOptionsManager
Definition: SpecialSearch.php:117
SpecialSearch\powerSearchOptions
powerSearchOptions()
Reconstruct the 'power search' options for links TODO: Instead of exposing this publicly,...
Definition: SpecialSearch.php:717
SpecialSearch\goResult
goResult( $term)
If an exact title match can be found, jump straight ahead to it.
Definition: SpecialSearch.php:333
SpecialSearch\$namespaces
array $namespaces
Definition: SpecialSearch.php:75
SpecialSearch\$nsInfo
NamespaceInfo $nsInfo
Definition: SpecialSearch.php:105
SpecialSearch\getSearchEngine
getSearchEngine()
Definition: SpecialSearch.php:818
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:851
SpecialSearch\load
load()
Set up basic search parameters from the request and user settings.
Definition: SpecialSearch.php:262
ISearchResultSet\SECONDARY_RESULTS
const SECONDARY_RESULTS
Identifier for interwiki results that are displayed only together with existing main wiki results.
Definition: ISearchResultSet.php:17
SpecialSearch\$readOnlyMode
ReadOnlyMode $readOnlyMode
Definition: SpecialSearch.php:114
SearchEngineConfig
Configuration handling class for SearchEngine.
Definition: SearchEngineConfig.php:12
SpecialSearch\$mPrefix
string $mPrefix
The prefix url parameter.
Definition: SpecialSearch.php:65
SpecialSearch\showCreateLink
showCreateLink( $title, $num, $titleMatches, $textMatches)
Definition: SpecialSearch.php:580
NamespaceInfo
This is a utility class for dealing with namespaces that encodes all the "magic" behaviors of them ba...
Definition: NamespaceInfo.php:35
SpecialPage\getContentLanguage
getContentLanguage()
Shortcut to get content language.
Definition: SpecialPage.php:828
SpecialSearch\$searchEngineFactory
SearchEngineFactory $searchEngineFactory
Definition: SpecialSearch.php:99
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:381
$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:9555
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:707
SpecialSearch\redirectOnExactMatch
redirectOnExactMatch()
Definition: SpecialSearch.php:366
MediaWiki\Search\SearchWidgets\FullSearchResultWidget
Renders a 'full' multi-line search result with metadata.
Definition: FullSearchResultWidget.php:22
SpecialSearch\$searchEngineType
string null $searchEngineType
Search engine type, if not default.
Definition: SpecialSearch.php:56