Skip to content

Commit 9217c09

Browse files
authored
Merge pull request dokufreaks#262 from dokufreaks/feature/editform-improvements
Improve editing support and fix dokufreaks#245
2 parents a25f142 + 1a02160 commit 9217c09

File tree

4 files changed

+15
-11
lines changed

4 files changed

+15
-11
lines changed

action.php

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -285,8 +285,10 @@ function handle_secedit_button(Doku_Event &$event, $params) {
285285
if ($page_stack[0]['writable']) {
286286
$params = array('do' => 'edit',
287287
'id' => $page_stack[0]['id']);
288-
if ($page_stack[0]['redirect'])
288+
if ($page_stack[0]['redirect']) {
289289
$params['redirect_id'] = $ID;
290+
$params['hid'] = $data['hid'];
291+
}
290292
$event->result = '<div class="secedit">' . DOKU_LF .
291293
html_btn('incledit', $page_stack[0]['id'], '',
292294
$params, 'post',

helper.php

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -457,9 +457,11 @@ function _convert_instructions(&$ins, $lvl, $page, $sect, $flags, $root_id, $inc
457457
array_push($ins, array('plugin', array('include_closelastsecedit', array($endpos))));
458458
}
459459

460+
$include_secid = (isset($flags['include_secid']) ? $flags['include_secid'] : NULL);
461+
460462
// add edit button
461463
if($flags['editbtn']) {
462-
$this->_editbtn($ins, $page, $sect, $sect_title, ($flags['redirect'] ? $root_id : false));
464+
$this->_editbtn($ins, $page, $sect, $sect_title, ($flags['redirect'] ? $root_id : false), $include_secid);
463465
}
464466

465467
// add footer
@@ -484,7 +486,6 @@ function _convert_instructions(&$ins, $lvl, $page, $sect, $flags, $root_id, $inc
484486
}
485487

486488
// add instructions entry wrapper
487-
$include_secid = (isset($flags['include_secid']) ? $flags['include_secid'] : NULL);
488489
array_unshift($ins, array('plugin', array('include_wrap', array('open', $page, $flags['redirect'], $include_secid))));
489490
if (isset($flags['beforeeach']))
490491
array_unshift($ins, array('entity', array($flags['beforeeach'])));
@@ -516,11 +517,11 @@ function _footer($page, $sect, $sect_title, $flags, $footer_lvl, $root_id) {
516517
*
517518
* @author Michael Klier <[email protected]>
518519
*/
519-
function _editbtn(&$ins, $page, $sect, $sect_title, $root_id) {
520+
function _editbtn(&$ins, $page, $sect, $sect_title, $root_id, $hid = '') {
520521
$title = ($sect) ? $sect_title : $page;
521522
$editbtn = array();
522523
$editbtn[0] = 'plugin';
523-
$editbtn[1] = array('include_editbtn', array($title));
524+
$editbtn[1] = array('include_editbtn', array($title, $hid));
524525
$ins[] = $editbtn;
525526
}
526527

syntax/editbtn.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,10 +26,10 @@ function handle($match, $state, $pos, Doku_Handler $handler) {
2626
* @author Michael Klier <[email protected]>
2727
*/
2828
function render($mode, Doku_Renderer $renderer, $data) {
29-
list($title) = $data;
29+
list($title, $hid) = $data;
3030
if ($mode == 'xhtml') {
3131
if (defined('SEC_EDIT_PATTERN')) { // for DokuWiki Greebo and more recent versions
32-
$renderer->startSectionEdit(0, array('target' => 'plugin_include_editbtn', 'name' => $title));
32+
$renderer->startSectionEdit(0, array('target' => 'plugin_include_editbtn', 'name' => $title, 'hid' => $hid));
3333
} else {
3434
$renderer->startSectionEdit(0, 'plugin_include_editbtn', $title);
3535
}

syntax/wrap.php

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -30,18 +30,19 @@ function handle($match, $state, $pos, Doku_Handler $handler) {
3030
*/
3131
function render($mode, Doku_Renderer $renderer, $data) {
3232
if ($mode == 'xhtml') {
33-
list($state, $page, $redirect, $secid) = $data;
33+
$state = array_shift($data);
3434
switch($state) {
3535
case 'open':
36+
list($page, $redirect, $secid) = $data;
3637
if ($redirect) {
3738
if (defined('SEC_EDIT_PATTERN')) { // for DokuWiki Greebo and more recent versions
38-
$renderer->startSectionEdit(0, array('target' => 'plugin_include_start', 'name' => $page));
39+
$renderer->startSectionEdit(0, array('target' => 'plugin_include_start', 'name' => $page, 'hid' => ''));
3940
} else {
4041
$renderer->startSectionEdit(0, 'plugin_include_start', $page);
4142
}
4243
} else {
4344
if (defined('SEC_EDIT_PATTERN')) { // for DokuWiki Greebo and more recent versions
44-
$renderer->startSectionEdit(0, array('target' => 'plugin_include_start_noredirect', 'name' => $page));
45+
$renderer->startSectionEdit(0, array('target' => 'plugin_include_start_noredirect', 'name' => $page, 'hid' => ''));
4546
} else {
4647
$renderer->startSectionEdit(0, 'plugin_include_start_noredirect', $page);
4748
}
@@ -50,7 +51,7 @@ function render($mode, Doku_Renderer $renderer, $data) {
5051
// Start a new section with type != section so headers in the included page
5152
// won't print section edit buttons of the parent page
5253
if (defined('SEC_EDIT_PATTERN')) { // for DokuWiki Greebo and more recent versions
53-
$renderer->startSectionEdit(0, array('target' => 'plugin_include_end', 'name' => $page));
54+
$renderer->startSectionEdit(0, array('target' => 'plugin_include_end', 'name' => $page, 'hid' => ''));
5455
} else {
5556
$renderer->startSectionEdit(0, 'plugin_include_end', $page);
5657
}

0 commit comments

Comments
 (0)