Модуль:Конец анкеты

Материал из Кадровый состав НКВД 1935-1939
Перейти к навигации Перейти к поиску

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

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


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


pp[''] = function ( frame )
	local args = frame:getParent().args

	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]  and photo[1] ~= '-' then
		table.insert( out, '[[' .. photo[1] .. '|thumb|x250px]][[Категория:Страницы персоналий с фотоматериалами]]' )
	end

	local gFio = global.get( 'gFIO' )
	if not gFio then
		return '<p class=error>Нет правильного ФИО — нет данных!</p>'
	end
	local aboutUs = {}
	local ranksQuery, ranksCount = collect.dbtable( gFio, 'ranks', aboutUs )
	local designationsQuery, designationsCount = collect.dbtable( gFio, 'designations', aboutUs )
	local prizesQuery, prizesCount = collect.dbtable( gFio, 'awards', aboutUs )
	local mentionsQuery, mentionsCount = collect.dbtable( gFio, 'mentions', aboutUs )
	local excerptsQuery, excerptsCount = {}, 0
	local whoiswhoQuery, whoiswhoCount = {}, 0

	local data4person = collect.dbtable( gFio, 'data4person', aboutUs )

	if data4person.mentions then
		for _, row in ipairs( data4person.mentions ) do
			table.insert( mentionsQuery, row )
		end
		mentionsCount = mentionsCount + data4person.mentions.count
	end

	if data4person.excerpts then
		for _, row in ipairs( data4person.excerpts ) do
			table.insert( excerptsQuery, row )
		end
		excerptsCount = excerptsCount + data4person.excerpts.count
	end



	local aboutOther = global.get( 'gDelLink' ) or {}
	local counter = 0
	for i, page in ipairs( aboutOther ) do
		if aboutUs[page] then
			aboutUs[page] = nil
			aboutOther[i] = 0
			counter = counter + 1
		end
	end
	if next( aboutUs ) then
		table.insert( out, '<p class="nkvd-dis-links nkvd-hide-link">Документы, в которых, возможно, упоминается '
				.. mw.title.getCurrentTitle().text .. ': ' )
		outChap = {}
		for page, _ in pairs( aboutUs ) do
			tmp = mw.title.new( page )
			table.insert( outChap, '[[' .. tmp.fullText .. '|' .. tmp.text .. ']]' )
		end
		table.insert( out, table.concat( outChap, ', ') .. '.</p>' )
		outChap = {}
	end
	if #aboutOther ~= counter then
		table.insert( out, '<div class="nkvd-hide-link ">' )
		outChap = {}
		for _, page in ipairs( aboutOther ) do
			if page ~= 0 then
				table.insert( outChap, '[[' .. page .. ']]' )
			end
		end
		table.insert( out, tools.errorMsg( 'О другом', 'Нет ссылок на эту страницу со страниц: ' .. table.concat( outChap, ', ') ) .. '</div>' )
		outChap = {}
	end


	table.insert( out, '<p class="nkvd-bio">' )

	local gender
	gender, tmp = require('Модуль:Конец анкеты/ФИО') ( )
	if not gender then
		return tmp
	end
	table.insert( out, tmp )
	if gender ~= 2 then
		g_0_a = ''
		g_sya_as = 'ся'
	else
		g_0_a = 'а'
		g_sya_as = 'ась'
		table.insert( out, '[[Категория:Женщины]]&nbsp;' )
	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>' )

	local gRel = global.get( 'gRel' )
	if gRel then
		outChap = {}
		for i, rel in ipairs( gRel ) do
			outChap[i] = rel[1] .. ' — ' .. rel[2] .. tools.commonParams( rel.add, rel.ref, rel.source )
		end
		table.insert( out, '<p class="nkvd-bio">' )
		table.insert( out, tools.phrase( table.concat( outChap, '; ' ) ) )
		table.insert( out, '</p>' )
	end

	local gEdu = global.get( 'gEdu' )
	if gEdu then
		table.insert( out, '<p class="nkvd-bio">')
		table.insert( out, tools.phrase ( 'Образование: ' .. gEdu.text
			.. tools.commonParams( gEdu.addendum, gEdu.reference, gEdu.source ) )
			.. ' ' )
		table.insert( out, '</p>')
	end

	local gBiotext = global.get( 'gBiotext' )
	if gBiotext then
		table.insert( out, '<p class="nkvd-bio">')
		table.insert( out, tools.phrase ( gBiotext.text
			.. tools.commonParams( gBiotext.addendum, gBiotext.reference, gBiotext.source ) )
			.. ' ' )
		table.insert( out, '</p>')
	end
--[==[
	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
--]==]
	gBiotext = global.get( 'gViptext' )
	if gBiotext then
		table.insert( out, '<p class="nkvd-vip">[[Категория:Депутаты и проч.]]' )
		table.insert( out, tools.phrase ( gBiotext.text
			.. tools.commonParams( gBiotext.addendum, gBiotext.reference, gBiotext.source ) )
			.. ' ' )
		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
--]==]
	local KPSS, VLKSM, Bund
	tmp, KPSS, VLKSM, Bund = require( 'Модуль:Конец анкеты/Партии' ) ()
	table.insert( out, tmp )

	local gGBage = global.get( 'g-Чекстаж' )
	local gKAage = global.get( 'g-РККА' )
	if gGBage or gKAage then
		table.insert( out, '<p class="nkvd-nkvd">' )
		outChap = {}
		if gKAage and ( gKAage[1] or '' ) ~= '' then
			table.insert( outChap, 'В РККА с ' .. tools.reparseDate( gKAage[1] )
				.. tools.commonParams( gKAage[2], gKAage[3], gKAage[4] ) .. '.')
		end
		if gKAage and ( gKAage[5] or '' ) ~= '' then
			table.insert( outChap, tools.phrase(gKAage[5]) )
		end

		if gGBage and ( 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 ) .. '. ' )
--		else
--			reab = {}
--		end
--		if Bio.repr then
--			Bio.repr.reabstate = reab.state
--			Bio.repr.reabdate = reab.date
--			Bio.repr.reabaddendum = reab.addendum
--			Bio.repr.reabreference = reab.reference
--			Bio.repr.reabsource = reab.source
--			table.insert( out, frame:expandTemplate{ title = 'Таблица репрессий', args = Bio.repr } )
--		end
--		if Bio.repr2 then
--			Bio.repr2.reabstate = reab.state
--			Bio.repr2.reabdate = reab.date
--			Bio.repr2.reabaddendum = reab.addendum
--			Bio.repr2.reabreference = reab.reference
--			Bio.repr2.reabsource = reab.source
--			table.insert( out, frame:expandTemplate{ title = 'Таблица репрессий', args = Bio.repr2 } )
--		end

--		table.insert( out, '</p>' )

--	else
		local repr, reab = global.get( 'repression!' ), global.get( 'reabilitation!' )

		if repr or reab then
			-- data4person.repr_arch — делалось под номера дел от Кокурина, но в работу так и не пошло, можно убить
			local extData
			if data4person.repr_arch then
				extData = data4person.repr_arch[1]
				if data4person.repr_arch.count > 1 then
					table.insert( out, '[[Категория:Много упоминаний дел на одну персону]]' )
				else
					if #repr ~= 1 then
						table.insert( out, '[[Категория:Упоминание дела при нескольких репрессиях]]' )
					end
				end
			end
			table.insert( out, '<p class="nkvd-repr">[[Категория:Репрессированные]]Подвергал'.. g_sya_as .. ' репрессиям. &nbsp; ' )
			table.insert( out, require( 'Модуль:Репрессия!' ).reprText( repr, reab, gender == 2, extData ) )
			table.insert( out, '</p>' )
		elseif data4person.repr_arch then
			table.insert( out, '[[Категория:Неприкаянное дело]]' )
		end
--	end

	local newInfo = global.get( 'gInfo' )
	if whoiswhoCount ~= 0 then
		newInfo = newInfo or {}
		for _, dsc in ipairs( whoiswhoQuery ) do
			if dsc._eq_ then
				local txt = dsc.text
				if dsc.ref then
					txt = txt .. require( 'Module:RefTools' ).makeRef( dsc.ref )
				end
				table.insert( newInfo, txt )
			end
		end
	end
	if data4person.whoiswho and data4person.whoiswho.count ~= 0 then
		newInfo = newInfo or {}
		for _, dsc in ipairs( data4person.whoiswho ) do
			if dsc._eq_ then
				local txt = dsc.text
				if dsc.ref then
					txt = txt .. require( 'Module:RefTools' ).makeRef( dsc.ref )
				end
				table.insert( newInfo, txt )
			end
		end
	end
	if newInfo then
		table.insert( out, '<p class="nkvd-info">Источники и дополнительная информация: ' )
		table.insert( out, table.concat( newInfo, ',&nbsp; ') )
		table.insert( out, '.</p>' )
	end

	local talk = mw.title.getCurrentTitle().talkPageTitle
	if talk.exists then
		table.insert( out, '<p class="nkvd-info">См. также [[' .. talk.fullText .. '|обсуждение]] этой страницы.</p>' )
	end
--	local chapVar = true -- = args and args[1] == 'chap'
--	if not chapVar then
--		table.insert( out, require('Module:!Отображение упоминаний').display( mentionsQuery, mentionsCount ) )
--	end
--[===[
--]===]
	table.insert( out, '<h2>Прохождение службы</h2>' )
	table.insert( out, require('Module:!Отображение назначений').display( designationsQuery, designationsCount ) )
	table.insert( out, '<h2>Звания</h2>' )
	table.insert( out, require('Module:!Отображение званий').display( ranksQuery, ranksCount ) )
	table.insert( out, '<h2>Награды</h2>' )
	table.insert( out, require('Module:!Отображение наград').display( prizesQuery, prizesCount ) )
	if --[[chapVar and]] mentionsCount ~= 0 then
		table.insert( out, '<h2>Иные упоминания</h2>' )
		table.insert( out, require('Module:!Отображение упоминаний').display( mentionsQuery, mentionsCount, nil --[[, 'chap']] ) )
	end
	if photo and ( #photo > 1 --[[ or photo.more ]] )  then
		outChap = { '<h2>Фотографии</h2>[[Категория:Страницы персоналий с фотоматериалами]]' }
		if   #photo > 1 then
			table.insert( outChap, '<gallery mode="traditional">' )
			for _, v in ipairs( photo ) do
				if v ~= '-' then
					table.insert( outChap, v )
				end
			end
			table.insert( outChap, '</gallery>' )
		end
		table.insert( out, frame:preprocess( table.concat( outChap, '\n' ) ) )
		if photo.more then
			table.insert( out, 'См. также [' .. photo.more .. ' фотографии и документы в архиве].' )
		end
	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 ) --
--	if args and args[1] then
--		local persocat = {
--			[''] = '',
--			['ПР15'] = 'Включенные в связи с награждением ПР15',
--		}
--		local tmp = persocat[mw.text.trim(args[1])]
--		if ( tmp or '' ) ~= '' then
--			table.insert( out, '[[Category:' .. tmp .. ']]' )
--		end
----			table.insert( out, '*****' )
--	end

	if excerptsCount ~= 0 then
		table.insert( out, '<h2>Дополнительные сведения</h2>' )
		local refTools
		for _, row in ipairs( excerptsQuery ) do
			if row._eq_ then
				local text = string.gsub( row.text, '%b{}', function ( str )
					refTools = refTools or require( 'Module:RefTools' )
					return refTools.makeRef( string.sub( str, 2, -2 ) )
				end )
				table.insert( out, frame:preprocess( '\n'
					.. '{{ цитата | текст = ' .. text
					.. ' | источник = ' .. ( row.source or '' )
					.. ' | первоисточник = ' .. ( row.original or '' )
					.. ' | архив = ' .. ( row.archive or '' )
					.. ' | дополнение = ' .. ( row.addendum or '' )
					.. ' | сноска = ' .. ( row.ref or '' )
					.. '}}' ) )
			end
		end
		global.set( 'допинфо', true )
	end
	table.insert( out, '<div id=nkvd-searchbar>' )
	if #gFio > 1 then
		table.insert( out, '<div id=nkvd-searchbar-toggle><span class="nkvd-searchbar-toggle active" data-n=1></span>' )
		for n = 2, #gFio do
			table.insert( out, '<span class=nkvd-searchbar-toggle data-n=' .. n .. '></span>' )
		end
		table.insert( out, '</div>' )
	else
		table.insert( out, '<div id=nkvd-searchbar-toggle style="display:none"><span class="nkvd-searchbar-toggle active" data-n=1></span></div>' )
	end
	local bd = string.sub( birthDate or '', 1, 4 )
	local active = ' active'
	for n, fio in ipairs( gFio ) do
		table.insert( out, '<div id=nkvd-searchbar-el-' .. n
			.. ' class="nkvd-searchbar-el' .. active .. '" data-n=' .. n
			.. ' data-f="' .. fio.l .. '" data-i="' .. fio.f .. '" data-o="' .. fio.m
			.. '" data-y="' .. bd .. '" data-d="' .. ( fio.d or '' ) .. '"></div>' )
		active = ''
	end
	table.insert( out, '<div id=nkvd-searchbar-place></div></div>' )
	return table.concat( out )
end

pp['Допинфо'] = function ( frame )
	if not global.get( 'допинфо' ) then
		return '<h2>Дополнительные сведения</h2>'
	end
end
return pp