|
1 | 1 | <?php |
2 | 2 |
|
3 | | -if(!defined('DOKU_INC')) die(); |
| 3 | +if (!defined('DOKU_INC')) die(); |
4 | 4 |
|
5 | | -class action_plugin_drawio extends DokuWiki_Action_Plugin { |
6 | | - |
7 | | - public function register(Doku_Event_Handler $controller) { |
8 | | - $controller->register_hook('DOKUWIKI_STARTED', 'AFTER', $this, 'handle_started'); |
9 | | - $controller->register_hook('TEMPLATE_PAGETOOLS_DISPLAY', 'BEFORE', $this, 'add_button'); |
| 5 | +class action_plugin_drawio extends DokuWiki_Action_Plugin |
| 6 | +{ |
| 7 | + |
| 8 | + public function register(Doku_Event_Handler $controller) |
| 9 | + { |
| 10 | + $controller->register_hook('DOKUWIKI_STARTED', 'AFTER', $this, 'handle_started'); |
| 11 | + $controller->register_hook('MENU_ITEMS_ASSEMBLY', 'AFTER', $this, 'add_button'); |
10 | 12 | } |
11 | | - |
12 | | - public function handle_started(Doku_Event $event, $param) { |
| 13 | + |
| 14 | + public function handle_started(Doku_Event $event, $param) |
| 15 | + { |
13 | 16 | global $JSINFO; |
14 | 17 | $JSINFO['iseditor'] = auth_quickaclcheck('*') >= AUTH_UPLOAD; |
15 | 18 | $JSINFO['sectok'] = getSecurityToken(); |
16 | 19 | } |
17 | 20 |
|
18 | | - public function add_button(Doku_Event $event, $param) { |
19 | | - if($event->data['view'] == 'main') { |
20 | | - array_splice($event->data['items'], -1, 0, [ 'add_diagram' => '<li><a href="#" class="action" id="drawio-newfile-create"><span>Neues Diagramm</span></a></li>' ]); |
21 | | - } |
| 21 | + public function add_button(Doku_Event $event, $param) |
| 22 | + { |
| 23 | + if ($event->data['view'] != 'page') return; |
| 24 | + array_splice($event->data['items'], -1, 0, [new dokuwiki\plugin\drawio\MenuItem()]); |
22 | 25 | } |
23 | 26 | } |
0 commit comments