Module:Infobox/Organisation

La documentation pour ce module peut être créée à Module:Infobox/Organisation/doc

--[[ 
Avant de mettre en production une nouvelle version avez-vous :
- testé avec la version bac à sable ?
- modifié la documentation ?
]]

local generic = require "Module:Infobox/Fonctions"
local localdata = require "Module:Infobox/Localdata"
local organisation = require "Module:Infobox/Fonctions/Organisation"
local wd = require "Module:Wikidata"

local chartes = {
	-- {titre charte, élément wikidata, couleur titre, couleur texte, pictogramme}
    {'agence fédérale des États-Unis', 'Q20857065', '#3c3b6e', '#FFF', 'musee'},
    {'bibliothèque', 'Q7075', '4C6099', '#FFF', 'universite'},
    {'dicastère', 'Q1225300', '#FFE8BF', '#000', 'eveque'},
    {'école', 'Q3914', '4d6699', 'ffffff', 'universite'},
    {'institut de recherche', 'Q31855', '#8089b7', '#FFF', 'universite'},
    {'institution spécialisée des Nations unies', 'Q15925165', '#4B92DB', '#FFF', 'nations-unies'},
    {'organe de l\'Union européenne', 'Q4936585', '#003399', '#FFF', 'union-europeenne'},
    {'musée', 'Q33506', 'A0A0FF', '#000', 'musee'},
    {'organisme sans but lucratif', 'Q163740', '6e77ef', '#FFF', 'association'},
    {'parti politique', 'Q7278', '#E1E1E1', '#000', 'defaut'},
    {'société nationale du Mouvement international de la Croix-Rouge et du Croissant-Rouge', 'Q1968122', '#CC0000', '#FFF', 'medecine'},
    {'société savante', 'Q955824', '#FFDEAD', '#000', 'universite'},
    {'syndicat', 'Q681615', '#D20012', '#FFF', 'association'},
}

local function setformat()
	local instanceof = wd.getIds(localdata.item, {property = 'P31'})

	if not instanceof then
		return  {'Q', '', '#323996', '#FFF', 'defaut'}
	end
	instanceof = wd.addVals(instanceof, {property = 'P279'}, 2)
	for i, j in pairs(instanceof) do
		for k, l in pairs(chartes) do
			if l[2] == j then
				return l
			end
		end
	end
	return {'Q', '', '#323996', '#FFF', 'defaut'}
end

local function setcharte()
	local charte = localdata['charte']
	if charte then
		for i, j in pairs(chartes) do
			if j[1] == charte then
				return j
			end
		end
	end
	return setformat()
end

local infoboxformat = setcharte()

local defaultquery = {property = {'P101', 'P366', 'P361', 'P279'}}

return {
	maincolor = infoboxformat[3],
	secondcolor = infoboxformat[3],
	thirdcolor = infoboxformat[4],
 	parts =
		{
			generic.title(infoboxformat[5]),
			generic.logo(),
			generic.blason(),
			generic.flag(),
			generic.locationmap(),
			generic.mainimage{cat = 'Atik pou ilistre òganizasyon', wikidata = {property = {"P2716", "P18", "P5252"}}},
			{type = 'table',
				rows = 	{
				{type = 'row', value = {'deviz', 'eslogan', 'asosyasyon_eslogan'}, wikidata = {property = 'P1451', showlang = true, isinlang = {'ht','fr', 'en', 'la'}, conjtype = 'new line'}, style = { ['text-align'] = 'center', ['font-size'] = '0.9em', ['font-weight'] = 'normal', ['font-style'] = 'italic' }},
				}
			},			
			{type = 'table', title = localdata['istwa'] or wd.formatStatements{entity = id, property = 'P2184', withlink = 'htwiki'} or 'Istwa',
				rows = 	{
				{type = 'row', label = 'Fondasyon', value = {'kreyasyon', 'fondasyon', 'dat_fondasyon'}, wikidata = {property = {'P571', 'P740'}, showqualifiers = {'P518', 'P1810', 'P4649', 'P5168', 'P8338'}, conjtype = 'new line'}},
				{type = 'row', label = 'Disolisyon', value = 'disolisyon', wikidata = {property = 'P576'}},
				{type = 'row', label = 'Orijin', value = {'orijin'}},
				{type = 'row', label = 'Predesesè', plurallabel = 'Predesesè yo', value = {'ranplase', 'te ranplase', 'predesè'}, wikidata = {property = {'P1365', 'P155', 'P1398'}, removedupes = true}},
				{type = 'row', label = 'Siksesè', plurallabel = 'Siksesè yo', value = {'ranplase pa', 'siksesè'}, wikidata = {property = {'P1366', 'P156', 'P167'}, removedupes = true}},
				{type = 'row', label = 'Scission de', value = {'scission de'}},
				{type = 'row', label = 'Fusion de', value = {'fusion de'}},
				{type = 'row', label = 'Scission dans', value = {'scission dans'}},
				{type = 'row', label = 'Fusionné dans', value = {'fusionné dans'}},
				}
			},
			{type = 'table', title='Kad',
				rows = 	{
				{type = 'row', label = 'Sig', plurallabel = 'Sig yo', value = {'sig', 'akwonim'}, wikidata = {property = {'P1813'}, showlang = true, isinlang = {'ht', 'fr', 'mul', 'en'}}},
				{type = 'row', label = 'Ti non', plurallabel = 'Ti non yo', value = {'ti non', 'tinon'}, wikidata = {property = {'P1449'}, showlang = true, isinlang = {'ht', 'fr', 'en'}}},
				{type = 'row', label = 'Kòd', plurallabel = 'Kòd yo', value = 'kòd', wikidata = {property = 'P4550', atdate = "today"}},
				{type = 'row', label = 'Zòn aktivite', value = {'kouvèti', 'rejyon', 'zòn operasyonèl', 'zòn enfliyans'}, wikidata = {property = 'P2541', showqualifiers = 'P1001', speciallabels = {Q13780930 = '[[Lemonn|Lemond antye]]', Q46 = '[[Ewòp]]'}}},
				{type = 'row', label = 'Tio', value = {'tip', 'asosyasyon_tip'},
					wikidata = {property = 'P31',
						removedupes = true, showdate = true, showqualifiers = {'P642', 'P459', 'P1013', 'P5102'}, qualifconjtype = 'comma',
						defaultlink = '-', defaultlinkquery = defaultquery,
						excludevalues = {'Q43229','Q41176','Q45400320'}} --non affichées : "organisation" (trop vague), "bâtiment" (hors sujet), "éditeur en accès libre" (secondaire, présent sur un grand nombre d'institutions scientifiques)
				}, 
				{type = 'row', label = '[[Fòm jiridik]]', value = 'fòm jiridik', wikidata = {property = 'P1454', showqualifiers = 'P4649', defaultlink = '-', defaultlinkquery = defaultquery, rank = 'valid', showdate = true, sorttype = 'chronological', conjtype = 'new line'}},
				{type = 'row', label = 'Estriti', value = 'estriti'},
				{type = 'row', label = '[[Objè sosyal]]', plurallabel = '[[Objè sosyal|Objè sosyal yo]]', value = {'objè sosyal', 'objè sosyal yo'}, wikidata = {property = 'P6346'}},
				{type = 'row', label = 'Domèn aktivite', plurallabel = 'Domèn aktivite yo', value = {'disiplin', 'disiplin yo', 'domèn', 'domèn yo', 'sektè yo'}, wikidata = {property = {'P101', 'P452', 'P2650'}, defaultlink = '-', defaultlinkquery = defaultquery, excludevalues={'Q112166212','Q107607934','Q29584118'}}}, --on exclut les regroupements statistiques pas informatifs
				{type = 'row', label = '[[Mouvman kiltirèl|Mouvman]]', value = {'mouvman'}, wikidata = {property = 'P135'}},
				{type = 'row', label = 'Finansman', value = 'finansman', wikidata = {property = 'P2770', speciallabels = {Q193219 = '[[sibvansyon]]s= yo', Q1124860 = '[[don]]'}, conjtype = "and"}},
				{type = 'row', label = 'Objektif', plurallabel = 'Objektif yo', value = {'but', 'objektif', 'objektif yo'}, wikidata = {property = 'P3712'}},
				{type = 'row', label = 'Metòd', plurallabel = 'Metòd yo', value = {'metòd', 'metod'}},
				{type = 'row', label = 'Campus', value = 'campus'},
				{type = 'row', label = function() return localdata['tit syèj'] or 'Syèj' end, value = {'syèj', 'syèj sosyal', 'adrè', 'lokalizasyon', 'vil', 'syej'}, wikidata = {property = 'P159', defaultlink = '-', defaultlinkquery = {property = {'P669', 'P131', 'P466'}}, showdate = true , showqualifiers = {'P670', 'P969', 'P669', 'P281', 'P131', 'P17', 'P5102'}, conjtype = 'new line', qualifconjtype = 'comma', labelformat = function(id) local label = wd.getLabel(id) if label then if mw.ustring.match(label, '(%d)(e)') then label = label:gsub('(%d)(e)', '%1<sup>e</sup>') elseif mw.ustring.match(label, 'de jure') then label = label:gsub('de jure', '<i>de jure</i>') elseif mw.ustring.match(label, 'de facto') then label = label:gsub('de facto', '<i>de facto</i>') end return label end end}},
				generic.country(),
				generic.coordinates(),
				{type = 'row', label = 'Lang', plurallabel = 'Lang yo', value = {'lang', 'lang yo', 'lang ofisyèl', 'lang ofisyèl yo', 'lang ofisyel'}, wikidata = {property = 'P37', showqualifiers = 'P4626'}},
				{type = 'row', label = '[[Lang travay]]', plurallabel = '[[Lang travay|Lang travay yo]]', value = {'lang travay', 'lang travay yo'}, wikidata = {property = 'P2936', showqualifiers = 'P4626'}},
				}
			},
			{type = 'table', title='Òganizasyonon',
				rows = 	{
				organisation.membres(id),
				organisation.custom(),
				-- Entités liées
				{type = 'row', label = 'Òganizasyon paran', plurallabel = 'Òganizasyon paran yo', value = {'òganizasyon paran', 'sosyete paran', 'òganis'}, wikidata = {property = 'P749', showdate = true, sorttype = 'chronological', showqualifiers = {'P1001'}, conjtype = 'new line'}},
				{type = 'row', label = 'Branch', plurallabel = 'Branch yo', value = 'branch', wikidata = {property = 'P199'}},
				{type = 'row', label = 'Patnè', value = 'patnè'},
				{type = 'row', label = 'Depann de', value = 'depann de'},
				{type = 'row', label = 'Afilyasyon', value = {'afilyasyon', 'afilyation_ewopeyèn', 'afilyasyon_entènasyonal', 'ratacheman'}, wikidata = {property = {'P1416'}, showdate = true, defaultlinkquery = {property = {'P749', 'P127', 'P112'}}, qualifdefaultlinkquery = defaultquery, showqualifiers = {'P2868', 'P1416', 'P3831'}}},
				{type = 'row', label = 'Esponnsò', plurallabel = 'Esponnsò yo', value = 'esponnsò', wikidata = {property = 'P859', defaultlinkquery = {property = {'P749', 'P127', 'P112'}}}},
				-- Orientation politique
				{type = 'row', label = 'Ideyoloji', value = {'ideyoloji', 'oryantasyon politik', 'politik', 'pol'}, wikidata = {property = 'P1142'}},
				{type = 'row', label = '[[Echikye politik|Pozisyònman]]', value = {'pozisyònman', 'pozisyònman politik'}, wikidata = {property = 'P1387'}},
				{type = 'row', label = '[[Kowalisyon politik]]', plurallabels = '[[Kowalisyon politik|Kowalisyon politik yo]]', value = {'kowalisyon', 'kowalisyon politik'}, wikidata = {property = 'P5832'}},
				{type = 'row', label = '[[Gwoup palmantè]]', value = {'gwoup palmantè', 'paleman'}, wikidata = {property = 'P4100'}},
				-- Situation financière 
				{type = 'row', label = 'Bidjè', value = 'bidjè', wikidata = {property = 'P2769', showdate = true, sorttype = 'chronological', showunit = 'true', showlink = true}},
				{type = 'row', label = 'Chif dafe1', value = 'chif dafè', wikidata = {property = 'P2139', showdate = true, sorttype = 'chronological', showunit = 'true', showlink = true}},
				{type = 'row', label = 'Résultat net', value = 'résultat net', wikidata = {property = 'P2295', showdate = true, sorttype = 'chronological', showunit = 'true', showlink = true}},
				{type = 'row', label = 'Depans', value = {'depans', 'depans anyèl', 'depans total yo'}, wikidata = {property = 'P2402', showdate = true, sorttype = 'chronological', showunit = 'true', showlink = true}},
				{type = 'row', label = 'Kapitalizasyon bousyè', value = 'kapitalizasyon', wikidata = {property = 'P2226', showdate = true, sorttype = 'chronological', showunit = 'true', showlink = true}},
				{type = 'row', label = 'Kotasyon', plurallabel = 'Kotasyon yo', value = 'kotasyon', wikidata = {property = 'P414', showqualifiers = 'P249', conjtype = 'new line'}},
				{type = 'row', label = 'Notasyon', value = 'notasyon'},
				-- Divers
				{type = 'row', label = 'Rekonpans', plurallabel = 'Rekonpans yo', value = 'rekonpans', wikidata = {property = 'P166', showdate = true, sorttype = 'chronological', conjtype = 'new line', defaultlink = '-', defaultlinkquery = {property = 'P1027'}}},
				{type = 'row', label = 'Pwodui', plurallabel = 'Pwodui yo', value = 'pwodui', wikidata = {property = 'P1056'}},
				{type = 'row', label = '[[Représentativité syndicale en France|Représentativité]]', value = {'representativite', 'représentativité'}},
				{type = 'row', label = 'Piblikasyon', plurallabel = 'Piblikasyon', value = {'òganis laprès', 'piblikasyon', 'piblikasyon yo'}, wikidata = {property = 'P2813', showdate = true, sorttype = 'chronological', conjtype = 'new line', defaultlink = '-', defaultlinkquery = {property = 'P123', 'P1433'}, labelformat = function(id) local label = wd.getLabel(id) if label then return '<i>' .. label .. '</i>' end end}},
				generic.website(),
                                {type = "mixed", label = "Pòtay open data", value = "pòtay open data", wikidata = {property = "P8402"}},
                                {type = "mixed", label = "Pòtay done yo", value = "pòtay done yo", wikidata = {property = "P1325", displayformat = "weblink"}},
				{type = "mixed", label = "[[Estati jiridik|Estati]]", value = "estati yo", wikidata = {property = "P6378", displayformat = "weblink", text = "An liy"}},
				}
			},
			organisation.ids(),
			generic.geoloc({default_zoom=13, maptype = localdata["type carte"], width = localdata["taille carte"]}),
		}
	}