X-Git-Url: https://git.cyclocoop.org/?a=blobdiff_plain;f=includes%2Fspecials%2FSpecialSearch.php;h=727179af7d845c37a4c1f88bb9769fcf35a5a74d;hb=f9e21f91e459c40fed6d8f2e76cccbce07e2ba1b;hp=9280b0478fcb7d86892b40453a24c26157d373b6;hpb=cf5c36ccfd8dce53ea8d3631b1902050e93d4acd;p=lhc%2Fweb%2Fwiklou.git diff --git a/includes/specials/SpecialSearch.php b/includes/specials/SpecialSearch.php index 9280b0478f..727179af7d 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( "
\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 ) { @@ -483,9 +499,16 @@ class SpecialSearch extends SpecialPage { } $stParams = array_merge( $params, $this->powerSearchOptions() ); - $suggest = Linker::linkKnown( + $linkRenderer = $this->getLinkRenderer(); + + $snippet = $textMatches->getSuggestionSnippet() ?: null; + if ( $snippet !== null ) { + $snippet = new HtmlArmor( $snippet ); + } + + $suggest = $linkRenderer->makeKnownLink( $this->getPageTitle(), - $textMatches->getSuggestionSnippet() ?: null, + $snippet, [ 'id' => 'mw-search-DYM-suggestion' ], $stParams ); @@ -519,18 +542,25 @@ class SpecialSearch extends SpecialPage { } $stParams = array_merge( $params, $this->powerSearchOptions() ); - $rewritten = Linker::linkKnown( + $linkRenderer = $this->getLinkRenderer(); + + $snippet = $textMatches->getQueryAfterRewriteSnippet() ?: null; + if ( $snippet !== null ) { + $snippet = new HtmlArmor( $snippet ); + } + + $rewritten = $linkRenderer->makeKnownLink( $this->getPageTitle(), - $textMatches->getQueryAfterRewriteSnippet() ?: null, + $snippet, [ 'id' => 'mw-search-DYM-rewritten' ], $stParams ); $stParams['search'] = $term; $stParams['runsuggestion'] = 0; - $original = Linker::linkKnown( + $original = $linkRenderer->makeKnownLink( $this->getPageTitle(), - htmlspecialchars( $term ), + $term, [ 'id' => 'mw-search-DYM-original' ], $stParams ); @@ -750,7 +780,13 @@ class SpecialSearch extends SpecialPage { Hooks::run( 'ShowSearchHitTitle', [ &$link_t, &$titleSnippet, $result, $terms, $this, &$query ] ); - $link = Linker::linkKnown( + $linkRenderer = $this->getLinkRenderer(); + + if ( $titleSnippet !== null ) { + $titleSnippet = new HtmlArmor( $titleSnippet ); + } + + $link = $linkRenderer->makeKnownLink( $link_t, $titleSnippet, [ 'data-serp-pos' => $position ], // HTML attributes @@ -784,9 +820,13 @@ class SpecialSearch extends SpecialPage { $redirectText = null; } + if ( $redirectText !== null ) { + $redirectText = new HtmlArmor( $redirectText ); + } + $redirect = "" . $this->msg( 'search-redirect' )->rawParams( - Linker::linkKnown( $redirectTitle, $redirectText ) )->text() . + $linkRenderer->makeKnownLink( $redirectTitle, $redirectText ) )->text() . ""; } @@ -796,9 +836,13 @@ class SpecialSearch extends SpecialPage { $sectionText = null; } + if ( $sectionText !== null ) { + $sectionText = new HtmlArmor( $sectionText ); + } + $section = "" . $this->msg( 'search-section' )->rawParams( - Linker::linkKnown( $sectionTitle, $sectionText ) )->text() . + $linkRenderer->makeKnownLink( $sectionTitle, $sectionText ) )->text() . ""; } @@ -955,6 +999,8 @@ class SpecialSearch extends SpecialPage { return ''; } + $linkRenderer = $this->getLinkRenderer(); + $title = $result->getTitle(); $titleSnippet = $result->getTitleSnippet(); @@ -963,7 +1009,11 @@ class SpecialSearch extends SpecialPage { $titleSnippet = null; } - $link = Linker::linkKnown( + if ( $titleSnippet !== null ) { + $titleSnippet = new HtmlArmor( $titleSnippet ); + } + + $link = $linkRenderer->makeKnownLink( $title, $titleSnippet ); @@ -977,9 +1027,13 @@ class SpecialSearch extends SpecialPage { $redirectText = null; } + if ( $redirectText !== null ) { + $redirectText = new HtmlArmor( $redirectText ); + } + $redirect = "" . $this->msg( 'search-redirect' )->rawParams( - Linker::linkKnown( $redirectTitle, $redirectText ) )->text() . + $linkRenderer->makeKnownLink( $redirectTitle, $redirectText ) )->text() . ""; } @@ -997,7 +1051,7 @@ class SpecialSearch extends SpecialPage { } // "more results" link (special page stuff could be localized, but we might not know target lang) $searchTitle = Title::newFromText( $title->getInterwiki() . ":Special:Search" ); - $searchLink = Linker::linkKnown( + $searchLink = $linkRenderer->makeKnownLink( $searchTitle, $this->msg( 'search-interwiki-more' )->text(), [],