For faster navigation, this Iframe is preloading the Wikiwand page for Módulo:Wikibase.

Módulo:Wikibase

Indicacións de uso do módulo

Uso

Este módulo define funcións para acceder ós datos de Wikidata.

Exemplos

  • ID: ((#invoke:Wikibase|id)) → Q8565357
  • Etiqueta(): ((#invoke:Wikibase|etiqueta)) → Wikibase
  • Etiqueta(Q29): ((#invoke:Wikibase|etiqueta|Q29)) → España
  • Etiqueta(q555555): ((#invoke:Wikibase|etiqueta|q555555)) → Sam Webb
  • Enlace(): ((#invoke:Wikibase|enlace)) → Módulo:Wikibase
  • Enlace(Q29): ((#invoke:Wikibase|enlace|Q29)) → España
  • Enlace(q555555): ((#invoke:Wikibase|enlace|q555555)) → Sam Webb
  • descricion(P166): ((#invoke:Wikibase|descricion|p166)) → premio ou recoñecemento recibido por unha persoa, organización ou obra creativa

Nota: Este módulo é usado polo Modelo:Commonscat para determinar a ligazón á categoría de commons correspondente baseándose no valor da propiedade correspondente no wikidata

Esta documentación está transcluída desde Módulo:Wikibase/uso. Os editores poden probar cambios no mesmo en Módulo:Wikibase/probas.
Por favor, engade as categorías na subpáxina de documentación e os interwikis no Wikidata. Ver as subpáxinas deste módulo.

-- Module:Wikibase
local p = {}

-- copiado de ca.wiki
-- Return the item ID of the item connected to the current page or connected to a page title via a sitelink.
-- mw.wikibase.getEntityIdForCurrentPage, mw.wikibase.getEntityIdForTitle
function p.id(frame)
	local page_title = frame.args[1] and mw.text.trim(frame.args[1])
	if page_title == nil or page_title == '' then
		return mw.wikibase.getEntityIdForCurrentPage()
	end
	return mw.wikibase.getEntityIdForTitle(page_title)
end

-- Devolve a etiqueta dun ítem dado.
function p.etiqueta(frame)
        if frame.args[1] == nil then
            entity = mw.wikibase.getEntityObject()
            if not entity then return nil end
 
            id = entity.id
        else
            id = frame.args[1]
        end
 
        return mw.wikibase.label( id )
end

-- copiado de ca.wiki
-- Return the label of a given data item, optionally in a given language.
function p.label(frame)
    if frame.args[1] == nil then
        entity = mw.wikibase.getEntityObject()
        if not entity then return nil end
        id = entity.id
    else
        id = frame.args[1]
    end
    if frame.args[2] then
    	return mw.wikibase.getLabelByLang(id, frame.args[2])
    end
    return mw.wikibase.label( id )
end

-- copiado de ca.wiki
-- Return the language code of the label of a given data item.
function p.label_lang(frame)
	local id
    if frame.args[1] == nil then
        entity = mw.wikibase.getEntityObject()
        if not entity then return nil end
        id = entity.id
    else
        id = frame.args[1]
    end
    local _, lang = mw.wikibase.getLabelWithLang(id)
    return lang
end

-- copiado de ca.wiki
-- Return the local page about a given data item, optionary in a given wiki.
function p.page(frame)
    if frame.args[1] == nil then
        entity = mw.wikibase.getEntityObject()
        if not entity then return nil end
        id = entity.id
    else
        id = frame.args[1]
    end
    return mw.wikibase.sitelink(id, frame.args[2])
end

--copiado de ca.wiki
-- Return the first value of given property of the item linked to the current page.
function p.firstproperty(frame)
    local property = frame.args[1]
    local entity = mw.wikibase.getEntityObject()
    if not entity then return nil end
    if not entity.claims then return nil end
    local hasProp = entity.claims[property]
    if not hasProp then return nil end
    return hasProp[0].mainsnak.datavalue.value
end

-- Devolve a páxina local dun ítem dado.
function p.enlace(frame)
        if frame.args[1] == nil then
            entity = mw.wikibase.getEntityObject()
            if not entity then return nil end
 
            id = entity.id
        else
            id = frame.args[1]
        end
 
        return mw.wikibase.sitelink( id )
end

-- Devolve a descrición dun ítem dado.
function p.descricion(frame)
        if frame.args[1] == nil then
            entity = mw.wikibase.getEntityObject()
            if not entity then return nil end
 
            id = entity.id
        else
            id = frame.args[1]
        end
 
        return mw.wikibase.description( id )
end

return p
{{bottomLinkPreText}} {{bottomLinkText}}
Módulo:Wikibase
Listen to this article

This browser is not supported by Wikiwand :(
Wikiwand requires a browser with modern capabilities in order to provide you with the best reading experience.
Please download and use one of the following browsers:

This article was just edited, click to reload
This article has been deleted on Wikipedia (Why?)

Back to homepage

Please click Add in the dialog above
Please click Allow in the top-left corner,
then click Install Now in the dialog
Please click Open in the download dialog,
then click Install
Please click the "Downloads" icon in the Safari toolbar, open the first download in the list,
then click Install
{{::$root.activation.text}}

Install Wikiwand

Install on Chrome Install on Firefox
Don't forget to rate us

Tell your friends about Wikiwand!

Gmail Facebook Twitter Link

Enjoying Wikiwand?

Tell your friends and spread the love:
Share on Gmail Share on Facebook Share on Twitter Share on Buffer

Our magic isn't perfect

You can help our automatic cover photo selection by reporting an unsuitable photo.

This photo is visually disturbing This photo is not a good choice

Thank you for helping!


Your input will affect cover photo selection, along with input from other users.

X

Get ready for Wikiwand 2.0 🎉! the new version arrives on September 1st! Don't want to wait?