Відмінності між версіями «Модуль:Wikidata1»

нема опису редагування
-- If a property is chosen that is not of type "commonsMedia", it will return empty text.
p.getImages = function(frame)
local propertyID = mw.text.trim(frame.args[1] or "")
local input_parm = mw.text.trim(frame.args[2] or "")
local sep = mw.text.trim(frame.args[3] or " ")
local imgsize = mw.text.trim(frame.args[4] or "frameless")
local go, errorOrentity, claims = parseInput(frame)
if input_parm == "FETCH_WIKIDATA" then
if not go then
local entity = mw.wikibase.getEntityObject()
return errorOrentity
local claims
end
if entity and entity.claims then
local entity = errorOrentity
claims = entity.claims[propertyID]
if (claims[1] and claims[1].mainsnak.datatype == "commonsMedia") then
end
iflocal claimsout then= {}
for k, v in pairs(claims) do
if (claims[1] and claims[1].mainsnak.datatype == "commonsMedia") then
local outfilename = {}v.mainsnak.datavalue.value
out[#out + 1] = "[[File:" .. filename .. "|" .. imgsize .. "]]"
for k, v in pairs(claims) do
local filename = v.mainsnak.datavalue.value
out[#out + 1] = "[[File:" .. filename .. "|" .. imgsize .. "]]"
end
return table.concat(out, sep)
else
return ""
end
else
return ""
end
return table.concat(out, sep)
else
return input_parm""
end
end
else
return input_parm
end
end
 
-- This is used to get the QIDs of all of the values of a property, as a comma separated list if multiple values exist
-- Usage: {{#invoke:Wikidata |getPropertyIDs |<PropertyID> |FETCH_WIKIDATA}}
-- Usage: {{#invoke:Wikidata |getPropertyIDs |<PropertyID> |<InputParameter> |qid=<QID>}}
 
p.getPropertyIDs = function(frame)
local go, errorOrentity, propclaims = parseInput(frame)
if not go then
return errorOrentity
end
local entity = errorOrentity
-- if wiki-linked value collect the QID in a table
if (propclaims[1] and propclaims[1].mainsnak.snaktype == "value" and propclaims[1].mainsnak.datavalue.type == "wikibase-entityid") then
local claimsout = {}
for k, v in pairs(propclaims) do
localout[#out filename+ 1] = "Q" .. v.mainsnak.datavalue.value["numeric-id"]
end
return table.concat(out, ", ")
else
-- not a wikibase-entityid, so return empty
return ""
end
end
250

редагувань