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

Descrição editar

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

Uso editar

Outra documentação:

local geoloc = require 'Módulo:Infobox/Funções/Geolocalização'
local general = require 'Módulo:Infobox/Funções'
local voice = require 'Módulo:Infobox/Funções/Pessoa'
local owner = require 'Módulo:Proprietário'
local material = require 'Módulo:Material'
local linguistic = require 'Módulo:Linguística'
local protected = require 'Módulo:Classificação'
local wikidata = require 'Módulo:Infobox/Wikidata'
local linktopic = 'nas artes plásticas'

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', 'p', 'P2610' , 'profundidade', false},
    }
    local data, dims = {}, {}
    local label = 'Dimensões'
    local unit = localdata['unidade'] or 'cm'
   
    local wikidataval = function(d)
        return wikidata.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 = wikidata.formatAndCat{entity = localdata.item, property = propertyused, value = val}
    end
       
    return {
        type = 'row',
        label = label,
        value = function() return val end
    }
end

-- Descrição audível dif de P990
local function descricao()

    local function selectsound()
          -- prioridade em português
          if wikidata.getClaims{entity = item, property = 'P989' } then
                return {property = 'P989' }
          end
      return {property = 'P989'}
    end
    return {
       type     = 'images',
       style      = {['padding-top'] = '25px'},--{['border-width'] = '10px', ['border-style'] = 'solid'},
       label    = 'Registo vocal',
       captionparameter = 'legenda voz',
       value    = 'voz',
       wikidata      = selectsound (),
       numval     = 1,
    }
end

return {
    maincolor = '#f9f9f9',
    parts = {
        general.title(),
        general.mainimage("!Artigos sem imagens"),
        {type = 'table', rows = {
            {
                type = 'row',
                label = 'Autor',
                plurallabel = 'Autores',
                value = {'artista', 'autor'},
                wikidata = {
                    property = 'P170',
                    statementformat = function(statement)
                       
                        local str
   
                        -- Começamos com os qualificadores (acessados, workshop etc.)
                        local possiblequalifiers = {
                            P1773 = "atribuído $to $creator",
                            P1774 = "oficina $of $creator",
                            P1775 = "seguidor $of $creator",
                            P1776 = "círculo $of $creator",
                            P1777 = "de acordo com o $creator", -- TODO : de acordo com o mestre X
                            P1778 = "falso de acordo com $creator",
                            P1779 = "$creator (?)",
                            P1780 = "escola $of",
                            P1877 = "de acordo com um trabalho $of",
                        }
   
                        if statement.qualifiers then
                            for qualif, text in pairs(possiblequalifiers) do
                                local creator = wikidata.getFormattedQualifiers(statement, {qualif})
                                if creator then
                                    str = text
                                    str = mw.ustring.gsub(str, '$to $creator', "a ".. creator)
                                    str = mw.ustring.gsub(str, '$of $creator', linguistic.of(creator))
                                    str = mw.ustring.gsub(str, '$creator', creator)
                                    break
                                end
                            end
                        end
                       
                        -- Senão, a via normal
                        if not str then
                            str = wikidata.formatStatement(statement, {speciallabels = {Q4233718 = "anónimo"}}) -- speciallabels para evitar o link padrão
                        end
                        return str
                        end
                }
            },
            {
                type = 'row',
                label = 'Data',
                value = {'data','ano'},
                wikidata = {
                    property = 'P571',
                    showqualifiers = {'P518'},
                    -- linktopic = linktopic,
                    sorttype = 'chronological',
                    conjtype = function()
                        if wikidata.getClaims{entity = item, property = 'P571', qualifier = {'P518'}} then
                            return "new line"
                        else
                            return "or"
                        end
                        end
                    }
            },
            {
                type = 'row',
                label = 'Tipo',
                plurallabel= 'Tipos',
                value = {'género', 'gênero', 'tipo'},
                property = 'P136'
            },
            {
                type = 'row',
                label = 'Encomendador',
                plurallabel = 'Encomendadores',
                value = 'encomendador',
                property = 'P88'
            },
            {
                type = 'row',
                label = 'Técnica',
                plurallabel= 'Técnicas',
                value = {'técnica', 'tecnica'},
                property = {'P186', 'P2079'}
            },
            {
                type = 'row',
                label = 'Material',
                value = function( localdata )
                    if localdata['tipo'] or localdata['técnica'] or localdata['tecnica'] then  -- o material é algumas vezes contido no parâmetro "type", não use wikidata neste caso
                        return nil
                    end
                    return material.formatFromItem(localdata.item)
                    end
            },
            {
                type = 'row',
                label = 'Local de criação',
                plurallabel = 'Locais de criação',
                value = 'local de criação',
                property = 'P1071'
            },
            dimensions,
   
            {
                type = 'row',
                label = 'Formato',
                value = 'formato'
            },
            {
                type = 'row',
                label = 'Movimento',
                plurallabel = 'Movimentos',
                value = 'estilo',
                property = 'P135',
            },
            {
                type = 'row',
                label = 'Localização',
                value = function(localdata)
                    local museum, city, location, country = localdata['museu'], localdata['cidade'], localdata['localização'], localdata['país']
                    location = linguistic.conj({museum, location, city}, 'comma')
                    if location == '-' then
                        -- desativando o uso de wikidata (porque não há necessidade de espaço depois)
                        return '-'
                    end
                    country = linguistic.inparentheses(country)
                    if location or country then
                        return (location or '') .. ' ' .. (country or '')
                    end
                    return nil
                end,
                property = 'P276' -- deve atravessar P195 e usar o acesso arbitrário para o lugar
            },
            {
                type = 'row',
                label = 'Proprietário',
                plurallabel = 'Proprietários',
                value = 'proprietário',
                wikidata = function() return owner.formatFromItem(item, {atdate = 'today'}) end
            },
            {
                type = 'row',
                label = 'Número de inventário',
                value = 'inventário',
                property = 'P217'
            },
    --[[
            {
                type = 'row',
                label = 'Representa',
                value = 'representa',
                wikidata = {property = 'P180', numval = '4', rank = 'best'}
            },
    ]]--
            {
                type = 'row',
                label = 'Inscrição',
                plurallabel = 'Inscrições',
                value = 'inscrição',
                wikidata = {property = 'P1684', conjtype = '<br />', numval = '3', rank = 'best'}
            },
            {   
                type = 'row',
                label = 'Commentário',
                value = 'commentário',
            },
            {
                type = 'row',
                label = 'Proteção',
                value = function(localdata) return localdata['proteção'] or localdata['classificação'] end,
                wikidata = function(item) return protected.formattedList(item)end
            },
            voice.voice(),
            descricao,
            geoloc.coordenadas{maintenancecat = ""},
        }},
        geoloc.geoloc('default', '-'), -- '-' indica não procurar automaticamente um mapa se nenhum for fornecido em | geolocalização =
    }
}