Jump to content

Module:Protection banner: Difference between revisions

output the categories, and don't display the banner if the page is not protected
(add expiry category code)
(output the categories, and don't display the banner if the page is not protected)
Line 705: Line 705:
local Category = class('Category')
local Category = class('Category')


function Category:initialize(configObj, protectionStatusObj, titleObj)
function Category:initialize(configObj, protectionStatusObj)
self._configObj = configObj
self._configObj = configObj
self._protectionStatusObj = protectionStatusObj
self._protectionStatusObj = protectionStatusObj
self._titleObj = titleObj
end
end


Line 740: Line 739:
local protectionStatusObj = self._protectionStatusObj
local protectionStatusObj = self._protectionStatusObj
local titleObj = self._titleObj
local titleObj = self._titleObj
-- Get the level and exit if the page is not protected.
local level = protectionStatusObj:getLevel()
if level == '*' then
return ''
end
-- Get the expiry.
-- Get the expiry.
Line 763: Line 768:
local reason = protectionStatusObj:getReason()
local reason = protectionStatusObj:getReason()
local action = protectionStatusObj:getAction()
local action = protectionStatusObj:getAction()
local level = protectionStatusObj:getLevel()
   
   
--[[
--[[
Line 883: Line 887:
if cat then
if cat then
Category.setName(self, cat)
Category.setName(self, cat)
return Category.export(self)
return Category.render(self)
else
else
error(
error(
Line 915: Line 919:
local cat = configObj:getMessage('tracking-category-expiry')
local cat = configObj:getMessage('tracking-category-expiry')
Category.setName(self, cat)
Category.setName(self, cat)
return Category.export(self)
return Category.render(self)
end
end
end
end
Line 935: Line 939:
if level == '*' or type(expiry) == 'number' and expiry < os.time() then
if level == '*' or type(expiry) == 'number' and expiry < os.time() then
Category.setName(self, configObj:getMessage('tracking-category-incorrect'))
Category.setName(self, configObj:getMessage('tracking-category-incorrect'))
return Category.export(self)
return Category.render(self)
end
end
end
end
Line 967: Line 971:


-- Render the banner
-- Render the banner
do
if protectionObj:getLevel() ~= '*' then
-- Get the banner object
-- Get the banner object
local isPadlock = yesno(args.small)
local isPadlock = yesno(args.small)
Line 1,006: Line 1,010:
-- Render the categories
-- Render the categories
do
local objects = {
ProtectionCategory:new(configObj, protectionObj, titleObj),
ExpiryCategory:new(configObj, protectionObj),
ErrorCategory:new(configObj, protectionObj)
}
for _, obj in ipairs(objects) do
ret[#ret + 1] = obj:render()
end
end
return table.concat(ret)
return table.concat(ret)
Cookies help us deliver our services. By using our services, you agree to our use of cookies.