From c6977b3a35d43dd2a2c9271648980059f410f648 Mon Sep 17 00:00:00 2001 From: Satoshi Sahara Date: Wed, 26 Aug 2020 20:25:18 +0900 Subject: [PATCH] change event naming scheme FORM_*_OUTPUT scheme had been introduced since Apriil 2018, see #2286 --- inc/Form/Form.php | 6 ++---- inc/Ui/Editor.php | 4 +--- inc/Ui/Login.php | 4 +--- inc/Ui/PageConflict.php | 4 +--- inc/Ui/PageDraft.php | 4 +--- inc/Ui/Recent.php | 4 +--- inc/Ui/Revisions.php | 7 ++----- inc/Ui/Search.php | 4 +--- inc/Ui/Subscribe.php | 4 +--- inc/Ui/UserProfile.php | 8 ++------ inc/Ui/UserRegister.php | 4 +--- inc/Ui/UserResendPwd.php | 4 +--- inc/media.php | 7 ++----- inc/template.php | 3 +-- lib/plugins/authad/action.php | 4 ++-- 15 files changed, 20 insertions(+), 51 deletions(-) diff --git a/inc/Form/Form.php b/inc/Form/Form.php index af87edb7e..3f6ea9448 100644 --- a/inc/Form/Form.php +++ b/inc/Form/Form.php @@ -469,7 +469,7 @@ class Form extends Element /** * 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 */ public function toHTML($eventName = null) @@ -478,9 +478,7 @@ class Form extends Element // trigger event to provide an opportunity to modify this form if (isset($eventName)) { - if (!preg_match('/^HTMLFORM_[A-Z]+?_OUTPUT$/', $eventName)) { - $eventName = 'HTMLFORM_'.strtoupper($eventName).'_OUTPUT'; - } + $eventName = 'FORM_'.strtoupper($eventName).'_OUTPUT'; Event::createAndTrigger($eventName, $this, null, false); } diff --git a/inc/Ui/Editor.php b/inc/Ui/Editor.php index 4f869537f..a560f570c 100644 --- a/inc/Ui/Editor.php +++ b/inc/Ui/Editor.php @@ -19,7 +19,6 @@ class Editor extends Ui * @author Andreas Gohr * * @triggers HTML_EDIT_FORMSELECTION - * @triggers HTMLFORM_EDIT_OUTPUT * @return void */ public function show() @@ -174,8 +173,7 @@ class Editor extends Ui } echo ''; - // print form that might be modified by HTMLFORM_EDIT_OUTPUT event handlers - echo $form->toHTML('edit'); + echo $form->toHTML('Edit'); echo ''; // close div editBox class } diff --git a/inc/Ui/Login.php b/inc/Ui/Login.php index 9686eae47..0980130a4 100644 --- a/inc/Ui/Login.php +++ b/inc/Ui/Login.php @@ -28,7 +28,6 @@ class Login extends Ui * * @author Andreas Gohr * - * @triggers HTMLFORM_LOGIN_OUTPUT * @return void */ public function show() @@ -75,8 +74,7 @@ class Login extends Ui $form->addHTML('

'.$lang['pwdforget'].': '. $resendPwLink .'

'); } - // print form that might be modified by HTMLFORM_LOGIN_OUTPUT event handlers - print $form->toHTML('login'); + print $form->toHTML('Login'); print ''; } diff --git a/inc/Ui/PageConflict.php b/inc/Ui/PageConflict.php index e13744ae1..fcab37e8f 100644 --- a/inc/Ui/PageConflict.php +++ b/inc/Ui/PageConflict.php @@ -31,7 +31,6 @@ class PageConflict extends Ui * * @author Andreas Gohr * - * @triggers HTMLFORM_CONFLICT_OUTPUT * @return void */ public function show() @@ -53,8 +52,7 @@ class PageConflict extends Ui $form->addButton('do[cancel]', $lang['btn_cancel'] )->attrs(['type' => 'submit']); $form->addTagClose('div'); - // print form that might be modified by HTMLFORM_CONFLICT_OUTPUT event handlers - print $form->toHTML('conflict'); + print $form->toHTML('Conflict'); print '



'; diff --git a/inc/Ui/PageDraft.php b/inc/Ui/PageDraft.php index 67d4e05be..609ee508d 100644 --- a/inc/Ui/PageDraft.php +++ b/inc/Ui/PageDraft.php @@ -17,7 +17,6 @@ class PageDraft extends Ui * * @author Andreas Gohr * - * @triggers HTMLFORM_DRAFT_OUTPUT * @return void */ public function show() @@ -49,8 +48,7 @@ class PageDraft extends Ui $form->addButton('do[show]', $lang['btn_cancel'] )->attrs(['type' => 'submit', 'tabindex' => '3']); $form->addTagClose('div'); - // print form that might be modified by HTMLFORM_DRAFT_OUTPUT event handlers - print $form->toHTML('draft'); + print $form->toHTML('Draft'); } } diff --git a/inc/Ui/Recent.php b/inc/Ui/Recent.php index 7daabc820..f6fe6a3f6 100644 --- a/inc/Ui/Recent.php +++ b/inc/Ui/Recent.php @@ -36,7 +36,6 @@ class Recent extends Ui * @author Kate Arzamastseva * @author Satoshi Sahara * - * @triggers HTMLFORM_RECENT_OUTPUT * @return void */ public function show() @@ -98,8 +97,7 @@ class Recent extends Ui // provide navigation for pagenated recent list (of pages and/or media files) $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'); } /** diff --git a/inc/Ui/Revisions.php b/inc/Ui/Revisions.php index 01b4ae778..293fab541 100644 --- a/inc/Ui/Revisions.php +++ b/inc/Ui/Revisions.php @@ -36,7 +36,6 @@ class Revisions extends Ui * @author Kate Arzamastseva * @author Satoshi Sahara * - * @triggers HTMLFORM_REVISIONS_OUTPUT * @return void */ public function show() @@ -115,8 +114,7 @@ class Revisions extends Ui $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) print $this->htmlNavigation($id, $first, $hasNext); @@ -182,8 +180,7 @@ class Revisions extends Ui $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) print $this->htmlNavigation($id, $first, $hasNext); diff --git a/inc/Ui/Search.php b/inc/Ui/Search.php index e4eef6706..cbd7c0378 100644 --- a/inc/Ui/Search.php +++ b/inc/Ui/Search.php @@ -87,9 +87,7 @@ class Search extends Ui $searchForm->addFieldsetClose(); - Event::createAndTrigger('FORM_SEARCH_OUTPUT', $searchForm); - - return $searchForm->toHTML(); + return $searchForm->toHTML('Search'); } /** diff --git a/inc/Ui/Subscribe.php b/inc/Ui/Subscribe.php index e97c39a09..80352d7fd 100644 --- a/inc/Ui/Subscribe.php +++ b/inc/Ui/Subscribe.php @@ -16,7 +16,6 @@ class Subscribe extends Ui * * @author Adrian Lang * - * @triggers HTMLFORM_SUBSCRIBE_OUTPUT * @return void */ public function show() @@ -108,8 +107,7 @@ class Subscribe extends Ui $form->addButton('do[subscribe]', $lang['subscr_m_subscribe'])->attr('type', 'submit'); $form->addTagClose('div'); - // print form that might be modified by HTMLFORM_SUBSCRIBE_OUTPUT event handlers - print $form->toHTML('subscribe'); + print $form->toHTML('Subscribe'); echo ''; } diff --git a/inc/Ui/UserProfile.php b/inc/Ui/UserProfile.php index 2f4acc451..300f1b384 100644 --- a/inc/Ui/UserProfile.php +++ b/inc/Ui/UserProfile.php @@ -16,8 +16,6 @@ class UserProfile extends Ui * * @author Andreas Gohr * - * @triggers HTMLFORM_UPDATEPROFILE_OUTPUT - * @triggers HTMLFORM_PROFILEDELETE_OUTPUT * @return void */ public function show() @@ -88,8 +86,7 @@ class UserProfile extends Ui $form->addFieldsetClose(); $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')) { @@ -119,8 +116,7 @@ class UserProfile extends Ui $form->addFieldsetClose(); $form->addTagClose('div'); - // print form that might be modified by HTMLFORM_PROFILEDELETE_OUTPUT event handlers - print $form->toHTML('profiledelete'); + print $form->toHTML('ProfileDelete'); } print ''; diff --git a/inc/Ui/UserRegister.php b/inc/Ui/UserRegister.php index 71674bb6d..26da3933e 100644 --- a/inc/Ui/UserRegister.php +++ b/inc/Ui/UserRegister.php @@ -16,7 +16,6 @@ class UserRegister extends Ui * * @author Andreas Gohr * - * @triggers HTMLFORM_REGISTER_OUTPUT * @return void */ public function show() @@ -67,8 +66,7 @@ class UserRegister extends Ui $form->addFieldsetClose(); $form->addTagClose('div'); - // print form that might be modified by HTMLFORM_REGISTER_OUTPUT event handlers - print $form->toHTML('register'); + print $form->toHTML('Register'); print ''; } diff --git a/inc/Ui/UserResendPwd.php b/inc/Ui/UserResendPwd.php index f64b213fe..65cd2151e 100644 --- a/inc/Ui/UserResendPwd.php +++ b/inc/Ui/UserResendPwd.php @@ -17,7 +17,6 @@ class UserResendPwd extends Ui * @author Benoit Chesneau * @author Andreas Gohr * - * @triggers HTMLFORM_RESENDPWD_OUTPUT * @return void */ public function show() @@ -37,8 +36,7 @@ class UserResendPwd extends Ui $form = $this->formResendPassword(); } - //print form that might be modified by HTMLFORM_RESENDPWD_OUTPUT event handlers - print $form->toHTML('resendpwd'); + print $form->toHTML('ResendPwd'); print ''; } diff --git a/inc/media.php b/inc/media.php index 644779618..54df30547 100644 --- a/inc/media.php +++ b/inc/media.php @@ -1883,8 +1883,7 @@ function media_uploadform($ns, $auth, $fullscreen = false) { } echo '
'.DOKU_LF; - // print form that might be modified by HTMLFORM_UPLOAD_OUTPUT event handlers - echo $form->toHTML('upload'); + echo $form->toHTML('Upload'); echo '
'.DOKU_LF; echo '

'; @@ -1948,9 +1947,7 @@ function media_searchform($ns, $query = '', $fullscreen = false) { $form->addButton('', $lang['btn_search'])->attr('type', 'submit'); $form->addTagClose('p'); $form->addTagClose('div'); - - // print form that might be modified by HTMLFORM_SEARCHMEDIA_OUTPUT event handlers - print $form->toHTML('searchmedia'); + print $form->toHTML('SearchMedia'); } /** diff --git a/inc/template.php b/inc/template.php index 50cbf70c3..2f4d63faa 100644 --- a/inc/template.php +++ b/inc/template.php @@ -705,9 +705,8 @@ function tpl_searchform($ajax = true, $autocomplete = true) { $searchForm->addTagClose('div'); } $searchForm->addTagClose('div'); - Event::createAndTrigger('FORM_QUICKSEARCH_OUTPUT', $searchForm); - echo $searchForm->toHTML(); + echo $searchForm->toHTML('QuickSearch'); return true; } diff --git a/lib/plugins/authad/action.php b/lib/plugins/authad/action.php index 149f6852e..671138a98 100644 --- a/lib/plugins/authad/action.php +++ b/lib/plugins/authad/action.php @@ -18,7 +18,7 @@ class action_plugin_authad extends DokuWiki_Action_Plugin public function register(Doku_Event_Handler $controller) { $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 array $param */ - public function handleHtmlFormLoginOutput(Doku_Event $event, $param) + public function handleFormLoginOutput(Doku_Event $event, $param) { global $INPUT; /** @var auth_plugin_authad $auth */