Modulo:Tabs: differenze tra le versioni

Da Wikizionario, il dizionario a contenuto aperto.
Contenuto cancellato Contenuto aggiunto
Nascondo il pulsante per la creazione rapida, perché rischia di essere incompreso
Test
Etichetta: Annullato
Riga 59: Riga 59:


--Categorizzazione forme semplici
--Categorizzazione forme semplici
if titleExists(masc) == false then
if titleExists(masc) then
categoriaMasc = ''..categorizza('Lemmi con forma maschile da scrivere')
else
categoriaMasc = ''
categoriaMasc = ''
else
categoriaMasc = ''..categorizza('Lemmi con forma maschile da scrivere')
end
end
if titleExists(mascPl) == false then
if titleExists(mascPl) then
categoriaMascPl = ''..categorizza('Lemmi con forma maschile plurale da scrivere')
else
categoriaMascPl = ''
categoriaMascPl = ''
else
categoriaMascPl = ''..categorizza('Lemmi con forma maschile plurale da scrivere')
end
end
if titleExists(fem) == false then
if titleExists(fem) then
categoriaFem = ''..categorizza('Lemmi con forma femminile da scrivere')
else
categoriaFem = ''
categoriaFem = ''
else
categoriaFem = ''..categorizza('Lemmi con forma femminile da scrivere')
end
end
if titleExists(femPl) == false then
if titleExists(femPl) then
categoriaFemPl = ''..categorizza('Lemmi con forma femminile plurale da scrivere')
else
categoriaFemPl = ''
categoriaFemPl = ''
else
categoriaFemPl = ''..categorizza('Lemmi con forma femminile plurale da scrivere')
end
end
-- Categorizzazione forme alternative
-- Categorizzazione forme alternative
if titleExists(masc2) == false then
if titleExists(masc2) then
categoriaMasc2 = ''..categorizza('Lemmi con forma maschile alternativa da scrivere')
else
categoriaMasc2 = ''
categoriaMasc2 = ''
else
categoriaMasc2 = ''..categorizza('Lemmi con forma maschile alternativa da scrivere')
end
end
if titleExists(mascPl2) == false then
if titleExists(mascPl2) then
categoriaMascPl2 = ''..categorizza('Lemmi con forma maschile plurale alternativa da scrivere')
else
categoriaMascPl2 = ''
categoriaMascPl2 = ''
else
categoriaMascPl2 = ''..categorizza('Lemmi con forma maschile plurale alternativa da scrivere')
end
end
if titleExists(fem2) == false then
if titleExists(fem2) then
categoriaFem2 = ''..categorizza('Lemmi con forma femminile alternativa da scrivere')
else
categoriaFem2 = ''
categoriaFem2 = ''
else
categoriaFem2 = ''..categorizza('Lemmi con forma femminile alternativa da scrivere')
end
end
if titleExists(femPl2) == false then
if titleExists(femPl2) then
categoriaFemPl2 = ''..categorizza('Lemmi con forma femminile plurale alternativa da scrivere')
else
categoriaFemPl2 = ''
categoriaFemPl2 = ''
else
categoriaFemPl2 = ''..categorizza('Lemmi con forma femminile plurale alternativa da scrivere')
end
end
return ''..categoriaMasc..''..categoriaMasc2..''..categoriaMascPl..''..categoriaMascPl2..''..categoriaFem..''..categoriaFem2..''..categoriaFemPl..''..categoriaFemPl2
return ''..categoriaMasc..''..categoriaMasc2..''..categoriaMascPl..''..categoriaMascPl2..''..categoriaFem..''..categoriaFem2..''..categoriaFemPl..''..categoriaFemPl2

Versione delle 18:59, 22 set 2021

Questo modulo è stato scritto per implementare le funzioni presente nel {{Tabs}}, perciò il suo funzionamento è strettamente legato alla necessità di suddetto template.

Funzioni interne

Questo modulo si avvale di funzioni interne:

  1. categorizzazione: La gestione di quando un lemma deve essere categorizzato o meno;
  2. categorizza: La funzione che aggiunge materialmente la funzione;
  3. titleExists: La funzione che valuta se una pagina esiste o meno;
  4. tabs: La funzione principale che crea la tabella e ordina funzioni e variabili.

Funzione esterna

Questo modulo, sfrutta la funzione Differenze del Modulo:FormeFlesse per gestire la parte delle desinenze, relative allo script per scrivere le forme flesse, tramite la funzione FFLink.Differenze richiamata con la variabile "differenze".

Variabili

Variabile Valore di riferimento Valore del template
masc arg.m
arg[1]
Link al lemma maschile singolare
mascPl arg.mp
arg[2]
Link al lemma maschile plurale
fem arg.f
arg[3]
Link al lemma femminile singolare
femPl arg.fp
arg[4]
Link al lemma femminile plurale
masc2 arg.m2 Link al lemma maschile singolare
(Forma alternativa)
mascPl2 arg.mp2 Link al lemma maschile plurale
(Forma alternativa)
fem2 arg.f2 Link al lemma femminile singolare
(Forma alternativa)
femPl2 arg.fp2 Link al lemma femminile plurale
(Forma alternativa)

Categorizzazioni

categorie dei lemmi da scrivere

Il modulo è anche in grado di categorizzare i lemmi se all'interno della tabella ci sono delle forme flesse da scrivere, le categorie sono:

Forma alternative

Manutenzione

In caso un campo del template sia stato lasciato vuoto, oltre l'avviso a comparsa nel lemma, il modulo categorizzerà la pagine in Categoria:Template per le forme flesse senza informazioni

Dipendenze

Questo modulo sfrutta il Modulo:FormeFlesse per gestire la parte delle desinenze, relative allo script per scrivere le forme flesse


-- Moduli necessari
local getArgs = require('Modulo:Arguments').getArgs -- carica i valori dei parametri
local FFLink = require('Modulo:FormeFlesse') -- carica la funzione per le desinenze delle forme flesse

-- Funzione della categorizzazione
local function categorizza(cat)
	return string.format('[[%s:%s]]', mw.site.namespaces[14].name, cat)
end

-- funzione per rilevare se una determinata pagina esiste o no
local function titleExists(pagina)
	local title = mw.title.new(pagina)
	return title and title.exists
end


local p = {}

function p.Tabs(frame)
local arg = getArgs(frame)
-- variabile a me sconosciuta ma che comunque nel template c'è, io ce la metto
-- credo sia un titolo, e io la chiamo titolo, poi vediamo...
local titolo = arg[5] or ' '

--Forme base
local masc = arg.m or arg[1] 
local mascPl = arg.mp or arg[2] 
local fem = arg.f or arg[3] 
local femPl = arg.fp or arg[4]

-- Forme alternative
local masc2 = arg.m2 or ''
local mascPl2 = arg.mp2  or ''
local fem2 = arg.f2 or ''
local femPl2 = arg.fp2 or ''

-- Gestione per mostrare o meno le forme alternative
if masc2 ~= '' then masc2Insert = '/ [[' .. masc2 .. ']]' else masc2Insert = '' end
if mascPl2 ~= '' then mascPl2Insert = '/ [[' .. mascPl2 .. ']]' else mascPl2Insert = '' end
if fem2 ~= '' then fem2Insert = '/ [[' .. fem2 .. ']]' else fem2Insert = '' end
if femPl2 ~= '' then femPl2Insert = '/ [[' .. femPl2 .. ']]' else femPl2Insert = '' end

-- Funzione per separare le desinenze, fondamentale per l'autocompilazione della pagina [[Speciale:FormeFlesse]]
-- Usa la funzione "differenze" del [[Modulo:FormeFlesse]]

-- IF per controllare che tutti i parametri minimi siano stati scritti
if masc == nil or mascPl == nil or fem == nil or femPl == nil then
	modifica = ' ['..mw.title.getCurrentTitle():fullUrl{action = 'edit'}..' correggi il template]'
	ErrVuoti ='<strong class="error plainlinks">Uno o più parametri del {{[[Template:Tabs|Tabs]]}} sono stati lasciati vuoti, '..modifica..'</strong>'
	return ErrVuoti..''..categorizza('Template per le forme flesse senza informazioni')
else
	
	local differenze =  FFLink.Differenze(arg)
	local function categorizzazione (frame)

--[=[###########################################################################
							 GESTIONE DELLA CATEGORIZZAZIONE
#############################################################################]=]

--Categorizzazione forme semplici
	if titleExists(masc) then
				categoriaMasc = ''
			else 
				categoriaMasc = ''..categorizza('Lemmi con forma maschile da scrivere')
			end	
			
	if titleExists(mascPl) then
				categoriaMascPl = ''
			else 
				categoriaMascPl = ''..categorizza('Lemmi con forma maschile plurale da scrivere')
			end	
			
	if titleExists(fem) then
				categoriaFem = ''
			else 
				categoriaFem = ''..categorizza('Lemmi con forma femminile da scrivere')
			end	
			
	if titleExists(femPl) then
				categoriaFemPl = ''
			else 
				categoriaFemPl = ''..categorizza('Lemmi con forma femminile plurale da scrivere')
			end	
			
	
-- Categorizzazione forme alternative	
	if titleExists(masc2) then
				categoriaMasc2 = ''
			else 
				categoriaMasc2 = ''..categorizza('Lemmi con forma maschile alternativa da scrivere')
			end	
			
	if titleExists(mascPl2) then
				categoriaMascPl2 = ''
			else 
				categoriaMascPl2 = ''..categorizza('Lemmi con forma maschile plurale alternativa da scrivere')
			end	
			
	if titleExists(fem2) then
				categoriaFem2 = ''
			else 
				categoriaFem2 = ''..categorizza('Lemmi con forma femminile alternativa da scrivere')
			end	
			
	if titleExists(femPl2) then
				categoriaFemPl2 = ''
			else 
				categoriaFemPl2 = ''..categorizza('Lemmi con forma femminile plurale alternativa da scrivere')
			end	
		return		''..categoriaMasc..''..categoriaMasc2..''..categoriaMascPl..''..categoriaMascPl2..''..categoriaFem..''..categoriaFem2..''..categoriaFemPl..''..categoriaFemPl2
	end	

--[=[###########################################################################
							 CREAZIONE DELLA TABELLA
#############################################################################]=]

	    tabs =		   '{| style="float:right; margin-left:0.5em; margin-bottom:0.5em;'
		tabs = tabs .. 'border: 1px solid #AAAAAA; border-collapse:collapse;" cellpadding="3" rules="all"\n'
		tabs = tabs .. '|- align="center"\n'
		tabs = tabs .. '!'..titolo..--[=['<div class="sost" id="ButtonFF" >'.. differenze .. '</div>]=]'\n'
		tabs = tabs .. '! bgcolor="#FFFFE0" |&nbsp;\'\'[[singolare]]\'\'&nbsp;\n'
		tabs = tabs .. '! bgcolor="#FFFFE0" |&nbsp;\'\'[[plurale]]\'\'&nbsp;\n'
		tabs = tabs .. '|- align="center"\n'
		tabs = tabs .. '! bgcolor="#FFFFE0" |&nbsp;\'\'[[maschile]]\'\'&nbsp;\n'
		tabs = tabs .. '| &nbsp; [['..masc..']]&nbsp;'..masc2Insert..'\n'
		tabs = tabs .. '| &nbsp; [['..mascPl..']]&nbsp;'..mascPl2Insert..'\n'
		tabs = tabs .. '|- align="center"\n'
		tabs = tabs .. '! bgcolor="#FFFFE0" |&nbsp;\'\'[[femminile]]\'\'&nbsp;\n'
		tabs = tabs .. '| &nbsp; [['..fem..']]&nbsp;'..fem2Insert..'\n'
		tabs = tabs .. '| &nbsp; [['..femPl..']]&nbsp;'..femPl2Insert..'\n'
		tabs = tabs .. '|}\n' ..categorizzazione(frame)
		return tabs 
	end
end

return p