36 $this->hookRunner =
new HookRunner( $hookContainer );
48 if ( $result->isBrokenTitle() || $result->isMissingRevision() ) {
57 if ( !$this->specialPage->getAuthority()->definitelyCan(
'read', $result->getTitle() ) ) {
58 return Html::rawElement(
'li', [], $link );
64 $date = htmlspecialchars(
65 $this->specialPage->getLanguage()->userTimeAndDate(
66 $result->getTimestamp(),
67 $this->specialPage->getUser()
71 $snippet = $result->getTextSnippet();
73 $extract = Html::rawElement(
'div', [
'class' =>
'searchresult' ], $snippet );
78 if ( $thumb ===
null ) {
90 $terms = $result instanceof \SqlSearchResult ? $result->getTermMatches() : [];
91 if ( !$this->hookRunner->onShowSearchHit( $this->specialPage, $result,
92 $terms, $link, $redirect, $section, $extract, $score,
93 $desc, $date, $related, $html )
100 $joined =
"{$link} {$redirect} {$category} {$section} {$file}";
101 $meta = $this->
buildMeta( $desc, $date );
103 if ( $thumb ===
null ) {
104 $html = Html::rawElement(
106 [
'class' =>
'mw-search-result-heading' ],
109 $html .= $extract .
' ' . $meta;
111 $tableCells = Html::rawElement(
113 [
'style' =>
'width: 120px; text-align: center; vertical-align: top' ],
115 ) . Html::rawElement(
117 [
'style' =>
'vertical-align: top' ],
118 "$joined $extract $meta"
120 $html = Html::rawElement(
122 [
'class' =>
'searchResultImage' ],
131 return Html::rawElement(
'li', [
'class' =>
'mw-search-result' ], $html );
145 $snippet = $result->getTitleSnippet();
146 if ( $snippet ===
'' ) {
153 $title = clone $result->getTitle();
156 $attributes = [
'data-serp-pos' => $position ];
157 $this->hookRunner->onShowSearchHitTitle(
$title, $snippet, $result,
161 $link = $this->linkRenderer->makeLink(
184 : $this->linkRenderer->makeLink(
$title, $text ?
new HtmlArmor( $text ) : null );
186 return "<span class='searchalttitle'>" .
187 $this->specialPage->msg( $msgKey )->rawParams( $inner )->parse()
196 $title = $result->getRedirectTitle();
207 $title = $result->getSectionTitle();
218 $snippet = $result->getCategorySnippet();
229 $title = $result->getTitle();
231 $cat = Category::newFromTitle(
$title );
232 return $this->specialPage->msg(
'search-result-category-size' )
233 ->numParams( $cat->getPageCount(), $cat->getSubcatCount(), $cat->getFileCount() )
236 } elseif ( $result->getByteSize() !==
null || $result->getWordCount() > 0 ) {
237 $lang = $this->specialPage->getLanguage();
238 $bytes =
$lang->formatSize( $result->getByteSize() );
239 $words = $result->getWordCount();
241 return $this->specialPage->msg(
'search-result-size', $bytes )
242 ->numParams( $words )
256 $title = $result->getTitle();
258 return [
'',
null, null ];
261 if ( $result->isFileMatch() ) {
262 $html = Html::rawElement(
264 [
'class' =>
'searchalttitle' ],
265 $this->specialPage->msg(
'search-file-match' )->escaped()
277 $thumb = $img->transform( [
'width' => 120,
'height' => 120 ] );
279 $descHtml = $this->specialPage->msg(
'parentheses' )
280 ->rawParams( $img->getShortDesc() )
282 $thumbHtml = $thumb->toHtml( [
'desc-link' =>
true ] );
286 return [ $html, $descHtml, $thumbHtml ];
297 if ( $desc && $date ) {
298 $meta =
"{$desc} - {$date}";
307 return "<div class='mw-search-result-data'>{$meta}</div>";
Category objects are immutable, strictly speaking.
Marks HTML that shouldn't be escaped.
This class is a collection of static functions that serve two purposes:
NOTE: this class is being refactored into an abstract base class.
implements Special:Search - Run text & title search and display the output
Represents a title within MediaWiki.
if(PHP_SAPI !='cli-server') if(!isset( $_SERVER['SCRIPT_FILENAME'])) $file
Item class for a filearchive table row.
if(!isset( $args[0])) $lang