コンテンツにスキップ

英文维基 | 中文维基 | 日文维基 | 草榴社区

モジュール:サンドボックス/rxy/保護状態

モジュールの解説[作成]
--[[
Copyright (c) 2016 rxy <https://rxy.jp/>
License: The MIT License (MIT)
License detail: https://opensource.org/licenses/MIT
]]

local p = {}
local expiry = require("モジュール:Effective protection expiry")

function p.main(frame)
	local pageName = frame.args[1]
	local page = mw.title.new( pageName )
	mw.log(mw.dumpObject(page.protectionLevels))
	local returnProtectionLevels = ""
	for action, level in pairs( page.protectionLevels ) do
		if level[1] ~= nil then
			local actionMsg = mw.message.new( "restriction-"..action):plain()
			if action == "create" then
				if level[1] == "editprotected" then 
					level[1] = "sysop"
				elseif level[1] == "editsemiprotected" then 
					level[1] = "autoconfirmed"
				end
			end
			local levelMsg = mw.message.new( "protect-level-"..level[1] ):plain()
			local expiry = expiry._main(action, pageName)
			local expiryMsg
			if expiry == "infinity" then
				expiryMsg = mw.message.new("protect-expiry-indefinite"):plain()
			else
				expiryMsg = mw.message.new("protect-expiring", expiry):plain()
			end
			returnProtectionLevels = mw.message.new( "protect-summary-desc", actionMsg, levelMsg, expiryMsg ):plain().." "..returnProtectionLevels
			mw.log(mw.dumpObject( returnProtectionLevels ))
		end
	end
	returnProtectionLevels = returnProtectionLevels ~= "" and returnProtectionLevels or "未保護"
	return returnProtectionLevels
end

return p