欢迎来到奇葩栖息地!欢迎加入Discord服务器:XfrfHCzfbW。请先至特殊:参数设置验证邮箱后再进行编辑。在特殊:参数设置挑选自己想要使用的小工具!不会编辑?请至这里学习Wikitext语法。
模块:Infobox
来自奇葩栖息地
-- Infobox code modified by MyNe70 aka [[User:マジやばくね]]
local p = {}
function p.infobox( f )
local args = require('Module:ProcessArgs').merge(true)
local isSubBox = args.subbox
local title
local imageArea
local subHeader
local footer
if not isSubBox then
if args.title and args.title ~= 'none' then
title = args.title
local titleNode = mw.html.create('div')
:addClass('infobox-title')
:cssText(args.titlestyle)
:wikitext(title)
title = tostring(titleNode)
end
imageArea = args.imagearea
if not (imageArea and imageArea ~= 'none') then
local images = {}
local defaultImageSize = args.defaultimagesize or '160px'
args.image1 = args.image1 or args.image
args.image1size = args.image1size or args.imagesize or defaultImageSize
local imgCount = {}
for k, v in pairs(args) do
if type(k) == 'string' then
local image, num = k:match('(image)(%d+)$')
if v:lower() ~= 'none' and image then
table.insert(imgCount, tonumber(num))
end
end
end
table.sort(imgCount)
for _, v in ipairs(imgCount) do
local size = args['image' .. v .. 'size'] or defaultImageSize
local image = '[[File:' .. args['image' .. v] .. '|' .. size .. ']]'
table.insert(images, '<div>' .. image .. '</div>')
end
images = table.concat(images, '\n')
imageArea = images ~= '' and images or 'none'
end
if imageArea and imageArea ~= 'none' then
imageArea = '<div class="infobox-imagearea">' .. imageArea .. '</div>'
else
imageArea = nil
end
subHeader = args.subheader
if subHeader then
local subHeaderNode = mw.html.create('div')
:addClass('infobox-subheader')
:cssText(args.subheaderstyle)
:wikitext(subHeader)
subHeader = tostring(subHeaderNode)
end
footer = args.footer
if footer then
footer = '<div class="infobox-footer">' .. footer .. '</div>'
end
end
local rows = args.rows
if rows then
if isSubBox then
rows = '<div class="infobox-rows subinfobox">' .. rows .. '</div>'
else
rows = '<div class="infobox-rows">' .. rows .. '</div>'
end
end
if not (title or imageArea or subHeader or rows or footer) then
return ''
else
local html = {}
if not isSubBox then
html = {
'<div class="notaninfobox">',
title or '',
imageArea or '',
subHeader or '',
rows or '',
footer or '',
'</div>'
}
else
html = {rows}
end
return table.concat(html, '')
end
end
return p