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

Différences entre les versions de « Module:Outils »

De Commission Historique
m
m
Ligne 6 : Ligne 6 :
local field_branches = frame.args['field_branches']
local field_branches = frame.args['field_branches']
local field_noeuds = frame.args['field_noeuds']
local field_noeuds = frame.args['field_noeuds']
arbre = p.ramif('', racine,'*',cargo_table,field_branches,liens)
arbre = p.ramif('', racine, '*', cargo_table, field_branches, liens)
return(arbre)
return(arbre)
end
end


function p.ramif(arbre, noeud, prof, cargo_table, field_branches,liens)
function p.ramif(arbre, noeud, prof, cargo_table, field_branches, liens)
local arguments = {
local arguments = {
where = field_branches .. '=' .. '"' .. noeud .. '"',
where = field_branches .. '=' .. '"' .. noeud .. '"',
Ligne 24 : Ligne 24 :
arbre = arbre .. '\n'.. prof .. branche['_pageName']
arbre = arbre .. '\n'.. prof .. branche['_pageName']
end
end
arbre = p.ramif(arbre,branche['_pageName'], prof .. '*', cargo_table, field_branches)
arbre = p.ramif(arbre,branche['_pageName'], prof .. '*', cargo_table, field_branches, liens)
end
end
end
end

Version du 30 mars 2021 à 17:35

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']
	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',
			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 == 'Oui' 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

return p