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 : 'id' must be specified."
end
local name = args.name or Utils.ItemNameFromID(args.id)
-- nom du fichier
local Icon = args.id .. "_Icon.png"
-- taille et style par défaut
local IconSize = args.size or 28
local IconStyle = args.style or "1"
-- préparation du lien
local IconLink = ""
if args.link == "1" then
IconLink = "[[" .. name .. "]]"
elseif args.link and args.link ~= "" then
IconLink = "[[" .. args.link .. "]]"
end
-- texte additionnel
local IconTextLine = IconLink ~= "" and " " .. IconLink or " " .. name
local IconTextBr = IconLink ~= "" and "<br>" .. IconLink or "<br>" .. name
-- construit le wikitext en fonction du style
local wikitext = ""
if IconStyle == "1" then
wikitext = "[[File:" .. Icon .. "|" .. IconSize .. "px" .. (IconLink ~= "" and "|link=" .. IconLink or "") .. "]]"
elseif IconStyle == "2" then
wikitext = "[[File:" .. Icon .. "|" .. IconSize .. "px" .. (IconLink ~= "" and "|link=" .. IconLink or "") .. "]]" .. IconTextLine
elseif IconStyle == "3" then
wikitext = "[[File:" .. Icon .. "|" .. IconSize .. "px" .. (IconLink ~= "" and "|link=" .. IconLink or "") .. "]]" .. IconTextBr
elseif IconStyle == "4" then
wikitext = '<div class="IconFrame">[[File:' .. Icon .. "|" .. IconSize .. "px" .. (IconLink ~= "" and "|link=" .. IconLink or "") .. "]]" .. IconTextBr .. "</div>"
else
wikitext = "[[File:" .. Icon .. "|" .. IconSize .. "px" .. (IconLink ~= "" and "|link=" .. IconLink or "") .. "]]"
end
return wikitext
end
return p