Module:IconUtils

De Eco - Wiki Français
Aller à :navigation, rechercher

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)

    if not args.id then
        return "Module:IconUtils : 'id' must be specified."
    end

    -- nom à afficher : si name fourni, on l'utilise, sinon fallback via Utils.ItemNameFromID
    local name = args.name or Utils.ItemNameFromID(args.id)

    local Icon = args.id .. "_Icon.png"
    local IconSize = args.size or 28
    local IconStyle = args.style or "1"

    local IconLink = ""
    if args.link == "1" then
        IconLink = "[[" .. name .. "]]"
    elseif args.link and args.link ~= "" then
        IconLink = "[[" .. args.link .. "]]"
    end

    local IconTextLine = IconLink ~= "" and "  " .. IconLink or "  " .. name
    local IconTextBr   = IconLink ~= "" and "<br>" .. IconLink or "<br>" .. name

    if IconStyle == "1" then
        return "[[File:" .. Icon .. "|" .. IconSize .. "px|link=" .. IconLink .. "]]"
    elseif IconStyle == "2" then
        return "[[File:" .. Icon .. "|" .. IconSize .. "px|link=" .. IconLink .. "]]" .. IconTextLine
    elseif IconStyle == "3" then
        return "[[File:" .. Icon .. "|" .. IconSize .. "px|link=" .. IconLink .. "]]" .. IconTextBr
    elseif IconStyle == "4" then
        return '<div class="IconFrame">[[File:' .. Icon .. "|" .. IconSize .. "px|link=" .. IconLink .. "]]" .. IconTextBr .. "</div>"
    end
end

return p