1<?php
2
3use dokuwiki\Extension\ActionPlugin;
4use dokuwiki\Extension\EventHandler;
5use dokuwiki\Extension\Event;
6
7/**
8 * @license    See LICENSE file
9 */
10// See help: https://www.dokuwiki.org/devel:toolbar
11class action_plugin_bpmnio_toolbar extends ActionPlugin
12{
13    public function register(EventHandler $controller)
14    {
15        $controller->register_hook('TOOLBAR_DEFINE', 'AFTER', $this, 'handleToolbar');
16    }
17
18    public function handleToolbar(Event $event)
19    {
20        $basedir = DOKU_BASE . 'lib/plugins/bpmnio/images/toolbar/';
21        $event->data[] = [
22            'type' => 'picker',
23            'title' => $this->getLang('picker'),
24            'icon' => $basedir . 'picker.png',
25            'list' => [
26                [
27                    'type' => 'format',
28                    'class' => 'plugin-bpmnio icon-large',
29                    'title' => $this->getLang('bpmn_add'),
30                    'icon' => $basedir . 'bpmn_add.png',
31                    'open' => $this->getFileContent('bpmn_open'),
32                    'close' => $this->getFileContent('bpmn_close')
33                ],
34                [
35                    'type' => 'format',
36                    'class' => 'plugin-bpmnio icon-large',
37                    'title' => $this->getLang('dmn_add'),
38                    'icon' => $basedir . 'dmn_add.png',
39                    'open' => $this->getFileContent('dmn_open'),
40                    'close' => $this->getFileContent('dmn_close')
41                ]
42            ]
43        ];
44    }
45
46    private function getFileContent($file)
47    {
48        return trim(file_get_contents(__DIR__ . '/../data/' . $file . '.text'));
49    }
50}
51