Modulo:Wikidata/sandbox: differenze tra le versioni

Contenuto cancellato Contenuto aggiunto
m variabile globale a inizio modulo
aggiunto parametro "cache"
Riga 48:
}
 
-- Table per la funzione getEntityCachedgetEntity
local entitiesCache = {}
 
Riga 387:
 
-- Versione con cache di mw.wikibase.getEntity
local function getEntityCachedgetEntity(entityId, cache)
local ret
if entityIdcache then
entityId = entityId or mw.wikibase.getEntityIdForCurrentPage()
if entityId then
if entityId then
ret = entitiesCache[entityId]
if not ret then
ret = mw.wikibase.getEntity(entityId)
if ret then
entitiesCache[entityId] = ret
end
end
end
else
return mw.wikibase.getEntity(entityId)
end
return ret
Line 436 ⟶ 440:
-- get entity
entity = getEntityCachedgetEntity(args.from, args.cache)
if not entity then
return nil
Line 675 ⟶ 679:
-- Restituisce l'etichetta di un item o di una proprietà Wikidata.
function p._getLabel(args)
local entity = getEntityCachedgetEntity(args[1] and string.upper(args[1]), args.cache)
return entity and entity:getLabel(args[2])
end
Line 700 ⟶ 704:
end
 
entity = getEntityCachedgetEntity(property, args.cache)
if not entity then
error(i18n.errors['entity-not-found'], 2)