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
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
|
<?php
namespace Kanboard\Plugin\Customizer;
use Kanboard\Core\Plugin\Base;
use Kanboard\Core\Translator;
use Kanboard\Core\Security\Role;
use Kanboard\Event\AuthSuccessEvent;
use Kanboard\Core\Security\AuthenticationManager;
use Kanboard\Plugin\Customizer\Model\CustomizerFileModel;
class Plugin extends Base
{
public function initialize()
{
global $customizer;
// Themes
$customizer['themes'] = array(
'Default' => 'plugins/Customizer/Assets/css/theme.css'
);
$scanned_temp_themes = array_diff(scandir('plugins/Customizer/Assets/css/userthemes'), array('..', '.'));
$scanned_preset_themes = array_diff(scandir('plugins/Customizer/Assets/css/themes'), array('..', '.'));
foreach ($scanned_temp_themes as $theme) {
unlink('plugins/Customizer/Assets/css/userthemes/' . $theme);
}
if (file_exists(DATA_DIR . '/files/customizer/themes')) {
$scanned_user_themes = array_diff(scandir(DATA_DIR . '/files/customizer/themes'), array('..', '.'));
foreach ($scanned_user_themes as $theme) {
copy(DATA_DIR . '/files/customizer/themes/' . $theme, 'plugins/Customizer/Assets/css/userthemes/' . $theme);
$customizer['themes'][rtrim($theme, '.css')] = 'plugins/Customizer/Assets/css/userthemes/' . $theme;
}
} else { mkdir(DATA_DIR . '/files/customizer/themes', 0755, true); }
foreach ($scanned_preset_themes as $theme) {
$customizer['themes'][rtrim($theme, '.css')] = 'plugins/Customizer/Assets/css/themes/' . $theme;
}
//Helper
$this->helper->register('themeHelper', '\Kanboard\Plugin\Customizer\Helper\ThemeHelper');
$this->helper->register('dynamicAvatar', '\Kanboard\Plugin\Customizer\Helper\DynamicAvatar');
//Check if login logo is set
if (null !== $this->customizerFileModel->getByType(3)) {
$customizer['loginCheck'] = true;
} else {
$customizer['loginCheck'] = false;
}
//Grabs login page settings from database
$customizer['backURL'] = $this->configModel->get('background_url', '');
$customizer['backColor'] = $this->configModel->get('loginbackground_color', '#ffffff');
$customizer['logoSize'] = $this->configModel->get('loginlogo_size', '50');
$customizer['loginpanel_color'] = $this->configModel->get('loginpanel_color', '#ffffff');
$customizer['login_shadow_color'] = $this->configModel->get('login_shadow_color', '#333');
$customizer['login_shadow'] = $this->configModel->get('login_shadow', '0');
$customizer['login_border_color'] = $this->configModel->get('login_border_color', '#ffffff');
$customizer['login_border'] = $this->configModel->get('login_border', '0');
$customizer['login_btn_color'] = $this->configModel->get('login_btn_color', '#3079ed');
$customizer['login_btn_shadow_color'] = $this->configModel->get('login_btn_shadow_color', '#333');
$customizer['login_btn_border_color'] = $this->configModel->get('login_btn_border_color', 'transparent');
$customizer['login_btn_shade_color'] = $this->configModel->get('login_btn_shade_color', 'transparent');
$customizer['login_btn_font_color'] = $this->configModel->get('login_btn_font_color', '#ffffff');
$customizer['login_btn_shadow'] = $this->configModel->get('login_btn_shadow', '0');
$customizer['login_btn_border'] = $this->configModel->get('login_btn_border', '0');
$customizer['login_btn_width'] = $this->configModel->get('login_btn_width', '95');
$customizer['login_note'] = $this->configModel->get('login_note', '');
//Templates and Assets
$this->template->hook->attach('template:config:sidebar', 'customizer:config/sidebar');
$this->template->setTemplateOverride('header/title', 'customizer:header/title');
$this->template->setTemplateOverride('header/user_dropdown', 'customizer:header/user_dropdown');
$this->template->setTemplateOverride('board/task_avatar', 'customizer:board/task_avatar');
$this->template->setTemplateOverride('layout', 'customizer:layout/layout');
$this->template->setTemplateOverride('auth/index', 'customizer:layout/index');
$this->hook->on('template:layout:css', array('template' => 'plugins/Customizer/Assets/rgbaColorPicker/rgbaColorPicker.css'));
$this->hook->on('template:layout:js', array('template' => 'plugins/Customizer/Assets/rgbaColorPicker/rgbaColorPicker.js'));
$this->hook->on('template:layout:css', array('template' => 'plugins/Customizer/Assets/css/customizer.css'));
$this->hook->on('template:layout:js', array('template' => 'plugins/Customizer/Assets/js/customizer.js'));
$this->template->hook->attach('customizer:config:themecreator', 'customizer:config/themecreator');
if ($customizer['login_note'] != '') {
$this->template->hook->attach('template:auth:login-form:newbox', 'customizer:layout/note');
}
if ($this->configModel->get('toggle_user_themes', 'disable') == 'enable') {
$this->template->setTemplateOverride('user_modification/show', 'customizer:user_mod/show');
}
if ($this->configModel->get('use_custom_login', '') == 'checked') {
$this->template->hook->attach('customizer:config:style', 'customizer:layout/preview_style');
$this->template->hook->attach('template:auth:login-form:before', 'customizer:layout/login_with_custom');
} else {
$this->template->hook->attach('template:auth:login-form:before', 'customizer:layout/login_no_custom');
}
//Routes
$this->route->addRoute('settings/customizer', 'CustomizerFileController', 'show', 'Customizer');
//Permissions for login page to access logos
$this->applicationAccessMap->add('CustomizerFileController', array('image', 'loginlogo', 'logo', 'link', 'logoexists', 'linkexists'), Role::APP_PUBLIC);
//Get accurate version
$wasmaster = str_replace('v', '', APP_VERSION);
$wasmaster = preg_replace('/\s+/', '', $wasmaster);
if (strpos(APP_VERSION, 'master') !== false && file_exists('ChangeLog')) { $wasmaster = trim(file_get_contents('ChangeLog', false, null, 8, 6), ' '); }
if (version_compare($wasmaster, '1.2.4') >= 0) {
$this->template->setTemplateOverride('header/title', 'customizer:header/title');
} else {
$this->template->setTemplateOverride('header/title', 'customizer:header/title_older_kb');
}
}
public function onStartup()
{
Translator::load($this->languageModel->getCurrentLanguage(), __DIR__.'/Locale');
$user_id = $this->customizerFileModel->getUserSessionId();
$user_theme = $this->userMetadataModel->get($user_id, 'themeSelection', $this->configModel->get('themeSelection', 'plugins/Customizer/Assets/css/theme.css' ));
$default_theme = $this->configModel->get('themeSelection', 'plugins/Customizer/Assets/css/theme.css');
if ($this->configModel->get('toggle_user_themes', 'disable') == 'enable') {
$this->hook->on('template:layout:css', array('template' => $user_theme));
} else {
$this->hook->on('template:layout:css', array('template' => $default_theme));
}
}
public function getClasses() {
return array(
'Plugin\Customizer\Model' => array(
'CustomizerFileModel',
)
);
}
public function getPluginName()
{
return 'Customizer';
}
public function getPluginDescription()
{
return t('Completely customize your Kanboard experience with logos, favicons & themes.');
}
public function getPluginAuthor()
{
return 'Craig Crosby';
}
public function getPluginVersion()
{
return '1.13.1';
}
public function getPluginHomepage()
{
return 'https://github.com/creecros/Customizer';
}
public function getCompatibleVersion()
{
return '>=1.0.42';
}
}
|