Module:Protection banner: Difference between revisions

various category updates
(Add render methods to the Padlock and Banner classes, and call them from the exportToLua function. Now we have something to look at, yay!)
(various category updates)
Line 701:
local Category = class('Category')
 
function Category:initialize(configObj, protectionStatusObj, titleObj)
self._configObj = configObj
self._protectionStatusObj = protectionStatusObj
self._titleObj = titleObj
end
 
Line 708 ⟶ 711:
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
Line 726 ⟶ 727:
local ProtectionCategory = Category:subclass('ProtectionCategory')
 
function ProtectionCategory:setNameinitialize(configObj, protectionStatusObj, titleObj)
Category.initialize(self, configObj, protectionStatusObj)
name,
self._titleObj = titleObj
configObj,
end
protectionStatusObj,
 
namespace
function ProtectionCategory:render()
)
local configObj = self._configObj
--[[
local protectionStatusObj = self._protectionStatusObj
-- Sets the protection category. If a category name is not provided, this
local titleObj = self._titleObj
-- method gets a category name from the module config, given a combination
-- of the protection type, the protection level, the namespace number, the
-- reason for protection, and the expiry date.
--]]
-- If a name was provided, use that.
if name then
Category.setName(self, name)
end
-- Get the namespace category key from the namespace number.
local nskey
do
local namespace = titleObj.namespace
local categoryNamespaces = configObj:getConfigTable('categoryNamespaces')
nskey = categoryNamespaces[nsnamespace]
if not namespace or type(namespace) ~= 'number' then
if not nskey and namespace % 2 == 1 nilthen
nskey = 'talk'
else
nskey = categoryNamespaces[ns]
if not nskey and ns % 2 == 1 then
nskey = 'talk'
end
end
end
Line 883 ⟶ 873:
if cat then
Category.setName(self, cat)
return Category.setNameexport(self, name)
else
error(
Line 896 ⟶ 887:
 
local ExpiryCategory = Category:subclass('ExpiryCategory')
 
function ExpiryCategory:render()
local configObj = self._configObj
local protectionStatusObj = self._protectionStatusObj
end
 
--------------------------------------------------------------------------------
Line 902 ⟶ 898:
 
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
 
--------------------------------------------------------------------------------