Communauté  • Livre d'or
Chats noirs.jpg Actualités, astuces, interview... Venez lire la gazette de ce printemps de Vikidia ! DessinInterview.png
Cette page est semi-protégée.

Module:Système planétaire

Aller à la navigation Aller à la recherche
 Documentation[modifier] [purger]

Le module : Système planétaire sert à faire fonctionner le modèle : Système planétaire, voir sa documentation.

local p = {}

function p.Systeme( frame )
	local args = frame:getParent().args

	-- élaboration du titre du tableau
	local titre = 'Système '
                   .. mw.text.trim( args['système'] ~= '' and args['système'] or mw.title.getCurrentTitle().text )

	local source = args['source']
	if source and source ~= '' then
		titre = titre .. '<span style="font-weight:normal;">'
		              .. source
		              .. '</span>'
	end

	-- création du tableau
	local retour = mw.html.create( 'table' )
	retour = retour:addClass( 'wikitable' )
	               :css( 'margin', 'auto' )
	               :tag( 'caption' ):wikitext( titre ):done()
	               :tag( 'tr' ):tag( 'th' ):attr( 'scope', 'col' ):wikitext( 'Planète' ):done()
	                           :tag( 'th' ):attr( 'scope', 'col' ):wikitext( 'Masse à l’échelle de [[Jupiter (planète)|Jupiter]]' ):done()
	                           :tag( 'th' ):attr( 'scope', 'col' ):wikitext( '[[Période orbitale]] en [[jour]]s' ):done()
	                           :tag( 'th' ):attr( 'scope', 'col' ):wikitext( 'Découverte' ):done()
	               :done()

	local i = 1
	while args[i] do
		local ligne = mw.html.create( 'tr' )
		ligne:tag( 'td' ):wikitext( args[i] ):done()
		     :tag( 'td' ):wikitext( args['masse' .. tostring( i )] or '' ):done() 
		     :tag( 'td' ):wikitext( args['période' .. tostring( i )] or '' ):done() 
		     :tag( 'td' ):wikitext( args['découverte' .. tostring( i )] or '' ):done()
		retour = retour:node( ligne )
		i = i + 1
	end

	return tostring( retour )
end

return p