Aller au contenu

Module:Infobox/Gare

Une page de Wikipédia, l'encyclopédie libre.
Ceci est la version actuelle de cette page, en date du 5 juin 2023 à 01:14 et modifiée en dernier par Od1n (discuter | contributions) (utilisation du TemplateStyles Modèle:BS/styles.css, pour la classe "tablelignesferroviaires" ; remarquer que c'est désactivé, parce que la classe aussi est désactivée (refs 112903436) ; d'ailleurs, comme ça n'a jamais été utilisé, et que ça ne me semble pas être une bonne idée de mettre ça dans l'infobox, on pourrait envisager de simplement supprimer cela). L'URL présente est un lien permanent vers cette version.
(diff) ← Version précédente | Voir la version actuelle (diff) | Version suivante → (diff)

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


local building = require "Module:Infobox/Fonctions/Bâtiment"
local general = require "Module:Infobox/Fonctions"
local wikidata = require "Module:Wikidata"
local linguistic = require "Module:Linguistique"

return {
	maincolor = '#E0E0E0',
	parts = {
		general.title(),
		building.mainimage('Article à illustrer Gare', 'Defaut.svg'),
		{type = 'table', title = 'Localisation', rows = {
			{type = 'row', label = 'Pays', value = 'pays', property = 'P17'}, -- ne pas utiliser la fonction p.country pour ne pas afficher le drapeau
			building.adminlocation(),
			building.coordinates{
				wikidataquery = {property = 'P625', qualifier = 'P518', qualifiervalue = 'Q160342'}, -- en priorité : voies ferrées
				fallbackquery = {property = 'P625'}, -- sinon la première valeur de P625
			},
		}},
		{type = 'table', title = ' Gestion et exploitation', rows = {
			building.owner(),
			{type = 'row', label = 'Exploitant', value = 'exploitant', property = 'P137'},
			{type = 'row', label = function(localdata) return localdata['titre services'] or 'Services' end, value = 'services'},
		}},
		{type = 'table', title = 'Caractéristiques', rows = {
			{
				type = 'row',
				label = 'Ligne(s)',
				singularlabel = 'Ligne',
				plurallabel = 'Lignes',
				value = 'lignes',
				wikidata = { 
					property = 'P81',
					labelformat = function(entity)
						local label = mw.wikibase.label(entity)
						return linguistic.keepcomplement(label, "ligne") 
					end
				}
			},
			{type = 'row', label = 'Voies', value = 'voies'},
			{type = 'row', label = 'Quais', value = 'quais', property = 'P1103'}, -- P1103: nombre de quais
			{type = 'row', label = 'Transit annuel', value = 'transit'},
			{
				type = 'row',
				label = 'Zone',
				value = function(localdata)
					local rawstring = localdata['zone']
					if not rawstring then
						return nil
					end
					-- format du paramètre : "nom de la région/numméro de zone"
					local splitted = mw.text.split( rawstring, '/', true )
					if not splitted or #splitted < 1 then
						return rawstring
					end
					--Île de-France
					if splitted[1] == 'IDF' then
						local zone = tonumber(splitted[2] or '')
						if not zone or (zone > 8) then
							return '[[Tarification des transports en commun d\'Île-de-France|Tarification Île-de-France]] non applicable[[Category:Hors zone des transports en commun d\'Île-de-France]]'
						end
						return splitted[2] .. ' ([[tarification des transports en commun d\'Île-de-France|tarification Île-de-France]])'
					end
					return rawstring
				end
			},
			{
				type = 'row',
				label = 'Altitude',
				value = function(localdata)
					if localdata['altitude'] then
						return localdata['altitude'] .. ' m'
					end
				end
				},
			}
		},
		{type = 'table', title = 'Historique', rows = {
			{
				type = 'row',
				label = 'Mise en service',
				value = 'mise en service',
				wikidata = function(item)
					return wikidata.getTheDate{entity = item, property = 'P793', targetvalue = 'Q18123869'}
				end
			},
			{type = 'row', label = 'Ouverture', value = 'ouverture'}, -- à supprimer ?
			{type = 'row', label = 'Fermeture', value = 'fermeture'},
			building.creator(),
			building.protection(),
			}
		},
		{type = 'table', title = 'Correspondances', rows = {
			{type = 'row', label = function(localdata) return localdata['titre corresp 1'] or 'Correspondance' end, value = 'corresp 1'},
			{type = 'row', label = function(localdata) return localdata['titre corresp 2'] or 'Correspondance' end, value = 'corresp 2'},
			{type = 'row', label = function(localdata) return localdata['titre corresp 3'] or 'Correspondance' end, value = 'corresp 3'},
			{type = 'row', label = function(localdata) return localdata['titre corresp 4'] or 'Correspondance' end, value = 'corresp 4'},
			{type = 'row', label = function(localdata) return localdata['titre corresp 5'] or 'Correspondance' end, value = 'corresp 5'},
			{type = 'row', label = function(localdata) return localdata['titre corresp 6'] or 'Correspondance' end, value = 'corresp 6'},
			{type = 'row', label = function(localdata) return localdata['titre corresp 7'] or 'Correspondance' end, value = 'corresp 7'},
		}},
		{type = 'table', title = 'Schéma de ligne', rows = {
			{
				type = 'row',
	--			class = 'collapsible collapsed tablelignesferroviaires',
				value = function(localdata)
					local val = localdata['schéma']
					if val then
						-- local templatestyles = mw.getCurrentFrame():extensionTag( 'templatestyles', '', { src = 'BS/styles.css' } )
						-- return templatestyles .. '\n{|' .. val .. '\n|}'
						return '{|' .. val .. '\n|}'
					end
				end,
			}
		}},
		building.geoloc({marker='rail'}),
	}
}