Module:Protection banner: Difference between revisions

make the protection object responsible for accessing the title object and the config inside the Blurb class
(remove another unnecessary local)
(make the protection object responsible for accessing the title object and the config inside the Blurb class)
Line 313:
self._cfg = cfg
self._protectionObj = protectionObj
self._bannerConfig = protectionObj.bannerConfig
self._title = protectionObj.title
self._deletionDiscussionPage = args.xfd
self._username = args.user
Line 396 ⟶ 394:
-- protection.
local action = self._protectionObj.action
local pagename = self._title_protectionObj.title.prefixedText
if action == 'move' then
-- We need the move log link.
Line 438 ⟶ 436:
return string.format(
'[[%s:%s#%s|%s]]',
mw.site.namespaces[self._title_protectionObj.title.namespace].talk.name,
self._title_protectionObj.title.text,
section,
disputes
Line 491 ⟶ 489:
local action = self._protectionObj.action
local level = self._protectionObj.level
local namespace = self._title_protectionObj.title.namespace
local isTalk = self._title_protectionObj.title.isTalkPage
 
-- @TODO: add semi-protection and pending changes blurbs
Line 554 ⟶ 552:
function Blurb:_makePagetypeParameter()
local pagetypes = self._cfg.pagetypes
local namespace = self._title_protectionObj.title.namespace
return pagetypes[namespace] or pagetypes.default or error('no default pagetype defined')
end
Line 603 ⟶ 601:
function Blurb:_makeProtectionLogParameter()
local action = self._protectionObj.action
local pagename = self._title_protectionObj.title.prefixedText
if action == 'autoreview' then
-- We need the pending changes log.
Line 635 ⟶ 633:
return string.format(
'[[%s:%s#%s|%s]]',
mw.site.namespaces[self._title_protectionObj.title.namespace].talk.name,
self._title_protectionObj.title.text,
section or 'top',
display
Line 654 ⟶ 652:
local mVandalM = require('Module:Vandal-m')
local username = self._username
username = username or self._title_protectionObj.title.baseText
return mVandalM._main{username}
end
Line 661 ⟶ 659:
 
function Blurb:makeReasonText()
local msg = self._bannerConfig_protectionObj.bannerConfig.text
if msg then
return self:_substituteParameters(msg)
Line 668 ⟶ 666:
 
function Blurb:makeExplanationText()
local msg = self._bannerConfig_protectionObj.bannerConfig.explanation
return self:_substituteParameters(msg)
end
 
function Blurb:makeTooltipText()
local msg = self._bannerConfig_protectionObj.bannerConfig.tooltip
return self:_substituteParameters(msg)
end
 
function Blurb:makeAltText()
local msg = self._bannerConfig_protectionObj.bannerConfig.alt
return self:_substituteParameters(msg)
end
 
function Blurb:makeLinkText()
local msg = self._bannerConfig_protectionObj.bannerConfig.link
return self:_substituteParameters(msg)
end