forked from humhub-contrib/gallery
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Events.php
55 lines (48 loc) · 1.78 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
<?php
/**
* @link https://www.humhub.org/
* @copyright Copyright (c) 2015 HumHub GmbH & Co. KG
* @license https://www.humhub.com/licences
*/
namespace humhub\modules\gallery;
use humhub\modules\gallery\widgets\GallerySnippet;
use Yii;
/**
* The event handler for the gallery module.
*
* @package humhub.modules.gallery
* @since 1.0
* @author Sebastian Stumpf
*/
class Events
{
public static function onSpaceMenuInit($event)
{
if ($event->sender->space !== null && $event->sender->space->isModuleEnabled('gallery')) {
$event->sender->addItem([
'label' => Yii::t('GalleryModule.base', 'Gallery'),
'group' => 'modules',
'url' => $event->sender->space->createUrl('/gallery/list'),
'icon' => '<i class="fa fa-picture-o"></i>',
'isActive' => (Yii::$app->controller->module && Yii::$app->controller->module->id == 'gallery')
]);
}
}
public static function onProfileMenuInit($event)
{
if ($event->sender->user !== null && $event->sender->user->isModuleEnabled('gallery')) {
$event->sender->addItem([
'label' => Yii::t('GalleryModule.base', 'Gallery'),
'url' => $event->sender->user->createUrl('/gallery/list'),
'icon' => '<i class="fa fa-picture-o"></i>',
'isActive' => (Yii::$app->controller->module && Yii::$app->controller->module->id == 'gallery')
]);
}
}
public static function onSpaceSidebarInit($event)
{
if ($event->sender->space !== null && $event->sender->space->isModuleEnabled('gallery')) {
$event->sender->addWidget(GallerySnippet::class, ['contentContainer' => $event->sender->space], ['sortOrder' => 0]);
}
}
}