MediaWiki REL1_30
SimpleSearchResultWidget.php
Go to the documentation of this file.
1<?php
2
4
5use HtmlArmor;
9
15 protected $specialSearch;
17 protected $linkRenderer;
18
20 $this->specialSearch = $specialSearch;
21 $this->linkRenderer = $linkRenderer;
22 }
23
30 public function render( SearchResult $result, $terms, $position ) {
31 $title = $result->getTitle();
32 $titleSnippet = $result->getTitleSnippet();
33 if ( $titleSnippet ) {
34 $titleSnippet = new HtmlArmor( $titleSnippet );
35 } else {
36 $titleSnippet = null;
37 }
38
39 $link = $this->linkRenderer->makeLink( $title, $titleSnippet );
40
41 $redirectTitle = $result->getRedirectTitle();
42 $redirect = '';
43 if ( $redirectTitle !== null ) {
44 $redirectText = $result->getRedirectSnippet();
45 if ( $redirectText ) {
46 $redirectText = new HtmlArmor( $redirectText );
47 } else {
48 $redirectText = null;
49 }
50 $redirect =
51 "<span class='searchalttitle'>" .
52 $this->specialSearch->msg( 'search-redirect' )->rawParams(
53 $this->linkRenderer->makeLink( $redirectTitle, $redirectText )
54 )->text() .
55 "</span>";
56 }
57
58 return "<li>{$link} {$redirect}</li>";
59 }
60}
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:2989
Renders a single search result to HTML.