PluginProbe
AcyMailing – An Ultimate Newsletter Plugin and Marketing Automation Solution for WordPress / 11.1.0
AcyMailing – An Ultimate Newsletter Plugin and Marketing Automation Solution for WordPress v11.1.0
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/Types/FileTreeType.php +23 -20 10.2.2 → 11.1.0 View file →
@@ -5,9 +5,9 @@
5 5 use AcyMailing\Core\AcymObject;
6 6
7 7 class FileTreeType extends AcymObject
8 8 {
9 - public function display($folders, $currentFolder, $nameInput)
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,16 +12,16 @@
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 - private function searchChildren($folders, $root)
23 + private function searchChildren(array $folders, string $root): array
24 24 {
25 25 $tree = [];
26 26 $tree[$root] = [];
27 27
@@ -43,12 +43,15 @@
43 43
44 44 return $tree;
45 45 }
46 46
47 - private function displayTree($tree, $pathValue, $path = '')
47 + private function displayTree(array $tree, string $pathValue, string $path = ''): void
48 48 {
49 - if (empty($tree)) return '';
50 - $results = '<ul>';
49 + if (empty($tree)) {
50 + return;
51 + }
52 +
53 + echo '<ul>';
51 54 foreach ($tree as $key => $treeItem) {
52 55 if (empty($path)) {
53 56 $currentPath = $key;
54 57 $title = '/';
@@ -64,18 +67,18 @@
64 67 $extraClass = $pathValue == $currentPath ? 'tree-current' : '';
65 68 $icon .= '-open';
66 69 }
67 70
68 - if (empty($treeItem)) $extraClass .= ' tree-empty';
71 + if (empty($treeItem)) {
72 + $extraClass .= ' tree-empty';
73 + }
69 74
70 - $subTree = $this->displayTree($treeItem, $pathValue, $currentPath);
71 - $results .= '<li class="tree-child-item '.acym_escape($extraClass).'" data-path="'.acym_escape($currentPath).'">
72 - <span class="tree-child-title">
73 - <i class="'.acym_escape($icon).'"></i> '.$title.'
74 - </span>'.$subTree.'
75 - </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>';
76 81 }
77 - $results .= '</ul>';
78 -
79 - return $results;
82 + echo '</ul>';
80 83 }
81 84 }