יחידה:PropertyLink: הבדלים בין גרסאות בדף
מ כנראה מיותר (נכון תמיד) |
מ use getBestStatements(Q, P) instead of entity:getBestStatements(P) |
||
| שורה 75: | שורה 75: | ||
]] | ]] | ||
function getProperty( propertyName, allowMulti, allowNA, entityId, multiSeperator, optionalQualifier ) | function getProperty( propertyName, allowMulti, allowNA, entityId, multiSeperator, optionalQualifier ) | ||
if not multiSeperator then | if not multiSeperator then | ||
multiSeperator = ', ' | multiSeperator = ', ' | ||
end | end | ||
if entityId then | if entityId==nil then | ||
entityId = mw.wikibase.getEntityIdForCurrentPage() | |||
end | end | ||
local propertyVals = mw.wikibase.getBestStatements(entityId, propertyName) | |||
local propertyVals = | |||
if (not propertyVals) or (#propertyVals==0) then return end --no such property for this item | if (not propertyVals) or (#propertyVals==0) then return end --no such property for this item | ||
| שורה 150: | שורה 146: | ||
table.insert(resTable, formatQuantity(property)) | table.insert(resTable, formatQuantity(property)) | ||
elseif propValue['type'] == 'time' then | elseif propValue['type'] == 'time' then | ||
local timeValue = | local timeValue = mw.wikibase.renderSnak( property.mainsnak ) | ||
timeValue = mw.ustring.gsub(timeValue, '^(%d+ %a+) (%d+)$', '[[%1]] [[%2]]') | timeValue = mw.ustring.gsub(timeValue, '^(%d+ %a+) (%d+)$', '[[%1]] [[%2]]') | ||
table.insert(resTable, timeValue) | table.insert(resTable, timeValue) | ||