Modul:Protection banner: Unterschied zwischen den Versionen
sort parameter methods into alphabetical order, and remove the ones that are no longer needed
(start converting the blurb class to the new parameter system) |
(sort parameter methods into alphabetical order, and remove the ones that are no longer needed) |
||
Zeile 230: | Zeile 230: | ||
}) | }) | ||
parameterFuncs.CURRENTVERSION = self._makeCurrentVersionParameter | parameterFuncs.CURRENTVERSION = self._makeCurrentVersionParameter | ||
parameterFuncs.DELETIONDISCUSSION = self._makeDeletionDiscussionParameter | parameterFuncs.DELETIONDISCUSSION = self._makeDeletionDiscussionParameter | ||
parameterFuncs.DISPUTESECTION = self. | parameterFuncs.DISPUTESECTION = self._makeDisputeSectionParameter | ||
parameterFuncs.EDITREQUEST = self._makeEditRequestParameter | parameterFuncs.EDITREQUEST = self._makeEditRequestParameter | ||
parameterFuncs.EXPIRY = self._makeExpiryParameter | parameterFuncs.EXPIRY = self._makeExpiryParameter | ||
parameterFuncs.EXPLANATIONBLURB = self._makeExplanationBlurbParameter | parameterFuncs.EXPLANATIONBLURB = self._makeExplanationBlurbParameter | ||
parameterFuncs.INTROBLURB = self._makeIntroBlurbParameter | parameterFuncs.INTROBLURB = self._makeIntroBlurbParameter | ||
parameterFuncs.PAGETYPE = self._makePagetypeParameter | parameterFuncs.PAGETYPE = self._makePagetypeParameter | ||
parameterFuncs.PROTECTIONDATE = self._makeProtectionDateParameter | parameterFuncs.PROTECTIONDATE = self._makeProtectionDateParameter | ||
parameterFuncs.PROTECTIONLEVEL = self._makeProtectionLevelParameter | parameterFuncs.PROTECTIONLEVEL = self._makeProtectionLevelParameter | ||
parameterFuncs.PROTECTIONLOG = self._makeProtectionLogParameter | parameterFuncs.PROTECTIONLOG = self._makeProtectionLogParameter | ||
parameterFuncs.TALKPAGE = self._makeTalkPageParameter | parameterFuncs.TALKPAGE = self._makeTalkPageParameter | ||
parameterFuncs.VANDAL = self._makeVandalTemplateParameter | parameterFuncs.VANDAL = self._makeVandalTemplateParameter | ||
self._params = params | self._params = params | ||
Zeile 251: | Zeile 251: | ||
end | end | ||
function Blurb: | function Blurb:_makeCurrentVersionParameter() | ||
-- | -- A link to the page history or the move log, depending on the kind of | ||
-- protection. | |||
local action = self._protectionStatusObj:getAction() | local action = self._protectionStatusObj:getAction() | ||
local | local pagename = self._titleObj.prefixedText | ||
if action == ' | if action == 'move' then | ||
-- We need the move log link. | |||
return self.makeFullUrl( | |||
'Special:Log', | |||
{type = 'move', page = pagename}, | |||
self._configObj:getMessage('dispute-move-link-display') | |||
) | |||
else | else | ||
-- We need the history link. | |||
return self.makeFullUrl( | |||
pagename, | |||
{action = 'history'}, | |||
self._configObj:getMessage('dispute-edit-link-display') | |||
) | |||
end | |||
end | |||
function Blurb:_makeDeletionDiscussionLinkParameter() | |||
local deletionDiscussionPage = self._deletionDiscussionPage | |||
if deletionDiscussionPage then | |||
local display = self._configObj:getMessage('deletion-discussion-link-display') | |||
return string.format('[[%s|%s]]', deletionDiscussionPage, display) | |||
end | end | ||
end | end | ||
function Blurb:_makeDisputeSectionParameter() | function Blurb:_makeDisputeSectionParameter() | ||
-- "disputes", with or without a section link | -- "disputes", with or without a section link | ||
local section = self._section | local section = self._section | ||
Zeile 285: | Zeile 296: | ||
return disputes | return disputes | ||
end | end | ||
end | |||
function Blurb:_makeEditRequestParameter() | |||
local mEditRequest = require('Module:Submit an edit request') | |||
local action = self._protectionStatusObj:getAction() | |||
local level = self._protectionStatusObj:getLevel() | |||
-- Get the display message key. | |||
local key | |||
if action == 'edit' and level == 'autoconfirmed' then | |||
key = 'edit-request-semi-display' | |||
else | |||
key = 'edit-request-full-display' | |||
end | |||
local display = self._configObj:getMessage(key) | |||
-- Get the edit request type. | |||
local requestType | |||
if action == 'edit' then | |||
if level == 'autoconfirmed' then | |||
requestType = 'semi' | |||
elseif level == 'templateeditor' then | |||
requestType = 'template' | |||
end | |||
end | |||
requestType = requestType or 'full' | |||
return mEditRequest.exportLinkToLua{type = requestType, display = display} | |||
end | |||
function Blurb:_makeExpiryParameter() | |||
local expiry = self._protectionStatusObj:getExpiry() | |||
if expiry == 'indef' then | |||
return nil | |||
elseif type(expiry) == 'number' then | |||
local formatted = Blurb.formatDate(expiry) | |||
return ' until ' .. formatted | |||
elseif expiry then | |||
-- Expiry is an error string. | |||
return expiry | |||
end | |||
end | |||
function Blurb:_makeExplanationBlurbParameter() | |||
local action = self._protectionStatusObj:getAction() | |||
local level = self._protectionStatusObj:getLevel() | |||
local key | |||
if action == 'edit' and level == 'autoconfirmed' then | |||
key = 'explanation-text-semi' | |||
elseif action == 'move' then | |||
key = 'explanation-text-move' | |||
elseif action == 'create' then | |||
key = 'explanation-text-create' | |||
else | |||
key = 'explanation-text-default' | |||
end | |||
local msg = self._configObj:getMessage(key) | |||
return self:_substituteParameters(msg) | |||
end | |||
function Blurb:_makeIntroBlurbParameter() | |||
local key | |||
local action = self._protectionStatusObj:getAction() | |||
local level = self._protectionStatusObj:getLevel() | |||
if action == 'edit' and level == 'autoconfirmed' then | |||
key = 'reason-text-semi' | |||
elseif action == 'move' then | |||
key = 'reason-text-move' | |||
elseif action == 'create' then | |||
key = 'reason-text-create' | |||
else | |||
key = 'reason-text-default' | |||
end | |||
local msg = self._configObj:getMessage(key) | |||
return self:_substituteParameters(msg) | |||
end | end | ||
function Blurb:_makePagetypeParameter() | function Blurb:_makePagetypeParameter() | ||
local pagetypes = self._configObj:getConfigTable('bannerPagetypes') | local pagetypes = self._configObj:getConfigTable('bannerPagetypes') | ||
local namespace = self._titleObj.namespace | local namespace = self._titleObj.namespace | ||
Zeile 295: | Zeile 380: | ||
function Blurb:_makeProtectionDateParameter() | function Blurb:_makeProtectionDateParameter() | ||
local protectionDate = self._protectionStatusObj:getProtectionDate() | local protectionDate = self._protectionStatusObj:getProtectionDate() | ||
if type(protectionDate) == 'number' then | if type(protectionDate) == 'number' then | ||
Zeile 302: | Zeile 386: | ||
return protectionDate | return protectionDate | ||
end | end | ||
end | end | ||
function Blurb:_makeProtectionLevelParameter() | function Blurb:_makeProtectionLevelParameter() | ||
local action = self._protectionStatusObj:getAction() | local action = self._protectionStatusObj:getAction() | ||
local level = self._protectionStatusObj:getLevel() | local level = self._protectionStatusObj:getLevel() | ||
Zeile 333: | Zeile 408: | ||
end | end | ||
return self._configObj:getMessage(key) | return self._configObj:getMessage(key) | ||
end | end | ||
function Blurb:_makeProtectionLogParameter() | function Blurb:_makeProtectionLogParameter() | ||
local action = self._protectionStatusObj:getAction() | local action = self._protectionStatusObj:getAction() | ||
local pagename = self._titleObj.prefixedText | local pagename = self._titleObj.prefixedText | ||
Zeile 395: | Zeile 431: | ||
function Blurb:_makeTalkPageParameter() | function Blurb:_makeTalkPageParameter() | ||
local section = self._section | local section = self._section | ||
local display = self._configObj:getMessage('talk-page-link-display') | local display = self._configObj:getMessage('talk-page-link-display') | ||
Zeile 407: | Zeile 442: | ||
end | end | ||
function Blurb: | function Blurb:_makeVandalTemplateParameter() | ||
local mVandalM = require('Module:Vandal-m') | |||
local | local username = self._username | ||
local | username = username or self._titleObj.baseText | ||
return mVandalM.luaMain{username} | |||
end | end | ||