ሞድዩል:Infobox/Wikidata
Appearance
Documentation for this module may be created at ሞድዩል:Infobox/Wikidata/doc
local p = {}
local Wikidata = require('Module:Wikidata')
local Formats = require('Module:Formats')
local ti = mw.language.new('ti')
local frame
function p:setFrame(frame)
frame = frame
Wikidata:setFrame(frame)
end
function p.getLabel()
local element = mw.wikibase.getEntityObject() or {}
return es:ucfirst(mw.wikibase.label(element.id) or '')
end
function p.getStatements()
return Wikidata.getStatements()
end
function p.getStatement(statement, property, separator, Module, feature, qualifier, link, cut, propertyValue)
local propOneValue = {'P41','P18','P94','P242','P6','P1082','P163','P237','P625'} -- Properties that should only have one value
local oneValue = 'no'
local highestRank = 'yes'
for k,v in pairs(propOneValue) do -- Check if property matches
if property == v then
oneValue = 'yes'
highestRank = 'no'
end
end
options = {
['property'] = property,
['value'] = nil, -- Value that would replace the value of Wikidata to be given
['separator'] = separator,
['value-module'] = Module,
['value-function'] = feature,
['legend'] = nil, -- Image footer if the Wikidata/Formats module and the formatImage function are used
['conjunction'] = separator,
['qualifier'] = qualifier,
['data'] = nil, -- If the value would be 'source' it would return the source of the declaration
['one'] = oneValue,
['textFormat'] = 'upperCase',
['highestRank'] = highestRank, -- will return only the highest ranking values
['link'] = link,
['kind'] = 'city',
['display'] = 'inline,title',
['format'] = 'dms',
['propertyValue'] = propertyValue,
['entityId'] = nil, -- entity id. It would not have any application here
['cut'] = cut -- Value that if matching would be cut in the string when using the Wikidata/Formats module and the flagFormat function is useful to cut province from if the province label is given
}
local formattedValue = Wikidata.getProperty(options,board)
if formattedValue == nil then return "" end
if type(formattedValue) == 'number' and link ~= 'no' then
formattedValue = es:formatNum(tonumber(formattedValue))
end
return formattedValue
end
return p