Moduuli:Fr:Infobox/Art

Wikipediasta
Siirry navigaatioon Siirry hakuun
Sininen ämpäri
Taiteilija
Päivämäärä
View and modify data on Wikidata
Materiaali
Mitat (K × L)
69,5 × 56 cmView and modify data on Wikidata
Kokoelma
UnknownView and modify data on Wikidata
Sijainti

local geoloc = require 'Moduuli:Fr:Infobox/Fonctions/Géolocalisation'
local general = require 'Moduuli:Fr:Infobox/Fonctions'
local owner = require 'Moduuli:Fr:Propriétaire'
local material = require 'Moduuli:Fr:Matériau'
local linguistic = require 'Moduuli:Fr:Linguistique'
local protected = require 'Moduuli:Fr:Classement'
local wikidata = require 'Moduuli:Fr: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, stop
		{'halkaisija', 'P2386', nil, 'Halkaisija', true},
		{'korkeus', 'K', 'P2048', 'Korkeus', false},
		{'leveys', 'L', 'P2049', 'Leveys', false},
		{'syvyys', 'S', 'P2610' , 'Syvyys', false},
	}
	local data, dims = {}, {}
	local label = 'Mitat'
	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 {
	parts = {
		general.title('entete map', {['font-style'] = 'italic'}),
		general.mainimage("Teoksen kuva"),
		--[[
		{
			type = 'title',
			value = 'titre',
			subtitle = 'titre original',
			style = {['font-style'] = 'italic'} -- ajouter une option pour supprimer l'italique ?
		},
		--]]
		{type = 'table', rows = {
			{
				type = 'row',
				label = 'Taiteilija',
				plurallabel = 'Taiteilijat',
				value = 'taiteilija',
				wikidata = {
					property = 'P170',
					statementformat = function(statement)
						
						local str
	
						-- On commence par les qualificatifs (attibué à, atelier etc.)
						local possiblequalifiers = {
							P1773 = "sanottu $creator tekemäksi", 
							P1774 = "ateljee $creator",
							P1775 = "$creator seuraaja",
							P1776 = "$creator piiri",
							P1777 = "$creator mukaan", -- TODO : d'après LE Maître X
							P1778 = "virheellisesti $creator mukaan",
							P1779 = "$creator (?)",
							P1780 = "koulu",
							P1877 = "teoksen mukaan",
						}
	
						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 = 'Päivämäärä',
				value = 'vuosi',
				wikidata = {
					property = 'P571',
					showqualifiers = {'P518'},
					sorttype = 'chronological'
				}
			},
			{
				type = 'row',
				label = 'Lajityyppi',
				plurallabel = 'Lajityypit',
				value = 'lajityyppi',
				property = 'P136',
			},
			{
				type = 'row',
				label = 'Tilaaja',
				plurallabel = 'Tilaajat',
				value = 'tilaaja',
				property = 'P88'
			},
			{
				type = 'row',
				label = 'Tyyppi',
				value = 'tyyppi',
			},
			{
				type = 'row',
				label = 'Tekniikka',
				plurallabel= 'Tekniikat',
				value = 'tekniikka',
				property = 'P2079'
			},
			{
				type = 'row',
				label = 'Materiaali',
				value = function( localdata )
					if localdata['tyyppi'] or localdata['tekniikka'] 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 = 'Valmistuspaikka',
				plurallabel = 'Valmistuspaikat',
				value = 'valmistuspaikka',
				property = 'P1071'
			},
			dimensions,
	
			{
				type = 'row',
				label = 'Formaatti',
				value = 'formaatti'
			},
			{
				type = 'row',
				label = 'Taidesuuntaus',
				plurallabel = 'Taidesuuntaukset',
				value = 'tyyli',
				property = 'P135',
			},
			{
				type = 'row',
				label = 'Kokoelma',
				plurallabel = 'Kokoelmat',
				value = 'kokoelma',
				property = 'P195'
			},
			{
				type = 'row',
				label = 'Sijainti',
				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 = 'Omistaja',
				plurallabel = 'Omistajat',
				value = 'omistaja',
				wikidata = function() return owner.formatFromItem(item, {atdate = 'today'}) end
			},
			{
				type = 'row',
				label = 'Inventaarionumero',
				value = 'inventaarionumero',
				property = 'P217'
			},
	--[[
			{
				type = 'row',
				label = 'Esittää',
				value = 'esittää',
				wikidata = {property = 'P180', numval = '4', rank = 'best'}
			},
	]]--
			{
				type = 'row',
				label = 'Merkintä',
				plurallabel = 'Merkinnät',
				value = 'merkintä',
				wikidata = {property = 'P1684', conjtype = '<br />', numval = '3', rank = 'best'}
			},
			{	
				type = 'row',
				label = 'Kommentti',
				value = 'kommentti',
			},
			{
				type = 'row',
				label = 'Suojeltu',
				value = function(localdata) return localdata['suojeltu'] or localdata['luokitus'] end,
				wikidata = function(item) return protected.formattedList(item)end
			},
			geoloc.coordinates{maintenancecat = "Paikannettavissa oleva taideteos, jolta puuttuu koordinaatit", displaytitle='-'},
		}},
		geoloc.geoloc('default', '-'), -- le '-' indique de ne pas chercher automatiquement une carte si aucune n'est fournie dans |géolocalisation=
	}
}