יחידה:PropertyLink: הבדלים בין גרסאות בדף
מ הוספת אישה סיסג'נדרית |
מ מיון לפי מבחין מפרמטר |
||
| שורה 294: | שורה 294: | ||
options['source'] = options['source'] or false | options['source'] = options['source'] or false | ||
options['filter'] = options['filter'] or nil | options['filter'] = options['filter'] or nil | ||
options['sort'] = options['sort'] or | options['sort'] = options['sort'] or 'P1545' | ||
local propertyVals = mw.wikibase.getBestStatements(entityId, propertyName) | local propertyVals = mw.wikibase.getBestStatements(entityId, 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 | ||
| שורה 302: | שורה 302: | ||
local hasFallbackTransation = false | local hasFallbackTransation = false | ||
local | local sortByQualifier = function(t1, t2) | ||
if t1 and t2 then | if t1 and t2 then | ||
local q1 = t1.qualifiers | local q1 = t1.qualifiers | ||
| שורה 309: | שורה 309: | ||
local c2 = nil | local c2 = nil | ||
if q1 and q2 then | if q1 and q2 then | ||
if q1[' | if q1[options['sort']] and q1[options['sort']][1] and q1[options['sort']][1].datavalue and q1[options['sort']][1].datavalue.value then | ||
c1 = q1[' | if q1[options['sort']][1].datavalue.type == 'string' then | ||
c1 = q1[options['sort']][1].datavalue.value | |||
elseif q1[options['sort']][1].datavalue.type == 'quantity' then | |||
c1 = q1[options['sort']][1].datavalue.value.amount | |||
elseif q1[options['sort']][1].datavalue.type == 'time' then | |||
c1 = q1[options['sort']][1].datavalue.value.time | |||
end | |||
end | end | ||
if q2[' | if q2[options['sort']] and q2[options['sort']][1] and q2[options['sort']][1].datavalue and q2[options['sort']][1].datavalue.value then | ||
c2 = q2[' | if q2[options['sort']][1].datavalue.type == 'string' then | ||
c2 = q2[options['sort']][1].datavalue.value | |||
elseif q2[options['sort']][1].datavalue.type == 'quantity' then | |||
c2 = q2[options['sort']][1].datavalue.value.amount | |||
elseif q2[options['sort']][1].datavalue.type == 'time' then | |||
c2 = q2[options['sort']][1].datavalue.value.time | |||
end | |||
end | end | ||
if c1 and c2 then | if c1 and c2 then | ||
| שורה 338: | שורה 350: | ||
end | end | ||
if options['sort'] then | if options['sort'] then | ||
table.sort(propertyVals, | table.sort(propertyVals, sortByQualifier) | ||
end | end | ||