Changes
		
		
		
		
		
		
		Jump to navigation
		Jump to search
		
 
 
 
 
 
		local actions = {if not args.action then			create self.action = true,			'edit = true,			move = true,			autoreview = true		}'		if argselseif self.action and actionssupportedActions[args.action] then
			selferror('Unsupported action ' .. args.action = 'edit', 2)
		local self.level = effectiveProtectionLevel(self.action, titleObj)		if self.level == 'accountcreator' then
			level = '*'		end		self.level = level or '*'	end 	-- Validation function for the expiry and the protection date	local function validateDate(date, dateType)		lang = lang or mw.language.getContentLanguage()		local success, expiry = pcall(lang.formatDate, lang, 'U', args.expiry)		expiry = tonumber(expiry)		if success and expiry then			return expiry		else			return string.format(				'<strong class="error">Error: invalid %s ("%s")</strong>',				dateType,				tostring(args.expiry)			)
		local indefStrings = if configObj.cfg.indefStrings		if indefStrings[args.expiry] then
		local fields = {
			'text',
			'explanation',
			'tooltip',
			'alt',
			'link',
			'image'
		}
end
 
function Protection._makeCategoryLink(cat)
	-- Static method for rendering category wikitext.
	if cat then
		return string.format(
			'[[%s:%s]]',
			mw.site.namespaces[14].name,
			cat
		)
	else
		return ''
	end
		
		
		
		
		
		
		
	
some cleanup
-- Lazily initialise modules and objects we don't always need.
local mArguments, mMessageBox, lang
--------------------------------------------------------------------------------
-- Helper functions
--------------------------------------------------------------------------------
local function makeCategoryLink(cat)
	if cat then
		return string.format(
			'[[%s:%s]]',
			mw.site.namespaces[14].name,
			cat
		)
	else
		return ''
	end
end
-- Validation function for the expiry and the protection date
local function validateDate(dateString, dateType)
	lang = lang or mw.language.getContentLanguage()
	local success, result = pcall(lang.formatDate, lang, 'U', dateString)
	if success then
		result = tonumber(result)
		if result then
			return result
		end
	end
	error(string.format(
		'invalid %s ("%s")',
		dateType,
		tostring(dateString)
	))
end
--------------------------------------------------------------------------------
local Protection = class('Protection')
Protection.supportedActions = {
	create = true,
	edit = true,
	move = true,
	autoreview = true
}
Protection.bannerConfigFields = {
	'text',
	'explanation',
	'tooltip',
	'alt',
	'link',
	'image'
}
function Protection:initialize(args, configObj, titleObj)
	-- Set action
	do
			self.action = args.action
		else
		end
	end
	-- Set level
	do
			-- Lump titleblacklisted pages in with template-protected pages,
			-- since templateeditors can do both.
			self.level = 'templateeditor'		end		if elseif not self.level or (self.action == 'move' and self.level == 'autoconfirmed' ) then
			-- Users need to be autoconfirmed to move pages anyway, so treat
			-- semi-move-protected pages as unprotected.
		end
	end
	-- Set expiry
	if args.expiry then
			self.expiry = 'indef'
		elseif type(args.expiry) == 'number' then
		self.bannerConfig = {}
		local cfg = configObj.cfg
		local configTables = {}
		if cfg.banners[self.action] then
		end
		configTables[#configTables + 1] = cfg.masterBanner
		for i, field in ipairs(fieldsself.bannerConfigFields) do
			for j, t in ipairs(configTables) do
				if t[field] then
function Protection:isProtected()
	return self.level ~= '*'
end
	end
	return self._makeCategoryLinkmakeCategoryLink(cat)
end
		cat = self._configObj.msg['tracking-category-expiry']
	end
	return self._makeCategoryLinkmakeCategoryLink(cat)
end
		cat = configObj.msg['tracking-category-incorrect']
	end
	return self._makeCategoryLinkmakeCategoryLink(cat)
end
		cat = configObj.msg['tracking-category-template']
	end
	return self._makeCategoryLinkmakeCategoryLink(cat)
end