Module:SubpageNavbox

local util_cargo = require('Module:CargoUtil') local util_vars = require('Module:VarsUtil')

local h = {} local p = {} function p.navbox(tabstype, title) if tabstype ~= 'Player' and tabstype ~= 'Team' then return nil end local teamAndSystem = h.getTeamAndSystem(tabstype, title) local clpnavbox = h.clpnArgs(teamAndSystem, tabstype) local orgnavbox = h.orgNavboxArgs(teamAndSystem, tabstype) local navboxes = { clpnavbox, orgnavbox } return navboxes end

function h.getTeamAndSystem(tabstype, title) if tabstype == 'Team' then return { Team = title } else return h.getTeamFromPlayer(title) end end

function h.getTeamFromPlayer(title) local query = { tables = 'Players', fields = { 'Team', 'TeamSystem=System' }, where = string.format('_pageName="%s"', title) }	return util_cargo.getOneRow(query) end

function h.orgNavboxArgs(teamAndSystem, tabstype) return { title = 'OrgNavbox', events = { showAll = true }, args = { teamAndSystem.Team, system = teamAndSystem.System, suffix = 'Yes', from_player = tabstype == 'Player' },	} end

function h.clpnArgs(teamAndSystem, tabstype) return { title = 'CurrentLeagueParticipantNavbox', events = { showAll = true }, args = { teamAndSystem.Team, suffix = 'Yes' }, pagetype = tabstype } end

return p