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
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
|
<?php
namespace Kanboard\Helper;
use Kanboard\Core\Base;
/**
* Application Helper
*
* @package helper
* @author Frederic Guillot
*/
class AppHelper extends Base
{
public function tooltipMarkdown($markdownText, $icon = 'fa-info-circle')
{
return '<span class="tooltip"><i class="fa '.$icon.'"></i><script type="text/template"><div class="markdown">'.$this->helper->text->markdown($markdownText).'</div></script></span>';
}
public function tooltipLink($label, $link)
{
return '<span class="tooltip" data-href="'.$link.'">'.$label.'</span>';
}
public function getToken()
{
return $this->token;
}
public function isAjax()
{
return $this->request->isAjax();
}
/**
* Render Javascript component
*
* @param string $name
* @param array $params
* @return string
*/
public function component($name, array $params = array())
{
return '<div class="js-'.$name.'" data-params=\''.json_encode($params, JSON_HEX_APOS).'\'></div>';
}
/**
* Get config variable
*
* @access public
* @param string $param
* @param mixed $default
* @return mixed
*/
public function config($param, $default = '')
{
return $this->configModel->get($param, $default);
}
/**
* Make sidebar menu active
*
* @access public
* @param string $controller
* @param string $action
* @param string $plugin
* @return string
*/
public function checkMenuSelection($controller, $action = '', $plugin = '')
{
$result = strtolower($this->getRouterController()) === strtolower($controller);
if ($result && $action !== '') {
$result = strtolower($this->getRouterAction()) === strtolower($action);
}
if ($result && $plugin !== '') {
$result = strtolower($this->getPluginName()) === strtolower($plugin);
}
return $result ? 'class="active"' : '';
}
/**
* Get plugin name from route
*
* @access public
* @return string
*/
public function getPluginName()
{
return $this->router->getPlugin();
}
/**
* Get router controller
*
* @access public
* @return string
*/
public function getRouterController()
{
return $this->router->getController();
}
/**
* Get router action
*
* @access public
* @return string
*/
public function getRouterAction()
{
return $this->router->getAction();
}
/**
* Get javascript language code
*
* @access public
* @return string
*/
public function jsLang()
{
return $this->languageModel->getJsLanguageCode();
}
/**
* Get date format for Jquery DatePicker
*
* @access public
* @return string
*/
public function getJsDateFormat()
{
$format = $this->dateParser->getUserDateFormat();
$format = str_replace('m', 'mm', $format);
$format = str_replace('Y', 'yy', $format);
$format = str_replace('d', 'dd', $format);
return $format;
}
/**
* Get time format for Jquery Plugin DateTimePicker
*
* @access public
* @return string
*/
public function getJsTimeFormat()
{
$format = $this->dateParser->getUserTimeFormat();
$format = str_replace('H', 'HH', $format);
$format = str_replace('i', 'mm', $format);
$format = str_replace('g', 'h', $format);
$format = str_replace('a', 'tt', $format);
return $format;
}
/**
* Get current timezone
*
* @access public
* @return string
*/
public function getTimezone()
{
return $this->timezoneModel->getCurrentTimezone();
}
/**
* Get session flash message
*
* @access public
* @return string
*/
public function flashMessage()
{
$success_message = $this->flash->getMessage('success');
$failure_message = $this->flash->getMessage('failure');
if (! empty($success_message)) {
return '<div class="alert alert-success alert-fade-out">'.$this->helper->text->e($success_message).'</div>';
}
if (! empty($failure_message)) {
return '<div class="alert alert-error">'.$this->helper->text->e($failure_message).'</div>';
}
return '';
}
}
|