Module:IconUtils
De Eco - Wiki Français
La documentation pour ce module peut être créée à Module:IconUtils/doc
local p = {}
function p.main(param)
local Utils = require('Module:Utils')
local args = Utils.normalise(param)
-- Vérifie que l'ID est fourni
if not args.id or args.id == '' then
return "Module:IconUtils FR : 'id' must be specified."
end
-- Récupère le nom localisé de l'item
local itemName = Utils.ItemNameFromID(args.id)
-- Nom du fichier image
local IconFile = args.id .. "_Icon.png"
-- Vérifie que le fichier existe
if Utils.checkImage(IconFile) ~= "Y" then
return "Image not found: " .. IconFile
end
-- Taille et style par défaut
local IconSize = (not args.size or args.size == '') and 28 or args.size
local IconStyle = (not args.style or args.style == '') and '1' or args.style
-- Gestion du lien
local IconLink = ''
if args.link == '1' then
IconLink = '[[' .. itemName .. ']]'
elseif args.link and args.link ~= '' then
IconLink = '[[' .. args.link .. ']]'
end
-- Texte additionnel pour certains styles
local IconTextLine = IconLink ~= '' and ' ' .. IconLink or ' ' .. itemName
local IconTextBr = IconLink ~= '' and '<br>' .. IconLink or '<br>' .. itemName
-- Retour selon style
if IconStyle == '1' then
return '[[File:' .. IconFile .. '|' .. IconSize .. 'px|link=' .. IconLink .. ']]'
elseif IconStyle == '2' then
return '[[File:' .. IconFile .. '|' .. IconSize .. 'px|link=' .. IconLink .. ']]' .. IconTextLine
elseif IconStyle == '3' then
return '[[File:' .. IconFile .. '|' .. IconSize .. 'px|link=' .. IconLink .. ']]' .. IconTextBr
elseif IconStyle == '4' then
return '<div class="IconFrame">[[File:' .. IconFile .. '|' .. IconSize .. 'px|link=' .. IconLink .. ']]' .. IconTextBr .. '</div>'
else
-- fallback style 1 si style inconnu
return '[[File:' .. IconFile .. '|' .. IconSize .. 'px|link=' .. IconLink .. ']]'
end
end
return p