Zum Inhalt springen

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
local cat
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
cat = attempt
return makeCategoryLink(attempt)
break
end
end
end
end
return makeCategoryLink(cat)
end
end


function Protection:makeExpiryCategory()
function Protection:makeExpiryCategory()
local reasonsWithoutExpiryCheck = self._cfg.reasonsWithoutExpiryCheck
local cfg = self._cfg
local expiryCheckActions = self._cfg.expiryCheckActions
local cat
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
cat = self._cfg.msg['tracking-category-expiry']
return makeCategoryLink(self._cfg.msg['tracking-category-expiry'])
end
end
return makeCategoryLink(cat)
end
end


function Protection:makeErrorCategory()
function Protection:makeErrorCategory()
local cfg = self._cfg
local expiry = self.expiry
local cat
if not self:isProtected()
if not self:isProtected()
or type(self.expiry) == 'number' and self.expiry < os.time()
or type(expiry) == 'number' and expiry < os.time()
then
then
cat = cfg.msg['tracking-category-incorrect']
return makeCategoryLink(self._cfg.msg['tracking-category-incorrect'])
end
end
return makeCategoryLink(cat)
end
end


function Protection:makeTemplateCategory()
function Protection:makeTemplateCategory()
local cfg = self._cfg
local action, namespace = self.action, self.title.namespace
local title = self.title
local cat
if self.level == 'templateeditor'
if self.level == 'templateeditor'
and (
and (
(self.action ~= 'edit' and self.action ~= 'move')
(action ~= 'edit' and action ~= 'move')
or (title.namespace ~= 10 and title.namespace ~= 828)
or (namespace ~= 10 and namespace ~= 828)
)
)
then
then
cat = cfg.msg['tracking-category-template']
return makeCategoryLink(self._cfg.msg['tracking-category-template'])
end
end
return makeCategoryLink(cat)
end
end


Zeile 363: Zeile 349:


function Blurb.makeFullUrl(page, query, display)
function Blurb.makeFullUrl(page, query, display)
local url = mw.uri.fullUrl(page, query)
return string.format(
url = tostring(url)
'[%s %s]',
return string.format('[%s %s]', url, display)
tostring(mw.uri.fullUrl(page, query)),
display
)
end
end


Zeile 384: Zeile 372:
-- Private methods --
-- Private methods --


function Blurb:_getExpandedMessage(msg)
function Blurb:_getExpandedMessage(msgKey)
local msg = self._cfg.msg[msg]
return self:_substituteParameters(self._cfg.msg[msgKey])
return self:_substituteParameters(msg)
end
end


Anonymer Benutzer