PluginProbe
AcyMailing – An Ultimate Newsletter Plugin and Marketing Automation Solution for WordPress / 11.0.3
AcyMailing – An Ultimate Newsletter Plugin and Marketing Automation Solution for WordPress v11.0.3
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 / back / Controllers / Forms / Listing.php

Listing.php in AcyMailing – An Ultimate Newsletter Plugin and Marketing Automation Solution for WordPress 11.0.3, at back/Controllers/Forms/Listing.php

74 lines 2.6 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2
3 namespace AcyMailing\Controllers\Forms;
4
5 use AcyMailing\Classes\FormClass;
6 use AcyMailing\Helpers\PaginationHelper;
7 use AcyMailing\Helpers\ToolbarHelper;
8
9 trait Listing
10 {
11 public function listing(): void
12 {
13 acym_setVar('layout', 'listing');
14 $pagination = new PaginationHelper();
15 $searchFilter = $this->getVarFiltersListing('string', 'forms_search', '');
16 $status = $this->getVarFiltersListing('string', 'forms_status', '');
17 $tagFilter = $this->getVarFiltersListing('string', 'forms_tag', '');
18 $ordering = $this->getVarFiltersListing('cmd', 'forms_ordering', 'id');
19 $orderingSortOrder = $this->getVarFiltersListing('cmd', 'forms_ordering_sort_order', 'asc');
20 $formClass = new FormClass();
21
22 // Get pagination data
23 $formsPerPage = $pagination->getListLimit();
24 $page = $this->getVarFiltersListing('int', 'forms_pagination_page', 1);
25
26 $requestData = [
27 'ordering' => $ordering,
28 'search' => $searchFilter,
29 'elementsPerPage' => $formsPerPage,
30 'offset' => ($page - 1) * $formsPerPage,
31 'tag' => $tagFilter,
32 'ordering_sort_order' => $orderingSortOrder,
33 'status' => $status,
34 ];
35
36 $matchingForms = $this->getMatchingElementsFromData($requestData, $status, $page);
37
38 // Prepare the pagination
39 $pagination->setStatus($matchingForms['total']->total, $page, $formsPerPage);
40
41 $filters = [
42 'all' => $matchingForms['total']->total,
43 'active' => $matchingForms['total']->totalActive,
44 'inactive' => $matchingForms['total']->total - $matchingForms['total']->totalActive,
45 ];
46
47 $data = [
48 'allForms' => $matchingForms['elements'],
49 'pagination' => $pagination,
50 'search' => $searchFilter,
51 'ordering' => $ordering,
52 'tag' => $tagFilter,
53 'status' => $status,
54 'orderingSortOrder' => $orderingSortOrder,
55 'formsNumberPerStatus' => $filters,
56 'formTypes' => $formClass->getTranslatedTypes(),
57 'formClass' => $formClass,
58 ];
59
60 $this->prepareToolbar($data);
61
62 parent::display($data);
63 }
64
65 public function prepareToolbar(array &$data): void
66 {
67 $toolbarHelper = new ToolbarHelper();
68 $toolbarHelper->addSearchBar($data['search'], 'forms_search', 'ACYM_SEARCH');
69 $toolbarHelper->addButton(acym_translation('ACYM_CREATE'), ['data-task' => 'newForm'], 'add', true);
70
71 $data['toolbar'] = $toolbarHelper;
72 }
73 }
74