Anonymous user
Module:Protection banner: Difference between revisions
make the banner in charge of setting its own fields
(the only reason to ever use a title other than the current one is for testing, so don't bother exposing it to wikitext) |
(make the banner in charge of setting its own fields) |
||
Line 722:
local BannerTemplate = class('BannerTemplate')
function BannerTemplate:initialize(protectionObj, cfg)
self._cfg = cfg
local imageFilename = protectionObj.bannerConfig.image
if imageFilename then
self._imageFilename = imageFilename
else
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']
else
-- Deal with regular protection types.
local images = self._cfg.images
if images[action] then
if images[action][level] then
self._imageFilename = images[action][level]
elseif images[action].default then
self._imageFilename = images[action].default
end
end
end
end
end
Line 790 ⟶ 782:
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)
self:setImageTooltip(blurbObj:makeAltText()) -- Large banners use the alt text for the tooltip.
self._reasonText = blurbObj:makeReasonText()
self._explanationText = blurbObj:makeExplanationText()
self._page = protectionObj.title.prefixedText -- This only affects Module:Message box if the page specified is not the current page.
end
Line 833 ⟶ 815:
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)
self:setImageTooltip(blurbObj:makeTooltipText())
self._imageAlt = blurbObj:makeAltText()
self._imageLink = blurbObj:makeLinkText()
end
Line 890 ⟶ 867:
-- Render the banner
if protectionObj:isProtected() then
ret[#ret + 1] = tostring(
(yesno(args.small) and Padlock or Banner)
:new(protectionObj, blurbObj, cfg)
)
end
|