Modul:Protection banner: Unterschied zwischen den Versionen
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) |
||
Zeile 313: | Zeile 313: | ||
self._cfg = cfg | self._cfg = cfg | ||
self._protectionObj = protectionObj | self._protectionObj = protectionObj | ||
self._deletionDiscussionPage = args.xfd | self._deletionDiscussionPage = args.xfd | ||
self._username = args.user | self._username = args.user | ||
Zeile 396: | Zeile 394: | ||
-- protection. | -- protection. | ||
local action = self._protectionObj.action | local action = self._protectionObj.action | ||
local pagename = self. | 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. | ||
Zeile 438: | Zeile 436: | ||
return string.format( | return string.format( | ||
'[[%s:%s#%s|%s]]', | '[[%s:%s#%s|%s]]', | ||
mw.site.namespaces[self. | mw.site.namespaces[self._protectionObj.title.namespace].talk.name, | ||
self. | self._protectionObj.title.text, | ||
section, | section, | ||
disputes | disputes | ||
Zeile 491: | Zeile 489: | ||
local action = self._protectionObj.action | local action = self._protectionObj.action | ||
local level = self._protectionObj.level | local level = self._protectionObj.level | ||
local namespace = self. | local namespace = self._protectionObj.title.namespace | ||
local isTalk = self. | local isTalk = self._protectionObj.title.isTalkPage | ||
-- @TODO: add semi-protection and pending changes blurbs | -- @TODO: add semi-protection and pending changes blurbs | ||
Zeile 554: | Zeile 552: | ||
function Blurb:_makePagetypeParameter() | function Blurb:_makePagetypeParameter() | ||
local pagetypes = self._cfg.pagetypes | local pagetypes = self._cfg.pagetypes | ||
local namespace = self. | 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 | ||
Zeile 603: | Zeile 601: | ||
function Blurb:_makeProtectionLogParameter() | function Blurb:_makeProtectionLogParameter() | ||
local action = self._protectionObj.action | local action = self._protectionObj.action | ||
local pagename = self. | 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. | ||
Zeile 635: | Zeile 633: | ||
return string.format( | return string.format( | ||
'[[%s:%s#%s|%s]]', | '[[%s:%s#%s|%s]]', | ||
mw.site.namespaces[self. | mw.site.namespaces[self._protectionObj.title.namespace].talk.name, | ||
self. | self._protectionObj.title.text, | ||
section or 'top', | section or 'top', | ||
display | display | ||
Zeile 654: | Zeile 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. | username = username or self._protectionObj.title.baseText | ||
return mVandalM._main{username} | return mVandalM._main{username} | ||
end | end | ||
Zeile 661: | Zeile 659: | ||
function Blurb:makeReasonText() | function Blurb:makeReasonText() | ||
local msg = self. | local msg = self._protectionObj.bannerConfig.text | ||
if msg then | if msg then | ||
return self:_substituteParameters(msg) | return self:_substituteParameters(msg) | ||
Zeile 668: | Zeile 666: | ||
function Blurb:makeExplanationText() | function Blurb:makeExplanationText() | ||
local msg = self. | 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. | 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. | 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. | local msg = self._protectionObj.bannerConfig.link | ||
return self:_substituteParameters(msg) | return self:_substituteParameters(msg) | ||
end | end |