if success and uri.protocol and protocols[uri.protocol] then
local dest = tostring(uri)
return string.format('<spandiv style="word-break: break-all;">[%s %s]</spandiv>', dest, dest:gsub(uri.protocol .. '://', ''))
else
return url
local siteLink = mw.wikibase.getSitelink(entityId)
local ret
elseifif siteLink and label then ▼
if entityId == mw.wikibase.getEntityIdForCurrentPage() then
ret = siteLink
▲ elseif siteLink and label then
ret = mw.getContentLanguage():ucfirst(label) == siteLink and
string.format('[[%s]]', label) or
qualifiers = (n and n <= #qualifiers) and { qualifiers[n] } or {}
end
-- qualifierqualifiers filtrati per snaktype, default "value"
args.snaktype = args.snaktype or 'value'
for _, qualifier in ipairs(qualifiers) do
if statement == entityId then
return true
end
end
end
-- Se non è stato trovato alcun valore, controlla se questo sia ereditato
-- tramite la proprietà "sottoclasse di" (P279) scavando in profondità
-- fino all'esaurirsi del numero specificato in args.recursion.
--[[ TODO: Valutare se sia opportuna una ricerca ricorsiva potenzialmente infinita.
Per farlo si può aggiungere un parametro (opzionale) maxDepth
che svolga l'attuale funzione di recursion e cambiare quest'ultimo
in un parametro booleano.
]]
args.recursion = tonumber(args.recursion) or 0
if args.recursion > 0 then
local recursion = args.recursion
if type(args.loadedEntities) ~= 'table' then
args.loadedEntities = setmetatable({}, {
__newindex = function(t, k, v)
rawset(t, k, v)
rawset(t, #t+1, k)
end })
args.loadedEntities[args.from or mw.wikibase.getEntityIdForCurrentPage()] = true
end
for _, statement in ipairs(statements) do
if not args.loadedEntities[statement] then
args.loadedEntities[statement] = true
args.recursion = args.recursion - 1
args.from = statement
if p._propertyHasEntity('P279', args) then
return true, args.loadedEntities
end
args.recursion = recursion
end
end
end
return false, args.loadedEntities
end
return p._getLabel(getArgs(frame, { parentOnly = true }))
end, errhandler))
end
function p._getDescription(entity, lang, fallback)
if not entity then
return i18n('Nessuna descrizione')
end
if not lang then
lang = "it"
end
if type(entity) ~= 'table' and lang == defaultlang then
local description, lg = mw.wikibase.getDescriptionWithLang(entity)
if description and (fallback ~= '-' or lg == lang) then
return description
end
else
entity = p.getEntity(entity)
if entity and entity.descriptions then
if fallback ~= '-' then
for _, lg in ipairs(fb.fblist(lang, true)) do
if entity.descriptions[lg] then
return entity.descriptions[lg].value
end
end
else
if entity.descriptions[lang] then
return entity.descriptions[lang].value
end
end
end
end
return i18n('Nessuna descrizione')
end
return p._N(getArgs(frame, { parentOnly = true })) > 0 and 1 or ''
end, errhandler))
end
function p.getDescription(frame) -- simple for simple templates like {{Q|}}}
local entity = frame.args.entity
if not entity then
return i18n('invalid-id')
end
local lang = frame.args.lang
local fallback = frame.args.fallback
return p._getDescription(entity, lang, fallback)
end
|