Module:Protection banner: Difference between revisions
put Protection in charge of generating its own category links
(make Blurb be responsible for setting its own fields) |
(put Protection in charge of generating its own category links) |
||
Line 301: | Line 301: | ||
end | end | ||
function Protection: | function Protection:needsExpiry() | ||
local cfg = self._cfg | local cfg = self._cfg | ||
return not self.expiry | |||
and cfg.expiryCheckActions[self.action] | and cfg.expiryCheckActions[self.action] | ||
and self.reason -- the old {{pp-protected}} didn't check for expiry | and self.reason -- the old {{pp-protected}} didn't check for expiry | ||
and not cfg.reasonsWithoutExpiryCheck[self.reason] | and not cfg.reasonsWithoutExpiryCheck[self.reason] | ||
end | end | ||
function Protection: | function Protection:isIncorrect() | ||
local expiry = self.expiry | local expiry = self.expiry | ||
return not self:isProtected() | |||
or type(expiry) == 'number' and expiry < os.time() | or type(expiry) == 'number' and expiry < os.time() | ||
end | end | ||
function Protection: | function Protection:isTemplateProtectedNonTemplate() | ||
local action, namespace = self.action, self.title.namespace | local action, namespace = self.action, self.title.namespace | ||
return self.level == 'templateeditor' | |||
and ( | and ( | ||
(action ~= 'edit' and action ~= 'move') | (action ~= 'edit' and action ~= 'move') | ||
or (namespace ~= 10 and namespace ~= 828) | or (namespace ~= 10 and namespace ~= 828) | ||
) | ) | ||
then | end | ||
function Protection:makeCategoryLinks() | |||
local msg = self._cfg.msg | |||
local ret = { self:makeProtectionCategory() } | |||
if self:needsExpiry() then | |||
ret[#ret + 1] = makeCategoryLink(msg['tracking-category-expiry']) | |||
end | |||
if self:isIncorrect() then | |||
ret[#ret + 1] = makeCategoryLink(msg['tracking-category-incorrect']) | |||
end | |||
if self:isTemplateProtectedNonTemplate() then | |||
ret[#ret + 1] = makeCategoryLink(msg['tracking-category-template']) | |||
end | end | ||
return table.concat(ret) | |||
end | end | ||
Line 916: | Line 922: | ||
-- Render the categories | -- Render the categories | ||
if yesno(args.category) ~= false then | if yesno(args.category) ~= false then | ||
ret[#ret + 1] = protectionObj: | ret[#ret + 1] = protectionObj:makeCategoryLinks() | ||
end | end | ||