local p = {}
local icons = {
positivo = 'Symbol confirmed',
probabile = 'Symbol support vote',
incerto = 'Symbol possible vote',
negativo = 'Symbol unrelated',
respinto = 'No sign2',
altro = 'Symbol unsupport vote',
in_attesa = 'Time2wait'
}
function listUsers(group, sign)
local pattern = '[[File:%s.svg|20px|link=]] %s'
local label = sign:gsub('^.', string.upper):gsub('_', ' ')
local div = mw.html.create('div')
div
:addClass('cu-request-block')
:tag('div')
:addClass('cu-request-symbol')
:wikitext(string.format(pattern, icons[sign], label))
:done()
:tag('div')
:addClass('cu-request-list')
:wikitext(table.concat(group, '<br />'))
:done()
:done()
return tostring(div)
end
function getLinks(user)
local links = {
'[[Utente:$1|$1]] <small class="plainlinks">[[Speciale:Contributi/$1|contributi]]',
'[[Speciale:DeletedContributions/$1|(cancellati)]]',
'[[luxo:$1|(CW)]]',
'[' .. tostring(mw.uri.fullUrl('Speciale:Log', { type = 'block', page = 'Utente:' .. mw.uri.encode(user, 'WIKI') })) .. ' blocchi]',
'[[Wikipedia:Check user/Richieste/Archivio/Utenti/$1|Prec]]</small>',
'[[Speciale:CU/$1|CU]]'
}
return mw.message.newRawMessage(table.concat(links, ' · '), user):plain()
end
function p.righe(frame)
local args = frame:getParent().args
local users = {}
local ret = {}
local i = 1
while true do
local user = args['UTENTE' .. i] or ''
if user ~= '' then
local result = args['RISULTATO_UTENTE' .. i] or ''
if result == '' then
result = args.RISULTATOSIGN
end
local group = icons[result] and result or 'in_attesa'
if not users[group] then users[group] = {} end
table.insert(users[group], getLinks(user))
i = i + 1
elseif i <= 2 then
return '<span class="error">Richiesta non valida: indicare almeno due utenze.</span>'
else
break
end
end
if users[args.RISULTATOSIGN] then
table.insert(ret, listUsers(users[args.RISULTATOSIGN], args.RISULTATOSIGN))
end
for k in pairs(icons) do
if users[k] and k ~= args.RISULTATOSIGN then
table.insert(ret, listUsers(users[k], k))
end
end
return table.concat(ret, '\n')
end
return p