Jump to content

Module:Protection banner: Difference between revisions

add more blurb functions
(add some more blurb parameter functions)
(add more blurb functions)
Line 127: Line 127:
self._bannerConfig = configObj:getBannerConfig(protectionStatusObj)
self._bannerConfig = configObj:getBannerConfig(protectionStatusObj)
self._titleObj = titleObj
self._titleObj = titleObj
end
function Blurb.makeFullUrl(page, query, display)
local url = mw.uri.fullUrl(page, query)
url = tostring(url)
return string.format('[%s %s]', url, display)
end
end


Line 288: Line 294:


function Blurb:_makeVandalTemplateParameter()
function Blurb:_makeVandalTemplateParameter()
-- parameter $6
local mVandalM = require('Module:Vandal-m')
local mVandalM = require('Module:Vandal-m')
local username = self._protectionStatusObj:getUsername()
local username = self._protectionStatusObj:getUsername()
username = username or self._titleObj.baseText
username = username or self._titleObj.baseText
return mVandalM.luaMain{username}
return mVandalM.luaMain{username}
end
function Blurb:_makeProtectionLevelParameter()
-- parameter $7
local action = self._protectionStatusObj:getAction()
local level = self._protectionStatusObj:getLevel()
local key
if action == 'edit' then
if level == 'sysop' then
key = 'protection-level-full'
elseif level == 'templateeditor' then
key = 'protection-level-template'
elseif level == 'autoconfirmed' then
key = 'protection-level-semi'
end
elseif action == 'move' then
key = 'protection-level-move'
elseif action == 'create' then
key = 'protection-level-create'
else
key = 'protection-level-default'
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 then
return ' until ' .. expiry
else
return ''
end
end
function Blurb:_makeDisputeLinkParameter()
-- 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()
local action = self._protectionStatusObj:getAction()
if action == 'autoreview' then
-- We need the pending changes log.
return self.makeFullUrl(
'Special:Log',
{type = 'stable', page = pagename},
self._configObj:getMessage('more-details-pc-log-display')
)
else
-- We need the protection log.
return self.makeFullUrl(
'Special:Log',
{type = 'protect', page = pagename},
self._configObj:getMessage('more-details-protection-log-display')
)
end
end
end


Cookies help us deliver our services. By using our services, you agree to our use of cookies.