Module:Infobox/Bac à sable

 Documentation

Cette page définit un module d'infobox.


local p = {}local wikiLang = 'fr'local localdata = {}-- données concernant les paramètres passés au modèle-- données concernant la page où est affichée l'infoboxlocal page = mw.title.getCurrentTitle()local maincolor, secondcolor, thirdcolor = '#E1E1E1', '#E1E1E1', '#000000'-- l'objet principal à retournerlocal infobox = mw.html.create('div')-- objets secondaires à retournerlocal maintenance = '' -- chaîne retournée avec le module : cats de maintenancelocal externaltext = '' -- par exemple coordonnées en titre-- modules importéslocal linguistic = require "Module:Linguistique"local wd = require 'Module:Wikidata/Bac à sable'local yesno = require 'Module:Yesno'local valueexpl = wd.translate("activate-query")local i18n = {['see doc'] = 'Documentation du modèle',['edit'] = 'modifier',['edit code'] = 'modifier le code',['edit item'] = 'modifier Wikidata',['tracking cat'] = "Page utilisant des données de Wikidata",['invalid block type'] = "Bloc de données invalide dans le module d'infobox",['default cat'] = "Maintenance des infobox",}local function expandQuery(query)local value, number -- valeur à retourner, nombre de valeurs pour accorder le libelléif not query.entity thenquery.entity = localdata.itemendif not query.conjtype thenquery.conjtype = 'comma'endlocal claims = wd.getClaims(query)if (not claims) thenreturn nilendreturn wd.formatAndCat(query), wd.getgendernum(claims) -- pour l'accord en genre et en  nombreendlocal function getWikidataValue(params, wikidataparam)-- Récupère la valeur Wikidata pour la valeur, soit dans le paramètre "wikidata" soit dans le paramètre "property"if not localdata.item thenreturn nilendif params.blockers then -- blockers are local parameters that disable the wikidata querylocal blockers = params.blockersif (type(blockers) == 'string') thenblockers = {blockers}endfor i, blocker in ipairs(blockers) doif localdata[blocker] thenreturn nilendendendlocal v, valgendernum -- la valeur à retourner, et le genre/nombre de de valeurs (pour l'accord grammatical)if not wikidataparam then -- par défaut la valeur wikidata est dans le paramètre "wikidata" mais dans les structures composées comme "title", il y a plusieurs paramètres wikidatawikidataparam = 'wikidata'endif params[wikidataparam] thenif type(params[wikidataparam]) == 'function' thenv, valgendernum = params[wikidataparam](localdata.item)elseif type(params[wikidataparam]) == 'table' thenv, valgendernum = expandQuery(params[wikidataparam])elsev, valgendernum = params[wikidataparam]endendif not v thenreturn nilendif(type(valgendernum) == 'number') thenif(valgendernum > 1) thenvalgendernum = 'p'elsevalgendernum = 's'endendv = linguistic.ucfirst(v)return v, valgendernumendlocal function getValue(val, params)if type(val) == 'string' thenreturn localdata[val]elseif type(val) == 'function' thenreturn val(localdata, localdata.item, params)elseif type(val) == 'table' thenfor i, j in pairs(val) do -- si plusieurs paramètres possibles (legacy de vieux code), prendre le premier non videif localdata[j] thenreturn localdata[j]endendendendlocal function addMaintenanceCat(cat, sortkey)if page.namespace ~= 0 thenreturn ''endif cat thenmaintenance = maintenance .. '[[Category:' .. cat .. '|' .. (sortkey or page.prefixedText) .. ']]'endendfunction p.separator(params)local style = params['separator style'] or {}style.height = style.height or '2px'style['background-color'] = style['background-color'] or maincolorreturn mw.html.create('hr'):css( style )end--[=[Construit le code du bloc de titre de l'infoboxParamètres (liste partielle) :- value : Moyen d'obtenir le titre via getValue (nom de paramètre de modèle ou fonction).- textdefaultvalue : Valeur par défaut du titre.- icon : Pictogramme d'infobox (voir [[Projet:Infobox/Pictogramme]]).- italic : Indique si le titre doit être affiché en italique.  Si italic=true, le paramètre "titre en italique" de l'infobox peut forcer la désactivation.- setdisplaytitle : Indique si le titre de l'article doit être mis en forme comme celui de l'infobox.  Si setdisplaytitle=true, le paramètre "titre article en italique" de l'infobox peut forcer la désactivation.]=]function p.buildtitle(params)local text = getValue(params.value, params) or params.textdefaultvalue or getWikidataValue(params) or page.prefixedTextlocal lang = localdata['langue du titre'] or ''if lang ~= '' thenlocal langueFunction = require( 'Module:Langue' ).languetext = langueFunction( { lang, text } )endlocal subtext = getValue(params.subtitle) or  getWikidataValue(params, 'wikidatasubtitle') or params.subtitledefaultvalueif subtext and (subtext ~= text) thentext = text .. '<br /><small>' .. subtext .. '</small>'endlocal icon = params.icon or ''if icon ~= '' and icon ~= 'defaut' thentext = text .. mw.getCurrentFrame():extensionTag('templatestyles', '', {src = 'Infobox/Pictogramme/' .. mw.text.trim(icon) .. '.css'})if not params.large thenicon = 'icon ' .. iconendendlocal classes = 'entete ' .. iconlocal italic = params.italic and yesno(localdata['titre en italique'] or '', true, true)if italic thenclasses = classes .. ' italique'endif params.setdisplaytitle and yesno(localdata['titre article en italique'] or '', true, true) thenlocal formatTitleModule = require( 'Module:Formatage du titre' )text = text .. formatTitleModule.setDisplayTitle{ args = {lang = lang,italic = italic,options = 'noreplace',} }end-- overwrites with those provided in the modulelocal style = {}style['background-color'] = maincolorstyle['color'] = thirdcolorif params.style thenfor i, j in pairs(params.style) dostyle[i] = jendendlocal title = mw.html.create('div'):addClass(classes):css(style):tag('div'):wikitext(text):allDone()return titleendp.buildTitle = p.buildtitlefunction p.buildnavigator(params)-- définition du stylelocal classes = "overflow infobox-navigateur " .. (params.class or '')local style = params.style or {}if params.separated then -- options pour ajouter une ligne de séparation au dessusclasses = classes .. ' bordered'style['border-top'] = '1px solid' .. maincolorend-- ajustement des paramètres de donnéesparams.previousval = params.previousval or params.previousparameter -- nom de paramètre obsolèteparams.nextval = params.nextval or params.nextparameterif params.previousproperty thenparams.previouswikidata = {property = params.previousproperty}endif params.nextproperty thenparams.nextwikidata = {property = params.nextproperty}endlocal previousval = getValue(params.previousval, params) or getWikidataValue(params, 'previouswikidata')local nextval = getValue(params.nextval, params) or getWikidataValue(params, 'nextwikidata')if previousval  == '-' and nextval  == '-' thenreturn    elseif previousval  == '-' then        previousval  = ''    elseif nextval  == '-' then        nextval  = ''endlocal navigatorif params.inner then -- pour celles qui sont à l'intérieur d'une tablenavigator = mw.html.create('tr'):tag('th'):attr('colspan', 2)style['font-weight'] = style['font-weight'] or 'normal'elsenavigator = mw.html.create('div')endif previousval or nextval thennavigator:addClass(classes):css(style):tag('div'):addClass('prev_bloc'):wikitext(previousval):done():tag('div'):addClass('next_bloc'):wikitext(nextval):done():allDone()return navigatorendreturn nilendp.buildNavigator = p.buildnavigatorfunction p.buildimages(params)local images = {}local upright, link, caption, alt, size  -- size is deprecatedif type(params.imageparameters) == 'string' thenparams.imageparameters = {params.imageparameters}endif not params.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'infoboxparams.imageparameters = {}endfor j, k in ipairs(params.imageparameters) dotable.insert(images, localdata[k])end-- Images de Wikidatalocal iswikidataimage, iswikidatacaption = falseif #images == 0 and localdata.item thenif params.property thenparams.wikidata = {entity = localdata.item, property = params.property}endif params.wikidata thenlocal wdq = params.wikidatawdq.excludespecial = trueif type(wdq) == 'table' thenwdq.entity = wdq.entity or localdata.itemwdq.numval = wdq.numval or params.numval or 1images = wd.getClaims(wdq)endif type(wdq) == 'function' thenimages = params.wikidata()if type(images) == 'string' thenreturn imagesend --c'est probablement une erreur dans la requête => afficher le messageendif (not images) thenimages = {}endif (#images > 0) and (params.wikidata.property) thenmaintenance = maintenance .. wd.addTrackingCat(params.wikidata.property)endif type(images[1]) == 'table' thenfor i, image in pairs(images) doif image.mainsnak.snaktype ~= 'value' thenreturnendif #images == 1 then -- si une seule image, on utilise la légende (si deux plusieurs images, comment mettre en forme ?)caption = wd.getFormattedQualifiers(images[i], {'P2096'}, {isinlang = wikiLang}) or wd.getFormattedQualifiers(images[i], {'P805'})iswikidatacaption = caption ~= nilendimages[i] = image.mainsnak.datavalue.valueiswikidataimage = trueendendendendif #images == 0 and getValue(params.captionparameter) ~= nil thenaddMaintenanceCat("Infobox avec une légende locale sans image")end-- Images par défautif #images == 0 thenif params.maintenancecat thenaddMaintenanceCat(params.maintenancecat, params.sortkey)endif params.defaultimages thenimages = params.defaultimagesif type(images) == 'string' thenimages = {images}endupright = params.defaultimageuprightcaption = params.defaultimagecaptionlink = params.defaultimagelinkalt = params.defaultimagealtif not alt and ( images[1] == 'Defaut.svg' or images[1] == 'Defaut 2.svg' ) thenalt = 'une illustration sous licence libre serait bienvenue'endendendif #images == 0 thenreturn nilendupright = upright or getValue(params.uprightparameter) or params.defaultupright or "1.2"link = link or getValue(params.linkparameter) or params.defaultlinkcaption = caption or getValue(params.captionparameter) or params.defaultcaptionalt = alt or getValue( params.altparameter) or params.defaultaltif iswikidataimage and not iswikidatacaption and getValue(params.captionparameter) ~= nil thenaddMaintenanceCat("Infobox avec une légende locale et une image sur Wikidata")end-- taille avec "size" (obsolète)size = size or getValue(params.sizeparameter) or params.defaultsize -- deprecatedif size thenlocal sizevalue = size:gsub('px$', '')local widthonly = mw.ustring.gsub(sizevalue, 'x.*', '')widthonly = tonumber(widthonly)if type(widthonly) ~= 'number' or widthonly > 280 thenaddMaintenanceCat("Infobox avec une image trop grande")endif tonumber(sizevalue) thensize = tostring( tonumber(sizevalue) / #images ) .. 'px'endendif tonumber(upright) thenupright = tostring( tonumber(upright) / #images )endlocal style = params.style or {padding ='2px 0',}-- Partie imagelocal imagesString = ''for i,image in pairs(images) doif image == '-' thenreturnendimagesString = imagesString ..  '[[Fichier:' .. image .. '|frameless'if size thenimagesString = imagesString .. '|' .. size -- not a mistake, parameter is unnamedendif alt thenimagesString = imagesString .. '|alt=' .. altendif link thenimagesString = imagesString .. '|link=' .. linkendif upright thenimagesString = imagesString .. '|upright=' .. uprightelseif #images > 1 and not size thenimagesString = imagesString .. '|upright=' .. ( 1 / #images )endif image:sub(-4):lower() == '.svg' thenimagesString = imagesString .. '|lang=' .. wikiLangendimagesString = imagesString .. ']]'endlocal image = mw.html.create('div'):addClass("images"):css(style):wikitext(imagesString)-- Partie légendelocal captionobjif caption thencaptionobj = mw.html.create('div'):wikitext(caption):css(params.legendstyle or {}):addClass("legend"):done()end-- séparateurlocal separatorif params.separator thenseparator = p.separator(params)endreturn mw.html.create('div'):node(image):node(captionobj):node(separator):done()endp.buildImages = p.buildimagesfunction p.buildtext(params)local classes = params.class or ''local style = {['text-align'] = 'center',['font-weight'] = 'bold'}if params.style thenfor i, j in pairs(params.style) dostyle[i] = jendendlocal text = getValue(params.value, params) or getWikidataValue(params) or params.defaultvalueif text == '-' thenreturnendif not text thenif params.maintenancecat thenaddMaintenanceCat(params.maintenancecat, params.sortkey)endreturn nilend-- séparateurlocal separatorif params.separator thenseparator = p.separator(params)endlocal formattedtext = mw.html.create('p'):addClass(classes):css(style):wikitext(text):node(separator):done()return formattedtextendp.buildText = p.buildtextfunction p.buildrow(params)local classes = params.class or ''local style = params.style or {}local valueClass = params.valueClass or ''local valueStyle = params.valueStyle or {}local value, gendernum = getValue(params.value, params)if(type(gendernum) == 'number') thenif(gendernum > 1) thengendernum = 'p'elsegendernum = 's'end endif type(params.wikidata) == 'table' thenparams.wikidata.wikidatalang = localdata.wikidatalangif (value == valueexpl) thenvalue = nilparams.wikidata.expl = falseendendif (not value) thenvalue, gendernum = getWikidataValue(params, 'wikidata')endif (not value) and (params.property) thenvalue, gendernum = expandQuery{ property = params.property, ucfirst = params.ucfirst }endif not value thenvalue = params.defaultvalueendif value == '-' thenreturn nilendif not gendernum thengendernum = 's' --singulier indéfiniendif not value thenif params.maintenancecat thenaddMaintenanceCat(params.maintenancecat, params.sortkey)endreturn nilendlocal label = params.labelif type(label) == 'string' then label = {default = label} endif type(label) == 'table' then -- Accord en genre et en nombrelocal onlynum = {default = 'default', s = 's', ms = 's', fs = 's', p = 'p', mp = 'p', fp = 'p', mixtep = 'p'} -- Accord seulement en nombre par défautlabel['s'] = label['s'] or params.singularlabel or label['default'] or label['ms']label['p'] = label['p'] or params.plurallabel or label['mp']label = label[gendernum] or label[onlynum[gendernum]] or label.defaultendif type(label) == 'function' thenlabel = label(localdata, localdata.item)end-- formatlocal formattedvalue = mw.html.create('div'):wikitext('\n' .. value) -- Le '\n' est requis lorsque value est une liste commençant par '*' ou '#'if (params.hidden == true)thenformattedvalue: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)endformattedvalue = mw.html.create('td'):node(formattedvalue):addClass(valueClass):css(valueStyle):allDone()local formattedlabelif label thenformattedlabel = mw.html.create('th'):attr('scope', 'row'):wikitext(label):done()endlocal row = mw.html.create('tr'):addClass(classes):css(style):node(formattedlabel):node(formattedvalue):done()return rowendp.buildRow = p.buildrowfunction p.buildsuccession(params)if not params.value thenreturn nilend--local style = params.style or {}--style['text-align'] = style['text-align'] or 'center'--style['color'] = style['color'] or '#000000'--style['background-color'] = style['background-color'] or '#F9F9F9'local rowI = mw.html.create('tr')local styleI = {}local colspan = '2'styleI['padding'] = '1px'local 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%'local tabC = mw.html.create('table'):attr({cellspacing = '0'}):addClass('navigation-not-searchable'):css(styleT)local row = mw.html.create('tr')local color = params.colorlocal style = {}local arrowLeft = '[[Fichier:Arrleft.svg|13px|alt=Précédent|link=]]'local arrowRight = '[[Fichier:Arrright.svg|13px|alt=Suivant|link=]]'if color ~= 'default' thenstyle['background-color'] = colorendlocal styleTrans = {}local values = params.valuelocal before = values['before']local center = values['center']local after = values['after']local widthCenterlocal widthCell = '44%'if center thenwidthCenter = '28%'widthCell = '29%'endlocal formattedbeforeif before thenformattedbefore = 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)elseformattedbefore = 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)endlocal formattedcenterformattedcenter = mw.html.create('td'):attr({width = '1%'}):css(styleTrans):wikitext(''):done()row:node(formattedcenter)if center thenformattedcenter = 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)endlocal formattedafterif after thenformattedafter = 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)elseformattedafter = 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)endrow:done()tabC:node(row)tabC:done()cellI:node(tabC)cellI:done()rowI:node(cellI)rowI:allDone()return rowIendp.buildSuccession = p.buildsuccessionfunction p.buildrow1col(params)if not params.value thenreturn nilend--local style = params.style or {}--style['text-align'] = style['text-align'] or 'center'--style['color'] = style['color'] or '#000000'--style['background-color'] = style['background-color'] or '#F9F9F9'local classes = params.classlocal rowcolorif params.color == 'secondcolor' thenrowcolor = secondcolorelserowcolor = params.colorendlocal style = {}style['padding'] = '4px'style['text-align'] = 'center'style['background-color'] = rowcolor or '#F9F9F9'style['color'] = '#000000'local text = params.valuelocal colspan ='2'local formattedlabelformattedlabel = mw.html.create('th'):attr({colspan = colspan}):css(style):wikitext(text):done()local row = mw.html.create('tr'):addClass(classes):css(style):node(formattedlabel):done()return rowendp.buildRow1Col = p.buildrow1colfunction p.buildtable(params)local tab = mw.html.create('table'):css(params.style or {})local rows = params.rows-- expand parameters so that we have a list of tableslocal i = 1while (i <= #rows) dolocal l = rows[i]if type(l) == 'function' thenl = l(localdata, localdata.item)endif (type(l) == 'table') and (l.type == 'multi') thentable.remove(rows, i)for j, row in ipairs(l.rows) dotable.insert(rows, i + j - 1, row)endelseif type(l) == 'nil' thentable.remove(rows, i)elseif type(l) ~= 'table' thenreturn error('les lignes d\'infobox ("rows") doivent être des tables, est ' .. type(l))elsei = i + 1endend-- CREATE ROWlocal expandedrows = {}for k, row in ipairs(rows) dolocal v = p.buildblock(row)if v thentable.insert(expandedrows, v)endendif (#expandedrows == 0) thenreturn nilendrows = expandedrows-- ADD TITLElocal titleif params.title or params.singulartitle or params.pluraltitle thenlocal textif #rows > 1 and params.pluraltitle thentext = params.pluraltitleelseif #rows == 1 and params.singulartitle thentext = params.singulartitleelsetext = params.titleendlocal style = params.titlestyle or {}style['text-align'] = style['text-align'] or 'center'style['color'] = style['color'] or thirdcolorstyle['background-color'] = style['background-color'] or maincolorlocal colspan ='2'title = mw.html.create('caption'):attr({colspan = colspan}):css(style):wikitext(text):done()endif title thentab:node(title)endfor i, j in pairs (rows) dotab:node(j)endif params.separator thenlocal separator = p.separator(params)tab:node(separator)endtab:allDone()return tabendp.buildTable = p.buildtablefunction p.buildinvalidblock(args)addMaintenanceCat(i18n['default cat'])local text = ''if type(args) ~= 'table' thentext = "Les blocs d'infobox doivent être des tables"elsetext = i18n["invalid block type"] .. ' : ' .. (args.type or '??')endreturn textendp.buildInvalidBlock = p.buildinvalidblockfunction p.buildmap(params)-- paramètre d'affichagelocal maplist = getValue(params.maps)local pointtype = params.pointtypelocal maptype = params.maptype -- choisit le type de carte le plus approprié (relief, administratif, etc.)if type(maplist) == 'function' thenmaplist = maplist(localdata, localdata.item)endlocal width = tonumber(params.width) or 280if width > 280 thenaddMaintenanceCat("Infobox avec une image trop grande")return 'image trop grande, la largeur doit être inférieure ou égale à 280px'end-- récupération des données localeslocal pointtable = {}local globe = params.globeif params.latitude thenlocal lat, longif type(params.latitude) == 'function' thenlat, long = params.latitude(localdata, localdata.item), params.longitude(localdata, localdata.item)elselat, long = localdata[params.latitude], localdata[params.longitude]endif lat thentable.insert(pointtable, {latitude = lat, longitude = long})endend-- récupération des données wikidatalocal function processWDval(claim, displayformat)if not claim thenreturn nilendlocal val = wd.formatSnak( claim.mainsnak )return {latitude = val.latitude, longitude = val.longitude, globe = val.globe, marker = displayformat.marker}endlocal function getWDvals(query)query.excludespecial = truequery.numval = query.numval or 1query.entity = query.entity or localdata.itemlocal claims = wd.getClaims(query)if (not claims) thenreturnendfor i, claim in ipairs(claims) doclaim = processWDval(claim, query)table.insert(pointtable, claim)endendif (#pointtable == 0) and localdata.item and params.wikidata and (params.wikidata ~= '-') thenfor i, query in ipairs(params.wikidata) doif type(query) == 'function' thenquery = query()endif query thengetWDvals(query)endendendif (not pointtable) or (#pointtable == 0) thenreturn nilendlocal newparams = {maplist = maplist, pointtype = pointtype, maptype = maptype, width = width, item = localdata.item, pointtable = pointtable, globe = globe, marker=params.marker, default_zoom=params.default_zoom, ids = params.ids, markercolor = params.markercolor, shapecolor = params.shapecolor }if params.params and type(params.params) == 'table' then -- paramètres additionnelsfor i, j in pairs(params.params) donewparams[i] = jendendreturn require('Module:Carte').multimap(newparams)endp.buildMap = p.buildmapfunction p.buildexternaltext(params)local value = getValue(params.value)if value and (type(value) == 'string') thenexternaltext = externaltext .. valueendendp.buildExternalText = p.buildexternaltextfunction p.buildfooter(params)if not params thenparams = {}endlocal classes = 'navbar noprint bordered navigation-not-searchable ' .. (params.class or '')local style = params.style or {}style['border-top'] = style['border-top'] or '1px solid ' .. maincolorlocal backlinkstr = '[' .. tostring( mw.uri.fullUrl( page.prefixedText, 'veaction=edit&section=0' ) ) .. ' ' .. i18n['edit'] .. ']'.. ' - [' .. tostring( mw.uri.fullUrl( page.prefixedText, 'action=edit&section=0' ) ) .. ' ' .. i18n['edit code'] .. ']'local itemlinkstrif localdata.item thenitemlinkstr = '[[d:' .. localdata.item .. '|' .. i18n['edit item'] .. ']]'endlocal editstr = backlinkstrif itemlinkstr theneditstr = editstr .. ' - ' .. itemlinkstrendlocal editlinkspan = mw.html.create('span'):css({['text-align'] = "left"}):addClass('plainlinks'):wikitext(editstr):done()local doclinkstr = '[[Fichier:Info Simple.svg|12px|link=' .. localdata.templatename .. '|' .. i18n['see doc'] .. ']]'-- si ce lien ne marche pas toujours, il faut ajouter un variable pour le nom de l'infobox récupéré par le framelocal doclinkspan = mw.html.create('span'):css({['text-align'] = "right"}):wikitext(doclinkstr):done()local footer = mw.html.create('p'):addClass(classes):css(style):node(editlinkspan):node(doclinkspan)return footerendp.buildFooter = p.buildfooterfunction p.buildblock(block)if type(block) == 'function' thenblock = block( localdata )endlocal blocktypes = { -- list of functions for block buildings['invalid'] = p.buildinvalidblock,['external text'] = p.buildexternaltext,['footer'] = p.buildfooter,['images'] = p.buildimages,['map']= p.buildmap,['mixed'] = p.buildrow,['navigator'] = p.buildnavigator,['table'] = p.buildtable,['row'] = p.buildrow,['row1col'] = p.buildrow1col,['succession'] = p.buildsuccession,['text'] = p.buildtext,['title'] = p.buildtitle,}if type(block) ~= 'table' or (not block.type) or (not blocktypes[block.type]) thenreturn blocktypes['invalid'](block)endreturn blocktypes[block.type](block)endp.buildBlock = p.buildblockfunction p.build()localdata = require( 'Module:Infobox/Localdata' )if type( localdata.item ) == 'table' thenlocaldata.item = localdata.item.idend-- assign rank to the infobox, "secondary" means special formatting like no displaytitle for coordinateslocal infoboxrank = 'main' -- main infobox of the page, with coordinates displayed in title etc.if page.namespace ~= 0 theninfoboxrank = 'secondary'end-- if infobox is linked to another item: rank = secondaryif localdata.item thenlocal itemlink = mw.wikibase.sitelink(localdata.item)local pagetitle = page.prefixedTextif (itemlink or '') ~= pagetitle theninfoboxrank = 'secondary'endendlocaldata.infoboxrank = infoboxrank-- load infobox module pagelocal moduledata = require('Module:Infobox/' .. localdata.modulename)moduledata.name = localdata.modulename-- defines main colormaincolor = localdata['couleur infobox'] or localdata['couleur boîte'] or moduledata.maincolor or maincolorsecondcolor = moduledata.secondcolor or secondcolorthirdcolor = localdata['texte noir'] or localdata['couleur texte'] or moduledata.thirdcolor or thirdcolorif ( #maincolor == 6 or #maincolor == 3 ) and maincolor:match( '^%x+$' ) thenmaincolor = '#' .. maincolorendif thirdcolor == 'oui' or thirdcolor == 'true' thenthirdcolor = '#000'elseif thirdcolor == 'non' or thirdcolor == 'false' thenthirdcolor = '#fff'end-- classeslocal classes = mw.getCurrentFrame():expandTemplate{ title = 'Classes début infobox', args = { version = '3' } }classes = classes .. ' large ' .. (moduledata.class or '')-- stylelocal style = moduledata.style or {}-- build infoboxinfobox:addClass(classes):css(style)for i, j in pairs( moduledata.parts ) doinfobox:node( p.buildblock(j) )endinfobox:node(p.buildfooter(moduledata.footer)):done()return tostring(infobox) .. externaltext, maintenanceendreturn p