-
-
Notifications
You must be signed in to change notification settings - Fork 3
/
Module.php
104 lines (85 loc) · 2.4 KB
/
Module.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
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
<?php
namespace humhub\modules\themeOrange;
use humhub\modules\ui\view\helpers\ThemeHelper;
use humhub\models\Setting;
use humhub\libs\DynamicConfig;
use Yii;
use yii\helpers\Url;
class Module extends \humhub\components\Module
{
/**
* @inheritdoc
*/
public $resourcesPath = 'resources';
/**
* @var string defines the style of comment links (options: icon, text, both)
*/
public $commentLink = 'icon';
/**
* @var string defines the style of like links (options: icon, text, both)
*/
public $likeLink = 'icon';
/**
* @var string defines the like icon (options: heart, thumbsup, star)
*/
public $likeIcon = 'heart';
const THEME_NAME = "themeOrange";
public static function getCommentLinkSetting() {
$commentLink = Yii::$app->getModule('theme-orange')->settings->get('commentLink', 'icon');
return $commentLink;
}
public static function getLikeLinkSetting() {
$likeLink = Yii::$app->getModule('theme-orange')->settings->get('likeLink', 'icon');
return $likeLink;
}
public static function getLikeIcon() {
$likeIcon = Yii::$app->getModule('theme-orange')->settings->get('likeIcon', 'heart');
return $likeIcon;
}
/*
* @inheritdoc
*/
public function getConfigUrl() {
return Url::to(['/theme-orange/config']);
}
/*
* @inheritdoc
*/
public function getDescription() {
return Yii::t('ThemeOrangeModule.base', 'Orange theme for HumHub based on the Community Theme');
}
public function enable() {
if (parent::enable()) {
$this->enableTheme();
return true;
}
return false;
}
private function enableTheme()
{
// Already a theme based theme is active
foreach (ThemeHelper::getThemeTree(Yii::$app->view->theme) as $theme) {
if ($theme->name === self::THEME_NAME) {
return;
}
}
$theme = ThemeHelper::getThemeByName(self::THEME_NAME);
if ($theme !== null) {
$theme->activate();
DynamicConfig::rewrite();
}
}
/**
* @inheritdoc
*/
public function disable() {
// Deselect theme (select community theme)
if (Yii::$app->view->theme->name == 'themeOrange') {
$theme = ThemeHelper::getThemeByName('HumHub');
if ($theme !== null) {
$theme->activate();
}
}
parent::disable();
}
}