Modulo:Wikidata: differenze tra le versioni

m
permetto valorizzazione di "recursion" anche dal codice del template
m (una versione importata)
m (permetto valorizzazione di "recursion" anche dal codice del template)
Riga 16: Riga 16:
-- =============================================================================
-- =============================================================================


require('Module:No globals')
require('strict')


local getArgs = require('Module:Arguments').getArgs
local getArgs = require('Module:Arguments').getArgs
local mConvert = require('Module:Conversione')
local mConvert = require('Module:Conversione')
local mLanguages = require('Module:Linguaggi')
local mLanguages = require('Module:Lingue')


-- Categoria per le pagine con errori
-- Categoria per le pagine con errori
Riga 36: Riga 36:
['unknown-snak-type'] = 'Tipo di snak sconosciuto',
['unknown-snak-type'] = 'Tipo di snak sconosciuto',
['unknown-datavalue-type'] = 'Tipo di dato sconosciuto',
['unknown-datavalue-type'] = 'Tipo di dato sconosciuto',
['unknown-entity-type'] = 'Tipo di entità sconosciuta'
['unknown-entity-type'] = 'Tipo di entità sconosciuta',
['unknown-output-format'] = 'Formato di output sconosciuto'
},
},
somevalue = "''valore sconosciuto''",
somevalue = "''valore sconosciuto''",
Riga 270: Riga 271:
local entityId = getEntityIdFromValue(datavalue.value)
local entityId = getEntityIdFromValue(datavalue.value)
if args.showprop then
if args.showprop then
ret = p._getProperty({ args.showprop, n = 1, from = entityId }) or ''
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
formatting == 'label' and mw.wikibase.getLabel(entityId) or
formatting == 'title' and mw.wikibase.getSitelink(entityId) or
error(i18n.errors['unknown-output-format'])
else
else
ret = args.formatting == 'raw' and entityId or formatEntityId(entityId)
ret = formatEntityId(entityId)
end
end
elseif datavalue.type == 'string' then
elseif datavalue.type == 'string' then
Riga 874: Riga 881:
-- Funzione per il template {{WikidataClasse}}
-- Funzione per il template {{WikidataClasse}}
function p.propertyHasEntity(frame)
function p.propertyHasEntity(frame)
local args = getArgs(frame, { parentOnly = true })
local args = getArgs(frame)
local propertyId = args[1]
local propertyId = args[1]
args.recursion = tonumber(args.prof) or 8
return select(2, xpcall(function()
return select(2, xpcall(function()
return p._propertyHasEntity(propertyId, args) and 1 or ''
return p._propertyHasEntity(propertyId, args) and 1 or ''
Utente anonimo