Moduł:Ikona
local data = mw.loadData("Module:Ikona/dane")
return {
plik = function(frame) local class if type(frame) == "string" then class = frame else class = frame.args[1] or frame:getParent().args[1] or "#default" end
local info = data.icons[mw.ustring.lower(class)] or data.icons["#default"] return info.plik end,
szablon = function(frame) -- load arguments local pf = frame:getParent() local class = pf.args.class or pf.args[1] or "#default" local size = pf.args[2] or "#default" local link = pf.args.link local pos = pf.args["dosuń"] local alt = pf.args.alt local desc = pf.args.opis
-- render output local result = {} table.insert(result, "[[Plik:") local icon = data.icons[mw.ustring.lower(class)] or data.icons["#default"] table.insert(result, icon.plik) table.insert(result, "|") table.insert(result, data.sizes[size] or data.sizes["#default"]) table.insert(result, "|link=") if link then table.insert(result, link) end if data.positions[pos] then table.insert(result, "|") table.insert(result, data.positions[pos]) end table.insert(result, "|alt=") if alt then table.insert(result, alt) end if desc then table.insert(result, "|") table.insert(result, desc) end table.insert(result, "]]")
return table.concat(result) end,
doc = function(frame) local group = frame.args[1] local items = {} for k, v in pairs(data.icons) do if group and (v.grupa == group) and v.opis and (#v.opis > 0) then table.insert(items, { name = k, file = v.plik, doc = v.opis, }) elseif not group and (not v.opis or (#v.opis == 0)) then table.insert(items, { name = k, file = v.plik, }) end end
if #items <= 0 then return end
local lang = mw.getContentLanguage() local comparison = function(a, b) return lang:caseFold((a or {}).name or "") < lang:caseFold((b or {}).name or "") end table.sort(items, comparison)
local result = {} if group and (#group > 0) then table.insert(result, "=== ") table.insert(result, group) table.insert(result, " ===\n") end
for _, v in ipairs(items) do
table.insert(result, "* ")
table.insert(result, "[[Plik:")
table.insert(result, v.file)
table.insert(result, "|20px|link=|alt=]]")
if group then
table.insert(result, " ")
table.insert(result, v.doc)
table.insert(result, "")
end
table.insert(result, ": ")
table.insert(result, mw.text.nowiki(""))
table.insert(result, "
\n")
end
return table.concat(result) end,
}