Modulo:Sandbox/Dega180: differenze tra le versioni

Contenuto cancellato Contenuto aggiunto
mNessun oggetto della modifica
Nessun oggetto della modifica
 
(38 versioni intermedie di uno stesso utente non sono mostrate)
Riga 1:
local mWikidata = require('Modulo:Wikidata')
local p = {}
local args = {} -- Parametri passati al template {{Divisione Amministrativa}}
local HtmlBuilder = require('Modulo:HtmlBuilder')
local lang = mw.language.new('it')
local function controllaParametri(frame)
if not args['Grado amministrativo'] then
return {true, frame:expandTemplate{title = 'Errore template', args = {'Grado amministrativo', 'Divisioni amministrative', man = 'Template:Divisione amministrativa/man'} } }
elseif tonumber(args['Grado amministrativo']) == nil then
return {true, frame:expandTemplate{title = 'Errore template', args = {'Grado amministrativo', 'Divisioni amministrative', man = 'Template:Divisione amministrativa/man', t = 'r'} } }
end
if not args['Stato'] then
return {true, frame:expandTemplate{title = 'Errore template', args = {'Stato', 'Divisioni amministrative', man = 'Template:Divisione amministrativa/man'} } }
elseif not(mw.title.new(args['Stato'], 'Template').exists) then
return {true, frame:expandTemplate{title = 'Errore template', args = {'Stato', 'Divisioni amministrative', t = 'r', man = 'Template:Divisione amministrativa/man'} } }
end
return {false, nil}
end
 
local function stileTitoloInt()
local gradoAmministrativo = tonumber(args['Grado amministrativo'])
if gradoAmministrativo == 1 then
return 'background-color:#C2FF91;'
elseif gradoAmministrativo == 2 then
return 'background-color:#C1FFD5;'
elseif gradoAmministrativo == 3 then
return 'background-color:#CEDEFF;'
elseif gradoAmministrativo == 4 then
return 'background-color:#E1E2FF;'
elseif gradoAmministrativo == 5 then
return 'background-color:#E1E1E1;'
else
return nil
end
end
 
local function titoloIntp.prova(frame)
local wdLat = mWikidata._getProperty({ 'P625', coord = 'latitude', n = 1, from = 'Q16148410' })
local output = HtmlBuilder.create() -- Conterrà la stringa di output
local wdLong = mWikidata._getProperty({ 'P625', coord = 'longitude', n = 1, from = 'Q16148410' })
local tipoDivisione = frame:expandTemplate{title='DivAmm', args = {args['Stato'], args['Grado amministrativo']} }
if wdLat then
local linkTipoDivisione = frame:expandTemplate{title='DivAmm', args = {args['Stato'], args['Grado amministrativo']..'L'} }
return 'latitudine uguale a' .. wdLat
local tipo
elseif wdLong then
if (tipoDivisione ~= '') or args['Tipo'] then
return 'longitudine uguale a' .. wdLong
if args['Tipo'] then
else
tipo = args['Tipo']
return 'errore'
else
if linkTipoDivisione ~= '' then
tipo='[['..linkTipoDivisione..'|'..lang:lc(tipoDivisione)..']]'
else
tipo=lang:lc(tipoDivisione)
end
if args['Data soppressione'] then
tipo=table.concat({'ex ',tipo})
end
end
return tostring(output.wikitext(args['Nome']).tag('br /', {unclosed = true}).tag('span').css('font-size','80%').wikitext(tipo).allDone())
end
return nome
end
 
local function immagine(frame)
local root = HtmlBuilder.create()
local tabella, riga, cella
if args['Nome ufficiale'] then
root.wikitext(args['Nome ufficiale'])
if args['Stemma'] or args['Bandiera'] or args['Panorama'] then
root.tag('br /', {unclosed = true})
end
end
tabella = root.tag('table')
riga = tabella.tag('tr')
if args['Stemma'] then
cella = riga.tag('td')
cella.wikitext('[[File:'..args['Stemma']..'|80x125px|'..args['Nome']..'– Stemma]]').done()
end
if args['Bandiera'] then
cella = riga.tag('td')
cella.wikitext('[[File:'..args['Bandiera']..'|125x125px')
if args['Bordo bandiera'] ~= 'no' then
cella.wikitext('|border')
end
cella.wikitext('|'..args['Nome']..' – Bandiera]]').done()
end
riga.done()
riga = tabella.tag('tr')
if args['Stemma'] and args['Voce stemma'] then
cella = riga.tag('td')
cella.wikitext('([['..args['Voce stemma']..'|dettagli]])').done()
end
if args['Bandiera'] and args['Voce bandiera'] then
if args['Bandiera'] and (not args['Voce bandiera']) then
cella = riga.tag('td')
cella.done()
cella = riga.tag('td')
cella.wikitext('([['..args['Voce bandiera']..'|dettagli]])').done()
else
cella = riga.tag('td')
cella.wikitext('([['..args['Voce bandiera']..'|dettagli]])').done()
end
end
root.allDone()
if args['Panorama'] then
root.wikitext('[[File:'..args['Panorama']..'|')
if args['Didascalia'] then
root.wikitext(args['Didascalia'])
else
root.wikitext(args['Nome']..' – Veduta')
end
root.wikitext('|260x250px]]')
end
return tostring(root)
end
 
function p.divisioneAmministrativa( frame )
local root = HtmlBuilder.create()
root.wikitext('ciao')
local tabella = root.tag('table')
local riga = tabella.tag('tr')
local cella = riga.tag('td')
cella.wikitext('sono andrea')
cella.wikitext(' salute')
cella.wikitext(' ariciao').done()
cella = riga.tag('td')
cella.wikitext('sono carlo').done()
riga.done()
riga = tabella.tag('tr')
cella = riga.tag('td')
cella.wikitext('sono giovanni').done()
cella = riga.tag('td')
cella.wikitext('sono marco').done()
root.allDone()
return tostring(root)
 
--[[ local argsInfobox = {} -- Parametri da passare al template {{Infobox}}
for k, v in pairs(frame:getParent().args) do
if v ~= '' then
args[k] = v
end
end
local controlloParametri = controllaParametri(frame)
if controlloParametri[1] then
return controlloParametri[2]
end
if not args['Nome'] then
args['Nome'] = mw.title.getCurrentTitle().text
end
argsInfobox['StileTitoloInt'] = stileTitoloInt()
argsInfobox['TitoloInt'] = titoloInt(frame)
argsInfobox['Immagine'] = immagine(frame)
argsInfobox['Didascalia'] = args['Didascalia']
argsInfobox['Gruppo1'] = 'titolo del gruppo 1'
argsInfobox['Nome2'] = 'titolo del nome 2'
argsInfobox['Valore2'] = 'titolo del valore 2'
return frame:expandTemplate{title = 'Infobox', args = argsInfobox}]]
end