change event naming scheme

FORM_*_OUTPUT scheme had been introduced since Apriil 2018, see #2286
This commit is contained in:
Satoshi Sahara 2020-08-26 20:25:18 +09:00
parent 8128de6c97
commit c6977b3a35
15 changed files with 20 additions and 51 deletions

View File

@ -469,7 +469,7 @@ class Form extends Element
/** /**
* The HTML representation of the whole form * The HTML representation of the whole form
* *
* @param string $eventName (optional) name of the event: HTMLFORM_{$name}_OUTPUT * @param string $eventName (optional) name of the event: FORM_{$name}_OUTPUT
* @return string * @return string
*/ */
public function toHTML($eventName = null) public function toHTML($eventName = null)
@ -478,9 +478,7 @@ class Form extends Element
// trigger event to provide an opportunity to modify this form // trigger event to provide an opportunity to modify this form
if (isset($eventName)) { if (isset($eventName)) {
if (!preg_match('/^HTMLFORM_[A-Z]+?_OUTPUT$/', $eventName)) { $eventName = 'FORM_'.strtoupper($eventName).'_OUTPUT';
$eventName = 'HTMLFORM_'.strtoupper($eventName).'_OUTPUT';
}
Event::createAndTrigger($eventName, $this, null, false); Event::createAndTrigger($eventName, $this, null, false);
} }

View File

@ -19,7 +19,6 @@ class Editor extends Ui
* @author Andreas Gohr <andi@splitbrain.org> * @author Andreas Gohr <andi@splitbrain.org>
* *
* @triggers HTML_EDIT_FORMSELECTION * @triggers HTML_EDIT_FORMSELECTION
* @triggers HTMLFORM_EDIT_OUTPUT
* @return void * @return void
*/ */
public function show() public function show()
@ -174,8 +173,7 @@ class Editor extends Ui
} }
echo '</div>'; echo '</div>';
// print form that might be modified by HTMLFORM_EDIT_OUTPUT event handlers echo $form->toHTML('Edit');
echo $form->toHTML('edit');
echo '</div>'; // close div editBox class echo '</div>'; // close div editBox class
} }

View File

@ -28,7 +28,6 @@ class Login extends Ui
* *
* @author Andreas Gohr <andi@splitbrain.org> * @author Andreas Gohr <andi@splitbrain.org>
* *
* @triggers HTMLFORM_LOGIN_OUTPUT
* @return void * @return void
*/ */
public function show() public function show()
@ -75,8 +74,7 @@ class Login extends Ui
$form->addHTML('<p>'.$lang['pwdforget'].': '. $resendPwLink .'</p>'); $form->addHTML('<p>'.$lang['pwdforget'].': '. $resendPwLink .'</p>');
} }
// print form that might be modified by HTMLFORM_LOGIN_OUTPUT event handlers print $form->toHTML('Login');
print $form->toHTML('login');
print '</div>'; print '</div>';
} }

View File

@ -31,7 +31,6 @@ class PageConflict extends Ui
* *
* @author Andreas Gohr <andi@splitbrain.org> * @author Andreas Gohr <andi@splitbrain.org>
* *
* @triggers HTMLFORM_CONFLICT_OUTPUT
* @return void * @return void
*/ */
public function show() public function show()
@ -53,8 +52,7 @@ class PageConflict extends Ui
$form->addButton('do[cancel]', $lang['btn_cancel'] )->attrs(['type' => 'submit']); $form->addButton('do[cancel]', $lang['btn_cancel'] )->attrs(['type' => 'submit']);
$form->addTagClose('div'); $form->addTagClose('div');
// print form that might be modified by HTMLFORM_CONFLICT_OUTPUT event handlers print $form->toHTML('Conflict');
print $form->toHTML('conflict');
print '<br /><br /><br /><br />'; print '<br /><br /><br /><br />';

View File

@ -17,7 +17,6 @@ class PageDraft extends Ui
* *
* @author Andreas Gohr <andi@splitbrain.org> * @author Andreas Gohr <andi@splitbrain.org>
* *
* @triggers HTMLFORM_DRAFT_OUTPUT
* @return void * @return void
*/ */
public function show() public function show()
@ -49,8 +48,7 @@ class PageDraft extends Ui
$form->addButton('do[show]', $lang['btn_cancel'] )->attrs(['type' => 'submit', 'tabindex' => '3']); $form->addButton('do[show]', $lang['btn_cancel'] )->attrs(['type' => 'submit', 'tabindex' => '3']);
$form->addTagClose('div'); $form->addTagClose('div');
// print form that might be modified by HTMLFORM_DRAFT_OUTPUT event handlers print $form->toHTML('Draft');
print $form->toHTML('draft');
} }
} }

View File

@ -36,7 +36,6 @@ class Recent extends Ui
* @author Kate Arzamastseva <pshns@ukr.net> * @author Kate Arzamastseva <pshns@ukr.net>
* @author Satoshi Sahara <sahara.satoshi@gmail.com> * @author Satoshi Sahara <sahara.satoshi@gmail.com>
* *
* @triggers HTMLFORM_RECENT_OUTPUT
* @return void * @return void
*/ */
public function show() public function show()
@ -98,8 +97,7 @@ class Recent extends Ui
// provide navigation for pagenated recent list (of pages and/or media files) // provide navigation for pagenated recent list (of pages and/or media files)
$form->addHTML($this->htmlNavigation($first, $hasNext)); $form->addHTML($this->htmlNavigation($first, $hasNext));
// print form that might be modified by HTMLFORM_RECENT_OUTPUT event handlers print $form->toHTML('Recent');
print $form->toHTML('recent');
} }
/** /**

View File

@ -36,7 +36,6 @@ class Revisions extends Ui
* @author Kate Arzamastseva <pshns@ukr.net> * @author Kate Arzamastseva <pshns@ukr.net>
* @author Satoshi Sahara <sahara.satoshi@gmail.com> * @author Satoshi Sahara <sahara.satoshi@gmail.com>
* *
* @triggers HTMLFORM_REVISIONS_OUTPUT
* @return void * @return void
*/ */
public function show() public function show()
@ -115,8 +114,7 @@ class Revisions extends Ui
$form->addTagClose('div'); // close div class=no $form->addTagClose('div'); // close div class=no
// print form that might be modified by HTMLFORM_REVISIONS_OUTPUT event handlers print $form->toHTML('Revisions');
print $form->toHTML('revisions');
// provide navigation for pagenated revision list (of pages and/or media files) // provide navigation for pagenated revision list (of pages and/or media files)
print $this->htmlNavigation($id, $first, $hasNext); print $this->htmlNavigation($id, $first, $hasNext);
@ -182,8 +180,7 @@ class Revisions extends Ui
$form->addTagClose('div'); // close div class=no $form->addTagClose('div'); // close div class=no
// print form that might be modified by HTMLFORM_REVISIONS_OUTPUT event handlers print $form->toHTML('Revisions');
print $form->toHTML('revisions');
// provide navigation for pagenated revision list (of pages and/or media files) // provide navigation for pagenated revision list (of pages and/or media files)
print $this->htmlNavigation($id, $first, $hasNext); print $this->htmlNavigation($id, $first, $hasNext);

View File

@ -87,9 +87,7 @@ class Search extends Ui
$searchForm->addFieldsetClose(); $searchForm->addFieldsetClose();
Event::createAndTrigger('FORM_SEARCH_OUTPUT', $searchForm); return $searchForm->toHTML('Search');
return $searchForm->toHTML();
} }
/** /**

View File

@ -16,7 +16,6 @@ class Subscribe extends Ui
* *
* @author Adrian Lang <lang@cosmocode.de> * @author Adrian Lang <lang@cosmocode.de>
* *
* @triggers HTMLFORM_SUBSCRIBE_OUTPUT
* @return void * @return void
*/ */
public function show() public function show()
@ -108,8 +107,7 @@ class Subscribe extends Ui
$form->addButton('do[subscribe]', $lang['subscr_m_subscribe'])->attr('type', 'submit'); $form->addButton('do[subscribe]', $lang['subscr_m_subscribe'])->attr('type', 'submit');
$form->addTagClose('div'); $form->addTagClose('div');
// print form that might be modified by HTMLFORM_SUBSCRIBE_OUTPUT event handlers print $form->toHTML('Subscribe');
print $form->toHTML('subscribe');
echo '</div>'; echo '</div>';
} }

View File

@ -16,8 +16,6 @@ class UserProfile extends Ui
* *
* @author Andreas Gohr <andi@splitbrain.org> * @author Andreas Gohr <andi@splitbrain.org>
* *
* @triggers HTMLFORM_UPDATEPROFILE_OUTPUT
* @triggers HTMLFORM_PROFILEDELETE_OUTPUT
* @return void * @return void
*/ */
public function show() public function show()
@ -88,8 +86,7 @@ class UserProfile extends Ui
$form->addFieldsetClose(); $form->addFieldsetClose();
$form->addTagClose('div'); $form->addTagClose('div');
// print form that might be modified by HTMLFORM_UPDATEPROFILE_OUTPUT event handlers print $form->toHTML('UpdateProfile');
print $form->toHTML('updateprofile');
if ($auth->canDo('delUser') && actionOK('profile_delete')) { if ($auth->canDo('delUser') && actionOK('profile_delete')) {
@ -119,8 +116,7 @@ class UserProfile extends Ui
$form->addFieldsetClose(); $form->addFieldsetClose();
$form->addTagClose('div'); $form->addTagClose('div');
// print form that might be modified by HTMLFORM_PROFILEDELETE_OUTPUT event handlers print $form->toHTML('ProfileDelete');
print $form->toHTML('profiledelete');
} }
print '</div>'; print '</div>';

View File

@ -16,7 +16,6 @@ class UserRegister extends Ui
* *
* @author Andreas Gohr <andi@splitbrain.org> * @author Andreas Gohr <andi@splitbrain.org>
* *
* @triggers HTMLFORM_REGISTER_OUTPUT
* @return void * @return void
*/ */
public function show() public function show()
@ -67,8 +66,7 @@ class UserRegister extends Ui
$form->addFieldsetClose(); $form->addFieldsetClose();
$form->addTagClose('div'); $form->addTagClose('div');
// print form that might be modified by HTMLFORM_REGISTER_OUTPUT event handlers print $form->toHTML('Register');
print $form->toHTML('register');
print '</div>'; print '</div>';
} }

View File

@ -17,7 +17,6 @@ class UserResendPwd extends Ui
* @author Benoit Chesneau <benoit@bchesneau.info> * @author Benoit Chesneau <benoit@bchesneau.info>
* @author Andreas Gohr <andi@splitbrain.org> * @author Andreas Gohr <andi@splitbrain.org>
* *
* @triggers HTMLFORM_RESENDPWD_OUTPUT
* @return void * @return void
*/ */
public function show() public function show()
@ -37,8 +36,7 @@ class UserResendPwd extends Ui
$form = $this->formResendPassword(); $form = $this->formResendPassword();
} }
//print form that might be modified by HTMLFORM_RESENDPWD_OUTPUT event handlers print $form->toHTML('ResendPwd');
print $form->toHTML('resendpwd');
print '</div>'; print '</div>';
} }

View File

@ -1883,8 +1883,7 @@ function media_uploadform($ns, $auth, $fullscreen = false) {
} }
echo '<div id="mediamanager__uploader">'.DOKU_LF; echo '<div id="mediamanager__uploader">'.DOKU_LF;
// print form that might be modified by HTMLFORM_UPLOAD_OUTPUT event handlers echo $form->toHTML('Upload');
echo $form->toHTML('upload');
echo '</div>'.DOKU_LF; echo '</div>'.DOKU_LF;
echo '<p class="maxsize">'; echo '<p class="maxsize">';
@ -1948,9 +1947,7 @@ function media_searchform($ns, $query = '', $fullscreen = false) {
$form->addButton('', $lang['btn_search'])->attr('type', 'submit'); $form->addButton('', $lang['btn_search'])->attr('type', 'submit');
$form->addTagClose('p'); $form->addTagClose('p');
$form->addTagClose('div'); $form->addTagClose('div');
print $form->toHTML('SearchMedia');
// print form that might be modified by HTMLFORM_SEARCHMEDIA_OUTPUT event handlers
print $form->toHTML('searchmedia');
} }
/** /**

View File

@ -705,9 +705,8 @@ function tpl_searchform($ajax = true, $autocomplete = true) {
$searchForm->addTagClose('div'); $searchForm->addTagClose('div');
} }
$searchForm->addTagClose('div'); $searchForm->addTagClose('div');
Event::createAndTrigger('FORM_QUICKSEARCH_OUTPUT', $searchForm);
echo $searchForm->toHTML(); echo $searchForm->toHTML('QuickSearch');
return true; return true;
} }

View File

@ -18,7 +18,7 @@ class action_plugin_authad extends DokuWiki_Action_Plugin
public function register(Doku_Event_Handler $controller) public function register(Doku_Event_Handler $controller)
{ {
$controller->register_hook('AUTH_LOGIN_CHECK', 'BEFORE', $this, 'handleAuthLoginCheck'); $controller->register_hook('AUTH_LOGIN_CHECK', 'BEFORE', $this, 'handleAuthLoginCheck');
$controller->register_hook('HTMLFORM_LOGIN_OUTPUT', 'BEFORE', $this, 'handleHtmlFormLoginOutput'); $controller->register_hook('FORM_LOGIN_OUTPUT', 'BEFORE', $this, 'handleFormLoginOutput');
} }
/** /**
@ -52,7 +52,7 @@ class action_plugin_authad extends DokuWiki_Action_Plugin
* @param Doku_Event $event * @param Doku_Event $event
* @param array $param * @param array $param
*/ */
public function handleHtmlFormLoginOutput(Doku_Event $event, $param) public function handleFormLoginOutput(Doku_Event $event, $param)
{ {
global $INPUT; global $INPUT;
/** @var auth_plugin_authad $auth */ /** @var auth_plugin_authad $auth */