Wikibase
MediaWiki Wikibase extension
Wikibase\Repo\Hooks\HtmlPageLinkRendererEndHookHandler Class Reference

Handler for the HtmlPageLinkRendererEnd hook, used to change the default link text of links to wikibase Entity pages to the respective entity's label. More...

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

Public Member Functions

 onHtmlPageLinkRendererEnd ( $linkRenderer, $target, $isKnown, &$text, &$extraAttribs, &$ret)
 Special page handling where we want to display meaningful link labels instead of just the items ID. More...
 
 __construct (EntityExistenceChecker $entityExistenceChecker, EntityIdParser $entityIdParser, TermLookup $termLookup, EntityNamespaceLookup $localEntityNamespaceLookup, InterwikiLookup $interwikiLookup, EntityLinkFormatterFactory $linkFormatterFactory, SpecialPageFactory $specialPageFactory, LanguageFallbackChainFactory $languageFallbackChainFactory, EntityUrlLookup $entityUrlLookup, LinkTargetEntityIdLookup $linkTargetEntityIdLookup, ?string $federatedPropertiesSourceScriptUrl, bool $federatedPropertiesEnabled)
 
 doHtmlPageLinkRendererEnd (LinkRenderer $linkRenderer, Title $target, &$text, array &$customAttribs, RequestContext $context, &$html=null)
 

Static Public Member Functions

static factory (InterwikiLookup $interwikiLookup, SpecialPageFactory $specialPageFactory, EntityExistenceChecker $entityExistenceChecker, EntityIdParser $entityIdParser, EntityLinkFormatterFactory $entityLinkFormatterFactory, EntityUrlLookup $entityUrlLookup, LanguageFallbackChainFactory $languageFallbackChainFactory, LinkTargetEntityIdLookup $linkTargetEntityIdLookup, EntityNamespaceLookup $localEntityNamespaceLookup, SettingsArray $repoSettings, TermLookup $termLookup)
 

Private Member Functions

 federatedPropsDegradedDoHtmlPageLinkRendererEnd (LinkTarget $linkTarget, &$text, array &$customAttribs)
 Hook handling logic for the HtmlPageLinkRendererEnd hook in case federated properties are enabled, but access to the source wiki failed. More...
 
 internalDoHtmlPageLinkRendererEnd (LinkRenderer $linkRenderer, Title $target, &$text, array &$customAttribs, RequestContext $context, &$html=null)
 Parts of the hook handling logic for the HtmlPageLinkRendererEnd hook that potentially interact with entity storage. More...
 
 removeNewClass (string $classes)
 Remove the new class from a space separated list of classes. More...
 
 termFallbackToTermData (TermFallback $term=null)
 
 parseForeignEntityId (LinkTarget $target)
 
 extractForeignIdString (LinkTarget $linkTarget)
 Should be given an already confirmed valid interwiki link that uses Special:EntityPage to link to an entity on a remote Wikibase. More...
 
 extractForeignIdStringMainNs (LinkTarget $linkTarget)
 
 extractForeignIdStringSpecialNs (LinkTarget $linkTarget)
 
 isApiRequest ()
 Whether this is an API request. More...
 
 shouldConvert (Title $currentTitle, LinkRenderer $linkRenderer)
 Whether we should try to convert links on this page. More...
 
 getLabelDescriptionLookup (RequestContext $context)
 

Private Attributes

 $entityExistenceChecker
 
 $entityIdParser
 
 $termLookup
 
 $localEntityNamespaceLookup
 
 $interwikiLookup
 
 $linkFormatterFactory
 
 $specialPageFactory
 
 $languageFallbackChainFactory
 
 $labelDescriptionLookup
 
 $entityUrlLookup
 
 $linkTargetEntityIdLookup
 
 $federatedPropertiesSourceScriptUrl
 
 $federatedPropertiesEnabled
 

Detailed Description

Handler for the HtmlPageLinkRendererEnd hook, used to change the default link text of links to wikibase Entity pages to the respective entity's label.

This is used mainly for listings on special pages or for edit summaries, where it is useful to see pages listed by label rather than their entity ID.

Label lookups are relatively expensive if done repeatedly for individual labels. If possible, labels should be pre-loaded and buffered for later use via the HtmlPageLinkRendererEnd hook.

See also
LabelPrefetchHookHandler
Author
Katie Filbert < aude..nosp@m.wiki.nosp@m.@gmai.nosp@m.l.co.nosp@m.m >

Constructor & Destructor Documentation

◆ __construct()

Wikibase\Repo\Hooks\HtmlPageLinkRendererEndHookHandler::__construct ( EntityExistenceChecker  $entityExistenceChecker,
EntityIdParser  $entityIdParser,
TermLookup  $termLookup,
EntityNamespaceLookup  $localEntityNamespaceLookup,
InterwikiLookup  $interwikiLookup,
EntityLinkFormatterFactory  $linkFormatterFactory,
SpecialPageFactory  $specialPageFactory,
LanguageFallbackChainFactory  $languageFallbackChainFactory,
EntityUrlLookup  $entityUrlLookup,
LinkTargetEntityIdLookup  $linkTargetEntityIdLookup,
?string  $federatedPropertiesSourceScriptUrl,
bool  $federatedPropertiesEnabled 
)

Member Function Documentation

◆ doHtmlPageLinkRendererEnd()

Wikibase\Repo\Hooks\HtmlPageLinkRendererEndHookHandler::doHtmlPageLinkRendererEnd ( LinkRenderer  $linkRenderer,
Title  $target,
$text,
array &  $customAttribs,
RequestContext  $context,
$html = null 
)
Parameters
LinkRenderer$linkRenderer
Title$target
HtmlArmor | string | null&$text
array&$customAttribs
RequestContext$context
string | null&$html
Returns
bool true to continue processing the link, false to use $html directly for the link

◆ extractForeignIdString()

Wikibase\Repo\Hooks\HtmlPageLinkRendererEndHookHandler::extractForeignIdString ( LinkTarget  $linkTarget)
private

Should be given an already confirmed valid interwiki link that uses Special:EntityPage to link to an entity on a remote Wikibase.

◆ extractForeignIdStringMainNs()

Wikibase\Repo\Hooks\HtmlPageLinkRendererEndHookHandler::extractForeignIdStringMainNs ( LinkTarget  $linkTarget)
private

◆ extractForeignIdStringSpecialNs()

Wikibase\Repo\Hooks\HtmlPageLinkRendererEndHookHandler::extractForeignIdStringSpecialNs ( LinkTarget  $linkTarget)
private

◆ factory()

static Wikibase\Repo\Hooks\HtmlPageLinkRendererEndHookHandler::factory ( InterwikiLookup  $interwikiLookup,
SpecialPageFactory  $specialPageFactory,
EntityExistenceChecker  $entityExistenceChecker,
EntityIdParser  $entityIdParser,
EntityLinkFormatterFactory  $entityLinkFormatterFactory,
EntityUrlLookup  $entityUrlLookup,
LanguageFallbackChainFactory  $languageFallbackChainFactory,
LinkTargetEntityIdLookup  $linkTargetEntityIdLookup,
EntityNamespaceLookup  $localEntityNamespaceLookup,
SettingsArray  $repoSettings,
TermLookup  $termLookup 
)
static

◆ federatedPropsDegradedDoHtmlPageLinkRendererEnd()

Wikibase\Repo\Hooks\HtmlPageLinkRendererEndHookHandler::federatedPropsDegradedDoHtmlPageLinkRendererEnd ( LinkTarget  $linkTarget,
$text,
array &  $customAttribs 
)
private

Hook handling logic for the HtmlPageLinkRendererEnd hook in case federated properties are enabled, but access to the source wiki failed.

Parameters
Title$linkTarget
HtmlArmor | string | null&$text
array&$customAttribs

◆ getLabelDescriptionLookup()

Wikibase\Repo\Hooks\HtmlPageLinkRendererEndHookHandler::getLabelDescriptionLookup ( RequestContext  $context)
private

◆ internalDoHtmlPageLinkRendererEnd()

Wikibase\Repo\Hooks\HtmlPageLinkRendererEndHookHandler::internalDoHtmlPageLinkRendererEnd ( LinkRenderer  $linkRenderer,
Title  $target,
$text,
array &  $customAttribs,
RequestContext  $context,
$html = null 
)
private

Parts of the hook handling logic for the HtmlPageLinkRendererEnd hook that potentially interact with entity storage.

Parameters
LinkRenderer$linkRenderer
Title$target
HtmlArmor | string | null&$text
array&$customAttribs
RequestContext$context
string | null&$html
Returns
bool true to continue processing the link, false to use $html directly for the link

◆ isApiRequest()

Wikibase\Repo\Hooks\HtmlPageLinkRendererEndHookHandler::isApiRequest ( )
private

Whether this is an API request.

Returns
bool

◆ onHtmlPageLinkRendererEnd()

Wikibase\Repo\Hooks\HtmlPageLinkRendererEndHookHandler::onHtmlPageLinkRendererEnd (   $linkRenderer,
  $target,
  $isKnown,
$text,
$extraAttribs,
$ret 
)

Special page handling where we want to display meaningful link labels instead of just the items ID.

This is only handling special pages right now and gets disabled in normal pages.

See also
https://www.mediawiki.org/wiki/Manual:Hooks/HtmlPageLinkRendererEnd
Parameters
LinkRenderer$linkRenderer
LinkTarget$target
bool$isKnown
HtmlArmor | string | null&$text
array&$extraAttribs
string | null&$ret
Returns
bool true to continue processing the link, false to use $ret directly as the HTML for the link

◆ parseForeignEntityId()

Wikibase\Repo\Hooks\HtmlPageLinkRendererEndHookHandler::parseForeignEntityId ( LinkTarget  $target)
private
Parameters
LinkTarget$target
Returns
EntityId|null

◆ removeNewClass()

Wikibase\Repo\Hooks\HtmlPageLinkRendererEndHookHandler::removeNewClass ( string  $classes)
private

Remove the new class from a space separated list of classes.

Parameters
string$classes
Returns
string

◆ shouldConvert()

Wikibase\Repo\Hooks\HtmlPageLinkRendererEndHookHandler::shouldConvert ( Title  $currentTitle,
LinkRenderer  $linkRenderer 
)
private

Whether we should try to convert links on this page.

Parameters
Title | null$currentTitle
LinkRenderer$linkRenderer
Returns
bool

◆ termFallbackToTermData()

Wikibase\Repo\Hooks\HtmlPageLinkRendererEndHookHandler::termFallbackToTermData ( TermFallback  $term = null)
private
Parameters
TermFallback | null$term
Returns
string[]|null

Member Data Documentation

◆ $entityExistenceChecker

Wikibase\Repo\Hooks\HtmlPageLinkRendererEndHookHandler::$entityExistenceChecker
private

◆ $entityIdParser

Wikibase\Repo\Hooks\HtmlPageLinkRendererEndHookHandler::$entityIdParser
private

◆ $entityUrlLookup

Wikibase\Repo\Hooks\HtmlPageLinkRendererEndHookHandler::$entityUrlLookup
private

◆ $federatedPropertiesEnabled

Wikibase\Repo\Hooks\HtmlPageLinkRendererEndHookHandler::$federatedPropertiesEnabled
private

◆ $federatedPropertiesSourceScriptUrl

Wikibase\Repo\Hooks\HtmlPageLinkRendererEndHookHandler::$federatedPropertiesSourceScriptUrl
private

◆ $interwikiLookup

Wikibase\Repo\Hooks\HtmlPageLinkRendererEndHookHandler::$interwikiLookup
private

◆ $labelDescriptionLookup

Wikibase\Repo\Hooks\HtmlPageLinkRendererEndHookHandler::$labelDescriptionLookup
private

◆ $languageFallbackChainFactory

Wikibase\Repo\Hooks\HtmlPageLinkRendererEndHookHandler::$languageFallbackChainFactory
private

◆ $linkFormatterFactory

Wikibase\Repo\Hooks\HtmlPageLinkRendererEndHookHandler::$linkFormatterFactory
private

◆ $linkTargetEntityIdLookup

Wikibase\Repo\Hooks\HtmlPageLinkRendererEndHookHandler::$linkTargetEntityIdLookup
private

◆ $localEntityNamespaceLookup

Wikibase\Repo\Hooks\HtmlPageLinkRendererEndHookHandler::$localEntityNamespaceLookup
private

◆ $specialPageFactory

Wikibase\Repo\Hooks\HtmlPageLinkRendererEndHookHandler::$specialPageFactory
private

◆ $termLookup

Wikibase\Repo\Hooks\HtmlPageLinkRendererEndHookHandler::$termLookup
private

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