Basculer le menu
Changer de menu des préférences
Basculer le menu personnel
Non connecté(e)
Votre adresse IP sera visible au public si vous faites des modifications.

La documentation pour ce module peut être créée à Module:Infobox/Configs/Membre/doc

local config = {
    titre = function(args) 
        return args.pseudo or '{{PAGENAME}}' 
    end,
    
    icone = {
        type = 'fas',
        nom = 'user'
    },
    
    image = function(args) 
        if args.image then
            return {
                nom = args.image,
                taille = args.tailleimage or "280px",
                legende = args.legende or args.pseudo or '{{PAGENAME}}'
            }
        end
        return nil
    end,

    sections = {
        {
            titre = 'Informations',
            champs = {
                { 
                    cle = 'discord', 
                    label = 'Discord',
                    process = function(value, args, frame)
                        if not value or value == '' then
                            return nil
                        end
                        
                        -- Créer le lien Discord
                        local discordLink = 'https://discord.com/users/' .. mw.text.encode(value)
                        
                        -- Retourner HTML flouté (CSS externe)
                        return '<span class="discord-masked">[' .. discordLink .. ' ' .. mw.text.encode(value) .. ']</span>'
                    end
                },


                { 
                    cle = 'role', 
                    label = 'Rôle',
                    process = function(value, args)
                        if not value or value == '' then
                            return nil
                        end
                        
                        local roleValues = {
                            ['fondateur'] = 'Fondateur',
                            ['propriétaire'] = 'Propriétaire',
                            ['administrateur'] = 'Administrateur',
                            ['modérateur'] = 'Modérateur',
                            ['builder'] = 'Builder',
                            ['développeur'] = 'Développeur',
                            ['joueur'] = 'Joueur'
                        }
                        
                        local cleanValue = mw.text.trim(mw.ustring.lower(value))
                        
                        if roleValues[cleanValue] then
                            return roleValues[cleanValue]
                        else
                            return value
                        end
                    end
                },
                { 
                    cle = 'date_arrivee', 
                    label = 'Date d\'arrivée',
                    process = function(value, args)
                        if not value or value == '' then
                            return nil
                        end
                        return value
                    end
                }
            }
        },
        {
            titre = 'Communauté',
            champs = {
                { 
                    cle = 'grade', 
                    label = 'Grade',
                    process = function(value, args)
                        if not value or value == '' then
                            return nil
                        end
                        
                        local gradeValues = {
                            ['grand intendant'] = '[[Intendant|Grand Intendant]]',
                            ['intendant'] = '[[Intendant]]',
                            ['officier'] = '[[Officier]]',
                            ['architecte'] = '[[Architecte]]',
                            ['scriptomancien'] = '[[Scriptomancien]]',
                            ['scribe'] = '[[Scribe]]',
                            ['aspirant'] = '[[Aspirant]]',
                            ['machiniste'] = '[[Machiniste]]',
                            ['batisseur'] = '[[Bâtisseur]]',
                            ['menestrel'] = '[[Ménestrel]]',
                            ['contremaitre'] = '[[Contremaître]]',
                            ['peregrin'] = '[[Pérégrin]]',
                            ['maraud'] = '[[Maraud]]'
                        }
                        
                        local cleanValue = mw.text.trim(mw.ustring.lower(value))
                        
                        if gradeValues[cleanValue] then
                            return gradeValues[cleanValue]
                        else
                            return value
                        end
                    end
                },
                { 
                    cle = 'statut', 
                    label = 'Statut',
                    process = function(value, args)
                        if not value or value == '' then
                            return nil
                        end
                        
                        local statusValues = {
                            ['actif'] = {
                                display = '<span style="color: #00ff00;">●</span> Actif',
                                icon = '✓'
                            },
                            ['inactif'] = {
                                display = '<span style="color: #ff0000;">●</span> Inactif',
                                icon = '✗'
                            },
                            ['pause'] = {
                                display = '<span style="color: #ffaa00;">●</span> En pause',
                                icon = '⏸'
                            },
                            ['retraite'] = {
                                display = '<span style="color: #888888;">●</span> Retraité',
                                icon = '⚐'
                            },
                            ['banni'] = {
                                display = '<span style="color: #aa0000;">●</span> Banni',
                                icon = '⊗'
                            }
                        }
                        
                        local cleanValue = mw.text.trim(mw.ustring.lower(value))
                        
                        if statusValues[cleanValue] then
                            return statusValues[cleanValue].display
                        else
                            return value
                        end
                    end
                },
                { 
                    cle = 'contribution', 
                    label = 'Contribution(s) notable(s)',
                    process = function(value, args)
                        if not value or value == '' then
                            return nil
                        end
                        return value
                    end
                }
            }
        },
        {
            titre = 'Association',
            champs = {
                { 
                    cle = 'association_role', 
                    label = 'Rôle',
                    process = function(value, args)
                        if not value or value == '' then
                            return nil
                        end
                        
                        local assoRoleValues = {
                            ['président'] = '[[Association:Président|Président]]',
                            ['vice-president'] = '[[Association:Vice-Président|Vice-Président]]',
                            ['trésorier'] = '[[Association:Trésorier|Trésorier]]',
                            ['tresorier adjoint'] = '[[Association:Trésorier adjoint|Trésorier adjoint]]',
                            ['secrétaire'] = '[[Association:Secrétaire|Secrétaire]]',
                            ['secretaire adjoint'] = '[[Association:Secrétaire adjoint|Secrétaire adjoint]]'
                        }
                        
                        local cleanValue = mw.text.trim(mw.ustring.lower(value))
                        
                        if assoRoleValues[cleanValue] then
                            return assoRoleValues[cleanValue]
                        else
                            return value
                        end
                    end
                },
                { 
                    cle = 'association_mandat', 
                    label = 'Mandat',
                    process = function(value, args)
                        if not value or value == '' then
                            return nil
                        end
                        
                        -- Formater les mandats (ex: "2020-2024" ou "Depuis 2020")
                        local function formatMandat(mandat)
                            -- Format "AAAA-AAAA"
                            local debut, fin = mandat:match("^(%d%d%d%d)%-(%d%d%d%d)$")
                            if debut and fin then
                                return debut .. ' - ' .. fin
                            end
                            
                            -- Format "depuis AAAA" ou "Depuis AAAA"
                            local annee = mandat:match("^[Dd]epuis%s+(%d%d%d%d)$")
                            if annee then
                                return 'Depuis ' .. annee
                            end
                            
                            -- Format "AAAA" seul (mandat en cours)
                            annee = mandat:match("^(%d%d%d%d)$")
                            if annee then
                                return 'Depuis ' .. annee
                            end
                            
                            return mandat
                        end
                        
                        return formatMandat(value)
                    end
                },
                { 
                    cle = 'association_adhesion', 
                    label = 'Date d\'adhésion',
                    process = function(value, args)
                        if not value or value == '' then
                            return nil
                        end
                        return value
                    end
                },
                { 
                    cle = 'association_statut', 
                    label = 'Statut associatif',
                    process = function(value, args)
                        if not value or value == '' then
                            return nil
                        end
                        
                        local assoStatusValues = {
                            ['actif'] = '<span style="color: #00ff00;">●</span> Membre actif',
                            ['inactif'] = '<span style="color: #ff6600;">●</span> Membre inactif',
                            ['ancien'] = '<span style="color: #888888;">●</span> Ancien membre',
                            ['honoraire'] = '<span style="color: #gold;">★</span> Membre d\'honneur',
                            ['fondateur'] = '<span style="color: #ffd700;">★</span> Membre fondateur'
                        }
                        
                        local cleanValue = mw.text.trim(mw.ustring.lower(value))
                        
                        if assoStatusValues[cleanValue] then
                            return assoStatusValues[cleanValue]
                        else
                            return value
                        end
                    end
                }
            }
        },
        {
            titre = 'IRL',
            champs = {
                { 
                    cle = 'age', 
                    label = 'Âge',
                    process = function(value, args)
                        -- Si un âge est fourni directement, l'utiliser
                        if value and value ~= '' then
                            if tonumber(value) then
                                return value .. ' ans'
                            end
                            return value
                        end
                        
                        -- Sinon, calculer depuis date_naissance ou annee_naissance
                        local dateNaissance = args.date_naissance or args.annee_naissance
                        
                        if not dateNaissance or dateNaissance == '' then
                            return nil
                        end
                        
                        -- Fonction de calcul de l'âge
                        local function calculateAge(birthDate)
                            local now = os.date("*t")
                            local birth = {}
                            
                            -- Parser différents formats de date
                            -- Format JJ/MM/AAAA
                            local day, month, year = birthDate:match("^(%d+)/(%d+)/(%d+)$")
                            if day then
                                birth.day = tonumber(day)
                                birth.month = tonumber(month)
                                birth.year = tonumber(year)
                            else
                                -- Format AAAA-MM-JJ (ISO)
                                year, month, day = birthDate:match("^(%d+)%-(%d+)%-(%d+)$")
                                if year then
                                    birth.day = tonumber(day)
                                    birth.month = tonumber(month)
                                    birth.year = tonumber(year)
                                else
                                    -- Format AAAA seulement
                                    year = birthDate:match("^(%d%d%d%d)$")
                                    if year then
                                        birth.year = tonumber(year)
                                        birth.month = 1
                                        birth.day = 1
                                    else
                                        return nil
                                    end
                                end
                            end
                            
                            -- Vérification de validité
                            if not birth.year or birth.year < 1900 or birth.year > now.year then
                                return nil
                            end
                            
                            -- Calcul de l'âge
                            local age = now.year - birth.year
                            
                            -- Ajustement si l'anniversaire n'est pas encore passé cette année
                            if birth.month and birth.day then
                                if now.month < birth.month or 
                                   (now.month == birth.month and now.day < birth.day) then
                                    age = age - 1
                                end
                            end
                            
                            return age
                        end
                        
                        local calculatedAge = calculateAge(dateNaissance)
                        
                        if calculatedAge then
                            return calculatedAge .. ' ans'
                        end
                        
                        return nil
                    end
                },
                { 
                    cle = 'date_naissance', 
                    label = 'Date de naissance',
                    process = function(value, args)
                        if not value or value == '' then
                            return nil
                        end
                        
                        -- Fonction pour formater la date en français
                        local function formatDate(dateStr)
                            local months = {
                                ['01'] = 'janvier', ['02'] = 'février', ['03'] = 'mars',
                                ['04'] = 'avril', ['05'] = 'mai', ['06'] = 'juin',
                                ['07'] = 'juillet', ['08'] = 'août', ['09'] = 'septembre',
                                ['10'] = 'octobre', ['11'] = 'novembre', ['12'] = 'décembre'
                            }
                            
                            -- Format JJ/MM/AAAA
                            local day, month, year = dateStr:match("^(%d+)/(%d+)/(%d+)$")
                            if day and months[month] then
                                return day .. ' ' .. months[month] .. ' ' .. year
                            end
                            
                            -- Format AAAA-MM-JJ
                            year, month, day = dateStr:match("^(%d+)%-(%d+)%-(%d+)$")
                            if year and months[month] then
                                return day .. ' ' .. months[month] .. ' ' .. year
                            end
                            
                            -- Format AAAA seulement
                            year = dateStr:match("^(%d%d%d%d)$")
                            if year then
                                return year
                            end
                            
                            -- Retourner tel quel si format non reconnu
                            return dateStr
                        end
                        
                        return formatDate(value)
                    end
                },
                { 
                    cle = 'annee_naissance', 
                    label = 'Année de naissance',
                    process = function(value, args)
                        -- Si date_naissance existe, ne pas afficher annee_naissance
                        if args.date_naissance and args.date_naissance ~= '' then
                            return nil
                        end
                        
                        if not value or value == '' then
                            return nil
                        end
                        
                        return value
                    end
                },
                { 
                    cle = 'sexe', 
                    label = 'Sexe',
                    process = function(value, args)
                        if not value or value == '' then
                            return nil
                        end
                        
                        local sexeValues = {
                            ['h'] = 'Homme',
                            ['homme'] = 'Homme',
                            ['m'] = 'Homme',
                            ['f'] = 'Femme',
                            ['femme'] = 'Femme',
                            ['autre'] = 'Autre',
                            ['non-binaire'] = 'Non-binaire'
                        }
                        
                        local cleanValue = mw.text.trim(mw.ustring.lower(value))
                        
                        return sexeValues[cleanValue] or value
                    end
                }
            }
        }
    },

    -- Fonction de catégorisation
    categories = function(args)
        local cats = {'Membre'}
        
        -- Catégories par statut
        if args.statut then
            local cleanStatut = mw.text.trim(mw.ustring.lower(args.statut))
            if cleanStatut == 'actif' then
                table.insert(cats, 'Membre actif')
            elseif cleanStatut == 'inactif' then
                table.insert(cats, 'Membre inactif')
            elseif cleanStatut == 'pause' then
                table.insert(cats, 'Membre en pause')
            elseif cleanStatut == 'retraite' then
                table.insert(cats, 'Membre retraité')
            elseif cleanStatut == 'banni' then
                table.insert(cats, 'Membre banni')
            end
        end
        
        -- Catégories par rôle
        if args.role then
            local cleanRole = mw.text.trim(mw.ustring.lower(args.role))
            if cleanRole == 'fondateur' then
                table.insert(cats, 'Fondateur')
            elseif cleanRole == 'propriétaire' then
                table.insert(cats, 'Propriétaire')
            elseif cleanRole == 'administrateur' then
                table.insert(cats, 'Administrateur')
            elseif cleanRole == 'modérateur' then
                table.insert(cats, 'Modérateur')
            elseif cleanRole == 'builder' then
                table.insert(cats, 'Builder')
            elseif cleanRole == 'développeur' then
                table.insert(cats, 'Développeur')
            end
        end
        
        -- Catégories par grade
        if args.grade then
            local cleanGrade = mw.text.trim(mw.ustring.lower(args.grade))
            table.insert(cats, 'Grade:' .. args.grade)
        end
        
        -- Catégories associatives
        if args.association_role then
            local cleanAssoRole = mw.text.trim(mw.ustring.lower(args.association_role))
            if cleanAssoRole == 'président' or cleanAssoRole == 'president' then
                table.insert(cats, 'Président d\'association')
            elseif cleanAssoRole == 'vice-président' or cleanAssoRole == 'vice-president' then
                table.insert(cats, 'Vice-Président d\'association')
            elseif cleanAssoRole == 'trésorier' or cleanAssoRole == 'tresorier' then
                table.insert(cats, 'Trésorier d\'association')
            elseif cleanAssoRole == 'secrétaire' or cleanAssoRole == 'secretaire' then
                table.insert(cats, 'Secrétaire d\'association')
            else
                table.insert(cats, 'Membre du bureau associatif')
            end
        end
        
        -- Catégories par statut associatif
        if args.association_statut then
            local cleanAssoStatut = mw.text.trim(mw.ustring.lower(args.association_statut))
            if cleanAssoStatut == 'actif' or cleanAssoStatut == 'fondateur' or cleanAssoStatut == 'honoraire' then
                table.insert(cats, 'Membre de l\'association')
            elseif cleanAssoStatut == 'ancien' then
                table.insert(cats, 'Ancien membre de l\'association')
            end
        end
        
        return cats
    end
}

return config