Moduuli:Fr:Infobox

Wikipediasta
Siirry navigaatioon Siirry hakuun

localp={}
locallang='fi'

localitem=nil-- l'élément Wikidata lié
locallocaldata={}-- données concernant les paramètres passés au modèle
localpage={-- données concernant la page où est affichée l'infobox
name=mw.title.getCurrentTitle().prefixedText,
namespace=mw.title.getCurrentTitle().namespace
}
localmaincolor,secondcolor,thirdcolor='#E0E0E0','#E0E0E0','#000000'
-- l'objet principal à retournerp
localinfobox=mw.html.create('div')

-- objes secondaires à retournerw
localmaintenance=''-- chaîne retournfoée avec le module: cats de maintenance
localexternaltext=''-- par exemple coordonnées en titre
-- modules importés
localwikidata=require('Module:Fr:Interface Wikidata').fromLua
localvalueexpl=wikidata.translate("activate-query")
locallinguistic=require"Module:Fr:Linguistique"
localwd=require'Module:Fr:Wikidata'
localmapmod=require"Module:Fr:Carte"

locali18n={
['show wikidata backlinks']='Näytä Wikidatasta tulevat arvot',-- Documentation du modèle
['see doc']='Tietolaatikon dokumentaatio',-- Documentation du modèle
['edit']='muokkaa',-- modifier
['edit code']='muokkaa wikitekstiä',-- 'modifier le code
['edit item']='muokkaa Wikidataa',-- modifier Wikidata
['tracking cat']="Wikidataa hyödyntävät artikkelit",-- Page utilisant des données de Wikidata
['invalid block type']="Tietolaatikon tyyppivirhe",-- Bloc de données invalide dans le module d'infobox
['default cat']="Huomiota kaipaavat tietolaatikot",-- Maintenance des infobox
}

localfunctionaddwikidatacat(prop)
maintenance=maintenance..wikidata.addtrackingcat(prop)
end

localfunctionexpandquery(query)
localvalue,number-- valeur à retourner, nombre de valeurs pour accorder le libellé
ifnotquery.entitythen
query.entity=localdata.item
end
ifnotquery.conjtypethen
query.conjtype='comma'
end
localclaims=wikidata.getClaims(query)
if(notclaims)then
returnnil
end
returnwikidata.formatAndCat(query),#claims-- pour l'accord au pluriel
end

localfunctiongetWikidataValue(params,wikidataparam)
-- Récupère la valeur Wikidata pour la valeur, soit dans le paramètre "wikidata" soit dans le praramètre "property"
ifnotlocaldata.itemthen
returnnil
end

ifparams.blockersthen-- blockers are local parameters that disable the wikidata query
localblockers=params.blockers
if(type(blockers)=='string')then
blockers={blockers}
end
fori,blockerinipairs(blockers)do
iflocaldata[blocker]then
returnnil
end
end
end

localv,valnum-- la valeur à retourner, et le nombre de de valeurs (pour l'accord grammatical)

ifnotwikidataparamthen-- 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 wikidata
wikidataparam='wikidata'
end

ifparams[wikidataparam]then
iftype(params[wikidataparam])=='function'then
v,valnum=params[wikidataparam](localdata.item)
elseiftype(params[wikidataparam])=='table'then
v,valnum=expandquery(params[wikidataparam])
else
v,valnum=params[wikidataparam]
end
end
ifnotvthen
returnnil
end
iftype(params[wikidataparam])=='table'then
ifparams[wikidataparam].ucfirst~="-"then
v=linguistic.ucfirst(v)
end
end
returnv,valnum
end

localfunctiongetvalue(val,params)
iftype(val)=='string'then
returnlocaldata[val]
elseiftype(val)=='function'then
returnval(localdata,localdata.item,params)
elseiftype(val)=='table'then
fori,jinpairs(val)do-- si plusieurs paramètres possibles (legacy de vieux code), prendre le preimeir non bide
iflocaldata[j]then
returnlocaldata[j]
end
end
end
end

localfunctionaddmaintenancecat(cat,sortkey)
ifpage.namespace~=0then
return''
end
ifcatthen
maintenance=maintenance..'[[Category:'..cat..'|'..(sortkeyorpage.name)..']]'
end
end

functionp.separator(params)
localstyle=params['separator style']or{}
style.height=style.heightor'2px'
style['background-color']=style['background-color']ormaincolor

returnmw.html.create('hr'):css(style)
end

functionp.buildtitle(params)
localtext=getvalue(params.value,params)orparams.textdefaultvalueorgetWikidataValue(params)ormw.title.getCurrentTitle().text
localsubtext=getvalue(params.subtitle)orgetWikidataValue(params,'wikidatasubtitle')orparams.subtitledefaultvalue

-- subtext returned by getWikidataValue is html. This fails if text is html too.
ifsubtextand((text~=subtext)and(string.find(subtext,">"..text.."[%[%<]")==nil))then
text=text..'<br /><small>'..subtext..'</small>'
end

ifstring.len(text)>20then
text=text.."[[category:Sivut, joiden tietolaatikon otsikko on pitkä]]"
end

localicon=params.iconor''
ificon~=''andnotparams.largethen
icon='icon '..icon
end
localclass='entete '..icon

-- overwrites with those provided in the module
localstyle={}
--style['background-color'] = maincolor
style['color']=thirdcolor
ifparams.stylethen
fori,jinpairs(params.style)do
style[i]=j
end
end
localtitle=mw.html.create('div')
:addClass(class)
:css(style)
:tag('div')
:wikitext(text)
:allDone()
returntitle
end

functionp.buildnavbox(params)

-- définition du style
localclass="overflow nav"..(params.classor'')
localstyle=params.styleor{}

ifparams.separatedthen-- options pour ajouter une ligne de séparation au dessus
class=class..' bordered'
style['border-top']='1px solid'..maincolor
end

-- ajustement des paramètres de données
params.previousval=params.previousvalorparams.previousparameter-- nom de paramètre obsolète
params.nextval=params.nextvalorparams.nextparameter

ifparams.previouspropertythen
params.previouswikidata={property=params.previousproperty}
end
ifparams.nextpropertythen
params.nextwikidata={property=params.nextproperty}
end


localpreviousval=getvalue(params.previousval,params)orgetWikidataValue(params,'previouswikidata')
localnextval=getvalue(params.nextval,params)orgetWikidataValue(params,'nextwikidata')

localnavbox
ifparams.innerthen-- pour celles qui sont à l'intérieur d'une table
navbox=mw.html.create('tr'):tag('th'):attr('colspan',2)
style['font-weight']=style['font-weight']or'normal'
else
navbox=mw.html.create('div')
end

navbox
:addClass(class)
:css(style)
:tag('div')
:addClass('prev_bloc')
:wikitext(previousval)
:done()
:tag('div')
:addClass('next_bloc')
:wikitext(nextval)
:done()
:allDone()
returnnavbox
end

functionp.buildimages(params)
localimages={}
localupright,link,caption,alt,size-- size is deprecated
localwikidataimageclass=""
iftype(params.imageparameters)=='string'then
params.imageparameters={params.imageparameters}
end
ifnotparams.imageparametersthen-- s'il n'y a pa de paramètre image, continuer, peut-être y-a-t-il une image par défaut définie dans le module d'infobox
params.imageparameters={}
end
forj,kinipairs(params.imageparameters)do
table.insert(images,localdata[k])
end
-- Images de Wikidata
if#images==0andlocaldata.itemthen
ifparams.propertythen
params.wikidata={entity=localdata.item,property=params.property}
end
ifparams.wikidatathen
localwdq=params.wikidata
iftype(wdq)=='table'then
wdq.entity=wdq.entityorlocaldata.item
images=wikidata.getClaims(wdq)
end
iftype(wdq)=='function'then
images=params.wikidata()
iftype(images)=='string'then
returnimages
end--c'est probablement une erreur dans la requête => afficher le message
end
if(notimages)then
images={}
end
if(#images>0)and(params.wikidata.property)then
addwikidatacat(params.wikidata.property)
wikidataimageclass="wikidataimages"
end
-- Récupération des légendes de Wikidata (par P2096 seulement, à rendre optionnel et plus flexible)
iftype(images[1])=='table'then
fori,jinpairs(images)do
ifj.mainsnak.snaktype~='value'then
return
end
localwdcaptions,wdcaption
localq=images[i].qualifiers
ifqthen
wdcaptions=q['P2096']
end
ifwdcaptionsthen
fork,linpairs(wdcaptions)do
ifl.datavalue.valueandl.datavalue.value.language==langthen
wdcaption=wd.formatSnak(l)
end
end
end
ifwdcaptionandcaptionthen-- si deux légendes, désactivées pour éviter les conflits
caption=nil
elseifwdcaptionthen
caption=wdcaption
end
ifi>(params.numvalor2)then
images[i]=nil
else
images[i]=j.mainsnak.datavalue.value
end
end
end
end
end

-- Images par défaut
if#images==0then
ifparams.maintenancecatthen
addmaintenancecat(params.maintenancecat,params.sortkey)
end
ifparams.defaultimagesthen
images=params.defaultimages
iftype(images)=='string'then
images={images}
end
upright=params.defaultimageupright
caption=params.defaultimagecaption
link=params.defaultimagelink
alt=params.defaultimagealt
ifnotaltand(images[1]=='Defaut.svg'orimages[1]=='Defaut 2.svg')then
alt='une illustration sous licence libre serait bienvenue'
end
end
end
if#images==0then
returnnil
end

upright=uprightorgetvalue(params.uprightparameter)orparams.defaultuprightor"1.2"
link=linkorgetvalue(params.linkparameter)orparams.defaultlink
caption=captionorgetvalue(params.captionparameter)orparams.defaultcaption
alt=altorgetvalue(params.altparameter)orparams.defaultalt

-- taille avec "size" (obsolète)
size=sizeorgetvalue(params.sizeparameter)orparams.defaultsize-- deprecated
ifsizethen
localnumsize=size:gsub('px','')
numsize=mw.ustring.gsub(numsize,'^x','')
numsize=mw.ustring.gsub(numsize,'x.*','')
numsize=tonumber(numsize)
iftype(numsize)~='number'ornumsize>300then
addmaintenancecat("Virheellinen kuvan koko"..numsize)
end
iftonumber(size)then
size=size..'px'
end
size='|'..size
else
size=''
end

iftonumber(upright)then
upright=tostring(tonumber(upright))
end
iftonumber(size)then
size=tostring(tonumber(size))/#images
end

--local style = params.style or {padding ='2px 0',}
localstyle=params.styleor{padding='0',}

-- Partie image

localimagesString=''
fori,imageinpairs(images)do
ifimage=='-'then
return
end
imagesString=imagesString..'[[Image:'..image..size..'|frameless'
ifaltthen
imagesString=imagesString..'|alt='..alt
end
iflinkthen
imagesString=imagesString..'|link='..link
end
ifuprightthen
imagesString=imagesString..'|upright='..upright
elseif#images>1then
imagesString=imagesString..'|upright='..(1/#images)
end
imagesString=imagesString..']]'
end

localimage=mw.html.create('div')
:addClass("images")
:addClass(wikidataimageclass)
:css(style)
:wikitext(imagesString)

-- Partie légende
localcaptionobj
ifcaptionthen
captionobj=mw.html.create('p')
:wikitext(caption)
:css(params.styleor{})
:addClass("legend")
:done()
end

-- séparateur
localseparator
ifparams.separatorthen
separator=separator(params)
end
returnmw.html.create('div')
:node(image)
:node(captionobj)
:node(separator)
:done()
end

functionp.buildtext(params)
localclass=params.classor''
localstyle={
['text-align']='center',
['font-weight']='bold'
}
ifparams.stylethen
fori,jinpairs(params.style)do
style[i]=j
end
end
localtext=getvalue(params.value,params)orgetWikidataValue(params)orparams.defaultvalue
iftext=='-'then
return
end
ifnottextthen
addmaintenancecat(params.maintenancecat,params.sortkey)
returnnil
end
localformattedtext=mw.html.create('p')
:addClass(class)
:css(style)
:wikitext(text)
:done()
returnformattedtext
end

functionp.buildrow(params)
localclass=params.classor''
localstyle=params.styleor{}
localvalue,number=getvalue(params.value,params)
if(value==valueexpl)then
value=nil
params.wikidata.expl=false
end
if(notvalue)then
value,number=getWikidataValue(params,'wikidata')
end
if(notvalue)and(params.property)and(params.property~="")then
value,number=expandquery{property=params.property,ucfirst=params.ucfirst}
end
ifnotvaluethen
value=params.defaultvalue
end
ifvalue=='-'then
returnnil
end
ifnotnumberthen
number=0-- == indéfini
end

ifnotvaluethen
ifparams.maintenancecatthen
localmaintenancecat=getvalue(params.maintenancecat,params)
addmaintenancecat(maintenancecat,params.sortkey)
end
returnnil
end

locallabel=params.label
ifnumber>1and(params.plurallabel)then
label=params.plurallabel
elseifnumber==1and(params.singularlabel)then
label=params.singularlabel
end
iftype(label)=='function'then
label=label(localdata,localdata.item)
end

-- format
localformattedvalue=mw.html.create('div')
:wikitext('\n'..value)-- Le '\n' est requis lorsque value est une liste commençant par '*' ou '#'

if(params.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)
:allDone()

localformattedlabel
iflabelthen
formattedlabel=mw.html.create('th')
:attr('scope','row')
:wikitext(label)
:done()
end
localrow=mw.html.create('tr')
:addClass(class)
:css(style)
:node(formattedlabel)
:node(formattedvalue)
:done()

returnrow
end

functionp.buildsuccession(params)
ifnotparams.valuethen
returnnil
end

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

localrowI=mw.html.create('tr')

localcolspan='2'
cellI=mw.html.create('td')
:attr({colspan=colspan})
:attr({align='center'})

localstyleT={}
styleT['background-color']='transparent'
styleT['width']='100%'
tabC=mw.html.create('table')
:attr({cellspacing='0'})
:addClass('navigation-not-searchable')
:css(styleT)

localrow=mw.html.create('tr')

localcolor=params.color

localstyle={}
localarrowLeft
localarrowRight

ifcolor=='default'then
style['background-color']='#E6E6E6'
arrowLeft='[[Image:Fleche-defaut-gauche.png|13px|alt=Précédent|link=]]'
arrowRight='[[Image:Fleche-defaut-droite.png|13px|alt=Précédent|link=]]'
else
style['background-color']=color
arrowLeft='[[Image:Fleche-defaut-gauche-gris-32.png|13px|alt=Suivant|link=]]'
arrowRight='[[Image:Fleche-defaut-droite-gris-32.png|13px|alt=Suivant|link=]]'
end

localstyleTrans={}
styleTrans['background-color']='#F9F9F9'

localvalues=params.value
localbefore=values['before']
localcenter=values['center']
localafter=values['after']

localwidthCell='44%'
ifcenterthen
widthCenter='28%'
widthCell='29%'
end

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

localformattedcenter
formattedcenter=mw.html.create('td')
:attr({width='1%'})
:css(styleTrans)
:wikitext('')
:done()
row:node(formattedcenter)

ifcenterthen
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

localformattedafter
ifafterthen
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()

returnrowI
end

functionp.buildrow1col(params)

ifnotparams.valuethen
returnnil
end

--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'
localclass=params.class
localrowcolor
ifparams.color=='secondcolor'then
rowcolor=secondcolor
else
rowcolor=params.color
end

localstyle={}
style['padding']='4px'
style['text-align']='center'
style['background-color']=rowcoloror'#F9F9F9'
style['color']='#000000'

localtext=params.value

localcolspan='2'

localformattedlabel
formattedlabel=mw.html.create('th')
:attr({colspan=colspan})
:css(style)
:wikitext(text)
:done()

localrow=mw.html.create('tr')
:addClass(class)
:css(style)
:node(formattedlabel)
:done()

returnrow
end

functionp.buildtable(params)
localtab=mw.html.create('table'):css(params.styleor{})

localrows=params.rows

-- expand parameters so that we have a list of tables
locali=1

while(i<=#rows)do
locall=rows[i]
iftype(l)=='function'then
l=l(localdata,localdata.item)
end
if(type(l)=='table')and(l.type=='multi')then
table.remove(rows,i)
forj,rowinipairs(l.rows)do
table.insert(rows,i+j-1,row)
end
elseiftype(l)=='nil'then
table.remove(rows,i)
elseiftype(l)~='table'then
returnerror('les lignes d\'infobox ( "rows" ) doivent être des tables, est '..type(l))
else
i=i+1
end
end

-- CREATE ROW
localexpandedrows={}
fork,rowinipairs(rows)do
localv=p.buildblock(row)
ifvthen
table.insert(expandedrows,v)
end
end
if(#expandedrows==0)then
returnnil
end
rows=expandedrows

-- ADD TITLE
localtitle
ifparams.titleorparams.singulartitleorparams.pluraltitlethen
localtext
if#rows>1andparams.pluraltitlethen
text=params.pluraltitle
elseif#rows==1andparams.singulartitlethen
text=params.singulartitle
else
text=params.title
end

localstyle=params.titlestyleor{}
style['color']=style['color']orthirdcolor
style['margin']='0.4em 0px 0px 5px'
style['border-bottom']=style['background-color']ormaincolor..' 1px solid'
--style['background-color'] = style['background-color'] or maincolor

localcolspan='2'
title=mw.html.create('caption')
:attr({colspan=colspan})
:css(style)
:wikitext(text)
:done()
end

iftitlethen
tab:node(title)
end

fori,jinpairs(rows)do
tab:node(j)
end

ifparams.separatorthen
localseparator=p.separator(params)
tab:node(separator)
end
tab:allDone()
returntab
end

functionp.buildinvalidblock(args)
addmaintenancecat(defaultcat)
localtext=''
iftype(args)~='table'then
text="Les blocs d'infobox doivent être des tables"
else
text=i18n["invalid block type"]..': '..(args.typeor'??')
end
returntext
end

functionp.buildmap(params)-- TODO: gestion de plusieurs points

-- paramètre d'affichage
localmaplist=getvalue(params.maps)
localpointtype=params.pointtype
localmaptype=params.maptype-- choisit le type de carte le plus approprié (relief, administratif, etc.)
iftype(maplist)=='function'then
maplist=maplist(localdata,localdata.item)
end
localwidth=tonumber(params.width)or290
ifwidth>290then
addmaintenancecat("Erreur d'Infobox/Image trop grande")
return'image trop grande, la largeur doit être inférieure ou égale à 290px'
end

-- récupération des données locales
locallatitude,longitude,globe=params.latitude,params.longitude,params.globe
iftype(params.latitude)=='function'then
latitude,longitude=params.latitude(localdata,localdata.item),params.longitude(localdata,localdata.item)
else
latitude,longitude=localdata[params.latitude],localdata[params.longitude]
end

-- récupération des données wikidata
if(notlatitudeornotlongitude)andparams.wikidatathen
localquery=params.wikidata
iftype(query)=='function'then
query=query()
end
ifnotquerythen
returnnil
end
query.excludespecial=true
query.entity=query.entityorlocaldata.item
localclaims=wikidata.getClaims(query)
ifnotclaimsthen
returnnil
end
localval=wd.formatSnak(claims[1].mainsnak)
latitude,longitude,globe=val.latitude,val.longitude,val.globe
end

ifnotlatitudeornotlongitudethen
returnnil
end
localnewparams={maplist=maplist,pointtype=pointtype,maptype=maptype,width=width,item=localdata.item,latitude=latitude,longitude=longitude,globe=globe,marker=params.marker,default_zoom=params.default_zoom,ids=params.ids}
ifparams.paramsandtype(params.params)=='table'then-- paramètres additionnels
fori,jinpairs(params.params)do
newparams[i]=j
end
end
returnmapmod.multimap(newparams)
end

functionp.buildexternaltext(params)
localvalue=getvalue(params.value)
ifvalueand(type(value)=='string')then
externaltext=externaltext..value
end
end

functionp.buildfooter(params)
ifnotparamsthen
params={}
end

localclass='navbar noprint bordered '..(params.classor'')
localstyle=params.styleor{}
style['border-top']=style['border-top']or'1px solid '..maincolor

localbacklinkstr='['..tostring(mw.uri.fullUrl(page.name,'veaction=edit&section=0'))..' '..i18n['edit']..']'
..' - ['..tostring(mw.uri.fullUrl(page.name,'action=edit&section=0'))..' '..i18n['edit code']..']'

localitemlinkstr
iflocaldata.entity_idthen
itemlinkstr='[[d:'..localdata.entity_id..'|'..i18n['edit item']..']]'
end
localeditstr=backlinkstr
ifitemlinkstrthen
editstr=editstr..' - '..itemlinkstr
end
localeditlinkspan=mw.html.create('span')
:css({['text-align']="left"})
:addClass('plainlinks')
:wikitext(editstr)
:done()
localdoclinkstr='[[Image: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 frame
localdoclinkspan=mw.html.create('span')
:css({['text-align']="right"})
:wikitext(doclinkstr)
:done()

localshowwikidatabacklinkstr="[[File:Wikidata-logo.svg|25px|"..i18n['show wikidata backlinks'].."|link=#]]"
localshowwikidatabacklinkspan=mw.html.create('span')
:css({['text-align']="right",['display']="none"})
:addClass('showlinkback')
:wikitext(showwikidatabacklinkstr)
:done()

localfooter=mw.html.create('p')
:addClass(class)
:css(style)
:node(editlinkspan)
:node(doclinkspan)
:node(showwikidatabacklinkspan)
returnfooter
end

functionp.buildblock(block)
iftype(block)=='function'then
block=block(localdata)
end

localblocktypes={-- 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,
['navbox']=p.buildnavbox,
['table']=p.buildtable,
['row']=p.buildrow,
['row1col']=p.buildrow1col,
['succession']=p.buildnavbox,
['text']=p.buildtext,
['title']=p.buildtitle,
}
iftype(block)~='table'or(notblock.type)or(notblocktypes[block.type])then
returnblocktypes['invalid'](block)
end
returnblocktypes[block.type](block)
end

functionp.build()

localdata=require('Module:Fr:Infobox/Localdata')
item=localdata.item

-- assign rank to the infobox, "secondary" means special formatting like no displaytitle for coordinates
localinfoboxrank='main'-- main infobox of the page, with coordinates displayed in title etc.
ifpage.namespace~=0then
infoboxrank='secondary'
end
-- if infobox is linked to another item: rank = secondary
iflocaldata.entity_idthen
localitemlink=mw.wikibase.sitelink(localdata.entity_id)
localpagetitle=mw.title.getCurrentTitle().text
if(itemlinkor'')~=pagetitlethen
infoboxrank='secondary'
end
end
localdata.infoboxrank=infoboxrank

-- load infobox module page
localmoduledata=require('Module:Fr:Infobox/'..localdata.modulename)
moduledata.name=localdata.modulename
-- defines main color
maincolor=localdata['couleur infobox']orlocaldata['couleur boîte']ormoduledata.maincolorormaincolor
secondcolor=moduledata.secondcolororsecondcolor
thirdcolor=moduledata.thirdcolororthirdcolor
ifmaincolor:match('^%x%x%x%x%x%x$')ormaincolor:match('^%x%x%x$')then
maincolor='#'..maincolor
end

-- class
localclass='infobox_v3'
ifmoduledata.classthen
class=class..' '..moduledata.class
end

-- style
localstyle=moduledata.styleor{}
ifnotstyle['max-width']then
style['max-width']='300px'
end

-- build infobox
infobox:addClass(class)
:css(style)
fori,jinpairs(moduledata.parts)do
infobox:node(p.buildblock(j))
end
infobox:node(p.buildfooter(moduledata.footer))
:done()

-- wrap whole thing inside infobox-div so mobileview parser will detect it as infobox
localinfobox_wrapper=mw.html.create('div')
infobox_wrapper:addClass("infobox")
:css("border","none")
:css("margin","0")
:css("margin-left","0.5em")
:css("padding","0")
:node(infobox)
:done()

returntostring(infobox_wrapper)..externaltext,maintenance
end

returnp