Module:Participants list team: Difference between revisions
From TwogPedia
            No edit summary  | 
				No edit summary  | 
				||
| (44 intermediate revisions by 2 users not shown) | |||
| Line 2: | Line 2: | ||
local getArgs = require('Module:Arguments').getArgs  | local getArgs = require('Module:Arguments').getArgs  | ||
local makeFlag = require('Module:  | local makeFlag = require('Module:Person/Flag').makeFlag  | ||
local Links = require('Module:Links')  | local Links = require('Module:Links')  | ||
local funcs = require('Module:Functions')  | |||
local getTeamDisplaytitle = funcs.getTeamDisplaytitle  | |||
local VariablesLua = mw.ext.VariablesLua  | |||
local Participants = {}  | local Participants = {}  | ||
function Participants.main(frame)  | |||
	local args = getArgs(frame)  | |||
	local currentTitleSplit = mw.text.split(mw.title.getCurrentTitle().text, '/')      | |||
	local container = mw.html.create('div'):addClass('p-team-container')  | |||
    local wrapper = mw.html.create('div')  | |||
	local teamsize = args.teamsize  | 	local teamsize = args.teamsize  | ||
| Line 25: | Line 27: | ||
		local pValues = mw.text.jsonDecode(value)  | 		local pValues = mw.text.jsonDecode(value)  | ||
        -- If pValues is title, then create a header and new container  | |||
        if pValues.title then  | |||
            local title = mw.html.create('h3'):wikitext(pValues.title)  | |||
            local clone = mw.clone(container)  | |||
            if key == 1 then  | |||
                wrapper:node(title)  | |||
            else   | |||
                wrapper:node(clone):node(title)  | |||
                container = mw.html.create('div'):addClass('p-team-container')  | |||
            end  | |||
        else  | |||
		local participant = mw.html.create('div')  | 		local participant = mw.html.create('div')  | ||
		local team = nil  | |||
        local company = nil  | |||
        local region = nil  -- Store the region  | |||
        local countryFlag = nil  -- Store the flag image  | |||
		if pValues.team then  | 		if pValues.team then  | ||
			local teamName = mw.html.create('div')  | 			-- Check if shorthand of a team was used if team does not include game name  | ||
            if not string.find(pValues.team, currentTitleSplit[1] .. '/') then  | |||
                local tables = 'Teams'  | |||
			    local fields = '_pageName, shorthand, org, region'  -- Added 'region'  | |||
			    local cargoArgs = {  | |||
				    where = '_pageName LIKE "' .. gameCategory .. '/%" AND shorthand = "' .. pValues.team .. '"'  | |||
			    }  | |||
			    local results = cargo.query(tables, fields, cargoArgs)  | |||
			    if #results > 0 then   | |||
                    team = results[1]._pageName   | |||
                    company = results[1].org  | |||
                    region = results[1].region  -- Store region  | |||
                else   | |||
                    team = gameCategory .. '/' .. pValues.team   | |||
                end  | |||
            end  | |||
            -- Get country flag based on region  | |||
            if region then  | |||
                local countryCode = {  | |||
                    ["China"] = "Cn",  | |||
                    ["South America"] = "Br",  | |||
                    ["North America"] = "Us",  | |||
                    ["Europe"] = "Eu",  | |||
                    ["CIS"] = "Ru",  | |||
                    ["SEA"] = "My",  | |||
                    ["Peru"] = "Pe"  | |||
                }  | |||
                if countryCode[region] then  | |||
                    countryFlag = '[[File:' .. countryCode[region] .. '.png|20px]]'  | |||
                end  | |||
            end  | |||
            -- Create team name div  | |||
            local teamName = mw.html.create('div')  | |||
                :addClass('tc fw-600 team-name')  | |||
            -- Add team name first  | |||
            teamName:wikitext('[['.. team ..'|' .. string.gsub(getTeamDisplaytitle(team, VariablesLua.var('endDate')), gameCategory .. '/', '') .. ']]')  | |||
            -- Add flag after team name  | |||
            if countryFlag then  | |||
                teamName:wikitext(' ' .. countryFlag)  | |||
            end  | |||
            -- Add notes if any  | |||
            if pValues.notes then  | |||
                local notesList = mw.text.split(pValues.notes, ',')  | |||
                local notes = mw.html.create('div'):addClass('notes')  | |||
                for i, v in ipairs (notesList) do  | |||
                    v = mw.text.trim(v)  | |||
                    notes:node(mw.html.create('sup'):attr('title',  v):wikitext(i .. '.'))  | |||
                end  | |||
                teamName:node(notes)  | |||
            end  | |||
            -- Append team name to participant  | |||
            participant:node(teamName)  | |||
        end  | |||
		-- Create list of players  | 		-- Create list of players  | ||
| Line 46: | Line 111: | ||
		local players = {}  | 		local players = {}  | ||
		local playersDb = ''  | |||
		for i = 1, teamsize, 1 do  | 		for i = 1, teamsize, 1 do  | ||
			if pValues['p'.. i] then  | 			if pValues['p'.. i] then  | ||
				local playerId =   | 				local playerId = ''  | ||
				if pValues['p'.. i .. 'link'] then  | 				if pValues['p'.. i .. 'link'] then  | ||
					playerId = pValues['p'.. i .. 'link'] .. '|' .. pValues['p'.. i]  | 					playerId = pValues['p'.. i .. 'link'] .. '|' .. pValues['p'.. i]  | ||
                else   | |||
                    playerId = 'People/' .. pValues['p'.. i]  | |||
                    -- If page does not exist, then add the entered id as link name  | |||
                    if not mw.title.new('People/' .. pValues['p'.. i]) then playerId = playerId .. '|' .. pValues['p'.. i] end  | |||
				end  | 				end  | ||
				playersDb = playersDb .. (pValues['p'.. i .. 'link'] or 'People/' .. pValues['p'.. i]) .. ','  | |||
				local flag = makeFlag(pValues['p'.. i .. 'flag'], pValues['p'.. i .. 'link'] or pValues['p'.. i], gameCategory)  | 				local flag = makeFlag(pValues['p'.. i .. 'flag'], pValues['p'.. i .. 'link'] or 'People/' .. pValues['p'.. i], gameCategory)  | ||
				players['p'.. i] = mw.html.create('tr')  | 				players['p'.. i] = mw.html.create('tr')  | ||
| Line 70: | Line 141: | ||
		end  | 		end  | ||
		if pValues.s then  | 		if pValues.s then  | ||
			local playerId = pValues.s  | 			local playerId = 'People/' .. pValues.s .. '|' .. pValues.s  | ||
			if pValues['slink'] then  | 			if pValues['slink'] then  | ||
				playerId = pValues['slink'] .. '|' .. pValues.s  | 				playerId = pValues['slink'] .. '|' .. pValues.s  | ||
			end  | 			end  | ||
			local flag = makeFlag(pValues['sflag'], pValues['slink'] or pValues.s, gameCategory)  | 			local flag = makeFlag(pValues['sflag'], pValues['slink'] or 'People/' .. pValues.s, gameCategory)  | ||
			local sub = mw.html.create('tr')  | 			local sub = mw.html.create('tr')  | ||
| Line 83: | Line 156: | ||
		end  | 		end  | ||
		-- COACHES  | |||
			local playerId =   |         local coaches = 1  | ||
			if pValues['  |         local coachesDb = ''  | ||
				playerId = pValues['  |         while pValues['c' .. coaches] do  | ||
			local playerId = ''  | |||
			if pValues['c'.. coaches .. 'link'] then  | |||
				playerId = pValues['c'.. coaches .. 'link'] .. '|' .. pValues['c'.. coaches]  | |||
            else   | |||
                playerId = 'People/' .. pValues['c'.. coaches]  | |||
                -- If page does not exist, then add the entered id as link name  | |||
                if not mw.title.new('People/' .. pValues['c'.. coaches]) then playerId = playerId .. '|' .. pValues['c'.. coaches] end  | |||
			end  | 			end  | ||
			local flag = makeFlag(pValues['cflag'], pValues['  | 			coachesDb = coachesDb .. (pValues['c'.. coaches .. 'link'] or 'People/' .. pValues['c'.. coaches]) .. ','  | ||
			local flag = makeFlag(pValues['cflag'], pValues['c'.. coaches .. 'link'] or 'People/' .. pValues['c' .. coaches], gameCategory)  | |||
			local coach = mw.html.create('tr')  | 			local coach = mw.html.create('tr')  | ||
| Line 94: | Line 175: | ||
				:node(mw.html.create('td'):wikitext(flag):wikitext('[['.. playerId ..']]'))  | 				:node(mw.html.create('td'):wikitext(flag):wikitext('[['.. playerId ..']]'))  | ||
			playerList:node(coach)  | 			playerList:node(coach)  | ||
            coaches = coaches + 1  | |||
        end  | |||
        -- ANALYSTS  | |||
        local analysts = 1  | |||
        local analystsDb = ''  | |||
        while pValues['a' .. analysts] do  | |||
			local playerId = ''  | |||
			if pValues['a'.. analysts .. 'link'] then  | |||
				playerId = pValues['a'.. analysts .. 'link'] .. '|' .. pValues['a'.. analysts]  | |||
            else   | |||
                playerId = 'People/' .. pValues['a'.. analysts]  | |||
                -- If page does not exist, then add the entered id as link name  | |||
                if not mw.title.new('People/' .. pValues['a'.. analysts]) then playerId = playerId .. '|' .. pValues['a'.. analysts] end  | |||
			end  | |||
			analystsDb = analystsDb .. (pValues['a'.. analysts .. 'link'] or 'People/' .. pValues['a'.. analysts]) .. ','  | |||
			local flag = makeFlag(pValues['cflag'], pValues['a'.. analysts .. 'link'] or 'People/' .. pValues['a' .. analysts], gameCategory)  | |||
			local analyst = mw.html.create('tr')  | |||
				:node(mw.html.create('th'):node(mw.html.create('abbr'):attr('title', 'Analyst'):wikitext('A')))  | |||
				:node(mw.html.create('td'):wikitext(flag):wikitext('[['.. playerId ..']]'))  | |||
			playerList:node(analyst)  | |||
            analysts = analysts + 1  | |||
        end  | |||
        -- MANAGERS  | |||
        local managers = 1  | |||
        local managersDb = ''  | |||
        while pValues['m' .. managers] do  | |||
			local playerId = ''  | |||
			if pValues['m'.. managers .. 'link'] then  | |||
				playerId = pValues['m'.. managers .. 'link'] .. '|' .. pValues['m'.. managers]  | |||
            else   | |||
                playerId = 'People/' .. pValues['m'.. managers]  | |||
                -- If page does not exist, then add the entered id as link name  | |||
                if not mw.title.new('People/' .. pValues['m'.. managers]) then playerId = playerId .. '|' .. pValues['m'.. managers] end  | |||
			end  | |||
			managersDb = managersDb .. (pValues['m'.. managers .. 'link'] or 'People/' .. pValues['m'.. managers]) .. ','  | |||
			local flag = makeFlag(pValues['cflag'], pValues['m'.. managers .. 'link'] or 'People/' .. pValues['m' .. managers], gameCategory)  | |||
			local manager = mw.html.create('tr')  | |||
				:node(mw.html.create('th'):node(mw.html.create('abbr'):attr('title', 'Manager'):wikitext('M')))  | |||
				:node(mw.html.create('td'):wikitext(flag):wikitext('[['.. playerId ..']]'))  | |||
			playerList:node(manager)  | |||
            managers = managers + 1  | |||
        end  | |||
        if team ~= nil and string.len(playersDb) > 0 then  | |||
			frame:callParserFunction{name = '#cargo_store:', args = {_table = 'Participants', team = team, players = playersDb, coaches = coachesDb, analysts = analystsDb, managers = managersDb}}  | |||
		else  | |||
			frame:callParserFunction{name = '#cargo_store:', args = {_table = 'Participants', team = nil, players = 'People/Yatoro'}}  | |||
		end  | 		end  | ||
		local relativeParent = mw.html.create('div')  | 		local relativeParent = mw.html.create('div')  | ||
			:addClass('team-list')  | 			:addClass('team-list')  | ||
			:node(playerList)  | |||
		if #results > 0 then  | 		if pValues.logoAll then  | ||
			relativeParent:node(Participants.createLogo(pValues.logoAll, nil, team))  | |||
		elseif pValues.logoLight and pValues.logoDark then  | |||
			relativeParent:node(Participants.createLogo(pValues.logoLight, 'light', team)):node(Participants.createLogo(pValues.logoDark, 'dark', team))  | |||
		elseif pValues.logoLight or pValues.logoDark then  | |||
			local logo = pValues.logoLight or pValues.logoDark  | |||
			relativeParent:node(Participants.createLogo(logo, nil, team))  | |||
		elseif pValues.team then  | |||
            -- Check if team has org if company is not already set from checking shorthand  | |||
            if not company then  | |||
            local tables = 'Teams'  | |||
			local fields = 'org'  | |||
			local cargoArgs = {  | |||
				where = '_pageName="' .. team .. '"'  | |||
			}  | |||
            local results = cargo.query(tables, fields, cargoArgs)  | |||
            if #results > 0 then company = results[1].org end  | |||
            end  | |||
            if not company then company = '' end  | |||
			-- Look up Cargo table for team images  | |||
			local tables = 'Logos'  | |||
			local fields = '_pageName, logoLight, logoDark, logoAll, iconAll, iconLight, iconDark, start, end'  | |||
			currentDate = os.date('%Y-%m-%d')  | |||
			local cargoArgs = {  | |||
				where = '(_pageName = "' .. team .. '" OR _pageName="' .. company .. '") AND  (start is NULL OR start < "' .. currentDate .. '") AND (end is NULL OR end > "' .. currentDate .. '")'  | |||
			}  | |||
			local results = cargo.query(tables, fields, cargoArgs)  | |||
			if #results > 0 then  | |||
				if results[1].iconAll then  | |||
					relativeParent:node(Participants.createLogo(results[1].iconAll, nil, team))  | |||
				elseif results[1].iconLight and results[1].iconDark then  | |||
					relativeParent:node(Participants.createLogo(results[1].iconLight, 'light', team)):node(Participants.createLogo(results[1].iconDark, 'dark', team))  | |||
				elseif results[1].logoAll then  | |||
					relativeParent:node(Participants.createLogo(results[1].logoAll, nil, team))  | |||
				elseif results[1].logoLight and results[1].logoDark then  | |||
					relativeParent:node(Participants.createLogo(results[1].logoLight, 'light', team)):node(Participants.createLogo(results[1].logoDark, 'dark', team))  | |||
				else    | |||
					local logo = results[1].iconLight or results[1].iconDark or results[1].logoLight or results[1].logoDark  | |||
					relativeParent:node(Participants.createLogo(logo, nil, team))  | |||
				end  | |||
			else   | |||
				relativeParent:node(Participants.createLogo())  | |||
			end  | |||
		end  | 		end  | ||
		participant:node(relativeParent)  | 		participant:node(relativeParent)  | ||
| Line 144: | Line 289: | ||
		container:node(participant)  | 		container:node(participant)  | ||
        end  | |||
	end  | 	end  | ||
	return   |     wrapper:node(container)	  | ||
	return wrapper  | |||
end  | |||
-- function Participants.createLogo(url, class)  | |||
-- 	local className = class and class .. ' h-100' or 'h-100'  | |||
-- 	local logoURL = url and url or 'Team_placeholder_dark.png'  | |||
-- 	local logoContainer = mw.html.create('div')  | |||
-- 		:addClass(className)  | |||
-- 	local logo = mw.html.create('div')  | |||
-- 		:addClass('team-list-logo')  | |||
-- 		:node('[[File:' .. logoURL .. '|190px]]')  | |||
-- 	logoContainer:node(logo)  | |||
-- 	return logoContainer  | |||
-- end  | |||
function Participants.createLogo(url, class, linkPage)  | |||
    local className = class and class .. ' h-100' or 'h-100'  | |||
    local logoURL = url or 'Team_placeholder_dark.png'  | |||
    local logoContainer = mw.html.create('div'):addClass(className)  | |||
    local logo = mw.html.create('div'):addClass('team-list-logo')  | |||
    local fileLinkWikitext  | |||
    if linkPage then  | |||
        fileLinkWikitext = '[[' .. 'File:' .. logoURL .. '|link=' .. linkPage .. '|190px]]'  | |||
    else  | |||
        fileLinkWikitext = '[[' .. 'File:' .. logoURL .. '|190px]]'  | |||
    end  | |||
    logo:node(fileLinkWikitext)  | |||
    logoContainer:node(logo)  | |||
    return logoContainer  | |||
end  | end  | ||
return Participants  | return Participants  | ||
Latest revision as of 20:17, 18 July 2025
Documentation for this module may be created at Module:Participants list team/doc
local cargo = mw.ext.cargo
local getArgs = require('Module:Arguments').getArgs
local makeFlag = require('Module:Person/Flag').makeFlag
local Links = require('Module:Links')
local funcs = require('Module:Functions')
local getTeamDisplaytitle = funcs.getTeamDisplaytitle
local VariablesLua = mw.ext.VariablesLua
local Participants = {}
function Participants.main(frame)
	local args = getArgs(frame)
	local currentTitleSplit = mw.text.split(mw.title.getCurrentTitle().text, '/')    
	local container = mw.html.create('div'):addClass('p-team-container')
    local wrapper = mw.html.create('div')
	
	local teamsize = args.teamsize
	local currentTitle = mw.title.getCurrentTitle().text
	local gameCategory = mw.text.split(currentTitle, '/')[1]
	
	for key, value in ipairs (args) do
		local pValues = mw.text.jsonDecode(value)
        -- If pValues is title, then create a header and new container
        if pValues.title then
            local title = mw.html.create('h3'):wikitext(pValues.title)
            local clone = mw.clone(container)
            if key == 1 then
                wrapper:node(title)
            else 
                wrapper:node(clone):node(title)
                container = mw.html.create('div'):addClass('p-team-container')
            end
            
        else
		local participant = mw.html.create('div')
		local team = nil
        local company = nil
        local region = nil  -- Store the region
        local countryFlag = nil  -- Store the flag image
		if pValues.team then
			-- Check if shorthand of a team was used if team does not include game name
            if not string.find(pValues.team, currentTitleSplit[1] .. '/') then
                local tables = 'Teams'
			    local fields = '_pageName, shorthand, org, region'  -- Added 'region'
			    local cargoArgs = {
				    where = '_pageName LIKE "' .. gameCategory .. '/%" AND shorthand = "' .. pValues.team .. '"'
			    }
			    local results = cargo.query(tables, fields, cargoArgs)
			    if #results > 0 then 
                    team = results[1]._pageName 
                    company = results[1].org
                    region = results[1].region  -- Store region
                else 
                    team = gameCategory .. '/' .. pValues.team 
                end
            end
            
            -- Get country flag based on region
            if region then
                local countryCode = {
                    ["China"] = "Cn",
                    ["South America"] = "Br",
                    ["North America"] = "Us",
                    ["Europe"] = "Eu",
                    ["CIS"] = "Ru",
                    ["SEA"] = "My",
                    ["Peru"] = "Pe"
                }
                if countryCode[region] then
                    countryFlag = '[[File:' .. countryCode[region] .. '.png|20px]]'
                end
            end
            -- Create team name div
            local teamName = mw.html.create('div')
                :addClass('tc fw-600 team-name')
            -- Add team name first
            teamName:wikitext('[['.. team ..'|' .. string.gsub(getTeamDisplaytitle(team, VariablesLua.var('endDate')), gameCategory .. '/', '') .. ']]')
            -- Add flag after team name
            if countryFlag then
                teamName:wikitext(' ' .. countryFlag)
            end
            -- Add notes if any
            if pValues.notes then
                local notesList = mw.text.split(pValues.notes, ',')
                local notes = mw.html.create('div'):addClass('notes')
                for i, v in ipairs (notesList) do
                    v = mw.text.trim(v)
                    notes:node(mw.html.create('sup'):attr('title',  v):wikitext(i .. '.'))
                end
                teamName:node(notes)
            end
            -- Append team name to participant
            participant:node(teamName)
        end
		
		-- Create list of players
		local playerList = mw.html.create('table')
			:addClass('table-bordered players')
		
		local players = {}
		local playersDb = ''
		for i = 1, teamsize, 1 do
			if pValues['p'.. i] then
				local playerId = ''
                
				if pValues['p'.. i .. 'link'] then
					playerId = pValues['p'.. i .. 'link'] .. '|' .. pValues['p'.. i]
                else 
                    playerId = 'People/' .. pValues['p'.. i]
                    -- If page does not exist, then add the entered id as link name
                    if not mw.title.new('People/' .. pValues['p'.. i]) then playerId = playerId .. '|' .. pValues['p'.. i] end
				end
				playersDb = playersDb .. (pValues['p'.. i .. 'link'] or 'People/' .. pValues['p'.. i]) .. ','
				local flag = makeFlag(pValues['p'.. i .. 'flag'], pValues['p'.. i .. 'link'] or 'People/' .. pValues['p'.. i], gameCategory)
				players['p'.. i] = mw.html.create('tr')
					:node(mw.html.create('th'):wikitext(i))
				
				local td = mw.html.create('td')
				if flag then
					td:wikitext(flag)
				end
				
				td:wikitext('[['.. playerId ..']]')
				players['p'.. i]:node(td)
				playerList:node(players['p'.. i])
			end
		end
		
	
		if pValues.s then
			local playerId = 'People/' .. pValues.s .. '|' .. pValues.s
			if pValues['slink'] then
				playerId = pValues['slink'] .. '|' .. pValues.s
			end
			local flag = makeFlag(pValues['sflag'], pValues['slink'] or 'People/' .. pValues.s, gameCategory)
			
			local sub = mw.html.create('tr')
				:node(mw.html.create('th'):node(mw.html.create('abbr'):attr('title', 'Substitute'):wikitext('S')))
				:node(mw.html.create('td'):wikitext(flag):wikitext('[['.. playerId ..']]'))
			playerList:node(sub)
		end
		
		-- COACHES
        local coaches = 1
        local coachesDb = ''
        while pValues['c' .. coaches] do
			local playerId = ''
			if pValues['c'.. coaches .. 'link'] then
				playerId = pValues['c'.. coaches .. 'link'] .. '|' .. pValues['c'.. coaches]
            else 
                playerId = 'People/' .. pValues['c'.. coaches]
                -- If page does not exist, then add the entered id as link name
                if not mw.title.new('People/' .. pValues['c'.. coaches]) then playerId = playerId .. '|' .. pValues['c'.. coaches] end
			end
			coachesDb = coachesDb .. (pValues['c'.. coaches .. 'link'] or 'People/' .. pValues['c'.. coaches]) .. ','
			local flag = makeFlag(pValues['cflag'], pValues['c'.. coaches .. 'link'] or 'People/' .. pValues['c' .. coaches], gameCategory)
			local coach = mw.html.create('tr')
				:node(mw.html.create('th'):node(mw.html.create('abbr'):attr('title', 'Coach'):wikitext('C')))
				:node(mw.html.create('td'):wikitext(flag):wikitext('[['.. playerId ..']]'))
			playerList:node(coach)
            coaches = coaches + 1
        end
        
        -- ANALYSTS
        local analysts = 1
        local analystsDb = ''
        while pValues['a' .. analysts] do
			local playerId = ''
			if pValues['a'.. analysts .. 'link'] then
				playerId = pValues['a'.. analysts .. 'link'] .. '|' .. pValues['a'.. analysts]
            else 
                playerId = 'People/' .. pValues['a'.. analysts]
                -- If page does not exist, then add the entered id as link name
                if not mw.title.new('People/' .. pValues['a'.. analysts]) then playerId = playerId .. '|' .. pValues['a'.. analysts] end
			end
			analystsDb = analystsDb .. (pValues['a'.. analysts .. 'link'] or 'People/' .. pValues['a'.. analysts]) .. ','
			local flag = makeFlag(pValues['cflag'], pValues['a'.. analysts .. 'link'] or 'People/' .. pValues['a' .. analysts], gameCategory)
			local analyst = mw.html.create('tr')
				:node(mw.html.create('th'):node(mw.html.create('abbr'):attr('title', 'Analyst'):wikitext('A')))
				:node(mw.html.create('td'):wikitext(flag):wikitext('[['.. playerId ..']]'))
			playerList:node(analyst)
            analysts = analysts + 1
        end
        
        -- MANAGERS
        local managers = 1
        local managersDb = ''
        while pValues['m' .. managers] do
			local playerId = ''
			if pValues['m'.. managers .. 'link'] then
				playerId = pValues['m'.. managers .. 'link'] .. '|' .. pValues['m'.. managers]
            else 
                playerId = 'People/' .. pValues['m'.. managers]
                -- If page does not exist, then add the entered id as link name
                if not mw.title.new('People/' .. pValues['m'.. managers]) then playerId = playerId .. '|' .. pValues['m'.. managers] end
			end
			managersDb = managersDb .. (pValues['m'.. managers .. 'link'] or 'People/' .. pValues['m'.. managers]) .. ','
			local flag = makeFlag(pValues['cflag'], pValues['m'.. managers .. 'link'] or 'People/' .. pValues['m' .. managers], gameCategory)
			local manager = mw.html.create('tr')
				:node(mw.html.create('th'):node(mw.html.create('abbr'):attr('title', 'Manager'):wikitext('M')))
				:node(mw.html.create('td'):wikitext(flag):wikitext('[['.. playerId ..']]'))
			playerList:node(manager)
            managers = managers + 1
        end
        
        if team ~= nil and string.len(playersDb) > 0 then
			frame:callParserFunction{name = '#cargo_store:', args = {_table = 'Participants', team = team, players = playersDb, coaches = coachesDb, analysts = analystsDb, managers = managersDb}}
		else
			frame:callParserFunction{name = '#cargo_store:', args = {_table = 'Participants', team = nil, players = 'People/Yatoro'}}
		end
		
		
		local relativeParent = mw.html.create('div')
			:addClass('team-list')
			:node(playerList)
		if pValues.logoAll then
			relativeParent:node(Participants.createLogo(pValues.logoAll, nil, team))
		elseif pValues.logoLight and pValues.logoDark then
			relativeParent:node(Participants.createLogo(pValues.logoLight, 'light', team)):node(Participants.createLogo(pValues.logoDark, 'dark', team))
		elseif pValues.logoLight or pValues.logoDark then
			local logo = pValues.logoLight or pValues.logoDark
			relativeParent:node(Participants.createLogo(logo, nil, team))
		elseif pValues.team then
            -- Check if team has org if company is not already set from checking shorthand
            if not company then
            local tables = 'Teams'
			local fields = 'org'
			local cargoArgs = {
				where = '_pageName="' .. team .. '"'
			}
            local results = cargo.query(tables, fields, cargoArgs)
            
            if #results > 0 then company = results[1].org end
            end
            if not company then company = '' end
			-- Look up Cargo table for team images
			local tables = 'Logos'
			local fields = '_pageName, logoLight, logoDark, logoAll, iconAll, iconLight, iconDark, start, end'
			currentDate = os.date('%Y-%m-%d')
			local cargoArgs = {
				where = '(_pageName = "' .. team .. '" OR _pageName="' .. company .. '") AND  (start is NULL OR start < "' .. currentDate .. '") AND (end is NULL OR end > "' .. currentDate .. '")'
			}
			local results = cargo.query(tables, fields, cargoArgs)
			if #results > 0 then
				if results[1].iconAll then
					relativeParent:node(Participants.createLogo(results[1].iconAll, nil, team))
				elseif results[1].iconLight and results[1].iconDark then
					relativeParent:node(Participants.createLogo(results[1].iconLight, 'light', team)):node(Participants.createLogo(results[1].iconDark, 'dark', team))
				elseif results[1].logoAll then
					relativeParent:node(Participants.createLogo(results[1].logoAll, nil, team))
				elseif results[1].logoLight and results[1].logoDark then
					relativeParent:node(Participants.createLogo(results[1].logoLight, 'light', team)):node(Participants.createLogo(results[1].logoDark, 'dark', team))
				else  
					local logo = results[1].iconLight or results[1].iconDark or results[1].logoLight or results[1].logoDark
					relativeParent:node(Participants.createLogo(logo, nil, team))
				end
			else 
				relativeParent:node(Participants.createLogo())
			end
		end
		
		participant:node(relativeParent)
		
		if pValues.qualifier then
			local qualifier = mw.html.create('div')
				:addClass('team-list-qualifier')
				:wikitext(pValues.qualifier)
			participant:node(qualifier)
		end
		
		container:node(participant)
        end
	end
	
    wrapper:node(container)	
	
	return wrapper
end
-- function Participants.createLogo(url, class)
-- 	local className = class and class .. ' h-100' or 'h-100'
-- 	local logoURL = url and url or 'Team_placeholder_dark.png'
-- 	local logoContainer = mw.html.create('div')
-- 		:addClass(className)
-- 	local logo = mw.html.create('div')
-- 		:addClass('team-list-logo')
-- 		:node('[[File:' .. logoURL .. '|190px]]')
-- 	logoContainer:node(logo)
-- 	return logoContainer
-- end
function Participants.createLogo(url, class, linkPage)
    local className = class and class .. ' h-100' or 'h-100'
    local logoURL = url or 'Team_placeholder_dark.png'
    local logoContainer = mw.html.create('div'):addClass(className)
    local logo = mw.html.create('div'):addClass('team-list-logo')
    local fileLinkWikitext
    if linkPage then
        fileLinkWikitext = '[[' .. 'File:' .. logoURL .. '|link=' .. linkPage .. '|190px]]'
    else
        fileLinkWikitext = '[[' .. 'File:' .. logoURL .. '|190px]]'
    end
    logo:node(fileLinkWikitext)
    logoContainer:node(logo)
    return logoContainer
end
return Participants
No categories