Module:Protection banner: Difference between revisions
Content deleted Content added
Enwikipedia>Mr. Stradivarius move section, username and deletion discussion methods out of the ProtectionStatus class, as they don't really have anything to do with protection status |
Enwikipedia>Mr. Stradivarius move image code to the BannerTemplate class, and simplify it |
||
Line 422:
--------------------------------------------------------------------------------
--
--------------------------------------------------------------------------------
local
function
self._configObj = configObj
end
function
if filename then
self.
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
end
-- 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._configObj:getMessage('image-filename-indef')
return nil
end
-- Deal with regular protection types.
local images = self._configObj:getConfigTable('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
return nil
end
end
return nil
end
function
self.
end
function
self.
end
function
self.
end
function
self.
end
function
or self._configObj:getMessage('image-filename-default')
or 'Transparent.gif'
return mFileLink.new(filename)
:
:alt(self._imageAlt)
:link(self._imageLink)
:caption(self._imageCaption)
:render()
end
function BannerTemplate:render()
-- Dummy method, to be implemented by the subclasses.
return ''
end
Line 527 ⟶ 509:
local Banner = BannerTemplate:subclass('Banner')
function Banner:initialize()
self:setImageWidth(40)
end
--------------------------------------------------------------------------------
Line 533 ⟶ 519:
local Padlock = BannerTemplate:subclass('Padlock')
function Padlock:initialize()
self:setImageWidth(20)
end
--------------------------------------------------------------------------------
Line 773 ⟶ 763:
theBanner:setUsername(args.user)
theBanner:setSection(args.section)
ret[#ret + 1] = theBanner:
-- Render the categories
|