546
edits
m (1 revision imported) |
No edit summary |
||
Line 581: | Line 581: | ||
function p.getIdsFromWikidata( itemId, property ) | function p.getIdsFromWikidata( itemId, property ) | ||
local ids = {} | local ids = {} | ||
local statements = mw.wikibase.getBestStatements( itemId, property ) | return ids | ||
if statements then | --local statements = mw.wikibase.getBestStatements( itemId, property ) | ||
for _, statement in ipairs( statements ) do | --if statements then | ||
if statement.mainsnak.datavalue then | --for _, statement in ipairs( statements ) do | ||
table.insert( ids, statement.mainsnak.datavalue.value ) | --if statement.mainsnak.datavalue then | ||
end | --table.insert( ids, statement.mainsnak.datavalue.value ) | ||
end | --end | ||
end | --end | ||
return ids | --end | ||
--return ids | |||
end | end | ||
function p.matchesWikidataRequirements( itemId, reqs ) | function p.matchesWikidataRequirements( itemId, reqs ) | ||
for _, group in ipairs( reqs ) do | return false | ||
local property = 'P' .. group[1] | --for _, group in ipairs( reqs ) do | ||
local qid = group[2] | --local property = 'P' .. group[1] | ||
local statements = mw.wikibase.getBestStatements( itemId, property ) | --local qid = group[2] | ||
if statements then | --local statements = mw.wikibase.getBestStatements( itemId, property ) | ||
for _, statement in ipairs( statements ) do | --if statements then | ||
if statement.mainsnak.datavalue then | --for _, statement in ipairs( statements ) do | ||
if statement.mainsnak.datavalue.value['numeric-id'] == qid then | --if statement.mainsnak.datavalue then | ||
return true | --if statement.mainsnak.datavalue.value['numeric-id'] == qid then | ||
end end end end end | --return true | ||
return false | --end end end end end | ||
--return false | |||
end | end | ||
Line 794: | Line 796: | ||
itemId = resolveEntity._id(itemId) --nil if unresolvable | itemId = resolveEntity._id(itemId) --nil if unresolvable | ||
end | end | ||
else | --else | ||
itemId = mw.wikibase.getEntityIdForCurrentPage() | --itemId = mw.wikibase.getEntityIdForCurrentPage() | ||
end | end | ||