Manual:Hooks/EditPage::showEditForm:initial/ja
| EditPage::showEditForm:initial | |
|---|---|
| バージョン 1.6.0 から利用可能 Called just before the preview and edit form are rendered | |
| 関数の定義: | public static function onEditPage_showEditForm_initial( EditPage $editPage, OutputPage $output ) { ... }
|
| フックのアタッチ: | extension.json 内:
{
"Hooks": {
"EditPage::showEditForm:initial": "MediaWiki\\Extension\\MyExtension\\Hooks::onEditPageshowEditForminitial"
}
}
|
| 呼び出し元: | ファイル: EditPage/EditPage.php |
| インターフェイス: | EditPage__showEditForm_initialHook.php |
フックの設定についての詳細情報は Manual:フック を参照してください。
このフックを使用する拡張機能の例については、Category:EditPage::showEditForm:initial extensions/ja を参照してください。
詳細
$editPage- the current EditPage object.$output- the OutputPage object. (1.20.0 で導入)
注記
You can do something like the following to only take action on certain types of edits:
if( $editPage->formtype == 'preview' ) {
// performing a preview.
}
Inject HTML
There are many locations within EditPage::showEditForm:initial that allow a user to inject HTML. These hook locations are represented by member variables of the EditPage object.
$editPage->editFormPageTop // MW >= 1.9 $editPage->editFormTextTop // MW >= 1.9 $editPage->editFormTextBeforeContent // MW >= 1.12 $editPage->editFormTextAfterWarn // MW >= 1.9 $editPage->editFormTextAfterTools // MW >= 1.9 $editPage->editFormTextBottom // MW >= 1.9
To inject your HTML, append your HTML to one of the aforementioned member variables, e.g.
$editPage->editFormPageTop .= "<span>Hello World!</span>";
Some hook locations are inside forms; some not. Those inside the form allow you to inject HTML form elements.
- Inside form
- editFormTextBeforeContent
- editFormTextAfterWarn
- editFormTextAfterTools
- editFormTextBottom
- Outside form
- editFormPageTop
- editFormTextTop
Normally, we use EditPage::showEditForm:fields for form elements, but there may be some circumstances for which it is necessary to use the aforementioned hook locations.
Read-only
In read-only mode, there is a similar EditPage::showReadOnlyForm:initial hook.