Module:Infobox/Fonctions/Bâtiment : Différence entre versions

De Lagny-sur-Marne Wiki
Aller à : navigation, rechercher
(réunit les fonctions d'adresse ici)
Ligne 18 : Ligne 18 :
 
end
 
end
  
function p.address2(localdata, item)
+
function p.country(default)
local div1, div2, div3, commune, address -- div for administrative "division"
+
return coordfunctions.country(default)
local labeldiv1, labeldiv2, labeldiv3, labelcommune, labeladdress
+
end
+
 
div1 = localdata['subdivision'] or localdata['subdivision1']
+
function p.address() return nil end -- pour éviter un bug de tansitions, si vous lisez cela vous pouvez effacer la fonctions
div2 = localdata['subdivision2']
+
 
div3 = localdata['subdivision3']
+
function p.historicalregion()
commune =localdata['commune']
+
return {
if item then
+
type = 'mixed', -- pour les régions historiques, non adminstratives
address = require('Module:Adresse').wikidataAddress(item)
+
value = 'région',
end
+
label = 'Région',
labeldiv1 = localdata['intitulé subdivision'] or localdata['lien subdivision'] or localdata['lien sudvisision1']
 
labeldiv2 = localdata['intitulé subdivision2'] or localdata['lien subdivision2']
 
labeldiv3 = localdata['intitulé subdivision3'] or localdata['lien subdivision3']
 
labelcommune = localdata['intitulé commune'] or 'commune'
 
labeladdress = 'Adresse'
 
 
return
 
{type = 'multi', rows =
 
{type = 'mixed', value = function() return div1 end, label = 'labeldiv1'},
 
{type = 'mixed', value = function() return div2 end, label = 'labeldiv2'},
 
{type = 'mixed', value = function() return div3 end, label = 'labeldiv3'},
 
{type = 'mixed', value = function() return div end, label = 'labelcommune'},
 
{type = 'mixed', value = function() return address  end, label = 'labeladdress'},
 
 
}
 
}
 +
end
 +
 +
function p.adminlocation()
 +
return
 +
{type = 'multi', rows = {
 +
{
 +
type = 'mixed',
 +
value = function(localdata, item) return localdata['subdivision'] or localdata['subdivision2']end,
 +
label = function(localdata, item) return
 +
localdata['intitulé subdivision'] or localdata['lien subdivision1'] or localdata['lien subdivision'] or 'Subdivision administrative'
 +
end
 +
},
 +
{
 +
type = 'mixed',
 +
value = 'subdivision2',
 +
label = function(localdata, item) return
 +
localdata['intitulé subdivision2'] or localdata['lien subdivision2'] or 'Subdivision administrative'
 +
end
 +
},
 +
{
 +
type = 'mixed',
 +
value = 'subdivision3',
 +
label = function(localdata, item) return
 +
localdata['intitulé subdivision3'] or localdata['lien subdivision3'] or 'Subdivision administrative'
 +
end
 +
},
 +
{
 +
type = 'mixed',
 +
value = 'commune',
 +
label = function(localdata, item) return
 +
localdata['intitulé commune'] or localdata['lien commune'] or 'Commune'
 +
end
 +
},
 +
{
 +
type = 'mixed',
 +
value = 'adrress',
 +
label = 'adresse',
 +
wikidata = function(localdata, item) return require('Module:Adresse').wikidataAddress(item) end,
 +
}
 +
} }
 
end
 
end
  
Ligne 53 : Ligne 80 :
 
end
 
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.opening() return
 
function p.opening() return
Ligne 91 : Ligne 109 :
 
}
 
}
 
}
 
}
end
 
 
function p.country(default)
 
return coordfunctions.country(default)
 
 
end
 
end
  

Version du 14 janvier 2015 à 17:19

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.country(default)
	return	coordfunctions.country(default)	
end

function p.address() return nil end -- pour éviter un bug de tansitions, si vous lisez cela vous pouvez effacer la fonctions

function p.historicalregion()
	return {
		type = 'mixed', -- pour les régions historiques, non adminstratives
		value = 'région',
		label = 'Région',
	}
end

function p.adminlocation()
	return 
	{type = 'multi', rows = {
			{
				type = 'mixed', 
				value = function(localdata, item) return localdata['subdivision'] or localdata['subdivision2']end,
				label = function(localdata, item) return
					localdata['intitulé subdivision'] or localdata['lien subdivision1'] or localdata['lien subdivision'] or 'Subdivision administrative'
				end
			},
			{
				type = 'mixed', 
				value = 'subdivision2',
				label = function(localdata, item) return
					localdata['intitulé subdivision2'] or localdata['lien subdivision2'] or 'Subdivision administrative'
				end
			},
			{
				type = 'mixed', 
				value = 'subdivision3',
				label = function(localdata, item) return
					localdata['intitulé subdivision3'] or localdata['lien subdivision3'] or 'Subdivision administrative'
				end
			},
			{
				type = 'mixed', 
				value = 'commune',
				label = function(localdata, item) return
					localdata['intitulé commune'] or localdata['lien commune'] or 'Commune'
				end
			},
		{
			type = 'mixed',
			value = 'adrress',
			label = 'adresse',
			wikidata = function(localdata, item) return require('Module:Adresse').wikidataAddress(item) end,
		}
	} }
end

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

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


function p.opening() return
		{type = 'multi', rows = {
			{type = 'mixed', label = 'Ouverture', value = 'ouverture'}, -- valeur de P793 pour ouverture
			{type = 'mixed', label = 'Inauguration', value = 'inauguration',
				wikidata = function(localdata, item)  -- déactivé si le paramètre "ouverture" este renseigné : risques de doublon
				if localdata['ouverture'] then return nil end
				return wikidatamod.getTheDate{property = 'P793', targetvalue = 'Q1417098', addcat = true, item=item}
			end
			}
		} }
end
function p.operator()
	return 
	{type = 'mixed', label = 'Gestionnaire', property = 'P137',
		value = function(localdata, item) return localdata['administration'] or localdata['gestionnaire'] 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.archistyle()
	return {
		type = 'mixed',
		label = 'Style architectural',
		value = function(localdata, item) return localdata['style architectural'] or localdata['style'] end,
		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:Classement/Logo')
	local texts = require('Module:Classement/Texte')
	local claims = wikidatamod.getClaims({item=item, property = 'P1435', exludespecial = true})
	if not claims then return nil end
	local statuses = {}-- nouvelle table pour ne pas afficher séparément deux statements décrivant le même statut
	for i, j in pairs(claims) do
		local pstatus = wikidatamod.getmainid(j)
		if not statuses[pstatus] then 
			statuses[pstatus] = {j}
		else
			table.insert(statuses[pstatus], j)
		end
	end
	local stringtable = {} -- liste des chaînes à retourner
	for i, j in pairs(statuses) do
		local mainstr = texts[i] or wikidatamod.formatEntity(i) -- nom de la protection
		
		local logostr = '' -- logo
		local logo = logos[i]
		if logo then 
			logostr = '[[File:' .. logo .. '|x18px]] ' 
		end

		local t = {} -- informations complémentaires sur les dates et les parties concernées
		for k, l in pairs(j) do
			local protectiondate = wikidatamod.getFormattedQualifiers(l, {'P580'}, {precision = 'year'})
			if protectiondate then
				table.insert(t, protectiondate)
			end
		end
		local details = table.concat(t, ", ")
		if details ~= '' then
			details = ' <small>(' .. details ..  ')</small>'
		else
			details = ''
		end
		table.insert(stringtable, logostr .. mainstr .. details)
	end
	return table.concat(stringtable, '<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