Aller au contenu

Module:Infobox/Ouvrage

Cette page est semi-protégée.
Une page de Wikipédia, l'encyclopédie libre.
Ceci est une version archivée de cette page, en date du 9 mars 2020 à 23:37 et modifiée en dernier par Orlodrim (discuter | contributions) (Retrait de l'inclusion de Module:Infobox/Fonctions/Personne, puisque la fonction title ne fait qu'appeler celle de Module:Infobox/Fonctions. Remplacement de "person" par "work" vu que c'est ce dont il est question.). 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 Ouvrage.


local localdata = require 'Module:Infobox/Localdata'
local general = require "Module:Infobox/Fonctions"
local wikidata = require "Module:Wikidata"
local linguistic = require "Module:Linguistique"
local convert = require "Module:Conversion"

local function italics(query)
	local val = wikidata.formatAndCat(query)
	if val then
		return '<i>' .. val .. '</i>'
	end
end

local function isNotInFrench(claim)
	local snak = claim.mainsnak
	if snak.snaktype == 'value' and snak.datatype == 'monolingualtext' then
		return snak.datavalue.value.language ~= 'fr'
	end
	return true
end

local occupationformats = {
	--{élément Wikidata, nom charte, couleur titre, couleur sous-titre, couleur texte, icône)  doivent être classés du plus spécifique au plus général
    {'Q131569' , 'traité' , '#E1E1E1' , '' , '' , ''},
    {'Q5185279' , 'poème', '#C4698F', '', '', 'auteur'},
    {'Q482' , 'poésie', '#C4698F', '', '', 'auteur'},
    {'Q49084', 'nouvelle' , '#FFE680' , '' , '' , 'auteur'},
    {'Q20730955' , 'conte' , '#70759A', '' , '#FFFFFF' , ''},
    {'Q56028349' , 'comic' , '#800000', "#FF3040", '#FFFFFF' , 'bd'},
    {'Q838795' , 'strip' , '#800000', "#FF3040", '#FFFFFF' , 'bd'},
    {'Q1004' , 'bd' , '#FFDD55', "#FFEEAA", '#000000' , 'bd'},
	{'Q8274' , 'manga' , '#9BD1FF' , '#C3E2FF' , '' , 'bd'},
	{'Q25379' , 'théâtre' , '#B03030' , '' , '#FFFFFF' , 'persofiction'},
	{'Q685935' , 'revue' , '#DDFFCC' , '' , '' , 'communication'},
	{'Q642946' , 'livre-jeu' , '#E8E8E8' , '' , '' , ''},
	{'Q2085381' , 'maison d\'édition' , '#8E5434' , '' , '#FFFFFF' , ''},
    {'Q12308638' ,'recueil de poèmes' , '#C4698F' , '' , '' , 'auteur'},
    {'Q1279564' , 'recueil de nouvelles' , '#FFE680' , '' , '' , 'auteur'},
    {'Q27560760' , 'recueil de contes' , '#70759A', '' , '#FFFFFF' , ''},
	{'Q5292' , 'encyclopédie' , '#CCB266' , '' , '' , 'universite'},
	{'Q23622' , 'dictionnaire' , '#CCB266' , '' , '' , 'universite'},
	{'Q41298' , 'magazine' , '#E1E1E1' , '' , '' , 'presse'},
	{'Q1002697' , 'périodique' , '#E1E1E1' , '' , '' , 'presse'},
	
}

local function setformat() --retourne une table contenant la couleur principale de l'infobox et l'icône de titre
	local occupations = wikidata.getIds(localdata.item, {property = 'P31,P136'}) -- récupère les Qid des genres

	--if not occupations or (#occupations > 1) then -- si plusieurs genres, on ne sait pas lequel choisir
		--return  {'Q', '', '#7DA7D9', '', '#000000', 'universite'}
	--end
	occupations = wikidata.addVals(occupations, {property = 'P279'}, 2) -- nombre d'étages de sous-classes à remonter
	for i, j in pairs(occupations) do
		for k, l in pairs(occupationformats) do
			if l[1] == j then
				return l
			end
		end
	end
	return {'Q', '', '#7DA7D9', '', '#000000', 'universite'}
end
local function setcharte()
	if localdata['charte'] then
		charte = localdata['charte']
		for i, j in pairs(occupationformats) do
			if j[2] == charte then
				return j
			end
		end
	end
	return setformat()
end
local workformat = setcharte()
return {
	maincolor = workformat[3],
	secondcolor = workformat[4],
	thirdcolor = workformat[5],
	parts =
    	{
			general.title(workformat[6]),
			general.mainimage{ 
				cat = "Article à illustrer Ouvrage",
				wikidata = {property = {"P3383", "P2716", "P18", "P10"}, numval = 1}
				},
		{type = "table", rows = {
			{type = "row", label = "Titre original", value = "titre original", plurallabel = "Titres originaux" , wikidata = function ( item )
					return italics({entity = item, property = 'P1476', conjtype = 'new line' , condition = isNotInFrench, showlang = true , numval = 1})
				end
			},
					{type = "row", label = "Nom officiel", value = "nom officiel", plurallabel = "Noms officiels" , wikidata = function ( item )
					return italics({entity = item, property = 'P1448', conjtype = 'new line' , lang='fr' , showlang = true })
				end
			},
			{type = "row", label = "Format", value = "format" , plurallabel = "Formats" , wikidata = {property = 'P31,P462', conjtype = 'new line' , excludevalues = {'Q571', 'Q47461344', 'Q7725634', 'Q3331189' , 'Q386724' , 'Q25839930'}}},
   			{type = "row", label = "Partie de", value = "comprend" , wikidata = function ( item )
					return italics({entity = item, property = 'P361', conjtype = 'new line' , showlang = true })
				end
			},
   			{type = "row", label = "Comprend", value = "comprend" , wikidata = function ( item )
					return italics({entity = item, property = 'P527', conjtype = 'new line' , showlang = true })
				end
			},
			{type = "row", label = "Langue", value = "langue" , plurallabel = "Langues", property = 'P364,P407'},
			{type = "row", label = "Auteur", value = "auteur", plurallabel = "Auteurs" , wikidata = {property = 'P50,P2093' , conjtype = 'new line'}},
			{type = "row", label = "Fondateur", value = "fondateur", plurallabel = "Fondateurs" , wikidata = {property = 'P112' , conjtype = 'new line'}},
			{type = "row", label = "Attribué à", value = "attribué à", wikidata = {property = 'P1773' , conjtype = 'new line'}},
			{type = "row", label = "Scénariste", value = "scénariste", plurallabel = "Scénaristes" , wikidata = {property = 'P58' , conjtype = 'new line'}},
			{type = "row", label = "Signataire", value = "signataire", plurallabel = "Signataires" , wikidata = {property = 'P1891' , conjtype = 'new line'}},
            {type = "row", label = "Préface", value = "préface", wikidata = {property = 'P2679' , conjtype = 'new line'}},
			{type = "row", label = "Traduction", value = "traduction", plurallabel = "Traductions" , wikidata = {property = 'P655' , conjtype = 'new line'}},
			{type = "row", label = "Illustration", value = "illustration" , wikidata = {property = 'P110' , conjtype = 'new line'}},
			{type = "row", label = "Coloriste", value = "coloriste" , plurallabel = "Coloristes" , wikidata = {property = 'P6338' , conjtype = 'new line'}},
            {type = "row", label = "Basé sur", value = "basé sur" , wikidata = function ( item )
					return italics({entity = item, property = 'P144,P941' , conjtype = 'new line' , showlang = true })
				end
			},
			{type = "row", label = "Genre", value = "genre", plurallabel = "Genres" , wikidata = {property = 'P136' , conjtype = 'new line'}},
			{type = "row", label = "Sujet", value = "sujet", plurallabel = "Sujets" , wikidata = {property = 'P921'}},
			{type = "row", label = "Personnage", value = "personnage", plurallabel = "Personnages" , wikidata = {property = 'P674' , numval = 5 , conjtype = 'new line'}},
			{type = "row", label = "Époque de l'action", value = "époque", wikidata = {property = 'P2408', sorttype = 'chronological', showqualifiers = 'P585,P1319,P1326,P580,P582' , conjtype='new line'}},
			{type = "row", label = "Date", value = "date", plurallabel = "Dates" , wikidata = {property = 'P585' , conjtype = 'new line', sorttype = 'chronological', showqualifiers = 'P291,P276,P437'}},
            {type = "row", label = "Date de création", value = "date de création", wikidata = {property = 'P571', sorttype = 'chronological'}},
			{type = "row", label = "Date de parution", value = "date de parution", plurallabel = "Dates de parution" , wikidata = {property = 'P577,P580' , conjtype = 'new line', sorttype = 'chronological', showqualifiers = 'P291,P276,P437,P407,P123'}},
			{type = 'row', label = "Date de fin", value="date de fin", wikidata = {property = 'P582' , sorttype = 'chronological'}},
			{type = "row", label = "Date de dissolution", value = "date de dissolution", wikidata = {property = 'P576', sorttype = 'chronological'}},
		--trouver le moyen de transformer en "mensuel", "annuel", etc.	{type = "row", label = "Périodicité" , value = "périodicité" , wikidata = {property = 'P2896' , showunit = 'long'}},
			{type = "row", label = "Lieu", value = "lieu" , plurallabel = "Lieux" , property = 'P276'},
			{type = "row", label = "Lieu de publication", value = "lieu de publication" , plurallabel = "Lieux de publication" , property = 'P291'},
			{type = "row", label = "Pays", value = "pays" , property = 'P495,P17'},
			{type = "row", label = "Publié dans", value = "publié dans", wikidata = function ( item )
					return italics({entity = item, property = 'P1433', conjtype = 'new line' , showlang = true })
					end
				},
			{type = "row", label = "Éditeur", value = "éditeur", plurallabel = "Éditeurs" , wikidata = {property = 'P123' , showqualifiers = 'P407' , showdate = true, conjtype = 'new line'}},
			{type = "row", label = "Collection", value = "collection", plurallabel = "Collections" , wikidata = {property = 'P195' , conjtype = 'new line' , sorttype = 'chronological' , showdate = true}},
			{type = "row", label = "Nombre de pages", value = "pages", wikidata = {property = 'P1104'}},
			{type = "row", label = "Œuvre dérivée", value = "oeuvre", plurallabel = "Œuvres dérivées" , wikidata = function ( item )
					return italics({entity = item, property = 'P4969', conjtype = 'new line' , showlang = true })
				end
				},
			{type = "row", label = "[[International Standard Book Number|ISBN]] 10", value = "isbn10" , wikidata = {property = 'P957' , conjtype = 'new line'}},
            {type = "row", label = "[[International Standard Book Number|ISBN]] 13", value = "isbn13" , wikidata = {property = 'P212' , conjtype = 'new line'}},
            {type = "row", label = "[[International Standard Serial Number|ISSN]]", value = "issn" , wikidata = {property = 'P236' , conjtype = 'new line'}},
            general.website(),
		}
		},
	{type = "table", title = "Distinctions", rows = {
			{type = "row", value = "distinction", wikidata = {property = 'P166' , conjtype = 'new line', showqualifiers = 'P585'}},
		}
		},
	{type = "table", title = "Séquence", rows = {
			{type = "row", label = "Série", value = "série", plurallabel = "Séries" , wikidata = function ( item )
					return italics({entity = item, property = 'P179', conjtype = 'new line' , showlang = true })
				end
			},
			{type = "row", label = "Précédé par" , value = "précédent" , wikidata = function ( item )
					return italics({entity = item, property = 'P155', conjtype = 'new line' , showlang = true })
				end
			},
			{type = "row", label = "Suivi par" , value = "suivant" ,wikidata = function ( item )
					return italics({entity = item, property = 'P156', conjtype = 'new line' , showlang = true })
				end
			},
		}
		},
	{
			type		     = 'images',
			style            = {['padding-top'] = '25px'},--{['border-width'] = '10px', ['border-style'] = 'solid'},
			label		     = 'Audio',
			captionparameter = 'légende audio',
			value		     = 'audio',
			property	     = 'P51',
			numval           = 1,
			defaultcaption = 'fichier audio',
		},
	{
		     type = 'images',
		     imageparameters =  {'logo'},
		     defaultimages = nil,
		     defaultupright = 0.5,
		     uprightparameter = 'upright logo',
		     sizeparameter = 'taille logo', -- obsolète
			 captionparameter = 'légende logo',
			 defaultcaption = 'logo',
			 property = 'P154',
    },
}
}