Mudanças entre as edições de "Predefinição:Infobox"

De Micropedia
Ir para navegação Ir para pesquisar
(Criou página com '<table class="infobox {{{bodyclass|}}}" cellspacing="5" style="width:{{#if:{{{subbox|}}}|100%;border:0|22em}}; text-align: left; font-size: 88%; line-height: 1.5em; {{{bodysty...')
 
Linha 1: Linha 1:
<table class="infobox {{{bodyclass|}}}" cellspacing="5" style="width:{{#if:{{{subbox|}}}|100%;border:0|22em}}; text-align: left; font-size: 88%; line-height: 1.5em; {{{bodystyle|}}}"><!--
+
--
Caption
+
-- This module implements {{Infobox}}
-->{{#if:{{{title|}}}|<caption class="{{{titleclass|}}}" style="font-size: 125%; text-color: red; font-weight: bold; {{{titlestyle|}}}">{{{title}}}</caption>}}
+
--
<!--
+
 
Header
+
local p = {}
-->{{#if:{{{above|}}}|<tr><td colspan="2" class="{{{aboveclass|}}}" style="text-align:center; font-size: 125%; font-weight: bold; {{{abovestyle|}}}">{{{above}}}</td></tr>}}<!--
+
 
  Subheader 1
+
local navbar = require('Module:Navbar')._navbar
-->{{#if:{{{subheader|{{{subheader1|}}}}}}|<tr><td colspan="2" class="{{{subheaderclass|}}}" style="text-align:center; {{{subheaderstyle|}}}">{{{subheader|{{{subheader1|}}}}}}</td></tr>}}<!--
+
 
Subheader 2
+
local args = {}
-->{{#if:{{{subheader2|}}}|<tr><td colspan="2" class="{{{subheaderclass|}}}" style="text-align:center; {{{subheaderstyle|}}}">{{{subheader2}}}</td></tr>}}<!--
+
local origArgs
Image 1
+
local root
-->{{#if:{{{image|{{{image1|}}}}}}|<tr><td colspan="2" class="{{{imageclass|}}}" style="text-align:center; {{{imagestyle|}}}"> {{{image|{{{image1|}}}}}} {{#if:{{{caption|{{{caption1|}}}}}}|<br />
+
 
<span style="{{{captionstyle|}}}">{{{caption|{{{caption1|}}}}}}</span> }}</td></tr>}}<!--
+
local function notempty( s ) return s and s:match( '%S' ) end
Image 2
+
 
-->{{#if:{{{image2|}}}|<tr><td colspan="2" class="{{{imageclass|}}}" style="text-align:center; {{{imagestyle|}}}"> {{{image2}}} {{#if:{{{caption2|}}}|<br />
+
local function fixChildBoxes(sval, tt)
<span style="{{{captionstyle|}}}">{{{caption2}}}</span> }}</td></tr>}}<!--
+
if notempty(sval) then
-->{{Infobox/row
+
local marker = '<span class=special_infobox_marker>'
|header = {{{header1|}}}  |headerstyle = {{{headerstyle|}}}
+
local s = sval
|label  = {{{label1|}}}  |labelstyle  = {{{labelstyle|}}}
+
s = mw.ustring.gsub(s, '(<%s*[Tt][Rr])', marker .. '%1')
|data  = {{{data1|}}}    |datastyle  = {{{datastyle|}}}
+
s = mw.ustring.gsub(s, '(</[Tt][Rr]%s*>)', '%1' .. marker)
|class  = {{{class1|}}}
+
if s:match(marker) then
}} {{Infobox/row
+
s = mw.ustring.gsub(s, marker .. '%s*' .. marker, '')
|header = {{{header2|}}}  |headerstyle = {{{headerstyle|}}}
+
s = mw.ustring.gsub(s, '([\r\n]|-[^\r\n]*[\r\n])%s*' .. marker, '%1')
|label = {{{label2|}}}  |labelstyle  = {{{labelstyle|}}}
+
s = mw.ustring.gsub(s, marker .. '%s*([\r\n]|-)', '%1')
|data  = {{{data2|}}}    |datastyle  = {{{datastyle|}}}
+
s = mw.ustring.gsub(s, '(</[Cc][Aa][Pp][Tt][Ii][Oo][Nn]%s*>%s*)' .. marker, '%1')
|class  = {{{class2|}}}
+
s = mw.ustring.gsub(s, '(<%s*[Tt][Aa][Bb][Ll][Ee][^<>]*>%s*)' .. marker, '%1')
}} {{Infobox/row
+
s = mw.ustring.gsub(s, '^(%{|[^\r\n]*[\r\n]%s*)' .. marker, '%1')
|header = {{{header3|}}}  |headerstyle = {{{headerstyle|}}}
+
s = mw.ustring.gsub(s, '([\r\n]%{|[^\r\n]*[\r\n]%s*)' .. marker, '%1')
|label = {{{label3|}}}  |labelstyle  = {{{labelstyle|}}}
+
s = mw.ustring.gsub(s,  marker .. '(%s*</[Tt][Aa][Bb][Ll][Ee]%s*>)', '%1')
|data  = {{{data3|}}}    |datastyle  = {{{datastyle|}}}
+
s = mw.ustring.gsub(s, marker .. '(%s*\n|%})', '%1')
|class  = {{{class3|}}}
+
end
}} {{Infobox/row
+
if s:match(marker) then
|header = {{{header4|}}}  |headerstyle = {{{headerstyle|}}}
+
local subcells = mw.text.split(s, marker)
|label  = {{{label4|}}}  |labelstyle  = {{{labelstyle|}}}
+
s = ''
|data  = {{{data4|}}}    |datastyle  = {{{datastyle|}}}
+
for k = 1, #subcells do
|class  = {{{class4|}}}
+
if k == 1 then
}} {{Infobox/row
+
s = s .. subcells[k] .. '</' .. tt .. '></tr>'
|header = {{{header5|}}}  |headerstyle = {{{headerstyle|}}}
+
elseif k == #subcells then
|label  = {{{label5|}}}  |labelstyle  = {{{labelstyle|}}}
+
local rowstyle = ' style="display:none"'
|data  = {{{data5|}}}    |datastyle  = {{{datastyle|}}}
+
if notempty(subcells[k]) then rowstyle = '' end
|class  = {{{class5|}}}
+
s = s .. '<tr' .. rowstyle ..'><' .. tt .. ' colspan=2>\n' .. subcells[k]
}} {{Infobox/row
+
elseif notempty(subcells[k]) then
|header = {{{header6|}}}  |headerstyle = {{{headerstyle|}}}
+
if (k % 2) == 0 then
|label  = {{{label6|}}}  |labelstyle  = {{{labelstyle|}}}
+
s = s .. subcells[k]
|data  = {{{data6|}}}    |datastyle  = {{{datastyle|}}}
+
else
|class  = {{{class6|}}}
+
s = s .. '<tr><' .. tt .. ' colspan=2>\n' .. subcells[k] .. '</' .. tt .. '></tr>'
}} {{Infobox/row
+
end
|header = {{{header7|}}}  |headerstyle = {{{headerstyle|}}}
+
end
|label  = {{{label7|}}}  |labelstyle  = {{{labelstyle|}}}
+
end
|data  = {{{data7|}}}    |datastyle  = {{{datastyle|}}}
+
end
|class  = {{{class7|}}}
+
-- the next two lines add a newline at the end of lists for the PHP parser
}} {{Infobox/row
+
-- https://en.wikipedia.org/w/index.php?title=Template_talk:Infobox_musical_artist&oldid=849054481
|header = {{{header8|}}}  |headerstyle = {{{headerstyle|}}}
+
-- remove when [[:phab:T191516]] is fixed or OBE
|label  = {{{label8|}}}  |labelstyle  = {{{labelstyle|}}}
+
s = mw.ustring.gsub(s, '([\r\n][%*#;:][^\r\n]*)$', '%1\n')
|data  = {{{data8|}}}    |datastyle  = {{{datastyle|}}}
+
s = mw.ustring.gsub(s, '^([%*#;:][^\r\n]*)$', '%1\n')
|class = {{{class8|}}}
+
s = mw.ustring.gsub(s, '^([%*#;:])', '\n%1')
}} {{Infobox/row
+
s = mw.ustring.gsub(s, '^(%{%|)', '\n%1')
|header = {{{header9|}}}  |headerstyle = {{{headerstyle|}}}
+
return s
|label  = {{{label9|}}}  |labelstyle  = {{{labelstyle|}}}
+
else
|data   = {{{data9|}}}    |datastyle   = {{{datastyle|}}}
+
return sval
|class = {{{class9|}}}
+
end
}} {{Infobox/row
+
end
|header = {{{header10|}}}  |headerstyle = {{{headerstyle|}}}
+
 
|label = {{{label10|}}}  |labelstyle  = {{{labelstyle|}}}
+
local function union(t1, t2)
|data   = {{{data10|}}}    |datastyle   = {{{datastyle|}}}
+
    -- Returns the union of the values of two tables, as a sequence.
|class = {{{class10|}}}
+
    local vals = {}
}} {{Infobox/row
+
    for k, v in pairs(t1) do
|header = {{{header11|}}}  |headerstyle = {{{headerstyle|}}}
+
        vals[v] = true
|label  = {{{label11|}}}  |labelstyle  = {{{labelstyle|}}}
+
    end
|data  = {{{data11|}}}    |datastyle  = {{{datastyle|}}}
+
    for k, v in pairs(t2) do
|class  = {{{class11|}}}
+
        vals[v] = true
}} {{Infobox/row
+
    end
|header = {{{header12|}}}  |headerstyle = {{{headerstyle|}}}
+
    local ret = {}
|label  = {{{label12|}}}  |labelstyle  = {{{labelstyle|}}}
+
    for k, v in pairs(vals) do
|data  = {{{data12|}}}    |datastyle  = {{{datastyle|}}}
+
        table.insert(ret, k)
|class  = {{{class12|}}}
+
    end
}} {{Infobox/row
+
    return ret
|header = {{{header13|}}}  |headerstyle = {{{headerstyle|}}}
+
end
|label  = {{{label13|}}}  |labelstyle  = {{{labelstyle|}}}
+
 
|data  = {{{data13|}}}    |datastyle  = {{{datastyle|}}}
+
local function getArgNums(prefix)
|class  = {{{class13|}}}
+
    -- Returns a table containing the numbers of the arguments that exist
}} {{Infobox/row
+
    -- for the specified prefix. For example, if the prefix was 'data', and
|header = {{{header14|}}}  |headerstyle = {{{headerstyle|}}}
+
    -- 'data1', 'data2', and 'data5' exist, it would return {1, 2, 5}.
|label  = {{{label14|}}}  |labelstyle  = {{{labelstyle|}}}
+
    local nums = {}
|data  = {{{data14|}}}    |datastyle  = {{{datastyle|}}}
+
    for k, v in pairs(args) do
|class  = {{{class14|}}}
+
        local num = tostring(k):match('^' .. prefix .. '([1-9]%d*)$')
}} {{Infobox/row
+
        if num then table.insert(nums, tonumber(num)) end
  |header = {{{header15|}}}  |headerstyle = {{{headerstyle|}}}
+
    end
|label  = {{{label15|}}}  |labelstyle  = {{{labelstyle|}}}
+
    table.sort(nums)
|data  = {{{data15|}}}    |datastyle  = {{{datastyle|}}}
+
    return nums
|class  = {{{class15|}}}
+
end
}} {{Infobox/row
+
 
|header = {{{header16|}}}  |headerstyle = {{{headerstyle|}}}
+
local function addRow(rowArgs)
|label  = {{{label16|}}}  |labelstyle  = {{{labelstyle|}}}
+
    -- Adds a row to the infobox, with either a header cell
|data  = {{{data16|}}}    |datastyle  = {{{datastyle|}}}
+
    -- or a label/data cell combination.
|class  = {{{class16|}}}
+
    if rowArgs.header then
}} {{Infobox/row
+
        root
|header = {{{header17|}}}  |headerstyle = {{{headerstyle|}}}
+
            :tag('tr')
|label  = {{{label17|}}}  |labelstyle  = {{{labelstyle|}}}
+
                :addClass(rowArgs.rowclass)
|data  = {{{data17|}}}    |datastyle  = {{{datastyle|}}}
+
                :cssText(rowArgs.rowstyle)
|class  = {{{class17|}}}
+
                :attr('id', rowArgs.rowid)
}} {{Infobox/row
+
                :tag('th')
|header = {{{header18|}}}  |headerstyle = {{{headerstyle|}}}
+
                    :attr('colspan', 2)
|label  = {{{label18|}}}  |labelstyle  = {{{labelstyle|}}}
+
                    :attr('id', rowArgs.headerid)
|data  = {{{data18|}}}    |datastyle  = {{{datastyle|}}}
+
                    :addClass(rowArgs.class)
|class  = {{{class18|}}}
+
                    :addClass(args.headerclass)
}} {{Infobox/row
+
                    :css('text-align', 'center')
|header = {{{header19|}}}  |headerstyle = {{{headerstyle|}}}
+
                    :cssText(args.headerstyle)
  |label  = {{{label19|}}}  |labelstyle  = {{{labelstyle|}}}
+
                    :cssText(rowArgs.rowcellstyle)
|data  = {{{data19|}}}   |datastyle  = {{{datastyle|}}}
+
                    :wikitext(fixChildBoxes(rowArgs.header, 'th'))
|class  = {{{class19|}}}
+
    elseif rowArgs.data then
}} {{Infobox/row
+
        local row = root:tag('tr')
|header = {{{header20|}}}  |headerstyle = {{{headerstyle|}}}
+
        row:addClass(rowArgs.rowclass)
|label  = {{{label20|}}}  |labelstyle  = {{{labelstyle|}}}
+
        row:cssText(rowArgs.rowstyle)
|data  = {{{data20|}}}    |datastyle   = {{{datastyle|}}}
+
        row:attr('id', rowArgs.rowid)
  |class = {{{class20|}}}
+
        if rowArgs.label then
}} {{Infobox/row
+
            row
|header = {{{header21|}}}  |headerstyle = {{{headerstyle|}}}
+
                :tag('th')
|label  = {{{label21|}}}  |labelstyle  = {{{labelstyle|}}}
+
                    :attr('scope', 'row')
|data  = {{{data21|}}}    |datastyle  = {{{datastyle|}}}
+
                    :attr('id', rowArgs.labelid)
|class  = {{{class21|}}}
+
                    :cssText(args.labelstyle)
}} {{Infobox/row
+
                    :cssText(rowArgs.rowcellstyle)
|header = {{{header22|}}}  |headerstyle = {{{headerstyle|}}}
+
                    :wikitext(rowArgs.label)
|label  = {{{label22|}}}  |labelstyle  = {{{labelstyle|}}}
+
                    :done()
|data  = {{{data22|}}}    |datastyle  = {{{datastyle|}}}
+
        end
|class  = {{{class22|}}}
+
       
}} {{Infobox/row
+
        local dataCell = row:tag('td')
|header = {{{header23|}}}  |headerstyle = {{{headerstyle|}}}
+
        if not rowArgs.label then
|label  = {{{label23|}}}  |labelstyle  = {{{labelstyle|}}}
+
            dataCell
|data  = {{{data23|}}}    |datastyle  = {{{datastyle|}}}
+
                :attr('colspan', 2)
|class  = {{{class23|}}}
+
                :css('text-align', 'center')
}} {{Infobox/row
+
        end
|header = {{{header24|}}}  |headerstyle = {{{headerstyle|}}}
+
        dataCell
|label  = {{{label24|}}}  |labelstyle  = {{{labelstyle|}}}
+
            :attr('id', rowArgs.dataid)
|data  = {{{data24|}}}    |datastyle  = {{{datastyle|}}}
+
            :addClass(rowArgs.class)
|class  = {{{class24|}}}
+
            :cssText(rowArgs.datastyle)
}} {{Infobox/row
+
            :cssText(rowArgs.rowcellstyle)
|header = {{{header25|}}}  |headerstyle = {{{headerstyle|}}}
+
            :wikitext(fixChildBoxes(rowArgs.data, 'td'))
|label  = {{{label25|}}}  |labelstyle  = {{{labelstyle|}}}
+
    end
|data  = {{{data25|}}}    |datastyle  = {{{datastyle|}}}
+
end
|class  = {{{class25|}}}
+
 
}} {{Infobox/row
+
local function renderTitle()
|header = {{{header26|}}}  |headerstyle = {{{headerstyle|}}}
+
    if not args.title then return end
|label  = {{{label26|}}}  |labelstyle  = {{{labelstyle|}}}
+
 
|data  = {{{data26|}}}    |datastyle  = {{{datastyle|}}}
+
    root
|class  = {{{class26|}}}
+
        :tag('caption')
}} {{Infobox/row
+
            :addClass(args.titleclass)
|header = {{{header27|}}}  |headerstyle = {{{headerstyle|}}}
+
            :cssText(args.titlestyle)
|label  = {{{label27|}}}  |labelstyle  = {{{labelstyle|}}}
+
            :wikitext(args.title)
|data  = {{{data27|}}}    |datastyle  = {{{datastyle|}}}
+
end
|class  = {{{class27|}}}
+
 
}} {{Infobox/row
+
local function renderAboveRow()
|header = {{{header28|}}}  |headerstyle = {{{headerstyle|}}}
+
    if not args.above then return end
|label  = {{{label28|}}}  |labelstyle  = {{{labelstyle|}}}
+
   
|data  = {{{data28|}}}    |datastyle  = {{{datastyle|}}}
+
    root
|class  = {{{class28|}}}
+
        :tag('tr')
}} {{Infobox/row
+
            :tag('th')
|header = {{{header29|}}}  |headerstyle = {{{headerstyle|}}}
+
                :attr('colspan', 2)
|label  = {{{label29|}}}  |labelstyle  = {{{labelstyle|}}}
+
                :addClass(args.aboveclass)
|data  = {{{data29|}}}    |datastyle  = {{{datastyle|}}}
+
                :css('text-align', 'center')
|class  = {{{class29|}}}
+
                :css('font-size', '125%')
}} {{Infobox/row
+
                :css('font-weight', 'bold')
|header = {{{header30|}}}  |headerstyle = {{{headerstyle|}}}
+
                :cssText(args.abovestyle)
|label  = {{{label30|}}}  |labelstyle  = {{{labelstyle|}}}
+
                :wikitext(fixChildBoxes(args.above,'th'))
|data  = {{{data30|}}}    |datastyle  = {{{datastyle|}}}
+
end
|class  = {{{class30|}}}
+
 
}} {{Infobox/row
+
local function renderBelowRow()
|header = {{{header31|}}}  |headerstyle = {{{headerstyle|}}}
+
    if not args.below then return end
|label  = {{{label31|}}}  |labelstyle  = {{{labelstyle|}}}
+
   
|data  = {{{data31|}}}    |datastyle  = {{{datastyle|}}}
+
    root
|class  = {{{class31|}}}
+
        :tag('tr')
}} {{Infobox/row
+
            :tag('td')
|header = {{{header32|}}}  |headerstyle = {{{headerstyle|}}}
+
                :attr('colspan', '2')
|label  = {{{label32|}}}  |labelstyle  = {{{labelstyle|}}}
+
                :addClass(args.belowclass)
|data  = {{{data32|}}}    |datastyle  = {{{datastyle|}}}
+
                :css('text-align', 'center')
|class  = {{{class32|}}}
+
                :cssText(args.belowstyle)
}} {{Infobox/row
+
                :wikitext(fixChildBoxes(args.below,'td'))
|header = {{{header33|}}}  |headerstyle = {{{headerstyle|}}}
+
end
|label  = {{{label33|}}}  |labelstyle  = {{{labelstyle|}}}
+
 
|data  = {{{data33|}}}    |datastyle  = {{{datastyle|}}}
+
local function renderSubheaders()
|class  = {{{class33|}}}
+
    if args.subheader then
}} {{Infobox/row
+
        args.subheader1 = args.subheader
|header = {{{header34|}}}  |headerstyle = {{{headerstyle|}}}
+
    end
|label  = {{{label34|}}}  |labelstyle  = {{{labelstyle|}}}
+
    if args.subheaderrowclass then
|data  = {{{data34|}}}    |datastyle  = {{{datastyle|}}}
+
        args.subheaderrowclass1 = args.subheaderrowclass
|class  = {{{class34|}}}
+
    end
}} {{Infobox/row
+
    local subheadernums = getArgNums('subheader')
|header = {{{header35|}}}  |headerstyle = {{{headerstyle|}}}
+
    for k, num in ipairs(subheadernums) do
|label  = {{{label35|}}}  |labelstyle  = {{{labelstyle|}}}
+
        addRow({
|data  = {{{data35|}}}    |datastyle  = {{{datastyle|}}}
+
            data = args['subheader' .. tostring(num)],
|class  = {{{class35|}}}
+
            datastyle = args.subheaderstyle,
}} {{Infobox/row
+
            rowcellstyle = args['subheaderstyle' .. tostring(num)],
|header = {{{header36|}}}  |headerstyle = {{{headerstyle|}}}
+
            class = args.subheaderclass,
|label  = {{{label36|}}}  |labelstyle  = {{{labelstyle|}}}
+
            rowclass = args['subheaderrowclass' .. tostring(num)]
|data  = {{{data36|}}}    |datastyle  = {{{datastyle|}}}
+
        })
|class  = {{{class36|}}}
+
    end
}} {{Infobox/row
+
end
|header = {{{header37|}}}  |headerstyle = {{{headerstyle|}}}
+
 
|label  = {{{label37|}}}  |labelstyle  = {{{labelstyle|}}}
+
local function renderImages()
|data  = {{{data37|}}}    |datastyle  = {{{datastyle|}}}
+
    if args.image then
|class  = {{{class37|}}}
+
        args.image1 = args.image
}} {{Infobox/row
+
    end
|header = {{{header38|}}}  |headerstyle = {{{headerstyle|}}}
+
    if args.caption then
|label  = {{{label38|}}}  |labelstyle  = {{{labelstyle|}}}
+
        args.caption1 = args.caption
|data  = {{{data38|}}}    |datastyle  = {{{datastyle|}}}
+
    end
|class  = {{{class38|}}}
+
    local imagenums = getArgNums('image')
}} {{Infobox/row
+
    for k, num in ipairs(imagenums) do
|header = {{{header39|}}}  |headerstyle = {{{headerstyle|}}}
+
        local caption = args['caption' .. tostring(num)]
|label  = {{{label39|}}}  |labelstyle  = {{{labelstyle|}}}
+
        local data = mw.html.create():wikitext(args['image' .. tostring(num)])
|data  = {{{data39|}}}    |datastyle  = {{{datastyle|}}}
+
        if caption then
|class  = {{{class39|}}}
+
            data
}} {{Infobox/row
+
                :tag('div')
|header = {{{header40|}}}  |headerstyle = {{{headerstyle|}}}
+
                    :cssText(args.captionstyle)
|label  = {{{label40|}}}  |labelstyle  = {{{labelstyle|}}}
+
                    :wikitext(caption)
|data  = {{{data40|}}}    |datastyle  = {{{datastyle|}}}
+
        end
|class  = {{{class40|}}}
+
        addRow({
}} {{Infobox/row
+
            data = tostring(data),
|header = {{{header41|}}}  |headerstyle = {{{headerstyle|}}}
+
            datastyle = args.imagestyle,
|label  = {{{label41|}}}  |labelstyle  = {{{labelstyle|}}}
+
            class = args.imageclass,
|data  = {{{data41|}}}    |datastyle  = {{{datastyle|}}}
+
            rowclass = args['imagerowclass' .. tostring(num)]
|class  = {{{class41|}}}
+
        })
}} {{Infobox/row
+
    end
|header = {{{header42|}}}  |headerstyle = {{{headerstyle|}}}
+
end
|label  = {{{label42|}}}  |labelstyle  = {{{labelstyle|}}}
+
 
|data  = {{{data42|}}}    |datastyle  = {{{datastyle|}}}
+
local function renderRows()
|class  = {{{class42|}}}
+
    -- Gets the union of the header and data argument numbers,
}} {{Infobox/row
+
    -- and renders them all in order using addRow.
|header = {{{header43|}}}  |headerstyle = {{{headerstyle|}}}
+
    local rownums = union(getArgNums('header'), getArgNums('data'))
|label  = {{{label43|}}}  |labelstyle  = {{{labelstyle|}}}
+
    table.sort(rownums)
|data  = {{{data43|}}}    |datastyle  = {{{datastyle|}}}
+
    for k, num in ipairs(rownums) do
|class  = {{{class43|}}}
+
        addRow({
}} {{Infobox/row
+
            header = args['header' .. tostring(num)],
|header = {{{header44|}}}  |headerstyle = {{{headerstyle|}}}
+
            label = args['label' .. tostring(num)],
|label  = {{{label44|}}}  |labelstyle  = {{{labelstyle|}}}
+
            data = args['data' .. tostring(num)],
|data  = {{{data44|}}}    |datastyle  = {{{datastyle|}}}
+
            datastyle = args.datastyle,
|class  = {{{class44|}}}
+
            class = args['class' .. tostring(num)],
}} {{Infobox/row
+
            rowclass = args['rowclass' .. tostring(num)],
|header = {{{header45|}}}  |headerstyle = {{{headerstyle|}}}
+
            rowstyle = args['rowstyle' .. tostring(num)],
|label  = {{{label45|}}}  |labelstyle  = {{{labelstyle|}}}
+
            rowcellstyle = args['rowcellstyle' .. tostring(num)],
|data  = {{{data45|}}}    |datastyle  = {{{datastyle|}}}
+
            dataid = args['dataid' .. tostring(num)],
|class  = {{{class45|}}}
+
            labelid = args['labelid' .. tostring(num)],
}} {{Infobox/row
+
            headerid = args['headerid' .. tostring(num)],
|header = {{{header46|}}}  |headerstyle = {{{headerstyle|}}}
+
            rowid = args['rowid' .. tostring(num)]
|label  = {{{label46|}}}  |labelstyle  = {{{labelstyle|}}}
+
        })
|data  = {{{data46|}}}    |datastyle  = {{{datastyle|}}}
+
    end
|class  = {{{class46|}}}
+
end
}} {{Infobox/row
+
 
|header = {{{header47|}}}  |headerstyle = {{{headerstyle|}}}
+
local function renderNavBar()
|label  = {{{label47|}}}  |labelstyle  = {{{labelstyle|}}}
+
    if not args.name then return end
|data  = {{{data47|}}}    |datastyle  = {{{datastyle|}}}
+
   
|class  = {{{class47|}}}
+
    root
}} {{Infobox/row
+
        :tag('tr')
|header = {{{header48|}}}  |headerstyle = {{{headerstyle|}}}
+
            :tag('td')
|label  = {{{label48|}}}  |labelstyle  = {{{labelstyle|}}}
+
                :attr('colspan', '2')
|data  = {{{data48|}}}    |datastyle  = {{{datastyle|}}}
+
                :css('text-align', 'right')
|class  = {{{class48|}}}
+
                :wikitext(navbar{
}} {{Infobox/row
+
                    args.name,
|header = {{{header49|}}}  |headerstyle = {{{headerstyle|}}}
+
                    mini = 1,
|label  = {{{label49|}}}  |labelstyle  = {{{labelstyle|}}}
+
                })
|data  = {{{data49|}}}    |datastyle  = {{{datastyle|}}}
+
end
|class  = {{{class49|}}}
+
 
}} {{Infobox/row
+
local function renderItalicTitle()
|header = {{{header50|}}}  |headerstyle = {{{headerstyle|}}}
+
    local italicTitle = args['italic title'] and mw.ustring.lower(args['italic title'])
|label  = {{{label50|}}}  |labelstyle  = {{{labelstyle|}}}
+
    if italicTitle == '' or italicTitle == 'force' or italicTitle == 'yes' then
|data  = {{{data50|}}}    |datastyle  = {{{datastyle|}}}
+
        root:wikitext(mw.getCurrentFrame():expandTemplate({title = 'italic title'}))
|class  = {{{class50|}}}
+
    end
}} {{Infobox/row
+
end
|header = {{{header51|}}}  |headerstyle = {{{headerstyle|}}}
+
 
|label  = {{{label51|}}}  |labelstyle  = {{{labelstyle|}}}
+
local function renderTrackingCategories()
|data  = {{{data51|}}}    |datastyle  = {{{datastyle|}}}
+
    if args.decat ~= 'yes' then
|class  = {{{class51|}}}
+
    if args.child == 'yes' then
}} {{Infobox/row
+
        if args.title then
|header = {{{header52|}}}  |headerstyle = {{{headerstyle|}}}
+
            root:wikitext('[[Category:Pages which use embedded infobox templates with the title parameter]]')
|label  = {{{label52|}}}  |labelstyle  = {{{labelstyle|}}}
+
        end
|data  = {{{data52|}}}    |datastyle  = {{{datastyle|}}}
+
        elseif #(getArgNums('data')) == 0 and mw.title.getCurrentTitle().namespace == 0 then
|class  = {{{class52|}}}
+
            root:wikitext('[[Category:Articles which use infobox templates with no data rows]]')
}} {{Infobox/row
+
        end
|header = {{{header53|}}}  |headerstyle = {{{headerstyle|}}}
+
    end
|label  = {{{label53|}}}  |labelstyle  = {{{labelstyle|}}}
+
end
|data  = {{{data53|}}}    |datastyle  = {{{datastyle|}}}
+
 
|class  = {{{class53|}}}
+
local function _infobox()
}} {{Infobox/row
+
    -- Specify the overall layout of the infobox, with special settings
|header = {{{header54|}}}  |headerstyle = {{{headerstyle|}}}
+
    -- if the infobox is used as a 'child' inside another infobox.
|label  = {{{label54|}}}  |labelstyle  = {{{labelstyle|}}}
+
    if args.child ~= 'yes' then
|data  = {{{data54|}}}    |datastyle  = {{{datastyle|}}}
+
        root = mw.html.create('table')
|class  = {{{class54|}}}
+
       
}} {{Infobox/row
+
        root
|header = {{{header55|}}}  |headerstyle = {{{headerstyle|}}}
+
            :addClass((args.subbox ~= 'yes') and 'infobox' or nil)
|label  = {{{label55|}}}  |labelstyle  = {{{labelstyle|}}}
+
            :addClass(args.bodyclass)
|data  = {{{data55|}}}    |datastyle  = {{{datastyle|}}}
+
           
|class  = {{{class55|}}}
+
            if args.subbox == 'yes' then
}} {{Infobox/row
+
                root
|header = {{{header56|}}}  |headerstyle = {{{headerstyle|}}}
+
                    :css('padding', '0')
|label  = {{{label56|}}}  |labelstyle  = {{{labelstyle|}}}
+
                    :css('border', 'none')
|data  = {{{data56|}}}    |datastyle  = {{{datastyle|}}}
+
                    :css('margin', '-3px')
|class  = {{{class56|}}}
+
                    :css('width', 'auto')
}} {{Infobox/row
+
                    :css('min-width', '100%')
|header = {{{header57|}}}  |headerstyle = {{{headerstyle|}}}
+
                    :css('font-size', '100%')
|label  = {{{label57|}}}  |labelstyle  = {{{labelstyle|}}}
+
                    :css('clear', 'none')
|data  = {{{data57|}}}    |datastyle  = {{{datastyle|}}}
+
                    :css('float', 'none')
|class  = {{{class57|}}}
+
                    :css('background-color', 'transparent')
}} {{Infobox/row
+
            else
|header = {{{header58|}}}  |headerstyle = {{{headerstyle|}}}
+
                root
|label  = {{{label58|}}}  |labelstyle  = {{{labelstyle|}}}
+
                    :css('width', '22em')
|data  = {{{data58|}}}    |datastyle  = {{{datastyle|}}}
+
            end
|class  = {{{class58|}}}
+
        root
}} {{Infobox/row
+
            :cssText(args.bodystyle)
|header = {{{header59|}}}  |headerstyle = {{{headerstyle|}}}
+
   
|label  = {{{label59|}}}  |labelstyle  = {{{labelstyle|}}}
+
        renderTitle()
|data  = {{{data59|}}}    |datastyle  = {{{datastyle|}}}
+
        renderAboveRow()
|class  = {{{class59|}}}
+
    else
}} {{Infobox/row
+
        root = mw.html.create()
|header = {{{header60|}}}  |headerstyle = {{{headerstyle|}}}
+
       
|label  = {{{label60|}}}  |labelstyle  = {{{labelstyle|}}}
+
        root
|data  = {{{data60|}}}    |datastyle  = {{{datastyle|}}}
+
            :wikitext(args.title)
|class  = {{{class60|}}}
+
    end
}} {{Infobox/row
+
 
|header = {{{header61|}}}  |headerstyle = {{{headerstyle|}}}
+
    renderSubheaders()
|label  = {{{label61|}}}  |labelstyle  = {{{labelstyle|}}}
+
    renderImages()
|data  = {{{data61|}}}    |datastyle  = {{{datastyle|}}}
+
    renderRows()
|class  = {{{class61|}}}
+
    renderBelowRow()  
}} {{Infobox/row
+
    renderNavBar()
|header = {{{header62|}}}  |headerstyle = {{{headerstyle|}}}
+
    renderItalicTitle()
|label  = {{{label62|}}}  |labelstyle  = {{{labelstyle|}}}
+
    renderTrackingCategories()
|data  = {{{data62|}}}    |datastyle  = {{{datastyle|}}}
+
   
|class  = {{{class62|}}}
+
    return tostring(root)
}} {{Infobox/row
+
end
|header = {{{header63|}}}  |headerstyle = {{{headerstyle|}}}
+
 
|label  = {{{label63|}}}  |labelstyle  = {{{labelstyle|}}}
+
local function preprocessSingleArg(argName)
|data  = {{{data63|}}}    |datastyle  = {{{datastyle|}}}
+
    -- If the argument exists and isn't blank, add it to the argument table.
|class  = {{{class63|}}}
+
    -- Blank arguments are treated as nil to match the behaviour of ParserFunctions.
}} {{Infobox/row
+
    if origArgs[argName] and origArgs[argName] ~= '' then
|header = {{{header64|}}}  |headerstyle = {{{headerstyle|}}}
+
        args[argName] = origArgs[argName]
|label  = {{{label64|}}}  |labelstyle  = {{{labelstyle|}}}
+
    end
|data  = {{{data64|}}}    |datastyle  = {{{datastyle|}}}
+
end
|class  = {{{class64|}}}
+
 
}} {{Infobox/row
+
local function preprocessArgs(prefixTable, step)
|header = {{{header65|}}}  |headerstyle = {{{headerstyle|}}}
+
    -- Assign the parameters with the given prefixes to the args table, in order, in batches
|label  = {{{label65|}}}  |labelstyle  = {{{labelstyle|}}}
+
    -- of the step size specified. This is to prevent references etc. from appearing in the
|data  = {{{data65|}}}    |datastyle  = {{{datastyle|}}}
+
    -- wrong order. The prefixTable should be an array containing tables, each of which has
|class  = {{{class65|}}}
+
    -- two possible fields, a "prefix" string and a "depend" table. The function always parses
}} {{Infobox/row
+
    -- parameters containing the "prefix" string, but only parses parameters in the "depend"
|header = {{{header66|}}}  |headerstyle = {{{headerstyle|}}}
+
    -- table if the prefix parameter is present and non-blank.
|label  = {{{label66|}}}  |labelstyle  = {{{labelstyle|}}}
+
    if type(prefixTable) ~= 'table' then
|data  = {{{data66|}}}    |datastyle  = {{{datastyle|}}}
+
        error("Non-table value detected for the prefix table", 2)
|class  = {{{class66|}}}
+
    end
}} {{Infobox/row
+
    if type(step) ~= 'number' then
|header = {{{header67|}}}  |headerstyle = {{{headerstyle|}}}
+
        error("Invalid step value detected", 2)
|label  = {{{label67|}}}  |labelstyle  = {{{labelstyle|}}}
+
    end
|data  = {{{data67|}}}    |datastyle  = {{{datastyle|}}}
+
   
|class  = {{{class67|}}}
+
    -- Get arguments without a number suffix, and check for bad input.
}} {{Infobox/row
+
    for i,v in ipairs(prefixTable) do
|header = {{{header68|}}}  |headerstyle = {{{headerstyle|}}}
+
        if type(v) ~= 'table' or type(v.prefix) ~= "string" or (v.depend and type(v.depend) ~= 'table') then
|label  = {{{label68|}}}  |labelstyle  = {{{labelstyle|}}}
+
            error('Invalid input detected to preprocessArgs prefix table', 2)
|data  = {{{data68|}}}    |datastyle  = {{{datastyle|}}}
+
        end
|class  = {{{class68|}}}
+
        preprocessSingleArg(v.prefix)
}} {{Infobox/row
+
        -- Only parse the depend parameter if the prefix parameter is present and not blank.
|header = {{{header69|}}}  |headerstyle = {{{headerstyle|}}}
+
        if args[v.prefix] and v.depend then
|label  = {{{label69|}}}  |labelstyle  = {{{labelstyle|}}}
+
            for j, dependValue in ipairs(v.depend) do
|data  = {{{data69|}}}    |datastyle  = {{{datastyle|}}}
+
                if type(dependValue) ~= 'string' then
|class  = {{{class69|}}}
+
                    error('Invalid "depend" parameter value detected in preprocessArgs')
}} {{Infobox/row
+
                end
|header = {{{header70|}}}  |headerstyle = {{{headerstyle|}}}
+
                preprocessSingleArg(dependValue)
|label  = {{{label70|}}}  |labelstyle  = {{{labelstyle|}}}
+
            end
|data  = {{{data70|}}}    |datastyle  = {{{datastyle|}}}
+
        end
|class  = {{{class70|}}}
+
    end
}} {{Infobox/row
+
 
|header = {{{header71|}}}  |headerstyle = {{{headerstyle|}}}
+
    -- Get arguments with number suffixes.
|label  = {{{label71|}}}  |labelstyle  = {{{labelstyle|}}}
+
    local a = 1 -- Counter variable.
|data  = {{{data71|}}}    |datastyle  = {{{datastyle|}}}
+
    local moreArgumentsExist = true
|class  = {{{class71|}}}
+
    while moreArgumentsExist == true do
}} {{Infobox/row
+
        moreArgumentsExist = false
|header = {{{header72|}}}  |headerstyle = {{{headerstyle|}}}
+
        for i = a, a + step - 1 do
|label  = {{{label72|}}}  |labelstyle  = {{{labelstyle|}}}
+
            for j,v in ipairs(prefixTable) do
|data  = {{{data72|}}}    |datastyle  = {{{datastyle|}}}
+
                local prefixArgName = v.prefix .. tostring(i)
|class  = {{{class72|}}}
+
                if origArgs[prefixArgName] then
}} {{Infobox/row
+
                    moreArgumentsExist = true -- Do another loop if any arguments are found, even blank ones.
|header = {{{header73|}}}  |headerstyle = {{{headerstyle|}}}
+
                    preprocessSingleArg(prefixArgName)
|label  = {{{label73|}}}  |labelstyle  = {{{labelstyle|}}}
+
                end
|data  = {{{data73|}}}    |datastyle  = {{{datastyle|}}}
+
                -- Process the depend table if the prefix argument is present and not blank, or
|class  = {{{class73|}}}
+
                -- we are processing "prefix1" and "prefix" is present and not blank, and
}} {{Infobox/row
+
                -- if the depend table is present.
|header = {{{header74|}}}  |headerstyle = {{{headerstyle|}}}
+
                if v.depend and (args[prefixArgName] or (i == 1 and args[v.prefix])) then
|label  = {{{label74|}}}  |labelstyle  = {{{labelstyle|}}}
+
                    for j,dependValue in ipairs(v.depend) do
|data  = {{{data74|}}}    |datastyle  = {{{datastyle|}}}
+
                        local dependArgName = dependValue .. tostring(i)
|class  = {{{class74|}}}
+
                        preprocessSingleArg(dependArgName)
}} {{Infobox/row
+
                    end
|header = {{{header75|}}}  |headerstyle = {{{headerstyle|}}}
+
                end
|label  = {{{label75|}}}  |labelstyle  = {{{labelstyle|}}}
+
            end
|data  = {{{data75|}}}    |datastyle  = {{{datastyle|}}}
+
        end
|class  = {{{class75|}}}
+
        a = a + step
}} {{Infobox/row
+
    end
|header = {{{header76|}}}  |headerstyle = {{{headerstyle|}}}
+
end
|label  = {{{label76|}}}  |labelstyle  = {{{labelstyle|}}}
+
   
|data  = {{{data76|}}}    |datastyle  = {{{datastyle|}}}
+
function p.infobox(frame)
|class  = {{{class76|}}}
+
    -- If called via #invoke, use the args passed into the invoking template.
}} {{Infobox/row
+
    -- Otherwise, for testing purposes, assume args are being passed directly in.
|header = {{{header77|}}}  |headerstyle = {{{headerstyle|}}}
+
    if frame == mw.getCurrentFrame() then
|label  = {{{label77|}}}  |labelstyle  = {{{labelstyle|}}}
+
        origArgs = frame:getParent().args
|data  = {{{data77|}}}    |datastyle  = {{{datastyle|}}}
+
    else
|class  = {{{class77|}}}
+
        origArgs = frame
}} {{Infobox/row
+
    end
|header = {{{header78|}}}  |headerstyle = {{{headerstyle|}}}
+
   
|label  = {{{label78|}}}  |labelstyle  = {{{labelstyle|}}}
+
    -- Parse the data parameters in the same order that the old {{infobox}} did, so that
|data  = {{{data78|}}}    |datastyle  = {{{datastyle|}}}
+
    -- references etc. will display in the expected places. Parameters that depend on
|class  = {{{class78|}}}
+
    -- another parameter are only processed if that parameter is present, to avoid
}} {{Infobox/row
+
    -- phantom references appearing in article reference lists.
|header = {{{header79|}}}  |headerstyle = {{{headerstyle|}}}
+
    preprocessSingleArg('child')
|label  = {{{label79|}}}  |labelstyle  = {{{labelstyle|}}}
+
    preprocessSingleArg('bodyclass')
|data  = {{{data79|}}}    |datastyle  = {{{datastyle|}}}
+
    preprocessSingleArg('subbox')
|class  = {{{class79|}}}
+
    preprocessSingleArg('bodystyle')
}} {{Infobox/row
+
    preprocessSingleArg('title')
|header = {{{header80|}}}  |headerstyle = {{{headerstyle|}}}
+
    preprocessSingleArg('titleclass')
|label  = {{{label80|}}}  |labelstyle  = {{{labelstyle|}}}
+
    preprocessSingleArg('titlestyle')
|data  = {{{data80|}}}    |datastyle  = {{{datastyle|}}}
+
    preprocessSingleArg('above')
|class  = {{{class80|}}}
+
    preprocessSingleArg('aboveclass')
}} {{Infobox/row
+
    preprocessSingleArg('abovestyle')
|header = {{{header81|}}}  |headerstyle = {{{headerstyle|}}}
+
    preprocessArgs({
|label  = {{{label81|}}}  |labelstyle  = {{{labelstyle|}}}
+
        {prefix = 'subheader', depend = {'subheaderstyle', 'subheaderrowclass'}}
|data  = {{{data81|}}}    |datastyle  = {{{datastyle|}}}
+
    }, 10)
|class  = {{{class81|}}}
+
    preprocessSingleArg('subheaderstyle')
}}{{Infobox/row
+
    preprocessSingleArg('subheaderclass')
|header = {{{header82|}}}  |headerstyle = {{{headerstyle|}}}
+
    preprocessArgs({
|label  = {{{label82|}}}  |labelstyle  = {{{labelstyle|}}}
+
        {prefix = 'image', depend = {'caption', 'imagerowclass'}}
|data  = {{{data82|}}}    |datastyle  = {{{datastyle|}}}
+
    }, 10)
|class  = {{{class82|}}}
+
    preprocessSingleArg('captionstyle')
}}{{Infobox/row
+
    preprocessSingleArg('imagestyle')
|header = {{{header83|}}}  |headerstyle = {{{headerstyle|}}}
+
    preprocessSingleArg('imageclass')
|label  = {{{label83|}}}  |labelstyle  = {{{labelstyle|}}}
+
    preprocessArgs({
|data  = {{{data83|}}}    |datastyle  = {{{datastyle|}}}
+
        {prefix = 'header'},
|class  = {{{class83|}}}
+
        {prefix = 'data', depend = {'label'}},
}}{{Infobox/row
+
        {prefix = 'rowclass'},
|header = {{{header84|}}}  |headerstyle = {{{headerstyle|}}}
+
        {prefix = 'rowstyle'},
|label  = {{{label84|}}}  |labelstyle  = {{{labelstyle|}}}
+
        {prefix = 'rowcellstyle'},
|data  = {{{data84|}}}    |datastyle  = {{{datastyle|}}}
+
        {prefix = 'class'},
|class  = {{{class84|}}}
+
        {prefix = 'dataid'},
}}{{Infobox/row
+
        {prefix = 'labelid'},
|header = {{{header85|}}}  |headerstyle = {{{headerstyle|}}}
+
        {prefix = 'headerid'},
|label  = {{{label85|}}}  |labelstyle  = {{{labelstyle|}}}
+
        {prefix = 'rowid'}
|data  = {{{data85|}}}    |datastyle  = {{{datastyle|}}}
+
    }, 50)
|class  = {{{class85|}}}
+
    preprocessSingleArg('headerclass')
}}{{Infobox/row
+
    preprocessSingleArg('headerstyle')
|header = {{{header86|}}}  |headerstyle = {{{headerstyle|}}}
+
    preprocessSingleArg('labelstyle')
|label  = {{{label86|}}}  |labelstyle  = {{{labelstyle|}}}
+
    preprocessSingleArg('datastyle')
|data  = {{{data86|}}}    |datastyle  = {{{datastyle|}}}
+
    preprocessSingleArg('below')
|class  = {{{class86|}}}
+
    preprocessSingleArg('belowclass')
}}{{Infobox/row
+
    preprocessSingleArg('belowstyle')
|header = {{{header87|}}}  |headerstyle = {{{headerstyle|}}}
+
    preprocessSingleArg('name')
|label  = {{{label87|}}}  |labelstyle  = {{{labelstyle|}}}
+
    args['italic title'] = origArgs['italic title'] -- different behaviour if blank or absent
|data  = {{{data87|}}}    |datastyle  = {{{datastyle|}}}
+
    preprocessSingleArg('decat')
|class  = {{{class87|}}}
+
   
}}{{Infobox/row
+
    return _infobox()
|header = {{{header88|}}}  |headerstyle = {{{headerstyle|}}}
+
end
|label  = {{{label88|}}}  |labelstyle  = {{{labelstyle|}}}
+
   
|data  = {{{data88|}}}    |datastyle  = {{{datastyle|}}}
+
return p
|class  = {{{class88|}}}
 
}}{{Infobox/row
 
|header = {{{header89|}}}  |headerstyle = {{{headerstyle|}}}
 
|label  = {{{label89|}}}  |labelstyle  = {{{labelstyle|}}}
 
|data  = {{{data89|}}}    |datastyle  = {{{datastyle|}}}
 
|class  = {{{class89|}}}
 
}}{{Infobox/row
 
|header = {{{header90|}}}  |headerstyle = {{{headerstyle|}}}
 
|label  = {{{label90|}}}  |labelstyle  = {{{labelstyle|}}}
 
|data  = {{{data90|}}}    |datastyle  = {{{datastyle|}}}
 
|class  = {{{class90|}}}
 
}}{{Infobox/row
 
|header = {{{header91|}}}  |headerstyle = {{{headerstyle|}}}
 
|label  = {{{label91|}}}  |labelstyle  = {{{labelstyle|}}}
 
|data  = {{{data91|}}}    |datastyle  = {{{datastyle|}}}
 
|class  = {{{class91|}}}
 
}}{{Infobox/row
 
|header = {{{header92|}}}  |headerstyle = {{{headerstyle|}}}
 
|label  = {{{label92|}}}  |labelstyle  = {{{labelstyle|}}}
 
|data  = {{{data92|}}}    |datastyle  = {{{datastyle|}}}
 
|class  = {{{class92|}}}
 
}}{{Infobox/row
 
|header = {{{header93|}}}  |headerstyle = {{{headerstyle|}}}
 
|label  = {{{label93|}}}  |labelstyle  = {{{labelstyle|}}}
 
|data  = {{{data93|}}}    |datastyle  = {{{datastyle|}}}
 
|class  = {{{class93|}}}
 
}}{{Infobox/row
 
|header = {{{header94|}}}  |headerstyle = {{{headerstyle|}}}
 
|label  = {{{label94|}}}  |labelstyle  = {{{labelstyle|}}}
 
|data  = {{{data94|}}}    |datastyle  = {{{datastyle|}}}
 
|class  = {{{class94|}}}
 
}}{{Infobox/row
 
|header = {{{header95|}}}  |headerstyle = {{{headerstyle|}}}
 
|label  = {{{label95|}}}  |labelstyle  = {{{labelstyle|}}}
 
|data  = {{{data95|}}}    |datastyle  = {{{datastyle|}}}
 
|class  = {{{class95|}}}
 
}}{{Infobox/row
 
|header = {{{header96|}}}  |headerstyle = {{{headerstyle|}}}
 
|label  = {{{label96|}}}  |labelstyle  = {{{labelstyle|}}}
 
|data  = {{{data96|}}}    |datastyle  = {{{datastyle|}}}
 
|class  = {{{class96|}}}
 
}}{{Infobox/row
 
|header = {{{header97|}}}  |headerstyle = {{{headerstyle|}}}
 
|label  = {{{label97|}}}  |labelstyle  = {{{labelstyle|}}}
 
|data  = {{{data97|}}}    |datastyle  = {{{datastyle|}}}
 
|class  = {{{class97|}}}
 
}}{{Infobox/row
 
|header = {{{header98|}}}  |headerstyle = {{{headerstyle|}}}
 
|label  = {{{label98|}}}  |labelstyle  = {{{labelstyle|}}}
 
|data  = {{{data98|}}}    |datastyle  = {{{datastyle|}}}
 
|class  = {{{class98|}}}
 
}}{{Infobox/row
 
|header = {{{header99|}}}  |headerstyle = {{{headerstyle|}}}
 
|label  = {{{label99|}}}  |labelstyle  = {{{labelstyle|}}}
 
|data  = {{{data99|}}}    |datastyle  = {{{datastyle|}}}
 
|class  = {{{class99|}}}
 
}}{{Infobox/row
 
|header = {{{header100|}}}  |headerstyle = {{{headerstyle|}}}
 
|label  = {{{label100|}}}  |labelstyle  = {{{labelstyle|}}}
 
|data  = {{{data100|}}}    |datastyle  = {{{datastyle|}}}
 
|class  = {{{class100|}}} }}
 
<!--
 
Below
 
-->{{#if:{{{below|}}}|<tr><td colspan="2" style="text-align:center; {{{belowstyle|}}}">{{{below|}}}</td></tr>}}<!--
 
Navbar
 
-->{{#if:{{{name|}}}|<tr><td style="text-align:right;" colspan="2">{{navbar|{{{name}}}|noedit={{{noedit|0}}}}}</td></tr>}}
 
</table><noinclude>[[Category:Templates|{{PAGENAME}}]]</noinclude>
 

Edição das 18h54min de 26 de janeiro de 2020

-- -- This module implements -- -- This module implements Ciclo de predefinições detectado: Predefinição:Infobox --

local p = {}

local navbar = require('Module:Navbar')._navbar

local args = {} local origArgs local root

local function notempty( s ) return s and s:match( '%S' ) end

local function fixChildBoxes(sval, tt) if notempty(sval) then local marker = '' local s = sval s = mw.ustring.gsub(s, '(<%s*[Tt][Rr])', marker .. '%1') s = mw.ustring.gsub(s, '(</[Tt][Rr]%s*>)', '%1' .. marker) if s:match(marker) then s = mw.ustring.gsub(s, marker .. '%s*' .. marker, ) s = mw.ustring.gsub(s, '([\r\n]|-[^\r\n]*[\r\n])%s*' .. marker, '%1') s = mw.ustring.gsub(s, marker .. '%s*([\r\n]|-)', '%1') s = mw.ustring.gsub(s, '(</[Cc][Aa][Pp][Tt][Ii][Oo][Nn]%s*>%s*)' .. marker, '%1') s = mw.ustring.gsub(s, '(<%s*[Tt][Aa][Bb][Ll][Ee][^<>]*>%s*)' .. marker, '%1') s = mw.ustring.gsub(s, '^(%{|[^\r\n]*[\r\n]%s*)' .. marker, '%1') s = mw.ustring.gsub(s, '([\r\n]%{|[^\r\n]*[\r\n]%s*)' .. marker, '%1') s = mw.ustring.gsub(s, marker .. '(%s*</[Tt][Aa][Bb][Ll][Ee]%s*>)', '%1') s = mw.ustring.gsub(s, marker .. '(%s*\n|%})', '%1') end if s:match(marker) then local subcells = mw.text.split(s, marker) s = for k = 1, #subcells do if k == 1 then

s = s .. subcells[k] .. '</' .. tt .. '>' elseif k == #subcells then local rowstyle = ' style="display:none"' if notempty(subcells[k]) then rowstyle = end s = s .. '<tr' .. rowstyle ..'><' .. tt .. ' colspan=2>\n' .. subcells[k] elseif notempty(subcells[k]) then if (k % 2) == 0 then s = s .. subcells[k] else s = s .. '<' .. tt .. ' colspan=2>\n' .. subcells[k] .. '</' .. tt .. '>' end end end end -- the next two lines add a newline at the end of lists for the PHP parser -- https://en.wikipedia.org/w/index.php?title=Template_talk:Infobox_musical_artist&oldid=849054481 -- remove when phab:T191516 is fixed or OBE s = mw.ustring.gsub(s, '([\r\n][%*#;:][^\r\n]*)$', '%1\n') s = mw.ustring.gsub(s, '^([%*#;:][^\r\n]*)$', '%1\n') s = mw.ustring.gsub(s, '^([%*#;:])', '\n%1') s = mw.ustring.gsub(s, '^(%{%|)', '\n%1') return s else return sval end end local function union(t1, t2) -- Returns the union of the values of two tables, as a sequence. local vals = {} for k, v in pairs(t1) do vals[v] = true end for k, v in pairs(t2) do vals[v] = true end local ret = {} for k, v in pairs(vals) do table.insert(ret, k) end return ret end local function getArgNums(prefix) -- Returns a table containing the numbers of the arguments that exist -- for the specified prefix. For example, if the prefix was 'data', and -- 'data1', 'data2', and 'data5' exist, it would return {1, 2, 5}. local nums = {} for k, v in pairs(args) do local num = tostring(k):match('^' .. prefix .. '([1-9]%d*)$') if num then table.insert(nums, tonumber(num)) end end table.sort(nums) return nums end local function addRow(rowArgs) -- Adds a row to the infobox, with either a header cell -- or a label/data cell combination. if rowArgs.header then root :tag('tr') :addClass(rowArgs.rowclass) :cssText(rowArgs.rowstyle) :attr('id', rowArgs.rowid) :tag('th') :attr('colspan', 2) :attr('id', rowArgs.headerid) :addClass(rowArgs.class) :addClass(args.headerclass) :css('text-align', 'center') :cssText(args.headerstyle) :cssText(rowArgs.rowcellstyle) :wikitext(fixChildBoxes(rowArgs.header, 'th')) elseif rowArgs.data then local row = root:tag('tr') row:addClass(rowArgs.rowclass) row:cssText(rowArgs.rowstyle) row:attr('id', rowArgs.rowid) if rowArgs.label then row :tag('th') :attr('scope', 'row') :attr('id', rowArgs.labelid) :cssText(args.labelstyle) :cssText(rowArgs.rowcellstyle) :wikitext(rowArgs.label) :done() end local dataCell = row:tag('td') if not rowArgs.label then dataCell :attr('colspan', 2) :css('text-align', 'center') end dataCell :attr('id', rowArgs.dataid) :addClass(rowArgs.class) :cssText(rowArgs.datastyle) :cssText(rowArgs.rowcellstyle) :wikitext(fixChildBoxes(rowArgs.data, 'td')) end end local function renderTitle() if not args.title then return end root :tag('caption') :addClass(args.titleclass) :cssText(args.titlestyle) :wikitext(args.title) end local function renderAboveRow() if not args.above then return end root :tag('tr') :tag('th') :attr('colspan', 2) :addClass(args.aboveclass) :css('text-align', 'center') :css('font-size', '125%') :css('font-weight', 'bold') :cssText(args.abovestyle) :wikitext(fixChildBoxes(args.above,'th')) end local function renderBelowRow() if not args.below then return end root :tag('tr') :tag('td') :attr('colspan', '2') :addClass(args.belowclass) :css('text-align', 'center') :cssText(args.belowstyle) :wikitext(fixChildBoxes(args.below,'td')) end local function renderSubheaders() if args.subheader then args.subheader1 = args.subheader end if args.subheaderrowclass then args.subheaderrowclass1 = args.subheaderrowclass end local subheadernums = getArgNums('subheader') for k, num in ipairs(subheadernums) do addRow({ data = args['subheader' .. tostring(num)], datastyle = args.subheaderstyle, rowcellstyle = args['subheaderstyle' .. tostring(num)], class = args.subheaderclass, rowclass = args['subheaderrowclass' .. tostring(num)] }) end end local function renderImages() if args.image then args.image1 = args.image end if args.caption then args.caption1 = args.caption end local imagenums = getArgNums('image') for k, num in ipairs(imagenums) do local caption = args['caption' .. tostring(num)] local data = mw.html.create():wikitext(args['image' .. tostring(num)]) if caption then data :tag('div') :cssText(args.captionstyle) :wikitext(caption) end addRow({ data = tostring(data), datastyle = args.imagestyle, class = args.imageclass, rowclass = args['imagerowclass' .. tostring(num)] }) end end local function renderRows() -- Gets the union of the header and data argument numbers, -- and renders them all in order using addRow. local rownums = union(getArgNums('header'), getArgNums('data')) table.sort(rownums) for k, num in ipairs(rownums) do addRow({ header = args['header' .. tostring(num)], label = args['label' .. tostring(num)], data = args['data' .. tostring(num)], datastyle = args.datastyle, class = args['class' .. tostring(num)], rowclass = args['rowclass' .. tostring(num)], rowstyle = args['rowstyle' .. tostring(num)], rowcellstyle = args['rowcellstyle' .. tostring(num)], dataid = args['dataid' .. tostring(num)], labelid = args['labelid' .. tostring(num)], headerid = args['headerid' .. tostring(num)], rowid = args['rowid' .. tostring(num)] }) end end local function renderNavBar() if not args.name then return end root :tag('tr') :tag('td') :attr('colspan', '2') :css('text-align', 'right') :wikitext(navbar{ args.name, mini = 1, }) end local function renderItalicTitle() local italicTitle = args['italic title'] and mw.ustring.lower(args['italic title']) if italicTitle == or italicTitle == 'force' or italicTitle == 'yes' then root:wikitext(mw.getCurrentFrame():expandTemplate({title = 'italic title'})) end end local function renderTrackingCategories() if args.decat ~= 'yes' then if args.child == 'yes' then if args.title then root:wikitext() end elseif #(getArgNums('data')) == 0 and mw.title.getCurrentTitle().namespace == 0 then root:wikitext() end end end local function _infobox() -- Specify the overall layout of the infobox, with special settings -- if the infobox is used as a 'child' inside another infobox. if args.child ~= 'yes' then root = mw.html.create('table') root :addClass((args.subbox ~= 'yes') and 'infobox' or nil) :addClass(args.bodyclass) if args.subbox == 'yes' then root :css('padding', '0') :css('border', 'none') :css('margin', '-3px') :css('width', 'auto') :css('min-width', '100%') :css('font-size', '100%') :css('clear', 'none') :css('float', 'none') :css('background-color', 'transparent') else root :css('width', '22em') end root :cssText(args.bodystyle) renderTitle() renderAboveRow() else root = mw.html.create() root :wikitext(args.title) end renderSubheaders() renderImages() renderRows() renderBelowRow() renderNavBar() renderItalicTitle() renderTrackingCategories() return tostring(root) end local function preprocessSingleArg(argName) -- If the argument exists and isn't blank, add it to the argument table. -- Blank arguments are treated as nil to match the behaviour of ParserFunctions. if origArgs[argName] and origArgs[argName] ~= then args[argName] = origArgs[argName] end end local function preprocessArgs(prefixTable, step) -- Assign the parameters with the given prefixes to the args table, in order, in batches -- of the step size specified. This is to prevent references etc. from appearing in the -- wrong order. The prefixTable should be an array containing tables, each of which has -- two possible fields, a "prefix" string and a "depend" table. The function always parses -- parameters containing the "prefix" string, but only parses parameters in the "depend" -- table if the prefix parameter is present and non-blank. if type(prefixTable) ~= 'table' then error("Non-table value detected for the prefix table", 2) end if type(step) ~= 'number' then error("Invalid step value detected", 2) end -- Get arguments without a number suffix, and check for bad input. for i,v in ipairs(prefixTable) do if type(v) ~= 'table' or type(v.prefix) ~= "string" or (v.depend and type(v.depend) ~= 'table') then error('Invalid input detected to preprocessArgs prefix table', 2) end preprocessSingleArg(v.prefix) -- Only parse the depend parameter if the prefix parameter is present and not blank. if args[v.prefix] and v.depend then for j, dependValue in ipairs(v.depend) do if type(dependValue) ~= 'string' then error('Invalid "depend" parameter value detected in preprocessArgs') end preprocessSingleArg(dependValue) end end end -- Get arguments with number suffixes. local a = 1 -- Counter variable. local moreArgumentsExist = true while moreArgumentsExist == true do moreArgumentsExist = false for i = a, a + step - 1 do for j,v in ipairs(prefixTable) do local prefixArgName = v.prefix .. tostring(i) if origArgs[prefixArgName] then moreArgumentsExist = true -- Do another loop if any arguments are found, even blank ones. preprocessSingleArg(prefixArgName) end -- Process the depend table if the prefix argument is present and not blank, or -- we are processing "prefix1" and "prefix" is present and not blank, and -- if the depend table is present. if v.depend and (args[prefixArgName] or (i == 1 and args[v.prefix])) then for j,dependValue in ipairs(v.depend) do local dependArgName = dependValue .. tostring(i) preprocessSingleArg(dependArgName) end end end end a = a + step end end function p.infobox(frame) -- If called via #invoke, use the args passed into the invoking template. -- Otherwise, for testing purposes, assume args are being passed directly in. if frame == mw.getCurrentFrame() then origArgs = frame:getParent().args else origArgs = frame end -- Parse the data parameters in the same order that the old Ciclo de predefinições detectado: Predefinição:Infobox did, so that -- references etc. will display in the expected places. Parameters that depend on -- another parameter are only processed if that parameter is present, to avoid -- phantom references appearing in article reference lists. preprocessSingleArg('child') preprocessSingleArg('bodyclass') preprocessSingleArg('subbox') preprocessSingleArg('bodystyle') preprocessSingleArg('title') preprocessSingleArg('titleclass') preprocessSingleArg('titlestyle') preprocessSingleArg('above') preprocessSingleArg('aboveclass') preprocessSingleArg('abovestyle') preprocessArgs({ {prefix = 'subheader', depend = {'subheaderstyle', 'subheaderrowclass'}} }, 10) preprocessSingleArg('subheaderstyle') preprocessSingleArg('subheaderclass') preprocessArgs({ {prefix = 'image', depend = {'caption', 'imagerowclass'}} }, 10) preprocessSingleArg('captionstyle') preprocessSingleArg('imagestyle') preprocessSingleArg('imageclass') preprocessArgs({ {prefix = 'header'}, {prefix = 'data', depend = {'label'}}, {prefix = 'rowclass'}, {prefix = 'rowstyle'}, {prefix = 'rowcellstyle'}, {prefix = 'class'}, {prefix = 'dataid'}, {prefix = 'labelid'}, {prefix = 'headerid'}, {prefix = 'rowid'} }, 50) preprocessSingleArg('headerclass') preprocessSingleArg('headerstyle') preprocessSingleArg('labelstyle') preprocessSingleArg('datastyle') preprocessSingleArg('below') preprocessSingleArg('belowclass') preprocessSingleArg('belowstyle') preprocessSingleArg('name') args['italic title'] = origArgs['italic title'] -- different behaviour if blank or absent preprocessSingleArg('decat') return _infobox() end return p -- local p = {} local navbar = require('Module:Navbar')._navbar local args = {} local origArgs local root local function notempty( s ) return s and s:match( '%S' ) end local function fixChildBoxes(sval, tt) if notempty(sval) then local marker = '' local s = sval s = mw.ustring.gsub(s, '(<%s*[Tt][Rr])', marker .. '%1') s = mw.ustring.gsub(s, '(</[Tt][Rr]%s*>)', '%1' .. marker) if s:match(marker) then s = mw.ustring.gsub(s, marker .. '%s*' .. marker, ) s = mw.ustring.gsub(s, '([\r\n]|-[^\r\n]*[\r\n])%s*' .. marker, '%1') s = mw.ustring.gsub(s, marker .. '%s*([\r\n]|-)', '%1') s = mw.ustring.gsub(s, '(</[Cc][Aa][Pp][Tt][Ii][Oo][Nn]%s*>%s*)' .. marker, '%1') s = mw.ustring.gsub(s, '(<%s*[Tt][Aa][Bb][Ll][Ee][^<>]*>%s*)' .. marker, '%1') s = mw.ustring.gsub(s, '^(%{|[^\r\n]*[\r\n]%s*)' .. marker, '%1') s = mw.ustring.gsub(s, '([\r\n]%{|[^\r\n]*[\r\n]%s*)' .. marker, '%1') s = mw.ustring.gsub(s, marker .. '(%s*</[Tt][Aa][Bb][Ll][Ee]%s*>)', '%1') s = mw.ustring.gsub(s, marker .. '(%s*\n|%})', '%1') end if s:match(marker) then local subcells = mw.text.split(s, marker) s = for k = 1, #subcells do if k == 1 then s = s .. subcells[k] .. '</' .. tt .. '>' elseif k == #subcells then local rowstyle = ' style="display:none"' if notempty(subcells[k]) then rowstyle = end s = s .. '<tr' .. rowstyle ..'><' .. tt .. ' colspan=2>\n' .. subcells[k] elseif notempty(subcells[k]) then if (k % 2) == 0 then s = s .. subcells[k] else s = s .. '<' .. tt .. ' colspan=2>\n' .. subcells[k] .. '</' .. tt .. '>' end end end end -- the next two lines add a newline at the end of lists for the PHP parser -- https://en.wikipedia.org/w/index.php?title=Template_talk:Infobox_musical_artist&oldid=849054481 -- remove when phab:T191516 is fixed or OBE s = mw.ustring.gsub(s, '([\r\n][%*#;:][^\r\n]*)$', '%1\n') s = mw.ustring.gsub(s, '^([%*#;:][^\r\n]*)$', '%1\n') s = mw.ustring.gsub(s, '^([%*#;:])', '\n%1') s = mw.ustring.gsub(s, '^(%{%|)', '\n%1') return s else return sval end end local function union(t1, t2) -- Returns the union of the values of two tables, as a sequence. local vals = {} for k, v in pairs(t1) do vals[v] = true end for k, v in pairs(t2) do vals[v] = true end local ret = {} for k, v in pairs(vals) do table.insert(ret, k) end return ret end local function getArgNums(prefix) -- Returns a table containing the numbers of the arguments that exist -- for the specified prefix. For example, if the prefix was 'data', and -- 'data1', 'data2', and 'data5' exist, it would return {1, 2, 5}. local nums = {} for k, v in pairs(args) do local num = tostring(k):match('^' .. prefix .. '([1-9]%d*)$') if num then table.insert(nums, tonumber(num)) end end table.sort(nums) return nums end local function addRow(rowArgs) -- Adds a row to the infobox, with either a header cell -- or a label/data cell combination. if rowArgs.header then root :tag('tr') :addClass(rowArgs.rowclass) :cssText(rowArgs.rowstyle) :attr('id', rowArgs.rowid) :tag('th') :attr('colspan', 2) :attr('id', rowArgs.headerid) :addClass(rowArgs.class) :addClass(args.headerclass) :css('text-align', 'center') :cssText(args.headerstyle) :cssText(rowArgs.rowcellstyle) :wikitext(fixChildBoxes(rowArgs.header, 'th')) elseif rowArgs.data then local row = root:tag('tr') row:addClass(rowArgs.rowclass) row:cssText(rowArgs.rowstyle) row:attr('id', rowArgs.rowid) if rowArgs.label then row :tag('th') :attr('scope', 'row') :attr('id', rowArgs.labelid) :cssText(args.labelstyle) :cssText(rowArgs.rowcellstyle) :wikitext(rowArgs.label) :done() end local dataCell = row:tag('td') if not rowArgs.label then dataCell :attr('colspan', 2) :css('text-align', 'center') end dataCell :attr('id', rowArgs.dataid) :addClass(rowArgs.class) :cssText(rowArgs.datastyle) :cssText(rowArgs.rowcellstyle) :wikitext(fixChildBoxes(rowArgs.data, 'td')) end end local function renderTitle() if not args.title then return end root :tag('caption') :addClass(args.titleclass) :cssText(args.titlestyle) :wikitext(args.title) end local function renderAboveRow() if not args.above then return end root :tag('tr') :tag('th') :attr('colspan', 2) :addClass(args.aboveclass) :css('text-align', 'center') :css('font-size', '125%') :css('font-weight', 'bold') :cssText(args.abovestyle) :wikitext(fixChildBoxes(args.above,'th')) end local function renderBelowRow() if not args.below then return end root :tag('tr') :tag('td') :attr('colspan', '2') :addClass(args.belowclass) :css('text-align', 'center') :cssText(args.belowstyle) :wikitext(fixChildBoxes(args.below,'td')) end local function renderSubheaders() if args.subheader then args.subheader1 = args.subheader end if args.subheaderrowclass then args.subheaderrowclass1 = args.subheaderrowclass end local subheadernums = getArgNums('subheader') for k, num in ipairs(subheadernums) do addRow({ data = args['subheader' .. tostring(num)], datastyle = args.subheaderstyle, rowcellstyle = args['subheaderstyle' .. tostring(num)], class = args.subheaderclass, rowclass = args['subheaderrowclass' .. tostring(num)] }) end end local function renderImages() if args.image then args.image1 = args.image end if args.caption then args.caption1 = args.caption end local imagenums = getArgNums('image') for k, num in ipairs(imagenums) do local caption = args['caption' .. tostring(num)] local data = mw.html.create():wikitext(args['image' .. tostring(num)]) if caption then data :tag('div') :cssText(args.captionstyle) :wikitext(caption) end addRow({ data = tostring(data), datastyle = args.imagestyle, class = args.imageclass, rowclass = args['imagerowclass' .. tostring(num)] }) end end local function renderRows() -- Gets the union of the header and data argument numbers, -- and renders them all in order using addRow. local rownums = union(getArgNums('header'), getArgNums('data')) table.sort(rownums) for k, num in ipairs(rownums) do addRow({ header = args['header' .. tostring(num)], label = args['label' .. tostring(num)], data = args['data' .. tostring(num)], datastyle = args.datastyle, class = args['class' .. tostring(num)], rowclass = args['rowclass' .. tostring(num)], rowstyle = args['rowstyle' .. tostring(num)], rowcellstyle = args['rowcellstyle' .. tostring(num)], dataid = args['dataid' .. tostring(num)], labelid = args['labelid' .. tostring(num)], headerid = args['headerid' .. tostring(num)], rowid = args['rowid' .. tostring(num)] }) end end local function renderNavBar() if not args.name then return end root :tag('tr') :tag('td') :attr('colspan', '2') :css('text-align', 'right') :wikitext(navbar{ args.name, mini = 1, }) end local function renderItalicTitle() local italicTitle = args['italic title'] and mw.ustring.lower(args['italic title']) if italicTitle == or italicTitle == 'force' or italicTitle == 'yes' then root:wikitext(mw.getCurrentFrame():expandTemplate({title = 'italic title'})) end end local function renderTrackingCategories() if args.decat ~= 'yes' then if args.child == 'yes' then if args.title then root:wikitext() end elseif #(getArgNums('data')) == 0 and mw.title.getCurrentTitle().namespace == 0 then root:wikitext() end end end local function _infobox() -- Specify the overall layout of the infobox, with special settings -- if the infobox is used as a 'child' inside another infobox. if args.child ~= 'yes' then root = mw.html.create('table') root :addClass((args.subbox ~= 'yes') and 'infobox' or nil) :addClass(args.bodyclass) if args.subbox == 'yes' then root :css('padding', '0') :css('border', 'none') :css('margin', '-3px') :css('width', 'auto') :css('min-width', '100%') :css('font-size', '100%') :css('clear', 'none') :css('float', 'none') :css('background-color', 'transparent') else root :css('width', '22em') end root :cssText(args.bodystyle) renderTitle() renderAboveRow() else root = mw.html.create() root :wikitext(args.title) end renderSubheaders() renderImages() renderRows() renderBelowRow() renderNavBar() renderItalicTitle() renderTrackingCategories() return tostring(root) end local function preprocessSingleArg(argName) -- If the argument exists and isn't blank, add it to the argument table. -- Blank arguments are treated as nil to match the behaviour of ParserFunctions. if origArgs[argName] and origArgs[argName] ~= then args[argName] = origArgs[argName] end end local function preprocessArgs(prefixTable, step) -- Assign the parameters with the given prefixes to the args table, in order, in batches -- of the step size specified. This is to prevent references etc. from appearing in the -- wrong order. The prefixTable should be an array containing tables, each of which has -- two possible fields, a "prefix" string and a "depend" table. The function always parses -- parameters containing the "prefix" string, but only parses parameters in the "depend" -- table if the prefix parameter is present and non-blank. if type(prefixTable) ~= 'table' then error("Non-table value detected for the prefix table", 2) end if type(step) ~= 'number' then error("Invalid step value detected", 2) end -- Get arguments without a number suffix, and check for bad input. for i,v in ipairs(prefixTable) do if type(v) ~= 'table' or type(v.prefix) ~= "string" or (v.depend and type(v.depend) ~= 'table') then error('Invalid input detected to preprocessArgs prefix table', 2) end preprocessSingleArg(v.prefix) -- Only parse the depend parameter if the prefix parameter is present and not blank. if args[v.prefix] and v.depend then for j, dependValue in ipairs(v.depend) do if type(dependValue) ~= 'string' then error('Invalid "depend" parameter value detected in preprocessArgs') end preprocessSingleArg(dependValue) end end end -- Get arguments with number suffixes. local a = 1 -- Counter variable. local moreArgumentsExist = true while moreArgumentsExist == true do moreArgumentsExist = false for i = a, a + step - 1 do for j,v in ipairs(prefixTable) do local prefixArgName = v.prefix .. tostring(i) if origArgs[prefixArgName] then moreArgumentsExist = true -- Do another loop if any arguments are found, even blank ones. preprocessSingleArg(prefixArgName) end -- Process the depend table if the prefix argument is present and not blank, or -- we are processing "prefix1" and "prefix" is present and not blank, and -- if the depend table is present. if v.depend and (args[prefixArgName] or (i == 1 and args[v.prefix])) then for j,dependValue in ipairs(v.depend) do local dependArgName = dependValue .. tostring(i) preprocessSingleArg(dependArgName) end end end end a = a + step end end function p.infobox(frame) -- If called via #invoke, use the args passed into the invoking template. -- Otherwise, for testing purposes, assume args are being passed directly in. if frame == mw.getCurrentFrame() then origArgs = frame:getParent().args else origArgs = frame end -- Parse the data parameters in the same order that the old -- -- This module implements Ciclo de predefinições detectado: Predefinição:Infobox -- local p = {} local navbar = require('Module:Navbar')._navbar local args = {} local origArgs local root local function notempty( s ) return s and s:match( '%S' ) end local function fixChildBoxes(sval, tt) if notempty(sval) then local marker = '' local s = sval s = mw.ustring.gsub(s, '(<%s*[Tt][Rr])', marker .. '%1') s = mw.ustring.gsub(s, '(</[Tt][Rr]%s*>)', '%1' .. marker) if s:match(marker) then s = mw.ustring.gsub(s, marker .. '%s*' .. marker, ) s = mw.ustring.gsub(s, '([\r\n]|-[^\r\n]*[\r\n])%s*' .. marker, '%1') s = mw.ustring.gsub(s, marker .. '%s*([\r\n]|-)', '%1') s = mw.ustring.gsub(s, '(</[Cc][Aa][Pp][Tt][Ii][Oo][Nn]%s*>%s*)' .. marker, '%1') s = mw.ustring.gsub(s, '(<%s*[Tt][Aa][Bb][Ll][Ee][^<>]*>%s*)' .. marker, '%1') s = mw.ustring.gsub(s, '^(%{|[^\r\n]*[\r\n]%s*)' .. marker, '%1') s = mw.ustring.gsub(s, '([\r\n]%{|[^\r\n]*[\r\n]%s*)' .. marker, '%1') s = mw.ustring.gsub(s, marker .. '(%s*</[Tt][Aa][Bb][Ll][Ee]%s*>)', '%1') s = mw.ustring.gsub(s, marker .. '(%s*\n|%})', '%1') end if s:match(marker) then local subcells = mw.text.split(s, marker) s = for k = 1, #subcells do if k == 1 then s = s .. subcells[k] .. '</' .. tt .. '>' elseif k == #subcells then local rowstyle = ' style="display:none"' if notempty(subcells[k]) then rowstyle = end s = s .. '<tr' .. rowstyle ..'><' .. tt .. ' colspan=2>\n' .. subcells[k] elseif notempty(subcells[k]) then if (k % 2) == 0 then s = s .. subcells[k] else s = s .. '<' .. tt .. ' colspan=2>\n' .. subcells[k] .. '</' .. tt .. '>' end end end end -- the next two lines add a newline at the end of lists for the PHP parser -- https://en.wikipedia.org/w/index.php?title=Template_talk:Infobox_musical_artist&oldid=849054481 -- remove when phab:T191516 is fixed or OBE s = mw.ustring.gsub(s, '([\r\n][%*#;:][^\r\n]*)$', '%1\n') s = mw.ustring.gsub(s, '^([%*#;:][^\r\n]*)$', '%1\n') s = mw.ustring.gsub(s, '^([%*#;:])', '\n%1') s = mw.ustring.gsub(s, '^(%{%|)', '\n%1') return s else return sval end end local function union(t1, t2) -- Returns the union of the values of two tables, as a sequence. local vals = {} for k, v in pairs(t1) do vals[v] = true end for k, v in pairs(t2) do vals[v] = true end local ret = {} for k, v in pairs(vals) do table.insert(ret, k) end return ret end local function getArgNums(prefix) -- Returns a table containing the numbers of the arguments that exist -- for the specified prefix. For example, if the prefix was 'data', and -- 'data1', 'data2', and 'data5' exist, it would return {1, 2, 5}. local nums = {} for k, v in pairs(args) do local num = tostring(k):match('^' .. prefix .. '([1-9]%d*)$') if num then table.insert(nums, tonumber(num)) end end table.sort(nums) return nums end local function addRow(rowArgs) -- Adds a row to the infobox, with either a header cell -- or a label/data cell combination. if rowArgs.header then root :tag('tr') :addClass(rowArgs.rowclass) :cssText(rowArgs.rowstyle) :attr('id', rowArgs.rowid) :tag('th') :attr('colspan', 2) :attr('id', rowArgs.headerid) :addClass(rowArgs.class) :addClass(args.headerclass) :css('text-align', 'center') :cssText(args.headerstyle) :cssText(rowArgs.rowcellstyle) :wikitext(fixChildBoxes(rowArgs.header, 'th')) elseif rowArgs.data then local row = root:tag('tr') row:addClass(rowArgs.rowclass) row:cssText(rowArgs.rowstyle) row:attr('id', rowArgs.rowid) if rowArgs.label then row :tag('th') :attr('scope', 'row') :attr('id', rowArgs.labelid) :cssText(args.labelstyle) :cssText(rowArgs.rowcellstyle) :wikitext(rowArgs.label) :done() end local dataCell = row:tag('td') if not rowArgs.label then dataCell :attr('colspan', 2) :css('text-align', 'center') end dataCell :attr('id', rowArgs.dataid) :addClass(rowArgs.class) :cssText(rowArgs.datastyle) :cssText(rowArgs.rowcellstyle) :wikitext(fixChildBoxes(rowArgs.data, 'td')) end end local function renderTitle() if not args.title then return end root :tag('caption') :addClass(args.titleclass) :cssText(args.titlestyle) :wikitext(args.title) end local function renderAboveRow() if not args.above then return end root :tag('tr') :tag('th') :attr('colspan', 2) :addClass(args.aboveclass) :css('text-align', 'center') :css('font-size', '125%') :css('font-weight', 'bold') :cssText(args.abovestyle) :wikitext(fixChildBoxes(args.above,'th')) end local function renderBelowRow() if not args.below then return end root :tag('tr') :tag('td') :attr('colspan', '2') :addClass(args.belowclass) :css('text-align', 'center') :cssText(args.belowstyle) :wikitext(fixChildBoxes(args.below,'td')) end local function renderSubheaders() if args.subheader then args.subheader1 = args.subheader end if args.subheaderrowclass then args.subheaderrowclass1 = args.subheaderrowclass end local subheadernums = getArgNums('subheader') for k, num in ipairs(subheadernums) do addRow({ data = args['subheader' .. tostring(num)], datastyle = args.subheaderstyle, rowcellstyle = args['subheaderstyle' .. tostring(num)], class = args.subheaderclass, rowclass = args['subheaderrowclass' .. tostring(num)] }) end end local function renderImages() if args.image then args.image1 = args.image end if args.caption then args.caption1 = args.caption end local imagenums = getArgNums('image') for k, num in ipairs(imagenums) do local caption = args['caption' .. tostring(num)] local data = mw.html.create():wikitext(args['image' .. tostring(num)]) if caption then data :tag('div') :cssText(args.captionstyle) :wikitext(caption) end addRow({ data = tostring(data), datastyle = args.imagestyle, class = args.imageclass, rowclass = args['imagerowclass' .. tostring(num)] }) end end local function renderRows() -- Gets the union of the header and data argument numbers, -- and renders them all in order using addRow. local rownums = union(getArgNums('header'), getArgNums('data')) table.sort(rownums) for k, num in ipairs(rownums) do addRow({ header = args['header' .. tostring(num)], label = args['label' .. tostring(num)], data = args['data' .. tostring(num)], datastyle = args.datastyle, class = args['class' .. tostring(num)], rowclass = args['rowclass' .. tostring(num)], rowstyle = args['rowstyle' .. tostring(num)], rowcellstyle = args['rowcellstyle' .. tostring(num)], dataid = args['dataid' .. tostring(num)], labelid = args['labelid' .. tostring(num)], headerid = args['headerid' .. tostring(num)], rowid = args['rowid' .. tostring(num)] }) end end local function renderNavBar() if not args.name then return end root :tag('tr') :tag('td') :attr('colspan', '2') :css('text-align', 'right') :wikitext(navbar{ args.name, mini = 1, }) end local function renderItalicTitle() local italicTitle = args['italic title'] and mw.ustring.lower(args['italic title']) if italicTitle == or italicTitle == 'force' or italicTitle == 'yes' then root:wikitext(mw.getCurrentFrame():expandTemplate({title = 'italic title'})) end end local function renderTrackingCategories() if args.decat ~= 'yes' then if args.child == 'yes' then if args.title then root:wikitext() end elseif #(getArgNums('data')) == 0 and mw.title.getCurrentTitle().namespace == 0 then root:wikitext() end end end local function _infobox() -- Specify the overall layout of the infobox, with special settings -- if the infobox is used as a 'child' inside another infobox. if args.child ~= 'yes' then root = mw.html.create('table') root :addClass((args.subbox ~= 'yes') and 'infobox' or nil) :addClass(args.bodyclass) if args.subbox == 'yes' then root :css('padding', '0') :css('border', 'none') :css('margin', '-3px') :css('width', 'auto') :css('min-width', '100%') :css('font-size', '100%') :css('clear', 'none') :css('float', 'none') :css('background-color', 'transparent') else root :css('width', '22em') end root :cssText(args.bodystyle) renderTitle() renderAboveRow() else root = mw.html.create() root :wikitext(args.title) end renderSubheaders() renderImages() renderRows() renderBelowRow() renderNavBar() renderItalicTitle() renderTrackingCategories() return tostring(root) end local function preprocessSingleArg(argName) -- If the argument exists and isn't blank, add it to the argument table. -- Blank arguments are treated as nil to match the behaviour of ParserFunctions. if origArgs[argName] and origArgs[argName] ~= then args[argName] = origArgs[argName] end end local function preprocessArgs(prefixTable, step) -- Assign the parameters with the given prefixes to the args table, in order, in batches -- of the step size specified. This is to prevent references etc. from appearing in the -- wrong order. The prefixTable should be an array containing tables, each of which has -- two possible fields, a "prefix" string and a "depend" table. The function always parses -- parameters containing the "prefix" string, but only parses parameters in the "depend" -- table if the prefix parameter is present and non-blank. if type(prefixTable) ~= 'table' then error("Non-table value detected for the prefix table", 2) end if type(step) ~= 'number' then error("Invalid step value detected", 2) end -- Get arguments without a number suffix, and check for bad input. for i,v in ipairs(prefixTable) do if type(v) ~= 'table' or type(v.prefix) ~= "string" or (v.depend and type(v.depend) ~= 'table') then error('Invalid input detected to preprocessArgs prefix table', 2) end preprocessSingleArg(v.prefix) -- Only parse the depend parameter if the prefix parameter is present and not blank. if args[v.prefix] and v.depend then for j, dependValue in ipairs(v.depend) do if type(dependValue) ~= 'string' then error('Invalid "depend" parameter value detected in preprocessArgs') end preprocessSingleArg(dependValue) end end end -- Get arguments with number suffixes. local a = 1 -- Counter variable. local moreArgumentsExist = true while moreArgumentsExist == true do moreArgumentsExist = false for i = a, a + step - 1 do for j,v in ipairs(prefixTable) do local prefixArgName = v.prefix .. tostring(i) if origArgs[prefixArgName] then moreArgumentsExist = true -- Do another loop if any arguments are found, even blank ones. preprocessSingleArg(prefixArgName) end -- Process the depend table if the prefix argument is present and not blank, or -- we are processing "prefix1" and "prefix" is present and not blank, and -- if the depend table is present. if v.depend and (args[prefixArgName] or (i == 1 and args[v.prefix])) then for j,dependValue in ipairs(v.depend) do local dependArgName = dependValue .. tostring(i) preprocessSingleArg(dependArgName) end end end end a = a + step end end function p.infobox(frame) -- If called via #invoke, use the args passed into the invoking template. -- Otherwise, for testing purposes, assume args are being passed directly in. if frame == mw.getCurrentFrame() then origArgs = frame:getParent().args else origArgs = frame end -- Parse the data parameters in the same order that the old Ciclo de predefinições detectado: Predefinição:Infobox did, so that -- references etc. will display in the expected places. Parameters that depend on -- another parameter are only processed if that parameter is present, to avoid -- phantom references appearing in article reference lists. preprocessSingleArg('child') preprocessSingleArg('bodyclass') preprocessSingleArg('subbox') preprocessSingleArg('bodystyle') preprocessSingleArg('title') preprocessSingleArg('titleclass') preprocessSingleArg('titlestyle') preprocessSingleArg('above') preprocessSingleArg('aboveclass') preprocessSingleArg('abovestyle') preprocessArgs({ {prefix = 'subheader', depend = {'subheaderstyle', 'subheaderrowclass'}} }, 10) preprocessSingleArg('subheaderstyle') preprocessSingleArg('subheaderclass') preprocessArgs({ {prefix = 'image', depend = {'caption', 'imagerowclass'}} }, 10) preprocessSingleArg('captionstyle') preprocessSingleArg('imagestyle') preprocessSingleArg('imageclass') preprocessArgs({ {prefix = 'header'}, {prefix = 'data', depend = {'label'}}, {prefix = 'rowclass'}, {prefix = 'rowstyle'}, {prefix = 'rowcellstyle'}, {prefix = 'class'}, {prefix = 'dataid'}, {prefix = 'labelid'}, {prefix = 'headerid'}, {prefix = 'rowid'} }, 50) preprocessSingleArg('headerclass') preprocessSingleArg('headerstyle') preprocessSingleArg('labelstyle') preprocessSingleArg('datastyle') preprocessSingleArg('below') preprocessSingleArg('belowclass') preprocessSingleArg('belowstyle') preprocessSingleArg('name') args['italic title'] = origArgs['italic title'] -- different behaviour if blank or absent preprocessSingleArg('decat') return _infobox() end return p did, so that -- references etc. will display in the expected places. Parameters that depend on -- another parameter are only processed if that parameter is present, to avoid -- phantom references appearing in article reference lists. preprocessSingleArg('child') preprocessSingleArg('bodyclass') preprocessSingleArg('subbox') preprocessSingleArg('bodystyle') preprocessSingleArg('title') preprocessSingleArg('titleclass') preprocessSingleArg('titlestyle') preprocessSingleArg('above') preprocessSingleArg('aboveclass') preprocessSingleArg('abovestyle') preprocessArgs({ {prefix = 'subheader', depend = {'subheaderstyle', 'subheaderrowclass'}} }, 10) preprocessSingleArg('subheaderstyle') preprocessSingleArg('subheaderclass') preprocessArgs({ {prefix = 'image', depend = {'caption', 'imagerowclass'}} }, 10) preprocessSingleArg('captionstyle') preprocessSingleArg('imagestyle') preprocessSingleArg('imageclass') preprocessArgs({ {prefix = 'header'}, {prefix = 'data', depend = {'label'}}, {prefix = 'rowclass'}, {prefix = 'rowstyle'}, {prefix = 'rowcellstyle'}, {prefix = 'class'}, {prefix = 'dataid'}, {prefix = 'labelid'}, {prefix = 'headerid'}, {prefix = 'rowid'} }, 50) preprocessSingleArg('headerclass') preprocessSingleArg('headerstyle') preprocessSingleArg('labelstyle') preprocessSingleArg('datastyle') preprocessSingleArg('below') preprocessSingleArg('belowclass') preprocessSingleArg('belowstyle') preprocessSingleArg('name') args['italic title'] = origArgs['italic title'] -- different behaviour if blank or absent preprocessSingleArg('decat') return _infobox() end return p