Anonymous user
Module:Protection banner: Difference between revisions
config isn't an object anymore
Enwikipedia>Jackmcbarn (simplify further) |
Enwikipedia>Jackmcbarn (config isn't an object anymore) |
||
Line 67:
}
function Protection:initialize(args,
self.
self._titleObj = titleObj
Line 98:
-- Set expiry
if args.expiry then
if
self.expiry = 'indef'
elseif type(args.expiry) == 'number' then
Line 122:
self.bannerConfig = {}
local configTables = {}
if
configTables[#configTables + 1] =
end
if
configTables[#configTables + 1] =
configTables[#configTables + 1] =
end
configTables[#configTables + 1] =
for i, field in ipairs(self.bannerConfigFields) do
for j, t in ipairs(configTables) do
Line 146:
function Protection:makeProtectionCategory()
local
local titleObj = self._titleObj
Line 166:
do
local namespace = titleObj.namespace
local categoryNamespaces =
nskey = categoryNamespaces[namespace]
if not nskey and namespace % 2 == 1 then
Line 201:
local configOrder = {}
do
local reasonsWithNamespacePriority =
local namespaceFirst = reason and reasonsWithNamespacePriority[reason] or false
for propertiesKey, t in pairs(properties) do
Line 270:
-- pos field in the property table.
--]]
local cats =
local cat
for i = 1, 2^noActive do
Line 299:
function Protection:makeExpiryCategory()
local reasonsWithoutExpiryCheck = self.
local expiryCheckActions = self.
local cat
Line 308:
and not reasonsWithoutExpiryCheck[self.reason]
then
cat = self.
end
return makeCategoryLink(cat)
Line 314:
function Protection:makeErrorCategory()
local
local cat
if not self:isProtected()
or type(self.expiry) == 'number' and self.expiry < os.time()
then
cat =
end
return makeCategoryLink(cat)
Line 325:
function Protection:makeTemplateCategory()
local
local titleObj = self._titleObj
Line 335:
)
then
cat =
end
return makeCategoryLink(cat)
Line 346:
local Blurb = class('Blurb')
function Blurb:initialize(
self.
self._protectionObj = protectionObj
self._bannerConfig = protectionObj.bannerConfig
Line 378:
function Blurb:_getExpandedMessage(msg)
local msg = self.
return self:_substituteParameters(msg)
end
Line 553:
function Blurb:_makeImageLinkParameter()
local imageLinks = self.
local action = self._protectionObj.action
local level = self._protectionObj.level
Line 586:
function Blurb:_makePagetypeParameter()
local pagetypes = self.
local namespace = self._titleObj.namespace
return pagetypes[namespace] or pagetypes.default or error('no default pagetype defined')
Line 592:
function Blurb:_makeProtectionBlurbParameter()
local protectionBlurbs = self.
local action = self._protectionObj.action
local level = self._protectionObj.level
Line 618:
function Blurb:_makeProtectionLevelParameter()
local protectionLevels = self.
local action = self._protectionObj.action
local level = self._protectionObj.level
Line 738:
local BannerTemplate = class('BannerTemplate')
function BannerTemplate:initialize(
self.
end
Line 761:
-- Fully protected modules and templates get the special red "indef"
-- padlock.
self._imageFilename = self.
return nil
end
-- Deal with regular protection types.
local images = self.
if images[action] then
if images[action][level] then
Line 790:
function BannerTemplate:renderImage()
local filename = self._imageFilename
or self.
or 'Transparent.gif'
return newFileLink(filename)
Line 806:
local Banner = BannerTemplate:subclass('Banner')
function Banner:initialize(
BannerTemplate.initialize(self,
self:setImageWidth(40)
end
Line 849:
local Padlock = BannerTemplate:subclass('Padlock')
function Padlock:initialize(
BannerTemplate.initialize(self,
self:setImageWidth(20)
end
Line 882:
local ProtectionBanner = {}
function ProtectionBanner.exportToWiki(frame,
mArguments = mArguments or require('Module:Arguments')
local args = mArguments.getArgs(frame)
return ProtectionBanner.exportToLua(args,
end
function ProtectionBanner.exportToLua(args,
titleObj = titleObj or mw.title.getCurrentTitle()
-- Initialise protection and blurb objects
local protectionObj = Protection:new(args,
local blurbObj = Blurb:new(
blurbObj:setDeletionDiscussionPage(args.xfd)
blurbObj:setUsername(args.user)
Line 907:
local bannerObj
if isPadlock then
bannerObj = Padlock:new(
else
bannerObj = Banner:new(
end
|