xref: /plugin/dwtimeline/action.php (revision 08c5c74535ab8a9d3f2131dac6cc63c7a8bbf983)
1<?php
2/**
3 * DokuWiki Plugin dwtimeline (Action Component)
4 *
5 * @license GPL 2 http://www.gnu.org/licenses/gpl-2.0.html
6 * @author  saggi <saggi@gmx.de>
7 */
8
9// must be run within Dokuwiki
10if(!defined('DOKU_INC')) die();
11
12class action_plugin_dwtimeline extends DokuWiki_Action_Plugin {
13
14    /**
15     * Register the eventhandlers
16     */
17    public function register(Doku_Event_Handler $controller) {
18        $controller->register_hook('TOOLBAR_DEFINE', 'AFTER', $this, 'insert_button', array ());
19    }
20
21    /**
22     * Inserts the toolbar button
23     */
24    public function insert_button(Doku_Event $event, $param) {
25        $event->data[] = array (
26            'type' => 'format',
27            'title' => $this->getLang('tl-button'),
28            'icon' => '../../plugins/dwtimeline/icons/timeline_marker.png',
29            'open' => $this->buildSkeleton(),
30            'sample' => $this->getLang('ms-content'),
31            'close' => '\n</milestone>\n</dwtimeline title="'.$this->getLang('tl-end').'">',
32        );
33    }
34
35    private function buildSkeleton() {
36        $skeleton = '';
37        $skeleton .= '<dwtimeline title="'.$this->getLang('tl-title').'" description="'.$this->getLang('tl-desc').'">\n';
38        $skeleton .= '<milestone title="'.$this->getLang('ms-title').'" description="'.$this->getLang('ms-desc').'" ';
39        $skeleton .= 'data="'.$this->getLang('ms-data').'">\n';
40        return $skeleton;
41    }
42
43
44}
45
46