Modification de Module:Référence
La modification peut être annulée. Veuillez vérifier les différences ci-dessous pour voir si c’est bien ce que vous voulez faire, puis publier ces changements pour finaliser l’annulation de cette modification.
Version actuelle | Votre texte | ||
Ligne 1 : | Ligne 1 : | ||
local p = {} | local p = {} | ||
-- | -------------------------------------- | ||
function | ----- Fonctions communes ----- | ||
if lang ~= | -------------------------------------- | ||
return | |||
function formatSentence(sentence, lang) | |||
if lang ~= 'fr' then | |||
return "''" .. sentence .. "''" | |||
else | else | ||
return sentence | return sentence | ||
Ligne 10 : | Ligne 13 : | ||
end | end | ||
function getArgs(frame) | |||
function | |||
local args = {} | local args = {} | ||
Ligne 24 : | Ligne 26 : | ||
end | end | ||
-- | -------------------------------------- | ||
-- | |||
local | function p.buildOneReference(frame) | ||
local args = getArgs(frame) | |||
local | local type = args['type'] | ||
if | if not type then | ||
return 'Le paramètre type n\'est pas renseigné.' | |||
end | end | ||
local type = type:lower() | |||
local | local attributes = {} | ||
local | |||
local name = args['nom'] | |||
if name then | |||
attributes['name'] = name | |||
end | end | ||
if | local group = args['groupe'] | ||
if group then | |||
attributes['group'] = group | |||
end | end | ||
local | local content = '' | ||
local | local lang = args['langue'] or 'fr' | ||
local | |||
if type == 'conversation' then | |||
local game = args['jeu'] | |||
if game then | |||
game = require( 'Module:Abréviation' ).name(game) | |||
if game == '' then | |||
game = 'jeu ?' | |||
else | |||
game = "''[[" .. game .. "]]''" | |||
end | |||
else | |||
game = 'jeu ?' | |||
end | |||
local character1 = args['personnage1'] or 'personnage1 ?' | |||
local character2 = args['personnage2'] or 'personnage2 ?' | |||
content = content .. 'Conversation entre ' .. character1 .. ' et ' .. character2 .. ' :' | |||
content = content .. '<br/>' | |||
if | for i = 1, 6 do | ||
break | local sentence = args['phrase' .. i] | ||
if sentence then | |||
content = content .. '— ' .. formatSentence(sentence, lang) .. '<br/>' | |||
else | |||
break | |||
end | |||
end | end | ||
if | local file = args['fichier'] or 'fichier ?' | ||
content = content .. 'Extrait du fichier ' .. file .. ', ' .. game | |||
elseif type == 'document' then | |||
local quotation = args['citation'] | |||
if quotation then | |||
content = content .. '« ' .. formatSentence(quotation, lang) .. ' »<br/>' | |||
end | end | ||
local document = args['ouvrage'] or 'ouvrage ?' | |||
local author = args['auteur'] or 'auteur ?' | |||
local date = args['date'] or 'date ?' | |||
local publisher = args['éditeur'] or 'éditeur ?' | |||
local page = args['page'] or 'page ?' | |||
content = content .. author .. '. \'\'' .. document .. '\'\'. ' .. publisher .. ', ' .. date .. '. pp. ' .. page | |||
end | end | ||
return frame:extensionTag( 'ref', content, attributes ) | |||
return | |||
end | end | ||
return p | return p |