Module:Infobox/Catch (spectacle)

 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 (spectacle).


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

local bgcolor = '#dfedff'

local function city()
	if localdata['ville'] then
		return {type = 'row', label = 'Ville(s)', value = 'ville'}
	end
	
	local statements = wikidata.getClaims{
		entity = localdata.item,
		property = 'P131'
	}
	
	if not statements then
		return nil
	end
	
	local title
	if #statements == 1 then
		title = 'Ville'
	else
		title = 'Villes'
	end
	
	local text = ''
	for i, statement in pairs(statements) do
		local city = wikidata.formatStatement(statement, {showqualifiers = 'P131'})
        text = text .. city .. '<br>'
        local country = wikidata.formatStatements{entity = localdata.item, property = 'P17', displayformat = 'raw', numval = 1} or wikidata.formatStatement(statement, {showonlyqualifier = 'P17', displayformat = 'raw'})
        local countryFlag, success = require 'Module:Country data'.standarddisplay(country)
        if success then
            text = text .. countryFlag .. '<br>'
        end
	end
	text = mw.text.trim(text, '<br>')
	text = wikidata.addTrackingCat('P131') .. wikidata.addLinkBack(text, localdata.item, 'P131')
	
	return {type = 'row', label = title, value = function() return text end}
end

local function review()
	if localdata['critique'] then
		return {type = 'row', label = 'Critique(s)', value = 'critique'}
	end
	
	local statements = wikidata.getClaims{
		entity = localdata.item,
		property = 'P444'
	}
	
	if not statements then
		return nil
	end
	
	local title
	if #statements == 1 then
		title = 'Critique'
	else
		title = 'Critiques'
	end
	
	local text = ''
	for i, statement in pairs(statements) do
		local rateBy = wikidata.formatStatement(statement, {showonlyqualifier = 'P447'})
		if rateBy then
			local rating = wikidata.formatStatement(statement)
			local pos = string.find(rating, '/')
			local stars = string.sub(rating, 0, pos - 1)
			local numStars = string.sub(rating, pos + 1)
        	text = text .. rateBy .. ' : ' .. require 'Module:Nombre d\'étoiles'._starnumber(stars, numStars) .. '<br>'
        end
	end
	text = mw.text.trim(text, '<br>') .. '>'
	text = wikidata.addTrackingCat('P444') .. wikidata.addLinkBack(text, localdata.item, 'P444')

	return {type = 'row', label = title, value = function() return text end}
end

local function eventSeries()
	local value = localdata['évènement'] or wikidata.formatAndCat{entity = localdata.item, property = {'P179', 'P747'}, numval = 1}
	if not value then
		return nil
	else
		return 'Chronologie des ' .. value
	end
end

return {
	maincolor = bgcolor,
	parts = {
		general.title('catch', {['font-style'] = 'italic'}),
		
		{type = 'images', imageparameters = 'image', captionparameter = {'légende', 'légende_image'}, sizeparameter = 'taille image'},
		
		{type = 'table', rows = {
			{type = 'row', label = '[[Liste des termes de catch#M|Main event]]', value = 'main_event'},
			{type = 'row', label = '[[Slogan]]', value = 'slogan', property = 'P1451'},
			{type = 'row', label = '[[Indicatif musical|Thème musical]]', value = 'thème_musical'},
		}},
		
		{type = 'table', title = 'Informations', rows = {
			{type = 'row', label = 'Fédération(s)', singularlabel = 'Fédération', plurallabel = 'Fédérations', value = 'fédération', wikidata = {property = 'P664', conjtype = 'new line'}},
			{type = 'row', label = 'Division(s)', singularlabel = 'Division', plurallabel = 'Divisions', value = 'division', wikidata = {property = 'P199', conjtype = 'new line'}},
			{type = 'row', label = '[[Sponsor|Sponsor(s)]]', singularlabel = '[[Sponsor]]', plurallabel = '[[Sponsor|Sponsors]]', value = 'sponsor', wikidata = {property = 'P859', conjtype = 'new line'}},
			{type = 'row', label = 'Date', singularlabel = 'Date', plurallabel = 'Dates', value = 'date', wikidata = {property = 'P585', conjtype = 'new line', numval = 1}},
			{type = 'row', label = 'Date de début', value = 'date début', wikidata = {property = 'P580', conjtype = 'new line', numval = 1}},
			{type = 'row', label = 'Date de fin', value = 'date fin', wikidata = {property = 'P582', conjtype = 'new line', numval = 1}},
			{type = 'row', label = 'Spectateurs', value = 
				function()
					value = localdata['spectateurs'] or wikidata.formatAndCat{entity = localdata.item, property = 'P1110', numval = 1}
					if value then
						return value .. ' personnes'
					end
				end
			},
			{type = 'row', label = 'Téléspectacteurs', value =
				function(localdata)
					if localdata['spectateurs_ppv'] then
						return localdata['spectateurs_ppv'] .. ' personnes'
					end
				end
			},
			{type = 'row', label = 'Lieu(x)', singularlabel = 'Lieu', plurallabel = 'Lieux', value = 'lieu', wikidata = {property = 'P276', conjtype = 'new line'}},
			city(),
			review()
		}},
	
		{type = 'table', title = 'Chronologie des événements', rows = {
			{type = 'navigator',
				previousval = 'ppv_précédent1',
				previouswikidata = {property = 'P155'},
				nextval = 'ppv_suivant1',
				nextwikidata = {property = 'P156'},
				inner = true
			}
		}},
	
		{type = 'navigator',
			previousval = 'ppv_précédent1bis',
			nextval = 'ppv_suivant1bis'
		},
	
		{type = 'table', title = eventSeries(), rows = {
			{type = 'navigator',
				previousval = 'ppv_précédent2',
				previouswikidata = {property = {'P179', 'P747'}, showonlyqualifier = 'P155', numval = 1},
				nextval = 'ppv_suivant2',
				nextwikidata = {property = {'P179', 'P747'}, showonlyqualifier = 'P156', numval = 1},
				inner = true
			}
		}},
	}
}