Module:Infobox/Fonctions/Localité

Cette page fait l’objet d’une mesure de semi-protection étendue.
Une page de Wikipédia, l'encyclopédie libre.

 Documentation[voir] [modifier] [historique] [purger]

Cette page définit un module d'infobox.


-- Functions utilisées par le module:Infobox/Localité
local l = {}
local localdata = require( 'Module:Infobox/Localdata' )
local wikidata = require "Module:Wikidata"
local general = require "Module:Infobox/Fonctions"

function l.mainimage()
	local defaultimage = 'Defaut 2.svg' -- demande d'illustration si pas d'illustration
	return  general.mainimage('Subdivision administrative illustrée par defaut.svg', defaultimage)
end

function l.population()
	local title = 'population'

	local rows
	if localdata['population'] then
		return {type = 'row',  label = title, value = 'population'}
	end
	
	local statements = wikidata.getClaims{
		entity = localdata.item,
		property= 'P1082',
		rank = 'best',
		conjtype= ' ou ',
		sorttype = inverted,
		numval = 1
	}
	if not statements then
		return nil
	end
		
	local text = ''
	for i, statement in pairs(statements) do
		local mainstr = wikidata.formatStatement(statement, {showqualifiers = {}})
		text = text .. mainstr .. ' hab.'
		local annee = wikidata.getFormattedQualifiers(statement, {'P585'})
		if annee then
			text = text .. ' <small>(' .. annee .. ')</small>'
		end
		text = text .. '<br />'
	end
	return {type = 'row', label = 'Population', value = function() return text end}
end
return l