ILIAS  trunk Revision v13.0_alpha-62-g3b72d83f2e5
class.ilIntLinkRepItemExplorerGUI.php
Go to the documentation of this file.
1<?php
2
20{
21 protected string $link_target_script;
22
26 public function __construct(
27 $a_parent_obj,
28 string $a_parent_cmd
29 ) {
30 parent::__construct($a_parent_obj, $a_parent_cmd, null, "", "");
31
32 // #14587 - ilRepositorySelectorExplorerGUI::__construct() does NOT include side blocks!
33 $list = $this->getTypeWhiteList();
34 $list[] = "poll";
35 $this->setTypeWhiteList($list);
36 }
37
41 public function setSetLinkTargetScript(string $a_script): void
42 {
43 $this->link_target_script = $a_script;
44 }
45
49 public function getSetLinkTargetScript(): string
50 {
52 }
53
57 public function getNodeHref($a_node): string
58 {
59 if ($this->getSetLinkTargetScript() === "") {
60 return "#";
61 }
62
65 "linktype=RepositoryItem&linktarget=il__" . $a_node["type"] . "_" . $a_node["child"]
66 );
67
68 return $link;
69 }
70
75 public function getNodeOnClick($a_node): string
76 {
77 if ($this->getSetLinkTargetScript() === "") {
78 $ref_id = $this->getRefIdFromNodeId($a_node["child"]);
79 $anchor = $this->getAnchorFromNodeId($a_node["child"]);
80
81 $anchor_str = "";
82 if ($anchor !== "") {
83 $anchor_str = " anchor=&quot;" . $anchor . "&quot;";
84 }
85 return "return il.IntLink.addInternalLink('[iln " . $a_node['type'] . "=&quot;" . $ref_id . "&quot;" . $anchor_str . "]','[/iln]', event);";
86 }
87
88 return "";
89 }
90
91 public function getChildsOfNode($a_parent_node_id): array
92 {
93 if (str_contains($a_parent_node_id, "#")) {
94 return [];
95 }
96 $ref_id = $this->getRefIdFromNodeId($a_parent_node_id);
97 $node = $this->tree->getNodeData($ref_id);
98 $childs = [];
99 if (!str_contains($a_parent_node_id, "#") && in_array($node["type"], ["crs", "cat", "grp", "fold"])) {
100 $obj_id = ilObject::_lookupObjId($ref_id);
101 foreach (ilPCParagraph::_readAnchors("cont", $obj_id, "") as $anchor) {
102 $anchor_node = $node;
103 $anchor_node["child"] = $ref_id . "#" . $anchor;
104 $anchor_node["title"] = "#" . $anchor;
105 $childs[] = $anchor_node;
106 }
107 }
108 $parent_childs = parent::getChildsOfNode($ref_id);
109 $childs = array_merge($childs, $parent_childs);
110 return $childs;
111 }
112
113 protected function getRefIdFromNodeId(string $node_id): int
114 {
115 $e = explode("#", $node_id);
116 return (int) $e[0];
117 }
118
119 protected function getAnchorFromNodeId(string $node_id): string
120 {
121 $e = explode("#", $node_id);
122 return $e[1] ?? "";
123 }
124
125 public function isNodeVisible($a_node): bool
126 {
127 $a_node["child"] = $this->getRefIdFromNodeId($a_node["child"]);
128 return parent::isNodeVisible($a_node);
129 }
130
131 public function getNodeIcon($a_node): string
132 {
133 if (str_contains($a_node["child"], "#")) {
134 return "";
135 }
136 $a_node["child"] = $this->getRefIdFromNodeId($a_node["child"]);
137 return parent::getNodeIcon($a_node);
138 }
139
140 public function isNodeClickable($a_node): bool
141 {
142 $a_node["child"] = $this->getRefIdFromNodeId($a_node["child"]);
143 return parent::isNodeClickable($a_node);
144 }
145
146 public function isNodeHighlighted($a_node): bool
147 {
148 if (str_contains($a_node["child"], "#")) {
149 return false;
150 }
151 $a_node["child"] = $this->getRefIdFromNodeId($a_node["child"]);
152 return parent::isNodeHighlighted($a_node);
153 }
154
155}
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
getChildsOfNode($a_parent_node_id)
Get childs of node.
__construct( $a_parent_obj, string $a_parent_cmd)
isNodeHighlighted($a_node)
Is node highlighted?
getSetLinkTargetScript()
Get "set link target" script.
getNodeOnClick($a_node)
get onclick event handling
setSetLinkTargetScript(string $a_script)
Set "set link target" script.
static _lookupObjId(int $ref_id)
static _readAnchors(string $a_parent_type, int $a_page_id, string $a_page_lang="-")
Read anchors of a page.
Explorer for selecting repository items.
getTypeWhiteList()
Get type white list.
setTypeWhiteList(array $a_val)
Set type white list.
static appendUrlParameterString(string $a_url, string $a_par, bool $xml_style=false)
__construct(Container $dic, ilPlugin $plugin)
@inheritDoc