יחידה: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 )
    local entity = nil
 
     if not multiSeperator then
     if not multiSeperator then
         multiSeperator = ', '
         multiSeperator = ', '
     end
     end
     if entityId then
     if entityId==nil then
     entity = mw.wikibase.getEntityObject( entityId )
     entityId = mw.wikibase.getEntityIdForCurrentPage()
    else
    entity = mw.wikibase.getEntityObject()
     end
     end


    if not entity or not entity.claims then return end --the entity doesnt exist or have no claims
     local propertyVals = mw.wikibase.getBestStatements(entityId, propertyName)
 
     local propertyVals = entity:getBestStatements(propertyName)
      
      
     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 = entity:formatPropertyValues( propertyName ).value
    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)