Open main menu

Changes

Module:Protection banner

608 bytes added, 02:47, 24 June 2014
various category updates
local Category = class('Category')
function Category:initialize(configObj, protectionStatusObj, titleObj) self._configObj = configObj self._protectionStatusObj = protectionStatusObj self._titleObj = titleObj
end
end
function Category:exportrender() if self._categoryName _name then
return string.format(
'[[%s:%s]]',
mw.site.namespaces[14].name,
self._categoryName_name
)
else
return ''
end
end
local ProtectionCategory = Category:subclass('ProtectionCategory')
function ProtectionCategory:setNameinitialize( name, configObj, protectionStatusObj, namespace titleObj) --[[ -- Sets the protection categoryCategory. If a category name is not providedinitialize(self, this -- method gets a category name from the module configconfigObj, given a combinationprotectionStatusObj) -- of the protection type, the protection level, the namespace number, theself._titleObj = titleObj -- reason for protection, and the expiry date.end --]] function ProtectionCategory:render() -- If a name was provided, use thatlocal configObj = self._configObj if name then Categorylocal protectionStatusObj = self.setName(self, name)_protectionStatusObj endlocal titleObj = self._titleObj
-- Get the namespace category key from the namespace number.
local nskey
do
local namespace = titleObj.namespace
local categoryNamespaces = configObj:getConfigTable('categoryNamespaces')
if not namespace or type(namespace) ~= 'number' then nskey = nil else nskey = categoryNamespaces[nsnamespace] if not nskey and ns namespace % 2 == 1 then nskey = 'talk' end
end
end
if cat then
Category.setName(self, cat)
return Category.export(self)
else
error(
local ExpiryCategory = Category:subclass('ExpiryCategory')
 
function ExpiryCategory:render()
local configObj = self._configObj
local protectionStatusObj = self._protectionStatusObj
end
--------------------------------------------------------------------------------
local ErrorCategory = Category:subclass('ErrorCategory')
 
function ErrorCategory:render()
local configObj = self._configObj
local protectionStatusObj = self._protectionStatusObj
local expiry = protectionStatusObj:getExpiry()
local action = protectionStatusObj:getAction()
local level = protectionStatusObj:getLevel()
 
if type(expiry) == 'number' and expiry < os.time()
or level == '*'
or action == 'move' and level == 'autoconfirmed'
then
Category.setName(self, configObj:getMessage('tracking-category-incorrect'))
return Category.export(self)
end
end
--------------------------------------------------------------------------------
Anonymous user