Open main menu

Changes

Module:Protection banner

1,061 bytes removed, 23:48, 3 March 2014
add namespace parser
['pc-autoconfirmed-all-all-all'] = 'Wikipedia pending changes protected pages (level 1)',
['pc-reviewer-all-all-all'] = 'Wikipedia pending changes protected pages (level 2)',
}
 
local nskeys = {
[2] = 'user',
[3] = 'user',
[4] = 'project',
[6] = 'file',
[10] = 'template',
[12] = 'project',
[14] = 'category',
[100] = 'portal',
}
end
function p.matchCategoryparseNamespace(cats, protType, protLevel, namespace, expiry, reasonns) local function isValidCat(t) --[[ -- Does a first parse over The ns variable is the categories, removing any that explicitly -- name a wrong parameternamespace number. This accounts for the majority of all of the -- categories. -- -- We check the parameters most likely to be wrong first. This saves on -- table lookups, which shoud make the function faster. --]] local testType, testLevel, testNs, testExpiry, testReason testReason = t.reason if testReason and testReason ~= reason then return false end testNs = t.namespace if testNs and not testNs[namespace] then return false end testExpiry = t.expiry if testExpiry and testExpiry ~= expiry then return false end testLevel = t.level if testLevel and testLevel ~= protLevel then return false end testType = t.ns or type if testType and testType (ns) ~= protType 'number' then return false end return true'all'
end
  -- Remove invalid cats. local sortCats nskey = {}nskeys[ns] for i, t in ipairs(cats) do if isValidCat(t) not nskey and ns % 2 == 1 then sortCats[#sortCats + 1] nskey = t'talk' else endnskey = 'all'
end
return nskey
end
-- Sort the remaining function p.matchCategory(cats. -- The categories which are left either explicitly name the right parameter, -- or implicitly allow all values for that parameter. table.sort(sortCatsprotType, function (t1protLevel, t2) local type1 = t1.type local type2 = t2.type local level1 = t1.level local level2 = t2.level local ns1 = t1.namespace local ns2 = t2.namespace local exp1 = t1., expiry local exp2 = t2.expiry local reason1 = t1., reason) local reason2 nskey = t2p.reason  local score1 = 0 local score2 = 0 endparseNamespace(namespace)
end
return p
Anonymous user