Module:Protection banner: Difference between revisions
Content added Content deleted
Enwikipedia>Mr. Stradivarius (export classes for testing purposes and a few other tweaks) |
Enwikipedia>Mr. Stradivarius (expand the Image class) |
||
Line 47: | Line 47: | ||
-- Set expiry |
-- Set expiry |
||
self._expiry = args.expiry |
self._expiry = args.expiry or 'indef' |
||
end |
end |
||
Line 104: | Line 104: | ||
local Image = class('Image') |
local Image = class('Image') |
||
function Image:setFilename(filename, configObj, protectionStatusObj, namespace) |
|||
if filename then |
|||
self._filename = filename |
|||
else |
|||
local images = configObj:getConfigTable('images') |
|||
local action = protectionStatusObj:getAction() |
|||
local level = protectionStatusObj:getLevel() |
|||
local reason = protectionStatusObj:getReason() |
|||
local image |
|||
if reason == 'office' or reason == 'reset' then |
|||
image = images.office |
|||
elseif namespace == 10 or namespace == 828 then |
|||
-- We are in the template or module namespaces. |
|||
if level == 'templateeditor' then |
|||
image = images.template |
|||
elseif level == 'sysop' then |
|||
image = images.indef |
|||
end |
|||
elseif action == 'create' then |
|||
image = images.create |
|||
elseif action == 'move' |
|||
and ( |
|||
level == 'templateeditor' |
|||
or level == 'sysop' |
|||
) |
|||
then |
|||
image = images.move |
|||
elseif action == 'edit' then |
|||
if level == 'sysop' then |
|||
image = images.full |
|||
elseif level == 'autoconfirmed' then |
|||
image = images.semi |
|||
end |
|||
elseif action == 'autoreview' then |
|||
if level == 'autoconfirmed' then |
|||
image = images.pc1 |
|||
elseif level == 'reviewer' then |
|||
image = images.pc2 |
|||
end |
|||
else |
|||
image = 'Transparent.gif' |
|||
end |
|||
self._filename = image |
|||
end |
|||
end |
|||
function Image:export() |
|||
return mFileLink.new(self._filename) |
|||
:width(self._size) |
|||
:alt(self._alt) |
|||
:caption(self._caption) |
|||
:render() |
|||
end |
|||
-------------------------------------------------------------------------------- |
-------------------------------------------------------------------------------- |