Open main menu

Changes

Module:Protection banner

576 bytes added, 01:44, 18 March 2014
make the category attempt order more configurable
--[[
-- Define the initial order to test properties in. The subtable position
-- is the order the properties will be tested in, and the pos keypos value in
-- each subtable is the position of the value in the category key.
--]]
local properties = {
expiry = {pos order = 1, keypos = 5, val = expiry}, namespace = {'namespace'order = 2, pos keypos = 3, val = p.matchNamespace(namespace)}, reason = {pos order = 3, keypos = 4, val = reason}, level = {pos order = 4, keypos = 2, val = level}, action = {pos order = 5, keypos = 1, val = action}
}
-- vandalism categories if they were available.
--]]
local reasonTable = cfg.reasons[reason] local categoryOrder = reasonTable and reasonTable.categoryOrder local categoryOrderType = type(categoryOrder) local configOrder = {} if not reason categoryOrderType == 'table' then local dupes = {} for i = 1, 5 do local propertiesKey = categoryOrder [i] if not propertiesKey then error('no properties key') end local property = properties[propertiesKey] if not property then error('reasoninvalid properties key') end if dupes[property] then error('dupe detected') else dupes[property] = true end configOrder[i] = property end
else
categoryOrder = cfgfor propertiesKey, t in pairs(properties) do configOrder[t.reasons[reasonorder].categoryOrder= t end if categoryOrder categoryOrderType == 'namespacestring' then toTableEnd( local property = properties, 2) -- move namespace to end[categoryOrder] if not property then elseif categoryOrder == error('reasoninvalid category order string' then) end toTableEnd(propertiesconfigOrder, 3property.order) -- move reason to end else error(reason .. ' is not a valid reason')end
end
--]]
local active, inactive = {}, {}
for i, t in ipairs(propertiesconfigOrder) do
if t.val then
active[#active + 1] = t
local key = {}
for j, t in ipairs(attemptOrder) do
local pos = t.pos
local val = t.val
if j > noActive then
key[post.keypos] = 'all'
else
local quotient = i / 2 ^ (j - 1)
quotient = ceil(quotient)
if quotient % 2 == 1 then
key[post.keypos] = t.val
else
key[post.keypos] = 'all'
end
end
Anonymous user