Module:Protection banner: Difference between revisions

export classes for testing purposes and a few other tweaks
Enwikipedia>Jackmcbarn
(add no globals now, to catch any problems sooner rather than later)
Enwikipedia>Mr. Stradivarius
(export classes for testing purposes and a few other tweaks)
Line 88:
 
function Config:getConfigTable(key)
local whitelistedblacklist = {
imagesbanners = true,
categoriesdefaultBanners = true,
categoryNamespaces = true,
pagetypeNamespaces = true,
errorCategories = true
}
if whitelistednot blacklist[key] then
return self._cfg[key]
else
Line 187 ⟶ 184:
local ProtectionBanner = {}
 
function ProtectionBanner._newBannerTemplateexportToWiki(argsframe, title)
-- Makes a new banner template object. This will be a new instance of
-- the most suitable subclass of BannerTemplate, e.g. Banner or Padlock.
if yesno(args.small) then
return Padlock:new(args)
else
return Banner:new(args)
end
end
 
function ProtectionBanner.exportToWiki(frame, titleObj)
local args = mArguments.getArgs(frame)
return ProtectionBanner.exportToLua(args, titleObjtitle)
end
 
function ProtectionBanner.exportToLua(args, title)
title = title or mw.title.getCurrentTitle()
local pstatus = ProtectionStatus.new(args, title)
local cfg = Config:new()
 
-- Get the banner template object
local banner
do
local bannerClass
if yesno(args.small) then
bannerClass = Padlock
else
bannerClass = Banner
end
banner = bannerClass:new()
end
end
 
function ProtectionBanner.exportToWiki_exportClasses(frame, titleObj)
return {
ProtectionStatus = ProtectionStatus,
Config = Config,
Image = Image,
Blurb = Blurb,
BannerTemplate = BannerTemplate,
Banner = Banner,
Padlock = Padlock,
Category = Category,
ProtectionCategory = ProtectionCategory,
ErrorCategory = ErrorCategory,
ExpiryCategory = ExpiryCategory
}
end