Module:Protection banner/sandbox: Difference between revisions

Content deleted Content added
m Simplified code to increase readability
sync to live module
 
Line 32:
-- Validation function for the expiry and the protection date
local function validateDate(dateString, dateType)
langif =not lang orthen
lang = mw.language.getContentLanguage()
end
local success, result = pcall(lang.formatDate, lang, 'U', dateString)
if success then
Line 125 ⟶ 127:
 
-- Set expiry
local effectiveExpiry = args.demoexpiry or effectiveProtectionExpiry(obj.action, obj.title)
if effectiveExpiry == 'infinity' then
obj.expiry = 'indef'
Line 412 ⟶ 414:
parameterFuncs.PROTECTIONLEVEL = self._makeProtectionLevelParameter
parameterFuncs.PROTECTIONLOG = self._makeProtectionLogParameter
parameterFuncs.PROTECTIONMESSAGE = self._makeProtectionMessageParameter
parameterFuncs.TALKPAGE = self._makeTalkPageParameter
parameterFuncs.TOOLTIPBLURB = self._makeTooltipBlurbParameter
Line 622 ⟶ 623:
)
end
end
 
function Blurb:_makeProtectionMessageParameter()
local protectionMessages = self._cfg.protectionMessages
local action = self._protectionObj.action
local level = self._protectionObj.level
local msg
if protectionMessages[action][level] then
msg = protectionMessages[action][level]
elseif protectionMessages[action].default then
msg = protectionMessages[action].default
elseif protectionMessages.edit.default then
msg = protectionMessages.edit.default
else
error('no protection level defined for protectionMessages.edit.default', 8)
end
return self:_substituteParameters(msg)
end
 
Line 881 ⟶ 865:
if yesno(args.category) ~= false then
ret[#ret + 1] = protectionObj:makeCategoryLinks()
end
-- For arbitration enforcement, flagging [[WP:PIA]] pages to enable [[Special:AbuseFilter/1339]] to flag edits to them
if protectionObj.level == "extendedconfirmed" then
if require("Module:TableTools").inArray(protectionObj.title.talkPageTitle.categories, "Wikipedia pages subject to the extended confirmed restriction related to the Arab-Israeli conflict") then
ret[#ret + 1] = "<p class='PIA-flag' style='display:none; visibility:hidden;' title='This page is subject to the extended confirmed restriction related to the Arab-Israeli conflict.'></p>"
end
end