Skip to content

Commit bf8dfdb

Browse files
committed
adjustment to work with menu system
1 parent 222c56d commit bf8dfdb

File tree

5 files changed

+52
-17
lines changed

5 files changed

+52
-17
lines changed

MenuItem.php

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
<?php
2+
3+
namespace dokuwiki\plugin\drawio;
4+
5+
use dokuwiki\Menu\Item\AbstractItem;
6+
7+
class MenuItem extends AbstractItem {
8+
9+
/** @inheritDoc */
10+
protected $type = 'add_diagram';
11+
12+
/** @inheritDoc */
13+
protected $svg = __DIR__ . '/drawing.svg';
14+
15+
/**
16+
* @inheritDoc
17+
* @todo localize
18+
*/
19+
public function getLabel()
20+
{
21+
return 'Neues Diagramm';
22+
}
23+
24+
/** @inheritDoc */
25+
public function getLinkAttributes($classprefix = 'menuitem ')
26+
{
27+
$attr = parent::getLinkAttributes($classprefix);
28+
$attr['href'] = '#';
29+
$attr['id'] = 'drawio-newfile-create';
30+
return $attr;
31+
}
32+
}

action.php

Lines changed: 15 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,26 @@
11
<?php
22

3-
if(!defined('DOKU_INC')) die();
3+
if (!defined('DOKU_INC')) die();
44

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');
1012
}
11-
12-
public function handle_started(Doku_Event $event, $param) {
13+
14+
public function handle_started(Doku_Event $event, $param)
15+
{
1316
global $JSINFO;
1417
$JSINFO['iseditor'] = auth_quickaclcheck('*') >= AUTH_UPLOAD;
1518
$JSINFO['sectok'] = getSecurityToken();
1619
}
1720

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()]);
2225
}
2326
}

drawing.svg

Lines changed: 1 addition & 0 deletions
Loading

manager.dat

Lines changed: 0 additions & 1 deletion
This file was deleted.

plugin.info.txt

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
base drawio
2-
author n/a
3-
email n/a
4-
date n/a
2+
author Innovakom + CosmoCode
3+
4+
date 2020-01-07
55
name Draw.io plugin
66
desc Embed Draw.io editor
7-
url http://www.dokuwiki.org
7+
url https://innovakom.de

0 commit comments

Comments
 (0)