Module:Protection banner: Difference between revisions

Jump to navigation Jump to search
make the protection object responsible for accessing the title object and the config inside the Blurb class
>Mr. Stradivarius
(remove another unnecessary local)
>Mr. Stradivarius
(make the protection object responsible for accessing the title object and the config inside the Blurb class)
Line 313: Line 313:
self._cfg = cfg
self._cfg = cfg
self._protectionObj = protectionObj
self._protectionObj = protectionObj
self._bannerConfig = protectionObj.bannerConfig
self._title = protectionObj.title
self._deletionDiscussionPage = args.xfd
self._deletionDiscussionPage = args.xfd
self._username = args.user
self._username = args.user
Line 396: Line 394:
-- protection.
-- protection.
local action = self._protectionObj.action
local action = self._protectionObj.action
local pagename = self._title.prefixedText
local pagename = self._protectionObj.title.prefixedText
if action == 'move' then
if action == 'move' then
-- We need the move log link.
-- We need the move log link.
Line 438: Line 436:
return string.format(
return string.format(
'[[%s:%s#%s|%s]]',
'[[%s:%s#%s|%s]]',
mw.site.namespaces[self._title.namespace].talk.name,
mw.site.namespaces[self._protectionObj.title.namespace].talk.name,
self._title.text,
self._protectionObj.title.text,
section,
section,
disputes
disputes
Line 491: Line 489:
local action = self._protectionObj.action
local action = self._protectionObj.action
local level = self._protectionObj.level
local level = self._protectionObj.level
local namespace = self._title.namespace
local namespace = self._protectionObj.title.namespace
local isTalk = self._title.isTalkPage
local isTalk = self._protectionObj.title.isTalkPage


-- @TODO: add semi-protection and pending changes blurbs
-- @TODO: add semi-protection and pending changes blurbs
Line 554: Line 552:
function Blurb:_makePagetypeParameter()
function Blurb:_makePagetypeParameter()
local pagetypes = self._cfg.pagetypes
local pagetypes = self._cfg.pagetypes
local namespace = self._title.namespace
local namespace = self._protectionObj.title.namespace
return pagetypes[namespace] or pagetypes.default or error('no default pagetype defined')
return pagetypes[namespace] or pagetypes.default or error('no default pagetype defined')
end
end
Line 603: Line 601:
function Blurb:_makeProtectionLogParameter()
function Blurb:_makeProtectionLogParameter()
local action = self._protectionObj.action
local action = self._protectionObj.action
local pagename = self._title.prefixedText
local pagename = self._protectionObj.title.prefixedText
if action == 'autoreview' then
if action == 'autoreview' then
-- We need the pending changes log.
-- We need the pending changes log.
Line 635: Line 633:
return string.format(
return string.format(
'[[%s:%s#%s|%s]]',
'[[%s:%s#%s|%s]]',
mw.site.namespaces[self._title.namespace].talk.name,
mw.site.namespaces[self._protectionObj.title.namespace].talk.name,
self._title.text,
self._protectionObj.title.text,
section or 'top',
section or 'top',
display
display
Line 654: Line 652:
local mVandalM = require('Module:Vandal-m')
local mVandalM = require('Module:Vandal-m')
local username = self._username
local username = self._username
username = username or self._title.baseText
username = username or self._protectionObj.title.baseText
return mVandalM._main{username}
return mVandalM._main{username}
end
end
Line 661: Line 659:


function Blurb:makeReasonText()
function Blurb:makeReasonText()
local msg = self._bannerConfig.text
local msg = self._protectionObj.bannerConfig.text
if msg then
if msg then
return self:_substituteParameters(msg)
return self:_substituteParameters(msg)
Line 668: Line 666:


function Blurb:makeExplanationText()
function Blurb:makeExplanationText()
local msg = self._bannerConfig.explanation
local msg = self._protectionObj.bannerConfig.explanation
return self:_substituteParameters(msg)
return self:_substituteParameters(msg)
end
end


function Blurb:makeTooltipText()
function Blurb:makeTooltipText()
local msg = self._bannerConfig.tooltip
local msg = self._protectionObj.bannerConfig.tooltip
return self:_substituteParameters(msg)
return self:_substituteParameters(msg)
end
end


function Blurb:makeAltText()
function Blurb:makeAltText()
local msg = self._bannerConfig.alt
local msg = self._protectionObj.bannerConfig.alt
return self:_substituteParameters(msg)
return self:_substituteParameters(msg)
end
end


function Blurb:makeLinkText()
function Blurb:makeLinkText()
local msg = self._bannerConfig.link
local msg = self._protectionObj.bannerConfig.link
return self:_substituteParameters(msg)
return self:_substituteParameters(msg)
end
end
Anonymous user

Navigation menu