Open main menu

Changes

Module:Protection banner

1,272 bytes removed, 13:18, 26 June 2014
sort parameter methods into alphabetical order, and remove the ones that are no longer needed
})
parameterFuncs.CURRENTVERSION = self._makeCurrentVersionParameter
parameterFuncs.DELETIONDISCUSSION = self._makeDeletionDiscussionParameter
parameterFuncs.DISPUTESECTION = self._makeDisputesParameter_makeDisputeSectionParameter 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
end
function Blurb:_makeIntroBlurbParameter_makeCurrentVersionParameter() -- parameter $1A link to the page history or the move log, depending on the kind of local key-- protection.
local action = self._protectionStatusObj:getAction()
local level pagename = self._protectionStatusObj:getLevel()_titleObj.prefixedText if action == 'edit' and level == 'autoconfirmedmove' then key = 'reason-text-semi'We need the move log link. return self.makeFullUrl( elseif action == 'moveSpecial:Log' then, key {type = 'reason-text-move' elseif action =, page = 'create' thenpagename}, key = self._configObj:getMessage('reasondispute-move-textlink-createdisplay') )
else
key -- We need the history link. return self.makeFullUrl( pagename, {action = 'history'}, self._configObj:getMessage('dispute-edit-link-display') ) endend function Blurb:_makeDeletionDiscussionLinkParameter() local deletionDiscussionPage = self._deletionDiscussionPage if deletionDiscussionPage then local display = self._configObj:getMessage('reasondeletion-textdiscussion-defaultlink-display') return string.format('[[%s|%s]]', deletionDiscussionPage, display)
end
local msg = self._configObj:getMessage(key)
return self:_substituteParameters(msg)
end
function Blurb:_makeDisputeSectionParameter()
-- parameter $3
-- "disputes", with or without a section link
local section = self._section
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()
-- parameter $4
local pagetypes = self._configObj:getConfigTable('bannerPagetypes')
local namespace = self._titleObj.namespace
function Blurb:_makeProtectionDateParameter()
-- parameter $5
local protectionDate = self._protectionStatusObj:getProtectionDate()
if type(protectionDate) == 'number' then
return protectionDate
end
end
 
function Blurb:_makeVandalTemplateParameter()
-- parameter $6
local mVandalM = require('Module:Vandal-m')
local username = self._username
username = username or self._titleObj.baseText
return mVandalM.luaMain{username}
end
function Blurb:_makeProtectionLevelParameter()
-- parameter $7
local action = self._protectionStatusObj:getAction()
local level = self._protectionStatusObj:getLevel()
end
return self._configObj:getMessage(key)
end
 
function Blurb:_makeExpiryParameter()
-- parameter $8
-- @TODO: Check to see if the expiry is valid.
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:_makeCurrentVersionParameter()
-- parameter $9
-- A link to the page history or the move log, depending on the kind of
-- protection.
local action = self._protectionStatusObj:getAction()
local pagename = self._titleObj.prefixedText
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
-- We need the history link.
return self.makeFullUrl(
pagename,
{action = 'history'},
self._configObj:getMessage('dispute-edit-link-display')
)
end
end
function Blurb:_makeProtectionLogParameter()
-- parameter $10
local action = self._protectionStatusObj:getAction()
local pagename = self._titleObj.prefixedText
function Blurb:_makeTalkPageParameter()
-- parameter $11
local section = self._section
local display = self._configObj:getMessage('talk-page-link-display')
end
function Blurb:_makeEditRequestParameter_makeVandalTemplateParameter() -- parameter $12 local mEditRequest mVandalM = require('Module:Submit an edit requestVandal-m') local action username = self._protectionStatusObj:getAction()_username local level username = 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 username or 'full' return mEditRequest.exportLinkToLua{type = requestType, display = display}end function Blurb:_makeRequestUnprotectionParameter() -- parameter $13 if self._titleObj.namespace ~= 8 then -- MediaWiki pages can't be unprotected. return self._configObj:getMessage('request-unprotection-blurb') endend function Blurb:_makeSubjectPageLinksParameter() -- parameter $14 -- Don't display these links if we are on a talk page.baseText if not self._titleObj.isTalkPage then local msg = self._configObj:getMessage('semi-subject-page-links') return self:_substituteParameters(msg) endend function Blurb:_makeDeletionBlurbParameter() -- parameter $15 local deletionDiscussionPage = selfmVandalM._deletionDiscussionPage local key if deletionDiscussionPage then key = 'deletion-discussion-blurb-xfd' else key = 'deletion-discussion-blurb-noxfd' end local msg = self._configObj:getMessage(msg) return self._substituteParameters(msg)end function Blurb:_makeDeletionDiscussionLinkParameter() -- parameter $16 local deletionDiscussionPage = self._deletionDiscussionPage if deletionDiscussionPage then local display = self._configObj:getMessage('deletion-discussion-link-display') return string.format('[[%s|%s]]', deletionDiscussionPage, display) endend function Blurb:_makeDeletionLogParameter() -- parameter $17 return Blurb.makeFullUrl( 'Special:Log', luaMain{type = 'delete', page = self._titleObj.prefixedTextusername}, self._configObj:getMessage('deletion-log-link-display') )end function Blurb:_makeExplanationBlurbParameter() -- parameter $18 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
Anonymous user