ILIAS  trunk Revision v11.0_alpha-3011-gc6b235a2e85
class.ilExplorer.php
Go to the documentation of this file.
1<?php
2
21
30{
35 protected ilLanguage $lng;
36 public string $id = "";
37 public string $output = "";
38 public array $format_options = [];
39 public ilTree $tree;
40 public string $target = "";
41 public string $target_get = "";
42 public string $params_get = "";
43 public array $expanded = [];
44 public string $order_column = "";
45 public string $order_direction = "asc";
46 public ?string $expand_target = null;
47 public bool $rbac_check = false;
48 public bool $output_icons = false;
49 public string $expand_variable = "";
50 // array ($type => clickable (empty means true, "n" means false)
51 public array $is_clickable = [];
52 public bool $post_sort = false;
53 public bool $filtered = false;
54 protected $filter = [];
55 public bool $filter_mode;
56 // expand entire tree regardless of values in $expanded
57 public bool $expand_all = false;
58 public $root_id = null;
59 public bool $use_standard_frame = false;
60 protected string $highlighted = "";
61 protected bool $show_minus = true;
62 protected int $counter = 0;
63 protected bool $asnch_expanding = false;
64 protected int $textwidth = 0;
65 protected string $title = "";
66 protected string $up_frame = "";
67 protected string $a_up_script = "";
68 protected string $up_params = "";
69 protected string $frame_target = "";
70 protected string $up_script = "";
71 protected string $tree_lead = "";
72 protected array $iconList = [];
73
74 protected \ILIAS\Refinery\Factory $refinery;
75 protected \ILIAS\HTTP\Wrapper\WrapperFactory $wrapper;
76
77 public function __construct(string $a_target)
78 {
80 global $DIC;
81
82 $this->obj_definition = $DIC["objDefinition"];
83 $this->error = $DIC["ilErr"];
84 $this->rbacsystem = $DIC->rbac()->system();
85 $this->tpl = $DIC["tpl"];
86 $this->lng = $DIC->language();
87 $objDefinition = $DIC["objDefinition"];
88 $ilErr = $DIC["ilErr"];
89
90 if (!isset($a_target) or !is_string($a_target)) {
91 $ilErr->raiseError(get_class($this) . "::Constructor(): No target given!", $ilErr->WARNING);
92 }
93
94 // autofilter object types in devmode
95 $devtypes = $objDefinition->getDevModeAll();
96
97 if (count($devtypes) > 0) {
98 // activate filter if objects found in devmode
99 $this->setFiltered(true);
100
101 foreach ($devtypes as $type) {
102 $this->addFilter($type);
103 }
104 }
105
106 $this->expanded = array();
107 $this->target = $a_target;
108 $this->target_get = 'ref_id';
109 $this->frame_target = "content";
110 $this->order_column = "title";
111 $this->tree = new ilTree(ROOT_FOLDER_ID);
112 $this->tree->initLangCode();
113 $this->expand_target = $_SERVER["PATH_INFO"] ?? "";
114 $this->rbac_check = true;
115 $this->output_icons = true;
116 $this->expand_variable = "expand";
117 $this->setTitleLength(50);
118 $this->post_sort = true;
120 $this->highlighted = "";
121 $this->show_minus = true;
122 $this->counter = 0;
123 $this->asnch_expanding = false;
124 $this->refinery = $DIC->refinery();
125 $this->wrapper = $DIC->http()->wrapper();
126 }
127
128 protected function requestStr(string $key): string
129 {
130 $str = $this->refinery->kindlyTo()->string();
131 if ($this->wrapper->post()->has($key)) {
132 return $this->wrapper->post()->retrieve($key, $str);
133 }
134 if ($this->wrapper->query()->has($key)) {
135 return $this->wrapper->query()->retrieve($key, $str);
136 }
137 return "";
138 }
139
140 public function setId(string $a_val): void
141 {
142 $this->id = $a_val;
143 }
144
145 public function getId(): string
146 {
147 return $this->id;
148 }
149
150 public function setAsynchExpanding(bool $a_val): void
151 {
152 $this->asnch_expanding = $a_val;
153 }
154
155 public function getAsynchExpanding(): bool
156 {
158 }
159
160 public function initItemCounter(int $a_number): void
161 {
162 $this->counter = $a_number;
163 }
164
165 public function setTitle(string $a_val): void
166 {
167 $this->title = $a_val;
168 }
169
170 public function setTitleLength(int $a_length): void
171 {
172 $this->textwidth = $a_length;
173 }
174
175 public function getTitleLength(): int
176 {
177 return $this->textwidth;
178 }
179
180 public function getTitle(): string
181 {
182 return $this->title;
183 }
184
185 public function setRoot($a_root_id): void
186 {
187 #$this->tree = new ilTree(ROOT_FOLDER_ID,$a_root_id);
188 $this->root_id = $a_root_id;
189 }
190
191 public function getRoot(): ?int
192 {
193 return $this->root_id ?? $this->tree->getRootId();
194 }
195
196 public function setOrderColumn(string $a_column): void
197 {
198 $this->order_column = $a_column;
199 }
200
201 public function setOrderDirection(string $a_direction): void
202 {
203 if ($a_direction === "desc") {
204 $this->order_direction = $a_direction;
205 } else {
206 $this->order_direction = "asc";
207 }
208 }
209
213 public function setTargetGet(string $a_target_get): void
214 {
216
217 if (!isset($a_target_get) or !is_string($a_target_get)) {
218 $ilErr->raiseError(get_class($this) . "::setTargetGet(): No target given!", $ilErr->WARNING);
219 }
220
221 $this->target_get = $a_target_get;
222 }
223
224 public function setParamsGet(array $a_params_get): void
225 {
227
228 if (!isset($a_params_get) or !is_array($a_params_get)) {
229 $ilErr->raiseError(get_class($this) . "::setTargetGet(): No target given!", $ilErr->WARNING);
230 }
231 $str = "";
232 foreach ($a_params_get as $key => $val) {
233 $str .= "&" . $key . "=" . $val;
234 }
235
236 $this->params_get = $str;
237 }
238
239
245 public function setExpandTarget(string $a_exp_target): void
246 {
247 $this->expand_target = $a_exp_target;
248 }
249
250 public function setFrameUpdater(
251 string $a_up_frame,
252 string $a_up_script,
253 string $a_params = ""
254 ): void {
255 $this->up_frame = $a_up_frame;
256 $this->up_script = $a_up_script;
257 $this->up_params = $a_params;
258 }
259
260
261 public function highlightNode(string $a_id): void
262 {
263 $this->highlighted = $a_id;
264 }
265
266 public function checkPermissions(bool $a_check): void
267 {
268 $this->rbac_check = $a_check;
269 }
270
271 public function setSessionExpandVariable(string $a_var_name = "expand"): void
272 {
273 $this->expand_variable = $a_var_name;
274 }
275
276 public function outputIcons(bool $a_icons): void
277 {
278 $this->output_icons = $a_icons;
279 }
280
281 public function setClickable(string $a_type, bool $a_clickable): void
282 {
283 if ($a_clickable) {
284 $this->is_clickable[$a_type] = "";
285 } else {
286 $this->is_clickable[$a_type] = "n";
287 }
288 }
289
290 public function isVisible(
291 $a_ref_id,
292 string $a_type
293 ): bool {
294 $rbacsystem = $this->rbacsystem;
295
296 if (!$this->rbac_check) {
297 return true;
298 }
299
300 $visible = $rbacsystem->checkAccess('visible', $a_ref_id);
301
302 return $visible;
303 }
304
305 // Set tree leading content
306 public function setTreeLead(string $a_val): void
307 {
308 $this->tree_lead = $a_val;
309 }
310
311 public function getTreeLead(): string
312 {
313 return $this->tree_lead;
314 }
315
316 // check if links for certain object type are activated
317 public function isClickable(
318 string $type,
319 int $ref_id = 0
320 ): bool {
321 // in this standard implementation
322 // only the type determines, wether an object should be clickable or not
323 // but this method can be overwritten and make $exp->setFilterMode(IL_FM_NEGATIVE);use of the ref id
324 // (this happens e.g. in class ilRepositoryExplorerGUI)
325 return $this->is_clickable[$type] !== "n";
326 }
327
328 public function setPostSort(bool $a_sort): void
329 {
330 $this->post_sort = $a_sort;
331 }
332
333 public function setFilterMode(int $a_mode = IL_FM_NEGATIVE): void
334 {
335 $this->filter_mode = $a_mode;
336 }
337
341 public function getFilterMode(): int
342 {
343 return $this->filter_mode;
344 }
345
350 public function setUseStandardFrame(bool $a_val): void
351 {
352 $this->use_standard_frame = $a_val;
353 }
354
355 public function getUseStandardFrame(): bool
356 {
357 return $this->use_standard_frame;
358 }
359
360 public function getChildsOfNode($a_parent_id): array
361 {
362 return $this->tree->getChilds($a_parent_id, $this->order_column);
363 }
364
365
370 public function setOutput(
371 $a_parent_id,
372 int $a_depth = 1,
373 int $a_obj_id = 0,
374 bool $a_highlighted_subtree = false
375 ): void {
376 $ilErr = $this->error;
377
378 $parent_index = 0;
379
380 if (!isset($a_parent_id)) {
381 $ilErr->raiseError(get_class($this) . "::setOutput(): No node_id given!", $ilErr->WARNING);
382 }
383
384 if ($this->showChilds($a_parent_id)) {
385 $objects = $this->getChildsOfNode($a_parent_id);
386 } else {
387 $objects = array();
388 }
389
390 $objects = $this->modifyChilds($a_parent_id, $objects);
391
392 // force expansion (of single nodes)
393 if ($this->forceExpanded($a_parent_id) && !in_array($a_parent_id, $this->expanded)) {
394 $this->expanded[] = $a_parent_id;
395 }
396
397 if (count($objects) > 0) {
398 // Maybe call a lexical sort function for the child objects
399 $tab = ++$a_depth - 2;
400 if ($this->post_sort) {
401 $objects = $this->sortNodes($objects, $a_obj_id);
402 }
403 $skip_rest = false;
404 foreach ($objects as $key => $object) {
405 // skip childs, if parent is not expanded
406 if (!$this->forceExpanded($object["child"]) && $skip_rest) {
407 continue;
408 }
409 //echo "<br>-".$object["child"]."-".$this->forceExpanded($object["child"])."-";
410 //ask for FILTER
411 if ($this->filtered === false || $this->checkFilter($object["type"]) === false) {
412 if ($this->isVisible($object['child'], $object['type'])) {
413 #echo 'CHILD getIndex() '.$object['child'].' parent: '.$this->getRoot();
414 if ($object["child"] != $this->getRoot()) {
415 $parent_index = $this->getIndex($object);
416 }
417 $this->format_options[(string) $this->counter]["parent"] = $object["parent"];
418 $this->format_options[(string) $this->counter]["child"] = $object["child"];
419 $this->format_options[(string) $this->counter]["title"] = $object["title"];
420 $this->format_options[(string) $this->counter]["type"] = $object["type"];
421 $this->format_options[(string) $this->counter]["obj_id"] = $object["obj_id"];
422 $this->format_options[(string) $this->counter]["desc"] = "obj_" . $object["type"];
423 $this->format_options[(string) $this->counter]["depth"] = $tab;
424 $this->format_options[(string) $this->counter]["container"] = false;
425 $this->format_options[(string) $this->counter]["visible"] = true;
426 $this->format_options[(string) $this->counter]["highlighted_subtree"] = $a_highlighted_subtree;
427
428 // Create prefix array
429 for ($i = 0; $i < $tab; ++$i) {
430 $this->format_options[(string) $this->counter]["tab"][] = 'blank';
431 }
432
433 // fix explorer (sometimes explorer disappears)
434 if ($parent_index === 0) {
435 if (!$this->expand_all && !in_array($object["parent"], $this->expanded)) {
436 $this->expanded[] = $object["parent"];
437 }
438 }
439
440 // only if parent is expanded and visible, object is visible
441 if ($object["child"] != $this->getRoot() && ((!$this->expand_all && !in_array($object["parent"], $this->expanded))
442 or !$this->format_options[(string) $parent_index]["visible"])) {
443 if (!$this->forceExpanded($object["child"])) {
444 // if parent is not expanded, and one child is
445 // visible we don't need more information and
446 // can skip the rest of the childs
447 if ($this->format_options[(string) $this->counter]["visible"]) {
448 //echo "-setSkipping";
449 $skip_rest = true;
450 }
451 $this->format_options[(string) $this->counter]["visible"] = false;
452 }
453 }
454
455 // if object exists parent is container
456 if ($object["child"] != $this->getRoot()) {
457 $this->format_options[(string) $parent_index]["container"] = true;
458
459 if ($this->expand_all || in_array($object["parent"], $this->expanded)) {
460 //echo "<br>-".$object["child"]."-".$this->forceExpanded($object["child"])."-";
461 if ($this->forceExpanded($object["parent"])) {
462 $this->format_options[(string) $parent_index]["tab"][($tab - 2)] = 'forceexp';
463 } else {
464 $this->format_options[(string) $parent_index]["tab"][($tab - 2)] = 'minus';
465 }
466 } else {
467 $this->format_options[(string) $parent_index]["tab"][($tab - 2)] = 'plus';
468 }
469 }
470 //echo "-"."$parent_index"."-";
471 //var_dump($this->format_options["$parent_index"]);
473
474 // stop recursion if 2. level beyond expanded nodes is reached
475 if ($this->expand_all || in_array($object["parent"], $this->expanded) or ($object["parent"] == 0)
476 or $this->forceExpanded($object["child"])) {
477 $highlighted_subtree = $a_highlighted_subtree ||
478 ($object["child"] == $this->highlighted);
479
480 // recursive
481 $this->setOutput($object["child"], $a_depth, $object['obj_id'], $highlighted_subtree);
482 }
483 } //if
484 } //if FILTER
485 } //foreach
486 } //if
487 } //function
488
489 public function modifyChilds(
490 $a_parent_id,
491 array $a_objects
492 ): array {
493 return $a_objects;
494 }
495
501 public function showChilds($a_parent_id): bool
502 {
503 return true;
504 }
505
509 public function forceExpanded($a_obj_id): bool
510 {
511 return false;
512 }
513
514 public function getMaximumTreeDepth(): int
515 {
516 $this->tree->getMaximumDepth();
517 return 0; // seems to not return the value...
518 }
519
520
521 public function getOutput(): string
522 {
523 $tpl = $this->tpl;
525
526 $this->format_options[0]["tab"] = array();
527
528 $depth = $this->getMaximumTreeDepth();
529
530 for ($i = 0;$i < $depth;++$i) {
531 $this->createLines($i);
532 }
533
535 $tpl->addJavaScript("assets/js/ilExplorer.js");
536
537 //echo "hh";
538 // set global body class
539 // $tpl->setBodyClass("il_Explorer");
540
541 $tpl_tree = new ilTemplate("tpl.tree.html", true, true, "components/ILIAS/UIComponent/Explorer");
542
543 // updater
544 if (($this->requestStr("ict") !== "" ||
545 $this->requestStr("collapseAll") !== "" ||
546 $this->requestStr("expandAll") !== "") && $this->up_frame !== "") {
547 $tpl_tree->setCurrentBlock("updater");
548 $tpl_tree->setVariable("UPDATE_FRAME", $this->up_frame);
549 $tpl_tree->setVariable("UPDATE_SCRIPT", $this->up_script);
550 if (is_array($this->up_params)) {
551 $up_str = $lim = "";
552 foreach ($this->up_params as $p) {
553 $up_str .= $lim . "'" . $p . "'";
554 $lim = ",";
555 }
556 $tpl_tree->setVariable("UPDATE_PARAMS", $up_str);
557 }
558 $tpl_tree->parseCurrentBlock();
559 }
560 $cur_depth = -1;
561 foreach ($this->format_options as $key => $options) {
562 //echo "-".$options["depth"]."-";
563 if (!($options["visible"] ?? false)) {
564 continue;
565 }
566
567 // end tags
568 $this->handleListEndTags($tpl_tree, $cur_depth, $options["depth"]);
569
570 // start tags
571 $this->handleListStartTags($tpl_tree, $cur_depth, $options["depth"]);
572
573 $cur_depth = $options["depth"];
574
575 if ($options["visible"] and $key != 0) {
576 $this->formatObject($tpl_tree, $options["child"], $options, $options['obj_id']);
577 }
578 if ($key == 0) {
579 $this->formatHeader($tpl_tree, $options["child"], $options);
580 }
581 }
582
583 $this->handleListEndTags($tpl_tree, $cur_depth, -1);
584
585 $tpl_tree->setVariable("TREE_LEAD", "");
586 if ($this->tree_lead !== "") {
587 $tpl_tree->setCurrentBlock("tree_lead");
588 $tpl_tree->setVariable("TREE_LEAD", $this->tree_lead);
589 $tpl_tree->parseCurrentBlock();
590 }
591 if ($this->getId() !== "") {
592 $tpl_tree->setVariable("TREE_ID", 'id="' . $this->getId() . '_tree"');
593 }
594
595 $html = $tpl_tree->get();
596
597 if ($this->getUseStandardFrame()) {
598 $mtpl = new ilGlobalTemplate("tpl.main.html", true, true);
599 $mtpl->setVariable("LOCATION_STYLESHEET", ilUtil::getStyleSheetLocation());
600 $mtpl->setVariable("BODY_CLASS", "il_Explorer");
601 $mtpl->addBlockFile("CONTENT", "content", "tpl.explorer.html");
602 if ($this->getTitle() !== "") {
603 $mtpl->setVariable("TXT_EXPLORER_HEADER", $this->getTitle());
604 }
605 if ($this->getId() !== "") {
606 $mtpl->setVariable("ID", 'id="' . $this->getId() . '"');
607 }
608 $mtpl->setVariable("IMG_SPACE", ilUtil::getImagePath("media/spacer.png", false));
609 $mtpl->setCurrentBlock("content");
610 $mtpl->setVariable("EXPLORER", $html);
611 $mtpl->setVariable("EXP_REFRESH", $lng->txt("refresh"));
612 $mtpl->parseCurrentBlock();
613 $html = $mtpl->get();
614 }
615
616 return $html;
617 }
618
619
620
624 public function handleListEndTags(
625 ilTemplate $a_tpl_tree,
626 int $a_cur_depth,
627 int $a_item_depth
628 ): void {
629 if ($a_item_depth < $a_cur_depth) {
630 // </li></ul> for ending lists
631 for ($i = 0; $i < ($a_cur_depth - $a_item_depth); $i++) {
632 $a_tpl_tree->touchBlock("end_list_item");
633 $a_tpl_tree->touchBlock("element");
634
635 $a_tpl_tree->touchBlock("end_list");
636 $a_tpl_tree->touchBlock("element");
637 }
638 } elseif ($a_item_depth == $a_cur_depth) {
639 // </li> for ending list items
640 $a_tpl_tree->touchBlock("end_list_item");
641 $a_tpl_tree->touchBlock("element");
642 }
643 }
644
648 public function handleListStartTags(
649 ilTemplate $a_tpl_tree,
650 int $a_cur_depth,
651 int $a_item_depth
652 ): void {
653 // start tags
654 if ($a_item_depth > $a_cur_depth) {
655 // <ul><li> for new lists
656 if ($a_item_depth > 1) {
657 $a_tpl_tree->touchBlock("start_list");
658 } else {
659 $a_tpl_tree->touchBlock("start_list_no_indent");
660 }
661 $a_tpl_tree->touchBlock("element");
662 }
663 $a_tpl_tree->touchBlock("start_list_item");
664 $a_tpl_tree->touchBlock("element");
665 }
666
667 public function formatHeader(
668 ilTemplate $tpl,
669 $a_obj_id,
670 array $a_option
671 ): void {
672 }
673
674 public function formatObject(
675 ilTemplate $tpl,
676 $a_node_id,
677 array $a_option,
678 $a_obj_id = 0
679 ): void {
680 $lng = $this->lng;
681 $ilErr = $this->error;
682
683 if (!isset($a_node_id) or !is_array($a_option)) {
684 $ilErr->raiseError(get_class($this) . "::formatObject(): Missing parameter or wrong datatype! " .
685 "node_id: " . $a_node_id . " options:" . var_export($a_option, true), $ilErr->WARNING);
686 }
687
688 $pic = false;
689 foreach ((array) $a_option["tab"] as $picture) {
690 if ($picture === 'plus') {
691 $tpl->setCurrentBlock("expander");
692 $tpl->setVariable("EXP_DESC", $lng->txt("collapsed"));
693 $tpl->setVariable("LINK_NAME", $a_node_id);
694 if (!$this->getAsynchExpanding()) {
695 $target = $this->createTarget('+', $a_node_id, $a_option["highlighted_subtree"]);
696 $tpl->setVariable("LINK_TARGET_EXPANDER", $target);
697 } else {
698 $target = $this->createTarget('+', $a_node_id, $a_option["highlighted_subtree"], false);
699 $tpl->setVariable("ONCLICK_TARGET_EXPANDER", " onclick=\"return il.Explorer.refresh('tree_div', '" . $target . "');\"");
700 $tpl->setVariable("LINK_TARGET_EXPANDER", "#");
701 }
702 $tpl->setVariable("IMGPATH", $this->getImage("browser/plus.png"));
703 $tpl->parseCurrentBlock();
704 $pic = true;
705 }
706
707 if ($picture === 'forceexp') {
708 $tpl->setCurrentBlock("expander");
709 $tpl->setVariable("EXP_DESC", $lng->txt("expanded"));
710 $target = $this->createTarget('+', $a_node_id);
711 $tpl->setVariable("LINK_NAME", $a_node_id);
712 $tpl->setVariable("LINK_TARGET_EXPANDER", $target);
713 $tpl->setVariable("IMGPATH", $this->getImage("browser/forceexp.png"));
714 $tpl->parseCurrentBlock();
715 $pic = true;
716 }
717
718 if ($picture === 'minus' && $this->show_minus) {
719 $tpl->setCurrentBlock("expander");
720 $tpl->setVariable("EXP_DESC", $lng->txt("expanded"));
721 $tpl->setVariable("LINK_NAME", $a_node_id);
722 if (!$this->getAsynchExpanding()) {
723 $target = $this->createTarget('-', $a_node_id, $a_option["highlighted_subtree"]);
724 $tpl->setVariable("LINK_TARGET_EXPANDER", $target);
725 } else {
726 $target = $this->createTarget('-', $a_node_id, $a_option["highlighted_subtree"], false);
727 $tpl->setVariable("ONCLICK_TARGET_EXPANDER", " onclick=\"return il.Explorer.refresh('tree_div', '" . $target . "');\"");
728 $tpl->setVariable("LINK_TARGET_EXPANDER", "#");
729 }
730 $tpl->setVariable("IMGPATH", $this->getImage("browser/minus.png"));
731 $tpl->parseCurrentBlock();
732 $pic = true;
733 }
734 }
735
736 if (!$pic) {
737 $tpl->setCurrentBlock("blank");
738 $tpl->setVariable("BLANK_PATH", $this->getImage("browser/blank.png"));
739 $tpl->parseCurrentBlock();
740 }
741
742 if ($this->output_icons) {
743 $tpl->setCurrentBlock("icon");
744 $tpl->setVariable("ICON_IMAGE", $this->getImage("standard/icon_" . $a_option["type"] . ".svg", $a_option["type"], $a_obj_id));
745
746 $tpl->setVariable("TARGET_ID", "iconid_" . $a_node_id);
747 $this->iconList[] = "iconid_" . $a_node_id;
748 $tpl->setVariable(
749 "TXT_ALT_IMG",
750 $this->getImageAlt($lng->txt("icon") . " " . $lng->txt($a_option["desc"]), $a_option["type"], $a_obj_id)
751 );
752 $tpl->parseCurrentBlock();
753 }
754
755 if (($sel = $this->buildSelect($a_node_id, $a_option['type'])) !== '') {
756 $tpl->setCurrentBlock('select');
757 $tpl->setVariable('OBJ_SEL', $sel);
758 $tpl->parseCurrentBlock();
759 }
760
761 if ($this->isClickable($a_option["type"], $a_node_id)) { // output link
762 $tpl->setCurrentBlock("link");
763 //$target = (strpos($this->target, "?") === false) ?
764 // $this->target."?" : $this->target."&";
765 //$tpl->setVariable("LINK_TARGET", $target.$this->target_get."=".$a_node_id.$this->params_get);
766 $tpl->setVariable("LINK_TARGET", $this->buildLinkTarget($a_node_id, $a_option["type"]));
767
768 $style_class = $this->getNodeStyleClass($a_node_id, $a_option["type"]);
769
770 if ($style_class !== "") {
771 $tpl->setVariable("A_CLASS", ' class="' . $style_class . '" ');
772 }
773
774 if (($onclick = $this->buildOnClick($a_node_id, $a_option["type"], $a_option["title"])) != "") {
775 $tpl->setVariable("ONCLICK", "onClick=\"$onclick\"");
776 }
777
778 //$tpl->setVariable("LINK_NAME", $a_node_id);
779 $tpl->setVariable(
780 "TITLE",
782 $this->buildTitle($a_option["title"], $a_node_id, $a_option["type"]),
783 $this->textwidth,
784 true
785 )
786 );
787 $tpl->setVariable(
788 "DESC",
790 $this->buildDescription($a_option["description"] ?? "", $a_node_id, $a_option["type"]),
791 $this->textwidth,
792 true
793 )
794 );
795 $frame_target = $this->buildFrameTarget($a_option["type"], $a_node_id, $a_option["obj_id"]);
796 if ($frame_target !== "") {
797 $tpl->setVariable("TARGET", " target=\"" . $frame_target . "\"");
798 }
799 } else { // output text only
800 $tpl->setCurrentBlock("text");
801 $tpl->setVariable(
802 "OBJ_TITLE",
804 $this->buildTitle($a_option["title"], $a_node_id, $a_option["type"]),
805 $this->textwidth,
806 true
807 )
808 );
809 $tpl->setVariable(
810 "OBJ_DESC",
812 $this->buildDescription($a_option["desc"], $a_node_id, $a_option["type"]),
813 $this->textwidth,
814 true
815 )
816 );
817 }
818 $tpl->parseCurrentBlock();
819
820 $tpl->setCurrentBlock("list_item");
821 $tpl->parseCurrentBlock();
822 $tpl->touchBlock("element");
823 }
824
825 public function getImage(
826 string $a_name,
827 string $a_type = "",
828 $a_obj_id = ""
829 ): string {
830 return ilUtil::getImagePath($a_name);
831 }
832
833 public function getImageAlt(
834 string $a_default_text,
835 string $a_type = "",
836 $a_obj_id = ""
837 ): string {
838 return $a_default_text;
839 }
840
841 public function getNodeStyleClass(
842 $a_id,
843 string $a_type
844 ): string {
845 if ($a_id == $this->highlighted) {
846 return "il_HighlightedNode";
847 }
848 return "";
849 }
850
851 public function buildLinkTarget(
852 $a_node_id,
853 string $a_type
854 ): string {
855 $target = (strpos($this->target, "?") === false)
856 ? $this->target . "?"
857 : $this->target . "&";
858 return $target . $this->target_get . "=" . $a_node_id . $this->params_get;
859 }
860
861 public function buildOnClick(
862 $a_node_id,
863 string $a_type,
864 string $a_title
865 ): string {
866 return "";
867 }
868
869 public function buildTitle(
870 string $a_title,
871 $a_id,
872 string $a_type
873 ): string {
874 return $a_title;
875 }
876
877 public function buildDescription(
878 string $a_desc,
879 $a_id,
880 string $a_type
881 ): string {
882 return "";
883 }
884
888 public function buildSelect($a_node_id, string $a_type): string
889 {
890 return "";
891 }
892
893 public function buildFrameTarget(
894 string $a_type,
895 $a_child = 0,
896 $a_obj_id = 0
897 ): string {
898 return $this->frame_target;
899 }
900
901
902 public function createTarget(
903 string $a_type,
904 $a_node_id,
905 bool $a_highlighted_subtree = false,
906 bool $a_append_anch = true
907 ): string {
908 $ilErr = $this->error;
909
910 if (!isset($a_type) or !is_string($a_type) or !isset($a_node_id)) {
911 $ilErr->raiseError(get_class($this) . "::createTarget(): Missing parameter or wrong datatype! " .
912 "type: " . $a_type . " node_id:" . $a_node_id, $ilErr->WARNING);
913 }
914
915 // SET expand parameter:
916 // positive if object is expanded
917 // negative if object is compressed
918 $a_node_id = $a_type === '+' ? $a_node_id : -(int) $a_node_id;
919
920 $sep = (is_int(strpos($this->expand_target, "?")))
921 ? "&"
922 : "?";
923
924 // in current tree flag
925 $ict_str = ($a_highlighted_subtree || $this->highlighted === "")
926 ? "&ict=1"
927 : "";
928 if ($this->getAsynchExpanding()) {
929 $ict_str .= "&cmdMode=asynch";
930 }
931 if ($a_append_anch) {
932 return $this->expand_target . $sep . $this->expand_variable . "=" . $a_node_id . $this->params_get . $ict_str . "#" . abs($a_node_id);
933 } else {
934 return $this->expand_target . $sep . $this->expand_variable . "=" . $a_node_id . $this->params_get . $ict_str;
935 }
936 }
937
938 public function setFrameTarget(string $a_target): void
939 {
940 $this->frame_target = $a_target;
941 }
942
943 public function createLines(int $a_depth): void
944 {
945 for ($i = 0, $iMax = count($this->format_options); $i < $iMax; ++$i) {
946 if ($this->format_options[$i]["depth"] == $a_depth + 1
947 and !$this->format_options[$i]["container"]
948 and $this->format_options[$i]["depth"] != 1) {
949 $this->format_options[$i]["tab"][(string) $a_depth] = "quer";
950 }
951
952 if ($this->format_options[$i]["depth"] == $a_depth + 2) {
953 if ($this->is_in_array($i + 1, $this->format_options[$i]["depth"])) {
954 $this->format_options[$i]["tab"][(string) $a_depth] = "winkel";
955 } else {
956 $this->format_options[$i]["tab"][(string) $a_depth] = "ecke";
957 }
958 }
959
960 if ($this->format_options[$i]["depth"] > $a_depth + 2) {
961 if ($this->is_in_array($i + 1, $a_depth + 2)) {
962 $this->format_options[$i]["tab"][(string) $a_depth] = "hoch";
963 }
964 }
965 }
966 }
967
968 public function is_in_array(
969 int $a_start,
970 int $a_depth
971 ): bool {
972 for ($i = $a_start, $iMax = count($this->format_options); $i < $iMax; ++$i) {
973 if ($this->format_options[$i]["depth"] < $a_depth) {
974 break;
975 }
976
977 if ($this->format_options[$i]["depth"] == $a_depth) {
978 return true;
979 }
980 }
981 return false;
982 }
983
984 // get index of format_options array from specific ref_id,parent_id
985 public function getIndex(array $a_data): int
986 {
987 if (!is_array($this->format_options)) {
988 return -1;
989 }
990
991 foreach ($this->format_options as $key => $value) {
992 if (($value["child"] == $a_data["parent"])) {
993 return $key;
994 }
995 }
996
997 return -1;
998 }
999
1000 public function addFilter(string $a_item): bool
1001 {
1002 if (is_array($this->filter)) {
1003 //run through filter
1004 foreach ($this->filter as $item) {
1005 if ($item === $a_item) {
1006 return false;
1007 }
1008 }
1009 } else {
1010 $this->filter = array();
1011 }
1012 $this->filter[] = $a_item;
1013
1014 return true;
1015 }
1016
1017 public function delFilter(string $a_item): bool
1018 {
1019 $deleted = 0;
1020 //check if a filter exists
1021 if (is_array($this->filter)) {
1022 //build copy of the existing filter without the given item
1023 $tmp = array();
1024
1025 foreach ($this->filter as $item) {
1026 if ($item !== $a_item) {
1027 $tmp[] = $item;
1028 } else {
1029 $deleted = 1;
1030 }
1031 }
1032
1033 $this->filter = $tmp;
1034 } else {
1035 return false;
1036 }
1037
1038 return $deleted === 1;
1039 }
1040
1045 public function setExpand($a_node_id): void
1046 {
1047 // IF ISN'T SET CREATE SESSION VARIABLE
1048 if (!is_array(ilSession::get($this->expand_variable))) {
1049 ilSession::set($this->expand_variable, [$this->getRoot()]);
1050 }
1051 if ($a_node_id > 0 && !in_array($a_node_id, ilSession::get($this->expand_variable))) {
1052 $exp = ilSession::get($this->expand_variable);
1053 $exp[] = $a_node_id;
1054 ilSession::set($this->expand_variable, $exp);
1055 }
1056 if ($a_node_id < 0) {
1057 $key = array_keys(ilSession::get($this->expand_variable), -(int) $a_node_id);
1058 $exp = ilSession::get($this->expand_variable);
1059 if (isset($key[0]) && isset($exp[$key[0]])) {
1060 unset($exp[$key[0]]);
1061 }
1062 ilSession::set($this->expand_variable, $exp);
1063 }
1064 $this->expanded = (array) ilSession::get($this->expand_variable);
1065 }
1066
1071 public function forceExpandAll(
1072 bool $a_mode,
1073 bool $a_show_minus = true
1074 ): void {
1075 $this->expand_all = $a_mode;
1076 $this->show_minus = $a_show_minus;
1077 }
1078
1079 public function setFiltered(bool $a_bool): bool
1080 {
1081 $this->filtered = $a_bool;
1082 return true;
1083 }
1084
1085 public function checkFilter(string $a_item): bool
1086 {
1087 if (is_array($this->filter)) {
1088 if (in_array($a_item, $this->filter)) {
1089 $ret = true;
1090 } else {
1091 $ret = false;
1092 }
1093 } else {
1094 $ret = false;
1095 }
1096
1097 if ($this->getFilterMode() === IL_FM_NEGATIVE) {
1098 return $ret;
1099 } else {
1100 return !$ret;
1101 }
1102 }
1103
1107 public function sortNodes(array $a_nodes, $a_parent_obj_id): array
1108 {
1109 $adm_node = null;
1110 foreach ($a_nodes as $key => $node) {
1111 if ($node["type"] === "adm") {
1112 $match = $key;
1113 $adm_node = $node;
1114 break;
1115 }
1116 }
1117
1118 // cut off adm node
1119 if (isset($match)) {
1120 array_splice($a_nodes, $match, 1);
1121 }
1122
1123 $a_nodes = ilArrayUtil::sortArray($a_nodes, $this->order_column, $this->order_direction);
1124
1125 // append adm node to end of list
1126 if (isset($match)) {
1127 $a_nodes[] = $adm_node;
1128 }
1129
1130 return $a_nodes;
1131 }
1132}
setVariable($variable, $value='')
Sets a variable value.
Definition: IT.php:544
const IL_FM_POSITIVE
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
const IL_FM_NEGATIVE
error(string $a_errmsg)
static sortArray(array $array, string $a_array_sortby_key, string $a_array_sortorder="asc", bool $a_numeric=false, bool $a_keep_keys=false)
Error Handling & global info handling.
class for explorer view in admin frame
isClickable(string $type, int $ref_id=0)
setTitle(string $a_val)
handleListStartTags(ilTemplate $a_tpl_tree, int $a_cur_depth, int $a_item_depth)
handle list start tags (
setTreeLead(string $a_val)
addFilter(string $a_item)
ilRbacSystem $rbacsystem
ILIAS Refinery Factory $refinery
buildSelect($a_node_id, string $a_type)
standard implementation for adding an option select box between image and title
buildOnClick( $a_node_id, string $a_type, string $a_title)
ilErrorHandling $error
setOrderColumn(string $a_column)
getNodeStyleClass( $a_id, string $a_type)
showChilds($a_parent_id)
determines wether the childs of an object should be shown or not note: this standard implementation a...
setExpand($a_node_id)
set the expand option this value is stored in a SESSION variable to save it different view (lo view,...
checkPermissions(bool $a_check)
string $expand_variable
delFilter(string $a_item)
setRoot($a_root_id)
ILIAS HTTP Wrapper WrapperFactory $wrapper
formatHeader(ilTemplate $tpl, $a_obj_id, array $a_option)
buildTitle(string $a_title, $a_id, string $a_type)
getImageAlt(string $a_default_text, string $a_type="", $a_obj_id="")
buildFrameTarget(string $a_type, $a_child=0, $a_obj_id=0)
setTargetGet(string $a_target_get)
outputIcons(bool $a_icons)
string $order_direction
string $order_column
initItemCounter(int $a_number)
setFilterMode(int $a_mode=IL_FM_NEGATIVE)
string $target_get
setSessionExpandVariable(string $a_var_name="expand")
array $format_options
string $expand_target
modifyChilds( $a_parent_id, array $a_objects)
string $highlighted
buildDescription(string $a_desc, $a_id, string $a_type)
is_in_array(int $a_start, int $a_depth)
getImage(string $a_name, string $a_type="", $a_obj_id="")
setTitleLength(int $a_length)
bool $use_standard_frame
checkFilter(string $a_item)
setClickable(string $a_type, bool $a_clickable)
handleListEndTags(ilTemplate $a_tpl_tree, int $a_cur_depth, int $a_item_depth)
handle list end tags ( and )
ilObjectDefinition $obj_definition
getIndex(array $a_data)
requestStr(string $key)
buildLinkTarget( $a_node_id, string $a_type)
setParamsGet(array $a_params_get)
setFrameTarget(string $a_target)
getChildsOfNode($a_parent_id)
string $frame_target
setUseStandardFrame(bool $a_val)
Set use standard frame.
string $a_up_script
ilLanguage $lng
setExpandTarget(string $a_exp_target)
target script for expand icons
createTarget(string $a_type, $a_node_id, bool $a_highlighted_subtree=false, bool $a_append_anch=true)
setOrderDirection(string $a_direction)
setFiltered(bool $a_bool)
setId(string $a_val)
string $params_get
forceExpanded($a_obj_id)
force expansion of node
highlightNode(string $a_id)
forceExpandAll(bool $a_mode, bool $a_show_minus=true)
force expandAll.
setFrameUpdater(string $a_up_frame, string $a_up_script, string $a_params="")
setPostSort(bool $a_sort)
setAsynchExpanding(bool $a_val)
setOutput( $a_parent_id, int $a_depth=1, int $a_obj_id=0, bool $a_highlighted_subtree=false)
Creates output for explorer view in admin menue recursive method.
ilGlobalTemplateInterface $tpl
sortNodes(array $a_nodes, $a_parent_obj_id)
sort nodes and put adm object to the end of sorted array
isVisible( $a_ref_id, string $a_type)
createLines(int $a_depth)
special template class to simplify handling of ITX/PEAR
language handling
parses the objects.xml it handles the xml-description of all ilias objects
class ilRbacSystem system function like checkAccess, addActiveRole ... Supporting system functions ar...
checkAccess(string $a_operations, int $a_ref_id, string $a_type="")
checkAccess represents the main method of the RBAC-system in ILIAS3 developers want to use With this ...
static get(string $a_var)
static set(string $a_var, $a_val)
Set a value.
static shortenTextExtended(string $a_str, int $a_len, bool $a_dots=false, bool $a_next_blank=false, bool $a_keep_extension=false)
special template class to simplify handling of ITX/PEAR
setCurrentBlock(string $part=ilGlobalTemplateInterface::DEFAULT_BLOCK)
parseCurrentBlock(string $part=ilGlobalTemplateInterface::DEFAULT_BLOCK)
touchBlock(string $block)
Tree class data representation in hierachical trees using the Nested Set Model with Gaps by Joe Celco...
Util class various functions, usage as namespace.
static getImagePath(string $image_name, string $module_path="", string $mode="output", bool $offline=false)
get image path (for images located in a template directory)
static getStyleSheetLocation(string $mode="output", string $a_css_name="")
get full style sheet file name (path inclusive) of current user
static initConnection(?ilGlobalTemplateInterface $a_main_tpl=null)
Init YUI Connection module.
const ROOT_FOLDER_ID
Definition: constants.php:32
return['delivery_method'=> 'php',]
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
addJavaScript(string $a_js_file, bool $a_add_version_parameter=true, int $a_batch=2)
Add a javascript file that should be included in the header.
$ref_id
Definition: ltiauth.php:66
__construct(Container $dic, ilPlugin $plugin)
@inheritDoc
filter(string $filter_id, $class_path, string $cmd, bool $activated=true, bool $expanded=true)
global $lng
Definition: privfeed.php:31
$_SERVER['HTTP_HOST']
Definition: raiseError.php:26
$ilErr
Definition: raiseError.php:33
if(!file_exists('../ilias.ini.php'))
global $DIC
Definition: shib_login.php:26
$counter