Module:Infobox/Team

local lang = mw.getLanguage('en') local Team = require('Module:Team').team local Role = require('Module:Role').role --local Champion = require('Module:Champion').champion local Region = require('Module:Region').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_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 = { nonav = 'Yes', nocargo = true }, iesf = { cat = 'IESF Teams', nonav = 'Yes', nocargo = true }, national = { cat = 'National Teams', nonav = 'Yes', nocargo = true }, }

function 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 {} }	local othertitles = { args.title1, args.title2, args.title3, args.title4, args.title5, args.title6, args.title7, args.title8 } --	util_table.removeFalseEntries(othertitles) args.otherwikis = next(othertitles) and table.concat(othertitles, ',') return tbl end

function processDisplay(args, processed) local social = social.makeSocialSection(args) local display = { title = args.name or processed.pagename, image = getImage(args.image, processed.pagename), notice = 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 Region{args.region}, Owner = args.owner, HeadCoach = args.headcoach, Sponsor = args.sponsor, Partner = args.partner, social = next(social) and tostring(util_html.blockBox(social)), history = 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 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 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 makeHistory(args) if not args.created then return false end local tbl = mw.html.create('table') :addClass('infobox-subtable') makeHistoryLine(tbl, 'Created', args.created, args.created2 and 1) makeHistoryLine(tbl, 'Disbanded', args.disbanded, args.created2 and 1) local i = 2 while args['created' .. i] do makeHistoryLine(tbl, 'Created', args['created' .. i], i) makeHistoryLine(tbl, 'Disbanded', args['disbanded' .. i], i)		i = i + 1 end return tostring(tbl) end

function 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 processCargo(args, processed) return { {			'',			_table = 'InfoboxTeam', Name = args.name, Location = args.orgcountry, TeamLocation = args.country, Region = Region{args.region, 'regionname'}, 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 processVariables(args, processed) return { suppressorgnavbox = args.special and SPECIAL[args.special] and SPECIAL[args.special].nonav, } end

function processCategories(args, processed) local tbl = { args.region and (Region{args.region,'regionadjectivename'} .. ' 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 = 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 = processDisplay(args, processed) local cargo = processCargo(args, processed) local variables = processVariables(args, processed) local categories = processCategories(args, processed) return { display = display, cargo = cargo, settings = settings, categories = categories, variables = variables, layout = LAYOUT } end

return p