« Module:Classement » : différence entre les versions
Apparence
Modèle:Infobox>Zolo Aucun résumé des modifications |
Modèle:Infobox>Zolo Aucun résumé des modifications |
||
| Ligne 7 : | Ligne 7 : | ||
--utilise Module:Classement/Données pour les abréviations, redirects et logos | --utilise Module:Classement/Données pour les abréviations, redirects et logos | ||
local claims = wikidata.getClaims({ | local claims = wikidata.getClaims({entity = item, property = 'P1435', exludespecial = true}) | ||
if not claims then | if not claims then | ||
return nil | return nil | ||
| Ligne 50 : | Ligne 50 : | ||
table.insert(stringtable, logostr .. mainstr .. details) | table.insert(stringtable, logostr .. mainstr .. details) | ||
end | end | ||
local val = table.concat(stringtable, '<br />') .. wikidata.addtrackingcat('P1435') | |||
return wikidata.addLinkback(val, item, 'P1435') | |||
end | end | ||
return p | return p | ||
Version du 10 mars 2015 à 16:38
La documentation pour ce module peut être créée à Module:Classement/doc
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({entity = 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 = ' <small>(' .. details .. ')</small>'
else
details = ''
end
table.insert(stringtable, logostr .. mainstr .. details)
end
local val = table.concat(stringtable, '<br />') .. wikidata.addtrackingcat('P1435')
return wikidata.addLinkback(val, item, 'P1435')
end
return p