Modul:Wikidata/item
Dokumentaciju za ovaj modul možete napraviti na stranici Modul:Wikidata/item/dok
require 'Modul:No globals'
local p = {}
local lib = require 'Modul:Wikidata/lib'
local function constructLink(label, link, entityId)
if link then
if label then
return '[[' .. link .. '|' .. label .. ']]'
else
return '[[' .. link .. ']]'
end
else
return label or p.getLinkWhenNonexistingLabel(entityId)
end
end
function p.getLinkWhenNonexistingLabel(entityId)
local i18n = mw.loadData('Modul:Wikidata/i18n')
local ImageFormatter = require 'Modul:ImageFormatter'
return ImageFormatter.makeImage('Wikidata-edit.svg', {
description = i18n['missing-label'],
link = 'd:' .. entityId,
size = '27x17px'
}) .. '<code>[[d:' .. entityId .. '|' .. entityId .. ']]</code>' .. lib.category('missing-label')
end
function p.formatEntityWithGender(value, options)
local entityId = lib.getEntityIdFromValue(value)
local Module = require 'Modul:Wikidata/igralište'
local gender = Module.getRawValueFromLua{
entity = options.entity,
property = 'P21'
}
local label
if gender == 'Q6581072' then
label = Module.formatStatementsFromLua{
id = entityId,
limit = 1,
property = 'P2521',
rank = 'valid',
sort = 'rank',
withlang = 'bs'
}
end
if not label then
label = mw.wikibase.label(entityId)
end
local link = mw.wikibase.sitelink(entityId)
return constructLink(label, link, entityId)
end
function p.formatEntityId(entityId, options)
local label = mw.wikibase.label(entityId)
local link = mw.wikibase.sitelink(entityId)
return constructLink(label, link, entityId)
end
return p