Module:Infobox/Combiné nordique 2

Une page de Wikipédia, l'encyclopédie libre.

 Documentation[voir] [modifier] [historique] [purger]

Cette page définit un module d'infobox. Pour les conseils sur l'usage de ce module, voyez Modèle:Infobox Combiné nordique 2.


local general = require 'Module:Infobox/Fonctions'
local localdata = require 'Module:Infobox/Localdata'
local wikidata = require 'Module:Wikidata'
local person = require 'Module:Infobox/Fonctions/Personne'

local function getgender()
	local vals = {
		['Q6581072'] = 'f',
		['Q6581097'] = 'm',
		default      = '?'
	}
	local gender = wikidata.formatStatements{entity = localdata.item, property = 'P21', displayformat = 'raw', numval = 1}
	return vals[gender] or vals.default
end

local gender = getgender()

local function header()
	local words = {
		['m'] = {'Coureur du combiné nordique ', 'mort', 'retraité'},
		['f'] = {'Coureuse du combiné nordique ', 'morte', 'retraitée'},
		['?'] = {'Coureur du combiné nordique ', 'mort', 'retraité'},
	}
	
	local text = words[gender]
	local death = localdata['date de décès'] or wikidata.formatStatements{entity = localdata.item, property = 'P570'}
	if death then
		return text[1] .. text[2]
	end
	
	if localdata['fin de carrière'] then
		return text[1] .. text[3]
	end
	
	return text[1] .. 'en activité'
end

local function nationality()
	local nation = require 'Module:Country data'.nationality
	
	local g = gender
	if g == '?' then
		g = 'm'
	end
	
	local wd = {
		entity = item,
		property = 'P27',
		conjtype = 'new line',
		displayformat = 
			function(snak)
				local nationality, success = nation(wikidata.getId(snak), g)
				if not success then
					return wikidata.formatSnak(snak)
				end
				
				return nationality
			end
	}
	
	local value = function(localdata)
		if not localdata['nationalité'] then
			return nil
		end
		
		local nationality, success = nation(localdata['nationalité'], g)
		if not success then
			return nil
		end
		
		if not localdata['nationalité2'] then
			return nationality
		end
		
		local nationality2, success = nation(localdata['nationalité2'], g)
		if not success then
			return nationality
		end
		
		return nationality .. '<br>' .. nationality2
	end
		
	return {type = 'row', label = "Nationalité", singularlabel = 'Nationalité', plurallabel = 'Nationalités', value = value, wikidata = wd}	
end

local function height()
	local wd = {
		entity = item,
		property = 'P2048',
		displayformat =
			function(snak)
				return wikidata.getDataValue(snak, {targetunit = 'metre', rounding = 2, showlink = true}) .. ' (' .. wikidata.getDataValue(snak, {targetunit = 'foot', rounding = 2, showlink = true}) .. ')'
			end,
		numval = 1
	}
	
	local value = function(localdata)
		if not localdata['taille'] then
			return nil
		end
		
		local convert = require 'Module:Conversion'.displayvalue
		local metre = convert(localdata['taille'], 'metre', {showunit = true, rounding = 2, showlink = true})
		local foot = convert(localdata['taille'], 'metre', {targetunit = 'foot', showunit = true, rounding = 2, showlink = true})
		if metre == foot then
			return metre
		end
		
		return metre .. ' (' .. foot .. ')'
	end
	
	return {type = 'row', label = '[[Taille (anthropométrie)|Taille]]', value = value, wikidata = wd}
end

local function weight()
	local wd = {
		entity = item,
		property = 'P2067',
		displayformat =
			function(snak)
				return wikidata.getDataValue(snak, {targetunit = 'kilogram', rounding = 0, showlink = true}) .. ' (' .. wikidata.getDataValue(snak, {targetunit = 'pound', rounding = 0, showlink = true}) .. ')'
			end,
		numval = 1
	}
	
	local value = function(localdata)
		if not localdata['poids'] then
			return nil
		end
		
		local convert = require 'Module:Conversion'.displayvalue
		local kilogram = convert(localdata['poids'], 'kilogram', {showunit = true, rounding = 0, showlink = true})
		local pound = convert(localdata['poids'], 'kilogram', {targetunit = 'pound', showunit = true, rounding = 0, showlink = true})
		if kilogram == pound then
			return kilogram
		end
		
		return kilogram .. ' (' .. pound .. ')'
	end
	
	return {type = 'row', label = '[[Poids de forme|Poids]]', value = value, wikidata = wd}
end

return {
	maincolor = '#dfedff',
	parts = {
		general.title('combiné nordique 2'),
		general.mainimage('Article à illustrer Combiné nordique', 'Defaut 2.svg'),
		{type = 'table', title = 'Contexte général',
			rows = {		
			{type = 'row', label = 'Sport', singularlabel = 'Sport', plurallabel = 'Sports', value = 'Sport', wikidata = {property = 'P641', conjtype = 'new line'}}
			}
			}
		,	
		{type = 'table', title = 'Données générales',
			rows = {
				{type = 'row', label = 'Nom de naissance', value = 'nom de naissance', wikidata = {property = 'P1477', numval = 1}},
				{type = 'row', label = 'Surnom', singularlabel = 'Surnom', plurallabel = 'Surnoms', value = 'Surnom', wikidata = {property = 'P1449', conjtype = 'new line'}},
				{type = 'row', label = 'Formation', singularlabel = 'Formation', plurallabel = 'Formations', value = 'Formation', wikidata = {property = 'P69', conjtype = 'new line'}},
				person.awards(),
				{type = 'row', label = 'Club', singularlabel = 'Club', plurallabel = 'Clubs', value = 'Club', wikidata = {property = 'P54', conjtype = 'new line'}},
		     	person.family(),
				{type = 'row', label = 'Entraineur', singularlabel = 'Entraineur', plurallabel = 'Entraineurs', value = 'Entraineur', wikidata = {property = 'P286', conjtype = 'new line'}},
				nationality(),
				person.birth(),
				person.death(),
				}
		    	}
			,
{type = 'table', title='Autres informations', rows = {
			person.website(),
			{type = 'row', label = 'Lieu de sépulture', singularlabel = 'Lieu de sépulture', plurallabel = 'Lieux de sépulture', value = 'Lieu de sépulture', wikidata = {property = 'P119', conjtype = 'new line'}},
		}},
		person.signature(),
		person.plaque(),
		person.tombe(),
}
}