-
Notifications
You must be signed in to change notification settings - Fork 1
/
Events.php
89 lines (79 loc) · 2.96 KB
/
Events.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
<?php
namespace olan\wbowhiteboard;
use humhub\modules\ui\menu\MenuLink;
use Yii;
use yii\helpers\Url;
class Events
{
/**
* Defines what to do when the top menu is initialized.
*
* @param $event
*/
// public static function onTopMenuInit($event)
// {
// $event->sender->addItem([
// 'label' => 'Whiteboard',
// 'icon' => '<i class="fa fa-pencil-square"></i>',
// 'url' => Url::to(['/wbo-whiteboard/index']),
// 'sortOrder' => 99999,
// 'isActive' => (Yii::$app->controller->module && Yii::$app->controller->module->id == 'whiteboard' && Yii::$app->controller->id == 'index'),
// ]);
// }
/**
* Defines what to do if admin menu is initialized.
*
* @param $event
*/
public static function onAdminMenuInit($event)
{
$event->sender->addItem([
'label' => 'WBO Whiteboard',
'url' => Url::to(['/wbo-whiteboard/admin']),
'group' => 'manage',
'icon' => '<i class="fa fa-pencil-square"></i>',
'isActive' => (Yii::$app->controller->module && Yii::$app->controller->module->id == 'wbo-whiteboard' && Yii::$app->controller->id == 'admin'),
'sortOrder' => 402,
]);
}
public static function onSpaceMenuInit($event)
{
$space = $event->sender->space;
if($space->isModuleEnabled('wbo-whiteboard'))
{
$event->sender->addItem([
'label' => 'WBO Whiteboard',
'url' => $space->createUrl('/wbo-whiteboard/index'),
// 'group' => 'manage',
'icon' => '<i class="fa fa-pencil-square"></i>',
'isActive' => MenuLink::isActiveState('wbo-whiteboard', 'index'),
'sortOrder' => 403,
]);
}
}
public static function onSpaceHeaderControlsMenu($event)
{
if($event->sender->space->isModuleEnabled('wbo-whiteboard') && $event->sender->space->isAdmin())
{
$event->sender->addEntry(new MenuLink([
'label' => Yii::t('WboWhiteboardModule.base', 'WBO Whiteboard'),
'url' => $event->sender->space->createUrl('/wbo-whiteboard/space-settings'),
'icon' => 'pencil-square',
'sortOrder' => 200,
]));
}
}
public static function onSpaceDefaultMenu($event)
{
if($event->sender->space->isModuleEnabled('wbo-whiteboard') && $event->sender->space->isAdmin())
{
$event->sender->addEntry(new MenuLink([
'label' => Yii::t('WboWhiteboardModule.base', 'Whiteboard'),
'url' => $event->sender->space->createUrl('/wbo-whiteboard/space-settings'),
// 'icon' => 'money',
'isActive' => MenuLink::isActiveState('wbo-whiteboard', 'space-settings'),
'sortOrder' => 405
]));
}
}
}