Modulo:Wikidata: differenze tra le versioni
Contenuto cancellato Contenuto aggiunto
upd |
m inverto logica del parametro per retrocompatibilità |
||
(11 versioni intermedie di 3 utenti non mostrate) | |||
Riga 16:
-- =============================================================================
require('
local getArgs = require('Module:Arguments').getArgs
local mConvert = require('Module:Conversione')
local mLanguages = require('Module:
-- Categoria per le pagine con errori
Riga 36:
['unknown-snak-type'] = 'Tipo di snak sconosciuto',
['unknown-datavalue-type'] = 'Tipo di dato sconosciuto',
['unknown-entity-type'] = 'Tipo di entità sconosciuta',
['unknown-output-format'] = 'Formato di output sconosciuto'
},
somevalue = "''valore sconosciuto''",
Riga 270 ⟶ 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
formatting == 'label' and mw.wikibase.getLabel(entityId) or
formatting == 'title' and (mw.wikibase.getSitelink(entityId) or '') or
error(i18n.errors['unknown-output-format'])
else
ret =
end
elseif datavalue.type == 'string' then
Riga 410 ⟶ 417:
-------------------------------------------------------------------------------
-- Restituisce true se lo statement contiene il qualifier richiesto con un dato valore (o uno tra più valori separati da virgola)
local function hasQualifierValue(statement, qualifierId, qualifierValue)
local ret = false
Riga 416 ⟶ 423:
local isItem = qualifier.snaktype == 'value' and
qualifier.datavalue.type == 'wikibase-entityid'
local qualifierValues = mw.text.split(qualifierValue, ',')
-- per le proprietà di tipo item il confronto è eseguito sull'id▼
for _, qualifierHas in ipairs(qualifierValues) do
if formatSnak(qualifier, isItem and { formatting = 'raw' } or {}) == qualifierValue then▼
▲ -- per le proprietà di tipo item il confronto è eseguito sull'id
ret = true▼
▲ if formatSnak(qualifier, isItem and { formatting = 'raw' } or {}) ==
break▼
▲ ret = true
▲ break
end
end
end
Riga 768 ⟶ 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 779 ⟶ 790:
break
else
title = followRedirects and title.redirectTarget or nil
end
end
Riga 866 ⟶ 877:
return select(2, xpcall(function()
return p._N(getArgs(frame, { parentOnly = true })) > 0 and 1 or ''
end, errhandler))
end
-- 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 ''
end, errhandler))
end
|