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


Descrição

Este Módulo tem funções auxiliares para criar infocaixas. Ver {{Info/Monumento/Wikidata}}

Uso

Outra documentação:

local geoloc = require 'Módulo:Infobox/Funções/Geolocalização'

local building = require "Module:Infobox/Funções/Edifício"

local general = require "Módulo:Infobox/Funções"
local linguistic = require 'Módulo:Linguística'
local localdata = require "Módulo:Infobox/Localdata"
local wd = require "Módulo:Infobox/Wikidata"

local formats = {
        --{ícone do mapa, ícone do cabeçalho, cor do título, cor da legenda, texto colorido)
    Q1144661 = {'circle-stroked', nil, '#B0C4DE', '#E1E1E1', '#000000', 'defaut'}, -- attraction
    Q18761864 = {'bank', nil, '#E1E1E1', '#E1E1E1', '#000000', 'defaut'}, -- bâtiment bancaire
    Q655686 = {'shop', nil, '#E1E1E1', '#E1E1E1', '#000000', 'defaut'}, -- bâtiment commercial
    Q856584 = {'library', nil, '#E1E1E1', '#E1E1E1', '#000000', 'defaut'}, -- bibliothèque
    Q622425 = {'music', nil, '#E1E1E1', '#E1E1E1', '#000000', 'defaut'}, -- boîte de nuit
    Q274393 = {'bakery', nil, '#E1E1E1', '#E1E1E1', '#000000', 'defaut'}, -- boulangerie
    Q3649129 = {'warehouse', nil, '#E1E1E1', '#E1E1E1', '#000000', 'defaut'}, -- cabane
    Q876852 = {'playground', nil, '#E1E1E1', '#E1E1E1', '#000000', 'defaut'}, -- centre de vacances ou de loisirs
    Q751876 = {'building', 'castelo', '#00507f', '#ffffff', '#ffffff', 'defaut'}, --château
    Q23413 = {'circle-stroked', 'castelo', '#00507f', '#ffffff', '#ffffff', 'defaut'}, --château-fort
    Q105731 = {'barragem', 'mapa', '#E1E1E1', '#E1E1E1', '#000000', 'defaut'}, -- écluse
    Q3914 = {'edifício', nil, '#E1E1E1', '#E1E1E1', '#000000', 'defaut'}, -- escola
    Q16970 = {'igreja', 'edificioreligioso', '#E1E1E1', '#E1E1E1', '#000000', 'defaut'}, -- igreja
    Q67166646 = {'circle-stroked', nil, '#E1E1E1', '#E1E1E1', '#000000', 'defaut'}, -- entrée de grotte
    Q1303167 = {'edifício', nil, '#E1E1E1', '#E1E1E1', '#000000', 'defaut'}, -- grange
    Q1777951 = {'edifício', nil, '#E1E1E1', '#E1E1E1', '#000000', 'defaut'}, -- hangar à bateaux
    Q1021645 = {'edifício', nil, '#E1E1E1', '#E1E1E1', '#000000', 'defaut'}, -- immeuble de bureaux
    Q3947 = {'edifício', nil, '#E1E1E1', '#E1E1E1', '#000000', 'defaut'}, -- maison
    Q37654 = {'shop', nil, '#E1E1E1', '#E1E1E1', '#000000', 'defaut'}, -- marché
    Q32815 = {'mosque', 'edificioreligioso', '#E1E1E1', '#E1E1E1', '#000000', 'defaut'}, -- minaret
    Q4989906 = {'monumento', 'mapa', '#E1E1E1', '#E1E1E1', '#000000', 'defaut'}, -- monument
    Q32815 = {'mosque', 'edificioreligioso', '#E1E1E1', '#E1E1E1', '#000000', 'defaut'}, --mosquée
    Q170980 = {'monumento', 'mapa', '#E1E1E1', '#E1E1E1', '#000000', 'defaut'}, -- obélisque
    Q3689421 = {'edifício', nil, '#E1E1E1', '#E1E1E1', '#000000', 'defaut'}, -- office de commercialisation touristique
    Q1137809 = {'museum', nil, '#E1E1E1', '#E1E1E1', '#000000', 'defaut'}, -- palais de justice
    Q509028 = {'circle-stroked', nil, '#E1E1E1', '#E1E1E1', '#000000', 'defaut'}, -- ranch
    Q41253 = {'edifício', nil, '#E1E1E1', '#E1E1E1', '#000000', 'defaut'}, -- salle de cinéma
    Q839954 = {'circle-stroked', 'mapa', '#CCCCAA', '#CCCCAA', '#000000', 'defaut'}, -- site archéologique
    Q96102071 = {'edifício', 'mapa', '#CCCCAA', '#CCCCAA', '#000000', 'defaut'}, -- site d'observation des animaux
    Q36728566 = {'edifício', nil, '#E1E1E1', '#E1E1E1', '#000000', 'defaut'}, -- station de rangers
    Q205495 = {'industrial', nil, '#E1E1E1', '#E1E1E1', '#000000', 'defaut'}, -- station-service
    Q34627 = {'sinagoga', 'edificioreligioso', '#E1E1E1', '#E1E1E1', '#000000', 'defaut'}, -- synagogue
    Q267596 = {'igreja', 'mapa', '#E1E1E1', '#E1E1E1', '#000000', 'defaut'}, -- temple grec
    Q849706 = {'aeroporto', 'mapa', '#E1E1E1', '#E1E1E1', '#000000', 'defaut'}, -- terminal aéroportuaire
    Q27108230 = {'campsite', nil, '#E1E1E1', '#E1E1E1', '#000000', 'defaut'}, -- terrain de camping
    Q813966 = {'banheiros', nil, '#E1E1E1', '#E1E1E1', '#000000', 'defaut'}, -- toilettes publiques
    Q748998 = {'fire-station', nil, '#E1E1E1', '#E1E1E1', '#000000', 'defaut'}, -- tour de guet contre les incendies
    Q870 = {'rail', nil, '#E1E1E1', '#E1E1E1', '#000000', 'defaut'}, -- train
    Q83405 = {'industrial', nil, '#E1E1E1', '#E1E1E1', '#000000', 'defaut'}, -- usine
    Q208502 = {'rail', nil, '#E1E1E1', '#E1E1E1', '#000000', 'defaut'}, -- véhicule ferroviaire remorqué
    Q3024331 = {'edificioreligioso', 'mapa', '#E00000', '#E00000', '#FFFFFF', 'defaut'}, -- commanderie templière
    Q174981 = {'edificioreligioso', 'mapa', '#000000', '#000000', '#FFFFFF', 'defaut'}, -- commanderie hospitalière
    default = {'monumento', 'mapa', '#E1E1E1', '#E1E1E1', '#000000', 'defaut'}
}

local function wdformat() --retorna uma tabela contendo a cor principal da infobox e o ícone do título
        local wtypes = wd.stringTable{ -- obtenha o Qid das profissões
                entity = localdata.item,
            property = 'P31',
            displayformat = 'raw',
            excludespecial = true
        }
        local default = formats.default
        wtypes = wd.addVals(wtypes or {}, {property = 'P279'}, 1) -- usamos também a subclasse
        for i, item in pairs(wtypes or {}) do
                if formats[item] then
                        return formats[item]
            end
        end
        return default
end
local function setcharte()
    local charte = localdata['charte']
    if charte then
        for i, j in pairs(formats) do
            if j[2] == charte then
                return j
            end
        end
    end
    return wdformat()
end

local function closure() -- évite les doublons, building.demolition() et building.closure() prennent en compte la propriété P576
    if not wd.formatStatements{property = 'P576'} or localdata['fermeture'] or localdata['date de fermeture'] then
        return building.closure()
    end
end

local function fondation()
    if not (localdata['data de construção'] or localdata['construção']) then
        return {type = 'row', label = 'Fundação', value = 'fundação', wikidata = {property = 'P571'}}
    else
        return building.fondation()
    end
end

local function dimensions( localdata )
    local dimensions = {
        -- parâmetro, abreviação para exibir no cabeçalho, nome Wikidata, nome completo para exibir no cabeçalho, parar
        {{'diâmetro_cm', 'dimensões'}, 'P2386', nil, 'Diâmetro', true},
        {'altura', 'A', 'P2048', 'Altura', false},
        {'largura', 'L', 'P2049', 'Largura', false},
        {'profundidade', 'l', 'P2610' , 'profundidade', false},
    }
    local data, dims = {}, {}
    local label = 'Dimensões'
    local unit = localdata['unidade'] or 'm'
 
    local wikidataval = function(d)
        return wd.formatStatements{
            entity = localdata.item,
            showunit = '-',
            targetunit = unit,
            addcat = true,
            property = d
        }
    end
    local propertyused = nil
 
    for i, j in pairs(dimensions) do
        local val = localdata[j[1]]
        if localdata.item and j[3] and not val then
            val = wikidataval(j[3])
            if val then
                propertyused = j[3]
            end
        end
        if val then
            table.insert(data, val)
            table.insert(dims, i)
            if j[5] then
                break
            end
        end
    end
    if #data == 0 then
        return nil
    end
    if #data == 1 then
        label = dimensions[dims[1]][4]
    else
        for i, j in pairs(dims) do dims[i] = dimensions[j][2] end
        label = label .. linguistic.inparentheses(linguistic.conj(dims, ' × '))
    end

    local val = linguistic.conj(data, ' × ') .. ' ' .. unit
    if propertyused then
        val = wd.formatAndCat{entity = localdata.item, property = propertyused, value = val}
    end
      
    return {
        type = 'row',
        label = label,
        value = function() return val end
    }
end

local displayformat = setcharte()

return
    {
        maincolor = displayformat[3],
        secondcolor = displayformat[4],
        thirdcolor = displayformat[5],
        parts =
        {
        general.title(displayformat[2], nil, 'nome local', nil),
                general.logo(),
                building.mainimage('!Artigos de sociedade sem imagens'),
                {type = 'table', title = 'Apresentação', rows = {
                {type = 'row', label = 'Tipo', value = 'tipo', blockers = {'destino inicial', 'destino final'},
                    wikidata = {property = 'P31', defaultlinkquery = 'P279', showqualifiers = "P580",
                        excludevalues = {'Q41176', 'Q811979', 'Q13226383','Q3395377','Q19860854'}
                    } --non affichés : "bâtiment", "structure architecturale", "équipement", "monument ancien", "bâtiment ou structure détruit"
                },
                {type = 'row', label = 'Parte de', value = 'partie de',
                    wikidata = {property = 'P361', defaultlinkquery = 'P279', showqualifiers = "P580"}
                },
                        {type = 'row', label = 'Nomes precedentes', value = 'nomes precedentes'},
                    {type = 'row', label = 'Sobrenome(s)', value = 'sobrenome'},
                    {type = 'row', label = 'Nome completo', value = 'nome completo'},
                    {type = 'row', label = 'Culto', value = 'culto'},
            {type = 'row', label = 'Civilização', plurallabel = 'Civilizações', value = 'civilização', wikidata = {property = 'P2596'}},
                    {type = 'row', label = 'Destino inicial', value = 'destino inicial'},
                    {type = 'row', label = 'Destino atual', value = 'destino atual'},
             fondation(),
                    {type = 'row', label = 'Anexos', value = 'anexos'},
                    {type = 'row', label = 'Diocese', value = 'diocese', property = 'P708'},
                    {type = 'row', label = 'Dedicado', plurallabel = 'Dedicados', value = 'dedicado', property = 'P825'},
                    {type = 'row', label = 'Comemora', value = 'comemora', property = 'P547'},
            {type = 'row', label = 'Anuncio', value = 'anuncio', wikidata = {property = 'P6291'}},
                building.orientation(),
                {type = 'row', label = 'Periódo', value = 'periódo', wikidata = {property = 'P2348'}},
                    building.archistyle(),
                    building.creator(),
                    building.material(),
            building.cornerstonelaying(),
                    building.construction(),
                    building.opening(),
                    building.reconstruction(),
                    building.relocation(),
                    building.renovation(),
            closure(),
                    building.demolition(),
                    {type = 'row', label = 'Patrocinador', value = 'patrocinador', property = 'P88'},
                    dimensions,
            building.recordheld(),
            building.religion(),
            {type = 'row', label = 'Ordem religiosa', plurallabel = 'Ordens religiosas', value = 'ordem religiosa', wikidata = {property = 'P611'}},
            {type = 'row', label = 'Ocupante', plurallabel = 'Ocupantes', value = 'occupant', wikidata = {property = 'P466', showdate = true}},
                    building.owner(),
            building.usage(),
            {type = 'row', label = 'Atravessa', wikidata = {property = 'P177'}},
            {type = 'row', label = 'Próxima travessia a montante', wikidata = {property = 'P2673'}},
            {type = 'row', label = 'Próxima travessia a jusante', wikidata = {property = 'P2674'}},
            {type = 'row', label = 'Permite a passagem', wikidata = {property = 'P2505'}},
                {type = "row",
                    label = {ms = 'Directeur des fouilles', fs = 'Directrice des fouilles',
                        mp = 'Directeurs des fouilles', fp = 'Directrices des fouilles',
                        default = 'Direction des fouilles'
                    },
                    value = "fouilles",
                    wikidata = {property = "P4345", showdate = true, stilltrue = false}
                },
                building.protection(),
                {type = 'row', label = '[[Trinomial Smithsonian|Smithsonian]]', value = 'Smithsonian', wikidata = {property = 'P3518'}},
                {type = 'row', label = "[[Office de tourisme|Informations]]", value = "informations", wikidata = {property = 'P2872', numval = '3'}},
                building.visitors(),
                {type = 'row', label = 'Estado de conservação', value = 'estado de conservação', wikidata = {property = 'P5816', ucfirst = '-'}},
                {type = 'row', label = 'Substitui', value = 'substitui', wikidata = {property = {'P1398','P1365'}}},
                {type = 'row', label = 'Substituído por', value = 'substituído por', wikidata = {property = {'P167','P1366'}, showdate = true}},
                building.website('site'),
                }
            },
                building.unesco(),
            {type = 'table', title = 'Localização', rows = {
                building.adminlocation(),
                {type = 'row', label = 'Região histórica', value = 'região histórica', wikidata = {property = 'P6885', numval = '1'}},
                {type = 'row', label = 'Altitude', value = 'altitude',
                    wikidata = {property = 'P2044', targetunit = 'metro', conjtype = ' ou ', rounding = '0'}
                },
                {type = 'row', label = 'Localizado', value = 'localizado', wikidata = {property = 'P706', numval = '1'}},
                building.mountainrange(),
                building.onshoreof(),
                building.watershed(),
                building.protectedarea(),
                }
            },
            {type = 'table', title = 'Accesso e transporte', rows = {
                building.transport(),
                },
            },
            {type = 'table', rows = {
                building.coordenadas(),
                }
            },
        geoloc.geoloc('displayformat[1]', '-'), -- '-' indica não procurar automaticamente um mapa se nenhum for fornecido em | geolocalização =
    }
}