http://proplan.55bet-pro.com/wiki/index.php?action=history&feed=atom&title=M%C3%B3dulo%3AInfobox Módulo:Infobox - Histórico de revisão-55BET Pro 2026-05-11T07:36:12Z Histórico de revisões para esta página neste wiki MediaWiki 1.42.7 http://proplan.55bet-pro.com/wiki/index.php?title=M%C3%B3dulo:Infobox&diff=73&oldid=prev Módulo:Infobox - Histórico de revisão-55BET Pro 2024-06-27T11:11:54Z <p>uma edição</p> <table style="background-color: #fff; color: #202122;" data-mw="interface"> <tr class="diff-title" lang="pt-BR"> <td colspan="1" style="background-color: #fff; color: #202122; text-align: center;">← Edição anterior</td> <td colspan="1" style="background-color: #fff; color: #202122; text-align: center;">Edição das 08h11min de 27 de junho de 2024</td> </tr><tr><td colspan="2" class="diff-notice" lang="pt-BR"><div class="mw-diff-empty">(Sem diferença)</div> </td></tr></table> Henryzord http://proplan.55bet-pro.com/wiki/index.php?title=M%C3%B3dulo:Infobox&diff=72&oldid=prev Módulo:Infobox - Histórico de revisão-55BET Pro 2022-12-27T21:29:12Z <p>merge hlist here</p> <p><b>Página nova</b></p><div>local p = {}<br /> local args = {}<br /> local origArgs = {}<br /> local root<br /> local empty_row_categories = {}<br /> local category_in_empty_row_pattern = &#039;%[%[%s*[Cc][Aa][Tt][Ee][Gg][Oo][Rr][Yy]%s*:[^]]*]]&#039;<br /> local has_rows = false<br /> local lists = {<br /> plainlist_t = {<br /> patterns = {<br /> &#039;^plainlist$&#039;,<br /> &#039;%splainlist$&#039;,<br /> &#039;^plainlist%s&#039;,<br /> &#039;%splainlist%s&#039;<br /> },<br /> found = false,<br /> styles = &#039;Plainlist/styles.css&#039;<br /> },<br /> hlist_t = {<br /> patterns = {<br /> &#039;^hlist$&#039;,<br /> &#039;%shlist$&#039;,<br /> &#039;^hlist%s&#039;,<br /> &#039;%shlist%s&#039;<br /> },<br /> found = false,<br /> styles = &#039;Hlist/styles.css&#039;<br /> }<br /> }<br /> <br /> local function has_list_class(args_to_check)<br /> for _, list in pairs(lists) do<br /> if not list.found then<br /> for _, arg in pairs(args_to_check) do<br /> for _, pattern in ipairs(list.patterns) do<br /> if mw.ustring.find(arg or &#039;&#039;, pattern) then<br /> list.found = true<br /> break<br /> end<br /> end<br /> if list.found then break end<br /> end<br /> end<br /> end<br /> end<br /> <br /> local function fixChildBoxes(sval, tt)<br /> local function notempty( s ) return s and s:match( &#039;%S&#039; ) end<br /> <br /> if notempty(sval) then<br /> local marker = &#039;&lt;span class=special_infobox_marker&gt;&#039;<br /> local s = sval<br /> -- start moving templatestyles and categories inside of table rows<br /> local slast = &#039;&#039;<br /> while slast ~= s do<br /> slast = s<br /> s = mw.ustring.gsub(s, &#039;(&lt;/[Tt][Rr]%s*&gt;%s*)(%[%[%s*[Cc][Aa][Tt][Ee][Gg][Oo][Rr][Yy]%s*:[^]]*%]%])&#039;, &#039;%2%1&#039;)<br /> s = mw.ustring.gsub(s, &#039;(&lt;/[Tt][Rr]%s*&gt;%s*)(\127[^\127]*UNIQ%-%-templatestyles%-%x+%-QINU[^\127]*\127)&#039;, &#039;%2%1&#039;)<br /> end<br /> -- end moving templatestyles and categories inside of table rows<br /> s = mw.ustring.gsub(s, &#039;(&lt;%s*[Tt][Rr])&#039;, marker .. &#039;%1&#039;)<br /> s = mw.ustring.gsub(s, &#039;(&lt;/[Tt][Rr]%s*&gt;)&#039;, &#039;%1&#039; .. marker)<br /> if s:match(marker) then<br /> s = mw.ustring.gsub(s, marker .. &#039;%s*&#039; .. marker, &#039;&#039;)<br /> s = mw.ustring.gsub(s, &#039;([\r\n]|-[^\r\n]*[\r\n])%s*&#039; .. marker, &#039;%1&#039;)<br /> s = mw.ustring.gsub(s, marker .. &#039;%s*([\r\n]|-)&#039;, &#039;%1&#039;)<br /> s = mw.ustring.gsub(s, &#039;(&lt;/[Cc][Aa][Pp][Tt][Ii][Oo][Nn]%s*&gt;%s*)&#039; .. marker, &#039;%1&#039;)<br /> s = mw.ustring.gsub(s, &#039;(&lt;%s*[Tt][Aa][Bb][Ll][Ee][^&lt;&gt;]*&gt;%s*)&#039; .. marker, &#039;%1&#039;)<br /> s = mw.ustring.gsub(s, &#039;^(%{|[^\r\n]*[\r\n]%s*)&#039; .. marker, &#039;%1&#039;)<br /> s = mw.ustring.gsub(s, &#039;([\r\n]%{|[^\r\n]*[\r\n]%s*)&#039; .. marker, &#039;%1&#039;)<br /> s = mw.ustring.gsub(s, marker .. &#039;(%s*&lt;/[Tt][Aa][Bb][Ll][Ee]%s*&gt;)&#039;, &#039;%1&#039;)<br /> s = mw.ustring.gsub(s, marker .. &#039;(%s*\n|%})&#039;, &#039;%1&#039;)<br /> end<br /> if s:match(marker) then<br /> local subcells = mw.text.split(s, marker)<br /> s = &#039;&#039;<br /> for k = 1, #subcells do<br /> if k == 1 then<br /> s = s .. subcells[k] .. &#039;&lt;/&#039; .. tt .. &#039;&gt;&lt;/tr&gt;&#039;<br /> elseif k == #subcells then<br /> local rowstyle = &#039; style=&quot;display:none&quot;&#039;<br /> if notempty(subcells[k]) then rowstyle = &#039;&#039; end<br /> s = s .. &#039;&lt;tr&#039; .. rowstyle ..&#039;&gt;&lt;&#039; .. tt .. &#039; colspan=2&gt;\n&#039; ..<br /> subcells[k]<br /> elseif notempty(subcells[k]) then<br /> if (k % 2) == 0 then<br /> s = s .. subcells[k]<br /> else<br /> s = s .. &#039;&lt;tr&gt;&lt;&#039; .. tt .. &#039; colspan=2&gt;\n&#039; ..<br /> subcells[k] .. &#039;&lt;/&#039; .. tt .. &#039;&gt;&lt;/tr&gt;&#039;<br /> end<br /> end<br /> end<br /> end<br /> -- the next two lines add a newline at the end of lists for the PHP parser<br /> -- [[Special:Diff/849054481]]<br /> -- remove when [[:phab:T191516]] is fixed or OBE<br /> s = mw.ustring.gsub(s, &#039;([\r\n][%*#;:][^\r\n]*)$&#039;, &#039;%1\n&#039;)<br /> s = mw.ustring.gsub(s, &#039;^([%*#;:][^\r\n]*)$&#039;, &#039;%1\n&#039;)<br /> s = mw.ustring.gsub(s, &#039;^([%*#;:])&#039;, &#039;\n%1&#039;)<br /> s = mw.ustring.gsub(s, &#039;^(%{%|)&#039;, &#039;\n%1&#039;)<br /> return s<br /> else<br /> return sval<br /> end<br /> end<br /> <br /> -- Cleans empty tables<br /> local function cleanInfobox()<br /> root = tostring(root)<br /> if has_rows == false then<br /> root = mw.ustring.gsub(root, &#039;&lt;table[^&lt;&gt;]*&gt;%s*&lt;/table&gt;&#039;, &#039;&#039;)<br /> end<br /> end<br /> <br /> -- Returns the union of the values of two tables, as a sequence.<br /> local function union(t1, t2)<br /> <br /> local vals = {}<br /> for k, v in pairs(t1) do<br /> vals[v] = true<br /> end<br /> for k, v in pairs(t2) do<br /> vals[v] = true<br /> end<br /> local ret = {}<br /> for k, v in pairs(vals) do<br /> table.insert(ret, k)<br /> end<br /> return ret<br /> end<br /> <br /> -- Returns a table containing the numbers of the arguments that exist<br /> -- for the specified prefix. For example, if the prefix was &#039;data&#039;, and<br /> -- &#039;data1&#039;, &#039;data2&#039;, and &#039;data5&#039; exist, it would return {1, 2, 5}.<br /> local function getArgNums(prefix)<br /> local nums = {}<br /> for k, v in pairs(args) do<br /> local num = tostring(k):match(&#039;^&#039; .. prefix .. &#039;([1-9]%d*)$&#039;)<br /> if num then table.insert(nums, tonumber(num)) end<br /> end<br /> table.sort(nums)<br /> return nums<br /> end<br /> <br /> -- Adds a row to the infobox, with either a header cell<br /> -- or a label/data cell combination.<br /> local function addRow(rowArgs)<br /> <br /> if rowArgs.header and rowArgs.header ~= &#039;_BLANK_&#039; then<br /> has_rows = true<br /> has_list_class({ rowArgs.rowclass, rowArgs.class, args.headerclass })<br /> <br /> root<br /> :tag(&#039;tr&#039;)<br /> :addClass(rowArgs.rowclass)<br /> :cssText(rowArgs.rowstyle)<br /> :tag(&#039;th&#039;)<br /> :attr(&#039;colspan&#039;, &#039;2&#039;)<br /> :addClass(&#039;infobox-header&#039;)<br /> :addClass(rowArgs.class)<br /> :addClass(args.headerclass)<br /> -- @deprecated next; target .infobox-&lt;name&gt; .infobox-header<br /> :cssText(args.headerstyle)<br /> :cssText(rowArgs.rowcellstyle)<br /> :wikitext(fixChildBoxes(rowArgs.header, &#039;th&#039;))<br /> if rowArgs.data then<br /> root:wikitext(<br /> &#039;[[Category:Pages using infobox templates with ignored data cells]]&#039;<br /> )<br /> end<br /> elseif rowArgs.data and rowArgs.data:gsub(category_in_empty_row_pattern, &#039;&#039;):match(&#039;^%S&#039;) then<br /> has_rows = true<br /> has_list_class({ rowArgs.rowclass, rowArgs.class })<br /> <br /> local row = root:tag(&#039;tr&#039;)<br /> row:addClass(rowArgs.rowclass)<br /> row:cssText(rowArgs.rowstyle)<br /> if rowArgs.label then<br /> row<br /> :tag(&#039;th&#039;)<br /> :attr(&#039;scope&#039;, &#039;row&#039;)<br /> :addClass(&#039;infobox-label&#039;)<br /> -- @deprecated next; target .infobox-&lt;name&gt; .infobox-label<br /> :cssText(args.labelstyle)<br /> :cssText(rowArgs.rowcellstyle)<br /> :wikitext(rowArgs.label)<br /> :done()<br /> end<br /> <br /> local dataCell = row:tag(&#039;td&#039;)<br /> dataCell<br /> :attr(&#039;colspan&#039;, not rowArgs.label and &#039;2&#039; or nil)<br /> :addClass(not rowArgs.label and &#039;infobox-full-data&#039; or &#039;infobox-data&#039;)<br /> :addClass(rowArgs.class)<br /> -- @deprecated next; target .infobox-&lt;name&gt; .infobox(-full)-data<br /> :cssText(rowArgs.datastyle)<br /> :cssText(rowArgs.rowcellstyle)<br /> :wikitext(fixChildBoxes(rowArgs.data, &#039;td&#039;))<br /> else<br /> table.insert(empty_row_categories, rowArgs.data or &#039;&#039;)<br /> end<br /> end<br /> <br /> local function renderTitle()<br /> if not args.title then return end<br /> <br /> has_rows = true<br /> has_list_class({args.titleclass})<br /> <br /> root<br /> :tag(&#039;caption&#039;)<br /> :addClass(&#039;infobox-title&#039;)<br /> :addClass(args.titleclass)<br /> -- @deprecated next; target .infobox-&lt;name&gt; .infobox-title<br /> :cssText(args.titlestyle)<br /> :wikitext(args.title)<br /> <br /> end<br /> <br /> local function renderAboveRow()<br /> if not args.above then return end<br /> <br /> has_rows = true<br /> has_list_class({ args.aboveclass })<br /> <br /> root<br /> :tag(&#039;tr&#039;)<br /> :tag(&#039;th&#039;)<br /> :attr(&#039;colspan&#039;, &#039;2&#039;)<br /> :addClass(&#039;infobox-above&#039;)<br /> :addClass(args.aboveclass)<br /> -- @deprecated next; target .infobox-&lt;name&gt; .infobox-above<br /> :cssText(args.abovestyle)<br /> :wikitext(fixChildBoxes(args.above,&#039;th&#039;))<br /> end<br /> <br /> local function renderBelowRow()<br /> if not args.below then return end<br /> <br /> has_rows = true<br /> has_list_class({ args.belowclass })<br /> <br /> root<br /> :tag(&#039;tr&#039;)<br /> :tag(&#039;td&#039;)<br /> :attr(&#039;colspan&#039;, &#039;2&#039;)<br /> :addClass(&#039;infobox-below&#039;)<br /> :addClass(args.belowclass)<br /> -- @deprecated next; target .infobox-&lt;name&gt; .infobox-below<br /> :cssText(args.belowstyle)<br /> :wikitext(fixChildBoxes(args.below,&#039;td&#039;))<br /> end<br /> <br /> local function addSubheaderRow(subheaderArgs)<br /> if subheaderArgs.data and<br /> subheaderArgs.data:gsub(category_in_empty_row_pattern, &#039;&#039;):match(&#039;^%S&#039;) then<br /> has_rows = true<br /> has_list_class({ subheaderArgs.rowclass, subheaderArgs.class })<br /> <br /> local row = root:tag(&#039;tr&#039;)<br /> row:addClass(subheaderArgs.rowclass)<br /> <br /> local dataCell = row:tag(&#039;td&#039;)<br /> dataCell<br /> :attr(&#039;colspan&#039;, &#039;2&#039;)<br /> :addClass(&#039;infobox-subheader&#039;)<br /> :addClass(subheaderArgs.class)<br /> :cssText(subheaderArgs.datastyle)<br /> :cssText(subheaderArgs.rowcellstyle)<br /> :wikitext(fixChildBoxes(subheaderArgs.data, &#039;td&#039;))<br /> else<br /> table.insert(empty_row_categories, subheaderArgs.data or &#039;&#039;)<br /> end<br /> end<br /> <br /> local function renderSubheaders()<br /> if args.subheader then<br /> args.subheader1 = args.subheader<br /> end<br /> if args.subheaderrowclass then<br /> args.subheaderrowclass1 = args.subheaderrowclass<br /> end<br /> local subheadernums = getArgNums(&#039;subheader&#039;)<br /> for k, num in ipairs(subheadernums) do<br /> addSubheaderRow({<br /> data = args[&#039;subheader&#039; .. tostring(num)],<br /> -- @deprecated next; target .infobox-&lt;name&gt; .infobox-subheader<br /> datastyle = args.subheaderstyle,<br /> rowcellstyle = args[&#039;subheaderstyle&#039; .. tostring(num)],<br /> class = args.subheaderclass,<br /> rowclass = args[&#039;subheaderrowclass&#039; .. tostring(num)]<br /> })<br /> end<br /> end<br /> <br /> local function addImageRow(imageArgs)<br /> <br /> if imageArgs.data and<br /> imageArgs.data:gsub(category_in_empty_row_pattern, &#039;&#039;):match(&#039;^%S&#039;) then<br /> <br /> has_rows = true<br /> has_list_class({ imageArgs.rowclass, imageArgs.class })<br /> <br /> local row = root:tag(&#039;tr&#039;)<br /> row:addClass(imageArgs.rowclass)<br /> <br /> local dataCell = row:tag(&#039;td&#039;)<br /> dataCell<br /> :attr(&#039;colspan&#039;, &#039;2&#039;)<br /> :addClass(&#039;infobox-image&#039;)<br /> :addClass(imageArgs.class)<br /> :cssText(imageArgs.datastyle)<br /> :wikitext(fixChildBoxes(imageArgs.data, &#039;td&#039;))<br /> else<br /> table.insert(empty_row_categories, imageArgs.data or &#039;&#039;)<br /> end<br /> end<br /> <br /> local function renderImages()<br /> if args.image then<br /> args.image1 = args.image<br /> end<br /> if args.caption then<br /> args.caption1 = args.caption<br /> end<br /> local imagenums = getArgNums(&#039;image&#039;)<br /> for k, num in ipairs(imagenums) do<br /> local caption = args[&#039;caption&#039; .. tostring(num)]<br /> local data = mw.html.create():wikitext(args[&#039;image&#039; .. tostring(num)])<br /> if caption then<br /> data<br /> :tag(&#039;div&#039;)<br /> :addClass(&#039;infobox-caption&#039;)<br /> -- @deprecated next; target .infobox-&lt;name&gt; .infobox-caption<br /> :cssText(args.captionstyle)<br /> :wikitext(caption)<br /> end<br /> addImageRow({<br /> data = tostring(data),<br /> -- @deprecated next; target .infobox-&lt;name&gt; .infobox-image<br /> datastyle = args.imagestyle,<br /> class = args.imageclass,<br /> rowclass = args[&#039;imagerowclass&#039; .. tostring(num)]<br /> })<br /> end<br /> end<br /> <br /> -- When autoheaders are turned on, preprocesses the rows<br /> local function preprocessRows()<br /> if not args.autoheaders then return end<br /> <br /> local rownums = union(getArgNums(&#039;header&#039;), getArgNums(&#039;data&#039;))<br /> table.sort(rownums)<br /> local lastheader<br /> for k, num in ipairs(rownums) do<br /> if args[&#039;header&#039; .. tostring(num)] then<br /> if lastheader then<br /> args[&#039;header&#039; .. tostring(lastheader)] = nil<br /> end<br /> lastheader = num<br /> elseif args[&#039;data&#039; .. tostring(num)] and<br /> args[&#039;data&#039; .. tostring(num)]:gsub(<br /> category_in_empty_row_pattern, &#039;&#039;<br /> ):match(&#039;^%S&#039;) then<br /> local data = args[&#039;data&#039; .. tostring(num)]<br /> if data:gsub(category_in_empty_row_pattern, &#039;&#039;):match(&#039;%S&#039;) then<br /> lastheader = nil<br /> end<br /> end<br /> end<br /> if lastheader then<br /> args[&#039;header&#039; .. tostring(lastheader)] = nil<br /> end<br /> end<br /> <br /> -- Gets the union of the header and data argument numbers,<br /> -- and renders them all in order<br /> local function renderRows()<br /> <br /> local rownums = union(getArgNums(&#039;header&#039;), getArgNums(&#039;data&#039;))<br /> table.sort(rownums)<br /> for k, num in ipairs(rownums) do<br /> addRow({<br /> header = args[&#039;header&#039; .. tostring(num)],<br /> label = args[&#039;label&#039; .. tostring(num)],<br /> data = args[&#039;data&#039; .. tostring(num)],<br /> datastyle = args.datastyle,<br /> class = args[&#039;class&#039; .. tostring(num)],<br /> rowclass = args[&#039;rowclass&#039; .. tostring(num)],<br /> -- @deprecated next; target .infobox-&lt;name&gt; rowclass<br /> rowstyle = args[&#039;rowstyle&#039; .. tostring(num)],<br /> rowcellstyle = args[&#039;rowcellstyle&#039; .. tostring(num)]<br /> })<br /> end<br /> end<br /> <br /> local function renderNavBar()<br /> if not args.name then return end<br /> <br /> has_rows = true<br /> root<br /> :tag(&#039;tr&#039;)<br /> :tag(&#039;td&#039;)<br /> :attr(&#039;colspan&#039;, &#039;2&#039;)<br /> :addClass(&#039;infobox-navbar&#039;)<br /> :wikitext(require(&#039;Module:Navbar&#039;)._navbar{<br /> args.name,<br /> mini = 1,<br /> })<br /> end<br /> <br /> local function renderItalicTitle()<br /> local italicTitle = args[&#039;italic title&#039;] and mw.ustring.lower(args[&#039;italic title&#039;])<br /> if italicTitle == &#039;&#039; or italicTitle == &#039;force&#039; or italicTitle == &#039;yes&#039; then<br /> root:wikitext(require(&#039;Module:Italic title&#039;)._main({}))<br /> end<br /> end<br /> <br /> -- Categories in otherwise empty rows are collected in empty_row_categories.<br /> -- This function adds them to the module output. It is not affected by<br /> -- args.decat because this module should not prevent module-external categories<br /> -- from rendering.<br /> local function renderEmptyRowCategories()<br /> for _, s in ipairs(empty_row_categories) do<br /> root:wikitext(s)<br /> end<br /> end<br /> <br /> -- Render tracking categories. args.decat == turns off tracking categories.<br /> local function renderTrackingCategories()<br /> if args.decat == &#039;yes&#039; then return end<br /> if args.child == &#039;yes&#039; then<br /> if args.title then<br /> root:wikitext(<br /> &#039;[[Category:Pages using embedded infobox templates with the title parameter]]&#039;<br /> )<br /> end<br /> elseif #(getArgNums(&#039;data&#039;)) == 0 and mw.title.getCurrentTitle().namespace == 0 then<br /> root:wikitext(&#039;[[Category:Articles using infobox templates with no data rows]]&#039;)<br /> end<br /> end<br /> <br /> --[=[<br /> Loads the templatestyles for the infobox.<br /> <br /> TODO: FINISH loading base templatestyles here rather than in<br /> MediaWiki:Common.css. There are 4-5000 pages with &#039;raw&#039; infobox tables.<br /> See [[Mediawiki_talk:Common.css/to_do#Infobox]] and/or come help :).<br /> When we do this we should clean up the inline CSS below too.<br /> Will have to do some bizarre conversion category like with sidebar.<br /> <br /> ]=]<br /> local function loadTemplateStyles()<br /> local frame = mw.getCurrentFrame()<br /> <br /> local hlist_templatestyles = &#039;&#039;<br /> if lists.hlist_t.found then<br /> hlist_templatestyles = frame:extensionTag{<br /> name = &#039;templatestyles&#039;, args = { src = lists.hlist_t.styles }<br /> }<br /> end<br /> <br /> local plainlist_templatestyles = &#039;&#039;<br /> if lists.plainlist_t.found then<br /> plainlist_templatestyles = frame:extensionTag{<br /> name = &#039;templatestyles&#039;, args = { src = lists.plainlist_t.styles }<br /> }<br /> end<br /> <br /> -- See function description<br /> local base_templatestyles = frame:extensionTag{<br /> name = &#039;templatestyles&#039;, args = { src = &#039;Module:Infobox/styles.css&#039; }<br /> }<br /> <br /> local templatestyles = &#039;&#039;<br /> if args[&#039;templatestyles&#039;] then<br /> templatestyles = frame:extensionTag{<br /> name = &#039;templatestyles&#039;, args = { src = args[&#039;templatestyles&#039;] }<br /> }<br /> end<br /> <br /> local child_templatestyles = &#039;&#039;<br /> if args[&#039;child templatestyles&#039;] then<br /> child_templatestyles = frame:extensionTag{<br /> name = &#039;templatestyles&#039;, args = { src = args[&#039;child templatestyles&#039;] }<br /> }<br /> end<br /> <br /> local grandchild_templatestyles = &#039;&#039;<br /> if args[&#039;grandchild templatestyles&#039;] then<br /> grandchild_templatestyles = frame:extensionTag{<br /> name = &#039;templatestyles&#039;, args = { src = args[&#039;grandchild templatestyles&#039;] }<br /> }<br /> end<br /> <br /> return table.concat({<br /> -- hlist -&gt; plainlist -&gt; base is best-effort to preserve old Common.css ordering.<br /> -- this ordering is not a guarantee because the rows of interest invoking<br /> -- each class may not be on a specific page<br /> hlist_templatestyles,<br /> plainlist_templatestyles,<br /> base_templatestyles,<br /> templatestyles,<br /> child_templatestyles,<br /> grandchild_templatestyles<br /> })<br /> end<br /> <br /> -- common functions between the child and non child cases<br /> local function structure_infobox_common()<br /> renderSubheaders()<br /> renderImages()<br /> preprocessRows()<br /> renderRows()<br /> renderBelowRow()<br /> renderNavBar()<br /> renderItalicTitle()<br /> renderEmptyRowCategories()<br /> renderTrackingCategories()<br /> cleanInfobox()<br /> end<br /> <br /> -- Specify the overall layout of the infobox, with special settings if the<br /> -- infobox is used as a &#039;child&#039; inside another infobox.<br /> local function _infobox()<br /> if args.child ~= &#039;yes&#039; then<br /> root = mw.html.create(&#039;table&#039;)<br /> <br /> root<br /> :addClass(args.subbox == &#039;yes&#039; and &#039;infobox-subbox&#039; or &#039;infobox&#039;)<br /> :addClass(args.bodyclass)<br /> -- @deprecated next; target .infobox-&lt;name&gt;<br /> :cssText(args.bodystyle)<br /> <br /> has_list_class({ args.bodyclass })<br /> <br /> renderTitle()<br /> renderAboveRow()<br /> else<br /> root = mw.html.create()<br /> <br /> root<br /> :wikitext(args.title)<br /> end<br /> structure_infobox_common()<br /> <br /> return loadTemplateStyles() .. root<br /> end<br /> <br /> -- If the argument exists and isn&#039;t blank, add it to the argument table.<br /> -- Blank arguments are treated as nil to match the behaviour of ParserFunctions.<br /> local function preprocessSingleArg(argName)<br /> if origArgs[argName] and origArgs[argName] ~= &#039;&#039; then<br /> args[argName] = origArgs[argName]<br /> end<br /> end<br /> <br /> -- Assign the parameters with the given prefixes to the args table, in order, in<br /> -- batches of the step size specified. This is to prevent references etc. from<br /> -- appearing in the wrong order. The prefixTable should be an array containing<br /> -- tables, each of which has two possible fields, a &quot;prefix&quot; string and a<br /> -- &quot;depend&quot; table. The function always parses parameters containing the &quot;prefix&quot;<br /> -- string, but only parses parameters in the &quot;depend&quot; table if the prefix<br /> -- parameter is present and non-blank.<br /> local function preprocessArgs(prefixTable, step)<br /> if type(prefixTable) ~= &#039;table&#039; then<br /> error(&quot;Non-table value detected for the prefix table&quot;, 2)<br /> end<br /> if type(step) ~= &#039;number&#039; then<br /> error(&quot;Invalid step value detected&quot;, 2)<br /> end<br /> <br /> -- Get arguments without a number suffix, and check for bad input.<br /> for i,v in ipairs(prefixTable) do<br /> if type(v) ~= &#039;table&#039; or type(v.prefix) ~= &quot;string&quot; or<br /> (v.depend and type(v.depend) ~= &#039;table&#039;) then<br /> error(&#039;Invalid input detected to preprocessArgs prefix table&#039;, 2)<br /> end<br /> preprocessSingleArg(v.prefix)<br /> -- Only parse the depend parameter if the prefix parameter is present<br /> -- and not blank.<br /> if args[v.prefix] and v.depend then<br /> for j, dependValue in ipairs(v.depend) do<br /> if type(dependValue) ~= &#039;string&#039; then<br /> error(&#039;Invalid &quot;depend&quot; parameter value detected in preprocessArgs&#039;)<br /> end<br /> preprocessSingleArg(dependValue)<br /> end<br /> end<br /> end<br /> <br /> -- Get arguments with number suffixes.<br /> local a = 1 -- Counter variable.<br /> local moreArgumentsExist = true<br /> while moreArgumentsExist == true do<br /> moreArgumentsExist = false<br /> for i = a, a + step - 1 do<br /> for j,v in ipairs(prefixTable) do<br /> local prefixArgName = v.prefix .. tostring(i)<br /> if origArgs[prefixArgName] then<br /> -- Do another loop if any arguments are found, even blank ones.<br /> moreArgumentsExist = true<br /> preprocessSingleArg(prefixArgName)<br /> end<br /> -- Process the depend table if the prefix argument is present<br /> -- and not blank, or we are processing &quot;prefix1&quot; and &quot;prefix&quot; is<br /> -- present and not blank, and if the depend table is present.<br /> if v.depend and (args[prefixArgName] or (i == 1 and args[v.prefix])) then<br /> for j,dependValue in ipairs(v.depend) do<br /> local dependArgName = dependValue .. tostring(i)<br /> preprocessSingleArg(dependArgName)<br /> end<br /> end<br /> end<br /> end<br /> a = a + step<br /> end<br /> end<br /> <br /> -- Parse the data parameters in the same order that the old {{infobox}} did, so<br /> -- that references etc. will display in the expected places. Parameters that<br /> -- depend on another parameter are only processed if that parameter is present,<br /> -- to avoid phantom references appearing in article reference lists.<br /> local function parseDataParameters()<br /> <br /> preprocessSingleArg(&#039;autoheaders&#039;)<br /> preprocessSingleArg(&#039;child&#039;)<br /> preprocessSingleArg(&#039;bodyclass&#039;)<br /> preprocessSingleArg(&#039;subbox&#039;)<br /> preprocessSingleArg(&#039;bodystyle&#039;)<br /> preprocessSingleArg(&#039;title&#039;)<br /> preprocessSingleArg(&#039;titleclass&#039;)<br /> preprocessSingleArg(&#039;titlestyle&#039;)<br /> preprocessSingleArg(&#039;above&#039;)<br /> preprocessSingleArg(&#039;aboveclass&#039;)<br /> preprocessSingleArg(&#039;abovestyle&#039;)<br /> preprocessArgs({<br /> {prefix = &#039;subheader&#039;, depend = {&#039;subheaderstyle&#039;, &#039;subheaderrowclass&#039;}}<br /> }, 10)<br /> preprocessSingleArg(&#039;subheaderstyle&#039;)<br /> preprocessSingleArg(&#039;subheaderclass&#039;)<br /> preprocessArgs({<br /> {prefix = &#039;image&#039;, depend = {&#039;caption&#039;, &#039;imagerowclass&#039;}}<br /> }, 10)<br /> preprocessSingleArg(&#039;captionstyle&#039;)<br /> preprocessSingleArg(&#039;imagestyle&#039;)<br /> preprocessSingleArg(&#039;imageclass&#039;)<br /> preprocessArgs({<br /> {prefix = &#039;header&#039;},<br /> {prefix = &#039;data&#039;, depend = {&#039;label&#039;}},<br /> {prefix = &#039;rowclass&#039;},<br /> {prefix = &#039;rowstyle&#039;},<br /> {prefix = &#039;rowcellstyle&#039;},<br /> {prefix = &#039;class&#039;}<br /> }, 50)<br /> preprocessSingleArg(&#039;headerclass&#039;)<br /> preprocessSingleArg(&#039;headerstyle&#039;)<br /> preprocessSingleArg(&#039;labelstyle&#039;)<br /> preprocessSingleArg(&#039;datastyle&#039;)<br /> preprocessSingleArg(&#039;below&#039;)<br /> preprocessSingleArg(&#039;belowclass&#039;)<br /> preprocessSingleArg(&#039;belowstyle&#039;)<br /> preprocessSingleArg(&#039;name&#039;)<br /> -- different behaviour for italics if blank or absent<br /> args[&#039;italic title&#039;] = origArgs[&#039;italic title&#039;]<br /> preprocessSingleArg(&#039;decat&#039;)<br /> preprocessSingleArg(&#039;templatestyles&#039;)<br /> preprocessSingleArg(&#039;child templatestyles&#039;)<br /> preprocessSingleArg(&#039;grandchild templatestyles&#039;)<br /> end<br /> <br /> -- If called via #invoke, use the args passed into the invoking template.<br /> -- Otherwise, for testing purposes, assume args are being passed directly in.<br /> function p.infobox(frame)<br /> if frame == mw.getCurrentFrame() then<br /> origArgs = frame:getParent().args<br /> else<br /> origArgs = frame<br /> end<br /> <br /> parseDataParameters()<br /> <br /> return _infobox()<br /> end<br /> <br /> -- For calling via #invoke within a template<br /> function p.infoboxTemplate(frame)<br /> origArgs = {}<br /> for k,v in pairs(frame.args) do origArgs[k] = mw.text.trim(v) end<br /> <br /> parseDataParameters()<br /> <br /> return _infobox()<br /> end<br /> return p</div> infobox>Izno