Editing Module:Protection banner

From MINR.ORG WIKI

Warning: You are not logged in. Your IP address will be publicly visible if you make any edits. If you log in or create an account, your edits will be attributed to your username, along with other benefits.

The edit can be undone. Please check the comparison below to verify that this is what you want to do, and then save the changes below to finish undoing the edit.
Latest revision Your text
Line 46: Line 46:
 
dateType,
 
dateType,
 
tostring(dateString)
 
tostring(dateString)
), 4)
+
), 0)
 
end
 
end
  
Line 115: Line 115:
 
'invalid action: %s',
 
'invalid action: %s',
 
tostring(args.action)
 
tostring(args.action)
), 3)
+
), 0)
 
end
 
end
  
Line 138: Line 138:
 
obj.reason = mw.ustring.lower(args[1])
 
obj.reason = mw.ustring.lower(args[1])
 
if obj.reason:find('|') then
 
if obj.reason:find('|') then
error('reasons cannot contain the pipe character ("|")', 3)
+
error('reasons cannot contain the pipe character ("|")', 0)
 
end
 
end
 
end
 
end
Line 505: Line 505:
 
level,
 
level,
 
talkKey
 
talkKey
), 8)
+
))
 
end
 
end
 
return self:_substituteParameters(msg)
 
return self:_substituteParameters(msg)
Line 545: Line 545:
 
return pagetypes[self._protectionObj.title.namespace]
 
return pagetypes[self._protectionObj.title.namespace]
 
or pagetypes.default
 
or pagetypes.default
or error('no default pagetype defined', 8)
+
or error('no default pagetype defined')
 
end
 
end
  
Line 560: Line 560:
 
msg = protectionBlurbs.edit.default
 
msg = protectionBlurbs.edit.default
 
else
 
else
error('no protection blurb defined for protectionBlurbs.edit.default', 8)
+
error('no protection blurb defined for protectionBlurbs.edit.default')
 
end
 
end
 
return self:_substituteParameters(msg)
 
return self:_substituteParameters(msg)
Line 586: Line 586:
 
msg = protectionLevels.edit.default
 
msg = protectionLevels.edit.default
 
else
 
else
error('no protection level defined for protectionLevels.edit.default', 8)
+
error('no protection level defined for protectionLevels.edit.default')
 
end
 
end
 
return self:_substituteParameters(msg)
 
return self:_substituteParameters(msg)
Line 665: Line 665:
 
tostring(key),
 
tostring(key),
 
type(msg)
 
type(msg)
), 4)
+
))
 
end
 
end
 
return self:_substituteParameters(msg)
 
return self:_substituteParameters(msg)
Line 755: Line 755:
 
-- Renders the banner.
 
-- Renders the banner.
 
makeMessageBox = makeMessageBox or require('Module:Message box').main
 
makeMessageBox = makeMessageBox or require('Module:Message box').main
local reasonText = self._reasonText or error('no reason text set', 2)
+
local reasonText = self._reasonText or error('no reason text set')
 
local explanationText = self._explanationText
 
local explanationText = self._explanationText
 
local mbargs = {
 
local mbargs = {
Line 820: Line 820:
 
cfg = cfg or require(CONFIG_MODULE)
 
cfg = cfg or require(CONFIG_MODULE)
  
local protectionObj = Protection.new(args, cfg, title)
+
-- 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
  
 
local ret = {}
 
local ret = {}
Line 859: Line 879:
 
-- Find default args, if any.
 
-- Find default args, if any.
 
local parent = frame.getParent and frame:getParent()
 
local parent = frame.getParent and frame:getParent()
local defaultArgs = parent and cfg.wrappers[parent:getTitle():gsub('/sandbox$', '')]
+
local defaultArgs = parent and cfg.wrappers[parent:getTitle():gsub('/sandbox$', '')] or {}
  
 
-- Find user args, and use the parent frame if we are being called from a
 
-- Find user args, and use the parent frame if we are being called from a
Line 871: Line 891:
 
-- Build the args table. User-specified args overwrite default args.
 
-- Build the args table. User-specified args overwrite default args.
 
local args = {}
 
local args = {}
for k, v in pairs(defaultArgs or {}) do
+
for k, v in pairs(defaultArgs) do
 
args[k] = v
 
args[k] = v
 
end
 
end

Please note that all contributions to MINR.ORG WIKI may be edited, altered, or removed by other contributors. If you do not want your writing to be edited mercilessly, then do not submit it here.
You are also promising us that you wrote this yourself, or copied it from a public domain or similar free resource (see MINR.ORG WIKI:Copyrights for details). Do not submit copyrighted work without permission!

Cancel Editing help (opens in new window)