41 if ( $result->isBrokenTitle() || $result->isMissingRevision() ) {
50 if ( !$result->getTitle()->userCan(
'read', $this->specialPage->getUser() ) ) {
51 return "<li>{$link}</li>";
57 $date = $this->specialPage->getLanguage()->userTimeAndDate(
58 $result->getTimestamp(),
59 $this->specialPage->getUser()
62 $snippet = $result->getTextSnippet( $terms );
64 $extract =
"<div class='searchresult'>$snippet</div>";
69 if ( $thumb ===
null ) {
79 if ( !Hooks::run(
'ShowSearchHit', [
80 $this->specialPage, $result, $terms,
82 &$score, &$desc, &$date, &$related, &
$html
89 $joined =
"{$link} {$redirect} {$category} {$section} {$file}";
92 if ( $thumb ===
null ) {
94 "<div class='mw-search-result-heading'>{$joined}</div>" .
98 "<table class='searchResultImage'>" .
100 "<td style='width: 120px; text-align: center; vertical-align: top'>" .
103 "<td style='vertical-align: top'>" .
104 "{$joined} {$extract} {$meta}" .
110 return "<li class='mw-search-result'>{$html}</li>";
125 $snippet = $result->getTitleSnippet();
126 if ( $snippet ===
'' ) {
133 $title = clone $result->getTitle();
136 $attributes = [
'data-serp-pos' => $position ];
137 Hooks::run(
'ShowSearchHitTitle',
138 [ &$title, &$snippet, $result, $terms, $this->specialPage, &
$query, &$attributes ] );
140 $link = $this->linkRenderer->makeLink(
161 $inner = $title ===
null
163 : $this->linkRenderer->makeLink( $title, $text ?
new HtmlArmor( $text ) : null );
165 return "<span class='searchalttitle'>" .
166 $this->specialPage->msg( $msgKey )->rawParams( $inner )->parse()
175 $title = $result->getRedirectTitle();
176 return $title ===
null
186 $title = $result->getSectionTitle();
187 return $title ===
null
197 $snippet = $result->getCategorySnippet();
208 $title = $result->getTitle();
210 $cat = Category::newFromTitle( $title );
211 return $this->specialPage->msg(
'search-result-category-size' )
212 ->numParams( $cat->getPageCount(), $cat->getSubcatCount(), $cat->getFileCount() )
215 } elseif ( $result->getByteSize() !==
null || $result->getWordCount() > 0 ) {
216 $lang = $this->specialPage->getLanguage();
217 $bytes =
$lang->formatSize( $result->getByteSize() );
218 $words = $result->getWordCount();
220 return $this->specialPage->msg(
'search-result-size', $bytes )
221 ->numParams( $words )
235 $title = $result->getTitle();
236 if ( $title->getNamespace() !==
NS_FILE ) {
237 return [
'',
null, null ];
240 if ( $result->isFileMatch() ) {
241 $html =
"<span class='searchalttitle'>" .
242 $this->specialPage->msg(
'search-file-match' )->escaped() .
251 $img = $result->getFile() ?:
wfFindFile( $title );
253 $thumb = $img->transform( [
'width' => 120,
'height' => 120 ] );
255 $descHtml = $this->specialPage->msg(
'parentheses' )
256 ->rawParams( $img->getShortDesc() )
258 $thumbHtml = $thumb->toHtml( [
'desc-link' =>
true ] );
262 return [
$html, $descHtml, $thumbHtml ];
273 if ( $desc && $date ) {
274 $meta =
"{$desc} - {$date}";
283 return "<div class='mw-search-result-data'>{$meta}</div>";
wfFindFile( $title, $options=[])
Find a file.
Category objects are immutable, strictly speaking.
Marks HTML that shouldn't be escaped.
implements Special:Search - Run text & title search and display the output
Represents a title within MediaWiki.
deferred txt A few of the database updates required by various functions here can be deferred until after the result page is displayed to the user For updating the view updating the linked to tables after a etc PHP does not yet have any way to tell the server to actually return and disconnect while still running these but it might have such a feature in the future We handle these by creating a deferred update object and putting those objects on a global list
null means default in associative array with keys and values unescaped Should be merged with default with a value of false meaning to suppress the attribute in associative array with keys and values unescaped noclasses just before the function returns a value If you return an< a > element with HTML attributes $attribs and contents $html will be returned If you return $ret will be returned and may include noclasses & $html
usually copyright or history_copyright This message must be in HTML not wikitext & $link
null for the local wiki Added should default to null in handler for backwards compatibility add a value to it if you want to add a cookie that have to vary cache options can modify $query
usually copyright or history_copyright This message must be in HTML not wikitext if the section is included from a template $section
if(!isset( $args[0])) $lang