Module:Protection banner: Difference between revisions

Jump to navigation Jump to search
Content added Content deleted
(get rid of unnecessary wrapper functions)
(move section, username and deletion discussion methods out of the ProtectionStatus class, as they don't really have anything to do with protection status)
Line 46: Line 46:
self._reason = args.reason
self._reason = args.reason
self._expiry = args.expiry or 'indef'
self._expiry = args.expiry or 'indef'
self._section = args.section
self._protectionDate = args.date
self._protectionDate = args.date
self._username = args.user
self._deletionDiscussionPage = args.xfd
end
end


Line 66: Line 63:
function ProtectionStatus:getExpiry()
function ProtectionStatus:getExpiry()
return self._expiry
return self._expiry
end

function ProtectionStatus:getSection()
return self._section
end
end


function ProtectionStatus:getProtectionDate()
function ProtectionStatus:getProtectionDate()
return self._protectionDate
return self._protectionDate
end

function ProtectionStatus:getUsername()
return self._username
end

function ProtectionStatus:getDeletionDiscussionPage()
return self._deletionDiscussionPage
end
end


Line 138: Line 123:
url = tostring(url)
url = tostring(url)
return string.format('[%s %s]', url, display)
return string.format('[%s %s]', url, display)
end

function Blurb:setDeletionDiscussionPage(page)
self._deletionDiscussionPage = page
end

function Blurb:setUsername(username)
self._username = username
end

function Blurb:setSection(section)
self._section = section
end
end


Line 210: Line 207:
-- parameter $3
-- parameter $3
-- "disputes", with or without a section link
-- "disputes", with or without a section link
local section = self._protectionStatusObj:getSection()
local section = self._section
local disputes = self.configObj:getMessage('dispute-section-link-display')
local disputes = self.configObj:getMessage('dispute-section-link-display')
if section then
if section then
Line 252: Line 249:
-- parameter $6
-- parameter $6
local mVandalM = require('Module:Vandal-m')
local mVandalM = require('Module:Vandal-m')
local username = self._protectionStatusObj:getUsername()
local username = self._username
username = username or self._titleObj.baseText
username = username or self._titleObj.baseText
return mVandalM.luaMain{username}
return mVandalM.luaMain{username}
Line 336: Line 333:
function Blurb:_makeTalkLinkParameter()
function Blurb:_makeTalkLinkParameter()
-- parameter $11
-- parameter $11
local section = self._protectionStatusObj:getSection()
local section = self._section
local display = self._configObj:getMessage('talk-page-link-display')
local display = self._configObj:getMessage('talk-page-link-display')
return string.format(
return string.format(
Line 395: Line 392:
function Blurb:_makeDeletionBlurbParameter()
function Blurb:_makeDeletionBlurbParameter()
-- parameter $15
-- parameter $15
local deletionDiscussionPage = getDeletionDiscussionPage()
local deletionDiscussionPage = self._deletionDiscussionPage
local key
local key
if deletionDiscussionPage then
if deletionDiscussionPage then
Line 408: Line 405:
function Blurb:_makeDeletionDiscussionLinkParameter()
function Blurb:_makeDeletionDiscussionLinkParameter()
-- parameter $16
-- parameter $16
local deletionDiscussionPage = getDeletionDiscussionPage()
local deletionDiscussionPage = self._deletionDiscussionPage
if deletionDiscussionPage then
if deletionDiscussionPage then
local display = self._configObj:getMessage('deletion-discussion-link-display')
local display = self._configObj:getMessage('deletion-discussion-link-display')
Line 766: Line 763:


-- Render the banner
-- Render the banner
local theBanner
if yesno(args.small) then
theBanner = Padlock.new(theConfig, theProtectionStatus, title)
else
theBanner = Banner.new(theConfig, theProtectionStatus, title)
end
theBanner = Padlock.new(theConfig, theProtectionStatus, title)
theBanner:setDeletionDiscussionPage(args.xfd)
theBanner:setUsername(args.user)
theBanner:setSection(args.section)
ret[#ret + 1] = theBanner:export()
-- Render the categories
-- Render the categories