Changes
Jump to navigation
Jump to search
else
nskey = 'all'
end
-- Preprocess parameters
local noActiveProperties = #activePropertyKeys -- Try successively generic matches until we run out of key combinations for i = 1, 2^noActiveProperties noActive do local categoryKey key = {} for j, t in ipairs(attemptOrder) do local pos = t.pos local val = 1, 5 dot.val if pos j > noActiveProperties noActive then categoryKeykey[pos] = 'all'
categoryKeykey[pos] = properties[activePropertyKeys[pos]]val else -- quotient % 2 == 0 categoryKeykey[pos] = 'all'
categoryKey key = tconcat(categoryKeykey, '-') mw.log(categoryKeykey) -- for debugging local attempt = cats[categoryKeykey]
key components are in the correct order now - property order still a long way off, though
local tconcat = table.concat
local tinsert = table.insert
local tremove = table.remove
local floor = math.floor
local function toTableEnd(t, pos)
-- Sends the item at position pos to the end of array t,
-- and shifts all the other array items down accordingly.
tinsert(t, tremove(t, pos))
end
local p = {}
-- namespace parameter of p.getCategoryName.
if not ns or type(ns) ~= 'number' then
return 'all'nil
end
local nskey = nskeys[ns]
if not nskey then if and ns % 2 == 1 then
nskey = 'talk'
end
return nskey
-- the protection type, the protection level, the namespace number, the
-- reason for protection, and the expiry date.
cats = cats or categories
local properties = { {pos = 5, val = expiry}, properties.protType {pos = 3, val = namespace}, {pos = 2, val = protLevel}, {pos = 1, val = protType or 'all'}, properties.protLevel {pos = 4, val = protLevel or 'all'reason} properties.namespace = p.matchNamespace(namespace)} properties.reason local behavior = reason or 'allreasonFirst' if not expiry reason then properties.expiry behavior = behaviors[reason] if behavior == 'allnamespaceFirst'then toTableEnd(properties, 2) -- move namespace to the end elseif expiry behavior ~= 'indefreasonFirst' then properties error(reason ..expiry = 'tempis not a valid reason') end
end
local order active, inactive = {'expiry'}, 'namespace', 'protLevel', 'protType', 'reason'{} local behavior = behaviorsfor i, t in ipairs(properties) do if t.val then active[reason#active + 1] if behavior == 'namespaceFirst' thent tinsert(order, table.remove(order, 2)) -- move namespace to the endelse elseif behavior ~ inactive[#inactive + 1] = 'reasonFirst' and reason ~= 'all' thent error(reason .. ' is not a valid reason')end
end
local noActive = #active
local activePropertyKeys attemptOrder = {}active for i, propertyKey t in ipairs(orderinactive) do if properties[propertyKey] ~= 'all' then activePropertyKeysattemptOrder[#activePropertyKeys attemptOrder + 1] = propertyKey endt
end
else
local quotient = i / 2 ^ (pos j - 1)
quotient = floor(quotient)
if quotient % 2 == 1 then
end
end
end
if attempt then
return attempt