PluginProbe
AcyMailing – An Ultimate Newsletter Plugin and Marketing Automation Solution for WordPress / 11.1.1
AcyMailing – An Ultimate Newsletter Plugin and Marketing Automation Solution for WordPress v11.1.1
11.1.1 11.1.0 11.0.5 11.0.4 11.0.3 11.0.2 11.0.1 11.0.0 10.11.1 10.11.0 10.10.2 10.10.1 10.10.0 10.9.1 trunk 10.0.0 10.0.1 10.1.0 10.1.1 10.1.2 10.1.3 10.1.4 10.2.0 10.2.1 10.2.2 All 62 releases
← All changes | back/Classes/FormClass.php +0 -629 10.2.2 → 11.1.1 View file →
@@ -1,629 +1,0 @@
1 -<?php
2 -
3 -namespace AcyMailing\Classes;
4 -
5 -use AcyMailing\Helpers\PaginationHelper;
6 -use AcyMailing\Core\AcymClass;
7 -
8 -class FormClass extends AcymClass
9 -{
10 - const SUB_FORM_TYPE_SHORTCODE = 'shortcode';
11 - const SUB_FORM_TYPE_POPUP = 'popup';
12 - const SUB_FORM_TYPE_HEADER = 'header';
13 - const SUB_FORM_TYPE_FOOTER = 'footer';
14 -
15 - private $settings;
16 -
17 - public function __construct()
18 - {
19 - parent::__construct();
20 -
21 - $this->table = 'form';
22 - $this->pkey = 'id';
23 -
24 - $listClass = new ListClass();
25 - $lists = $listClass->getAllForSelect(false);
26 -
27 - $fieldClass = new FieldClass();
28 - $allFields = $fieldClass->getAll();
29 - $fields = [];
30 - foreach ($allFields as $field) {
31 - if ($field->id == 2 || intval($field->active) === 0) continue;
32 - $fields[$field->id] = acym_translation($field->name);
33 - }
34 -
35 - $this->settings = [
36 - 'options' => [
37 - 'display' => [
38 - 'display_action' => [
39 - 'label' => 'ACYM_DISPLAY_ON_CLICK',
40 - 'description' => 'ACYM_DISPLAY_ON_CLICK_DESC',
41 - 'type' => 'select',
42 - 'options' => [
43 - 'yes' => acym_translation('ACYM_YES'),
44 - 'no' => acym_translation('ACYM_NO'),
45 - ],
46 - 'default' => 'no',
47 - 'allowed_types' => [self::SUB_FORM_TYPE_POPUP],
48 - ],
49 - 'button' => [
50 - 'label' => 'ACYM_BUTTON_ID',
51 - 'description' => 'ACYM_BUTTON_ID_DESC',
52 - 'type' => 'text',
53 - 'default' => '',
54 - 'allowed_types' => [self::SUB_FORM_TYPE_POPUP],
55 - ],
56 - 'delay' => [
57 - 'label' => 'ACYM_DELAY',
58 - 'description' => 'ACYM_DELAY_DESC',
59 - 'type' => 'number',
60 - 'unit' => acym_translation('ACYM_SECONDS'),
61 - 'default' => 0,
62 - 'allowed_types' => [self::SUB_FORM_TYPE_POPUP],
63 - ],
64 - 'scroll' => [
65 - 'label' => 'ACYM_SCROLL',
66 - 'description' => 'ACYM_SCROLL_DESC',
67 - 'type' => 'number',
68 - 'unit' => '%',
69 - 'max' => 100,
70 - 'default' => 0,
71 - 'allowed_types' => [self::SUB_FORM_TYPE_POPUP],
72 - ],
73 - ],
74 - 'lists' => [
75 - 'automatic_subscribe' => [
76 - 'label' => 'ACYM_AUTO_SUBSCRIBE_TO',
77 - 'description' => 'ACYM_AUTO_SUBSCRIBE_TO_DESC',
78 - 'type' => 'multiselect',
79 - 'options' => $lists,
80 - 'default' => [],
81 - ],
82 - 'displayed' => [
83 - 'label' => 'ACYM_DISPLAYED_LISTS',
84 - 'description' => 'ACYM_DISPLAYED_LISTS_DESC',
85 - 'type' => 'multiselect',
86 - 'options' => $lists,
87 - 'default' => [],
88 - ],
89 - 'checked' => [
90 - 'label' => 'ACYM_LISTS_CHECKED_DEFAULT',
91 - 'description' => 'ACYM_LISTS_CHECKED_DEFAULT_DESC',
92 - 'type' => 'multiselect',
93 - 'options' => $lists,
94 - 'default' => [],
95 - ],
96 - 'display_position' => [
97 - 'label' => 'ACYM_DISPLAY_LISTS',
98 - 'type' => 'select',
99 - 'options' => [
100 - 'after' => acym_translation('ACYM_AFTER_FIELDS'),
101 - 'before' => acym_translation('ACYM_BEFORE_FIELDS'),
102 - ],
103 - 'default' => 'after',
104 - ],
105 - ],
106 - 'fields' => [
107 - 'displayed' => [
108 - 'label' => 'ACYM_FIELDS_TO_DISPLAY',
109 - 'type' => 'multiselect',
110 - 'options' => $fields,
111 - 'default' => [],
112 - ],
113 - 'display_mode' => [
114 - 'label' => 'ACYM_DISPLAY_FIELDS_LABEL',
115 - 'type' => 'select',
116 - 'options' => [
117 - 'inside' => acym_translation('ACYM_TEXT_INSIDE'),
118 - 'outside' => acym_translation('ACYM_TEXT_OUTSIDE'),
119 - ],
120 - 'default' => 'inside',
121 - ],
122 - ],
123 - 'termspolicy' => [
124 - 'termscond' => [
125 - 'label' => 'ACYM_TERMS_CONDITIONS',
126 - 'type' => 'article',
127 - 'default' => 0,
128 - ],
129 - 'privacy' => [
130 - 'label' => 'ACYM_PRIVACY_POLICY',
131 - 'type' => 'article',
132 - 'default' => 0,
133 - ],
134 - ],
135 - 'message' => [
136 - 'text' => [
137 - 'label' => 'ACYM_CUSTOM_MESSAGE_DISPLAY',
138 - 'type' => 'textarea',
139 - 'default' => '',
140 - 'allowed_types' => [self::SUB_FORM_TYPE_POPUP],
141 - ],
142 - 'position' => [
143 - 'label' => 'ACYM_MESSAGE_POSITION',
144 - 'type' => 'select',
145 - 'options' => [
146 - 'before-image' => acym_translation('ACYM_BEFORE_IMAGE'),
147 - 'before-fields' => acym_translation('ACYM_BEFORE_FIELDS'),
148 - 'before-lists' => acym_translation('ACYM_BEFORE_LISTS'),
149 - 'before-button' => acym_translation('ACYM_BEFORE_BUTTON'),
150 - ],
151 - 'default' => 'before-fields',
152 - 'allowed_types' => [self::SUB_FORM_TYPE_POPUP],
153 - ],
154 - 'color' => [
155 - 'label' => 'ACYM_COLOR',
156 - 'type' => 'color',
157 - 'default' => '#000000',
158 - ],
159 - ],
160 - 'cookie' => [
161 - 'cookie_expiration' => [
162 - 'label' => 'ACYM_COOKIE_EXPIRATION',
163 - 'type' => 'number',
164 - 'min' => 1,
165 - 'unit' => acym_translation('ACYM_DAYS'),
166 - 'default' => 1,
167 - 'allowed_types' => [self::SUB_FORM_TYPE_POPUP, self::SUB_FORM_TYPE_HEADER, self::SUB_FORM_TYPE_FOOTER],
168 - ],
169 - ],
170 - 'redirection' => [
171 - 'after_subscription' => [
172 - 'label' => 'ACYM_AFTER_SUBSCRIPTION',
173 - 'description' => 'ACYM_REDIRECT_LINK_DESC',
174 - 'type' => 'text',
175 - 'default' => '',
176 - ],
177 - 'confirmation_message' => [
178 - 'label' => 'ACYM_CONFIRMATION_MESSAGE',
179 - 'description' => 'ACYM_CONFIRMATION_MESSAGE_DESC',
180 - 'type' => 'text',
181 - 'default' => '',
182 - ],
183 - ],
184 - 'miscellaneous' => [
185 - 'js_loading' => [
186 - 'label' => 'ACYM_JS_LOADING',
187 - 'description' => 'ACYM_MODULE_JS_DESC',
188 - 'type' => 'select',
189 - 'options' => [
190 - 'form' => acym_translation('ACYM_IN_FORM'),
191 - 'head' => acym_translation('ACYM_WP_ENQUEUE_SCRIPT'),
192 - ],
193 - 'default' => 'form',
194 - 'allowed_types' => [self::SUB_FORM_TYPE_SHORTCODE],
195 - ],
196 - ],
197 - ],
198 - 'styles' => [
199 - 'image' => [
200 - 'url' => [
201 - 'label' => 'ACYM_CHOOSE_IMAGE',
202 - 'type' => 'media',
203 - 'default' => '',
204 - ],
205 - 'size' => [
206 - 'label' => 'ACYM_SIZE',
207 - 'type' => 'dimensions',
208 - 'default' => ['width' => 100, 'height' => 100],
209 - ],
210 - ],
211 - 'button' => [
212 - 'background_color' => [
213 - 'label' => 'ACYM_BACKGROUND_COLOR',
214 - 'type' => 'color',
215 - 'default' => '#000000',
216 - ],
217 - 'text_color' => [
218 - 'label' => 'ACYM_TEXT_COLOR',
219 - 'type' => 'color',
220 - 'default' => '#ffffff',
221 - ],
222 - 'border_color' => [
223 - 'label' => 'ACYM_BORDER_COLOR',
224 - 'type' => 'color',
225 - 'default' => '#000000',
226 - ],
227 - 'border_type' => [
228 - 'label' => 'ACYM_BORDER_TYPE',
229 - 'type' => 'select',
230 - 'options' => [
231 - 'solid' => acym_translation('ACYM_SOLID'),
232 - 'dotted' => acym_translation('ACYM_DOTTED'),
233 - 'dashed' => acym_translation('ACYM_DASHED'),
234 - 'double' => acym_translation('ACYM_DOUBLE'),
235 - 'groove' => acym_translation('ACYM_GROOVE'),
236 - 'ridge' => acym_translation('ACYM_RIDGE'),
237 - 'inset' => acym_translation('ACYM_INSET'),
238 - 'outset' => acym_translation('ACYM_OUTSET'),
239 - ],
240 - 'default' => 'solid',
241 - ],
242 - 'border_size' => [
243 - 'label' => 'ACYM_BORDER_SIZE',
244 - 'type' => 'number',
245 - 'default' => 0,
246 - ],
247 - 'border_radius' => [
248 - 'label' => 'ACYM_RADIUS',
249 - 'type' => 'number',
250 - 'default' => 0,
251 - ],
252 - 'size' => [
253 - 'label' => 'ACYM_SIZE',
254 - 'type' => 'dimensions',
255 - 'default' => ['width' => 20, 'height' => 10],
256 - ],
257 - 'text' => [
258 - 'label' => 'ACYM_SUBSCRIBE_TEXT',
259 - 'type' => 'text',
260 - 'placeholder' => acym_translation('ACYM_SUBSCRIBE'),
261 - 'default' => '',
262 - ],
263 - ],
264 - 'style' => [
265 - 'position' => [
266 - 'label' => 'ACYM_DISPLAY_FIELDS_LABEL',
267 - 'type' => 'position',
268 - 'default' => 'image-top',
269 - 'allowed_types' => [self::SUB_FORM_TYPE_HEADER, self::SUB_FORM_TYPE_POPUP, self::SUB_FORM_TYPE_FOOTER],
270 - ],
271 - 'background_color' => [
272 - 'label' => 'ACYM_BACKGROUND_COLOR',
273 - 'type' => 'color',
274 - 'default' => '#ffffff',
275 - ],
276 - 'background_image' => [
277 - 'label' => 'ACYM_BACKGROUND_IMAGE',
278 - 'type' => 'media',
279 - 'default' => '',
280 - 'allowed_types' => [self::SUB_FORM_TYPE_POPUP],
281 - ],
282 - 'background_position' => [
283 - 'label' => 'ACYM_POSITION',
284 - 'type' => 'select',
285 - 'options' => [
286 - 'center' => acym_translation('ACYM_CENTER'),
287 - 'top' => acym_translation('ACYM_POSITION_TOP'),
288 - 'right' => acym_translation('ACYM_RIGHT'),
289 - 'right_bottom' => acym_translation('ACYM_POSITION_RIGHT_BOTTOM'),
290 - 'right_top' => acym_translation('ACYM_POSITION_RIGHT_TOP'),
291 - 'bottom' => acym_translation('ACYM_POSITION_BOTTOM'),
292 - 'left' => acym_translation('ACYM_LEFT'),
293 - 'left_top' => acym_translation('ACYM_POSITION_LEFT_TOP'),
294 - 'left_bottom' => acym_translation('ACYM_POSITION_LEFT_BOTTOM'),
295 - ],
296 - 'default' => 'center',
297 - 'allowed_types' => [self::SUB_FORM_TYPE_POPUP],
298 - ],
299 - 'background_size' => [
300 - 'label' => 'ACYM_BACKGROUND_SIZE',
301 - 'type' => 'select',
302 - 'options' => [
303 - 'contain' => acym_translation('ACYM_BG_CONTAIN'),
304 - 'cover' => acym_translation('ACYM_BG_COVER'),
305 - ],
306 - 'default' => 'contain',
307 - 'allowed_types' => [self::SUB_FORM_TYPE_POPUP],
308 - ],
309 - 'background_repeat' => [
310 - 'label' => 'ACYM_BACKGROUND_REPEAT',
311 - 'type' => 'select',
312 - 'options' => [
313 - 'repeat' => acym_translation('ACYM_YES'),
314 - 'no-repeat' => acym_translation('ACYM_NO'),
315 - ],
316 - 'default' => 'no-repeat',
317 - 'allowed_types' => [self::SUB_FORM_TYPE_POPUP],
318 - ],
319 - 'text_color' => [
320 - 'label' => 'ACYM_TEXT_COLOR',
321 - 'type' => 'color',
322 - 'default' => '#000000',
323 - ],
324 - 'padding' => [
325 - 'label' => 'ACYM_PADDING',
326 - 'type' => 'dimensions',
327 - 'default' => ['width' => 20, 'height' => 20],
328 - 'allowed_types' => [self::SUB_FORM_TYPE_POPUP],
329 - ],
330 - 'size' => [
331 - 'label' => 'ACYM_SIZE',
332 - 'type' => 'dimensions',
333 - 'units' => [
334 - self::SUB_FORM_TYPE_HEADER => ['width' => '%', 'height' => 'px'],
335 - self::SUB_FORM_TYPE_FOOTER => ['width' => '%', 'height' => 'px'],
336 - ],
337 - 'default' => ['width' => 400, 'height' => 300],
338 - 'allowed_types' => [self::SUB_FORM_TYPE_HEADER, self::SUB_FORM_TYPE_SHORTCODE, self::SUB_FORM_TYPE_FOOTER],
339 - ],
340 - ],
341 - ],
342 - ];
343 -
344 - if (acym_isMultilingual()) {
345 - $languageTexts = [];
346 - foreach (acym_getMultilingualLanguages() as $key => $languages) {
347 - $languageTexts[$key] = '';
348 - }
349 - unset($this->settings['options']['redirection']['confirmation_message']);
350 - $this->settings['options']['redirection']['langConfirm'] = [
351 - 'label' => 'ACYM_CONFIRMATION_MESSAGE',
352 - 'description' => 'ACYM_CONFIRMATION_MESSAGE_DESC',
353 - 'type' => 'language',
354 - 'default' => $languageTexts,
355 - ];
356 -
357 - unset($this->settings['styles']['button']['text']);
358 - $this->settings['styles']['button']['lang'] = [
359 - 'label' => 'ACYM_SUBSCRIBE_TEXT',
360 - 'type' => 'language',
361 - 'default' => $languageTexts,
362 - ];
363 - }
364 - }
365 -
366 - private function getSectionTranslations(): array
367 - {
368 - return [
369 - 'display' => 'ACYM_DISPLAY',
370 - 'lists' => 'ACYM_LISTS',
371 - 'fields' => 'ACYM_FIELDS',
372 - 'termspolicy' => 'ACYM_ARTICLE',
373 - 'cookie' => 'ACYM_COOKIE_SETTINGS',
374 - 'redirection' => 'ACYM_REDIRECTIONS',
375 - 'miscellaneous' => 'ACYM_MISCELLANEOUS',
376 - 'message' => 'ACYM_MESSAGE',
377 - 'image' => 'ACYM_IMAGE',
378 - 'button' => 'ACYM_BUTTON',
379 - 'style' => 'ACYM_STYLE',
380 - ];
381 - }
382 -
383 - public function getMatchingElements(array $settings = []): array
384 - {
385 - $query = 'SELECT form.* FROM #__acym_form AS form';
386 - $queryCount = 'SELECT COUNT(form.id) AS total, SUM(active) AS totalActive FROM #__acym_form AS form';
387 -
388 - if (!empty($settings['search'])) {
389 - $filters[] = 'name LIKE '.acym_escapeDB('%'.$settings['search'].'%');
390 - }
391 -
392 - if (!empty($filters)) {
393 - $query .= ' WHERE ('.implode(') AND (', $filters).')';
394 - $queryCount .= ' WHERE ('.implode(') AND (', $filters).')';
395 - }
396 -
397 - if (!empty($settings['status'])) {
398 - $query .= empty($filters) ? ' WHERE ' : ' AND ';
399 - $query .= 'active = '.($settings['status'] == 'active' ? '1' : '0');
400 - }
401 -
402 - if (!empty($settings['ordering']) && !empty($settings['ordering_sort_order'])) {
403 - $query .= ' ORDER BY '.acym_secureDBColumn($settings['ordering']).' '.acym_secureDBColumn(strtoupper($settings['ordering_sort_order']));
404 - } else {
405 - $query .= ' ORDER BY id asc';
406 - }
407 -
408 - if (empty($settings['offset']) || $settings['offset'] < 0) {
409 - $settings['offset'] = 0;
410 - }
411 -
412 - if (empty($settings['elementsPerPage']) || $settings['elementsPerPage'] < 1) {
413 - $pagination = new PaginationHelper();
414 - $settings['elementsPerPage'] = $pagination->getListLimit();
415 - }
416 -
417 - return [
418 - 'elements' => acym_loadObjectList($query, '', $settings['offset'], $settings['elementsPerPage']),
419 - 'total' => acym_loadObject($queryCount),
420 - ];
421 - }
422 -
423 - public function getTranslatedTypes(): array
424 - {
425 - return [
426 - self::SUB_FORM_TYPE_FOOTER => acym_translation('ACYM_FOOTER'),
427 - self::SUB_FORM_TYPE_HEADER => acym_translation('ACYM_HEADER'),
428 - self::SUB_FORM_TYPE_POPUP => acym_translation('ACYM_POPUP'),
429 - self::SUB_FORM_TYPE_SHORTCODE => acym_translation('ACYM_SHORTCODE'),
430 - ];
431 - }
432 -
433 - public function getOneById($id)
434 - {
435 - $form = acym_loadObject('SELECT * FROM #__acym_form WHERE id = '.intval($id));
436 -
437 - if (empty($form)) {
438 - return $form;
439 - }
440 -
441 - $form->pages = json_decode($form->pages, true);
442 - $form->settings = json_decode($form->settings, true);
443 - $form->display_languages = json_decode($form->display_languages, true);
444 -
445 - return $form;
446 - }
447 -
448 - public function getAllFormsToDisplay()
449 - {
450 - $forms = acym_loadObjectList('SELECT * FROM #__acym_form WHERE active = 1 AND type != '.acym_escapeDB(self::SUB_FORM_TYPE_SHORTCODE));
451 - foreach ($forms as $form) {
452 - $form->pages = json_decode($form->pages, true);
453 - $form->settings = json_decode($form->settings, true);
454 - $form->display_languages = json_decode($form->display_languages, true);
455 - }
456 -
457 - return $forms;
458 - }
459 -
460 - public function initEmptyForm($type)
461 - {
462 - $newForm = new \stdClass();
463 - $newForm->id = 0;
464 - $newForm->name = '';
465 - $newForm->creation_date = acym_date('now', 'Y-m-d H:i:s');
466 - $newForm->active = 1;
467 - $newForm->type = $type;
468 - $newForm->pages = ['all'];
469 - $newForm->display_languages = ['all'];
470 -
471 - $newForm->settings = [];
472 - foreach ($this->settings['options'] as $category => $options) {
473 - foreach ($options as $name => $oneOption) {
474 - $newForm->settings[$category][$name] = $oneOption['default'];
475 - }
476 - }
477 - foreach ($this->settings['styles'] as $category => $options) {
478 - foreach ($options as $name => $oneOption) {
479 - $newForm->settings[$category][$name] = $oneOption['default'];
480 - }
481 - }
482 -
483 - if ($type === self::SUB_FORM_TYPE_HEADER) {
484 - $newForm->settings['style']['position'] = 'button-left';
485 - $newForm->settings['style']['size'] = ['height' => '', 'width' => ''];
486 - } elseif ($type === self::SUB_FORM_TYPE_FOOTER) {
487 - $newForm->settings['style']['position'] = 'button-left';
488 - $newForm->settings['style']['size'] = ['width' => '100%', 'height' => '50'];
489 - }
490 -
491 - return $newForm;
492 - }
493 -
494 - public function getFormWithMissingParams($formArray): \stdClass
495 - {
496 - if (!is_array($formArray)) {
497 - $formArray = get_object_vars($formArray);
498 - }
499 -
500 - $form = new \stdClass();
501 - $formEmpty = $this->initEmptyForm($formArray['type']);
502 -
503 - if (!empty($formArray['id'])) {
504 - $form->id = $formArray['id'];
505 - }
506 -
507 - foreach ($formEmpty as $key => $value) {
508 - if ($key === 'settings') {
509 - continue;
510 - }
511 -
512 - if (isset($formArray[$key])) {
513 - $form->$key = $formArray[$key];
514 - } else {
515 - $form->$key = $value;
516 - }
517 - }
518 -
519 - $form->settings = $formEmpty->settings;
520 - foreach ($formArray['settings'] as $category => $options) {
521 - foreach ($options as $optionName => $value) {
522 - $form->settings[$category][$optionName] = $value;
523 - }
524 - }
525 -
526 - return $form;
527 - }
528 -
529 - public function prepareMenuHtml($form, $type): array
530 - {
531 - $sections = $this->getSectionTranslations();
532 - $htmlMenu = [];
533 - foreach ($this->settings[$type] as $category => $options) {
534 - $categoryOptions = [];
535 - foreach ($options as $key => $option) {
536 - if (!empty($option['allowed_types']) && !in_array($form->type, $option['allowed_types'])) {
537 - continue;
538 - }
539 -
540 - $id = 'form_'.$category.'_'.$key;
541 - $name = 'form[settings]['.$category.']['.$key.']';
542 - $vModel = 'form.settings.'.$category.'.'.$key;
543 - $value = $form->settings[$category][$key] ?? $option['default'];
544 -
545 - $label = '<label class="cell" for="'.$id.'">'.acym_translation($option['label']);
546 - if (!empty($option['description'])) {
547 - $label .= acym_info($option['description']);
548 - }
549 - $label .= '</label>';
550 -
551 - ob_start();
552 - include acym_getPartial('fields', $option['type']);
553 - $categoryOptions[$key] = $label.ob_get_clean();
554 - }
555 -
556 - if (!empty($categoryOptions)) {
557 - $htmlMenu[] = [
558 - 'title' => acym_translation($sections[$category]),
559 - 'render' => $categoryOptions,
560 - ];
561 - }
562 - }
563 -
564 - return $htmlMenu;
565 - }
566 -
567 - public function renderForm($form, $edition = false, $isShortcode = false)
568 - {
569 - if (!empty($form->display_languages) && !in_array('all', $form->display_languages) && !$edition) {
570 - if (!in_array(acym_getLanguageTag(), $form->display_languages)) {
571 - return '';
572 - }
573 - }
574 - $loadJsInModule = $isShortcode;
575 - if ($isShortcode && isset($form->settings['miscellaneous']['js_loading']) && $form->settings['miscellaneous']['js_loading'] === 'head') {
576 - $loadJsInModule = false;
577 - }
578 - acym_initModule(null, ['loadJsInModule' => $loadJsInModule]);
579 - $fieldClass = new FieldClass();
580 - $listClass = new ListClass();
581 -
582 - $form = $this->getFormWithMissingParams($form);
583 -
584 - $form->settings['fields']['displayed'][] = 2;
585 - $form->settings['fields']['displayed'] = $fieldClass->getFieldsByID($form->settings['fields']['displayed']);
586 - foreach ($form->settings['fields']['displayed'] as $key => $field) {
587 - $field->option = json_decode($field->option ?? '');
588 - $fieldDB = empty($field->option->fieldDB) ? '' : json_decode($field->option->fieldDB);
589 - $field->value = empty($field->value) ? '' : json_decode($field->value);
590 - $valuesArray = [];
591 -
592 - if (!empty($field->value)) {
593 - foreach ($field->value as $value) {
594 - $valueTmp = new \stdClass();
595 - $valueTmp->text = $value->title;
596 - $valueTmp->value = $value->value;
597 - if ($value->disabled == 'y') {
598 - $valueTmp->disable = true;
599 - }
600 - $valuesArray[$value->value] = $valueTmp;
601 - }
602 - }
603 -
604 - if (!empty($fieldDB) && !empty($fieldDB->value)) {
605 - $fromDB = $fieldClass->getValueFromDB($fieldDB);
606 - foreach ($fromDB as $value) {
607 - $valuesArray[$value->value] = $value->title;
608 - }
609 - }
610 -
611 - $form->settings['fields']['displayed'][$key]->valuesArray = $valuesArray;
612 - }
613 - $form->fieldClass = $fieldClass;
614 - $form->lists = $listClass->getAllForSelect(false, 0, true, true);
615 - $form->form_tag_name = 'formAcym'.$form->id;
616 - $form->form_tag_action = htmlspecialchars_decode(ACYM_CMS == 'wordpress' ? acym_frontendLink('frontusers') : acym_completeLink('frontusers', true, true));
617 - $form->formClass = $this;
618 -
619 - $formFieldRender = acym_getPartial('forms', $form->type);
620 - if (!file_exists($formFieldRender)) return '';
621 -
622 - acym_initModule(null, ['loadJsInModule' => $loadJsInModule]);
623 -
624 - ob_start();
625 - include $formFieldRender;
626 -
627 - return ob_get_clean();
628 - }
629 -}