MediaWiki REL1_32
SimpleSearchResultWidget.php
Go to the documentation of this file.
1<?php
2
4
5use HtmlArmor;
9
17 protected $specialSearch;
19 protected $linkRenderer;
20
22 wfDeprecated( __METHOD__, '1.31' );
23 $this->specialSearch = $specialSearch;
24 $this->linkRenderer = $linkRenderer;
25 }
26
33 public function render( SearchResult $result, $terms, $position ) {
34 $title = $result->getTitle();
35 $titleSnippet = $result->getTitleSnippet();
36 if ( $titleSnippet ) {
37 $titleSnippet = new HtmlArmor( $titleSnippet );
38 } else {
39 $titleSnippet = null;
40 }
41
42 $link = $this->linkRenderer->makeLink( $title, $titleSnippet );
43
44 $redirectTitle = $result->getRedirectTitle();
45 $redirect = '';
46 if ( $redirectTitle !== null ) {
47 $redirectText = $result->getRedirectSnippet();
48 if ( $redirectText ) {
49 $redirectText = new HtmlArmor( $redirectText );
50 } else {
51 $redirectText = null;
52 }
53 $redirect =
54 "<span class='searchalttitle'>" .
55 $this->specialSearch->msg( 'search-redirect' )->rawParams(
56 $this->linkRenderer->makeLink( $redirectTitle, $redirectText )
57 )->parse() .
58 "</span>";
59 }
60
61 return "<li>{$link} {$redirect}</li>";
62 }
63}
wfDeprecated( $function, $version=false, $component=false, $callerOffset=2)
Throws a warning that $function is deprecated.
Marks HTML that shouldn't be escaped.
Definition HtmlArmor.php:28
Class that generates HTML links for pages.
__construct(SpecialSearch $specialSearch, LinkRenderer $linkRenderer)
render(SearchResult $result, $terms, $position)
implements Special:Search - Run text & title search and display the output
usually copyright or history_copyright This message must be in HTML not wikitext & $link
Definition hooks.txt:3106
Renders a single search result to HTML.