Halo Esports Wiki
[checked revision][checked revision]
Donut (talk | contribs)
No edit summary
m (Syncing content across wikis from Call of Duty Esports Wiki, if something seems broken as a result let me know)
 
(5 intermediate revisions by 2 users not shown)
Line 1: Line 1:
local util_form = require('Module:FormUtil')
 
 
local util_cargo = require('Module:CargoUtil')
 
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
 
-- this module is to be wiki-specific
   
 
local p = {}
 
local p = {}
function p.after(frame, fulltitle, tabstype)
+
function p.after(tabstype)
local titletbl = mw.text.split(fulltitle, '/')
+
local titletbl = util_title.titleTable()
 
local text = {}
 
local text = {}
 
if tabstype == 'Player' then
 
if tabstype == 'Player' then
p.after_player(text, frame, titletbl)
+
p.after_player(text, titletbl)
 
elseif tabstype == 'Team' then
 
elseif tabstype == 'Team' then
p.after_team(text, frame, titletbl)
+
p.after_team(text, titletbl)
 
end
 
end
 
if not mw.title.makeTitle('',titletbl[1]).exists then
 
if not mw.title.makeTitle('',titletbl[1]).exists then
Line 20: Line 25:
 
end
 
end
   
function p.after_player(text, frame, titletbl)
+
function p.after_player(text, titletbl)
 
if titletbl[2] == 'Statistics' and titletbl[3] then
 
if titletbl[2] == 'Statistics' and titletbl[3] then
 
text[#text+1] = p.playerConcept(titletbl) or ''
 
text[#text+1] = p.playerConcept(titletbl) or ''
 
end
 
end
 
if titletbl[2] then
 
if titletbl[2] then
if p.doWeLowercase('InfoboxPlayer', titletbl[1]) then
+
if p.doWeLowercase('Players', titletbl[1]) then
text[#text+1] = frame:expandTemplate({ title = 'lowercase' })
+
util_title.lowercase()
 
end
 
end
 
end
 
end
Line 35: Line 40:
 
local player = titletbl[1]
 
local player = titletbl[1]
 
local year = titletbl[3]
 
local year = titletbl[3]
local concept = mw.title.makeTitle('Concept', player .. '/Games')
+
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(
if not concept.exists then
 
  +
util_text.possessive(util_esports.playerLinked(player)),
return nil
 
end
 
local formlink = util_form.makeBaseQueryURL('CareerPlayerStats', 'CPS', { 'player', 'year'}, { player, year })
 
return string.format("\n:''To see all stats for %s not separated by tournament, <span class=\"plainlinks\">[%s Click Here]</span>.",
 
 
year,
 
year,
formlink.full
+
formlink
)
+
)
 
end
 
end
   
function p.after_team(text, frame, titletbl)
+
function p.after_team(text, titletbl)
 
if titletbl[2] then
 
if titletbl[2] then
if p.doWeLowercase('InfoboxTeam', titletbl[1]) then
+
if p.doWeLowercase('Teams', titletbl[1]) then
text[#text+1] = frame:expandTemplate({ title = 'lowercase' })
+
util_title.lowercase()
 
end
 
end
 
end
 
end
Line 56: Line 58:
   
 
function p.doWeLowercase(tbl, title)
 
function p.doWeLowercase(tbl, title)
  +
local query = {
local where = string.format('_pageName="%s"',title)
 
  +
tables = tbl,
return util_cargo.getOneResult(tbl,'IsLowercase', {where = where}) == 'Yes'
 
  +
fields = 'IsLowercase [boolean]',
 
where = string.format('OverviewPage="%s"',title),
  +
}
 
return util_cargo.getOneResult(query)
 
end
 
end
 
return p
 
return p

Latest revision as of 16:39, 31 August 2021

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