Module:Submit an edit request

-- This module implements.

local cfg = {}

cfg['preload-template'] = 'Template:Submit an edit request/preload' cfg['preload-title-text'] = '$1 edit request on $2' cfg['preload-title-date-format'] = 'j F Y'

cfg['semi-editintro'] = 'Template:Edit semi-protected/editintro' cfg['semi-request-template'] = 'edit semi-protected' cfg['semi-protectionlevel'] = 'Semi-protected'

cfg['template-editintro'] = 'Template:Edit template-protected/editintro' cfg['template-request-template'] = 'edit template-protected' cfg['template-protectionlevel'] = 'Template-protected'

cfg['full-editintro'] = 'Template:Edit protected/editintro' cfg['full-request-template'] = 'edit protected' cfg['full-protectionlevel'] = 'Protected'

local mRedirect = require('Module:Redirect')

local p = {}

local function message(key, ...) local params = {...} local msg = cfg[key] if #params < 1 then return msg else return mw.message.newRawMessage(msg):params(params):plain end end

function p.makeRequestUrl(level, titleObj) titleObj = titleObj or mw.title.getCurrentTitle local editintro, requestTemplate, levelText do local messages = { semi = { editintro = 'semi-editintro', requestTemplate = 'semi-request-template', protectionLevel = 'semi-protectionlevel' },			template = { editintro = 'template-editintro', requestTemplate = 'template-request-template', protectionLevel = 'template-protectionlevel' },			full = { editintro = 'full-editintro', requestTemplate = 'full-request-template', protectionLevel = 'full-protectionlevel' }		}		local levelMessages = messages[level] editintro = message(levelMessages.editintro) requestTemplate = message(levelMessages.requestTemplate) levelText = message(levelMessages.levelText) end local preloadtitle, talkpagename do -- Get the date text. local dateFormat = message('preload-title-date-format') local lang = mw.language.getContentLanguage local date = lang:formatDate(dateFormat) -- Get the talk page name, and resolve it if it is a redirect. local namespace = titleObj.namespace if namespace % 2 == 0 then namespace = namespace + 1 end talkpagename = mw.site.namespaces[namespace].name .. titleObj.text talkpagename = mRedirect.main{talkpagename} preloadtitle = message('preload-title-text', talkpagename, date) end local preloadTemplate = message('preload-template') local function encode(key, value) local ret = key .. '=' .. value return mw.uri.encode(ret) end

local query = {} query[#query + 1] = 'action=edit' query[#query + 1] = encode('preload', preloadTemplate) query[#query + 1] = encode('editintro', editintro) query[#query + 1] = encode('preloadparams[]', requestTemplate) query[#query + 1] = encode('preloadtitle', preloadtitle) query[#query + 1] = encode('preloadparams[]', titleObj.prefixedText) local url = mw.uri.fullUrl(talkpagename, table.concat(query, '&')) return tostring(url) end

return p