Module:Tableau des destinations

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

--[[ 	Source script:	https://fr.wikivoyage.org/wiki/Module:Tableau_des_destinations 	Maintainer:		Andyrom75 ]] local function _templateStyle( frame, src )    return frame:extensionTag( 'templatestyles', '', { src = src } ) end  local function _Tableau_des_destinations(frame) 	local args = frame.args 	-- Je transfère tous les paramètres numériques ou positionnels dans une nouvelle variable 	local keys = {} 	for k in pairs(args) do 		if tonumber(k) then 			table.insert(keys, tonumber(k)) 		end 	end 	table.sort(keys)  	local mode = args["mode"] or "avion" 	local titre_col3 = args["titre colonne 3"] or "" 	local nombreDeColonnes = args["titre colonne 3"] and 3 or 2 	local miseAJour = args["mise à jour"] 	local output = '' 	 	-- Titre de la première colonne 	local CompagnieType = { 		avion	= "Compagnie aérienne", 		bateau	= "Compagnie maritime", 		train	= "Compagnie ferroviaire", 		car		= "Compagnie routière", 	} 	local col1_title = CompagnieType[mode] -- "Compagnie aérienne" par défaut  	 	-- Inizio tabella 	local html = mw.html.create('table') 		:addClass('prettytable sortable Tableau-des-destinations') 	 	-- Titre 	local header = html:tag('tr'):addClass('Tableau-des-destinationsTitre') 	header:tag('th'):wikitext(col1_title) 	header:tag('th'):addClass('unsortable'):wikitext('Destinations') 	if titre_col3 ~= "" then 		header:tag('th'):addClass('Tableau-des-destinationsTitre3'):wikitext(titre_col3) 	end 	 	-- Lignes 	for i = 1, #keys, nombreDeColonnes do 		local v1, v2 = args[tostring(keys[i])], args[tostring(keys[i+1])] 		if v1 then 			local row = html:tag('tr') 			row:tag('td'):wikitext(v1) 			row:tag('td'):wikitext(v2 or "") 			if titre_col3 ~= "" then 				row:tag('td'):addClass('Tableau-des-destinationsColonne3'):wikitext(args[tostring(keys[i+2])] or " ") 			end 		end 	end 	output = tostring(html)  	if miseAJour and miseAJour ~= "" then 		local date = mw.getCurrentFrame():callParserFunction("#time", "M Y", miseAJour)  		-- Costruisci il contenuto 		local miseAJourHtml = mw.html.create('span') 		miseAJourHtml:wikitext('[[Fichier:Information icon4.svg|16px|Information]] ') 		miseAJourHtml:tag('small'):wikitext('dernière mise à jour : ' .. date) 			output = output .. tostring(miseAJourHtml) 	end 	    return _templateStyle( frame, 'Tableau des destinations/styles.css' ) .. output end  local p = {}  function p.Tableau_des_destinationsTemplate(frame) 	return _Tableau_des_destinations(frame:getParent()) end  function p.Tableau_des_destinationsInvoke(frame) 	return _Tableau_des_destinations(frame) end  function p.Tableau_des_destinationsModule(frame) 	local Cframe = mw.getCurrentFrame() 	Cframe.args = frame.args 	return _Tableau_des_destinations(Cframe) end  return p