Open main menu

Changes

Module:Protection banner

532 bytes added, 19 January
m
1 revision imported
-- Initialise necessary modules.
require('Module:No globalsstrict')
local makeFileLink = require('Module:File link')._main
local effectiveProtectionLevel = require('Module:Effective protection level')._main
end
return setmetatable(obj, Protection)
end
 
function Protection:isUserScript()
-- Whether the page is a user JavaScript or CSS page.
local title = self.title
return title.namespace == 2 and (
title.contentModel == 'javascript' or title.contentModel == 'css'
)
end
return self.level ~= '*'
end
 
function Protection:shouldShowLock()
-- Whether we should output a banner/padlock
return self:isProtected() and not self:isUserScript()
end
 
-- Whether this page needs a protection category.
Protection.shouldHaveProtectionCategory = Protection.shouldShowLock
function Protection:isTemporary()
function Protection:makeProtectionCategory()
if not self:shouldHaveProtectionCategory() then
return ''
end
 
local cfg = self._cfg
local title = self.title
-- Exit if the page is not protected.
if not self:isProtected() then
return ''
end
-- Get the expiry key fragment.
namespaceFragment = 'talk'
end
-- Define the order that key fragments are tested in. This is done with an
-- array of tables containing the value to be tested, along with its
function Protection:isIncorrect()
local expiry = self.expiry
return not self:isProtectedshouldHaveProtectionCategory()
or type(expiry) == 'number' and expiry < os.time()
end
function Protection:makeCategoryLinks()
local msg = self._cfg.msg
local ret = { self:makeProtectionCategory() }
if self:isIncorrect() then
ret[#ret + 1] = makeCategoryLink(
function Blurb:_makeVandalTemplateParameter()
return requiremw.getCurrentFrame('Module):VandalexpandTemplate{ title="vandal-m')._main{", args={self._args.user or self._protectionObj.title.baseText}
}
end
-- protection from some other action, then don't bother displaying anything
-- for the other action (except categories).
if not yesno(args.catonly) and (protectionObj.action == 'edit' or
args.demolevel or
not getReachableNodes(
cfg.hierarchy,
protectionObj.level
)[effectiveProtectionLevel('edit', protectionObj.title)])
then
-- Initialise the blurb object
-- Render the banner
if protectionObj:isProtectedshouldShowLock() then
ret[#ret + 1] = tostring(
(yesno(args.small) and Padlock or Banner)