飞机杯是什么| 官杀是什么| degaia是什么牌子| 吃了西瓜不能吃什么| 皮肤一块块白是什么病| 2022年属虎的是什么命| 路虎为什么叫奇瑞路虎| 空调外机为什么会滴水| 小孩子发烧是什么原因引起的| f4什么意思| 1月21日什么星座| 尿液黄绿色是什么原因| 白带是什么颜色的| 荷兰豆炒什么好吃| 00后是什么意思| 囊肿和肿瘤有什么区别| 胡子变白是什么原因| 75c是什么罩杯| 交界痣是什么| 面基是什么意思啊| 摸摸唱是什么意思| 县团级是什么级别| 什么是扁平疣图片| 湿气重吃什么蔬菜| au750是什么金属| 舌苔发白厚吃什么药| 身体肿是什么原因引起的| 一个壳一个心念什么| 西瓜红是什么颜色| 皋读什么| 赏脸是什么意思| 肝脾不和吃什么中成药| 为什么精子射不出来| 牛皮癣是什么样的| 氨纶是什么面料| 回忆杀是什么意思| 松字五行属什么| 帕金森挂什么科| 楼台是什么意思| 总蛋白是什么| 酸豆角炒什么好吃| 桂字五行属什么| 鱼油对身体有什么好处| 肚子胀痛吃什么药| 弦是什么| k是什么单位| 体脂率是什么| 白羊座的幸运色是什么| 稳重什么意思| 腺管瘤是什么| 弄璋之喜是什么意思| 退行性改变是什么意思| 什么叫肝功能不全| 午餐吃什么好又能减肥| 右边小腹疼是什么原因| 堃是什么意思| 梦见被猪咬是什么意思| 艺体生是什么意思| 射手座男生喜欢什么样的女生| 内痔疮用什么药治最好效果最快| 后期是什么意思| 尿隐血3十是什么病| 大队长是什么级别| 反复口腔溃疡是什么原因| 井柏然原名叫什么| 睡觉爱流口水是什么原因| 什么话什么说| 1992年是什么命| 腺病毒吃什么药| 梦见别人笑什么意思| 苦瓜泡水喝有什么功效和作用| 男人肾虚吃什么补得快| 相知是什么意思| 空字五行属什么| 园五行属什么| 经常便秘吃什么| 奶奶的妈妈应该叫什么| 排湿气最快的方法吃什么| 眼睛老是流眼泪是什么原因| 蛋白肉是什么东西做的| 什么药治便秘最好最快| 全员加速中什么时候播| 滑膜炎挂什么科| 为什么会突然耳鸣| 郝字五行属什么| 身上痒但是什么都没有| 青岛啤酒节什么时候| 高笋和茭白有什么区别| 送孕妇什么礼物最贴心| 00年是什么年| 微信英文名叫什么| 脸上长斑是什么原因| 长公主是皇上的什么人| 嘴角疱疹用什么药膏| 早上屁多是什么原因造成的| pr医学上什么意思| 榴莲不能与什么食物一起吃| 吃什么降低胆固醇| 脑血管痉挛是什么原因引起的| 天降横财什么意思| 眼泪多是什么原因| 吃什么安神有助于睡眠| 特应性皮炎用什么药膏| 山宗读什么| 肺结核阳性是什么意思| 外科是看什么病的| 什么是太监| 外阴痒用什么洗| sod是什么| 小孩瘦小不长肉是什么原因| 身上带什么可以辟邪| 属蛇的是什么星座| 频繁做梦是什么原因| 上火吃什么药| 阴道里面痒是什么原因| 姿态万千的意思是什么| 月经后一周又出血是什么原因| 为什么吃甲鱼不吃乌龟| 婴幼儿积食会有什么症状| 肛门疼痛是什么原因引起的| 盯眝是什么意思| 脚底麻是什么原因| 2024是什么年生肖| 什么的眉头| 超纤皮是什么| 吃苹果有什么好处和功效| 牛油果和什么榨汁好喝| 周杰伦的粉丝叫什么| 每天跳绳有什么好处| 宝宝辅食虾和什么搭配| 嘴唇有黑斑是什么原因| kiki是什么意思| 不感冒是什么意思| 脚肿吃什么药| 酒精对皮肤有什么伤害| 眼睛做激光手术有什么后遗症| 软肋是什么意思| 动脉钙化是什么意思| 喝啤酒头疼是什么原因| 今年78岁属什么生肖| 慢性肠炎用什么药| 喊麦什么意思| 9月13日是什么星座| 拈花一笑什么意思| 两肺纹理增粗是什么意思| 猫吐了吃什么药| 夏天为什么会下冰雹| 籍贯填什么| 榴莲吃多了有什么危害| 生化了是什么意思| 疥疮是什么病| 流清鼻涕打喷嚏吃什么药| 09年的牛是什么命| 中性粒细胞百分比高是什么原因| 肿瘤标志物是什么意思| 没晨勃说明什么问题| 一到晚上就咳嗽是什么原因| 指甲盖有竖纹是什么原因| 肾结石发作有什么症状| 什么是三公经费| 欧金金什么意思| 脸红是什么原因引起的| 四月四号什么星座| 同房子宫疼痛什么原因| 什么环境唱什么歌原唱| 干咳是什么原因| 卧推100公斤什么水平| 拉肚子发烧是什么原因| 梦到蜘蛛是什么意思| 柯什么意思| 松子吃多了有什么害处| 七月十五日是什么节日| 派对是什么意思| 眼底充血用什么眼药水| 大四什么时候毕业| 白细胞多是什么意思| 什么路最窄打一生肖| bc是什么牌子| 什么叫靶向治疗| 什么房不能住人| 细胞角蛋白19片段是什么意思| 梦见好多动物是什么意思| 精子有点黄是什么原因| 荡漾什么意思| 胸部中间痛什么原因引起的| 胸闷吃什么药| 什么是粉尘螨过敏| 不解大便是什么原因| 补血最快的方法是什么| 十二月是什么星座| 禅茶一味什么意思| 约法三章什么意思| 遗精什么意思| 口腔异味吃什么药| 吃杏子有什么好处| 落是什么生肖| 羸弱是什么意思| 盆腔积液是什么原因引起的| 排骨炖什么菜好吃| 试管都有什么方案| 上皮细胞什么意思| 什么是局限性肺纤维化| 甲沟炎挂什么科| 为什么会得阑尾炎| 耳目比喻什么| 安抚奶嘴什么时候开始用| 荷花是什么季节开放的| 天蝎女跟什么星座最配| 图灵测试是什么| 什么啤酒好| 995是什么意思| 硫酸亚铁适合浇什么花| 例假血是黑色的是什么原因| 来例假喝什么好| kai是什么意思| 什么是类风湿性关节炎| 吃什么可以生发| 6月21号是什么日子| 斜视手术有什么后遗症和风险| ft什么单位| 萎缩性胃炎吃什么药能治好| 什么的小朋友填词语| 西米是什么| rush是什么| 怀孕去医院检查挂什么科| 1.7号是什么星座| 脸颊红是什么原因| 日本全称是什么| 呼吸机vt代表什么| 笃什么意思| 洛神花是什么花| 国窖1573是什么香型| 鹿加几念什么| 小孩有点咳嗽吃什么药| 甲状腺结节什么引起的| 6月有什么水果| 女排精神是什么| 吃什么减肥最好最快| 乌龟肺炎用什么药| 小姨是什么关系| 子时右眼跳是什么预兆| 核磁共振什么时候出结果| 气血不足吃什么| 脑供血不足吃什么药好| 和风对什么| 白带是什么味道| 宁静是什么民族| 上报是什么意思| 孕妇梦见洪水是什么意思| 浮尘是什么意思| 结扎对男人有什么伤害| 蝉是什么生肖| 洗白是什么意思| 什么的列车| 为什么生气会胃疼| 睡觉打呼噜是什么病| 脚麻是什么病的前兆| 什么毛什么血| 港澳通行证签注是什么意思| 稷是什么农作物| 大腿骨叫什么骨| 557是什么意思| 脚一直出汗是什么原因| 1987年出生属什么| 百度Aller au contenu

Число погибших при крушении землечерпательного судна у берегов Малайзии возросло до четырех человек

Cette page fait l’objet d’une mesure de semi-protection étendue.
Une page de Wikipédia, l'encyclopédie libre.
百度 书信里记录了一个民族的往昔,也保留着濒临忘却的记忆。

 Documentation[voir] [modifier] [historique] [purger]

Module pour la création d'infobox à partir d'un sous-module de paramétrage de l'infobox, de paramètres passés à un modèle et, le cas échéant, de données de Wikidata.

build(frame)

Fonction à utiliser depuis un modèle, elle ne prend qu'un paramètre direct, nom, le nom du sous-module où est définie la structure de l'infobox. Par exemple Modèle:Infobox Tapis persan contient {{#invoke:Infobox|build|nom=Tapis persan}}, indiquant qu'il faut utiliser Module:Infobox/Tapis persan. Les paramètres passés au modèle sont disponibles dans le Module:Infobox/Localdata, qui peut être appelé depuis les sous-modules. Les classes css des infobox (actuellement infobox_v3 et noarchive) sont gérées par Modèle:Classes début infobox.

La structure de l'infobox est définie par une table contenue dans un sous-module, et dont le format est :

{
 maincolor = '#XXXXXX' -- couleur à utiliser par défaut pour les titres et les sous titre
 parts = {} -- les différentes sous-parties de l'infobox
}

La partie parts contient elle-même des tables, ou des fonctions utilisant les variables localdata et item pour créer des tables. Pour une liste des types de données acceptés, et des conseils pratiques, voir Aide:Infobox en Lua.

-- luacheck: globals mw, no max line length

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'infobox
local page = mw.title.getCurrentTitle()

local maincolor, secondcolor, thirdcolor
-- l'objet principal à retourner
local infobox = mw.html.create('div')

-- objets secondaires à retourner
local maintenance = '' -- cha?ne retournée avec le module : cats de maintenance
local externaltext = '' -- par exemple coordonnées en titre
-- modules importés
local wd = require 'Module:Wikidata'
local yesno = require 'Module:Yesno'
local valueexpl = wd.translate("activate-query")

-- maintenance des images dupliquées
local usedImages = {}

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)
	if not query.entity then
		query.entity = localdata.item
	end
	if not query.conjtype then
		query.conjtype = 'comma'
	end
	local claims = wd.getClaims(query)
	if (not claims) then
		return nil
	end

	return wd.formatAndCat(query), wd.getgendernum(claims) -- valeur  et code indiquant le genre/nombre pour accorder le libellé
end

local 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 then
		return nil
	end

	if params.blockers then -- blockers are local parameters that disable the wikidata query
		local blockers = params.blockers
		if (type(blockers) == 'string') then
			blockers = {blockers}
		end
		for i, blocker in ipairs(blockers) do
			if localdata[blocker] then
				return nil
			end
		end
	end

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

	if params.property and not params[wikidataparam] then params[wikidataparam] = {property = params.property} end

	if params[wikidataparam] then
		if type(params[wikidataparam]) == 'function' then
			v, valgendernum = params[wikidataparam](localdata.item)
		elseif type(params[wikidataparam]) == 'table' then
			v, valgendernum = expandQuery(params[wikidataparam])
		else
			v, valgendernum = params[wikidataparam]
		end
	end
	if not v then
		return nil
	end

	if(type(valgendernum) == 'number') then
		if(valgendernum > 1) then
			valgendernum = 'p'
		else
			valgendernum = 's'
		end
	end

	return v, valgendernum
end

local function getValue(val, params)
	if type(val) == 'string' then
		return localdata[val]
	elseif type(val) == 'function' then
		return val(localdata, localdata.item, params)
	elseif type(val) == 'table' then
		for i, j in pairs(val) do -- si plusieurs paramètres possibles (legacy de vieux code), prendre le premier non vide
			if localdata[j] then
				return localdata[j]
			end
		end
	end
end

local function addMaintenanceCat(cat, sortkey)
	if page.namespace ~= 0 then
		return ''
	end
	if cat then
		local sortkeycode
		if sortkey then sortkeycode = '|' .. sortkey else sortkeycode = '' end
		maintenance = maintenance .. '[[Category:'.. cat .. sortkeycode .. ']]'
	end
end

function p.separator(params)
	local classes = params['separator classes']
	local style = params['separator style'] or {}
	style['background-color'] = style['background-color'] or maincolor
	if style['background-color'] then
		style.color = 'var( --color-base )'
	end

	return mw.html.create('hr'):addClass( classes ):css( style )
end

--[=[
Construit le code du bloc de titre de l'infobox

Paramè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.prefixedText
	local lang = localdata['langue du titre'] or ''
	if lang ~= '' then
		local langueFunction = require( 'Module:Langue' ).langue
		text = langueFunction( { lang, text } )
	end
	local subtext = getValue(params.subtitle) or  getWikidataValue(params, 'wikidatasubtitle') or params.subtitledefaultvalue
	if subtext and (subtext ~= text) then
		text = text .. '<br><small>' .. subtext .. '</small>'
	end
	local icon = params.icon or ''
	if icon ~= '' and icon ~= 'defaut' then
		text = text .. mw.getCurrentFrame():extensionTag('templatestyles', '', {src = 'Infobox/Pictogramme/' .. mw.text.trim(icon) .. '.css'})
		if not params.large then
			icon = 'icon ' .. icon
		end
	end
	local classes = 'entete ' .. icon

	local italic = params.italic and yesno(localdata['titre en italique'] or '', true, true)
	if italic then
		classes = classes .. ' italique'
	end
	if params.setdisplaytitle and yesno(localdata['titre article en italique'] or '', true, true) then
		local formatTitleModule = require( 'Module:Formatage du titre' )
		text = text .. formatTitleModule.setDisplayTitle{ args = {
			lang = lang,
			italic = italic,
			options = 'noreplace',
		} }
	end

	-- overwrites with those provided in the module
	local style = {}
	style['background-color'] = maincolor
	style['color'] = thirdcolor
	if params.style then
		for i, j in pairs(params.style) do
			style[i] = j
		end
	end
	local title = mw.html.create('div')
		:addClass(classes)
		:css(style)
		:tag('div')
			:wikitext(text)
		:allDone()
	return title
end
p.buildTitle = p.buildtitle

function p.buildnavigator(params)

	-- définition du style
	local 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 dessus
		classes = classes .. ' bordered'
		if maincolor then
			style['border-top'] = '1px solid' .. maincolor
		end
	end

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

	if params.previousproperty then
		params.previouswikidata = {property = params.previousproperty}
	end
	if params.nextproperty then
		params.nextwikidata = {property = params.nextproperty}
	end


	local previousval = getValue(params.previousval, params) or getWikidataValue(params, 'previouswikidata')
	local nextval = getValue(params.nextval, params) or getWikidataValue(params, 'nextwikidata')

    if previousval  == '-' then previousval  = nil end
    if nextval  == '-' then nextval  = nil end

	local navigator
	if params.inner then -- pour celles qui sont à l'intérieur d'une table
		navigator = mw.html.create('tr'):tag('th'):attr('colspan', 2)
		style['font-weight'] = style['font-weight'] or 'normal'
	else
		navigator = mw.html.create('div')
	end

	if previousval or nextval then
		navigator
			:addClass(classes)
			:css(style)
			:tag('div')
				:addClass('prev_bloc')
				:wikitext(previousval)
				:done()
			:tag('div')
				:addClass('next_bloc')
				:wikitext(nextval)
				:done()
			:allDone()
		return navigator
	end
	return nil
end
p.buildNavigator = p.buildnavigator

function p.buildimages(params)
	local images = {}
	local upright, link, caption, classe, alt, size  -- size is deprecated
	if type(params.imageparameters) == 'string' then
		params.imageparameters = {params.imageparameters}
	end
	if 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'infobox
		params.imageparameters = {}
	end
	for j, k in ipairs(params.imageparameters) do
		table.insert(images, localdata[k])
	end
	-- Images de Wikidata
	local iswikidataimage, iswikidatacaption = false
	if #images == 0 and localdata.item then
		if params.property then
			params.wikidata = {entity = localdata.item, property = params.property}
		end
		if params.wikidata then
			local wdq = params.wikidata
			wdq.excludespecial = true
			if type(wdq) == 'table' then
				wdq.entity = wdq.entity or localdata.item
				wdq.numval = wdq.numval or params.numval or 1
				images = wd.getClaims(wdq)
			end
			if type(wdq) == 'function' then
				images = params.wikidata()
				if type(images) == 'string' then
					return images
				end --c'est probablement une erreur dans la requête => afficher le message
			end
			if (not images) then
				images = {}
			end
			if (#images > 0) and (params.wikidata.property) then
				maintenance = maintenance .. wd.addTrackingCat(params.wikidata.property)
			end

			if type(images[1]) == 'table' then
				for i, image in pairs(images) do
					if image.mainsnak.snaktype ~= 'value' then
						return
					end
					if #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})
						caption = caption or wd.getFormattedQualifiers(images[i], {'P805'}) --"affirmation détaillée dans"
						if params.datecaption and not caption then --légende construite à partir de la date de l'image et d'une table de paramètres spécifiques
							local dcparams = params.datecaption
							if type(dcparams) ~= 'table' then dcparams = {} end
							local numdate = wd.compare.get_claim_date(images[i])
							local endclaims = wd.getClaims({entity = wdq.entity, property = dcparams.endproperty, numval = 1})
							local endnumdate = ( endclaims and wd.compare.get_claim_date(endclaims[1]) ) or math.huge
							if numdate <= endnumdate then
								caption = wd.getFormattedDate(images[i],
									{precision = dcparams.precision or 'year',
									linktopic = dcparams.linktopic or '-',
									withpreposition = true})
								if caption then
									if dcparams.prefix then caption = dcparams.prefix .. ' ' .. caption end
									caption = require('Module:Linguistique').ucfirst(caption) .. '.'
									addMaintenanceCat("Infobox avec une légende automatique à partir de la date de l'image")
								end
							end
						end
						iswikidatacaption = caption ~= nil
					end
					images[i] = image.mainsnak.datavalue.value
					iswikidataimage = true
				end
			end
		end
	end

	if #images == 0 and getValue(params.captionparameter) ~= nil then
		addMaintenanceCat("Infobox avec une légende locale sans image")
	end
	-- Images par défaut
	if #images == 0 then
		if params.maintenancecat then
			addMaintenanceCat(params.maintenancecat, params.sortkey)
		end
		if params.defaultimages then
			images = params.defaultimages
			if type(images) == 'string' then
				images = {images}
			end
			upright = params.defaultimageupright
			caption = params.defaultimagecaption
			link = params.defaultimagelink
			classe = params.defaultimageclass
			if not classe and ( images[1] == 'Defaut.svg' or images[1] == 'Defaut 2.svg' ) then
				classe = 'skin-invert-image'
			end
			alt = params.defaultimagealt
			if not alt and ( images[1] == 'Defaut.svg' or images[1] == 'Defaut 2.svg' ) then
				alt = 'une illustration sous licence libre serait bienvenue'
			end
		end
	end
	if #images == 0 then
		return nil
	end

	upright = upright or getValue(params.uprightparameter) or params.defaultupright or "1.2"
	link = link or getValue(params.linkparameter) or params.defaultlink
	caption = caption or getValue(params.captionparameter) or params.defaultcaption
	classe = classe or getValue( params.classparameter) or params.defaultclass
	alt = alt or getValue( params.altparameter) or params.defaultalt

	if iswikidataimage and not iswikidatacaption and getValue(params.captionparameter) ~= nil then
		addMaintenanceCat("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 -- deprecated
	if size then
		local sizevalue = size:gsub('px$', '')

		local widthonly = mw.ustring.gsub(sizevalue, 'x.*', '')
		widthonly = tonumber(widthonly)
		if type(widthonly) ~= 'number' or widthonly > 280 then
			addMaintenanceCat("Infobox avec une image trop grande")
		end

		if tonumber(sizevalue) then
			size = tostring( tonumber(sizevalue) ) .. 'px'
		end
	end

	if tonumber(upright) then
		upright = tostring( tonumber(upright) )
	end

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

	-- Partie image

	local imagesString = ''
	for i,image in pairs(images) do
		if image == '-' then
			return
		end
		imagesString = imagesString ..  '[[Fichier:' .. image .. '|frameless'
		if size then
			imagesString = imagesString .. '|' .. size -- not a mistake, parameter is unnamed
		end
		if classe then
			imagesString = imagesString .. '|class=' .. classe
		end
		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 and not size then
			imagesString = imagesString .. '|upright=' .. ( 1 / #images )
		end
		if image:sub(-4):lower() == '.svg' then
			imagesString = imagesString .. '|lang=' .. wikiLang
		end
		imagesString = imagesString .. ']]'

		if usedImages[image] then
			addMaintenanceCat('Infobox avec plusieurs images identiques')
		end
		usedImages[image] = true
	end

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

	-- Partie légende
	local captionobj
	if caption then
		captionobj = mw.html.create('div')
			:wikitext(caption)
			:css(params.legendstyle or {})
			:addClass("legend")
			:done()
	end

	-- séparateur
	local separator
	if params.separator then
		separator = p.separator(params)
	end
	return mw.html.create('div')
		:node(image)
		:node(captionobj)
		:node(separator)
		:done()
end
p.buildImages = p.buildimages

function p.buildtext(params)
	local classes = params.class or ''
	local style = {
		['text-align'] = 'center',
		['font-weight'] = 'bold'
	}
	if params.style then
		for i, j in pairs(params.style) do
			style[i] = j
		end
	end
	local text = getValue(params.value, params) or getWikidataValue(params) or params.defaultvalue
	if text == '-' then
		return
	end
	if not text then
		if params.maintenancecat then
			addMaintenanceCat(params.maintenancecat, params.sortkey)
		end
		return nil
	end
	-- séparateur
	local separator
	if params.separator then
		separator = p.separator(params)
	end
	local formattedtext = mw.html.create('p')
		:addClass(classes)
		:css(style)
		:wikitext(text)
		:node(separator)
		:done()
	return formattedtext
end
p.buildText = p.buildtext

function 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') then
		if(gendernum > 1) then
			gendernum = 'p'
		else
			gendernum = 's'
		end
	end

	if type(params.wikidata) == 'table' then
		params.wikidata.wikidatalang = localdata.wikidatalang
		if (value == valueexpl) then
			value = nil
			params.wikidata.expl = false
		end
	end
	if (not value) then
		value, gendernum = getWikidataValue(params, 'wikidata')
	end

	if not value then
		value = params.defaultvalue
	end
	if value == '-' then
		return nil
	end
	if not gendernum then
		gendernum = 's' --singulier indéfini
	end

	if not value then
		if params.maintenancecat then
			addMaintenanceCat(params.maintenancecat, params.sortkey)
		end
		return nil
	end

	local label = params.label
	if type(label) == 'string' then label = {default = label} end

	if type(label) == 'table' then -- Accord en genre et en nombre
		local onlynum = {default = 'default', s = 's', ms = 's', fs = 's', p = 'p', mp = 'p', fp = 'p', mixtep = 'p'} -- Accord seulement en nombre par défaut

		label['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.default
	end

	if type(label) == 'function' then
			label = label(localdata, localdata.item)
	end

	-- format
	local 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)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(classes)
		:css(style)
		:node(formattedlabel)
		:node(formattedvalue)
		:done()

	return row
end
p.buildRow = p.buildrow

function p.buildsuccession(params)
	if not params.value then
		return nil
	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'

	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 = {
		margin = '0',
		['background-color'] = 'transparent',
		color = 'inherit',
		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.color

	local style = {}
	local arrowLeft = '[[Fichier:Arrleft.svg|13px|alt=Précédent|link=]]'
	local arrowRight = '[[Fichier:Arrright.svg|13px|alt=Suivant|link=]]'

	if color ~= 'default' then
		style['background-color'] = color
	end

	local styleTrans = {}

	local values = params.value
	local before = values['before']
	local center = values['center']
	local after = values['after']

	local widthCenter
	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.buildSuccession = p.buildsuccession

function p.buildrow1col(params)

	if not params.value then
		return nil
	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'
	local classes = 'row1col ' .. (params.class or '')
	local style = {}
	if params.color == 'secondcolor' then
		style['background-color'] = secondcolor
	else
		style['background-color'] = params.color
	end

	local text = params.value

	local colspan ='2'

	local formattedlabel
	formattedlabel = 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 row
end
p.buildRow1Col = p.buildrow1col

function p.buildtable(params)
	local tab = mw.html.create('table'):addClass(params.classes):css(params.style or {})

	local rows = params.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 params.title or params.singulartitle or params.pluraltitle then
		local text
		if #rows > 1 and params.pluraltitle then
			text = params.pluraltitle
		elseif #rows == 1 and params.singulartitle then
			text = params.singulartitle
		else
			text = params.title
		end

		local style = params.titlestyle or {}
		style['text-align'] = style['text-align'] or 'center'
		style['color'] = style['color'] or thirdcolor
		style['background-color'] = style['background-color'] or maincolor

		local colspan ='2'
		title = mw.html.create('caption')
			:attr({colspan = colspan})
			: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 params.separator then
		local separator = p.separator(params)
		tab:node(separator)
	end
	tab:allDone()
	return tab
end
p.buildTable = p.buildtable

--------------------------------------------------------------------------------
-- Fonction créant une ligne d’en-tête à 2 colonnes (subheader2col)
--------------------------------------------------------------------------------
function p.buildSubheader2col(params)
    local row = mw.html.create('tr')

    local col1 = mw.html.create('th')
        :attr('scope', 'col')
        :wikitext(params.col1)
        :done()

    local col2 = mw.html.create('th')
        :attr('scope', 'col')
        :wikitext(params.col2)
        :done()

    row:node(col1)
    row:node(col2)
    row:done()
    return row
end

function p.buildinvalidblock(args)
	addMaintenanceCat(i18n['default cat'])
	local text = ''
	if type(args) ~= 'table' then
		text = "Les blocs d'infobox doivent être des tables"
	else
		text = i18n["invalid block type"] .. ' : ' .. (args.type or '??')
	end
	return text
end
p.buildInvalidBlock = p.buildinvalidblock

function p.buildmap(params)

	-- paramètre d'affichage
	local maplist = getValue(params.maps)
	local pointtype = params.pointtype
	local maptype = params.maptype -- choisit le type de carte le plus approprié (relief, administratif, etc.)
	if type(maplist) == 'function' then
		maplist = maplist(localdata, localdata.item)
	end
	local width = tonumber(params.width) or 280
	if width > 280 then
		addMaintenanceCat("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 locales
	local pointtable = {}
	local globe = params.globe
	if params.latitude then
		local lat, long
		if type(params.latitude) == 'function' then
			lat, long = params.latitude(localdata, localdata.item), params.longitude(localdata, localdata.item)
		else
			lat, long = localdata[params.latitude], localdata[params.longitude]
		end
		if lat then
			table.insert(pointtable, {latitude = lat, longitude = long})
		end
	end

	-- récupération des données wikidata
	local function processWDval(claim, displayformat)
		if not claim then
			return nil
		end
		local val = wd.formatSnak( claim.mainsnak )
		return {latitude = val.latitude, longitude = val.longitude, globe = val.globe, marker = displayformat.marker}
	end

	local function getWDvals(query)
		query.excludespecial = true
		query.numval = query.numval or 1
		query.entity = query.entity or localdata.item
		local claims = wd.getClaims(query)
		if (not claims) then
			return
		end
		for i, claim in ipairs(claims) do
			claim = processWDval(claim, query)
			table.insert(pointtable, claim)
		end
	end

	if (#pointtable == 0) and localdata.item and params.wikidata and (params.wikidata ~= '-') then
		for i, query in ipairs(params.wikidata) do
			if type(query) == 'function' then
				query = query()
			end
			if query then
				getWDvals(query)
			end
		end
	end

	if (not pointtable) or (#pointtable == 0) then
		return nil
	end

	local 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 additionnels
		for i, j in pairs(params.params) do
			newparams[i] = j
		end
	end
	return require('Module:Carte').multimap(newparams)
end
p.buildMap = p.buildmap

function p.buildexternaltext(params)
	local value = getValue(params.value)
	if value and (type(value) == 'string') then
		externaltext = externaltext .. value
	end
end
p.buildExternalText = p.buildexternaltext

function p.buildfooter(params)
	if not params then
		params = {}
	end

	local classes = 'navbar noprint bordered navigation-not-searchable ' .. (params.class or '')
	local style = params.style or {}
	if not style['border-top'] and maincolor then
		style['border-top'] = '1px solid' .. maincolor
	end

	local 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 itemlinkstr
	if localdata.item and localdata.item ~= '-' then
		itemlinkstr = '[[d:' .. localdata.item .. '|' .. i18n['edit item'] .. ']]'
	end
	local editstr = backlinkstr
	if itemlinkstr then
		editstr = editstr .. ' - ' .. itemlinkstr
	end
	local 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 frame
	local 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 footer
end
p.buildFooter = p.buildfooter

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

	local 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,
		['subheader2col'] = p.buildSubheader2col,
	}
	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' )
	if type( localdata.item ) == 'table' then
		localdata.item = localdata.item.id
	end

	-- assign rank to the infobox, "secondary" means special formatting like no displaytitle for coordinates
	local infoboxrank = 'main' -- main infobox of the page, with coordinates displayed in title etc.
	if page.namespace ~= 0 then
		infoboxrank = 'secondary'
	end
	-- if infobox is linked to another item: rank = secondary
	if localdata.item then
		local itemlink = mw.wikibase.sitelink(localdata.item)
		local pagetitle = page.prefixedText
		if (itemlink or '') ~= pagetitle then
			infoboxrank = 'secondary'
		end
	end
	localdata.infoboxrank = infoboxrank

	-- load infobox module page
	local moduledata = require('Module:Infobox/' .. localdata.modulename)
	moduledata.name = localdata.modulename

	-- maintenance categories given by the module page
	if moduledata.categories then
		for i, j in pairs(moduledata.categories) do
			if (type(j) == 'string') then addMaintenanceCat(j) end
			if (type(j) == 'table') then addMaintenanceCat(j[1],j[2]) end
		end
	end

	-- defines main color
	maincolor = localdata['couleur infobox'] or localdata['couleur bo?te'] or localdata['couleur boite'] or moduledata.maincolor
	secondcolor = moduledata.secondcolor
	thirdcolor = localdata['texte noir'] or localdata['couleur texte'] or moduledata.thirdcolor
	if maincolor and ( #maincolor == 6 or #maincolor == 3 ) and maincolor:match( '^%x+$' ) then
		maincolor = '#' .. maincolor
	end
	if thirdcolor and (thirdcolor == 'non' or thirdcolor == 'false') then
		thirdcolor = '#fff'
	end

	-- classes
	local classes = mw.getCurrentFrame():expandTemplate{ title = 'Classes début infobox', args = { version = '3' } }
	classes = classes .. ' large ' .. (moduledata.class or '')

	-- style
	if moduledata.style then addMaintenanceCat("Infobox en Lua avec un style CSS spécifique") end
	local style = moduledata.style or {}

	-- templatestyles
	local templatestyles = ''
	if moduledata.templatestyles then
		templatestyles = templatestyles .. mw.getCurrentFrame():extensionTag{ name = 'templatestyles', args = { src = moduledata.templatestyles} }
	end

	-- build infobox
	infobox	:addClass(classes)
			:css(style)
	for i, j in pairs( moduledata.parts ) do
		infobox:node( p.buildblock(j) )
	end
	infobox	:node(p.buildfooter(moduledata.footer))
			:done()

	return templatestyles .. tostring(infobox) .. externaltext, maintenance
end

return p
教师节送老师什么好 口腔医学专业学什么 牙齿上白色斑块是什么 女生为什么会痛经 蜱虫咬人后有什么症状
乳酸菌是什么菌 拉架棉是什么面料 ab型血可以给什么血型输血 打点是什么意思 肛周湿疹挂什么科
吴孟达什么时候去世的 苍蝇是什么味道 闪点什么意思 折什么时候读she 人流需要准备什么
size是什么意思 精梳棉是什么面料 胃胀打嗝吃什么药最好 为什么手机会发烫 静脉曲张看什么科室
广东有什么特色美食hcv8jop6ns1r.cn 腮帮子长痘痘是什么原因hcv8jop2ns3r.cn 睚眦欲裂什么意思hcv7jop9ns8r.cn 天气一热身上就痒是什么原因hcv8jop8ns2r.cn 脚底干裂起硬皮是什么原因怎么治hcv7jop6ns9r.cn
月牙消失了是什么原因hcv7jop9ns7r.cn 50分贝相当于什么声音hcv8jop9ns8r.cn 骨骼是什么意思hcv8jop8ns6r.cn 胆固醇高不能吃什么食物tiangongnft.com 牛肉粉是什么调料hcv9jop7ns0r.cn
小米什么时候成熟hcv9jop5ns5r.cn 馥字五行属什么hcv8jop2ns5r.cn 阿罗汉是什么意思bjcbxg.com 毛泽东属相是什么hcv8jop3ns1r.cn 牛尾炖什么最好aiwuzhiyu.com
耳朵真菌感染用什么药bjhyzcsm.com 梦见吐血是什么预兆hcv7jop4ns6r.cn 幼儿园什么时候开学hcv8jop7ns7r.cn 上身胖下身瘦是什么原因hcv9jop4ns7r.cn 停电了打什么电话wzqsfys.com
百度