MediaWiki  REL1_31
SpecialSearch.php
Go to the documentation of this file.
1 <?php
33 
38 class SpecialSearch extends SpecialPage {
47  protected $profile;
48 
50  protected $searchEngine;
51 
53  protected $searchEngineType;
54 
56  protected $extraParams = [];
57 
62  protected $mPrefix;
63 
67  protected $limit, $offset;
68 
72  protected $namespaces;
73 
77  protected $fulltext;
78 
82  protected $runSuggestion = true;
83 
88  protected $searchConfig;
89 
90  const NAMESPACES_CURRENT = 'sense';
91 
92  public function __construct() {
93  parent::__construct( 'Search' );
94  $this->searchConfig = MediaWikiServices::getInstance()->getSearchEngineConfig();
95  }
96 
102  public function execute( $par ) {
103  $request = $this->getRequest();
104  $out = $this->getOutput();
105 
106  // Fetch the search term
107  $term = str_replace( "\n", " ", $request->getText( 'search' ) );
108 
109  // Historically search terms have been accepted not only in the search query
110  // parameter, but also as part of the primary url. This can have PII implications
111  // in releasing page view data. As such issue a 301 redirect to the correct
112  // URL.
113  if ( strlen( $par ) && !strlen( $term ) ) {
114  $query = $request->getValues();
115  unset( $query['title'] );
116  // Strip underscores from title parameter; most of the time we'll want
117  // text form here. But don't strip underscores from actual text params!
118  $query['search'] = str_replace( '_', ' ', $par );
119  $out->redirect( $this->getPageTitle()->getFullURL( $query ), 301 );
120  return;
121  }
122 
123  // Need to load selected namespaces before handling nsRemember
124  $this->load();
125  // TODO: This performs database actions on GET request, which is going to
126  // be a problem for our multi-datacenter work.
127  if ( !is_null( $request->getVal( 'nsRemember' ) ) ) {
128  $this->saveNamespaces();
129  // Remove the token from the URL to prevent the user from inadvertently
130  // exposing it (e.g. by pasting it into a public wiki page) or undoing
131  // later settings changes (e.g. by reloading the page).
132  $query = $request->getValues();
133  unset( $query['title'], $query['nsRemember'] );
134  $out->redirect( $this->getPageTitle()->getFullURL( $query ) );
135  return;
136  }
137 
138  $this->searchEngineType = $request->getVal( 'srbackend' );
139  if (
140  !$request->getVal( 'fulltext' ) &&
141  $request->getVal( 'offset' ) === null
142  ) {
143  $url = $this->goResult( $term );
144  if ( $url !== null ) {
145  // successful 'go'
146  $out->redirect( $url );
147  return;
148  }
149  // No match. If it could plausibly be a title
150  // run the No go match hook.
152  if ( !is_null( $title ) ) {
153  Hooks::run( 'SpecialSearchNogomatch', [ &$title ] );
154  }
155  }
156 
157  $this->setupPage( $term );
158 
159  if ( $this->getConfig()->get( 'DisableTextSearch' ) ) {
160  $searchForwardUrl = $this->getConfig()->get( 'SearchForwardUrl' );
161  if ( $searchForwardUrl ) {
162  $url = str_replace( '$1', urlencode( $term ), $searchForwardUrl );
163  $out->redirect( $url );
164  } else {
165  $out->addHTML(
166  "<fieldset>" .
167  "<legend>" .
168  $this->msg( 'search-external' )->escaped() .
169  "</legend>" .
170  "<p class='mw-searchdisabled'>" .
171  $this->msg( 'searchdisabled' )->escaped() .
172  "</p>" .
173  $this->msg( 'googlesearch' )->rawParams(
174  htmlspecialchars( $term ),
175  'UTF-8',
176  $this->msg( 'searchbutton' )->escaped()
177  )->text() .
178  "</fieldset>"
179  );
180  }
181 
182  return;
183  }
184 
185  $this->showResults( $term );
186  }
187 
193  public function load() {
194  $request = $this->getRequest();
195  list( $this->limit, $this->offset ) = $request->getLimitOffset( 20, '' );
196  $this->mPrefix = $request->getVal( 'prefix', '' );
197 
198  $user = $this->getUser();
199 
200  # Extract manually requested namespaces
201  $nslist = $this->powerSearch( $request );
202  if ( !count( $nslist ) ) {
203  # Fallback to user preference
204  $nslist = $this->searchConfig->userNamespaces( $user );
205  }
206 
207  $profile = null;
208  if ( !count( $nslist ) ) {
209  $profile = 'default';
210  }
211 
212  $profile = $request->getVal( 'profile', $profile );
213  $profiles = $this->getSearchProfiles();
214  if ( $profile === null ) {
215  // BC with old request format
216  $profile = 'advanced';
217  foreach ( $profiles as $key => $data ) {
218  if ( $nslist === $data['namespaces'] && $key !== 'advanced' ) {
219  $profile = $key;
220  }
221  }
222  $this->namespaces = $nslist;
223  } elseif ( $profile === 'advanced' ) {
224  $this->namespaces = $nslist;
225  } else {
226  if ( isset( $profiles[$profile]['namespaces'] ) ) {
227  $this->namespaces = $profiles[$profile]['namespaces'];
228  } else {
229  // Unknown profile requested
230  $profile = 'default';
231  $this->namespaces = $profiles['default']['namespaces'];
232  }
233  }
234 
235  $this->fulltext = $request->getVal( 'fulltext' );
236  $this->runSuggestion = (bool)$request->getVal( 'runsuggestion', true );
237  $this->profile = $profile;
238  }
239 
246  public function goResult( $term ) {
247  # If the string cannot be used to create a title
248  if ( is_null( Title::newFromText( $term ) ) ) {
249  return null;
250  }
251  # If there's an exact or very near match, jump right there.
252  $title = $this->getSearchEngine()
253  ->getNearMatcher( $this->getConfig() )->getNearMatch( $term );
254  if ( is_null( $title ) ) {
255  return null;
256  }
257  $url = null;
258  if ( !Hooks::run( 'SpecialSearchGoResult', [ $term, $title, &$url ] ) ) {
259  return null;
260  }
261 
262  return $url === null ? $title->getFullUrlForRedirect() : $url;
263  }
264 
268  public function showResults( $term ) {
270 
271  if ( $this->searchEngineType !== null ) {
272  $this->setExtraParam( 'srbackend', $this->searchEngineType );
273  }
274 
275  $out = $this->getOutput();
277  $this,
278  $this->searchConfig,
279  $this->getSearchProfiles()
280  );
281  $filePrefix = $wgContLang->getFormattedNsText( NS_FILE ) . ':';
282  if ( trim( $term ) === '' || $filePrefix === trim( $term ) ) {
283  // Empty query -- straight view of search form
284  if ( !Hooks::run( 'SpecialSearchResultsPrepend', [ $this, $out, $term ] ) ) {
285  # Hook requested termination
286  return;
287  }
288  $out->enableOOUI();
289  // The form also contains the 'Showing results 0 - 20 of 1234' so we can
290  // only do the form render here for the empty $term case. Rendering
291  // the form when a search is provided is repeated below.
292  $out->addHTML( $formWidget->render(
293  $this->profile, $term, 0, 0, $this->offset, $this->isPowerSearch()
294  ) );
295  return;
296  }
297 
298  $search = $this->getSearchEngine();
299  $search->setFeatureData( 'rewrite', $this->runSuggestion );
300  $search->setLimitOffset( $this->limit, $this->offset );
301  $search->setNamespaces( $this->namespaces );
302  $search->prefix = $this->mPrefix;
303  $term = $search->transformSearchTerm( $term );
304 
305  Hooks::run( 'SpecialSearchSetupEngine', [ $this, $this->profile, $search ] );
306  if ( !Hooks::run( 'SpecialSearchResultsPrepend', [ $this, $out, $term ] ) ) {
307  # Hook requested termination
308  return;
309  }
310 
312  $showSuggestion = $title === null || !$title->isKnown();
313  $search->setShowSuggestion( $showSuggestion );
314 
315  // fetch search results
316  $rewritten = $search->replacePrefixes( $term );
317 
318  $titleMatches = $search->searchTitle( $rewritten );
319  $textMatches = $search->searchText( $rewritten );
320 
321  $textStatus = null;
322  if ( $textMatches instanceof Status ) {
323  $textStatus = $textMatches;
324  $textMatches = $textStatus->getValue();
325  }
326 
327  // Get number of results
328  $titleMatchesNum = $textMatchesNum = $numTitleMatches = $numTextMatches = 0;
329  if ( $titleMatches ) {
330  $titleMatchesNum = $titleMatches->numRows();
331  $numTitleMatches = $titleMatches->getTotalHits();
332  }
333  if ( $textMatches ) {
334  $textMatchesNum = $textMatches->numRows();
335  $numTextMatches = $textMatches->getTotalHits();
336  if ( $textMatchesNum > 0 ) {
337  $search->augmentSearchResults( $textMatches );
338  }
339  }
340  $num = $titleMatchesNum + $textMatchesNum;
341  $totalRes = $numTitleMatches + $numTextMatches;
342 
343  // start rendering the page
344  $out->enableOOUI();
345  $out->addHTML( $formWidget->render(
346  $this->profile, $term, $num, $totalRes, $this->offset, $this->isPowerSearch()
347  ) );
348 
349  // did you mean... suggestions
350  if ( $textMatches ) {
351  $dymWidget = new MediaWiki\Widget\Search\DidYouMeanWidget( $this );
352  $out->addHTML( $dymWidget->render( $term, $textMatches ) );
353  }
354 
355  $hasErrors = $textStatus && $textStatus->getErrors() !== [];
356  $hasOtherResults = $textMatches &&
357  $textMatches->hasInterwikiResults( SearchResultSet::INLINE_RESULTS );
358 
359  if ( $textMatches && $textMatches->hasInterwikiResults( SearchResultSet::SECONDARY_RESULTS ) ) {
360  $out->addHTML( '<div class="searchresults mw-searchresults-has-iw">' );
361  } else {
362  $out->addHTML( '<div class="searchresults">' );
363  }
364 
365  if ( $hasErrors ) {
366  list( $error, $warning ) = $textStatus->splitByErrorType();
367  if ( $error->getErrors() ) {
368  $out->addHTML( Html::errorBox(
369  $error->getHTML( 'search-error' )
370  ) );
371  }
372  if ( $warning->getErrors() ) {
373  $out->addHTML( Html::warningBox(
374  $warning->getHTML( 'search-warning' )
375  ) );
376  }
377  }
378 
379  // Show the create link ahead
380  $this->showCreateLink( $title, $num, $titleMatches, $textMatches );
381 
382  Hooks::run( 'SpecialSearchResults', [ $term, &$titleMatches, &$textMatches ] );
383 
384  // If we have no results and have not already displayed an error message
385  if ( $num === 0 && !$hasErrors ) {
386  $out->wrapWikiMsg( "<p class=\"mw-search-nonefound\">\n$1</p>", [
387  $hasOtherResults ? 'search-nonefound-thiswiki' : 'search-nonefound',
389  ] );
390  }
391 
392  // Although $num might be 0 there can still be secondary or inline
393  // results to display.
394  $linkRenderer = $this->getLinkRenderer();
395  $mainResultWidget = new FullSearchResultWidget( $this, $linkRenderer );
396 
397  // Default (null) on. Can be explicitly disabled.
398  if ( $search->getFeatureData( 'enable-new-crossproject-page' ) !== false ) {
399  $sidebarResultWidget = new InterwikiSearchResultWidget( $this, $linkRenderer );
400  $sidebarResultsWidget = new InterwikiSearchResultSetWidget(
401  $this,
402  $sidebarResultWidget,
404  MediaWikiServices::getInstance()->getInterwikiLookup(),
405  $search->getFeatureData( 'show-multimedia-search-results' )
406  );
407  } else {
408  $sidebarResultWidget = new SimpleSearchResultWidget( $this, $linkRenderer );
409  $sidebarResultsWidget = new SimpleSearchResultSetWidget(
410  $this,
411  $sidebarResultWidget,
413  MediaWikiServices::getInstance()->getInterwikiLookup()
414  );
415  }
416 
417  $widget = new BasicSearchResultSetWidget( $this, $mainResultWidget, $sidebarResultsWidget );
418 
419  $out->addHTML( $widget->render(
420  $term, $this->offset, $titleMatches, $textMatches
421  ) );
422 
423  if ( $titleMatches ) {
424  $titleMatches->free();
425  }
426 
427  if ( $textMatches ) {
428  $textMatches->free();
429  }
430 
431  $out->addHTML( '<div class="mw-search-visualclear"></div>' );
432 
433  // prev/next links
434  if ( $totalRes > $this->limit || $this->offset ) {
435  // Allow matches to define the correct offset, as interleaved
436  // AB testing may require a different next page offset.
437  if ( $textMatches && $textMatches->getOffset() !== null ) {
438  $offset = $textMatches->getOffset();
439  } else {
441  }
442 
443  $prevnext = $this->getLanguage()->viewPrevNext(
444  $this->getPageTitle(),
445  $offset,
446  $this->limit,
447  $this->powerSearchOptions() + [ 'search' => $term ],
448  $this->limit + $this->offset >= $totalRes
449  );
450  $out->addHTML( "<p class='mw-search-pager-bottom'>{$prevnext}</p>\n" );
451  }
452 
453  // Close <div class='searchresults'>
454  $out->addHTML( "</div>" );
455 
456  Hooks::run( 'SpecialSearchResultsAppend', [ $this, $out, $term ] );
457  }
458 
465  protected function showCreateLink( $title, $num, $titleMatches, $textMatches ) {
466  // show direct page/create link if applicable
467 
468  // Check DBkey !== '' in case of fragment link only.
469  if ( is_null( $title ) || $title->getDBkey() === ''
470  || ( $titleMatches !== null && $titleMatches->searchContainedSyntax() )
471  || ( $textMatches !== null && $textMatches->searchContainedSyntax() )
472  ) {
473  // invalid title
474  // preserve the paragraph for margins etc...
475  $this->getOutput()->addHTML( '<p></p>' );
476 
477  return;
478  }
479 
480  $messageName = 'searchmenu-new-nocreate';
481  $linkClass = 'mw-search-createlink';
482 
483  if ( !$title->isExternal() ) {
484  if ( $title->isKnown() ) {
485  $messageName = 'searchmenu-exists';
486  $linkClass = 'mw-search-exists';
487  } elseif ( ContentHandler::getForTitle( $title )->supportsDirectEditing()
488  && $title->quickUserCan( 'create', $this->getUser() )
489  ) {
490  $messageName = 'searchmenu-new';
491  }
492  }
493 
494  $params = [
495  $messageName,
496  wfEscapeWikiText( $title->getPrefixedText() ),
497  Message::numParam( $num )
498  ];
499  Hooks::run( 'SpecialSearchCreateLink', [ $title, &$params ] );
500 
501  // Extensions using the hook might still return an empty $messageName
502  if ( $messageName ) {
503  $this->getOutput()->wrapWikiMsg( "<p class=\"$linkClass\">\n$1</p>", $params );
504  } else {
505  // preserve the paragraph for margins etc...
506  $this->getOutput()->addHTML( '<p></p>' );
507  }
508  }
509 
516  protected function setupPage( $term ) {
517  $out = $this->getOutput();
518 
519  $this->setHeaders();
520  $this->outputHeader();
521  // TODO: Is this true? The namespace remember uses a user token
522  // on save.
523  $out->allowClickjacking();
524  $this->addHelpLink( 'Help:Searching' );
525 
526  if ( strval( $term ) !== '' ) {
527  $out->setPageTitle( $this->msg( 'searchresults' ) );
528  $out->setHTMLTitle( $this->msg( 'pagetitle' )
529  ->plaintextParams( $this->msg( 'searchresults-title' )->plaintextParams( $term )->text() )
530  ->inContentLanguage()->text()
531  );
532  }
533 
534  $out->addJsConfigVars( [ 'searchTerm' => $term ] );
535  $out->addModules( 'mediawiki.special.search' );
536  $out->addModuleStyles( [
537  'mediawiki.special', 'mediawiki.special.search.styles', 'mediawiki.ui', 'mediawiki.ui.button',
538  'mediawiki.ui.input', 'mediawiki.widgets.SearchInputWidget.styles',
539  ] );
540  }
541 
547  protected function isPowerSearch() {
548  return $this->profile === 'advanced';
549  }
550 
558  protected function powerSearch( &$request ) {
559  $arr = [];
560  foreach ( $this->searchConfig->searchableNamespaces() as $ns => $name ) {
561  if ( $request->getCheck( 'ns' . $ns ) ) {
562  $arr[] = $ns;
563  }
564  }
565 
566  return $arr;
567  }
568 
576  public function powerSearchOptions() {
577  $opt = [];
578  if ( $this->isPowerSearch() ) {
579  foreach ( $this->namespaces as $n ) {
580  $opt['ns' . $n] = 1;
581  }
582  } else {
583  $opt['profile'] = $this->profile;
584  }
585 
586  return $opt + $this->extraParams;
587  }
588 
594  protected function saveNamespaces() {
595  $user = $this->getUser();
596  $request = $this->getRequest();
597 
598  if ( $user->isLoggedIn() &&
599  $user->matchEditToken(
600  $request->getVal( 'nsRemember' ),
601  'searchnamespace',
602  $request
603  ) && !wfReadOnly()
604  ) {
605  // Reset namespace preferences: namespaces are not searched
606  // when they're not mentioned in the URL parameters.
607  foreach ( MWNamespace::getValidNamespaces() as $n ) {
608  $user->setOption( 'searchNs' . $n, false );
609  }
610  // The request parameters include all the namespaces to be searched.
611  // Even if they're the same as an existing profile, they're not eaten.
612  foreach ( $this->namespaces as $n ) {
613  $user->setOption( 'searchNs' . $n, true );
614  }
615 
616  DeferredUpdates::addCallableUpdate( function () use ( $user ) {
617  $user->saveSettings();
618  } );
619 
620  return true;
621  }
622 
623  return false;
624  }
625 
629  protected function getSearchProfiles() {
630  // Builds list of Search Types (profiles)
631  $nsAllSet = array_keys( $this->searchConfig->searchableNamespaces() );
632  $defaultNs = $this->searchConfig->defaultNamespaces();
633  $profiles = [
634  'default' => [
635  'message' => 'searchprofile-articles',
636  'tooltip' => 'searchprofile-articles-tooltip',
637  'namespaces' => $defaultNs,
638  'namespace-messages' => $this->searchConfig->namespacesAsText(
639  $defaultNs
640  ),
641  ],
642  'images' => [
643  'message' => 'searchprofile-images',
644  'tooltip' => 'searchprofile-images-tooltip',
645  'namespaces' => [ NS_FILE ],
646  ],
647  'all' => [
648  'message' => 'searchprofile-everything',
649  'tooltip' => 'searchprofile-everything-tooltip',
650  'namespaces' => $nsAllSet,
651  ],
652  'advanced' => [
653  'message' => 'searchprofile-advanced',
654  'tooltip' => 'searchprofile-advanced-tooltip',
655  'namespaces' => self::NAMESPACES_CURRENT,
656  ]
657  ];
658 
659  Hooks::run( 'SpecialSearchProfiles', [ &$profiles ] );
660 
661  foreach ( $profiles as &$data ) {
662  if ( !is_array( $data['namespaces'] ) ) {
663  continue;
664  }
665  sort( $data['namespaces'] );
666  }
667 
668  return $profiles;
669  }
670 
676  public function getSearchEngine() {
677  if ( $this->searchEngine === null ) {
678  $this->searchEngine = $this->searchEngineType ?
679  MediaWikiServices::getInstance()->getSearchEngineFactory()->create( $this->searchEngineType ) :
680  MediaWikiServices::getInstance()->newSearchEngine();
681  }
682 
683  return $this->searchEngine;
684  }
685 
690  function getProfile() {
691  return $this->profile;
692  }
693 
698  function getNamespaces() {
699  return $this->namespaces;
700  }
701 
711  public function setExtraParam( $key, $value ) {
712  $this->extraParams[$key] = $value;
713  }
714 
715  protected function getGroupName() {
716  return 'pages';
717  }
718 }
$user
please add to it if you re going to add events to the MediaWiki code where normally authentication against an external auth plugin would be creating a account $user
Definition: hooks.txt:247
SpecialSearch\getNamespaces
getNamespaces()
Current namespaces.
Definition: SpecialSearch.php:698
SpecialPage\getPageTitle
getPageTitle( $subpage=false)
Get a self-referential title object.
Definition: SpecialPage.php:675
Html\errorBox
static errorBox( $html, $heading='')
Return an error box.
Definition: Html.php:713
Message\numParam
static numParam( $num)
Definition: Message.php:1028
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:273
SpecialPage\msg
msg( $key)
Wrapper around wfMessage that sets the current context.
Definition: SpecialPage.php:793
MWNamespace\getValidNamespaces
static getValidNamespaces()
Returns an array of the namespaces (by integer id) that exist on the wiki.
Definition: MWNamespace.php:290
use
Apache License January AND DISTRIBUTION Definitions License shall mean the terms and conditions for use
Definition: APACHE-LICENSE-2.0.txt:10
SpecialSearch\$fulltext
string $fulltext
Definition: SpecialSearch.php:77
SpecialPage\getOutput
getOutput()
Get the OutputPage being used for this instance.
Definition: SpecialPage.php:722
array
the array() calling protocol came about after MediaWiki 1.4rc1.
SpecialSearch\$limit
int $limit
Definition: SpecialSearch.php:67
$opt
$opt
Definition: postprocess-phan.php:119
text
design txt This is a brief overview of the new design More thorough and up to date information is available on the documentation wiki at etc Handles the details of getting and saving to the user table of the and dealing with sessions and cookies OutputPage Encapsulates the entire HTML page that will be sent in response to any server request It is used by calling its functions to add text
Definition: design.txt:18
$out
this hook is for auditing only or null if authentication failed before getting that far or null if we can t even determine that probably a stub it is not rendered in wiki pages or galleries in category pages allow injecting custom HTML after the section Any uses of the hook need to handle escaping see BaseTemplate::getToolbox and BaseTemplate::makeListItem for details on the format of individual items inside of this array or by returning and letting standard HTTP rendering take place modifiable or by returning false and taking over the output $out
Definition: hooks.txt:864
NS_FILE
const NS_FILE
Definition: Defines.php:80
$params
$params
Definition: styleTest.css.php:40
wfReadOnly
wfReadOnly()
Check whether the wiki is in read-only mode.
Definition: GlobalFunctions.php:1262
ContentHandler\getForTitle
static getForTitle(Title $title)
Returns the appropriate ContentHandler singleton for the given title.
Definition: ContentHandler.php:240
SpecialPage\getLanguage
getLanguage()
Shortcut to get user's language.
Definition: SpecialPage.php:752
MediaWiki\Widget\Search\InterwikiSearchResultSetWidget
Renders one or more SearchResultSets into a sidebar grouped by interwiki prefix.
Definition: InterwikiSearchResultSetWidget.php:18
MediaWiki\Widget\Search\BasicSearchResultSetWidget
Renders the search result area.
Definition: BasicSearchResultSetWidget.php:14
MediaWiki\Widget\Search\SearchFormWidget
Definition: SearchFormWidget.php:13
SpecialSearch\isPowerSearch
isPowerSearch()
Return true if current search is a power (advanced) search.
Definition: SpecialSearch.php:547
SpecialSearch\setupPage
setupPage( $term)
Sets up everything for the HTML output page including styles, javascript, page title,...
Definition: SpecialSearch.php:516
SpecialSearch\getSearchProfiles
getSearchProfiles()
Definition: SpecialSearch.php:629
php
injection txt This is an overview of how MediaWiki makes use of dependency injection The design described here grew from the discussion of RFC T384 The term dependency this means that anything an object needs to operate should be injected from the the object itself should only know narrow no concrete implementation of the logic it relies on The requirement to inject everything typically results in an architecture that based on two main types of and essentially stateless service objects that use other service objects to operate on the value objects As of the beginning MediaWiki is only starting to use the DI approach Much of the code still relies on global state or direct resulting in a highly cyclical dependency which acts as the top level factory for services in MediaWiki which can be used to gain access to default instances of various services MediaWikiServices however also allows new services to be defined and default services to be redefined Services are defined or redefined by providing a callback the instantiator that will return a new instance of the service When it will create an instance of MediaWikiServices and populate it with the services defined in the files listed by thereby bootstrapping the DI framework Per $wgServiceWiringFiles lists includes ServiceWiring php
Definition: injection.txt:37
SpecialSearch\NAMESPACES_CURRENT
const NAMESPACES_CURRENT
Definition: SpecialSearch.php:90
Status
Generic operation result class Has warning/error list, boolean status and arbitrary value.
Definition: Status.php:40
$hasErrors
$hasErrors
Definition: postprocess-phan.php:146
SpecialPage\addHelpLink
addHelpLink( $to, $overrideBaseUrl=false)
Adds help link with an icon via page indicators.
Definition: SpecialPage.php:832
$term
For QUnit the mediawiki tests qunit testrunner dependency will be added to any module whereas SearchGetNearMatch runs after $term
Definition: hooks.txt:2845
namespaces
to move a page</td >< td > &*You are moving the page across namespaces
Definition: All_system_messages.txt:2670
SpecialPage\getConfig
getConfig()
Shortcut to get main config object.
Definition: SpecialPage.php:761
SpecialSearch\getGroupName
getGroupName()
Under which header this special page is listed in Special:SpecialPages See messages 'specialpages-gro...
Definition: SpecialSearch.php:715
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:13
SpecialSearch\$runSuggestion
bool $runSuggestion
Definition: SpecialSearch.php:82
SpecialPage\setHeaders
setHeaders()
Sets headers - this should be called from the execute() method of all derived classes!
Definition: SpecialPage.php:527
$title
namespace and then decline to actually register it file or subcat img or subcat $title
Definition: hooks.txt:964
SpecialSearch\$offset
int $offset
Definition: SpecialSearch.php:67
SpecialPage\getUser
getUser()
Shortcut to get the User executing this instance.
Definition: SpecialPage.php:732
SpecialSearch\saveNamespaces
saveNamespaces()
Save namespace preferences when we're supposed to.
Definition: SpecialSearch.php:594
global
when a variable name is used in a it is silently declared as a new masking the global
Definition: design.txt:95
SpecialSearch\__construct
__construct()
Definition: SpecialSearch.php:92
MediaWiki\Widget\Search\SimpleSearchResultSetWidget
Renders one or more SearchResultSets into a sidebar grouped by interwiki prefix.
Definition: SimpleSearchResultSetWidget.php:19
Html\warningBox
static warningBox( $html)
Return a warning box.
Definition: Html.php:702
list
deferred txt A few of the database updates required by various functions here can be deferred until after the result page is displayed to the user For updating the view updating the linked to tables after a etc PHP does not yet have any way to tell the server to actually return and disconnect while still running these but it might have such a feature in the future We handle these by creating a deferred update object and putting those objects on a global list
Definition: deferred.txt:11
SpecialSearch\$searchConfig
SearchEngineConfig $searchConfig
Search engine configurations.
Definition: SpecialSearch.php:88
SpecialSearch\$searchEngine
SearchEngine $searchEngine
Search engine.
Definition: SpecialSearch.php:50
SpecialSearch\execute
execute( $par)
Entry point.
Definition: SpecialSearch.php:102
$value
$value
Definition: styleTest.css.php:45
MediaWiki\Widget\Search\SimpleSearchResultWidget
Renders a simple one-line result.
Definition: SimpleSearchResultWidget.php:15
SpecialPage
Parent class for all special pages.
Definition: SpecialPage.php:36
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:712
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:20
SpecialSearch\powerSearch
powerSearch(&$request)
Extract "power search" namespace settings from the request object, returning a list of index numbers ...
Definition: SpecialSearch.php:558
wfEscapeWikiText
wfEscapeWikiText( $text)
Escapes the given text so that it may be output using addWikiText() without any linking,...
Definition: GlobalFunctions.php:1643
SpecialSearch\getProfile
getProfile()
Current search profile.
Definition: SpecialSearch.php:690
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:907
SpecialSearch\powerSearchOptions
powerSearchOptions()
Reconstruct the 'power search' options for links TODO: Instead of exposing this publicly,...
Definition: SpecialSearch.php:576
SpecialSearch\goResult
goResult( $term)
If an exact title match can be found, jump straight ahead to it.
Definition: SpecialSearch.php:246
SpecialSearch\$namespaces
array $namespaces
Definition: SpecialSearch.php:72
$name
Allows to change the fields on the form that will be generated $name
Definition: hooks.txt:302
SpecialSearch\getSearchEngine
getSearchEngine()
Definition: SpecialSearch.php:676
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:711
as
This document is intended to provide useful advice for parties seeking to redistribute MediaWiki to end users It s targeted particularly at maintainers for Linux since it s been observed that distribution packages of MediaWiki often break We ve consistently had to recommend that users seeking support use official tarballs instead of their distribution s and this often solves whatever problem the user is having It would be nice if this could such as
Definition: distributors.txt:22
SpecialSearch\load
load()
Set up basic search parameters from the request and user settings.
Definition: SpecialSearch.php:193
MediaWiki\Widget\Search\InterwikiSearchResultWidget
Renders an enhanced interwiki result.
Definition: InterwikiSearchResultWidget.php:14
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:465
SpecialPage\$linkRenderer
MediaWiki Linker LinkRenderer null $linkRenderer
Definition: SpecialPage.php:66
$request
do that in ParserLimitReportFormat instead use this to modify the parameters of the image all existing parser cache entries will be invalid To avoid you ll need to handle that somehow(e.g. with the RejectParserCacheValue hook) because MediaWiki won 't do it for you. & $defaults also a ContextSource after deleting those rows but within the same transaction you ll probably need to make sure the header is varied on $request
Definition: hooks.txt:2806
MediaWikiServices
injection txt This is an overview of how MediaWiki makes use of dependency injection The design described here grew from the discussion of RFC T384 The term dependency this means that anything an object needs to operate should be injected from the the object itself should only know narrow no concrete implementation of the logic it relies on The requirement to inject everything typically results in an architecture that based on two main types of and essentially stateless service objects that use other service objects to operate on the value objects As of the beginning MediaWiki is only starting to use the DI approach Much of the code still relies on global state or direct resulting in a highly cyclical dependency MediaWikiServices
Definition: injection.txt:25
$query
null for the wiki Added should default to null in handler for backwards compatibility add a value to it if you want to add a cookie that have to vary cache options can modify $query
Definition: hooks.txt:1620
DeferredUpdates\addCallableUpdate
static addCallableUpdate( $callable, $stage=self::POSTSEND, $dbw=null)
Add a callable update.
Definition: DeferredUpdates.php:111
Hooks\run
static run( $event, array $args=[], $deprecatedVersion=null)
Call hook functions defined in Hooks::register and $wgHooks.
Definition: Hooks.php:203
SpecialSearch\showResults
showResults( $term)
Definition: SpecialSearch.php:268
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:629
$wgContLang
this class mediates it Skin Encapsulates a look and feel for the wiki All of the functions that render HTML and make choices about how to render it are here and are called from various other places when and is meant to be subclassed with other skins that may override some of its functions The User object contains a reference to a and so rather than having a global skin object we just rely on the global User and get the skin with $wgUser and also has some character encoding functions and other locale stuff The current user interface language is instantiated as and the content language as $wgContLang
Definition: design.txt:57