Deprecate usage of SearchEngine:transformSearchTerm
[lhc/web/wiklou.git] / includes / specials / SpecialSearch.php
1 <?php
2 /**
3 * Implements Special:Search
4 *
5 * Copyright © 2004 Brion Vibber <brion@pobox.com>
6 *
7 * This program is free software; you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License as published by
9 * the Free Software Foundation; either version 2 of the License, or
10 * (at your option) any later version.
11 *
12 * This program is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
16 *
17 * You should have received a copy of the GNU General Public License along
18 * with this program; if not, write to the Free Software Foundation, Inc.,
19 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
20 * http://www.gnu.org/copyleft/gpl.html
21 *
22 * @file
23 * @ingroup SpecialPage
24 */
25
26 use MediaWiki\MediaWikiServices;
27 use MediaWiki\Widget\Search\BasicSearchResultSetWidget;
28 use MediaWiki\Widget\Search\FullSearchResultWidget;
29 use MediaWiki\Widget\Search\InterwikiSearchResultWidget;
30 use MediaWiki\Widget\Search\InterwikiSearchResultSetWidget;
31 use MediaWiki\Widget\Search\SimpleSearchResultWidget;
32 use MediaWiki\Widget\Search\SimpleSearchResultSetWidget;
33
34 /**
35 * implements Special:Search - Run text & title search and display the output
36 * @ingroup SpecialPage
37 */
38 class SpecialSearch extends SpecialPage {
39 /**
40 * Current search profile. Search profile is just a name that identifies
41 * the active search tab on the search page (content, discussions...)
42 * For users tt replaces the set of enabled namespaces from the query
43 * string when applicable. Extensions can add new profiles with hooks
44 * with custom search options just for that profile.
45 * @var null|string
46 */
47 protected $profile;
48
49 /** @var SearchEngine Search engine */
50 protected $searchEngine;
51
52 /** @var string Search engine type, if not default */
53 protected $searchEngineType;
54
55 /** @var array For links */
56 protected $extraParams = [];
57
58 /**
59 * @var string The prefix url parameter. Set on the searcher and the
60 * is expected to treat it as prefix filter on titles.
61 */
62 protected $mPrefix;
63
64 /**
65 * @var int
66 */
67 protected $limit, $offset;
68
69 /**
70 * @var array
71 */
72 protected $namespaces;
73
74 /**
75 * @var string
76 */
77 protected $fulltext;
78
79 /**
80 * @var bool
81 */
82 protected $runSuggestion = true;
83
84 /**
85 * Search engine configurations.
86 * @var SearchEngineConfig
87 */
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
97 /**
98 * Entry point
99 *
100 * @param string $par
101 */
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.
151 $title = Title::newFromText( $term );
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
188 /**
189 * Set up basic search parameters from the request and user settings.
190 *
191 * @see tests/phpunit/includes/specials/SpecialSearchTest.php
192 */
193 public function load() {
194 $request = $this->getRequest();
195 list( $this->limit, $this->offset ) = $request->getLimitOffset( 20, '' );
196 $this->mPrefix = $request->getVal( 'prefix', '' );
197 if ( $this->mPrefix !== '' ) {
198 $this->setExtraParam( 'prefix', $this->mPrefix );
199 }
200
201 $user = $this->getUser();
202
203 # Extract manually requested namespaces
204 $nslist = $this->powerSearch( $request );
205 if ( !count( $nslist ) ) {
206 # Fallback to user preference
207 $nslist = $this->searchConfig->userNamespaces( $user );
208 }
209
210 $profile = null;
211 if ( !count( $nslist ) ) {
212 $profile = 'default';
213 }
214
215 $profile = $request->getVal( 'profile', $profile );
216 $profiles = $this->getSearchProfiles();
217 if ( $profile === null ) {
218 // BC with old request format
219 $profile = 'advanced';
220 foreach ( $profiles as $key => $data ) {
221 if ( $nslist === $data['namespaces'] && $key !== 'advanced' ) {
222 $profile = $key;
223 }
224 }
225 $this->namespaces = $nslist;
226 } elseif ( $profile === 'advanced' ) {
227 $this->namespaces = $nslist;
228 } else {
229 if ( isset( $profiles[$profile]['namespaces'] ) ) {
230 $this->namespaces = $profiles[$profile]['namespaces'];
231 } else {
232 // Unknown profile requested
233 $profile = 'default';
234 $this->namespaces = $profiles['default']['namespaces'];
235 }
236 }
237
238 $this->fulltext = $request->getVal( 'fulltext' );
239 $this->runSuggestion = (bool)$request->getVal( 'runsuggestion', true );
240 $this->profile = $profile;
241 }
242
243 /**
244 * If an exact title match can be found, jump straight ahead to it.
245 *
246 * @param string $term
247 * @return string|null The url to redirect to, or null if no redirect.
248 */
249 public function goResult( $term ) {
250 # If the string cannot be used to create a title
251 if ( is_null( Title::newFromText( $term ) ) ) {
252 return null;
253 }
254 # If there's an exact or very near match, jump right there.
255 $title = $this->getSearchEngine()
256 ->getNearMatcher( $this->getConfig() )->getNearMatch( $term );
257 if ( is_null( $title ) ) {
258 return null;
259 }
260 $url = null;
261 if ( !Hooks::run( 'SpecialSearchGoResult', [ $term, $title, &$url ] ) ) {
262 return null;
263 }
264
265 return $url ?? $title->getFullUrlForRedirect();
266 }
267
268 /**
269 * @param string $term
270 */
271 public function showResults( $term ) {
272 global $wgContLang;
273
274 if ( $this->searchEngineType !== null ) {
275 $this->setExtraParam( 'srbackend', $this->searchEngineType );
276 }
277
278 $out = $this->getOutput();
279 $formWidget = new MediaWiki\Widget\Search\SearchFormWidget(
280 $this,
281 $this->searchConfig,
282 $this->getSearchProfiles()
283 );
284 $filePrefix = $wgContLang->getFormattedNsText( NS_FILE ) . ':';
285 if ( trim( $term ) === '' || $filePrefix === trim( $term ) ) {
286 // Empty query -- straight view of search form
287 if ( !Hooks::run( 'SpecialSearchResultsPrepend', [ $this, $out, $term ] ) ) {
288 # Hook requested termination
289 return;
290 }
291 $out->enableOOUI();
292 // The form also contains the 'Showing results 0 - 20 of 1234' so we can
293 // only do the form render here for the empty $term case. Rendering
294 // the form when a search is provided is repeated below.
295 $out->addHTML( $formWidget->render(
296 $this->profile, $term, 0, 0, $this->offset, $this->isPowerSearch()
297 ) );
298 return;
299 }
300
301 $search = $this->getSearchEngine();
302 $search->setFeatureData( 'rewrite', $this->runSuggestion );
303 $search->setLimitOffset( $this->limit, $this->offset );
304 $search->setNamespaces( $this->namespaces );
305 $search->prefix = $this->mPrefix;
306
307 Hooks::run( 'SpecialSearchSetupEngine', [ $this, $this->profile, $search ] );
308 if ( !Hooks::run( 'SpecialSearchResultsPrepend', [ $this, $out, $term ] ) ) {
309 # Hook requested termination
310 return;
311 }
312
313 $title = Title::newFromText( $term );
314 $showSuggestion = $title === null || !$title->isKnown();
315 $search->setShowSuggestion( $showSuggestion );
316
317 $nterm = $search->transformSearchTerm( $term );
318 if ( $nterm !== $term ) {
319 $term = $nterm;
320 wfDeprecated( 'SearchEngine::transformSearchTerm() (overridden by ' .
321 get_class( $search ) . ')', '1.32' );
322 }
323
324 // fetch search results
325 $rewritten = $search->replacePrefixes( $term );
326
327 $titleMatches = $search->searchTitle( $rewritten );
328 $textMatches = $search->searchText( $rewritten );
329
330 $textStatus = null;
331 if ( $textMatches instanceof Status ) {
332 $textStatus = $textMatches;
333 $textMatches = $textStatus->getValue();
334 }
335
336 // Get number of results
337 $titleMatchesNum = $textMatchesNum = $numTitleMatches = $numTextMatches = 0;
338 if ( $titleMatches ) {
339 $titleMatchesNum = $titleMatches->numRows();
340 $numTitleMatches = $titleMatches->getTotalHits();
341 }
342 if ( $textMatches ) {
343 $textMatchesNum = $textMatches->numRows();
344 $numTextMatches = $textMatches->getTotalHits();
345 if ( $textMatchesNum > 0 ) {
346 $search->augmentSearchResults( $textMatches );
347 }
348 }
349 $num = $titleMatchesNum + $textMatchesNum;
350 $totalRes = $numTitleMatches + $numTextMatches;
351
352 // start rendering the page
353 $out->enableOOUI();
354 $out->addHTML( $formWidget->render(
355 $this->profile, $term, $num, $totalRes, $this->offset, $this->isPowerSearch()
356 ) );
357
358 // did you mean... suggestions
359 if ( $textMatches ) {
360 $dymWidget = new MediaWiki\Widget\Search\DidYouMeanWidget( $this );
361 $out->addHTML( $dymWidget->render( $term, $textMatches ) );
362 }
363
364 $hasErrors = $textStatus && $textStatus->getErrors() !== [];
365 $hasOtherResults = $textMatches &&
366 $textMatches->hasInterwikiResults( SearchResultSet::INLINE_RESULTS );
367
368 if ( $textMatches && $textMatches->hasInterwikiResults( SearchResultSet::SECONDARY_RESULTS ) ) {
369 $out->addHTML( '<div class="searchresults mw-searchresults-has-iw">' );
370 } else {
371 $out->addHTML( '<div class="searchresults">' );
372 }
373
374 if ( $hasErrors ) {
375 list( $error, $warning ) = $textStatus->splitByErrorType();
376 if ( $error->getErrors() ) {
377 $out->addHTML( Html::errorBox(
378 $error->getHTML( 'search-error' )
379 ) );
380 }
381 if ( $warning->getErrors() ) {
382 $out->addHTML( Html::warningBox(
383 $warning->getHTML( 'search-warning' )
384 ) );
385 }
386 }
387
388 // Show the create link ahead
389 $this->showCreateLink( $title, $num, $titleMatches, $textMatches );
390
391 Hooks::run( 'SpecialSearchResults', [ $term, &$titleMatches, &$textMatches ] );
392
393 // If we have no results and have not already displayed an error message
394 if ( $num === 0 && !$hasErrors ) {
395 $out->wrapWikiMsg( "<p class=\"mw-search-nonefound\">\n$1</p>", [
396 $hasOtherResults ? 'search-nonefound-thiswiki' : 'search-nonefound',
397 wfEscapeWikiText( $term )
398 ] );
399 }
400
401 // Although $num might be 0 there can still be secondary or inline
402 // results to display.
403 $linkRenderer = $this->getLinkRenderer();
404 $mainResultWidget = new FullSearchResultWidget( $this, $linkRenderer );
405
406 // Default (null) on. Can be explicitly disabled.
407 if ( $search->getFeatureData( 'enable-new-crossproject-page' ) !== false ) {
408 $sidebarResultWidget = new InterwikiSearchResultWidget( $this, $linkRenderer );
409 $sidebarResultsWidget = new InterwikiSearchResultSetWidget(
410 $this,
411 $sidebarResultWidget,
412 $linkRenderer,
413 MediaWikiServices::getInstance()->getInterwikiLookup(),
414 $search->getFeatureData( 'show-multimedia-search-results' )
415 );
416 } else {
417 $sidebarResultWidget = new SimpleSearchResultWidget( $this, $linkRenderer );
418 $sidebarResultsWidget = new SimpleSearchResultSetWidget(
419 $this,
420 $sidebarResultWidget,
421 $linkRenderer,
422 MediaWikiServices::getInstance()->getInterwikiLookup()
423 );
424 }
425
426 $widget = new BasicSearchResultSetWidget( $this, $mainResultWidget, $sidebarResultsWidget );
427
428 $out->addHTML( $widget->render(
429 $term, $this->offset, $titleMatches, $textMatches
430 ) );
431
432 if ( $titleMatches ) {
433 $titleMatches->free();
434 }
435
436 if ( $textMatches ) {
437 $textMatches->free();
438 }
439
440 $out->addHTML( '<div class="mw-search-visualclear"></div>' );
441
442 // prev/next links
443 if ( $totalRes > $this->limit || $this->offset ) {
444 // Allow matches to define the correct offset, as interleaved
445 // AB testing may require a different next page offset.
446 if ( $textMatches && $textMatches->getOffset() !== null ) {
447 $offset = $textMatches->getOffset();
448 } else {
449 $offset = $this->offset;
450 }
451
452 $prevnext = $this->getLanguage()->viewPrevNext(
453 $this->getPageTitle(),
454 $offset,
455 $this->limit,
456 $this->powerSearchOptions() + [ 'search' => $term ],
457 $this->limit + $this->offset >= $totalRes
458 );
459 $out->addHTML( "<p class='mw-search-pager-bottom'>{$prevnext}</p>\n" );
460 }
461
462 // Close <div class='searchresults'>
463 $out->addHTML( "</div>" );
464
465 Hooks::run( 'SpecialSearchResultsAppend', [ $this, $out, $term ] );
466 }
467
468 /**
469 * @param Title $title
470 * @param int $num The number of search results found
471 * @param null|SearchResultSet $titleMatches Results from title search
472 * @param null|SearchResultSet $textMatches Results from text search
473 */
474 protected function showCreateLink( $title, $num, $titleMatches, $textMatches ) {
475 // show direct page/create link if applicable
476
477 // Check DBkey !== '' in case of fragment link only.
478 if ( is_null( $title ) || $title->getDBkey() === ''
479 || ( $titleMatches !== null && $titleMatches->searchContainedSyntax() )
480 || ( $textMatches !== null && $textMatches->searchContainedSyntax() )
481 ) {
482 // invalid title
483 // preserve the paragraph for margins etc...
484 $this->getOutput()->addHTML( '<p></p>' );
485
486 return;
487 }
488
489 $messageName = 'searchmenu-new-nocreate';
490 $linkClass = 'mw-search-createlink';
491
492 if ( !$title->isExternal() ) {
493 if ( $title->isKnown() ) {
494 $messageName = 'searchmenu-exists';
495 $linkClass = 'mw-search-exists';
496 } elseif ( ContentHandler::getForTitle( $title )->supportsDirectEditing()
497 && $title->quickUserCan( 'create', $this->getUser() )
498 ) {
499 $messageName = 'searchmenu-new';
500 }
501 }
502
503 $params = [
504 $messageName,
505 wfEscapeWikiText( $title->getPrefixedText() ),
506 Message::numParam( $num )
507 ];
508 Hooks::run( 'SpecialSearchCreateLink', [ $title, &$params ] );
509
510 // Extensions using the hook might still return an empty $messageName
511 if ( $messageName ) {
512 $this->getOutput()->wrapWikiMsg( "<p class=\"$linkClass\">\n$1</p>", $params );
513 } else {
514 // preserve the paragraph for margins etc...
515 $this->getOutput()->addHTML( '<p></p>' );
516 }
517 }
518
519 /**
520 * Sets up everything for the HTML output page including styles, javascript,
521 * page title, etc.
522 *
523 * @param string $term
524 */
525 protected function setupPage( $term ) {
526 $out = $this->getOutput();
527
528 $this->setHeaders();
529 $this->outputHeader();
530 // TODO: Is this true? The namespace remember uses a user token
531 // on save.
532 $out->allowClickjacking();
533 $this->addHelpLink( 'Help:Searching' );
534
535 if ( strval( $term ) !== '' ) {
536 $out->setPageTitle( $this->msg( 'searchresults' ) );
537 $out->setHTMLTitle( $this->msg( 'pagetitle' )
538 ->plaintextParams( $this->msg( 'searchresults-title' )->plaintextParams( $term )->text() )
539 ->inContentLanguage()->text()
540 );
541 }
542
543 if ( $this->mPrefix !== '' ) {
544 $subtitle = $this->msg( 'search-filter-title-prefix' )->plaintextParams( $this->mPrefix );
545 $params = $this->powerSearchOptions();
546 unset( $params['prefix'] );
547 $params += [
548 'search' => $term,
549 'fulltext' => 1,
550 ];
551
552 $subtitle .= ' (';
553 $subtitle .= Xml::element(
554 'a',
555 [
556 'href' => $this->getPageTitle()->getLocalURL( $params ),
557 'title' => $this->msg( 'search-filter-title-prefix-reset' ),
558 ],
559 $this->msg( 'search-filter-title-prefix-reset' )
560 );
561 $subtitle .= ')';
562 $out->setSubtitle( $subtitle );
563 }
564
565 $out->addJsConfigVars( [ 'searchTerm' => $term ] );
566 $out->addModules( 'mediawiki.special.search' );
567 $out->addModuleStyles( [
568 'mediawiki.special', 'mediawiki.special.search.styles', 'mediawiki.ui', 'mediawiki.ui.button',
569 'mediawiki.ui.input', 'mediawiki.widgets.SearchInputWidget.styles',
570 ] );
571 }
572
573 /**
574 * Return true if current search is a power (advanced) search
575 *
576 * @return bool
577 */
578 protected function isPowerSearch() {
579 return $this->profile === 'advanced';
580 }
581
582 /**
583 * Extract "power search" namespace settings from the request object,
584 * returning a list of index numbers to search.
585 *
586 * @param WebRequest &$request
587 * @return array
588 */
589 protected function powerSearch( &$request ) {
590 $arr = [];
591 foreach ( $this->searchConfig->searchableNamespaces() as $ns => $name ) {
592 if ( $request->getCheck( 'ns' . $ns ) ) {
593 $arr[] = $ns;
594 }
595 }
596
597 return $arr;
598 }
599
600 /**
601 * Reconstruct the 'power search' options for links
602 * TODO: Instead of exposing this publicly, could we instead expose
603 * a function for creating search links?
604 *
605 * @return array
606 */
607 public function powerSearchOptions() {
608 $opt = [];
609 if ( $this->isPowerSearch() ) {
610 foreach ( $this->namespaces as $n ) {
611 $opt['ns' . $n] = 1;
612 }
613 } else {
614 $opt['profile'] = $this->profile;
615 }
616
617 return $opt + $this->extraParams;
618 }
619
620 /**
621 * Save namespace preferences when we're supposed to
622 *
623 * @return bool Whether we wrote something
624 */
625 protected function saveNamespaces() {
626 $user = $this->getUser();
627 $request = $this->getRequest();
628
629 if ( $user->isLoggedIn() &&
630 $user->matchEditToken(
631 $request->getVal( 'nsRemember' ),
632 'searchnamespace',
633 $request
634 ) && !wfReadOnly()
635 ) {
636 // Reset namespace preferences: namespaces are not searched
637 // when they're not mentioned in the URL parameters.
638 foreach ( MWNamespace::getValidNamespaces() as $n ) {
639 $user->setOption( 'searchNs' . $n, false );
640 }
641 // The request parameters include all the namespaces to be searched.
642 // Even if they're the same as an existing profile, they're not eaten.
643 foreach ( $this->namespaces as $n ) {
644 $user->setOption( 'searchNs' . $n, true );
645 }
646
647 DeferredUpdates::addCallableUpdate( function () use ( $user ) {
648 $user->saveSettings();
649 } );
650
651 return true;
652 }
653
654 return false;
655 }
656
657 /**
658 * @return array
659 */
660 protected function getSearchProfiles() {
661 // Builds list of Search Types (profiles)
662 $nsAllSet = array_keys( $this->searchConfig->searchableNamespaces() );
663 $defaultNs = $this->searchConfig->defaultNamespaces();
664 $profiles = [
665 'default' => [
666 'message' => 'searchprofile-articles',
667 'tooltip' => 'searchprofile-articles-tooltip',
668 'namespaces' => $defaultNs,
669 'namespace-messages' => $this->searchConfig->namespacesAsText(
670 $defaultNs
671 ),
672 ],
673 'images' => [
674 'message' => 'searchprofile-images',
675 'tooltip' => 'searchprofile-images-tooltip',
676 'namespaces' => [ NS_FILE ],
677 ],
678 'all' => [
679 'message' => 'searchprofile-everything',
680 'tooltip' => 'searchprofile-everything-tooltip',
681 'namespaces' => $nsAllSet,
682 ],
683 'advanced' => [
684 'message' => 'searchprofile-advanced',
685 'tooltip' => 'searchprofile-advanced-tooltip',
686 'namespaces' => self::NAMESPACES_CURRENT,
687 ]
688 ];
689
690 Hooks::run( 'SpecialSearchProfiles', [ &$profiles ] );
691
692 foreach ( $profiles as &$data ) {
693 if ( !is_array( $data['namespaces'] ) ) {
694 continue;
695 }
696 sort( $data['namespaces'] );
697 }
698
699 return $profiles;
700 }
701
702 /**
703 * @since 1.18
704 *
705 * @return SearchEngine
706 */
707 public function getSearchEngine() {
708 if ( $this->searchEngine === null ) {
709 $this->searchEngine = $this->searchEngineType ?
710 MediaWikiServices::getInstance()->getSearchEngineFactory()->create( $this->searchEngineType ) :
711 MediaWikiServices::getInstance()->newSearchEngine();
712 }
713
714 return $this->searchEngine;
715 }
716
717 /**
718 * Current search profile.
719 * @return null|string
720 */
721 function getProfile() {
722 return $this->profile;
723 }
724
725 /**
726 * Current namespaces.
727 * @return array
728 */
729 function getNamespaces() {
730 return $this->namespaces;
731 }
732
733 /**
734 * Users of hook SpecialSearchSetupEngine can use this to
735 * add more params to links to not lose selection when
736 * user navigates search results.
737 * @since 1.18
738 *
739 * @param string $key
740 * @param mixed $value
741 */
742 public function setExtraParam( $key, $value ) {
743 $this->extraParams[$key] = $value;
744 }
745
746 /**
747 * The prefix value send to Special:Search using the 'prefix' URI param
748 * It means that the user is willing to search for pages whose titles start with
749 * this prefix value.
750 * (Used by the InputBox extension)
751 *
752 * @return string
753 */
754 public function getPrefix() {
755 return $this->mPrefix;
756 }
757
758 protected function getGroupName() {
759 return 'pages';
760 }
761 }