Module:TournamentStickerGallery

local util_args = require('Module:ArgsUtil') local util_cargo = require("Module:CargoUtil") 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_vars = require("Module:VarsUtil") local i18n = require("Module:I18nUtil") local lang = mw.getLanguage('en') local Gallery = require('Module:GalleryClass') local m_team = require('Module:Team') local h = {} local p = {} function p.main(frame) local args = util_args.merge local images = h.makeAndRunQuery(args) return Gallery(images):run end

function h.makeAndRunQuery(args) local query = h.getQuery(args) return util_cargo.queryAndCast(query) end

function h.getQuery(args) local query = { tables = { 'PlayerStickers=PS', },		where = h.getWhere(args), fields = { 'PS.FileName', 'PS.LinkPlayerCaption', 'PS.Link' }, orderBy = 'PS.Link', }	util_cargo.logQuery(query) return query end

function h.getWhere(args) local where = { ('PS.Team="%s"'):format(m_team.teamname(args.team)), ('PS.Tournament="%s"'):format(mw.title.getCurrentTitle.baseText), ('PS._pageName IS NOT NULL'), }	return where end

return p