X-Git-Url: https://git.heureux-cyclage.org/?a=blobdiff_plain;f=includes%2Fspecials%2FSpecialSearch.php;h=e1fbe6a4882ef8cefd71f7901d2ffdf81b717c1e;hb=eecc04472a0050093928bc48e0c789e99ce93e65;hp=a5203960c024f2ebb64bdec72345dfc04818e85d;hpb=751bac3786c561225f121b607189ccd865416e1b;p=lhc%2Fweb%2Fwiklou.git diff --git a/includes/specials/SpecialSearch.php b/includes/specials/SpecialSearch.php index a5203960c0..e1fbe6a488 100644 --- a/includes/specials/SpecialSearch.php +++ b/includes/specials/SpecialSearch.php @@ -243,14 +243,12 @@ class SpecialSearch extends SpecialPage { $this->namespaces = $nslist; } elseif ( $profile === 'advanced' ) { $this->namespaces = $nslist; + } elseif ( isset( $profiles[$profile]['namespaces'] ) ) { + $this->namespaces = $profiles[$profile]['namespaces']; } else { - if ( isset( $profiles[$profile]['namespaces'] ) ) { - $this->namespaces = $profiles[$profile]['namespaces']; - } else { - // Unknown profile requested - $profile = 'default'; - $this->namespaces = $profiles['default']['namespaces']; - } + // Unknown profile requested + $profile = 'default'; + $this->namespaces = $profiles['default']['namespaces']; } $this->fulltext = $request->getVal( 'fulltext' ); @@ -292,6 +290,7 @@ class SpecialSearch extends SpecialPage { } $out = $this->getOutput(); + $widgetOptions = $this->getConfig()->get( 'SpecialSearchFormOptions' ); $formWidget = new MediaWiki\Widget\Search\SearchFormWidget( $this, $this->searchConfig, @@ -310,19 +309,19 @@ class SpecialSearch extends SpecialPage { // only do the form render here for the empty $term case. Rendering // the form when a search is provided is repeated below. $out->addHTML( $formWidget->render( - $this->profile, $term, 0, 0, $this->offset, $this->isPowerSearch() + $this->profile, $term, 0, 0, $this->offset, $this->isPowerSearch(), $widgetOptions ) ); return; } - $search = $this->getSearchEngine(); - $search->setFeatureData( 'rewrite', $this->runSuggestion ); - $search->setLimitOffset( $this->limit, $this->offset ); - $search->setNamespaces( $this->namespaces ); - $search->setSort( $this->sort ); - $search->prefix = $this->mPrefix; + $engine = $this->getSearchEngine(); + $engine->setFeatureData( 'rewrite', $this->runSuggestion ); + $engine->setLimitOffset( $this->limit, $this->offset ); + $engine->setNamespaces( $this->namespaces ); + $engine->setSort( $this->sort ); + $engine->prefix = $this->mPrefix; - Hooks::run( 'SpecialSearchSetupEngine', [ $this, $this->profile, $search ] ); + Hooks::run( 'SpecialSearchSetupEngine', [ $this, $this->profile, $engine ] ); if ( !Hooks::run( 'SpecialSearchResultsPrepend', [ $this, $out, $term ] ) ) { # Hook requested termination return; @@ -330,24 +329,17 @@ class SpecialSearch extends SpecialPage { $title = Title::newFromText( $term ); $showSuggestion = $title === null || !$title->isKnown(); - $search->setShowSuggestion( $showSuggestion ); + $engine->setShowSuggestion( $showSuggestion ); - $rewritten = $search->transformSearchTerm( $term ); - if ( $rewritten !== $term ) { - $term = $rewritten; - wfDeprecated( 'SearchEngine::transformSearchTerm() (overridden by ' . - get_class( $search ) . ')', '1.32' ); - } - - $rewritten = $search->replacePrefixes( $term ); + $rewritten = $engine->replacePrefixes( $term ); if ( $rewritten !== $term ) { wfDeprecated( 'SearchEngine::replacePrefixes() (overridden by ' . - get_class( $search ) . ')', '1.32' ); + get_class( $engine ) . ')', '1.32' ); } // fetch search results - $titleMatches = $search->searchTitle( $rewritten ); - $textMatches = $search->searchText( $rewritten ); + $titleMatches = $engine->searchTitle( $rewritten ); + $textMatches = $engine->searchText( $rewritten ); $textStatus = null; if ( $textMatches instanceof Status ) { @@ -365,7 +357,7 @@ class SpecialSearch extends SpecialPage { $textMatchesNum = $textMatches->numRows(); $numTextMatches = $textMatches->getTotalHits(); if ( $textMatchesNum > 0 ) { - $search->augmentSearchResults( $textMatches ); + $engine->augmentSearchResults( $textMatches ); } } $num = $titleMatchesNum + $textMatchesNum; @@ -374,7 +366,7 @@ class SpecialSearch extends SpecialPage { // start rendering the page $out->enableOOUI(); $out->addHTML( $formWidget->render( - $this->profile, $term, $num, $totalRes, $this->offset, $this->isPowerSearch() + $this->profile, $term, $num, $totalRes, $this->offset, $this->isPowerSearch(), $widgetOptions ) ); // did you mean... suggestions @@ -426,14 +418,14 @@ class SpecialSearch extends SpecialPage { $mainResultWidget = new FullSearchResultWidget( $this, $linkRenderer ); // Default (null) on. Can be explicitly disabled. - if ( $search->getFeatureData( 'enable-new-crossproject-page' ) !== false ) { + if ( $engine->getFeatureData( 'enable-new-crossproject-page' ) !== false ) { $sidebarResultWidget = new InterwikiSearchResultWidget( $this, $linkRenderer ); $sidebarResultsWidget = new InterwikiSearchResultSetWidget( $this, $sidebarResultWidget, $linkRenderer, MediaWikiServices::getInstance()->getInterwikiLookup(), - $search->getFeatureData( 'show-multimedia-search-results' ) + $engine->getFeatureData( 'show-multimedia-search-results' ) ); } else { $sidebarResultWidget = new SimpleSearchResultWidget( $this, $linkRenderer ); @@ -471,13 +463,13 @@ class SpecialSearch extends SpecialPage { $offset = $this->offset; } - $prevnext = $this->buildPrevNextNavigation( + $prevNext = $this->buildPrevNextNavigation( $offset, $this->limit, $this->powerSearchOptions() + [ 'search' => $term ], $this->limit + $this->offset >= $totalRes ); - $out->addHTML( "

{$prevnext}

\n" ); + $out->addHTML( "

{$prevNext}

\n" ); } // Close
@@ -656,7 +648,9 @@ class SpecialSearch extends SpecialPage { ) { // Reset namespace preferences: namespaces are not searched // when they're not mentioned in the URL parameters. - foreach ( MWNamespace::getValidNamespaces() as $n ) { + foreach ( MediaWikiServices::getInstance()->getNamespaceInfo()->getValidNamespaces() + as $n + ) { $user->setOption( 'searchNs' . $n, false ); } // The request parameters include all the namespaces to be searched.