Changes
Jump to navigation
Jump to search
mMessageBox makeMessageBox = mMessageBox makeMessageBox or require('Module:Message box').main
make the Protection class be in charge of the title, and some other tweaks
-- Lazily initialise modules and objects we don't always need.
local mArgumentsgetArgs, mMessageBoxmakeMessageBox, lang
--------------------------------------------------------------------------------
}
function Protection:initialize(args, cfg, titleObj)
self._cfg = cfg
if args.title then self.title = mw.title.new(args.title) if not self.title then error('Invalid title "' .. args.title .. '"', 2) end else self._titleObj title = titleObjmw.title.getCurrentTitle() end
-- Set action
-- Set level
do
self.level = effectiveProtectionLevel(self.action, titleObjself.title)
if self.level == 'accountcreator' then
-- Lump titleblacklisted pages in with template-protected pages,
function Protection:makeProtectionCategory()
local cfg = self._cfg
local titleObj title = self._titleObjtitle
-- Exit if the page is not protected.
local nskey
do
local namespace = titleObjtitle.namespace
local categoryNamespaces = cfg.categoryNamespaceKeys
nskey = categoryNamespaces[namespace]
function Protection:makeTemplateCategory()
local cfg = self._cfg
local titleObj title = self._titleObjtitle
local cat
and (
(self.action ~= 'edit' and self.action ~= 'move')
or (titleObjtitle.namespace ~= 10 and titleObjtitle.namespace ~= 828)
)
then
local Blurb = class('Blurb')
function Blurb:initialize(cfg, protectionObj, titleObj)
self._cfg = cfg
self._protectionObj = protectionObj
self._bannerConfig = protectionObj.bannerConfig
self._titleObj _title = titleObjprotectionObj.title
end
-- protection.
local action = self._protectionObj.action
local pagename = self._titleObj_title.prefixedText
if action == 'move' then
-- We need the move log link.
return string.format(
'[[%s:%s#%s|%s]]',
mw.site.namespaces[self._titleObj_title.namespace].talk.name, self._titleObj_title.text,
section,
disputes
local action = self._protectionObj.action
local level = self._protectionObj.level
local namespace = self._titleObj_title.namespace local isTalk = self._titleObj_title.isTalkPage
-- @TODO: add semi-protection and pending changes blurbs
function Blurb:_makePagetypeParameter()
local pagetypes = self._cfg.pagetypes
local namespace = self._titleObj_title.namespace
return pagetypes[namespace] or pagetypes.default or error('no default pagetype defined')
end
function Blurb:_makeProtectionLogParameter()
local action = self._protectionObj.action
local pagename = self._titleObj_title.prefixedText
if action == 'autoreview' then
-- We need the pending changes log.
return string.format(
'[[%s:%s#%s|%s]]',
mw.site.namespaces[self._titleObj_title.namespace].talk.name, self._titleObj_title.text,
section or 'top',
display
local mVandalM = require('Module:Vandal-m')
local username = self._username
username = username or self._titleObj_title.baseText
return mVandalM._main{username}
end
end
function BannerTemplate:setImageFilename(filename, protectionObj, titleObj)
if filename then
self._imageFilename = filename
local level = protectionObj.level
local expiry = protectionObj.expiry
local namespace = titleObjprotectionObj.title.namespace
-- Deal with special cases first.
function Banner:__tostring()
-- Renders the banner.
local reasonText = self._reasonText or error('no reason text set')
local explanationText = self._explanationText
)
}
return mMessageBox.mainmakeMessageBox('mbox', mbargs)
end
--------------------------------------------------------------------------------
-- ProtectionBanner classExports
--------------------------------------------------------------------------------
local ProtectionBanner p = {}
function ProtectionBannerp.exportToWiki_exportClasses(frame, cfg, titleObj) mArguments -- This is used for testing purposes. return { Protection = Protection, Blurb = mArguments or require('Module:Arguments')Blurb, local args BannerTemplate = mArguments.getArgs(frame)BannerTemplate, return ProtectionBanner.exportToLua(args Banner = Banner, cfg Padlock = Padlock, titleObj) }
end
function ProtectionBannerp.exportToLua_main(args, cfg, titleObj) if not cfg then cfg = cfg or mw.loadData('Module:Protection banner/config') titleObj = titleObj or mw.title.getCurrentTitle()end
-- Initialise protection and blurb objects
local protectionObj = Protection:new(args, cfg, titleObj) local blurbObj = Blurb:new(cfg, protectionObj, titleObj)
blurbObj:setDeletionDiscussionPage(args.xfd)
blurbObj:setUsername(args.user)
-- Set the image fields
local bannerConfig = protectionObj.bannerConfig
bannerObj:setImageFilename(bannerConfig.image, protectionObj, titleObj)
if isPadlock then
bannerObj:setImageTooltip(blurbObj:makeTooltipText())
bannerObj:setReasonText(blurbObj:makeReasonText())
bannerObj:setExplanationText(blurbObj:makeExplanationText())
bannerObj:setPage(titleObjprotectionObj.title.prefixedText)
end
end
function ProtectionBannerp._exportClassesmain(frame) -- This is used to export the classes for testing purposes. return {if not getArgs then Protection getArgs = Protection,require('Module:Arguments').getArgs Blurb = Blurb, BannerTemplate = BannerTemplate, Banner = Banner, Padlock = Padlock, end }return p._main(getArgs(frame))
end
return ProtectionBannerp