Advertisement

Module:SubpageAfter

Documentation for this module may be created at Module:SubpageAfter/doc

local util_cargo = require('Module:CargoUtil')
local util_esports = require("Module:EsportsUtil")
local util_form = require('Module:FormUtil')
local util_text = require("Module:TextUtil")
local util_title = require("Module:TitleUtil")

local FORM_INFO = { form = 'TournamentStatistics', template = 'TS' }

-- this module is to be wiki-specific

local p = {}
function p.after(tabstype)
	local titletbl = util_title.titleTable()
	local text = {}
	if tabstype == 'Player' then
		p.after_player(text, titletbl)
	elseif tabstype == 'Team' then
		p.after_team(text, titletbl)
	end
	if not mw.title.makeTitle('',titletbl[1]).exists then
		text[#text+1] = '[[Category:Player Secondary Pages Without Primary Pages]]'
	end
	local output = table.concat(text)
	return output
end

function p.after_player(text, titletbl)
	if titletbl[2] == 'Statistics' and titletbl[3] then
		text[#text+1] = p.playerConcept(titletbl) or ''
	end
	if titletbl[2] then
		if p.doWeLowercase('Players', titletbl[1]) then
			util_title.lowercase()
		end
	end
	return
end

function p.playerConcept(titletbl)
	local player = titletbl[1]
	local year = titletbl[3]
	local formlink = util_form.fullURL(FORM_INFO, {preload = 'PlayerByChampion', link = player, year = year})
	return ("\n:''This page shows all of %s statistics from %s separated by tournament. To see combined stats, <span class=\"plainlinks\">[%s Click Here]</span>."):format(
		util_text.possessive(util_esports.playerLinked(player)),
		year,
		formlink
	)
end

function p.after_team(text, titletbl)
	if titletbl[2] then
		if p.doWeLowercase('Teams', titletbl[1]) then
			util_title.lowercase()
		end
	end
	return
end

function p.doWeLowercase(tbl, title)
	local query = {
		tables = tbl,
		fields = 'IsLowercase [boolean]',
		where = string.format('OverviewPage="%s"',title),
	}
	return util_cargo.getOneResult(query)
end
return p

In some regions the distribution of power ranking points is slower, we ask for your patience in this regard. All players will receive their points before the start of the C2S8 competitive season.

READ MORE