Jump to content

Extension:InputBox

From mediawiki.org
This page is a translated version of the page Extension:InputBox and the translation is 92% complete.
MediaWiki 拡張機能マニュアル
InputBox
リリースの状態: 安定
実装 タグ , ページの操作 , 検索
説明 あらかじめ定義された HTML フォームを利用者がウィキページに追加できるようにする
作者
  • Erik Möller
  • Leonardo Pimenta
  • Rob Church
  • Trevor Parscal
  • Daniel Schuba
最新バージョン Continuous updates
MediaWiki >= 1.47.0
データベースの変更 いいえ
  • <inputbox>
ライセンス MIT ライセンス
ダウンロード
translatewiki.net で翻訳を利用できる場合は、InputBox 拡張機能の翻訳にご協力ください
問題点 未解決のタスク · バグを報告

InputBox 拡張機能はあらかじめ作られた HTML フォームをウィキページに追加します。 利用者はボックスにテキストを入力することによってフォームを「埋める」(テキストを入力する、メニュー項目を選択する、等)ことができます。

InputBoxは、当初は Erik Möller によって Wikinews の「記事を作成する」欄を追加するために作成されました。

インストール

この拡張機能は MediaWiki 1.21 以降に同梱されているため、ダウンロードする必要はありません。 残りの設定手順は必ず従ってください。
  • ダウンロードして、ファイルをextensions/フォルダー内のInputBoxという名前のディレクトリ内に配置します。
    開発者とコード寄稿者は、上記の代わりに以下を使用してGitからインストールします:
    cd extensions/
    git clone https://gerrit.wikimedia.org/r/mediawiki/extensions/InputBox
    
  • 以下のコードを LocalSettings.php ファイルの末尾に追加します:
    wfLoadExtension( 'InputBox' );
    
  • Yes 完了 – ウィキの「Special:Version」に移動して、拡張機能が正しくインストールされたことを確認します。

例

新しい記事を開始するためのボックス。

ウィキコード

<inputbox>
type  = create
width = 30px   <!-- with unit of measurement -->
break = no
placeholder = Page title
</inputbox>

結果

一般的な構文

入力ボックスは以下のように構築されます:

<inputbox>
type              = <!-- <input> type  ==  search search2 create comment commenttitle fulltext move -->
bgcolor           = <!-- Background color of parent <form>. -->
width             = <!-- テキスト領域(検索ボックス)の幅を「文字数」で指定。 既定値: 50 -->
page              = <!-- Wiki pagename (i.e. page title) to post comment to, or move page to. No [[X]]. -->
default           = <!-- Initial value of the text field. -->
preloadtitle      = <!-- Content to prepopulate the title field with for a new comment -->
preload           = <!-- Content to prepopulate the source editor with for a new topic/comment, or new page. -->
editintro         = <!-- Wiki pagename of page to be transcluded as 'help text' shown above source editor window. -->

hidden            = <!-- Any value will hide the text field, but not buttons whose links will still work. -->
searchbuttonlabel = <!-- Visual label for "Search full text" in type == search == fulltext. -->
searchengine      = <!-- Either 'MediaSearch' or 'Search'. Defaults to the wiki's value for the search-special-page preference. -->
searchtype        = <!-- If 'MediaSearch' is selected for searchengine, the result type. One of 'image' (default), 'video', 'audio', 'page', or 'other'. -->
fulltextbutton    = <!-- Visual label for "Search full text" -->
labeltext         = <!-- labeltext -->
break             = <!-- break -->
namespaces        = <!-- namespaces -->
prefix            = <!-- prefix -->
placeholder       = <!-- placeholder -->
minor             = <!-- minor -->
nosummary         = <!-- nosummary -->
summary           = <!-- summary -->
id                = <!-- id -->
inline            = <!-- inline -->
dir               = <!-- dir -->
preloadparams[]   = <!-- preloadparams[] -->
searchfilter      = <!-- searchfilter -->
useve             = <!-- useve -->
usedt             = <!-- usedt -->
arialabel         = <!-- arialabel -->
buttonlabel       = <!-- Visual label for primary search button. -->
</inputbox>

Buttons are not exposed to assistive technology: currently the button elements generated by this template have no accessible label. Screen readers therefore announce only the element role (for example, "Button.") rather than a meaningful label. There is no reliable way to add an accessible label without access to the HTML code.

type パラメーターは必須です。 その他のパラメーターはすべて省略可能です。 preloadparams[]は複数回使用できます。

ボックスの種類

既定では、「送信」ボタンは入力ボックスの下に配置されます。

「送信」ボタンは、break=no というパラメータを指定することで入力ボックスの右に配置させることも可能です。このパラメーターは、ボックスとボタンの間にある改行を取り除くものです。

「送信」ボタンを下に配置すると入力の自動補完機能によってボタンが隠れてしまうといった場合には右に配置するのが有用です。

種類 例 説明
search
既定の幅が50文字の検索ボックスを作成します。 テキストボックスに入力された情報を正確なページ名(1番目のボタン)または記事内のテキスト(2番目のボタン)で検索します。
create

新しいページを作成します。 テキストボックスに入力する情報は、作成するページ(既に存在している場合は編集するページ)の名前です。
comment

テキストボックスに指定されたページの末尾に新しい節を追加します(ページが存在しない場合は新しくページを作成します)。
commenttitle

テキストボックスに入力した文字列を見出しとして、新しい節を追加します。 あらかじめ見出し名を default= パラメーターで指定しておくことが可能です。ページ名は、page= パラメーターで指定する必要があります。 ‎<inputbox> として使用する場合限定であり、{{#tag}} で拡張機能を呼び出す場合は機能しません。 (rev:47203 で導入)
fulltext
完全一致ボタン(「表示」ボタン)を使わずに、全文検索ボタンのみで検索します。 (rev:45269 で導入)
move

ページ名を別の名前に移動する。 This also doesn't work when creating it by invoking a tag. (gerrit:97559 で導入)

type=search2 の場合、検索ボタンの既定の位置は右側でインラインです。 現在のところ、このタイプの入力ボックスに他のパラメータを追加することはできないようです。 この検索ボックスは、それが置かれたWiki全体を検索します。

種類 例
search2
 

パラメータ

パラメーター 説明 通用範囲 結果 例 互換性
arialabel= 生成されたマークアップがスクリーンリーダーでアクセスできるようにするには、InputBox に aria-label 属性を指定します。 ARIA: aria-label 属性を参照してください。 すべての種類
<inputbox>
type=search
arialabel=Search the wiki
</inputbox>
≧ 1.35
Gerrit change 572050
bgcolor= テーブルの背景色を設定します(HTMLカラー値)。 引用符は使用しないでください。 すべての種類
<inputbox>
type=search
bgcolor=gray
</inputbox>
?
width= InputBoxの幅を文字数で設定します。 すべての種類

<inputbox>
type=create
width=24
</inputbox>
?
default= InputBoxに入れる既定のテキスト。 すべての種類

<inputbox>
type=comment
default=User talk:Eloquence
</inputbox>
?
preloadtitle= 新しいコメントのタイトルで事前入力される既定のテキスト。 comment

<inputbox>
type=comment
preloadtitle=My comment title
default=Extension talk:InputBox
</inputbox>
≧ 1.45
Gerrit change 1191433
preload= 新しいページを作成すると、このページ名のページが空白の編集ボックスにあらかじめ読み込まれます(Manual:テキストをプリロードしてページを作る 参照)。 create, comment, commenttitle

<inputbox>
type=create
preload=Log
</inputbox>
?
上または下の例のInputBoxに存在しないページのページ名を入力し、それぞれ「項目を作成」または「新しい節」をクリックして、この効果を試してみてください。
editintro= このパラメータで指定されたページは、編集ウィンドウの上に指示として表示されます。 create, comment

<inputbox>
type=comment
editintro=MediaWiki:Missingcommenttext
</inputbox>
?
buttonlabel= このラベルは、フォームのメインボタンに使用されます。 すべての種類

<inputbox>
type=comment
buttonlabel=新しいリソースを追加
</inputbox>
?
hidden= これを指定すると InputBox は非表示になります。

パラメーター default と共に使用され、現在は既定ではなく、ページ名の固定値となっています。 どのような値を指定しても有効になります。

create, comment

<inputbox>
type=comment
editintro=Extension:InputBox/editintro comment
preloadtitle=Comment title
preload=Extension:InputBox/preload
hidden=yes
default=Extension talk:InputBox
buttonlabel=トークページ上にコメントを投稿する
</inputbox>
?
searchbuttonlabel= このラベルは、フォームのメインボタンに使用されます。 search, fulltext
<inputbox>
type=search
searchbuttonlabel=深堀り
</inputbox>
?
searchengine= Extension:MediaSearch がインストールされている場合のみ有効で、このパラメーターは検索で使用する特別ページを Search か MediaSearch に設定します。 パラメーター未使用の場合は、利用者(またはウィキの既定)の設定が使用されます。 search, search2
<inputbox>
type=search
searchengine=MediaSearch
</inputbox>
≧ 1.45
Gerrit change 1167841
searchtype= searchengine=MediaSearch の場合、このパラメーターは結果に表示するタブを設定します。 次のいずれかです: image, video, audio, page, other search, search2
<inputbox>
type=search
searchengine=MediaSearch
searchtype=audio
</inputbox>
≧ 1.46
Gerrit change 1174925
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=
  • 特定の接頭辞で始まるページに絞り込むことができます。 これは特定の検索バックエンドでのみ動作することに注意しましょう。現在は Extension:CirrusSearch のみです。 既定では空文字列(全ページ検索)です。
  • 特定の接頭辞で始まる新しいページを作成します。
  • type=moveでは、既定のパラメータに接頭辞が付きます。

注:アンダースコアはスペースとして認識されません。

search, fulltext, create

下のボタンは、名前の前にSpecial:Mypage/を付けています。


<inputbox>
type=search
prefix={{FULLPAGENAME}}/Archive
</inputbox>
?
placeholder= 入力ボックスが空のときに表示されるプレースホルダーテキストを定義します。 すべての種類
<inputbox>
type=search
placeholder=このウィキ内を検索
</inputbox>
≧ 1.19
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 属性。 すべての種類

<inputbox>
type=comment
page=Project:Sandbox
summary=Foo
id=bar
</inputbox>
≧ 1.23

for some types
inline= InputBoxをインライン要素にする(冒頭で改行しない)。 どのような値を指定しても有効になります。 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

<inputbox>
type=create
preload=Log
preloadparams[]=param1
preloadparams[]=param2
</inputbox>
≧ 1.25
searchfilter= 検索に付加するパラメータを指定する See Help:CirrusSearch for details. search, fulltext
<inputbox>
type=search
searchfilter=insource:foo
</inputbox>
≧ 1.30
useve= VisualEditor 拡張機能がインストールされていて、このパラメーターに任意の値が設定されている場合、入力ボックスのページ作成先でビジュアルエディターを使用します。 create, comment
<inputbox>
type=create
break=no
useve=true
</inputbox>
usedt= DiscussionTools 拡張機能がインストールされていて、このパラメーターに任意の値が設定されている場合、入力ボックスの節追加先で話題の追加ツールが開きます。 comment, commenttitle

<inputbox>
type=commenttitle
page=Project:Sandbox
usedt=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.

CSS によるカスタマイズ

テンプレート内の入力ボックスは CSS を使用してカスタマイズできます。入力ボックスを一意の ID を持つ ‎<div> タグで囲み、CSS セレクタで外観を変更します。 入力ボックス自体に ID を設定し、その ID を CSS セレクタで使用することも可能です。また、カスタム検索ボタンやアイコンを追加することもできます。


Template:Exampleinputbox
<templatestyles src="Template:Example/styles.css"/><div id = "inputbox-search-wrapper">
{{#tag: inputbox|
type        = search
id          = inputbox-search
placeholder = Search all pages
namespaces  = Main**,Help**
}}<div class = "inputbox-search-icon"></div>
</div>
Exampleinputbox/styles.css
#inputbox-search-wrapper {
	box-sizing: border-box;
    height: 32px;
    display: flex;
    border: 1px solid var(--border-color-base, #a2a9b1);
    border-radius: 10px;
}

#inputbox-search-wrapper input {
	all: unset;
    padding-left: 8px;
    padding-top: 6px;
    padding-bottom: 6px;
    width: 180px !important;
	font-family: 'Helvetica Neue', 'Helvetica', 'Liberation Sans', 'Arial', sans-serif;;
    font-size: 14px;
    line-height: 20px;
    color: var(--color-base--subtle, #72777d);
}

#inputbox-search-wrapper input::placeholder {
	font-family: 'Helvetica Neue', 'Helvetica', 'Liberation Sans', 'Arial', sans-serif;;
    font-size: 14px;
    line-height: 20px;
    color: var(--color-base--subtle, #72777d);
}

#inputbox-search-wrapper input.mw-ui-button,
.searchbox .cdx-checkbox--inline,
#inputbox-search-wrapper .cdx-button,
#inputbox-search-wrapper div.mw-ui-checkbox {
	display: none;
}

.inputbox-search-icon {
    padding-left: 8px;
    width: 25px;
    background-image: url("https://upload.wikimedia.org/wikipedia/commons/thumb/7/7e/Vector_search_icon.svg");
    background-size: 18px;
    background-repeat: no-repeat;
    background-position: center;
    cursor: pointer;
}

配置

ページの右側に入力ボックスを作成する場合は、次のようにします:

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

出力:


テンプレートでの InputBox の使用

MediaWiki バージョン:
≦ 1.45
Gerrit change 1224857

テンプレート内で InputBox を使用すると、類似した入力ボックスの作成が可能になります。

次の例は、名前付きテンプレートから新しいウィキページを作成するためのテンプレートです:

<inputbox>
type=create
buttonlabel={{{1|article}}}の新規作成
preload={{{2|Template:Article}}}
</inputbox>

このテンプレートを動作させる場合、第1引数にはボタンに表示されているものと同じ作成項目の種別(既定値: article)を、第2引数には項目の作成に使用されるテンプレート(雛形)の名前(既定値: Template:Article)を指定します。

例えば、project テンプレートから新しいプロジェクトを作成するための入力ボックスのコードは次のようになります:

{{CreateNew|project|Template:Project}}

As of version 1.46 template parameters work as expected with the ‎<inputbox>...‎</inputbox> syntax and it is no longer necessary to use the {{#tag:}} workaround.

1.46 未満では、テンプレートの引数を InputBox の引数へ渡すには、テンプレート内で {{#tag:inputbox | ...}} を含む #tag パーサー関数を介して ‎<inputbox>...‎</inputbox> タグを使用する必要があります。

{{#tag:inputbox
|type=create
|buttonlabel=...
|preload=...
}}

注記

この拡張機能は地域化されたラベルテキストを表示するために、ユーザーインターフェイス言語 に基づいてパーサーキャッシュ を分割します(gitiles:e18b7e6)。

関連項目