« Module:Infobox/Fonctions/Personne » : différence entre les versions

Contenu supprimé Contenu ajouté
Zebulon84 (discuter | contributions)
interface wikidata → wikidata
Zolo (discuter | contributions)
p.death : meilleure articulation wikipédia / wikidata et disparition / décès, fonctions : à partir de->depuis quand la personne n'est pas morte
Ligne 84 :
local unknowndatelabel = "date inconnue"
local birthdate = localdata['naissance'] or localdata['date de naissance'] or wikidatadate('P569', {unknownlabel = unknowndatelabel})
local deathdate = localdata['décès'] or localdata['date de décès'] or wikidatadate('P570', {unknownlabel =unknowndatelabel })
 
local dead = wikidata.getClaims{entity = item, property = 'P570'} --utilisé comme booléen qui dit si une personne est morte pour modifier certaines élément d'affichage
local deathdate = localdata['décès'] or localdata['date de décès'] or wikidatadate('P570', {unknownlabel =unknowndatelabel })
deathdatelocal wddeathdate = wikidatadate('P570', {unknownlabel = unknowndatelabel , minprecision = 9})
 
local function format1(event, period, predecessor, successor, displayformat)
Ligne 186 ⟶ 188 :
wdconf.labelformat = wdconf.labelformat or function(id) return genderedlabel(id) end
wdconf.linktopic = wdconf.linktopic or "-"
wdconf.stilltrue = not(deathdate) dead -- si la personne est vivante, on emploie "depuis" plutôt que "à partir de" (mais lorsque c'est fini mais que la date de fin manque, ça devient faux)
 
local statements = wikidata.getClaims(wdconf)
Ligne 207 ⟶ 209 :
local predecessor = wikidata.getFormattedQualifiers(statement, {'P155', 'P1365'})
local successor = wikidata.getFormattedQualifiers(statement, {'P156', 'P1366'})
local period = wikidata.getFormattedDate(statement, {linktopic = wdconf.linktopic, stilltrue = not dead } ) -- dont pass all wdconf or else qualifiers will show up
local detailstr
if type(details) == "function" then
Ligne 312 ⟶ 314 :
value =
function()
local thedate = datemodule.dateInfobox{args = {[1] = 'naissance', [2] = birthdate or '', [3] = deathdate or wddeathdate or '', qualificatif = linktopic}}
local theplace = localdata['lieu de naissance'] or wikidata.formatAndCat({entity =item, property= 'P19', rank = 'best', conjtype= ' ou ', unknownlabel = "lieu inconnu"})
return dateandplace(thedate, theplace)
Ligne 321 ⟶ 323 :
function p.death() -- même fonctionnement que la fonction p.birth
--- récup de Wikidata seulement en l'absence de données locales
local label = "Décès"
local ddate = deathdate --déclarée pour l'ensemble du module
 
if (not ddate) and (not localdata['disparition']) then
local val
deathdate = wddeathdate
local thedate, theplace
local disparitiondate
 
-- date
--- récup données locales
disparitiondate = localdata["disparition"]
 
--- récup Wikidata
if not (disparitiondate or deathdate) then
disparitiondate = wikidata.formatAndCat{entity = item, property = "P746", rank = 'best', conjtype= ' ou '}
if not disparitiondate then
deathdate = wikidatadate('P570', {unknownlabel = unknowndatelabel })
end
end
thedate = datemodule.dateInfobox{args = {[1] = 'mort', [2] = birthdate or '', [3] = deathdate or disparitiondate or '', qualificatif = linktopic, unknownlabel = "date inconnue"}}
 
--- mise en forme
thedate = datemodule.dateInfobox{args = {[1] = 'mort', [2] = birthdate or '', [3] = deathdate or disparitiondate or '', qualificatif = linktopic, unknownlabel = "date inconnue"}}
 
-- lieu
theplace = localdata["lieu de décès"] or wikidata.formatAndCat{entity = item, property= 'P20', rank = 'best', conjtype= ' ou ', unknownlabel = "lieu inconnu"}
 
 
-- Adaptations si on a la date de disparition à la place de la date de décès
if disparitiondate then
if theplace then -- cas un peu bizarre et pas très logique, ne vaut pas trop la peine d'un affichage plus élaboré
disparitiondate = "Date de disparition : " .. thedate
theplace = "Lieu de décès : " .. theplace
else
label = "Disparition"
end
end
 
 
val = dateandplace(thedate, theplace)
 
return {
{type = 'multi', rows = {
{ -- disparition
type = 'row',
label = "'Disparition"',
ifvalue not= function() return disparitiondate thenend
},
{ -- décès
type = 'row',
label = label,
value = function() return val end,
}
}}
end
 
Ligne 1 245 ⟶ 1 227 :
textformat = 'long',
precision = 'year',
stilltrue = (not deathdate)dead,
}
},
Ligne 1 260 ⟶ 1 242 :
textformat = 'long',
precision = 'year',
stilltrue = (not deathdate)dead,
precision = 'year',
}
Ligne 1 275 ⟶ 1 257 :
textformat = 'long',
precision = 'year',
stilltrue = (not deathdatedead),
precision = 'year',
}