Changes
don't use Module:Middleclass
-- Initialise necessary modules.
require('Module:No globals')
local newFileLink = require('Module:File link').new
local effectiveProtectionLevel = require('Module:Effective protection level')._main
--------------------------------------------------------------------------------
local Protection = class('{}Protection.__index = Protection')
Protection.supportedActions = {
}
function Protection:initialize.new(args, cfg, title) selflocal obj = {} obj._cfg = cfg selfobj.title = title or mw.title.getCurrentTitle()
-- Set action
if not args.action then
else
error(string.format(
-- Set level
-- Lump titleblacklisted pages in with template-protected pages,
-- since templateeditors can do both.
-- Users need to be autoconfirmed to move pages anyway, so treat
-- semi-move-protected pages as unprotected.
end
if args.expiry then
if cfg.indefStrings[args.expiry] then
elseif type(args.expiry) == 'number' then
else
end
end
-- Set reason
if args[1] then
error('reasons cannot contain the pipe character ("|")', 0)
end
-- Set protection date
if args.date then
end
-- Set banner config
do
local configTables = {}
if cfg.banners[selfobj.action] then configTables[#configTables + 1] = cfg.banners[selfobj.action][selfobj.reason]
end
if cfg.defaultBanners[selfobj.action] then configTables[#configTables + 1] = cfg.defaultBanners[selfobj.action][selfobj.level] configTables[#configTables + 1] = cfg.defaultBanners[selfobj.action].default
end
configTables[#configTables + 1] = cfg.masterBanner
for i, field in ipairs(selfobj.bannerConfigFields) do
for j, t in ipairs(configTables) do
if t[field] then
break
end
end
end
return setmetatable(obj, Protection)
end
--------------------------------------------------------------------------------
local Blurb = class('{}Blurb.__index = Blurb')
Blurb.bannerTextFields = {
}
function Blurb:initialize.new(protectionObj, args, cfg) self.return setmetatable({ _cfg = cfg, self. _protectionObj = protectionObj, self. _args = args }, Blurb)
end
--------------------------------------------------------------------------------
local BannerTemplate = class('{}BannerTemplate.__index = BannerTemplate')
function BannerTemplate:initialize.new(protectionObj, cfg) selflocal obj = {} obj._cfg = cfg
-- Set the image filename.
local imageFilename = protectionObj.bannerConfig.image
if imageFilename then
else
-- If an image filename isn't specified explicitly in the banner config,
-- Fully protected modules and templates get the special red "indef"
-- padlock.
else
-- Deal with regular protection types.
local images = selfobj._cfg.images
if images[action] then
if images[action][level] then
elseif images[action].default then
end
end
end
end
return setmetatable(obj, BannerTemplate)
end
--------------------------------------------------------------------------------
local Banner = setmetatable({}, BannerTemplate:subclass(')Banner.__index = Banner')
function Banner:initialize.new(protectionObj, blurbObj, cfg) BannerTemplatelocal obj = Banner.initializenew(self, protectionObj, cfg) -- This doesn't need the blurb. selfobj:setImageWidth(40) selfobj:setImageTooltip(blurbObj:makeBannerText('alt')) -- Large banners use the alt text for the tooltip. selfobj._reasonText = blurbObj:makeBannerText('text') selfobj._explanationText = blurbObj:makeBannerText('explanation') selfobj._page = protectionObj.title.prefixedText -- Only makes a difference in testing. return setmetatable(obj, Banner)
end
--------------------------------------------------------------------------------
local Padlock = setmetatable({}, BannerTemplate:subclass(')Padlock.__index = Padlock')
function Padlock:initialize.new(protectionObj, blurbObj, cfg) local obj = BannerTemplate.initializenew(self, protectionObj, cfg) -- This doesn't need the blurb. selfobj:setImageWidth(20) selfobj:setImageTooltip(blurbObj:makeBannerText('tooltip')) selfobj._imageAlt = blurbObj:makeBannerText('alt') selfobj._imageLink = blurbObj:makeBannerText('link') selfobj._right = cfg.padlockPositions[protectionObj.action]
or cfg.padlockPositions.default
or '55px'
return setmetatable(obj, Padlock)
end
-- Initialise the protection object and check for errors
local protectionObjCreated, protectionObj = pcall(
Protection.new, Protection, -- equivalent to Protection:new()
args,
cfg,
-- Initialise the blurb object
local blurbObj = Blurb:.new(protectionObj, args, cfg)
local ret = {}
ret[#ret + 1] = tostring(
(yesno(args.small) and Padlock or Banner)
)
end