Wikibase
MediaWiki Wikibase extension
Loading...
Searching...
No Matches
Wikibase\Repo\Hooks\ShowSearchHitHandler Class Reference

Handler to format entities in the search results. More...

+ Inheritance diagram for Wikibase\Repo\Hooks\ShowSearchHitHandler:
+ Collaboration diagram for Wikibase\Repo\Hooks\ShowSearchHitHandler:

Public Member Functions

 __construct (EntityContentFactory $entityContentFactory, EntityIdLookup $entityIdLookup, EntityLookup $entityLookup, LanguageFallbackChainFactory $fallbackChainFactory)
 
 onShowSearchHit ( $searchPage, $result, $terms, &$link, &$redirect, &$section, &$extract, &$score, &$size, &$date, &$related, &$html)
 Format the output when the search result contains entities.
 
 onShowSearchHitTitle (&$title, &$titleSnippet, $result, $terms, $specialSearch, &$query, &$attributes)
 Remove span tag placed around title search hit for entity titles to highlight matches in bold.
 

Static Public Member Functions

static addLanguageAttrs (array &$attr, string $displayLanguage, array $text)
 Add attributes appropriate for language of this text.
 
static addDescription (string &$html, array $description, SpecialSearch $searchPage)
 Add HTML description to search result.
 
static withLanguage ( $text, $displayLanguage)
 If text's language is not the same as display language, add marker with language name to the string.
 

Private Member Functions

 isTitleEntity (Title $title)
 
 getEntity (Title $title)
 

Private Attributes

 $entityContentFactory
 
 $entityIdLookup
 
 $entityLookup
 
 $fallbackChainFactory
 

Detailed Description

Handler to format entities in the search results.

Author
Matěj Suchánek
Daniel Kinzler

Constructor & Destructor Documentation

◆ __construct()

Wikibase\Repo\Hooks\ShowSearchHitHandler::__construct ( EntityContentFactory $entityContentFactory,
EntityIdLookup $entityIdLookup,
EntityLookup $entityLookup,
LanguageFallbackChainFactory $fallbackChainFactory )

Member Function Documentation

◆ addDescription()

static Wikibase\Repo\Hooks\ShowSearchHitHandler::addDescription ( string & $html,
array $description,
SpecialSearch $searchPage )
static

Add HTML description to search result.

Parameters
string&$htmlThe html of the description will be appended here.
string[]$descriptionDescription as [language, value] array
SpecialSearch$searchPage

◆ addLanguageAttrs()

static Wikibase\Repo\Hooks\ShowSearchHitHandler::addLanguageAttrs ( array & $attr,
string $displayLanguage,
array $text )
static

Add attributes appropriate for language of this text.

Parameters
array&$attrLink attributes, to be modified if needed
string$displayLanguage
array$textText description array, with language in ['language']

◆ getEntity()

Wikibase\Repo\Hooks\ShowSearchHitHandler::getEntity ( Title $title)
private

◆ isTitleEntity()

Wikibase\Repo\Hooks\ShowSearchHitHandler::isTitleEntity ( Title $title)
private

◆ onShowSearchHit()

Wikibase\Repo\Hooks\ShowSearchHitHandler::onShowSearchHit ( $searchPage,
$result,
$terms,
& $link,
& $redirect,
& $section,
& $extract,
& $score,
& $size,
& $date,
& $related,
& $html )

Format the output when the search result contains entities.

See also
https://www.mediawiki.org/wiki/Manual:Hooks/ShowSearchHit
showEntityResultHit
showPlainSearchHit
Parameters
SpecialSearch$searchPage
SearchResult$result
string[]$terms
string&$link
string&$redirect
string&$section
string&$extract
string&$score
string&$size
string&$date
string&$related
string&$html
Returns
void

◆ onShowSearchHitTitle()

Wikibase\Repo\Hooks\ShowSearchHitHandler::onShowSearchHitTitle ( & $title,
& $titleSnippet,
$result,
$terms,
$specialSearch,
& $query,
& $attributes )

Remove span tag placed around title search hit for entity titles to highlight matches in bold.

Todo
Add highlighting when Q##-id matches and not label text.
Parameters
Title&$title
string | HtmlArmor | null&$titleSnippet
SearchResult$result
array$terms
SpecialSearch$specialSearch
string[]&$query
string[]&$attributes
Returns
void

◆ withLanguage()

static Wikibase\Repo\Hooks\ShowSearchHitHandler::withLanguage ( $text,
$displayLanguage )
static

If text's language is not the same as display language, add marker with language name to the string.

Parameters
string[]$text['language' => LANG, 'value' => TEXT]
string$displayLanguage
Returns
array ['language' => LANG, 'value' => TEXT]

Member Data Documentation

◆ $entityContentFactory

Wikibase\Repo\Hooks\ShowSearchHitHandler::$entityContentFactory
private

◆ $entityIdLookup

Wikibase\Repo\Hooks\ShowSearchHitHandler::$entityIdLookup
private

◆ $entityLookup

Wikibase\Repo\Hooks\ShowSearchHitHandler::$entityLookup
private

◆ $fallbackChainFactory

Wikibase\Repo\Hooks\ShowSearchHitHandler::$fallbackChainFactory
private

The documentation for this class was generated from the following file: