Модуль:УИК
Материал из Справочника наблюдателя
Описание модуля[]
Документация отсутствует!
Вы можете создать документацию ( создать ).
Задавайте категории на странице документации, а не здесь! Показать подстраницы
Задавайте категории на странице документации, а не здесь! Показать подстраницы
local p={}
local t = mw.loadData( 'Модуль:УИК/Табличное' );
function NormUIK (numbUIK)
return ( string.gsub (numbUIK, '^0*([0-9]+)[%-/]?([0-9]*)$','%1%2'))..''
end
function DenormUIK (numbUIK)
return ( string.sub ('0000'..numbUIK, string.len (numbUIK) + 1) )
end
function p.Header (frame)
if (frame.args[1] == '') or (frame.args[1] == nil) then
return "<tr><th> Пустой заголовок </th></tr>"
end
local res = '<tr>'
local columns = mw.text.split (mw.text.trim(frame.args[1]), '[\t\r\n\f ]*[,;][\t\r\n\f ]*')
--[[
for column = 1, #columns do
res = res .. '«' .. columns[column] .. '» '
end
return res
]]--
local cols, colt, z
for column = 1, #columns do
z = columns[column]
if t.ht [z] == nil then
colt = '?'
cols = 'style="background-color:red;"'
else
colt = t.ht [z]
cols = t.hs [z]
end
res = res .. '<th ' .. cols .. '>' .. colt .. '</th>'
end
return frame:preprocess (res .. '</tr>')
end
function p.Data (frame)
if (frame.args[1] == '') or (frame.args[1] == nil) then
return "<tr><td> Пустой список колонок </td></tr>"
end
if (mw.text.trim(frame.args[1]) == 'карта') or (mw.text.trim(frame.args[1]) == 'multimaps') then
-- return frame:preprocess(trim(frame.args['гео']) .. '; ')
local geoa = frame.args['геоадрес'];
if geoa == nil then
geoa = frame.args['адрес'];
end
if geoa ~= nil then
local geo3 = mw.text.split (mw.text.trim(geoa) .. '::', '[\t\r\n\f ]*[:][\t\r\n\f ]*');
local coord = mw.text.split (mw.text.trim(geo3 [3]) .. ',', '[\t\r\n\f ]*[,][\t\r\n\f ]*');
if (mw.text.trim(frame.args[1]) == 'карта') then
geoa = '{{геокарта|'
else
geoa = '{{multimaps|'
end
if (frame.args['тип'] == '') or (frame.args['тип'] == 'УИК') or (frame.args['тип'] == nil) then
local Nu = DenormUIK(NormUIK(frame.args['номер']));
return frame:preprocess (geoa .. 'УИК|' .. frame.args['номер'] .. '|' .. geo3 [1] .. '|' .. geo3 [2] .. '|' .. coord [1] .. '|' .. coord [2] .. '|/E/'
.. string.sub (Nu,1,1) .. '/uik' .. Nu .. '-e.png}}')
else
local lab = frame.args['метка'];
if (lab == nil) then
lab = ''
end;
local titi = frame.args['тип'];
local tico = t.iconame[titi];
if tico == nil then
tico = '';
else
tico = '|/E/gov/'..tico;
end;
return frame:preprocess (geoa .. frame.args['тип'] .. '|' .. lab .. '|' .. geo3 [1] .. '|' .. geo3 [2] .. '|' .. coord [1] .. '|' .. coord [2] .. tico .. '}}')
end
end
return '';
elseif (mw.text.trim(frame.args[1]) == '{{{1}}}') then
return '';
else
local res = '<tr>'
local z, xt, xs
local columns = mw.text.split (mw.text.trim(frame.args[1]), '[\t\r\n\f ]*[;,][\t\r\n\f ]*')
for column = 1, #columns do
z = columns[column]
if (t.dt [z] == nil) or (t.dt [z] == '') then
xt = frame.args[z]
if xt == nil then
xt = ''
end
elseif z == 'галерея' then
xt = frame.args[z];
if (xt == '') or (xt == nil) then
xt = ''
else
xt = '[[Файл:Фотофайлы.png|link=' .. xt .. ']]'
end
elseif z == 'номер' then
xt = frame.args[z];
if (xt == '') or (xt == nil) then
xt = ''
else
xt = '[https://www.wikiuiki.org/ik/{{#var:RegCode}}-uik-' .. NormUIK (xt) .. ' ' .. xt .. ']';
end
elseif z == 'тип' then
xt = '[[Файл:Фотофайлы.png]]'
elseif z == 'адрес' then
xt = frame.args['геоадрес'];
if xt == nil then
xt = frame.args['адрес'];
if xt == nil then
xt = ''
end
else
xs = mw.text.split (mw.text.trim(xt) .. '::', '[\t\r\n\f ]*[:][\t\r\n\f ]*');
xt = mw.text.split (mw.text.trim(xs [3]) .. ',', '[\t\r\n\f ]*[,][\t\r\n\f ]*');
xt = '{{геоадрес|' .. xs [1] .. '|' .. xs [2] .. '|' .. xt [1] .. '|' .. xt [2] .. '}}';
end
else
xt = '???'
end
xs = t.ds [z]
if xs == nil then
xs = 'style="background-color:red;"'
end
res = res .. '<td ' .. xs .. '>' .. xt .. '</td>'
end
return frame:preprocess(res .. "</tr>")
end
end
return p
-- [[Категория:Шаблоны для таблиц УИК]]