Halo Esports Wiki
Halo Esports Wiki
[checked revision][checked revision]
Donut (talk | contribs)
Donut (talk | contribs)
Line 21: Line 21:
   
 
function p.after_player(text, frame, titletbl)
 
function p.after_player(text, frame, titletbl)
  +
if titletbl[2] == 'Statistics' and titletbl[3] then
  +
text[#text+1] = p.playerConcept(titletbl) or ''
  +
end
 
if titletbl[2] then
 
if titletbl[2] then
 
if p.doWeLowercase('InfoboxPlayer', titletbl[1]) then
 
if p.doWeLowercase('InfoboxPlayer', titletbl[1]) then
Line 27: Line 30:
 
end
 
end
 
return
 
return
  +
end
  +
  +
function p.playerConcept(titletbl)
  +
local player = titletbl[1]
  +
local year = titletbl[3]
  +
local concept = mw.title.makeTitle('Concept', player .. '/Games')
  +
if not concept.exists then
  +
return nil
  +
end
  +
local formlink = util_form.fullURL('CareerPlayerStats', 'CPS', {player = player, year = year})
  +
return string.format("\n:''To see all stats for %s not separated by tournament, <span class=\"plainlinks\">[%s Click Here]</span>.",
  +
year,
  +
formlink
  +
)
 
end
 
end
   
Line 39: Line 56:
   
 
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',
 
where = string.format('_pageName="%s"',title),
  +
types = { IsLowercase = 'boolean' }
  +
}
 
return util_cargo.getOneResult(query)
 
end
 
end
 
return p
 
return p

Revision as of 04:43, 16 April 2019

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

local util_form = require('Module:FormUtil')
local util_cargo = require('Module:CargoUtil')

-- this module is to be wiki-specific

local p = {}
function p.after(frame, fulltitle, tabstype)
	local titletbl = mw.text.split(fulltitle, '/')
	local text = {}
	if tabstype == 'Player' then
		p.after_player(text, frame, titletbl)
	elseif tabstype == 'Team' then
		p.after_team(text, frame, 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, frame, titletbl)
	if titletbl[2] == 'Statistics' and titletbl[3] then
		text[#text+1] = p.playerConcept(titletbl) or ''
	end
	if titletbl[2] then
		if p.doWeLowercase('InfoboxPlayer', titletbl[1]) then
			text[#text+1] = frame:expandTemplate({ title = 'lowercase' })
		end
	end
	return
end

function p.playerConcept(titletbl)
	local player = titletbl[1]
	local year = titletbl[3]
	local concept = mw.title.makeTitle('Concept', player .. '/Games')
	if not concept.exists then
		return nil
	end
	local formlink = util_form.fullURL('CareerPlayerStats', 'CPS', {player = player, year = year})
	return string.format("\n:''To see all stats for %s not separated by tournament, <span class=\"plainlinks\">[%s Click Here]</span>.",
		year,
		formlink
		)
end

function p.after_team(text, frame, titletbl)
	if titletbl[2] then
		if p.doWeLowercase('InfoboxTeam', titletbl[1]) then
			text[#text+1] = frame:expandTemplate({ title = 'lowercase' })
		end
	end
	return
end

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