Module:Lua banner: Difference between revisions
Jump to navigation
Jump to search
Content added Content deleted
m (1 revision imported) |
(Putting that logic in the correct place) |
||
Line 74: | Line 74: | ||
if titleObj.namespace == 10 |
if titleObj.namespace == 10 |
||
and not subpageBlacklist[titleObj.subpageText] |
and not subpageBlacklist[titleObj.subpageText] |
||
⚫ | |||
then |
then |
||
local category = args.category |
local category = args.category |
||
Line 89: | Line 88: | ||
end |
end |
||
cats[#cats + 1] = category |
cats[#cats + 1] = category |
||
⚫ | |||
local protLevels = { |
|||
local protLevels = { |
|||
autoconfirmed = 1, |
|||
extendedconfirmed = 2, |
|||
templateeditor = 3, |
|||
sysop = 4 |
|||
} |
} |
||
local currentProt |
local currentProt |
||
if titleObj.id ~= 0 then |
if titleObj.id ~= 0 then |
||
-- id is 0 (page does not exist) if am previewing before creating a template. |
-- id is 0 (page does not exist) if am previewing before creating a template. |
||
currentProt = titleObj.protectionLevels["edit"][1] |
currentProt = titleObj.protectionLevels["edit"][1] |
||
end |
end |
||
if currentProt == nil then currentProt = 0 else currentProt = protLevels[currentProt] end |
if currentProt == nil then currentProt = 0 else currentProt = protLevels[currentProt] end |
||
for i, module in ipairs(modules) do |
for i, module in ipairs(modules) do |
||
local moduleProt = mw.title.new(module).protectionLevels["edit"][1] |
|||
local moduleProt = mw.title.new(module).protectionLevels["edit"][1] |
|||
if moduleProt |
if moduleProt == nil then moduleProt = 0 else moduleProt = protLevels[moduleProt] end |
||
if moduleProt < currentProt then |
|||
cats[#cats + 1] = "Templates using under-protected Lua modules" |
cats[#cats + 1] = "Templates using under-protected Lua modules" |
||
break |
break |
||
end |
|||
end |
end |
||
end |
end |
||
end |
end |
||
for i, cat in ipairs(cats) do |
for i, cat in ipairs(cats) do |
||
cats[i] = string.format('[[Category:%s]]', cat) |
cats[i] = string.format('[[Category:%s]]', cat) |