Module:Infobox/Usine
Wikimedia module / De Wikipedia, l'encyclopédie encyclopedia
local building = require "Module:Infobox/Fonctions/Bâtiment" local general = require "Module:Infobox/Fonctions" local localdata = require "Module:Infobox/Localdata" local linguistic = require "Module:Linguistique" local convert = require "Module:Conversion" local formatnum = require "Module:Format".do_formatnum local wd = require "Module:Wikidata"
local plurallabels = { Q42889 = "véhicules", }
local function keyFigure(statement) -- à essayer de faire de manière plus simple et rationnelle 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('Article à illustrer Usine'),
{type = 'table', title = 'Installations', rows = {
{type = 'row', label = "Type d'usine", value = "type d'usine", wikidata = {property = 'P31'}},
{type = 'row', label = "Superficie",
value = function() if localdata['superficie'] then return convert.displayvalue(localdata['superficie'], 'ha') end end,
wikidata = {property = 'P2046', targetunit = 'hectare'}
},
}
},
{type = 'table', title = 'Fonctionnement', rows = {
{type = 'row', label = 'Opérateur', value = 'opérateur', wikidata = {property = 'P137', sorttype = 'chronological', rank = 'valid', showdate = true, conjtype = '
'}},
{type = 'row', label = 'Effectif',
value =
function()
if (not localdata['effectif']) then
return nil
end
local n = localdata['effectif']
if tonumber(n) then
n = formatnum(n)
end
local dat = localdata['date effectif']
return linguistic.conj({n, linguistic.inparentheses(dat)}, " ")
end,
wikidata = {property = 'P1128', sorttype = 'chronological', rank = 'valid', showdate = true, conjtype = '
'}},
{type = 'row', label = "Date d'ouverture", value = "date d'ouverture", wikidata = {property = 'P1619'}},
{type = 'row', label = "Date de fermeture", value = "date de fermeture", wikidata = {property = 'P3999'}},
{type = 'row', label = "Destination actuelle", value = 'destination actuelle'},
},
},
{type = 'table', title = 'Production', rows = {
{type = 'row', label = 'Produits', value = 'produits', wikidata = {property = 'P1056'}},
{type = 'row', label = 'Marques', value = 'marques', wikidata = {property = 'P1716'}},
{type = 'row', label = "Modèles", value = "modèles"},
{type = 'row', label = "Production", sorttype = 'chronological',
value = function()
local val, dat = localdata['production'], localdata['date production']
return linguistic.conj({val, linguistic.inparentheses(dat)}, " ")
end,
wikidata = {
property = "P2746",
conjtype = "new line",
statementformat = function(statement) return keyFigure(statement) end
}
}, } }, {type = 'table', title = 'Localisation', rows = { function() if localdata['localité'] then -- paramètre spécifique à ce module, à déprécier ? return {type = 'multi', rows = { {type = 'row', label = 'Situation', value = function() return localdata['localité'] .. ' ' .. (linguistic.inparentheses(localdata['région']) or ) end}, building.country(), } } end return building.adminlocation() end, building.coordinates(), }, }, building.geoloc({pointtype = "usine", marker = 'industry'}), } }