maio
[h2N7SspZmY.git] / lib / plugins / uparrow / action.php
blob0ba8c51bb48ade080082683ce2a0496ebd0dbb8b
1 <?php
2 /**
3 * DokuWiki Action Plugin Uparrow
4 *
5 * @license GPL 2 (http://www.gnu.org/licenses/gpl.html)
6 * @author Michael Klier <chi@chimeric.de>
7 */
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');
16 /**
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 {
22 function getInfo() {
23 return array(
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',
33 // register hook
34 function register(&$controller) {
35 $controller->register_hook('PARSER_HANDLER_DONE', 'BEFORE', $this, 'insert_uparrow');
38 /**
39 * Modifies the final instruction list of a page and adds instructions for
40 * an uparow link.
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';
50 } else {
51 $image = 'lib/plugins/uparrow/images/' . $image; //DOKU_URL.
53 // uparrow plugin instructions
54 $uparrow = array('plugin', array('uparrow', array($image), 1, '~~UP~~'));
56 $ins_new = array();
57 $ins =& $event->data->calls;
58 $num = count($ins);
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]);
67 $ins = $ins_new;
71 // vim:ts=4:sw=4:et:enc=utf-8: