Aller au contenu

Module:Infobox/Art

Cette page fait l’objet d’une mesure de semi-protection étendue.
Une page de Wikipédia, l'encyclopédie libre.
Ceci est une version archivée de cette page, en date du 31 janvier 2016 à 20:17 et modifiée en dernier par Zolo (discuter | contributions) (intégration de la propriété Wikidata 'auteur présumé', des dates floues, et des liens vers la chronologie des arts plastiques (voir PDD)). Elle peut contenir des erreurs, des inexactitudes ou des contenus vandalisés non présents dans la version actuelle.

 Documentation[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.


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 v = wikidata.formatAndCat{entity = item, property = 'P170'} -- créateur
				if v then
					return v
				end
				v = wikidata.formatStatements{entity = item, property = 'P1779'} -- créateur présumé
				if not v then
					return
				end
				v = v .. ' (?)'
				return wikidata.formatAndCat{value = v, property = 'P1770', entity = item}
				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=
	}
}