יחידה:PropertyLink: הבדלים בין גרסאות בדף
DK |
מ 8 גרסאות של הדף wikipedia:he:יחידה:PropertyLink יובאו |
||
| (6 גרסאות ביניים של 3 משתמשים אינן מוצגות) | |||
| שורה 112: | שורה 112: | ||
gender[1].mainsnak.datavalue and | gender[1].mainsnak.datavalue and | ||
gender[1].mainsnak.datavalue.value and | gender[1].mainsnak.datavalue.value and | ||
(gender[1].mainsnak.datavalue.value["numeric-id"] == 6581072 or gender[1].mainsnak.datavalue.value["numeric-id"] == 1052281) | (gender[1].mainsnak.datavalue.value["numeric-id"] == 6581072 | ||
or gender[1].mainsnak.datavalue.value["numeric-id"] == 1052281 | |||
or gender[1].mainsnak.datavalue.value["numeric-id"] == 15145779) | |||
if isFemale then | if isFemale then | ||
| שורה 292: | שורה 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 | ||
| שורה 300: | שורה 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 | ||
| שורה 307: | שורה 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 | ||
| שורה 336: | שורה 350: | ||
end | end | ||
if options['sort'] then | if options['sort'] then | ||
table.sort(propertyVals, | table.sort(propertyVals, sortByQualifier) | ||
end | end | ||
| שורה 564: | שורה 578: | ||
for site, val in pairs(raw) do | for site, val in pairs(raw) do | ||
truncated, found = string.gsub(site, 'wiki$', '') | truncated, found = string.gsub(site, 'wiki$', '') | ||
if found then interwikis = interwikis .. '[[' .. truncated .. ':' .. val.title .. ']]' end | truncated = string.gsub(truncated, '_', '-') | ||
if found == 1 and truncated ~= 'he' and truncated ~= 'commons' then interwikis = interwikis .. '[[' .. truncated .. ':' .. val.title .. ']]' end | |||
end | end | ||
return interwikis | return interwikis | ||