Module:Protection banner: Difference between revisions

try a different category matching algorithm completely
(fix "Wikipedia protected categories" key)
(try a different category matching algorithm completely)
Line 136:
-- Define the key table and the order to test it in
local keyTable = {protType, protLevel, namespace, reason, expiry}
local tryOrderattemptOrder = {
{true, true, true, true, true},
if reason == 'vandalism' then
tryOrder = {5true, 4true, 3true, 2true, 1false},
{true, true, true, false, true},
else
tryOrder = {5true, 3true, 4false, 2true, 1true},
{true, true, true, false, false},
end
{true, true, false, true, false},
{true, true, false, false, true},
{true, true, false, false, false},
{true, false, false, false, false},
{false, false, false, false, false}
}
-- Try successively generic matches until we run out of key combinations
for i, keyTableKeyt in ipairs(tryOrderattemptOrder) do
local function attemptMatch()
local key = table.concat(keyTable, '-'){}
for j = 1, 5 do
return cats[key]
if attemptt[j] then
end
key[j] = keyTable[j]
local attempt = attemptMatch()
else
if attempt then
key[j] = 'all'
return attempt
end
end
for i, keyTableKey in ipairs(tryOrder) do
key = table.concat(key, '-')
keyTable[keyTableKey] = 'all'
local attempt = attemptMatch()cats[key]
if attempt then
return attempt