Movatterモバイル変換


[0]ホーム

URL:


Jump to content
WikipediaThe Free Encyclopedia
Search

Module:Submit an edit request

Permanently protected module
From Wikipedia, the free encyclopedia
Module documentation[view] [edit] [history] [purge]
WarningThis Lua module is used in system messages.
Changes to it can cause immediate changes to the Wikipedia user interface.
To avoid major disruption, any changes should be tested in the module's/sandbox or/testcases subpages, or in your ownmodule sandbox. The tested changes can be added to this page in a single edit. Please discuss changes on thetalk page before implementing them.
This module depends on the following other modules:

This module implements the{{submit an edit request}} and{{submit an edit request/link}} templates.

Usage from wikitext

To use this module from wikitext, you should normally use the{{Submit an edit request}} and{{Submit an edit request/link}} templates. However, the module can also be used directly from #invoke. For the edit request button, use{{#invoke:Submit an edit request|button|args}}, and for the edit request link only, use{{#invoke:Submit an edit request|link|args}}. Please see the respective template pages for a list of available parameters.

Usage from Lua modules

To use this module from other Lua modules, first load the module.

localmEditRequest=require('Module:Submit an edit request')

You can then use the _button function to generate an edit request button, and the _link function to generate an edit request link.

mEditRequest._button(args)mEditRequest._link(args)

Theargs variable should be a table containing the arguments to pass to the module. To see the different arguments that can be specified and how they affect the module output, please refer to the documentation of{{Submit an edit request}} and{{Submit an edit request/link}}.

Configuration

This module can be translated and configured for other wikis by editingModule:Submit an edit request/config.

The abovedocumentation istranscluded fromModule:Submit an edit request/doc.(edit |history)
Editors can experiment in this module'ssandbox(edit |diff) and testcases(create) pages.
Subpages of this module.

-- This module implements {{Submit an edit request}}.localCONFIG_MODULE='Module:Submit an edit request/config'-- Load necessary moduleslocalmRedirect=require('Module:Redirect')localcfg=mw.loadData(CONFIG_MODULE)localeffectiveProtectionLevel=require('Module:Effective protection level')._mainlocalescape=require("Module:String")._escapePatternlocallang=mw.language.getContentLanguage()localp={}localvalidLevels={semi='semi',extended='extended',template='template',full='full',interface='interface',manual='manual'}localfunctionmessage(key,...)localparams={...}localmsg=cfg[key]if#params<1thenreturnmsgelsereturnmw.message.newRawMessage(msg):params(params):plain()endendlocalfunctionvalidateLevel(level)returnlevelandvalidLevels[level]or'full'endlocalfunctiongetLevelInfo(level,field)returncfg.protectionLevels[level][field]endlocalfunctionresolveRedirect(page)returnmRedirect.luaMain(page)endlocalfunctionisProtected(page)localaction=mw.title.new(page).existsand'edit'or'create'returneffectiveProtectionLevel(action,page)~='*'endfunctionp.makeRequestUrl(level,titleObj)titleObj=titleObjormw.title.getCurrentTitle()localbasePage=titleObj.basePageTitle.fullTextifcfg['main-page-content'][basePage]thenreturntostring(mw.uri.fullUrl(message('main-page-request-page')))endlocaltalkPageName=titleObj.talkPageTitleiftalkPageName==nilthenreturntostring(mw.uri.fullUrl(message('protected-talk-page-request-page')))endtalkPageName=resolveRedirect(talkPageName.prefixedText)ifisProtected(talkPageName)thenreturntostring(mw.uri.fullUrl(message('protected-talk-page-request-page')))endlevel=validateLevel(level)iflevel=='manual'thenreturntostring(mw.uri.fullUrl(talkPageName,{action='edit',section='new'}))endlocalsectionname=message('preload-title-text',getLevelInfo(level,'levelText'),lang:formatDate(message('preload-title-date-format')))localcontent=mw.title.new(talkPageName):getContent()ifcontentandcontent:find("== *"..escape(sectionname).." *==")thenlocaldedup=2whiletruedolocalnewname=message("preload-title-dedup-suffix",sectionname,dedup)ifnotcontent:find("== *"..escape(newname).." *==")thensectionname=newnamebreakenddedup=dedup+1endendlocalurl=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.localfunctionencodeParam(key,val)returnstring.format('&%s=%s',mw.uri.encode(key),mw.uri.encode(val))endurl=url..encodeParam('preloadparams[]',getLevelInfo(level,'requestTemplate'))url=url..encodeParam('preloadparams[]',titleObj.prefixedText)returnurlendfunctionp._link(args)returnstring.format('<span class="plainlinks">[%s %s]</span>',p.makeRequestUrl(args.type),args.displayormessage('default-display-value'))endfunctionp._button(args)returnrequire('Module:Clickable button').main{[1]=args.displayormessage('default-display-value'),url=p.makeRequestUrl(args.type),class='mw-ui-progressive'}endlocalfunctionmakeInvokeFunc(func,wrapper)returnfunction(frame)localargs=require('Module:Arguments').getArgs(frame,{wrappers={wrapper}})returnfunc(args)endendp.link=makeInvokeFunc(p._link,message('link-wrapper-template'))p.button=makeInvokeFunc(p._button,message('button-wrapper-template'))returnp
Retrieved from "https://en.wikipedia.org/w/index.php?title=Module:Submit_an_edit_request&oldid=1263420381"
Hidden category:

[8]ページ先頭

©2009-2025 Movatter.jp