Module:Protection banner: Difference between revisions
Content deleted Content added
change BannerTemplate:setImageFilename to accept protection objects and title objects rather than individual parameters |
shorter names - use protectionObj instead of protectionStatusObj, and Protection instead of ProtectionStatus |
||
Line 25:
end
function Config:getBannerConfig(
if self._bannerConfigTables[
return self._bannerConfigTables[
else
local ret = {}
local cfg = self._cfg
local action =
local level =
local reason =
local fields = {
'text',
Line 58:
end
end
self._bannerConfigTables[
return ret
end
Line 81:
--------------------------------------------------------------------------------
--
--------------------------------------------------------------------------------
local
function
-- Set action
do
Line 158:
end
function
return self._action
end
function
return self._level
end
function
return self._level ~= '*'
end
function
return self._reason
end
function
return self._expiry
end
function
return self._protectionDate
end
Line 188:
local Blurb = class('Blurb')
function Blurb:initialize(configObj,
self._configObj = configObj
self._protectionObj = protectionObj
self._bannerConfig = configObj:getBannerConfig(
self._titleObj = titleObj
end
Line 268:
-- A link to the page history or the move log, depending on the kind of
-- protection.
local action = self.
local pagename = self._titleObj.prefixedText
if action == 'move' then
Line 296:
function Blurb:_makeDisputeBlurbParameter()
local expiry = self.
if type(expiry) == 'number' then
return self:_getExpandedMessage('dispute-blurb-expiry')
Line 323:
function Blurb:_makeEditRequestParameter()
local mEditRequest = require('Module:Submit an edit request')
local action = self.
local level = self.
-- Get the display message key.
Line 350:
function Blurb:_makeExpiryParameter()
local expiry = self.
if expiry == 'indef' then
return nil
Line 362:
function Blurb:_makeExplanationBlurbParameter()
local action = self.
local level = self.
local namespace = self._titleObj.namespace
local isTalk = self._titleObj.isTalkPage
Line 394:
function Blurb:_makeIntroBlurbParameter()
local expiry = self.
if type(expiry) == 'number' then
return self:_getExpandedMessage('intro-blurb-expiry')
Line 403:
function Blurb:_makeOfficeBlurbParameter()
local protectionDate = self.
if protectionDate then
return self:_getExpandedMessage('office-blurb-protectiondate')
Line 419:
function Blurb:_makeProtectionBlurbParameter()
local protectionBlurbs = self._configObj:getConfigTable('protectionBlurbs')
local action = self.
local level = self.
local msg
if protectionBlurbs[action][level] then
Line 435:
function Blurb:_makeProtectionDateParameter()
local protectionDate = self.
if type(protectionDate) == 'number' then
return Blurb.formatDate(protectionDate)
Line 445:
function Blurb:_makeProtectionLevelParameter()
local protectionLevels = self._configObj:getConfigTable('protectionLevels')
local action = self.
local level = self.
local msg
if protectionLevels[action][level] then
Line 461:
function Blurb:_makeProtectionLogParameter()
local action = self.
local pagename = self._titleObj.prefixedText
if action == 'autoreview' then
Line 481:
function Blurb:_makeResetBlurbParameter()
local protectionDate = self.
if protectionDate then
return self:_getExpandedMessage('reset-blurb-protectiondate')
Line 502:
function Blurb:_makeTooltipBlurbParameter()
local expiry = self.
if type(expiry) == 'number' then
return self:_getExpandedMessage('tooltip-blurb-expiry')
Line 566:
end
function BannerTemplate:setImageFilename(filename,
if filename then
self._imageFilename = filename
Line 572:
end
local action =
local level =
local expiry =
local namespace = titleObj.namespace
Line 707:
local Category = class('Category')
function Category:initialize(configObj,
self._configObj = configObj
self._protectionObj = protectionObj
end
Line 732:
local ProtectionCategory = Category:subclass('ProtectionCategory')
function ProtectionCategory:initialize(configObj,
Category.initialize(self, configObj,
self._titleObj = titleObj
end
Line 739:
function ProtectionCategory:render()
local configObj = self._configObj
local
local titleObj = self._titleObj
-- Get the level and exit if the page is not protected.
if not
return ''
end
-- Get the expiry.
local expiry =
if type(expiry) == 'number' then
expiry = 'temp'
Line 767:
-- Get the other inputs.
local reason =
local action =
local level =
--[[
Line 901:
function ExpiryCategory:render()
local configObj = self._configObj
local
local reasonsWithoutExpiryCheck = configObj:getConfigTable('reasonsWithoutExpiryCheck')
local expiryCheckActions = configObj:getConfigTable('expiryCheckActions')
local expiry =
local action =
local reason =
if not expiry
Line 927:
function ErrorCategory:render()
local configObj = self._configObj
local
local expiry =
local action =
local level =
if not
or type(expiry) == 'number' and expiry < os.time()
then
Line 947:
local TemplateCategory = Category:subclass('TemplateCategory')
function TemplateCategory:initialize(configObj,
Category.initialize(self, configObj,
self._titleObj = titleObj
end
Line 954:
function TemplateCategory:render()
local configObj = self._configObj
local
local titleObj = self._titleObj
local action =
local level =
local namespace = titleObj.namespace
Line 989:
-- Get data objects
local configObj = Config:new()
local protectionObj =
-- Initialise the blurb object
Line 1,050:
-- This is used to export the classes for testing purposes.
return {
Protection = Protection,
Config = Config,
Blurb = Blurb,
|