35 $this->hookRunner =
new HookRunner( $hookContainer );
47 if ( $result->isBrokenTitle() || $result->isMissingRevision() ) {
57 if ( !$permissionManager->userCan(
58 'read', $this->specialPage->getUser(), $result->getTitle()
60 return "<li>{$link}</li>";
66 $date = htmlspecialchars(
67 $this->specialPage->getLanguage()->userTimeAndDate(
68 $result->getTimestamp(),
69 $this->specialPage->getUser()
73 $snippet = $result->getTextSnippet();
75 $extract =
"<div class='searchresult'>$snippet</div>";
80 if ( $thumb ===
null ) {
92 $terms = $result instanceof \SqlSearchResult ? $result->getTermMatches() : [];
93 if ( !$this->hookRunner->onShowSearchHit( $this->specialPage, $result,
94 $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 ) {
107 "<div class='mw-search-result-heading'>{$joined}</div>" .
108 "{$extract} {$meta}";
111 "<table class='searchResultImage'>" .
113 "<td style='width: 120px; text-align: center; vertical-align: top'>" .
116 "<td style='vertical-align: top'>" .
117 "{$joined} {$extract} {$meta}" .
123 return "<li class='mw-search-result'>{$html}</li>";
137 $snippet = $result->getTitleSnippet();
138 if ( $snippet ===
'' ) {
145 $title = clone $result->getTitle();
148 $attributes = [
'data-serp-pos' => $position ];
149 $this->hookRunner->onShowSearchHitTitle(
$title, $snippet, $result,
153 $link = $this->linkRenderer->makeLink(
176 : $this->linkRenderer->makeLink(
$title, $text ?
new HtmlArmor( $text ) : null );
178 return "<span class='searchalttitle'>" .
179 $this->specialPage->msg( $msgKey )->rawParams( $inner )->parse()
188 $title = $result->getRedirectTitle();
199 $title = $result->getSectionTitle();
210 $snippet = $result->getCategorySnippet();
221 $title = $result->getTitle();
223 $cat = Category::newFromTitle(
$title );
224 return $this->specialPage->msg(
'search-result-category-size' )
225 ->numParams( $cat->getPageCount(), $cat->getSubcatCount(), $cat->getFileCount() )
228 } elseif ( $result->getByteSize() !==
null || $result->getWordCount() > 0 ) {
229 $lang = $this->specialPage->getLanguage();
230 $bytes =
$lang->formatSize( $result->getByteSize() );
231 $words = $result->getWordCount();
233 return $this->specialPage->msg(
'search-result-size', $bytes )
234 ->numParams( $words )
248 $title = $result->getTitle();
250 return [
'',
null, null ];
253 if ( $result->isFileMatch() ) {
254 $html =
"<span class='searchalttitle'>" .
255 $this->specialPage->msg(
'search-file-match' )->escaped() .
267 $thumb = $img->transform( [
'width' => 120,
'height' => 120 ] );
269 $descHtml = $this->specialPage->msg(
'parentheses' )
270 ->rawParams( $img->getShortDesc() )
272 $thumbHtml = $thumb->toHtml( [
'desc-link' =>
true ] );
276 return [ $html, $descHtml, $thumbHtml ];
287 if ( $desc && $date ) {
288 $meta =
"{$desc} - {$date}";
297 return "<div class='mw-search-result-data'>{$meta}</div>";
Category objects are immutable, strictly speaking.
Marks HTML that shouldn't be escaped.
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