Module:Infobox/Fonctions/Personne : Différence entre versions

De Lagny-sur-Marne Wiki
Aller à : navigation, rechercher
Ligne 39 : Ligne 39 :
 
value =
 
value =
 
function(localdata, item)
 
function(localdata, item)
local thedate = localdata['naissance'], localdata['lieu de naissance']
+
local thedate, theplace = localdata['naissance'], localdata['lieu de naissance']
 
if not thedate then
 
if not thedate then
 
thedate = wikidata._formatStatements({property= 'P569', rank = 'best', conjunction= ' ou '})
 
thedate = wikidata._formatStatements({property= 'P569', rank = 'best', conjunction= ' ou '})
Ligne 59 : Ligne 59 :
 
value =
 
value =
 
function(localdata, item)
 
function(localdata, item)
local thedate = localdata['naissance'], localdata['lieu de naissance']
+
local thedate, theplace = localdata['naissance'], localdata['lieu de naissance']
 
if not thedate then
 
if not thedate then
 
thedate = wikidata._formatStatements({property= 'P570', rank = 'best', conjunction= ' ou '})
 
thedate = wikidata._formatStatements({property= 'P570', rank = 'best', conjunction= ' ou '})

Version du 24 septembre 2014 à 16:22

La documentation pour ce module peut être créée à Module:Infobox/Fonctions/Personne/doc

-- 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 '[[Catégorie:Page utilisant des données de Wikidata/' .. prop .. ']]'
end
-- ========== Fonctions d'aide ====================================

local function dateandplace(thedate, theplace) 
	if thedate and theplace then
		return thedate .. '<br />' .. 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, theplace = 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, theplace = 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,
		property = 'P109',
		numval = 1
	}
end

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

return p