Module:ExternalContent

local util_args = require('Module:ArgsUtil') local util_cargo = require('Module:CargoUtil') local util_esports = require('Module:EsportsUtil') local util_html = require('Module:HtmlUtil') local util_map = require('Module:MapUtil') local util_math = require('Module:MathUtil') local util_text = require('Module:TextUtil') local util_title = require('Module:TitleUtil') local util_vars = require('Module:VarsUtil') local Publication = require('Module:Publication') local i18n = require('Module:I18nUtil') local WeeklyDataPages = require('Module:WeeklyDataPages')

local m_team = require('Module:Team')

local COLUMNS = { 'Link', 'Publication', 'Authors', 'Series', 'SeriesSeason', 'ContentType', 'PlayersDisplay', 'TeamsDisplay', 'TournamentsDisplay' }

local h = {}

local p = {}

function p.start(frame) return WeeklyDataPages.start('External Content') end

function p.date(frame) i18n.init('ExternalContent') local args = util_args.merge return WeeklyDataPages.date(args, COLUMNS) end

function p.line(frame) local args = util_args.merge i18n.init('ExternalContent') local data = h.processArgsToData(args) util_cargo.store(data) return h.makeRowOutput(data) end

function p.endTable(frame) return ' ' end

function h.processArgsToData(args) local ret = { _table = 'ExternalContent', ContentType = util_text.ucFirstOnly(args.type or 'Article'), Title = args.title, URL = args.url, Series = args.series, SeriesSeason = args.season, SeriesSeasonNumber = args.seasonnumber, MediaType = util_args.castAsBool(args.isvideo) and 'Video' or 'Article', Language = args.language or 'English', Players = args.players, Teams = args.teams, Date = util_vars.getVar('Date'), Year = util_vars.getVar('Year'), Publication = Publication(args.publication):name, N_ItemInDate = util_vars.setGlobalIndex('N_ItemInDate'), Authors = args.author, Teams = util_map.splitAndConcat(args.teams, nil, m_team.teamlinkname,','), Tournaments = util_map.splitAndConcat(args.tournament, nil, util_esports.getOverviewPage,','), }	return ret end

function h.makeRowOutput(data) h.processDataForPrinting(data) local tr = mw.html.create util_html.printRowByList(tr, data, COLUMNS) return tr end

function h.processDataForPrinting(data) if data.URL then if not data.Title then error(i18n.print('error_noTitle', data.URL)) end data.Link = util_text.link(data.URL, mw.text.nowiki(data.Title)) end data.TeamsDisplay = util_map.splitAndConcat(data.Teams, nil, m_team.rightshortlinked) data.PlayersDisplay = util_esports.playersLinked(data.Players) data.TournamentsDisplay = util_map.splitAndConcat(data.Tournaments, nil, util_text.intLinkOrText,',') end

return p