יחידה:PropertyLink: הבדלים בין גרסאות בדף
מיון לפי מבחין "מספר סודר" |
מ 8 גרסאות של הדף wikipedia:he:יחידה:PropertyLink יובאו |
||
| (12 גרסאות ביניים של 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 | ||
| שורה 548: | שורה 562: | ||
function getSitelinksFromQid(frame) | function getSitelinksFromQid(frame) | ||
resTable =mw.wikibase.getEntity(string.upper(frame.args[1] )) | resTable = mw.wikibase.getEntity(string.upper(frame.args[1] )) | ||
resTable = resTable["sitelinks"] | resTable = resTable["sitelinks"] | ||
s= "<table>\n" | s= "<table>\n" | ||
| שורה 555: | שורה 569: | ||
s=s.."<tr>".. "<td>" .. k.."</td>".. "<td>" .. v.title.."</td>".."</tr>" .. "\n" | s=s.."<tr>".. "<td>" .. k.."</td>".. "<td>" .. v.title.."</td>".."</tr>" .. "\n" | ||
end | end | ||
end | |||
return s .. "</table>" | |||
end | |||
local function createInterwikiForQid(frame) | |||
local raw = mw.wikibase.getEntity( string.upper( frame.args[1] ) )["sitelinks"] | |||
local interwikis = '' | |||
for site, val in pairs(raw) do | |||
truncated, found = string.gsub(site, 'wiki$', '') | |||
truncated = string.gsub(truncated, '_', '-') | |||
if found == 1 and truncated ~= 'he' and truncated ~= 'commons' then interwikis = interwikis .. '[[' .. truncated .. ':' .. val.title .. ']]' end | |||
end | |||
return interwikis | |||
end | end | ||
return { | return { | ||
imageLink = imageLink, | imageLink = imageLink, | ||
| שורה 574: | שורה 599: | ||
getPropertyByOptions = getPropertyByOptions, | getPropertyByOptions = getPropertyByOptions, | ||
getPropertyQualifier = getPropertyQualifier, | getPropertyQualifier = getPropertyQualifier, | ||
getItem = getItem, | |||
getImageLink = getImageLink, | getImageLink = getImageLink, | ||
getLabel = getLabel, | getLabel = getLabel, | ||
hasEntry = hasEntry, | hasEntry = hasEntry, | ||
getPageEntry = getPageEntry, | getPageEntry = getPageEntry, | ||
getSitelinksFromQid=getSitelinksFromQid, | getSitelinksFromQid = getSitelinksFromQid, | ||
createInterwikiForQid = createInterwikiForQid, | |||
['יש פריט'] = hasEntry | ['יש פריט'] = hasEntry | ||
} | } | ||