| 1 |
<?php |
| 2 |
|
| 3 |
namespace AcyMailing\Helpers; |
| 4 |
|
| 5 |
use AcyMailing\Core\AcymObject; |
| 6 |
|
| 7 |
class ToolbarHelper extends AcymObject |
| 8 |
{ |
| 9 |
private string $leftPart = ''; |
| 10 |
private string $rightPart = ''; |
| 11 |
private array $moreOptionsPart = []; |
| 12 |
|
| 13 |
public function addButton($textContent, $attributes, $icon = '', $isPrimary = false) |
| 14 |
{ |
| 15 |
$data = []; |
| 16 |
$data['icon'] = $icon; |
| 17 |
$data['content'] = acym_translation($textContent); |
| 18 |
$data['attributes'] = $attributes; |
| 19 |
$data['isPrimary'] = $isPrimary; |
| 20 |
|
| 21 |
ob_start(); |
| 22 |
include acym_getPartial('toolbar', 'button_main'); |
| 23 |
$this->rightPart .= ob_get_clean(); |
| 24 |
} |
| 25 |
|
| 26 |
public function addOtherContent($content, $side = 'right') |
| 27 |
{ |
| 28 |
if (in_array($side, ['left', 'right'])) { |
| 29 |
$this->{$side.'Part'} .= $content; |
| 30 |
} |
| 31 |
} |
| 32 |
|
| 33 |
public function addSearchBar($search, $name, $placeholder = 'ACYM_SEARCH', $showClearBtn = true) |
| 34 |
{ |
| 35 |
$this->leftPart .= acym_filterSearch($search, $name, $placeholder, $showClearBtn, 'acym__toolbar__search-field margin-bottom-0'); |
| 36 |
} |
| 37 |
|
| 38 |
public function addFilterByTag(&$data, $name, $class) |
| 39 |
{ |
| 40 |
$allTags = new \stdClass(); |
| 41 |
$allTags->name = acym_translation('ACYM_ALL_TAGS'); |
| 42 |
$allTags->value = ''; |
| 43 |
array_unshift($data['allTags'], $allTags); |
| 44 |
$this->addOptionSelect( |
| 45 |
acym_translation('ACYM_TAG'), |
| 46 |
acym_select( |
| 47 |
$data['allTags'], |
| 48 |
$name, |
| 49 |
acym_escape($data['tag']), |
| 50 |
[ |
| 51 |
'class' => $class, |
| 52 |
], |
| 53 |
'value', |
| 54 |
'name' |
| 55 |
) |
| 56 |
); |
| 57 |
} |
| 58 |
|
| 59 |
public function addOption($content) |
| 60 |
{ |
| 61 |
$this->moreOptionsPart[] = $content; |
| 62 |
} |
| 63 |
|
| 64 |
public function addOptionSelect($title, $select) |
| 65 |
{ |
| 66 |
$this->moreOptionsPart[] = '<div class="cell grid-x shrink acym__toolbar__filters__select"><label class="cell">'.$title.'</label>'.$select.'</div>'; |
| 67 |
} |
| 68 |
|
| 69 |
public function displayToolbar($data) |
| 70 |
{ |
| 71 |
$data['leftPart'] = $this->leftPart; |
| 72 |
$data['rightPart'] = $this->rightPart; |
| 73 |
$data['moreOptionsPart'] = $this->moreOptionsPart; |
| 74 |
include acym_getPartial('toolbar', 'toolbar'); |
| 75 |
} |
| 76 |
} |
| 77 |
|