Jump to content

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
(add some more blurbs)
(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: Line 9:


cfg.reasons = {
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',
banner = 'vandalism'
}
}
cfg.banners = {
-- $1 = "until" or "or until" depending on the expiry
-- $1 = "until" or "or until" depending on the expiry
-- $2 = "disputes", with or without a section link
-- $2 = "disputes", with or without a section link
blp = {
blp = {
behavior = 'reasonFirst'
},
},
dispute = {
dispute = {
behavior = 'reasonFirst',
text = '$1 editing $2 have been resolved',
reason = '$1 editing $2 have been resolved',
tooltip = 'due to editing disputes',
iconReason = 'due to editing disputes',
dispute = true
dispute = true
},
},
office = {
office = {
behavior = 'reasonFirst'
},
},
sock = {
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 = {
vandalism = {
behavior = 'namespaceFirst',
text = 'due to [[Wikipedia:Vandalism|vandalism]]',
reason = 'due to [[Wikipedia:Vandalism|vandalism]]',
tooltip = 'due to vandalism'
iconReason = 'due to vandalism'
},
},
}
cfg.protectionLevels = {
foo
}
}


Line 158: Line 186:
end
end


function p.getCategoryName(cats, protType, protLevel, namespace, reason, expiry)
function p.getCategoryName(cats, action, level, namespace, reason, expiry)
--[[
--[[
-- Gets a category name from the category table, given a combination of
-- Gets a category name from the category table, given a combination of
Line 172: Line 200:
--]]
--]]
local properties = {
local properties = {
{pos = 5, val = expiry},
expiry = {pos = 5, val = expiry},
{pos = 3, val = p.matchNamespace(namespace)},
namespace = {'namespace', pos = 3, val = p.matchNamespace(namespace)},
{pos = 4, val = reason},
reason = {pos = 4, val = reason},
{pos = 2, val = protLevel},
level = {pos = 2, val = level},
{pos = 1, val = protType}
action = {pos = 1, val = action}
}
}


Line 186: Line 214:
-- vandalism categories if they were available.
-- vandalism categories if they were available.
--]]
--]]
local behavior
local categoryOrder
if not reason then
if not reason then
behavior = 'reasonFirst'
categoryOrder = 'reason'
else
else
behavior = cfg.reasons[reason].behavior
categoryOrder = cfg.reasons[reason].categoryOrder
end
end
if behavior == 'namespaceFirst' then
if categoryOrder == 'namespace' then
toTableEnd(properties, 2) -- move namespace to end
toTableEnd(properties, 2) -- move namespace to end
elseif behavior == 'reasonFirst' then
elseif categoryOrder == 'reason' then
toTableEnd(properties, 3) -- move reason to end
toTableEnd(properties, 3) -- move reason to end
else
else
Cookies help us deliver our services. By using our services, you agree to our use of cookies.