Module:Infobox
Көрініс
![]() | Бұл Lua модулі қолданылады көптеген беттерде бетте і йақауларды кеңінен байқауға болады. Өтінеміз, кез келген өңдемені сынақтан өткізіңіз /зертхана және /сынақ беттерінде модульдің немесе өзіңіздің жекеій модуль зертханасында, және өзгерістің талқылауын назарға алыңыз на талқылау бетінде талқылаңыз енгізбес бұрын. |
Module:Infobox {{Инфобокс}} үлгісінің жұмыс істеуіне қажет модуль. Оны қолдану нұсқаулығын үлгі бетінен қараңыз.
Үлгіде қателері бар беттерді қадағалау санаттары
- Санат:Pages using infobox templates with ignored data cells
- Санат:Articles using infobox templates with no data rows
- Санат:Pages using embedded infobox templates with the title parameter
local p = {};
local yesno = require('Module:Yesno')
local function _renderLine( frame, args, i )
if args[ 'тақырыпша' .. i ] and args[ 'тақырыпша' .. i ] == '-' then
return ''
elseif args[ 'тақырыпша' .. i ] and args[ 'тақырыпша' .. i ] ~= '' then
local style = ( args[ 'тақырыпша_стиль' ] or '' ) .. ( args[ 'тақырыпша_стиль' .. i ] or '' );
local class = ( args[ 'класс' .. i ] or '' );
return '\n<tr>\n<th colspan="2" scope="colgroup" class="infobox-header ' .. class .. '" style="' .. style .. '">' ..
args[ 'тақырыпша' .. i ] ..
'</th>\n</tr>';
end
if args[ 'блок' .. i ] and args[ 'блок' .. i ] ~= '' then
return args[ 'блок' .. i ];
end
local text = args[ 'мәтін' .. i ] or '';
if args[ 'уикидеректер' .. i ] and args[ 'уикидеректер' .. i ] ~= '' then
text = frame:expandTemplate{ title = 'Wikidata', args = {
args[ 'уикидеректер' .. i ],
text,
from = args[ 'from' ] or ''
} };
end
if text ~= '' then
local label = args[ 'белгі' .. i ] or '';
local class = args[ 'класс' .. i ] or '';
if string.find(class, 'noplainlist') == nil and string.find(class, 'nofirstlevel') == nil then
class = class .. ' plainlist';
end
if class ~= '' then
class = ' class="' .. class .. '"';
end
local style = ( args[ 'мәтіндер_стиль' ] or '' ) .. ( args[ 'мәтін_стиль' ] or '' ) .. ( args[ 'мәтін_стиль' .. i ] or '' );
if label == '' then
style = 'text-align:center;' .. style;
end
if style ~= '' then
style = ' style="' .. style .. '"';
end
if label ~= '' then
local labelClass = args[ 'белгі_класс' ] or '';
if string.find(labelClass, 'noplainlist') == nil and string.find(labelClass, 'nofirstlevel') == nil then
labelClass = labelClass .. ' plainlist';
end
if labelClass ~= '' then
labelClass = ' class="' .. labelClass .. '"';
end
local labelStyle = ( args[ 'белгі_стиль' ] or '' ) .. ( args[ 'белгі_стиль' .. i ] or '' );
if labelStyle ~= '' then
labelStyle = ' style="' .. labelStyle .. '"';
end
return '\n<tr>\n<th scope="row"' .. labelClass .. labelStyle .. '>' .. label .. '</th>' ..
'\n<td' .. class .. style .. '>\n' .. text .. '</td>\n</tr>';
end
return '\n<tr>\n<td colspan="2"' .. class .. style .. '>\n' .. text .. '</td>\n</tr>';
end
return '';
end
local function maxNumber ( args )
local maxNumber = 0
for argName, _ in pairs(args) do
local argNumber = mw.ustring.match(argName, '^[^0-9]+([0-9]+)$')
if argNumber and tonumber(argNumber) > maxNumber then
maxNumber = tonumber(argNumber)
end
end
return maxNumber
end
function p.renderLine( frame )
local args = frame:getParent().args;
return _renderLine(frame, args, '')
end
function p.renderLines( frame )
local args = frame:getParent().args;
local res = ''
local header, text = '', ''
local autoHeaders = yesno(args [ 'автотақырыпша' ] or 'false', false)
for i = 1, maxNumber(args) do
if args[ 'тақырыпша' .. i ] and args[ 'тақырыпша' .. i ] ~= '' then
if text ~= '' or not autoHeaders then
res = res .. header .. text
end
header, text = _renderLine(frame, args, i), ''
else
text = text .. _renderLine(frame, args, i)
end
end
if text ~= '' or not autoHeaders then
res = res .. header .. text
end
return res
end
return p;