帮助:开发者文档:修订间差异

添加3,804字节 、​ 2020年11月10日 (星期二)
→‎mw.html.escape:​ // Edit via Wikiplus
(.)
→‎mw.html.escape:​ // Edit via Wikiplus
 
(未显示3个用户的4个中间版本)
{{不完整|一晚上就搬完不可能的|只翻译了一半}}
{{施工中|3小时}}
{{不完整|一晚上就搬完不可能的}}
{{帮助文档难度/困难}}
{{浮动帮助菜单}}
其中大部分以 '''wg''' 为前缀。
 
* For legacy reasons these names are exposed as global JavaScript variables 因为历史原因,这些变量是全局的js变量。若<code>$wgLegacyJavaScriptGlobals</code>为真,所以需要一个前缀以防变量名冲突。
* A subset of these names correspond to $wg_variable in PHP, but others are unrelated.
* 除了本列表中的名字意外,很多扩展还设置了额外的以wg开头的js配置变量。
* Besides the names in this list, many extensions also set additional JavaScript config variables prefixed with 'wg'.
 
你可以通过<code>mw.config</code>来访问这些值。
|valign="top"|<code>wgArticlePath</code>
|valign="top"|字符串
|valign="top"| Local path从根目录开始的本地路径, starting at the root, to reference articles, containing a "用于引用文章。含有一个“$1" placeholder that may be replaced by a page title to get a valid 1”占位符,可以用页面标题替换来获取一个有效的页面URL to that page. Given a valid page title 。给定有效的页面标题<code>title</code>, a valid URL may be constructed using 可以用<code>wgArticlePath.replace('$1', title)</code>. See also 获取有效URL。另见$wgArticlePath.
|valign="top"|MW 1.8+
|-
|valign="top"|<code>wgCaseSensitiveNamespaces</code>
|valign="top"|数组
|valign="top"| The IDs of the namespaces treated as case-sensitive by MediaWiki. Determined by the values of them 中对大小写敏感的命名空间的ID。由<code>$wgCapitalLinks</code> and <code>$wgCapitalLinksOverrides</code> configuration variables.这两个配置变量的值决定。<!-- I'm assuming; it would be good to have someone confirm this -->
|valign="top"|MW 1.18+ (90234)
|-
|valign="top"|<code>wgContentNamespaces</code>
|valign="top"|整数数组
|valign="top"| The IDs of the namespaces considered "content namespaces" by MediaWiki. Equivalent to the value of the 看作是“内容名字空间”的名字空间ID。和配置变量<code>$wgContentNamespaces</code> configuration variable,的值等价, 没有加载好的话就是<code>0</code>。
|valign="top"|MW 1.23+ <small>(Git: 3d87e3a86bcb39d444ef916129dd48bf80b5bb31)</small>
|-
|valign="top"|<code>wgEnableWriteAPI</code>
|valign="top"|布尔型
|valign="top"|如果mw的写入API启用则为<code>true</code>,反之为<code>false</code>。If 如果<code>wgEnableAPI && !wgEnableWriteAPI</code>, only the read operations of the 只有读取API are enabled.会被启用。
|valign="top"|MW 1.12+
|-
|valign="top"|<code>wgScript</code>
|valign="top"|字符串
|valign="top"| Full path to the main access point script, starting at the root, including the full script name with extension. On 到达主要脚本接入点的完全路径,从根部开始。包括带着扩展名的脚本名。在WMF wikis, normally Wiki上,一般是"/w/index.php". See also 。另见$wgScript.
|valign="top"|MW 1.11+
|-
|valign="top"|<code>wgScriptPath</code>
|valign="top"|字符串
|valign="top"|<code>wgScript</code>的路径部分,结尾不是"/"。This is the path to use for direct calls to the 这是用于直接调用php access points such as 接入点(如<code>index.php</code> <code>api.php</code>. See also )的路径。另见$wgScriptPath.
|valign="top"|MW 1.8+
|-
|valign="top"|<code>wgServer</code>
|valign="top"|字符串
|valign="top"|服务器链接,结尾不是"/"。The combination <code>wgServer + wgScriptPath + "/api.php"</code>, for instance, results in a valid 。比如说,可以得到API脚本接入点的合法URL to the API access point script.
|valign="top"|MW 1.8+
|-
 
== mw.html ==
=== mw.html.escape ===
HTML转义。
<pre>mw.html.escape( '< > \' & "' ); // Returns: &amp;lt; &amp;gt; &amp;#039; &amp;amp; &amp;quot;</pre>
 
== mw.msg ==
 
== mw.loader ==
=== mw.loader.addSource ===
 
== mw.user ==
* 需要实例化才能使用。
* 大部分需要导入额外的JS才能使用。
=== plugins ===
* 需要导入对应的JS才能正常使用。
* '''混入的是mw.Api。'''
; .category
: [https://doc.wikimedia.org/mediawiki-core/master/js/source/category.html#mw-Api-plugin-category 文件]
: getCategories( title : mw.Title|string ) : jQuery.Promise
:: 获取页面的分类列表
:: 返回 jQuery.Promise
::: done : Function : boolean|mw.Title[]
:: 若没有分类,返回false
: getCategoriesByPrefix( prefix : string ) : jQuery.Promise
:: 获取以此为前缀的分类
:: 返回 jQuery.Promise
::: done : Function : string[]
:: 返回获取到的分类名
: isCategory( title : string ) : jQuery.Promise
:: 检查某个分类是否存在
:: 返回 jQuery.Promise
::: done : Function : boolean
:: 存在返回true,否则返回false
 
; .edit
: [https://doc.wikimedia.org/mediawiki-core/master/js/source/edit.html#mw-Api-plugin-edit 文件]
: create( title : mw.Title|string , params : Object , content : string ) : jQuery.Promise
:: params : {summary : string}
::: summary: 描述
:: 返回 jQuery.Promise
::: done : Function : void
: edit( title : mw.Title|string , transform : Function ) : jQuery.Promise
::
: getEditToken( ) : jQuery.Promise
::
: newSection( title, header, message, [additionalParams] ) : jQuery.Promise
::
: postWithEditToken( params, [ajaxOptions] ) : jQuery.Promise
::
 
; .login
: [https://doc.wikimedia.org/mediawiki-core/master/js/source/login.html#mw-Api-plugin-login 文件]
: login( username, password ) : jQuery.Promise
 
; .messages
: [https://doc.wikimedia.org/mediawiki-core/master/js/source/messages.html#mw-Api-plugin-messages 文件]
: getMessages( messages, [options] ) : jQuery.Promise
::
: loadMessages( messages, [options] ) : jQuery.Promise
::
: loadMessagesIfMissing( messages, [options] ) : jQuery.Promise
::
 
; .options
: [https://doc.wikimedia.org/mediawiki-core/master/js/source/options.html#mw-Api-plugin-options 文件]
: saveOption( name, value ) : jQuery.Promise
::
: saveOptions( options ) : jQuery.Promise
 
; .parse
: [https://doc.wikimedia.org/mediawiki-core/master/js/source/parse.html#mw-Api-plugin-parse 文件]
: parse( content, additionalParams ) : jQuery.Promise
 
; .rollback
: [https://doc.wikimedia.org/mediawiki-core/master/js/source/rollback.html#mw-Api-plugin-rollback 文件]
: rollback( page, user, [params] ) : jQuery.Promise
 
; .upload
: [https://doc.wikimedia.org/mediawiki-core/master/js/source/upload.html#mw-Api-plugin-upload 文件]
: chunkedUpload( file, data, [chunkSize], [chunkRetries] ) : jQuery.Promise
::
: chunkedUploadToStash( file, [data], [chunkSize], [chunkRetries] ) : jQuery.Promise
::
: processIframeResult( iframe ) : Object
::
: upload( file, data ) : jQuery.Promise
::
: uploadFromStash( filekey, data ) : jQuery.Promise
::
: uploadToStash( file, [data] ) : jQuery.Promise
::
 
; .user
: [https://doc.wikimedia.org/mediawiki-core/master/js/source/user.html#mw-Api-plugin-user 文件]
: assertCurrentUser( query ) : Object
::
: getUserInfo( ) : jQuery.Promise
::
 
; .watch
: [https://doc.wikimedia.org/mediawiki-core/master/js/source/watch.html#mw-Api-plugin-watch 文件]
: unwatch( pages, [addParams] ) : jQuery.Promise
::
: watch( pages, [addParams] ) : jQuery.Promise
::
 
== mw.Debug ==
: 创建或修改一个或多个键值。
=== mw.ui ===
* MCBBSWiki似乎没这个。
** 在MediaWiki1.29后mw.ui完全废弃了,改为使用[[#OOui]]。
=== mw.Title ===
结构页面标题。
* MCBBSWiki似乎没这个。
<pre>
new mw.Uri(); // 当前URI
new mw.Uri(URL); // 指定URL的URI
</pre>
=== mw.notify ===
</pre>
== jQuery与插件 ==
 
== OOui ==
使用这些特性之前,需要导入[https://doc.wikimedia.org/oojs-ui/master/js/source/core.html OOui核心]。
; OO.EmitterList
:
; OO.EventEmitter
:
; OO.Factory
:
; OO.Registry
:
; OO.SortedEmitterList
:
=== OO.ui ===
需要导入[https://doc.wikimedia.org/oojs-ui/master/js/source/windows.html#OO-ui Windows扩展]。
 
 
== OOui混入 ==
使用这些特性之前,需要导入[https://doc.wikimedia.org/oojs-ui/master/js/source/core.html OOui核心]和[https://doc.wikimedia.org/oojs-ui/master/js/source/windows.html#OO-ui Windows扩展]。