Module:Infobox/Catch (spectacles)

 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 Catch (spectacles).


local general = require 'Module:Infobox/Fonctions'
local localdata = require 'Module:Infobox/Localdata'
local wikidata = require 'Module:Wikidata'

local function brands()
	local statements = wikidata.getClaims{
		entity = localdata.item,
		property = 'P199',
		sorttype = 'chronological'
	}
	
	if not statements then
		return nil
	end
	
	local title
	if #statements == 1 then
		title = 'Division'
	else
		title = 'Divisions'
	end
	
	local values = {}
	for i, statement in pairs(statements) do
		local value = wikidata.formatStatement(statement)
        if not values[value] then
			values[value] = {}
		end
		
		local before = wikidata.formatStatement(statement, {showonlyqualifier = 'P580'})
		if before then
			local text = before .. '-'
			local after = wikidata.formatStatement(statement, {showonlyqualifier = 'P582'})
			if after then
				if before == after then
					text = before
				else
					text = text .. after
				end
			end
			table.insert(values[value], text)
    	end
	end
	
	local text = ''
	for i, value in pairs(values) do
		text = text .. i .. ' <small>('
		for j, date in pairs(value) do
			text = text .. date .. '; '
		end
		text = mw.text.trim(text, '; ') .. ')</small><br>'
	end
	text = mw.text.trim(text, '<br>') .. '>'
	text = wikidata.addTrackingCat('P199') .. wikidata.addLinkBack(text, localdata.item, 'P199')
	
	return {type = 'row', label = title, value = function() return text end}
end

local function website()
	local wd = {
		property = 'P856', 
		conjtype = 'new line',
		numval = 1,
		displayformat = 
			function(snak)
				return wikidata.getDataValue(snak, {text = wikidata.getLabel(localdata.item)})
			end
	}
	
	return {type = 'row', label = 'Site web', wikidata = wd}
end

return {
	maincolor = '#dfedff',
	parts = {
		general.title('catch'),
		general.mainimage('Article à illustrer Catch'),
		
		{type = 'table', rows = {
			{type = 'row', label = 'Surnom(s)', singularlabel = 'Surnom', plurallabel = 'Surnoms', wikidata = {property = 'P1449', conjtype = 'new line'}}
		}},
		
		{type = 'table', title='Informations', rows = {
			{type = 'row', label = 'Créé par', value = 'créer_par', wikidata = {property = 'P112', conjtype = 'new line'}},
			{type = 'row', label = 'Date de création', property = 'P571'},
			{type = 'row', label = '[[Fédération de catch|Fédération(s)]]', singularlabel = '[[Fédération de catch|Fédération]]', plurallabel = '[[Fédération de catch|Fédérations]]', wikidata = {property = 'P664', conjtype = 'new line'}},
			brands(),
			{type = 'row', label = '[[Type de match au catch|Match principal]]', value = 'match_principal', property = 'P793'},
			website()
		}}
	}
}