ILIAS  release_8 Revision v8.25-1-g13de6a5eca6
class.ilChapterHierarchyFormGUI.php
Go to the documentation of this file.
1<?php
2
26{
27 protected ilObjUser $user;
28 protected array $page_layouts;
29 protected string $lang;
30 protected string $lm_type;
31
32 public function __construct(string $a_lm_type, string $a_lang = "-")
33 {
34 global $DIC;
35
36 $this->lng = $DIC->language();
37 $this->user = $DIC->user();
38 $this->ctrl = $DIC->ctrl();
39 $this->lm_type = $a_lm_type;
40
41 $this->lang = ($a_lang == "")
42 ? "-"
43 : $a_lang;
45 $this->setCheckboxName("id");
46
47 $this->page_layouts = ilPageLayout::activeLayouts(
49 );
50 }
51
52 public function getChildTitle(array $a_child): string
53 {
54 if ($this->lang != "-") {
55 $lmobjtrans = new ilLMObjTranslation($a_child["node_id"], $this->lang);
56 return $lmobjtrans->getTitle();
57 }
58 return $a_child["title"];
59 }
60
66 public function getChildInfo(array $a_child): string
67 {
68 if ($this->lang != "-") {
69 return $a_child["title"];
70 }
71 return "";
72 }
73
77 public function getMenuItems(array $a_node, int $a_depth, bool $a_first_child = false, ?array $a_next_sibling = null, ?array $a_childs = null): array
78 {
81
82 $cmds = array();
83
84 if ($a_childs == null) {
85 $a_childs = [];
86 }
87
88 if (!$a_first_child) { // drop area of node
89 if ($a_node["type"] == "pg" || ($a_node["type"] == "st" && count($a_childs) == 0 && $this->getMaxDepth() != 0)) {
90 if ($a_node["type"] == "st") {
91 $cmds[] = array("text" => $lng->txt("cont_insert_page"), "cmd" => "insertPage", "multi" => 10,
92 "as_subitem" => true);
93 if (count($this->page_layouts) > 0) {
94 $cmds[] = array("text" => $lng->txt("cont_insert_pagelayout"), "cmd" => "insertTemplate", "multi" => 10,
95 "as_subitem" => true);
96 }
97 if ($ilUser->clipboardHasObjectsOfType("pg")) {
98 $cmds[] = array("text" => $lng->txt("cont_insert_page_from_clip"), "multi" => 0,
99 "cmd" => "insertPageClip", "as_subitem" => true);
100 }
101 } else {
102 $cmds[] = array("text" => $lng->txt("cont_insert_page"), "cmd" => "insertPage", "multi" => 10);
103 if (count($this->page_layouts) > 0) {
104 $cmds[] = array("text" => $lng->txt("cont_insert_pagelayout"), "cmd" => "insertTemplate", "multi" => 10);
105 }
106 if ($ilUser->clipboardHasObjectsOfType("pg")) {
107 $cmds[] = array("text" => $lng->txt("cont_insert_page_from_clip"), "multi" => 0,
108 "cmd" => "insertPageClip");
109 }
110 }
111 }
112 if ($a_node["type"] != "pg" && $this->getMaxDepth() != 0) {
113 $cmds[] = array("text" => $lng->txt("cont_insert_subchapter"),
114 "cmd" => "insertSubchapter", "multi" => 10);
115 if ($ilUser->clipboardHasObjectsOfType("st")) {
116 $cmds[] = array("text" => $lng->txt("cont_insert_subchapter_from_clip"), "multi" => 0,
117 "cmd" => "insertSubchapterClip");
118 }
119 }
120
121 if ((($a_next_sibling["type"] ?? "") != "pg" && ($a_depth == 0 || ($a_next_sibling["type"] ?? "") == "st"))
122 || $a_node["type"] == "st") {
123 $cmds[] = array("text" => $lng->txt("cont_insert_chapter"),
124 "cmd" => "insertChapter",
125 "multi" => 10
126 );
127 if ($ilUser->clipboardHasObjectsOfType("st")) {
128 $cmds[] = array("text" => $lng->txt("cont_insert_chapter_from_clip"),
129 "cmd" => "insertChapterClip", "multi" => 0
130 );
131 }
132 }
133 } else { // drop area before first child of node
134 if ($a_node["type"] == "st" && $this->getMaxDepth() != 0) {
135 $cmds[] = array("text" => $lng->txt("cont_insert_page"),
136 "cmd" => "insertPage", "multi" => 10);
137 if (count($this->page_layouts) > 0) {
138 $cmds[] = array("text" => $lng->txt("cont_insert_pagelayout"), "cmd" => "insertTemplate", "multi" => 10);
139 }
140 if ($ilUser->clipboardHasObjectsOfType("pg")) {
141 $cmds[] = array("text" => $lng->txt("cont_insert_page_from_clip"),"multi" => 0,
142 "cmd" => "insertPageClip");
143 }
144 }
145 if (($a_childs[0]["type"] ?? "") != "pg") {
146 $cmds[] = array("text" => $lng->txt("cont_insert_chapter"),
147 "cmd" => "insertChapter", "multi" => 10);
148 if ($ilUser->clipboardHasObjectsOfType("st")) {
149 $cmds[] = array("text" => $lng->txt("cont_insert_chapter_from_clip"),"multi" => 0,
150 "cmd" => "insertChapterClip");
151 }
152 }
153 }
154
155 return $cmds;
156 }
157
161 public function nodeAllowsChilds(array $a_node): bool
162 {
163 if ($a_node["type"] == "pg") {
164 return false;
165 }
166 return true;
167 }
168
173 public function manageDragAndDrop(array $a_node, int $a_depth, bool $a_first_child = false, ?array $a_next_sibling = null, ?array $a_childs = null): void
174 {
176
177 $this->makeDragContent($a_node["node_id"], "grp_" . $a_node["type"]);
178
179 if ($a_childs == null) {
180 $a_childs = [];
181 }
182
183 if (!$a_first_child) {
184 if ($a_node["type"] == "pg" || ($a_node["type"] == "st" && count($a_childs) == 0 && $this->getMaxDepth() != 0)) {
185 if ($a_node["type"] == "st") {
186 $this->makeDragTarget(
187 $a_node["node_id"],
188 "grp_pg",
189 $a_first_child,
190 true,
191 ""
192 );
193 } else {
194 $this->makeDragTarget(
195 $a_node["node_id"],
196 "grp_pg",
197 $a_first_child,
198 false,
199 ""
200 );
201 }
202 }
203
204 if ($a_node["type"] != "pg" && $this->getMaxDepth() != 0) {
205 $this->makeDragTarget(
206 $a_node["node_id"],
207 "grp_st",
208 $a_first_child,
209 true,
210 $lng->txt("cont_insert_as_subchapter")
211 );
212 }
213
214 if ($a_next_sibling) {
215 if (($a_next_sibling["type"] != "pg" && ($a_depth == 0 || $a_next_sibling["type"] == "st"))
216 || $a_node["type"] == "st") {
217 $this->makeDragTarget(
218 $a_node["node_id"],
219 "grp_st",
220 $a_first_child,
221 false,
222 $lng->txt("cont_insert_as_chapter")
223 );
224 }
225 }
226 } else {
227 if ($a_node["type"] == "st" && $this->getMaxDepth() != 0) {
228 $this->makeDragTarget(
229 $a_node["node_id"],
230 "grp_pg",
231 $a_first_child,
232 true
233 );
234 }
235 if (($a_childs[0]["type"] ?? "") != "pg") {
236 $this->makeDragTarget(
237 $a_node["node_id"],
238 "grp_st",
239 $a_first_child,
240 true
241 );
242 }
243 }
244 }
245
252 public function getChildIcon(array $a_item): string
253 {
254 $img = "icon_" . $a_item["type"] . ".svg";
255
256 if ($a_item["type"] == "pg") {
257 $lm_set = new ilSetting("lm");
258 $active = ilLMPage::_lookupActive(
259 $a_item["node_id"],
260 $this->lm_type,
261 (bool) $lm_set->get("time_scheduled_page_activation")
262 );
263
264 // is page scheduled?
265 $img_sc = ($lm_set->get("time_scheduled_page_activation") &&
266 ilLMPage::_isScheduledActivation($a_item["node_id"], $this->lm_type))
267 ? "_sc"
268 : "";
269
270 $img = "icon_pg" . $img_sc . ".svg";
271
272 if (!$active) {
273 $img = "icon_pg_d" . $img_sc . ".svg";
274 } else {
276 $a_item["node_id"],
277 $this->lm_type
278 );
279 if ($contains_dis) {
280 $img = "icon_pg_del" . $img_sc . ".svg";
281 }
282 }
283 }
285 }
286
293 public function getChildIconAlt(array $a_item): string
294 {
296
297
298 if ($a_item["type"] == "pg") {
299 $active = ilLMPage::_lookupActive($a_item["node_id"], $this->lm_type);
300
301 if (!$active) {
302 return $lng->txt("cont_page_deactivated");
303 } else {
305 $a_item["node_id"],
306 $this->lm_type
307 );
308 if ($contains_dis) {
309 return $lng->txt("cont_page_deactivated_elements");
310 }
311 }
312 return $lng->txt("pg");
313 }
314 return $lng->txt("st");
315 ;
316 }
317
323 public function getChildCommands(array $a_item): array
324 {
326 $ilCtrl = $this->ctrl;
327
328 $lm_class = "ilobjlearningmodulegui";
329
330 $commands = array();
331 switch ($a_item["type"]) {
332 case "pg":
333 $ilCtrl->setParameterByClass(
334 "illmpageobjectgui",
335 "obj_id",
336 $a_item["node_id"]
337 );
338 $commands[] = array("text" => $lng->txt("edit"),
339 "link" => $ilCtrl->getLinkTargetByClass(array($lm_class, "illmpageobjectgui"), "edit"));
340 break;
341
342 case "st":
343 $ilCtrl->setParameterByClass(
344 "ilstructureobjectgui",
345 "obj_id",
346 $a_item["node_id"]
347 );
348 $commands[] = array("text" => $lng->txt("edit"),
349 "link" => $ilCtrl->getLinkTargetByClass(array($lm_class, "ilstructureobjectgui"), "view"));
350 break;
351 }
352
353 return $commands;
354 }
355}
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
nodeAllowsChilds(array $a_node)
Which nodes allow child nodes?
getChildIcon(array $a_item)
Get icon path for an item.
__construct(string $a_lm_type, string $a_lang="-")
getChildIconAlt(array $a_item)
Get icon alt text.
manageDragAndDrop(array $a_node, int $a_depth, bool $a_first_child=false, ?array $a_next_sibling=null, ?array $a_childs=null)
Makes nodes drag and drop content and targets.
getMenuItems(array $a_node, int $a_depth, bool $a_first_child=false, ?array $a_next_sibling=null, ?array $a_childs=null)
Get menu items.
getChildCommands(array $a_item)
Get item commands.
getChildInfo(array $a_child)
Get child info.
This class represents a hierarchical form.
setCheckboxName(string $a_checkboxname)
makeDragTarget(string $a_id, string $a_group, bool $a_first_child_drop_area=false, bool $a_as_subitem=false, string $a_diss_text="")
makeDragContent(string $a_id, string $a_group)
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
txt(string $a_topic, string $a_default_lang_fallback_mod="")
gets the text for a given topic if the topic is not in the list, the topic itself with "-" will be re...
User class.
static activeLayouts(int $a_module=0)
Get active layouts.
static _isScheduledActivation(int $a_id, string $a_parent_type, string $a_lang="-")
Check whether page is activated by time schedule.
static _lookupActive(int $a_id, string $a_parent_type, bool $a_check_scheduled_activation=false, string $a_lang="-")
lookup activation status
static _lookupContainsDeactivatedElements(int $a_id, string $a_parent_type, string $a_lang="-")
lookup whether page contains deactivated elements
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
static getImagePath(string $img, string $module_path="", string $mode="output", bool $offline=false)
get image path (for images located in a template directory)
global $DIC
Definition: feed.php:28
$img
Definition: imgupload.php:83
$ilUser
Definition: imgupload.php:34
__construct(Container $dic, ilPlugin $plugin)
@inheritDoc
$lm_set