扩展:输入框
InputBox 发布状态: 稳定版 |
|
---|---|
![]() |
|
实现 | 标签 , 页面操作 , 搜索 |
描述 | 允许编辑者在页面中添加预置的HTML表格 |
作者 |
|
最新版本 | Continuous updates |
MediaWiki | 1.30+ |
数据庫更改 | 否 |
许可协议 | MIT授權條款 |
下载 | |
* <inputbox> |
|
翻譯InputBox擴充功能如在translatewiki.net可用 | |
问题 | 尚未完成的工作 · 回報錯誤 |
InputBox扩展已经创造了HTML表单维基页面。 用户可以通过将文本输入框中“完成”表单(输入文本、选择菜单项等)。
InputBox最初是由Erik Möller为在维基新闻中加入创建条目框的目的而创建的。
安装
- 下载文件,并将其放置在您
extensions/
文件夹中的InputBox
目录内。 - 将下列代码放置在您的LocalSettings.php的底部:
wfLoadExtension( 'InputBox' );
- 完成 – 在您的wiki上导航至Special:Version,以验证扩展已成功安装。
致使用MediaWiki 1.24或更早版本的用户:
上面的说明介绍的是安装此扩展的新方法,它使用wfLoadExtension()
。
如果您需要在早期版本(MediaWiki 1.24和更早版本)中安装此扩展,而不是wfLoadExtension( 'InputBox' );
,您需要使用:
require_once "$IP/extensions/InputBox/InputBox.php";
示例
开始新条目的盒子。
Wiki代码
<inputbox> type=create break=no </inputbox>
输出结果
常见问题
输入框像这样子构造
<inputbox>
type=
bgcolor=
width=
page=
default=
preload=
editintro=
buttonlabel=
hidden=
searchbuttonlabel=
fulltextbutton=
labeltext=
break=
namespaces=
prefix=
placeholder=
minor=
nosummary=
summary=
id=
inline=
dir=
preloadparams[]=
searchfilter=
useve=
arialabel=
</inputbox>
|
type参数必须输入。 而其他所有参数均为可选。 preloadparams[]可以出现不止一次。
输入框类型
默认情况下提交按钮位于输入框的下面。
The “提交” button can be moved to the right by using the line break parameter to eliminate the line break between the box and the button: break=no
.
Having the “提交” button to the right is useful for search boxes when search suggestions would otherwise cover up a search button below the search box.
类型 | 例子 | 描述 |
---|---|---|
type=search | 创建的搜索框的默认宽度为50字符。 Information added in the text box is searched for. | |
type=create | 创建新页面。 Information added in the text box is the name of the page which is edited. | |
type=comment | Adds a new section to the bottom of the page specified in the text box. | |
type=commenttitle | Adds a new section with the section header typed into the text box. The title can be specified with default= parameter. The page has to be specified with page= parameter. (引入 自 rev:47203)
| |
type=fulltext | Search only with the fulltext search button, without the “前往” button. (引入 自 rev:45269) | |
type=move | 将页面移动至另一个名字。 (引入 自 gerrit:97559) |
For type=search2
, the default location for the search button is to the right.
目前,似乎无法将其他参数添加到这种类型的输入框中。
This search box searches the entire wiki that it is placed on.
类型 | 例子 |
---|---|
type=search2 |
参数
参数 | 描述 | 适用范围 | 兼容性 | 例子 | 结果 | |
---|---|---|---|---|---|---|
arialabel= | Supply the aria-label attribute to the inputbox to allow generated markup be accessible to screen readers | All types |
|
<inputbox> type=search arialabel=Search the Wiki </inputbox> |
||
bgcolor= | Sets the table background color (HTML color values). Do not use quotes. | 所有类型 | ? | <inputbox> type=search bgcolor=#eeeeff </inputbox> |
||
width= | 设置输入框的宽度,单位为字符。 | 所有类型 | ? | <inputbox> type=create width=24 </inputbox> |
||
default= | Default text to put in the InputBox. | 所有类型 | ? | <inputbox> type=comment default=User talk:Eloquence </inputbox> |
||
preload= | The page under this title will be preloaded (see Manual:Creating pages with preloaded text ) into the blank editbox when a new page is created. | create, comment, commenttitle | ? | <inputbox> type=create preload=Log </inputbox> |
||
Enter the title of a non-existent page in the example InputBox above or below, and click "创建页面" or "新段落" respectively to test this effect. | ||||||
editintro= | The page which is given under this parameter will be shown, as instructions, above the editing window. | create, comment | ? | <inputbox> type=comment editintro=MediaWiki:Missingcommenttext </inputbox> |
||
buttonlabel= | This label will be used for the main button of the form. | 所有类型 | ? | <inputbox> type=comment buttonlabel=Add new rumor </inputbox> |
||
hidden= | This specifies that there is no InputBox. It is used with parameter "default", now not being a default, but the fixed value of the name of the page. |
create, comment | ? | <inputbox> type=comment editintro=Extension:InputBox/editintro comment preload=Extension:InputBox/preload hidden=yes default=Extension talk:InputBox buttonlabel=Post a comment on the talk page </inputbox> |
||
searchbuttonlabel= | This label will be used for the "Search full text" button of the search form. | search, fulltext | ? | <inputbox> type=search searchbuttonlabel=Dig deeper </inputbox> |
||
fulltextbutton= | Show the full text search button on search2 form | search2 | ? | <inputbox> type=search2 searchbuttonlabel=Dig deeper fulltextbutton=true </inputbox> |
||
labeltext= | Text to print beside the button | search2 | ? | <inputbox> type=search2 searchbuttonlabel=Dig deeper labeltext=Look for: </inputbox> |
||
break= | Whether or not to insert a line break between the input box and the button(s). Defaults to yes (use a line break). | 所有类型 | ? | <inputbox> type=create width=24 break=no </inputbox> |
||
namespaces= | Support for namespace checkboxes in fulltext search. With " |
search, fulltext | ? | <inputbox> type=search namespaces=Main**,Help </inputbox> |
||
prefix= |
Remark: underscores aren't recognized as spaces. |
search, fulltext, create | ? | <inputbox> type=search prefix={{FULLPAGENAME}}/Archive </inputbox> |
The button below prefixes the name with | |
placeholder= | Define placeholder text that will display in the input box when it is empty. | 所有类型 |
|
<inputbox> type=search placeholder=Search this Wiki </inputbox> |
||
page= | Page to posts comment to, or page to move. | comment, move | <inputbox> type=comment page=Project:Sandbox </inputbox> |
|||
minor= | 小编辑。 | comment, create | <inputbox> type=comment page=Project:Sandbox minor=true </inputbox> |
|||
nosummary= | Edit summary (headline) not required for new comment. | comment | <inputbox> type=comment page=Project:Sandbox nosummary=true </inputbox> |
|||
summary= | Edit summary or move reason. | create, move | <inputbox> type=create default=Special:Mypage/inputbox test summary=Foo </inputbox> |
|||
id= | id attribute for <form>. | 所有类型 |
|
<inputbox> type=comment page=Project:Sandbox summary=Foo id=bar </inputbox> |
||
inline= | Make the InputBox be an inline element (no line break at beginning). | search2 | Text here: <inputbox> type=search2 inline=true width=10 </inputbox> |
Text here: | ||
dir= | Right to left (rtl) or left to right (ltr). Defaults to directionality of the page's language. | All types | <inputbox> dir=rtl type=comment page=Project:Sandbox summary=Foo </inputbox> |
|||
preloadparams[]= | Specify parameters to the preload text. See Creating pages with preloaded text. | create, comment, commenttitle |
|
<inputbox> type=create preload=Log preloadparams[]=param1 preloadparams[]=param2 </inputbox> |
||
searchfilter= | Specify parameters to append to the search | search |
|
<inputbox> type=search searchfilter=insource:foo </inputbox> |
||
useve= | When creating a page the input box will use the new visual editor, if the extension is installed, and this parameter is set to true. | create, comment | <inputbox> type=create break=no useve=true </inputbox> |
Applying create to an existing page simply gives the edit page.
In that case preload
is ignored.
Applying comment for a new page works.
The texts taken from the MediaWiki:
namespace are of course only examples, any existing page can be used for editintro
or preload
.
Unfortunately preload
does not yet work for the Upload summary.
Alignment
If you want to create an inputbox on the right side of the page, do something like:
<div style="float:{{dir|{{pagelang}}|left|right}}; width:42em">
<inputbox>
type=create
</inputbox>
</div>
Parser function
Using InputBox in a template
In order to create many similar input boxes, InputBox can be used in a template.
However, passing template parameters to InputBox parameters only works if the <inputbox>...</inputbox>
tag is written as {{#tag:inputbox | ...}}
inside the template.
The following example is a template to create a new wiki page from a named template:
{{#tag:inputbox |
type=create
buttonlabel=Create new {{{1|article}}}
preload={{{2|Template:Article}}} }}
When instantiating the template, the first parameter gives the item that is created (default: article
) as spelled out in the button, the second parameter gives the name of the template used to create the item (default: Template:Article
).
E.g., the code for an input box to create a new project from a project template might look like this:
{{Template:CreateNew|project|Template:Project}}
参见
此扩展被用于一个或多个维基媒体项目上。 这可能意味着扩展稳定且工作良好,足以用在同等高流量的网站上。 请在维基媒体的CommonSettings.php和InitialiseSettings.php配置文件中寻找此扩展名称以查看安装它的网站。 详细的已安装扩展的完整列表可在wiki的Special:Version页面找到。 |