Anonymous user
Module:Protection banner: Difference between revisions
try to merge the edit conflict, one variable at a time, starting with action
Enwikipedia>Mr. Stradivarius ((edit conflict) replace Protection getter functions with public attributes) |
Enwikipedia>Jackmcbarn (try to merge the edit conflict, one variable at a time, starting with action) |
||
Line 10:
-- Lazily initialise modules and objects we don't always need.
local mArguments, mMessageBox, lang, config
--------------------------------------------------------------------------------
Line 116 ⟶ 47:
level = '*'
end
self.
end
Line 137 ⟶ 68:
-- Set expiry
if args.expiry then
local indefStrings = configObj
if indefStrings[args.expiry] then
self.
elseif type(args.expiry) == 'number' then
self.
else
self.
end
end
Line 151 ⟶ 82:
local reason = args.reason or args[1]
if reason then
self.
end
end
-- Set protection date
self.
-- Set banner config
do
self.bannerConfig = {}
local cfg = configObj.cfg
local fields = {
'text',
'explanation',
'tooltip',
'alt',
'link',
'image'
}
local configTables = {}
if cfg.banners[self.action] then
configTables[#configTables + 1] = cfg.banners[self.action][self._reason]
end
if cfg.defaultBanners[self.action] then
configTables[#configTables + 1] = cfg.defaultBanners[self.action][self._level]
configTables[#configTables + 1] = cfg.defaultBanners[self.action].default
end
configTables[#configTables + 1] = cfg.masterBanner
for i, field in ipairs(fields) do
for j, t in ipairs(configTables) do
if t[field] then
self.bannerConfig[field] = t[field]
break
end
end
end
end
end
Line 172 ⟶ 134:
self._configObj = configObj
self._protectionObj = protectionObj
self._bannerConfig =
self._titleObj = titleObj
end
Line 201 ⟶ 163:
function Blurb:_getExpandedMessage(msg)
local msg = self._configObj
return self:_substituteParameters(msg)
end
Line 278 ⟶ 240:
function Blurb:_makeDisputeBlurbParameter()
local expiry = self._protectionObj
if type(expiry) == 'number' then
return self:_getExpandedMessage('dispute-blurb-expiry')
Line 306 ⟶ 268:
local mEditRequest = require('Module:Submit an edit request')
local action = self._protectionObj.action
local level = self._protectionObj
-- Get the display message key.
Line 332 ⟶ 294:
function Blurb:_makeExpiryParameter()
local expiry = self._protectionObj
if expiry == 'indef' then
return nil
Line 345 ⟶ 307:
function Blurb:_makeExplanationBlurbParameter()
local action = self._protectionObj.action
local level = self._protectionObj
local namespace = self._titleObj.namespace
local isTalk = self._titleObj.isTalkPage
Line 376 ⟶ 338:
function Blurb:_makeImageLinkParameter()
local imageLinks = self._configObj
local action = self._protectionObj.action
local level = self._protectionObj
local msg
if imageLinks[action][level] then
Line 391 ⟶ 353:
function Blurb:_makeIntroBlurbParameter()
local expiry = self._protectionObj
if type(expiry) == 'number' then
return self:_getExpandedMessage('intro-blurb-expiry')
Line 400 ⟶ 362:
function Blurb:_makeOfficeBlurbParameter()
local protectionDate = self._protectionObj
if protectionDate then
return self:_getExpandedMessage('office-blurb-protectiondate')
Line 409 ⟶ 371:
function Blurb:_makePagetypeParameter()
local pagetypes = self._configObj
local namespace = self._titleObj.namespace
return pagetypes[namespace] or pagetypes.default or error('no default pagetype defined')
Line 415 ⟶ 377:
function Blurb:_makeProtectionBlurbParameter()
local protectionBlurbs = self._configObj
local action = self._protectionObj.action
local level = self._protectionObj
local msg
if protectionBlurbs[action][level] then
Line 432 ⟶ 394:
function Blurb:_makeProtectionDateParameter()
local protectionDate = self._protectionObj
if type(protectionDate) == 'number' then
return Blurb.formatDate(protectionDate)
Line 441 ⟶ 403:
function Blurb:_makeProtectionLevelParameter()
local protectionLevels = self._configObj
local action = self._protectionObj.action
local level = self._protectionObj
local msg
if protectionLevels[action][level] then
Line 478 ⟶ 440:
function Blurb:_makeResetBlurbParameter()
local protectionDate = self._protectionObj
if protectionDate then
return self:_getExpandedMessage('reset-blurb-protectiondate')
Line 499 ⟶ 461:
function Blurb:_makeTooltipBlurbParameter()
local expiry = self._protectionObj
if type(expiry) == 'number' then
return self:_getExpandedMessage('tooltip-blurb-expiry')
Line 572 ⟶ 534:
local action = protectionObj.action
local level = protectionObj
local expiry = protectionObj
local namespace = titleObj.namespace
Line 584 ⟶ 546:
-- Fully protected modules and templates get the special red "indef"
-- padlock.
self._imageFilename = self._configObj
return nil
end
-- Deal with regular protection types.
local images = self._configObj
if images[action] then
if images[action][level] then
Line 613 ⟶ 575:
function BannerTemplate:renderImage()
local filename = self._imageFilename
or self._configObj
or 'Transparent.gif'
return newFileLink(filename)
Line 747 ⟶ 709:
-- Get the expiry.
local expiry = protectionObj
if type(expiry) == 'number' then
expiry = 'temp'
Line 758 ⟶ 720:
do
local namespace = titleObj.namespace
local categoryNamespaces = configObj
nskey = categoryNamespaces[namespace]
if not nskey and namespace % 2 == 1 then
Line 766 ⟶ 728:
-- Get the other inputs.
local reason = protectionObj
local action = protectionObj.action
local level = protectionObj
--[[
Line 793 ⟶ 755:
local configOrder = {}
do
local reasonsWithNamespacePriority = configObj
local namespaceFirst = reason and reasonsWithNamespacePriority[reason] or false
for propertiesKey, t in pairs(properties) do
Line 862 ⟶ 824:
-- pos field in the property table.
--]]
local cats = configObj
local cat
for i = 1, 2^noActive do
Line 899 ⟶ 861:
function ExpiryCategory:render()
local
local protectionObj = self._protectionObj
local reasonsWithoutExpiryCheck = configObj.cfg.reasonsWithoutExpiryCheck
local expiryCheckActions = configObj.cfg.expiryCheckActions
local expiry = protectionObj:getExpiry()
local action = protectionObj.action
local reason = protectionObj:getReason()
if not expiry
Line 910 ⟶ 875:
and not reasonsWithoutExpiryCheck[reason]
then
self:setName(configObj
end
return Category.render(self)
Line 924 ⟶ 889:
local configObj = self._configObj
local protectionObj = self._protectionObj
local expiry = protectionObj:getExpiry()
local action = protectionObj.action
local level = protectionObj
if not protectionObj:isProtected()
or type(expiry) == 'number' and expiry < os.time()
then
self:setName(configObj
end
return Category.render(self)
Line 949 ⟶ 915:
function TemplateCategory:render()
local configObj = self._configObj
local
local
local action = protectionObj.action
local level = protectionObj:getLevel()
local namespace = titleObj.namespace
if level == 'templateeditor'
Line 959 ⟶ 928:
)
then
self:setName(configObj
end
return Category.render(self)
Line 980 ⟶ 949:
-- Get data objects
if not config then
config = mw.loadData('Module:Protection banner/config')
end
local configObj = config
local protectionObj = Protection:new(args, configObj, titleObj)
Line 1,003 ⟶ 975:
-- Set the image fields
local bannerConfig =
bannerObj:setImageFilename(bannerConfig.image, protectionObj, titleObj)
if isPadlock then
Line 1,043 ⟶ 1,015:
return {
Protection = Protection,
Blurb = Blurb,
BannerTemplate = BannerTemplate,
|