Skip to content

Commit 1a02160

Browse files
committed
Pass section id to included page edit button, fix warning dokufreaks#245
This fixes another undefined index 'hid' warning. Further, if the include plugin sets its own section id, this section id is passed to the editor now. This allows jumping back to the place from where the page has been included. Currently, these section ids are only set when a page is included for the first time.
1 parent e223151 commit 1a02160

File tree

3 files changed

+10
-7
lines changed

3 files changed

+10
-7
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
}

0 commit comments

Comments
 (0)