Skip to content

Commit

Permalink
Merge pull request #33 from gregoryloichot/master
Browse files Browse the repository at this point in the history
Make the plugin post 2020 compatible
  • Loading branch information
michitux authored Apr 16, 2024
2 parents ca1c8e7 + 1c4557b commit 4a63ea6
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 8 deletions.
20 changes: 12 additions & 8 deletions action.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@

if (!defined('DOKU_LF')) define('DOKU_LF', "\n");
if (!defined('DOKU_TAB')) define('DOKU_TAB', "\t");
if (!defined('DOKU_PLUGIN')) define('DOKU_PLUGIN',DOKU_INC.'lib/plugins/');

class action_plugin_saveandedit extends DokuWiki_Action_Plugin {

Expand All @@ -21,7 +20,7 @@ class action_plugin_saveandedit extends DokuWiki_Action_Plugin {
public function register(Doku_Event_Handler $controller) {
// try to register our handler at a late position so e.g. the edittable plugin has a possibility to process its data
$controller->register_hook('ACTION_ACT_PREPROCESS', 'BEFORE', $this, 'handle_action_act_preprocess', null, 1000);
$controller->register_hook('HTML_EDITFORM_OUTPUT', 'BEFORE', $this, 'handle_html_editform_output');
$controller->register_hook('FORM_EDIT_OUTPUT', 'BEFORE', $this, 'handle_html_editform_output');
}

/**
Expand Down Expand Up @@ -130,13 +129,18 @@ public function handle_action_act_preprocess(Doku_Event $event, $param) {
public function handle_html_editform_output(Doku_Event $event, $param) {
global $INPUT;

$pos = $event->data->findElementByAttribute('type','submit');
if(!$pos) return; // no submit button found, source view
$form = $event->data;
$pos = $form->findPositionByAttribute('type','submit');

if(!$pos) return; // no submit button found, source view
$pos -= 1;
$event->data->insertElement($pos++, form_makeOpenTag('div', array()));
$attrs = $INPUT->bool('saveandedit') ? array('checked' => 'checked') : array();
$event->data->insertElement($pos++, form_makeCheckboxField('saveandedit', '1', $this->getLang('btn_saveandedit'), '', '', $attrs));
$event->data->insertElement($pos++, form_makeCloseTag('div'));

$form->addTagOpen('div', $pos++);
$attrs = $INPUT->bool('saveandedit') ? array('checked' => 'checked') : array();

$cb = $form->addCheckBox('saveandedit', $this->getLang('btn_saveandedit'), $pos++);
$cb->attrs = $attrs;
$form->addtagClose('div', $pos++);
}
}

Expand Down
13 changes: 13 additions & 0 deletions lang/fr/lang.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
<?php
/**
* French language file for saveandedit plugin
*
* @author Michael Hamann <[email protected]>
*/

// custom language strings for the plugin
$lang['btn_saveandedit'] = 'Continuer à éditer après enregistrement';



//Setup VIM: ex: et ts=4 :

0 comments on commit 4a63ea6

Please sign in to comment.