local BannerTemplate = class('BannerTemplate')
function BannerTemplate:initialize(protectionObj, cfg)
self._cfg = cfg
end function BannerTemplate:setImageFilename(filename, local imageFilename = protectionObj).bannerConfig.image if filename imageFilename then self._imageFilename = filename return nilimageFilename endelse local action = protectionObj.action local level = protectionObj.level local expiry = protectionObj.expiry local namespace = protectionObj.title.namespace -- Deal with special cases first. if (namespace == 10 or namespace == 828) -- Maybe we don't need the namespace check? and action == 'edit' and level == 'sysop' and not expiry then -- Fully protected modules and templates get the special red "indef" -- padlock. self._imageFilename = self._cfg.msg['image-filename-indef'] return nilelse end -- Deal with regular protection types. local images = self._cfg.images if images[action] then if images[action][level] then self._imageFilename = images[action][level] return nil elseif images[action].default then self._imageFilename = images[action].default end return nilend
end
end
return nil
end
local Banner = BannerTemplate:subclass('Banner')
function Banner:initialize(protectionObj, blurbObj, cfg) BannerTemplate.initialize(self, protectionObj, cfg)-- this doesn't need the blurb
self:setImageWidth(40)
end function Banner self:setImageTooltip(blurbObj:setReasonTextmakeAltText(s)) -- Large banners use the alt text for the tooltip. self._reasonText = send function BannerblurbObj:setExplanationTextmakeReasonText(s) self._explanationText = send function BannerblurbObj:setPagemakeExplanationText(s) self._page = protectionObj.title.prefixedText -- This specifies the page to generate the banner for. This only affects -- Module:Message box if the page specified is not the current page. self._page = s
end
local Padlock = BannerTemplate:subclass('Padlock')
function Padlock:initialize(protectionObj, blurbObj, cfg) BannerTemplate.initialize(self, protectionObj, cfg)-- this doesn't need the blurb
self:setImageWidth(20)
end function Padlock self:setImageTooltip(blurbObj:setImageAltmakeTooltipText(alt)) self._imageAlt = altend function PadlockblurbObj:setImageLinkmakeAltText(link) self._imageLink = linkblurbObj:makeLinkText()
end
-- Render the banner
if protectionObj:isProtected() then
-- Get the banner objectret[#ret + 1] = tostring( local bannerObj if (yesno(args.small) then bannerObj = and Padlock:new(cfg) bannerObj:setImageTooltip(blurbObj:makeTooltipText()) bannerObj:setImageAlt(blurbObj:makeAltText()) bannerObj:setImageLink(blurbObj:makeLinkText()or Banner) else bannerObj = Banner:new(cfg) -- Large banners use the alt text for the tooltip. bannerObj:setImageTooltip(blurbObj:makeAltText()) -- Set the text fields and the page name. bannerObj:setReasonText(blurbObj:makeReasonText()) bannerObj:setExplanationText(protectionObj, blurbObj:makeExplanationText()) bannerObj:setPage(protectionObj.title.prefixedText) end -- Set the image fields local bannerConfig = protectionObj.bannerConfig bannerObj:setImageFilename(bannerConfig.image, protectionObjcfg) ret[#ret + 1] = tostring(bannerObj)
end