Módulo:Infobox/Equipa ciclista

Documentação do módulo[ver] [editar] [histórico] [purgar]

Descrição

Este módulo tem funções auxiliares de {{Info/Equipa de Ciclismo}}

Uso

Outra documentação:

local wikidata = require "Módulo:Infobox/Wikidata"
local general = require "Módulo:Infobox/Funções"
local sports = require "Módulo:Infobox/Funções/Competição desportiva"
local linktopic = '-'


local function getFormerNames( item )
    local claims =  wikidata.getClaims{
        property = vals,
        entity = item,
        property = 'P1448',
        rank = 'valid',
        sorttype = 'chronological'
    }
    if not claims then
        return nil
    end
    local names, periods = {}, {}
    for i, val in pairs(claims) do
        table.insert(names, wikidata.formatStatement(val))
        table.insert(periods, wikidata.getFormattedDate(val, {linktopic = '-', precision = 'day'}))
    end
    return names, periods
end

local function formerNamesTable( localdata ) -- retourne une table de lignes contenant les anciens noms de l'équipe
    local names, periods = localdata['nome-ant'], localdata['ano']
    if names then
        names =  mw.text.split(names, '<br />')
        periods = mw.text.split(periods or '', '<br />')
    else
        names, periods = getFormerNames( localdata.item )
    end
    if not names then
        return nil
    end
    local rows = {}
    for i, period in pairs(periods) do
        table.insert( rows, {type = 'row', label = period, value = function () return names[i] end})  
    end
    local title = 'Designações anteriores'
    if #names == 1 then
        title = 'Designação anterior'
    end
    return {type = 'table', title = title, rows = rows}
end

local function jersey(upright)
    return {
        type = 'images',
        imageparameters =  {'kitimage'},
    defaultcaption   = 'Camiseta',
    --    defaultimage = {},
    --    maintenancecat =
        defaultupright = upright or '0.4',
    }
end

local function jersey1()
          local value = function(localdata)
              local maillot = mw.getCurrentFrame():expandTemplate{title = 'EquipamentoFutebol', args = { pattern_la = localdata['pattern_la'], pattern_b = localdata['pattern_b'], pattern_ra = localdata['pattern_ra'], pattern_sh = localdata['pattern_sh'], pattern_so = localdata['pattern_so'], leftarm = localdata['leftarm'], body = localdata['body'], rightarm = localdata['rightarm'], shorts = localdata['shorts'], socks = localdata['socks'], title = localdata['title'] or 'equipamento'}}
                if not maillot then
                        return nil
                end
                return maillot
    end
        return {
                type = 'mixed',
            value =  value,
        }
end

return {
    maincolor = '#FFDF80',
    parts = {
        general.title('ciclismo', nil, 'subtítulo'),
        general.mainimage('!Artigos de esporte sem imagens'),
        {type = 'table', title = 'Informações', rows = {
            sports.typeofteam,
            {
                type = 'row',
                label = function ( localdata )
                    local claims = wikidata.getClaims{property = 'P1998', entity = localdata.item}
                    if (not claims) or #claims == 1 then
                        return "Código UCI"
                    end
                    return "Códigos UCI"
                end,
                value = 'código',
                wikidata = function ( item )
                    local claims = wikidata.getClaims{
                        entity = item,
                        property = 'P1998',
                        conjtype = 'new line',
                        sorttype = 'chronological',
                        rank = 'valid'
                    }
                    if not claims then
                        return nil
                    end
                    local conjtype,textformat = 'new line', 'long'
                    if #claims > 4 then
                        conjtype, textformat = 'comma', 'long'
                    end
                    return wikidata.formatAndCat{
                        entity = item,
                        property = 'P1998',
                        showdate = true,
                        textformat = textformat,
                        linktopic = '-',
                        rank = 'valid'
                    }
                end
            },
            {type = 'row', label = 'Disciplina', value = {'disciplina', 'discipline'}, property = 'P641'},
            function ( localdata ) -- affichage du pays, avec les dates seulement s'il y en a plus qu'1
                local c = wikidata.getClaims{entity = localdata.item, property = 'P17', rank = 'valid'}
                if not c then
                    return nil
                elseif c == 1 then
                    return general.country{rank = 'valid', sorttype = 'chronological'}
                else
                    return general.country{rank = 'valid', sorttype = 'chronological', showdate = true}
                end
            end,
            {type = 'row', label = 'Fundação', value = {'fundação', 'fund'}, property = 'P571'},
            {type = 'row', label = 'Extinção', value = {'extinção', 'ext'}, property = 'P576'},
            {
                type = 'row',
                label = 'Temporadas',
                value = 'temporadas',
                wikidata = function ( item ) -- suppose que P527 ne contienne que des saisons, et contienne toutes les saisons
                    local seasons = wikidata.getClaims{entity = item, property = 'P527'}
                    if not seasons then
                        return nil
                    end
                    local str = tostring(#seasons)
                    str = wikidata.addLinkBack(str, item, 'P527')
                    str = str .. wikidata.addTrackingCat('P527')
                    return str
                end,
            },
            {type = 'row', label = 'Orçamento', value = 'orçamento', wikidata = {
                property = 'P2769',
                separator = 'new line',
                rank = 'valid',
                showdate = true
            }},
            {type = 'row', label = 'Patrocinador', singularlabel = 'Sponsor', plurallabel = 'Patrocinadores', property = 'P859'},
            {type = 'row', label = 'Marca das bicicletas', value = {'bicicleta', 'bicycles'}},
            {type = 'row', label = 'Componentes', value = {'componentes', 'components'}},
        }},
        {type = 'table', title = 'Pessoas chave', rows = {
            {type = 'row', label = 'Director geral', value = 'manager_gen', wikidata = {
                property = 'P505',
                conjtype = 'new line',
                showdate = true,
                linktopic = linktopic
            }},
            {type = 'row', label = 'Director técnico', value = 'dir_tech'},
            {
                type = 'row',
                label = 'Director(s) desportivo(s)',
                singularlabel = 'Director desportivo',
                plurallabel = 'Directores desportivos',
                value = function ( localdata )
                    local vals = {}
                    for i = 1, 10 do
                        local dir = localdata['manager' .. tostring(i)]
                        if dir then
                            table.insert(vals, dir)
                        end
                    end
                    if #vals > 0 then
                        return table.concat(vals, '<br />')
                    end
                end,
                wikidata = {
                    property = 'P286',
                    conjtype = 'new line',
                    showdate = true,
                    linktopic = linktopic
                }
            },
            {type = 'row', label = 'Terapeuta', value = 'sg1'},
            {type = 'row', label = 'Médico', value = 'médico'},
        }},
        formerNamesTable,
        {type = 'table', title = 'Equipamento', rows = {
            jersey(),
            jersey1()
        }}
    }
}