Anonymous user
Module:Protection banner: Difference between revisions
finish converting p.getCategoryName
Enwikipedia>Mr. Stradivarius (start converting the getCategoryName function) |
Enwikipedia>Mr. Stradivarius (finish converting p.getCategoryName) |
||
Line 224:
local ProtectionCategory = Category:subclass('ProtectionCategory')
function ProtectionCategory:setName(
name,
configObj,
protectionStatusObj,
namespace
)▼
--[[
-- Sets the protection category. If a category name is not provided, this
Line 231 ⟶ 236:
-- reason for protection, and the expiry date.
--]]
local cats = configObj:getConfigTable('categories')▼
-- If a name was provided, use that.
Category.setName(self, name)
end▼
-- Get the namespace category key from the namespace number.
Line 253 ⟶ 262:
--]]
local properties = {
expiry = {order = 1, keypos = 5, val =
namespace = {order = 2, keypos = 3, val = nskey},
reason = {order = 3, keypos = 4, val =
level = {order = 4, keypos = 2, val =
action = {order = 5, keypos = 1, val =
}
--[[
--
-- will be a property string, e.g. 'reason', 'namespace', etc. The property
--
-- important, because it keeps its specified value the longest) and the
-- other properties are tested in the canonical order. If
--
--]]
local categoryOrder = reasonTable and reasonTable.categoryOrder▼
local configOrder = {}
do
local bannerConfig = configObj:getBannerConfig(protectionStatusObj)
error(msg)▼
end▼
if not property then▼
end▼
else▼
else▼
for propertiesKey, t in pairs(properties) do
configOrder[t.order] = t
end
if
local property = properties[categoryOrder]
if not property then
Line 321 ⟶ 294:
error(msg)
end
end
end
Line 333 ⟶ 306:
-- parameter.
--]]
local
do
for i, t in ipairs(configOrder) do▼
local active, inactive = {}, {}
▲ if t.val then
active[#active + 1] = t▼
▲ else
▲ end
attemptOrder[#attemptOrder + 1] = t▼
end
▲ end
▲ local noActive = #active
▲ local attemptOrder = active
▲ for i, t in ipairs(inactive) do
▲ attemptOrder[#attemptOrder + 1] = t
end
Line 379 ⟶ 355:
-- pos field in the property table.
--]]
▲ local cats = configObj:getConfigTable('categories')
local cat
for i = 1, 2^noActive do
local key = {}
Line 397 ⟶ 375:
local attempt = cats[key]
if attempt then
break
end
end
if cat then
Category.setName(self, cat)
'No category match found;'▼
▲ else
.. ' please define the category for key "all-all-all-all-all"'▼
▲ )
▲ 'No category match found;'
▲ .. ' please define the category for key "all-all-all-all-all"'
)
end
|