37 $this->hookRunner =
new HookRunner( $hookContainer );
49 if ( $result->isBrokenTitle() || $result->isMissingRevision() ) {
58 if ( !$this->specialPage->getAuthority()->definitelyCan(
'read', $result->getTitle() ) ) {
59 return Html::rawElement(
'li', [], $link );
65 $date = htmlspecialchars(
66 $this->specialPage->getLanguage()->userTimeAndDate(
67 $result->getTimestamp(),
68 $this->specialPage->getUser()
72 $snippet = $result->getTextSnippet();
74 $extract = Html::rawElement(
'div', [
'class' =>
'searchresult' ], $snippet );
79 if ( $thumb ===
null ) {
91 $terms = $result instanceof \SqlSearchResult ? $result->getTermMatches() : [];
92 if ( !$this->hookRunner->onShowSearchHit( $this->specialPage, $result,
93 $terms, $link, $redirect, $section, $extract, $score,
95 $desc, $date, $related, $html )
102 $joined =
"{$link} {$redirect} {$category} {$section} {$file}";
103 $meta = $this->
buildMeta( $desc, $date );
105 if ( $thumb ===
null ) {
106 $html = Html::rawElement(
108 [
'class' =>
'mw-search-result-heading' ],
111 $html .= $extract .
' ' . $meta;
113 $tableCells = Html::rawElement(
115 [
'style' =>
'width: 120px; text-align: center; vertical-align: top' ],
117 ) . Html::rawElement(
119 [
'style' =>
'vertical-align: top' ],
120 "$joined $extract $meta"
122 $html = Html::rawElement(
124 [
'class' =>
'searchResultImage' ],
133 return Html::rawElement(
'li', [
'class' =>
'mw-search-result' ], $html );
147 $snippet = $result->getTitleSnippet();
148 if ( $snippet ===
'' ) {
155 $title = clone $result->getTitle();
158 $attributes = [
'data-serp-pos' => $position ];
159 $this->hookRunner->onShowSearchHitTitle(
$title, $snippet, $result,
164 $link = $this->linkRenderer->makeLink(
187 : $this->linkRenderer->makeLink(
$title, $text ?
new HtmlArmor( $text ) : null );
189 return "<span class='searchalttitle'>" .
190 $this->specialPage->msg( $msgKey )->rawParams( $inner )->parse()
199 $title = $result->getRedirectTitle();
210 $title = $result->getSectionTitle();
221 $snippet = $result->getCategorySnippet();
232 $title = $result->getTitle();
234 $cat = Category::newFromTitle(
$title );
235 return $this->specialPage->msg(
'search-result-category-size' )
236 ->numParams( $cat->getMemberCount(), $cat->getSubcatCount(), $cat->getFileCount() )
239 } elseif ( $result->getByteSize() !==
null || $result->getWordCount() > 0 ) {
240 return $this->specialPage->msg(
'search-result-size' )
241 ->sizeParams( $result->getByteSize() )
242 ->numParams( $result->getWordCount() )
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 ] );
281 $unsafeShortDesc = $img->getShortDesc();
282 $shortDesc = Sanitizer::removeSomeTags( $unsafeShortDesc );
284 $descHtml = $this->specialPage->msg(
'parentheses' )
285 ->rawParams( $shortDesc )
287 $thumbHtml = $thumb->toHtml( [
'desc-link' =>
true ] );
291 return [ $html, $descHtml, $thumbHtml ];
302 if ( $desc && $date ) {
303 $meta =
"{$desc} - {$date}";
312 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:
HTML sanitizer for MediaWiki.
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.