Modulo:Wikidata: differenze tra le versioni
Contenuto cancellato Contenuto aggiunto
implemento parametro "outputtype" (funzionalità proposta in Discussioni template:Wikidata#Solo etichette/titoli) |
m inverto logica del parametro per retrocompatibilità |
||
(6 versioni intermedie di uno stesso utente non sono mostrate) | |||
Riga 37:
['unknown-datavalue-type'] = 'Tipo di dato sconosciuto',
['unknown-entity-type'] = 'Tipo di entità sconosciuta',
['unknown-output-
},
somevalue = "''valore sconosciuto''",
Riga 271:
local entityId = getEntityIdFromValue(datavalue.value)
if args.showprop then
ret = p._getProperty({ args.showprop, n = 1, from = entityId, formatting = args.formatting }) or ''
elseif args.formatting then
local formatting = args.formatting:lower()
ret = (formatting == 'raw' or formatting == 'id') and entityId or
else
ret =
end
elseif datavalue.type == 'string' then
Riga 382 ⟶ 388:
local function formatStatements(claims, args, rawTable)
local formattedStatements = {}
for _, claim in ipairs(claims) do
local formattedStatement = formatStatement(claim, args)
▲ outputtype == 'label' and mw.wikibase.getLabel(entityId) or
▲ outputtype == 'title' and mw.wikibase.getSitelink(entityId) or
▲ error(i18n.errors['unknown-output-type'])
if formattedStatement ~= '' then
-- eventuale pattern
Riga 783 ⟶ 778:
-- Restituisce l'ID dell'item Wikidata collegato alla pagina corrente o a una pagina specificata
-- (nota: se il parametro followRedirects è valorizzato con "no", segue i redirect fermandosi al primo redirect collegato a un elemento)
function p._getId(args)
local ret
local followRedirects = not args.followRedirects or args.followRedirects ~= "no"
if args[1] then
local title = mw.title.new(args[1])
Riga 794 ⟶ 790:
break
else
title = followRedirects and title.redirectTarget or nil
end
end
Riga 886 ⟶ 882:
-- Funzione per il template {{WikidataClasse}}
function p.propertyHasEntity(frame)
local args = getArgs(frame
local propertyId = args[1]
return select(2, xpcall(function()
return p._propertyHasEntity(propertyId, args) and 1 or ''
|