בדוקי עריכות אוטומטית, אינטערפעיס רעדאקטארן, אינטערפעיס אדמיניסטראַטאָרן, סיסאפן, מייבאים, מעדכנים, מייבא, אספקלריה רעדאקטארן
46,382
רעדאגירונגען
שרגא (שמועס | ביישטייערונגען) ק (1 רעוויזיע אימפארטירט: אימפארטירט פון די יידישע וויקיפעדיע, זע ביישטייערער ליסטע) |
ק (1 רעוויזיע אימפארטירט פון wikipedia:he:יחידה:Wikidata) |
||
| (2 צווישנדיגע ווערסיעס פונעם זעלבן באַניצער נישט געוויזן) | |||
| שורה 229: | שורה 229: | ||
end | end | ||
function getQualifierSnak(claim, qualifierId) | function getQualifierSnak(claim, qualifierId, onlyHebrew) | ||
-- a "snak" is Wikidata terminology for a typed key/value pair | -- a "snak" is Wikidata terminology for a typed key/value pair | ||
-- a claim consists of a main snak holding the main information of this claim, | -- a claim consists of a main snak holding the main information of this claim, | ||
| שורה 237: | שורה 237: | ||
if claim.qualifiers then | if claim.qualifiers then | ||
local qualifier = claim.qualifiers[qualifierId] | local qualifier = claim.qualifiers[qualifierId] | ||
if qualifier then return qualifier[1] end | if qualifier then | ||
-- only hebrew qualifiers for monolingualtext type | |||
if onlyHebrew and qualifier[1].datatype == 'monolingualtext' then | |||
for idx,eachForm in pairs(qualifier) do | |||
if eachForm.datavalue.value.language == 'he' then | |||
return qualifier[idx] | |||
end | |||
end | |||
else | |||
return qualifier[1] | |||
end | |||
end | |||
end | end | ||
return nil, printError("qualifier-not-found") | return nil, printError("qualifier-not-found") | ||
| שורה 249: | שורה 260: | ||
local error | local error | ||
local snak | local snak | ||
snak, error = getQualifierSnak(claim, qualifierId) | |||
local onlyHebrew | |||
if qualifierId == 'P2096' then onlyHebrew = true end | |||
snak, error = getQualifierSnak(claim, qualifierId, onlyHebrew) | |||
if snak then | if snak then | ||
| שורה 277: | שורה 292: | ||
end | end | ||
return result | return result | ||
end | |||
-- Check if the 'qualifierId' exists on the 'property' of given 'id' | |||
function p.isClaimExist(property, qualifierId, id) | |||
-- get wikidata entity | |||
local entity = mw.wikibase.getEntityObject(id or nil) | |||
if not entity then | |||
return false | |||
end | |||
-- fetch the first claim of satisfying the given property | |||
local claims = findClaims(entity, property) | |||
if not claims or not claims[1] then | |||
return false | |||
end | |||
-- get initial sort indices | |||
local sortindices = {} | |||
for idx in pairs(claims) do | |||
sortindices[#sortindices + 1] = idx | |||
end | |||
-- check if there is an element | |||
local claim = claims[sortindices[1]] | |||
result, error = getValueOfClaim(claim, qualifierId, parameter) | |||
return result ~= nil | |||
end | end | ||
| שורה 526: | שורה 568: | ||
return computeLinkToItem(entityId, capitalize, callFunction) | return computeLinkToItem(entityId, capitalize, callFunction) | ||
end | end | ||
-- check whether entityId has a claim with propertyId referencing to claimedEntity | |||
p.hasClaim = function(entityId, propertyId, claimedEntity) | |||
if entityId==nil or propertyId==nil then return false end | |||
local propertyVals = mw.wikibase.getBestStatements(entityId, propertyId) | |||
if (not propertyVals) or (#propertyVals==0) then return false end | |||
for i, property in ipairs(propertyVals) do | |||
local propValue = property.mainsnak and property.mainsnak.datavalue | |||
if not propValue then return false end | |||
if propValue.value['id'] == claimedEntity then | |||
return true | |||
end | |||
end | |||
return false | |||
end | |||
p.getValueOfClaim = getValueOfClaim | p.getValueOfClaim = getValueOfClaim | ||
return p | return p | ||
רעדאגירונגען