Module:Video game reviews/sandbox: Difference between revisions

Content deleted Content added
Jackmcbarn (talk | contribs)
reduce variable scopes
No edit summary
 
(221 intermediate revisions by 14 users not shown)
Line 1:
require('strict')
--
-- Module layout for reviewer section in the work
--
-- 1 get args
-- 2 extract all reviewer args
-- 3 sort args for reviewer then system
-- 4 output args value where reviewer + system correlate
--
 
local p = {}
local data = require('Module:Video game reviews/data/sandbox')
local yesno = require('Module:Yesno')
local vgwd = require('Module:Video game wikidata')
local getArgs
 
local function getActiveSystems(args)
local reviewer = {{'[[1UP.com]]', '1UP'}, {'[[ActionTrip]]', 'Atrip'}, {'[[Adventure Gamers]]', 'AdvGamers'}, {'[[Allgame]]', 'Allgame'}, {'[[Amstrad Action]]', 'AAction'}, {'[[Amtix!]]', 'Amtix'}, {'[[Computer and Video Games]]', 'CVG'}, {'[[Crash (magazine)|Crash]]', 'CRASH'}, {'[[Destructoid]]', 'Destruct'}, {'[[Dragon (magazine)]]', 'Dragon'}, {'[[Edge (magazine)|Edge]]', 'Edge'}, {'[[Electronic Gaming Monthly]]', 'EGM'}, {'[[Eurogamer]]', 'EuroG'}, {'[[Famitsu]]', 'Fam'}, {'[[G4 (TV channel)|G4]]', 'G4'}, {'GameCritics', 'GCritics'}, {'[[GameFan]]', 'GameFan'}, {'[[Game Informer]]', 'GI'}, {'[[GamePro]]', 'GamePro'}, {'[[Game Revolution]]', 'GameRev'}, {'[[GamesMaster]]', 'GMaster'}, {'[[GamesRadar]]', 'GRadar'}, {'[[GameSpot]]', 'GSpot'}, {'[[GameSpy]]', 'GSpy'}, {'[[GamesTM]]', 'GTM'}, {'[[GameTrailers]]', 'GT'}, {'GameWire', 'GW'}, {'[[GameZone]]', 'GameZone'}, {'[[Giant Bomb]]', 'GB'}, {'[[Hyper (magazine)|Hyper Magazine]]', 'Hyper'}, {'[[IGN]]', 'IGN'}, {'[[Joystiq]]', 'Joystiq'}, {'[[Maximum PC]]', 'MaxPC'}, {'[[NGC Magazine]]', 'N64'}, {'[[NGC Magazine]]', 'NGC'}, {'[[NGamer]]', 'NG'}, {'NintendoLife', 'NLife'}, {'[[Nintendo Power]]', 'NP'}, {'Nintendo World Report', 'NWR'}, {'[[Official Nintendo Magazine]]', 'ONM'}, {'[[Official U.S. PlayStation Magazine|Official PlayStation Magazine (US)]]', 'OPM'}, {'[[PlayStation Official Magazine (UK)|Official PlayStation Magazine (UK)]]', 'OPMUK'}, {'[[Official PlayStation Magazine (Australia)]]', 'OPMAU'}, {'[[Official Xbox Magazine]]', 'OXM'}, {'[[Official Xbox Magazine|Official Xbox Magazine UK]]', 'OXMUK'}, {'[[PALGN]]', 'PALGN'}, {'[[PC Format]]', 'PCF'}, {'[[PC Gamer|PC Gamer UK]]', 'PCGUK'}, {'[[PC Gamer|PC Gamer US]]', 'PCGUS'}, {'[[PC PowerPlay]]', 'PCPP'}, {'[[PC Zone]]', 'PCZone'}, {'[[Play (UK magazine)|Play Magazine]]', 'Play'}, {'[[Polygon (website)|Polygon]]', 'Poly'}, {'[[PlayStation: The Official Magazine|PlayStation Magazine]]', 'PSM'}, {'[[PSM3|PlayStation 3 Magazine]]', 'PSM3'}, {'[[RPGamer]]', 'RPG'}, {'[[Sinclair User]]', 'SUser'}, {'[[TeamXbox]]', 'TX'}, {'[[VideoGamer.com]]', 'VG'}, {'[[X-Play]]', 'XPlay'}, {'[[Your Sinclair]]', 'YSinclair'}}
local activeSystems = {}
for k, v in pairs(args) do
if data.systems[k] and yesno(v) then
table.insert(activeSystems, k)
end
end
table.sort(activeSystems, function(a, b)
return data.systems[a].sortkey < data.systems[b].sortkey
end)
return activeSystems
end
 
local function getArgKeyTables(args)
local aggregator = {{'[[GameRankings]]','GR'}, {'[[Metacritic]]','MC'}}
local reviewers, aggregators, awards = {}, {}, {}
 
for k in pairs(args) do
local system = {{'[[Atari 2600]]','A2600'}, {'[[ColecoVision]]','CV'}, {'[[Nintendo DS|DS]]','DS'}, {'[[Game Boy]]','GB'}, {'[[Game Boy Advance|GBA]]','GBA'}, {'[[Game Boy Color|GBC]]','GBC'}, {'[[List of video game consoles|General]]', 'GEN'}, {'[[iOS]]','iOS'}, {'[[N-Gage (device)|N-Gage]]','N-G'}, {'[[Nintendo 64|N64]]','N64'}, {'[[Nintendo Entertainment System|NES]]','NES'}, {'[[GameCube|GC]]','NGC'}, {'[[Nvidia Shield|Shield]]','NSHI'}, {'[[Personal Computer|PC]]','PC'}, {'[[PlayStation|PS]]','PS'}, {'[[PlayStation 2|PS2]]','PS2'}, {'[[PlayStation 3|PS3]]','PS3'}, {'[[PlayStation 4|PS4]]','PS4'}, {'[[PlayStation Portable|PSP]]','PSP'}, {'[[Dreamcast]]','SDC'}, {'[[Sega Game Gear|SGG]]','SGG'}, {'[[Super Nintendo Entertainment System|SNES]]','SNES'}, {'[[Sega Genesis|Mega Drive]]','SMD'}, {'[[Master System]]','SMS'}, {'[[Sega Saturn|Saturn]]','SSAT'}, {'[[TurboGrafx-16]]','TG16'}, {'[[PlayStation Vita]]','VITA'}, {'[[Xbox]]','XBOX'}, {'[[Xbox 360]]','X360'}, {'[[Xbox One]]','XONE'}, {'[[Wii]]','WII'}}
if string.match(k, data.i18n.pattern.reviewer) then
 
table.insert(reviewers, k)
local data = mw.loadData('Module:Video game reviews/data')
elseif string.match(k, data.i18n.pattern.aggregator) then
 
table.insert(aggregators, k)
local HtmlBuilder = require('Module:HtmlBuilder')
elseif string.match(k, data.i18n.pattern.award) then
local categoryHandler = require('Module:Category handler').main
table.insert(awards, k)
 
end
local args
end
local halfkeysrev
local function comparator(a, b)
local halfkeysagg
return tonumber(a:match('%d+')) < tonumber(b:match('%d+'))
local platforms
end
local custome_agg
table.sort(reviewers, comparator)
local custome_rev
table.sort(aggregators, comparator)
local awardnums = {}
table.sort(awards, comparator)
 
return reviewers, aggregators, awards
function Split(str, delim)
if string.find(str, delim) == nil then
return { str }
end
local result = {}
local pat = "(.-)" .. delim .. "()"
local nb = 0
local lastPos
for part, pos in string.gfind(str, pat) do
nb = nb + 1
result[nb] = part
lastPos = pos
end
result[nb + 1] = string.sub(str, lastPos)
return result
end
 
local function getActiveSystemsgetProvidedReviewersAndAggregators(args, usePlatforms)
local providedReviewers, providedAggregators = {}, {}
local activeSystems = {}
if usePlatforms then
for _,v in ipairs(data.systems) do
local argValueseen = args[v[2]]{}
for k in pairs(args) do
if argValue and argValue:lower() == 'true' then
local splitPos = string.find(k, '_')
table.insert(activeSystems, v)
if splitPos then
end
local halfarg = string.sub(k, 1, splitPos - 1)
end
if not seen[halfarg] then
return activeSystems
seen[halfarg] = true
if data.reviewers[halfarg] then
table.insert(providedReviewers, halfarg)
elseif data.aggregators[halfarg] then
table.insert(providedAggregators, halfarg)
end
end
end
end
else
for k in pairs(args) do
if not string.find(k, '_') then
if data.reviewers[k] then
table.insert(providedReviewers, k)
elseif data.aggregators[k] then
table.insert(providedAggregators, k)
end
end
end
end
table.sort(providedReviewers, function(a, b)
return data.reviewers[a].sortkey < data.reviewers[b].sortkey
end)
table.sort(providedAggregators, function(a, b)
return data.aggregators[a].sortkey < data.aggregators[b].sortkey
end)
return providedReviewers, providedAggregators
end
 
local function renderHeadingRowWithSystems(builder, activeSystems, headingText)
function getActiveCustomAggregatorsAndReviewers(args)
builder:tag('tr')
local aggregators, reviewers = {}, {}
:addClass(data.i18n.class.headerrow)
for k,v in pairs(args) do
:tag('th')
if k:match('^agg(%d+)$') then
:attr('scope', 'col')
table.insert(aggregators, v)
:attr('rowspan', '2')
elseif k:match('^rev(%d+)$') then
:wikitext(headingText)
table.insert(reviewers, v)
:done()
end
:tag('th')
:attr('scope', 'colgroup')
:attr('colspan', #activeSystems)
:wikitext(data.i18n.display.score)
:done()
builder = builder:tag('tr')
for _, v in ipairs(activeSystems) do
builder:tag('th')
:wikitext(data.systems[v].name)
:attr('scope', 'col')
:done()
end
return aggregators, reviewers
end
 
local function renderTitleRowrenderHeadingRow(tblbuilder, nameHeading)
builder:tag('tr')
local titleCell = tbl.tag('tr').tag('th').css('font-size', '120%')
:addClass(data.i18n.class.headerrow)
:tag('th')
:attr('scope', 'col')
:wikitext(nameHeading)
:done()
:tag('th')
:attr('scope', 'col')
:wikitext(data.i18n.display.score)
:done()
end
 
local function renderRatingsBySystem(builder, code, name, activeSystems, args, na)
if args.state == 'plain' then
builder = builder:tag('tr')
titleCell
. builder:tag('spantd')
:wikitext(name)
.css('padding-left', '5.7em')
.wikitext('&nbsp;')
end
 
for _, v in ipairs(activeSystems) do
if args.title then
local combinedCode = code .. '_' .. v
titleCell
local cell = builder:tag('td')
.wikitext(args.title)
if args[combinedCode] then
.done()
cell
else
:wikitext(args[combinedCode])
titleCell
:done()
.addClass('Reception')
elseif na then
.wikitext('Reception')
cell
.done()
:addClass(data.i18n.class.na)
end
:wikitext(data.i18n.display.na)
:done()
end
end
end
 
local function renderRating(builder, name, rating)
if args.subtitle then
builder:tag('tr')
tbl
. :tag('trtd')
:addClass(data.i18n.class.centeredpub)
.tag('th')
:wikitext(name)
.css('font-size', '120%')
:done()
.wikitext(args.subtitle)
:tag('td')
.done()
:wikitext(rating)
end
:done()
end
 
local function renderAggregators(builder, providedAggregators, activeSystems, customAggregatorKeys, args)
function reviews()
local arg_system
local aggregatorCount = #providedAggregators + #customAggregatorKeys
local tbl2
if aggregatorCount == 0 then return end
if (#halfkeysrev > 0 or #halfkeysagg > 0) and platforms >= 1 then
tbl2 = HtmlBuilder.create('table')
builder = builder:tag('table')
.addClass('infobox wikitable')
:addClass(data.i18n.class.aggregators)
.attr('cellpadding', 0)
:addClass(data.i18n.class.wikitable)
.attr('cellspacing', 0)
:addClass(args.state and 'mw-collapsible-content' or nil)
.css('width', '100%')
:tag('caption')
.css('border-bottom', 'none')
:wikitext(data.i18n.display[aggregatorCount == 1 and 'aggregateScore' or 'aggregateScores'])
.css('margin', '0em')
. :done()
elseif (#halfkeysrev > 0 or #halfkeysagg > 0 or custome_agg > 0 or custome_rev > 0) and platforms == 0 then
tbl2 = HtmlBuilder.create('table')
.addClass('infobox wikitable')
.attr('cellpadding', 0)
.attr('cellspacing', 0)
.css('width', '100%')
.css('font-size', '100%')
.css('border-bottom', 'none')
.css('margin', '0em')
.done()
end
if #halfkeysrev > 0 and (platforms > 1 or string.lower(tostring(args['showplatforms'])) == 'true') then
tbl2.tag('tr').tag('th')
.attr('colspan', #system + 1)
.css('background', '#d1dbdf')
.css('font-size', '120%')
.wikitext('Review scores')
.done()
 
if #activeSystems ~= 0 then
tbl2
local na = yesno(args.na)
.tag('tr')
local showplatforms = #activeSystems ~= 1 or yesno(args.showplatforms)
.tag('th')
if showplatforms then
.attr('rowspan', '2')
renderHeadingRowWithSystems(builder, activeSystems, data.i18n.display.aggregator)
.css('background', '#e8f4f8')
else
.css('text-align', 'center')
renderHeadingRow(builder, data.i18n.display.aggregator)
.css('vertical-align', 'middle')
end
.wikitext('Publication')
.done()
.tag('th')
.attr('colspan', #system)
.css('background', '#e8f4f8')
.css('vertical-align', 'middle')
.wikitext('Score')
.done()
local forloop = tbl2.tag('tr')
for j = 1, #system do
if string.lower(tostring(args[tostring(system[j][2])])) == 'true' then
forloop.tag('th').wikitext(tostring(system[j][1]))
end
end
elseif #halfkeysrev > 0 and platforms == 1 and string.lower(tostring(args['showplatforms'])) ~= 'true' then
tbl2.tag('tr').tag('th')
.attr('colspan', '2')
.css('background', '#d1dbdf')
.css('font-size', '120%')
.wikitext('Review scores')
.done()
 
for _, v in ipairs(providedAggregators) do
tbl2
renderRatingsBySystem(builder, v, data.aggregators[v].name, activeSystems, args, na)
.tag('tr')
end
.tag('th')
for _, v in ipairs(customAggregatorKeys) do
.css('background', '#e8f4f8')
renderRatingsBySystem(builder, v, args[v], activeSystems, args, na)
.css('text-align', 'center')
end
.css('vertical-align', 'middle')
else
.wikitext('Publication')
renderHeadingRow(builder, data.i18n.display.aggregator)
.done()
for _, v in ipairs(providedAggregators) do
.tag('th')
renderRating(builder, data.aggregators[v].name, args[v])
.css('background', '#e8f4f8')
end
.css('vertical-align', 'middle')
for _, v in ipairs(customAggregatorKeys) do
.wikitext('Score')
renderRating(builder, args[v], args[v .. 'Score'])
.done()
end
end
if platforms >= 1 then
end
for i = 1, #reviewer do
for k = 1, #halfkeysrev do
if reviewer[i][2] == halfkeysrev[k] then
local forloop = tbl2.tag('tr')
forloop.tag('td')
.css('vertical-align','middle')
.wikitext(reviewer[i][1])
.done()
 
local function renderReviews(builder, providedReviewers, activeSystems,
for j = 1, #system do
customReviewerKeys, args, reviewerCount, priorReviewCount)
local temp = tostring(reviewer[i][2]) .. '_' .. tostring(system[j][2])
if string.lower(tostring(args[tostring(system[j][2])])) == 'true' and args[temp] ~= nil then
if reviewerCount == 0 then return end
forloop.tag('td')
.css('vertical-align', 'middle')
builder = builder:tag('table')
.wikitext(tostring(args[temp]))
:addClass(data.i18n.class.reviews)
elseif string.lower(tostring(args[tostring(system[j][2])])) == 'true' and string.lower(tostring(args['na'])) == 'true' then
:addClass(data.i18n.class.wikitable)
forloop.tag('td')
:addClass(args.state and 'mw-collapsible-content' or nil)
.css('color', 'lightgray')
:tag('caption')
.css('vertical-align','middle')
:wikitext(data.i18n.display[reviewerCount == 1 and 'reviewScore' or 'reviewScores'])
.css('text-align', 'center')
:addClass(priorReviewCount > 0 and data.i18n.class.stacked or nil)
.addClass('table-na')
:done()
.wikitext('N/A')
.done()
if #activeSystems ~= 0 then
elseif string.lower(tostring(args[tostring(system[j][2])])) == 'true' then
local na = yesno(args.na)
forloop.tag('td').done()
local showplatforms = #activeSystems ~= 1 or yesno(args.showplatforms)
end
if showplatforms then
end
renderHeadingRowWithSystems(builder, activeSystems, data.i18n.display.publication)
end
else
end
renderHeadingRow(builder, data.i18n.display.publication)
end
end
for i = 1, 10 do
 
if args['rev' .. tostring(i)] ~= nil then
for _, v in ipairs(providedReviewers) do
local forloop = tbl2.tag('tr')
renderRatingsBySystem(builder, v, data.reviewers[v].name, activeSystems, args, na)
forloop.tag('td').wikitext(tostring(args['rev' .. tostring(i)]))
end
for j = 1, #system do
for _, v in ipairs(customReviewerKeys) do
local temp = 'rev'.. tostring(i) .. '_' .. tostring(system[j][2])
renderRatingsBySystem(builder, v, args[v], activeSystems, args, na)
if string.lower(tostring(args[tostring(system[j][2])])) == 'true' and args[temp] ~= nil then
end
forloop.tag('td')
else
.css('vertical-align','middle')
renderHeadingRow(builder, data.i18n.display.publication)
.wikitext(tostring(args[temp]))
for _, v in ipairs(providedReviewers) do
.done()
renderRating(builder, data.reviewers[v].name, args[v])
elseif string.lower(tostring(args[tostring(system[j][2])])) == 'true' and string.lower(tostring(args['na'])) == 'true' then
end
forloop.tag('td')
for _, v in ipairs(customReviewerKeys) do
.css('color', 'lightgray')
renderRating(builder, args[v], args[v .. 'Score'])
.css('vertical-align','middle')
end
.css('text-align', 'center')
end
.addClass('table-na')
end
.wikitext('N/A')
.done()
elseif string.lower(tostring(args[tostring(system[j][2])])) == 'true' then
forloop.tag('td').done()
end
end
end
end
if (#halfkeysagg > 0 and platforms > 1) and #halfkeysrev == 0 then
tbl2
.tag('tr')
.tag('th')
.attr('colspan', #system+1)
.css('background', '#d1dbdf')
.css('font-size', '120%')
.wikitext('Aggregate scores')
.done()
tbl2
.tag('tr')
.tag('th')
.attr('rowspan', '2')
.css('background', '#e8f4f8')
.css('text-align', 'center')
.css('vertical-align', 'middle')
.wikitext('Publication')
.done()
.tag('th')
.attr('colspan', #system+1)
.css('background', '#e8f4f8')
.css('vertical-align', 'middle')
.wikitext('Score')
.done()
local forloop = tbl2.tag('tr')
for j = 1, #system do
if string.lower(tostring(args[tostring(system[j][2])])) == 'true' then
forloop.tag('th').wikitext(tostring(system[j][1]))
end
end
elseif (#halfkeysagg > 0 and #halfkeysrev > 0) or (#halfkeysagg > 0 and platforms == 1)then
tbl2
.tag('tr')
.tag('th')
.attr('colspan', #system+1)
.css('background', '#d1dbdf')
.css('font-size', '120%')
.wikitext('Aggregate scores')
.done()
end
for i = 1, #aggregator do
for k = 1, #halfkeysagg do
if aggregator[i][2] == halfkeysagg[k] then
local forloop = tbl2.tag('tr')
forloop.tag('td')
.css('vertical-align','middle')
.wikitext(aggregator[i][1])
.done()
 
local function renderAwards(builder, args, awardKeys, priorReviewCount)
for j = 1, #system do
if #awardKeys == 0 then return end
local temp = tostring(aggregator[i][2]) .. '_' .. tostring(system[j][2])
if string.lower(tostring(args[tostring(system[j][2])])) == 'true' and args[temp] ~= nil then
builder = builder:tag('table')
forloop.tag('td').wikitext(tostring(args[temp]))
:addClass(data.i18n.class.awards)
elseif string.lower(tostring(args[tostring(system[j][2])])) == 'true' and string.lower(tostring(args['na'])) == 'true' then
:addClass(data.i18n.class.wikitable)
forloop.tag('td')
:addClass(args.state and 'mw-collapsible-content' or nil)
.css('color', 'lightgray')
:tag('caption')
.css('vertical-align','middle')
:wikitext(data.i18n.display[#awardKeys == 1 and 'award' or 'awards'])
.css('text-align', 'center')
:addClass(priorReviewCount > 0 and data.i18n.class.stacked or nil)
.addClass('table-na')
:done()
.wikitext('N/A')
:tag('tr')
.done()
:tag('th')
elseif string.lower(tostring(args[tostring(system[j][2])])) == 'true' then
:attr('scope', 'col')
forloop.tag('td').done()
:wikitext(data.i18n.display.publication)
end
:done()
end
:tag('th')
end
:attr('scope', 'col')
end
:wikitext(data.i18n.display.award)
end
:done()
elseif platforms == 0 then
if #halfkeysagg > 0 or custome_agg > 0 then
tbl2
.tag('tr')
.tag('th')
.attr('colspan', 2)
.css('background', '#d1dbdf')
.css('font-size', '120%')
.wikitext('Aggregate scores')
.done()
.tag('tr')
.tag('th')
.css('background', '#e8f4f8')
.css('text-align', 'center')
.wikitext('Aggregator')
.done()
.tag('th')
.css('background', '#e8f4f8')
.wikitext('Score')
.done()
end
for i = 1, #aggregator do
for k = 1, #halfkeysagg do
if aggregator[i][2] == halfkeysagg[k] then
tbl2
.tag('tr')
.tag('td')
.css('text-align', 'center')
.css('vertical-align', 'middle')
.wikitext(aggregator[i][1])
.done()
.tag('td')
.css('text-align', 'center')
.css('font-size', '110%')
.wikitext(tostring(args[tostring(aggregator[i][2])]))
.done()
end
end
end
for i = 1, 10 do
if args['agg' .. tostring(i)] ~= nil then
tbl2
.tag('tr')
.tag('td')
.css('text-align', 'center')
.css('vertical-align', 'middle')
.wikitext(tostring(args['agg' .. tostring(i)]))
.done()
.tag('td')
.css('text-align', 'center')
.css('font-size', '110%')
.wikitext(tostring(args['agg'.. tostring(i) .. 'Score']))
.done()
end
end
if #halfkeysrev > 0 or custome_rev > 0 then
tbl2.tag('tr').tag('th')
.attr('colspan', #system + 1)
.css('background', '#d1dbdf')
.css('font-size', '120%')
.wikitext('Review scores')
.done()
tbl2
.tag('tr')
.tag('th')
.css('background', '#e8f4f8')
.css('text-align', 'center')
.wikitext('Publication')
.done()
.tag('th')
.attr('colspan', '25')
.css('background', '#e8f4f8')
.wikitext('Score')
.done()
 
for i_, =v 1,in #revieweripairs(awardKeys) do
builder:tag('tr')
for k = 1, #halfkeysrev do
:tag('td')
if reviewer[i][2] == halfkeysrev[k] then
:wikitext(args[v .. 'Pub'])
tbl2
:done()
.tag('tr')
. :tag('td')
:wikitext(args[v])
.css('text-align', 'center')
:done()
.css('vertical-align', 'middle')
.wikitext(reviewer[i][1])
.done()
.tag('td')
.css('text-align', 'center')
.css('font-size', '110%')
.wikitext(tostring(args[tostring(reviewer[i][2])]))
.done()
end
end
end
for i = 1, 10 do
if args['rev' .. tostring(i)] ~= nil then
tbl2
.tag('tr')
.tag('td')
.css('text-align', 'center')
.css('vertical-align', 'middle')
.wikitext(tostring(args['rev' .. tostring(i)]))
.done()
.tag('td')
.css('text-align', 'center')
.css('font-size', '110%')
.wikitext(tostring(args['rev'.. tostring(i) .. 'Score']))
.done()
end
end
end
end
builder:done()
return tbl2
builder:done()
end
 
local function awardrenderEditOnWikidata(tblbuilder, wikidata, awardnumstate)
if not wikidata then return end
local temp = tbl.tag('tr')
.tag('td')
builder:tag('div')
.css('font-weight','bold')
:addClass(data.i18n.class.wikidata)
.css('background-color','#f2f2f2')
:addClass(state and 'mw-collapsible-content' or nil)
.wikitext(args['award' .. awardnum .. 'Pub'])
:wikitext(vgwd.getUpdateLink())
.done()
:done()
.tag('td')
.css('background-color','#f2f2f2')
.wikitext(args['award' .. awardnum])
.done()
return temp
end
 
local function categorizePlatformCount(builder, platformCount)
function awards()
if platformCount ~= 0 then
if args['award1'] then
builder:wikitext(data.i18n.category.multiplatform)
local Cell = HtmlBuilder.create('table')
else
.addClass('infobox wikitable')
builder:wikitext(data.i18n.category.singleplatform)
.css('width', '100%')
end
.css('margin', '0em')
.css('border-top', 'none')
.attr('cellpadding', 3)
.attr('cellspacing', 0)
Cell
.tag('tr')
.tag('th')
.attr('colspan', 2)
.css('background', '#d1dbdf')
.css('font-size', '120%')
.css('border-top', 'none')
.wikitext('Awards')
.done()
Cell
.tag('tr')
.tag('th').wikitext('Publication')
.tag('th').wikitext('Award')
 
for i, awardnum in ipairs(awardnums) do
local awardRow = award(Cell, awardnum)
awardRow
.done()
end
return Cell
end
end
 
local function renderTitles(builder, title, subtitle)
function renderMainTable()
builder:tag('div')
local tbl
:addClass(data.i18n.class.title)
:wikitext(title or data.i18n.display.reception)
:done()
 
if subtitle then
if args['award1'] or ((#halfkeysagg > 0 or #halfkeysrev > 0 or custome_agg > 0 or custome_rev > 0) and platforms >= 0) then
builder:tag('div')
if platforms == 0 then
:addClass(data.i18n.class.subtitle)
-- Width: 20% Seems better since it scales with the article size.
-- The only reason to use the subtitle is collapsible content
tbl = HtmlBuilder.create('table')
-- So always add the related class.
.attr('cellpadding', 0)
:addClass('mw-collapsible-content')
.attr('cellspacing', 0)
:wikitext(subtitle)
.css('background', 'transparent')
:done()
.css('padding', '0em')
end
.css('margin', '0em 1em 1em 1em')
end
.css('text-align', 'center')
.css('font-size', '80%')
if args.width then
tbl
.css('width',args.width)
else
tbl
.css('width', '23em')
end
else
tbl = HtmlBuilder.create('table')
.attr('cellpadding', 0)
.attr('cellspacing', 0)
.css('background', 'transparent')
.css('padding', '0em')
.css('margin', '0em 1em 1em 1em')
.css('text-align', 'center')
.css('font-size', '80%')
end
if args.state then
tbl
.addClass(args.state)
else
tbl
.addClass('collapsible')
end
 
local function render(providedReviewers, providedAggregators, awardKeys,
if args.title and (args.state ~= 'plain' and args.state ~= 'off') then
activeSystems, customAggregatorKeys, customReviewerKeys, args, wikidata)
tbl
local is_collapsible = args.title and args.state and
.addClass('collapsible')
(args.state == data.i18n.state.autocollapse or
.addClass(args.state)
args.state == data.i18n.state.collapsed or
end
args.state == data.i18n.state.expanded
)
local div = mw.html.create('div')
:attr('role', 'complementary')
:addClass(data.i18n.class.container)
:addClass(#activeSystems == 0 and data.i18n.class.containersingle or nil)
:addClass(args.align == data.i18n.align.left and data.i18n.class.containerleft or nil)
:addClass(args.align == data.i18n.align.none and data.i18n.class.containernone or nil)
:addClass(is_collapsible and 'mw-collapsible' or nil)
:addClass(is_collapsible and args.state == data.i18n.state.collapsed and 'mw-collapsed' or nil)
:addClass(is_collapsible and args.state == data.i18n.state.autocollapse and args.state or nil)
 
renderTitles(div, args.title, args.subtitle)
tbl.css('float', args.align or 'right').css('clear', args.align or 'right')
 
local aggregatorCount = #providedAggregators + #customAggregatorKeys
renderTitleRow(tbl)
renderAggregators(
 
div,
tbl
providedAggregators,
.tag('tr')
activeSystems,
.tag('td')
customAggregatorKeys,
.node(reviews())
args,
.done()
aggregatorCount
 
)
tbl
local reviewerCount = #customReviewerKeys + #providedReviewers
.tag('tr')
renderReviews(
.tag('td')
div,
.node(awards())
providedReviewers,
.done()
activeSystems,
else
customReviewerKeys,
category = categoryHandler{
args,
main = '[[Category:Empty templates on articles]]'
reviewerCount,
}
aggregatorCount
category = category or ''
)
tbl = HtmlBuilder.create()
renderAwards(
tbl.wikitext(category)
div,
end
args,
return tbl
awardKeys,
reviewerCount + aggregatorCount
)
renderEditOnWikidata(div, wikidata, args.state)
categorizePlatformCount(div, #activeSystems)
return div
end
 
local function checkForWikidata(frame, args, activeSystems, providedAggregators)
function p._reviewbox(reviewBoxArgs)
local twikidata = {}false
local flags = {}
if args.qid == 'none' then
local nitem = {}
return wikidata
local halfargs = {}
end
local j = 1
args = reviewBoxArgs
local activeSystems = getActiveSystems(args)
platforms = #activeSystems
local activeAggregators, activeReviewers = getActiveCustomAggregatorsAndReviewers(args)
custome_agg, custome_rev = #activeAggregators, #activeReviewers
 
for k in pairsvgwd.setDateFormat(args.df) do
vgwd.setGame(args.qid)
if type(k) == 'string' then
vgwd.setSystem(nil)
table.insert(t, k)
vgwd.setGenerateReferences(true)
vgwd.setShowUpdateLink(false)
vgwd.setUpdateLinkStyle("text and pen")
vgwd.setSystemFormat(args.systemFormat)
 
-- Loop through aggregators if we have any.
if #providedAggregators ~= 0 then
for _, aggr in ipairs(providedAggregators) do
-- Check if vgwd knows this aggregator.
if vgwd.setReviewer(aggr) == nil then
-- Loop through active systems
if #activeSystems ~= 0 then
for _, sys in ipairs(activeSystems) do
local combinedCode = aggr .. '_' .. sys
if args[combinedCode] == 'wikidata' then
vgwd.setSystem(sys)
vgwd.setShowSystem(false)
local vgwdScore = vgwd.printReviewScores(frame)
if vgwdScore then
args[combinedCode] = vgwdScore
end
wikidata = true
end
end
else
vgwd.setShowSystem(true)
if args[aggr] == 'wikidata' then
local vgwdScore = vgwd.printReviewScores(frame)
if vgwdScore then
args[aggr] = vgwdScore
end
wikidata = true
end
end
end
end
end
table.sort(t)
local keys = t
 
return wikidata
-- creates a table of all unique reviewers.
end
for i=1,#keys do
if string.find(tostring(keys[i]), '_') ~= nil and platforms >= 1 then
halfargs = Split(tostring(keys[i]),'_')
for k=1, #reviewer do
if reviewer[k][2] == halfargs[1] then
if not flags[halfargs[1]] then
flags[halfargs[1]] = true
nitem[j] = halfargs[1]
j = j + 1
end
end
end
elseif string.find(tostring(keys[i]), '_') == nil and platforms == 0 then
for k=1, #reviewer do
if reviewer[k][2] == keys[i] then
nitem[j] = keys[i]
j = j + 1
end
end
end
end
halfkeysrev = nitem
 
local flags = {}
local nitem = {}
local halfargs = {}
local j = 1
-- creates a table of all unique aggregators.
for i=1,#keys do
if string.find(tostring(keys[i]), '_') ~= nil and platforms >= 1 then
halfargs = Split(tostring(keys[i]),'_')
for k=1, #aggregator do
if aggregator[k][2] == halfargs[1] then
if not flags[halfargs[1]] then
flags[halfargs[1]] = true
nitem[j] = halfargs[1]
j = j + 1
end
end
end
elseif string.find(tostring(keys[i]), '_') == nil and platforms == 0 then
for k=1, #aggregator do
if aggregator[k][2] == keys[i] then
nitem[j] = keys[i]
j = j + 1
end
end
end
end
halfkeysagg = nitem
 
-- sorts awards by number from args.
for k, v in pairs(args) do
local awardnum = ('' .. k):match('^award(%d+)$')
if awardnum then table.insert(awardnums, tonumber(awardnum)) end
end
if awardnums then table.sort(awardnums) end
 
local tbl = renderMainTable()
 
function p._reviewbox(frame, args)
-- render the appropriate wrapper around the Review Box, depending on the border param
local resactiveSystems = HtmlBuilder.creategetActiveSystems(args)
local customReviewerKeys, customAggregatorKeys, awardKeys = getArgKeyTables(args)
 
local providedReviewers, providedAggregators = getProvidedReviewersAndAggregators(args, #activeSystems ~= 0)
res.node(tbl)
local wikidata = checkForWikidata(frame, args, activeSystems, providedAggregators)
 
if #customAggregatorKeys ~= 0 or #customReviewerKeys ~= 0 or
return tostring(res)
#providedAggregators ~= 0 or #providedReviewers ~= 0 or #awardKeys ~= 0 then
return frame:extensionTag{
name='templatestyles', args = { src = data.i18n.templatestyles }
} .. tostring(render(
providedReviewers,
providedAggregators,
awardKeys,
activeSystems,
customAggregatorKeys,
customReviewerKeys,
args,
wikidata
))
elseif mw.title.getCurrentTitle().namespace == 0 then
return data.i18n.category.empty
end
end
 
function p.reviewbox(frame)
if not getArgs then
-- ParserFunctions considers the empty string to be false, so to preserve the previous
getArgs = require('Module:Arguments').getArgs
-- behavior of {{Video game multiple console reviews}}, change any empty arguments to nil, so Lua will consider
end
-- them false too.
return p._reviewbox(frame, getArgs(frame,
local args = {}
{ wrappers = data.i18n.wrapper, trim = false, translate = data.argi18n }
local parent_args = frame:getParent().args;
))
for k, v in pairs(parent_args) do
if v ~= '' then
args[k] = v
end
end
 
return p._reviewbox(args)
end