Module:Protection banner: Difference between revisions
rm some locals that only get used once
(make the Protection class be in charge of the title, and some other tweaks) |
(rm some locals that only get used once) |
||
Line 278: | Line 278: | ||
--]] | --]] | ||
local cats = cfg.protectionCategories | local cats = cfg.protectionCategories | ||
for i = 1, 2^noActive do | for i = 1, 2^noActive do | ||
local key = {} | local key = {} | ||
Line 297: | Line 296: | ||
local attempt = cats[key] | local attempt = cats[key] | ||
if attempt then | if attempt then | ||
return makeCategoryLink(attempt) | |||
end | end | ||
end | end | ||
end | end | ||
function Protection:makeExpiryCategory() | function Protection:makeExpiryCategory() | ||
local | local cfg = self._cfg | ||
if not self.expiry | if not self.expiry | ||
and 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 reasonsWithoutExpiryCheck[self.reason] | and not cfg.reasonsWithoutExpiryCheck[self.reason] | ||
then | then | ||
return makeCategoryLink(self._cfg.msg['tracking-category-expiry']) | |||
end | end | ||
end | end | ||
function Protection:makeErrorCategory() | function Protection:makeErrorCategory() | ||
local | local expiry = self.expiry | ||
if not self:isProtected() | if not self:isProtected() | ||
or type( | or type(expiry) == 'number' and expiry < os.time() | ||
then | then | ||
return makeCategoryLink(self._cfg.msg['tracking-category-incorrect']) | |||
end | end | ||
end | end | ||
function Protection:makeTemplateCategory() | function Protection:makeTemplateCategory() | ||
local | local action, namespace = self.action, self.title.namespace | ||
if self.level == 'templateeditor' | if self.level == 'templateeditor' | ||
and ( | and ( | ||
( | (action ~= 'edit' and action ~= 'move') | ||
or ( | or (namespace ~= 10 and namespace ~= 828) | ||
) | ) | ||
then | then | ||
return makeCategoryLink(self._cfg.msg['tracking-category-template']) | |||
end | end | ||
end | end | ||
Line 363: | Line 349: | ||
function Blurb.makeFullUrl(page, query, display) | function Blurb.makeFullUrl(page, query, display) | ||
return string.format( | |||
'[%s %s]', | |||
return string.format('[%s %s]', | tostring(mw.uri.fullUrl(page, query)), | ||
display | |||
) | |||
end | end | ||
Line 384: | Line 372: | ||
-- Private methods -- | -- Private methods -- | ||
function Blurb:_getExpandedMessage( | function Blurb:_getExpandedMessage(msgKey) | ||
return self:_substituteParameters(self._cfg.msg[msgKey]) | |||
end | end | ||