PluginProbe
AcyMailing – An Ultimate Newsletter Plugin and Marketing Automation Solution for WordPress / 11.0.0
AcyMailing – An Ultimate Newsletter Plugin and Marketing Automation Solution for WordPress v11.0.0
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
acymailing / front / Params / lists.php

lists.php in AcyMailing – An Ultimate Newsletter Plugin and Marketing Automation Solution for WordPress 11.0.0, at front/Params/lists.php

66 lines 1.8 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 defined('ABSPATH') || die('Restricted Access');
3
4 use AcyMailing\Classes\ListClass;
5
6 include_once __DIR__.DIRECTORY_SEPARATOR.'AcymJFormField.php';
7
8 // phpcs:ignore WordPress.NamingConventions.PrefixAllGlobals.NonPrefixedClassFound -- Joomla specific class naming with imposed prefix "JFormField".
9 class JFormFieldLists extends AcymJFormField
10 {
11 public function __construct($form = null)
12 {
13 $this->type = 'lists';
14 parent::__construct($form);
15 }
16
17 public function getInput()
18 {
19
20 $listClass = new ListClass();
21 $lists = $listClass->getAllWithoutManagement();
22 foreach ($lists as $i => $oneList) {
23 if ($oneList->active == 0) {
24 unset($lists[$i]);
25 }
26 }
27
28 // In Joomla, when the user chooses to empty a field, it sets the default value of this field... that's not what we want
29 if (ACYM_CMS == 'joomla' && $this->value === 'All' && !empty($this->form)) {
30 $formId = $this->form->getData()->get('id');
31 if (!empty($formId)) {
32 $this->value = '';
33 }
34 }
35
36 if (is_string($this->value)) {
37 $this->value = explode(',', $this->value);
38 }
39
40 if (in_array('None', $this->value)) {
41 $this->value = [];
42 }
43 if (in_array('All', $this->value)) {
44 $visibleLists = [];
45 foreach ($lists as $listId => $oneList) {
46 if ($oneList->visible == 0) continue;
47
48 $visibleLists[] = $listId;
49 }
50 $this->value = $visibleLists;
51 }
52
53 return acym_selectMultiple(
54 $lists,
55 $this->name,
56 $this->value,
57 [
58 'class' => 'acym_simple_select2',
59 'id' => $this->name,
60 ],
61 'id',
62 'name'
63 );
64 }
65 }
66