Module:Infobox/Pays Eurovision/Bac à sable

Cette page définit un module d'infobox. Pour les conseils sur l'usage de ce module, voyez Modèle:Infobox Pays Eurovision/Bac à sable.


local general = require 'Module:Infobox/Fonctions'
local localdata = require 'Module:Infobox/Localdata'

return {
    maincolor = '#77AADD',
    parts = {
        general.title('musique'),
        general.mainimage({
            cat = 'Article à illustrer Concours Eurovision de la chanson',
            size = '150'
        }),
        {
            type = 'table',
            rows = {
                { 
                    type = 'mixed', 
                    label = 'Pays', 
                    value = function() 
                        if localdata['pays'] and localdata['pays'] ~= '' then
                            return mw.getCurrentFrame():preprocess('{{' .. localdata['pays'] .. '}}')
                        end
                        return '[[Catégorie:Modèle Infobox Pays Eurovision comportant une erreur|P]]'
                    end 
                },
                { type = 'mixed', label = 'Radio diffuseur', value = 'radio diffuseur' },
                { type = 'mixed', label = 'Émission de présélection', value = 'émission' }
            },
        },
        {
            type = 'table',
            title = 'Participations',
            rows = {
                { 
                    type = 'mixed', 
                    label = function()
                        return mw.getCurrentFrame():preprocess('{{1re}} participation')
                    end, 
                    value = function()
                        if localdata['première'] and localdata['première'] ~= '' then
                            return '[[Concours Eurovision de la chanson ' .. localdata['première'] .. '|Eurovision ' .. localdata['première'] .. ']]'
                        end
                    end 
                },
                { type = 'mixed', label = 'Participations', value = 'participation' },
                { 
                    type = 'mixed', 
                    label = 'Meilleure place', 
                    value = function()
                        if localdata['top place'] and localdata['top place'] ~= '' and localdata['top année'] and localdata['top année'] ~= '' then
                            return localdata['top place'] .. ' <small>(en ' .. localdata['top année'] .. ')</small>'
                        end
                    end 
                },
                { 
                    type = 'mixed', 
                    label = 'Moins bonne place', 
                    value = function()
                        if localdata['flop place'] and localdata['flop place'] ~= '' and localdata['flop année'] and localdata['flop année'] ~= '' then
                            return localdata['flop place'] .. ' <small>(en ' .. localdata['flop année'] .. ')</small>'
                        end
                    end 
                },
            },
        },
        {
            type = 'table',
            title = 'Liens externes',
            rows = {
                {
                    type = 'row',
                    value = function()
                        local contenu_liens = {}

                        if localdata['diffuseur web'] and localdata['diffuseur web'] ~= '' then
                            table.insert(contenu_liens, '\'\'\'[' .. localdata['diffuseur web'] .. ' Page officielle du diffuseur]\'\'\'')
                        end

                        if localdata['Eurovision web'] and localdata['Eurovision web'] ~= '' then
                            if string.match(localdata['Eurovision web'], '^https?://.*eurovision%.tv/') then
                                table.insert(contenu_liens, '\'\'\'[' .. localdata['Eurovision web'] .. ' Page sur Eurovision.tv]\'\'\'')
                            else
                                table.insert(contenu_liens, '[[Catégorie:Modèle Infobox Pays Eurovision comportant une erreur|A]]')
                            end
                        end

                        if #contenu_liens > 0 then
                            return table.concat(contenu_liens, '<br>')
                        end
                    end,
                    style = { ['text-align'] = 'center' }
                }
            }
        },
        {
            type = 'table',
            rows = {
                {
                    type = 'row',
                    value = function()
                        if localdata['participation récente'] and localdata['participation récente'] ~= '' then
                            return '[[Fichier:Song contest current event.png|25px|valign=middle]] Pour la participation la plus récente, voir :<br>\'\'\'[[' .. localdata['participation récente'] .. ']]\'\'\''
                        end
                    end,
                    style = { ['text-align'] = 'center', ['font-size'] = '0.9em' }
                }
            }
        }
    }
}