Module:Protection banner: Difference between revisions
Content added Content deleted
Enwikipedia>Mr. Stradivarius (move the category methods to the Protection class, and get rid of all the category objects) |
Enwikipedia>Mr. Stradivarius (use a __tostring metamethod to render the banner objects) |
||
Line 794: | Line 794: | ||
:caption(self._imageCaption) |
:caption(self._imageCaption) |
||
:render() |
:render() |
||
⚫ | |||
function BannerTemplate:render() |
|||
-- Dummy method, to be implemented by the subclasses. |
|||
return '' |
|||
end |
end |
||
Line 820: | Line 815: | ||
end |
end |
||
function Banner: |
function Banner:setPage(s) |
||
⚫ | |||
-- Module:Message box if the page specified is not the current page. |
|||
self._page = s |
|||
⚫ | |||
function Banner:__tostring() |
|||
-- Renders the banner. |
-- Renders the banner. |
||
⚫ | |||
-- testing purposes. |
|||
mMessageBox = mMessageBox or require('Module:Message box') |
mMessageBox = mMessageBox or require('Module:Message box') |
||
local reasonText = self._reasonText or error('no reason text set') |
local reasonText = self._reasonText or error('no reason text set') |
||
local explanationText = self._explanationText |
local explanationText = self._explanationText |
||
local mbargs = { |
local mbargs = { |
||
page = |
page = self._page, |
||
type = 'protection', |
type = 'protection', |
||
image = self:renderImage(), |
image = self:renderImage(), |
||
Line 863: | Line 862: | ||
end |
end |
||
function Padlock: |
function Padlock:__tostring() |
||
local root = mw.html.create('div') |
local root = mw.html.create('div') |
||
root |
root |
||
Line 921: | Line 920: | ||
end |
end |
||
-- Set the text fields |
-- Set the text fields and the page name. |
||
if not isPadlock then |
if not isPadlock then |
||
bannerObj:setReasonText(blurbObj:makeReasonText()) |
bannerObj:setReasonText(blurbObj:makeReasonText()) |
||
bannerObj:setExplanationText(blurbObj:makeExplanationText()) |
bannerObj:setExplanationText(blurbObj:makeExplanationText()) |
||
bannerObj:setPage(titleObj.prefixedText) |
|||
end |
end |
||
ret[#ret + 1] = |
ret[#ret + 1] = tostring(bannerObj) |
||
end |
end |
||