X-Git-Url: https://git.heureux-cyclage.org/?a=blobdiff_plain;f=includes%2Fspecials%2FSpecialSearch.php;h=9f83832e133b883e83af4354db47c19b7a08e2ff;hb=6bb1170e2f3539218965d1ceaa2cfc5e6197f465;hp=9280b0478fcb7d86892b40453a24c26157d373b6;hpb=1674c8413a4ec5065040408a8cbdb948c74bf6fa;p=lhc%2Fweb%2Fwiklou.git diff --git a/includes/specials/SpecialSearch.php b/includes/specials/SpecialSearch.php index 9280b0478f..9f83832e13 100644 --- a/includes/specials/SpecialSearch.php +++ b/includes/specials/SpecialSearch.php @@ -295,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() ) { @@ -360,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 ) { @@ -388,7 +407,8 @@ class SpecialSearch extends SpecialPage { } $titleMatches->free(); } - if ( $textMatches && !$textStatus ) { + + if ( $textMatches ) { // output appropriate heading if ( $numTextMatches > 0 && $numTitleMatches > 0 ) { $out->addHTML( '
' ); @@ -412,22 +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 ( !$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 ) - ] ); + // 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 ) + ] ); } if ( $hasOtherResults ) {