Moduł:Osoba
Wygląd
Dokumentacja dla tego modułu może zostać utworzona pod nazwą Moduł:Osoba/opis
local p = {}
local function notEmpty(v)
return v ~= nil and v ~= ""
end
local function formatDate(frame, d)
if notEmpty(d) then
return frame:callParserFunction("#time", "j xg Y", d)
end
return ""
end
-- lista z *
local function makeList(text)
if notEmpty(text) and string.find(text, "%*") then
local items = {}
for line in string.gmatch(text, "[^\r\n]+") do
local item = string.gsub(line, "^%*%s*", "")
table.insert(items, "<li>" .. item .. "</li>")
end
return "<ul>" .. table.concat(items) .. "</ul>"
end
return text
end
-- medale
local function addMedals(text)
if notEmpty(text) then
text = string.gsub(text, "{złoto}", "[[Plik:Gold medal icon.png|16px]]")
text = string.gsub(text, "{srebro}", "[[Plik:Silver medal icon.png|16px]]")
text = string.gsub(text, "{brąz}", "[[Plik:Bronze medal icon.png|16px]]")
end
return text
end
local function row(label, value)
if notEmpty(value) then
return "|-\n! " .. label .. "\n| " .. value .. "\n"
end
return ""
end
local function section(title, content, medals)
if notEmpty(content) then
content = makeList(content)
if medals then
content = addMedals(content)
end
return "|-\n! colspan='2' style='background:#eaecf0; text-align:center;' | " .. title .. "\n" ..
"|-\n| colspan='2' | " .. content .. "\n"
end
return ""
end
function p.infobox(frame)
local a = frame:getParent().args
local txt = "{| class='infobox' style='float:right; width:270px; border:1px solid #a2a9b1; background:#f8f9fa;'\n"
-- nagłówek z ikoną
local header = ""
if notEmpty(a.dyscyplina_ikona) then
header = "[[Plik:" .. a.dyscyplina_ikona .. "|20px]] "
end
txt = txt .. "|+ style='background:#3366cc; color:white; text-align:center;' | " ..
header .. "'''" .. (a.imie or "") .. " " .. (a.nazwisko or "") .. "'''\n"
-- zdjęcie + podpis
if notEmpty(a.zdjecie) then
txt = txt .. "|-\n| colspan='2' style='text-align:center;' | [[Plik:" .. a.zdjecie .. "|250px]]"
if notEmpty(a.podpis_zdjecia) then
txt = txt .. "<br><small>" .. a.podpis_zdjecia .. "</small>"
end
txt = txt .. "\n"
end
-- obywatelstwo + flaga
local obywatelstwo = a.obywatelstwo or ""
if notEmpty(a.flaga) then
obywatelstwo = "[[Plik:" .. a.flaga .. "|20px]] " .. obywatelstwo
end
local dane = ""
dane = dane .. row("Nazwisko panieńskie", a.nazwisko_panienskie)
dane = dane .. row("Pseudonim", a.pseudonim)
dane = dane .. row("Data urodzenia", formatDate(frame, a.data_urodzenia))
dane = dane .. row("Miejsce urodzenia", a.miejsce_urodzenia)
dane = dane .. row("Data śmierci", formatDate(frame, a.data_smierci))
dane = dane .. row("Miejsce śmierci", a.miejsce_smierci)
dane = dane .. row("Obywatelstwo", obywatelstwo)
dane = dane .. row("Wzrost", a.wzrost)
dane = dane .. row("Pozycja", a.pozycja)
if dane ~= "" then
txt = txt .. "|-\n! colspan='2' style='background:#eaecf0; text-align:center;' | Dane osobowe\n"
txt = txt .. dane
end
local klub = ""
klub = klub .. row("Klub", a.klub)
klub = klub .. row("Numer", a.numer)
if klub ~= "" then
txt = txt .. "|-\n! colspan='2' style='background:#eaecf0; text-align:center;' | Informacje klubowe\n"
txt = txt .. klub
end
txt = txt .. section("Kariera juniorska", a.kariera_juniorska)
txt = txt .. section("Kariera klubowa", a.kariera_klubowa)
txt = txt .. section("Kariera reprezentacyjna", a.kariera_reprezentacyjna)
txt = txt .. section("Kariera trenerska", a.kariera_trenerska)
txt = txt .. section("Osiągnięcia", a.osiagniecia, true)
txt = txt .. "|}"
return txt
end
local licznik = 0
function p.resetCounter()
licznik = 0
return ""
end
function p.nextCounter()
licznik = licznik + 1
return tostring(licznik)
end
return p