Module:Database report
Appearance
This module is used from {{Database report}}, {{Database report/subpage}} and {{Database report/footer}}.
local getArgs = require('Module:Arguments').getArgs
local p = {}
function p.main(frame)
local args = getArgs(frame)
return p.check_syntax(args)
end
local function error(text)
return '*' .. require('Module:Error').error{ 'Invalid config: ' .. text, tag = 'p' }
end
local function has_value(array, val)
for index, value in ipairs(array) do
if value == val then
return true
end
end
return false
end
local function get_namespaces(namespaces_list)
local list = {}
for token in string.gmatch(namespaces_list, "%d+") do
local ns_id = tonumber(token)
table.insert(list, ns_id ~= 0 and lowerfirst(mw.site.namespaces[ns_id]['name']) or 'main')
end
return table.concat(list, ', ')
end
function p.check_syntax(args)
-- check for invalid parameters
for param, value in pairs(args) do
if not has_value({'sql', 'wikilinks', 'excerpts', 'comments', 'widths', 'table_style', 'remove_underscores', 'update'}, param) then
return error('unknown parameter: ' .. param .. ' used')
end
end
-- check that required parameters are provided
if not args.sql then
return error('required parameters "bot" and/or "task" missing')
end
return ''
end
return p