| @@ -1,72 +1,0 @@ | ||
| 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(string $textContent, array $attributes, string $icon = '', bool $isPrimary = false): void | |
| 14 | - { | |
| 15 | - $data = [ | |
| 16 | - 'icon' => $icon, | |
| 17 | - 'content' => acym_translation($textContent), | |
| 18 | - 'attributes' => $attributes, | |
| 19 | - 'isPrimary' => $isPrimary, | |
| 20 | - ]; | |
| 21 | - | |
| 22 | - ob_start(); | |
| 23 | - include acym_getPartial('toolbar', 'button_main'); | |
| 24 | - $this->rightPart .= ob_get_clean(); | |
| 25 | - } | |
| 26 | - | |
| 27 | - public function addOtherContent(string $content, string $side = 'right'): void | |
| 28 | - { | |
| 29 | - if (in_array($side, ['left', 'right'])) { | |
| 30 | - $this->{$side.'Part'} .= $content; | |
| 31 | - } | |
| 32 | - } | |
| 33 | - | |
| 34 | - public function addSearchBar(string $search, string $name, string $placeholder = 'ACYM_SEARCH', bool $showClearBtn = true): void | |
| 35 | - { | |
| 36 | - $this->leftPart .= acym_filterSearch($search, $name, $placeholder, $showClearBtn, 'acym__toolbar__search-field margin-bottom-0'); | |
| 37 | - } | |
| 38 | - | |
| 39 | - public function addFilterByTag(array &$data, string $name, string $class): void | |
| 40 | - { | |
| 41 | - $allTags = new \stdClass(); | |
| 42 | - $allTags->name = acym_translation('ACYM_ALL_TAGS'); | |
| 43 | - $allTags->value = ''; | |
| 44 | - array_unshift($data['allTags'], $allTags); | |
| 45 | - $this->addOptionSelect( | |
| 46 | - acym_translation('ACYM_TAG'), | |
| 47 | - acym_select( | |
| 48 | - $data['allTags'], | |
| 49 | - $name, | |
| 50 | - acym_escape($data['tag']), | |
| 51 | - [ | |
| 52 | - 'class' => $class, | |
| 53 | - ], | |
| 54 | - 'value', | |
| 55 | - 'name' | |
| 56 | - ) | |
| 57 | - ); | |
| 58 | - } | |
| 59 | - | |
| 60 | - public function addOptionSelect(string $title, string $select): void | |
| 61 | - { | |
| 62 | - $this->moreOptionsPart[] = '<div class="cell grid-x shrink acym__toolbar__filters__select"><label class="cell">'.$title.'</label>'.$select.'</div>'; | |
| 63 | - } | |
| 64 | - | |
| 65 | - public function displayToolbar(array $data): void | |
| 66 | - { | |
| 67 | - $data['leftPart'] = $this->leftPart; | |
| 68 | - $data['rightPart'] = $this->rightPart; | |
| 69 | - $data['moreOptionsPart'] = $this->moreOptionsPart; | |
| 70 | - include acym_getPartial('toolbar', 'toolbar'); | |
| 71 | - } | |
| 72 | -} | |