Module:Lockbox

local export = {}

function export.lock(frame) local output = {} -- check if the current page is cascade-protected -- XXX: unfortunately there is no other way; title.protectionLevels does not report cascading protection status mw.title.getCurrentTitle:getContent -- self-transclude; see mw:Extension:Scribunto/Lua reference manual if frame:preprocess "" == "" then table.insert(output, ' Warning: this page (' .. mw.title.getCurrentTitle.fullText .. ') is not cascade-protected. \n') end local match = string.match local args = { }

for _, item in ipairs(frame.args) do		item = mw.text.trim(item) local ns = match(item, "^(.-):") if not ns or not mw.site.namespaces[ns] then mw.title.makeTitle('Template', item):getContent table.insert(output, '* Template:' .. item .. '\n') elseif (ns == "File") or (ns == "Image") then local _ = mw.title.makeTitle('File', item).fileExists table.insert(output, '* ' .. item .. '\n') elseif ns == "Category" then mw.title.makeTitle('Category', item):getContent table.insert(output, '* ' .. item .. '\n') else mw.title.makeTitle(item):getContent table.insert(output, '* ' .. item .. '\n') end end

if frame.args.silent then return "" else return table.concat(output) end end

return export