| @@ -1,58 +1,0 @@ | ||
| 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'), true); | |
| 32 | - if (empty($order)) { | |
| 33 | - $order = []; | |
| 34 | - } | |
| 35 | - | |
| 36 | - $i = 1; | |
| 37 | - $error = false; | |
| 38 | - foreach ($order as $field) { | |
| 39 | - $query = 'UPDATE #__acym_field SET `ordering` = '.intval($i).' WHERE `id` = '.intval($field); | |
| 40 | - $error = acym_query($query) < 0 || $error; | |
| 41 | - $i++; | |
| 42 | - } | |
| 43 | - | |
| 44 | - acym_sendAjaxResponse('', [], !$error); | |
| 45 | - } | |
| 46 | - | |
| 47 | - public function delete(): void | |
| 48 | - { | |
| 49 | - $fieldClass = new FieldClass(); | |
| 50 | - $ids = acym_getVar('cmd', 'elements_checked'); | |
| 51 | - if (in_array('1', $ids) || in_array('2', $ids) || in_array($fieldClass->getLanguageFieldId(), $ids)) { | |
| 52 | - acym_enqueueMessage(acym_translation('ACYM_CANT_DELETE'), 'error'); | |
| 53 | - $this->listing(); | |
| 54 | - } else { | |
| 55 | - parent::delete(); | |
| 56 | - } | |
| 57 | - } | |
| 58 | -} | |