Module:Protection banner: Difference between revisions

add category sort keys
m (fix cfg field name)
(add category sort keys)
Line 16: Line 16:
--------------------------------------------------------------------------------
--------------------------------------------------------------------------------


local function makeCategoryLink(cat)
local function makeCategoryLink(cat, sort)
if cat then
local nsText = mw.site.namespaces[14].name
if cat and sort then
return string.format(
'[[%s:%s|%s]]',
nsText,
cat,
sort
)
elseif cat then
return string.format(
return string.format(
'[[%s:%s]]',
'[[%s:%s]]',
mw.site.namespaces[14].name,
nsText,
cat
cat
)
)
Line 293: Line 301:
local attempt = cats[key]
local attempt = cats[key]
if attempt then
if attempt then
return makeCategoryLink(attempt)
return makeCategoryLink(attempt, title.text)
end
end
end
end
Line 330: Line 338:
local ret = { self:makeProtectionCategory() }
local ret = { self:makeProtectionCategory() }
if self:needsExpiry() then
if self:needsExpiry() then
ret[#ret + 1] = makeCategoryLink(msg['tracking-category-expiry'])
ret[#ret + 1] = makeCategoryLink(
msg['tracking-category-expiry'],
self.title.text
)
end
end
if self:isIncorrect() then
if self:isIncorrect() then
ret[#ret + 1] = makeCategoryLink(msg['tracking-category-incorrect'])
ret[#ret + 1] = makeCategoryLink(
msg['tracking-category-incorrect'],
self.title.text
)
end
end
if self:isTemplateProtectedNonTemplate() then
if self:isTemplateProtectedNonTemplate() then
ret[#ret + 1] = makeCategoryLink(msg['tracking-category-template'])
ret[#ret + 1] = makeCategoryLink(
msg['tracking-category-template'],
self.title.text
)
end
end
return table.concat(ret)
return table.concat(ret)
Line 817: Line 834:
'<strong class="error">%s</strong>%s',
'<strong class="error">%s</strong>%s',
errorText,
errorText,
makeCategoryLink(cfg.msg['tracking-category-incorrect'])
makeCategoryLink(
cfg.msg['tracking-category-incorrect'],
title and title.text or mw.title.getCurrentTitle().text
)
)
)
end
end