Module:Protection banner: Difference between revisions

Content deleted Content added
add catonly param which hides both the banner and padlock if set to yes. all testcases pass. tested in sandbox.
m 1 revision imported: Import "Information Appliance" infobox template
Line 146: Line 146:
obj.protectionDate = validateDate(args.date, 'protection date')
obj.protectionDate = validateDate(args.date, 'protection date')
end
end

-- Set banner config
-- Set banner config
do
do
Line 202: Line 202:
local cfg = self._cfg
local cfg = self._cfg
local title = self.title
local title = self.title

-- Get the expiry key fragment.
-- Get the expiry key fragment.
local expiryFragment
local expiryFragment
Line 240: Line 240:
--]]
--]]
table.insert(order, table.remove(order, self.reason and cfg.reasonsWithNamespacePriority[self.reason] and 2 or 3))
table.insert(order, table.remove(order, self.reason and cfg.reasonsWithNamespacePriority[self.reason] and 2 or 3))

--[[
--[[
-- Define the attempt order. Inactive subtables (subtables with nil "value"
-- Define the attempt order. Inactive subtables (subtables with nil "value"
Line 265: Line 265:
end
end
end
end

--[[
--[[
-- Check increasingly generic key combinations until we find a match. If a
-- Check increasingly generic key combinations until we find a match. If a
Line 278: Line 278:
-- would look like this, with 0 corresponding to the key fragment "all", and
-- would look like this, with 0 corresponding to the key fragment "all", and
-- 1 corresponding to other key fragments.
-- 1 corresponding to other key fragments.
--
--
-- j 1 2 3
-- j 1 2 3
-- i
-- i
-- 1 1 1 1
-- 1 1 1 1
-- 2 0 1 1
-- 2 0 1 1
Line 289: Line 289:
-- 7 1 0 0
-- 7 1 0 0
-- 8 0 0 0
-- 8 0 0 0
--
--
-- Values of j higher than the number of active subtables are set
-- Values of j higher than the number of active subtables are set
-- to the string "all".
-- to the string "all".
Line 418: Line 418:
parameterFuncs.TOOLTIPFRAGMENT = self._makeTooltipFragmentParameter
parameterFuncs.TOOLTIPFRAGMENT = self._makeTooltipFragmentParameter
parameterFuncs.VANDAL = self._makeVandalTemplateParameter
parameterFuncs.VANDAL = self._makeVandalTemplateParameter

self._params = setmetatable({}, {
self._params = setmetatable({}, {
__index = function (t, k)
__index = function (t, k)
Line 431: Line 431:
})
})
end
end

msg = msg:gsub('${(%u+)}', self._params)
msg = msg:gsub('${(%u+)}', self._params)
return msg
return msg
Line 461: Line 461:
local action = self._protectionObj.action
local action = self._protectionObj.action
local level = self._protectionObj.level
local level = self._protectionObj.level

-- Get the edit request type.
-- Get the edit request type.
local requestType
local requestType
Line 474: Line 474:
end
end
requestType = requestType or 'full'
requestType = requestType or 'full'

-- Get the display value.
-- Get the display value.
local display = self:_getExpandedMessage('edit-request-display')
local display = self:_getExpandedMessage('edit-request-display')
Line 709: Line 709:
local namespace = protectionObj.title.namespace
local namespace = protectionObj.title.namespace
local reason = protectionObj.reason
local reason = protectionObj.reason

-- Deal with special cases first.
-- Deal with special cases first.
if (
if (
Line 852: Line 852:
-- Initialise the blurb object
-- Initialise the blurb object
local blurbObj = Blurb.new(protectionObj, args, cfg)
local blurbObj = Blurb.new(protectionObj, args, cfg)

-- Render the banner
-- Render the banner
if protectionObj:shouldShowLock() then
if protectionObj:shouldShowLock() then
Line 866: Line 866:
ret[#ret + 1] = protectionObj:makeCategoryLinks()
ret[#ret + 1] = protectionObj:makeCategoryLinks()
end
end

return table.concat(ret)
return table.concat(ret)
end
end