Toggle menu
Toggle personal menu
Not logged in
Your IP address will be publicly visible if you make any edits.

Module:Protection banner: Difference between revisions

From the Lonsdale Battalion wiki
Content deleted Content added
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
local cat
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
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


Line 363: Line 349:


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


Line 384: Line 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


Cookies help us deliver our services. By using our services, you agree to our use of cookies.