Open main menu

Changes

Module:Protection banner

444 bytes removed, 05:07, 27 June 2014
shorter names - use protectionObj instead of protectionStatusObj, and Protection instead of ProtectionStatus
end
function Config:getBannerConfig(protectionStatusObjprotectionObj) if self._bannerConfigTables[protectionStatusObjprotectionObj] then return self._bannerConfigTables[protectionStatusObjprotectionObj]
else
local ret = {}
local cfg = self._cfg
local action = protectionStatusObjprotectionObj:getAction() local level = protectionStatusObjprotectionObj:getLevel() local reason = protectionStatusObjprotectionObj:getReason()
local fields = {
'text',
end
end
self._bannerConfigTables[protectionStatusObjprotectionObj] = ret
return ret
end
--------------------------------------------------------------------------------
-- ProtectionStatus Protection class
--------------------------------------------------------------------------------
local ProtectionStatus Protection = class('ProtectionStatusProtection')
function ProtectionStatusProtection:initialize(args, configObj, titleObj)
-- Set action
do
end
function ProtectionStatusProtection:getAction()
return self._action
end
function ProtectionStatusProtection:getLevel()
return self._level
end
function ProtectionStatusProtection:isProtected()
return self._level ~= '*'
end
function ProtectionStatusProtection:getReason()
return self._reason
end
function ProtectionStatusProtection:getExpiry()
return self._expiry
end
function ProtectionStatusProtection:getProtectionDate()
return self._protectionDate
end
local Blurb = class('Blurb')
function Blurb:initialize(configObj, protectionStatusObjprotectionObj, titleObj)
self._configObj = configObj
self._protectionStatusObj _protectionObj = protectionStatusObjprotectionObj self._bannerConfig = configObj:getBannerConfig(protectionStatusObjprotectionObj)
self._titleObj = titleObj
end
-- A link to the page history or the move log, depending on the kind of
-- protection.
local action = self._protectionStatusObj_protectionObj:getAction()
local pagename = self._titleObj.prefixedText
if action == 'move' then
function Blurb:_makeDisputeBlurbParameter()
local expiry = self._protectionStatusObj_protectionObj:getExpiry()
if type(expiry) == 'number' then
return self:_getExpandedMessage('dispute-blurb-expiry')
function Blurb:_makeEditRequestParameter()
local mEditRequest = require('Module:Submit an edit request')
local action = self._protectionStatusObj_protectionObj:getAction() local level = self._protectionStatusObj_protectionObj:getLevel()
-- Get the display message key.
function Blurb:_makeExpiryParameter()
local expiry = self._protectionStatusObj_protectionObj:getExpiry()
if expiry == 'indef' then
return nil
function Blurb:_makeExplanationBlurbParameter()
local action = self._protectionStatusObj_protectionObj:getAction() local level = self._protectionStatusObj_protectionObj:getLevel()
local namespace = self._titleObj.namespace
local isTalk = self._titleObj.isTalkPage
function Blurb:_makeIntroBlurbParameter()
local expiry = self._protectionStatusObj_protectionObj:getExpiry()
if type(expiry) == 'number' then
return self:_getExpandedMessage('intro-blurb-expiry')
function Blurb:_makeOfficeBlurbParameter()
local protectionDate = self._protectionStatusObj_protectionObj:getProtectionDate()
if protectionDate then
return self:_getExpandedMessage('office-blurb-protectiondate')
function Blurb:_makeProtectionBlurbParameter()
local protectionBlurbs = self._configObj:getConfigTable('protectionBlurbs')
local action = self._protectionStatusObj_protectionObj:getAction() local level = self._protectionStatusObj_protectionObj:getLevel()
local msg
if protectionBlurbs[action][level] then
function Blurb:_makeProtectionDateParameter()
local protectionDate = self._protectionStatusObj_protectionObj:getProtectionDate()
if type(protectionDate) == 'number' then
return Blurb.formatDate(protectionDate)
function Blurb:_makeProtectionLevelParameter()
local protectionLevels = self._configObj:getConfigTable('protectionLevels')
local action = self._protectionStatusObj_protectionObj:getAction() local level = self._protectionStatusObj_protectionObj:getLevel()
local msg
if protectionLevels[action][level] then
function Blurb:_makeProtectionLogParameter()
local action = self._protectionStatusObj_protectionObj:getAction()
local pagename = self._titleObj.prefixedText
if action == 'autoreview' then
function Blurb:_makeResetBlurbParameter()
local protectionDate = self._protectionStatusObj_protectionObj:getProtectionDate()
if protectionDate then
return self:_getExpandedMessage('reset-blurb-protectiondate')
function Blurb:_makeTooltipBlurbParameter()
local expiry = self._protectionStatusObj_protectionObj:getExpiry()
if type(expiry) == 'number' then
return self:_getExpandedMessage('tooltip-blurb-expiry')
end
function BannerTemplate:setImageFilename(filename, protectionStatusObjprotectionObj, titleObj)
if filename then
self._imageFilename = filename
end
local action = protectionStatusObjprotectionObj:getAction() local level = protectionStatusObjprotectionObj:getAction() local expiry = protectionStatusObjprotectionObj:getExpiry()
local namespace = titleObj.namespace
local Category = class('Category')
function Category:initialize(configObj, protectionStatusObjprotectionObj)
self._configObj = configObj
self._protectionStatusObj _protectionObj = protectionStatusObjprotectionObj
end
local ProtectionCategory = Category:subclass('ProtectionCategory')
function ProtectionCategory:initialize(configObj, protectionStatusObjprotectionObj, titleObj) Category.initialize(self, configObj, protectionStatusObjprotectionObj)
self._titleObj = titleObj
end
function ProtectionCategory:render()
local configObj = self._configObj
local protectionStatusObj protectionObj = self._protectionStatusObj_protectionObj
local titleObj = self._titleObj
-- Get the level and exit if the page is not protected.
if not protectionStatusObjprotectionObj:isProtected() then
return ''
end
-- Get the expiry.
local expiry = protectionStatusObjprotectionObj:getExpiry()
if type(expiry) == 'number' then
expiry = 'temp'
-- Get the other inputs.
local reason = protectionStatusObjprotectionObj:getReason() local action = protectionStatusObjprotectionObj:getAction() local level = protectionStatusObjprotectionObj:getLevel()
--[[
function ExpiryCategory:render()
local configObj = self._configObj
local protectionStatusObj protectionObj = self._protectionStatusObj_protectionObj
local reasonsWithoutExpiryCheck = configObj:getConfigTable('reasonsWithoutExpiryCheck')
local expiryCheckActions = configObj:getConfigTable('expiryCheckActions')
local expiry = protectionStatusObjprotectionObj:getExpiry() local action = protectionStatusObjprotectionObj:getAction() local reason = protectionStatusObjprotectionObj:getReason()
if not expiry
function ErrorCategory:render()
local configObj = self._configObj
local protectionStatusObj protectionObj = self._protectionStatusObj_protectionObj
local expiry = protectionStatusObjprotectionObj:getExpiry() local action = protectionStatusObjprotectionObj:getAction() local level = protectionStatusObjprotectionObj:getLevel()
if not protectionStatusObjprotectionObj:isProtected()
or type(expiry) == 'number' and expiry < os.time()
then
local TemplateCategory = Category:subclass('TemplateCategory')
function TemplateCategory:initialize(configObj, protectionStatusObjprotectionObj, titleObj) Category.initialize(self, configObj, protectionStatusObjprotectionObj)
self._titleObj = titleObj
end
function TemplateCategory:render()
local configObj = self._configObj
local protectionStatusObj protectionObj = self._protectionStatusObj_protectionObj
local titleObj = self._titleObj
local action = protectionStatusObjprotectionObj:getAction() local level = protectionStatusObjprotectionObj:getLevel()
local namespace = titleObj.namespace
-- Get data objects
local configObj = Config:new()
local protectionObj = ProtectionStatusProtection:new(args, configObj, titleObj)
-- Initialise the blurb object
-- This is used to export the classes for testing purposes.
return {
ProtectionStatus Protection = ProtectionStatusProtection,
Config = Config,
Blurb = Blurb,
Anonymous user