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/global/field.php +0 -818 10.10.2 → 11.1.1 View file →
@@ -1,818 +1,0 @@
1 -<?php
2 -
3 -function acym_radio(
4 - array $options,
5 - string $name,
6 - $selected = null,
7 - array $attributes = [],
8 - array $params = [],
9 - bool $frontDisplay = false,
10 - array $disabledOptions = [],
11 - bool $escapeLabels = true
12 -): string {
13 - $id = preg_replace(
14 - '#[^a-zA-Z0-9_]+#mi',
15 - '_',
16 - str_replace(
17 - ['[', ']'],
18 - ['_', ''],
19 - empty($params['id']) ? $name : $params['id']
20 - )
21 - );
22 -
23 - $objValue = empty($params['objectValue']) ? 'value' : $params['objectValue'];
24 - $objText = empty($params['objectText']) ? 'text' : $params['objectText'];
25 -
26 - $attributes['type'] = 'radio';
27 - $attributes['name'] = $name;
28 - if (empty($params['containerClass'])) {
29 - $params['containerClass'] = '';
30 - }
31 -
32 - $return = '<div class="acym_radio_group '.acym_escape($params['containerClass']).'">';
33 - $k = 0;
34 - foreach ($options as $value => $label) {
35 - $currentAttributes = $attributes;
36 - $currentAttributes['class'] = '';
37 - unset($currentAttributes['related']);
38 -
39 - if (is_object($label)) {
40 - if (!empty($label->class)) {
41 - $currentAttributes['class'] = $label->class;
42 - }
43 -
44 - $value = $label->$objValue;
45 - $label = $label->$objText;
46 - }
47 -
48 - $currentId = empty($params['useIncrement']) ? $id.$value : $id.$k;
49 -
50 - $currentAttributes['value'] = $value;
51 - $currentAttributes['id'] = $currentId;
52 -
53 - if (isset($attributes['related'][$value])) {
54 - $currentAttributes['acym-data-related'] = $attributes['related'][$value];
55 - }
56 -
57 - $extraClass = '';
58 - if (!empty($disabledOptions[$value])) {
59 - $currentAttributes['disabled'] = 'disabled';
60 - $extraClass = ' '.$disabledOptions[$value]['disabledClass'];
61 - $currentAttributes['class'] .= $extraClass;
62 - }
63 -
64 - if ((string)$value === (string)$selected) {
65 - $currentAttributes['checked'] = 'checked';
66 - }
67 - $formattedAttributes = acym_getFormattedAttributes($currentAttributes);
68 -
69 - if (!empty($params['required'])) {
70 - $formattedAttributes .= ' required';
71 - unset($params['required']);
72 - }
73 -
74 - $currentOption = '';
75 - if (!$frontDisplay) {
76 - $currentOption .= '<i data-radio="'.acym_escape($currentId).'" class="acymicon-radio-button-checked acym_radio_checked'.acym_escape($extraClass).'"></i>';
77 - $currentOption .= '<i data-radio="'.acym_escape($currentId).'" class="acymicon-radio-button-unchecked acym_radio_unchecked'.acym_escape($extraClass).'"></i>';
78 - }
79 -
80 - $currentOption .= '<input '.$formattedAttributes.' />';
81 - $currentOption .= '<label for="'.acym_escape($currentId).'" id="'.acym_escape($currentId).'-lbl" class="'.acym_escape($extraClass).'">';
82 - if ($escapeLabels) {
83 - $currentOption .= acym_escape(acym_translation($label));
84 - } else {
85 - $currentOption .= acym_translation($label);
86 - }
87 - $currentOption .= '</label>';
88 -
89 - if (!empty($disabledOptions[$value]['tooltipTxt'])) {
90 - $currentOption = acym_tooltip(
91 - [
92 - 'hoveredText' => $currentOption,
93 - 'textShownInTooltip' => $disabledOptions[$value]['tooltipTxt'],
94 - ]
95 - );
96 - }
97 -
98 - $return .= $currentOption;
99 -
100 - if (!empty($params['pluginMode'])) {
101 - $return .= '<br />';
102 - }
103 - $k++;
104 - }
105 - $return .= '</div>';
106 -
107 - return $return;
108 -}
109 -
110 -function acym_boolean(
111 - string $name,
112 - bool $selected = false,
113 - ?string $id = null,
114 - array $attributes = [],
115 - string $yes = 'ACYM_YES',
116 - string $no = 'ACYM_NO'
117 -): string {
118 - $options = [
119 - '1' => acym_translation($yes),
120 - '0' => acym_translation($no),
121 - ];
122 -
123 - $params = ['id' => $id];
124 - if (!empty($attributes['containerClass'])) {
125 - $params['containerClass'] = $attributes['containerClass'];
126 - unset($attributes['containerClass']);
127 - }
128 -
129 - return acym_radio(
130 - $options,
131 - $name,
132 - $selected ? 1 : 0,
133 - $attributes,
134 - $params,
135 - !acym_isAdmin()
136 - );
137 -}
138 -
139 -function acym_select(
140 - array $data,
141 - string $name,
142 - $selected = null,
143 - ?array $attribs = null,
144 - string $optKey = 'value',
145 - string $optText = 'text',
146 - ?string $idtag = null,
147 - bool $translate = false
148 -): string {
149 - if (empty($attribs)) {
150 - $attribs = [];
151 - }
152 -
153 - $attribs['name'] = $name;
154 - $attribs['id'] = str_replace(['[', ']', ' '], '', empty($idtag) ? $name : $idtag);
155 - $attributes = acym_getFormattedAttributes($attribs);
156 -
157 - $dropdown = '<select '.$attributes.'>';
158 -
159 - foreach ($data as $key => $oneOption) {
160 - $disabled = false;
161 - if (is_object($oneOption)) {
162 - $value = $oneOption->$optKey;
163 - $text = $oneOption->$optText;
164 - if (isset($oneOption->disable)) {
165 - $disabled = $oneOption->disable;
166 - }
167 - } else {
168 - $value = $key;
169 - $text = $oneOption;
170 - }
171 -
172 - if ($translate) {
173 - $text = acym_translation($text);
174 - }
175 -
176 - if (strtolower($value) === '<optgroup>') {
177 - $dropdown .= '<optgroup label="'.acym_escape($text).'">';
178 - } elseif (strtolower($value) === '</optgroup>') {
179 - $dropdown .= '</optgroup>';
180 - } else {
181 - $dropdown .= '<option value="'.acym_escape($value).'"'.(strval($value) === strval($selected) ? ' selected="selected"' : '').($disabled ? ' disabled="disabled"'
182 - : '').'>'.acym_escape($text).'</option>';
183 - }
184 - }
185 -
186 - $dropdown .= '</select>';
187 -
188 - return $dropdown;
189 -}
190 -
191 -function acym_selectMultiple(
192 - array $data,
193 - string $name,
194 - array $selected = [],
195 - array $attribs = [],
196 - string $optValue = 'value',
197 - string $optText = 'text',
198 - bool $translate = false
199 -): string {
200 -
201 - if (substr($name, -2) !== '[]') {
202 - $name .= '[]';
203 - }
204 - $baseName = substr($name, 0, -2);
205 -
206 - $attribs['multiple'] = 'multiple';
207 -
208 - $parameters = acym_getFormattedAttributes($attribs);
209 -
210 - $dropdown = '<input type="hidden" name="'.acym_escape($baseName).'" value="">';
211 - $dropdown .= '<select name="'.acym_escape($name).'"'.$parameters.'>';
212 -
213 - foreach ($data as $oneDataKey => $oneDataValue) {
214 - $disabled = '';
215 -
216 - if (is_object($oneDataValue)) {
217 - $value = $oneDataValue->$optValue;
218 - $text = $oneDataValue->$optText;
219 -
220 - if (!empty($oneDataValue->disable)) {
221 - $disabled = ' disabled="disabled"';
222 - }
223 - } else {
224 - $value = $oneDataKey;
225 - $text = $oneDataValue;
226 - }
227 -
228 - if ($translate) {
229 - $text = acym_translation($text);
230 - }
231 -
232 - if (strtolower($value) === '<optgroup>') {
233 - $dropdown .= '<optgroup label="'.acym_escape($text).'">';
234 - } elseif (strtolower($value) === '</optgroup>') {
235 - $dropdown .= '</optgroup>';
236 - } else {
237 - $dropdown .= '<option value="'.acym_escape($value).'"'.(in_array($value, $selected) ? ' selected="selected"' : '').$disabled.'>'.acym_escape($text).'</option>';
238 - }
239 - }
240 -
241 - $dropdown .= '</select>';
242 -
243 - return $dropdown;
244 -}
245 -
246 -function acym_selectOption(
247 - $value,
248 - string $text = '',
249 - string $optKey = 'value',
250 - string $optText = 'text',
251 - bool $disable = false
252 -): object {
253 - $option = new stdClass();
254 - $option->$optKey = $value;
255 - $option->$optText = acym_translation($text);
256 - $option->disable = $disable;
257 -
258 - return $option;
259 -}
260 -
261 -function acym_switch(
262 - string $name,
263 - $value,
264 - ?string $label = null,
265 - array $attrInput = [],
266 - string $labelClass = 'medium-6 small-9',
267 - string $switchContainerClass = 'auto',
268 - string $switchClass = '',
269 - ?string $toggle = null,
270 - bool $toggleOpen = true,
271 - string $vModel = '',
272 - bool $disabled = false,
273 - string $disabledMessage = ''
274 -): string {
275 - static $occurrence = 100;
276 - $occurrence++;
277 -
278 - $id = 'switch_'.$occurrence;
279 - $checked = $value == 1 ? 'checked="checked"' : '';
280 -
281 - $checkboxAriaLabel = '';
282 - if (!empty($attrInput['aria-label'])) {
283 - $checkboxAriaLabel = ' aria-label="'.acym_escape($attrInput['aria-label']).'"';
284 - unset($attrInput['aria-label']);
285 - }
286 -
287 - $attrInput['name'] = $name;
288 - $attrInput['data-switch'] = $id;
289 - $attrInput['value'] = $value;
290 -
291 - if (!empty($toggle)) {
292 - $attrInput['data-toggle-switch'] = $toggle;
293 - $attrInput['data-toggle-switch-open'] = $toggleOpen ? 'show' : 'hide';
294 - }
295 - $inputParameters = acym_getFormattedAttributes($attrInput);
296 -
297 - $switch = '
298 - <div class="switch '.acym_escape($switchClass).'">
299 - <input type="hidden" '.$vModel.' '.$inputParameters.'>';
300 -
301 - $labelSwitchDisabled = !$disabled ? '' : ' disabled';
302 - $inputSwitchDisabled = !$disabled ? '' : ' disabled="disabled"';
303 - $disabledTooltip = !$disabled || empty($disabledMessage) ? '' : ' data-acym-tooltip="'.acym_escape($disabledMessage).'"';
304 - $switch .= '
305 - <input class="switch-input" type="checkbox" id="'.acym_escape($id).'" value="1" tabindex="0" role="switch" '.$checked.$inputSwitchDisabled.$checkboxAriaLabel.'>
306 - <label class="switch-paddle switch-label'.$labelSwitchDisabled.'" '.$disabledTooltip.' for="'.acym_escape($id).'">
307 - <span class="switch-active" aria-hidden="true">1</span>
308 - <span class="switch-inactive" aria-hidden="true">0</span>
309 - </label>
310 - </div>';
311 -
312 - if (!empty($label)) {
313 - $label = '<label for="'.acym_escape($id).'" class="cell '.acym_escape($labelClass).' switch-label">'.$label.'</label>';
314 - $switch = $label.'<div class="cell '.acym_escape($switchContainerClass).'">'.$switch.'</div>';
315 - }
316 -
317 - return $switch;
318 -}
319 -
320 -function acym_showMore(string $toggle, string $text = 'ACYM_SHOW_MORE', string $class = ''): string
321 -{
322 - $showMore = '<div class="showmore '.acym_escape($class).'" data-toggle-showmore="'.acym_escape($toggle).'">';
323 - $showMore .= '<label>'.acym_escape(acym_translation($text)).'<i class="acymicon-keyboard-arrow-down"></i></label>';
324 - $showMore .= '</div>';
325 -
326 - return $showMore;
327 -}
328 -
329 -function acym_generateCountryNumber(string $name, string $defaultvalue = ''): string
330 -{
331 - $country = [
332 - '' => acym_translation('ACYM_PHONE_NOCOUNTRY'),
333 - '93' => 'Afghanistan',
334 - '355' => 'Albania',
335 - '213' => 'Algeria',
336 - '1684' => 'American Samoa',
337 - '376' => 'Andorra',
338 - '244' => 'Angola',
339 - '1264' => 'Anguilla',
340 - '672' => 'Antarctica',
341 - '1268' => 'Antigua & Barbuda',
342 - '54' => 'Argentina',
343 - '374' => 'Armenia',
344 - '297' => 'Aruba',
345 - '247' => 'Ascension Island',
346 - '61' => 'Australia',
347 - '43' => 'Austria',
348 - '994' => 'Azerbaijan',
349 - '1242' => 'Bahamas',
350 - '973' => 'Bahrain',
351 - '880' => 'Bangladesh',
352 - '1246' => 'Barbados',
353 - '375' => 'Belarus',
354 - '32' => 'Belgium',
355 - '501' => 'Belize',
356 - '229' => 'Benin',
357 - '1441' => 'Bermuda',
358 - '975' => 'Bhutan',
359 - '591' => 'Bolivia',
360 - '387' => 'Bosnia/Herzegovina',
361 - '267' => 'Botswana',
362 - '55' => 'Brazil',
363 - '1284' => 'British Virgin Islands',
364 - '673' => 'Brunei',
365 - '359' => 'Bulgaria',
366 - '226' => 'Burkina Faso',
367 - '257' => 'Burundi',
368 - '855' => 'Cambodia',
369 - '237' => 'Cameroon',
370 - '1' => 'Canada/USA',
371 - '238' => 'Cape Verde Islands',
372 - '1345' => 'Cayman Islands',
373 - '236' => 'Central African Republic',
374 - '235' => 'Chad Republic',
375 - '56' => 'Chile',
376 - '86' => 'China',
377 - '6724' => 'Christmas Island',
378 - '6722' => 'Cocos Keeling Island',
379 - '57' => 'Colombia',
380 - '269' => 'Comoros',
381 - '243' => 'Congo Democratic Republic',
382 - '242' => 'Congo, Republic of',
383 - '682' => 'Cook Islands',
384 - '506' => 'Costa Rica',
385 - '225' => 'Cote D\'Ivoire',
386 - '385' => 'Croatia',
387 - '53' => 'Cuba',
388 - '357' => 'Cyprus',
389 - '420' => 'Czech Republic',
390 - '45' => 'Denmark',
391 - '253' => 'Djibouti',
392 - '1767' => 'Dominica',
393 - '1809' => 'Dominican Republic',
394 - '593' => 'Ecuador',
395 - '20' => 'Egypt',
396 - '503' => 'El Salvador',
397 - '240' => 'Equatorial Guinea',
398 - '291' => 'Eritrea',
399 - '372' => 'Estonia',
400 - '251' => 'Ethiopia',
401 - '500' => 'Falkland Islands',
402 - '298' => 'Faroe Island',
403 - '679' => 'Fiji Islands',
404 - '358' => 'Finland',
405 - '33' => 'France',
406 - '596' => 'French Antilles/Martinique',
407 - '594' => 'French Guiana',
408 - '689' => 'French Polynesia',
409 - '241' => 'Gabon Republic',
410 - '220' => 'Gambia',
411 - '995' => 'Georgia',
412 - '49' => 'Germany',
413 - '233' => 'Ghana',
414 - '350' => 'Gibraltar',
415 - '30' => 'Greece',
416 - '299' => 'Greenland',
417 - '1473' => 'Grenada',
418 - '590' => 'Guadeloupe',
419 - '1671' => 'Guam',
420 - '502' => 'Guatemala',
421 - '224' => 'Guinea Republic',
422 - '245' => 'Guinea-Bissau',
423 - '592' => 'Guyana',
424 - '509' => 'Haiti',
425 - '504' => 'Honduras',
426 - '852' => 'Hong Kong',
427 - '36' => 'Hungary',
428 - '354' => 'Iceland',
429 - '91' => 'India',
430 - '62' => 'Indonesia',
431 - '964' => 'Iraq',
432 - '98' => 'Iran',
433 - '353' => 'Ireland',
434 - '972' => 'Israel',
435 - '39' => 'Italy',
436 - '1876' => 'Jamaica',
437 - '81' => 'Japan',
438 - '962' => 'Jordan',
439 - '254' => 'Kenya',
440 - '686' => 'Kiribati',
441 - '3774' => 'Kosovo',
442 - '965' => 'Kuwait',
443 - '996' => 'Kyrgyzstan',
444 - '856' => 'Laos',
445 - '371' => 'Latvia',
446 - '961' => 'Lebanon',
447 - '266' => 'Lesotho',
448 - '231' => 'Liberia',
449 - '218' => 'Libya',
450 - '423' => 'Liechtenstein',
451 - '370' => 'Lithuania',
452 - '352' => 'Luxembourg',
453 - '853' => 'Macau',
454 - '389' => 'Macedonia',
455 - '261' => 'Madagascar',
456 - '265' => 'Malawi',
457 - '60' => 'Malaysia',
458 - '960' => 'Maldives',
459 - '223' => 'Mali Republic',
460 - '356' => 'Malta',
461 - '692' => 'Marshall Islands',
462 - '222' => 'Mauritania',
463 - '230' => 'Mauritius',
464 - '52' => 'Mexico',
465 - '691' => 'Micronesia',
466 - '373' => 'Moldova',
467 - '377' => 'Monaco',
468 - '976' => 'Mongolia',
469 - '382' => 'Montenegro',
470 - '1664' => 'Montserrat',
471 - '212' => 'Morocco',
472 - '258' => 'Mozambique',
473 - '95' => 'Myanmar (Burma)',
474 - '264' => 'Namibia',
475 - '674' => 'Nauru',
476 - '977' => 'Nepal',
477 - '31' => 'Netherlands',
478 - '599' => 'Netherlands Antilles',
479 - '687' => 'New Caledonia',
480 - '64' => 'New Zealand',
481 - '505' => 'Nicaragua',
482 - '227' => 'Niger Republic',
483 - '234' => 'Nigeria',
484 - '683' => 'Niue Island',
485 - '6723' => 'Norfolk',
486 - '850' => 'North Korea',
487 - '47' => 'Norway',
488 - '968' => 'Oman Dem Republic',
489 - '92' => 'Pakistan',
490 - '680' => 'Palau Republic',
491 - '970' => 'Palestine',
492 - '507' => 'Panama',
493 - '675' => 'Papua New Guinea',
494 - '595' => 'Paraguay',
495 - '51' => 'Peru',
496 - '63' => 'Philippines',
497 - '48' => 'Poland',
498 - '351' => 'Portugal',
499 - '1787' => 'Puerto Rico',
500 - '974' => 'Qatar',
501 - '262' => 'Reunion Island',
502 - '40' => 'Romania',
503 - '7' => 'Russia',
504 - '250' => 'Rwanda Republic',
505 - '1670' => 'Saipan/Mariannas',
506 - '378' => 'San Marino',
507 - '239' => 'Sao Tome/Principe',
508 - '966' => 'Saudi Arabia',
509 - '221' => 'Senegal',
510 - '381' => 'Serbia',
511 - '248' => 'Seychelles Island',
512 - '232' => 'Sierra Leone',
513 - '65' => 'Singapore',
514 - '421' => 'Slovakia',
515 - '386' => 'Slovenia',
516 - '677' => 'Solomon Islands',
517 - '252' => 'Somalia Republic',
518 - '685' => 'Somoa',
519 - '27' => 'South Africa',
520 - '82' => 'South Korea',
521 - '34' => 'Spain',
522 - '94' => 'Sri Lanka',
523 - '290' => 'St. Helena',
524 - '1869' => 'St. Kitts',
525 - '1758' => 'St. Lucia',
526 - '508' => 'St. Pierre',
527 - '1784' => 'St. Vincent',
528 - '249' => 'Sudan',
529 - '597' => 'Suriname',
530 - '268' => 'Swaziland',
531 - '46' => 'Sweden',
532 - '41' => 'Switzerland',
533 - '963' => 'Syria',
534 - '886' => 'Taiwan',
535 - '992' => 'Tajikistan',
536 - '255' => 'Tanzania',
537 - '66' => 'Thailand',
538 - '228' => 'Togo Republic',
539 - '690' => 'Tokelau',
540 - '676' => 'Tonga Islands',
541 - '1868' => 'Trinidad & Tobago',
542 - '216' => 'Tunisia',
543 - '90' => 'Turkey',
544 - '993' => 'Turkmenistan',
545 - '1649' => 'Turks & Caicos Island',
546 - '688' => 'Tuvalu',
547 - '256' => 'Uganda',
548 - '380' => 'Ukraine',
549 - '971' => 'United Arab Emirates',
550 - '44' => 'United Kingdom',
551 - '598' => 'Uruguay',
552 - '1 ' => 'USA/Canada',
553 - '998' => 'Uzbekistan',
554 - '678' => 'Vanuatu',
555 - '3966' => 'Vatican City',
556 - '58' => 'Venezuela',
557 - '84' => 'Vietnam',
558 - '1340' => 'Virgin Islands (US)',
559 - '681' => 'Wallis/Futuna Islands',
560 - '967' => 'Yemen Arab Republic',
561 - '260' => 'Zambia',
562 - '263' => 'Zimbabwe',
563 - ];
564 -
565 - $countryCodeForSelect = [];
566 -
567 - foreach ($country as $key => $one) {
568 - $countryCodeForSelect[$key] = '+'.$key.' ('.$one.')';
569 - }
570 -
571 - return acym_select(
572 - $countryCodeForSelect,
573 - $name,
574 - empty($defaultvalue) ? '' : $defaultvalue,
575 - [
576 - 'class' => 'acym__select__country acym__select',
577 - 'autocomplete' => 'tel-country-code',
578 - ]
579 - );
580 -}
581 -
582 -function acym_cancelButton(string $text = 'ACYM_CANCEL', string $url = '', string $class = 'button medium-6 large-shrink'): string
583 -{
584 - if (empty($url)) {
585 - $url = acym_completeLink(acym_getVar('cmd', 'ctrl').'&task=listing');
586 - }
587 -
588 - return '<a href="'.$url.'" class="cell '.$class.' acym__button__cancel">'.acym_escape(acym_translation($text)).'</a>';
589 -}
590 -
591 -function acym_tooltip(array $options): string
592 -{
593 - if (!isset($options['classContainer'])) $options['classContainer'] = '';
594 - if (!isset($options['classText'])) $options['classText'] = '';
595 - if (!isset($options['titleShownInTooltip'])) $options['titleShownInTooltip'] = '';
596 - if (!isset($options['textShownInTooltip'])) $options['textShownInTooltip'] = '';
597 - if (!isset($options['hoveredText'])) $options['hoveredText'] = '';
598 - if (!isset($options['classLink'])) $options['classLink'] = '';
599 -
600 - if (!empty($options['link'])) {
601 - $options['hoveredText'] = '<a href="'.$options['link'].'" title="'.acym_escape($options['titleShownInTooltip']).'" target="_blank" class="'.acym_escape(
602 - $options['classLink']
603 - ).'">'.$options['hoveredText'].'</a>';
604 - }
605 -
606 - if (!empty($options['titleShownInTooltip'])) {
607 - $options['titleShownInTooltip'] = '<span class="acym__tooltip__title">'.$options['titleShownInTooltip'].'</span>';
608 - }
609 -
610 - $tooltip = '<span class="acym__tooltip '.$options['classContainer'].'">';
611 - $tooltip .= '<span class="acym__tooltip__text '.$options['classText'].'">';
612 - $tooltip .= $options['titleShownInTooltip'].$options['textShownInTooltip'].'</span>'.$options['hoveredText'].'</span>';
613 -
614 - return $tooltip;
615 -}
616 -
617 -function acym_info($options, string $class = '', string $containerClass = '', string $classText = '', bool $warningInfo = false): string
618 -{
619 - if (!is_array($options)) {
620 - $options = [
621 - 'textShownInTooltip' => $options,
622 - 'classContainer' => $containerClass,
623 - 'classIcon' => $class,
624 - 'classText' => $classText,
625 - 'isWarning' => $warningInfo,
626 - ];
627 - }
628 -
629 - if (!isset($options['textShownInTooltip'])) $options['textShownInTooltip'] = '';
630 - if (!isset($options['classContainer'])) $options['classContainer'] = '';
631 - if (!isset($options['classText'])) $options['classText'] = '';
632 - if (!isset($options['classIcon'])) $options['classIcon'] = '';
633 - if (!isset($options['isWarning'])) $options['isWarning'] = false;
634 -
635 - $classWarning = $options['isWarning'] ? 'acym__tooltip__info__warning' : '';
636 -
637 - return acym_tooltip(
638 - [
639 - 'hoveredText' => '<span class="acym__tooltip__info__container '.$options['classIcon'].'"><i class="acym__tooltip__info__icon acymicon-info-circle '.acym_escape(
640 - $classWarning
641 - ).'"></i></span>',
642 - 'textShownInTooltip' => acym_translation($options['textShownInTooltip']),
643 - 'classContainer' => 'acym__tooltip__info '.$options['classContainer'],
644 - 'classText' => $options['classText'],
645 - ]
646 - );
647 -}
648 -
649 -function acym_sortBy(array $options, string $listing, string $default = '', string $defaultSortOrdering = 'desc'): string
650 -{
651 - $default = empty($default) ? reset($options) : $default;
652 -
653 - $selected = acym_getVar('string', $listing.'_ordering', $default);
654 - $orderingSortOrder = acym_getVar('string', $listing.'_ordering_sort_order', $defaultSortOrdering);
655 - $classSortOrder = $orderingSortOrder === 'asc' ? 'acymicon-sort-amount-asc' : 'acymicon-sort-amount-desc';
656 -
657 - $display = '<span class="acym__color__dark-gray">'.acym_translation('ACYM_SORT_BY').'</span>';
658 - $display .= acym_select(
659 - $options,
660 - $listing.'_ordering',
661 - $selected,
662 - [
663 - 'id' => 'acym__listing__ordering',
664 - 'class' => 'acym__select acym__select__sort',
665 - ]
666 - );
667 -
668 - $tooltipText = $orderingSortOrder === 'asc' ? acym_translation('ACYM_SORT_ASC') : acym_translation('ACYM_SORT_DESC');
669 - $display .= acym_tooltip(
670 - [
671 - 'hoveredText' => '<i class="'.$classSortOrder.' acym__listing__ordering__sort-order" aria-hidden="true"></i>',
672 - 'textShownInTooltip' => $tooltipText,
673 - ]
674 - );
675 -
676 - $display .= '<input type="hidden" id="acym__listing__ordering__sort-order--input" name="'.$listing.'_ordering_sort_order" value="'.$orderingSortOrder.'">';
677 -
678 - return $display;
679 -}
680 -
681 -function acym_checkbox(
682 - array $values,
683 - string $name,
684 - array $selected = [],
685 - string $label = '',
686 - string $parentClass = '',
687 - string $labelClass = '',
688 - array $dataAttr = []
689 -): void {
690 - echo '<div class="'.acym_escape($parentClass).'"><div class="cell acym__label '.acym_escape($labelClass).'">'.$label.'</div><div class="cell auto grid-x">';
691 - foreach ($values as $key => $value) {
692 - $dtAttr = '';
693 - if (!empty($dataAttr[$key])) {
694 - $dtAttr = 'data-attr="'.acym_escape($dataAttr[$key]).'"';
695 - }
696 -
697 - echo '<label class="cell grid-x margin-top-1"><input type="checkbox" name="'.acym_escape($name).'" value="'.acym_escape($key).'" '.(in_array(
698 - $key,
699 - $selected
700 - ) ? 'checked="checked"' : '').' '.$dtAttr.'>'.$value.'</label>';
701 - }
702 - echo '</div></div>';
703 -}
704 -
705 -function acym_switchFilter(array $switchOptions, string $selected, string $name, string $addClass = ''): string
706 -{
707 - $return = '<input type="hidden" id="acym__type-template-'.acym_escape($name).'" name="'.acym_escape($name).'" value="'.acym_escape($selected).'">';
708 - foreach ($switchOptions as $value => $text) {
709 - $class = 'button button-secondary acym__type__choosen cell small-6 xlarge-auto large-shrink';
710 - if ($value === $selected) {
711 - $class .= ' is-active';
712 - }
713 - $class .= ' '.$addClass;
714 - $return .= '<button class="'.acym_escape($class).'" type="button" data-type="'.acym_escape($value).'">'.acym_escape(acym_translation($text)).'</button>';
715 - }
716 -
717 - return $return;
718 -}
719 -
720 -function acym_filterStatus(array $options, string $selected, string $name): string
721 -{
722 - $filterStatus = '<input type="hidden" id="acym_filter_status" name="'.acym_escape($name).'" value="'.acym_escape($selected).'"/>';
723 -
724 - foreach ($options as $value => $text) {
725 - $class = 'acym__filter__status ';
726 - if ($value === $selected) {
727 - $class .= ' font-bold acym__status__select';
728 - }
729 -
730 - $extraIcon = '';
731 - if (!empty($text[2]) && 'pending' == $text[2]) {
732 - $extraIcon = ' <i class="acymicon-exclamation-triangle acym__color__orange" style="font-size: 15px;"></i>';
733 - }
734 -
735 - if (is_null($text[1])) {
736 - $disabled = '';
737 - $userCount = '';
738 - } else {
739 - $disabled = empty($text[1]) ? ' disabled="disabled"' : '';
740 - $userCount = ' ('.$text[1].')';
741 - }
742 - $filterStatus .= '<button type="button" acym-data-status="'.acym_escape($value).'" class="'.acym_escape($class).'"'.$disabled.'>';
743 - $filterStatus .= acym_escape(acym_translation($text[0])).$extraIcon.'<span class="acym__filter__status__number">'.acym_escape($userCount).'</span></button>';
744 - }
745 -
746 - return $filterStatus;
747 -}
748 -
749 -function acym_filterSearch(
750 - string $search,
751 - string $name,
752 - string $placeholder = 'ACYM_SEARCH',
753 - bool $showClearBtn = true,
754 - string $additionalClasses = ''
755 -): string {
756 - $searchField = '<div class="input-group acym__search-area '.acym_escape($additionalClasses).'">
757 - <div class="input-group-button">
758 - <button class="button acym__search__button"><i class="acymicon-search"></i></button>
759 - </div>
760 - <input class="input-group-field acym__search-field" type="text" name="'.acym_escape($name).'" placeholder="'.acym_escape(
761 - acym_translation($placeholder)
762 - ).'" value="'.acym_escape($search).'">';
763 - if ($showClearBtn) {
764 - $searchField .= '<span class="acym__search-clear"><i class="acymicon-close"></i></span>';
765 - }
766 - $searchField .= '</div>';
767 -
768 - return $searchField;
769 -}
770 -
771 -function acym_displayParam(string $type, $value, string $name): string
772 -{
773 - if (!include_once ACYM_FRONT.'Params'.DS.$type.'.php') {
774 - return '';
775 - }
776 -
777 - $class = 'JFormField'.ucfirst($type);
778 -
779 - $field = new $class();
780 - $field->value = $value;
781 - $field->name = $name;
782 -
783 - return $field->getInput();
784 -}
785 -
786 -function acym_externalLink(
787 - string $text,
788 - string $link,
789 - bool $displayIcon = true,
790 - bool $openInNewTab = true,
791 - array $classesA = []
792 -): string {
793 - $target = $openInNewTab ? 'target="_blank"' : '';
794 - $link = 'href="'.acym_escapeUrl($link).'"';
795 - $icon = $displayIcon ? ' <i class="acymicon-external-link"></i>' : '';
796 - $translatedText = acym_translation($text);
797 - $classesA[] = 'acym__external__link';
798 - $classesAHtml = 'class="'.acym_escape(implode(' ', $classesA)).'"';
799 -
800 - return '<a '.$target.' '.$link.' '.$classesAHtml.'>'.acym_escape($translatedText).$icon.'</a>';
801 -}
802 -
803 -function acym_getFormattedAttributes(array $attributes): string
804 -{
805 - $params = '';
806 - foreach ($attributes as $oneAttribute => $oneValue) {
807 - $params .= ' '.$oneAttribute;
808 -
809 - if ($oneValue !== true) {
810 - if (is_array($oneValue) || is_object($oneValue)) {
811 - $oneValue = json_encode($oneValue);
812 - }
813 - $params .= '="'.acym_escape($oneValue).'"';
814 - }
815 - }
816 -
817 - return $params;
818 -}