Minecraft Wiki
Advertisement

Этот модуль реализует {{К удалению}}.

В зависимости от пространства имён автоматически используется тело шаблона {{msgbox}} или {{ambox}}. Стили, включая изображение, настраиваются через классы на странице MediaWiki:Common-all.css.

Зависит от

См. также


local p = {}

local getType = function( namespace )
	local pageType = 'main'
	if namespace == 'Шаблон' or namespace == 'Template' then
		pageType = 'template'
	elseif namespace == 'Модуль' or namespace == 'Module' then
		pageType = 'module'
	elseif namespace == 'Категория' or namespace == 'Category' then
		pageType = 'category'
	elseif namespace == 'Файл' or namespace == 'File' then
		pageType = 'file'
	elseif namespace == 'Участник' or namespace == 'User' then
		pageType = 'user'
	end
	
	return pageType
end

local typeForms = {
	module = {nom = 'Этот модуль', acc = 'этот модуль', pronoun_gen = "его", nomP = 'Модули'},
	template = {nom = 'Этот шаблон', acc = 'этот виджет', pronoun_gen = "его", nomP = 'Виджеты'},
	category = {nom = 'Эта категория', acc = 'эту таблицу стилей', pronoun_gen = "её", nomP = 'Таблицы стилей'},
	file = {nom = 'Этот файл', acc = 'этот скрипт', pronoun_gen = "его", nomP = 'Скрипты'},
	user = {nom = 'Эта страница участника', acc = 'это сообщение', pronoun_gen = "его", nomP = 'Сообщения'},
	main = {nom = 'Эта страница', acc = 'этот шаблон', pronoun_gen = "его", nomP = 'Шаблоны'}
}

local reason_span = function(text)
	return '<span class="delete-reason">' .. text .. '</span>'
end

function p.base( args )
	local thisTypeForms = typeForms[args.page_type]

	local msgbox = {}
	local explanation = 'Пояснение причин вы можете найти на портале сообщества.'
	local prod_text = thisTypeForms.nom .. ' предлагается к удалению.'
	
	if args.reason and args.csd then
		error('Указана и причина для медленного удаления, и критерий для быстрого. Укажите что-то одно!')
	end
	if args.reason then
		explanation = ' <br><i>Причина: ' .. reason_span(args.reason) .. '</i>'
	end
	if args.csd then
		prod_text = thisTypeForms.nom .. ' предлагается к быстрому удалению.'
		explanation = 'Критерий для удаления: ' .. reason_span( require('Модуль:КБУ').criterion({args.csd, nil, args.csd_variant}) )
	end

	table.insert( msgbox, '{| class="msgbox msgbox-red delete-msgbox ' .. args.class .. '" ')
	table.insert( msgbox, '|-\n| class="msgbox_column1" | ')
	table.insert( msgbox, '| class="msgbox_column2" | <span class="msgbox_title">' .. prod_text .. '</span>')
	table.insert( msgbox, '<div class="msgbox_text">' .. explanation .. '</div>')
	table.insert( msgbox, '|}')

	msgbox = table.concat( msgbox, '\n' )
	return msgbox
end

function p.box( f )
	local args = require( 'Module:ProcessArgs' ).merge( true )
	
	local page = mw.title.getCurrentTitle()
	local namespace = page.nsText
	
	local processed_args = {
		reason = args[1],
		class = args.class or args["класс"] or '',
		csd = args["КБУ"],
		csd_variant = args["КБУВариант"] or '',
		page_type = getType( namespace )
	}
	return p.base(processed_args)
end

return p
Advertisement