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