Module:Video game reviews/sandbox: Difference between revisions

Content deleted Content added
Jackmcbarn (talk | contribs)
use pre-existing sorted keys, and prepare to use awards
No edit summary
 
(205 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
--
 
require('Module:No globals')
 
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
local aggregator = {{'[[GameRankings]]','GR'}, {'[[Metacritic]]','MC'}}
if data.systems[k] and yesno(v) then
 
table.insert(activeSystems, k)
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'}}
end
 
local data = mw.loadData('Module:Video game reviews/data')
 
local HtmlBuilder = require('Module:HtmlBuilder')
local categoryHandler = require('Module:Category handler').main
 
local function Split(str, delim)
local retval, endpos = {}, 1
for elem, pos in str:gmatch('(.-)' .. delim .. '()') do
table.insert(retval, elem)
endpos = pos
end
table.insertsort(retvalactiveSystems, str:subfunction(endpos)a, b)
return data.systems[a].sortkey < data.systems[b].sortkey
return retval
end)
return activeSystems
 
local function getActiveSystems(args)
local activeSystems = {}
for _,v in ipairs(data.systems) do
local argValue = args[v[2]]
if argValue and argValue:lower() == 'true' then
table.insert(activeSystems, v)
end
end
return activeSystems
end
 
local function getArgKeyTables(orderedKeysargs)
local reviewers, aggregators, awards = {}, {}, {}
for _,vk in ipairspairs(orderedKeysargs) do
if v:string.match('^rev(%d+)$'k, data.i18n.pattern.reviewer) then
table.insert(reviewers, vk)
elseif v:string.match('^agg(%d+)$'k, data.i18n.pattern.aggregator) then
table.insert(aggregators, vk)
elseif v:string.match('^k, data.i18n.pattern.award(%d)$') then
table.insert(awards, vk)
end
end
local function comparator(a, b)
return tonumber(a:match('%d+')) < tonumber(b:match('%d+'))
end
table.sort(reviewers, comparator)
table.sort(aggregators, comparator)
table.sort(awards, comparator)
return reviewers, aggregators, awards
end
 
local function renderTitleRowgetProvidedReviewersAndAggregators(tblargs, plain, titleusePlatforms)
local providedReviewers, providedAggregators = {}, {}
local titleCell = tbl.tag('tr').tag('th').css('font-size', '120%')
if usePlatforms then
local seen = {}
for k in pairs(args) do
local splitPos = string.find(k, '_')
if splitPos then
local halfarg = string.sub(k, 1, splitPos - 1)
if not seen[halfarg] then
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)
if plain then
builder:tag('tr')
titleCell
:addClass(data.i18n.class.headerrow)
.tag('span')
:tag('th')
.css('padding-left', '5.7em')
:attr('scope', 'col')
.wikitext('&nbsp;')
:attr('rowspan', '2')
end
:wikitext(headingText)
:done()
: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
end
 
local function renderHeadingRow(builder, nameHeading)
if title then
builder:tag('tr')
titleCell
:addClass(data.i18n.class.headerrow)
.wikitext(title)
:tag('th')
else
:attr('scope', 'col')
titleCell
:wikitext(nameHeading)
.addClass('Reception')
:done()
.wikitext('Reception')
:tag('th')
end
:attr('scope', 'col')
:wikitext(data.i18n.display.score)
:done()
end
 
local function reviewsrenderRatingsBySystem(halfkeysrevbuilder, halfkeysaggcode, platformsname, custome_aggactiveSystems, custome_revargs, argsna)
builder = builder:tag('tr')
local arg_system
builder:tag('td')
local tbl2
:wikitext(name)
if (#halfkeysrev > 0 or #halfkeysagg > 0) and platforms >= 1 then
tbl2 = HtmlBuilder.create('table')
.addClass('infobox wikitable')
.attr('cellpadding', 0)
.attr('cellspacing', 0)
.css('width', '100%')
.css('border-bottom', 'none')
.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')
 
for _, v in ipairs(activeSystems) do
tbl2
local combinedCode = code .. '_' .. v
.tag('tr')
local cell = .builder:tag('thtd')
if args[combinedCode] then
.attr('rowspan', '2')
cell
.css('background', '#e8f4f8')
:wikitext(args[combinedCode])
.css('text-align', 'center')
:done()
.css('vertical-align', 'middle')
elseif na then
.wikitext('Publication')
cell
.done()
:addClass(data.i18n.class.na)
.tag('th')
:wikitext(data.i18n.display.na)
.attr('colspan', #system)
:done()
.css('background', '#e8f4f8')
end
.css('vertical-align', 'middle')
end
.wikitext('Score')
end
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')
 
local function renderRating(builder, name, rating)
tbl2
. builder:tag('tr')
. :tag('thtd')
:addClass(data.i18n.class.centeredpub)
.css('background', '#e8f4f8')
:wikitext(name)
.css('text-align', 'center')
:done()
.css('vertical-align', 'middle')
:tag('td')
.wikitext('Publication')
:wikitext(rating)
.done()
:done()
.tag('th')
end
.css('background', '#e8f4f8')
.css('vertical-align', 'middle')
.wikitext('Score')
end
if platforms >= 1 then
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])
 
local function renderAggregators(builder, providedAggregators, activeSystems, customAggregatorKeys, args)
for j = 1, #system do
local temp = tostring(reviewer[i][2]) .. '_' .. tostring(system[j][2])
local aggregatorCount = #providedAggregators + #customAggregatorKeys
if string.lower(tostring(args[tostring(system[j][2])])) == 'true' and args[temp] ~= nil then
if aggregatorCount == 0 then return end
forloop.tag('td')
.css('vertical-align', 'middle')
builder = builder:tag('table')
.wikitext(tostring(args[temp]))
:addClass(data.i18n.class.aggregators)
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[aggregatorCount == 1 and 'aggregateScore' or 'aggregateScores'])
.css('text-align', 'center')
:done()
.addClass('table-na')
.wikitext('N/A')
elseif string.lower(tostring(args[tostring(system[j][2])])) == 'true' then
forloop.tag('td')
end
end
end
end
end
for i = 1, 10 do
if args['rev' .. tostring(i)] ~= nil then
local forloop = tbl2.tag('tr')
forloop.tag('td').wikitext(tostring(args['rev' .. tostring(i)]))
for j = 1, #system do
local temp = 'rev'.. tostring(i) .. '_' .. tostring(system[j][2])
if string.lower(tostring(args[tostring(system[j][2])])) == 'true' and args[temp] ~= nil then
forloop.tag('td')
.css('vertical-align','middle')
.wikitext(tostring(args[temp]))
elseif string.lower(tostring(args[tostring(system[j][2])])) == 'true' and string.lower(tostring(args['na'])) == 'true' then
forloop.tag('td')
.css('color', 'lightgray')
.css('vertical-align','middle')
.css('text-align', 'center')
.addClass('table-na')
.wikitext('N/A')
elseif string.lower(tostring(args[tostring(system[j][2])])) == 'true' then
forloop.tag('td')
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')
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')
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')
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])
 
if #activeSystems ~= 0 then
for j = 1, #system do
local na = yesno(args.na)
local temp = tostring(aggregator[i][2]) .. '_' .. tostring(system[j][2])
local showplatforms = #activeSystems ~= 1 or yesno(args.showplatforms)
if string.lower(tostring(args[tostring(system[j][2])])) == 'true' and args[temp] ~= nil then
if showplatforms then
forloop.tag('td').wikitext(tostring(args[temp]))
renderHeadingRowWithSystems(builder, activeSystems, data.i18n.display.aggregator)
elseif string.lower(tostring(args[tostring(system[j][2])])) == 'true' and string.lower(tostring(args['na'])) == 'true' then
else
forloop.tag('td')
renderHeadingRow(builder, data.i18n.display.aggregator)
.css('color', 'lightgray')
end
.css('vertical-align','middle')
.css('text-align', 'center')
.addClass('table-na')
.wikitext('N/A')
elseif string.lower(tostring(args[tostring(system[j][2])])) == 'true' then
forloop.tag('td')
end
end
end
end
end
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')
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])]))
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']))
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')
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')
 
for _, v in ipairs(providedAggregators) do
for i = 1, #reviewer do
renderRatingsBySystem(builder, v, data.aggregators[v].name, activeSystems, args, na)
for k = 1, #halfkeysrev do
end
if reviewer[i][2] == halfkeysrev[k] then
for _, v in ipairs(customAggregatorKeys) do
tbl2
renderRatingsBySystem(builder, v, args[v], activeSystems, args, na)
.tag('tr')
end
.tag('td')
else
.css('text-align', 'center')
renderHeadingRow(builder, data.i18n.display.aggregator)
.css('vertical-align', 'middle')
for _, v in ipairs(providedAggregators) do
.wikitext(reviewer[i][1])
renderRating(builder, data.aggregators[v].name, args[v])
.done()
end
.tag('td')
for _, v in ipairs(customAggregatorKeys) do
.css('text-align', 'center')
renderRating(builder, args[v], args[v .. 'Score'])
.css('font-size', '110%')
end
.wikitext(tostring(args[tostring(reviewer[i][2])]))
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']))
end
end
end
end
return tbl2
end
 
local function appendAwardRowrenderReviews(tblbuilder, awardnumprovidedReviewers, args)activeSystems,
customReviewerKeys, args, reviewerCount, priorReviewCount)
tbl.tag('tr')
.tag('td')
if reviewerCount == 0 then return end
.css('font-weight','bold')
.css('background-color','#f2f2f2')
builder = builder:tag('table')
.wikitext(args['award' .. awardnum .. 'Pub'])
:addClass(data.i18n.class.reviews)
.done()
:addClass(data.i18n.class.wikitable)
.tag('td')
:addClass(args.state and 'mw-collapsible-content' or nil)
.css('background-color','#f2f2f2')
:tag('caption')
.wikitext(args['award' .. awardnum])
:wikitext(data.i18n.display[reviewerCount == 1 and 'reviewScore' or 'reviewScores'])
:addClass(priorReviewCount > 0 and data.i18n.class.stacked or nil)
:done()
if #activeSystems ~= 0 then
local na = yesno(args.na)
local showplatforms = #activeSystems ~= 1 or yesno(args.showplatforms)
if showplatforms then
renderHeadingRowWithSystems(builder, activeSystems, data.i18n.display.publication)
else
renderHeadingRow(builder, data.i18n.display.publication)
end
 
for _, v in ipairs(providedReviewers) do
renderRatingsBySystem(builder, v, data.reviewers[v].name, activeSystems, args, na)
end
for _, v in ipairs(customReviewerKeys) do
renderRatingsBySystem(builder, v, args[v], activeSystems, args, na)
end
else
renderHeadingRow(builder, data.i18n.display.publication)
for _, v in ipairs(providedReviewers) do
renderRating(builder, data.reviewers[v].name, args[v])
end
for _, v in ipairs(customReviewerKeys) do
renderRating(builder, args[v], args[v .. 'Score'])
end
end
end
 
local function awardsrenderAwards(builder, args, awardnumsawardKeys, argspriorReviewCount)
if #awardKeys == 0 then return end
if args['award1'] then
local Cell = HtmlBuilder.create('table')
builder = builder:tag('table')
.addClass('infobox wikitable')
:addClass(data.i18n.class.awards)
.css('width', '100%')
:addClass(data.i18n.class.wikitable)
.css('margin', '0em')
:addClass(args.state and 'mw-collapsible-content' or nil)
.css('border-top', 'none')
:tag('caption')
.attr('cellpadding', 3)
:wikitext(data.i18n.display[#awardKeys == 1 and 'award' or 'awards'])
.attr('cellspacing', 0)
:addClass(priorReviewCount > 0 and data.i18n.class.stacked or nil)
Cell
:done()
.tag('tr')
. :tag('thtr')
:tag('th')
.attr('colspan', 2)
:attr('scope', 'col')
.css('background', '#d1dbdf')
:wikitext(data.i18n.display.publication)
.css('font-size', '120%')
:done()
.css('border-top', 'none')
:tag('th')
.wikitext('Awards')
:attr('scope', 'col')
Cell
:wikitext(data.i18n.display.award)
.tag('tr')
:done()
.tag('th').wikitext('Publication')
.tag('th').wikitext('Award')
 
for _, v in ipairs(awardnumsawardKeys) do
builder:tag('tr')
appendAwardRow(Cell, v, args)
:tag('td')
end
:wikitext(args[v .. 'Pub'])
return Cell
:done()
end
:tag('td')
:wikitext(args[v])
:done()
end
builder:done()
builder:done()
end
 
local function renderEditOnWikidata(builder, wikidata, state)
local function renderMainTable(halfkeysrev, halfkeysagg, awardnums, platforms, custome_agg, custome_rev, args)
if not wikidata then return end
local tbl
builder:tag('div')
:addClass(data.i18n.class.wikidata)
:addClass(state and 'mw-collapsible-content' or nil)
:wikitext(vgwd.getUpdateLink())
:done()
end
 
local function categorizePlatformCount(builder, platformCount)
if args['award1'] or ((#halfkeysagg > 0 or #halfkeysrev > 0 or custome_agg > 0 or custome_rev > 0) and platforms >= 0) then
if platformsplatformCount =~= 0 then
builder:wikitext(data.i18n.category.multiplatform)
-- Width: 20% Seems better since it scales with the article size.
else
tbl = HtmlBuilder.create('table')
builder:wikitext(data.i18n.category.singleplatform)
.attr('cellpadding', 0)
end
.attr('cellspacing', 0)
end
.css('background', 'transparent')
.css('padding', '0em')
.css('margin', '0em 1em 1em 1em')
.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 renderTitles(builder, title, subtitle)
if args.title and (args.state ~= 'plain' and args.state ~= 'off') then
builder:tag('div')
tbl
. :addClass('collapsible'data.i18n.class.title)
:wikitext(title or data.i18n.display.reception)
.addClass(args.state)
:done()
end
 
if subtitle then
tbl.css('float', args.align or 'right').css('clear', args.align or 'right')
builder:tag('div')
 
:addClass(data.i18n.class.subtitle)
renderTitleRow(tbl, args.state == 'plain', args.title)
-- The only reason to use the subtitle is collapsible content
-- So always add the related class.
:addClass('mw-collapsible-content')
:wikitext(subtitle)
:done()
end
end
 
local function render(providedReviewers, providedAggregators, awardKeys,
if args.subtitle then
activeSystems, customAggregatorKeys, customReviewerKeys, args, wikidata)
tbl
local is_collapsible = args.title and args.state and
.tag('tr')
(args.state == data.i18n.state.autocollapse or
.tag('th')
args.state == data.i18n.state.collapsed or
.css('font-size', '120%')
args.state == data.i18n.state.expanded
.wikitext(args.subtitle)
)
end
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
.tag('tr')
.tag('td')
.node(reviews(halfkeysrev, halfkeysagg, platforms, custome_agg, custome_rev, args))
 
local aggregatorCount = #providedAggregators + #customAggregatorKeys
tbl
renderAggregators(
.tag('tr')
div,
.tag('td')
providedAggregators,
.node(awards(args, awardnums, args))
activeSystems,
else
customAggregatorKeys,
local category = categoryHandler{
args,
main = '[[Category:Empty templates on articles]]'
aggregatorCount
}
)
category = category or ''
local reviewerCount = #customReviewerKeys + #providedReviewers
tbl = HtmlBuilder.create()
renderReviews(
tbl.wikitext(category)
div,
end
providedReviewers,
return tbl
activeSystems,
customReviewerKeys,
args,
reviewerCount,
aggregatorCount
)
renderAwards(
div,
args,
awardKeys,
reviewerCount + aggregatorCount
)
renderEditOnWikidata(div, wikidata, args.state)
categorizePlatformCount(div, #activeSystems)
return div
end
 
local function checkForWikidata(frame, args, activeSystems, providedAggregators)
function p._reviewbox(args)
local halfkeysrev,wikidata halfkeysagg= false
local flags = {}
if args.qid == 'none' then
local nitem = {}
return wikidata
local halfargs = {}
end
local awardnums = {}
local j = 1
 
vgwd.setDateFormat(args.df)
local sortedArgKeys = {}
for k in pairsvgwd.setGame(args.qid) do
vgwd.setSystem(nil)
if type(k) == 'string' then
vgwd.setGenerateReferences(true)
table.insert(sortedArgKeys, k)
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(sortedArgKeys)
local activeSystems = getActiveSystems(args)
local platforms = #activeSystems
local reviewerKeys, aggregatorKeys, awardKeys = getArgKeyTables(sortedArgKeys)
local custome_rev, custome_agg = #reviewerKeys, #aggregatorKeys
 
return wikidata
-- creates a table of all unique reviewers.
end
for i=1,#sortedArgKeys do
if string.find(tostring(sortedArgKeys[i]), '_') ~= nil and platforms >= 1 then
halfargs = Split(tostring(sortedArgKeys[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(sortedArgKeys[i]), '_') == nil and platforms == 0 then
for k=1, #reviewer do
if reviewer[k][2] == sortedArgKeys[i] then
nitem[j] = sortedArgKeys[i]
j = j + 1
end
end
end
end
halfkeysrev = nitem
 
function p._reviewbox(frame, args)
local flags = {}
local activeSystems = getActiveSystems(args)
local nitem = {}
local customReviewerKeys, customAggregatorKeys, awardKeys = getArgKeyTables(args)
local halfargs = {}
local providedReviewers, providedAggregators = getProvidedReviewersAndAggregators(args, #activeSystems ~= 0)
local j = 1
local wikidata = checkForWikidata(frame, args, activeSystems, providedAggregators)
-- creates a table of all unique aggregators.
if #customAggregatorKeys ~= 0 or #customReviewerKeys ~= 0 or
for i=1,#sortedArgKeys do
#providedAggregators ~= 0 or #providedReviewers ~= 0 or #awardKeys ~= 0 then
if string.find(tostring(sortedArgKeys[i]), '_') ~= nil and platforms >= 1 then
return frame:extensionTag{
halfargs = Split(tostring(sortedArgKeys[i]),'_')
name='templatestyles', args = { src = data.i18n.templatestyles }
for k=1, #aggregator do
} .. tostring(render(
if aggregator[k][2] == halfargs[1] then
providedReviewers,
if not flags[halfargs[1]] then
providedAggregators,
flags[halfargs[1]] = true
awardKeys,
nitem[j] = halfargs[1]
activeSystems,
j = j + 1
customAggregatorKeys,
end
customReviewerKeys,
end
args,
end
wikidata
elseif string.find(tostring(sortedArgKeys[i]), '_') == nil and platforms == 0 then
))
for k=1, #aggregator do
elseif mw.title.getCurrentTitle().namespace == 0 then
if aggregator[k][2] == sortedArgKeys[i] then
return data.i18n.category.empty
nitem[j] = sortedArgKeys[i]
end
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
 
return renderMainTable(halfkeysrev, halfkeysagg, awardnums, platforms, custome_agg, custome_rev, args)
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