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

De Lagny-sur-Marne Wiki
Aller à : navigation, rechercher
(+ renovation)
Ligne 1 : Ligne 1 :
 
local p = {}
 
local p = {}
local wikidatamod = require 'Module:Wikidata'
+
local util = require 'Module:Utilitaire Wikidata'
 
local general = require 'Module:Infobox/Fonctions'
 
local general = require 'Module:Infobox/Fonctions'
 
local coordfunctions = require 'Module:Infobox/Fonctions/Géolocalisation'
 
local coordfunctions = require 'Module:Infobox/Fonctions/Géolocalisation'
 
local function keydate(event)
 
if string.sub(event, 1, 1) == 'Q' then -- on demande un élément utilisé dans P:P793 (événement clé)
 
return  wikidatamod.getTheDate{property = 'P793', targetvalue = event, addcat = true, item = item}
 
elseif string.sub(event, 1, 1) == 'P'  then -- on demande une propriété
 
return wikidatamod.formatAndCat{property = event, item = item}
 
end
 
end
 
  
 
local function daterow(args)
 
local function daterow(args)
 
local wikidataquery
 
local wikidataquery
 
if args.event then
 
if args.event then
wikidataquery = function() return keydate(args.event) end
+
wikidataquery = function() return util.keydate(args.event) end
 
end
 
end
 
 
Ligne 121 : Ligne 113 :
  
 
-- construction (nom de paramètre "date de constuction" à déprécier)
 
-- construction (nom de paramètre "date de constuction" à déprécier)
daterow{param = {'construction', 'Construction'}, label = 'Construction', event = 'Q385378'},
+
daterow{param = {'construction', 'Construction'}, label = 'Construction', event = {'Q385378', 'P571'}},
  
 
-- événement apparentés
 
-- événement apparentés
daterow{param = 'ouverture', label = 'Ouverture'}, -- wikidata  valeur de P793 ?
+
daterow{param = 'ouverture', label = 'Ouverture', 'P1849'}, -- P1849 = ouverture officielle, pas ouverture de facto
 
daterow{param = 'inauguration', label = 'Inauguration', event = 'Q1417098', blocker = 'ouverture'}, -- désactivé si "ouverture" est renseigné : risques de doublon  
 
daterow{param = 'inauguration', label = 'Inauguration', event = 'Q1417098', blocker = 'ouverture'}, -- désactivé si "ouverture" est renseigné : risques de doublon  
 
daterow{param = {'consécration'}, label = 'Consécration', event = 'Q125375', blocker = 'inauguration'},
 
daterow{param = {'consécration'}, label = 'Consécration', event = 'Q125375', blocker = 'inauguration'},
Ligne 163 : Ligne 155 :
 
Q182060 = 'bureaux', -- bureaux semble toujours pouvoir se mettre au pluriel quand c'est en P366 d'un bâtiment
 
Q182060 = 'bureaux', -- bureaux semble toujours pouvoir se mettre au pluriel quand c'est en P366 d'un bâtiment
 
}
 
}
return wikidatamod.formatAndCat{entity = item, property = 'P366', speciallabels = speciallabels, link = '-'}
+
return util.formatAndCat{entity = item, property = 'P366', speciallabels = speciallabels, link = '-'}
 
end
 
end
 
}
 
}
Ligne 197 : Ligne 189 :
 
value = {'style architectural', 'style'},
 
value = {'style architectural', 'style'},
 
wikidata = function ()
 
wikidata = function ()
local val = wikidatamod.formatAndCat{entity = item, property = 'P149'} or wikidatamod.formatAndCat{entity = item, property = 'P135'}
+
local val = util.formatAndCat{entity = item, property = 'P149'} or util.formatAndCat{entity = item, property = 'P135'}
 
if not val then
 
if not val then
 
return nil
 
return nil
Ligne 213 : Ligne 205 :
 
label = localdata['titre architecte'] or 'Architecte',
 
label = localdata['titre architecte'] or 'Architecte',
 
value = 'architecte',
 
value = 'architecte',
wikidata = wikidatamod.formatAndCat{entity = item, property = 'P84', showqualifiers = {'P518'}, showdate = true, qualiflink = '-'}
+
wikidata = util.formatAndCat{entity = item, property = 'P84', showqualifiers = {'P518'}, showdate = true, qualiflink = '-'}
 
},
 
},
 
-- ingénieur
 
-- ingénieur
Ligne 233 : Ligne 225 :
 
end
 
end
 
if item then
 
if item then
return wikidatamod.formatAndCat{entity = item, property = 'P170', showqualifiers = {'P518'}}
+
return util.formatAndCat{entity = item, property = 'P170', showqualifiers = {'P518'}}
 
end
 
end
 
end
 
end

Version du 19 avril 2015 à 07:13

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

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

local function daterow(args)
	local wikidataquery
	if args.event then
		wikidataquery = function() return util.keydate(args.event) end
	end
	
	-- blocker définit des événements proches de celui recherché, s'il sont rensignés localement, on désactive la reuqête Wikidata pour éviter les doublons 
	-- exemple : "ouverture" désactive la recher d'"inauguration" sur Wikidata
	if args.blocker and localdata[args.blocker] then
		wikidata = false
	elseif args.blocker and type(args.blocker) == 'table' then
		for i, j in pairs(blocker) do 
			if localdata[j] then
				wikidata = false
				break
			end
		end
	end

	return {
		type = 'row',
		label = args.label,
		value =  args.param,
		wikidata = wikidataquery
	}
end

--Titrest
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 = 'row', -- pour les régions historiques, non adminstratives
		value = 'région',
		label = localdata['intitulé région'] or localdata['lien région'] or 'Région',
	}
end

function p.adminlocation() -- Fonction assez compliquée du fait des différences entre infobox. Simlifiable si on harmonise les infobox
	-- infobox à prendre en compte : bâtiment, gratte-ciel, gare, château
	return 
	{type = 'multi', rows = {
			{
				type = 'row', 
				value = {'subdivision', 'subdivision1'},
				label = localdata['intitulé subdivision'] or localdata['lien subdivision1'] or localdata['lien subdivision'] or 'Subdivision administrative'
			},
			{
				type = 'row', 
				value = 'subdivision2',
				label = localdata['intitulé subdivision2'] or localdata['lien subdivision2'] or 'Subdivision administrative'
			},
			{
				type = 'row', 
				value = 'subdivision3',
				label = localdata['intitulé subdivision3'] or localdata['lien subdivision3'] or 'Subdivision administrative'
			},
			{
				type = 'row', 
				value = {'commune', 'ville'},
				label = localdata['intitulé commune'] or localdata['lien commune'] or 'Commune'
			},
			{
				type = 'row', 
				value = 'quartier',
				label = localdata['intitulé quartier'] or localdata['titre quartier'] or 'Quartier'
			},
		{
			type = 'row',
			value = 'adresse',
			label = 'Adresse',
			wikidata = require('Module:Adresse').wikidataAddress(item),
		}
	} }
end

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

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

function p.construction()
	return
		{type = 'multi', rows = {
		-- début construction, fin construction (legacy infobox Stade, Infobox Château),
			daterow{param = 'début construction', label = 'Début de construction'},
			daterow{param = 'fin construction', label = 'Fin de construction'},

		-- construction (nom de paramètre "date de constuction" à déprécier)
			daterow{param = {'construction', 'Construction'}, label = 'Construction', event = {'Q385378', 'P571'}},

		-- événement apparentés
			daterow{param = 'ouverture', label = 'Ouverture', 'P1849'}, -- P1849 = ouverture officielle, pas ouverture de facto
			daterow{param = 'inauguration', label = 'Inauguration', event = 'Q1417098', blocker = 'ouverture'}, -- désactivé si "ouverture" est renseigné : risques de doublon 
			daterow{param = {'consécration'}, label = 'Consécration', event = 'Q125375', blocker = 'inauguration'},		
		}
	}

end

function p.renovation() return
	{type = 'multi', rows = {
		daterow{param = 'restauration', label = 'Restauration', event = 'Q217102', blocker = 'rénovation'},
		daterow{param = 'rénovation', label = 'Rénovation', event = 'Q2144402', blocker = 'restauration'},
		daterow{param = 'agrandissement', label = 'Extension', event = 'Q18621193'},
		daterow{param = 'autres travaux', label = 'Autres campagnes de travaux'},
		}
	}
end

function p.demolition() return
	{type = 'multi', rows = {
		daterow{param = 'démolition', label = 'Démolition', event = 'Q331483'},
		daterow{param = 'destruction', label = 'Destruction', event = 'Q17781833'},
	}
	}
end

function p.closure() return
	daterow{param = 'Fermeture', label = 'Fermeture', event = 'Q14954904'}
end

function p.usage() return
	{
	type = 'row',
	label = 'Usage',
	value = 'usage', 
	wikidata = function(item)
		local speciallabels = {
			Q182060 = 'bureaux', -- bureaux semble toujours pouvoir se mettre au pluriel quand c'est en P366 d'un bâtiment
		}
		return util.formatAndCat{entity = item, property = 'P366', speciallabels = speciallabels, link = '-'}		
	end
	}
end

function p.operator()
	return 
	{
		type = 'row',
		label = 'Gestionnaire',
		property = 'P137',
		value = localdata['administration'] or localdata['gestionnaire']
	}
end

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

function p.archistyle()
	return {
		type = 'row',
		label = 'Style',
		value = {'style architectural', 'style'},
		wikidata = function ()
			local val = util.formatAndCat{entity = item, property = 'P149'} or util.formatAndCat{entity = item, property = 'P135'}
			if not val then
				return nil
			end
			val = mw.ustring.gsub(val, "\|style ", "\|")
			return val
			end
	}
end

function p.creator() -- toute sorte de créateurs, pourraient peut-être être partagé avec infobox oeuvre d'art
	return {type = 'multi', rows = {
	-- architect
	{	type = 'row',
		label = localdata['titre architecte'] or 'Architecte',
		value = 'architecte',
		wikidata = util.formatAndCat{entity = item, property = 'P84', showqualifiers = {'P518'}, showdate = true, qualiflink = '-'}
	},
	-- ingénieur
	{
		type = 'row',
		label = 'Ingénieur',
		value = 'ingénieur',
		property = 'P631',
	},
	-- créateur (quand les autres noms ne conviennent pas)
	{	type = 'row',
		label = 'Créateur',
		value = function() 
			if localdata['architecte'] then
				return nil
			end
			if localdata['créateur'] then
				return localdata['créateur']
			end
			if item then
				return util.formatAndCat{entity = item, property = 'P170', showqualifiers = {'P518'}}
			end
		end
	},
}	}
end


function p.owner()
	return 	{type = 'multi', rows = {
		{
			type = 'row',
			label = 'Propriétaire initial',
			value = 'propriétaire initial',
		},
		{
			type = 'row',
			label = 'Propriétaire actuel',
			value = 'propriétaire actuel',
		},
		{
			type = 'row',
			label = 'Propriétaire',
			value = 'propriétaire',
			wikidata = require('Module:Propriétaire').formatFromItem(item)
		}
	} }
end

function p.material()
	return {
		type = 'row',
		label = 'Matériau',
		value = 'matériau', 
		wikidata = require('Module:Matériau').formatFromItem(item),
	}
end

function p.protection()
	return {
		type = 'row',
		label = 'Statut patrimonial',
		value = 'classement',
		wikidata = require('Module:Classement').formattedList(item)
	}
end

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

return p