Module:Wd: Difference between revisions
Jump to navigation
Jump to search
m (1 revision imported) |
mp>Thayts (Partial revert to undo introduction of linking obscurity) |
||
Line 653: | Line 653: | ||
function Config:getLabel(id, raw, link, short) | function Config:getLabel(id, raw, link, short) | ||
local label = nil | local label = nil | ||
local title | local prefix, title= "", nil | ||
if not id then | if not id then | ||
Line 670: | Line 669: | ||
if mw.wikibase.isValidEntityId(id) and mw.wikibase.entityExists(id) then | if mw.wikibase.isValidEntityId(id) and mw.wikibase.entityExists(id) then | ||
label = id | label = id | ||
end | end | ||
prefix = "d:" | prefix, title = "d:Special:EntityPage/", label -- may be nil | ||
else | else | ||
-- try short name first if requested | -- try short name first if requested | ||
Line 691: | Line 684: | ||
-- get label | -- get label | ||
if not label then | if not label then | ||
label = mw.wikibase.getLabelByLang(id, self.langCode) | label = mw.wikibase.getLabelByLang(id, self.langCode) -- XXX: should use fallback labels? | ||
end | end | ||
end | end | ||
Line 704: | Line 697: | ||
elseif id:sub(1,1) == "P" then | elseif id:sub(1,1) == "P" then | ||
-- properties have no sitelink, link to Wikidata instead | -- properties have no sitelink, link to Wikidata instead | ||
title | prefix, title = "d:Special:EntityPage/", id | ||
end | end | ||
end | end | ||
label = mw.text.nowiki(label) -- escape raw label text so it cannot be wikitext markup | |||
if title then | if title then | ||
label = buildWikilink(prefix .. title, label) | label = buildWikilink(prefix .. title, label) |