3 * DokuWiki Action Plugin Uparrow
5 * @license GPL 2 (http://www.gnu.org/licenses/gpl.html)
6 * @author Michael Klier <chi@chimeric.de>
8 // must be run within Dokuwiki
9 if(!defined('DOKU_INC')) die();
11 if(!defined('DOKU_PLUGIN')) define('DOKU_PLUGIN', DOKU_INC
.'lib/plugins/');
12 if(!defined('DOKU_LF')) define('DOKU_LF', "\n");
14 require_once(DOKU_PLUGIN
.'action.php');
17 * All DokuWiki plugins to extend the admin function
18 * need to inherit from this class
20 class action_plugin_uparrow
extends DokuWiki_Action_Plugin
{
24 'author' => 'Michael Klier',
25 'email' => 'chi@chimeric.de',
26 'date' => @file_get_contents
(DOKU_PLUGIN
.'uparrow/VERSION'),
27 'name' => 'UpArrow Plugin (action component)',
28 'desc' => 'Automatically adds an arrow which links to the top of the page after each section.',
29 'url' => 'http://dokuwiki.org/plugin:uparrow',
34 function register(&$controller) {
35 $controller->register_hook('PARSER_HANDLER_DONE', 'BEFORE', $this, 'insert_uparrow');
39 * Modifies the final instruction list of a page and adds instructions for
42 * Michael Klier <chi@chimeric.de>
44 function insert_uparrow(&$event, $param){
45 if(!$this->getConf('auto')) return;
47 $image = $this->getConf('image');
48 if(!@file_exists
(DOKU_PLUGIN
.'uparrow/images/' . $image)) {
49 $image = 'lib/plugins/uparrow/images/tango-big.png';
51 $image = 'lib/plugins/uparrow/images/' . $image; //DOKU_URL.
53 // uparrow plugin instructions
54 $uparrow = array('plugin', array('uparrow', array($image), 1, '~~UP~~'));
57 $ins =& $event->data
->calls
;
60 for($i=0;$i<$num;$i++
) {
61 if($ins[$i][0] == 'section_close') {
62 array_push($ins_new, $uparrow);
64 array_push($ins_new, $ins[$i]);
71 // vim:ts=4:sw=4:et:enc=utf-8: