Module:Protection banner: Difference between revisions

Content added Content deleted
Enwikipedia>Mr. Stradivarius
(allow category suppression with category=no)
Enwikipedia>Mr. Stradivarius
(change BannerTemplate:setImageFilename to accept protection objects and title objects rather than individual parameters)
Line 566: Line 566:
end
end


function BannerTemplate:setImageFilename(filename, action, level, namespace, expiry)
function BannerTemplate:setImageFilename(filename, protectionStatusObj, titleObj)
if filename then
if filename then
self._imageFilename = filename
self._imageFilename = filename
return nil
end
if not action or not level then
-- If the filename is not specified, we need the action and the level
-- to find the image name. The namespace and the expiry are optional,
-- however.
return nil
return nil
end
end


local action = protectionStatusObj:getAction()
local level = protectionStatusObj:getAction()
local expiry = protectionStatusObj:getExpiry()
local namespace = titleObj.namespace
-- Deal with special cases first.
-- Deal with special cases first.
if (namespace == 10 or namespace == 828) -- Maybe we don't need the namespace check?
if (namespace == 10 or namespace == 828) -- Maybe we don't need the namespace check?
Line 1,014: Line 1,012:
-- Set the image fields
-- Set the image fields
local bannerConfig = configObj:getBannerConfig(protectionObj)
local bannerConfig = configObj:getBannerConfig(protectionObj)
local imageFilename = bannerConfig.image
bannerObj:setImageFilename(bannerConfig.image, protectionObj, titleObj)
bannerObj:setImageFilename(
imageFilename,
protectionObj:getAction(),
protectionObj:getLevel(),
titleObj.namespace,
protectionObj:getExpiry()
)
if isPadlock then
if isPadlock then
bannerObj:setImageTooltip(blurbObj:makeTooltipText())
bannerObj:setImageTooltip(blurbObj:makeTooltipText())