Jump to content
Main menu
Main menu
move to sidebar
hide
Navigation
Main page
Recent changes
Random page
Help about MediaWiki
Micro Pedia
Search
Search
Appearance
Create account
Log in
Personal tools
Create account
Log in
Pages for logged out editors
learn more
Contributions
Talk
Editing
Module:Submit an edit request
Module
Discussion
English
Read
Edit
View history
Tools
Tools
move to sidebar
hide
Actions
Read
Edit
View history
General
What links here
Related changes
Special pages
Page information
Get shortened URL
Appearance
move to sidebar
hide
Warning:
You are not logged in. Your IP address will be publicly visible if you make any edits. If you
log in
or
create an account
, your edits will be attributed to your username, along with other benefits.
The edit appears to have already been undone.
Anti-spam check. Do
not
fill this in!
-- This module implements {{Submit an edit request}}. local CONFIG_MODULE = 'Module:Submit an edit request/config' -- Load necessary modules local mRedirect = require('Module:Redirect') local cfg = mw.loadData(CONFIG_MODULE) local effectiveProtectionLevel = require('Module:Effective protection level')._main local escape = require("Module:String")._escapePattern local lang = mw.language.getContentLanguage() local p = {} local validLevels = { semi = 'semi', extended = 'extended', template = 'template', full = 'full', interface = 'interface', manual = 'manual' } 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 local function validateLevel(level) return level and validLevels[level] or 'full' end local function getLevelInfo(level, field) return cfg.protectionLevels[level][field] end local function resolveRedirect(page) return mRedirect.luaMain(page) end local function isProtected(page) local action = mw.title.new(page).exists and 'edit' or 'create' return effectiveProtectionLevel(action, page) ~= '*' end function p.makeRequestUrl(level, titleObj) titleObj = titleObj or mw.title.getCurrentTitle() local basePage = titleObj.basePageTitle.fullText if cfg['main-page-content'][basePage] then return tostring(mw.uri.fullUrl(message('main-page-request-page'))) end local talkPageName = titleObj.talkPageTitle if talkPageName == nil then return tostring(mw.uri.fullUrl(message('protected-talk-page-request-page'))) end talkPageName = resolveRedirect(talkPageName.prefixedText) if isProtected(talkPageName) then return tostring(mw.uri.fullUrl(message('protected-talk-page-request-page'))) end level = validateLevel(level) if level == 'manual' then return tostring(mw.uri.fullUrl(talkPageName, { action = 'edit', section = 'new' })) end local sectionname = message( 'preload-title-text', getLevelInfo(level, 'levelText'), lang:formatDate(message('preload-title-date-format')) ) local content = mw.title.new(talkPageName):getContent() if content and content:find("== *" .. escape(sectionname) .. " *==") then local dedup = 2 while true do local newname = message("preload-title-dedup-suffix", sectionname, dedup) if not content:find("== *" .. escape(newname) .. " *==") then sectionname = newname break end dedup = dedup + 1 end end local url = mw.uri.fullUrl(talkPageName, { action = 'edit', editintro = getLevelInfo(level, 'editintro'), preload = message('preload-template'), preloadtitle = sectionname, section = 'new' }) url = tostring(url) -- Add the preload parameters. @TODO: merge this into the mw.uri.fullUrl -- query table once [[phab:T93059]] is fixed. local function encodeParam(key, val) return string.format('&%s=%s', mw.uri.encode(key), mw.uri.encode(val)) end url = url .. encodeParam('preloadparams[]', getLevelInfo(level, 'requestTemplate')) url = url .. encodeParam('preloadparams[]', titleObj.prefixedText) return url end function p._link(args) return string.format( '<span class="plainlinks">[%s %s]</span>', p.makeRequestUrl(args.type), args.display or message('default-display-value') ) end function p._button(args) return require('Module:Clickable button 2').main{ [1] = args.display or message('default-display-value'), url = p.makeRequestUrl(args.type), class = 'mw-ui-progressive' } end local function makeInvokeFunc(func, wrapper) return function (frame) local args = require('Module:Arguments').getArgs(frame, { wrappers = {wrapper} }) return func(args) end end p.link = makeInvokeFunc(p._link, message('link-wrapper-template')) p.button = makeInvokeFunc(p._button, message('button-wrapper-template')) return p
Summary:
Please note that all contributions to Micro Pedia may be edited, altered, or removed by other contributors. If you do not want your writing to be edited mercilessly, then do not submit it here.
You are also promising us that you wrote this yourself, or copied it from a public domain or similar free resource (see
Micro Pedia:Copyrights
for details).
Do not submit copyrighted work without permission!
Cancel
Editing help
(opens in new window)
Template used on this page:
Module:Submit an edit request/doc
(
edit
)