Module:Infobox/Fonctions/Personne

De Wikipedia

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

-- Fonctions utilisées par les infobox personnes
local p = {}
local wikidata = require('Module:Wikidata')
local general = require('Module:Infobox/Fonctions')
local gender -- set by setgender

local i18n = {
	birth = 'Fānauraa',
	death = 'Poheraa',
	nationality = 'Tiàraa pātireia',
}


-- ========== 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


local function setgender(localdata, item) -- établit la valeur de la variable "gender" qui sert à adapter la grammaire au sexe de la personne
	if localdata['sexe'] or localdata['genre'] then
		gendertable = {f = 'f' , ['féminin'] = 'f', femme = 'f', homme = 'm', m = 'm', masculin = 'm'}
		gender = gendertable[(localdata['sexe'] or localdata['genre'])]
		if not gender then gender = '?' end
		return
	end
	local g = wikidata._formatStatements{item= item, property = 'P21', format = 'raw'}
	if g == 'Q6581072' then
		gender = 'f'
	elseif g == 'Q6581097' then
		gender = 'm'
	else
		gender = '?'
	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 = i18n.birth,
		value =
			function(localdata, item)
					local thedate, theplace = localdata['date de naissance'], localdata['lieu de naissance']
					if not thedate then
						thedate = wikidata._formatAndCat({item = item, property= 'P569', rank = 'best', conjtype= ' ou '})
					end
					if not theplace then
						theplace =  wikidata._formatAndCat({item = item, property= 'P19', rank = 'best', conjtype= ' ou '})
					end
					return dateandplace(thedate, theplace)
			end
	}
end

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

function p.polfunctions() -- à améliorer
	return {
		type = 'mixed',
		label = 'Fonctions',
		value = 'fonctions',
		property = 'P39'
	}
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 = i18n.nationality,
		value = 'nationalité',
		property = 'P27'
	}
end

-- parcours professionel
function p.education() -- à améliorer
	return {
		type = 'mixed',
		label = 'Formation',
		value = function(localdata) return locadata['éducation'] or localdata['formation'] end,
		wikidata = function(item) return wikidata._formatAndCat{item=item, property = 'P69', showdate = true, conjtype = '<br />'} end
	}
end

function p.awards() -- à améliorer
	return {
		type = 'mixed',
		label = 'Distinctions',
		value = 'prix',
		wikidata = function(item) return wikidata._formatAndCat{item = item, property= 'P166', sorttype= 'chronological' , showdate= true, conjtype= '<br />'} end,
	}
end


-- Influences 
function p.influencedby()
	return {
		type = 'mixed',
		label = 
		function(localdata, item) 
		if not gender then setgender(localdata, item) end
		if gender == 'f' then
			return 'Influencée par'
		elseif gender == 'm' then
			return 'Influencé par'
		else
			return 'Influencé(e) par'
		end
		end,
		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',
		property = 'P109',
		numval = 1
	}
end

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

return p