پودمان:Infobox football biography: تفاوت میان نسخهها
ظاهر
صفحهای تازه حاوی «local p = {} local getArgs = require('Module:Arguments').getArgs -- Helper functions 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...» ایجاد کرد |
جزبدون خلاصۀ ویرایش |
||
| خط ۲: | خط ۲: | ||
local getArgs = require('Module:Arguments').getArgs | local getArgs = require('Module:Arguments').getArgs | ||
local function isSet(v) | local function isSet(v) | ||
if v == nil then return false end | if v == nil then return false end | ||
| خط ۸: | خط ۷: | ||
end | end | ||
local function firstArg(args, ...) | local function firstArg(args, ...) | ||
for i = 1, select('#', ...) do | for i = 1, select('#', ...) do | ||
| خط ۳۳: | خط ۳۱: | ||
local function addMultiDataRow(root, label, dataa, datab, datac) | local function addMultiDataRow(root, label, dataa, datab, datac) | ||
if not isSet(dataa) and not isSet(datab) and not isSet(datac) then | 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') | ||
| خط ۶۸: | خط ۶۴: | ||
-- Title | -- Title | ||
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') | |||
:addClass('infobox-title') | |||
:wikitext(title) | |||
-- Image | -- Image | ||
| خط ۸۸: | خط ۸۲: | ||
-- اطلاعات شخصی | -- اطلاعات شخصی | ||
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, 'death_date', 'dateofdeath', 'تاریخ مرگ')) | |||
addRow(root, 'محل مرگ', firstArg(args, 'death_place', 'محل مرگ')) | |||
addRow(root, 'قد', firstArg(args, 'height', 'قد')) | |||
addRow(root, 'پست', firstArg(args, 'position', 'پست')) | |||
-- اطلاعات باشگاهی | -- اطلاعات باشگاهی | ||
local | local current = firstArg(args, 'currentclub', 'باشگاه کنونی') | ||
if isSet( | if isSet(current) then | ||
root:tag('tr'):tag('th') | root:tag('tr'):tag('th') | ||
:attr('colspan', '4') | :attr('colspan', '4') | ||
:addClass('infobox-header') | :addClass('infobox-header') | ||
:wikitext('اطلاعات باشگاهی') | :wikitext('اطلاعات باشگاهی') | ||
addRow(root, 'باشگاه کنونی', current) | |||
addRow(root, 'باشگاه کنونی', | |||
addRow(root, 'شمارهٔ پیراهن', firstArg(args, 'clubnumber', 'شمارهٔ پیراهن')) | addRow(root, 'شمارهٔ پیراهن', firstArg(args, 'clubnumber', 'شمارهٔ پیراهن')) | ||
end | end | ||
-- باشگاههای جوانان | -- باشگاههای جوانان | ||
local i = 1 | local i = 1 | ||
while isSet(args['youthclubs' .. i]) or (i == 1 and isSet(args.youthclubs)) do | |||
local club = args['youthclubs' .. i] or (i == 1 and args.youthclubs) | |||
local club = | local years = args['youthyears' .. i] or (i == 1 and args.youthyears) | ||
if i == 1 then | |||
if | |||
root:tag('tr'):tag('th') | root:tag('tr'):tag('th') | ||
:attr('colspan', '4') | :attr('colspan', '4') | ||
:addClass('infobox-header') | :addClass('infobox-header') | ||
:wikitext('باشگاههای جوانان') | :wikitext('باشگاههای جوانان') | ||
end | end | ||
addRow(root, years or '', club) | addRow(root, years or '', club) | ||
i = i + 1 | i = i + 1 | ||
end | end | ||
-- | -- بقیه بخشها را برای جلوگیری از خطا فعلاً ساده کردم | ||
-- (بعداً کامل میکنیم) | |||
-- | |||
return tostring(root) | return tostring(root) | ||
نسخهٔ ۷ ژوئیهٔ ۲۰۲۶، ساعت ۱۹:۴۴
توضیحات این پودمان میتواند در پودمان: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
local title = firstArg(args, 'name', 'playername') or mw.title.getCurrentTitle().text
root:tag('caption')
:addClass('infobox-title')
:wikitext(title)
-- Image
if isSet(args.image) then
local imgCell = root:tag('tr'):tag('td')
:attr('colspan', '4')
:addClass('infobox-image')
:wikitext(args.image)
if isSet(args.caption) then
imgCell: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, 'death_date', 'dateofdeath', 'تاریخ مرگ'))
addRow(root, 'محل مرگ', firstArg(args, 'death_place', 'محل مرگ'))
addRow(root, 'قد', firstArg(args, 'height', 'قد'))
addRow(root, 'پست', firstArg(args, 'position', 'پست'))
-- اطلاعات باشگاهی
local current = firstArg(args, 'currentclub', 'باشگاه کنونی')
if isSet(current) then
root:tag('tr'):tag('th')
:attr('colspan', '4')
:addClass('infobox-header')
:wikitext('اطلاعات باشگاهی')
addRow(root, 'باشگاه کنونی', current)
addRow(root, 'شمارهٔ پیراهن', firstArg(args, 'clubnumber', 'شمارهٔ پیراهن'))
end
-- باشگاههای جوانان
local i = 1
while isSet(args['youthclubs' .. i]) or (i == 1 and isSet(args.youthclubs)) do
local club = args['youthclubs' .. i] or (i == 1 and args.youthclubs)
local years = args['youthyears' .. i] or (i == 1 and args.youthyears)
if i == 1 then
root:tag('tr'):tag('th')
:attr('colspan', '4')
:addClass('infobox-header')
:wikitext('باشگاههای جوانان')
end
addRow(root, years or '', club)
i = i + 1
end
-- بقیه بخشها را برای جلوگیری از خطا فعلاً ساده کردم
-- (بعداً کامل میکنیم)
return tostring(root)
end
return p