Module:Protection banner: Difference between revisions

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