„Modul:WikidataCheck” változatai közötti eltérés

[ellenőrzött változat][ellenőrzött változat]
Tartalom törölve Tartalom hozzáadva
megegyező
Frissítés az angol modul mintájára.
2. sor:
 
function p.wikidatacheck(frame)
local pframe = frame:getParent()
local config = frame.args -- the arguments passed BY the template, in the wikitext of the template itself
local args = pframe.args -- the arguments passed TO the template, in the wikitext that transcludes the template
 
local property = config.property:upper()
local value = config.value or ""
local catbase = config.category
local namespaces = config.namespaces
local nocatsame = config.nocatsame or ""
local ok = false -- one-way flag to check if we're in a good namespace
local qid = config.qid or ""
local ns = mw.title.getCurrentTitle().namespace
local ok = false -- one-way flag to check if we're in a good namespace
for v in mw.text.gsplit( namespaces, ",", true) do
local ns = mw.title.getCurrentTitle().namespace
if tonumber(v) == ns then
ok = true
end
for v in mw.text.gsplit( namespaces, ",", true) do
end
if tonumber(v) == ns then
if not ok then -- not in one of the approved namespaces
ok = true
return ""
end
end
local entity = mw.wikibase.getEntityObject()
if not entityok then -- nonot in one of the Wikidataapproved itemnamespaces
return ""
return "[[Category:" .. catbase .. " not in Wikidata]]"
end
local claims = entity.claims or {}
if qid == "" then
local hasProp = claims[property]
local entity = mw.wikibase.getEntityObject()
if not hasProp then -- no claim of that property
else
return "[[Kategória:" .. catbase .. " not in Wikidata]]" -- bad. Bot needs to add the property
entity = mw.wikibase.getEntityObject(qid)
end
local propValue = hasProp[1].mainsnak.datavalue.value -- This should eventually iterate over all possible values?
if not entity then -- no Wikidata item
if propValue == value then
return "[[Kategória:" .. catbase .. " megegyezőnot in Wikidata azonosítóval]]" -- yay!
end
else
if value == "" then
return "[[Kategória:" .. catbase .. " különbözik Wikidatán tárolt értéktől]]" -- needs human review :(
return nil -- Using Wikidata
end
end
local claims = entity.claims or {}
local hasProp = claims[property]
if not hasProp then -- no claim of that property
return "[[CategoryKategória:" .. catbase .. " not in Wikidata]]" -- bad. Bot needs to add the property
end
for i, v in ipairs(hasProp) do -- Now we try to iterate over all possible values?
propValue = (v.mainsnak.datavalue or {}).value
if propValue == value then
if nocatsame == "" then
return "[[Kategória:" .. catbase .. " különbözikmegegyező WikidatánWikidata tárolt értéktőlazonosítóval]]" -- needs human review :(yay!
else
return nil -- if nocatsame, the "same as" category is not added
end
end
end
return "[[Kategória:" .. catbase .. " notkülönbözik inWikidatán Wikidatatárolt értéktől]]" -- bad. Bot needs tohuman addreview the property:(
end