Changes

Jump to navigation Jump to search

Module:Protection banner

730 bytes added, 21:14, 6 September 2014
only show banners for actions other than edit if they're more restricted than edit
-- other items down accordingly.
return table.insert(t, table.remove(t, pos))
end
 
local function walkHierarchy(hierarchy, start)
local toWalk, retval = {[start] = true}, {}
while true do
-- Can't use pairs() since we're adding and removing things as we're iterating
local k = next(toWalk)
if k == nil then break end
toWalk[k] = nil
retval[k] = true
for _,v in ipairs(hierarchy[k]) do
if not retval[v] then
toWalk[v] = true
end
end
end
return retval
end
function p._main(args, cfg, title)
args = args or {}
cfg = cfg or require('Module:Protection banner/config'CONFIG_MODULE)
-- Initialise the protection object and check for errors
)
end
-- Initialise the blurb object
local blurbObj = Blurb.new(protectionObj, args, cfg)
local ret = {}
-- If a page's edit protection is equally or more restrictive than its protection from some other action, -- then don't bother displaying anything for the other action (except categories). if protectionObj.action == 'edit' or not walkHierarchy(cfg.hierarchy, protectionObj.level)[effectiveProtectionLevel('edit', protectionObj.title)] then -- Initialise the blurb object local blurbObj = Blurb.new(protectionObj, args, cfg) -- Render the banner if protectionObj:isProtected() then ret[#ret + 1] = tostring( (yesno(args.small) and Padlock or Banner) .new(protectionObj, blurbObj, cfg) ) )end
end
-- Render the categories
if yesno(args.category) ~= false then
-- Find default args, if any.
local parentTitle parent = frame.getParent and frame:getParent() local defaultArgs = parent and cfg.wrappers[parent:getTitle() parentTitle = parentTitle:gsub('/sandbox$', '') local defaultArgs = cfg.wrappers[parentTitle] or {}
-- Find user args, and use the parent frame if we are being called from a
Anonymous user

Navigation menu