====== Edit Section Reorganizer Plugin ======
---- plugin ----
description: Move section edit buttons to the start of the section, support hierarchical sections on edit
author : Christophe Drevet
email : dr4ke@dr4ke.net
type : action
lastupdate : 2011-04-17
compatible : Lemming, Anteater
depends :
conflicts :
similar : editsections2
tags : !obsolete, !discontinued, editing, section
downloadurl: https://github.com/dr4Ke/editsections/tarball/master
bugtracker : https://github.com/dr4Ke/editsections/issues
sourcerepo : https://github.com/dr4Ke/editsections
donationurl:
----
===== Obsolete =====
This plugin is now obsolete and won't be maintained as I don't use it anymore (at least by me, //Christophe Drevet// 14-10-2012). This other plugin can be used (didn't try it, though) plugin [[Editsections2]], developed on https://github.com/kazmiya/dokuwiki-plugin-editsections2
See plugin [[Editsections2]]
===== Plugin =====
The "editsections" plugin moves edit section buttons up to the heading they originated from. Configurable for nested (hierarchical) or flat edit sections. Nested edit sections cover the same indentation level as their heading.
Since 2010-11-07 dokuwiki release, this plugin can't store useful things in the cache. So, there is an option to disable cache (only for writers) in order to use all features :
* nested editing
* names in the summary
The Edit Section Reorganizer Plugin is identified as "editsections" in the Plugin Manager.
===== Installing =====
==== Plugin Manager ====
Search and install the plugin using the [[plugin:extension|Extension Manager]]. Refer to [[:Plugins]] on how to install plugins manually.
===== Technical Notes =====
This plugin uses [[:devel:events_list|action events]] to do some clever things with the [[:devel:parser|instruction list]] before it gets rendered into XHTML. This also means that the work of this plugin is cached in the stored instructions saved after parsing a wiki page. The work of this plugin is greatly simplified by the use of [[http://www.php.net/references|references]]. Note that ''$edits'' is an array of references to the subset of [[:devel:parser|instructions]] that need to be changed. The small CSS adjustment is used to clearly associate the edit section buttons with their headings. A JS script is used to adjust hightlighting accordingly.
==== Source ====
New sources are now freely available at [[https://github.com/dr4Ke/editsections|github]]
Old source :
'Ben Coburn',
'email' => 'btcoburn@silicodon.net',
'date' => '2006-05-23',
'name' => 'Edit Section Reorganizer',
'desc' => 'Moves edit section buttons up to the heading they originated from. '.
'Configurable for nested (hierarchical) or flat edit sections. '.
'Requires the development version of DokuWiki from 2006-05-23 or a later release.',
'url' => 'http://source.silicodon.net/releases/dokuwiki-plugins/edit-section-reorganizer/editsections.tgz',
);
}
function register(Doku_Event_Handler $controller) {
$controller->register_hook('PARSER_HANDLER_DONE', 'BEFORE', $this, 'rewrite_sections');
}
function rewrite_sections(&$event, $ags) {
// get the instructions list from the handler
$calls =& $event->data->calls;
$edits = array();
$order = $this->getConf('order_type');
// scan instructions for edit sections
$size = count($calls);
for ($i=0; $i<$size; $i++) {
if ($calls[$i][0]=='section_edit') {
$edits[] =& $calls[$i];
}
}
// rewrite edit section instructions
$last = max(count($edits)-1,0);
for ($i=0; $i<=$last; $i++) {
$end = 0;
// get data to move
$start = $edits[min($i+1,$last)][1][0];
$level = $edits[min($i+1,$last)][1][2];
$name = $edits[min($i+1,$last)][1][3];
// find the section end point
if ($order) {
$finger = $i+2;
while (isset($edits[$finger]) && $edits[$finger][1][2]>$level) {
$finger++;
}
if (isset($edits[$finger])) {
$end = $edits[$finger][1][0]-1;
}
} else {
$end = $edits[min($i+1,$last)][1][1];
}
// put the data back where it belongs
$edits[$i][1][0] = $start;
$edits[$i][1][1] = $end;
$edits[$i][1][2] = $level;
$edits[$i][1][3] = $name;
}
$edits[max($last-1,0)][1][1] = 0; // set new last section
$edits[$last][1][0] = -1; // hide old last section
}
}
/*
Makes the default template display much better with this plugin.
If using other templates, you may want to make your own adjustments.
This moves the section edit button down onto the same "line" as the header
that it belongs to.
Note: Adding the 'body' selector makes these rules more specific, and so
ensures that they will augment DokuWiki's 'secedit' css rules. You should
be able to override this by adding the 'html' selector to the 'secedit' css
rules in your template.
*/
body div.dokuwiki div.secedit {
overflow: visible;
}
body div.dokuwiki div.secedit input.button {
margin-top: 1.25em;
}
===== Discussion =====
:?: Is it possible to place the edit button exactly under the
function header($text, $level, $pos) {
global $conf;
// create a unique header id
$hid = $this->_headerToLink($text,'true');
//handle TOC
if($level >= $conf['toptoclevel'] && $level <= $conf['maxtoclevel']){
// the TOC is one of our standard ul list arrays ;-)
$this->toc[] = array( 'hid' => $hid,
'title' => $text,
'type' => 'ul',
'level' => $level-$conf['toptoclevel']+1);
}
// write the header
$this->doc .= DOKU_LF.'
== /inc/parser/xhtml.php: NEW ==
function header($text, $level, $pos) {
global $conf;
// create a unique header id
$hid = $this->_headerToLink($text,'true');
//handle TOC
if($level >= $conf['toptoclevel'] && $level <= $conf['maxtoclevel']){
// the TOC is one of our standard ul list arrays ;-)
$this->toc[] = array( 'hid' => $hid,
'title' => $text,
'type' => 'ul',
'level' => $level-$conf['toptoclevel']+1);
}
// write the header
$this->doc .= DOKU_LF.'
== /conf/local.php: Option-Add ==
insert this:\\
(=1 On, =0 Off)
$conf['editsectionreplace'] = 1;
----
====== dokuwiki-rc2007-05-24 ======
I just upgraded my DokuWiki [[http://www.patentblurb.com/ | site]] and found that this plug in seems to work, with the same problems as before, i.e., the edit button is positioned above the header line. I found that the ORIGINAL xhtml.php fix works to place it in-line with the first row of the header (which looks great when the header is only on one line). The modified xhtml.php fix places it **below** the header line. --- //[[lenehey@gmail.com|Lenny]] 2007-05-27 16:07//
>i don't understand exactly what you min, but the position of the edit button can by selected by activating one of this 3 lines.
you can experiment wit this an activate ONE of the lines.
what is the result you want? (rc2007-05-24 no tested)
//$this->doc .= ''.""."".DOKU_LF;
$this->doc .= "".''."".DOKU_LF;
//$this->doc .= ""."".''.DOKU_LF;
====== DokuWiki-2007-06-26 ======
The plugin works without any changes (header). Be sure to touch one of the config files to purge the cache - otherwise you won't see the change instantly.
====== DokuWiki-2008-05-05 ======
I have a new version of the code above, which works with DokuWiki 2008-05-05, and moves the button up so that it is right next to the headers. Note this gets rid of the config option, to make the code a bit simpler. If you're making this mod, I'm going to assume that you want it turned on. :-)
== /inc/parser/xhtml.php: ORIGINAL ==
function header($text, $level, $pos) {
$hid = $this->_headerToLink($text,true);
//only add items within configured levels
$this->toc_additem($hid, $text, $level);
// write the header
$this->doc .= DOKU_LF.'
== /inc/parser/xhtml.php: NEW ==
function header($text, $level, $pos) {
global $conf; /* NEW */
$hid = $this->_headerToLink($text,true);
//only add items within configured levels
$this->toc_additem($hid, $text, $level);
// write the header
/* NEW */
if ($level<=$conf['maxseclevel'])
$this->doc .= DOKU_LF.''.'
I actually found that moved the buttons up a bit too high, so you may want to put in some CSS in your template with a ''margin-top''
div.dokuwiki div.secedit input.button {
border-color: __form_border__;
font-size: 100%;
/* NEW */
margin-top:10px;
/* NEW */
}
Using the monobook-template, how could I fix the position of the edit-button? Where would I place a CSS file, and what would it be named and what would I type into it? :-)
[[Marc.Jedamzik@hil.interpane.net|Jedamzik, Marc]]
====== DokuWiki-2009-12-25 ======
The plugin installs and seems to work fine. But DokuWiki has a nice new feature: section highlighting. Section highlighting is built so it highlights the section above the button, this also needs a change after installing this plugin: the section below needs highlighting now. How could I fix this? --- //Klap-in 2010/01/02 01:49//
@Klap-in: You can do this by changing the ''addInitEvent()'' function in ''lib/scripts/script.js''. Simply replace any instance of ''previousSibling'' with ''nextSibling'' in that function (there are four places it needs to be changed) -- //DLO 5-Feb-2010//
@DLO: Thanks, it works for the flat usage of this plugin. I added a script.js that works with both settings (flat and nested), a french translation and made a few other modifications and published a new version of this plugin. It can be downloaded at : [[https://github.com/downloads/dr4Ke/editsections/editsections.tar.gz]] -- //dr4Ke 11 May 2010//
====== DokuWiki-2010-11-07 ======
The plugin doesn't work as section editing is now managed by the renderer.
That's really a shame. Perhaps this functionality should be included as an option in Dokuwiki? -- //Lackbeard 12 Nov 2010//
> Same for me, after editing a page every edit links on the page disappears, It's a shame because this functionality is really useful.
>> It works now (release 2010-11-28) but can't make use of the cache. Work is in progress to either include the functionality in dokuwiki or add more hooks. -- //Christophe Drevet 28-11-2010//
>>> After updating and enabling the plugin the title in the browser title bar disapear, the