Chronos chronos left.png
Rusmed logo color.png
Chronos chronos right.png

A B C D E F G H I J K L M N O P Q R S T U V W X Y Z

Module:Institution

De Commission Historique

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

local pagetitle = tostring(mw.title.getCurrentTitle())

local p = {}
function p.main(frame)
	
	f = require("Module:Fonctions")
	fo = require("Module:Fo")
	
	local langue = frame:preprocess("{{int:lang}}")
	local lang = mw.getLanguage( langue )

-- Relations personnes/institutions

	local tables = 'Pers_inst'

	local fields = 'Objet_1,Nature,RefBib,_pageName=Prel'
	local arguments = {
		where='Objet_2 WITHIN "' .. pagetitle .. '" ',
		groupBy='Nature,Objet_1',
		orderBy='Nature,Objet_1',		
		intro=''
	}	
	local result = mw.ext.cargo.query(tables, fields, arguments)
	local pers_inst
	if result then
		pers_inst = '\n=={{int:Template-Personnels_et_protagonistes}}==\n' 
		local relations = f.trie_relations(result,"Nature",langue)
		for nature, relation in pairs(relations) do
			pers_inst = pers_inst .. '\r===' .. nature .. '===\r'
			for _,role in ipairs(relation) do
				 pers_inst = pers_inst .. '* [[' .. role["Objet_1"] .. ']]' .. fo.splitTextN(role['RefBib']) .. '[[' .. role["Prel"] .. '|→]]\n'
			end
		end	
	end
	
	return frame:preprocess(pers_inst)
end
return p