יחידה:PropertyLink: הבדלים בין גרסאות בדף
מאין תקציר עריכה |
מאין תקציר עריכה |
||
| שורה 35: | שורה 35: | ||
- for image - returns image inclusion with 250px size | - for image - returns image inclusion with 250px size | ||
]] | ]] | ||
function getProperty( propertyName, allowMulti ) | function getProperty( propertyName, allowMulti, allowNA ) | ||
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 | ||
| שורה 44: | שורה 44: | ||
for i, property in ipairs(propertyVals) do | for i, property in ipairs(propertyVals) do | ||
local propValue = property.mainsnak and property.mainsnak.datavalue | local propValue = property.mainsnak and property.mainsnak.datavalue | ||
if not propValue then return | if not propValue then | ||
if allowNA and (property.mainsnak and property.mainsnak.snaktype)=='somevalue' then | |||
return 'לא ידוע' | |||
else | |||
--property doesnt exist | |||
return | |||
end | |||
end | |||
local isImage = (property.mainsnak.datatype=='commonsMedia') | local isImage = (property.mainsnak.datatype=='commonsMedia') | ||
| שורה 78: | שורה 85: | ||
function property( frame ) | function property( frame ) | ||
return getProperty(string.upper(frame.args[1]), (frame.args[2] and string.len(frame.args[2])>0) or false) | return getProperty(string.upper(frame.args[1]), (frame.args[2] and string.len(frame.args[2])>0) or false, true) | ||
end | end | ||