This page is a translated version of the page Extension:InputBox and the translation is 100% complete.
此扩展随附于MediaWiki 1.21及更高版本。 因此您无需另外下载。 但是,您仍需遵循此页面提供的其他使用说明。
MediaWiki扩展手册
InputBox
发行状态: 稳定版
实现 标签 , 页面操作 , 搜索
描述 允许编辑者在页面中添加预置的HTML表格
作者
  • Erik Möller
  • Leonardo Pimenta
  • Rob Church
  • Trevor Parscal
  • Daniel Schuba
最新版本 Continuous updates
MediaWiki >= 1.42
数据库更改
许可协议 MIT授權條款
下載
  • <inputbox>
季度下載量 288 (Ranked 23rd)
正在使用的公开wiki数 10,897 (Ranked 10th)
前往translatewiki.net翻譯InputBox扩展
問題 开启的任务 · 报告错误

输入框(InputBox)扩展可以给维基页面添加已经创建好的HTML表单。 用户可以在输入框中输入文本以“填写”表单(输入文本、选择菜单项等)。

InputBox最初是由Erik Möller为在维基新闻中加入创建条目框的目的而创建的。

安裝

  • 下载文件,并将其放置在您extensions/文件夹中的InputBox目录内。
    开发者和代码贡献人员应从Git安装扩展,输入:cd extensions/
    git clone https://gerrit.wikimedia.org/r/mediawiki/extensions/InputBox
  • 将下列代码放置在您的LocalSettings.php 的底部:
    wfLoadExtension( 'InputBox' );
    
  •   完成 – 在您的wiki上导航至Special:Version,以验证已成功安装扩展。

示例

创建一篇新文章的输入框。

Wiki代码

<inputbox>
type=create
width=30
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=
usedt=
arialabel=
</inputbox>

type 参数必须输入。 而其他所有参数均为可选。 preloadparams[] 可以出现不止一次。

输入框类型

默认情况下提交按钮位于输入框的下面。

通过设置换行参数可将“提交”按钮移至右侧:break=no

将“提交”按钮移至右侧对于使用搜索框时搜索建议覆盖了下方搜索按钮的情况很有用。

类型 示例 描述
search
创建的搜索框的默认宽度为50字符。 输入的内容为要搜索的确切页面标题(按钮1)或是条目中的文本(按钮2)。
create

创建新页面。 输入的内容为要创建的页面名称(对于已存在页面则是编辑页面)。
comment

在输入框指定的页面下增加一个新段落(如果为新页面则会创建页面)。
commenttitle

以输入框中输入的标题增加一个新段落。 标题可以用default=参数指定。页面必须用page=参数指定。 For some reason this does NOT work when using the extension by invoking it with {{#tag}}, only when using ‎<inputbox>. (在版本rev:47203引入)
fulltext
仅显示搜索全文按钮,不显示精确匹配按钮(“前往”按钮)。 (在版本rev:45269引入)
move

将页面移动至另一个名字。 This also doesn't work when creating it by invoking a tag. (在版本gerrit:97559引入)

对于type=search2,默认的搜索按钮位置在同行右侧。 目前,似乎无法将其他参数添加到这种类型的输入框中。 这种搜索框将搜索其所在的整个维基。

类型 示例
search2
 

参数

参数 描述 适用范围 兼容性 示例 结果
arialabel= 为输入框提供aria-label属性,以允许屏幕阅读器访问生成的标记。 所有类型
1.35
Gerrit change 572050
<inputbox>
type=search
arialabel=Search the Wiki
</inputbox>
bgcolor= 设置表格背景色(HTML颜色值)。 不要使用引号。 所有类型 ?
<inputbox>
type=search
bgcolor=#eeeeff
</inputbox>
width= 设置输入框的宽度,单位为字符。 所有类型 ?
<inputbox>
type=create
width=24
</inputbox>

default= 输入框中的默认文本。 所有类型 ?
<inputbox>
type=comment
default=User talk:Eloquence
</inputbox>

preload= 当创建新页面时,此标题的页面将会被预先载入(参见手册:创建包含预加载文本的页面 )进空白编辑框。 create, comment, commenttitle ?
<inputbox>
type=create
preload=Log
</inputbox>

在上面或下面的输入框示例中输入一个不存在的页面标题,并分别点击“创建页面”或“新段落”按钮来测试此功能。
editintro= 通过这一参数指定的页面将会作为编辑指引显示在编辑窗口上方 create, comment ?
<inputbox>
type=comment
editintro=MediaWiki:Missingcommenttext
</inputbox>

buttonlabel= 此参数将作为表单主按钮显示的文字。 所有类型 ?
<inputbox>
type=comment
buttonlabel=添加新的传言
</inputbox>

hidden= 此参数指定不显示输入框。

此参数需要与参数 default 配合使用,此参数现在不是默认值,而是作为页面标题的固定值。 任何带有 yes/true 意义的值。

create, comment ?
<inputbox>
type=comment
editintro=Extension:InputBox/editintro comment
preload=Extension:InputBox/preload
hidden=yes
default=Extension talk:InputBox
buttonlabel=在讨论页留言
</inputbox>

searchbuttonlabel= 此参数将作为表单“搜索全文”按钮显示的文字。 search, fulltext ?
<inputbox>
type=search
searchbuttonlabel=深入探索
</inputbox>
fulltextbutton= 在“search2”表单上显示全文搜索按钮。 search2 ?
<inputbox>
type=search2
searchbuttonlabel=深入探索
fulltextbutton=true
</inputbox>
labeltext= 在左侧显示的文字。 search2 ?
<inputbox>
type=search2
searchbuttonlabel=深入探索
labeltext=查找: 
</inputbox>
 
break= 是否在输入框和按钮之间插入换行。 默认为yes(使用换行)。 所有类型 ?
<inputbox>
type=create
width=24
break=no
</inputbox>
namespaces= 在全文搜索中支持选择命名空间。

使用“Main**”以默认选中主命名空间。

search, fulltext ?
<inputbox>
type=search
namespaces=Main**,Help
</inputbox>
prefix=
  • 指定搜索以特定前缀开头的页面来缩小范围。 注意这仅兼容特定的搜索后端,目前仅有扩展:CirrusSearch 。 默认为空(搜索所有页面)。
  • 创建一个以特定前缀开头的页面。
  • 在type=move中,前缀将加在默认参数前。

注:下划线不等同于空格。

search, fulltext, create ?
<inputbox>
type=search
prefix={{FULLPAGENAME}}/Archive
</inputbox>

下面的按钮以Special:Mypage/作为前缀。


placeholder= 设置当输入框为空时的占位文字。 所有类型
1.19
<inputbox>
type=search
placeholder=搜索此维基
</inputbox>
page= 要发表评论或要移动的页面。 comment, move
<inputbox>
type=comment
page=Project:Sandbox
</inputbox>

minor= 小编辑。 comment, create
<inputbox>
type=comment
page=Project:Sandbox
minor=true
</inputbox>

nosummary= 对新评论不要求编辑摘要(标题)。 comment
<inputbox>
type=commenttitle
page=Special:Mypage/inputbox test
nosummary=true
</inputbox>

summary= 编辑摘要或移动理由。 create, move
<inputbox>
type=create
default=Special:Mypage/inputbox test
summary=Foo
</inputbox>

id= <form>的id属性。 所有类型
1.23
for some types
<inputbox>
type=comment
page=Project:Sandbox
summary=Foo
id=bar
</inputbox>

inline= 将输入框作为内联元素(在开头不换行)。 任何带有yes/true意义的值。 search2
在此输入: <inputbox>
type=search2
inline=true
width=10
</inputbox>
在此输入:
 
dir= 书写方向从右到左(rtl)或从左到右(ltr)。 默认与页面语言的方向相同。 所有类型
<inputbox>
dir=rtl
type=comment
page=Project:Sandbox
summary=Foo
</inputbox>

preloadparams[]= 设置预载文本的参数。 参见使用预加载文本创建页面 create, comment, commenttitle
1.25
<inputbox>
type=create
preload=Log
preloadparams[]=param1
preloadparams[]=param2
</inputbox>

searchfilter= 指定在搜索中追加的参数。 search
1.30
<inputbox>
type=search
searchfilter=insource:foo
</inputbox>
useve= 当新的可视化编辑器扩展被安装且此参数被设为任何值时,将使用可视化编辑器创建页面。 create, comment
<inputbox>
type=create
break=no
useve=true
</inputbox>
usedt= 添加新段落时,输入框将会打开讨论页工具的新话题工具,如果安装了拓展,则该参数会设置为任何值。 comment, commenttitle
<inputbox>
type=commenttitle
page=Project:Sandbox
usedt=true
</inputbox>

对于已存在的页面使用create只会跳转到编辑界面。 在这种情况下preload被忽略。 对新页面使用comment是有效的。

这里使用的在MediaWiki:命名空间下的文本只是作为示例,任何存在的页面都能被用于editintropreload。 不幸的是preload现在还不能对上传文件摘要生效。

对齐

如果你想要在页面右侧创建一个输入框,使用:

<div style="float:right; width:42em">
<inputbox>
type=create
</inputbox>
</div>

会显示:


解析器函数

在模板中使用输入框

为了创建许多类似的输入框,输入框可以在模板中使用。 然而,在模板中只有当‎<inputbox>...‎</inputbox>标签以{{#tag:inputbox | ...}}的形式编写时,传递给输入框的模板参数才能够生效。

下面的例子是一个通过指定模板创建新页面的模板:

{{#tag:inputbox |
type=create
buttonlabel=创建新{{{1|条目}}}
preload={{{2|Template:Article}}} }}

实例化此模板时,第一个参数提供一个已经创建好的项(默认为article),就像按钮中显示的那样。第二个参数提供用来创建项的模板名称(默认为Template:Article)。

例如:这段代码产生一个用于从项目模板创建新的项目的输入框:

{{Template:CreateNew|project|Template:Project}}

參見