Loading
  • 21 Aug, 2019

  • By, Wikipedia

Module:PHL Sports Team

{{#invoke:PHL sports team|function_name}}

Data modules

Test cases

Collegiate teams, e.g. UAAP, NCAA
TeamCode or
Alias/es
SchoolLeft-sided iconRight-sided iconNo icon
(Function: main)(Function: rt)(Function: name)
AUFAUFAngeles University FoundationAUF school colors AUF
AUF school colors AUF Great Danes
AUF school colors AUF Lady Danes
AUF school colors AUF Baby Danes
No girls' team
AUF school colors Custom Team Name
AUF AUF school colors
AUF Great Danes AUF school colors
AUF Lady Danes AUF school colors
AUF Baby Danes AUF school colors
No girls' team
Custom Team Name AUF school colors
AUF
AUF Great Danes
AUF Lady Danes
AUF Baby Danes
No girls' team
Custom Team Name
AdamsonADUAdamson UniversityAdamson school colors Adamson
Adamson school colors Adamson Soaring Falcons
Adamson school colors Adamson Lady Falcons
Adamson school colors Adamson Baby Falcons
Adamson school colors Adamson Lady Baby Falcons
Adamson school colors Custom Team Name
Adamson Adamson school colors
Adamson Soaring Falcons Adamson school colors
Adamson Lady Falcons Adamson school colors
Adamson Baby Falcons Adamson school colors
Adamson Lady Baby Falcons Adamson school colors
Custom Team Name Adamson school colors
Adamson
Adamson Soaring Falcons
Adamson Lady Falcons
Adamson Baby Falcons
Adamson Lady Baby Falcons
Custom Team Name
ArellanoAUN
(AU)
Arellano UniversityArellano school colors Arellano
Arellano school colors Arellano Chiefs
Arellano school colors Arellano Lady Chiefs
Arellano school colors Arellano Braves
Arellano school colors Arellano Lady Braves
Arellano school colors Custom Team Name
Arellano Arellano school colors
Arellano Chiefs Arellano school colors
Arellano Lady Chiefs Arellano school colors
Arellano Braves Arellano school colors
Arellano Lady Braves Arellano school colors
Custom Team Name Arellano school colors
Arellano
Arellano Chiefs
Arellano Lady Chiefs
Arellano Braves
Arellano Lady Braves
Custom Team Name
AteneoADM
(ADMU)
Ateneo de Manila University
• Ateneo de Manila (ADM)
Ateneo school colors Ateneo
Ateneo school colors Ateneo Blue Eagles
Ateneo school colors Ateneo Lady Eagles
Ateneo school colors Ateneo Blue Eaglets
Ateneo school colors Ateneo Lady Eaglets
Ateneo school colors Custom Team Name
Ateneo Ateneo school colors
Ateneo Blue Eagles Ateneo school colors
Ateneo Lady Eagles Ateneo school colors
Ateneo Blue Eaglets Ateneo school colors
Ateneo Lady Eaglets Ateneo school colors
Custom Team Name Ateneo school colors
Ateneo
Ateneo Blue Eagles
Ateneo Lady Eagles
Ateneo Blue Eaglets
Ateneo Lady Eaglets
Custom Team Name
CEUCEUCentro Escolar UniversityCEU school colors CEU
CEU school colors CEU Scorpions
CEU school colors CEU Lady Scorpions
CEU school colors CEU Baby Scorpions
No girls' team
CEU school colors Custom Team Name
CEU CEU school colors
CEU Scorpions CEU school colors
CEU Lady Scorpions CEU school colors
CEU Baby Scorpions CEU school colors
No girls' team
Custom Team Name CEU school colors
CEU
CEU Scorpions
CEU Lady Scorpions
CEU Baby Scorpions
No girls' team
Custom Team Name
CSBCSBDe La Salle–College of Saint Benilde
• La Salle Green Hills (LSGH)
CSB school colors Benilde
CSB school colors Benilde Blazers
CSB school colors Benilde Lady Blazers
CSB school colors La Salle Green Hills Greenies
CSB school colors La Salle Lady Greenies
CSB school colors Custom Team Name
Benilde CSB school colors
Benilde Blazers CSB school colors
Benilde Lady Blazers CSB school colors
La Salle Green Hills Greenies CSB school colors
La Salle Lady Greenies CSB school colors
Custom Team Name CSB school colors
Benilde
Benilde Blazers
Benilde Lady Blazers
La Salle Green Hills Greenies
La Salle Lady Greenies
Custom Team Name
Don BoscoDBCDon Bosco Technical CollegeDon Bosco school colors Don Bosco
Don Bosco school colors Don Bosco Grey Wolves
No women's team
Don Bosco school colors Don Bosco Baby Grey Wolves
No girls' team
Don Bosco school colors Custom Team Name
Don Bosco Don Bosco school colors
Don Bosco Grey Wolves Don Bosco school colors
No women's team
Don Bosco Baby Grey Wolves Don Bosco school colors
No girls' team
Custom Team Name Don Bosco school colors
Don Bosco
Don Bosco Grey Wolves
No women's team
Don Bosco Baby Grey Wolves
No girls' team
Custom Team Name
EACEACEmilio Aguinaldo College
• EAC–Immaculate Conception Academy (EAC-ICA)
EAC school colors EAC
EAC school colors EAC Generals
EAC school colors EAC Lady Generals
EAC school colors EAC–ICA Brigadiers
EAC school colors EAC–ICA Lady Brigadiers
EAC school colors Custom Team Name
EAC EAC school colors
EAC Generals EAC school colors
EAC Lady Generals EAC school colors
EAC–ICA Brigadiers EAC school colors
EAC–ICA Lady Brigadiers EAC school colors
Custom Team Name EAC school colors
EAC
EAC Generals
EAC Lady Generals
EAC–ICA Brigadiers
EAC–ICA Lady Brigadiers
Custom Team Name
FEUFEUFar Eastern University
• Far Eastern University–FERN College (FEU-FERN)
• Far Eastern University–Diliman (FEU-D)
• Institute of Accounts (IOA)
FEU school colors FEU
FEU school colors FEU Tamaraws
FEU school colors FEU Lady Tamaraws
FEU school colors FEU–D Baby Tamaraws
FEU school colors FEU–D Lady Baby Tamaraws
FEU school colors Custom Team Name
FEU FEU school colors
FEU Tamaraws FEU school colors
FEU Lady Tamaraws FEU school colors
FEU–D Baby Tamaraws FEU school colors
FEU–D Lady Baby Tamaraws FEU school colors
Custom Team Name FEU school colors
FEU
FEU Tamaraws
FEU Lady Tamaraws
FEU–D Baby Tamaraws
FEU–D Lady Baby Tamaraws
Custom Team Name
JRUJRUJosé Rizal University
• José Rizal College (JRC)
JRU school colors JRU
JRU school colors JRU Heavy Bombers
JRU school colors JRU Lady Bombers
JRU school colors JRU Light Bombers
JRU school colors JRU Light Lady Bombers
JRU school colors Custom Team Name
JRU JRU school colors
JRU Heavy Bombers JRU school colors
JRU Lady Bombers JRU school colors
JRU Light Bombers JRU school colors
JRU Light Lady Bombers JRU school colors
Custom Team Name JRU school colors
JRU
JRU Heavy Bombers
JRU Lady Bombers
JRU Light Bombers
JRU Light Lady Bombers
Custom Team Name
La SalleDLS
(DLSZ)
(DLSU)
De La Salle University
• De La Salle College (DLSC)
• La Salle Green Hills (LSGH)
• De La Salle Zobel (DLSZ)
La Salle school colors La Salle
La Salle school colors De La Salle Green Archers
La Salle school colors De La Salle Lady Archers
La Salle school colors DLSZ Junior Archers
La Salle school colors DLSZ Junior Lady Archers
La Salle school colors Custom Team Name
La Salle La Salle school colors
De La Salle Green Archers La Salle school colors
De La Salle Lady Archers La Salle school colors
DLSZ Junior Archers La Salle school colors
DLSZ Junior Lady Archers La Salle school colors
Custom Team Name La Salle school colors
La Salle
De La Salle Green Archers
De La Salle Lady Archers
DLSZ Junior Archers
DLSZ Junior Lady Archers
Custom Team Name
LetranCSJ
(CSJL)
Colegio de San Juan de LetranLetran school colors Letran
Letran school colors Letran Knights
Letran school colors Letran Lady Knights
Letran school colors Letran Squires
Letran school colors Letran Lady Squires
Letran school colors Custom Team Name
Letran Letran school colors
Letran Knights Letran school colors
Letran Lady Knights Letran school colors
Letran Squires Letran school colors
Letran Lady Squires Letran school colors
Custom Team Name Letran school colors
Letran
Letran Knights
Letran Lady Knights
Letran Squires
Letran Lady Squires
Custom Team Name
LyceumLPULyceum of the Philippines University
• Lyceum of the Philippines University–Cavite (LPU-C)
Lyceum school colors Lyceum
Lyceum school colors Lyceum Pirates
Lyceum school colors Lyceum Lady Pirates
Lyceum school colors Lyceum Junior Pirates
Lyceum school colors Lyceum Junior Lady Pirates
Lyceum school colors Custom Team Name
Lyceum Lyceum school colors
Lyceum Pirates Lyceum school colors
Lyceum Lady Pirates Lyceum school colors
Lyceum Junior Pirates Lyceum school colors
Lyceum Junior Lady Pirates Lyceum school colors
Custom Team Name Lyceum school colors
Lyceum
Lyceum Pirates
Lyceum Lady Pirates
Lyceum Junior Pirates
Lyceum Junior Lady Pirates
Custom Team Name
MapuaMUN
(MU)
(MIT)
Mapúa University
• Mapúa Institute of Technology (MIT)
• Malayan High School of Science (Malayan)
• Malayan High School of Science (MHSS)
Mapua school colors Mapúa
Mapua school colors Mapúa Cardinals
Mapua school colors Mapúa Lady Cardinals
Mapua school colors Malayan Red Robins
Mapua school colors Malayan Lady Red Robins
Mapua school colors Custom Team Name
Mapúa Mapua school colors
Mapúa Cardinals Mapua school colors
Mapúa Lady Cardinals Mapua school colors
Malayan Red Robins Mapua school colors
Malayan Lady Red Robins Mapua school colors
Custom Team Name Mapua school colors
Mapúa
Mapúa Cardinals
Mapúa Lady Cardinals
Malayan Red Robins
Malayan Lady Red Robins
Custom Team Name
NUNUINational University
• Nazareth School of National University (NSNU)
• National University–Nazareth School (NUNS)
NU school colors NU
NU school colors NU Bulldogs
NU school colors NU Lady Bulldogs
NU school colors NUNS Bullpups
NU school colors NUNS Lady Bullpups
NU school colors Custom Team Name
NU NU school colors
NU Bulldogs NU school colors
NU Lady Bulldogs NU school colors
NUNS Bullpups NU school colors
NUNS Lady Bullpups NU school colors
Custom Team Name NU school colors
NU
NU Bulldogs
NU Lady Bulldogs
NUNS Bullpups
NUNS Lady Bullpups
Custom Team Name
PCUPCUPhilippine Christian UniversityPCU school colors PCU
PCU school colors PCU Dolphins
PCU school colors PCU Lady Dolphins
PCU school colors PCU Baby Dolphins
No girls' team
PCU school colors Custom Team Name
PCU PCU school colors
PCU Dolphins PCU school colors
PCU Lady Dolphins PCU school colors
PCU Baby Dolphins PCU school colors
No girls' team
Custom Team Name PCU school colors
PCU
PCU Dolphins
PCU Lady Dolphins
PCU Baby Dolphins
No girls' team
Custom Team Name
SSC-RSSCSan Sebastian College–RecoletosSSC-R school colors San Sebastian
SSC-R school colors San Sebastian Stags
SSC-R school colors San Sebastian Lady Stags
SSC-R school colors San Sebastian Staglets
SSC-R school colors San Sebastian Lady Staglets
SSC-R school colors Custom Team Name
San Sebastian SSC-R school colors
San Sebastian Stags SSC-R school colors
San Sebastian Lady Stags SSC-R school colors
San Sebastian Staglets SSC-R school colors
San Sebastian Lady Staglets SSC-R school colors
Custom Team Name SSC-R school colors
San Sebastian
San Sebastian Stags
San Sebastian Lady Stags
San Sebastian Staglets
San Sebastian Lady Staglets
Custom Team Name
SWUSWUSouthwestern UniversitySWU school colors SWU
SWU school colors SWU Cobras
SWU school colors SWU Lady Cobras
No boys' team
No girls' team
SWU school colors Custom Team Name
SWU SWU school colors
SWU Cobras SWU school colors
SWU Lady Cobras SWU school colors
No boys' team
No girls' team
Custom Team Name SWU school colors
SWU
SWU Cobras
SWU Lady Cobras
No boys' team
No girls' team
Custom Team Name
San BedaSBU
(SBC)
San Beda University
• San Beda College–Rizal (SBC-R)
• San Beda University–Rizal (SBU-R)
• San Beda College (SBC)
San Beda school colors San Beda
San Beda school colors San Beda Red Lions
San Beda school colors San Beda Red Lionesses
San Beda school colors San Beda Red Cubs
San Beda school colors San Beda Red Lioness Cubs
San Beda school colors Custom Team Name
San Beda San Beda school colors
San Beda Red Lions San Beda school colors
San Beda Red Lionesses San Beda school colors
San Beda Red Cubs San Beda school colors
San Beda Red Lioness Cubs San Beda school colors
Custom Team Name San Beda school colors
San Beda
San Beda Red Lions
San Beda Red Lionesses
San Beda Red Cubs
San Beda Red Lioness Cubs
Custom Team Name
TIPTIPTechnological Institute of the PhilippinesTIP school colors TIP
TIP school colors TIP Engineers
TIP school colors TIP Lady Engineers
No boys' team
No girls' team
TIP school colors Custom Team Name
TIP TIP school colors
TIP Engineers TIP school colors
TIP Lady Engineers TIP school colors
No boys' team
No girls' team
Custom Team Name TIP school colors
TIP
TIP Engineers
TIP Lady Engineers
No boys' team
No girls' team
Custom Team Name
UEUEAUniversity of the EastUE school colors UE
UE school colors UE Red Warriors
UE school colors UE Lady Warriors
UE school colors UE Junior Warriors
UE school colors UE Junior Lady Warriors
UE school colors Custom Team Name
UE UE school colors
UE Red Warriors UE school colors
UE Lady Warriors UE school colors
UE Junior Warriors UE school colors
UE Junior Lady Warriors UE school colors
Custom Team Name UE school colors
UE
UE Red Warriors
UE Lady Warriors
UE Junior Warriors
UE Junior Lady Warriors
Custom Team Name
UPUPDUniversity of the Philippines Diliman
• UP Integrated School (UPIS)
• University of the Philippines Manila (UPM)
UP school colors UP
UP school colors UP Fighting Maroons
UP school colors UP Lady Maroons
UP school colors UPIS Junior Maroons
UP school colors UPIS Junior Lady Maroons
UP school colors Custom Team Name
UP UP school colors
UP Fighting Maroons UP school colors
UP Lady Maroons UP school colors
UPIS Junior Maroons UP school colors
UPIS Junior Lady Maroons UP school colors
Custom Team Name UP school colors
UP
UP Fighting Maroons
UP Lady Maroons
UPIS Junior Maroons
UPIS Junior Lady Maroons
Custom Team Name
UPHDUPHUniversity of Perpetual Help System DALTA
• University of Perpetual Help Rizal (UPHR)
• Perpetual Help College of Rizal (PHCR)
UPHD school colors Perpetual
UPHD school colors Perpetual Altas
UPHD school colors Perpetual Lady Altas
UPHD school colors Perpetual Junior Altas
UPHD school colors Perpetual Junior Lady Altas
UPHD school colors Custom Team Name
Perpetual UPHD school colors
Perpetual Altas UPHD school colors
Perpetual Lady Altas UPHD school colors
Perpetual Junior Altas UPHD school colors
Perpetual Junior Lady Altas UPHD school colors
Custom Team Name UPHD school colors
Perpetual
Perpetual Altas
Perpetual Lady Altas
Perpetual Junior Altas
Perpetual Junior Lady Altas
Custom Team Name
USJ-RUSJ
(USJR)
University of San Jose–RecoletosUSJ-R school colors USJ–R
USJ-R school colors USJ–R Jaguars
USJ-R school colors USJ–R Lady Jaguars
No boys' team
No girls' team
USJ-R school colors Custom Team Name
USJ–R USJ-R school colors
USJ–R Jaguars USJ-R school colors
USJ–R Lady Jaguars USJ-R school colors
No boys' team
No girls' team
Custom Team Name USJ-R school colors
USJ–R
USJ–R Jaguars
USJ–R Lady Jaguars
No boys' team
No girls' team
Custom Team Name
USLSUSLUniversity of St. La SalleUSLS school colors USLS
USLS school colors USLS Stingers
USLS school colors USLS Lady Stingers
No boys' team
No girls' team
USLS school colors Custom Team Name
USLS USLS school colors
USLS Stingers USLS school colors
USLS Lady Stingers USLS school colors
No boys' team
No girls' team
Custom Team Name USLS school colors
USLS
USLS Stingers
USLS Lady Stingers
No boys' team
No girls' team
Custom Team Name
USTUSTUniversity of Santo TomasUST school colors UST
UST school colors UST Growling Tigers
UST school colors UST Tigresses
UST school colors UST Tiger Cubs
UST school colors UST Junior Tigresses
UST school colors Custom Team Name
UST UST school colors
UST Growling Tigers UST school colors
UST Tigresses UST school colors
UST Tiger Cubs UST school colors
UST Junior Tigresses UST school colors
Custom Team Name UST school colors
UST
UST Growling Tigers
UST Tigresses
UST Tiger Cubs
UST Junior Tigresses
Custom Team Name
UVUVUniversity of the VisayasUV school colors UV
UV school colors UV Green Lancers
UV school colors UV Green Lancers
UV school colors UV Green Lancers
No girls' team
UV school colors Custom Team Name
UV UV school colors
UV Green Lancers UV school colors
UV Green Lancers UV school colors
UV Green Lancers UV school colors
No girls' team
Custom Team Name UV school colors
UV
UV Green Lancers
UV Green Lancers
UV Green Lancers
No girls' team
Custom Team Name
{{{team1}}}Value for parameter '{{{team1}}}' not provided.Value for parameter '{{{team1}}}' not provided.
Value for parameter '{{{team1}}}' not provided.
Value for parameter '{{{team1}}}' not provided.
Value for parameter '{{{team1}}}' not provided.
Value for parameter '{{{team1}}}' not provided.
Value for parameter '{{{team1}}}' not provided.
Value for parameter '{{{team1}}}' not provided.
Value for parameter '{{{team1}}}' not provided.
Value for parameter '{{{team1}}}' not provided.
Value for parameter '{{{team1}}}' not provided.
Value for parameter '{{{team1}}}' not provided.
Value for parameter '{{{team1}}}' not provided.
Value for parameter '{{{team1}}}' not provided.
Value for parameter '{{{team1}}}' not provided.
Value for parameter '{{{team1}}}' not provided.
Value for parameter '{{{team1}}}' not provided.
Value for parameter '{{{team1}}}' not provided.
Value for parameter '{{{team1}}}' not provided.
Philippine Basketball Association (PBA) teams, includes PBA D–League
Code or
Alias/es
UsageOutput
ALA{{PBA team|ALA}}Alaska Aces
{{PBA team|ALA|short}}Alaska
{{PBA team|ALA|name=Custom Team Name}}Custom Team Name
AMA{{PBA team|AMA}}AMA Online Education Titans
{{PBA team|AMA|short}}AMA
{{PBA team|AMA|name=Custom Team Name}}Custom Team Name
BWB{{PBA team|BWB}}Blackwater Bossing
{{PBA team|BWB|short}}Blackwater
{{PBA team|BWB|name=Custom Team Name}}
or {{PBA team|BWB|yr=2014}} (2014–2020)
Custom Team Name
or Blackwater Elite (2014–2020)
CEU{{PBA team|CEU}}CEU Scorpions
{{PBA team|CEU|short}}CEU
{{PBA team|CEU|name=Custom Team Name}}
or {{PBA team|CEU|yr=2020}} (2020–2020)
Custom Team Name
or Karate Kid–CEU Scorpions (2020–2020)
COL{{PBA team|COL}}Terrafirma Dyip
{{PBA team|COL|short}}Terrafirma
{{PBA team|COL|name=Custom Team Name}}
or {{PBA team|COL|yr=2018}} (2018–2019)
Custom Team Name
or Columbian Dyip (2018–2019)
CON{{PBA team|CON}}Converge FiberXers
{{PBA team|CON|short}}Converge
{{PBA team|CON|name=Custom Team Name}}Custom Team Name
DIL{{PBA team|DIL}}Diliman Blue Dragons
{{PBA team|DIL|short}}DIL
{{PBA team|DIL|name=Custom Team Name}}Custom Team Name
DLS{{PBA team|DLS}}De La Salle Green Archers
{{PBA team|DLS|short}}DLS
{{PBA team|DLS|name=Custom Team Name}}
or {{PBA team|DLS|yr=2020}} (2020–2020)
Custom Team Name
or Eco Oil–La Salle Green Archers (2020–2020)
END{{PBA team|END}}Enderun Titans
{{PBA team|END|short}}END
{{PBA team|END|name=Custom Team Name}}
or {{PBA team|END|yr=2019}} (2019–2020)
Custom Team Name
or FamilyMart–Enderun Titans (2019–2020)
FEU{{PBA team|FEU}}FEU Tamaraws
{{PBA team|FEU|short}}FEU
{{PBA team|FEU|name=Custom Team Name}}
or {{PBA team|FEU|yr=2020}} (2020–2020)
Custom Team Name
or Seaoil Extreme Racers–FEU Tamaraws (2020–2020)
GSM{{PBA team|GSM}}Barangay Ginebra San Miguel
{{PBA team|GSM|short}}Barangay Ginebra
{{PBA team|GSM|name=Custom Team Name}}Custom Team Name
LET{{PBA team|LET}}Letran Knights
{{PBA team|LET|short}}LET
{{PBA team|LET|name=Custom Team Name}}
or {{PBA team|LET|yr=2020}} (2020–2020)
Custom Team Name
or Wang's Basketball Couriers–Letran Knights (2020–2020)
MAG{{PBA team|MAG}}Magnolia Hotshots
{{PBA team|MAG|short}}Magnolia
{{PBA team|MAG|name=Custom Team Name}}Custom Team Name
MAP{{PBA team|MAP}}Marinerong Pilipino Skippers
{{PBA team|MAP|short}}MAP
{{PBA team|MAP|name=Custom Team Name}}Custom Team Name
MAU{{PBA team|MAU}}Mapúa Cardinals
{{PBA team|MAU|short}}MAU
{{PBA team|MAU|name=Custom Team Name}}
or {{PBA team|MAU|yr=2020}} (2020–2020)
Custom Team Name
or ADG Dong–Mapúa Cardinals (2020–2020)
MER{{PBA team|MER}}Meralco Bolts
{{PBA team|MER|short}}Meralco
{{PBA team|MER|name=Custom Team Name}}Custom Team Name
NLX{{PBA team|NLX}}NLEX Road Warriors
{{PBA team|NLX|short}}NLEX
{{PBA team|NLX|name=Custom Team Name}}Custom Team Name
NP{{PBA team|NP}}NorthPort Batang Pier
{{PBA team|NP|short}}NorthPort
{{PBA team|NP|name=Custom Team Name}}Custom Team Name
PHX{{PBA team|PHX}}Phoenix Super LPG Fuel Masters
{{PBA team|PHX|short}}Phoenix Super LPG
{{PBA team|PHX|name=Custom Team Name}}
or {{PBA team|PHX|yr=2016}} (2016–2018)
or {{PBA team|PHX|yr=2019}} (2019–2019)
Custom Team Name
or Phoenix Fuel Masters (2016–2018)
or Phoenix Pulse Fuel Masters (2019–2019)
ROS{{PBA team|ROS}}Rain or Shine Elasto Painters
{{PBA team|ROS|short}}Rain or Shine
{{PBA team|ROS|name=Custom Team Name}}Custom Team Name
SMB{{PBA team|SMB}}San Miguel Beermen
{{PBA team|SMB|short}}San Miguel
{{PBA team|SMB|name=Custom Team Name}}Custom Team Name
SSC{{PBA team|SSC}}San Sebastian Stags
{{PBA team|SSC|short}}SSC
{{PBA team|SSC|name=Custom Team Name}}
or {{PBA team|SSC|yr=2020}} (2020–2020)
Custom Team Name
or Apex Fuel–San Sebastian Golden Stags (2020–2020)
TIP{{PBA team|TIP}}TIP Engineers
{{PBA team|TIP|short}}TIP
{{PBA team|TIP|name=Custom Team Name}}Custom Team Name
TNT{{PBA team|TNT}}TNT Tropang Giga
{{PBA team|TNT|short}}TNT
{{PBA team|TNT|name=Custom Team Name}}
or {{PBA team|TNT|yr=2016}} (2016–2019)
Custom Team Name
or TNT KaTropa (2016–2019)
UST{{PBA team|UST}}UST Growling Tigers
{{PBA team|UST|short}}UST
{{PBA team|UST|name=Custom Team Name}}
or {{PBA team|UST|yr=2019}} (2019–2019)
or {{PBA team|UST|yr=2020}} (2020–2020)
Custom Team Name
or Ironcon–UST Growling Tigers (2019–2019)
or Builders Warehouse–UST Growling Tigers (2020–2020)
{{{team1}}}{{PBA team|{{{team1}}}}}Value for parameter '{{{team1}}}' not provided.
{{PBA team|{{{team1}}}|short}}Value for parameter '{{{team1}}}' not provided.
{{PBA team|{{{team1}}}|name=Custom Team Name}}Value for parameter '{{{team1}}}' not provided.

require('strict')

local p = { isalias = false }
local yesno = require('Module:Yesno')
local constants = {	CODE_LEN = 3, SPACE = ' ', SHORT = 'short', INST = 'inst' }

local function makeInvokeFunc(funcName, league)
	return function (frame)
		local args = (frame.args[1] ~= nil) and frame.args or frame:getParent().args
		args['league'] = args['league'] or league or 'collegiate'
		return p[funcName](args)
	end
end

local function stripwhitespace(text) return text:match("^%s*(.-)%s*$") end

local function load_data(args)
	local data_module = 'Module:PHL sports team/' .. args['league']
	return mw.loadData(data_module)
end

local function get_key_by_code(code, data)
	if (data[code] ~= nil and type(data[code]) == 'string') then
		p.isalias = true
		return data[code]
	elseif (string.len(code) == constants.CODE_LEN) then
		for k,v in pairs(data) do
			if v[1]==code then return k end
		end
	end
	return code
end

local function get_icon(team, size, alt_team)
	local icon = '[[File:%s colors.svg|%s|border|%s school colors|link=]]'
	return string.format(icon, team, size or '11px', alt_team or team)
end

local function get_athlete_link(link, athl_name)
	if mw.title.new(link or athl_name, '').exists == true then return string.format('[[%s|%s]]', link or athl_name, athl_name) else return athl_name end
end

local function show_empty_param(param)
	return mw.html.create('span'):css('color', 'red'):cssText('style'):wikitext(string.format('Value for parameter \'%s\' not provided.', param))
end

local function get_link_by_evt(args, div, divLt, text, team)
	local evt = { bk = 'basketball', vb = 'volleyball', ft = 'football' }
	local mRdr = require('Module:Redirect')
	evt = evt[args[2]] or evt[args[3]] or evt[args['evt']]
	if evt == nil then
		if type(div) == 'number' and div < 3 then
			 return mRdr.getTarget(team)
		else return mRdr.getTarget(text) end
	end
	if (type(div) == 'string') then div = 3 end
	local evt_link = string.format('%s %s %s', text, divLt[div-2], evt)
	if (args['yr'] ~= nil) then return args['yr'] .. ' ' .. evt_link .. ' team' end
	return mRdr.getTarget(evt_link) or evt_link
end

local function get_name_by_year(team, year)
	if not year then return team[1] end
	for k, v in pairs(team) do
		if mw.ustring.find(k, "%d%d%d%dthru%d%d%d%d$") then
			local start_year, end_year = mw.ustring.match(k, "(%d%d%d%d)thru(%d%d%d%d)$")
			if (tonumber(start_year) <= tonumber(year)) and (tonumber(year) <= tonumber(end_year)) then
				return v
			end
		end
	end
	return team[1]
end

local function add_link(args, team, name, div, divLt, text)
	local evt_link = get_link_by_evt(args, div, divLt, team[div] or team[3], team[3])
	if (type(div) == 'number' and div >= 3 and div <= 6) then
		if ((args['inst'] or name) ~= nil or args[3] == constants.SHORT)
				then return string.format('[[%s|%s]]', evt_link or team[div], not p.isalias and team[args['inst']] or text)
			elseif (evt_link ~= nil) then return string.format('[[%s|%s]]', evt_link, text)
			else return string.format('[[%s]]', text) end
	end
	return string.format('[[%s|%s]]', evt_link or team[3], text)
end

local function add_link_generic(args, team, text)
	local mRdr = require('Module:Redirect')
	local tln = team.link or get_name_by_year(team, args['season'] or args['team'])
	local dab  = team.dab and (tln .. ' (' .. team.dab .. ')') or nil
	local fln = dab or tln
	
	if args['name']     then fln = team[args['name']] or dab or tln end
	if args['season']   then fln = args['season'] .. ' ' .. tln .. ' season'
	elseif args['team'] then fln = args['team'] .. ' ' .. tln .. ' team'
	else fln = mRdr.getTarget(fln) end
	return string.format('[[%s|%s]]', fln or dab or tln, text)
end

function p._main(args)
	local data = load_data(args)
	local in_team = stripwhitespace(args[1] or '')
	if (in_team:match('^{{{.*}}}$') ~= nil) then return show_empty_param(in_team) elseif (in_team == '' or nil) then return '—' end
	
	local in_div = stripwhitespace(args[2] or '')
	local in_name = args['name']
	local key = get_key_by_code(in_team, data)
	local team = data[key]
	if (team == nil) then return tostring(mw.html.create('span'):css('color', 'red'):cssText('style'):wikitext(string.format('Invalid team: %s', in_team))) end
	
	local out
	local divLt = { "men's", "women's", "boys'", "girls'" }
	
	if (in_div ~= constants.SHORT) then
		local div = { inst = 2, men = 3, women = 4, junior = 5, boys = 5, girls = 6 }
		in_div = div[in_div] or tonumber(in_div:match('[2-6]') or '3')
		if (args[3] == constants.INST or args['inst'] ~= nil or in_div == 2) then out = p.isalias and team[in_team] or team[div['inst']]
			elseif (args[3] == constants.SHORT) then out = team[7] or key or in_team
			else out = in_name or team[in_div] end
		if (out == nil) then return mw.html.create('span'):css('color', 'red'):cssText('style'):wikitext('No ' .. divLt[in_div-2] .. ' team') end
	else
		out = team[7] or key or in_team
	end
	
	out = out:gsub("-", "&ndash;")
	
	if yesno(args['add_link'] or 'y') then
		out = add_link(args, team, in_name, in_div, divLt, out)
	end

	if yesno(args['icon'] or 'y') then
		local icon = get_icon(key or in_team, args['iconsize'])
		out = yesno(args['rt'] or 'n') and out .. constants.SPACE .. icon or icon .. constants.SPACE .. out
	end
	
	return out
end

function p._rt(args)
	args['rt'] = 'y'
	return p._main(args)
end

function p._name(args)
	args['icon'] = 'n'
	return p._main(args)
end

function p._color(args)
	local data = load_data(args)
	local in_team = stripwhitespace(args[1] or '')
	local no_img = string.format('[[File:No image.svg|%s|link=]]', args['size'] or '11px')
	local note = ''
	if in_team and in_team:match('[%*]$') then
		note = mw.ustring.gsub(in_team, '^(.-)([%*]*)$', '%2')
		in_team = mw.ustring.gsub(in_team, '^(.-)([%*]*)$', '%1')
	end
	if (in_team:match('^{{{.*}}}$') ~= nil) then
		return show_empty_param(in_team) .. note
	elseif (in_team == '' or nil) then return no_img .. note end
		
	local key = get_key_by_code(in_team, data)
	if ((data[in_team] or data[key]) == nil) then
		return no_img .. note
	end
	return get_icon(key or in_team, args['size'], args[2]) .. note
end

function p._generic(args)
	local data = load_data(args)
	local code, name, out = stripwhitespace(args[1] or ''), args['name']
	local team = data[code]
	
	if (code:match('^{{{.*}}}$') ~= nil) then return show_empty_param(code) elseif (code == '' or nil) then return '—' end

	if type(team) == 'string' then
		local alias = mw.text.split(team, '%s*|%s*')
		team = data[alias[1]]
		name = name or alias[2]
	end
	
	if not team then return mw.html.create('span'):css('color', 'red'):cssText('style'):wikitext(string.format('Invalid team: %s', code)) end
	if args[2] == constants.SHORT then out = team[2] or code
		elseif name then out = team[name] or name
		else out = get_name_by_year(team, args['season'] or args['team'] or args['yr'])
	end
	return add_link_generic(args, team, out)
end

function p._athlete(args)
	local athl_1 = args['athl']
	local athl_2 = args['athl2']
	
	if athl_1 == nil then return mw.html.create('span'):css('color', 'red'):cssText('style'):wikitext('Invalid athlete: no value') end
	local link = get_athlete_link(args['link'], athl_1)
	
	if (athl_2 ~= nil) then link = link .. ' and ' .. get_athlete_link(args['link2'], athl_2) end
	
	local showicon = yesno(args['icon'])
	local sport = args['sp']
	
	if (showicon) then args[3] = constants.SHORT end
	args['add_link'] = 'n'
	local lbl = p._name(args)
	if (sport ~= nil) then
		lbl = string.format('%s&nbsp;<span style="font-size:90%%;">(%s,&nbsp;%s)</span>', link, lbl, string.lower(sport))
	else lbl = string.format('%s&nbsp;<span style="font-size:90%%;">(%s)</span>', link, lbl)
	end
	
	if (showicon) then
		args[2] = args[1]
		return p._color(args) .. constants.SPACE .. lbl
	else return lbl
	end
end

function p._athlete_bc(args)
	if (args['athl'] == nil) then
	    -- reassign arguments for backward compatibility --
	    args['athl'] = args[2]
		args[2] = args[3] or ''
		args[3] = args[4] or ''
	end
	return p._athlete(args)
end

p.main = makeInvokeFunc('_main')
p.rt = makeInvokeFunc('_rt')
p.name = makeInvokeFunc('_name')
p.color = makeInvokeFunc('_color')
p.pba = makeInvokeFunc('_generic', 'PBA')
p.mpbl = makeInvokeFunc('_generic', 'MPBL')
p.athlete = makeInvokeFunc('_athlete_bc')

return p