Modulo:Tassobox

Modulo a supporto del template {{Tassobox}}.

Modulo:Tassobox
Info Istruzioni per l'uso
Questo è un modulo scritto in Lua. Le istruzioni che seguono sono contenute nella sottopagina Modulo:Tassobox/man (modifica · cronologia)
Sandbox: Modulo:Tassobox/sandbox (modifica · cronologia) · Sottopagine: lista · Test: Modulo:Tassobox/test

Modulo a supporto del template {{Tassobox}}.

Ha una sottopagina di configurazione: Modulo:Tassobox/Configurazione.



--[[  
Questo modulo è in appoggio al template Tassobox 
]]

local p = {}
local cfg = mw.loadData("Modulo:Tassobox/Configurazione")
local getArgs = require('Module:Arguments').getArgs

local function check_value(valore)
	return valore and cfg.missing_table[mw.ustring.lower(valore)]
end

--===================================================================
-- Richiamo di un'immagine di file mancante appropriata al 
-- regno/phylum/classe/ordine/ecc della voce in cui è inserito
-- il tassobox
--===================================================================
function p.missing_image(frame)
	local args = getArgs(frame, {wrapper = 'Template:Tassobox'})
	local missing_link
	-- testa in ordine dal più specifico al più generico la classificazione di un essere vivente
	for _,test in ipairs(cfg.param_to_check) do
		missing_link = args[test] and check_value(args[test])
		if missing_link then break end
	end 
	-- se ha non trovato il valore nella tabella ricade nell'immagine di default
	missing_link = missing_link or "File:Unknown missing 1.png"
	return mw.ustring.format('[[%s|220px|Immagine di %s mancante|class=skin-invert itwiki-preserve-color]]', missing_link,  mw.title.getCurrentTitle().text)
end

----------------------------------------------------------------------------------
-- Ritorna la configurazione della tabella per le ere geologiche
----------------------------------------------------------------------------------
function p.ere_geologiche_table(frame)
-- Restituisce una tabella delle ere geologiche presenti in configurazione
 
	local root = mw.html.create('table')
	root
		:addClass('wikitable sortable')
		:tag('tr')
			:tag('th'):wikitext('Era'):done()
			:tag('th'):wikitext('Inizio'):done()
			:tag('th'):wikitext('Successiva'):done()
			:tag('th'):wikitext('Colore'):done()
	for name, values in pairs(cfg.ere_geologiche) do
		local start = values['start'] or "?"
		local next_era = values['next_era'] or "?"
		local color 
		if values['color'] then 
			color = mw.html.create('span')
				:cssText("display:inline-block;border:solid grey 1px;width:1em;height:1em")
				:css('background', values['color'])
				:wikitext(' ')
		else
			color = mw.html.create('span'):done()
		end
		root:tag('tr')
			:tag('td'):wikitext(name):done()
			:tag('td'):css('text-align', 'right'):wikitext(start):done()
			:tag('td'):wikitext(next_era):done()
			:tag('td'):css('text-align', 'center'):node(color)
	end
	return tostring(root)
end

--===================================================================
-- Genera lo stato di conservazione di uno specie
--===================================================================
function p.stato_conservazione(frame)

	local args = getArgs(frame, {wrapper = 'template:Tassobox'})
	local statocons = args.statocons
	if statocons == nil then return end
	local iucn =  { ['iucn2.3'] = true, ['iucn3.1'] = true}
	statocons = mw.ustring.lower(statocons)
	statocons = cfg.stato_alias[statocons] or statocons
	local row_stato = cfg.stato[statocons]
	if row_stato == nil then 
		local cat_error = ''
		if mw.title.getCurrentTitle().namespace == 0 then
			cat_error = '[[Categoria:Errori di compilazione del template Tassobox]]'
		end
		return '<strong class=\"error\">Parametro statocons non valido</div>' .. cat_error 
	end
	local immagine = ''
	if row_stato.image then
		if row_stato.versione then 
			local versione = args.statocons_versione or ''
			versione = (iucn[versione] and versione) or (statocons == 'ex' and 'none') or 'iucn3.1'
			if versione == 'none' then 
				immagine = 'Status_none_EX.svg'
			else
				immagine = mw.ustring.format(row_stato.image, versione)
			end
		else
			immagine = row_stato.image
		end
		immagine = '<div>\[\[Image:' .. immagine .. '|200px\]\]</div>'
	end
	local ref = args.statocons_ref
	ref = (ref and  '<span style=font-size:80%>' .. ref .. '</span>') or '' 
	local dataestinzione = ''
	if row_stato.data then
		dataestinzione = (row_stato.pre_data and ' ' .. row_stato.pre_data) or dataestinzione
		dataestinzione = (args.dataestinzione and mw.ustring.format(row_stato.data, args.dataestinzione)) or dataestinzione
		dataestinzione = mw.ustring.format('<span style="color:%s;">%s</span>', row_stato.color_data or row_stato.color, dataestinzione)
	end
	local base_msg = 
'<div style="margin:0 auto; text-align:center;%s" class="skin-invert itwiki-preserve-color">'..
	'%s<div style="color:%s;font-weight:bold;">%s%s%s</div>' ..
'</div>'
	return mw.ustring.format(base_msg, ((immagine and 'background:white;') or ''), immagine, row_stato.color, row_stato.text, dataestinzione, ref)
end

return p

Content Disclaimer

Informasi ini disarikan dari Wikipedia dan disajikan kembali untuk tujuan edukasi. Konten tersedia di bawah lisensi CC BY-SA 3.0. Kami tidak bertanggung jawab atas ketidakakuratan data yang bersumber dari kontribusi publik tersebut.

  1. The information displayed on this website is sourced in part or in whole from Wikipedia and has been adapted for the purpose of restating it. We strive to provide accurate and relevant information, however:
  2. There is no guarantee of absolute accuracy. Wikipedia is an open, collaborative project that can be edited by anyone, so information is subject to change.
  3. It is not intended to constitute professional advice. The content displayed is for informational and educational purposes only. For important decisions (e.g., medical, legal, or financial), please consult a professional.
  4. Content copyright. Wikipedia is licensed under the Creative Commons Attribution-ShareAlike License (CC BY-SA). This means that content may be reused with appropriate attribution and shared under a similar license.
  5. Responsible use. Any risk arising from the use of information from this website is entirely the responsibility of the user.