41 if ( $result->isBrokenTitle() || $result->isMissingRevision() ) {
50 if ( !$result->getTitle()->userCan(
'read', $this->specialPage->getUser() ) ) {
51 return "<li>{$link}</li>";
57 $date = htmlspecialchars(
58 $this->specialPage->getLanguage()->userTimeAndDate(
59 $result->getTimestamp(),
60 $this->specialPage->getUser()
64 $snippet = $result->getTextSnippet( $terms );
66 $extract =
"<div class='searchresult'>$snippet</div>";
71 if ( $thumb ===
null ) {
81 if ( !Hooks::run(
'ShowSearchHit', [
82 $this->specialPage, $result, $terms,
84 &$score, &$desc, &$date, &$related, &
$html
91 $joined =
"{$link} {$redirect} {$category} {$section} {$file}";
94 if ( $thumb ===
null ) {
96 "<div class='mw-search-result-heading'>{$joined}</div>" .
100 "<table class='searchResultImage'>" .
102 "<td style='width: 120px; text-align: center; vertical-align: top'>" .
105 "<td style='vertical-align: top'>" .
106 "{$joined} {$extract} {$meta}" .
112 return "<li>{$html}</li>";
127 $snippet = $result->getTitleSnippet();
128 if ( $snippet ===
'' ) {
135 $title = clone $result->getTitle();
138 $attributes = [
'data-serp-pos' => $position ];
139 Hooks::run(
'ShowSearchHitTitle',
140 [ &$title, &$snippet, $result, $terms, $this->specialPage, &
$query, &$attributes ] );
142 $link = $this->linkRenderer->makeLink(
163 $inner = $title ===
null
165 : $this->linkRenderer->makeLink( $title, $text ?
new HtmlArmor( $text ) : null );
167 return "<span class='searchalttitle'>" .
168 $this->specialPage->msg( $msgKey )->rawParams( $inner )->parse()
177 $title = $result->getRedirectTitle();
178 return $title ===
null
188 $title = $result->getSectionTitle();
189 return $title ===
null
199 $snippet = $result->getCategorySnippet();
210 $title = $result->getTitle();
212 $cat = Category::newFromTitle( $title );
213 return $this->specialPage->msg(
'search-result-category-size' )
214 ->numParams( $cat->getPageCount(), $cat->getSubcatCount(), $cat->getFileCount() )
217 } elseif ( $result->getByteSize() !==
null || $result->getWordCount() > 0 ) {
218 $lang = $this->specialPage->getLanguage();
219 $bytes =
$lang->formatSize( $result->getByteSize() );
220 $words = $result->getWordCount();
222 return $this->specialPage->msg(
'search-result-size', $bytes )
223 ->numParams( $words )
237 $title = $result->getTitle();
238 if ( $title->getNamespace() !==
NS_FILE ) {
239 return [
'',
null, null ];
242 if ( $result->isFileMatch() ) {
243 $html =
"<span class='searchalttitle'>" .
244 $this->specialPage->msg(
'search-file-match' )->escaped() .
253 $img = $result->getFile() ?:
wfFindFile( $title );
255 $thumb = $img->transform( [
'width' => 120,
'height' => 120 ] );
257 $descHtml = $this->specialPage->msg(
'parentheses' )
258 ->rawParams( $img->getShortDesc() )
260 $thumbHtml = $thumb->toHtml( [
'desc-link' =>
true ] );
264 return [
$html, $descHtml, $thumbHtml ];
275 if ( $desc && $date ) {
276 $meta =
"{$desc} - {$date}";
285 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