Module:Infobox/Configs/Plugin
De Nefald
Autres actions
La documentation pour ce module peut être créée à Module:Infobox/Configs/Plugin/doc
local p = {}
function p.main(frame)
local args = frame:getParent().args
local config = {
titre = function(args)
return args.nom or '{{PAGENAME}}'
end,
icone = {
type = 'fas',
nom = 'puzzle-piece'
},
image = function(args)
if args.image then
return {
nom = args.image,
taille = args.tailleimage or "280x200px",
legende = args.legende or args.nom or '{{PAGENAME}}'
}
end
return nil
end,
sections = {
{
champs = {
{
cle = 'type',
label = 'Type',
process = function(value, args)
if not value or value == '' then
return nil
end
-- Configuration locale des types
local typeValues = {
['économie'] = 'Plugin d\'économie',
['pvp'] = 'Plugin de PvP',
['roleplay'] = 'Plugin de roleplay',
['administration'] = 'Plugin d\'administration',
['protection'] = 'Plugin de protection',
['cosmétique'] = 'Plugin cosmétiques',
['communication'] = 'Plugin de communication',
['utilitaire'] = 'Plugin utilitaires',
['mini-jeu'] = 'Plugin de mini-jeux',
['monde'] = 'Plugin de monde',
['inventaire'] = 'Plugin d\'inventaire',
['transport'] = 'Plugin de transport',
['magie'] = 'Plugin de magie',
['mob'] = 'Plugin de mobs'
}
-- Nettoyer la valeur d'entrée
local cleanValue = mw.text.trim(mw.ustring.lower(value))
-- Retourner la valeur formatée ou la valeur originale
return typeValues[cleanValue] or value
end
},
{
cle = 'status',
label = 'Statut',
process = function(value, args)
if not value or value == '' then
return nil
end
-- Configuration locale des statuts
local statusValues = {
['installé'] = { text = 'Installé', color = 'green' },
['installe'] = { text = 'Installé', color = 'green' },
['non-installé'] = { text = 'Non installé', color = 'red' },
['non-installe'] = { text = 'Non installé', color = 'red' },
['non installé'] = { text = 'Non installé', color = 'red' },
['non installe'] = { text = 'Non installé', color = 'red' },
['désinstallé'] = { text = 'Désinstallé', color = 'red' },
['desinstalle'] = { text = 'Désinstallé', color = 'red' }
}
-- Nettoyer la valeur d'entrée
local cleanValue = mw.text.trim(mw.ustring.lower(value))
if statusValues[cleanValue] then
local status = statusValues[cleanValue]
return '<span style="color: ' .. status.color .. '; font-weight: bold;">' .. status.text .. '</span>'
end
return value
end
},
{ cle = 'version', label = 'Version' },
{ cle = 'author', label = 'Auteur', aliases = {'auteur'} },
{ cle = 'source', label = 'Source' },
{ cle = 'langue', label = 'Langue' }
}
},
{
titre = 'Compatibilite',
visible = function(args)
-- La section est visible seulement si au moins un de ces champs est rempli
return (args.dependance and args.dependance ~= '') or
(args.compatibilite and args.compatibilite ~= '')
end,
champs = {
{ cle = 'dependance', label = 'Dépendance(s)' },
{ cle = 'compatibilite', label = 'Compatible avec' }
}
},
{
titre = 'Description',
champs = {
{ cle = 'description', label = 'Description', multiligne = true }
}
}
},
categories = function(args, frame)
local cats = {}
-- Configuration des catégories par type
local typeCategories = {
['économie'] = 'Plugin d\'économie',
['pvp'] = 'Plugin de PvP',
['roleplay'] = 'Plugin de roleplay',
['administration'] = 'Plugin d\'administration',
['protection'] = 'Plugin de protection',
['cosmétique'] = 'Plugin cosmétiques',
['communication'] = 'Plugin de communication',
['utilitaire'] = 'Plugin utilitaires',
['mini-jeu'] = 'Plugin de mini-jeux',
['monde'] = 'Plugin de monde',
['inventaire'] = 'Plugin d\'inventaire',
['transport'] = 'Plugin de transport',
['magie'] = 'Plugin de magie',
['mob'] = 'Plugin de mobs'
}
-- Configuration des catégories par statut
local statusCategories = {
['installé'] = 'Plugin installé',
['non-installé'] = 'Plugin non-installé'
}
-- Catégorie basée sur le type
if args.type then
local cleanType = mw.text.trim(mw.ustring.lower(args.type))
if typeCategories[cleanType] then
table.insert(cats, typeCategories[cleanType])
end
end
-- Catégorie basée sur le statut
if args.status then
local cleanStatus = mw.text.trim(mw.ustring.lower(args.status))
if statusCategories[cleanStatus] then
table.insert(cats, statusCategories[cleanStatus])
end
end
return cats
end
}
return require('Module:Infobox').build(args, config, frame)
end
return p