Module:Infobox/Art
Apparence
[voir] [modifier] [historique] [purger]
Cette page définit un module d'infobox. Pour les conseils sur l'usage de ce module, voyez Modèle:Infobox Art.
La documentation de ce module est générée par le modèle {{Documentation module}}.
Elle est incluse depuis la page Modèle:Documentation module d'infobox. Veuillez placer les catégories sur cette page-là.
Les éditeurs peuvent travailler dans le bac à sable (modifier).
Voir les statistiques d'appel depuis le wikicode sur l'outil wstat et les appels depuis d'autres modules.
local geoloc = require 'Module:Infobox/Fonctions/Géolocalisation'
local general = require 'Module:Infobox/Fonctions'
local owner = require 'Module:Propriétaire'
local material = require 'Module:Matériau'
local linguistic = require 'Module:Linguistique'
local protected = require 'Module:Classement'
local wikidata = require 'Module:Interface Wikidata'.fromLua
local linktopic = 'en arts plastiques'
local function dimensions()
local dimensions = {
-- paramètre, abréviation à afficher dans l'en tête, prorpriété Wikidata, nom complet à afficher dans l'entête, stop
{'diamètre', 'diamètre', nil, 'Diamètre', true},
{ 'hauteur', 'H', 'P2048', 'Hauteur', false},
{'largeur', 'L', 'P2049', 'Largeur', false},
{'profondeur', 'l', nil, 'profondeur', false},
}
local data, dims = {}, {}
local label = 'Dimensions'
local unit = localdata['unité'] or 'cm'
local wikidataval = function(d) return wikidata.formatStatements{entity = 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 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 = item, property = propertyused, value = val}
end
return {
type = 'row',
label = label,
value = function() return val end
}
end
return {
maincolor = '#f9f9f9',
parts = {
{
type = 'title',
value = 'titre',
subtitle = 'titre original',
style = {['font-style'] = 'italic'} -- ajouter une option pour supprimer l'italique ?
},
general.mainimage("Article à illustrer Art"),
{type = 'table', rows = {
{
type = 'row',
label = 'Artiste',
plurallabel = 'Artistes',
value = 'artiste',
wikidata = function()
local property = 'P170'
local statements = wikidata.getClaims{entity = item, property = property}
if not statements then
return nil
end
local possiblequalifiers = {
P1773 = "attribué $to $person",
P1774 = "atelier $of $person",
P1775 = "suiveur $of $person",
P1776 = "cercle $of $person",
P1777 = "d'après $person", -- TODO : d'après LE Maître X
P1778 = "faux d'après $person",
P1779 = "$person (?)",
P1780 = "école $of",
P1877 = "d'après un œuvre $of",
}
local formattedvals = {}
for i, j in pairs(statements) do
local s -- valeur formatée
local v = wikidata.getmainid(j)
if j.qualifiers then
for k, l in pairs(possiblequalifiers) do
local t = wikidata.getFormattedQualifiers(j, {k})
if t then
local t2 = wikidata.getFormattedQualifiers(j, {k}, {link = '-'}) -- valeur sans lie, plus facile pour améliorer la grammaire
s = possiblequalifiers[k]
s = mw.ustring.gsub(s, '$to', 'à') -- à améliorer
s = mw.ustring.gsub(s, '$of', linguistic.of('', 'm', 's', false, t2))
s = mw.ustring.gsub(s, '$person', t)
s = mw.ustring.gsub(s, "d’ ", "d’") -- à cause d'un bug
break
end
end
end
if not s then
s = wikidata.formatStatement(j) -- ne pas mettre de lien Wikidata pour "anonyme"
end
table.insert(formattedvals, s)
end
local str = linguistic.conj(formattedvals) -- valeur formatée
return wikidata.formatAndCat{entity = item, property = property, value = str}, #formattedvals -- valeur + rétrolien, nombre de valeurs pour accord grammatical
end
},
{
type = 'row',
label = 'Date',
value = 'année',
wikidata = function() return wikidata.wikidataDate('P571', item, {linktopic = linktopic}) end -- affiche les dates de début et fin utilisées dans les qualificatifs
},
{
type = 'row',
label = 'Commanditaire',
plurallabel = 'Commanditaires',
value = 'commanditaire',
property = 'P88'
},
{
type = 'row',
label = 'Type',
value = 'type',
},
{
type = 'row',
label = 'Technique',
plurallabel= 'Techniques',
value = 'technique',
property = 'P2079'
},
{
type = 'row',
label = 'Matériau',
value = function(localdata, item)
if localdata['type'] or localdata['technique'] then -- la matériau est parfois contenu dans le paramètre "type", ne pas utiliser wikidata dans ce cas
return nil
end
return material.formatFromItem(item)
end
},
{
type = 'row',
label = 'Lieu de création',
plurallabel = 'Lieux de création',
value = 'lieu de création',
property = 'P1071'
},
dimensions(),
{
type = 'row',
label = 'Format',
value = 'format'
},
{
type = 'row',
label = 'Mouvement',
plurallabel = 'Mouvements',
value = 'style',
property = 'P135',
},
{
type = 'row',
label = 'Localisation',
value = function(localdata, item)
local museum, city, location, country = localdata['musée'], localdata['ville'], localdata['localisation'], localdata['pays']
location = linguistic.conj({museum, location, city}, 'comma')
country = linguistic.inparentheses(country)
if location or country then
return (location or '') .. ' ' .. (country or '')
end
return nil
end,
property = 'P276' -- devrait croiser P195 et utiliser l'arbitrary access pour le lieu
},
{
type = 'row',
label = 'Propriétaire',
plurallabel = 'Propriétaires',
value = 'propriétaire',
wikidata = function(item) return owner.formatFromItem(item) end
},
{
type = 'row',
label = 'Numéro d’inventaire',
value = 'inventaire',
property = 'P217'
},
--[[
{
type = 'row',
label = 'Représente',
value = 'représente',
wikidata = {property = 'P180', numval = '4', rank = 'best'}
},
]]--
{
type = 'row',
label = 'Inscription',
plurallabel = 'Inscriptions',
value = 'inscription',
wikidata = {property = 'P1684', conjtype = '<br />', numval = '3', rank = 'best'}
},
{
type = 'row',
label = 'Commentaire',
value = 'commentaire',
},
{
type = 'row',
label = 'Protection',
value = function(localdata) return localdata['protection'] or localdata['classement'] end,
wikidata = function(item) return protected.formattedList(item)end
},
geoloc.coordinates({maintenancecat = "Œuvre d'art géolocalisable sans coordonnées paramétrées"}),
}
},
geoloc.geoloc('default', '-'), -- le '-' indique de ne pas chercher automatiquement une carte si aucune n'est fournie dans |géolocalisation=
}
}