Changes
some cleanup
-- Lazily initialise modules and objects we don't always need.
local mArguments, mMessageBox, lang
--------------------------------------------------------------------------------
-- Helper functions
--------------------------------------------------------------------------------
local function makeCategoryLink(cat)
if cat then
return string.format(
'[[%s:%s]]',
mw.site.namespaces[14].name,
cat
)
else
return ''
end
end
-- Validation function for the expiry and the protection date
local function validateDate(dateString, dateType)
lang = lang or mw.language.getContentLanguage()
local success, result = pcall(lang.formatDate, lang, 'U', dateString)
if success then
result = tonumber(result)
if result then
return result
end
end
error(string.format(
'invalid %s ("%s")',
dateType,
tostring(dateString)
))
end
--------------------------------------------------------------------------------
local Protection = class('Protection')
Protection.supportedActions = {
create = true,
edit = true,
move = true,
autoreview = true
}
Protection.bannerConfigFields = {
'text',
'explanation',
'tooltip',
'alt',
'link',
'image'
}
function Protection:initialize(args, configObj, titleObj)
-- Set action
do
self.action = args.action
else
end
end
-- Set level
do
-- Lump titleblacklisted pages in with template-protected pages,
-- since templateeditors can do both.
self.level = 'templateeditor' end if elseif not self.level or (self.action == 'move' and self.level == 'autoconfirmed' ) then
-- Users need to be autoconfirmed to move pages anyway, so treat
-- semi-move-protected pages as unprotected.
end
end
-- Set expiry
if args.expiry then
self.expiry = 'indef'
elseif type(args.expiry) == 'number' then
self.bannerConfig = {}
local cfg = configObj.cfg
local configTables = {}
if cfg.banners[self.action] then
end
configTables[#configTables + 1] = cfg.masterBanner
for i, field in ipairs(fieldsself.bannerConfigFields) do
for j, t in ipairs(configTables) do
if t[field] then
function Protection:isProtected()
return self.level ~= '*'
end
end
return self._makeCategoryLinkmakeCategoryLink(cat)
end
cat = self._configObj.msg['tracking-category-expiry']
end
return self._makeCategoryLinkmakeCategoryLink(cat)
end
cat = configObj.msg['tracking-category-incorrect']
end
return self._makeCategoryLinkmakeCategoryLink(cat)
end
cat = configObj.msg['tracking-category-template']
end
return self._makeCategoryLinkmakeCategoryLink(cat)
end