Saltar para o conteúdo

Módulo:Infobox/Funções/Competição desportiva

Permanently protected module
Origem: Wikipédia, a enciclopédia livre.
Documentação do módulo[ver] [editar] [histórico] [purgar]


Descrição

Este módulo tem funções auxiliares para criar infocaixas.

Uso

Outra documentação:

local p = {}
local item = require( 'Módulo:Infobox/Localdata' ).item
local wikidata = require "Módulo:Infobox/Wikidata"
local countrymod = require "Módulo:Country data"
local typeofteam = require "Módulo:Dicionário Wikidata/Typeofteam"

-- data da corrida para adaptar as bandeiras e nacionalidades dos participantes   
local raceDate = wikidata.formatStatements{
    entity = item,
    property = {'P580', 'P585'},
    numval = 1,
    displayformat = 'raw'
}

local function formatPerson(person) -- devolver o nome de uma pessoa precedido pela (s) bandeira (s) apropriada (s)

    local str = wikidata.formatEntity(person)

    -- recupera nacionalidade como armazenado em P27 (pessoas) ou P17 (equipes)
    local nationalities = wikidata.stringTable{entity = person, property = {'P27', 'P17'}, atdate = raceDate, displayformat = 'raw'}
    if not nationalities then
        return str
    end
   
    local flags = {}
    for i, nation in pairs(nationalities) do
        local flag, success = countrymod.standarddisplay(nation, {label = '-', date = 'default'})
        if success then
            str = flag .. ' ' .. str
        end
    end
    return str
end

function p.winnerRow(label, winnertype)
   
    local function wikidataval(winnertype)
        -- se você não conhece o qualificador, não use o Wikidata
        if not winnertype then
            return nil
        end
        local winners = wikidata.stringTable{
            entity = item,
            property = 'P1346',
            displayformat = 'raw',
            excludespecial = true,
            qualifier = 'P642',
            qualifiervalue = winnertype
        }
        if not winners then
            return nil
        end
        for i, winner in pairs(winners) do
            winners[i] = formatPerson(winner)
        end
        local str = table.concat(winners, '<br />')
        -- ajustra retrolink e cat
        str = wikidata.formatAndCat{value = str, entity = entity, property = 'P1346'}
        return str
    end
         
    return {type = 'row', label = label, value = param, wikidata = function() return wikidataval(winnertype) end}
end

function p.winnerRow2(label, param, winnertype)
   
    local function wikidataval()
        -- se você não conhece o qualificador, não use o Wikidata
        if not winnertype then
            return nil
        end
        local winners = wikidata.stringTable{
            entity = item,
            property = 'P1346',
            displayformat = 'raw',
            excludespecial = true,
            qualifier = 'P642',
            qualifiervalue = winnertype
        }
        if not winners then
            return nil
        end
        for i, winner in pairs(winners) do
            winners[i] = formatPerson(winner)
        end
        local str = table.concat(winners, '<br />')
        -- ajout rétrolien et cat
        str = wikidata.formatAndCat{value = str, entity = entity, property = 'P1346'}
        return str
    end
         
    return {type = 'row', label = label, value = param, wikidata = wikidataval}
end

function p.typeofteam()
    return {
        type = 'row',
        value = 'competição',
        wikidata = {
            property = 'P31',
            showdate = true,
            conjtype = '<br />',
            sorttype = 'chronological',
            speciallabels = typeofteam,
        },
        label = 'Estatuto',
        plurallabel = 'Estatuto'
    }
end

return p