پودمان:Tennis events nav

از ویکی‌پدیا، دانشنامهٔ آزاد
توضیحات پودمان[ایجاد] [پاکسازی]
-- This module implements [[Template:Infobox tennis tournament event/events]].
-- [SublimeLinter luacheck-globals:mw]

local p = {}
local getBuffer, print = require("Module:OutputBuffer")()

local STYLES = {
	["singlesdoubles"] = {[=[|-
| [[{prefix} {tournament} {year} – انفرادی|انفرادی]]
| [[{prefix} {year} {tournamentd} – دونفره|دونفره]]]=]},
		["1"] = "singlesdoubles",
		["men"] = "singlesdoubles",
		["mens"] = "singlesdoubles",
		["women"] = "singlesdoubles",
		["womens"] = "singlesdoubles",
	["risingstarsinvitational"] = {[=[|-
| [[{prefix} {tournament} {year} – انفرادی|انفرادی]]
| [[{prefix} {year} {tournamentd} – دونفره|دونفره]]
|-
| colspan="2" | [[{prefix} {tournament} {year} – Rising Stars Invitational|Rising Stars]]]=]},
	["boysgirlssingles"] = {[=[|-
! scope="row" style="font-weight: normal; text-align: right;" | انفرادی
| [[{prefix} {tournament} {year} – انفرادی مردان|مردان]]
| [[{prefix} {tournament} {year} – انفرادی زنان|زنان]]
| [[{prefix} {tournament} {year} – انفرادی پسران|پسران]]
| [[{prefix} {tournament} {year} – انفرادی دختران|دختران]]
|-
! scope="row" style="font-weight: normal; text-align: right;" | دونفره
| [[{prefix} {tournament} {year} – دونفره مردان|مردان]]
| [[{prefix} {tournament} {year} – دونفره زنان|زنان]]]=]},
		["miamimasters"] = "boysgirlssingles",
	["mixeddoubles"] = {[=[|-
! scope="row" style="font-weight: normal; text-align: right;" | انفرادی
| [[{prefix} {tournament} {year} – انفرادی مردان|مردان]]
| [[{prefix} {tournament} {year} – انفرادی زنان|زنان]]
|-
! scope="row" style="font-weight: normal; text-align: right;" | دونفره
| [[{prefix} {tournament} {year} – دونفره مردان|مردان]]
| [[{prefix} {tournament} {year} – دونفره زنان|زنان]]
| [[{prefix} {tournament} {year} – Mixed Doubles|mixed]]]=]},
		["mixed"] = "mixeddoubles",
		["grandslam"] = "mixeddoubles",
	["mixedandteam"] = {[=[|-
! scope="row" style="font-weight: normal; text-align: right;" | انفرادی
| [[{prefix} {tournament} {year} – انفرادی مردان|مردان]]
| [[{prefix} {tournament} {year} – انفرادی زنان|زنان]]
|-
! scope="row" style="font-weight: normal; text-align: right;" | دونفره
| [[{prefix} {tournament} {year} – دونفره مردان|مردان]]
| [[{prefix} {tournament} {year} – دونفره زنان|زنان]]
| [[{prefix} {tournament} {year} – Mixed Doubles|mixed]]
|-
! scope="row" style="font-weight: normal; text-align: right;" | تیم
| [[{prefix} {tournament} {year} – Men's Team|men]]
| [[{prefix} {tournament} {year} – Women's Team|women]]]=]},
	["australianopen"] = {[=[|-
! scope="row" style="font-weight: normal; text-align: right;" | انفرادی
| [[{tournament} {year} – انفرادی مردان|مردان]]
| [[{tournament} {year} – انفرادی زنان|زنان]]
|
| [[{tournament} {year} – انفرادی پسران|پسران]]
| [[{tournament} {year} – انفرادی دختران|دختران]]
|-
! scope="row" style="font-weight: normal; text-align: right;" | دونفره
| [[{tournament} {year} – دونفره مردان|مردان]]
| [[{tournament} {year} – دونفره زنان|زنان]]
| [[{tournament} {year} – Mixed Doubles|mixed]]
| [[{tournament} {year} – دونفره پسران|پسران]]
| [[{tournament} {year} – دونفره دختران|دختران]]
|-
! scope="row" style="font-weight: normal; text-align: right;" | Legends
| [[{tournament} {year} – Men Legends' Doubles|men]]
| [[{tournament} {year} – Women Legends' Doubles|women]]
| [[{tournament} {year} – Legends Mixed|mixed]]
|-
! scope="row" style="font-weight: normal; text-align: right;" | WC Singles
| [[{tournament} {year} – Wheelchair Men's Singles|men]]
| [[{tournament} {year} – Wheelchair Women's Singles|women]]
| [[{tournament} {year} – Wheelchair Quad Singles|quad]]
|-
! scope="row" style="font-weight: normal; text-align: right;" | WC Doubles
| [[{tournament} {year} – Wheelchair Men's Doubles|men]]
| [[{tournament} {year} – Wheelchair Women's Doubles|women]]
| [[{tournament} {year} – Wheelchair Quad Doubles|quad]]
]=]},
	["frenchopen"] = {[=[|-
! scope="row" style="font-weight: normal; text-align: right;" | انفرادی
| [[{tournament} {year} – انفرادی مردان|مردان]]
| [[{tournament} {year} – انفرادی زنان|زنان]]
|
| [[{tournament} {year} – انفرادی پسران|پسران]]
| [[{tournament} {year} – انفرادی دختران|دختران]]
|-
! scope="row" style="font-weight: normal; text-align: right;" | دونفره
| [[{tournament} {year} – دونفره مردان|مردان]]
| [[{tournament} {year} – دونفره زنان|زنان]]
| [[{tournament} {year} – Mixed Doubles|mixed]]
| [[{tournament} {year} – دونفره پسران|پسران]]
| [[{tournament} {year} – دونفره دختران|دختران]]
|-
! scope="row" style="font-weight: normal; text-align: right;" | Legends
| [[{tournament} {year} – Legends Under 45 Doubles|−45]]
| [[{tournament} {year} – Legends Over 45 Doubles|45+]]
| [[{tournament} {year} – Women's Legends Doubles|women]]
|-
! scope="row" style="font-weight: normal; text-align: right;" | WC Singles
| [[{tournament} {year} – Wheelchair Men's Singles|men]]
| [[{tournament} {year} – Wheelchair Women's Singles|women]]
|-
! scope="row" style="font-weight: normal; text-align: right;" | WC Doubles
| [[{tournament} {year} – Wheelchair Men's Doubles|men]]
| [[{tournament} {year} – Wheelchair Women's Doubles|women]]
]=]},
	["wimbledonchampionships"] = {[=[|-
! scope="row" style="font-weight: normal; text-align: right;" | انفرادی
| [[{tournament} {year} – انفرادی مردان|مردان]]
| [[{tournament} {year} – انفرادی زنان|زنان]]
|
| [[{tournament} {year} – انفرادی پسران|پسران]]
| [[{tournament} {year} – انفرادی دختران|دختران]]
|-
! scope="row" style="font-weight: normal; text-align: right;" | دونفره
| [[{tournament} {year} – دونفره مردان|مردان]]
| [[{tournament} {year} – دونفره زنان|زنان]]
| [[{tournament} {year} – Mixed Doubles|mixed]]
| [[{tournament} {year} – دونفره پسران|پسران]]
| [[{tournament} {year} – دونفره دختران|دختران]]
|-
! scope="row" style="font-weight: normal; text-align: right;" | Legends
| [[{tournament} {year} – Gentlemen's Invitation Doubles|men]]
| [[{tournament} {year} – Ladies' Invitation Doubles|women]]
| [[{tournament} {year} – Senior Gentlemen's Invitation Doubles|seniors]]
|-
! scope="row" style="font-weight: normal; text-align: right;" | WC Doubles
| [[{tournament} {year} – Wheelchair Men's Doubles|men]]
| [[{tournament} {year} – Wheelchair Women's Doubles|women]]
]=]},
	["usopen"] = {[=[|-
! scope="row" style="font-weight: normal; text-align: right;" | انفرادی
| [[{tournament} {year} – انفرادی مردان|مردان]]
| [[{tournament} {year} – انفرادی زنان|زنان]]
|
| [[{tournament} {year} – انفرادی پسران|پسران]]
| [[{tournament} {year} – انفرادی دختران|دختران]]
|-
! scope="row" style="font-weight: normal; text-align: right;" | دونفره
| [[{tournament} {year} – دونفره مردان|مردان]]
| [[{tournament} {year} – دونفره زنان|زنان]]
| [[{tournament} {year} – Mixed Doubles|mixed]]
| [[{tournament} {year} – دونفره پسران|پسران]]
| [[{tournament} {year} – دونفره دختران|دختران]]
|-
! scope="row" style="font-weight: normal; text-align: right;" | Legends
| [[{tournament} {year} – Men's Champions Invitational|men]]
| [[{tournament} {year} – Women's Champions Invitational|women]]
| [[{tournament} {year} – Mixed Champions Invitational|mixed]]
|-
! scope="row" style="font-weight: normal; text-align: right;" | WC Singles
| [[{tournament} {year} – Wheelchair Men's Singles|men]]
| [[{tournament} {year} – Wheelchair Women's Singles|women]]
| [[{tournament} {year} – Wheelchair Quad Singles|quad]]
|-
! scope="row" style="font-weight: normal; text-align: right;" | WC Doubles
| [[{tournament} {year} – Wheelchair Men's Doubles|men]]
| [[{tournament} {year} – Wheelchair Women's Doubles|women]]
| [[{tournament} {year} – Wheelchair Quad Doubles|quad]]
]=]},
	["abnamroworldtennistournament"] = {[=[|-
| [[{prefix} {tournament} {year} – Singles|singles]]
| [[{prefix} {year} {tournamentd} – Doubles|doubles]]
|-
| [[{prefix} {tournament} {year} – Wheelchair Singles|wheelchair singles]]
| [[{prefix} {year} {tournamentd} – Wheelchair Doubles|wheelchair doubles]]]=]},
	["doublestwotourneys"] = {[=[|-
! scope="row" style="font-weight: normal; text-align: right;" | انفرادی
| [[{prefix} {tournament} {year} – Singles|men]]
| [[{prefix} {year} {tournamentd} – Singles|women]]
|-
! scope="row" style="font-weight: normal; text-align: right;" | دونفره
| [[{prefix} {tournament} {year} – Doubles|men]]
| [[{prefix} {year} {tournamentd} – Doubles|women]]]=]},
	[""] = {[=[|-
! scope="row" style="font-weight: normal; text-align: right;" | انفرادی
| [[{prefix} {tournament} {year} – انفرادی مردان|مردان]]
| [[{prefix} {tournament} {year} – انفرادی زنان|زنان]]
|-
! scope="row" style="font-weight: normal; text-align: right;" | دونفره
| [[{prefix} {tournament} {year} – دونفره مردان|مردان]]
| [[{prefix} {tournament} {year} – دونفره زنان|زنان]]]=]}}

local function pullItem(value, default)
	value = value and string.lower(string.gsub(value, "%A", ""))
	if type(STYLES[value]) == "string" then
		value = STYLES[value]
	end
	if STYLES[value] then
		return STYLES[value][1]
	else
		return STYLES[default][1]
	end
end

function p._main(args)
	local default = ""
	if args[2] ~= args[3] then
		default = "doublestwotourneys"
	end

	print('{| style="border-spacing: 0.6em 0; margin: auto; ' ..
		  'text-align: center;"')
	print(string.gsub(pullItem(args.type, default), "{(%a+)}",
		{prefix = args.prefix or "", year = args[1], tournament = args[2],
		 tournamentd = args[3]}))
	print("|}")
	return getBuffer("\n")
end

function p.main(frame)
	local args = require("Module:Arguments").getArgs(frame)
	return p._main(args)
end

return p