モジュール:Protected edit request

これはこのページの過去の版です。222.230.131.5 (会話) による 2016年2月24日 (水) 15:23個人設定で未設定ならUTC)時点の版であり、現在の版とは大きく異なる場合があります。

モジュールの解説[表示] [編集] [履歴] [キャッシュを破棄]

このモジュールは{{半保護編集依頼}}や{{拡張半保護編集依頼}}といった保護編集依頼テンプレートの内部で使用されています。編集依頼が有効化されている場合に限り、サブモジュールであるモジュール:Protected edit request/activeが使用されます。

require('Module:No globals')

local yesno = require('Module:Yesno')
local makeMessageBox = require('Module:Message box').main
local getArgs

local activeBox -- lazily initialized if we get an active request

----------------------------------------------------------------------
-- Box class definition
----------------------------------------------------------------------

local box = {}
box.__index = box

function box.new(protectionType, args)
	local obj = {}
	setmetatable(obj, box)
	obj.tmboxArgs = {} -- Used to store arguments to be passed to tmbox by the box:export method.
	-- Set data fields.
	obj.tmboxArgs.attrs = { ['data-origlevel'] = protectionType }
	return obj
end

function box:setArg(key, value)
	-- This sets a value to be passed to tmbox.
	if key then
		self.tmboxArgs[key] = value
	end
end

function box:export()
	self:setArg('smalltext', "この依頼は終了処理されました。依頼を再活性化するには<code style=\"white-space: nowrap;\">&#124;answered&#61;</code>または<code style=\"white-space: nowrap;\">&#124;ans&#61;</code>パラメータを'''no'''にして下さい。")
	self:setArg('small', true)
	self:setArg('class', 'editrequest')
	return makeMessageBox('tmbox', self.tmboxArgs)
end

----------------------------------------------------------------------
-- Process arguments and initialise objects
----------------------------------------------------------------------

local p = {}

function p._main(protectionType, args)
	local boxType = box
	if not yesno(args.answered or args.ans, true) then
		if not activeBox then
			activeBox = require('モジュール:Protected edit request/active')(box, yesno, makeMessageBox)
		end
		boxType = activeBox
	end
	local requestBox = boxType.new(protectionType, args)
	return requestBox:export()
end

local mt = {}

function mt.__index(t, k)
	if not getArgs then
		getArgs = require('Module:Arguments').getArgs
	end
	return function (frame)
		return t._main(k, getArgs(frame, {wrappers = {'Template:Edit fully-protected', 'Template:Edit semi-protected', 'Template:Edit template-protected'}}))
	end
end

return setmetatable(p, mt)