[checked revision] | [checked revision] |
No edit summary |
No edit summary |
||
Line 143: | Line 143: | ||
not processed.region and 'Tournaments Without Region', |
not processed.region and 'Tournaments Without Region', |
||
args.game and args.game .. ' Tournaments', |
args.game and args.game .. ' Tournaments', |
||
+ | args.tier and args.tier .. ' Tournaments', |
||
+ | args.type and args.type .. ' Tournaments', |
||
'Tournaments', |
'Tournaments', |
||
processed.name:find('<br>') and 'Tournaments with br In Stored Name', |
processed.name:find('<br>') and 'Tournaments with br In Stored Name', |
Revision as of 04:59, 21 November 2018
To edit the documentation or categories for this module, click here.
local lang = mw.getLanguage('en')
local Team = require('Module:Team').team
local m_region = require('Module:Region')
local m_country = require('Module:Country')
local social = require('Module:Infobox/Social')
local teamhist = require('Module:Infobox/TeamHist')
local util_infobox = require('Module:InfoboxUtil')
local util_html = require('Module:HTMLUtil')
local util_cargo = require('Module:CargoUtil')
local util_dpl = require('Module:DPLUtil')
local util_table = require('Module:TableUtil')
local util_form = require('Module:FormUtil')
local NOIMAGE = 'Unknown Infobox Image - Player.png'
LAYOUT = {
sections = { 'Tournament Information', 'Location & Dates', 'Broadcast', 'Results' },
contents = {
{ 'Organizer', 'Rulebook', 'Sponsor', 'Format', 'PrizePool','NumberofTeams', 'Links' },
{ 'Server', 'Type', 'Game', 'Tier', 'Mode', 'Platform', 'Country', 'Location', 'Venue', 'StartDate', 'EndDate', 'Date', },
{ 'Casters', 'Streams', 'Schedule' },
{ 'Winner', 'Second', 'Third', 'Fourth', 'Qualified', },
},
i18n = {
Type = 'Type',
Mode = 'Mode',
Casters = 'Caster(s)',
Streams = 'Stream(s)',
PrizePool = 'Prize Pool',
NumberofTeams = 'Number of Teams',
StartDate = 'Start Date',
EndDate = 'End Date',
}
}
local h = {}
function h.getProcessed(args)
local pagename = args.pagename or mw.title.getCurrentTitle().text
local result = util_cargo.getOneRow({
tables = 'CCMTournaments',
fields = { 'StandardName', 'Region', 'League' },
where = ('OverviewPage="%s"'):format(pagename)
})
local tbl = {
pagename = pagename,
name = result.StandardName or args.storedname or args.name,
region = result.Region or (args.region and m_region.medium(args.region)),
league = result.League or args.league
}
return tbl
end
function h.processDisplay(args, processed)
local frame = mw.getCurrentFrame()
local tbl = {
title = args.name,
image = util_infobox.getFile(args.image, NOIMAGE),
notice = args.rednotice,
Organizer = args.organizer and util_table.concatFromArgs(args, 'organizer', '<br>'),
Rulebook = args.rulebook and ('[%s Rulebook]'):format(args.rulebook),
Sponsor = args.sponsor,
Server = args.server,
Type = args.type,
Game = args.game,
Tier = args.tier,
Mode = args.mode,
Platform = args.platform,
Country = args.country and m_country.rightlong(args.country),
Location = args.location,
Venue = args.venue,
Format = args.format,
PrizePool = args.prizepool,
NumberofTeams = args.numberofteams,
Date = args.date,
StartDate = args.sdate,
EndDate = args.edate,
Links = args.web and ('[%s Website]'):format(args.web),
Casters = args.caster or args.casters,
Streams = args.streams and (args.streams .. (args.linkstreams and '<br>[[#Streams|Full List]]' or '')),
Schedule = h.makeSchedule(processed.pagename),
}
h.addResults(tbl, args)
return tbl
end
function h.makeSchedule(pagename)
if util_cargo.getOneResult('GameSchedule','Tournament',{ where = ('_pageName="%s"'):format(pagename) }) then
local url = util_form.makeBaseQueryURLFromArgs('SpoilerFreeSchedule','SFS', { pagename }, 'full')
return ('[%s Link (Spoiler-Free)]'):format(url)
end
return nil
end
function h.addResults(tbl, args)
local format = lang:lc(args.freeedit or '') ~= 'true'
local places = { first = 'Winner', second = 'Second', third = 'Third', fourth = 'Fourth' }
for k, v in pairs(places) do
if args[k] then
tbl[v] = format and Team{args[k], 'rightmediumlinked'} or args[k]
end
end
if args.third2 then
tbl.Third = util_table.concatSpecial({ args.third1 or args.third, args.third2 }, '<br>', format and Team, { [2] = 'rightmediumlinked' })
end
tbl.Qualified = args.qual1 and util_table.concatFromArgsSpecial(args, 'qual', '<br>', format and Team, { [2] = 'rightmediumlinked'})
return
end
function h.processCargo(args, processed)
local tbl = {
{
_table = 'InfoboxTournament',
Name = processed.name,
DateStart = args.sdate,
Date = args.edate or args.date or '',
League = processed.league,
Region = processed.region,
Prizepool = args.prizepool,
Country = args.country,
Location = args.location,
Rulebook = args.rulebook,
Platform = args.platform,
Type = args.type,
Game = args.game,
Tier = args.tier,
Mode = args.mode,
Links = args.web,
Sponsors = args.sponsors,
Organizer = args.organizer,
NumberofTeams = args.numberofteams,
First = args.first,
Second = args.second,
}
}
return tbl
end
function h.processCategories(args, processed)
local tbl = {
args.country and ('%s Tournaments'):format(m_country.localization(args.country) or ''),
not processed.region and 'Tournaments Without Region',
args.game and args.game .. ' Tournaments',
args.tier and args.tier .. ' Tournaments',
args.type and args.type .. ' Tournaments',
'Tournaments',
processed.name:find('<br>') and 'Tournaments with br In Stored Name',
}
return tbl
end
function h.processVariables(args, processed)
local tbl = {
['Event Date'] = args.edate or args.date,
['Event Prizepool'] = args.prizepool,
['Event Name'] = processed.name,
['Event League'] = processed.league,
['Event Region'] = processed.region,
}
return tbl
end
local p = {}
function p.main(args)
local processed = h.getProcessed(args)
local settings = {
lc = processed.lc,
nocargo = mw.title.getCurrentTitle().nsText ~= '' or args.nocargo,
nocat = mw.title.getCurrentTitle().nsText ~= '' or args['no-cat'],
}
return {
display = h.processDisplay(args, processed),
cargo = h.processCargo(args, processed),
settings = settings,
categories = h.processCategories(args, processed),
variables = h.processVariables(args, processed),
layout = LAYOUT
}
end
return p