« Module:Infobox » : différence entre les versions

De wikarphy
Linarphy (discussion | contributions)
Aucun résumé des modifications
Linarphy (discussion | contributions)
Aucun résumé des modifications
Ligne 1 : Ligne 1 :
-- Module https://fallout-wiki.com/Module:Infobox utilisé comme source et
-- lui-même inspiré de https://fr.wikipedia.org/wiki/Module:Infobox
-- Gère la construction des infobox dans le paramétrage doit être défini
-- un sous-module.
local p = {}
local p = {}
local args = {}
 
local origArgs = {}
-- données concernant les paramètres passés au modèle
local root
local localdata = {}
local empty_row_categories = {}
 
local category_in_empty_row_pattern = '%[%[%s*[Cc][Aa][Tt][Ee][Gg][Oo][Rr][Yy]%s*:[^]]*]]'
-- données concernant la page où est affichée l"infobox
local has_rows = false
local page = {
local lists = {
name = mw.title.getCurrentTitle().prefixedText,
plainlist_t = {
namespace = mw.title.getCurrentTitle().namespace
patterns = {
'^plainlist$',
'%splainlist$',
'^plainlist%s',
'%splainlist%s'
},
found = false,
styles = 'Plainlist/style.css'
},
hlist_t = {
patterns = {
'^hlist$',
'%shlist$',
'^hlist%s',
'%shlist%s'
},
found = false,
styles = 'Hlist/style.css'
}
}
}


local function has_list_class(args_to_check)
-- l"objet principal à retourner
for _, list in pairs(lists) do
local infobox = mw.html.create("div")
if not list.found then
 
for _, arg in pairs(args_to_check) do
--[[ Outils ]]
for _, pattern in ipairs(list.patterns) do
 
if mw.ustring.find(arg or '', pattern) then
local function get_value(value, part)
list.found = true
if type(value) == "string" then
break
return localdata[value]
end
elseif type(value) == "function" then
end
return value(localdata, part)
if list.found then break end
elseif type(value) == "table" then
        -- si plusieurs paramètres possibles (legacy de vieux code),
        -- prendre le premier non vide
for i, j in pairs(value) do
if localdata[j] then
return localdata[j]
end
end
end
end
Ligne 45 : Ligne 36 :
end
end


local function fixChildBoxes(sval, tt)
function p.separator()
local function notempty( s ) return s and s:match( '%S' ) end
return mw.html.create("hr"):addClass("separator")
end
 
--[[ Construction des blocs ]]
 
function p.build_title(part)
local text = get_value(part.value, part) or part.textdefaultvalue or mw.title.getCurrentTitle().text
local subtext = get_value(part.subtitle, part) or part.subtitledefaultvalue
local classes = "avt-infobox-header " .. (part.class or "")
-- Supprime l"indication d"homonymie
text = mw.ustring.gsub(text, " [(][^()]*[)]$", "")
if notempty(sval) then
if subtext and (subtext ~= text) then
local marker = '<span class=special_infobox_marker>'
text = text .. "<br/><small>" .. subtext .. "</small>"
local s = sval
-- start moving templatestyles and categories inside of table rows
local slast = ''
while slast ~= s do
slast = s
s = mw.ustring.gsub(s, '(</[Tt][Rr]%s*>%s*)(%[%[%s*[Cc][Aa][Tt][Ee][Gg][Oo][Rr][Yy]%s*:[^]]*%]%])', '%2%1')
s = mw.ustring.gsub(s, '(</[Tt][Rr]%s*>%s*)(\127[^\127]*UNIQ%-%-templatestyles%-%x+%-QINU[^\127]*\127)', '%2%1')
end
-- end moving templatestyles and categories inside of table rows
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 .. '></tr>'
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 .. '<tr><' .. tt .. ' colspan=2>\n' ..
subcells[k] .. '</' .. tt .. '></tr>'
end
end
end
end
-- the next two lines add a newline at the end of lists for the PHP parser
-- [[Special:Diff/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
end


-- Cleans empty tables
local title = mw.html.create("div")
local function cleanInfobox()
:addClass(classes)
root = tostring(root)
:tag("div")
if has_rows == false then
:addClass("avt-infobox-header-title")
root = mw.ustring.gsub(root, '<table[^<>]*>%s*</table>', '')
:wikitext(text)
end
:allDone()
return title
end
end
p.build_title = p.build_title


-- Returns the union of the values of two tables, as a sequence.
function p.build_images(part)
local function union(t1, t2)
local images = {}
 
local upright, link, caption, alt
local vals = {}
if type(part.imageparameters) == "string" then
for k, v in pairs(t1) do
part.imageparameters = { part.imageparameters }
vals[v] = true
end
end
for k, v in pairs(t2) do
if not part.imageparameters then -- s"il n"y a pas de paramètre image, continuer, peut-être y a-t-il une image par défaut définie dans le module d"infobox
vals[v] = true
part.imageparameters = {}
end
end
local ret = {}
for j, k in ipairs(part.imageparameters) do
for k, v in pairs(vals) do
table.insert(images, localdata[k])
table.insert(ret, k)
end
end
return ret
end


-- Returns a table containing the numbers of the arguments that exist
-- Images par défaut
-- for the specified prefix. For example, if the prefix was 'data', and
if #images == 0 then
-- 'data1', 'data2', and 'data5' exist, it would return {1, 2, 5}.
if part.defaultimages then
local function getArgNums(prefix)
images = part.defaultimages
local nums = {}
if type(images) == "string" then
for k, v in pairs(args) do
images = { images }
local num = tostring(k):match('^' .. prefix .. '([1-9]%d*)$')
end
if num then table.insert(nums, tonumber(num)) end
upright = part.defaultimageupright
caption = part.defaultimagecaption
link = part.defaultimagelink
alt = part.defaultimagealt
if not alt then
alt = "une illustration pour cette infobox serait bienvenue"
end
end
end
end
table.sort(nums)
return nums
end
-- Adds a row to the infobox, with either a header cell
-- or a label/data cell combination.
local function addRow(rowArgs)
if rowArgs.header and rowArgs.header ~= '_BLANK_' then
if #images == 0 then
has_rows = true
return nil
has_list_class({ rowArgs.rowclass, rowArgs.class, args.headerclass })
root
:tag('tr')
:addClass(rowArgs.rowclass)
:cssText(rowArgs.rowstyle)
:tag('th')
:attr('colspan', '2')
:addClass('infobox-header')
:addClass(rowArgs.class)
:addClass(args.headerclass)
-- @deprecated next; target .infobox-<name> .infobox-header
:cssText(args.headerstyle)
:cssText(rowArgs.rowcellstyle)
:wikitext(fixChildBoxes(rowArgs.header, 'th'))
if rowArgs.data then
root:wikitext(
'[[Category:Pages using infobox templates with ignored data cells]]'
)
end
elseif rowArgs.data and rowArgs.data:gsub(category_in_empty_row_pattern, ''):match('^%S') then
has_rows = true
has_list_class({ rowArgs.rowclass, rowArgs.class })
local row = root:tag('tr')
row:addClass(rowArgs.rowclass)
row:cssText(rowArgs.rowstyle)
if rowArgs.label then
row
:tag('th')
:attr('scope', 'row')
:addClass('infobox-label')
-- @deprecated next; target .infobox-<name> .infobox-label
:cssText(args.labelstyle)
:cssText(rowArgs.rowcellstyle)
:wikitext(rowArgs.label)
:done()
end
 
local dataCell = row:tag('td')
dataCell
:attr('colspan', not rowArgs.label and '2' or nil)
:addClass(not rowArgs.label and 'infobox-full-data' or 'infobox-data')
:addClass(rowArgs.class)
-- @deprecated next; target .infobox-<name> .infobox(-full)-data
:cssText(rowArgs.datastyle)
:cssText(rowArgs.rowcellstyle)
:wikitext(fixChildBoxes(rowArgs.data, 'td'))
else
table.insert(empty_row_categories, rowArgs.data or '')
end
end
end
local function renderTitle()
if not args.title then return end
has_rows = true
has_list_class({args.titleclass})
root
upright = upright or get_value(part.uprightparameter) or part.defaultupright or "1.2"
:tag('caption')
link = link or get_value(part.linkparameter) or part.defaultlink
:addClass('infobox-title')
caption = caption or get_value(part.captionparameter) or part.defaultcaption
:addClass(args.titleclass)
alt = alt or get_value(part.altparameter) or part.defaultalt
-- @deprecated next; target .infobox-<name> .infobox-title
:cssText(args.titlestyle)
:wikitext(args.title)
end
if tonumber(upright) then
upright = tostring( tonumber(upright) / #images )
end
 
local style = part.style or {}


local function renderAboveRow()
-- Partie image
if not args.above then return end


has_rows = true
local imagesString = ""
has_list_class({ args.aboveclass })
for i,image in pairs(images) do
if image == "-" then
root
return
:tag('tr')
end
:tag('th')
imagesString = imagesString ..  "[[Fichier:" .. image .. "|frameless"
:attr('colspan', '2')
if alt then
:addClass('infobox-above')
imagesString = imagesString .. "|alt=" .. alt
:addClass(args.aboveclass)
end
-- @deprecated next; target .infobox-<name> .infobox-above
if link then
:cssText(args.abovestyle)
imagesString = imagesString .. "|link=" .. link
:wikitext(fixChildBoxes(args.above,'th'))
end
end
if upright then
imagesString = imagesString .. "|upright=" .. upright
elseif #images > 1 then
imagesString = imagesString .. "|upright=" .. ( 1 / #images )
end
imagesString = imagesString .. "]]"
end


local function renderBelowRow()
local image = mw.html.create("div")
if not args.below then return end
:addClass("avt-infobox-images")
:css(style)
:wikitext(imagesString)


has_rows = true
-- Partie légende
has_list_class({ args.belowclass })
local captionobj
if caption then
captionobj = mw.html.create("div")
:wikitext(caption)
:css(part.legendstyle or {})
:addClass("avt-infobox-images-legend")
:done()
end
root
-- séparateur
:tag('tr')
local separator
:tag('td')
if part.separator then
:attr('colspan', '2')
separator = separator(part)
:addClass('infobox-below')
:addClass(args.belowclass)
-- @deprecated next; target .infobox-<name> .infobox-below
:cssText(args.belowstyle)
:wikitext(fixChildBoxes(args.below,'td'))
end
 
local function addSubheaderRow(subheaderArgs)
if subheaderArgs.data and
subheaderArgs.data:gsub(category_in_empty_row_pattern, ''):match('^%S') then
has_rows = true
has_list_class({ subheaderArgs.rowclass, subheaderArgs.class })
local row = root:tag('tr')
row:addClass(subheaderArgs.rowclass)
 
local dataCell = row:tag('td')
dataCell
:attr('colspan', '2')
:addClass('infobox-subheader')
:addClass(subheaderArgs.class)
:cssText(subheaderArgs.datastyle)
:cssText(subheaderArgs.rowcellstyle)
:wikitext(fixChildBoxes(subheaderArgs.data, 'td'))
else
table.insert(empty_row_categories, subheaderArgs.data or '')
end
end
return mw.html.create("div")
:node(image)
:node(captionobj)
:node(separator)
:done()
end
end
p.build_images = p.build_images


local function renderSubheaders()
function p.build_text(part)
if args.subheader then
local class = part.class or ""
args.subheader1 = args.subheader
local style = {
["text-align"] = "center",
["font-weight"] = "bold",
}
if part.style then
for i, j in pairs(part.style) do
style[i] = j
end
end
end
if args.subheaderrowclass then
local text = get_value(part.value, part) or part.defaultvalue
args.subheaderrowclass1 = args.subheaderrowclass
if text == "-" then
return
end
end
local subheadernums = getArgNums('subheader')
if not text then
for k, num in ipairs(subheadernums) do
return nil
addSubheaderRow({
data = args['subheader' .. tostring(num)],
-- @deprecated next; target .infobox-<name> .infobox-subheader
datastyle = args.subheaderstyle,
rowcellstyle = args['subheaderstyle' .. tostring(num)],
class = args.subheaderclass,
rowclass = args['subheaderrowclass' .. tostring(num)]
})
end
end
local formattedtext = mw.html.create("p")
:addClass(class)
:css(style)
:wikitext(text)
:done()
return formattedtext
end
end
p.build_text = p.build_text


local function addImageRow(imageArgs)
function p.build_row(part)
 
local class = part.class or ""
if imageArgs.data and
local style = part.style or {}
imageArgs.data:gsub(category_in_empty_row_pattern, ''):match('^%S') then
local valueClass = part.valueClass or ""
 
local valueStyle = part.valueStyle or {}
has_rows = true
local value, number = get_value(part.value, part)
has_list_class({ imageArgs.rowclass, imageArgs.class })
if not value then
local row = root:tag('tr')
value = part.defaultvalue
row:addClass(imageArgs.rowclass)
 
local dataCell = row:tag('td')
dataCell
:attr('colspan', '2')
:addClass('infobox-image')
:addClass(imageArgs.class)
:cssText(imageArgs.datastyle)
:wikitext(fixChildBoxes(imageArgs.data, 'td'))
else
table.insert(empty_row_categories, imageArgs.data or '')
end
end
end
if value == nil then
 
return nil
local function renderImages()
if args.image then
args.image1 = args.image
end
end
if args.caption then
if not number then
args.caption1 = args.caption
number = 0 -- == indéfini
end
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')
:addClass('infobox-caption')
-- @deprecated next; target .infobox-<name> .infobox-caption
:cssText(args.captionstyle)
:wikitext(caption)
end
addImageRow({
data = tostring(data),
-- @deprecated next; target .infobox-<name> .infobox-image
datastyle = args.imagestyle,
class = args.imageclass,
rowclass = args['imagerowclass' .. tostring(num)]
})
end
end


-- When autoheaders are turned on, preprocesses the rows
local label = part.label
local function preprocessRows()
if number > 1 and part.plurallabel then
if not args.autoheaders then return end
label = part.plurallabel
elseif number == 1 and part.singularlabel then
local rownums = union(getArgNums('header'), getArgNums('data'))
label = part.singularlabel
table.sort(rownums)
local lastheader
for k, num in ipairs(rownums) do
if args['header' .. tostring(num)] then
if lastheader then
args['header' .. tostring(lastheader)] = nil
end
lastheader = num
elseif args['data' .. tostring(num)] and
args['data' .. tostring(num)]:gsub(
category_in_empty_row_pattern, ''
):match('^%S') then
local data = args['data' .. tostring(num)]
if data:gsub(category_in_empty_row_pattern, ''):match('%S') then
lastheader = nil
end
end
end
end
if lastheader then
if type(label) == "function" then
args['header' .. tostring(lastheader)] = nil
label = label(localdata, localdata.item)
end
end
end


-- Gets the union of the header and data argument numbers,
-- format
-- and renders them all in order
local formattedvalue = mw.html.create("div")
local function renderRows()
-- Le "\n" est requis lorsque value est une liste
 
-- commençant par "*" ou "#"
local rownums = union(getArgNums('header'), getArgNums('data'))
:wikitext("\n" .. value)
table.sort(rownums)
for k, num in ipairs(rownums) do
if part.hidden == true then
addRow({
formattedvalue
header = args['header' .. tostring(num)],
:attr({class="NavContent", style="display: none; text-align: left;"})
label = args['label' .. tostring(num)],
formattedvalue = mw.html.create("div")
data = args['data' .. tostring(num)],
:attr({class="NavFrame", title="[Afficher]/[Masquer]", style="border: none; padding: 0;"})
datastyle = args.datastyle,
:node(formattedvalue)
class = args['class' .. tostring(num)],
rowclass = args['rowclass' .. tostring(num)],
-- @deprecated next; target .infobox-<name> rowclass
rowstyle = args['rowstyle' .. tostring(num)],
rowcellstyle = args['rowcellstyle' .. tostring(num)]
})
end
end
end
formattedvalue =  mw.html.create("td")
 
:node(formattedvalue)
local function renderNavBar()
:addClass(valueClass)
if not args.name then return end
:css(valueStyle)
 
:allDone()
has_rows = true
root
local formattedlabel
:tag('tr')
if label then
:tag('td')
formattedlabel = mw.html.create("th")
:attr('colspan', '2')
:attr("scope", "row")
:addClass('infobox-navbar')
:wikitext(label)
:wikitext(require('Module:Navbar')._navbar{
:done()
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(require('Module:Italic title')._main({}))
end
end
local row = mw.html.create("tr")
:addClass(class)
:css(style)
:node(formattedlabel)
:node(formattedvalue)
:done()
return row
end
end
p.build_row = p.build_row


-- Categories in otherwise empty rows are collected in empty_row_categories.
function p.build_succession(part)
-- This function adds them to the module output. It is not affected by
if not part.value then
-- args.decat because this module should not prevent module-external categories
return nil
-- from rendering.
local function renderEmptyRowCategories()
for _, s in ipairs(empty_row_categories) do
root:wikitext(s)
end
end
end
 
local values = part.value
-- Render tracking categories. args.decat == turns off tracking categories.
local before = get_value(values["before"], part)
local function renderTrackingCategories()
local center = get_value(values["center"], part)
if args.decat == 'yes' then return end
local after  = get_value(values["after"], part)
if args.child == 'yes' then
if args.title then
if not before and not center and not after then
root:wikitext(
return nil
'[[Category:Pages using embedded infobox templates with the title parameter]]'
)
end
elseif #(getArgNums('data')) == 0 and mw.title.getCurrentTitle().namespace == 0 then
root:wikitext('[[Category:Articles using infobox templates with no data rows]]')
end
end
end
local rowI = mw.html.create("tr")
local styleI = {}
local colspan = "2"
styleI["padding"] = "1px"
cellI = mw.html.create("td")
:attr({colspan = colspan})
:attr({align = "center"})
:css(styleI)
local styleT = {}
styleT["margin"] = "0px"
styleT["background-color"] = "transparent"
styleT["width"] = "100%"
tabC = mw.html.create("table")
:attr({cellspacing = "0"})
:addClass("navigation-not-searchable")
:css(styleT)
local row = mw.html.create("tr")


--[=[
local color = part.color
Loads the templatestyles for the infobox.


TODO: FINISH loading base templatestyles here rather than in
local style = {}
MediaWiki:Common.css. There are 4-5000 pages with 'raw' infobox tables.
local arrowLeft
See [[Mediawiki_talk:Common.css/to_do#Infobox]] and/or come help :).
local arrowRight
When we do this we should clean up the inline CSS below too.
Will have to do some bizarre conversion category like with sidebar.
 
]=]
local function loadTemplateStyles()
local frame = mw.getCurrentFrame()
local hlist_templatestyles = ''
if color == "default" then
if lists.hlist_t.found then
arrowLeft = "[[Fichier:SCRWEST.png|13px|alt=Précédent|link=]]"
hlist_templatestyles = frame:extensionTag{
arrowRight = "[[Fichier:SCREAST.png|13px|alt=Suivant|link=]]"
name = 'templatestyles', args = { src = lists.hlist_t.styles }
else
}
arrowLeft = "[[Fichier:SCRWEST.png|13px|alt=Précédent|link=]]"
arrowRight = "[[Fichier:SCREAST.png|13px|alt=Suivant|link=]]"
style["background-color"] = color
end
end
local plainlist_templatestyles = ''
local styleTrans = {}
if lists.plainlist_t.found then
plainlist_templatestyles = frame:extensionTag{
local widthCell = "44%"
name = 'templatestyles', args = { src = lists.plainlist_t.styles }
if center then
}
widthCenter = "28%"
widthCell = "29%"
end
end
-- See function description
local formattedbefore
local base_templatestyles = frame:extensionTag{
if before then
name = 'templatestyles', args = { src = 'Module:Infobox/style.css' }
formattedbefore = mw.html.create("td")
}
:attr({valign = "middle"})
 
:attr({align = "left"})
local templatestyles = ''
:attr({width = "5%"})
if args['templatestyles'] then
:css(style)
templatestyles = frame:extensionTag{
:wikitext(arrowLeft)
name = 'templatestyles', args = { src = args['templatestyles'] }
:done()
}
row:node(formattedbefore)
formattedbefore = mw.html.create("td")
:attr({width = "1%"})
:css(style)
:wikitext("")
:done()
row:node(formattedbefore)
formattedbefore = mw.html.create("td")
:attr({align = "left"})
:attr({valign = "middle"})
:attr({width = widthCell})
:css(style)
:wikitext(before)
:done()
row:node(formattedbefore)
else
formattedbefore = mw.html.create("td")
:attr({valign = "middle"})
:attr({align = "left"})
:attr({width = "5%"})
:css(styleTrans)
:wikitext("")
:done()
row:node(formattedbefore)
formattedbefore = mw.html.create("td")
:attr({width = "1%"})
:css(styleTrans)
:wikitext("")
:done()
row:node(formattedbefore)
formattedbefore = mw.html.create("td")
:attr({align = "left"})
:attr({valign = "middle"})
:attr({width = widthCell})
:css(styleTrans)
:wikitext("")
:done()
row:node(formattedbefore)
end
end
local child_templatestyles = ''
local formattedcenter
if args['child templatestyles'] then
formattedcenter = mw.html.create("td")
child_templatestyles = frame:extensionTag{
:attr({width = "1%"})
name = 'templatestyles', args = { src = args['child templatestyles'] }
:css(styleTrans)
}
:wikitext("")
:done()
row:node(formattedcenter)
if center then
formattedcenter = mw.html.create("td")
:attr({align = "center"})
:attr({valign = "middle"})
:attr({width = widthCenter})
:css(style)
:wikitext(center)
:done()
row:node(formattedcenter)
formattedcenter = mw.html.create("td")
:attr({width = "1%"})
:css(styleTrans)
:wikitext("")
:done()
row:node(formattedcenter)
end
end
local grandchild_templatestyles = ''
local formattedafter
if args['grandchild templatestyles'] then
if after then
grandchild_templatestyles = frame:extensionTag{
formattedafter = mw.html.create("td")
name = 'templatestyles', args = { src = args['grandchild templatestyles'] }
:attr({align = "right"})
}
:attr({valign = "middle"})
:attr({width = widthCell})
:css(style)
:wikitext(after)
:done()
row:node(formattedafter)
formattedbefore = mw.html.create("td")
:attr({width = "1%"})
:css(style)
:wikitext("")
:done()
row:node(formattedbefore)
formattedafter = mw.html.create("td")
:attr({align = "right"})
:attr({valign = "middle"})
:attr({width = "5%"})
:css(style)
:wikitext(arrowRight)
:done()
row:node(formattedafter)
else
formattedafter = mw.html.create("td")
:attr({align = "right"})
:attr({valign = "middle"})
:attr({width = widthCell})
:css(styleTrans)
:wikitext("")
:done()
row:node(formattedafter)
formattedbefore = mw.html.create("td")
:attr({width = "1%"})
:css(styleTrans)
:wikitext("")
:done()
row:node(formattedbefore)
formattedafter = mw.html.create("td")
:attr({align = "right"})
:attr({valign = "middle"})
:attr({width = "5%"})
:css(styleTrans)
:wikitext("")
:done()
row:node(formattedafter)
end
end
return table.concat({
row:done()
-- hlist -> plainlist -> base is best-effort to preserve old Common.css ordering.
tabC:node(row)
-- this ordering is not a guarantee because the rows of interest invoking
tabC:done()
-- each class may not be on a specific page
cellI:node(tabC)
hlist_templatestyles,
cellI:done()
plainlist_templatestyles,
rowI:node(cellI)
base_templatestyles,
rowI:allDone()
templatestyles,
child_templatestyles,
return rowI
grandchild_templatestyles
})
end
end
p.build_succession = p.build_succession


-- common functions between the child and non child cases
function p.build_row1col(part)
local function structure_infobox_common()
if not part.value then
renderSubheaders()
return nil
renderImages()
end
preprocessRows()
renderRows()
renderBelowRow()
renderNavBar()
renderItalicTitle()
renderEmptyRowCategories()
renderTrackingCategories()
cleanInfobox()
end


-- Specify the overall layout of the infobox, with special settings if the
local class = "row1col"
-- infobox is used as a 'child' inside another infobox.
if part.class then
local function _infobox()
class = class .. " " .. part.class
if args.child ~= 'yes' then
end
root = mw.html.create('table')
local text = get_value(part.value, part)
if not text then
return nil
end


root
local formattedlabel
:addClass(args.subbox == 'yes' and 'infobox-subbox' or 'infobox')
formattedlabel = mw.html.create("th")
:addClass(args.bodyclass)
:attr({ colspan = "2" })
-- @deprecated next; target .infobox-<name>
:addClass(class)
:cssText(args.bodystyle)
:wikitext(text)
:done()
has_list_class({ args.bodyclass })


renderTitle()
local row = mw.html.create("tr")
renderAboveRow()
:node(formattedlabel)
else
:done()
root = mw.html.create()
 
root
:wikitext(args.title)
end
structure_infobox_common()
return loadTemplateStyles() .. root
return row
end
end
p.build_row1Col = p.build_row1col


-- If the argument exists and isn't blank, add it to the argument table.
function p.buildtable(part)
-- Blank arguments are treated as nil to match the behaviour of ParserFunctions.
local class = nil
local function preprocessSingleArg(argName)
if part.collapseparameters then
if origArgs[argName] and origArgs[argName] ~= '' then
if part.collapseparameters.collapsible == true then
args[argName] = origArgs[argName]
class = "mw-collapsible"
if part.collapseparameters.collapsed == true then
class = class .." mw-collapsed"
end
end
end
end
end
local tab = mw.html.create("table")
:addClass(class)
:css(part.style or {})


-- Assign the parameters with the given prefixes to the args table, in order, in
local rows = part.rows
-- 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
-- expand parameters so that we have a list of tables
-- tables, each of which has two possible fields, a "prefix" string and a
local i = 1
-- "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.
local function preprocessArgs(prefixTable, step)
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.
while (i <= #rows) do  
for i,v in ipairs(prefixTable) do
local l = rows[i]
if type(v) ~= 'table' or type(v.prefix) ~= "string" or
if type(l) == "function" then
(v.depend and type(v.depend) ~= 'table') then
l = l(localdata, localdata.item)
error('Invalid input detected to preprocessArgs prefix table', 2)
end
end
preprocessSingleArg(v.prefix)
if (type(l) == "table") and (l.type == "multi") then
-- Only parse the depend parameter if the prefix parameter is present
table.remove(rows, i) 
-- and not blank.
for j, row in ipairs(l.rows) do
if args[v.prefix] and v.depend then
table.insert(rows, i + j - 1, row)  
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
elseif type(l) == "nil" then
table.remove(rows, i)
elseif type(l) ~= "table" then
return error("les lignes d'infobox ('rows') doivent être des tables, est " .. type(l))
else
i = i + 1
end
end
end
-- CREATE ROW
local expandedrows = {}
for k, row in ipairs(rows) do
local v = p.buildblock(row)
if v then
table.insert(expandedrows, v)
end
end
if (#expandedrows == 0) then
return nil
end
end
rows = expandedrows


-- Get arguments with number suffixes.
-- ADD TITLE
local a = 1 -- Counter variable.
local title
local moreArgumentsExist = true
if part.title or part.singulartitle or part.pluraltitle then
while moreArgumentsExist == true do
local text
moreArgumentsExist = false
if #rows > 1 and part.pluraltitle then
for i = a, a + step - 1 do
text = part.pluraltitle
for j,v in ipairs(prefixTable) do
elseif #rows == 1 and part.singulartitle then
local prefixArgName = v.prefix .. tostring(i)
text = part.singulartitle
if origArgs[prefixArgName] then
else
-- Do another loop if any arguments are found, even blank ones.
text = part.title
moreArgumentsExist = true
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
end
a = a + step
 
local style = part.titlestyle or {}
 
title = mw.html.create("caption")
:attr({ colspan = "2" })
:css(style)
:wikitext(text)
:done()
end
if title then
tab:node(title)
end
for i, j in pairs (rows) do
tab:node(j)
end
end
if part.separator then
local separator = p.separator(part)
tab:node(separator)
end
tab:allDone()
return tab
end
end
p.buildTable = p.buildtable


-- 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
Construction de l"infobox
-- depend on another parameter are only processed if that parameter is present,
]]
-- to avoid phantom references appearing in article reference lists.
local function parseDataParameters()


preprocessSingleArg('autoheaders')
function p.buildblock(block)
preprocessSingleArg('child')
if type(block) == "function" then
preprocessSingleArg('bodyclass')
block = block(localdata)
preprocessSingleArg('subbox')
end
preprocessSingleArg('bodystyle')
 
preprocessSingleArg('title')
-- list of functions for block buildings
preprocessSingleArg('titleclass')
local blocktypes = {
preprocessSingleArg('titlestyle')
["images"] = p.build_images,
preprocessSingleArg('above')
["table"] = p.buildtable,
preprocessSingleArg('aboveclass')
["row"] = p.build_row,
preprocessSingleArg('abovestyle')
["row1col"] = p.build_row1col,
preprocessArgs({
["succession"] = p.build_succession,
{prefix = 'subheader', depend = {'subheaderstyle', 'subheaderrowclass'}}
["text"] = p.build_text,
}, 10)
["title"] = p.build_title,
preprocessSingleArg('subheaderstyle')
}
preprocessSingleArg('subheaderclass')
if type(block) ~= "table" or (not block.type) or (not blocktypes[block.type]) then
preprocessArgs({
return blocktypes["invalid"](block)
{prefix = 'image', depend = {'caption', 'imagerowclass'}}
end
}, 10)
return blocktypes[block.type](block)  
preprocessSingleArg('captionstyle')
preprocessSingleArg('imagestyle')
preprocessSingleArg('imageclass')
preprocessArgs({
{prefix = 'header'},
{prefix = 'data', depend = {'label'}},
{prefix = 'rowclass'},
{prefix = 'rowstyle'},
{prefix = 'rowcellstyle'},
{prefix = 'class'}
}, 50)
preprocessSingleArg('headerclass')
preprocessSingleArg('headerstyle')
preprocessSingleArg('labelstyle')
preprocessSingleArg('datastyle')
preprocessSingleArg('below')
preprocessSingleArg('belowclass')
preprocessSingleArg('belowstyle')
preprocessSingleArg('name')
-- different behaviour for italics if blank or absent
args['italic title'] = origArgs['italic title']
preprocessSingleArg('decat')
preprocessSingleArg('templatestyles')
preprocessSingleArg('child templatestyles')
preprocessSingleArg('grandchild templatestyles')
end
end
p.buildBlock = p.buildblock


-- If called via #invoke, use the args passed into the invoking template.
function p.build()
-- Otherwise, for testing purposes, assume args are being passed directly in.
localdata = require("Module:Infobox/Localdata")
function p.infobox(frame)
item = localdata.item
if frame == mw.getCurrentFrame() then
 
origArgs = frame:getParent().args
-- chargement du module de paramétrage
else
local moduledata = require("Module:Infobox/" .. localdata.modulename)
origArgs = frame
moduledata.name = localdata.modulename
-- class
local class = "infobox avt-infobox"
if moduledata.class then
class = class .. " " .. moduledata.class
end
end
-- style
local style = moduledata.style or {}
parseDataParameters()
-- build infobox
infobox :addClass(class)
:css(style)
return _infobox()
for i, j in pairs(moduledata.parts) do
infobox:node(p.buildblock(j))
end
 
return tostring(infobox)
end
end


-- For calling via #invoke within a template
function p.infoboxTemplate(frame)
origArgs = {}
for k,v in pairs(frame.args) do origArgs[k] = mw.text.trim(v) end
parseDataParameters()
return _infobox()
end
return p
return p

Version du 26 février 2025 à 18:57

La documentation pour ce module peut être créée à Module:Infobox/doc

-- Module https://fallout-wiki.com/Module:Infobox utilisé comme source et
-- lui-même inspiré de https://fr.wikipedia.org/wiki/Module:Infobox
-- Gère la construction des infobox dans le paramétrage doit être défini
-- un sous-module.

local p = {}

-- données concernant les paramètres passés au modèle
local localdata = {}

-- données concernant la page où est affichée l"infobox
local page = {
	name = mw.title.getCurrentTitle().prefixedText,
	namespace =  mw.title.getCurrentTitle().namespace
}

-- l"objet principal à retourner
local infobox = mw.html.create("div")

--[[ Outils ]]

local function get_value(value, part)
	if type(value) == "string" then
		return localdata[value]
	elseif type(value) == "function" then
		return value(localdata, part)
	elseif type(value) == "table" then
        -- si plusieurs paramètres possibles (legacy de vieux code),
        -- prendre le premier non vide
		for i, j in pairs(value) do
			if localdata[j] then
				return localdata[j]
			end
		end
	end
end

function p.separator()
	return mw.html.create("hr"):addClass("separator")	
end

--[[ Construction des blocs ]]

function p.build_title(part)
	local text = get_value(part.value, part) or part.textdefaultvalue or mw.title.getCurrentTitle().text
	local subtext = get_value(part.subtitle, part) or part.subtitledefaultvalue
	local classes = "avt-infobox-header " .. (part.class or "")
	
	-- Supprime l"indication d"homonymie
	text = mw.ustring.gsub(text, " [(][^()]*[)]$", "")
	
	if subtext and (subtext ~= text) then
		text = text .. "<br/><small>" .. subtext .. "</small>"
	end

	local title = mw.html.create("div")
		:addClass(classes)
		:tag("div")
			:addClass("avt-infobox-header-title")
			:wikitext(text)
		:allDone()
	
	return title
end
p.build_title = p.build_title

function p.build_images(part)
	local images = {}
	local upright, link, caption, alt
	if type(part.imageparameters) == "string" then
		part.imageparameters = { part.imageparameters }
	end
	if not part.imageparameters then -- s"il n"y a pas de paramètre image, continuer, peut-être y a-t-il une image par défaut définie dans le module d"infobox
		part.imageparameters = {}
	end
	for j, k in ipairs(part.imageparameters) do
		table.insert(images, localdata[k])
	end

	-- Images par défaut
	if #images == 0 then
		if part.defaultimages then
			images = part.defaultimages
			if type(images) == "string" then
				images = { images }
			end
			upright = part.defaultimageupright
			caption = part.defaultimagecaption
			link = part.defaultimagelink
			alt = part.defaultimagealt
			if not alt then
				alt = "une illustration pour cette infobox serait bienvenue"
			end
		end
	end
	
	if #images == 0 then
		return nil
	end
	
	upright = upright or get_value(part.uprightparameter) or part.defaultupright or "1.2"
	link = link or get_value(part.linkparameter) or part.defaultlink
	caption = caption or get_value(part.captionparameter) or part.defaultcaption
	alt = alt or get_value(part.altparameter) or part.defaultalt
	
	if tonumber(upright) then
		upright = tostring( tonumber(upright) / #images )
	end

	local style = part.style or {}

	-- Partie image

	local imagesString = ""
	for i,image in pairs(images) do
		if image == "-" then
			return
		end
		imagesString = imagesString ..  "[[Fichier:" .. image .. "|frameless"
		if alt then
			imagesString = imagesString .. "|alt=" .. alt
		end
		if link then
			imagesString = imagesString .. "|link=" .. link
		end
		if upright then
			imagesString = imagesString .. "|upright=" .. upright
		elseif #images > 1 then
			imagesString = imagesString .. "|upright=" .. ( 1 / #images )
		end
		imagesString = imagesString .. "]]"
	end

	local image = mw.html.create("div")
		:addClass("avt-infobox-images")
		:css(style)
		:wikitext(imagesString)

	-- Partie légende
	local captionobj
	if caption then
		captionobj = mw.html.create("div")
			:wikitext(caption)
			:css(part.legendstyle or {})
			:addClass("avt-infobox-images-legend")
			:done()
	end
	
	-- séparateur
	local separator
	if part.separator then
		separator = separator(part)
	end
	return mw.html.create("div")
		:node(image)
		:node(captionobj)
		:node(separator)
		:done()
end
p.build_images = p.build_images

function p.build_text(part)
	local class = part.class or ""
	local style = {
		["text-align"] = "center",
		["font-weight"] = "bold",
	}
	if part.style then
		for i, j in pairs(part.style) do
			style[i] = j
		end
	end
	local text = get_value(part.value, part) or part.defaultvalue
	if text == "-" then
		return
	end
	if not text then
		return nil
	end
	local formattedtext = mw.html.create("p")
		:addClass(class)
		:css(style)
		:wikitext(text)
		:done()
	return formattedtext
end
p.build_text = p.build_text

function p.build_row(part)
	local class = part.class or ""
	local style = part.style or {}
	local valueClass = part.valueClass or ""
	local valueStyle = part.valueStyle or {}
	local value, number = get_value(part.value, part)
	
	if not value then
		value = part.defaultvalue
	end
	if value == nil then
		return nil
	end
	if not number then
		number = 0 -- == indéfini
	end

	local label = part.label
	if number > 1 and part.plurallabel then
		label = part.plurallabel
	elseif number == 1 and part.singularlabel then
		label = part.singularlabel
	end
	if type(label) == "function" then
			label = label(localdata, localdata.item)
	end

	-- format
	local formattedvalue = mw.html.create("div")
		-- Le "\n" est requis lorsque value est une liste 
		-- commençant par "*" ou "#"
		:wikitext("\n" .. value)
		
	if part.hidden == true then
		formattedvalue
			:attr({class="NavContent", style="display: none; text-align: left;"})
		formattedvalue = mw.html.create("div")
			:attr({class="NavFrame", title="[Afficher]/[Masquer]", style="border: none; padding: 0;"})
			:node(formattedvalue)
	end
	formattedvalue =  mw.html.create("td")
			:node(formattedvalue)
			:addClass(valueClass)
			:css(valueStyle)
			:allDone()
	
	local formattedlabel
	if label then
		formattedlabel = mw.html.create("th")
			:attr("scope", "row")
			:wikitext(label)
			:done()
	end
	local row = mw.html.create("tr")
		:addClass(class)
		:css(style)
		:node(formattedlabel)
		:node(formattedvalue)
		:done()
	
	return row
end
p.build_row = p.build_row

function p.build_succession(part)
	if not part.value then
		return nil
	end
	
	local values = part.value
	local before = get_value(values["before"], part)
	local center = get_value(values["center"], part)
	local after  = get_value(values["after"], part)
	
	if not before and not center and not after then
		return nil
	end
	
	local rowI = mw.html.create("tr")
	
	local styleI = {}
	local colspan = "2"
	styleI["padding"] = "1px"
	cellI = mw.html.create("td")
			:attr({colspan = colspan})
			:attr({align = "center"})
			:css(styleI)
	
	local styleT = {}
	styleT["margin"] = "0px"
	styleT["background-color"] = "transparent"
	styleT["width"] = "100%"
	tabC = mw.html.create("table")
			:attr({cellspacing = "0"})
			:addClass("navigation-not-searchable")
			:css(styleT)
	
	local row = mw.html.create("tr")

	local color = part.color

	local style = {}
	local arrowLeft
	local arrowRight
	
	if color == "default" then
		arrowLeft = "[[Fichier:SCRWEST.png|13px|alt=Précédent|link=]]"
		arrowRight = "[[Fichier:SCREAST.png|13px|alt=Suivant|link=]]"
	else
		arrowLeft = "[[Fichier:SCRWEST.png|13px|alt=Précédent|link=]]"
		arrowRight = "[[Fichier:SCREAST.png|13px|alt=Suivant|link=]]"
		style["background-color"] = color
	end
	
	local styleTrans = {}
	
	local widthCell = "44%"
	if center then
		widthCenter = "28%"
		widthCell = "29%"
	end
	
	local formattedbefore
	if before then
		formattedbefore = mw.html.create("td")
			:attr({valign = "middle"})
			:attr({align = "left"})
			:attr({width = "5%"})
			:css(style)
			:wikitext(arrowLeft)
			:done()
		row:node(formattedbefore)
		formattedbefore = mw.html.create("td")
			:attr({width = "1%"})
			:css(style)
			:wikitext("")
			:done()
		row:node(formattedbefore)
		formattedbefore = mw.html.create("td")
			:attr({align = "left"})
			:attr({valign = "middle"})
			:attr({width = widthCell})
			:css(style)
			:wikitext(before)
			:done()
		row:node(formattedbefore)
	else
		formattedbefore = mw.html.create("td")
			:attr({valign = "middle"})
			:attr({align = "left"})
			:attr({width = "5%"})
			:css(styleTrans)
			:wikitext("")
			:done()
		row:node(formattedbefore)
		formattedbefore = mw.html.create("td")
			:attr({width = "1%"})
			:css(styleTrans)
			:wikitext("")
			:done()
		row:node(formattedbefore)
		formattedbefore = mw.html.create("td")
			:attr({align = "left"})
			:attr({valign = "middle"})
			:attr({width = widthCell})
			:css(styleTrans)
			:wikitext("")
			:done()
		row:node(formattedbefore)
	end
	
	local formattedcenter
	formattedcenter = mw.html.create("td")
		:attr({width = "1%"})
		:css(styleTrans)
		:wikitext("")
		:done()
	row:node(formattedcenter)
	
	if center then
		formattedcenter = mw.html.create("td")
			:attr({align = "center"})
			:attr({valign = "middle"})
			:attr({width = widthCenter})
			:css(style)
			:wikitext(center)
			:done()
		row:node(formattedcenter)
		formattedcenter = mw.html.create("td")
			:attr({width = "1%"})
			:css(styleTrans)
			:wikitext("")
			:done()
		row:node(formattedcenter)
	end
	
	local formattedafter
	if after then
		formattedafter = mw.html.create("td")
			:attr({align = "right"})
			:attr({valign = "middle"})
			:attr({width = widthCell})
			:css(style)
			:wikitext(after)
			:done()
		row:node(formattedafter)
		formattedbefore = mw.html.create("td")
			:attr({width = "1%"})
			:css(style)
			:wikitext("")
			:done()
		row:node(formattedbefore)
		formattedafter = mw.html.create("td")
			:attr({align = "right"})
			:attr({valign = "middle"})
			:attr({width = "5%"})
			:css(style)
			:wikitext(arrowRight)
			:done()
		row:node(formattedafter)
	else
		formattedafter = mw.html.create("td")
			:attr({align = "right"})
			:attr({valign = "middle"})
			:attr({width = widthCell})
			:css(styleTrans)
			:wikitext("")
			:done()
		row:node(formattedafter)
		formattedbefore = mw.html.create("td")
			:attr({width = "1%"})
			:css(styleTrans)
			:wikitext("")
			:done()
		row:node(formattedbefore)
		formattedafter = mw.html.create("td")
			:attr({align = "right"})
			:attr({valign = "middle"})
			:attr({width = "5%"})
			:css(styleTrans)
			:wikitext("")
			:done()
		row:node(formattedafter)
	end
	
	row:done()
	tabC:node(row)
	tabC:done()
	cellI:node(tabC)
	cellI:done()
	rowI:node(cellI)
	rowI:allDone()
	
	return rowI
end
p.build_succession = p.build_succession

function p.build_row1col(part)
	if not part.value then
		return nil
	end

	local class = "row1col"
	if part.class then
		class = class .. " " .. part.class
	end
	
	local text = get_value(part.value, part)
	
	if not text then
		return nil
	end

	local formattedlabel
	formattedlabel = mw.html.create("th")
		:attr({ colspan = "2" })
		:addClass(class)
		:wikitext(text)
		:done()

	local row = mw.html.create("tr")
		:node(formattedlabel)
		:done()
	
	return row
end
p.build_row1Col = p.build_row1col

function p.buildtable(part)
	local class = nil
	if part.collapseparameters then
		if part.collapseparameters.collapsible == true then
			class = "mw-collapsible"
			if part.collapseparameters.collapsed == true then
				class = class .." mw-collapsed"
			end
		end
	end
	
	local tab = mw.html.create("table")
		:addClass(class)
		:css(part.style or {})

	local rows = part.rows
	
	-- expand parameters so that we have a list of tables
	local i = 1

	while (i <= #rows) do 
		local l = rows[i]
		if type(l) == "function" then 
			l = l(localdata, localdata.item)
		end
		if (type(l) == "table") and (l.type == "multi") then
			table.remove(rows, i)  
			for j, row in ipairs(l.rows) do
				table.insert(rows, i + j - 1, row) 
			end
		elseif type(l) == "nil" then
			table.remove(rows, i)
		elseif type(l) ~= "table" then 
			return error("les lignes d'infobox ('rows') doivent être des tables, est " .. type(l))
		else
			i = i + 1
		end
	end 

	-- CREATE ROW
	local expandedrows = {}
	for k, row in ipairs(rows) do
		local v = p.buildblock(row)
		if v then
			table.insert(expandedrows, v)
		end
	end
	if (#expandedrows == 0) then
		return nil
	end
	rows = expandedrows

	-- ADD TITLE
	local title
	if part.title or part.singulartitle or part.pluraltitle then
		local text
		if #rows > 1 and part.pluraltitle then
			text = part.pluraltitle
		elseif #rows == 1 and part.singulartitle then
			text = part.singulartitle
		else
			text = part.title
		end

		local style = part.titlestyle or {}

		title = mw.html.create("caption")
			:attr({ colspan = "2" })
			:css(style)
			:wikitext(text)
			:done()
	end
	
	if title then
		tab:node(title)
	end
	
	for i, j in pairs (rows) do
		tab:node(j)
	end
	
	if part.separator then
		local separator = p.separator(part)
		tab:node(separator)
	end
	tab:allDone()
	return tab
end
p.buildTable = p.buildtable

--[[
	Construction de l"infobox
]]

function p.buildblock(block)
	if type(block) == "function" then
		block = block(localdata)
	end

	 -- list of functions for block buildings
	local blocktypes = {
		["images"] = p.build_images,
		["table"] = p.buildtable,
		["row"] = p.build_row,
		["row1col"] = p.build_row1col,
		["succession"] = p.build_succession,
		["text"] = p.build_text,
		["title"] = p.build_title,
	}
	if type(block) ~= "table" or (not block.type) or (not blocktypes[block.type]) then
		return blocktypes["invalid"](block)
	end
	return blocktypes[block.type](block) 
end
p.buildBlock = p.buildblock

function p.build()
	localdata = require("Module:Infobox/Localdata")
	item = localdata.item

	-- chargement du module de paramétrage
	local moduledata = require("Module:Infobox/" .. localdata.modulename)
	moduledata.name = localdata.modulename
	
	-- class
	local class = "infobox avt-infobox"
	if moduledata.class then
		class = class .. " " .. moduledata.class
	end

	-- style
	local style = moduledata.style or {}
	
	-- build infobox
	infobox	:addClass(class)
			:css(style)
	
	for i, j in pairs(moduledata.parts) do
		infobox:node(p.buildblock(j))
	end

	return tostring(infobox)
end

return p