-
Notifications
You must be signed in to change notification settings - Fork 9
Expand file tree
/
Copy pathtestoptions.php
More file actions
433 lines (422 loc) · 17.4 KB
/
testoptions.php
File metadata and controls
433 lines (422 loc) · 17.4 KB
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
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
<?php
/**
* Created by PhpStorm.
* User: lenovo
* Date: 21.01.2016
* Time: 21:08
*
* @author Pavel Shulaev (http://rover-it.me)
*/
namespace Rover\Fadmin;
use Bitrix\Main\ArgumentNullException;
use Bitrix\Main\SystemException;
use Rover\Fadmin\Inputs\Addpreset;
use Rover\Fadmin\Inputs\Checkbox;
use Rover\Fadmin\Inputs\Clock;
use Rover\Fadmin\Inputs\Color;
use Rover\Fadmin\Inputs\File;
use Rover\Fadmin\Inputs\Header;
use Rover\Fadmin\Inputs\Iblock;
use Rover\Fadmin\Inputs\Number;
use Rover\Fadmin\Inputs\Password;
use Rover\Fadmin\Inputs\PresetName;
use Rover\Fadmin\Inputs\Radio;
use Rover\Fadmin\Inputs\Removepreset;
use Rover\Fadmin\Inputs\Row;
use Rover\Fadmin\Inputs\Schedule;
use Rover\Fadmin\Inputs\Selectbox;
use Rover\Fadmin\Inputs\Selectgroup;
use Rover\Fadmin\Inputs\SubTab;
use Rover\Fadmin\Inputs\SubTabControl;
use Rover\Fadmin\Inputs\Text;
use Rover\Fadmin\Inputs\Textarea;
use Rover\Fadmin\Options\Settings;
/**
* Class TestOptions
*
* @package Rover\Fadmin
* @author Pavel Shulaev (http://rover-it.me)
*/
class TestOptions extends Options
{
const MODULE_ID = 'rover.fadmin';
const OPTION__PRESET_COLOR = 'preset_color';
const OPTION__TEXTAREA = 'input_textarea';
/**
* @param string $moduleId
* @return TestOptions
* @throws ArgumentNullException
* @author Pavel Shulaev (https://rover-it.me)
*/
public static function getInstance($moduleId = self::MODULE_ID): static
{
return parent::getInstance(self::MODULE_ID);
}
/**
* @return array
* @author Pavel Shulaev (http://rover-it.me)
*/
public function getConfig(): array
{
return [
'tabs' => self::getTabs(),
'settings' => [
Settings::BOOL_CHECKBOX => true,
Settings::USE_SORT => true,
Settings::GROUP_RIGHTS => true,
]
];
}
/**
* @return array
* @author Pavel Shulaev (https://rover-it.me)
*/
protected static function getTabs(): array
{
return [
[
'name' => 'first_tab',
'label' => 'First Tab',
'default' => 'First tab description',
'siteId' => 's1',
'inputs' => [
[
'type' => Header::getType(),
'label' => 'First tab header',
'sort' => 100,
],
[
'type' => Text::getType(),
'name' => 'text',
'label' => 'text input (maxlength 50)',
'default' => '',
'maxLength' => 50,
'sort' => '200',
'placeholder' => 'enter a text here',
'disabled' => true
],
[
'type' => Text::getType(),
'preInput' => 'https://',
'postInput' => '.domain.com',
'name' => 'subdimain',
'label' => 'Please, enter you subdomain here',
'help' => 'format: https://<strong><u>subdomain</u></strong>.domain.com',
'default' => 'subdomain',
'maxLength' => 255,
'size' => 10,
'sort' => '250',
'placeholder' => 'subdomain'
],
[
'type' => Password::getType(),
'name' => 'password',
'label' => 'Please, enter password here',
'default' => 'qwerty',
'maxLength' => 255,
'sort' => '260',
'placeholder' => 'enter password here'
],
[
'type' => Number::getType(),
'name' => 'number',
'label' => 'number input (min 0, max 100)',
'default' => 50,
'max' => 100,
'min' => 0,
'sort' => '300',
'placeholder' => 'enter a number here'
],
[
'type' => Textarea::getType(),
'name' => self::OPTION__TEXTAREA,
'label' => 'input textarea (3 rows 20 cols)',
'default' => 'default text',
'rows' => 3,
'cols' => 20,
'help' => 'textarea help',
'sort' => '500',
'placeholder' => 'enter a big text here'
],
[
'type' => Textarea::getType(),
'name' => 'input_textarea_2',
'label' => 'Visual Editor',
'default' => 'Visual Editor default text',
'help' => 'visual editor help',
'sort' => '550',
'htmlEditor' => true,
'htmlEditorBB' => true,
'placeholder' => 'enter a big text with bb-codes here'
],
[
'type' => Clock::getType(),
'name' => 'clock',
'label' => 'This is a clock',
'default' => '15:15',
'sort' => 400
],
[
'type' => Row::getType(),
'inputs' => [
[
'type' => Selectbox::getType(),
'name' => 'selectbox-row-1',
'label' => 'Mapping selectbox',
'options' => [
'0' => 'option 0',
'1' => 'option 1',
'2' => 'option 2'
]
],
[
'type' => Selectbox::getType(),
'name' => 'selectbox-row-2',
'label' => ' = ',
'options' => [
'3' => 'option 3',
'4' => 'option 4',
'5' => 'option 5'
]
],
]
],
[
'type' => SubTabControl::getType(),
'name' => 'subtabcontrol',
'label' => 'subtabcontrol label',
'default' => 'subtabcontrol default',
'sort' => 550,
'subTabs' => [
[
'type' => SubTab::getType(),
'name' => 'subtab_1',
'label' => 'subtab 1 label',
'default' => 'subtab 1 default',
'inputs' => [
[
'type' => Color::getType(),
'name' => 'color',
'label' => 'This is a color',
'default' => '15:15',
'help' => 'Please, select a color',
'sort' => '600',
],
[
'type' => Checkbox::getType(),
'name' => 'checkbox',
'label' => 'This is a checkbox',
'default' => '#FFFF00',
'help' => 'Please, check me!',
'sort' => '700'
],
]
],
[
'type' => SubTab::getType(),
'name' => 'subtab_2',
'label' => 'subtab 2 label',
'default' => 'subtab 2 default',
'inputs' => [
[
'type' => File::getType(),
'name' => 'file',
'label' => 'This is a file',
'default' => '',
'help' => 'You may load an image here (max size 1 M)',
'maxSize' => 1024 * 1024,
'isImage' => true,
'sort' => '800'
],
[
'type' => Iblock::getType(),
'name' => 'iblock',
'label' => 'This is a hidden single iblock',
'sort' => '900',
'hidden' => true
],
[
'type' => Iblock::getType(),
'name' => 'multiple_iblock',
'multiple' => true,
'label' => 'This is a multiple iblock',
'sort' => '500'
],
]
]
]
],
[
'type' => Addpreset::getType(),
'label' => 'add preset s1',
'default' => 'new preset default name',
'popup' => 'add preset popup', // false - not show
'sort' => '1100'
]
]
],
[
'name' => 'presetTab',
'label' => 'Preset',
'preset' => true,
'default' => 'This is a description of preset tab',
'siteId' => 's1',
'inputs' => [
[
'type' => Header::getType(),
'label' => 'Preset header',
],
[
'type' => PresetName::getType(),
'name' => 'presetName',
'label' => 'preset name',
'help' => 'Enter a new name of preset here'
],
[
'type' => Color::getType(),
'name' => self::OPTION__PRESET_COLOR,
'label' => 'preset color',
'default' => '#FFAA00',
'help' => 'color help',
],
[
'type' => Removepreset::getType(),
'label' => 'remove_preset',
'popup' => 'Are you sure?',
]
],
],
[
'name' => 'tab_22',
'label' => 'Second Tab',
'default' => 'This is a description of second normal tab',
'siteId' => 'm',
'inputs' => [
[
'type' => Selectbox::getType(),
'name' => 'selectbox',
'label' => 'single selectbox',
'options' => [
'0' => 'option 0',
'1' => 'option 1',
'2' => 'option 2'
]
],
[
'type' => Selectbox::getType(),
'name' => 'multiple_selectbox',
'label' => 'Multiple selectbox',
'multiple' => true,
'options' => [
'0' => 'option 0',
'1' => 'option 1',
'2' => 'option 2'
]
],
[
'type' => Selectgroup::getType(),
'name' => 'select_group',
'label' => 'select_group',
'options' => [
'g1' => [
'name' => 'Group 1',
'options' => [
'g1:o1' => 'group 1: option 1',
'g1:o2' => 'group 1: option 2',
'g1:o3' => 'group 1: option 3',
]
],
'g2' => [
'name' => 'Group 2',
'options' => [
'g2:o1' => 'group 2: option 1',
'g2:o2' => 'group 2: option 2',
'g2:o3' => 'group 2: option 3',
]
],
'g3' => [
'name' => 'Group 3',
'options' => [
'g3:o1' => 'group 3: option 1',
'g3:o2' => 'group 3: option 2',
'g3:o3' => 'group 3: option 3',
]
]
]
],
[
'type' => Radio::getType(),
'name' => 'radio_demo',
'label' => 'radio',
'options' => [
'1' => 'v1',
'2' => 'v2',
'3' => 'v3'
]
],
[
'type' => Schedule::getType(),
'name' => 'schedule_demo',
'label' => 'demo schedule',
'periodLabel' => 'period label',
'width' => 400,
'height' => 300
],
[
'type' => Addpreset::getType(),
'label' => 'add preset',
'default' => 'new preset default name',
'popup' => 'add preset popup 2' // false - not show
]
]
],
[
'name' => 'presetTab2',
'label' => 'Preset2',
'preset' => true,
'default' => 'This is a description of preset tab 2',
'siteId' => 'm',
'inputs' => [
[
'type' => Header::getType(),
'label' => 'Preset header',
],
[
'type' => Color::getType(),
'name' => 'preset_color_2',
'label' => 'preset color',
'default' => '#FFAA00',
'help' => 'color help',
],
[
'type' => Removepreset::getType(),
'label' => 'remove_preset',
'popup' => 'Are you sure?',
]
],
],
];
}
/**
* @param bool $reload
* @return mixed
* @throws SystemException
* @author Pavel Shulaev (https://rover-it.me)
*/
public function getTextareaValueS1(bool $reload = false)
{
return $this->getNormalValue(self::OPTION__TEXTAREA, 's1', $reload);
}
/**
* @param $presetId
* @param bool $reload
* @return mixed
* @throws ArgumentNullException
* @throws SystemException
* @author Pavel Shulaev (https://rover-it.me)
*/
public function getS1PresetColor($presetId, bool $reload = false)
{
return $this->getPresetValue(self::OPTION__PRESET_COLOR, $presetId, 's1', $reload);
}
}