/**
* @param SearchResult $result The result to render
- * @param string[] $terms Terms to be highlighted (@see SearchResult::getTextSnippet)
* @param int $position The result position, including offset
* @return string HTML
*/
- public function render( SearchResult $result, $terms, $position ) {
+ public function render( SearchResult $result, $position ) {
// If the page doesn't *exist*... our search index is out of date.
// The least confusing at this point is to drop the result.
// You may get less results, but... on well. :P
return '';
}
- $link = $this->generateMainLinkHtml( $result, $terms, $position );
+ $link = $this->generateMainLinkHtml( $result, $position );
// If page content is not readable, just return ths title.
// This is not quite safe, but better than showing excerpts from
// non-readable pages. Note that hiding the entry entirely would
$this->specialPage->getUser()
);
list( $file, $desc, $thumb ) = $this->generateFileHtml( $result );
- $snippet = $result->getTextSnippet( $terms );
+ $snippet = $result->getTextSnippet();
if ( $snippet ) {
$extract = "<div class='searchresult'>$snippet</div>";
} else {
$html = null;
$score = '';
$related = '';
+ // TODO: remove this instanceof and always pass [], let implementors do the cast if
+ // they want to be SearchDatabase specific
+ $terms = $result instanceof \SqlSearchResult ? $result->getTermMatches() : [];
if ( !Hooks::run( 'ShowSearchHit', [
$this->specialPage, $result, $terms,
&$link, &$redirect, &$section, &$extract,
* title with highlighted words).
*
* @param SearchResult $result
- * @param string[] $terms
* @param int $position
* @return string HTML
*/
- protected function generateMainLinkHtml( SearchResult $result, $terms, $position ) {
+ protected function generateMainLinkHtml( SearchResult $result, $position ) {
$snippet = $result->getTitleSnippet();
if ( $snippet === '' ) {
$snippet = null;
$attributes = [ 'data-serp-pos' => $position ];
Hooks::run( 'ShowSearchHitTitle',
- [ &$title, &$snippet, $result, $terms, $this->specialPage, &$query, &$attributes ] );
+ [ &$title, &$snippet, $result,
+ $result instanceof \SqlSearchResult ? $result->getTermMatches() : [],
+ $this->specialPage, &$query, &$attributes ] );
$link = $this->linkRenderer->makeLink(
$title,