Leaguepedia | League of Legends Esports Wiki
Advertisement
Leaguepedia | League of Legends Esports Wiki

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

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_table = require("Module:TableUtil")
local util_text = require("Module:TextUtil")
local util_title = require("Module:TitleUtil")
local util_vars = require("Module:VarsUtil")
local i18n = require("Module:I18nUtil")
local lang = mw.getLanguage('en')
local m_team = require('Module:Team')
util_cargo.setStoreNamespace('File')

local ROWS = { 'TeamDisplay', 'TournamentDisplay', 'Caption', 'SortDateDisplay', 'IsHiddenDisplay' }

local h = {}
local p = {}

function p.main(frame)
	local args = util_args.merge()
	i18n.init('TeamRosterPhotoMetadata')
	local data = h.formatDataFromArgs(args)
	util_cargo.store(data)
	return h.makeOutput(data)
end

function h.formatDataFromArgs(args)
	local data = {
		_table = 'TeamRosterPhotos',
		Team = args.team and m_team.teamlinkname(args.team),
		Tournament = util_title.target(args.tournament),
		Caption = args.caption or h.makeCaption(args),
		SortDate = args.date,
		FileName = mw.title.getCurrentTitle().text,
		Hide = util_args.castAsBool(args.hide)
	}
	data.TeamDisplay = util_text.intLinkOrText(data.Team)
	data.TournamentDisplay = util_text.intLinkOrText(data.Tournament)
	data.SortDateDisplay = args.date or i18n.print('noSortDate')
	data.IsHiddenDisplay = (args.hide or 'No ') .. i18n.print('isHidden')
	return data
end

function h.makeCaption(args)
	if args.playerorder and args.tournament then
		return ('%s, %s, Left to Right: %s'):format(
			m_team.teamname(args.team),
			args.tournament,
			util_map.splitAndConcat(args.playerorder, nil, nil, ', ')
		)
	end
	if args.tournament then
		return ('%s, %s'):format(
			m_team.teamname(args.team),
			args.tournament
		)
	end
	if args.playerorder then
		return ('%s, Left to Right: %s'):format(
			m_team.teamname(args.team),
			util_map.splitAndConcat(args.playerorder, nil, nil, ', ')
		)
	end
	if args.team then
		return m_team.teamname(args.team)
	end
	return mw.title.getCurrentTitle().text:find('(.+?)%.')
end


function h.makeOutput(data)
	local output = mw.html.create('table')
		:addClass('wikitable')
	util_html.printVerticalData(output, data, ROWS)
	return output
end

return p
Advertisement