Module:Classement
local p = {} local formattingdata = mw.loadData('Module:Classement/Données') local wikidata = require('Module:Wikidata')
function p.formattedList(item) -- créé une liste des status patrimoniaux de l'élement --utilise Module:Classement/Données pour les abréviations, redirects et logos
local claims = wikidata.getClaims({item = item, property = 'P1435', exludespecial = true}) if not claims then return nil end
local statuses = {}-- nouvelle table pour ne pas afficher séparément deux statements décrivant le même statut for i, j in pairs(claims) do local pstatus = wikidata.getmainid(j) if not statuses[pstatus] then statuses[pstatus] = {j} else table.insert(statuses[pstatus], j) end end
local stringtable = {} -- liste des chaînes à retourner for i, j in pairs(statuses) do local mainstr = if formattingdata[i] then mainstr = formattingdata[i][1] else mainstr = wikidata.formatEntity(i) end local logostr = if formattingdata[i] and formattingdata[i][2] then logostr = '[[File:' .. formattingdata[i][2] .. '|x18px]] ' end
local t = {} -- informations complémentaires sur les dates et les parties concernées
for k, l in pairs(j) do
local protectiondate = wikidata.getFormattedQualifiers(l, {'P580'}, {precision = 'year'})
if protectiondate then
table.insert(t, protectiondate)
end
end
local details = table.concat(t, ", ")
if details ~= then
details = ' (' .. details .. ')'
else
details =
end
table.insert(stringtable, logostr .. mainstr .. details)
end
return table.concat(stringtable, '
') ..
end
return p