Bearbeiten von „Modul:PropertyLink“
Die Bearbeitung kann rückgängig gemacht werden. Bitte prüfe den Vergleich unten, um sicherzustellen, dass du dies tun möchtest, und veröffentliche dann unten deine Änderungen, um die Bearbeitung rückgängig zu machen.
Aktuelle Version | Dein Text | ||
Zeile 1: | Zeile 1: | ||
function getLinkLabel(propValue | function getLinkLabel(propValue) | ||
if propValue['type'] == 'wikibase-entityid' then | if propValue['type'] == 'wikibase-entityid' then | ||
local linkTarget = mw.wikibase.sitelink( "Q" .. propValue.value['numeric-id'] ) | local linkTarget = mw.wikibase.sitelink( "Q" .. propValue.value['numeric-id'] ) | ||
if not linkTarget then | if not linkTarget then | ||
Zeile 7: | Zeile 6: | ||
if targetEntity and targetEntity['sitelinks'] then | if targetEntity and targetEntity['sitelinks'] then | ||
if targetEntity['sitelinks']['dewiki'] then | if targetEntity['sitelinks']['dewiki'] then | ||
linkTarget = | linkTarget = 'wikipedia:de:' .. targetEntity['sitelinks']['dewiki']['title'] | ||
elseif targetEntity['sitelinks']['enwiki'] then | elseif targetEntity['sitelinks']['enwiki'] then | ||
linkTarget = | linkTarget = 'wikipedia:' .. targetEntity['sitelinks']['enwiki']['title'] | ||
end | end | ||
end | end | ||
end | |||
local linkTitle = mw.wikibase.label( "Q" ..propValue.value['numeric-id'] ) | local linkTitle = mw.wikibase.label( "Q" ..propValue.value['numeric-id'] ) | ||
return linkTarget and linkTitle and mw.ustring.format( "[[%s|%s]]", linkTarget, linkTitle ) | |||
or linkTitle | |||
elseif propValue and propValue['type'] == 'string' then | elseif propValue and propValue['type'] == 'string' then | ||
return propValue.value | return propValue.value | ||
Zeile 33: | Zeile 20: | ||
end | end | ||
function getProperty(propertyName | function getProperty( propertyName ) | ||
local entity = mw.wikibase.getEntityObject() | local entity = mw.wikibase.getEntityObject() | ||
if not entity or not entity.claims then return end--the entity doesnt exist or have no claims | if not entity or not entity.claims then return end--the entity doesnt exist or have no claims | ||
Zeile 42: | Zeile 29: | ||
if not propValue then return end --property doesnt exist | if not propValue then return end --property doesnt exist | ||
return getLinkLabel(propValue) | |||
end | end | ||
function property( frame ) | function property( frame ) | ||
return getProperty(string.upper(frame.args[1] | return getProperty(string.upper(frame.args[1])) | ||
end | end | ||
Zeile 88: | Zeile 66: | ||
if not propValue then return '' end --property doesnt exist | if not propValue then return '' end --property doesnt exist | ||
local value = getLinkLabel(propValue | local value = getLinkLabel(propValue) | ||
if retVal == '' then | if retVal == '' then | ||
retVal = value | retVal = value |