Documentation for this module may be created at Module:PageTabs person/doc
local cargo = mw.ext.cargo
local p = {}
function p.main(frame)
local currentTitle = mw.title.getCurrentTitle().text
local split = mw.text.split(currentTitle, '/')
local parent = split[1] .. '/' .. split[2]
local subPage = split[3]
local str = '{{Tabs|name1=Overview|link1=' .. parent
local order = 1
if subPage == 'Results' then
order = order + 1
str = str .. '|name' .. order .. '=Results' .. '|link' .. order .. '=' .. currentTitle
else
-- Check if results in soloMatches
local tables = "AllMatches"
local fields = '_pageName'
local cargoArgs = {
where = '(p1 = "' .. parent .. '" OR p2="' .. parent .. '") AND winner IS NOT NULL AND winner != "0"',
limit = 1,
}
local soloMatches = cargo.query(tables, fields, cargoArgs)
local hadResults = false
if #soloMatches > 0 then
hadResults = true
else
-- Check if part of tournament prizes
tables = 'Participants, Prizes'
fields = 'Participants._pageName=_pageName'
cargoArgs = {
join = 'Participants._pageName=Prizes._pageName',
where = '(Participants.players HOLDS "' .. parent .. '" AND Prizes.teams HOLDS Participants.team ) OR Prizes.players HOLDS "' .. parent .. '"',
limit = 1
}
local placementResults = cargo.query(tables, fields, cargoArgs)
if #placementResults > 0 then
hadResults = true
end
end
if hadResults then
order = order + 1
str = str .. '|name' .. order .. '=Results' .. '|link' .. order .. '=' .. parent .. '/Results'
end
-- Check for broadcasts
if subPage == 'Broadcasts' then
order = order + 1
str = str .. '|name' .. order .. '=Broadcasts' .. '|link' .. order .. '=' .. currentTitle
else
-- Check if observer or caster in matches
tables = 'AllMatches'
fields = '_pageName'
cargoArgs = {
where = '(casters HOLDS "' .. parent .. '" OR observers HOLDS "' .. parent .. '") AND winner IS NOT NULL AND winner != "0"',
limit = 1,
}
local matchBroadcasts = cargo.query(tables, fields, cargoArgs)
local hadBroadcasts = false
if #matchBroadcasts > 0 then
hadBroadcasts = true
else
-- Check if is in list of tournament talent
tables = 'Talent, Tournaments'
fields = 'Tournaments._pageName=_pageName'
cargoArgs = {
join = 'Talent._pageName=Tournaments._pageName',
where = 'Talent.people HOLDS "' .. parent .. '"',
limit = 1
}
local talentTournaments = cargo.query(tables, fields, cargoArgs)
if #talentTournaments > 0 then hadBroadcasts = true end
end
if hadBroadcasts then
order = order + 1
str = str .. '|name' .. order .. '=Broadcasts' .. '|link' .. order .. '=' .. parent .. '/Broadcasts'
end
end
end
str = str .. '}}'
if order > 1 then return frame:preprocess(str) end
end
return p