Module:Protection banner: Difference between revisions
use cfg.explanationBlurbs to fetch the explanation blurbs rather than hard-coding the message keys here
(add explanation blurb for semi-protection) |
(use cfg.explanationBlurbs to fetch the explanation blurbs rather than hard-coding the message keys here) |
||
Line 469: | Line 469: | ||
function Blurb:_makeExplanationBlurbParameter() | function Blurb:_makeExplanationBlurbParameter() | ||
-- Cover special cases first. | |||
if self._protectionObj.title.namespace == 8 then | |||
-- MediaWiki namespace | |||
return self:_getExpandedMessage('explanation-blurb-nounprotect') | |||
end | |||
-- Get explanation blurb table keys | |||
local action = self._protectionObj.action | local action = self._protectionObj.action | ||
local level = self._protectionObj.level | local level = self._protectionObj.level | ||
local | local talkKey = self._protectionObj.title.isTalkPage and 'talk' or 'subject' | ||
-- | -- Find the message in the explanation blurb table and substitute any | ||
local | -- parameters. | ||
if | local explanations = self._cfg.explanationBlurbs | ||
local msg | |||
if explanations[action][level] and explanations[action][level][talkKey] then | |||
elseif action | msg = explanations[action][level][talkKey] | ||
elseif explanations[action][level] and explanations[action][level].default then | |||
elseif action | msg = explanations[action][level].default | ||
elseif explanations[action].default and explanations[action].default[talkKey] then | |||
msg = explanations[action].default[talkKey] | |||
elseif explanations[action].default and explanations[action].default.default then | |||
msg = explanations[action].default.default | |||
elseif action | |||
else | else | ||
error(string.format( | |||
'could not find explanation blurb for action "%s", level "%s" and talk key "%s"', | |||
action, | |||
level, | |||
talkKey | |||
)) | |||
end | end | ||
return self: | return self:_substituteParameters(msg) | ||
end | end | ||