Module:Biblio
local Biblio = {}
local moduleLangue = require ( 'Module:Langue' )
-- cette simple fonction permet de récupérer les arguement du modèle, -- ou la table transmise à la fonction par une autre fonction d'un module local function extractArgs ( frame )
-- return ( frame.getParent and frame:getParent().args ) or frame or { }
return frame.args or frame or { } -- renvoie les arguments transmis par invoke et non par le modèle, pour tester avant de créer les modèle.
end
-- fonction abréviation, abréviation discrète -- paramètres : 1 = abréviation, 2 = texte, 3 = langue, abrd = abréviation discrète function Biblio.abr ( frame )
local args = extractArgs ( frame )
if args[2] == nil then
return args[1] or -- retoune l'abréviation ou au minimum une chaine vide s'il n'y a pas de texte
end
local wikiText = { '<abbr' }
if args.abrd then
table.insert(wikiText, ' class="abbr"')
end
table.insert(wikiText, ' title="' .. args[2])
if args[3] then
table.insert(wikiText, '" lang="' .. args[3])
end
table.insert(wikiText, '">' .. args[1] .. '')
return table.concat (wikiText)
end
function Biblio.spanInitial ( frame )
local args = extractArgs ( frame ) -- préparation pour appel par modèle ou direct.
local id = args.id or
if string.len( id ) == 0 then
id = mw.uri.anchorEncode ( args.id1 .. args.id2 .. args.id3 .. args.id4 .. args.id5 )
end
return ' 0 then
lib = '[' .. lib .. '] '
end
return lib
end
function Biblio.indicationDeLangue ( frame )
local args = extractArgs ( frame )
local langue = args.langue
local codeLangue = moduleLangue ( langue )
if codeLangue ~= and codeLangue ~= 'fr' then
langue = moduleLangue.codeLangue2 ( codeLangue )
return moduleLangue.indicationDeLangue { langue, codeLangue }
else
return
end
end
function Biblio.responsabilitePrincipale ( frame )
local args = extractArgs ( frame )
local listeRresponsables = { }
local nom = ( args ['nom1'] or ) or
if nom then
return
end
local directeur = Biblio.abr { 'dir.', 'directeur de publication', abrd = true }
local responsable, prenom, lien , precision, resp
local i = 1
repeat
lien = args [ 'lien' .. i ] or
if lien ~= then lien = lien .. '|' end
prenom = args [ 'prénom' .. i ] or
if prenom ~= then prenom = prenom .. ' ' end
precision = args [ 'directeur' .. i ] or
resp = args [ 'responsabilité' .. i ] or
if precision == then
if resp ~= then
precision = ' (' .. resp .. ')'
end
else
if resp ~= then
precision = ' (' .. directeur .. ' et ' .. resp .. ')'
else
precision = ' (' .. directeur .. ')'
end
end
responsable = '' .. lien .. prenom .. nom .. '' .. precision
table.insert ( listeRresponsables, responsable )
nom = args [ 'nom' .. ( i + 1 ) ] or
until nom ==
if args [ 'et al.' ] == 'oui' then
local et_al = " " .. Biblio.abr { "et al.", "et alii (et d’autres)", abrd = true } .. ""
return table.concat ( listeRresponsables, ',' ) .. et_al
else
return mw.text.listToText ( listeRresponsables )
end
end
return Biblio