Module:Protection banner: Difference between revisions
Jump to navigation
Jump to search
Content added Content deleted
(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. |
|||
⚫ | |||
⚫ | |||
⚫ | |||
⚫ | |||
⚫ | |||
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' |
||
local isTalk = self._protectionObj.title.isTalkPage |
|||
-- Find the message in the explanation blurb table and substitute any |
|||
-- @TODO: add pending changes |
|||
-- parameters. |
|||
⚫ | |||
local explanations = self._cfg.explanationBlurbs |
|||
⚫ | |||
⚫ | |||
⚫ | |||
if explanations[action][level] and explanations[action][level][talkKey] then |
|||
⚫ | |||
msg = explanations[action][level][talkKey] |
|||
elseif action == 'edit' and level == 'sysop' and not isTalk then |
|||
elseif explanations[action][level] and explanations[action][level].default then |
|||
key = 'explanation-blurb-full-subject' |
|||
msg = explanations[action][level].default |
|||
elseif action == 'edit' and level == 'autoconfirmed' then |
|||
elseif explanations[action].default and explanations[action].default[talkKey] then |
|||
if isTalk then |
|||
msg = explanations[action].default[talkKey] |
|||
key = 'explanation-blurb-semi-talk' |
|||
elseif explanations[action].default and explanations[action].default.default then |
|||
else |
|||
msg = explanations[action].default.default |
|||
key = 'explanation-blurb-semi-subject' |
|||
⚫ | |||
elseif action == 'move' then |
|||
if isTalk then |
|||
key = 'explanation-blurb-move-talk' |
|||
else |
|||
key = 'explanation-blurb-move-subject' |
|||
end |
|||
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 |
||