мНемає опису редагування |
мНемає опису редагування |
||
Рядок 110: | Рядок 110: | ||
imageArea = images .. '\n' .. invImages |
imageArea = images .. '\n' .. invImages |
||
else |
else |
||
− | imageArea = ' |
+ | imageArea = 'ні' |
end |
end |
||
end |
end |
Версія за 15:12, 9 червня 2019
This module implements {{Картка}}
. It should generally be invoked directly on template pages, rather than using the infobox template.
Parent arguments are automatically merged with directly passed arguments (the latter overwriting the former) and all arguments are normalised to trim whitespace and set empty arguments to nil
.
Dependencies
- Модуль:Анімація (when using animated images)
- Модуль:Інвентарний слот (when using invimages)
- Модуль:ProcessArgs
Див. також
{{3rd Party Tool}}
{{Блок}}
{{Блок-сутність}}
{{Компанія}}
{{Сутність}}
{{Їжа}}
{{Ігровий режим}}
{{Предмет}}
{{Предмет-сутність}}
{{Модифікація}}
{{Людина}}
{{Профіль}}
{{Програма}}
{{Споруда}}
{{Технічний блок}}
{{Версія навігація}}
- Модуль:Картка
local p = {}
function p.infobox( f )
local args = require( 'Модуль:ProcessArgs' ).merge( true )
local titleObject = mw.title.getCurrentTitle()
local title = args['назва'] or titleObject.subpageText
---Передача даних про використаний інструмент з шаблону Блок для модуля Breaking row
f:callParserFunction( '#dplvar:set', 'blocktool', args["інструмент"] )
local imageArea = args["зображення"]
if not imageArea and imageArea ~= 'none' then
local images = {}
local invImages = {}
local defaultImageSize = args["промоврозмзобр"] or '160px'
args["зобр1"] = args["зобр1"] or args["зобр"] or 'title'
args["зобр1розмір"] = args["зобр1розмір"] or args["зобррозмір"]
args["інвзображення1"] = args["інвзображення1"] or args["інвзображення"] or 'title'
local imgCount = {}
local invImgCount = {}
for k, v in pairs( args ) do
if type( k ) == 'string' then
local image, num = mw.ustring.match(k, '^(зобр)(%d+)$' )
local invImage, invNum = mw.ustring.match(k, '^(інвзображення)(%d+)$' )
if mw.ustring.lower(v) ~= 'ні' then
if image then
table.insert( imgCount, tonumber( num ) )
elseif invImage then
table.insert( invImgCount, tonumber( invNum ) )
end
end
end
end
table.sort( imgCount )
local animate
for k, v in ipairs( imgCount ) do
local image = args['зобр' .. v]
local size = args['зобр' .. v .. 'розм'] or defaultImageSize
if image == 'title' then
local filename
if titleObject.isSubpage then
filename = title .. ' (' .. titleObject.baseText .. ').png'
else
filename = title .. '.png'
end
local imageTitle = mw.title.new( 'Файл:' .. filename )
if imageTitle and imageTitle.exists then
image = '[[Файл:' .. filename .. '|' .. size .. ']]'
elseif titleObject.namespace == 0 then
image = '[[Файл:No image.svg|' .. size .. '|link=Файл:' .. filename .. '|Завантажити ' .. filename .. ']]'
else
image = '[[Файл:No image.svg|' .. size .. '|link=]]'
end
elseif mw.ustring.match(image, ';' ) then
if not animate then
animate = require( 'Модуль:Анімація' ).animate
end
image = animate{ image, size }
else
image = '[[Файл:' .. image .. '|' .. size .. ']]'
end
table.insert( images, '<div>' .. image .. '</div>' )
end
images = table.concat( images, '\n' )
if #invImgCount > 0 then
table.sort( invImgCount )
local grid
local invIds = mw.loadData( [[Модуль:ІнвСпрайт]] ).ids
for k, v in ipairs( invImgCount ) do
local image = args['інвзображення' .. v]
if image == 'title' then
local imageExists
if invIds[title] then
imageExists = true
else
local imageTitle = mw.title.new( 'Файл:Grid ' .. title .. '.png' )
imageExists = imageTitle and imageTitle.exists
end
if imageExists then
image = title
else
image = false
end
end
if image == '----' then
table.insert( invImages, '</div><div style="padding-top:.5em">' )
elseif image then
if not grid then
grid = require( 'Модуль:Інвентарний слот' ).slot
end
table.insert( invImages, grid{ image, ['посилання'] = 'none' } )
end
end
if grid and #invImages > 0 then
invImages = '<div class="infobox-invimages"><div>' .. table.concat( invImages, '' ) .. '</div></div>'
else
invImages = ''
end
else
invImages = ''
end
if images ~= '' or invImages ~= '' then
imageArea = images .. '\n' .. invImages
else
imageArea = 'ні'
end
end
if imageArea and imageArea ~= 'ні' then
imageArea = '<div class="infobox-imagearea">' .. imageArea .. '</div>'
else
imageArea = ''
end
local footer = args["підвал"] or args.footer
if footer then
footer = '| class="infobox-footer" colspan="2" | ' .. footer
end
local bgcolor = args["колір"]
if bgcolor then
bgcolor = ' style="background:#' .. bgcolor .. '"'
end
local s = ''
if args["ширина"] then s = ' style="width:' .. args["ширина"] .. 'px"' end
local html = {
'<div class="notaninfobox"' .. s .. '>',
'<div class="mcwiki-header infobox-title"', bgcolor or '', '>' .. title .. '</div>',
imageArea,
'{| class="infobox-rows" cellspacing="1" cellpadding="4"',
'|-',
args["ряди"] or args.rows or '',
footer or '',
'|}',
'</div>'
}
return table.concat( html, '\n' )
end
return p