Модуль:Конец анкеты: различия между версиями

Материал из Кадровый состав НКВД 1935-1939
Перейти к навигации Перейти к поиску
Нет описания правки
Нет описания правки
Строка 308: Строка 308:
addendum      = '',
addendum      = '',
} } )
} } )
return table.concat( out ) .. editorSearch -- mw.dumpObject( out ) --
return table.concat( out ) .. editorSearch() -- mw.dumpObject( out ) --


end
end


return pp
return pp

Версия от 21:42, 25 января 2017

Для документации этого модуля может быть создана страница Модуль:Конец анкеты/doc

local pp = {}
local global = mw.ext.luaglobal
local tools = require( 'Модуль:Tools' )
global.strict( true )

local coD = mw.loadData( 'Модуль:Анкета/Причины смерти' )

local function editorSearch()
	local gFio = global.get( 'gFIO' )[1]
	local name
	local out = {}
	if ( gFio[2] or '' ) ~= '' then
		name = gFio[1] .. ', ' .. gFio[2] .. ' ' .. gFio[3]
	else
		name = gFio[1]
	end
	out[#out+1] = '[[ru:' .. name .. '|Википедия]]'
	
	local birth =  global.get( 'gBirth' ) or {}
	birth = tools.reparseDate( birth[1] or '—' )
	if birth == '—' then
		birth = ''
	end
	out[#out+1] =  '«[https://pamyatnaroda.mil.ru/heroes/?last_name=' .. gFio[1] 
		.. '&first_name=' .. (gFio[2] or '') .. '&middle_name=' .. (gFio[3] or '')
		.. '&date_birth=' .. birth .. ' Память народа]»'
	
	out[#out+1] = '[' .. tostring( mw.uri.fullUrl( 'Special:Drilldown/names' , { ['_search_name[0]'] = gFio[2] .. ' ' .. gFio[3] } ) ) .. ' Поиск тезок (И.О.)]'
	out[#out+1] = '[[Special:Drilldown/names|Свободный поиск по ФИО]]'
	out[#out+1] = '[https://yandex.ru/yandsearch?text=' .. mw.uri.encode( name ) .. ' Поиск Яндексом]'


--	return '<div class="nkvd-hide-link" style="columns: 3 25em; -moz-columns: 3 25em; -webkit-columns: 3 25em; background-color:#fff7d1; margin:1em; padding:1em;">\n'
--		.. '<ul><li>' .. table.concat( out, '</li><li>' ) .. '</li></ul></div>'
	return '<div class="nkvd-hide-link" style="text-align: center; background-color:#fff7d1; margin:1em; padding:1em;">\n'
		.. '<ul class=hlist><li>' .. table.concat( out, '</li><li>' ) .. '</li></ul></div>'
end
	



pp[''] = function ( frame )

	local out = { '__NOTOC__' }
--	local categories = {}
	local tmp
	local outChap = {}
	local Bio = global.get( 'gBio' ) or {}
	local g_0_a, g_sya_as

	local photo = global.get( 'g-Фото' )
	if photo and photo[1] ~= '-' then
		table.insert( out, '[[' .. photo[1] .. '|thumb|x250px]][[Категория:Страницы персоналий с фотоматериалами]]' )
	end
	tmp = tools.cq( 'unknowns', '_pageName, pattern', {
			where = '"' .. mw.title.getCurrentTitle().text .. '" LIKE pattern',
		} )
	if #tmp ~= 0 then
		table.insert( out, '<p class="nkvd-dis-links">Документы, в которых, возможно, упоминается ' 
				.. mw.title.getCurrentTitle().text .. ': ' )
		outChap = {}
		for _, page in ipairs( tmp ) do
			table.insert( outChap, '[[' .. mw.title.new( page._pageName ).fullText .. '|' .. mw.title.new( page._pageName ).text .. ']]' )
		end	
		table.insert( out, table.concat( outChap, ', ') .. '.</p>' )
		outChap = {}
	end
	
	table.insert( out, '<p class="nkvd-bio">' )

	local gender, fioForJournals = require('Модуль:Конец анкеты/ФИО') ( out )
	if not gender then
		return fioForJournals
	end
	if gender ~= 2 then
		g_0_a = ''
		g_sya_as = 'ся'
	else
		g_0_a = 'а'
		g_sya_as = 'ась'
		table.insert( out, '[[Категория:Женщины]]' )
	end	
	local gEthn =  global.get( 'gEthn' )
	if gEthn then
		table.insert( out, 'Национальность — ' .. gEthn[1]
			.. tools.commonParams( unpack( gEthn, 2, 4 ) ) .. '. ' )
	end
	local gRod =  global.get( 'gBirth' )
	local birthDate, birthPlace, family, birthAddendum, reference, source
	if gRod then
		birthDate, birthPlace, family, birthAddendum, reference, source
			= unpack( gRod )
		outChap = {}
		if birthDate ~= '' or family ~= '' then
			outChap[1] = 'Родил' .. g_sya_as
			if #birthDate == 10 then
				outChap[2] = string.sub( birthDate, 9, 10 ) .. '.'
					.. string.sub( birthDate, 6, 7 ) .. '.'
					.. string.sub( birthDate, 1, 4 )
			elseif #birthDate == 7 then
				outChap[2] = 'в ' .. string.sub( birthDate, 6, 7 ) .. '.'
					.. string.sub( birthDate, 1, 4 )
			elseif #birthDate == 4 then
				outChap[2] =  'в ' .. string.sub( birthDate, 1, 4 ) .. ' году'
			end
			if family ~= '' then
				table.insert( outChap, 'в семье ' .. tools.noPhrase( family ) )
			end
		end
		table.insert( out, table.concat( outChap, ' ' ) )
		if birthPlace ~= '' then
			if #outChap ~= 0 then
				outChap = '; место '
			else
				outChap = 'Место '
			end
			outChap = 	outChap .. tools.noPhrase( 'рождения — ' .. birthPlace )
			table.insert( out, outChap )
		end
		table.insert( out, tools.commonParams( birthAddendum, reference, source ) .. '. ' )
	else
		table.insert( out, 'Информации о дате и месте рождения нет. ' )
	end
	local gDeath = global.get( 'gDeath' )
	local deathDate, deathPlace, deathCause, deathAddendum
	if gDeath then
		deathDate, deathPlace, deathCause, deathAddendum, reference, source
			= unpack( gDeath )
		outChap = {}
		if deathDate ~= '' then
			if #deathDate == 10 then
				outChap[1] = string.sub( deathDate, 9, 10 ) .. '.'
					.. string.sub( deathDate, 6, 7 ) .. '.'
					.. string.sub( deathDate, 1, 4 )
			elseif #deathDate == 7 then
				outChap[1] = 'в ' .. string.sub( deathDate, 6, 7 ) .. '.'
					.. string.sub( deathDate, 1, 4 )
			elseif #deathDate == 4 then
				outChap[1] =  'в ' .. string.sub( deathDate, 1, 4 ) .. ' году'
			end
		end
		if deathPlace ~= '' then
			table.insert( outChap, deathPlace )
		end
		if deathCause ~= '' then
			table.insert( outChap, 'причина смерти — ' .. coD.causeOD[deathCause] )
		end
		table.insert( out, 'Смерть: ' .. table.concat( outChap, ', ' ) )
		table.insert( out, tools.commonParams( deathAddendum, reference, source ) .. '. ' )
	else
		table.insert( out, 'Информации о смерти нет. ' )
	end
	table.insert( out, '</p>' )

	if Bio.who then
		table.insert( out, '<p class="nkvd-bio">')
		table.insert( out, tools.phrase ( Bio.who.text
			.. tools.commonParams( Bio.who.addendum, Bio.who.reference, Bio.who.source ) )
			.. ' ' )
		table.insert( out, '</p>')
	end
	
	local KPSS, VLKSM, Bund
	tmp, KPSS, VLKSM, Bund = require( 'Модуль:Конец анкеты/Партии' ) ()
	table.insert( out, tmp )
	local gGBage = global.get( 'g-Чекстаж' )
	if gGBage then
		table.insert( out, '<p class="nkvd-nkvd">' )
		outChap = {}
		if ( gGBage[1] or '' ) ~= '' then
			table.insert( outChap, 'В органах ВЧК−ОГПУ−НКВД с ' .. tools.reparseDate( gGBage[1] )
				.. tools.commonParams( gGBage[2], gGBage[3], gGBage[4] ) .. '.')
		end
		table.insert( out, table.concat( outChap, ' ' ) .. '</p>' )
	end

	if Bio.repr or Bio.reab then
		table.insert( out, '<p class="nkvd-repr">' )
		outChap = { '[[Категория:Репрессированные]]Подвергал'.. g_sya_as .. ' репрессиям' }
		local double
		for _, r in ipairs( { Bio.repr, Bio.repr2 } ) do
			if r.arrest ~= '' then
				if double then
					tmp = 'Повторно арестован' .. g_0_a .. ' '
					double = false
				else
					tmp = 'Арестован' .. g_0_a .. ' '
				end
				table.insert( outChap, tmp .. tools.reparseDate( r.arrest ) )
			end
			-- date, court, decision
			-- Осужден date (court). Приговор: decision
			-- Осужден date. Приговор: decision
			-- Приговор (court): decision
			-- Орган, вынесший решение: court
			if r.date ~= '' then
				if double then
					tmp = 'Повторно осужден' .. g_0_a .. ' '
					double = false
				else
					tmp = 'Осужден' .. g_0_a .. ' '
				end
				table.insert( outChap, tmp .. tools.reparseDate( r.date ) )
			end
			if ( r.court or '' ) ~= '' then
				if double then
					table.insert( outChap, 'Осужден' .. g_0_a .. ' повторно' )
					double = false
				end
				table.insert( outChap, 'Орган, вынесший решение — ' .. r.court )
			end
			if ( r.indictment or '' ) ~= '' then
				if double then
					table.insert( outChap, 'Осужден' .. g_0_a .. ' повторно' )
					double = false
				end
				table.insert( outChap, 'Обвинение — ' .. r.indictment )
			end
			if ( r.decision or '' ) ~= '' then
				if double then
					table.insert( outChap, 'Осужден' .. g_0_a .. ' повторно.' )
					double = false
				end
				table.insert( outChap, 'Решение: ' .. r.decision )
			end
			table.insert( out, table.concat( outChap, '. ' ) ..
				tools.commonParams( r.addendum, r.reference, r.source ) .. '. ' )
			outChap = {}
			double = true
		end
		local reab = Bio.reab
		if reab then
			if reab.state == 1 then
				outChap = 'Реабилитирован' .. g_0_a
			elseif reab.state == -1 then
				outChap = 'В реабилитации отказано'
			else
				outChap = 'Не реабилитирован' .. g_0_a
			end
			if reab.date ~= '' then
				outChap = outChap .. ' ' .. tools.reparseDate( reab.date )
			end
			table.insert( out, outChap ..
				tools.commonParams( reab.addendum, reab.reference, reab.source ) .. '. ' )
		end

		table.insert( out, '</p>' )
	end
	if Bio.vip then
		table.insert( out, '<p class="nkvd-vip">[[Категория:Депутаты и проч.]]' )
		table.insert( out, tools.phrase(Bio.vip.text ..
			tools.commonParams( Bio.vip.addendum, Bio.vip.reference, Bio.vip.source ) ) )
		table.insert( out, '</p>' )
	end
	if Bio.info then
		table.insert( out, '<p class="nkvd-info">Дополнительную информацию см. ' )
		table.insert( out, table.concat( Bio.info, ', ') )
		table.insert( out, '.</p>' )
	end

	fioForJournals = 'person="' .. table.concat( fioForJournals, '" OR person="' )
		.. '"'

	table.insert( out, require('Module:Отображение упоминаний').display(fioForJournals) )
	table.insert( out, '<h2>Прохождение службы</h2>' )
	table.insert( out, require('Module:Отображение назначений').display(fioForJournals) )
	table.insert( out, '<h2>Звания</h2>' )
	table.insert( out, require('Module:Отображение званий').display(fioForJournals) )
	table.insert( out, '<h2>Награды</h2>' )
	table.insert( out, require('Module:Отображение наград').display(fioForJournals) )
	
	if photo and #photo > 1 then
		outChap = { '<h2>Фотоматериалы</h2>[[Категория:Страницы персоналий с фотоматериалами]]<gallery mode="tracitional">' }
		for _, v in ipairs( photo ) do
			if v ~= '-' then
				table.insert( outChap, v )
			end
		end
		table.insert( outChap, '</gallery>' )
		table.insert( out, frame:preprocess( table.concat( outChap, '\n' ) ) )
	end
	
	gEthn = gEthn or {}
	table.insert( out, frame:expandTemplate{ title = 'Таблица персон', args = {
			gender         = gender,
			ethn           = gEthn[1],
			ethn_addendum  = gEthn[2],
			b_date         = birthDate,
			b_place        = birthPlace,
			b_addendum     = birthAddendum,
			d_date         = deathDate,
			d_place        = deathPlace,
			d_cause        = deathCause,
			d_addendum     = deathAddendum,
			difference     = Bio.difference,

			kp_state       = KPSS[1],
			kp_cand        = KPSS[2],
			kp_in          = KPSS[3],
			kp_out         = KPSS[4],
			kp_addendum    = KPSS[5],
			ksm_state      = VLKSM[1],
			ksm_in         = VLKSM[2],
			ksm_out        = VLKSM[3],
			ksm_addendum   = VLKSM[4],
			bund           = Bund[1],
--			bund_addendum  = gBund[2],
			addendum       = '',
		} } )
	return table.concat( out ) .. editorSearch()	-- mw.dumpObject( out ) --

end

return pp