| 1 |
<?php |
| 2 |
|
| 3 |
use AcyMailing\Classes\ListClass; |
| 4 |
|
| 5 |
include_once __DIR__.DIRECTORY_SEPARATOR.'AcymJFormField.php'; |
| 6 |
|
| 7 |
class JFormFieldLists extends AcymJFormField |
| 8 |
{ |
| 9 |
var $type = 'lists'; |
| 10 |
|
| 11 |
public $value; |
| 12 |
|
| 13 |
public function getInput() |
| 14 |
{ |
| 15 |
|
| 16 |
$listClass = new ListClass(); |
| 17 |
$lists = $listClass->getAllWithoutManagement(); |
| 18 |
foreach ($lists as $i => $oneList) { |
| 19 |
if ($oneList->active == 0) { |
| 20 |
unset($lists[$i]); |
| 21 |
} |
| 22 |
} |
| 23 |
|
| 24 |
if (ACYM_CMS == 'joomla' && $this->value == 'All' && !empty($this->form)) { |
| 25 |
$formId = $this->form->getData()->get('id'); |
| 26 |
if (!empty($formId)) { |
| 27 |
$this->value = ''; |
| 28 |
} |
| 29 |
} |
| 30 |
|
| 31 |
if (is_string($this->value)) { |
| 32 |
$this->value = explode(',', $this->value); |
| 33 |
} |
| 34 |
|
| 35 |
if (in_array('None', $this->value)) { |
| 36 |
$this->value = []; |
| 37 |
} |
| 38 |
if (in_array('All', $this->value)) { |
| 39 |
$visibleLists = []; |
| 40 |
foreach ($lists as $listId => $oneList) { |
| 41 |
if ($oneList->visible == 0) continue; |
| 42 |
|
| 43 |
$visibleLists[] = $listId; |
| 44 |
} |
| 45 |
$this->value = $visibleLists; |
| 46 |
} |
| 47 |
|
| 48 |
return acym_selectMultiple( |
| 49 |
$lists, |
| 50 |
$this->name, |
| 51 |
$this->value, |
| 52 |
[ |
| 53 |
'class' => 'acym_simple_select2', |
| 54 |
'id' => $this->name, |
| 55 |
], |
| 56 |
'id', |
| 57 |
'name' |
| 58 |
); |
| 59 |
} |
| 60 |
} |
| 61 |
|