Module:Versions

local p = {} local cargo = mw.ext.cargo

function p.List( frame ) local args = frame.args local contentfieldstable = { "Version=CVersion", "ReleaseDate=CReleaseDate", "_pageName=CPageName", "Hotfix=CHotfix", "Name=CName", "Image=CImage", "NotesPost=CNotesPost", "AnnouncePost=CAnnouncePost", }   local contenttables = 'Versions' local contentfields = table.concat(contentfieldstable,",") -- optional parameters are grouped in one table -- you can omit any or all of them, except joinOn if you use more than one table local contentcargoquery = { where = args.where, groupBy='Version', orderBy='ReleaseDate DESC', limit=args.limit, offset=args.offset, }   local contentresult = mw.ext.cargo.query( contenttables, contentfields, contentcargoquery )

local hotfixfieldstable = { "Version=HVersion", "ReleaseDate=HReleaseDate", "_pageName=HPageName", "Hotfix=HHotfix", }   local hotfixtables = 'Versions' local hotfixfields = table.concat(hotfixfieldstable,",") -- optional parameters are grouped in one table -- you can omit any or all of them, except joinOn if you use more than one table local hotfixcargoquery = { where = 'Hotfix=1', groupBy='Version' }   local hotfixresult = mw.ext.cargo.query( hotfixtables, hotfixfields, hotfixcargoquery )

if contentresult[1] == nil then return args.default

elseif contentresult[1] ~= nil then --Start the table local tbl = mw.html.create('table') tbl:addClass('wikitable sortable mw-datatable') if args.Version ~= "hide" then tbl:tag("th"):wikitext("Patch"):done end if args.ReleaseDate ~= "hide" then tbl:tag("th"):wikitext("Release Date"):done end if args.PatchNotes ~= "hide" then tbl:tag("th"):wikitext("Patch Notes"):done end if args.Announcement == "show" then tbl:tag("th"):wikitext("Announcement"):done end if args.Hotfixes ~= "hide" then tbl:tag("th"):wikitext("Hotfix Patches"):done end if args.Name ~= "hide" then tbl:tag("th"):wikitext("Name"):done end if args.Image ~= "hide" then tbl:tag("th"):wikitext("Image"):done end tbl:done --Construct the rows in the table for i,row in ipairs(contentresult) do		tr = tbl:tag("tr") if args.Version ~= "hide" then tr:tag("td"):wikitext("" .. row.CVersion .. ""):done end if args.ReleaseDate ~= "hide" then tr:tag("td"):wikitext(row.CReleaseDate):done end if args.PatchNotes ~= "hide" then tr:tag("td"):wikitext(row.CNotesPost):done end if args.Announcement == "show" then tr:tag("td"):wikitext(row.CAnnouncePost):done end if args.Hotfixes ~= "hide" then local hotbox = tr:tag("td") for i2,row2 in ipairs(hotfixresult) do                           if row2.HPageName == row.CPageName then hotbox:wikitext( '' .. row2.HVersion .. ' (' .. row2.HReleaseDate .. ') ' ):done end end end if args.Name ~= "hide" then tr:tag("td"):wikitext(row.CName):done end if args.Image ~= "hide" then tr:tag("td"):wikitext( (row.CImage ~=  and  or '') ):done end end return tbl end -- . . . end return p