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

De Office System
Ir para navegação Ir para pesquisar
Linha 1: Linha 1:
<includeonly>{{Info
+
local p = {}
|infobox = sim
+
 
|classe = infobox {{{bodyclass|}}}  
+
local navbar = require('Module:Navbar')._navbar
|estilo = width: {{{tamanho|24em}}}; text-align: left; font-size: 88%; line-height: 1.5em; {{{bodystyle|}}}
+
 
|espaço_entre_células = {{#if:{{{cellpadding|}}}|{{{cellpadding|}}}|5}}
+
local args = {}
|espaço_conteúdo-borda_das_células = {{#if:{{{cellspacing|}}}|{{{cellspacing|}}}|0}}
+
local origArgs
|cabeçalho = {{{title|}}}
+
local root
|cabeçalho-classe = {{{titleclass|}}}
+
 
|cabeçalho-estilo = font-size: 125%; font-weight: bold; {{{titlestyle|}}}
+
local function notempty( s ) return s and s:match( '%S' ) end
|título = {{{above|}}}
+
 
|título-classe = {{{aboveclass|}}}
+
local function fixChildBoxes(sval, tt)
|título-estilo = text-align:center; font-size: 125%; font-weight: bold; {{{abovestyle|}}}
+
if notempty(sval) then
|subtítulo1 = {{{subheader|{{{subheader1|}}}}}}}
+
local marker = '<span class=special_infobox_marker>'
|subtítulo1-classe = {{{subheaderclass|}}}
+
local s = sval
|subtítulo1-estilo = text-align:center; {{{subheaderstyle|}}}
+
s = mw.ustring.gsub(s, '(<%s*[Tt][Rr])', marker .. '%1')
|subtítulo2 = {{{subheader2|}}}
+
s = mw.ustring.gsub(s, '(</[Tt][Rr]%s*>)', '%1' .. marker)
|subtítulo2-classe = {{{subheaderclass|}}}
+
if s:match(marker) then
|subtítulo2-estilo = text-align:center; {{{subheaderstyle|}}}
+
s = mw.ustring.gsub(s, marker .. '%s*' .. marker, '')
|imagem = {{{image|}}}{{{imagem|}}}
+
s = mw.ustring.gsub(s, '([\r\n]|-[^\r\n]*[\r\n])%s*' .. marker, '%1')
|imagem-tamanho = {{{imagem-tamanho|}}}
+
s = mw.ustring.gsub(s, marker .. '%s*([\r\n]|-)', '%1')
|imagem-estilo = text-align:center; {{{imagestyle|}}}
+
s = mw.ustring.gsub(s, '(</[Cc][Aa][Pp][Tt][Ii][Oo][Nn]%s*>%s*)' .. marker, '%1')
|legenda = {{{caption|}}}
+
s = mw.ustring.gsub(s, '(<%s*[Tt][Aa][Bb][Ll][Ee][^<>]*>%s*)' .. marker, '%1')
|legenda-estilo = {{{captionstyle|}}}
+
s = mw.ustring.gsub(s, '^(%{|[^\r\n]*[\r\n]%s*)' .. marker, '%1')
|imagem1 = {{{imagem2|}}}
+
s = mw.ustring.gsub(s, '([\r\n]%{|[^\r\n]*[\r\n]%s*)' .. marker, '%1')
|imagem-tamanho1 = {{{size2|}}}
+
s = mw.ustring.gsub(s,  marker .. '(%s*</[Tt][Aa][Bb][Ll][Ee]%s*>)', '%1')
|legenda1 = {{{caption2|}}}
+
s = mw.ustring.gsub(s,  marker .. '(%s*\n|%})', '%1')
|legenda-estilo1 = {{{abelstyle2|}}}
+
end
|tópico-estilo = {{{headerstyle|}}}  
+
if s:match(marker) then
|rótulo-estilo = {{{labelstyle|}}}  
+
local subcells = mw.text.split(s, marker)
|dados-estilo = {{{datastyle|}}}  
+
s = ''
|classe1 = {{{class1|}}}  
+
for k = 1, #subcells do
|tópico1 = {{{header1|}}}
+
if k == 1 then
|rótulo1 = {{{label1|}}}
+
s = s .. subcells[k] .. '</' .. tt .. '></tr>'
|dados1 = {{{data1|}}}
+
elseif k == #subcells then
|classe2 = {{{class2|}}}
+
local rowstyle = ' style="display:none"'
|tópico2 = {{{header2|}}}
+
if notempty(subcells[k]) then rowstyle = '' end
|rótulo2 = {{{label2|}}}
+
s = s .. '<tr' .. rowstyle ..'><' .. tt .. ' colspan=2>\n' .. subcells[k]
|dados2 = {{{data2|}}}
+
elseif notempty(subcells[k]) then
|classe3 = {{{class3|}}}
+
if (k % 2) == 0 then
|tópico3 = {{{header3|}}}
+
s = s .. subcells[k]
|rótulo3 = {{{label3|}}}
+
else
|dados3 = {{{data3|}}}
+
s = s .. '<tr><' .. tt .. ' colspan=2>\n' .. subcells[k] .. '</' .. tt .. '></tr>'
|classe4 = {{{class4|}}}
+
end
|tópico4 = {{{header4|}}}
+
end
|rótulo4 = {{{label4|}}}
+
end
|dados4 = {{{data4|}}}
+
end
|classe5 = {{{class5|}}}
+
-- the next two lines add a newline at the end of lists for the PHP parser
|tópico5 = {{{header5|}}}
+
-- https://en.wikipedia.org/w/index.php?title=Template_talk:Infobox_musical_artist&oldid=849054481
|rótulo5 = {{{label5|}}}
+
-- remove when [[:phab:T191516]] is fixed or OBE
|dados5 = {{{data5|}}}
+
s = mw.ustring.gsub(s, '([\r\n][%*#;:][^\r\n]*)$', '%1\n')
|classe6 = {{{class6|}}}
+
s = mw.ustring.gsub(s, '^([%*#;:][^\r\n]*)$', '%1\n')
|tópico6 = {{{header6|}}}
+
s = mw.ustring.gsub(s, '^([%*#;:])', '\n%1')
|rótulo6 = {{{label6|}}}
+
s = mw.ustring.gsub(s, '^(%{%|)', '\n%1')
|dados6 = {{{data6|}}}
+
return s
|classe7 = {{{class7|}}}
+
else
|tópico7 = {{{header7|}}}
+
return sval
|rótulo7 = {{{label7|}}}
+
end
|dados7 = {{{data7|}}}
+
end
|classe8 = {{{class8|}}}
+
 
|tópico8 = {{{header8|}}}
+
local function union(t1, t2)
|rótulo8 = {{{label8|}}}
+
    -- Returns the union of the values of two tables, as a sequence.
|dados8 = {{{data8|}}}
+
    local vals = {}
|classe9 = {{{class9|}}}
+
    for k, v in pairs(t1) do
|tópico9 = {{{header9|}}}
+
        vals[v] = true
|rótulo9 = {{{label9|}}}
+
    end
|dados9 = {{{data9|}}}
+
    for k, v in pairs(t2) do
|classe10 = {{{class10|}}}
+
        vals[v] = true
|tópico10 = {{{header10|}}}
+
    end
|rótulo10 = {{{label10|}}}
+
    local ret = {}
|dados10 = {{{data10|}}}
+
    for k, v in pairs(vals) do
|classe11 = {{{class11|}}}
+
        table.insert(ret, k)
|tópico11 = {{{header11|}}}
+
    end
|rótulo11 = {{{label11|}}}
+
    return ret
|dados11 = {{{data11|}}}
+
end
|classe12 = {{{class12|}}}
+
 
|tópico12 = {{{header12|}}}
+
local function getArgNums(prefix)
|rótulo12 = {{{label12|}}}
+
    -- Returns a table containing the numbers of the arguments that exist
|dados12 = {{{data12|}}}
+
    -- for the specified prefix. For example, if the prefix was 'data', and
|classe13 = {{{class13|}}}
+
    -- 'data1', 'data2', and 'data5' exist, it would return {1, 2, 5}.
|tópico13 = {{{header13|}}}
+
    local nums = {}
|rótulo13 = {{{label13|}}}
+
    for k, v in pairs(args) do
|dados13 = {{{data13|}}}
+
        local num = tostring(k):match('^' .. prefix .. '([1-9]%d*)$')
|classe14 = {{{class14|}}}
+
        if num then table.insert(nums, tonumber(num)) end
|tópico14 = {{{header14|}}}
+
    end
|rótulo14 = {{{label14|}}}
+
    table.sort(nums)
|dados14 = {{{data14|}}}
+
    return nums
|classe15 = {{{class15|}}}
+
end
|tópico15 = {{{header15|}}}
+
 
|rótulo15 = {{{label15|}}}
+
local function addRow(rowArgs)
|dados15 = {{{data15|}}}
+
    -- Adds a row to the infobox, with either a header cell
|classe16 = {{{class16|}}}
+
    -- or a label/data cell combination.
|tópico16 = {{{header16|}}}
+
    if rowArgs.header then
|rótulo16 = {{{label16|}}}
+
        root
|dados16 = {{{data16|}}}
+
            :tag('tr')
|classe17 = {{{class17|}}}
+
                :addClass(rowArgs.rowclass)
|tópico17 = {{{header17|}}}
+
                :cssText(rowArgs.rowstyle)
|rótulo17 = {{{label17|}}}
+
                :attr('id', rowArgs.rowid)
|dados17 = {{{data17|}}}
+
                :tag('th')
|classe18 = {{{class18|}}}
+
                    :attr('colspan', 2)
|tópico18 = {{{header18|}}}
+
                    :attr('id', rowArgs.headerid)
|rótulo18 = {{{label18|}}}
+
                    :addClass(rowArgs.class)
|dados18 = {{{data18|}}}
+
                    :addClass(args.headerclass)
|classe19 = {{{class19|}}}
+
                    :css('text-align', 'center')
|tópico19 = {{{header19|}}}
+
                    :cssText(args.headerstyle)
|rótulo19 = {{{label19|}}}
+
                    :cssText(rowArgs.rowcellstyle)
|dados19 = {{{data19|}}}  
+
                    :wikitext(fixChildBoxes(rowArgs.header, 'th'))
|classe20 = {{{class20|}}}
+
    elseif rowArgs.data then
|tópico20 = {{{header20|}}}
+
        local row = root:tag('tr')
|rótulo20 = {{{label20|}}}
+
        row:addClass(rowArgs.rowclass)
|dados20 = {{{data20|}}}
+
        row:cssText(rowArgs.rowstyle)
|classe21 = {{{class21|}}}
+
        row:attr('id', rowArgs.rowid)
|tópico21 = {{{header21|}}}
+
        if rowArgs.label then
|rótulo21 = {{{label21|}}}
+
            row
|dados21 = {{{data21|}}}
+
                :tag('th')
|classe22 = {{{class22|}}}
+
                    :attr('scope', 'row')
|tópico22 = {{{header22|}}}  
+
                    :attr('id', rowArgs.labelid)
|rótulo22 = {{{label22|}}}
+
                    :cssText(args.labelstyle)
|dados22 = {{{data22|}}}
+
                    :cssText(rowArgs.rowcellstyle)
|classe23 = {{{class23|}}}
+
                    :wikitext(rowArgs.label)
|tópico23 = {{{header23|}}}
+
                    :done()
|rótulo23 = {{{label23|}}}
+
        end
|dados23 = {{{data23|}}}
+
       
|classe24 = {{{class24|}}}
+
        local dataCell = row:tag('td')
|tópico24 = {{{header24|}}}
+
        if not rowArgs.label then
|rótulo24 = {{{label24|}}}
+
            dataCell
|dados24 = {{{data24|}}}
+
                :attr('colspan', 2)
|classe25 = {{{class25|}}}  
+
                :css('text-align', 'center')
|tópico25 = {{{header25|}}}
+
        end
|rótulo25 = {{{label25|}}}  
+
        dataCell
|dados25 = {{{data25|}}}
+
            :attr('id', rowArgs.dataid)
|classe26 = {{{class26|}}}  
+
            :addClass(rowArgs.class)
|tópico26 = {{{header26|}}}
+
            :cssText(rowArgs.datastyle)
|rótulo26 = {{{label26|}}}
+
            :cssText(rowArgs.rowcellstyle)
|dados26 = {{{data26|}}}
+
            :wikitext(fixChildBoxes(rowArgs.data, 'td'))
|classe27 = {{{class27|}}}
+
    end
|tópico27 = {{{header27|}}}
+
end
|rótulo27 = {{{label27|}}}
+
 
|dados27 = {{{data27|}}}
+
local function renderTitle()
|classe28 = {{{class28|}}}
+
    if not args.title then return end
|tópico28 = {{{header28|}}}
+
 
|rótulo28 = {{{label28|}}}
+
    root
|dados28 = {{{data28|}}}
+
        :tag('caption')
|classe29 = {{{class29|}}}
+
            :addClass(args.titleclass)
|tópico29 = {{{header29|}}}
+
            :cssText(args.titlestyle)
|rótulo29 = {{{label29|}}}
+
            :wikitext(args.title)
|dados29 = {{{data29|}}}
+
end
|classe30 = {{{class30|}}}
+
 
|tópico30 = {{{header30|}}}
+
local function renderAboveRow()
|rótulo30 = {{{label30|}}}
+
    if not args.above then return end
|dados30 = {{{data30|}}}
+
   
|classe31 = {{{class31|}}}
+
    root
|tópico31 = {{{header31|}}}
+
        :tag('tr')
|rótulo31 = {{{label31|}}}
+
            :tag('th')
|dados31 = {{{data31|}}}
+
                :attr('colspan', 2)
|classe32 = {{{class32|}}}
+
                :addClass(args.aboveclass)
|tópico32 = {{{header32|}}}
+
                :css('text-align', 'center')
|rótulo32 = {{{label32|}}}
+
                :css('font-size', '125%')
|dados32 = {{{data32|}}}
+
                :css('font-weight', 'bold')
|classe33 = {{{class33|}}}
+
                :cssText(args.abovestyle)
|tópico33 = {{{header33|}}}
+
                :wikitext(fixChildBoxes(args.above,'th'))
|rótulo33 = {{{label33|}}}
+
end
|dados33 = {{{data33|}}}
+
 
|classe34 = {{{class34|}}}
+
local function renderBelowRow()
|tópico34 = {{{header34|}}}
+
    if not args.below then return end
|rótulo34 = {{{label34|}}}
+
   
|dados34 = {{{data34|}}}
+
    root
|classe35 = {{{class35|}}}
+
        :tag('tr')
|tópico35 = {{{header35|}}}
+
            :tag('td')
|rótulo35 = {{{label35|}}}
+
                :attr('colspan', '2')
|dados35 = {{{data35|}}}
+
                :addClass(args.belowclass)
|classe36 = {{{class36|}}}
+
                :css('text-align', 'center')
|tópico36 = {{{header36|}}}
+
                :cssText(args.belowstyle)
|rótulo36 = {{{label36|}}}
+
                :wikitext(fixChildBoxes(args.below,'td'))
|dados36 = {{{data36|}}}
+
end
|classe37 = {{{class37|}}}
+
 
|tópico37 = {{{header37|}}}
+
local function renderSubheaders()
|rótulo37 = {{{label37|}}}
+
    if args.subheader then
|dados37 = {{{data37|}}}
+
        args.subheader1 = args.subheader
|classe38 = {{{class38|}}}
+
    end
|tópico38 = {{{header38|}}}
+
    if args.subheaderrowclass then
|rótulo38 = {{{label38|}}}
+
        args.subheaderrowclass1 = args.subheaderrowclass
|dados38 = {{{data38|}}}
+
    end
|classe39 = {{{class39|}}}
+
    local subheadernums = getArgNums('subheader')
|tópico39 = {{{header39|}}}
+
    for k, num in ipairs(subheadernums) do
|rótulo39 = {{{label39|}}}
+
        addRow({
|dados39 = {{{data39|}}}
+
            data = args['subheader' .. tostring(num)],
|classe40 = {{{class40|}}}
+
            datastyle = args.subheaderstyle,
|tópico40 = {{{header40|}}}
+
            rowcellstyle = args['subheaderstyle' .. tostring(num)],
|rótulo40 = {{{label40|}}}
+
            class = args.subheaderclass,
|dados40 = {{{data40|}}}
+
            rowclass = args['subheaderrowclass' .. tostring(num)]
|classe41 = {{{class41|}}}
+
        })
|tópico41 = {{{header41|}}}
+
    end
|rótulo41 = {{{label41|}}}
+
end
|dados41 = {{{data41|}}}
+
 
|classe42 = {{{class42|}}}
+
local function renderImages()
|tópico42 = {{{header42|}}}
+
    if args.image then
|rótulo42 = {{{label42|}}}
+
        args.image1 = args.image
|dados42 = {{{data42|}}}
+
    end
|classe43 = {{{class43|}}}
+
    if args.caption then
|tópico43 = {{{header43|}}}
+
        args.caption1 = args.caption
|rótulo43 = {{{label43|}}}  
+
    end
|dados43 = {{{data43|}}}
+
    local imagenums = getArgNums('image')
|classe44 = {{{class44|}}}
+
    for k, num in ipairs(imagenums) do
|tópico44 = {{{header44|}}}
+
        local caption = args['caption' .. tostring(num)]
|rótulo44 = {{{label44|}}}  
+
        local data = mw.html.create():wikitext(args['image' .. tostring(num)])
|dados44 = {{{data44|}}}  
+
        if caption then
|classe45 = {{{class45|}}}  
+
            data
|tópico45 = {{{header45|}}}  
+
                :tag('div')
|rótulo45 = {{{label45|}}}  
+
                    :cssText(args.captionstyle)
|dados45 = {{{data45|}}}  
+
                    :wikitext(caption)
|classe46 = {{{class46|}}}  
+
        end
|tópico46 = {{{header46|}}}  
+
        addRow({
|rótulo46 = {{{label46|}}}
+
            data = tostring(data),
|dados46 = {{{data46|}}}
+
            datastyle = args.imagestyle,
|classe47 = {{{class47|}}}
+
            class = args.imageclass,
|tópico47 = {{{header47|}}}
+
            rowclass = args['imagerowclass' .. tostring(num)]
|rótulo47 = {{{label47|}}}
+
        })
|dados47 = {{{data47|}}}
+
    end
|classe48 = {{{class48|}}}
+
end
|tópico48 = {{{header48|}}}
+
 
|rótulo48 = {{{label48|}}}
+
local function renderRows()
|dados48 = {{{data48|}}}
+
    -- Gets the union of the header and data argument numbers,
|classe49 = {{{class49|}}}
+
    -- and renders them all in order using addRow.
|tópico49 = {{{header49|}}}
+
    local rownums = union(getArgNums('header'), getArgNums('data'))
|rótulo49 = {{{label49|}}}
+
    table.sort(rownums)
|dados49 = {{{data49|}}}
+
    for k, num in ipairs(rownums) do
|classe50 = {{{class50|}}}
+
        addRow({
|tópico50 = {{{header50|}}}
+
            header = args['header' .. tostring(num)],
|rótulo50 = {{{label50|}}}
+
            label = args['label' .. tostring(num)],
|dados50 = {{{data50|}}}
+
            data = args['data' .. tostring(num)],
|classe51 = {{{class51|}}}
+
            datastyle = args.datastyle,
|tópico51 = {{{header51|}}}
+
            class = args['class' .. tostring(num)],
|rótulo51 = {{{label51|}}}
+
            rowclass = args['rowclass' .. tostring(num)],
|dados51 = {{{data51|}}}
+
            rowstyle = args['rowstyle' .. tostring(num)],
|classe52 = {{{class52|}}}
+
            rowcellstyle = args['rowcellstyle' .. tostring(num)],
|tópico52 = {{{header52|}}}
+
            dataid = args['dataid' .. tostring(num)],
|rótulo52 = {{{label52|}}}
+
            labelid = args['labelid' .. tostring(num)],
|dados52 = {{{data52|}}}
+
            headerid = args['headerid' .. tostring(num)],
|classe53 = {{{class53|}}}
+
            rowid = args['rowid' .. tostring(num)]
|tópico53 = {{{header53|}}}
+
        })
|rótulo53 = {{{label53|}}}
+
    end
|dados53 = {{{data53|}}}
+
end
|classe54 = {{{class54|}}}
+
 
|tópico54 = {{{header54|}}}
+
local function renderNavBar()
|rótulo54 = {{{label54|}}}
+
    if not args.name then return end
|dados54 = {{{data54|}}}
+
   
|classe55 = {{{class55|}}}
+
    root
|tópico55 = {{{header55|}}}
+
        :tag('tr')
|rótulo55 = {{{label55|}}}
+
            :tag('td')
|dados55 = {{{data55|}}}
+
                :attr('colspan', '2')
|classe56 = {{{class56|}}}
+
                :css('text-align', 'right')
|tópico56 = {{{header56|}}}
+
                :wikitext(navbar{
|rótulo56 = {{{label56|}}}
+
                    args.name,
|dados56 = {{{data56|}}}
+
                    mini = 1,
|classe57 = {{{class57|}}}
+
                })
|tópico57 = {{{header57|}}}
+
end
|rótulo57 = {{{label57|}}}
+
 
|dados57 = {{{data57|}}}
+
local function renderItalicTitle()
|classe58 = {{{class58|}}}
+
    local italicTitle = args['italic title'] and mw.ustring.lower(args['italic title'])
|tópico58 = {{{header58|}}}
+
    if italicTitle == '' or italicTitle == 'force' or italicTitle == 'yes' then
|rótulo58 = {{{label58|}}}
+
        root:wikitext(mw.getCurrentFrame():expandTemplate({title = 'italic title'}))
|dados58 = {{{data58|}}}
+
    end
|classe59 = {{{class59|}}}
+
end
|tópico59 = {{{header59|}}}
+
 
|rótulo59 = {{{label59|}}}
+
local function renderTrackingCategories()
|dados59 = {{{data59|}}}
+
    if args.decat ~= 'yes' then
|classe60 = {{{class60|}}}
+
    if args.child == 'yes' then
|tópico60 = {{{header60|}}}
+
        if args.title then
|rótulo60 = {{{label60|}}}
+
            root:wikitext('[[Category:Pages which use embedded infobox templates with the title parameter]]')
|dados60 = {{{data60|}}}
+
        end
|classe61 = {{{class61|}}}
+
        elseif #(getArgNums('data')) == 0 and mw.title.getCurrentTitle().namespace == 0 then
|tópico61 = {{{header61|}}}
+
            root:wikitext('[[Category:Articles which use infobox templates with no data rows]]')
|rótulo61 = {{{label61|}}}
+
        end
|dados61 = {{{data61|}}}
+
    end
|classe62 = {{{class62|}}}
+
end
|tópico62 = {{{header62|}}}
+
 
|rótulo62 = {{{label62|}}}
+
local function _infobox()
|dados62 = {{{data62|}}}
+
    -- Specify the overall layout of the infobox, with special settings
|classe63 = {{{class63|}}}
+
    -- if the infobox is used as a 'child' inside another infobox.
|tópico63 = {{{header63|}}}
+
    if args.child ~= 'yes' then
|rótulo63 = {{{label63|}}}
+
        root = mw.html.create('table')
|dados63 = {{{data63|}}}
+
       
|classe64 = {{{class64|}}}
+
        root
|tópico64 = {{{header64|}}}
+
            :addClass((args.subbox ~= 'yes') and 'infobox' or nil)
|rótulo64 = {{{label64|}}}
+
            :addClass(args.bodyclass)
|dados64 = {{{data64|}}}
+
           
|classe65 = {{{class65|}}}
+
            if args.subbox == 'yes' then
|tópico65 = {{{header65|}}}
+
                root
|rótulo65 = {{{label65|}}}
+
                    :css('padding', '0')
|dados65 = {{{data65|}}}
+
                    :css('border', 'none')
|classe66 = {{{class66|}}}
+
                    :css('margin', '-3px')
|tópico66 = {{{header66|}}}
+
                    :css('width', 'auto')
|rótulo66 = {{{label66|}}}
+
                    :css('min-width', '100%')
|dados66 = {{{data66|}}}
+
                    :css('font-size', '100%')
|classe67 = {{{class67|}}}
+
                    :css('clear', 'none')
|tópico67 = {{{header67|}}}
+
                    :css('float', 'none')
|rótulo67 = {{{label67|}}}
+
                    :css('background-color', 'transparent')
|dados67 = {{{data67|}}}
+
            else
|classe68 = {{{class68|}}}
+
                root
|tópico68 = {{{header68|}}}
+
                    :css('width', '22em')
|rótulo68 = {{{label68|}}}
+
            end
|dados68 = {{{data68|}}}
+
        root
|classe69 = {{{class69|}}}
+
            :cssText(args.bodystyle)
|tópico69 = {{{header69|}}}
+
   
|rótulo69 = {{{label69|}}}
+
        renderTitle()
|dados69 = {{{data69|}}}
+
        renderAboveRow()
|classe70 = {{{class70|}}}
+
    else
|tópico70 = {{{header70|}}}
+
        root = mw.html.create()
|rótulo70 = {{{label70|}}}
+
       
|dados70 = {{{data70|}}}
+
        root
|classe71 = {{{class71|}}}
+
            :wikitext(args.title)
|tópico71 = {{{header71|}}}
+
    end
|rótulo71 = {{{label71|}}}
+
 
|dados71 = {{{data71|}}}
+
    renderSubheaders()
|classe72 = {{{class72|}}}
+
    renderImages()
|tópico72 = {{{header72|}}}
+
    renderRows()
|rótulo72 = {{{label72|}}}
+
    renderBelowRow() 
|dados72 = {{{data72|}}}
+
    renderNavBar()
|classe73 = {{{class73|}}}
+
    renderItalicTitle()
|tópico73 = {{{header73|}}}
+
    renderTrackingCategories()
|rótulo73 = {{{label73|}}}
+
   
|dados73 = {{{data73|}}}
+
    return tostring(root)
|classe74 = {{{class74|}}}
+
end
|tópico74 = {{{header74|}}}
+
 
|rótulo74 = {{{label74|}}}
+
local function preprocessSingleArg(argName)
|dados74 = {{{data74|}}}
+
    -- If the argument exists and isn't blank, add it to the argument table.
|classe75 = {{{class75|}}}
+
    -- Blank arguments are treated as nil to match the behaviour of ParserFunctions.
|tópico75 = {{{header75|}}}
+
    if origArgs[argName] and origArgs[argName] ~= '' then
|rótulo75 = {{{label75|}}}
+
        args[argName] = origArgs[argName]
|dados75 = {{{data75|}}}
+
    end
|classe76 = {{{class76|}}}
+
end
|tópico76 = {{{header76|}}}
+
 
|rótulo76 = {{{label76|}}}
+
local function preprocessArgs(prefixTable, step)
|dados76 = {{{data76|}}}
+
    -- Assign the parameters with the given prefixes to the args table, in order, in batches
|classe77 = {{{class77|}}}
+
    -- of the step size specified. This is to prevent references etc. from appearing in the
|tópico77 = {{{header77|}}}
+
    -- wrong order. The prefixTable should be an array containing tables, each of which has
|rótulo77 = {{{label77|}}}
+
    -- two possible fields, a "prefix" string and a "depend" table. The function always parses
|dados77 = {{{data77|}}}
+
    -- parameters containing the "prefix" string, but only parses parameters in the "depend"
|classe78 = {{{class78|}}}
+
    -- table if the prefix parameter is present and non-blank.
|tópico78 = {{{header78|}}}
+
    if type(prefixTable) ~= 'table' then
|rótulo78 = {{{label78|}}}
+
        error("Non-table value detected for the prefix table", 2)
|dados78 = {{{data78|}}}
+
    end
|classe79 = {{{class79|}}}
+
    if type(step) ~= 'number' then
|tópico79 = {{{header79|}}}
+
        error("Invalid step value detected", 2)
|rótulo79 = {{{label79|}}}
+
    end
|dados79 = {{{data79|}}}
+
   
|classe80 = {{{class80|}}}
+
    -- Get arguments without a number suffix, and check for bad input.
|tópico80 = {{{header80|}}}
+
    for i,v in ipairs(prefixTable) do
|rótulo80 = {{{label80|}}}
+
        if type(v) ~= 'table' or type(v.prefix) ~= "string" or (v.depend and type(v.depend) ~= 'table') then
|dados80 = {{{data80|}}}
+
            error('Invalid input detected to preprocessArgs prefix table', 2)
|rodapé = {{{below|}}}
+
        end
|rodapé-estilo = {{{belowstyle|}}}
+
        preprocessSingleArg(v.prefix)
}}</includeonly>
+
        -- 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 {{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

Edição das 19h40min de 6 de março de 2019

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 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