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

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

Public Member Functions

 __construct (EntityContentFactory $entityContentFactory, LanguageFallbackChain $languageFallbackChain, EntityIdLookup $entityIdLookup, EntityLookup $entityLookup, EntityLinkFormatter $linkFormatter)
 

Static Public Member Functions

static onShowSearchHit (SpecialSearch $searchPage, SearchResult $result, array $terms, &$link, &$redirect, &$section, &$extract, &$score, &$size, &$date, &$related, &$html)
 Format the output when the search result contains entities.
 
static addLanguageAttrs (array &$attr, $displayLanguage, array $text)
 Add attributes appropriate for language of this text.
 
static addDescription (&$html, array $description, SpecialSearch $searchPage)
 Add HTML description to search result.
 
static onShowSearchHitTitle (Title $title, &$titleSnippet, SearchResult $result, $terms, SpecialSearch $specialSearch, array &$query, array &$attributes)
 Remove span tag placed around title search hit for entity titles to highlight matches in bold.
 
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

 showPlainSearchHit (SpecialSearch $searchPage, SearchResult $result, array $terms, &$link, &$redirect, &$section, &$extract, &$score, &$size, &$date, &$related, &$html)
 Show result hit display.
 
 isTitleEntity (Title $title)
 Check whether the title represents entity.
 
 getEntity (Title $title)
 Retrieve entity by title.
 
 showPlainSearchTitle (Title $title, &$titleSnippet)
 Handle search result title.
 

Static Private Member Functions

static newFromGlobalState (IContextSource $context)
 

Private Attributes

 $entityContentFactory
 
 $languageFallbackChain
 
 $entityIdLookup
 
 $entityLookup
 

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,
LanguageFallbackChain  $languageFallbackChain,
EntityIdLookup  $entityIdLookup,
EntityLookup  $entityLookup,
EntityLinkFormatter  $linkFormatter 
)

Member Function Documentation

◆ addDescription()

static Wikibase\Repo\Hooks\ShowSearchHitHandler::addDescription ( $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,
  $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

Retrieve entity by title.

Parameters
Title$title
Returns
EntityDocument|null

◆ isTitleEntity()

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

Check whether the title represents entity.

Parameters
Title$title
Returns
bool

◆ newFromGlobalState()

static Wikibase\Repo\Hooks\ShowSearchHitHandler::newFromGlobalState ( IContextSource  $context)
staticprivate
Parameters
IContextSource$context
Returns
self

◆ onShowSearchHit()

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

Format the output when the search result contains entities.

See also
https://www.mediawiki.org/wiki/Manual:Hooks/ShowSearchHit
showEntityResultHit
showPlainSearchHit

◆ onShowSearchHitTitle()

static Wikibase\Repo\Hooks\ShowSearchHitHandler::onShowSearchHitTitle ( Title  $title,
$titleSnippet,
SearchResult  $result,
  $terms,
SpecialSearch  $specialSearch,
array &  $query,
array &  $attributes 
)
static

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&$titleSnippet
SearchResult$result
string$terms
SpecialSearch$specialSearch
string[]&$query
string[]$attributes

◆ showPlainSearchHit()

Wikibase\Repo\Hooks\ShowSearchHitHandler::showPlainSearchHit ( SpecialSearch  $searchPage,
SearchResult  $result,
array  $terms,
$link,
$redirect,
$section,
$extract,
$score,
$size,
$date,
$related,
$html 
)
private

Show result hit display.

◆ showPlainSearchTitle()

Wikibase\Repo\Hooks\ShowSearchHitHandler::showPlainSearchTitle ( Title  $title,
$titleSnippet 
)
private

Handle search result title.

Parameters
Title$title
string&$titleSnippet

◆ 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

◆ $languageFallbackChain

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

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