xref: /plugin/dwtimeline/action.php (revision 08c5c74535ab8a9d3f2131dac6cc63c7a8bbf983)
14ff971beSsaggi-dw<?php
24ff971beSsaggi-dw/**
34ff971beSsaggi-dw * DokuWiki Plugin dwtimeline (Action Component)
44ff971beSsaggi-dw *
54ff971beSsaggi-dw * @license GPL 2 http://www.gnu.org/licenses/gpl-2.0.html
64ff971beSsaggi-dw * @author  saggi <saggi@gmx.de>
74ff971beSsaggi-dw */
84ff971beSsaggi-dw
94ff971beSsaggi-dw// must be run within Dokuwiki
104ff971beSsaggi-dwif(!defined('DOKU_INC')) die();
114ff971beSsaggi-dw
124ff971beSsaggi-dwclass action_plugin_dwtimeline extends DokuWiki_Action_Plugin {
134ff971beSsaggi-dw
144ff971beSsaggi-dw    /**
154ff971beSsaggi-dw     * Register the eventhandlers
164ff971beSsaggi-dw     */
174ff971beSsaggi-dw    public function register(Doku_Event_Handler $controller) {
184ff971beSsaggi-dw        $controller->register_hook('TOOLBAR_DEFINE', 'AFTER', $this, 'insert_button', array ());
194ff971beSsaggi-dw    }
204ff971beSsaggi-dw
214ff971beSsaggi-dw    /**
224ff971beSsaggi-dw     * Inserts the toolbar button
234ff971beSsaggi-dw     */
244ff971beSsaggi-dw    public function insert_button(Doku_Event $event, $param) {
254ff971beSsaggi-dw        $event->data[] = array (
264ff971beSsaggi-dw            'type' => 'format',
274ff971beSsaggi-dw            'title' => $this->getLang('tl-button'),
284ff971beSsaggi-dw            'icon' => '../../plugins/dwtimeline/icons/timeline_marker.png',
294ff971beSsaggi-dw            'open' => $this->buildSkeleton(),
304ff971beSsaggi-dw            'sample' => $this->getLang('ms-content'),
314ff971beSsaggi-dw            'close' => '\n</milestone>\n</dwtimeline title="'.$this->getLang('tl-end').'">',
324ff971beSsaggi-dw        );
334ff971beSsaggi-dw    }
344ff971beSsaggi-dw
354ff971beSsaggi-dw    private function buildSkeleton() {
36*08c5c745SSteffen Sagert        $skeleton = '';
374ff971beSsaggi-dw        $skeleton .= '<dwtimeline title="'.$this->getLang('tl-title').'" description="'.$this->getLang('tl-desc').'">\n';
384ff971beSsaggi-dw        $skeleton .= '<milestone title="'.$this->getLang('ms-title').'" description="'.$this->getLang('ms-desc').'" ';
394ff971beSsaggi-dw        $skeleton .= 'data="'.$this->getLang('ms-data').'">\n';
404ff971beSsaggi-dw        return $skeleton;
414ff971beSsaggi-dw    }
424ff971beSsaggi-dw
434ff971beSsaggi-dw
444ff971beSsaggi-dw}
454ff971beSsaggi-dw
46