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

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

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

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

global.strict( true )

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

local function editorSearch()
	local gFio = global.get( 'gFIO' )[1]
	local name
	local out = {}
	if ( gFio.f or '' ) ~= '' then
		name = gFio.l .. ', ' .. (gFio.f or '') .. ' ' .. (gFio.m or '')
	else
		name = gFio.l
	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://pamyat-naroda.ru/heroes/?last_name=' .. mw.uri.encode( gFio.l )
		.. '&first_name=' .. mw.uri.encode( gFio.f or '' ) .. '&middle_name=' .. mw.uri.encode( gFio.m or '' )
		.. '&date_birth=' .. birth .. ' Память народа]»'

	out[#out+1] = '[' .. tostring( mw.uri.fullUrl( 'Special:Drilldown/names' ,
			{ ['_search_name[0]'] = gFio.f .. ' ' .. gFio.m } ) )
				.. ' Поиск тезок (И.О.)] ([[Special:Drilldown/names|Свободный поиск по ФИО]])'
	out[#out+1] = '[https://yandex.ru/yandsearch?text=' .. mw.uri.encode( name ) .. ' Поиск Яндексом]'
	out[#out+1] = '[https://yandex.ru/yandsearch?text=' .. mw.uri.encode( name ) .. '&site=mozohin.ru Поиск на сайте Мозохина]'


--	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
	
	local gFio = global.get( 'gFIO' ) or {}
	local aboutUs = {}
	local ranksQuery, ranksCount = collect.dbtable( gFio, 
		'ranks_table', 
		'cDate, cDate__precision, _pageName, reference, rank, origin, alias, nLast, nFirst, nMiddle, nDisambig, nPrecision',
		aboutUs )
	local designationsQuery, designationsCount = collect.dbtable( gFio, 
		'designations_table',
		'cDate, cDate__precision, _pageName, reference, unit, position, segment, origin, article, dismissal_type, formula, alias, nLast, nFirst, nMiddle, nDisambig, nPrecision',
		aboutUs )
	local prizesQuery, prizesCount = collect.dbtable( gFio, 
		'prizes_table',
		'cDate, cDate__precision, _pageName, reference, prize, prizeNumber, origin, podvig, nLast, nFirst, nMiddle, nDisambig, nPrecision',
		aboutUs )
	local mentionsQuery, mentionsCount = collect.dbtable( gFio, 
		'mentions_table',
		'cDate, cDate__precision, _pageName, reference, comment, nLast, nFirst, nMiddle, nDisambig, nPrecision',
		aboutUs )
	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">Документы, в которых, возможно, упоминается '
				.. 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
--]==]
	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
	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
--]==]
	if Bio.info then
		table.insert( out, '<p class="nkvd-info">Дополнительную информацию см. ' )
		table.insert( out, table.concat( Bio.info, ', ') )
		table.insert( out, '.</p>' )
	end

	table.insert( out, require('Module:Отображение упоминаний').display( mentionsQuery, mentionsCount ) )
--[===[
--]===]
	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 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' ) ) )
		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 ) --
	return table.concat( out ) .. require( 'module:Toolbar' )( gFio[1].l, gFio[1].f, gFio[1].m )	-- mw.dumpObject( out ) --
end

return pp