Модуль:Perso

Материал из Справочника наблюдателя
Перейти к:навигация, поиск

(i)      Описание модуля[]

Документация отсутствует!


local p = {}

local divHide = '<div style="border:1px solid #D2B48C; background-color:#FFFFC0; padding:3px 6px; '

local function statusIK (sta, short)
	local x = mw.ustring.lower (mw.ustring.sub (sta,1,3))
	local tab = {
		['пре'] = {'председатель', 'Председатель избирательной комиссии'},
		['зам'] = {'зам. председателя', 'Заместитель председателя избирательной комиссии'},
		['сек'] = {'секретарь', 'Секретарь избирательной комиссии'},
		['чле'] = {'', 'Член избирательной комиссии'},
	}
	return ( tab [x] [short] )
end

local function guber (gudu)
	local y = mw.ustring.sub (gudu,1,3)
	local x = mw.ustring.lower (y)
	return ( x == 'губ' and mw.ustring.sub (y,1,7) ~= 'губернс' )	or x == 'мэр' or x == 'гла' or x == 'пре'
end

local function upperFirstAndRmDot (str)
	local i = -1
	if mw.ustring.sub (str, -1, -1) == '.' then
		i = -2
	end
	return mw.ustring.upper (mw.ustring.sub (str, 1, 1)) .. mw.ustring.sub (str, 2, i)
end

local function iniFio (io, f)
	local i_o = mw.text.split (io, ' ')
	return (mw.ustring.sub (i_o[1],1,1) .. '.&nbsp;' .. mw.ustring.sub (i_o[2],1,1) .. '.&nbsp;' .. f)
end

function p.Data (frame)
	local ownArgs = frame.args
	local extArgs = frame:getParent().args
	local pageTitle = mw.title.getCurrentTitle ()
	local result = {}
	local showMode
	if extArgs ['вид'] == 'ИКСРФ' then
		showMode = 1
	elseif pageTitle.nsText == 'Служебное' then
		showMode = 4
	else
		showMode = 3
	end

	local gender = mw.ustring.sub (ownArgs['ИО'],-1,-1) == 'а'
	if gender then
		gender = 'а'
	else
		gender = ''
	end
	
	local fa = ownArgs['Ф'] 
	local fio = fa .. ', ' .. ownArgs['ИО']
	local function compact (s, comma)
		local a, b, c = ownArgs [s] or '', extArgs [fa .. ':' .. s] or '', extArgs [fio .. ':' .. s] or ''
		if b ~= '' or c ~= '' then
			if a ~= '' then
				a = a .. comma
			end
			a = a .. divHide .. 'display:inline;">' .. b
			if b ~= '' and c ~= '' then
				a = a .. comma
			end
			a = a .. c .. '</div>'
		end
		return a
	end
	
	
	if showMode == 1 then
		if ownArgs ['ИК'] ~= 'ИКСРФ' then
			return nil
		end
		
		local x = statusIK (ownArgs ['ИК:статус'], 1)
		if x ~= '' then
			x = ' (' .. x .. ')'
		end
		table.insert (result, '<td>[[' .. pageTitle.text .. '/Персоналии#' .. fio .. '|' .. fio .. ']]' .. x .. '</td>')
		table.insert (result, '<td>' .. ownArgs['ИК:выдвинут'] .. '</td>') 

		x = ownArgs ['ИК:назначен'] or ''
		if x ~= '' then
			if guber (x) then
				x = 'Icon 11103.svg'
			else
				x = 'Community Noun project 2280.svg'
			end
			x = '&nbsp;[[Файл:' .. x .. '|16px|Назначен' .. gender .. ' ' .. ownArgs ['ИК:назначен'] .. ']]&nbsp;'
		end
		table.insert (result, '<td>' .. ownArgs['ИК:дата'] .. x .. '</td>') 
		
--		table.insert (result, '<td>' .. ownArgs['ИК:профиль']  .. '</td>') 
		
		table.insert (result, '<td>' .. ownArgs['работа'] .. '</td>') 

		table.insert (result, '<td>' .. ownArgs['ДР'] .. '</td>') 
		return ('<tr>' .. table.concat (result) .. '</tr>')
	elseif showMode >= 3 then
		local x  = ownArgs ['фото'] or ''
		local y
		if x ~= '' then
			if mw.ustring.sub (x,1,1) == '[' then
				table.insert (result, x .. '\n')
			else
				y  = ownArgs ['фото:текст'] or ''
				if y == '' then
					y = iniFio (ownArgs['ИО'], ownArgs['Ф'])
				end
				table.insert (result, '[[Файл:' .. x .. '|x150px|thumb|right|' .. y .. ']]\n')
			end
		end
		
		table.insert (result, '<h4>' .. fio .. '</h4>\n')
		
		x = {}
		y = compact('телефон', '&nbsp; ')
		if y  ~= '' then
			table.insert (x, '[[Файл:Телефон.svg|x16px|link=]]&nbsp;' .. y)
		end
		y = compact('e-mail', '&nbsp; ') 
		if y ~= '' then
			table.insert (x, y)
		end
		y = compact('соцсети', ' ')
		if y ~= '' then
			table.insert (x, y)
		end
		
		x = table. concat (x, '&nbsp;&nbsp; ')
		if x ~= '' then
			table.insert (result, '<span class="plainlinks">' .. x .. '</span>\n\n')
		end
		
		
		x = ownArgs ['ИК:статус'] or ''
		if x ~= '' then 
			x = statusIK (x, 2)
 -- это текстовый вариант выдачи
			table.insert (result, x .. '.\n')
			x = ownArgs ['ИК:назначен'] or ''
			if x ~= '' then
				table.insert (result, 'Назначен' .. gender .. ' в состав комиссии ' .. x .. '.\n')
			end
			x = ownArgs ['ИК:дата'] or ''
			if x ~= '' then
				table.insert (result, 'Начало полномочий ' .. x .. '.\n')
			end
			x = ownArgs ['ИК:выдвинут'] or ''
			if x ~= '' then
				table.insert (result, 'Субъект выдвижения в комиссию: ' .. x .. '.\n')
			end
--[==[ -- это табличный вариант выдачи
			table.insert (result, '<table class=standard width=100%><tr><td>' .. x .. '</td>')
			table.insert (result, '<td>' .. ownArgs['ИК:выдвинут'] .. '</td>') 
	
			x = ownArgs ['ИК:назначен'] or ''
			if x ~= '' then
				if guber (x) then
					x = 'Icon 11103.svg'
				else
					x = 'Community Noun project 2280.svg'
				end
				x = '&nbsp;[[Файл:' .. x .. '|16px|Назначен' .. gender .. ' ' .. ownArgs ['ИК:назначен'] .. ']]&nbsp;'
			end
			table.insert (result, '<td>' .. ownArgs['ИК:дата'] .. x .. '</td></tr></table>') 
--]==]
 -- это общая часть	
 			
			x = ownArgs ['ИК:профиль'] or ''
			if x ~= '' then
				table.insert (result, 'Сфера ответственности: ' .. x .. '.\n\n') 
			else
				table.insert (result, '\n')
			end
		end
		
		x = ownArgs ['работа'] or ''
		if x ~= '' then
			table.insert (result, upperFirstAndRmDot (x) .. '.\n\n')
		end
		
		x = ownArgs ['ДР'] or ''
		if x ~= '' then
			if gender == '' then
				y = 'Родился '
			else 
				y = 'Родилась '
			end
			if #x == 4 then
				x = y ..  'в ' .. x .. ' году'
			else 
				x = y .. x
			end
			table.insert (result, x .. '.\n')
		end

		x = ownArgs ['биография'] or ''
		if x ~= '' then
			table.insert (result, x)
		end
		
		x = (extArgs [fa .. ':дополнения'] or '') .. (extArgs [fio .. ':дополнения'] or '')
		if x ~= '' then
			table.insert (result, divHide .. 'min-width:60%; float:none; overflow:auto;">' .. x .. '</div>')
		end


		return  table.concat (result)
	end
		
end


function p.Section (frame)
	local ownArgs = frame.args
	local extArgs = frame:getParent().args
	local pageTitle = mw.title.getCurrentTitle ()
	local showMode
	if extArgs ['вид'] == 'ИКСРФ' then
		showMode = 1
	elseif pageTitle.nsText == 'Служебное' then
		showMode = 2
	else
		showMode = 3
	end
	
	if showMode == 1 then
		return nil
	end
	return ('<h' .. ((ownArgs[2] or 1)+1) .. '>' .. ownArgs[1] .. '</h' .. ((ownArgs[2] or 1)+1) .. '>')
end		


return p