Modul:Tennis events nav

De la Wikipedia, enciclopedia liberă

Documentația acestui modul poate fi creată la Modul:Tennis events nav/doc

-- This module implements [[Template:Infobox tennis tournament event/events]].
-- [SublimeLinter luacheck-globals:mw]

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

local STYLES = {
	["singlesdoubles"] = {[=[|-
| [[{prefix} {year} {tournament} – Singles|Singles]]
| [[{prefix} {year} {tournamentd} – Doubles|Doubles]]]=]},
		["1"] = "singlesdoubles",
		["men"] = "singlesdoubles",
		["mens"] = "singlesdoubles",
		["women"] = "singlesdoubles",
		["womens"] = "singlesdoubles",
		["singles"] = {[=[|-
| [[{prefix} {year} {tournament} – Simplu|Simplu]]]=]},
	["doubles"] = {[=[|-
| [[{prefix} {year} {tournamentd} – Dublu|Dublu]]]=]},
	["risingstarsinvitational"] = {[=[|-
| [[{prefix} {year} {tournament} – Simplu|Simplu]]
| [[{prefix} {year} {tournamentd} – Dublu|Dublu]]
|-
| colspan="2" | [[{prefix} {year} {tournament} – Rising Stars Invitational|Rising Stars]]]=]},
	["boysgirlssingles"] = {[=[|-
! scope="row" style="font-weight: normal; text-align: right;" | Simplu
| [[{prefix} {year} {tournament} – Simplu masculin|masculin]]
| [[{prefix} {year} {tournament} – Simplu feminin|feminin]]
| [[{prefix} {year} {tournament} – Simplu băieți|băieți]]
| [[{prefix} {year} {tournament} – Simplu fete|fete]]
|-
! scope="row" style="font-weight: normal; text-align: right;" | Dublu
| [[{prefix} {year} {tournament} – Dublu masculin|masculin]]
| [[{prefix} {year} {tournament} – Dublu feminin|feminin]]]=]},
		["miamimasters"] = "boysgirlssingles",
	["mixeddoubles"] = {[=[|-
! scope="row" style="font-weight: normal; text-align: right;" | Simplu
| [[{prefix} {year} {tournament} – Simplu masculin|masculin]]
| [[{prefix} {year} {tournament} – Simplu feminin|feminin]]
|-
! scope="row" style="font-weight: normal; text-align: right;" | Dublu
| [[{prefix} {year} {tournament} – Dublu masculin|masculin]]
| [[{prefix} {year} {tournament} – Dublu feminin|feminin]]
| [[{prefix} {year} {tournament} – Dublu mixt|mixt]]]=]},
		["mixed"] = "mixeddoubles",
		["grandslam"] = "mixeddoubles",
	["mixedandteam"] = {[=[|-
! scope="row" style="font-weight: normal; text-align: right;" | Simplu
| [[{prefix} {year} {tournament} – Simplu masculin|masculin]]
| [[{prefix} {year} {tournament} – Simplu feminin|feminin]]
|-
! scope="row" style="font-weight: normal; text-align: right;" | Dublu
| [[{prefix} {year} {tournament} – Dublu masculin|masculin]]
| [[{prefix} {year} {tournament} – Dublu feminin|feminin]]
| [[{prefix} {year} {tournament} – Dublu mixt|mixt]]
|-
! scope="row" style="font-weight: normal; text-align: right;" | Team
| [[{prefix} {year} {tournament} – Men's Team|men]]
| [[{prefix} {year} {tournament} – Women's Team|women]]]=]},
	["australianopen"] = {[=[|-
! scope="row" style="font-weight: normal; text-align: right;" | Simplu
| [[{year} {tournament} – Simplu masculin|masculin]]
| [[{year} {tournament} – Simplu feminin|feminin]]
|
| [[{year} {tournament} – Simplu băieți|băieți]]
| [[{year} {tournament} – Simplu fete|fete]]
|-
! scope="row" style="font-weight: normal; text-align: right;" | Dublu
| [[{year} {tournament} – Dublu masculin|masculin]]
| [[{year} {tournament} – Dublu feminin|feminin]]
| [[{year} {tournament} – Dublu mixt|mixt]]
| [[{year} {tournament} – Dublu băieți|băieți]]
| [[{year} {tournament} – Dublu fete|fete]]
|-
! scope="row" style="font-weight: normal; text-align: right;" | WC Singles
| [[{year} {tournament} – Wheelchair Men's Singles|men]]
| [[{year} {tournament} – Wheelchair Women's Singles|women]]
| [[{year} {tournament} – Wheelchair Quad Singles|quad]]
|-
! scope="row" style="font-weight: normal; text-align: right;" | WC Doubles
| [[{year} {tournament} – Wheelchair Men's Doubles|men]]
| [[{year} {tournament} – Wheelchair Women's Doubles|women]]
| [[{year} {tournament} – Wheelchair Quad Doubles|quad]]
|-
! scope="row" style="font-weight: normal; text-align: right;" | Legends
| [[{year} {tournament} – Men's Legends' Doubles|men]]
| [[{year} {tournament} – Women's Legends' Doubles|women]]
| [[{year} {tournament} – Legends Mixed|mixed]]
]=]},
	["frenchopen"] = {[=[|-
! scope="row" style="font-weight: normal; text-align: right;" | Simplu
| [[{year} {tournament} – Simplu masculin|masculin]]
| [[{year} {tournament} – Simplu feminin|feminin]]
|
| [[{year} {tournament} – Simplu băieți|băieți]]
| [[{year} {tournament} – Simplu fete|fete]]
|-
! scope="row" style="font-weight: normal; text-align: right;" | Dublu
| [[{year} {tournament} – Dublu masculin|masculin]]
| [[{year} {tournament} – Dublu feminin|feminin]]
| [[{year} {tournament} – Dublu mixt|mixt]]
| [[{year} {tournament} – Dublu băieți|băieți]]
| [[{year} {tournament} – Dublu fete|fete]]
|-
! scope="row" style="font-weight: normal; text-align: right;" | WC Singles
| [[{year} {tournament} – Wheelchair Men's Singles|men]]
| [[{year} {tournament} – Wheelchair Women's Singles|women]]
| [[{year} {tournament} – Wheelchair Quad Singles|quad]]
|-
! scope="row" style="font-weight: normal; text-align: right;" | WC Doubles
| [[{year} {tournament} – Wheelchair Men's Doubles|men]]
| [[{year} {tournament} – Wheelchair Women's Doubles|women]]
| [[{year} {tournament} – Wheelchair Quad Doubles|quad]]
|-
! scope="row" style="font-weight: normal; text-align: right;" | Legends
| [[{year} {tournament} – Legends Under 45 Doubles|−45]]
| [[{year} {tournament} – Legends Over 45 Doubles|45+]]
| [[{year} {tournament} – Women's Legends Doubles|women]]
]=]},
	["wimbledonchampionships"] = {[=[|-
! scope="row" style="font-weight: normal; text-align: right;" | Simplu
| [[{year} {tournament} – Simplu masculin|masculin]]
| [[{year} {tournament} – Simplu feminin|feminin]]
|
| [[{year} {tournament} – Simplu băieți|băieți]]
| [[{year} {tournament} – Simplu fete|fete]]
|-
! scope="row" style="font-weight: normal; text-align: right;" | Dublu
| [[{year} {tournament} – Dublu masculin|masculin]]
| [[{year} {tournament} – Dublu feminin|feminin]]
| [[{year} {tournament} – Dublu mixt|mixt]]
| [[{year} {tournament} – Dublu băieți|băieți]]
| [[{year} {tournament} – Dublu fete|fete]]
|-
! scope="row" style="font-weight: normal; text-align: right;" | WC Singles
| [[{year} {tournament} – Wheelchair Men's Singles|men]]
| [[{year} {tournament} – Wheelchair Women's Singles|women]]
| [[{year} {tournament} – Wheelchair Quad Singles|quad]]
|-
! scope="row" style="font-weight: normal; text-align: right;" | WC Doubles
| [[{year} {tournament} – Wheelchair Men's Doubles|men]]
| [[{year} {tournament} – Wheelchair Women's Doubles|women]]
| [[{year} {tournament} – Wheelchair Quad Doubles|quad]]
|-
! scope="row" style="font-weight: normal; text-align: right;" | Legends
| [[{year} {tournament} – Gentlemen's Invitation Doubles|men]]
| [[{year} {tournament} – Ladies' Invitation Doubles|women]]
| [[{year} {tournament} – Senior Gentlemen's Invitation Doubles|seniors]]
]=]},
	["usopen"] = {[=[|-
! scope="row" style="font-weight: normal; text-align: right;" | Simplu
| [[{year} {tournament} – Simplu masculin|masculin]]
| [[{year} {tournament} – Simplu feminin|feminin]]
|
| [[{year} {tournament} – Simplu băieți|băieți]]
| [[{year} {tournament} – Simplu fete|fete]]
|-
! scope="row" style="font-weight: normal; text-align: right;" | Dublu
| [[{year} {tournament} – Dublu masculin|masculin]]
| [[{year} {tournament} – Dublu feminin|feminin]]
| [[{year} {tournament} – Dublu mixt|mixt]]
| [[{year} {tournament} – Dublu băieți|băieți]]
| [[{year} {tournament} – Dublu fete|fete]]
|-
! scope="row" style="font-weight: normal; text-align: right;" | WC Singles
| [[{year} {tournament} – Wheelchair Men's Singles|men]]
| [[{year} {tournament} – Wheelchair Women's Singles|women]]
| [[{year} {tournament} – Wheelchair Quad Singles|quad]]
|-
! scope="row" style="font-weight: normal; text-align: right;" | WC Doubles
| [[{year} {tournament} – Wheelchair Men's Doubles|men]]
| [[{year} {tournament} – Wheelchair Women's Doubles|women]]
| [[{year} {tournament} – Wheelchair Quad Doubles|quad]]
|-
! scope="row" style="font-weight: normal; text-align: right;" | Legends
| [[{year} {tournament} – Men's Champions Invitational|men]]
| [[{year} {tournament} – Women's Champions Invitational|women]]
| [[{year} {tournament} – Mixed Champions Invitational|mixed]]
]=]},
	["abnamroworldtennistournament"] = {[=[|-
| [[{prefix} {year} {tournament} – Singles|singles]]
| [[{prefix} {year} {tournamentd} – Doubles|doubles]]
|-
| [[{prefix} {year} {tournament} – Wheelchair Singles|wheelchair singles]]
| [[{prefix} {year} {tournamentd} – Wheelchair Doubles|wheelchair doubles]]]=]},
	["doublestwotourneys"] = {[=[|-
! scope="row" style="font-weight: normal; text-align: right;" | Simplu
| [[{prefix} {year} {tournament} – Simplu|masculin]]
| [[{prefix} {year} {tournamentd} – Simplu|feminin]]
|-
! scope="row" style="font-weight: normal; text-align: right;" | Dublu
| [[{prefix} {year} {tournament} – Dublu|masculin]]
| [[{prefix} {year} {tournamentd} – Dublu|feminin]]]=]},
	[""] = {[=[|-
! scope="row" style="font-weight: normal; text-align: right;" | Simplu
| [[{prefix} {year} {tournament} – Simplu masculin|masculin]]
| [[{prefix} {year} {tournament} – Simplu feminin|feminin]]
|-
! scope="row" style="font-weight: normal; text-align: right;" | Dublu
| [[{prefix} {year} {tournament} – Dublu masculin|masculin]]
| [[{prefix} {year} {tournament} – Dublu feminin|feminin]]]=]}}

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("Modul:Arguments").getArgs(frame)
	return p._main(args)
end

return p