Modulo:Wikidata/sandbox: differenze tra le versioni

Contenuto cancellato Contenuto aggiunto
m getEntity
aggiornato alla versione corrente
Riga 47:
}
}
 
-- Table per la funzione getEntity
local entitiesCache = {}
 
local p = {}
Line 385 ⟶ 382:
-- Lettura e selezione statement
-------------------------------------------------------------------------------
 
-- Versione con cache di mw.wikibase.getEntity
local function getEntity(entityId, cache)
local ret
if cache then
entityId = entityId or mw.wikibase.getEntityIdForCurrentPage()
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
ret = mw.wikibase.getEntity(entityId)
end
return ret
end
 
-- Restituisce true se lo statement contiene il qualifier richiesto con un dato valore
Line 440 ⟶ 417:
-- get entity
entity = mw.wikibase.getEntity(args.from, args.cache)
if not entity then
return nil
Line 679 ⟶ 656:
-- Restituisce l'etichetta di un item o di una proprietà Wikidata.
function p._getLabel(args)
local entity = mw.wikibase.getEntity(args[1] and string.upper(args[1]), args.cache)
return entity and entity:getLabel(args[2])
end
Line 704 ⟶ 681:
end
 
entity = mw.wikibase.getEntity(property, args.cache)
if not entity then
error(i18n.errors['entity-not-found'], 2)