Module:Infobox/Fonctions/Bâtiment

De Lagny-sur-Marne Wiki
< Module:Infobox‎ | Fonctions
Révision datée du 5 janvier 2015 à 08:23 par Zolo (discussion) (p.architect : showdate = true)
Aller à : navigation, rechercher

La documentation pour ce module peut être créée à Module:Infobox/Fonctions/Bâtiment/doc

local p = {}
local wikidatamod = require 'Module:Wikidata'
local general = require 'Module:Infobox/Fonctions'
local coordfunctions = require 'Module:Infobox/Fonctions/Géolocalisation'

--Titre
function p.title()
	--	local class = en-tête par défaut à définir ici ?
	return general.title()
end

--Image
function p.mainimage(cat, defaultimage)
	if not cat then 
		cat = 'Article à illustrer Bâtiment divers'
	end
	return general.mainimage(cat, defaultimage)
end

function p.coordinates(coordspecs)
	return coordfunctions.coordinates(coordspecs)
end

function p.website() 
	return general.website()
end


function p.address()
	return	{
		type = 'mixed',
		label = 'Adresse',
		value = 'adresse',
		wikidata = function(localdata, item) return require('Module:Adresse').wikidataAddress(item) end,
	}
end

function p.transport()
	return {
		{type = 'table', title = 'Accès et transport', rows = {
				{type = 'mixed', label = 'Stationnement', value = 'stationnement'},
				{type = 'mixed', label = 'Gare', value = 'gare'},
				{type = 'mixed', label = 'Métro', value = 'métro'},
				{type = 'mixed', label = 'Tramway', value = 'bus'},
				{type = 'mixed', label = 'Autobus', value = 'gare'},
				},
		}
	}
end

function p.country(default)
 return	coordfunctions.country(default)	
end

function p.archistyle()
	return {
		type = 'mixed',
		label = 'Style architectural',
		value = 'style architectural',
		property = 'P149', 
	}
end

function p.architect()
	return {
		type = 'mixed',
		label = function(localdata, item) return localdata['titre architecte'] or 'Architecte' end,
		value = 'architecte', 
		wikidata = wikidatamod.formatAndCat{item = item, property = 'P84', showqualifiers = {'P518'}, showdate = true}
	}
end

function p.engineer()
	return {
		type = 'mixed',
		label = 'Ingénieur',
		value = 'ingénieur',
		property = 'P631'
	}
end

function p.owner()
	return {
		type = 'mixed',
		label = 'Propriétaire',
		value = 'propriétaire',
		property = 'P631'
	}
end

local function protectionline(localdata, item)
	local logos = require('Module:Logos classement')
	local claims = wikidatamod.getClaims({item=item, property = 'P1435', exludespecial = true})
	if not claims then return nil end
	for i, j in pairs(claims) do
		local val = wikidatamod.getmainid(j)
		local logo = logos[val]
		logostr = ''
		if logo then 
			logostr = '[[File:' .. logo .. '|x18px]] ' 
		end
		local protectiondate = wikidatamod.getFormattedQualifiers(j, {'P580'}, {precision = 'year'})
		if protectiondate then
			protectiondate = ' <small>(' .. protectiondate ..  ')</small>'
		else
			protectiondate = ''
		end
		local mainstr = wikidatamod.formatSnak(j.mainsnak)
		claims[i] = logostr .. mainstr .. protectiondate
	end
	return table.concat(claims, '<br />') .. '[[Catégorie:Page utilisant des données de Wikidata/P1435]]'
end

function p.protection(localdata, item)
	return {
		type = 'mixed',
		label = 'Protection',
		value = 'classement',
		wikidata = protectionline(locadata, item)
	}
end

function p.geoloc(params)
	return coordfunctions.geoloc(params)
end

return p