Modul:Protection banner: Unterschied zwischen den Versionen
add template protection tracking category
(output the categories, and don't display the banner if the page is not protected) |
(add template protection tracking category) |
||
Zeile 164: | Zeile 164: | ||
function ProtectionStatus:getLevel() | function ProtectionStatus:getLevel() | ||
return self._level | return self._level | ||
end | |||
function ProtectionStatus:isProtected() | |||
return self._level ~= '*' | |||
end | end | ||
Zeile 741: | Zeile 745: | ||
-- Get the level and exit if the page is not protected. | -- Get the level and exit if the page is not protected. | ||
if not protectionStatusObj:isProtected() then | |||
return '' | return '' | ||
end | end | ||
Zeile 768: | Zeile 771: | ||
local reason = protectionStatusObj:getReason() | local reason = protectionStatusObj:getReason() | ||
local action = protectionStatusObj:getAction() | local action = protectionStatusObj:getAction() | ||
local level = protectionStatusObj:getLevel() | |||
--[[ | --[[ | ||
Zeile 886: | Zeile 890: | ||
end | end | ||
if cat then | if cat then | ||
self:setName(cat) | |||
end | end | ||
return Category.render(self) | |||
end | end | ||
Zeile 917: | Zeile 916: | ||
and not reasonsWithoutExpiryCheck[reason] | and not reasonsWithoutExpiryCheck[reason] | ||
then | then | ||
self:setName(configObj:getMessage('tracking-category-expiry')) | |||
end | end | ||
return Category.render(self) | |||
end | end | ||
Zeile 937: | Zeile 935: | ||
local level = protectionStatusObj:getLevel() | local level = protectionStatusObj:getLevel() | ||
if | if not protectionStatusObj:isProtected() | ||
or type(expiry) == 'number' and expiry < os.time() | |||
then | |||
self:setName(configObj:getMessage('tracking-category-incorrect')) | |||
end | |||
return Category.render(self) | |||
end | |||
-------------------------------------------------------------------------------- | |||
-- TemplateCategory class | |||
-------------------------------------------------------------------------------- | |||
local TemplateCategory = Category:subclass('TemplateCategory') | |||
function TemplateCategory:initialize(configObj, protectionStatusObj, titleObj) | |||
Category.initialize(self, configObj, protectionStatusObj) | |||
self._titleObj = titleObj | |||
end | |||
function TemplateCategory:render() | |||
local configObj = self._configObj | |||
local protectionStatusObj = self._protectionStatusObj | |||
local titleObj = self._titleObj | |||
local action = protectionStatusObj:getAction() | |||
local level = protectionStatusObj:getLevel() | |||
local namespace = titleObj.namespace | |||
if level == 'templateeditor' | |||
and ( | |||
action == 'create' | |||
or not (namespace == 10 or namespace == 828) | |||
) | |||
then | |||
self:setName(configObj:getMessage('tracking-category-template')) | |||
end | end | ||
return Category.render(self) | |||
end | end | ||
Zeile 1.014: | Zeile 1.045: | ||
ProtectionCategory:new(configObj, protectionObj, titleObj), | ProtectionCategory:new(configObj, protectionObj, titleObj), | ||
ExpiryCategory:new(configObj, protectionObj), | ExpiryCategory:new(configObj, protectionObj), | ||
ErrorCategory:new(configObj, protectionObj) | ErrorCategory:new(configObj, protectionObj), | ||
TemplateCategory:new(configObj, protectionObj, titleObj) | |||
} | } | ||
for _, obj in ipairs(objects) do | for _, obj in ipairs(objects) do |