For faster navigation, this Iframe is preloading the Wikiwand page for Module:Infobox/Ouvrage/Bac à sable.

Module:Infobox/Ouvrage/Bac à sable

 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/Bac à sable.


local localdata = require 'Module:Infobox/Localdata'
local general = require "Module:Infobox/Fonctions/Bac à sable"
local wikidata = require "Module:Wikidata/Bac à sable"
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 formformats = {
	--{é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 forms = wikidata.getIds(localdata.item, {property = 'P7937,P31,P136'}) -- récupère les Qid des forms et genres
	--if not occupations or (#occupations > 1) then -- si plusieurs genres, on ne sait pas lequel choisir
		--return {'Q', '', '#7DA7D9', '', '#000000', 'universite'}
	--end
	forms = wikidata.addVals(forms, {property = 'P279'}, 2) -- nombre d'étages de sous-classes à remonter
	for i, j in pairs(forms) do
		for k, l in pairs(formformats) do
			if l[1] == j then
				return l
			end
		end
	end
	return {'Q', '', '#7DA7D9', '', '#000000', 'universite'}
end
local function setcharte()
	local charte = localdata['charte']
	if charte then
		for i, j in pairs(formformats) do
			if j[2] == charte then
				return j
			end
		end
	end
	return setformat()
end
local workformat = setcharte()

local function sequences()
	local rows = {}
	local seriesrows = { }
	local seriesrowsplur = { }
	
	rows[ #rows + 1 ] = { type = "row", label = "Univers", value = "univers", wikidata = function ( item )
						return italics( { entity = item, property = 'P1434', conjtype = 'new line' , showlang = true } )
					end }
	
	if localdata["série"] or localdata["séquence"] then -- s'il y a un paramètre local
		rows[ #rows + 1 ] = { type = "row", label = "Série", value = { "série", "séquence" }, plurallabel = "Séries", wikidata = function ( item )
					return italics({ entity = item })
				end }
	else
		-- récupérer toutes les séries
		local series = wikidata.getClaims{ entity = localdata.item, property = 'P179' } or { }
		local alreadyShowNavitem = { }
		local lastHasNavigator = true
		local navigator
		for _, serie in ipairs( series ) do
			-- pour chaque série préparer les items précédents et suivants
			local prev = wikidata.getQualifiers( serie, { 'P155' } ) or { }
			prev = wikidata.filterClaims( prev, { excludespecial = true } ) or { }
			for i, j in ipairs( prev ) do
				alreadyShowNavitem[ #alreadyShowNavitem + 1 ] = wikidata.getId( j )
				prev[i] = wikidata.formatSnak( j, { showlang = true } )
			end
			local next = wikidata.getQualifiers( serie, { 'P156' } ) or { }
			next = wikidata.filterClaims( next, { excludespecial = true } ) or { }
			for i, j in ipairs( next ) do
				alreadyShowNavitem[ #alreadyShowNavitem + 1 ] = wikidata.getId( j )
				next[i] = wikidata.formatSnak( j, { showlang = true } )
			end
			navigator = { type = "navigator", inner = true
				, previouswikidata = function()
					local result = linguistic.conj( prev, 'new line' )
					if result then
						return '<i>' .. result .. '</i>'
					end
				end
				, nextwikidata = function()
					local result = linguistic.conj( next, 'new line' )
					if result then
						return '<i>' .. result .. '</i>'
					end
				end}
			
			-- si la série d'avant n'avait pas de navigateur ou s'il s'agit de la première, mettre le label "Série", sinon indiqué que le précédent label devrait être au pluriel
			local label = ""
			if lastHasNavigator then
				label = "Série"
				seriesrowsplur[ #seriesrowsplur + 1 ] = false
			else
				seriesrowsplur[ #seriesrowsplur + 1 ] = true
			end
			lastHasNavigator = #prev > 0 or #next > 0
			seriesrows[ #seriesrows + 1 ] = { type = "row", label = label, value = "série", plurallabel = "Séries" , wikidata = function ()
					return italics( { claims = { serie }, entity = localdata.item, property = 'P179', showlang = true } )
				end
			}
			seriesrows[ #seriesrows + 1 ] = navigator
		end
	end
	
	-- ajouter les items précédents et suivant qui sont en mainvalue ou en local et qui n'ont pas déjà été affichés
	navigator = { type = "navigator", inner = true,
		previousval = "précédé par", previouswikidata = function ( item )
			return italics( { entity = item, property = 'P155', conjtype = 'new line' , showlang = true, excludevalues = alreadyShowNavitem } )
		end,
		nextval = "suivi par", nextwikidata = function ( item )
			return italics( { entity = item, property = 'P156', conjtype = 'new line' , showlang = true, excludevalues = alreadyShowNavitem } )
		end
	}
	rows[ #rows + 1 ] = navigator
	
	-- ajouter ensuite les séries, au pluriel si besoin
	for i,v in pairs( seriesrows ) do
		if seriesrowsplur[ i + 1 ] then
			v.label = "Séries"	
		end
		rows[ #rows + 1 ] = v
	end
	return { type = "table", title = "Séquence", rows = rows }
end

return {
	maincolor = workformat[3],
	secondcolor = workformat[4],
	thirdcolor = workformat[5],
	parts =
	{
		general.title(workformat[6], nil, nil, nil, true),
		general.mainimage{ 
			cat = "Article à illustrer Ouvrage",
			wikidata = {property = {"P3383", "P2716", "P18", "P10"}, numval = 1},
			alt = localdata['alt']
		},
		{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 = 'P7937,P31', conjtype = 'new line' , excludevalues = {'Q571', 'Q47461344', 'Q7725634', 'Q3331189' , 'Q386724' , 'Q25839930', 'Q108329152','Q58483083','Q105543609'))},
				{type = "row", label = "Partie de", value = "partie de" , 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, sorttype = 'P1545' })
					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', sorttype = 'P1545')),
				{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 = "Lettreur", value = "lettreur" , plurallabel = "Lettreurs" , wikidata = {property = 'P9191' , 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,P98' , 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')),
			}
		},
		sequences(),
		{
			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',
		},
	}
}
{{bottomLinkPreText}} {{bottomLinkText}}
Module:Infobox/Ouvrage/Bac à sable
Listen to this article

This browser is not supported by Wikiwand :(
Wikiwand requires a browser with modern capabilities in order to provide you with the best reading experience.
Please download and use one of the following browsers:

This article was just edited, click to reload
This article has been deleted on Wikipedia (Why?)

Back to homepage

Please click Add in the dialog above
Please click Allow in the top-left corner,
then click Install Now in the dialog
Please click Open in the download dialog,
then click Install
Please click the "Downloads" icon in the Safari toolbar, open the first download in the list,
then click Install
{{::$root.activation.text}}

Install Wikiwand

Install on Chrome Install on Firefox
Don't forget to rate us

Tell your friends about Wikiwand!

Gmail Facebook Twitter Link

Enjoying Wikiwand?

Tell your friends and spread the love:
Share on Gmail Share on Facebook Share on Twitter Share on Buffer

Our magic isn't perfect

You can help our automatic cover photo selection by reporting an unsuitable photo.

This photo is visually disturbing This photo is not a good choice

Thank you for helping!


Your input will affect cover photo selection, along with input from other users.

X

Get ready for Wikiwand 2.0 🎉! the new version arrives on September 1st! Don't want to wait?