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: | Line 136: | ||
-- Define the key table and the order to test it in | -- Define the key table and the order to test it in | ||
local keyTable = {protType, protLevel, namespace, reason, expiry} | local keyTable = {protType, protLevel, namespace, reason, expiry} | ||
local | local attemptOrder = { | ||
{true, true, true, true, true}, | |||
{true, true, true, true, false}, | |||
{true, true, true, false, true}, | |||
{true, true, false, true, true}, | |||
{true, true, true, false, false}, | |||
{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 | -- Try successively generic matches until we run out of key combinations | ||
for i, t in ipairs(attemptOrder) do | |||
local key = | local key = {} | ||
for j = 1, 5 do | |||
if t[j] then | |||
key[j] = keyTable[j] | |||
else | |||
key[j] = 'all' | |||
end | |||
end | |||
key = table.concat(key, '-') | |||
attempt = | local attempt = cats[key] | ||
if attempt then | if attempt then | ||
return attempt | return attempt |