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,
94 $desc, $date, $related, $html )
101 $joined =
"{$link} {$redirect} {$category} {$section} {$file}";
102 $meta = $this->
buildMeta( $desc, $date );
104 if ( $thumb ===
null ) {
105 $html = Html::rawElement(
107 [
'class' =>
'mw-search-result-heading' ],
110 $html .= $extract .
' ' . $meta;
112 $tableCells = Html::rawElement(
114 [
'style' =>
'width: 120px; text-align: center; vertical-align: top' ],
116 ) . Html::rawElement(
118 [
'style' =>
'vertical-align: top' ],
119 "$joined $extract $meta"
121 $html = Html::rawElement(
123 [
'class' =>
'searchResultImage' ],
132 return Html::rawElement(
'li', [
'class' =>
'mw-search-result' ], $html );
146 $snippet = $result->getTitleSnippet();
147 if ( $snippet ===
'' ) {
154 $title = clone $result->getTitle();
157 $attributes = [
'data-serp-pos' => $position ];
158 $this->hookRunner->onShowSearchHitTitle(
$title, $snippet, $result,
163 $link = $this->linkRenderer->makeLink(
186 : $this->linkRenderer->makeLink(
$title, $text ?
new HtmlArmor( $text ) : null );
188 return "<span class='searchalttitle'>" .
189 $this->specialPage->msg( $msgKey )->rawParams( $inner )->parse()
198 $title = $result->getRedirectTitle();
209 $title = $result->getSectionTitle();
220 $snippet = $result->getCategorySnippet();
231 $title = $result->getTitle();
233 $cat = Category::newFromTitle(
$title );
234 return $this->specialPage->msg(
'search-result-category-size' )
235 ->numParams( $cat->getMemberCount(), $cat->getSubcatCount(), $cat->getFileCount() )
238 } elseif ( $result->getByteSize() !==
null || $result->getWordCount() > 0 ) {
239 return $this->specialPage->msg(
'search-result-size' )
240 ->sizeParams( $result->getByteSize() )
241 ->numParams( $result->getWordCount() )
255 $title = $result->getTitle();
257 return [
'',
null, null ];
260 if ( $result->isFileMatch() ) {
261 $html = Html::rawElement(
263 [
'class' =>
'searchalttitle' ],
264 $this->specialPage->msg(
'search-file-match' )->escaped()
276 $thumb = $img->transform( [
'width' => 120,
'height' => 120 ] );
278 $descHtml = $this->specialPage->msg(
'parentheses' )
279 ->rawParams( $img->getShortDesc() )
281 $thumbHtml = $thumb->toHtml( [
'desc-link' =>
true ] );
285 return [ $html, $descHtml, $thumbHtml ];
296 if ( $desc && $date ) {
297 $meta =
"{$desc} - {$date}";
306 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.