19declare(strict_types=1);
54 protected array $branch_object_type_list,
55 protected array $leaf_object_type_list,
56 protected int $max_branch_node_depth,
57 protected int $root_node_id,
59 $this->node_object_type_list = array_merge($this->branch_object_type_list, $this->leaf_object_type_list);
63 NodeFactory $node_factory,
64 IconFactory $icon_factory,
65 ?
string $parent_id =
null,
67 yield
from $this->
createNodes($node_factory, $icon_factory, (
int) ($parent_id ?? $this->root_node_id));
71 NodeFactory $node_factory,
72 IconFactory $icon_factory,
75 foreach ($node_ids as $node_id) {
77 $tree_node_data = $this->tree->getNodeData((
int) $node_id);
78 [$object_ref_id, $object_type, $object_title] = $this->extractObjectDataOrAbort($tree_node_data);
79 yield $node_factory->leaf(
82 $this->getObjectIcon($icon_factory, $object_ref_id, $object_type),
84 }
catch (\LogicException) {
85 yield $node_factory->leaf($node_id, $this->
language->txt(
'unknown'));
92 NodeFactory $node_factory,
93 IconFactory $icon_factory,
94 int $parent_object_id,
97 $children = $this->tree->getChildsByTypeFilter(
99 $this->node_object_type_list,
104 foreach ($children as $child) {
105 [$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($node_factory, $icon_factory, $object_ref_id, $depth + 1)];
116 $object_icon = $this->getObjectIcon($icon_factory, $object_ref_id, $object_type);
118 if ($is_object_visible && $is_object_container) {
119 if ($depth < $this->max_branch_node_depth) {
120 $nodes[] = $node_factory->branch(
124 ...$this->createNodes($node_factory, $icon_factory, $object_ref_id, $depth + 1),
127 $nodes[] = $node_factory->async(
128 $this->getAsyncRenderUrl($object_ref_id),
136 if ($is_object_visible && !$is_object_container) {
137 $nodes[] = $node_factory->leaf($object_ref_id, $object_title, $object_icon);
146 $object_ref_id = $tree_node_data[
'ref_id'] ??
null;
147 $object_type = $tree_node_data[
'type'] ??
null;
148 $object_title = $tree_node_data[
'title'] ??
null;
149 if (in_array(
null, [$object_ref_id, $object_type, $object_title],
true)) {
150 throw new \LogicException(
"Object data is invalid");
152 return [$object_ref_id, $object_type, $object_title];
157 $async_node_url_builder = $this->async_node_url_builder->
withParameter(
158 $this->async_node_id_parameter,
159 (
string) $object_ref_id
161 return $this->data_factory->uri((
string) $async_node_url_builder->buildURI());
164 protected function getObjectIcon(IconFactory $icon_factory,
int $object_ref_id,
string $object_type):
Icon
169 if ($this->tree->getRootId() >= $object_ref_id) {
170 $alt_text = $this->
language->txt(
'repository');
172 $alt_text = $this->
language->txt($object_type);
174 return $icon_factory->custom($icon_path, $alt_text, Icon::SMALL);
177 protected function isObjectVisible(
int $object_ref_id,
string $object_type =
''): bool
179 return $this->
access->checkAccess(
'visible',
'', $object_ref_id, $object_type);
184 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.
getNodesAsLeaf(NodeFactory $node_factory, IconFactory $icon_factory, array $node_ids,)
getNodes(NodeFactory $node_factory, IconFactory $icon_factory, ?string $parent_id=null,)
const string NODE_SORT_BY
node attribute used to sort entries,
array $node_object_type_list
getObjectIcon(IconFactory $icon_factory, int $object_ref_id, string $object_type)
extractObjectDataOrAbort(array $tree_node_data)
isObjectVisible(int $object_ref_id, string $object_type='')
isObjectContainer(string $object_type)
__construct(protected Language $language, protected \ILIAS\Data\Factory $data_factory, protected URLBuilderToken $async_node_id_parameter, protected 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,)
createNodes(NodeFactory $node_factory, IconFactory $icon_factory, int $parent_object_id, int $depth=0,)
getAsyncRenderUrl(int $object_ref_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 is how a factory for icons looks like.
This describes how an icon could be modified during construction of UI.
This is how the factory for UI elements looks.
Interface Observer \BackgroundTasks Contains several chained tasks and infos about them.