Modul:Wikibase
Asayış
Seba na module şıma şenê yû pela dokumani vırazê Modul:Wikibase/dok
require 'Modul:No globals'
local p = {}
local function getIdIfNil(id)
if id then
return id
else
return mw.wikibase.getEntityIdForCurrentPage()
end
end
-- Return the item ID of the item linked to the current page.
function p.id(frame)
return mw.wikibase.getEntityIdForCurrentPage() or '(no item connected)'
end
-- Return the item ID of the item linked to the given page.
function p.idForPage(frame)
return mw.wikibase.getEntityIdForTitle(frame.args[1], frame.args[2])
end
-- Return the label of a given data item.
function p.label(frame)
local id = getIdIfNil(frame.args[1])
if not id then
return nil
end
return mw.wikibase.label(id)
end
-- Return the local page about a given data item.
function p.page(frame)
local id = getIdIfNil(frame.args[1])
if not id then
return nil
end
return mw.wikibase.sitelink(id)
end
function p.renderSnaks(frame)
local entity = mw.wikibase.getEntity()
local property = frame.args[1]
if entity and entity.claims and entity.claims[property] and entity.claims[property][1].qualifiers then
return mw.wikibase.renderSnaks(entity.claims[property][1].qualifiers)
end
return nil
end
function p.renderReference(frame)
local entity = mw.wikibase.getEntity()
local property = frame.args[1]
local statementIndex = tonumber(frame.args[2]) or 1
local referenceIndex = tonumber(frame.args[3]) or 1
if entity and entity.claims and entity.claims[property] and entity.claims[property][statementIndex] and
entity.claims[property][statementIndex].references and entity.claims[property][statementIndex].references[referenceIndex] then
return mw.wikibase.renderSnaks(entity.claims[property][statementIndex].references[referenceIndex].snaks)
end
return nil
end
-- Return the sitelink on globalSiteId wiki (connected to entityId entity)
-- Burkolósablonok: Projektlink
function p.sitelink(frame)
local args = require('Modul:Arguments').getArgs(frame)
local globalSiteId = args.globalSiteId or args[1]
local entityId = args.entityId or args[2]
local entity = mw.wikibase.getEntity(entityId)
return entity and entity:getSitelink(globalSiteId)
end
return p