پودمان:Infobox football biography: تفاوت میان نسخهها
ظاهر
جزبدون خلاصۀ ویرایش |
جزبدون خلاصۀ ویرایش |
||
| خط ۱۰: | خط ۱۰: | ||
for i = 1, select('#', ...) do | for i = 1, select('#', ...) do | ||
local key = select(i, ...) | local key = select(i, ...) | ||
if isSet(args[key]) then | if isSet(args[key]) then return args[key] end | ||
end | end | ||
return nil | return nil | ||
| خط ۲۰: | خط ۱۸: | ||
if not isSet(data) then return end | if not isSet(data) then return end | ||
local row = root:tag('tr') | local row = root:tag('tr') | ||
row:tag('th') | row:tag('th'):attr('scope', 'row'):addClass('infobox-label'):wikitext(label) | ||
row:tag('td'):attr('colspan', '3'):addClass('infobox-data'):wikitext(data) | |||
row:tag('td') | |||
end | end | ||
| خط ۳۳: | خط ۲۵: | ||
if not isSet(dataa) and not isSet(datab) and not isSet(datac) then return end | if not isSet(dataa) and not isSet(datab) and not isSet(datac) then return end | ||
local row = root:tag('tr') | local row = root:tag('tr') | ||
row:tag('th') | row:tag('th'):attr('scope', 'row'):addClass('infobox-label'):wikitext(label) | ||
row:tag('td'):addClass('infobox-data infobox-data-a'):wikitext(isSet(dataa) and dataa or '') | |||
if isSet(datab) then row:tag('td'):addClass('infobox-data infobox-data-b'):wikitext(datab) end | |||
if isSet(datac) then row:tag('td'):addClass('infobox-data infobox-data-c'):wikitext(datac) end | |||
row:tag('td') | |||
if isSet(datab) then | |||
if isSet(datac) then | |||
end | end | ||
function p.main(frame) | function p.main(frame) | ||
local args = getArgs(frame) | local args = getArgs(frame) | ||
local root = mw.html.create('table') | local root = mw.html.create('table') | ||
:addClass('infobox') | :addClass('infobox') | ||
:addClass(args.child == 'yes' and 'infobox-subbox' or nil) | :addClass(args.child == 'yes' and 'infobox-subbox' or nil) | ||
:cssText(args.bodystyle or 'width: 22em | :cssText(args.bodystyle or 'width: 22em;') | ||
-- | -- Title + Image (ساده) | ||
local title = firstArg(args, 'name', 'playername') or mw.title.getCurrentTitle().text | local title = firstArg(args, 'name', 'playername') or mw.title.getCurrentTitle().text | ||
root:tag('caption') | root:tag('caption'):addClass('infobox-title'):wikitext(title) | ||
if isSet(args.image) then | if isSet(args.image) then | ||
local | local img = root:tag('tr'):tag('td'):attr('colspan', '4'):addClass('infobox-image'):wikitext(args.image) | ||
if isSet(args.caption) then img:tag('div'):addClass('infobox-caption'):wikitext(args.caption) end | |||
if isSet(args.caption) then | |||
end | end | ||
-- اطلاعات شخصی | -- اطلاعات شخصی | ||
root:tag('tr'):tag('th'):attr('colspan', '4'):addClass('infobox-header'):wikitext('اطلاعات شخصی') | |||
addRow(root, 'نام کامل', firstArg(args, 'fullname', 'full_name', 'نام کامل')) | |||
addRow(root, 'زادروز', firstArg(args, 'birth_date', 'dateofbirth', 'زادروز')) | |||
addRow(root, 'زادگاه', firstArg(args, 'birth_place', 'cityofbirth', 'زادگاه')) | |||
addRow(root, 'قد', firstArg(args, 'height', 'قد')) | |||
addRow(root, 'پست', firstArg(args, 'position', 'پست')) | |||
-- | -- باشگاه کنونی | ||
local curr = firstArg(args, 'currentclub', 'باشگاه کنونی') | |||
if isSet(curr) then | |||
root:tag('tr'):tag('th'):attr('colspan', '4'):addClass('infobox-header'):wikitext('اطلاعات باشگاهی') | |||
addRow(root, 'باشگاه کنونی', curr) | |||
addRow(root, | |||
end | end | ||
-- فقط بخشهای اصلی برای تست | |||
return tostring(root) | return tostring(root) | ||
end | end | ||
return p | return p | ||
نسخهٔ ۷ ژوئیهٔ ۲۰۲۶، ساعت ۱۹:۴۷
توضیحات این پودمان میتواند در پودمان:Infobox football biography/توضیحات قرار گیرد.
local p = {}
local getArgs = require('Module:Arguments').getArgs
local function isSet(v)
if v == nil then return false end
return mw.text.trim(tostring(v)) ~= ''
end
local function firstArg(args, ...)
for i = 1, select('#', ...) do
local key = select(i, ...)
if isSet(args[key]) then return args[key] end
end
return nil
end
local function addRow(root, label, data)
if not isSet(data) then return end
local row = root:tag('tr')
row:tag('th'):attr('scope', 'row'):addClass('infobox-label'):wikitext(label)
row:tag('td'):attr('colspan', '3'):addClass('infobox-data'):wikitext(data)
end
local function addMultiDataRow(root, label, dataa, datab, datac)
if not isSet(dataa) and not isSet(datab) and not isSet(datac) then return end
local row = root:tag('tr')
row:tag('th'):attr('scope', 'row'):addClass('infobox-label'):wikitext(label)
row:tag('td'):addClass('infobox-data infobox-data-a'):wikitext(isSet(dataa) and dataa or '')
if isSet(datab) then row:tag('td'):addClass('infobox-data infobox-data-b'):wikitext(datab) end
if isSet(datac) then row:tag('td'):addClass('infobox-data infobox-data-c'):wikitext(datac) end
end
function p.main(frame)
local args = getArgs(frame)
local root = mw.html.create('table')
:addClass('infobox')
:addClass(args.child == 'yes' and 'infobox-subbox' or nil)
:cssText(args.bodystyle or 'width: 22em;')
-- Title + Image (ساده)
local title = firstArg(args, 'name', 'playername') or mw.title.getCurrentTitle().text
root:tag('caption'):addClass('infobox-title'):wikitext(title)
if isSet(args.image) then
local img = root:tag('tr'):tag('td'):attr('colspan', '4'):addClass('infobox-image'):wikitext(args.image)
if isSet(args.caption) then img:tag('div'):addClass('infobox-caption'):wikitext(args.caption) end
end
-- اطلاعات شخصی
root:tag('tr'):tag('th'):attr('colspan', '4'):addClass('infobox-header'):wikitext('اطلاعات شخصی')
addRow(root, 'نام کامل', firstArg(args, 'fullname', 'full_name', 'نام کامل'))
addRow(root, 'زادروز', firstArg(args, 'birth_date', 'dateofbirth', 'زادروز'))
addRow(root, 'زادگاه', firstArg(args, 'birth_place', 'cityofbirth', 'زادگاه'))
addRow(root, 'قد', firstArg(args, 'height', 'قد'))
addRow(root, 'پست', firstArg(args, 'position', 'پست'))
-- باشگاه کنونی
local curr = firstArg(args, 'currentclub', 'باشگاه کنونی')
if isSet(curr) then
root:tag('tr'):tag('th'):attr('colspan', '4'):addClass('infobox-header'):wikitext('اطلاعات باشگاهی')
addRow(root, 'باشگاه کنونی', curr)
end
-- فقط بخشهای اصلی برای تست
return tostring(root)
end
return p