Jump to content

Module:Protection banner and Module:Protection banner/sandbox: Difference between pages

(Difference between pages)
Page 1
Page 2
Content deleted Content added
fix for mobile and search issue, see talk page
 
m Simplified code to increase readability
 
Line 13: Line 13:


-- Set constants.
-- Set constants.
local CONFIG_MODULE = 'Module:Protection banner/config'
local CONFIG_MODULE = 'Module:Protection banner/config/sandbox' -- SWITCH THIS BACK TO THE MAIN CONFIG PAGE BEFORE GOING LIVE!


--------------------------------------------------------------------------------
--------------------------------------------------------------------------------
Line 32: Line 32:
-- Validation function for the expiry and the protection date
-- Validation function for the expiry and the protection date
local function validateDate(dateString, dateType)
local function validateDate(dateString, dateType)
lang = lang or mw.language.getContentLanguage()
if not lang then
lang = mw.language.getContentLanguage()
end
local success, result = pcall(lang.formatDate, lang, 'U', dateString)
local success, result = pcall(lang.formatDate, lang, 'U', dateString)
if success then
if success then
Line 127: Line 125:


-- Set expiry
-- Set expiry
local effectiveExpiry = effectiveProtectionExpiry(obj.action, obj.title)
local effectiveExpiry = args.demoexpiry or effectiveProtectionExpiry(obj.action, obj.title)
if effectiveExpiry == 'infinity' then
if effectiveExpiry == 'infinity' then
obj.expiry = 'indef'
obj.expiry = 'indef'
Line 414: Line 412:
parameterFuncs.PROTECTIONLEVEL = self._makeProtectionLevelParameter
parameterFuncs.PROTECTIONLEVEL = self._makeProtectionLevelParameter
parameterFuncs.PROTECTIONLOG = self._makeProtectionLogParameter
parameterFuncs.PROTECTIONLOG = self._makeProtectionLogParameter
parameterFuncs.PROTECTIONMESSAGE = self._makeProtectionMessageParameter
parameterFuncs.TALKPAGE = self._makeTalkPageParameter
parameterFuncs.TALKPAGE = self._makeTalkPageParameter
parameterFuncs.TOOLTIPBLURB = self._makeTooltipBlurbParameter
parameterFuncs.TOOLTIPBLURB = self._makeTooltipBlurbParameter
Line 623: Line 622:
)
)
end
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
end


Line 865: Line 881:
if yesno(args.category) ~= false then
if yesno(args.category) ~= false then
ret[#ret + 1] = protectionObj:makeCategoryLinks()
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
end