X-Git-Url: https://git.heureux-cyclage.org/?a=blobdiff_plain;f=includes%2Fspecials%2FSpecialSearch.php;h=9f83832e133b883e83af4354db47c19b7a08e2ff;hb=5a1104444f3d71d3f696f130de79b315f86e15cc;hp=26b86f9762cf75173023058b6374f8e3a4803dcd;hpb=d7a9ccee2dc835d2b662c7bc8b7ff655d762c093;p=lhc%2Fweb%2Fwiklou.git diff --git a/includes/specials/SpecialSearch.php b/includes/specials/SpecialSearch.php index 26b86f9762..9f83832e13 100644 --- a/includes/specials/SpecialSearch.php +++ b/includes/specials/SpecialSearch.php @@ -234,11 +234,6 @@ class SpecialSearch extends SpecialPage { return; } - # No match, generate an edit URL - $title = Title::newFromText( $term ); - if ( !is_null( $title ) ) { - Hooks::run( 'SpecialSearchNogomatch', [ &$title ] ); - } $this->showResults( $term ); } @@ -300,12 +295,12 @@ class SpecialSearch extends SpecialPage { $textStatus = null; if ( $textMatches instanceof Status ) { $textStatus = $textMatches; - $textMatches = null; + $textMatches = $textStatus->getValue(); } // did you mean... suggestions $didYouMeanHtml = ''; - if ( $showSuggestion && $textMatches && !$textStatus ) { + if ( $showSuggestion && $textMatches ) { if ( $textMatches->hasRewrittenQuery() ) { $didYouMeanHtml = $this->getDidYouMeanRewrittenHtml( $term, $textMatches ); } elseif ( $textMatches->hasSuggestion() ) { @@ -365,6 +360,25 @@ class SpecialSearch extends SpecialPage { $out->addHTML( "
" ); + $hasErrors = $textStatus && $textStatus->getErrors(); + if ( $hasErrors ) { + list( $error, $warning ) = $textStatus->splitByErrorType(); + if ( $error->getErrors() ) { + $out->addHTML( Html::rawElement( + 'div', + [ 'class' => 'errorbox' ], + $error->getHTML( 'search-error' ) + ) ); + } + if ( $warning->getErrors() ) { + $out->addHTML( Html::rawElement( + 'div', + [ 'class' => 'warningbox' ], + $warning->getHTML( 'search-warning' ) + ) ); + } + } + // prev/next links $prevnext = null; if ( $num || $this->offset ) { @@ -393,7 +407,8 @@ class SpecialSearch extends SpecialPage { } $titleMatches->free(); } - if ( $textMatches && !$textStatus ) { + + if ( $textMatches ) { // output appropriate heading if ( $numTextMatches > 0 && $numTitleMatches > 0 ) { $out->addHTML( '
' ); @@ -403,6 +418,7 @@ class SpecialSearch extends SpecialPage { // show results if ( $numTextMatches > 0 ) { + $search->augmentSearchResults( $textMatches ); $out->addHTML( $this->showMatches( $textMatches ) ); } @@ -416,17 +432,18 @@ class SpecialSearch extends SpecialPage { $hasOtherResults = $textMatches && $textMatches->hasInterwikiResults( SearchResultSet::INLINE_RESULTS ); - if ( $num === 0 ) { - if ( $textStatus ) { - $out->addHTML( '
' . - $textStatus->getMessage( 'search-error' ) . '
' ); - } else { + // If we have no results and we have not already displayed an error message + if ( $num === 0 && !$hasErrors ) { + if ( !$this->offset ) { + // If we have an offset the create link was rendered earlier in this function. + // This class needs a good de-spaghettification, but for now this will + // do the job. $this->showCreateLink( $title, $num, $titleMatches, $textMatches ); - $out->wrapWikiMsg( "

\n$1

", - [ $hasOtherResults ? 'search-nonefound-thiswiki' : 'search-nonefound', - wfEscapeWikiText( $term ) - ] ); } + $out->wrapWikiMsg( "

\n$1

", [ + $hasOtherResults ? 'search-nonefound-thiswiki' : 'search-nonefound', + wfEscapeWikiText( $term ) + ] ); } if ( $hasOtherResults ) { @@ -454,7 +471,6 @@ class SpecialSearch extends SpecialPage { $out->addHTML( "
" ); Hooks::run( 'SpecialSearchResultsAppend', [ $this, $out, $term ] ); - } /** @@ -469,25 +485,6 @@ class SpecialSearch extends SpecialPage { return "

\n$wikiMsg

"; } - /** - * Decide if the suggested query should be run, and it's results returned - * instead of the provided $textMatches - * - * @param SearchResultSet $textMatches The results of a users query - * @return bool - */ - protected function shouldRunSuggestedQuery( SearchResultSet $textMatches ) { - if ( !$this->runSuggestion || - !$textMatches->hasSuggestion() || - $textMatches->numRows() > 0 || - $textMatches->searchContainedSyntax() - ) { - return false; - } - - return $this->getConfig()->get( 'SearchRunSuggestedQuery' ); - } - /** * Generates HTML shown to the user when we have a suggestion about a query * that might give more results than their current query. @@ -716,7 +713,7 @@ class SpecialSearch extends SpecialPage { * * @return string */ - protected function showMatches( &$matches, $interwiki = null ) { + protected function showMatches( $matches, $interwiki = null ) { global $wgContLang; $terms = $wgContLang->convertForSearchResult( $matches->termMatches() ); @@ -725,7 +722,7 @@ class SpecialSearch extends SpecialPage { $pos = $this->offset; if ( $result && $interwiki ) { - $out .= $this->interwikiHeader( $interwiki, $result ); + $out .= $this->interwikiHeader( $interwiki, $matches ); } $out .= "