Aller au contenu

Module:Infobox/Idéologie

Une page de Wikipédia, l'encyclopédie libre.
Ceci est une version archivée de cette page, en date du 25 novembre 2024 à 22:24 et modifiée en dernier par MarinBzh (discuter | contributions). Elle peut contenir des erreurs, des inexactitudes ou des contenus vandalisés non présents dans la version actuelle.

 Documentation[voir] [modifier] [historique] [purger]

Cette page définit un module d'infobox. Pour les conseils sur l'usage de ce module, voyez Modèle:Infobox Idéologie.


local wikidata = require "Module:Wikidata"
local jeu = require "Module:Infobox/Fonctions"
local generic = require "Module:Infobox/Fonctions"
local geo = require "Module:Infobox/Fonctions/Géolocalisation"
local localdata = require "Module:Infobox/Localdata"
local p = {}

-- Fonction permettant l'affichage de la partie succession
local function buildsuccession()
    localdata["précédent"] = localdata["précédent"] or wikidata.formatStatements {
        property = "P179", 
        showonlyqualifier = "P155"
    }
    localdata["suivant"] = localdata["suivant"] or wikidata.formatStatements {
        property = "P179", 
        showonlyqualifier = "P156"
    }
    localdata["idéologie"] = localdata["idéologie"] or wikidata.formatStatements {
        property = "P179"
    }

    -- Fonction permettant de définir le titre de la partie succession
    local function titre(a, b, c)
        if c and (a or b) then
            return "<i>" .. c .. "</i>"
        end
    end

    -- Fonction permettant l'affichage des articles de la partie succession
    local function succession(a, b, c, d)
        local succession = {}
        if a and b then
            succession["before"] = "<i>" .. a .. "</i> ([[" .. b .. " idéologie|" .. b .. "]])"
        elseif a then
            succession["before"] = "<i>" .. a .. "</i>"
        end
        if c and d then
            succession["after"] = "<i>" .. c .. "</i> ([[" .. d .. " idéologie|" .. d .. "]])"
        elseif c then
            succession["after"] = "<i>" .. c .. "</i>"
        end
        return succession
    end

    if localdata["précédent"] or localdata["suivant"] then
        return {
            type = "table",
            separator = true,
            mixeds = {
                {type = "mixed1col", value = titre(localdata["précédent"], localdata["suivant"], localdata["idéologie"])}
            }
        }, {
            type = "table",
            separator = true,
            mixeds = {
                {
                    type = "succession",
                    color = "transparent",
                    value = succession(
                        localdata["précédent"],
                        localdata["date précédent"],
                        localdata["suivant"],
                        localdata["date suivant"]
                    )
                }
            }
        }
    end
end

-- Fonction pour afficher le slogan
function p.slogan()
    return {
        type = "text",
        style = { ["font-weight"] = "normal", ["font-style"] = "italic" },
        value = function()
            local slogan = localdata["slogan"]
            if slogan then
                return "« " .. slogan .. " »"
            end
        end
    }
end

-- Fonction pour définir la couleur principale
function p.maincolor()
    local user_input = localdata["couleur boîte"]
    if user_input then
        if user_input:sub(1, 1) ~= "#" then
            return "#" .. user_input
        else
            return user_input
        end
    else
        return "#4A6AA5"
    end
end

-- Retour du module principal
return {
    maincolor = p.maincolor(),
    parts = {
        generic.title({}, "white"),
        generic.logo(1),
        p.slogan(),
        parts = {
            generic.title("idéologie"),
            {type = 'images', imageparameters = {'blason'}, captionparameter = 'légende blason', defaultimages = nil, defaultupright = 0.7, uprightparameter = 'upright blason'},
            generic.mainimage('Article à illustrer Politique'),
            {type = 'table', title = 'Histoire', mixeds = {
                {type = 'mixed', label = 'Fondation', value = 'fondation', property = 'P571'},
                {type = 'mixed', label = function() return localdata['intitulé fondateur'] or 'Fondateur' end, value = 'fondateur', property = 'P112'},
                {type = 'mixed', label = 'Dates-clés', value = 'dates-clés'},
                {type = 'mixed', label = 'Philosophes', value = 'philosophes'},
                {type = 'mixed', label = 'Personnages-clés', value = 'personnages-clés', property = 'P576'},
                {type = 'mixed', label = "Zone d'influence", value = "zone d'influence"}
            }},
            {type = 'table', title = 'Principes', mixeds = {
                {type = 'mixed', label = 'Régimes politiques', value = 'régimes politiques'},
                {type = 'mixed', label = 'Idées', value = 'idées'},
                {type = 'mixed', label = 'Positionnement', value = 'positionnement'},
                {type = 'mixed', label = 'Idéologies mères', value = 'idéologies mères'},
                {type = 'mixed', label = 'Idéologies soeurs', value = 'idéologies soeurs'},
                {type = 'mixed', label = 'Devise', value = 'devise', property = 'P1451'},
                {type = 'mixed', label = 'Chiffres-clés', value = 'chiffres-clés'}
            }},
            {type = 'table', title = 'Organisations', mixeds = {
                {type = 'mixed', label = 'Organisations régionales', value = 'organisations régionales'},
                {type = 'mixed', label = 'Organisations internationales', value = 'organisations internationales'}
            }},
            {type = 'table', title = 'Localisation', mixeds = {
                {type = 'mixed', label = 'Pays', value = 'pays', property = 'P17'},
                {type = 'mixed', label = 'Localisation', value = 'localisation', wikidata = {property = 'P131'}, blockers = {'ville'}},
                {type = 'mixed', label = 'Ville', value = 'ville'}
            }},
            geo.geoloc({marker = ''})
        }
    }
}