-- Initialise necessary modules.
require('Module:No globals')
local newFileLink makeFileLink = require('Module:File link').new_main
local effectiveProtectionLevel = require('Module:Effective protection level')._main
local yesno = require('Module:Yesno')
dateType,
tostring(dateString)
), 04)
end
-- 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
'invalid action ("%s")',
tostring(args.action)
), 03)
end
-- Set level
obj.level = args.demolevel or effectiveProtectionLevel(obj.action, obj.title) if obj.level == 'accountcreator' then -- Lump titleblacklisted pages in with template-protected pages, -- since templateeditors can do both. obj.level = 'templateeditor' elseif not obj.level or (obj.action == 'move' and obj.level == 'autoconfirmed') then
-- Users need to be autoconfirmed to move pages anyway, so treat
-- semi-move-protected pages as unprotected.
obj.reason = mw.ustring.lower(args[1])
if obj.reason:find('|') then
error('reasons cannot contain the pipe character ("|")', 03)
end
end
level,
talkKey
), 8)
end
return self:_substituteParameters(msg)
return pagetypes[self._protectionObj.title.namespace]
or pagetypes.default
or error('no default pagetype defined', 8)
end
msg = protectionBlurbs.edit.default
else
error('no protection blurb defined for protectionBlurbs.edit.default', 8)
end
return self:_substituteParameters(msg)
msg = protectionLevels.edit.default
else
error('no protection level defined for protectionLevels.edit.default', 8)
end
return self:_substituteParameters(msg)
tostring(key),
type(msg)
), 4)
end
return self:_substituteParameters(msg)
or self._cfg.msg['image-filename-default']
or 'Transparent.gif'
return newFileLink(makeFileLink{ file = filename), :widthsize = (self._imageWidth or 20).. 'px', :alt(= self._imageAlt), :link(= self._imageLink), :caption(= self._imageCaption) :render() }
end
-- Renders the banner.
makeMessageBox = makeMessageBox or require('Module:Message box').main
local reasonText = self._reasonText or error('no reason text set', 2)
local explanationText = self._explanationText
local mbargs = {
obj._imageAlt = blurbObj:makeBannerText('alt')
obj._imageLink = blurbObj:makeBannerText('link')
obj._right _indicatorName = cfg.padlockPositionspadlockIndicatorNames[protectionObj.action] or cfg.padlockPositionspadlockIndicatorNames.default or '55pxpp-default'
return setmetatable(obj, Padlock)
end
function Padlock:__tostring()
local root frame = mw.html.creategetCurrentFrame('div') root-- The nowiki tag helps prevent whitespace at the top of articles. local nowiki = frame:addClass(extensionTag{name = 'metadata topicon nopopupsnowiki')} local indicator = frame:extensionTag{ :attr(name = 'idindicator', 'protected-icon') :cssargs = {display = 'none', right name = self._right_indicatorName}, :wikitext(content = self:renderImage()) } return tostring(root)nowiki .. indicator
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 local protectionObjCreated, protectionObj = pcall( Protection.new, (args, cfg, title ) if not protectionObjCreated then local errorBlurb = cfg.msg['error-message-blurb'] or 'Error: $1.' local errorText = mw.message.newRawMessage(errorBlurb) :params(protectionObj) -- protectionObj is the error message :plain() return string.format( '<strong class="error">%s</strong>%s', errorText, makeCategoryLink( cfg.msg['tracking-category-incorrect'], title and title.text or mw.title.getCurrentTitle().text ) ) 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 args.demolevel 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
-- Build the args table. User-specified args overwrite default args.
local args = {}
for k, v in pairs(defaultArgsor {}) do
args[k] = v
end