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 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 vgwd = require('Module:Video game wikidata')
local getArgs
local aggregator = {{'[[GameRankings]]','GR'}, {'[[Metacritic]]','MC'}}
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'}}
local data = mw.loadData('Module:Video game reviews/data')
local HtmlBuilder = require('Module:HtmlBuilder')
local categoryHandler = require('Module:Category handler').main
local function getActiveSystems(args)
local activeSystems = {}
for k, v in pairs(data.systemsargs) do
if data.systems[k] and yesno(v) then
local argValue = args[k]
if argValue and argValue:lower() == 'true' 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(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 = {}
if plain then
for k in pairs(args) do
titleCell
local splitPos = string.find(k, '_')
.tag('span')
if splitPos then
.css('padding-left', '5.7em')
local halfarg = string.sub(k, 1, splitPos - 1)
.wikitext(' ')
if not seen[halfarg] then
end
seen[halfarg] = true
if titledata.reviewers[halfarg] then
table.insert(providedReviewers, halfarg)
titleCell
elseif data.aggregators[halfarg] then
.wikitext(title)
table.insert(providedAggregators, halfarg)
end
end
end
end
else
for k in pairs(args) do
titleCell
if not string.find(k, '_') then
.addClass('Reception')
if data.reviewers[k] then
.wikitext('Reception')
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)
local function reviews(halfkeysrev, halfkeysagg, platforms, custome_agg, custome_rev, args)
builder:tag('tr')
local arg_system
:addClass(data.i18n.class.headerrow)
local tbl2
:tag('th')
if (#halfkeysrev > 0 or #halfkeysagg > 0) and platforms >= 1 then
:attr('scope', 'col')
tbl2 = HtmlBuilder.create('table')
.addClass:attr('infoboxrowspan', wikitable'2')
:wikitext(headingText)
.attr('cellpadding', 0)
:done()
.attr('cellspacing', 0)
.css:tag('width', '100%th')
.css:attr('border-bottomscope', 'nonecolgroup')
.css:attr('margincolspan', '0em'#activeSystems)
:wikitext(data.i18n.display.score)
.done()
:done()
elseif (#halfkeysrev > 0 or #halfkeysagg > 0 or custome_agg > 0 or custome_rev > 0) and platforms == 0 then
builder = builder:tag('tr')
tbl2 = HtmlBuilder.create('table')
for _, v in ipairs(activeSystems) do
.addClass('infobox wikitable')
builder:tag('th')
.attr('cellpadding', 0)
:wikitext(data.systems[v].name)
.attr('cellspacing', 0)
.css:attr('widthscope', '100%col')
:done()
.css('font-size', '100%')
.css('border-bottom', 'none')
.css('margin', '0em')
.done()
end
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')
local function renderHeadingRow(builder, nameHeading)
tbl2
. builder:tag('tr')
:addClass(data.i18n.class.headerrow)
.tag('th')
.attr:tag('rowspan', '2th')
.css:attr('backgroundscope', '#e8f4f8col')
:wikitext(nameHeading)
.css('text-align', 'center')
:done()
.css('vertical-align', 'middle')
.wikitext:tag('Publicationth')
:attr('scope', 'col')
.done()
:wikitext(data.i18n.display.score)
.tag('th')
:done()
.attr('colspan', #system)
end
.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 #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 renderRatingsBySystem(builder, code, name, activeSystems, args, na)
tbl2
. builder = builder:tag('tr')
. builder:tag('thtd')
:wikitext(name)
.css('background', '#e8f4f8')
.css('text-align', 'center')
for _, v in ipairs(activeSystems) do
.css('vertical-align', 'middle')
local combinedCode = code .. '_' .. v
.wikitext('Publication')
local cell = builder:tag('td')
.done()
if args[combinedCode] then
.tag('th')
cell
.css('background', '#e8f4f8')
:wikitext(args[combinedCode])
.css('vertical-align', 'middle')
.wikitext:done('Score')
elseif na then
cell
:addClass(data.i18n.class.na)
:wikitext(data.i18n.display.na)
:done()
end
end
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 renderRating(builder, name, rating)
for j = 1, #system do
builder:tag('tr')
local temp = tostring(reviewer[i][2]) .. '_' .. tostring(system[j][2])
:tag('td')
if string.lower(tostring(args[tostring(system[j][2])])) == 'true' and args[temp] ~= nil then
:addClass(data.i18n.class.centeredpub)
forloop.tag('td')
:wikitext(name)
.css('vertical-align', 'middle')
:done()
.wikitext(tostring(args[temp]))
:tag('td')
elseif string.lower(tostring(args[tostring(system[j][2])])) == 'true' and string.lower(tostring(args['na'])) == 'true' then
:wikitext(rating)
forloop.tag('td')
:done()
.css('color', 'lightgray')
end
.css('vertical-align','middle')
.css('text-align', 'center')
local function renderAggregators(builder, providedAggregators, activeSystems, customAggregatorKeys, args)
.addClass('table-na')
.wikitext('N/A')
local aggregatorCount = #providedAggregators + #customAggregatorKeys
elseif string.lower(tostring(args[tostring(system[j][2])])) == 'true' then
if aggregatorCount == 0 then return end
forloop.tag('td')
end
builder = builder:tag('table')
end
:addClass(data.i18n.class.aggregators)
end
:addClass(data.i18n.class.wikitable)
end
:addClass(args.state and 'mw-collapsible-content' or nil)
:tag('caption')
:wikitext(data.i18n.display[aggregatorCount == 1 and 'aggregateScore' or 'aggregateScores'])
: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.aggregator)
else
renderHeadingRow(builder, data.i18n.display.aggregator)
end
for i = 1, 10 do
for _, v in ipairs(providedAggregators) do
if args['rev' .. tostring(i)] ~= nil then
renderRatingsBySystem(builder, v, data.aggregators[v].name, activeSystems, args, na)
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
for _, v in ipairs(customAggregatorKeys) do
if (#halfkeysagg > 0 and platforms > 1) and #halfkeysrev == 0 then
renderRatingsBySystem(builder, v, args[v], activeSystems, args, na)
tbl2
end
.tag('tr')
else
.tag('th')
renderHeadingRow(builder, data.i18n.display.aggregator)
.attr('colspan', #system+1)
for _, v in ipairs(providedAggregators) do
.css('background', '#d1dbdf')
renderRating(builder, data.aggregators[v].name, args[v])
.css('font-size', '120%')
end
.wikitext('Aggregate scores')
for _, v in ipairs(customAggregatorKeys) do
tbl2
renderRating(builder, args[v], args[v .. 'Score'])
.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
end
for i = 1, #aggregator do
end
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])
local function renderReviews(builder, providedReviewers, activeSystems,
for j = 1, #system do
customReviewerKeys, args, reviewerCount, priorReviewCount)
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
if reviewerCount == 0 then return end
forloop.tag('td').wikitext(tostring(args[temp]))
elseif string.lower(tostring(args[tostring(system[j][2])])) == 'true' and string.lower(tostring(args['na'])) == 'true' then
forloop. builder = builder:tag('tdtable')
:addClass(data.i18n.class.reviews)
.css('color', 'lightgray')
:addClass(data.i18n.class.wikitable)
.css('vertical-align','middle')
:addClass(args.state and 'mw-collapsible-content' or nil)
.css('text-align', 'center')
.addClass:tag('table-nacaption')
:wikitext(data.i18n.display[reviewerCount == 1 and 'reviewScore' or 'reviewScores'])
.wikitext('N/A')
:addClass(priorReviewCount > 0 and data.i18n.class.stacked or nil)
elseif string.lower(tostring(args[tostring(system[j][2])])) == 'true' then
forloop.tag:done('td')
end
if #activeSystems ~= 0 then
end
local na = yesno(args.na)
end
local showplatforms = #activeSystems ~= 1 or yesno(args.showplatforms)
end
if showplatforms then
renderHeadingRowWithSystems(builder, activeSystems, data.i18n.display.publication)
else
renderHeadingRow(builder, data.i18n.display.publication)
end
elseif platforms == 0 then
for _, v in ipairs(providedReviewers) do
if #halfkeysagg > 0 or custome_agg > 0 then
renderRatingsBySystem(builder, v, data.reviewers[v].name, activeSystems, args, na)
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_, =v 1,in #aggregatoripairs(customReviewerKeys) do
renderRatingsBySystem(builder, v, args[v], activeSystems, args, na)
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
else
for i = 1, 10 do
renderHeadingRow(builder, data.i18n.display.publication)
if args['agg' .. tostring(i)] ~= nil then
for _, v in ipairs(providedReviewers) do
tbl2
renderRating(builder, data.reviewers[v].name, args[v])
.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
for _, v in ipairs(customReviewerKeys) do
if #halfkeysrev > 0 or custome_rev > 0 then
renderRating(builder, args[v], args[v .. 'Score'])
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 i = 1, #reviewer do
for k = 1, #halfkeysrev do
if reviewer[i][2] == halfkeysrev[k] then
tbl2
.tag('tr')
.tag('td')
.css('text-align', 'center')
.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])]))
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 awardsrenderAwards(builder, args, awardKeys, priorReviewCount)
if #awardKeys ~== 0 then return end
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')
.attr:tag('cellpaddingcaption', 3)
:wikitext(data.i18n.display[#awardKeys == 1 and 'award' or 'awards'])
.attr('cellspacing', 0)
:addClass(priorReviewCount > 0 and data.i18n.class.stacked or nil)
.tag('tr')
.tag:done('th')
.attr:tag('colspantr', 2)
.css:tag('background', '#d1dbdfth')
.css:attr('font-sizescope', '120%col')
:wikitext(data.i18n.display.publication)
.css('border-top', 'none')
.wikitext:done('Awards')
.done:tag('th')
:attr('scope', 'col')
.done()
:wikitext(data.i18n.display.award)
.tag('tr')
.tag:done('th')
.wikitext('Publication')
.done()
.tag('th')
.wikitext('Award')
.done()
.done()
for _, v in ipairs(awardKeys) do
Cell.builder:tag('tr')
.:tag('td')
:wikitext(args[v .. 'Pub'])
.css('font-weight','bold')
:done()
.css('background-color','#f2f2f2')
.wikitext:tag(args[v .. 'Pubtd'])
.done:wikitext(args[v])
.tag:done('td')
.css('background-color','#f2f2f2')
.wikitext(args[v])
end
return Cell
end
builder:done()
builder:done()
end
local function renderEditOnWikidata(builder, wikidata, state)
local function renderMainTable(halfkeysrev, halfkeysagg, awardKeys, 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)
end:done()
if subtitle then
tbl.css('float', args.align or 'right').css('clear', args.align or 'right')
builder:tag('div')
:addClass(data.i18n.class.subtitle)
-- 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,
renderTitleRow(tbl, args.state == 'plain', args.title)
activeSystems, customAggregatorKeys, customReviewerKeys, args, wikidata)
local is_collapsible = args.title and args.state and
(args.state == data.i18n.state.autocollapse or
args.state == data.i18n.state.collapsed or
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)
if args.subtitle then
tbl
.tag('tr')
.tag('th')
.css('font-size', '120%')
.wikitext(args.subtitle)
end
local aggregatorCount = #providedAggregators + #customAggregatorKeys
tbl
renderAggregators(
.tag('tr')
div,
.tag('td')
providedAggregators,
.node(reviews(halfkeysrev, halfkeysagg, platforms, custome_agg, custome_rev, args))
activeSystems,
customAggregatorKeys,
tbl
args,
.tag('tr')
aggregatorCount
.tag('td')
)
.node(awards(args, awardKeys))
local reviewerCount = #customReviewerKeys + #providedReviewers
else
renderReviews(
local category = categoryHandler{
div,
main = '[[Category:Empty templates on articles]]'
providedReviewers,
}
activeSystems,
category = category or ''
customReviewerKeys,
tbl = HtmlBuilder.create()
args,
tbl.wikitext(category)
reviewerCount,
end
aggregatorCount
return tbl
)
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, halfkeysaggwikidata = {}, {}false
if args.qid == 'none' then
local sortedArgKeys = {}
return wikidata
for k in pairs(args) do
if type(k) == 'string' then
table.insert(sortedArgKeys, k)
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
vgwd.setDateFormat(args.df)
if platforms ~= 0 then
vgwd.setGame(args.qid)
local seen = {}
vgwd.setSystem(nil)
for _,argKey in ipairs(sortedArgKeys) do
vgwd.setGenerateReferences(true)
local splitPos = argKey:find('_')
vgwd.setShowUpdateLink(false)
if splitPos then
vgwd.setUpdateLinkStyle("text and pen")
local halfarg = argKey:sub(1, splitPos - 1)
vgwd.setSystemFormat(args.systemFormat)
if not seen[halfarg] then
seen[halfarg] = true
-- Loop through aggregators if we have any.
if data.reviewers[halfarg] then
if #providedAggregators ~= 0 then
table.insert(halfkeysrev, halfarg)
for _, aggr in ipairs(providedAggregators) do
elseif data.aggregators[halfarg] then
-- Check if vgwd knows this aggregator.
table.insert(halfkeysagg, halfarg)
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
else
for _,argKey in ipairs(sortedArgKeys) do
if not argKey:find('_') then
if data.reviewers[argKey] then
table.insert(halfkeysrev, argKey)
elseif data.aggregators[argKey] then
table.insert(halfkeysagg, argKey)
end
end
end
end
return renderMainTable(halfkeysrev, halfkeysagg, awardKeys, platforms, custome_agg, custome_rev, args)
return wikidata
end
function p.reviewbox_reviewbox(frame, args)
local activeSystems = getActiveSystems(args)
-- ParserFunctions considers the empty string to be false, so to preserve the previous
local customReviewerKeys, customAggregatorKeys, awardKeys = getArgKeyTables(args)
-- behavior of {{Video game multiple console reviews}}, change any empty arguments to nil, so Lua will consider
local providedReviewers, providedAggregators = getProvidedReviewersAndAggregators(args, #activeSystems ~= 0)
-- them false too.
local wikidata = checkForWikidata(frame, args, activeSystems, providedAggregators)
local args = {}
if #customAggregatorKeys ~= 0 or #customReviewerKeys ~= 0 or
local parent_args = frame:getParent().args;
#providedAggregators ~= 0 or #providedReviewers ~= 0 or #awardKeys ~= 0 then
for k, v in pairs(parent_args) do
return frame:extensionTag{
if v ~= '' then
name='templatestyles', args = { src = data.i18n.templatestyles }
args[k] = v
} .. tostring(render(
end
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)
return p._reviewbox(args)
if not getArgs then
getArgs = require('Module:Arguments').getArgs
end
return p._reviewbox(frame, getArgs(frame,
{ wrappers = data.i18n.wrapper, trim = false, translate = data.argi18n }
))
end
|