-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathUserSettings.php
277 lines (245 loc) · 12.3 KB
/
UserSettings.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
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
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
<?php
/**
* Piwik - free/libre analytics platform
*
* @link http://piwik.org
* @license http://www.gnu.org/licenses/gpl-3.0.html GPL v3 or later
*/
namespace Piwik\Plugins\IceCastStatistics;
use Piwik\Settings\Setting;
use Piwik\Settings\FieldConfig;
/**
* Defines Settings for IceCastStatistics.
*
* Usage like this:
* $settings = new UserSettings();
* $settings->autoRefresh->getValue();
* $settings->color->getValue();
*/
class UserSettings extends \Piwik\Settings\Plugin\UserSettings
{
/** @var UserSetting */
public $autoRefresh;
/** @var UserSetting */
public $refreshInterval;
/** @var UserSetting */
public $color;
protected function init()
{
$this->autoRefresh = $this->createAutoRefreshSetting();
$this->refreshInterval = $this->createRefreshIntervalSetting();
$this->displayButtonAudioInfo = $this->createdisplayButtonAudioInfo();
$this->displayButtonBitrate = $this->createdisplayButtonBitrate();
$this->displayButtonChannels = $this->createdisplayButtonChannels();
$this->displayButtonListenerPeak = $this->createdisplayButtonListenerPeak();
$this->displayButtonCurrentlyListeners = $this->createdisplayButtonCurrentlyListeners();
$this->displayButtonListenUrl = $this->createdisplayButtonListenUrl();
$this->displayButtonMaxListeners = $this->createdisplayButtonMaxListeners();
$this->displayButtonPublic = $this->createdisplayButtonPublic();
$this->displayButtonSampleRate = $this->createdisplayButtonSampleRate();
$this->displayButtonServerDescription = $this->createdisplayButtonServerDescription();
$this->displayButtonServerName = $this->createdisplayButtonServerName();
$this->displayButtonServerType = $this->createdisplayButtonServerType();
$this->displayButtonServerUrl = $this->createdisplayButtonServerUrl();
$this->displayButtonSlowListeners = $this->createdisplayButtonSlowListeners();
$this->displayButtonSourceIp = $this->createdisplayButtonSourceIp();
$this->displayButtonStreamStart = $this->createdisplayButtonStreamStart();
$this->displayButtonStreamStartIso8601 = $this->createdisplayButtonStreamStartIso8601();
$this->displayButtonTitle = $this->createdisplayButtonTitle();
$this->displayButtonTotalBytesSent = $this->createdisplayButtonTotalBytesSent();
$this->displayButtonTotalBytesRead = $this->createdisplayButtonTotalBytesRead();
$this->displayButtonUserAgent = $this->createdisplayButtonUserAgent();
}
private function createRefreshIntervalSetting()
{
return $this->makeSetting('refreshInterval', $default = '15', FieldConfig::TYPE_INT, function (FieldConfig $field) {
$field->title = 'Refresh Interval';
$field->uiControl = FieldConfig::UI_CONTROL_TEXT;
$field->uiControlAttributes = array('size' => 3);
$field->inlineHelp = 'Enter a number which is >= 15';
$field->introduction = 'New group of settings';
$field->description = 'Defines how often the widget should be updated';
$field->validate = function ($value, $setting) {
if ($value < 15) {
throw new \Exception('Value is invalid');
}
};
});
}
private function createAutoRefreshSetting()
{
return $this->makeSetting('autoRefresh', $default = false, FieldConfig::TYPE_BOOL, function (FieldConfig $field) {
$field->title = 'Auto refresh';
$field->uiControl = FieldConfig::UI_CONTROL_CHECKBOX;
$field->description = 'If enabled, the informations displayed in the widget will be automatically refreshed depending on the specified interval';
});
}
private function createdisplayButtonAudioInfo()
{
return $this->makeSetting('displayButtonAudioInfo', $default = false, FieldConfig::TYPE_BOOL, function (FieldConfig $field) {
$field->title = 'Combined audio information';
$field->uiControl = FieldConfig::UI_CONTROL_CHECKBOX;
$field->description = 'Enable displaying combined Audio Information';
});
}
private function createdisplayButtonBitrate()
{
return $this->makeSetting('displayButtonBitrate', $default = false, FieldConfig::TYPE_BOOL, function (FieldConfig $field) {
$field->title = 'Bitrate';
$field->uiControl = FieldConfig::UI_CONTROL_CHECKBOX;
$field->description = 'Enable displaying the bitrate';
});
}
private function createdisplayButtonChannels()
{
return $this->makeSetting('displayButtonChannels', $default = false, FieldConfig::TYPE_BOOL, function (FieldConfig $field) {
$field->title = 'Number of channels';
$field->uiControl = FieldConfig::UI_CONTROL_CHECKBOX;
$field->description = 'Enable displaying the number of channels';
});
}
private function createdisplayButtonListenerPeak()
{
return $this->makeSetting('displayButtonListenerPeak', $default = false, FieldConfig::TYPE_BOOL, function (FieldConfig $field) {
$field->title = 'Maximum number of todays listeners';
$field->uiControl = FieldConfig::UI_CONTROL_CHECKBOX;
$field->description = 'Enable displaying the maximum number of todays listeners';
});
}
private function createdisplayButtonCurrentlyListeners()
{
return $this->makeSetting('displayButtonCurrentlyListeners', $default = false, FieldConfig::TYPE_BOOL, function (FieldConfig $field) {
$field->title = 'Current amount of listeners';
$field->uiControl = FieldConfig::UI_CONTROL_CHECKBOX;
$field->description = 'Enable displaying the current amount of listeners';
});
}
private function createdisplayButtonUserAgent()
{
return $this->makeSetting('displayButtonUserAgent', $default = false, FieldConfig::TYPE_BOOL, function (FieldConfig $field) {
$field->title = 'User agent';
$field->uiControl = FieldConfig::UI_CONTROL_CHECKBOX;
$field->description = 'Display the user agent of the IceCast client';
});
}
private function createdisplayButtonListenUrl()
{
return $this->makeSetting('displayButtonListenUrl', $default = false, FieldConfig::TYPE_BOOL, function (FieldConfig $field) {
$field->title = 'ListenerURL';
$field->uiControl = FieldConfig::UI_CONTROL_CHECKBOX;
$field->description = 'Enable displaying the URL to the chosen mountpoint';
});
}
private function createdisplayButtonMaxListeners()
{
return $this->makeSetting('displayButtonMaxListeners', $default = false, FieldConfig::TYPE_BOOL, function (FieldConfig $field) {
$field->title = 'Amount of allowed listeners';
$field->uiControl = FieldConfig::UI_CONTROL_CHECKBOX;
$field->description = 'Enable displaying the maximum amount of allowed listeners';
});
}
private function createdisplayButtonPublic()
{
return $this->makeSetting('displayButtonPublic', $default = false, FieldConfig::TYPE_BOOL, function (FieldConfig $field) {
$field->title = 'Server is public?';
$field->uiControl = FieldConfig::UI_CONTROL_CHECKBOX;
$field->description = 'Enable displaying whether your server is public or not';
});
}
private function createdisplayButtonSampleRate()
{
return $this->makeSetting('displayButtonSampleRate', $default = false, FieldConfig::TYPE_BOOL, function (FieldConfig $field) {
$field->title = 'Sample rate';
$field->uiControl = FieldConfig::UI_CONTROL_CHECKBOX;
$field->description = 'Enable displaying the currently used sample rate';
});
}
private function createdisplayButtonServerDescription()
{
return $this->makeSetting('displayButtonServerDescription', $default = false, FieldConfig::TYPE_BOOL, function (FieldConfig $field) {
$field->title = 'Server description';
$field->uiControl = FieldConfig::UI_CONTROL_CHECKBOX;
$field->description = 'Enable displaying the server description';
});
}
private function createdisplayButtonServerName()
{
return $this->makeSetting('displayButtonServerName', $default = false, FieldConfig::TYPE_BOOL, function (FieldConfig $field) {
$field->title = 'Server name';
$field->uiControl = FieldConfig::UI_CONTROL_CHECKBOX;
$field->description = 'Enable displaying of the server name';
});
}
private function createdisplayButtonServerType()
{
return $this->makeSetting('displayButtonServerType', $default = false, FieldConfig::TYPE_BOOL, function (FieldConfig $field) {
$field->title = 'Codec information';
$field->uiControl = FieldConfig::UI_CONTROL_CHECKBOX;
$field->description = 'Enable displaying the codec information';
});
}
private function createdisplayButtonServerUrl()
{
return $this->makeSetting('displayButtonServerUrl', $default = false, FieldConfig::TYPE_BOOL, function (FieldConfig $field) {
$field->title = 'Server URL';
$field->uiControl = FieldConfig::UI_CONTROL_CHECKBOX;
$field->description = 'Enable displaying of the server URL';
});
}
private function createdisplayButtonSlowListeners()
{
return $this->makeSetting('displayButtonSlowListeners', $default = false, FieldConfig::TYPE_BOOL, function (FieldConfig $field) {
$field->title = 'Amount of slow listeners';
$field->uiControl = FieldConfig::UI_CONTROL_CHECKBOX;
$field->description = 'Enable displaying the currently amount of slow listeners';
});
}
private function createdisplayButtonSourceIp()
{
return $this->makeSetting('displayButtonSourceIp', $default = false, FieldConfig::TYPE_BOOL, function (FieldConfig $field) {
$field->title = 'Source IP';
$field->uiControl = FieldConfig::UI_CONTROL_CHECKBOX;
$field->description = 'IP address of the currently connected source client. In case of relays the content of <server>';
});
}
private function createdisplayButtonStreamStart()
{
return $this->makeSetting('displayButtonStreamStart', $default = false, FieldConfig::TYPE_BOOL, function (FieldConfig $field) {
$field->title = 'Start time of the server';
$field->uiControl = FieldConfig::UI_CONTROL_CHECKBOX;
$field->description = 'Enable displaying the start time of the server';
});
}
private function createdisplayButtonStreamStartIso8601()
{
return $this->makeSetting('displayButtonStreamStartIso8601', $default = false, FieldConfig::TYPE_BOOL, function (FieldConfig $field) {
$field->title = 'Start time of the serverin ISO8601 format';
$field->uiControl = FieldConfig::UI_CONTROL_CHECKBOX;
$field->description = 'Enable displaying the start time of the server in ISO8601 format';
});
}
private function createdisplayButtonTitle()
{
return $this->makeSetting('displayButtonTitle', $default = false, FieldConfig::TYPE_BOOL, function (FieldConfig $field) {
$field->title = 'Currently played title';
$field->uiControl = FieldConfig::UI_CONTROL_CHECKBOX;
$field->description = 'Enable displaying of the currently played title';
});
}
private function createdisplayButtonTotalBytesSent()
{
return $this->makeSetting('displayButtonTotalBytesSent', $default = false, FieldConfig::TYPE_BOOL, function (FieldConfig $field) {
$field->title = 'Total amount of sent bytes';
$field->uiControl = FieldConfig::UI_CONTROL_CHECKBOX;
$field->description = 'Enable displaying the total amount of sent bytes';
});
}
private function createdisplayButtonTotalBytesRead()
{
return $this->makeSetting('displayButtonTotalBytesRead', $default = false, FieldConfig::TYPE_BOOL, function (FieldConfig $field) {
$field->title = 'Total amount of read bytes';
$field->uiControl = FieldConfig::UI_CONTROL_CHECKBOX;
$field->description = 'Enable displaying the total amount of read bytes';
});
}
}