Aller au contenu

Module:Infobox/Catch (personnalité)

Une page de Wikipédia, l'encyclopédie libre.
Ceci est une version archivée de cette page, en date du 11 août 2017 à 21:45 et modifiée en dernier par Jérôme B. (discuter | contributions). Elle peut contenir des erreurs, des inexactitudes ou des contenus vandalisés non présents dans la version actuelle.

 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 Catch (personnalité).


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

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

local gender = getgender(item)

local words = {
	{'Catcheur ', 'mort', 'retraité'},
	{'Catheuse ', 'morte', 'retraitée'},
	{'Catcheure (ou Catcheuse) ', 'mort(e)', 'retraité(e)'},
}

local function header()
	local text
	
	if gender == 'm' then
		text = words[1]
	elseif gender == 'f' then
		text = words[2]
	else
		text = words[3]
	end
	
	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 function wd()
		return {
			property = 'P27',
			showdate = true,
			entity = item,
			conjtype = 'comma',
			removedupes = true,
			linktopic = '-',
			displayformat = 
				function(snak)
					local val, success = nation(wikidata.getid(snak), g)
					if not success then
						val = wikidata.formatSnak(snak)
					end
					return val
				end
		}
	end
		
	return {
		type = 'row',
		label = 'Nationalité',
		plurallabel = 'Nationalités',
		value = function(localdata)
			local val, success = nation(localdata['nationalité'], g)
			return val
		end,
		wikidata = wd()
	}	
end

return {
	maincolor = '#dfedff',
	parts = {
		general.title('catch'),
		general.mainimage('Article à illustrer Catch', 'Defaut 2.svg'),
		
		{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 = '[[Nom de scène|Nom de ring]]', plurallabel = '[[Nom de scène|Noms de ring]]', value = 'surnom', wikidata = {property = 'P1449', rank = 'valid', conjtype = 'new line'}},
				person.nationality(),
				person.birth(),
				person.death(),
				{type = 'row', label = 'Lieu de résidence', value = 'lieu de résidence', wikidata = {property = 'P551', showqualifiers = 'P131', numval = 1}},
				{type = 'row', label = '[[Taille (anthropométrie)|Taille]]', value = 'taille', wikidata = {property = 'P2048', targetunit = 'metre', rounding = '2', numval = 1}},
				{type = 'row', label = '[[Poids de forme|Poids]]', value = 'poids', wikidata = {property = 'P2067', targetunit = 'kilogram', rounding = '1', numval = 1}}
			}
		},
	
		{type = 'table', title = header(),
			rows = {
				{type = 'row', label = 'Fédération(s)', value = 'fédérations'},
				{type = 'row', label = 'Entraîneur(s)', singularlabel = 'Entraîneur', plurallabel = 'Entraîneurs', value = 'entraîneur', wikidata = {property = 'P286', conjtype = 'new line'}},
				{type = 'row', label = 'Carrière pro.',
					value = function(localdata)
						if localdata['début de carrière'] then
							if localdata['fin de carrière'] then
								return localdata['début de carrière'] .. ' - ' .. localdata['fin de carrière']
							else
								return localdata['début de carrière'] .. ' - <i>aujourd\'hui</i>'
							end
						end
					end
				}
			}
		}
	}
}