Wikibase
MediaWiki Wikibase extension
|
A UsageLookup
which decorates an inner lookup and adds an implicit usage on a linked item’s description.
More...
Public Member Functions | |
__construct (UsageLookup $usageLookup, TitleFactory $titleFactory, bool $allowLocalShortDesc, DescriptionLookup $descriptionLookup, LinkBatchFactory $linkBatchFactory, string $globalSiteId, SiteLinkLookup $siteLinkLookup) | |
getUsagesForPage (int $pageId) | |
Get the entities used on the given page. | |
getUnusedEntities (array $entityIds) | |
Returns the elements of $entityIds that are currently not used as far as this UsageTracker knows. | |
Public Member Functions inherited from Wikibase\Client\Usage\UsageLookup | |
getPagesUsing (array $entityIds, array $aspects=[]) | |
Returns the pages that use any of the given entities. | |
Private Member Functions | |
aspectsMatchImplicitUsage (array $aspects) | |
Whether the given aspects potentially match an implicit usage. | |
findImplicitUsages (array $entityIds) | |
Find the implicit usages on the given entity IDs. | |
filterImplicitUsages (array $itemIdsByPageId, array $contentLanguagesByPageId, array $aspects) | |
Filter the implicit usages by the given aspects. | |
Private Attributes | |
$usageLookup | |
$titleFactory | |
$allowLocalShortDesc | |
$descriptionLookup | |
$linkBatchFactory | |
$globalSiteId | |
$siteLinkLookup | |
A UsageLookup
which decorates an inner lookup and adds an implicit usage on a linked item’s description.
An implicit usage is different from an ordinary, explicit usage in that it is never recorded by a UsageTracker
: it is not tracked when the page is parsed and actually uses a part of an entity, but rather synthesized by this class based on hard-coded knowledge about where else an entity’s data is used in relation to a page. However, implicit usages otherwise look exactly like explicit usages: for a user of the UsageLookup
interface, it is not (yet?) possible to determine whether a usage from the lookup is explicit or implicit.
This class implements one kind of implicit usage: if a client page is linked to an item, it has an implicit usage on that item’s description in the client wiki’s content language, unless the client page also has a local description overriding the central one. This is because the description is used, for example, as part of the search result for the page (typically on mobile), even if it is never used in the page itself.
Wikibase\Client\Usage\ImplicitDescriptionUsageLookup::__construct | ( | UsageLookup | $usageLookup, |
TitleFactory | $titleFactory, | ||
bool | $allowLocalShortDesc, | ||
DescriptionLookup | $descriptionLookup, | ||
LinkBatchFactory | $linkBatchFactory, | ||
string | $globalSiteId, | ||
SiteLinkLookup | $siteLinkLookup ) |
UsageLookup | $usageLookup | The underlying/inner lookup. |
TitleFactory | $titleFactory | |
bool | $allowLocalShortDesc | The 'allowLocalShortDesc' client setting. If true, only pages with a local description will get an implicit usage. |
DescriptionLookup | $descriptionLookup | Used to look up local descriptions. Unused if $allowLocalShortDesc is false. |
LinkBatchFactory | $linkBatchFactory | |
string | $globalSiteId | The global site ID of the client wiki. |
SiteLinkLookup | $siteLinkLookup |
|
private |
Whether the given aspects potentially match an implicit usage.
string[] | $aspects |
|
private |
Filter the implicit usages by the given aspects.
Takes two arrays as returned by findImplicitUsages
and returns similar arrays, but filtered if necessary.
ItemId[] | $itemIdsByPageId | |
string[] | $contentLanguagesByPageId | |
string[] | $aspects |
|
private |
Find the implicit usages on the given entity IDs.
Returns two arrays, both keyed by page ID: the item ID linked to that page and the content language of the page.
EntityId[] | $entityIds |
Wikibase\Client\Usage\ImplicitDescriptionUsageLookup::getUnusedEntities | ( | array | $entityIds | ) |
Returns the elements of $entityIds that are currently not used as far as this UsageTracker knows.
In other words, this method answers the question which of a given list of entities are currently being used on wiki pages.
EntityId[] | $entityIds |
Implements Wikibase\Client\Usage\UsageLookup.
Wikibase\Client\Usage\ImplicitDescriptionUsageLookup::getUsagesForPage | ( | int | $pageId | ) |
Get the entities used on the given page.
The returned array uses the identity string
as the key, so that a specific usage can be found quickly.
int | $pageId |
Implements Wikibase\Client\Usage\UsageLookup.
|
private |
|
private |
|
private |
|
private |
|
private |
|
private |
|
private |