Module:Infobox/Appareil informatique/Bac à sable

Une page de Wikipédia, l'encyclopédie libre.

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


-- Module pour afficher un appareil informatique
local wd = require( 'Module:Wikidata' )
local general = require( 'Module:Infobox/Fonctions' )
local localdata = require( 'Module:Infobox/Localdata' )

local debut = localdata["début"]
local debut_wd = wd.formatStatements{ property = 'P5204', conjtype = 'new line' }
	or wd.formatStatements{ property = 'P577', conjtype = 'new line' }
if debut_wd then debut_wd = wd.addLinkBack(debut_wd, nil, 'P5204') end

local succ = localdata["successeur"] or wd.formatStatements{property = 'P156', conjtype = 'new line' }
local prec = localdata["prédécesseur"] or wd.formatStatements{property = 'P155', conjtype = 'new line' }

if not debut and debut_wd then debut = debut_wd end
	
local debut_count = 0
local date_main, date_second = nil, nil
if debut then debut_count = select(2, debut:gsub('\n', '\n')) + select(2, debut:gsub('<br', '<br')) end
if debut_count > 4 then date_second = debut else date_main = debut end


local function collapsiblebox(main, second)
	if main == '' then main = nil end
	if second == '' then second = nil end
	
	-- affiche la boîte déroulante
	local function navframe()
		local content, navf, navh = '', '', ''
		if second then
			navf = 'class="NavFrame collapsed" '
			navh = 'class="NavHead" 'end
		
		if second then content = content .. '<div '.. navf ..'style="border:none;">' end
		if main then content = content .. '<span style="display: table-cell;text-align: left;">'.. main ..'</span>' end
		if second then content = content .. '<div class="NavContent" style="font-size:100%; text-align:left;">'.. second ..'</div>' end
		if second then content = content .. '</div>' end
		return content
	end
	
	if main or second then
		return navframe
	else return nil	end
end

-- Fonction permettant l'affichage des dimensions ; facilement adaptable pour changer l'unité si besoin
local function dimensions ()
	local val = localdata["dimensions"]
	
	local d1 = wd.formatStatements{property = 'P2049', targetunit = 'mm', showunit = '-' }
	local d2 = wd.formatStatements{property = 'P2048', targetunit = 'mm', showunit = '-' }
	local d3 = wd.formatStatements{property = 'P2610', targetunit = 'mm', showunit = '-' }
	
	if not val and d1 and d2 and d3 then 
		val =  d1 .. ' × ' .. d2 .. ' × ' .. d3  .. ' mm'
	end
	
	return {
		type = 'row',
		label = 'Dimensions',
		value = function() return val end
	}
end

-- Fonction permettant l'affichage de la masse ; facilement adaptable pour changer l'unité si besoin
local function masse ()
	local val = localdata["poids"]
	local m = wd.formatStatements{property = 'P2067', targetunit = 'g', showunit = '-' }
	
	if not val and m then val = m .. ' g' end
	return { type = 'row', label = 'Masse', value = function() return val end }
end

-- Fonction permettant l'affichage du stockage ; facilement adaptable pour changer l'unité si besoin
local function stockage ()
	local val = localdata["stockage"]
	local sto = wd.formatStatements{property = 'P3559', conjtype = 'or' }
	local type = wd.formatStatements{property = 'P4788' }
	
	if sto and type then sto = sto .. ' (' .. type .. ')' end
	
	if not val and sto then val = sto end
	if val then
		val = wd.addLinkBack(val, nil, 'P3559')
		return { type = 'row', label = 'Stockage', value = function() return val end }
	end
end


local function scr ()
	local fre = localdata["fréquence"]
	local def = localdata["définition"]
	local res = localdata["résolution"]
	local tai = localdata["taille d'écran"]
	
	local content = ''
	if fre then content = content .. '- Fréquence : ' .. fre ..'<br>' end
	if def then content = content .. '- Définition : ' .. def ..'<br>' end
	if res then content = content .. '- Résolution : ' .. res ..'<br>' end
	if tai then content = content .. '- Taille : ' .. tai end
	
	if content ~= '' then return content end
end

-- voir https://fr.wikipedia.org/wiki/Aide:Infobox_en_Lua
return {
	maincolor = '#D5D9ED',
	parts = {
		-- paramètre 'nom complet' en sous-titre
		general.title('informatique', nil, 'nom complet'),
		general.logo(),
		general.mainimage('Article à illustrer Appareil informatique'),
		{
			type = 'images',
			imageparameters =  {'image2'},
			captionparameter = {'légende2', 'description2'},
			defaultupright = '0.6',
			uprightparameter = 'upright',
			sizeparameter = 'taille image2',
			numval = 1,
		},
		{ type = 'table', rows = {
			{	type = 'row',
				label = 'Développeur',
				value = 'développeur',
        		property = 'P178'
			},
			{	type = 'row',
				label = 'Fabricant',
				value = 'fabricant',
	       		property = 'P176'
			},
			{	type = 'row',
				label = 'Famille',
				value = 'famille',
				property = 'P179'
			},
			{	type = 'row',
				label = 'Présentation',
				value = 'présentation',
				property = 'P571'
			},
			{	type = 'row',
				label = 'Date de sortie',
				value = collapsiblebox(date_main, date_second)
			},
			{	type = 'row',
				label = 'Date de retrait',
				value = 'fin',
        		property = {'P2669', 'P730'}
			},
		},	},
		{ type = 'table', title = 'Fonctions', titlestyle = { ['padding'] = '4px' }, rows = {
			{	type = 'row',
				label = 'Type',
				value = 'type',
				wikidata = { property = 'P279', conjtype = 'and' } -- P31 ?
			},
			{	type = 'row',
				label = 'Génération',
				value = 'génération',
			},
			{	type = 'row',
				label = 'Média',
				value = 'média',
			},
			{	type = 'row',
				label = 'Unités vendues',
				value = 'vente',
			},
			{	type = 'row',
				label = 'Environnement',
				value = 'environnement',
			},
			{	type = 'row',
				label = 'Entrées',
				value = 'entrées',
				wikidata = { property = 'P479', conjtype = 'and', defaultlink = '-' }
			},
			{	type = 'row',
				label = 'Capteurs',
				value = 'capteurs',
				wikidata = { property = 'P9192', conjtype = 'and', defaultlink = '-' }
			},
			{	type = 'row',
				label = 'Connectique',
				value = 'connectivité',
				wikidata = { property = 'P2935', conjtype = 'and', defaultlink = '-' }
			},
			{	type = 'row',
				label = 'Audio',
				value = 'audio',
				wikidata = { property = 'P7501', conjtype = 'and', defaultlink = '-' }
			},
			{	
				type = 'row',
				label = 'Écran',
				value = collapsiblebox(localdata["écran"] or wd.formatStatements{property = 'P5307' }, scr())
			}
		},  },
		{ type = 'table', title = 'Caractéristiques', titlestyle = { ['padding'] = '4px' }, rows = {
			{	type = 'row',
				label = 'Alimentation',
				value = 'alimentation',
				wikidata = { property = 'P618', showqualifiers ='P4140', defaultlink = '-', showunit = 'short' }
			},
			{	type = 'row',
				label = 'Autonomie',
				value = 'autonomie',
			},
			{	type = 'row',
				label = 'Batterie',
				value = 'barrerie',
				wikidata = { property = 'P4140', defaultlink = '-', showunit = 'short' }
			},
			{	type = 'row',
				label = 'Caméra',
				value = 'caméra',
				wikidata = { property = 'P4082', defaultlink = '-' }
			},
			{	type = 'row',
				label = 'Puce',
				value = 'SoC'
			},
			{	type = 'row',
				label = 'Processeur',
				value = 'processeur',
				wikidata = { property = 'P880', showqualifiers = 'P2144', conjtype = "new line", defaultlink = "-" }
			},
			{	type = 'row',
				label = 'Bus système',
				value = 'bus',
				wikidata = { property = 'P8107', conjtype = "or", defaultlink = "-" }
			},
			{	type = 'row',
				label = 'Carte graphique',
				value = 'carte graphique',
				wikidata = { property = 'P2560', conjtype = "new line", defaultlink = "-" }
			},
			{	type = 'row',
				label = 'Processeur sonore',
				value = 'processeur sonore',
			},
			{	type = 'row',
				label = 'Mémoire',
				value = {'mémoire', 'mémoire vive'},
				wikidata = { property = 'P2928', conjtype = 'or' }
			},
			stockage,
			{	type = 'row',
				label = 'Système d\'exploitation',
				value = 'os',
        		wikidata = { property = 'P306', showqualifiers ='P348', defaultlink = '-' }
			},
			{	type = 'row',
				label = 'Contrôleurs',
				value = 'contrôleurs',
			},
			{	type = 'row',
				label = 'Pavé tactile',
				value = 'touchpad',
			},
			{	type = 'row',
				label = 'Services',
				value = 'services',
			},
			{	type = 'row',
				label = '[[Degré de liberté (mécanique)|Degrés de liberté]]',
				value = 'degrés de liberté',
			},
			{	type = 'row',
				label = 'Compatibilité',
				value = 'compatibilité',
			},
		},  },
		{
			type = 'table', title = 'Mesures', titlestyle = { ['padding'] = '4px' }, rows = { dimensions, masse }
		},
		{
			type = 'table', title = localdata["chronologie"], titlestyle = { ['background-color'] = '#E6E6E6', ['padding'] = '4px' }, rows = {
			{	type = 'succession',
				value = {
					before = prec,
					after = succ
				}
			}
		}, }, 
	--buildsuccession ()
	}
}