Modulo:Videogioco: differenze tra le versioni

Contenuto cancellato Contenuto aggiunto
aggiungo controllo per evitare possibili conflitti di categorizzazione come da discussione
revisione della categorizzazione per aziende, v. dp:Videogiochi#Categorizzazione_per_azienda
 
(5 versioni intermedie di 2 utenti non mostrate)
Riga 43:
t1[#t1+1] = el
end
end
 
-- ========================================================================
-- Restituisce l'aggettivo plurale maschile del Paese specificato usando
-- il template AggNaz
-- ========================================================================
local function get_adj(paese)
local adj
local title = mw.title.new('Template:AggNaz/' .. paese)
adj = title and title.exists and
mw.getCurrentFrame():expandTemplate {
title = title.text,
args = { 'mp' }
}
 
return adj
end
 
Riga 65 ⟶ 81:
-- da controllare
-- ========================================================================
local function categorizza(args, base_name, table_name, lowercase, must_exist, cat_assenza)
local categories = {}
local name_value = args[base_name] or args[base_name .. " 1"]
Riga 92 ⟶ 108:
index = index + 1
end
elseif cat_assenza and not args[base_name .. " altro"] then
categories[#categories+1] = 'Videogiochi senza ' .. base_name
end
if args[base_name] and args[base_name .. " 1"] then
Riga 98 ⟶ 116:
return categories
end
 
----------------------------------------------------------------------------------
-- ========================================================================
-- Categorizzazione per aziende (sviluppo N e pubblicazione N)
-- ========================================================================
local function categoria_azienda(str)
-- converte eventuali alias
str = cfg['alias_aziende'][str] or str
-- se il nome contiene un wikilink, estrae la voce puntata, senza disambiguante
local azienda = mw.ustring.match(str, "%[%[([^%]%(|]+)") or str
azienda = mw.text.trim(azienda)
-- se esiste "cat:Videogiochi Azienda" la seleziona
local cat = "Videogiochi " .. azienda
local titolo = mw.title.new(cat, "Categoria")
if titolo and titolo.exists then
return cat
end
return nil
end
 
local function categorizza_aziende(args, base_name)
local categories = {}
local name_value = args[base_name] or args[base_name .. " 1"]
if name_value then
local cat = categoria_azienda(name_value)
if cat then
categories[#categories+1] = cat
end
local index = 2
while true do
name_value = args[base_name .. ' ' .. tostring(index)]
if name_value then
cat = categoria_azienda(name_value)
if cat then
categories[#categories+1] = cat
end
else
break
end
index = index + 1
end
end
if args[base_name] and args[base_name .. " 1"] then
errors_msg[#errors_msg+1] = 'Inserire solo uno di ' .. base_name .. ' e ' .. base_name .. ' ' .. tostring(index)
end
return categories
end
 
-- ========================================================================
-- categorizza
-- ========================================================================
----------------------------------------------------------------------------------
function p.categorie(frame)
local args = getArgs(frame, {parentOnly = not frame.args.debug})
Riga 112 ⟶ 177:
local anno = tonumber(args.anno)
if anno == nil then
errors_msg[#errors_msg+1]if args.anno == 'annoannullato' di pubblicazione non valido'then
categories[#categories+1] = 'Videogiochi annullati'
else
errors_msg[#errors_msg+1] = 'anno di pubblicazione non valido'
end
elseif anno <= 1970 then
categories[#categories+1] = 'Videogiochi fino al 1970'
Riga 118 ⟶ 187:
categories[#categories+1] = 'Videogiochi del ' .. args.anno
end
else
categories[#categories+1] = 'Videogiochi senza anno'
end
append_table(categories, categorizza(args, 'genere', 'genere', true, true, true))
append_table(categories, categorizza(args, 'tema', 'tema', true))
for i = 1, 3 do
append_table(categories, categorizza(args, 'piattaforma', 'piattaforma', false, true))
local origine = args['origine ' .. i] or i == 1 and args['origine']
append_table(categories, categorizza(args, 'sviluppo', 'aziende'))
if not origine then
append_table(categories, categorizza(args, 'pubblicazione', 'aziende'))
categories[#categories+1] = i == 1 and 'Videogiochi senza nazionalità' or nil
break
end
local adj = get_adj(origine)
if adj then
categories[#categories+1] = 'Videogiochi ' .. adj
end
end
append_table(categories, categorizza(args, 'piattaforma', 'piattaforma', false, true, true))
append_table(categories, categorizzacategorizza_aziende(args, 'sviluppo', 'aziende'))
append_table(categories, categorizzacategorizza_aziende(args, 'pubblicazione', 'aziende'))
append_table(categories, categorizza(args, 'distribuzione digitale', 'distribuzione', false, true))
entity = mw.wikibase.getEntity()
Riga 147 ⟶ 229:
return frame.args.debug and mw.text.nowiki(table.concat(categories)) or table.concat(categories)
end
 
----------------------------------------------------------------------------------
-- ========================================================================
-- Ritorna la configurazione della tabella per le aziende di videogiochi
-- Visualizza le tabelle delle configurazioni per il manuale
----------------------------------------------------------------------------------
-- ========================================================================
function p.tabella_configurazione(frame)
local args = getArgs(frame)