Module:Protection banner: Difference between revisions

add some more blurb parameter functions
(move the parameter functions to the top level of the blurb class and add a new one)
(add some more blurb parameter functions)
Line 47: Line 47:
self._expiry = args.expiry or 'indef'
self._expiry = args.expiry or 'indef'
self._section = args.section
self._section = args.section
self._protectionDate = args.date
self._username = args.user
end
end


Line 67: Line 69:
function ProtectionStatus:getSection()
function ProtectionStatus:getSection()
return self._section
return self._section
end
function ProtectionStatus:getProtectionDate()
return self._protectionDate
end
function ProtectionStatus:getUsername()
return self._username
end
end


Line 167: Line 177:


parameterFuncs[9] = function ()
parameterFuncs[9] = function ()
return self:_makeDisputeLinkParameter() -- A link to the page history or the move log
-- A link to the page history or the move log
return self:_makeDisputeLinkParameter()
end
end


Line 187: Line 198:


parameterFuncs[14] = function ()
parameterFuncs[14] = function ()
return self:_makeSubjectPageLinksParameter() -- Adds links to edit requests and the talk page if we are on a subject page
-- Adds links to edit requests and the talk page if we are on a
-- subject page
return self:_makeSubjectPageLinksParameter()
end
end


Line 259: Line 272:
function Blurb:_makeProtectionDateParameter()
function Blurb:_makeProtectionDateParameter()
-- parameter $5
-- parameter $5
if self._protectionDate then
local protectionDate = self._protectionStatusObj:getProtectionDate()
if protectionDate then
local lang = mw.language.getContentLanguage()
local lang = mw.language.getContentLanguage()
local success, date = pcall(
local success, date = pcall(
Line 265: Line 279:
lang,
lang,
'j F Y',
'j F Y',
self._protectionDate
protectionDate
)
)
if success and date then
if success and date then
Line 271: Line 285:
end
end
end
end
end
function Blurb:_makeVandalTemplateParameter()
local mVandalM = require('Module:Vandal-m')
local username = self._protectionStatusObj:getUsername()
username = username or self._titleObj.baseText
return mVandalM.luaMain{username}
end
end