-
Notifications
You must be signed in to change notification settings - Fork 7
Expand file tree
/
Copy pathCategoryButton.php
More file actions
82 lines (69 loc) · 2.69 KB
/
Copy pathCategoryButton.php
File metadata and controls
82 lines (69 loc) · 2.69 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
<?php
namespace FriendsOfRedaxo\QuickNavigation\Button;
use rex;
use rex_addon;
use rex_article;
use rex_category;
use rex_clang;
use rex_context;
use rex_fragment;
use rex_i18n;
use rex_string;
use rex_url;
use rex_yrewrite;
use FriendsOfRedaxo\QuickNavigation\Utility\BuildNavigationArray;
class CategoryButton implements ButtonInterface
{
public function RenderCategoriesAsList(array $categoriesArray, int $depth = 0): array
{
$listItems = [];
foreach ($categoriesArray as $item) {
$attributes = [
'href' => $item['url'],
'title' => 'Domain: ' . $item['domain'],
];
if ($item['current'] === true) {
$attributes['class'] = 'quick-navigation-current';
}
$listItem =
'<a' . rex_string::buildAttributes($attributes) . '>
' . rex_escape($item['name']) . '
<small class="rex-primary-id">(' . rex_escape($item['id']) . ')</small>
<small class="hidden">' . rex_escape($item['domain']) . '</small>
</a>';
if (!empty($item['children'])) {
$fragment = new rex_fragment([
'listItems' => $this->RenderCategoriesAsList($item['children'], $depth + 1),
]);
$listItem .= $fragment->parse('QuickNavigation/List.php');
}
$listItems[] = $listItem;
}
return $listItems;
}
public function get(): string
{
$ignoreOffline = false;
$user = rex::getUser()->getId();
if (rex_addon::get('quick_navigation')->getConfig('quick_navigation_ignoreoffline' . $user) == '1') {
$ignoreOffline = true;
}
$currentClangId = rex_clang::getCurrentId();
$categoriesArray = BuildNavigationArray::GenerateBackendNavArray($currentClangId, $ignoreOffline, null);
$listItems = $this->RenderCategoriesAsList($categoriesArray);
$placeholder = rex_i18n::msg('quick_navigation_placeholder');
$fragment = new rex_fragment();
$fragment->setVar('id', 'quick-navigation-search');
$fragment->setVar('placeholder', $placeholder);
$fragment->setVar('class', 'input-group input-group-xs has-feedback form-clear-button');
$searchbar = $fragment->parse('core/form/search.php');
$fragment = new rex_fragment([
'header' => $searchbar,
'label' => rex_i18n::msg('quick_navigation_structure'),
'icon' => 'fa-solid fa-folder-tree',
'listItems' => $listItems,
'listType' => 'tree',
]);
return $fragment->parse('QuickNavigation/Dropdown.php');
}
}