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
--
--
-- This module will implement {{Video game multiple console reviews}}
--
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)
-- Require necessary modules.
local activeSystems = {}
local HtmlBuilder = require('Module:HtmlBuilder')
for k, v in pairs(args) do
local categoryHandler = require('Module:Category handler').main
if data.systems[k] and yesno(v) then
table.insert(activeSystems, k)
-- Load our data.
end
local reviewer, aggregator, system
end
do
table.sort(activeSystems, function(a, b)
local data = mw.loadData('Module:Video game reviews/data')
reviewer, aggregator, system = return data.reviewers, datasystems[a].aggregators,sortkey < data.systems[b].sortkey
end)
return activeSystems
end
local function getArgKeyTables(args)
-- Set aliases for often-used functions to reduce table lookups.
local reviewers, aggregators, awards = {}, {}, {}
local args
for k in pairs(args) do
local frame
if string.match(k, data.i18n.pattern.reviewer) then
local keys
table.insert(reviewers, k)
local halfkeysrev
elseif string.match(k, data.i18n.pattern.aggregator) then
local halfkeysagg
table.insert(aggregators, k)
local platforms
elseif string.match(k, data.i18n.pattern.award) then
local custome_agg
table.insert(awards, k)
local custome_rev
end
local awardnums = {}
end
local function comparator(a, b)
--
return tonumber(a:match('%d+')) < tonumber(b:match('%d+'))
-- Splits a string on a delimiter n number of times.
end
--
table.sort(reviewers, comparator)
function Split(str, delim)
table.sort(aggregators, comparator)
if string.find(str, delim) == nil then
table.sort(awards, comparator)
return { str }
return reviewers, aggregators, awards
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 getProvidedReviewersAndAggregators(args, usePlatforms)
--
local providedReviewers, providedAggregators = {}, {}
-- Returns the count of how many platforms are active.
if usePlatforms then
--
local seen = {}
function platforms()
for k in pairs(args) do
local count = 0
local splitPos = string.find(k, '_')
for i = 1, #system do
if splitPos then
if args[tostring(system[i][2])] ~= nil then
local halfarg = string.sub(k, 1, splitPos - 1)
if string.lower(tostring(args[tostring(system[i][2])])) == 'true' then
if not seen[halfarg] then
count=count+1
seen[halfarg] = true
end
if data.reviewers[halfarg] then
end
table.insert(providedReviewers, halfarg)
end
elseif data.aggregators[halfarg] then
return count
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)
--
builder:tag('tr')
-- Returns the count of how many custom aggregators are active.
:addClass(data.i18n.class.headerrow)
--
:tag('th')
function custome_agg()
:attr('scope', 'col')
local cagg = 0
:attr('rowspan', '2')
for i = 1, 10 do
:wikitext(headingText)
if args['agg' .. tostring(i)] ~= nil then
:done()
cagg = cagg + 1
:tag('th')
end
:attr('scope', 'colgroup')
end
:attr('colspan', #activeSystems)
return cagg
: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)
--
builder:tag('tr')
-- Returns the count of how many custom reviewers are active.
:addClass(data.i18n.class.headerrow)
--
:tag('th')
function custome_rev()
:attr('scope', 'col')
local crev = 0
:wikitext(nameHeading)
for i = 1, 10 do
:done()
if args['rev' .. tostring(i)] ~= nil then
:tag('th')
crev = crev + 1
:attr('scope', 'col')
end
:wikitext(data.i18n.display.score)
end
:done()
return crev
end
--
-- Title row
--
function renderTitleRow(tbl)
local titleCell = tbl.tag('tr').tag('th').css('font-size', '120%')
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(' ')
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)
--
-- Insert reviews
local aggregatorCount = #providedAggregators + #customAggregatorKeys
--
if aggregatorCount == 0 then return end
function reviews()
local arg_system
builder = builder:tag('table')
local tbl2
:addClass(data.i18n.class.aggregators)
if (#halfkeysrev > 0 or #halfkeysagg > 0) and platforms >= 1 then
:addClass(data.i18n.class.wikitable)
tbl2 = HtmlBuilder.create('table')
:addClass(args.state and 'mw-collapsible-content' or nil)
.addClass('infobox wikitable')
:tag('caption')
.attr('cellpadding', 0)
:wikitext(data.i18n.display[aggregatorCount == 1 and 'aggregateScore' or 'aggregateScores'])
.attr('cellspacing', 0)
:done()
.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')
.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
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]))
.done()
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')
.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()
for _, v in ipairs(providedReviewers) do
for j = 1, #system do
renderRatingsBySystem(builder, v, data.reviewers[v].name, activeSystems, args, na)
local temp = tostring(aggregator[i][2]) .. '_' .. tostring(system[j][2])
end
if string.lower(tostring(args[tostring(system[j][2])])) == 'true' and args[temp] ~= nil then
for _, v in ipairs(customReviewerKeys) do
forloop.tag('td').wikitext(tostring(args[temp]))
renderRatingsBySystem(builder, v, args[v], activeSystems, args, na)
elseif string.lower(tostring(args[tostring(system[j][2])])) == 'true' and string.lower(tostring(args['na'])) == 'true' then
end
forloop.tag('td')
else
.css('color', 'lightgray')
renderHeadingRow(builder, data.i18n.display.publication)
.css('vertical-align','middle')
for _, v in ipairs(providedReviewers) do
.css('text-align', 'center')
renderRating(builder, data.reviewers[v].name, args[v])
.addClass('table-na')
end
.wikitext('N/A')
for _, v in ipairs(customReviewerKeys) do
.done()
renderRating(builder, args[v], args[v .. 'Score'])
elseif string.lower(tostring(args[tostring(system[j][2])])) == 'true' then
end
forloop.tag('td').done()
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')
.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 = 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])]))
.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
return tbl2
end
local function renderAwards(builder, args, awardKeys, priorReviewCount)
--
if #awardKeys == 0 then return end
-- Inserts a award into the table output.
--
builder = builder:tag('table')
function award(tbl, awardnum)
:addClass(data.i18n.class.awards)
local temp = tbl.tag('tr')
:addClass(data.i18n.class.wikitable)
.tag('td')
:addClass(args.state and 'mw-collapsible-content' or nil)
.css('font-weight','bold')
:tag('caption')
.css('background-color','#f2f2f2')
:wikitext(data.i18n.display[#awardKeys == 1 and 'award' or 'awards'])
.wikitext(args['award' .. awardnum .. 'Pub'])
:addClass(priorReviewCount > 0 and data.i18n.class.stacked or nil)
.done()
:done()
.tag('td')
:tag('tr')
.css('background-color','#f2f2f2')
:tag('th')
.wikitext(args['award' .. awardnum])
:attr('scope', 'col')
.done()
:wikitext(data.i18n.display.publication)
return temp
:done()
:tag('th')
:attr('scope', 'col')
:wikitext(data.i18n.display.award)
:done()
for _, v in ipairs(awardKeys) do
builder:tag('tr')
:tag('td')
:wikitext(args[v .. 'Pub'])
:done()
:tag('td')
:wikitext(args[v])
:done()
end
builder:done()
builder:done()
end
local function renderEditOnWikidata(builder, wikidata, state)
--
if not wikidata then return end
-- Insert awards header and calls award row creation.
--
builder:tag('div')
function awards()
:addClass(data.i18n.class.wikidata)
if args['award1'] then
:addClass(state and 'mw-collapsible-content' or nil)
local Cell = HtmlBuilder.create('table')
:wikitext(vgwd.getUpdateLink())
.addClass('infobox wikitable')
:done()
.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')
local function categorizePlatformCount(builder, platformCount)
for i, awardnum in ipairs(awardnums) do
if platformCount ~= 0 then
local awardRow = award(Cell, awardnum)
builder:wikitext(data.i18n.category.multiplatform)
awardRow
else
.done()
builder:wikitext(data.i18n.category.singleplatform)
end
end
return Cell
end
end
local function renderTitles(builder, title, subtitle)
--
builder:tag('div')
-- Main tables
:addClass(data.i18n.class.title)
--
:wikitext(title or data.i18n.display.reception)
:done()
if subtitle then
function renderMainTable()
builder:tag('div')
local tbl
:addClass(data.i18n.class.subtitle)
-- The only reason to use the subtitle is collapsible content
if args['award1'] or ((#halfkeysagg > 0 or #halfkeysrev > 0 or custome_agg > 0 or custome_rev > 0) and platforms >= 0) then
-- So always add the related class.
if platforms == 0 then
:addClass('mw-collapsible-content')
-- Width: 20% Seems better since it scales with the article size.
:wikitext(subtitle)
tbl = HtmlBuilder.create('table')
:done()
.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 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 '' -- Check that we don't have a nil value for the category variable.
)
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)
--
local wikidata = false
-- Creates the table and calls functions that create the reviews and awards tables/columns/rows.
--
if args.qid == 'none' then
function p._reviewbox(reviewBoxArgs)
return wikidata
local t = {}
end
local flags = {}
local nitem = {}
local halfargs = {}
local j = 1
-- calls for the args.
args = reviewBoxArgs
platforms = platforms()
custome_rev = custome_rev()
custome_agg = custome_agg()
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)
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
-- render the main body of the Review Box
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
--
-- Main: frame function.
--
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
|