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{ 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, ignoring')
end
end
-- check that required parameters are provided
if not args.sql then
return error('Invalid config: required parameter "sql" is missing')
end
return ''
end
return p