Wikibase
MediaWiki Wikibase extension
Loading...
Searching...
No Matches
Wikibase\Client\Hooks\LangLinkHandler Class Reference

Public Member Functions

 __construct (LanguageLinkBadgeDisplay $badgeDisplay, NamespaceChecker $namespaceChecker, SiteLinksForDisplayLookup $siteLinkForDisplayLookup, SiteLookup $siteLookup, string $siteId, array $siteGroups)
 
 useRepoLinks (Title $title, ParserOutput $parserOutput)
 Checks if a page have interwiki links from Wikidata repo? Disabled for a page when either:
 
 suppressRepoLinks (ParserOutput $parserOutput, array $repoLinks)
 Returns a filtered version of $repoLinks, containing only links that should be considered for combining with the local inter-language links.
 
 filterRepoLinksByGroup (array $repoLinks, array $allowedGroups)
 Filters the given list of links by site group: Any links pointing to a site that is not in $allowedGroups will be removed.
 
 getNoExternalLangLinks (ParserOutput $parserOutput)
 Get the noexternallanglinks page property from the ParserOutput, which is set by the {{#noexternallanglinks}} parser function.
 
 getEffectiveRepoLinks (Title $title, ParserOutput $parserOutput)
 Look up sitelinks for the given title on the repository and filter them taking into account any applicable configuration and any use of the {{#noexternallanglinks}} function on the page.
 
 addLinksFromRepository (Title $title, ParserOutput $parserOutput)
 Look up sitelinks for the given title on the repository and add them to the ParserOutput object, taking into account any applicable configuration and any use of the {{#noexternallanglinks}} function on the page.
 
 getInterwikiCodeFromSite (Site $site)
 Extracts the local interwiki code, which in case of the wikimedia site groups, is always the global id's prefix.
 

Private Member Functions

 indexLinksByInterwiki (array $links)
 
 localLinksToArray (array $flatLinks)
 Converts a list of interwiki links into an associative array that maps global site IDs to the respective target pages on the designated wikis.
 
 addLinksToOutput (array $links, ParserOutput $parserOutput)
 Adds the given SiteLinks to the given ParserOutput.
 

Private Attributes

 $badgeDisplay
 
 $namespaceChecker
 
 $siteLinksForDisplayLookup
 
 $siteLookup
 
 $siteId
 
 $siteGroups
 

Detailed Description

Todo
split this up and find a better home for stuff that adds parser output properties and extension data.
Author
Nikola Smolenski smole.nosp@m.nsk@.nosp@m.eunet.nosp@m..rs
Daniel Kinzler
Katie Filbert < aude..nosp@m.wiki.nosp@m.@gmai.nosp@m.l.co.nosp@m.m >

Constructor & Destructor Documentation

◆ __construct()

Wikibase\Client\Hooks\LangLinkHandler::__construct ( LanguageLinkBadgeDisplay $badgeDisplay,
NamespaceChecker $namespaceChecker,
SiteLinksForDisplayLookup $siteLinkForDisplayLookup,
SiteLookup $siteLookup,
string $siteId,
array $siteGroups )
Parameters
LanguageLinkBadgeDisplay$badgeDisplay
NamespaceChecker$namespaceCheckerdetermines which namespaces wikibase is enabled on
SiteLinksForDisplayLookup$siteLinkForDisplayLookup
SiteLookup$siteLookup
string$siteIdThe global site ID for the local wiki
string[]$siteGroupsThe ID of the site groups to use for showing language links.

Member Function Documentation

◆ addLinksFromRepository()

Wikibase\Client\Hooks\LangLinkHandler::addLinksFromRepository ( Title $title,
ParserOutput $parserOutput )

Look up sitelinks for the given title on the repository and add them to the ParserOutput object, taking into account any applicable configuration and any use of the {{#noexternallanglinks}} function on the page.

The language links are not sorted, call sortLanguageLinks() to do that.

Parameters
Title$titleThe page's title
ParserOutput$parserOutputParsed representation of the page

◆ addLinksToOutput()

Wikibase\Client\Hooks\LangLinkHandler::addLinksToOutput ( array $links,
ParserOutput $parserOutput )
private

Adds the given SiteLinks to the given ParserOutput.

Parameters
SiteLink[]$links
ParserOutput$parserOutput

◆ filterRepoLinksByGroup()

Wikibase\Client\Hooks\LangLinkHandler::filterRepoLinksByGroup ( array $repoLinks,
array $allowedGroups )

Filters the given list of links by site group: Any links pointing to a site that is not in $allowedGroups will be removed.

Parameters
array$repoLinksAn array that uses global site IDs as keys.
string[]$allowedGroupsA list of allowed site groups
Returns
array A filtered copy of $repoLinks, retaining only the links pointing to a site in an allowed group.

◆ getEffectiveRepoLinks()

Wikibase\Client\Hooks\LangLinkHandler::getEffectiveRepoLinks ( Title $title,
ParserOutput $parserOutput )

Look up sitelinks for the given title on the repository and filter them taking into account any applicable configuration and any use of the {{#noexternallanglinks}} function on the page.

The result is an associative array of links that should be added to the current page, excluding any target sites for which there already is a link on the page.

Parameters
Title$titleThe page's title
ParserOutput$parserOutputParsed representation of the page
Returns
SiteLink[] An associative array, using site IDs for keys and the target pages in the respective languages as the associated value.

◆ getInterwikiCodeFromSite()

Wikibase\Client\Hooks\LangLinkHandler::getInterwikiCodeFromSite ( Site $site)

Extracts the local interwiki code, which in case of the wikimedia site groups, is always the global id's prefix.

@fixme put somewhere more sane and use site identifiers data, so that this works in non-wikimedia cases where the assumption is not true.

Parameters
Site$site
Returns
string

◆ getNoExternalLangLinks()

Wikibase\Client\Hooks\LangLinkHandler::getNoExternalLangLinks ( ParserOutput $parserOutput)

Get the noexternallanglinks page property from the ParserOutput, which is set by the {{#noexternallanglinks}} parser function.

See also
NoLangLinkHandler::getNoExternalLangLinks
Parameters
ParserOutput$parserOutput
Returns
string[] A list of language codes, identifying which repository links to ignore. Empty if {{#noexternallanglinks}} was not used on the page.

◆ indexLinksByInterwiki()

Wikibase\Client\Hooks\LangLinkHandler::indexLinksByInterwiki ( array $links)
private
Parameters
SiteLink[]$links
Returns
SiteLink[] The SiteLinks in $links, indexed by interwiki prefix.

◆ localLinksToArray()

Wikibase\Client\Hooks\LangLinkHandler::localLinksToArray ( array $flatLinks)
private

Converts a list of interwiki links into an associative array that maps global site IDs to the respective target pages on the designated wikis.

Parameters
string[]$flatLinks
Returns
string[] An associative array, using site IDs for keys and the target pages on the respective wiki as the associated value.

◆ suppressRepoLinks()

Wikibase\Client\Hooks\LangLinkHandler::suppressRepoLinks ( ParserOutput $parserOutput,
array $repoLinks )

Returns a filtered version of $repoLinks, containing only links that should be considered for combining with the local inter-language links.

This takes into account the {{#noexternallanglinks}} parser function, and also removed any link to this wiki itself.

This function does not remove links to wikis for which there is already an inter-language link defined in the local wikitext. This is done later by getEffectiveRepoLinks().

Parameters
ParserOutput$parserOutput
array$repoLinksAn array that uses global site IDs as keys.
Returns
SiteLink[] A filtered copy of $repoLinks, with any inappropriate entries removed.

◆ useRepoLinks()

Wikibase\Client\Hooks\LangLinkHandler::useRepoLinks ( Title $title,
ParserOutput $parserOutput )

Checks if a page have interwiki links from Wikidata repo? Disabled for a page when either:

  • Wikidata not enabled for namespace
  • nel parser function = * (suppress all repo links)
Parameters
Title$title
ParserOutput$parserOutput
Returns
bool

Member Data Documentation

◆ $badgeDisplay

Wikibase\Client\Hooks\LangLinkHandler::$badgeDisplay
private

◆ $namespaceChecker

Wikibase\Client\Hooks\LangLinkHandler::$namespaceChecker
private

◆ $siteGroups

Wikibase\Client\Hooks\LangLinkHandler::$siteGroups
private

◆ $siteId

Wikibase\Client\Hooks\LangLinkHandler::$siteId
private

◆ $siteLinksForDisplayLookup

Wikibase\Client\Hooks\LangLinkHandler::$siteLinksForDisplayLookup
private

◆ $siteLookup

Wikibase\Client\Hooks\LangLinkHandler::$siteLookup
private

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