PluginProbe
AcyMailing – An Ultimate Newsletter Plugin and Marketing Automation Solution for WordPress / 11.1.1
AcyMailing – An Ultimate Newsletter Plugin and Marketing Automation Solution for WordPress v11.1.1
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
← All changes | back/Helpers/EntitySelectHelper.php +0 -183 10.10.2 → 11.1.1 View file →
@@ -1,183 +1,0 @@
1 -<?php
2 -
3 -namespace AcyMailing\Helpers;
4 -
5 -use AcyMailing\Core\AcymObject;
6 -
7 -class EntitySelectHelper extends AcymObject
8 -{
9 - private string $svg;
10 - private array $columnsHeaderNotToDisplay;
11 -
12 - public function __construct()
13 - {
14 - parent::__construct();
15 - $this->svg = acym_loaderLogo(false);
16 - $this->columnsHeaderNotToDisplay = ['color'];
17 - }
18 -
19 - public function entitySelect(
20 - string $entity,
21 - array $entityParams = [],
22 - array $columnsToDisplay = ['name'],
23 - array $buttonSubmit = [
24 - 'text' => '',
25 - 'action' => '',
26 - 'class' => '',
27 - ],
28 - bool $displaySelected = true,
29 - string $additionalData = '',
30 - string $displayedName = ''
31 - ): string {
32 - $columnJoin = '';
33 - if (!empty($columnsToDisplay['join'])) {
34 - $columnJoin = explode('.', $columnsToDisplay['join']);
35 - }
36 -
37 - unset($columnsToDisplay['join']);
38 -
39 - if (empty($entityParams['elementsPerPage']) || $entityParams['elementsPerPage'] < 1) {
40 - $paginationHelper = new PaginationHelper();
41 - $entityParams['elementsPerPage'] = $paginationHelper->getListLimit();
42 - }
43 -
44 - if (!empty($columnJoin)) $columnJoin = 'data-column-join="'.$columnJoin[1].'" data-table-join="'.$columnJoin[0].'"';
45 - $display = '<div
46 - style="display: none;"
47 - id="acym__entity_select"
48 - class="acym__entity_select cell grid-x"
49 - data-display-selected="'.($displaySelected ? 'true' : 'false').'"
50 - data-entity="'.acym_escape($entity).'"
51 - data-type="select"
52 - data-columns="'.implode(',', array_keys($columnsToDisplay)).'"
53 - data-columns-class="'.acym_escape(json_encode($columnsToDisplay)).'"
54 - data-join="'.$entityParams['join'].'"
55 - '.$columnJoin.'>';
56 -
57 - $display .= $this->getListing('available', 'select', $entity, $columnsToDisplay, $displayedName);
58 - $display .= '<div class="cell medium-shrink text-center grid-x acym_vcenter"><i class="acymicon-arrows-h cell"></i></div>';
59 - $display .= $this->getListing('selected', 'unselect', $entity, $columnsToDisplay, $displayedName);
60 - $display .= $additionalData;
61 -
62 - if (!empty($buttonSubmit['text'])) {
63 - $class = !empty($buttonSubmit['action']) ? 'acy_button_submit' : 'acym__entity_select__button__close';
64 - if (!empty($buttonSubmit['class'])) $class .= ' '.$buttonSubmit['class'];
65 - $buttonSubmit['action'] = !empty($buttonSubmit['action']) ? 'data-task="'.$buttonSubmit['action'].'"' : '';
66 - $display .= '<div class="cell grid-x align-center margin-top-1">';
67 - $display .= '<button
68 - type="button"
69 - id="acym__entity_select__button__submit"
70 - class="cell shrink grid-x '.$class.' button" '.$buttonSubmit['action'].'>'.$buttonSubmit['text'].'</button>';
71 - $display .= '</div>';
72 - }
73 -
74 - $display .= '<input type="hidden" class="acym__entity_select__selected" name="acym__entity_select__selected" value="">';
75 - $display .= '<input type="hidden" class="acym__entity_select__unselected" name="acym__entity_select__unselected" value="">';
76 - $display .= '</div>';
77 -
78 - return $display;
79 - }
80 -
81 - public function getColumnsForList(string $join = '', bool $small = false): array
82 - {
83 - $columns = [
84 - 'color' => $small ? 'small-2' : 'small-1',
85 - 'name' => 'auto',
86 - 'id' => 'small-2',
87 - ];
88 - if (!empty($join)) {
89 - $columns['join'] = $join;
90 - }
91 -
92 - return $columns;
93 - }
94 -
95 - public function getColumnsForUser(string $join = ''): array
96 - {
97 - $columns = [
98 - 'email' => 'auto',
99 - 'name' => 'auto',
100 - 'id' => 'small-1',
101 - ];
102 -
103 - if (!empty($join)) {
104 - $columns['join'] = $join;
105 - }
106 -
107 - return $columns;
108 - }
109 -
110 - private function getListing(string $type, string $allSelector, string $entity, array $columnsToDisplay = [], string $displayedName = ''): string
111 - {
112 - if (empty($displayedName)) {
113 - $displayedName = $entity;
114 - }
115 -
116 - $display = '<div class="cell medium-auto grid-x acym_area acym__entity_select__'.$type.'">
117 - <h5 class="cell font-bold acym__title acym__title__secondary text-center">'.acym_translation('ACYM_'.strtoupper($type).'_'.strtoupper($displayedName)).'</h5>
118 - <div class="cell grid-x">
119 - <div class="cell grid-x acym__entity_select__header">
120 - <div class="cell grid-x">
121 - <div class="cell margin-bottom-1"><input type="text" v-model="'.$type.'Search" placeholder="'.acym_translation('ACYM_SEARCH').'"></div>
122 - <div class="cell align-right grid-x acym__entity_select__select__all">
123 - <button type="button" v-show="!loading" v-if="displaySelectAll_'.$type.'" v-on:click="moveAll('.acym_escapeDB(
124 - $type
125 - ).')" class="cell shrink acym__entity_select__select__all__button acym__entity_select__select__all__button__'.$type.'">'.acym_translation(
126 - 'ACYM_'.strtoupper($allSelector).'_ALL'
127 - ).'</button>
128 - </div>
129 - </div>
130 - </div>
131 - <div v-infinite-scroll="loadMoreEntity'.ucfirst(
132 - $type
133 - ).'" :infinite-scroll-disabled="busy" class="acym__listing cell acym__entity_select__'.$type.'__listing acym__content" infinite-scroll-distance="10">';
134 - $emptyMessage = acym_translation($type === 'available' ? 'ACYM_NOTHING_TO_SHOW_HERE_RIGHT_PANEL' : 'ACYM_PLEASE_CLICK_ON_THE_LEFT_PANEL');
135 - $display .= '<div class="cell text-center acym__entity_select__title margin-top-2" v-show="Object.keys(entitiesToDisplay_'.$type.').length == 0 && !loading">'.$emptyMessage.'</div>
136 - <div class="cell acym_vcenter acym__listing__row grid-x acym__listing__row__header" v-if="Object.keys(entitiesToDisplay_'.$type.').length != 0">';
137 -
138 -
139 - if ($type !== 'available') $display .= '<div class="cell small-1"></div>';
140 -
141 - foreach ($columnsToDisplay as $column => $class) {
142 - $display .= '<div class="cell grid-x '.$class.'">'.(in_array($column, $this->columnsHeaderNotToDisplay) ? '' : acym_translation('ACYM_'.strtoupper($column))).'</div>';
143 - }
144 -
145 - if ($type === 'available') $display .= '<div class="cell small-1"></div>';
146 - $display .= '</div>';
147 -
148 - $functionClick = $type === 'available' ? 'v-on:click="selectEntity(entity.id)"' : 'v-on:click="unselectEntity(entity.id)"';
149 - $display .= '<div '.$functionClick.' v-for="(entity, index) in entitiesToDisplay_'.$type.'" class="cell acym_vcenter acym__listing__row grid-x acym__entity_select__'.$type.'__listing__row" >';
150 -
151 - if ($type !== 'available') {
152 - $display .= '<div class="cell small-1 vertical-align-middle text-center">
153 - <div class="plus-container acym__entity_select__selected__listing__row__unselect">
154 - <div class="top-plus plus-bar"></div>
155 - <div class="plus plus-bar"></div>
156 - <div class="bottom-plus plus-bar"></div>
157 - </div>
158 - </div>';
159 - }
160 -
161 - $display .= '<div v-for="(column, index) in columnsToDisplay" class="cell align-center acym__entity_select__columns" :class="getClass(column)" v-html="entity[column]"></div>';
162 -
163 - if ($type === 'available') {
164 - $display .= '<div class="cell small-1 vertical-align-middle text-center">
165 - <div class="plus-container acym__entity_select__available__listing__row__select">
166 - <div class="top-plus plus-bar"></div>
167 - <div class="plus plus-bar"></div>
168 - <div class="bottom-plus plus-bar"></div>
169 - </div>
170 - </div>';
171 - }
172 -
173 - $display .= '</div>
174 - <div class="cell grid-x align-center acym__entity_select__loading margin-top-1" v-show="loading"><div class="cell text-center acym__entity_select__title">';
175 - $display .= acym_translation('ACYM_WE_ARE_LOADING_YOUR_DATA');
176 - $display .= '</div><div class="cell grid-x shrink margin-top-1">'.$this->svg.'</div></div>';
177 - $display .= '</div>';
178 - $display .= '</div>
179 - </div>';
180 -
181 - return $display;
182 - }
183 -}