Module:Infobox/Stade

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 Stade.


local building = require "Module:Infobox/Fonctions/Bâtiment"
local general = require "Module:Infobox/Fonctions"
local wd = require "Module:Wikidata"
local address = require "Module:Adresse"
local localdata = require "Module:Infobox/Localdata"

local formats = {
	--{icône carte, icône entete, couleur titre, couleur sous-titre, couleur texte)
	Q37025296 = {'pitch', 'athlétisme', '#D7877B', 'defaut', 'defaut', 'defaut'}, -- stade d'athlétisme
	Q2488656 = {'tennis', 'badminton', '#FFBFC2', 'defaut', 'defaut', 'defaut'}, -- court de badminton
	Q595452 = {'baseball', 'baseball', '#408080', 'defaut', '#FFFFFF', 'defaut'}, -- stade de baseball
	Q682943 = {'cricket', 'cricket', '#F5F5DC', 'defaut', 'defaut', 'defaut'}, -- terrain de cricket
	Q1154710 = {'soccer', 'football', '#99CC99', 'defaut', 'defaut', 'defaut'}, -- stade de football
	Q1048525 = {'golf', 'golf', '#99CC99', 'defaut', '#FFFFFF', 'defaut'}, -- terrain de golf
	Q1501 = {'swimming', 'defaut', '#318CE7', 'defaut', '#FFFFFF', 'defaut'}, -- piscine
	Q130003 = {'skiing', 'defaut', '#DFEDFF', 'defaut', 'defaut', 'defaut'}, -- station de sports d'hiver
	Q741118 = {'tennis', 'tennis', '#FFAA77', 'defaut', 'defaut', 'defaut'}, -- court de tennis
	Q830528 = {'bicycle-share', 'defaut', '#FFDF80', 'defaut', 'defaut', 'defaut'}, -- vélodrome
	default = {'stadium', nil, '#EFEFEF', 'defaut', 'defaut', 'defaut'}
}

local function wdformat() --retourne une table contenant la couleur principale de l'infobox et l'icône de titre
	local wtypes = wd.stringTable{ -- récupère les Qid des professions
		entity = localdata.item,
		property = 'P31',
		displayformat = 'raw',
		excludespecial = true
	}
	local default = formats.default
	wtypes = wd.addVals(wtypes or {}, {property = 'P279'}, 1) -- on utilise en plus les sous-classe
	for i, item in pairs(wtypes or {}) do
		if formats[item] then
			return formats[item]
		end
	end
	return default
end
local function setcharte()
	local charte = localdata['charte']
	if charte then
		for i, j in pairs(formats) do
			if j[2] == charte then
				return j
			end
		end
	end
	return wdformat()
end

local displayformat = setcharte()

return 
	{
	maincolor = displayformat[3],
	secondcolor = displayformat[4],
	thirdcolor = displayformat[5],
	parts = {
		
		general.title(),
		general.logo(),
		building.mainimage('Article à illustrer Stade'),
		{type = 'table', title = 'Généralités', rows = {
			{type = 'mixed', label = 'Noms précédents', value = 'noms précédents'},
			{type = 'mixed', label = 'Surnom', value = 'surnom'},
			{type = 'mixed', label = 'Nom complet', value = 'nom complet'},
			{type = 'mixed', label = 'Adresse', value = 'adresse', wikidata = function ( item ) return address.fullAddress(item) end}
		}},
	
		{type = 'table', title = "Construction et ouverture", rows = {
			building.construction(),
			building.opening(),
					
			building.creator(),
			building.renovation(),
			{type = 'mixed', label = 'Coût de construction', value = 'cout construction'},
			building.closure(),
			building.demolition(),
		}},
	
		{type = 'table', title = 'Utilisation', rows = {
			{type = 'mixed', label = 'Clubs résidents', value = 'clubs résidents', property = 'P466'},
			{type = 'mixed', label = 'Propriétaire', value = 'propriétaire', property = 'P127'},
			{type = 'mixed', label = 'Administration', value = 'administration', property = 'P137'},
		}},
	
		{type = 'table', title = 'Équipement', rows = {
			{type = 'mixed', label = 'Surface', value = 'surface', property = 'P765'},
			{type = 'mixed', label = 'Capacité', value = 'capacité'}, -- , property = 'P1083' mais voir les qualificatifs à utiliser pour éviter les trucs bizarres
			{type = 'mixed', label = 'Tribunes', value = 'tribunes'},
			{type = 'mixed', label = 'Affluence record', value = 'affluence_record'},
			{type = 'mixed', label = 'Dimensions', value = 'dimensions'},
			building.protection()
		}},
	
		{type = 'table', title = 'Localisation', rows = {
			building.protectedarea(),
			building.coordinates(),
		}},
	
		building.geoloc({marker=displayformat[1], default_zoom=11}),
	}
}