| 1 |
<?php |
| 2 |
|
| 3 |
namespace AcyMailing\Controllers\Fields; |
| 4 |
|
| 5 |
use AcyMailing\Classes\FieldClass; |
| 6 |
use AcyMailing\Helpers\ToolbarHelper; |
| 7 |
|
| 8 |
trait Listing |
| 9 |
{ |
| 10 |
public function listing(): void |
| 11 |
{ |
| 12 |
$data = []; |
| 13 |
|
| 14 |
if (!acym_level(ACYM_ENTERPRISE)) { |
| 15 |
acym_setVar('layout', 'splashscreen'); |
| 16 |
} |
| 17 |
|
| 18 |
parent::display($data); |
| 19 |
} |
| 20 |
|
| 21 |
protected function prepareToolbar(array &$data): void |
| 22 |
{ |
| 23 |
$toolbarHelper = new ToolbarHelper(); |
| 24 |
$toolbarHelper->addButton(acym_translation('ACYM_CREATE'), ['data-task' => 'edit'], 'add', true); |
| 25 |
|
| 26 |
$data['toolbar'] = $toolbarHelper; |
| 27 |
} |
| 28 |
|
| 29 |
public function ajaxSetOrdering(): void |
| 30 |
{ |
| 31 |
$order = json_decode(acym_getVar('string', 'order')); |
| 32 |
$i = 1; |
| 33 |
$error = false; |
| 34 |
foreach ($order as $field) { |
| 35 |
$query = 'UPDATE #__acym_field SET `ordering` = '.intval($i).' WHERE `id` = '.intval($field); |
| 36 |
$error = acym_query($query) < 0 || $error; |
| 37 |
$i++; |
| 38 |
} |
| 39 |
|
| 40 |
acym_sendAjaxResponse('', [], !$error); |
| 41 |
} |
| 42 |
|
| 43 |
public function delete(): void |
| 44 |
{ |
| 45 |
$fieldClass = new FieldClass(); |
| 46 |
$ids = acym_getVar('cmd', 'elements_checked'); |
| 47 |
if (in_array('1', $ids) || in_array('2', $ids) || in_array($fieldClass->getLanguageFieldId(), $ids)) { |
| 48 |
acym_enqueueMessage(acym_translation('ACYM_CANT_DELETE'), 'error'); |
| 49 |
$this->listing(); |
| 50 |
} else { |
| 51 |
parent::delete(); |
| 52 |
} |
| 53 |
} |
| 54 |
} |
| 55 |
|