Module:Infobox/Team

local lang = mw.getLanguage('en') local m_region = require('Module:Region') local m_country = require('Module:Country') local social = require('Module:Infobox/Social') local util_infobox = require('Module:InfoboxUtil') local util_html = require('Module:HtmlUtil') local util_cargo = require('Module:CargoUtil') local util_dpl = require('Module:DPLUtil') local util_args = require('Module:ArgsUtil') local util_table = require('Module:TableUtil')

local NOIMAGE = 'Unknown Infobox Image - Team.png'

local LAYOUT = { tabs = 'TeamTabsHeader', sections = { 'Team Information', 'History', 'Social Media & Links', 'Current Roster' }, contents = { { 'Org Location', 'Team Location', 'FoundedIn', 'Region', 'Owner', 'HeadCoach', 'Sponsor', 'Partner' }, { 'history', history = 'wide' }, { 'social', social = 'wide' }, { 'rosterimage', rosterimage = 'wide' } },	i18n = { FoundedIn = 'Founded In', Owner = 'Owner(s)', HeadCoach = 'Head Coach', Sponsor = 'Sponsor(s)', Partner = 'Partner(s)', } }

local SPECIAL = { allstar = { cat = 'All-Star Regional Teams', nonav = 'Yes', nocargo = true }, aprilfools = { nonav = 'Yes', nocargo = true }, city = { nonav = 'Yes', nocargo = true }, clubmasters = { nonav = 'Yes', nocargo = true }, collegiate = { cat = 'Collegiate Teams', nocargo = false }, iesf = { cat = 'IESF Teams', nonav = 'Yes', nocargo = true }, nasg = { nonav = 'Yes', nocargo = true }, national = { cat = 'National Teams', nonav = 'Yes', nocargo = true }, }

local h = {}

function h.getProcessed(args) local tbl = { pagename = mw.title.getCurrentTitle.text, lc = args.name and lang:lcfirst(args.name) == args.name, isdisbanded = (args.isdisbanded or args.neworg or args.isrenamed) and lang:lc(args.isdisbanded or '') ~= 'no', special = args.special and SPECIAL[args.special] or {} }	return tbl end

function h.processDisplay(args, processed) local social = social.makeSocialSection(args) local display = { title = args.name or processed.pagename, image = h.getImage(args.image, processed.pagename), notice = h.makeNotice(args),

['Org Location'] = args.orgcountry and m_country.rightlong(args.orgcountry), ['Team Location'] = args.country and m_country.rightlong(args.country), FoundedIn = args.foundedcountry and m_country.rightlong(args.foundedcountry), Region = args.region and m_region.rightmedium(args.region), Owner = args.owner, HeadCoach = args.headcoach, Sponsor = args.sponsor, Partner = args.partner, social = next(social) and tostring(util_html.blockBox(social)), history = h.makeHistory(args), rosterimage = args.rosterphoto and (''):format(args.rosterphoto),

}	return display end

-- might need to rewrite this to depend on the teamLink variable instead of the actual pagename function h.getImage(image, pagename) if image and mw.title.makeTitle('Media', image).exists then return image end local profile = ('%slogo profile.png'):format(pagename) if mw.title.makeTitle('Media', profile).exists then return profile end local square = ('%slogo square.png'):format(pagename) if mw.title.makeTitle('Media', square).exists then return square end return NOIMAGE end

function h.makeNotice(args) if args.isdisbanded and lang:lc(args.isdisbanded) == 'yes' then return 'Team has disbanded.' elseif args.neworg then return ('Roster has joined a new organization.'):format(args.neworg) elseif args.isrenamed then return ('Team has renamed.'):format(args.isrenamed) else return false end end

function h.makeHistory(args) if not args.created then return false end local tbl = mw.html.create('table') :addClass('infobox-subtable') h.makeHistoryLine(tbl, 'Created', args.created, args.created2 and 1) h.makeHistoryLine(tbl, 'Disbanded', args.disbanded, args.created2 and 1) local i = 2 while args['created' .. i] do h.makeHistoryLine(tbl, 'Created', args['created' .. i], i) h.makeHistoryLine(tbl, 'Disbanded', args['disbanded' .. i], i)		i = i + 1 end return tostring(tbl) end

function h.makeHistoryLine(tbl, label, content, i)	if not content then return end tbl:tag('tr') :tag('th') :addClass('teamdate') :wikitext(label .. (i and (' (%s)'):format(i) or '')) :done :tag('td') :wikitext(content) :done :done return end

function h.processCargo(args, processed) return { {			'',			_table = 'Teams', Name = args.name, Location = args.orgcountry, TeamLocation = args.country, Region = m_region.long(args.region), Image = args.image, Twitter = args.twitter, Youtube = args.youtube, Facebook = args.facebook, Instagram = args.instagram, Discord = args.discord, Snapchat = args.snapchat, Vk = args.vk, Subreddit = args.subreddit, RosterPhoto = args.rosterphoto, IsDisbanded = processed.isdisbanded and 'Yes' or 'No', IsLowercase = processed.lc and 'Yes' or 'No', }	} end

function h.processVariables(args, processed) return { suppressorgnavbox = args.special and SPECIAL[args.special] and SPECIAL[args.special].nonav, } end

function h.processCategories(args, processed) local tbl = { args.region and (m_region.adjective(args.region) .. ' Teams') or 'Teams Without Region In Infobox', processed.isdisbanded and 'Inactive Teams' or 'Active Teams', args.country and ('%s Teams'):format(m_country.localization(args.country)), args.special and SPECIAL[args.special] and SPECIAL[args.special].cat, }	return tbl end

local p = {} function p.main(args) local processed = h.getProcessed(args) local settings = { lc = processed.lc, nocargo = mw.title.getCurrentTitle.nsText ~= '' or args.nocargo or processed.special.nocargo, nocat = mw.title.getCurrentTitle.nsText ~= '' or args['no-cat'], }	local display = h.processDisplay(args, processed) local cargo = h.processCargo(args, processed) local variables = h.processVariables(args, processed) local categories = h.processCategories(args, processed) return { display = display, cargo = cargo, settings = settings, categories = categories, variables = variables, layout = LAYOUT } end

return p