18declare(strict_types=1);
47 protected array $branch_object_type_list,
48 protected array $leaf_object_type_list,
49 protected int $max_branch_node_depth,
50 protected int $root_node_id,
52 $this->node_object_type_list = array_merge($this->branch_object_type_list, $this->leaf_object_type_list);
56 Field\Node\
Factory $node_factory,
58 array $sync_node_id_whitelist = [],
59 ?
string $parent_id =
null,
64 $sync_node_id_whitelist,
65 (
int) ($parent_id ?? $this->root_node_id),
70 Field\Node\
Factory $node_factory,
74 foreach ($node_ids as $node_id) {
76 $tree_node_data = $this->tree->getNodeData((
int) $node_id);
77 [$object_path, $object_ref_id, $object_type, $object_title] = $this->extractObjectDataOrAbort($tree_node_data);
78 yield $node_factory->leaf(
81 $this->getObjectIcon($icon_factory, $object_ref_id, $object_type),
83 }
catch (\LogicException) {
84 yield $node_factory->leaf([$node_id], $this->
language->txt(
'unknown'));
91 Field\Node\
Factory $node_factory,
93 array $max_depth_node_id_whitelist,
94 int $parent_object_id,
97 $children = $this->tree->getChildsByTypeFilter(
99 $this->node_object_type_list,
104 foreach ($children as $child) {
105 [$object_path, $object_ref_id, $object_type, $object_title] = $this->extractObjectDataOrAbort($child);
107 $is_object_visible = $this->isObjectVisible($object_ref_id, $object_type);
108 $is_object_container = $this->isObjectContainer($object_type);
111 if (!$is_object_visible && $is_object_container) {
112 $nodes = [...$nodes, ...$this->createNodes(
115 $max_depth_node_id_whitelist,
122 $object_icon = $this->getObjectIcon($icon_factory, $object_ref_id, $object_type);
124 if ($is_object_visible && $is_object_container) {
125 if ($depth < $this->max_branch_node_depth || in_array($object_ref_id, $max_depth_node_id_whitelist,
true)) {
126 $nodes[] = $node_factory->branch(
130 ...$this->createNodes(
133 $max_depth_node_id_whitelist,
139 $nodes[] = $node_factory->async(
140 $this->getAsyncRenderUrl($object_ref_id),
148 if ($is_object_visible && !$is_object_container) {
149 $nodes[] = $node_factory->leaf($object_path, $object_title, $object_icon);
158 $object_path = array_map(
'intval', explode(
'.', (
string) ($tree_node_data[
'path'] ??
'')));
159 $object_ref_id = $tree_node_data[
'ref_id'] ?? $tree_node_data[
'child'] ??
null;
160 $object_type = $tree_node_data[
'type'] ??
null;
161 $object_title = $tree_node_data[
'title'] ??
null;
162 if (empty($object_path) ||
null === $object_ref_id ||
null === $object_type ||
null === $object_title) {
163 throw new \LogicException(
"Object data is invalid");
165 return [$object_path, $object_ref_id, $object_type, $object_title];
170 $async_node_url_builder = $this->async_node_url_builder->
withParameter(
171 $this->async_node_id_parameter,
172 (
string) $object_ref_id
174 return $this->data_factory->uri((
string) $async_node_url_builder->buildURI());
182 if ($this->tree->getRootId() >= $object_ref_id) {
183 $alt_text = $this->
language->txt(
'repository');
185 $alt_text = $this->
language->txt($object_type);
187 return $icon_factory->custom($icon_path, $alt_text,
Icon\Icon::SMALL);
190 protected function isObjectVisible(
int $object_ref_id,
string $object_type =
''): bool
192 return $this->
access->checkAccess(
'visible',
'', $object_ref_id, $object_type);
197 return in_array($object_type, $this->branch_object_type_list,
true);
The scope of this class is split ilias-conform URI's into components.
withParameter(string $key, $value)
Get URI with modified parameters.
array $node_object_type_list
getAsyncRenderUrl(int $object_ref_id)
createNodes(Field\Node\Factory $node_factory, Icon\Factory $icon_factory, array $max_depth_node_id_whitelist, int $parent_object_id, int $depth=0,)
getObjectIcon(Icon\Factory $icon_factory, int $object_ref_id, string $object_type)
extractObjectDataOrAbort(array $tree_node_data)
isObjectContainer(string $object_type)
const string NODE_SORT_BY
node attribute used to sort entries,
isObjectVisible(int $object_ref_id, string $object_type='')
getNodes(Field\Node\Factory $node_factory, Icon\Factory $icon_factory, array $sync_node_id_whitelist=[], ?string $parent_id=null,)
getNodesAsLeaf(Field\Node\Factory $node_factory, Icon\Factory $icon_factory, array $node_ids)
__construct(protected \ILIAS\Language\Language $language, protected \ILIAS\Data\Factory $data_factory, protected \ILIAS\UI\URLBuilderToken $async_node_id_parameter, protected \ILIAS\UI\URLBuilder $async_node_url_builder, protected \ilAccess $access, protected \ilTree $tree, protected array $branch_object_type_list, protected array $leaf_object_type_list, protected int $max_branch_node_depth, protected int $root_node_id,)
Class ilAccessHandler Checks access for ILIAS objects.
static _lookupObjectId(int $ref_id)
static _getIcon(int $obj_id=0, string $size="big", string $type="", bool $offline=false)
Get icon for repository item.
Tree class data representation in hierachical trees using the Nested Set Model with Gaps by Joe Celco...
This describes how an icon could be modified during construction of UI.
Interface Observer \BackgroundTasks Contains several chained tasks and infos about them.