پودمان:FootballPlayer
ظاهر
توضیحات این پودمان میتواند در پودمان:FootballPlayer/توضیحات قرار گیرد.
local p = {}
local function add(t,h,l,d)
if d and mw.text.trim(d) ~= '' then
table.insert(t,{
header=h,
label=l,
data=d
})
end
end
local function addHeader(t,text)
table.insert(t,{
header=text
})
end
local function buildRows(args)
local rows={}
addHeader(rows,"اطلاعات فردی")
add(rows,nil,"نام کامل",args["نام کامل"])
add(rows,nil,"تاریخ تولد",args["تاریخ تولد"])
add(rows,nil,"محل تولد",args["محل تولد"])
add(rows,nil,"قد",args["قد"])
add(rows,nil,"پست",args["پست"])
add(rows,nil,"ملیت",args["ملیت"])
addHeader(rows,"اطلاعات باشگاهی")
add(rows,nil,"باشگاه کنونی",args["باشگاه کنونی"])
add(rows,nil,"شماره",args["شماره"])
local youth={}
for i=1,5 do
local years=args["سالهای جوانان"..i]
local club=args["جوانان"..i]
if (years and years~="") or (club and club~="") then
table.insert(youth,{
years=years or "",
club=club or ""
})
end
end
if #youth>0 then
addHeader(rows,"دوران جوانان")
local txt='{| class="wikitable" style="width:100%;font-size:90%;"\n'
txt=txt..'!سالها!!باشگاه\n'
for _,v in ipairs(youth) do
txt=txt.."|-\n"
txt=txt.."|"..v.years.."||"..v.club.."\n"
end
txt=txt.."|}"
add(rows,nil,nil,txt)
end
local clubs={}
for i=1,10 do
local years=args["سالها"..i]
local club=args["باشگاه"..i]
local apps=args["بازی"..i]
local goals=args["گل"..i]
if (years and years~="") or
(club and club~="") or
(apps and apps~="") or
(goals and goals~="") then
table.insert(clubs,{
years=years or "",
club=club or "",
apps=apps or "",
goals=goals or ""
})
end
end
if #clubs>0 then
addHeader(rows,"دوران باشگاهی")
local txt='{| class="wikitable" style="width:100%;font-size:90%;"\n'
txt=txt..'!سالها!!باشگاه!!بازی!!گل\n'
for _,v in ipairs(clubs) do
txt=txt.."|-\n"
txt=txt.."|"..
v.years.."||"..
v.club.."||"..
v.apps.."||"..
v.goals.."\n"
end
txt=txt.."|}"
add(rows,nil,nil,txt)
end
local national={}
for i=1,5 do
local years=args["سالهای ملی"..i]
local team=args["تیم ملی"..i]
local apps=args["بازی ملی"..i]
local goals=args["گل ملی"..i]
if (years and years~="") or
(team and team~="") or
(apps and apps~="") or
(goals and goals~="") then
table.insert(national,{
years=years or "",
team=team or "",
apps=apps or "",
goals=goals or ""
})
end
end
if #national>0 then
addHeader(rows,"تیم ملی")
local txt='{| class="wikitable" style="width:100%;font-size:90%;"\n'
txt=txt..'!سالها!!تیم!!بازی!!گل\n'
for _,v in ipairs(national) do
txt=txt.."|-\n"
txt=txt.."|"..
v.years.."||"..
v.team.."||"..
v.apps.."||"..
v.goals.."\n"
end
txt=txt.."|}"
add(rows,nil,nil,txt)
end
return rows
end
local function buildInfoboxArgs(frame,args)
local infobox={}
infobox.title=args["نام"] or mw.title.getCurrentTitle().text
if args["تصویر"] and args["تصویر"]~="" then
infobox.image="[[پرونده:"..args["تصویر"].."]]"
end
infobox.caption=args["توضیح تصویر"]
local rows=buildRows(args)
local n=1
for _,row in ipairs(rows) do
if row.header then
infobox["header"..n]=row.header
else
infobox["label"..n]=row.label
infobox["data"..n]=row.data
end
n=n+1
end
return infobox
end
function p.main(frame)
local args
if frame==mw.getCurrentFrame() then
args=frame:getParent().args
else
args=frame
end
local infoboxArgs=buildInfoboxArgs(frame,args)
return require("Module:Infobox").infoboxTemplate(infoboxArgs)
end
return p