Module:Protection banner: Difference between revisions

more data table restructuring, plus some fiddling around with the category name function; this is a progress save, so the code is horribly broken at the moment
Enwikipedia>Mr. Stradivarius
(add some more blurbs)
Enwikipedia>Mr. Stradivarius
(more data table restructuring, plus some fiddling around with the category name function; this is a progress save, so the code is horribly broken at the moment)
Line 9:
 
cfg.reasons = {
blp = {
categoryOrder = 'reason',
banner = 'blp'
},
dispute = {
categoryOrder = 'reason',
banner = 'dispute'
},
office = {
categoryOrder = 'reason',
banner = 'office'
},
sock = {
categoryOrder = 'reason',
banner = 'sock'
},
usertalk = {
banner = 'usertalk'
},
vandalism = {
categoryOrder = 'namespace',
iconReasonbanner = 'due to vandalism'
}
}
 
cfg.banners = {
-- $1 = "until" or "or until" depending on the expiry
-- $2 = "disputes", with or without a section link
blp = {
behavior = 'reasonFirst'
},
dispute = {
text = '$1 editing $2 have been resolved',
behavior = 'reasonFirst',
reasontooltip = '$1due to editing $2 have been resolveddisputes',
iconReason = 'due to editing disputes',
dispute = true
},
office = {
behavior = 'reasonFirst'
},
sock = {
},
behavior = 'reasonFirst'
usertalk = {
text = '',
explanation = 'If you cannot edit this user talk page and you need to'
.. ' make a change or leave a message, you can'
.. ' [[Wikipedia:Requests for page protection#'
.. 'Current requests for edits to a protected page|request an edit]],'
.. ' [[Wikipedia:Requests for page protection#'
.. 'Current requests for reduction in protection level|request unprotection]],'
.. ' [[Special:Userlogin|log in]],'
.. ' or [[Special:UserLogin/signup|create an account]].'
},
vandalism = {
text = 'due to [[Wikipedia:Vandalism|vandalism]]',
behavior = 'namespaceFirst',
reasontooltip = 'due to [[Wikipedia:Vandalism|vandalism]]',
iconReason = 'due to vandalism'
},
 
cfg.protectionLevels = {
foo
}
 
Line 158 ⟶ 186:
end
 
function p.getCategoryName(cats, protTypeaction, protLevellevel, namespace, reason, expiry)
--[[
-- Gets a category name from the category table, given a combination of
Line 172 ⟶ 200:
--]]
local properties = {
expiry = {pos = 5, val = expiry},
namespace = {'namespace', pos = 3, val = p.matchNamespace(namespace)},
reason = {pos = 4, val = reason},
level = {pos = 2, val = protLevellevel},
action = {pos = 1, val = protTypeaction}
}
 
Line 186 ⟶ 214:
-- vandalism categories if they were available.
--]]
local behaviorcategoryOrder
if not reason then
behaviorcategoryOrder = 'reasonFirstreason'
else
behaviorcategoryOrder = cfg.reasons[reason].behaviorcategoryOrder
end
if behaviorcategoryOrder == 'namespaceFirstnamespace' then
toTableEnd(properties, 2) -- move namespace to end
elseif behaviorcategoryOrder == 'reasonFirstreason' then
toTableEnd(properties, 3) -- move reason to end
else