Modul:Protection banner: Unterschied zwischen den Versionen
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) |
||
Zeile 278: | Zeile 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 = {} | ||
Zeile 297: | Zeile 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 | ||
Zeile 363: | Zeile 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 | ||
Zeile 384: | Zeile 372: | ||
-- Private methods -- | -- Private methods -- | ||
function Blurb:_getExpandedMessage( | function Blurb:_getExpandedMessage(msgKey) | ||
return self:_substituteParameters(self._cfg.msg[msgKey]) | |||
end | end | ||