Diferencia entre revisiones de «Módulo:Wikidata»

Comprobar si existe un calificador antes de filtrar
m Agregar opciones de personalización de valores en p.propiedad(); comentar código para revisión.
Línea 1047: Línea 1047:
opciones = {['linkback']='sí'}
opciones = {['linkback']='sí'}
end
end
--[[
local ValorPosicional = (function()
if opciones['valor_posicional'] == 'último' then return -1 end
if type(opciones['valor_posicional']) == 'number' then return opciones['valor_posicional'] end
return 1
end)()
local ValorPosicionalCalif =(function()
if opciones['valor_posicional_calif'] == 'último' then return -1 end
if type(opciones['valor_posicional_calif']) == 'number' then return opciones['valor_posicional_calif'] end
return 1
end)()
local Calificador = opciones['calificador']
local Obj = (function()
local Obj = (function()
local Obj = elementoTabla(entidad, 'claims', idPropiedad)
if ValorPosicional == -1 then return elementoTabla(Obj, #Obj) end
return elementoTabla(Obj, ValorPosicional)
end)()
if Calificador then
Obj = (function()
local Obj = elementoTabla(Obj, 'qualifiers', Calificador)
if ValorPosicionalCalif == -1 then return elementoTabla(Obj, #Obj) end
return elementoTabla(Obj, ValorPosicionalCalif)
end)()
end
return Obj
end)()
Tipo = elementoTabla(Obj, 'datavalue', 'type')
-- Devolver el ID de la entidad, para propiedades de entidad
if opciones['formato'] == 'entidadID' then
return elementoTabla(Obj, 'datavalue', 'value', 'id')
end
-- Preparar para devolver el archivo más reciente en la propiedad. Buscar cómo hacerlo con los calificadores
if opciones['formato'] == 'archivo' then
if Calificador then return elementoTabla(Obj, 'datavalue', 'value') end
if not opciones['uno'] then opciones['uno'] = 'último' end
opciones['ordenar'] = 'por fecha'
end
-- Obtener la propiedad como cadena sin formato
if opciones['formato'] == 'cadena' then
opciones['linkback'] = 'no'
if Tipo == 'string' then
return elementoTabla(Obj, 'datavalue', 'value')
end
end
-- Devolver una cadena numérica correctamente formateada
if opciones['formato'] == 'número' then
if Tipo == 'quantity' then
return formatoNumero(elementoTabla(Obj, 'datavalue', 'value', 'amount'))
end
end
-- Devolver una cadena numérica con su unidad
if opciones['formato'] == 'unidad' then
if elementoTabla(entidad, 'claims', idPropiedad, 2, 'mainsnak', 'datavalue') then
return formatoNumero(elementoTabla(entidad, 'claims', idPropiedad, 1, 'mainsnak', 'datavalue', 'value', 'amount')) .. ' - ' .. numeroUnidad(elementoTabla(entidad, 'claims', idPropiedad, 2, 'mainsnak', 'datavalue'), opciones)
else
return numeroUnidad(elementoTabla(entidad, 'claims', idPropiedad, 1, 'mainsnak', 'datavalue'), opciones)
end
end
--]]
opciones.entityId  = entidad.id
opciones.entityId  = entidad.id
opciones.propiedad = idPropiedad
opciones.propiedad = idPropiedad