Module:Infobox/Fonctions/Personne

De Lagny-sur-Marne Wiki
Version datée du 24 septembre 2014 à 15:26 par 0x010D (discussion | contributions) (cats pour Wikidata)
Aller à la navigation Aller à la recherche

-- Functions utilisées par les infobox personnes local p = {} local wikidata = require('Module:Wikidata') local general = require('Module:Infobox/Fonctions') local d = require('Module:Wikidata/Dates')

local function wikidatacat(prop) -- pour surveiller l'usage de Wikidata return end -- ========== Fonctions d'aide ====================================

local function dateandplace(thedate, theplace) if thedate and theplace then return thedate .. '
' .. theplace else return thedate or theplace --retourne tout ce qu'il trouve end end

--Titre function p.title() return { type = 'title', value = 'nom', class = 'entete icon humain', } end

--Image function p.mainimage() return general.mainimage() end

--Naissance, décès function p.birth() -- date de naissance en première ligne, lieu de naissance en deuxième return { type = 'mixed', label = 'Naissance', value = function(localdata, item) local thedate = localdata['naissance'], localdata['lieu de naissance'] if not thedate then thedate = wikidata._formatStatements({property= 'P569', rank = 'best', conjunction= ' ou '}) if thedate then thedate = thedate .. wikidatacat('P569') end end if not theplace then theplace = wikidata._formatStatements({property= 'P19', rank = 'best', conjunction= ' ou '}) if thedate then thedate = thedate .. wikidatacat('P19') end end return dateandplace(thedate, theplace) end } end

function p.death() -- même fonctionnement que la fonction p.birth return { type = 'mixed', label = 'Décès', value = function(localdata, item) local thedate = localdata['naissance'], localdata['lieu de naissance'] if not thedate then thedate = wikidata._formatStatements({property= 'P570', rank = 'best', conjunction= ' ou '}) if thedate then thedate = thedate .. wikidatacat('P570') end end if not theplace then theplace = wikidata._formatStatements({property= 'p20', rank = 'best', conjunction= ' ou '}) if thedate then thedate = thedate .. wikidatacat('P20') end end return dateandplace(thedate, theplace) end } end

function p.nationality() --pour l'instant, ne retourne que la valeur donnée par le paramètre nationalité, ou, à defaut, la propriété p570 de Wikidata, à retravailler pour le formatage. return { type = 'mixed', label = 'Nationalité', value = 'nationalité', property = 'P27' } end -- Influences function p.influencedby() return { type = 'mixed', label = 'Influencé par', value = 'influencé par', property = 'P737',

   }

end

function p.influenced() return { type = 'mixed', label = 'A influencé', value = 'a influencé', property = 'P738', } end

-- Signature function p.signature(default) return { type = 'images', imageparameters = {'signature'}, defaultimage = {default}, captionparameter = 'légende signature', defaultcaption = 'signature', defaultcaption = function() return defaultcaption end, wikidata = function() local val = wikidata.formatStatements({property = 'P109', first = 'true', returntype = 'table'}) if val then return val .. wikidatacat('P109') end end, -- Wikidata uniquement pour les images, pas la légende } end

--== Site web function p.website() return p.website() end

return p