Skip to content

Commit a25f142

Browse files
authored
Merge pull request dokufreaks#275 from dokufreaks/newforms
support new form events. fixes 274
2 parents dffff5e + 3684bc2 commit a25f142

File tree

1 file changed

+26
-17
lines changed

1 file changed

+26
-17
lines changed

action.php

Lines changed: 26 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -3,40 +3,43 @@
33
* Include Plugin: Display a wiki page within another wiki page
44
*
55
* Action plugin component, for cache validity determination
6-
*
6+
*
77
* @license GPL 2 (http://www.gnu.org/licenses/gpl.html)
8-
* @author Christopher Smith <[email protected]>
8+
* @author Christopher Smith <[email protected]>
99
* @author Michael Klier <[email protected]>
1010
*/
11-
11+
1212
/**
1313
* All DokuWiki plugins to extend the parser/rendering mechanism
1414
* need to inherit from this class
1515
*/
1616
class action_plugin_include extends DokuWiki_Action_Plugin {
17-
17+
1818
/* @var helper_plugin_include $helper */
1919
var $helper = null;
2020

2121
function __construct() {
2222
$this->helper = plugin_load('helper', 'include');
2323
}
24-
24+
2525
/**
2626
* plugin should use this method to register its handlers with the dokuwiki's event controller
2727
*/
2828
function register(Doku_Event_Handler $controller) {
2929
/* @var Doku_event_handler $controller */
3030
$controller->register_hook('INDEXER_PAGE_ADD', 'BEFORE', $this, 'handle_indexer');
3131
$controller->register_hook('INDEXER_VERSION_GET', 'BEFORE', $this, 'handle_indexer_version');
32-
$controller->register_hook('PARSER_CACHE_USE','BEFORE', $this, '_cache_prepare');
33-
$controller->register_hook('HTML_EDITFORM_OUTPUT', 'BEFORE', $this, 'handle_form');
34-
$controller->register_hook('HTML_CONFLICTFORM_OUTPUT', 'BEFORE', $this, 'handle_form');
35-
$controller->register_hook('HTML_DRAFTFORM_OUTPUT', 'BEFORE', $this, 'handle_form');
36-
$controller->register_hook('ACTION_SHOW_REDIRECT', 'BEFORE', $this, 'handle_redirect');
37-
$controller->register_hook('PARSER_HANDLER_DONE', 'BEFORE', $this, 'handle_parser');
38-
$controller->register_hook('PARSER_METADATA_RENDER', 'AFTER', $this, 'handle_metadata');
39-
$controller->register_hook('HTML_SECEDIT_BUTTON', 'BEFORE', $this, 'handle_secedit_button');
32+
$controller->register_hook('PARSER_CACHE_USE','BEFORE', $this, '_cache_prepare');
33+
$controller->register_hook('HTML_EDITFORM_OUTPUT', 'BEFORE', $this, 'handle_form'); // todo remove
34+
$controller->register_hook('FORM_EDIT_OUTPUT', 'BEFORE', $this, 'handle_form');
35+
$controller->register_hook('HTML_CONFLICTFORM_OUTPUT', 'BEFORE', $this, 'handle_form'); // todo remove
36+
$controller->register_hook('FORM_CONFLICT_OUTPUT', 'BEFORE', $this, 'handle_form');
37+
$controller->register_hook('HTML_DRAFTFORM_OUTPUT', 'BEFORE', $this, 'handle_form'); // todo remove
38+
$controller->register_hook('FORM_DRAFT_OUTPUT', 'BEFORE', $this, 'handle_form');
39+
$controller->register_hook('ACTION_SHOW_REDIRECT', 'BEFORE', $this, 'handle_redirect');
40+
$controller->register_hook('PARSER_HANDLER_DONE', 'BEFORE', $this, 'handle_parser');
41+
$controller->register_hook('PARSER_METADATA_RENDER', 'AFTER', $this, 'handle_metadata');
42+
$controller->register_hook('HTML_SECEDIT_BUTTON', 'BEFORE', $this, 'handle_secedit_button');
4043
$controller->register_hook('PLUGIN_MOVE_HANDLERS_REGISTER', 'BEFORE', $this, 'handle_move_register');
4144
}
4245

@@ -172,10 +175,16 @@ function handle_parser(Doku_Event $event, $param) {
172175
/**
173176
* Add a hidden input to the form to preserve the redirect_id
174177
*/
175-
function handle_form(Doku_Event &$event, $param) {
176-
if (array_key_exists('redirect_id', $_REQUEST)) {
177-
$event->data->addHidden('redirect_id', cleanID($_REQUEST['redirect_id']));
178-
}
178+
function handle_form(Doku_Event $event, $param)
179+
{
180+
if (!array_key_exists('redirect_id', $_REQUEST)) return;
181+
182+
if(is_a($event->data, \dokuwiki\Form\Form::class)) {
183+
$event->data->setHiddenField('redirect_id', cleanID($_REQUEST['redirect_id']));
184+
} else {
185+
// todo remove when old FORM events are no longer supported
186+
$event->data->addHidden('redirect_id', cleanID($_REQUEST['redirect_id']));
187+
}
179188
}
180189

181190
/**

0 commit comments

Comments
 (0)