Anonymous user
Module:Protection banner: Difference between revisions
sort parameter methods into alphabetical order, and remove the ones that are no longer needed
Enwikipedia>Mr. Stradivarius (start converting the blurb class to the new parameter system) |
Enwikipedia>Mr. Stradivarius (sort parameter methods into alphabetical order, and remove the ones that are no longer needed) |
||
Line 230:
})
parameterFuncs.CURRENTVERSION = self._makeCurrentVersionParameter
parameterFuncs.DELETIONDISCUSSION = self._makeDeletionDiscussionParameter
parameterFuncs.DISPUTESECTION = self.
parameterFuncs.EDITREQUEST = self._makeEditRequestParameter
parameterFuncs.EXPIRY = self._makeExpiryParameter
parameterFuncs.EXPLANATIONBLURB = self._makeExplanationBlurbParameter
parameterFuncs.INTROBLURB = self._makeIntroBlurbParameter
parameterFuncs.PAGETYPE = self._makePagetypeParameter
parameterFuncs.PROTECTIONDATE = self._makeProtectionDateParameter
parameterFuncs.PROTECTIONLEVEL = self._makeProtectionLevelParameter
parameterFuncs.PROTECTIONLOG = self._makeProtectionLogParameter
parameterFuncs.TALKPAGE = self._makeTalkPageParameter
parameterFuncs.VANDAL = self._makeVandalTemplateParameter
self._params = params
Line 251:
end
function Blurb:
-- A link to the page history or the move log, depending on the kind of
-- protection.
local action = self._protectionStatusObj:getAction()
local
if action == '
-- We need the move log link.
return self.makeFullUrl(
'Special:Log',
{type = 'move', page = pagename},
self._configObj:getMessage('dispute-move-link-display')
)
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
function Blurb:_makeDisputeSectionParameter()
-- "disputes", with or without a section link
local section = self._section
Line 285 ⟶ 296:
return disputes
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
function Blurb:_makePagetypeParameter()
local pagetypes = self._configObj:getConfigTable('bannerPagetypes')
local namespace = self._titleObj.namespace
Line 295 ⟶ 380:
function Blurb:_makeProtectionDateParameter()
local protectionDate = self._protectionStatusObj:getProtectionDate()
if type(protectionDate) == 'number' then
Line 302 ⟶ 386:
return protectionDate
end
end
function Blurb:_makeProtectionLevelParameter()
local action = self._protectionStatusObj:getAction()
local level = self._protectionStatusObj:getLevel()
Line 333 ⟶ 408:
end
return self._configObj:getMessage(key)
end
function Blurb:_makeProtectionLogParameter()
local action = self._protectionStatusObj:getAction()
local pagename = self._titleObj.prefixedText
Line 395 ⟶ 431:
function Blurb:_makeTalkPageParameter()
local section = self._section
local display = self._configObj:getMessage('talk-page-link-display')
Line 407 ⟶ 442:
end
function Blurb:
local mVandalM = require('Module:Vandal-m')
local username = self._username
username = username or self._titleObj.baseText
return mVandalM.luaMain{username}
end
|