Módulo:Infobox/Fábrica

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


Descrição[editar código-fonte]

Este Módulo tem funções auxiliares para criar infocaixas. Ver {{Info/Fábrica}}

Uso[editar código-fonte]

Outra documentação:

local building = require "Módulo:Infobox/Funções/Edifício"
local general = require "Módulo:Infobox/Funções"
local localdata = require "Módulo:Infobox/Localdata"
local linguistic = require "Módulo:Linguística"
local convert = require "Módulo:Conversão"
local formatnum = require "Módulo:Formato".do_formatnum
local wd = require "Módulo:Infobox/Wikidata"

local plurallabels = {
    Q42889 = "veículos",
}

local function keyFigure(statement) -- para tentar fazer isso de uma maneira mais simples e racional
    local qty, unit
    if statement.qualifiers and statement.qualifiers["P1092"] then
        qty = statement.qualifiers["P1092"][1].datavalue.value.amount
        unit = statement.qualifiers["P1092"][1].datavalue.value.unit
        if unit == '1' then
            unit = nil
        end
        if unit then
            unit = mw.ustring.sub(unit, mw.ustring.find(unit, "Q"), -1)
        end
    end
    if qty and (tonumber(qty) > 1) then
        speciallabels = plurallabels
    end
    local product = wd.formatStatement(statement, {speciallabels = speciallabels})
    local val = convert.displayvalue(qty, unit, {showunit = "long", }, product)
    
    local date = wd.getFormattedDate(statement)
    if date then
            date = linguistic.inparentheses(date)
    end
    return linguistic.conj({val, date}, " ")
end
    

return
    {
    parts =
        {
            general.title(),
            building.mainimage('!Artigos sem imagens'),
            {type = 'table', title = 'Instalações', rows = {    
                {type = 'row', label = "Tipo de fábrica", value = "tipo de fábrica", wikidata = {property = 'P31'}},
                {type = 'row', label = "Superfície",
                    value = function() if localdata['superfície'] then return convert.displayvalue(localdata['superfície'], 'ha') end end,
                    wikidata = {property = 'P2046', targetunit = 'hectare'}
                },
                }
            },
            {type = 'table', title = 'Funcionamento', rows = {
                {type = 'row', label = 'Operador', value = 'operador', wikidata = {property = 'P137', rank = 'valid', showdate = true, conjtype = '<br />'}},
                {type = 'row', label = 'Efectivo',
                    value =
                    function()
                        if (not localdata['efectivo']) then
                            return nil
                        end
                        local n = localdata['data efectivo']
                        if tonumber(n) then
                            n = formatnum(n)
                        end
                        local dat = localdata['data efectivo']
                        return linguistic.conj({n, linguistic.inparentheses(dat)}, " ")
                        end,
                    wikidata = {property = 'P1128', rank = 'valid', showdate = true, conjtype = '<br />'}},
                {type = 'row', label = "Data de abertura", value = "data de abertura", wikidata = {property = 'P1619'}},
                {type = 'row', label = "Date de fecho", value = "date de fecho", wikidata = {property = 'P3999'}},
                {type = 'row', label = "Destino actual", value = 'destino actual'},
                },
            },
            {type = 'table', title = 'Produção', rows = {
                {type = 'row', label = 'Produtos', value = 'produtos'},
                {type = 'row', label = 'Marcas', value = 'marcas', wikidata = {property = 'P1716'}},
                {type = 'row', label = "Modelos", value = "modelos"},
                {type = 'row', label = "Produção",
                    value = function()
                        local val, dat = localdata['produção'], localdata['data produção']
                        return linguistic.conj({val, linguistic.inparentheses(dat)}, " ")
                    end,
                    wikidata = {
                        property = "P2746",
                        conjtype = "new line",
                        statementformat = function(statement) return keyFigure(statement) end
                    }
                        
                    },
                }
        },
        {type = 'table', title = 'Localização', rows = {
                building.country(),
                building.adminlocation(),
                building.coordenadas(),
            },
        },
        building.geoloc({pointtype = "usina", marker = 'industrial'}),
    }
}