| @@ -5,9 +5,9 @@ | ||
| 5 | 5 | use AcyMailing\Core\AcymObject; |
| 6 | 6 | |
| 7 | 7 | class FileTreeType extends AcymObject |
| 8 | 8 | { |
| 9 | - public function display(array $folders, string $currentFolder, string $nameInput): string | |
| 9 | + public function display(array $folders, string $currentFolder, string $nameInput): void | |
| 10 | 10 | { |
| 11 | 11 | $tree = []; |
| 12 | 12 | foreach ($folders as $root => $children) { |
| 13 | 13 | $tree = array_merge($tree, $this->searchChildren($children, $root)); |
| @@ -12,13 +12,13 @@ | ||
| 12 | 12 | foreach ($folders as $root => $children) { |
| 13 | 13 | $tree = array_merge($tree, $this->searchChildren($children, $root)); |
| 14 | 14 | } |
| 15 | 15 | |
| 16 | - $treeView = '<div id="displaytree" class="cell medium-11"><input type="text" readonly name="currentPath" id="currentPath" value="'.acym_escape($currentFolder).'"></div>'; | |
| 17 | - $treeView .= '<div class="cell" id="treefile" style="display: none;">'.$this->displayTree($tree, $currentFolder).'</div>'; | |
| 18 | - $treeView .= '<input type="hidden" name="'.acym_escape($nameInput).'" id="'.acym_escape($nameInput).'" value="'.acym_escape($currentFolder).'">'; | |
| 19 | - | |
| 20 | - return $treeView; | |
| 16 | + echo '<div id="displaytree" class="cell medium-11"><input type="text" readonly name="currentPath" id="currentPath" value="'.esc_attr($currentFolder).'"></div>'; | |
| 17 | + echo '<div class="cell" id="treefile" style="display: none;">'; | |
| 18 | + $this->displayTree($tree, $currentFolder); | |
| 19 | + echo '</div>'; | |
| 20 | + echo '<input type="hidden" name="'.esc_attr($nameInput).'" id="'.esc_attr($nameInput).'" value="'.esc_attr($currentFolder).'">'; | |
| 21 | 21 | } |
| 22 | 22 | |
| 23 | 23 | private function searchChildren(array $folders, string $root): array |
| 24 | 24 | { |
| @@ -43,15 +43,15 @@ | ||
| 43 | 43 | |
| 44 | 44 | return $tree; |
| 45 | 45 | } |
| 46 | 46 | |
| 47 | - private function displayTree(array $tree, string $pathValue, string $path = ''): string | |
| 47 | + private function displayTree(array $tree, string $pathValue, string $path = ''): void | |
| 48 | 48 | { |
| 49 | 49 | if (empty($tree)) { |
| 50 | - return ''; | |
| 50 | + return; | |
| 51 | 51 | } |
| 52 | 52 | |
| 53 | - $results = '<ul>'; | |
| 53 | + echo '<ul>'; | |
| 54 | 54 | foreach ($tree as $key => $treeItem) { |
| 55 | 55 | if (empty($path)) { |
| 56 | 56 | $currentPath = $key; |
| 57 | 57 | $title = '/'; |
| @@ -71,16 +71,14 @@ | ||
| 71 | 71 | if (empty($treeItem)) { |
| 72 | 72 | $extraClass .= ' tree-empty'; |
| 73 | 73 | } |
| 74 | 74 | |
| 75 | - $subTree = $this->displayTree($treeItem, $pathValue, $currentPath); | |
| 76 | - $results .= '<li class="tree-child-item '.acym_escape($extraClass).'" data-path="'.acym_escape($currentPath).'"> | |
| 77 | - <span class="tree-child-title"> | |
| 78 | - <i class="'.acym_escape($icon).'"></i> '.$title.' | |
| 79 | - </span>'.$subTree.' | |
| 80 | - </li>'; | |
| 75 | + echo '<li class="tree-child-item '.esc_attr($extraClass).'" data-path="'.esc_attr($currentPath).'"> | |
| 76 | + <span class="tree-child-title"> | |
| 77 | + <i class="'.esc_attr($icon).'"></i> '.esc_html($title).' | |
| 78 | + </span>'; | |
| 79 | + $this->displayTree($treeItem, $pathValue, $currentPath); | |
| 80 | + echo '</li>'; | |
| 81 | 81 | } |
| 82 | - $results .= '</ul>'; | |
| 83 | - | |
| 84 | - return $results; | |
| 82 | + echo '</ul>'; | |
| 85 | 83 | } |
| 86 | 84 | } |