Changes
add missing parameter methods, add a Blurb:_getExpandedMessage method, and (hopefully) finish updating the various functions to work with the new config structure
-- Private methods --
function Blurb:_getExpandedMessage(msg)
local msg = self._configObj:getMessage(msg)
return self:_substituteParameters(msg)
end
function Blurb:_substituteParameters(msg)
parameterFuncs.CURRENTVERSION = self._makeCurrentVersionParameter
parameterFuncs.DELETIONDISCUSSION = self._makeDeletionDiscussionParameter
parameterFuncs.DISPUTEBLURB = self._makeDisputeBlurbParameter
parameterFuncs.DISPUTESECTION = self._makeDisputeSectionParameter
parameterFuncs.EDITREQUEST = self._makeEditRequestParameter
parameterFuncs.EXPLANATIONBLURB = self._makeExplanationBlurbParameter
parameterFuncs.INTROBLURB = self._makeIntroBlurbParameter
parameterFuncs.OFFICEBLURB = self._makeOfficeBlurbParameter
parameterFuncs.PAGETYPE = self._makePagetypeParameter
parameterFuncs.PROTECTIONBLURB = self._makeProtectionBlurbParameter
parameterFuncs.PROTECTIONDATE = self._makeProtectionDateParameter
parameterFuncs.PROTECTIONLEVEL = self._makeProtectionLevelParameter
parameterFuncs.PROTECTIONLOG = self._makeProtectionLogParameter
parameterFuncs.RESETBLURB = self._makeResetBlurbParameter
parameterFuncs.TALKPAGE = self._makeTalkPageParameter
parameterFuncs.TOOLTIPBLURB = self._makeTooltipBlurbParameter
parameterFuncs.VANDAL = self._makeVandalTemplateParameter
'Special:Log',
{type = 'move', page = pagename},
self._configObj:getMessage_getExpandedMessage('disputecurrent-version-move-link-display')
)
else
pagename,
{action = 'history'},
self._configObj:getMessage_getExpandedMessage('disputecurrent-version-edit-link-display')
)
end
local deletionDiscussionPage = self._deletionDiscussionPage
if deletionDiscussionPage then
local display = self._configObj:getMessage_getExpandedMessage('deletion-discussion-link-display')
return string.format('[[%s|%s]]', deletionDiscussionPage, display)
end
end
function Blurb:_makeDisputeBlurbParameter()
local expiry = self._protectionStatusObj:getExpiry()
if type(expiry) == 'number' then
return self:_getExpandedMessage('dispute-blurb-expiry')
else
return self:_getExpandedMessage('dispute-blurb-noexpiry')
end
end
-- "disputes", with or without a section link
local section = self._section
local disputes = self.configObj:getMessage_getExpandedMessage('dispute-section-link-display')
if section then
return string.format(
key = 'edit-request-full-display'
end
local display = self._configObj:getMessage_getExpandedMessage(key)
-- Get the edit request type.
return nil
elseif type(expiry) == 'number' then
elseif expiry then
-- Expiry is an error string.
local action = self._protectionStatusObj:getAction()
local level = self._protectionStatusObj:getLevel()
local namespace = self._titleObj.namespace
local isTalk = self._titleObj.isTalkPage
-- @TODO: add semi-protection and pending changes blurbs
local key
if namespace == 8 then -- MediaWiki namespace key = 'explanation-blurb-full-nounprotect' elseif action == 'edit' and level == 'autoconfirmedsysop' and not isTalk then key = 'explanation-textblurb-full-semisubject'
elseif action == 'move' then
if isTalk then key = 'explanation-textblurb-move-talk' else key = 'explanation-blurb-move-subject' end
elseif action == 'create' then
local xfd = self._deletionDiscussion if xfd then key = 'explanation-textblurb-create-xfd' else key = 'explanation-blurb-create-noxfd' end
else
key = 'explanation-textblurb-default'
end
end
function Blurb:_makeIntroBlurbParameter()
local key local action expiry = self._protectionStatusObj:getActiongetExpiry() local level = self._protectionStatusObj:getLevelif type(expiry) if action == 'edit' and level == 'autoconfirmednumber' then key = return self:_getExpandedMessage('reasonintro-textblurb-semiexpiry') elseif action == 'move' thenelse key = return self:_getExpandedMessage('reasonintro-textblurb-movenoexpiry') elseif action endend function Blurb:_makeOfficeBlurbParameter() local protectionDate == 'create' self._protectionStatusObj:getProtectionDate() if protectionDate then key = return self:_getExpandedMessage('reasonoffice-textblurb-createprotectiondate')
else
end
end
function Blurb:_makePagetypeParameter()
local pagetypes = self._configObj:getConfigTable('bannerPagetypespagetypes')
local namespace = self._titleObj.namespace
return pagetypes[namespace] or pagetypes.default or error('pageno default pagetype defined')end function Blurb:_makeProtectionBlurbParameter() local protectionBlurbs = self._configObj:getConfigTable('protectionBlurbs') local action = self._protectionStatusObj:getAction() local level = self._protectionStatusObj:getLevel() local msg if protectionBlurbs[action][level] then msg = protectionBlurbs[action][level] elseif protectionBlurbs[action].default then msg = protectionBlurbs[action].default elseif protectionBlurbs.edit.default then msg = protectionBlurbs.edit.default else error('no protection blurb defined for cfg.protectionBlurbs.edit.default') end return self:_substituteParameters(msg)
end
function Blurb:_makeProtectionLevelParameter()
local protectionLevels = self._configObj:getConfigTable('protectionLevels')
local action = self._protectionStatusObj:getAction()
local level = self._protectionStatusObj:getLevel()
local keymsg if protectionLevels[action == 'edit' then if ][level == 'sysop' ] then key = 'protection-level-full' elseif level msg == 'templateeditor' then key = 'protection-protectionLevels[action][level-template' elseif level == 'autoconfirmed' then key = 'protection-level-semi' end] elseif protectionLevels[action == 'move' ].default then key msg = 'protection-level-move'protectionLevels[action].default elseif action == 'create' protectionLevels.edit.default then key msg = 'protection-level-create'protectionLevels.edit.default
else
end
return self._configObj:getMessage_substituteParameters(keymsg)
end
'Special:Log',
{type = 'stable', page = pagename},
self._configObj:getMessage_getExpandedMessage('more-details-pc-log-display')
)
else
'Special:Log',
{type = 'protect', page = pagename},
self._configObj:getMessage_getExpandedMessage('more-details-protection-log-display')
)
end
end
function Blurb:_makeResetBlurbParameter()
local protectionDate = self._protectionStatusObj:getProtectionDate()
if protectionDate then
return self:_getExpandedMessage('reset-blurb-protectiondate')
else
return self:_getExpandedMessage('reset-blurb-noprotectiondate')
end
end
function Blurb:_makeTalkPageParameter()
local section = self._section
local display = self._configObj:getMessage_getExpandedMessage('talk-page-link-display') return string.format(
'[[%s:%s#%s|%s]]',
mw.site.namespaces[self._titleObj.namespace].talk.name,
display
)
end
function Blurb:_makeTooltipBlurbParameter()
local expiry = self._protectionStatusObj:getExpiry()
if type(expiry) == 'number' then
return self:_getExpandedMessage('tooltip-blurb-expiry')
else
return self:_getExpandedMessage('tooltip-blurb-noexpiry')
end
end
local username = self._username
username = username or self._titleObj.baseText
return mVandalM.luaMain_main{username}
end
local titleObj = self._titleObj
-- Get the expiry. local expiry = protectionStatusObj:getExpiry() if type(expiry) == 'number' then expiry = 'temp' elseif expiry ~= 'indef' then expiry = nil end -- Get the namespace category key from the namespace number.
local nskey
do
local namespace = titleObj.namespace
local categoryNamespaces = configObj:getConfigTable('categoryNamespacescategoryNamespaceKeys')
nskey = categoryNamespaces[namespace]
if not nskey and namespace % 2 == 1 then
end
end
-- Get the other inputs.
local reason = protectionStatusObj:getReason()
local action = protectionStatusObj:getAction()
local level = protectionStatusObj:getLevel()
--[[
--]]
local properties = {
expiry = {order = 1, val = protectionStatusObj:getExpiry()expiry},
namespace = {order = 2, val = nskey},
reason = {order = 3, val = protectionStatusObj:getReason()reason}, level = {order = 4, val = protectionStatusObj:getLevel()level}, action = {order = 5, val = protectionStatusObj:getAction()action}
}
local configOrder = {}
do
local bannerConfig reasonsWithNamespacePriority = configObj:getBannerConfiggetConfigTable(protectionStatusObj'reasonsWithNamespacePriority') local categoryOrder namespaceFirst = bannerConfig.categoryOrderreason and reasonsWithNamespacePriority[reason] or false
for propertiesKey, t in pairs(properties) do
configOrder[t.order] = t
end
if categoryOrder namespaceFirst then local property = properties[categoryOrder]-- Swap namespace and reason around. if not property then local msg namespaceTable = '"' table.. categoryOrder .. '" is not a valid value of cfg.reasons.' .. reason .. '.categoryOrder' errorremove(msgconfigOrder, 2) end table.insert(configOrder, table.remove(configOrder3, property.order)namespaceTable)
end
end
-- pos field in the property table.
--]]
local cats = configObj:getConfigTable('categoriesprotectionCategories')
local cat
for i = 1, 2^noActive do