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 24 mai 2019 à 14:06 et modifiée en dernier par Zolo (discuter | contributions) (correction + suprrime le "stop" qui arrête l'affichage des autres dimensions si le diamètre est affiché, ça complique le code et ne me parait pas logique. Il faudrait retrouver les cas où c'est utile pour voir ce qu'on a comme autre solution). 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:Wikidata'
local linktopic = 'en arts plastiques'

local function dimensions( localdata )
	local dimensions = {
		-- paramètre, abréviation à afficher dans l'en tête, prorpriété Wikidata, nom complet à afficher dans l'entête
		{'diamètre', 'Diam', 'P2386', 'Diamètre'},
		{ 'hauteur', 'H', 'P2048', 'Hauteur'},
		{'largeur', 'L', 'P2049', 'Largeur'},
		{'profondeur', 'l', 'P2610' , 'Profondeur'},
	}
	local data, dims = {}, {}
	local label = 'Dimensions'
	local unit = localdata['unité'] 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

return {
	maincolor = '#f9f9f9',
	parts = {
		{
			type = 'title',
			value = function(localdata) 
				return localdata['titre'] 
					or wikidata.getLabel(localdata.item) and mw.language.getContentLanguage():ucfirst( wikidata.getLabel(localdata.item) )
					or mw.title.getCurrentTitle().text
			end,
			subtitle = 'titre original',
		},
		general.mainimage("Article à illustrer Art"),
		{type = 'table', rows = {
			{
				type = 'row',
				label = 'Artiste',
				plurallabel = 'Artistes',
				value = 'artiste',
				wikidata = {
					property = 'P170',
					statementformat = function(statement)
						
						local str
	
						-- On commence par les qualificatifs (attibué à, atelier etc.)
						local possiblequalifiers = {
							P1773 = "attribué $to $creator", 
							P1774 = "atelier $of $creator",
							P1775 = "suiveur $of $creator",
							P1776 = "cercle $of $creator",
							P1777 = "d'après $creator", -- TODO : d'après LE Maître X
							P1778 = "faux d'après $creator",
							P1779 = "$creator (?)",
							P1780 = "école $of",
							P1877 = "d'après un œuvre $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', "à ".. creator)
									str = mw.ustring.gsub(str, '$of $creator', linguistic.of(creator))
									str = mw.ustring.gsub(str, '$creator', creator)
									break
								end
							end
						end
						
						-- Sinon, la voie normale
						if not str then
							str = wikidata.formatStatement(statement, {speciallabels = {Q4233718 = "anonyme"}}) -- speciallabels pour éviter le lien par défaut
						end
						return str
						end
				}
			},
			{
				type = 'row',
				label = 'Date',
				value = 'année',
				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 = 'Civilisation',
				plurallabel = 'Civilisations',
				value = 'civilisation',
				property = 'P2596'
			},
			{
				type = 'row',
				label = 'Commanditaire',
				plurallabel = 'Commanditaires',
				value = 'commanditaire',
				property = 'P88'
			},
			{
				type = 'row',
				label = 'Type',
				value = 'type',
				property = 'P136',
			},
			{
				type = 'row',
				label = 'Technique',
				plurallabel= 'Techniques',
				value = 'technique',
				property = 'P2079'
			},
			{
				type = 'row',
				label = 'Matériau',
				value = function( localdata )
					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(localdata.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',
				property = 'P1419',
			},
			{
				type = 'row',
				label = 'Étude pour',
				value = 'étude pour',
				property = 'P6606',
			},
		    {
				type = 'row',
				label = 'Inspiration',
			    value = 'inspiration',
				wikidata ={property = 'P941' , conjtype="new line"},
			},
			{
				type = 'row',
				label = 'Série',
				plurallabel = 'Séries',
				value = 'série',
				property = 'P179',
			},
			{
				type = 'row',
				label = 'Pendant',
				plurallabel = 'Pendants',
				value = 'pendant',
				property = 'P1639',
			},
			{
				type = 'row',
				label = 'Verso',
				value = 'verso',
				wikidata = {property = {'P2681', 'P2682'}},
			},
				{
				type = 'row',
				label = 'Mouvement',
				plurallabel = 'Mouvements',
				value = 'style',
				property = 'P135',
			},
			{
				type = 'row',
				label = 'Propriétaire',
				plurallabel = 'Propriétaires',
				value = 'propriétaire',
				wikidata = function() return owner.formatFromItem(item, {atdate = 'today'}) end
			},
			{
				type = 'row',
				label = 'Collection',
				plurallabel = 'Collections',
				value = 'collection',
				property = 'P195'
			},
			{
				type = 'row',
				label = 'N° d’inventaire',
				value = 'inventaire',
				property = 'P217'
			},
			{
				type = 'row',
				label = 'Localisation',
				value = function(localdata)
					local museum, city, location, country = localdata['musée'], localdata['ville'], localdata['localisation'], localdata['pays']
					location = linguistic.conj({museum, location, city}, 'comma')
					if location == '-' then
						-- désactivation de l'utilisation de wikidata (car il  ne faut pas d'espace après)
						return '-'
					end
					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 = 'Modèle',
				plurallabel = 'Modèles',
				value = 'modèle',
				property = 'P2634'
			},
	--[[
			{
				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=
	}
}