Call of Duty Esports Wiki
Advertisement

Documentation for this module may be created at Module:GalleryClass/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_vars = require("Module:VarsUtil")
local i18n = require("Module:I18nUtil")
local lang = mw.getLanguage('en')
local LCS = require('Module:LuaClassSystem')

local h = {}
local p = LCS.class()

function p:init(images)
	self.images = images
end

function p:run()
	return mw.getCurrentFrame():extensionTag{
		name = 'gallery',
		content = self:makeGalleryRows()
	}
end

function p:makeGalleryRows()
	local galleryList = {}
	for _, row in ipairs(self.images) do
		galleryList[#galleryList+1] = self:makeOneGalleryRow(row)
	end
	return util_table.concat(galleryList, '\n')
end

function p:makeOneGalleryRow(row)
	return ('%s|<div style="text-align:center">%s</div>'):format(
		self:getFileName(row),
		self:getCaption(row)
	)
end

function p:getFileName(row)
	return row.FileName or ''
end

function p:getCaption(row)
	if not row.LinkPlayerCaption then
		return row.Caption or row.Name or ''
	else
		return util_esports.playerLinked(row.Link)
	end
end

return p
Advertisement