Completed
Push — master ( 0ea243...da58d4 )
by Henry
10:25 queued 33s
created

includes/Admin/View/SettingForm.php (1 issue)

undocumented call capabilities.

Bug Documentation Minor

Upgrade to new PHP Analysis Engine

These results are based on our legacy PHP analysis, consider migrating to our new PHP analysis engine instead. Learn more

1
<?php
2
namespace Redaxscript\Admin\View;
3
4
use Redaxscript\Admin;
5
use Redaxscript\Html;
6
use Redaxscript\Module;
7
8
/**
9
 * children class to create the setting form
10
 *
11
 * @since 3.0.0
12
 *
13
 * @package Redaxscript
14
 * @category View
15
 * @author Henry Ruhs
16
 */
17
18
class SettingForm extends ViewAbstract
19
{
20
	/**
21
	 * render the view
22
	 *
23
	 * @since 3.0.0
24
	 *
25
	 * @return string
26
	 */
27
28 1
	public function render() : string
29
	{
30 1
		$output = Module\Hook::trigger('adminSettingFormStart');
31 1
		$settingModel = new Admin\Model\Setting();
32 1
		$helperOption = new Helper\Option($this->_language);
33
34
		/* html element */
35
36 1
		$titleElement = new Html\Element();
37
		$titleElement
38 1
			->init('h2',
39
			[
40 1
				'class' => 'rs-admin-title-content',
41
			])
42 1
			->text($this->_language->get('settings'));
43 1
		$formElement = new Admin\Html\Form($this->_registry, $this->_language);
44 1
		$formElement->init(
45
		[
46 1
			'form' =>
47
			[
48
				'class' => 'rs-admin-js-validate rs-admin-component-accordion rs-admin-form-default'
49
			],
50
			'button' =>
51
			[
52
				'save' =>
53
				[
54
					'name' => self::class
55
				]
56
			],
57
			'link' =>
58
			[
59
				'cancel' =>
60
				[
61 1
					'href' => $this->_registry->get('parameterRoute') . 'admin'
62
				]
63
			]
64
		]);
65
66
		/* create the form */
67
68
		$formElement
0 ignored issues
show
Documentation Bug introduced by
The method save does not exist on object<Redaxscript\Html\Form>? Since you implemented __call, maybe consider adding a @method annotation.

If you implement __call and you know which methods are available, you can improve IDE auto-completion and static analysis by adding a @method annotation to the class.

This is often the case, when __call is implemented by a parent class and only the child class knows which methods exist:

class ParentClass {
    private $data = array();

    public function __call($method, array $args) {
        if (0 === strpos($method, 'get')) {
            return $this->data[strtolower(substr($method, 3))];
        }

        throw new \LogicException(sprintf('Unsupported method: %s', $method));
    }
}

/**
 * If this class knows which fields exist, you can specify the methods here:
 *
 * @method string getName()
 */
class SomeClass extends ParentClass { }
Loading history...
69
70
			/* general */
71
72 1
			->radio(
73
			[
74 1
				'id' => self::class . '\General',
75
				'class' => 'rs-admin-fn-status-accordion',
76
				'name' => self::class . '\Accordion',
77
				'checked' => 'checked'
78
			])
79 1
			->label($this->_language->get('general'),
80
			[
81 1
				'class' => 'rs-admin-fn-toggle-accordion rs-admin-label-accordion',
82
				'for' => self::class . '\General'
83
			])
84 1
			->append('<ul class="rs-admin-fn-content-accordion rs-admin-box-accordion"><li>')
85 1
			->label($this->_language->get('language'),
86
			[
87 1
				'for' => 'language'
88
			])
89 1
			->select($helperOption->getLanguageArray(),
90
			[
91 1
				$settingModel->get('language')
92
			],
93
			[
94 1
				'id' => 'language',
95
				'name' => 'language'
96
			])
97 1
			->append('</li><li>')
98 1
			->label($this->_language->get('template'),
99
			[
100 1
				'for' => 'template'
101
			])
102 1
			->select($helperOption->getTemplateArray(),
103
			[
104 1
				$settingModel->get('template')
105
			],
106
			[
107 1
				'id' => 'template',
108
				'name' => 'template'
109
			])
110 1
			->append('</li></ul>')
111
112
			/* metadata */
113
114 1
			->radio(
115
			[
116 1
				'id' => self::class . '\Metadata',
117
				'class' => 'rs-admin-fn-status-accordion',
118
				'name' => self::class . '\Accordion'
119
			])
120 1
			->label($this->_language->get('metadata'),
121
			[
122 1
				'class' => 'rs-admin-fn-toggle-accordion rs-admin-label-accordion',
123
				'for' => self::class . '\Metadata'
124
			])
125 1
			->append('<ul class="rs-admin-fn-content-accordion rs-admin-box-accordion"><li>')
126 1
			->label($this->_language->get('title'),
127
			[
128 1
				'for' => 'title'
129
			])
130 1
			->text(
131
			[
132 1
				'id' => 'title',
133 1
				'name' => 'title',
134 1
				'value' => $settingModel->get('title')
135
			])
136 1
			->append('</li><li>')
137 1
			->label($this->_language->get('author'),
138
			[
139 1
				'for' => 'author'
140
			])
141 1
			->text(
142
			[
143 1
				'id' => 'author',
144 1
				'name' => 'author',
145 1
				'value' => $settingModel->get('author')
146
			])
147 1
			->append('</li><li>')
148 1
			->label($this->_language->get('copyright'),
149
			[
150 1
				'for' => 'copyright'
151
			])
152 1
			->text(
153
			[
154 1
				'id' => 'copyright',
155 1
				'name' => 'copyright',
156 1
				'value' => $settingModel->get('copyright')
157
			])
158 1
			->append('</li><li>')
159 1
			->label($this->_language->get('description'),
160
			[
161 1
				'for' => 'description'
162
			])
163 1
			->textarea(
164
			[
165 1
				'class' => 'rs-admin-js-resize rs-admin-field-textarea rs-admin-field-small',
166 1
				'id' => 'description',
167 1
				'name' => 'description',
168 1
				'rows' => 1,
169 1
				'value' => $settingModel->get('description')
170
			])
171 1
			->append('</li><li>')
172 1
			->label($this->_language->get('keywords'),
173
			[
174 1
				'for' => 'keywords'
175
			])
176 1
			->textarea(
177
			[
178 1
				'class' => 'rs-admin-js-resize rs-admin-field-textarea rs-admin-field-small',
179 1
				'id' => 'keywords',
180 1
				'name' => 'keywords',
181 1
				'rows' => 1,
182 1
				'value' => $settingModel->get('keywords')
183
			])
184 1
			->append('</li><li>')
185 1
			->label($this->_language->get('robots'),
186
			[
187 1
				'for' => 'robots'
188
			])
189 1
			->select($helperOption->getRobotArray(),
190
			[
191 1
				$settingModel->get('robots')
192
			],
193
			[
194 1
				'id' => 'robots',
195
				'name' => 'robots'
196
			])
197 1
			->append('</li></ul>')
198
199
			/* contact */
200
201 1
			->radio(
202
			[
203 1
				'id' => self::class . '\Contact',
204
				'class' => 'rs-admin-fn-status-accordion',
205
				'name' => self::class . '\Accordion'
206
			])
207 1
			->label($this->_language->get('contact'),
208
			[
209 1
				'class' => 'rs-admin-fn-toggle-accordion rs-admin-label-accordion',
210
				'for' => self::class . '\Contact'
211
			])
212 1
			->append('<ul class="rs-admin-fn-content-accordion rs-admin-box-accordion"><li>')
213 1
			->label($this->_language->get('email'),
214
			[
215 1
				'for' => 'email'
216
			])
217 1
			->email(
218
			[
219 1
				'id' => 'email',
220 1
				'name' => 'email',
221 1
				'value' => $settingModel->get('email')
222
			])
223 1
			->append('</li><li>')
224 1
			->label($this->_language->get('subject'),
225
			[
226 1
				'for' => 'subject'
227
			])
228 1
			->text(
229
			[
230 1
				'id' => 'subject',
231 1
				'name' => 'subject',
232 1
				'value' => $settingModel->get('subject')
233
			])
234 1
			->append('</li><li>')
235 1
			->label($this->_language->get('notification'),
236
			[
237 1
				'for' => 'notification'
238
			])
239 1
			->select($helperOption->getToggleArray(),
240
			[
241 1
				$settingModel->get('notification')
242
			],
243
			[
244 1
				'id' => 'notification',
245
				'name' => 'notification'
246
			])
247 1
			->append('</li></ul>')
248
249
			/* formatting */
250
251 1
			->radio(
252
			[
253 1
				'id' => self::class . '\Formatting',
254
				'class' => 'rs-admin-fn-status-accordion',
255
				'name' => self::class . '\Accordion'
256
			])
257 1
			->label($this->_language->get('formatting'),
258
			[
259 1
				'class' => 'rs-admin-fn-toggle-accordion rs-admin-label-accordion',
260
				'for' => self::class . '\Formatting'
261
			])
262 1
			->append('<ul class="rs-admin-fn-content-accordion rs-admin-box-accordion"><li>')
263 1
			->label($this->_language->get('charset'),
264
			[
265 1
				'for' => 'charset'
266
			])
267 1
			->text(
268
			[
269 1
				'id' => 'charset',
270 1
				'name' => 'charset',
271 1
				'value' => $settingModel->get('charset')
272
			])
273 1
			->append('</li><li>')
274 1
			->label($this->_language->get('divider'),
275
			[
276 1
				'for' => 'divider'
277
			])
278 1
			->text(
279
			[
280 1
				'id' => 'divider',
281 1
				'name' => 'divider',
282 1
				'value' => $settingModel->get('divider')
283
			])
284 1
			->append('</li><li>')
285 1
			->label($this->_language->get('zone'),
286
			[
287 1
				'for' => 'zone'
288
			])
289 1
			->select($helperOption->getZoneArray(),
290
			[
291 1
				$settingModel->get('zone')
292
			],
293
			[
294 1
				'id' => 'zone',
295
				'name' => 'zone'
296
			])
297 1
			->append('</li><li>')
298 1
			->label($this->_language->get('time'),
299
			[
300 1
				'for' => 'time'
301
			])
302 1
			->select($helperOption->getTimeArray(),
303
			[
304 1
				$settingModel->get('time')
305
			],
306
			[
307 1
				'id' => 'time',
308
				'name' => 'time'
309
			])
310 1
			->append('</li><li>')
311 1
			->label($this->_language->get('date'),
312
			[
313 1
				'for' => 'date'
314
			])
315 1
			->select($helperOption->getDateArray(),
316
			[
317 1
				$settingModel->get('date')
318
			],
319
			[
320 1
				'id' => 'date',
321
				'name' => 'date'
322
			])
323 1
			->append('</li></ul>')
324
325
			/* contents */
326
327 1
			->radio(
328
			[
329 1
				'id' => self::class . '\Contents',
330
				'class' => 'rs-admin-fn-status-accordion',
331
				'name' => self::class . '\Accordion'
332
			])
333 1
			->label($this->_language->get('contents'),
334
			[
335 1
				'class' => 'rs-admin-fn-toggle-accordion rs-admin-label-accordion',
336
				'for' => self::class . '\Contents'
337
			])
338 1
			->append('<ul class="rs-admin-fn-content-accordion rs-admin-box-accordion"><li>')
339 1
			->label($this->_language->get('homepage'),
340
			[
341 1
				'for' => 'homepage'
342
			])
343 1
			->select($helperOption->getArticleArray(),
344
			[
345 1
				$settingModel->get('homepage')
346
			],
347
			[
348 1
				'id' => 'homepage',
349
				'name' => 'homepage'
350
			])
351 1
			->append('</li><li>')
352 1
			->label($this->_language->get('limit'),
353
			[
354 1
				'for' => 'limit'
355
			])
356 1
			->number(
357
			[
358 1
				'id' => 'limit',
359 1
				'name' => 'limit',
360 1
				'value' => $settingModel->get('limit')
361
			])
362 1
			->append('</li><li>')
363 1
			->label($this->_language->get('order'),
364
			[
365 1
				'for' => 'order'
366
			])
367 1
			->select($helperOption->getOrderArray(),
368
			[
369 1
				$settingModel->get('order')
370
			],
371
			[
372 1
				'id' => 'order',
373
				'name' => 'order'
374
			])
375 1
			->append('</li><li>')
376 1
			->label($this->_language->get('pagination'),
377
			[
378 1
				'for' => 'pagination'
379
			])
380 1
			->select($helperOption->getToggleArray(),
381
			[
382 1
				$settingModel->get('pagination')
383
			],
384
			[
385 1
				'id' => 'pagination',
386
				'name' => 'pagination'
387
			])
388 1
			->append('</li></ul>')
389
390
			/* users */
391
392 1
			->radio(
393
			[
394 1
				'id' => self::class . '\Users',
395
				'class' => 'rs-admin-fn-status-accordion',
396
				'name' => self::class . '\Accordion'
397
			])
398 1
			->label($this->_language->get('users'),
399
			[
400 1
				'class' => 'rs-admin-fn-toggle-accordion rs-admin-label-accordion',
401
				'for' => self::class . '\Users'
402
			])
403 1
			->append('<ul class="rs-admin-fn-content-accordion rs-admin-box-accordion"><li>')
404 1
			->label($this->_language->get('registration'),
405
			[
406 1
				'for' => 'registration'
407
			])
408 1
			->select($helperOption->getToggleArray(),
409
			[
410 1
				$settingModel->get('registration')
411
			],
412
			[
413 1
				'id' => 'registration',
414
				'name' => 'registration'
415
			])
416 1
			->append('</li><li>')
417 1
			->label($this->_language->get('verification'),
418
			[
419 1
				'for' => 'verification'
420
			])
421 1
			->select($helperOption->getToggleArray(),
422
			[
423 1
				$settingModel->get('verification')
424
			],
425
			[
426 1
				'id' => 'verification',
427
				'name' => 'verification'
428
			])
429 1
			->append('</li><li>')
430 1
			->label($this->_language->get('recovery'),
431
			[
432 1
				'for' => 'recovery'
433
			])
434 1
			->select($helperOption->getToggleArray(),
435
			[
436 1
				$settingModel->get('recovery')
437
			],
438
			[
439 1
				'id' => 'recovery',
440
				'name' => 'recovery'
441
			])
442 1
			->append('</li></ul>')
443
444
			/* security */
445
446 1
			->radio(
447
			[
448 1
				'id' => self::class . '\Security',
449
				'class' => 'rs-admin-fn-status-accordion',
450
				'name' => self::class . '\Accordion'
451
			])
452 1
			->label($this->_language->get('security'),
453
			[
454 1
				'class' => 'rs-admin-fn-toggle-accordion rs-admin-label-accordion',
455
				'for' => self::class . '\Security'
456
			])
457 1
			->append('<ul class="rs-admin-fn-content-accordion rs-admin-box-accordion"><li>')
458 1
			->label($this->_language->get('moderation'),
459
			[
460 1
				'for' => 'moderation'
461
			])
462 1
			->select($helperOption->getToggleArray(),
463
			[
464 1
				$settingModel->get('moderation')
465
			],
466
			[
467 1
				'id' => 'moderation',
468
				'name' => 'moderation'
469
			])
470 1
			->append('</li><li>')
471 1
			->label($this->_language->get('captcha'),
472
			[
473 1
				'for' => 'captcha'
474
			])
475 1
			->select($helperOption->getCaptchaArray(),
476
			[
477 1
				$settingModel->get('captcha')
478
			],
479
			[
480 1
				'id' => 'captcha',
481
				'name' => 'captcha'
482
			])
483 1
			->append('</li></ul>')
484 1
			->token()
485 1
			->append('<div class="rs-admin-wrapper-button">')
486 1
			->cancel()
487 1
			->save()
488 1
			->append('</div>');
489
490
		/* collect output */
491
492 1
		$output .= $titleElement . $formElement;
493 1
		$output .= Module\Hook::trigger('adminSettingFormEnd');
494 1
		return $output;
495
	}
496
}
497