Zum Inhalt springen

Modul:Protection banner: Unterschied zwischen den Versionen

use a __tostring metamethod to render the banner objects
(move the category methods to the Protection class, and get rid of all the category objects)
(use a __tostring metamethod to render the banner objects)
Zeile 794: Zeile 794:
:caption(self._imageCaption)
:caption(self._imageCaption)
:render()
:render()
end
function BannerTemplate:render()
-- Dummy method, to be implemented by the subclasses.
return ''
end
end


Zeile 820: Zeile 815:
end
end


function Banner:render(page)
function Banner:setPage(s)
-- This specifies the page to generate the banner for. This only affects
-- Module:Message box if the page specified is not the current page.
self._page = s
end
 
function Banner:__tostring()
-- Renders the banner.
-- Renders the banner.
-- The page parameter specifies the page to generate the banner for, for
-- 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,
page = self._page,
type = 'protection',
type = 'protection',
image = self:renderImage(),
image = self:renderImage(),
Zeile 863: Zeile 862:
end
end


function Padlock:render()
function Padlock:__tostring()
local root = mw.html.create('div')
local root = mw.html.create('div')
root
root
Zeile 921: Zeile 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] = bannerObj:render()
ret[#ret + 1] = tostring(bannerObj)
end
end
Anonymer Benutzer