|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
/* |
|
4
|
|
|
* This file is part of Jitamin. |
|
5
|
|
|
* |
|
6
|
|
|
* Copyright (C) Jitamin Team |
|
7
|
|
|
* |
|
8
|
|
|
* For the full copyright and license information, please view the LICENSE |
|
9
|
|
|
* file that was distributed with this source code. |
|
10
|
|
|
*/ |
|
11
|
|
|
|
|
12
|
|
|
namespace Jitamin\Model; |
|
13
|
|
|
|
|
14
|
|
|
use Jitamin\Foundation\Database\Model; |
|
15
|
|
|
|
|
16
|
|
|
/** |
|
17
|
|
|
* Class Skin. |
|
18
|
|
|
*/ |
|
19
|
|
|
class SkinModel extends Model |
|
20
|
|
|
{ |
|
21
|
|
|
/** |
|
22
|
|
|
* Get available skins. |
|
23
|
|
|
* |
|
24
|
|
|
* @param bool $prepend Prepend a default value |
|
25
|
|
|
* |
|
26
|
|
|
* @return array |
|
27
|
|
|
*/ |
|
28
|
|
|
public function getSkins($prepend = false) |
|
29
|
|
|
{ |
|
30
|
|
|
// Sorted by value |
|
31
|
|
|
$skins = [ |
|
32
|
|
|
'default' => t('Default'), |
|
33
|
|
|
'black' => t('Black'), |
|
34
|
|
|
'blue' => t('Blue'), |
|
35
|
|
|
'green' => t('Green'), |
|
36
|
|
|
'purple' => t('Purple'), |
|
37
|
|
|
'red' => t('Red'), |
|
38
|
|
|
'white' => t('White'), |
|
39
|
|
|
'yellow' => t('Yellow'), |
|
40
|
|
|
]; |
|
41
|
|
|
|
|
42
|
|
|
if ($prepend) { |
|
43
|
|
|
return ['' => t('Use system skin')] + $skins; |
|
44
|
|
|
} |
|
45
|
|
|
|
|
46
|
|
|
return $skins; |
|
47
|
|
|
} |
|
48
|
|
|
|
|
49
|
|
|
/** |
|
50
|
|
|
* Get current skin. |
|
51
|
|
|
* |
|
52
|
|
|
* @return string |
|
53
|
|
|
*/ |
|
54
|
|
View Code Duplication |
public function getCurrentSkin() |
|
|
|
|
|
|
55
|
|
|
{ |
|
56
|
|
|
if ($this->userSession->isLogged() && !empty($this->sessionStorage->user['skin'])) { |
|
|
|
|
|
|
57
|
|
|
return $this->sessionStorage->user['skin']; |
|
|
|
|
|
|
58
|
|
|
} |
|
59
|
|
|
|
|
60
|
|
|
return $this->settingModel->get('application_skin', 'default'); |
|
|
|
|
|
|
61
|
|
|
} |
|
62
|
|
|
|
|
63
|
|
|
/** |
|
64
|
|
|
* Get available layouts. |
|
65
|
|
|
* |
|
66
|
|
|
* @param bool $prepend Prepend a default value |
|
67
|
|
|
* |
|
68
|
|
|
* @return array |
|
69
|
|
|
*/ |
|
70
|
|
|
public function getLayouts($prepend = false) |
|
71
|
|
|
{ |
|
72
|
|
|
// Sorted by value |
|
73
|
|
|
$layouts = [ |
|
74
|
|
|
'fluid' => t('Fluid'), |
|
75
|
|
|
'fixed' => t('Fixed'), |
|
76
|
|
|
]; |
|
77
|
|
|
|
|
78
|
|
|
if ($prepend) { |
|
79
|
|
|
return ['' => t('Use system layout')] + $layouts; |
|
80
|
|
|
} |
|
81
|
|
|
|
|
82
|
|
|
return $layouts; |
|
83
|
|
|
} |
|
84
|
|
|
|
|
85
|
|
|
/** |
|
86
|
|
|
* Get current layout. |
|
87
|
|
|
* |
|
88
|
|
|
* @return string |
|
89
|
|
|
*/ |
|
90
|
|
View Code Duplication |
public function getCurrentLayout() |
|
|
|
|
|
|
91
|
|
|
{ |
|
92
|
|
|
if ($this->userSession->isLogged() && !empty($this->sessionStorage->user['layout'])) { |
|
|
|
|
|
|
93
|
|
|
return $this->sessionStorage->user['layout']; |
|
|
|
|
|
|
94
|
|
|
} |
|
95
|
|
|
|
|
96
|
|
|
return $this->settingModel->get('application_layout', ''); |
|
|
|
|
|
|
97
|
|
|
} |
|
98
|
|
|
|
|
99
|
|
|
/** |
|
100
|
|
|
* Get available dashboards. |
|
101
|
|
|
* |
|
102
|
|
|
* @param bool $prepend Prepend a default value |
|
103
|
|
|
* |
|
104
|
|
|
* @return array |
|
105
|
|
|
*/ |
|
106
|
|
|
public function getDashboards($prepend = false) |
|
107
|
|
|
{ |
|
108
|
|
|
// Sorted by value |
|
109
|
|
|
$dashboards = [ |
|
110
|
|
|
'projects' => t('My projects'), |
|
111
|
|
|
'stars' => t('Starred projects'), |
|
112
|
|
|
'calendar' => t('My calendar'), |
|
113
|
|
|
'activities' => t('My activities'), |
|
114
|
|
|
'tasks' => t('My tasks'), |
|
115
|
|
|
]; |
|
116
|
|
|
|
|
117
|
|
|
if ($prepend) { |
|
118
|
|
|
return ['' => t('Use system dashboard')] + $dashboards; |
|
119
|
|
|
} |
|
120
|
|
|
|
|
121
|
|
|
return $dashboards; |
|
122
|
|
|
} |
|
123
|
|
|
|
|
124
|
|
|
/** |
|
125
|
|
|
* Get current dashboard. |
|
126
|
|
|
* |
|
127
|
|
|
* @return string |
|
128
|
|
|
*/ |
|
129
|
|
View Code Duplication |
public function getCurrentDashboard() |
|
|
|
|
|
|
130
|
|
|
{ |
|
131
|
|
|
if ($this->userSession->isLogged() && !empty($this->sessionStorage->user['dashboard'])) { |
|
|
|
|
|
|
132
|
|
|
return $this->sessionStorage->user['dashboard']; |
|
|
|
|
|
|
133
|
|
|
} |
|
134
|
|
|
|
|
135
|
|
|
return $this->settingModel->get('application_dashboard', ''); |
|
|
|
|
|
|
136
|
|
|
} |
|
137
|
|
|
} |
|
138
|
|
|
|
Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.
You can also find more detailed suggestions in the “Code” section of your repository.