Modul:PropertyLink: Unterschied zwischen den Versionen
Keine Bearbeitungszusammenfassung |
Keine Bearbeitungszusammenfassung |
||
Zeile 46: | Zeile 46: | ||
end | end | ||
function getLabels( propertyName | function getLabels( frame ) | ||
local entity = mw.wikibase. | propertyName = frame.args[1] | ||
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 | ||
local properties = entity.claims[propertyName] | local properties = entity.claims[propertyName] | ||
if not properties then return | if not properties then return end--no such property for this item | ||
local retVal = ' | local retVal = '' | ||
for | for propIndex in pairs(properties) do | ||
local property = properties[propIndex] | |||
local propValue = property.mainsnak.datavalue | local propValue = property.mainsnak.datavalue | ||
if not propValue then return '' end --property doesnt exist | if not propValue then return '' end --property doesnt exist | ||
Zeile 67: | Zeile 69: | ||
retVal = value | retVal = value | ||
else | else | ||
retVal = retVal | retVal = retVal .. ', ' .. value | ||
end | end | ||
end | end | ||
Zeile 76: | Zeile 78: | ||
-- Return the label for property, or the label of the linked entiy of that property | -- Return the label for property, or the label of the linked entiy of that property | ||
function label( frame ) | function label( frame ) | ||
return getLabel( string.lower(frame.args[1] )) | return getLabel(string.lower(frame.args[1])) | ||
end | end | ||