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:Outils

De Commission Historique

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

local p = {}

function p.arbre(frame)
	local racine = frame.args['racine']
	local cargo_table = frame.args['tables']
	local field_branches = frame.args['field_branches']
	local field_noeuds = frame.args['field_noeuds']
	local liens = frame.args['liens']
	arbre = p.ramif('', racine, '*', cargo_table, field_branches, liens)
	return(arbre)
end

function p.ramif(arbre, noeud, prof, cargo_table, field_branches, liens)	
	local arguments = {
			where = field_branches .. '=' .. '"' .. noeud .. '"',
			groupBy = '_pageName',
			limit = 5000,
			default = '',
		}
		liste_branches = mw.ext.cargo.query(cargo_table, '_pageName', arguments)
		for _,branche in ipairs(liste_branches) do
			if #branche['_pageName'] > 0 then
				if liens then
					arbre = arbre .. '\n'.. prof .. '[[' .. branche['_pageName'] .. ']]' 
				else
					arbre = arbre .. '\n'.. prof .. branche['_pageName']
				end
				arbre = p.ramif(arbre,branche['_pageName'], prof .. '*', cargo_table, field_branches, liens)
			end
		end
	return arbre
end


function p.requete(frame)
	local liste = ''
	local tables = frame.args['tables']
	local fields = frame.args['fields']
	local arguments = {
		join = frame.args['joinOn'],
		where = frame.args['where'],
		groupBy = frame.args['groupBy'],
		orderBy = frame.args['orderBy'],
		intro = frame.args['intro'],
		outro = frame.args['outro'],
	}
	local result = mw.ext.cargo.query(tables, fields, arguments)
	for _,row in ipairs(result) do
		for _, field in pairs(row) do
			if #field > 0 then
				liste = liste .. '\n' .. field
			end
		end
	end
	return liste
end


--function p.frise(frame)
--	local tStart, tEnd = frame.args['racine']
--end

function p.ffrise(desc,events)
	frise = '<itimeline height="512px" min="' .. tStart - 1 .. '" max="' .. tEnd + 1 .. '">"\n'
	for _, event in events do
		frise = frise .. event.date .. '|' .. event.category .. '|' .. event.label .. '\n'
	end
	frise = frise .. '</itimeline>'
	return frise
end

return p