Skip to content

Commit

Permalink
change event naming scheme
Browse files Browse the repository at this point in the history
FORM_*_OUTPUT scheme had been introduced since Apriil 2018, see dokuwiki#2286
  • Loading branch information
ssahara committed Aug 26, 2020
1 parent 8128de6 commit c6977b3
Show file tree
Hide file tree
Showing 15 changed files with 20 additions and 51 deletions.
6 changes: 2 additions & 4 deletions inc/Form/Form.php
Original file line number Diff line number Diff line change
Expand Up @@ -469,7 +469,7 @@ protected function balanceFieldsets()
/**
* 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)
Expand All @@ -478,9 +478,7 @@ public function toHTML($eventName = null)

// 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);
}

Expand Down
4 changes: 1 addition & 3 deletions inc/Ui/Editor.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@ class Editor extends Ui
* @author Andreas Gohr <andi@splitbrain.org>
*
* @triggers HTML_EDIT_FORMSELECTION
* @triggers HTMLFORM_EDIT_OUTPUT
* @return void
*/
public function show()
Expand Down Expand Up @@ -174,8 +173,7 @@ public function show()
}
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
}
Expand Down
4 changes: 1 addition & 3 deletions inc/Ui/Login.php
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@ public function __construct($showIcon = false)
*
* @author Andreas Gohr <andi@splitbrain.org>
*
* @triggers HTMLFORM_LOGIN_OUTPUT
* @return void
*/
public function show()
Expand Down Expand Up @@ -75,8 +74,7 @@ public function show()
$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>';
}
Expand Down
4 changes: 1 addition & 3 deletions inc/Ui/PageConflict.php
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,6 @@ public function __construct($text = '', $summary = '')
*
* @author Andreas Gohr <andi@splitbrain.org>
*
* @triggers HTMLFORM_CONFLICT_OUTPUT
* @return void
*/
public function show()
Expand All @@ -53,8 +52,7 @@ public function show()
$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 '<br /><br /><br /><br />';

Expand Down
4 changes: 1 addition & 3 deletions inc/Ui/PageDraft.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@ class PageDraft extends Ui
*
* @author Andreas Gohr <andi@splitbrain.org>
*
* @triggers HTMLFORM_DRAFT_OUTPUT
* @return void
*/
public function show()
Expand Down Expand Up @@ -49,8 +48,7 @@ public function show()
$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');
}

}
4 changes: 1 addition & 3 deletions inc/Ui/Recent.php
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,6 @@ public function __construct($first = 0, $show_changes = 'both')
* @author Kate Arzamastseva <pshns@ukr.net>
* @author Satoshi Sahara <sahara.satoshi@gmail.com>
*
* @triggers HTMLFORM_RECENT_OUTPUT
* @return void
*/
public function show()
Expand Down Expand Up @@ -98,8 +97,7 @@ public function show()
// 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');
}

/**
Expand Down
7 changes: 2 additions & 5 deletions inc/Ui/Revisions.php
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,6 @@ public function __construct($first = 0, $media_id = false)
* @author Kate Arzamastseva <pshns@ukr.net>
* @author Satoshi Sahara <sahara.satoshi@gmail.com>
*
* @triggers HTMLFORM_REVISIONS_OUTPUT
* @return void
*/
public function show()
Expand Down Expand Up @@ -115,8 +114,7 @@ protected function showMediaRevisions($id)

$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);
Expand Down Expand Up @@ -182,8 +180,7 @@ protected function showPageRevisions($id)

$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);
Expand Down
4 changes: 1 addition & 3 deletions inc/Ui/Search.php
Original file line number Diff line number Diff line change
Expand Up @@ -87,9 +87,7 @@ protected function getSearchFormHTML($query)

$searchForm->addFieldsetClose();

Event::createAndTrigger('FORM_SEARCH_OUTPUT', $searchForm);

return $searchForm->toHTML();
return $searchForm->toHTML('Search');
}

/**
Expand Down
4 changes: 1 addition & 3 deletions inc/Ui/Subscribe.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@ class Subscribe extends Ui
*
* @author Adrian Lang <lang@cosmocode.de>
*
* @triggers HTMLFORM_SUBSCRIBE_OUTPUT
* @return void
*/
public function show()
Expand Down Expand Up @@ -108,8 +107,7 @@ public function show()
$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 '</div>';
}
Expand Down
8 changes: 2 additions & 6 deletions inc/Ui/UserProfile.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,6 @@ class UserProfile extends Ui
*
* @author Andreas Gohr <andi@splitbrain.org>
*
* @triggers HTMLFORM_UPDATEPROFILE_OUTPUT
* @triggers HTMLFORM_PROFILEDELETE_OUTPUT
* @return void
*/
public function show()
Expand Down Expand Up @@ -88,8 +86,7 @@ public function show()
$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')) {
Expand Down Expand Up @@ -119,8 +116,7 @@ public function show()
$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 '</div>';
Expand Down
4 changes: 1 addition & 3 deletions inc/Ui/UserRegister.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@ class UserRegister extends Ui
*
* @author Andreas Gohr <andi@splitbrain.org>
*
* @triggers HTMLFORM_REGISTER_OUTPUT
* @return void
*/
public function show()
Expand Down Expand Up @@ -67,8 +66,7 @@ public function show()
$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 '</div>';
}
Expand Down
4 changes: 1 addition & 3 deletions inc/Ui/UserResendPwd.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@ class UserResendPwd extends Ui
* @author Benoit Chesneau <benoit@bchesneau.info>
* @author Andreas Gohr <andi@splitbrain.org>
*
* @triggers HTMLFORM_RESENDPWD_OUTPUT
* @return void
*/
public function show()
Expand All @@ -37,8 +36,7 @@ public function show()
$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>';
}
Expand Down
7 changes: 2 additions & 5 deletions inc/media.php
Original file line number Diff line number Diff line change
Expand Up @@ -1883,8 +1883,7 @@ function media_uploadform($ns, $auth, $fullscreen = false) {
}

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 '<p class="maxsize">';
Expand Down Expand Up @@ -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');
}

/**
Expand Down
3 changes: 1 addition & 2 deletions inc/template.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down
4 changes: 2 additions & 2 deletions lib/plugins/authad/action.php
Original file line number Diff line number Diff line change
Expand Up @@ -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');
}

/**
Expand Down Expand Up @@ -52,7 +52,7 @@ public function handleAuthLoginCheck(Doku_Event $event, $param)
* @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 */
Expand Down

0 comments on commit c6977b3

Please sign in to comment.