ILIAS  release_8 Revision v8.24
class.ilExplorer.php
Go to the documentation of this file.
1<?php
2
21
29{
34 protected ilLanguage $lng;
35 public string $id = "";
36 public string $output = "";
37 public array $format_options = [];
38 public ilTree $tree;
39 public string $target = "";
40 public string $target_get = "";
41 public string $params_get = "";
42 public array $expanded = [];
43 public string $order_column = "";
44 public string $order_direction = "asc";
45 public ?string $expand_target = null;
46 public bool $rbac_check = false;
47 public bool $output_icons = false;
48 public string $expand_variable = "";
49 // array ($type => clickable (empty means true, "n" means false)
50 public array $is_clickable = [];
51 public bool $post_sort = false;
52 public bool $filtered = false;
53 protected $filter = [];
54 public bool $filter_mode;
55 // expand entire tree regardless of values in $expanded
56 public bool $expand_all = false;
57 public $root_id = null;
58 public bool $use_standard_frame = false;
59 protected string $highlighted = "";
60 protected bool $show_minus = true;
61 protected int $counter = 0;
62 protected bool $asnch_expanding = false;
63 protected int $textwidth = 0;
64 protected string $title = "";
65 protected string $up_frame = "";
66 protected string $a_up_script = "";
67 protected string $up_params = "";
68 protected string $frame_target = "";
69 protected string $up_script = "";
70 protected string $tree_lead = "";
71 protected array $iconList = [];
72
73 protected \ILIAS\Refinery\Factory $refinery;
74 protected \ILIAS\HTTP\Wrapper\WrapperFactory $wrapper;
75
76 public function __construct(string $a_target)
77 {
79 global $DIC;
80
81 $this->obj_definition = $DIC["objDefinition"];
82 $this->error = $DIC["ilErr"];
83 $this->rbacsystem = $DIC->rbac()->system();
84 $this->tpl = $DIC["tpl"];
85 $this->lng = $DIC->language();
86 $objDefinition = $DIC["objDefinition"];
87 $ilErr = $DIC["ilErr"];
88
89 if (!isset($a_target) or !is_string($a_target)) {
90 $ilErr->raiseError(get_class($this) . "::Constructor(): No target given!", $ilErr->WARNING);
91 }
92
93 // autofilter object types in devmode
94 $devtypes = $objDefinition->getDevModeAll();
95
96 if (count($devtypes) > 0) {
97 // activate filter if objects found in devmode
98 $this->setFiltered(true);
99
100 foreach ($devtypes as $type) {
101 $this->addFilter($type);
102 }
103 }
104
105 $this->expanded = array();
106 $this->target = $a_target;
107 $this->target_get = 'ref_id';
108 $this->frame_target = "content";
109 $this->order_column = "title";
110 $this->tree = new ilTree(ROOT_FOLDER_ID);
111 $this->tree->initLangCode();
112 $this->expand_target = $_SERVER["PATH_INFO"] ?? "";
113 $this->rbac_check = true;
114 $this->output_icons = true;
115 $this->expand_variable = "expand";
116 $this->setTitleLength(50);
117 $this->post_sort = true;
119 $this->highlighted = "";
120 $this->show_minus = true;
121 $this->counter = 0;
122 $this->asnch_expanding = false;
123 $this->refinery = $DIC->refinery();
124 $this->wrapper = $DIC->http()->wrapper();
125 }
126
127 protected function requestStr(string $key): string
128 {
129 $str = $this->refinery->kindlyTo()->string();
130 if ($this->wrapper->post()->has($key)) {
131 return $this->wrapper->post()->retrieve($key, $str);
132 }
133 if ($this->wrapper->query()->has($key)) {
134 return $this->wrapper->query()->retrieve($key, $str);
135 }
136 return "";
137 }
138
139 public function setId(string $a_val): void
140 {
141 $this->id = $a_val;
142 }
143
144 public function getId(): string
145 {
146 return $this->id;
147 }
148
149 public function setAsynchExpanding(bool $a_val): void
150 {
151 $this->asnch_expanding = $a_val;
152 }
153
154 public function getAsynchExpanding(): bool
155 {
157 }
158
159 public function initItemCounter(int $a_number): void
160 {
161 $this->counter = $a_number;
162 }
163
164 public function setTitle(string $a_val): void
165 {
166 $this->title = $a_val;
167 }
168
169 public function setTitleLength(int $a_length): void
170 {
171 $this->textwidth = $a_length;
172 }
173
174 public function getTitleLength(): int
175 {
176 return $this->textwidth;
177 }
178
179 public function getTitle(): string
180 {
181 return $this->title;
182 }
183
184 public function setRoot($a_root_id): void
185 {
186 #$this->tree = new ilTree(ROOT_FOLDER_ID,$a_root_id);
187 $this->root_id = $a_root_id;
188 }
189
190 public function getRoot(): ?int
191 {
192 return $this->root_id ?? $this->tree->getRootId();
193 }
194
195 public function setOrderColumn(string $a_column): void
196 {
197 $this->order_column = $a_column;
198 }
199
200 public function setOrderDirection(string $a_direction): void
201 {
202 if ($a_direction === "desc") {
203 $this->order_direction = $a_direction;
204 } else {
205 $this->order_direction = "asc";
206 }
207 }
208
212 public function setTargetGet(string $a_target_get): void
213 {
215
216 if (!isset($a_target_get) or !is_string($a_target_get)) {
217 $ilErr->raiseError(get_class($this) . "::setTargetGet(): No target given!", $ilErr->WARNING);
218 }
219
220 $this->target_get = $a_target_get;
221 }
222
223 public function setParamsGet(array $a_params_get): void
224 {
226
227 if (!isset($a_params_get) or !is_array($a_params_get)) {
228 $ilErr->raiseError(get_class($this) . "::setTargetGet(): No target given!", $ilErr->WARNING);
229 }
230 $str = "";
231 foreach ($a_params_get as $key => $val) {
232 $str .= "&" . $key . "=" . $val;
233 }
234
235 $this->params_get = $str;
236 }
237
238
244 public function setExpandTarget(string $a_exp_target): void
245 {
246 $this->expand_target = $a_exp_target;
247 }
248
249 public function setFrameUpdater(
250 string $a_up_frame,
251 string $a_up_script,
252 string $a_params = ""
253 ): void {
254 $this->up_frame = $a_up_frame;
255 $this->up_script = $a_up_script;
256 $this->up_params = $a_params;
257 }
258
259
260 public function highlightNode(string $a_id): void
261 {
262 $this->highlighted = $a_id;
263 }
264
265 public function checkPermissions(bool $a_check): void
266 {
267 $this->rbac_check = $a_check;
268 }
269
270 public function setSessionExpandVariable(string $a_var_name = "expand"): void
271 {
272 $this->expand_variable = $a_var_name;
273 }
274
275 public function outputIcons(bool $a_icons): void
276 {
277 $this->output_icons = $a_icons;
278 }
279
280 public function setClickable(string $a_type, bool $a_clickable): void
281 {
282 if ($a_clickable) {
283 $this->is_clickable[$a_type] = "";
284 } else {
285 $this->is_clickable[$a_type] = "n";
286 }
287 }
288
289 public function isVisible(
290 $a_ref_id,
291 string $a_type
292 ): bool {
293 $rbacsystem = $this->rbacsystem;
294
295 if (!$this->rbac_check) {
296 return true;
297 }
298
299 $visible = $rbacsystem->checkAccess('visible', $a_ref_id);
300
301 return $visible;
302 }
303
304 // Set tree leading content
305 public function setTreeLead(string $a_val): void
306 {
307 $this->tree_lead = $a_val;
308 }
309
310 public function getTreeLead(): string
311 {
312 return $this->tree_lead;
313 }
314
315 // check if links for certain object type are activated
316 public function isClickable(
317 string $type,
318 int $ref_id = 0
319 ): bool {
320 // in this standard implementation
321 // only the type determines, wether an object should be clickable or not
322 // but this method can be overwritten and make $exp->setFilterMode(IL_FM_NEGATIVE);use of the ref id
323 // (this happens e.g. in class ilRepositoryExplorerGUI)
324 return $this->is_clickable[$type] !== "n";
325 }
326
327 public function setPostSort(bool $a_sort): void
328 {
329 $this->post_sort = $a_sort;
330 }
331
332 public function setFilterMode(int $a_mode = IL_FM_NEGATIVE): void
333 {
334 $this->filter_mode = $a_mode;
335 }
336
340 public function getFilterMode(): int
341 {
342 return $this->filter_mode;
343 }
344
349 public function setUseStandardFrame(bool $a_val): void
350 {
351 $this->use_standard_frame = $a_val;
352 }
353
354 public function getUseStandardFrame(): bool
355 {
356 return $this->use_standard_frame;
357 }
358
359 public function getChildsOfNode($a_parent_id): array
360 {
361 return $this->tree->getChilds($a_parent_id, $this->order_column);
362 }
363
364
369 public function setOutput(
370 $a_parent_id,
371 int $a_depth = 1,
372 int $a_obj_id = 0,
373 bool $a_highlighted_subtree = false
374 ): void {
375 $ilErr = $this->error;
376
377 $parent_index = 0;
378
379 if (!isset($a_parent_id)) {
380 $ilErr->raiseError(get_class($this) . "::setOutput(): No node_id given!", $ilErr->WARNING);
381 }
382
383 if ($this->showChilds($a_parent_id)) {
384 $objects = $this->getChildsOfNode($a_parent_id);
385 } else {
386 $objects = array();
387 }
388
389 $objects = $this->modifyChilds($a_parent_id, $objects);
390
391 // force expansion (of single nodes)
392 if ($this->forceExpanded($a_parent_id) && !in_array($a_parent_id, $this->expanded)) {
393 $this->expanded[] = $a_parent_id;
394 }
395
396 if (count($objects) > 0) {
397 // Maybe call a lexical sort function for the child objects
398 $tab = ++$a_depth - 2;
399 if ($this->post_sort) {
400 $objects = $this->sortNodes($objects, $a_obj_id);
401 }
402 $skip_rest = false;
403 foreach ($objects as $key => $object) {
404 // skip childs, if parent is not expanded
405 if (!$this->forceExpanded($object["child"]) && $skip_rest) {
406 continue;
407 }
408 //echo "<br>-".$object["child"]."-".$this->forceExpanded($object["child"])."-";
409 //ask for FILTER
410 if ($this->filtered === false || $this->checkFilter($object["type"]) === false) {
411 if ($this->isVisible($object['child'], $object['type'])) {
412 #echo 'CHILD getIndex() '.$object['child'].' parent: '.$this->getRoot();
413 if ($object["child"] != $this->getRoot()) {
414 $parent_index = $this->getIndex($object);
415 }
416 $this->format_options[(string) $this->counter]["parent"] = $object["parent"];
417 $this->format_options[(string) $this->counter]["child"] = $object["child"];
418 $this->format_options[(string) $this->counter]["title"] = $object["title"];
419 $this->format_options[(string) $this->counter]["type"] = $object["type"];
420 $this->format_options[(string) $this->counter]["obj_id"] = $object["obj_id"];
421 $this->format_options[(string) $this->counter]["desc"] = "obj_" . $object["type"];
422 $this->format_options[(string) $this->counter]["depth"] = $tab;
423 $this->format_options[(string) $this->counter]["container"] = false;
424 $this->format_options[(string) $this->counter]["visible"] = true;
425 $this->format_options[(string) $this->counter]["highlighted_subtree"] = $a_highlighted_subtree;
426
427 // Create prefix array
428 for ($i = 0; $i < $tab; ++$i) {
429 $this->format_options[(string) $this->counter]["tab"][] = 'blank';
430 }
431
432 // fix explorer (sometimes explorer disappears)
433 if ($parent_index === 0) {
434 if (!$this->expand_all && !in_array($object["parent"], $this->expanded)) {
435 $this->expanded[] = $object["parent"];
436 }
437 }
438
439 // only if parent is expanded and visible, object is visible
440 if ($object["child"] != $this->getRoot() && ((!$this->expand_all && !in_array($object["parent"], $this->expanded))
441 or !$this->format_options[(string) $parent_index]["visible"])) {
442 if (!$this->forceExpanded($object["child"])) {
443 // if parent is not expanded, and one child is
444 // visible we don't need more information and
445 // can skip the rest of the childs
446 if ($this->format_options[(string) $this->counter]["visible"]) {
447 //echo "-setSkipping";
448 $skip_rest = true;
449 }
450 $this->format_options[(string) $this->counter]["visible"] = false;
451 }
452 }
453
454 // if object exists parent is container
455 if ($object["child"] != $this->getRoot()) {
456 $this->format_options[(string) $parent_index]["container"] = true;
457
458 if ($this->expand_all || in_array($object["parent"], $this->expanded)) {
459 //echo "<br>-".$object["child"]."-".$this->forceExpanded($object["child"])."-";
460 if ($this->forceExpanded($object["parent"])) {
461 $this->format_options[(string) $parent_index]["tab"][($tab - 2)] = 'forceexp';
462 } else {
463 $this->format_options[(string) $parent_index]["tab"][($tab - 2)] = 'minus';
464 }
465 } else {
466 $this->format_options[(string) $parent_index]["tab"][($tab - 2)] = 'plus';
467 }
468 }
469 //echo "-"."$parent_index"."-";
470 //var_dump($this->format_options["$parent_index"]);
471 ++$this->counter;
472
473 // stop recursion if 2. level beyond expanded nodes is reached
474 if ($this->expand_all || in_array($object["parent"], $this->expanded) or ($object["parent"] == 0)
475 or $this->forceExpanded($object["child"])) {
476 $highlighted_subtree = $a_highlighted_subtree ||
477 ($object["child"] == $this->highlighted);
478
479 // recursive
480 $this->setOutput($object["child"], $a_depth, $object['obj_id'], $highlighted_subtree);
481 }
482 } //if
483 } //if FILTER
484 } //foreach
485 } //if
486 } //function
487
488 public function modifyChilds(
489 $a_parent_id,
490 array $a_objects
491 ): array {
492 return $a_objects;
493 }
494
500 public function showChilds($a_parent_id): bool
501 {
502 return true;
503 }
504
508 public function forceExpanded($a_obj_id): bool
509 {
510 return false;
511 }
512
513 public function getMaximumTreeDepth(): int
514 {
515 $this->tree->getMaximumDepth();
516 return 0; // seems to not return the value...
517 }
518
519
520 public function getOutput(): string
521 {
524
525 $this->format_options[0]["tab"] = array();
526
527 $depth = $this->getMaximumTreeDepth();
528
529 for ($i = 0;$i < $depth;++$i) {
530 $this->createLines($i);
531 }
532
534 $tpl->addJavaScript("./Services/UIComponent/Explorer/js/ilExplorer.js");
535
536 //echo "hh";
537 // set global body class
538 // $tpl->setBodyClass("il_Explorer");
539
540 $tpl_tree = new ilTemplate("tpl.tree.html", true, true, "Services/UIComponent/Explorer");
541
542 // updater
543 if (($this->requestStr("ict") !== "" ||
544 $this->requestStr("collapseAll") !== "" ||
545 $this->requestStr("expandAll") !== "") && $this->up_frame !== "") {
546 $tpl_tree->setCurrentBlock("updater");
547 $tpl_tree->setVariable("UPDATE_FRAME", $this->up_frame);
548 $tpl_tree->setVariable("UPDATE_SCRIPT", $this->up_script);
549 if (is_array($this->up_params)) {
550 $up_str = $lim = "";
551 foreach ($this->up_params as $p) {
552 $up_str .= $lim . "'" . $p . "'";
553 $lim = ",";
554 }
555 $tpl_tree->setVariable("UPDATE_PARAMS", $up_str);
556 }
557 $tpl_tree->parseCurrentBlock();
558 }
559 $cur_depth = -1;
560 foreach ($this->format_options as $key => $options) {
561 //echo "-".$options["depth"]."-";
562 if (!($options["visible"] ?? false)) {
563 continue;
564 }
565
566 // end tags
567 $this->handleListEndTags($tpl_tree, $cur_depth, $options["depth"]);
568
569 // start tags
570 $this->handleListStartTags($tpl_tree, $cur_depth, $options["depth"]);
571
572 $cur_depth = $options["depth"];
573
574 if ($options["visible"] and $key != 0) {
575 $this->formatObject($tpl_tree, $options["child"], $options, $options['obj_id']);
576 }
577 if ($key == 0) {
578 $this->formatHeader($tpl_tree, $options["child"], $options);
579 }
580 }
581
582 $this->handleListEndTags($tpl_tree, $cur_depth, -1);
583
584 $tpl_tree->setVariable("TREE_LEAD", "");
585 if ($this->tree_lead !== "") {
586 $tpl_tree->setCurrentBlock("tree_lead");
587 $tpl_tree->setVariable("TREE_LEAD", $this->tree_lead);
588 $tpl_tree->parseCurrentBlock();
589 }
590 if ($this->getId() !== "") {
591 $tpl_tree->setVariable("TREE_ID", 'id="' . $this->getId() . '_tree"');
592 }
593
594 $html = $tpl_tree->get();
595
596 if ($this->getUseStandardFrame()) {
597 $mtpl = new ilGlobalTemplate("tpl.main.html", true, true);
598 $mtpl->setVariable("LOCATION_STYLESHEET", ilUtil::getStyleSheetLocation());
599 $mtpl->setVariable("BODY_CLASS", "il_Explorer");
600 $mtpl->addBlockFile("CONTENT", "content", "tpl.explorer.html");
601 if ($this->getTitle() !== "") {
602 $mtpl->setVariable("TXT_EXPLORER_HEADER", $this->getTitle());
603 }
604 if ($this->getId() !== "") {
605 $mtpl->setVariable("ID", 'id="' . $this->getId() . '"');
606 }
607 $mtpl->setVariable("IMG_SPACE", ilUtil::getImagePath("spacer.png", false));
608 $mtpl->setCurrentBlock("content");
609 $mtpl->setVariable("EXPLORER", $html);
610 $mtpl->setVariable("EXP_REFRESH", $lng->txt("refresh"));
611 $mtpl->parseCurrentBlock();
612 $html = $mtpl->get();
613 }
614
615 return $html;
616 }
617
618
619
623 public function handleListEndTags(
624 ilTemplate $a_tpl_tree,
625 int $a_cur_depth,
626 int $a_item_depth
627 ): void {
628 if ($a_item_depth < $a_cur_depth) {
629 // </li></ul> for ending lists
630 for ($i = 0; $i < ($a_cur_depth - $a_item_depth); $i++) {
631 $a_tpl_tree->touchBlock("end_list_item");
632 $a_tpl_tree->touchBlock("element");
633
634 $a_tpl_tree->touchBlock("end_list");
635 $a_tpl_tree->touchBlock("element");
636 }
637 } elseif ($a_item_depth == $a_cur_depth) {
638 // </li> for ending list items
639 $a_tpl_tree->touchBlock("end_list_item");
640 $a_tpl_tree->touchBlock("element");
641 }
642 }
643
647 public function handleListStartTags(
648 ilTemplate $a_tpl_tree,
649 int $a_cur_depth,
650 int $a_item_depth
651 ): void {
652 // start tags
653 if ($a_item_depth > $a_cur_depth) {
654 // <ul><li> for new lists
655 if ($a_item_depth > 1) {
656 $a_tpl_tree->touchBlock("start_list");
657 } else {
658 $a_tpl_tree->touchBlock("start_list_no_indent");
659 }
660 $a_tpl_tree->touchBlock("element");
661 }
662 $a_tpl_tree->touchBlock("start_list_item");
663 $a_tpl_tree->touchBlock("element");
664 }
665
666 public function formatHeader(
668 $a_obj_id,
669 array $a_option
670 ): void {
671 }
672
673 public function formatObject(
675 $a_node_id,
676 array $a_option,
677 $a_obj_id = 0
678 ): void {
679 $lng = $this->lng;
680 $ilErr = $this->error;
681
682 if (!isset($a_node_id) or !is_array($a_option)) {
683 $ilErr->raiseError(get_class($this) . "::formatObject(): Missing parameter or wrong datatype! " .
684 "node_id: " . $a_node_id . " options:" . var_export($a_option, true), $ilErr->WARNING);
685 }
686
687 $pic = false;
688 foreach ((array) $a_option["tab"] as $picture) {
689 if ($picture === 'plus') {
690 $tpl->setCurrentBlock("expander");
691 $tpl->setVariable("EXP_DESC", $lng->txt("collapsed"));
692 $tpl->setVariable("LINK_NAME", $a_node_id);
693 if (!$this->getAsynchExpanding()) {
694 $target = $this->createTarget('+', $a_node_id, $a_option["highlighted_subtree"]);
695 $tpl->setVariable("LINK_TARGET_EXPANDER", $target);
696 } else {
697 $target = $this->createTarget('+', $a_node_id, $a_option["highlighted_subtree"], false);
698 $tpl->setVariable("ONCLICK_TARGET_EXPANDER", " onclick=\"return il.Explorer.refresh('tree_div', '" . $target . "');\"");
699 $tpl->setVariable("LINK_TARGET_EXPANDER", "#");
700 }
701 $tpl->setVariable("IMGPATH", $this->getImage("browser/plus.png"));
702 $tpl->parseCurrentBlock();
703 $pic = true;
704 }
705
706 if ($picture === 'forceexp') {
707 $tpl->setCurrentBlock("expander");
708 $tpl->setVariable("EXP_DESC", $lng->txt("expanded"));
709 $target = $this->createTarget('+', $a_node_id);
710 $tpl->setVariable("LINK_NAME", $a_node_id);
711 $tpl->setVariable("LINK_TARGET_EXPANDER", $target);
712 $tpl->setVariable("IMGPATH", $this->getImage("browser/forceexp.png"));
713 $tpl->parseCurrentBlock();
714 $pic = true;
715 }
716
717 if ($picture === 'minus' && $this->show_minus) {
718 $tpl->setCurrentBlock("expander");
719 $tpl->setVariable("EXP_DESC", $lng->txt("expanded"));
720 $tpl->setVariable("LINK_NAME", $a_node_id);
721 if (!$this->getAsynchExpanding()) {
722 $target = $this->createTarget('-', $a_node_id, $a_option["highlighted_subtree"]);
723 $tpl->setVariable("LINK_TARGET_EXPANDER", $target);
724 } else {
725 $target = $this->createTarget('-', $a_node_id, $a_option["highlighted_subtree"], false);
726 $tpl->setVariable("ONCLICK_TARGET_EXPANDER", " onclick=\"return il.Explorer.refresh('tree_div', '" . $target . "');\"");
727 $tpl->setVariable("LINK_TARGET_EXPANDER", "#");
728 }
729 $tpl->setVariable("IMGPATH", $this->getImage("browser/minus.png"));
730 $tpl->parseCurrentBlock();
731 $pic = true;
732 }
733 }
734
735 if (!$pic) {
736 $tpl->setCurrentBlock("blank");
737 $tpl->setVariable("BLANK_PATH", $this->getImage("browser/blank.png"));
738 $tpl->parseCurrentBlock();
739 }
740
741 if ($this->output_icons) {
742 $tpl->setCurrentBlock("icon");
743 $tpl->setVariable("ICON_IMAGE", $this->getImage("icon_" . $a_option["type"] . ".svg", $a_option["type"], $a_obj_id));
744
745 $tpl->setVariable("TARGET_ID", "iconid_" . $a_node_id);
746 $this->iconList[] = "iconid_" . $a_node_id;
747 $tpl->setVariable(
748 "TXT_ALT_IMG",
749 $this->getImageAlt($lng->txt("icon") . " " . $lng->txt($a_option["desc"]), $a_option["type"], $a_obj_id)
750 );
751 $tpl->parseCurrentBlock();
752 }
753
754 if (($sel = $this->buildSelect($a_node_id, $a_option['type'])) !== '') {
755 $tpl->setCurrentBlock('select');
756 $tpl->setVariable('OBJ_SEL', $sel);
757 $tpl->parseCurrentBlock();
758 }
759
760 if ($this->isClickable($a_option["type"], $a_node_id)) { // output link
761 $tpl->setCurrentBlock("link");
762 //$target = (strpos($this->target, "?") === false) ?
763 // $this->target."?" : $this->target."&";
764 //$tpl->setVariable("LINK_TARGET", $target.$this->target_get."=".$a_node_id.$this->params_get);
765 $tpl->setVariable("LINK_TARGET", $this->buildLinkTarget($a_node_id, $a_option["type"]));
766
767 $style_class = $this->getNodeStyleClass($a_node_id, $a_option["type"]);
768
769 if ($style_class !== "") {
770 $tpl->setVariable("A_CLASS", ' class="' . $style_class . '" ');
771 }
772
773 if (($onclick = $this->buildOnClick($a_node_id, $a_option["type"], $a_option["title"])) != "") {
774 $tpl->setVariable("ONCLICK", "onClick=\"$onclick\"");
775 }
776
777 //$tpl->setVariable("LINK_NAME", $a_node_id);
778 $tpl->setVariable(
779 "TITLE",
781 $this->buildTitle($a_option["title"], $a_node_id, $a_option["type"]),
782 $this->textwidth,
783 true
784 )
785 );
786 $tpl->setVariable(
787 "DESC",
789 $this->buildDescription($a_option["description"] ?? "", $a_node_id, $a_option["type"]),
790 $this->textwidth,
791 true
792 )
793 );
794 $frame_target = $this->buildFrameTarget($a_option["type"], $a_node_id, $a_option["obj_id"]);
795 if ($frame_target !== "") {
796 $tpl->setVariable("TARGET", " target=\"" . $frame_target . "\"");
797 }
798 } else { // output text only
799 $tpl->setCurrentBlock("text");
800 $tpl->setVariable(
801 "OBJ_TITLE",
803 $this->buildTitle($a_option["title"], $a_node_id, $a_option["type"]),
804 $this->textwidth,
805 true
806 )
807 );
808 $tpl->setVariable(
809 "OBJ_DESC",
811 $this->buildDescription($a_option["desc"], $a_node_id, $a_option["type"]),
812 $this->textwidth,
813 true
814 )
815 );
816 }
817 $tpl->parseCurrentBlock();
818
819 $tpl->setCurrentBlock("list_item");
820 $tpl->parseCurrentBlock();
821 $tpl->touchBlock("element");
822 }
823
824 public function getImage(
825 string $a_name,
826 string $a_type = "",
827 $a_obj_id = ""
828 ): string {
829 return ilUtil::getImagePath($a_name);
830 }
831
832 public function getImageAlt(
833 string $a_default_text,
834 string $a_type = "",
835 $a_obj_id = ""
836 ): string {
837 return $a_default_text;
838 }
839
840 public function getNodeStyleClass(
841 $a_id,
842 string $a_type
843 ): string {
844 if ($a_id == $this->highlighted) {
845 return "il_HighlightedNode";
846 }
847 return "";
848 }
849
850 public function buildLinkTarget(
851 $a_node_id,
852 string $a_type
853 ): string {
854 $target = (strpos($this->target, "?") === false)
855 ? $this->target . "?"
856 : $this->target . "&";
857 return $target . $this->target_get . "=" . $a_node_id . $this->params_get;
858 }
859
860 public function buildOnClick(
861 $a_node_id,
862 string $a_type,
863 string $a_title
864 ): string {
865 return "";
866 }
867
868 public function buildTitle(
869 string $a_title,
870 $a_id,
871 string $a_type
872 ): string {
873 return $a_title;
874 }
875
876 public function buildDescription(
877 string $a_desc,
878 $a_id,
879 string $a_type
880 ): string {
881 return "";
882 }
883
887 public function buildSelect($a_node_id, string $a_type): string
888 {
889 return "";
890 }
891
892 public function buildFrameTarget(
893 string $a_type,
894 $a_child = 0,
895 $a_obj_id = 0
896 ): string {
897 return $this->frame_target;
898 }
899
900
901 public function createTarget(
902 string $a_type,
903 $a_node_id,
904 bool $a_highlighted_subtree = false,
905 bool $a_append_anch = true
906 ): string {
907 $ilErr = $this->error;
908
909 if (!isset($a_type) or !is_string($a_type) or !isset($a_node_id)) {
910 $ilErr->raiseError(get_class($this) . "::createTarget(): Missing parameter or wrong datatype! " .
911 "type: " . $a_type . " node_id:" . $a_node_id, $ilErr->WARNING);
912 }
913
914 // SET expand parameter:
915 // positive if object is expanded
916 // negative if object is compressed
917 $a_node_id = $a_type === '+' ? $a_node_id : -(int) $a_node_id;
918
919 $sep = (is_int(strpos($this->expand_target, "?")))
920 ? "&"
921 : "?";
922
923 // in current tree flag
924 $ict_str = ($a_highlighted_subtree || $this->highlighted === "")
925 ? "&ict=1"
926 : "";
927 if ($this->getAsynchExpanding()) {
928 $ict_str .= "&cmdMode=asynch";
929 }
930 if ($a_append_anch) {
931 return $this->expand_target . $sep . $this->expand_variable . "=" . $a_node_id . $this->params_get . $ict_str . "#" . abs($a_node_id);
932 } else {
933 return $this->expand_target . $sep . $this->expand_variable . "=" . $a_node_id . $this->params_get . $ict_str;
934 }
935 }
936
937 public function setFrameTarget(string $a_target): void
938 {
939 $this->frame_target = $a_target;
940 }
941
942 public function createLines(int $a_depth): void
943 {
944 for ($i = 0, $iMax = count($this->format_options); $i < $iMax; ++$i) {
945 if ($this->format_options[$i]["depth"] == $a_depth + 1
946 and !$this->format_options[$i]["container"]
947 and $this->format_options[$i]["depth"] != 1) {
948 $this->format_options[$i]["tab"][(string) $a_depth] = "quer";
949 }
950
951 if ($this->format_options[$i]["depth"] == $a_depth + 2) {
952 if ($this->is_in_array($i + 1, $this->format_options[$i]["depth"])) {
953 $this->format_options[$i]["tab"][(string) $a_depth] = "winkel";
954 } else {
955 $this->format_options[$i]["tab"][(string) $a_depth] = "ecke";
956 }
957 }
958
959 if ($this->format_options[$i]["depth"] > $a_depth + 2) {
960 if ($this->is_in_array($i + 1, $a_depth + 2)) {
961 $this->format_options[$i]["tab"][(string) $a_depth] = "hoch";
962 }
963 }
964 }
965 }
966
967 public function is_in_array(
968 int $a_start,
969 int $a_depth
970 ): bool {
971 for ($i = $a_start, $iMax = count($this->format_options); $i < $iMax; ++$i) {
972 if ($this->format_options[$i]["depth"] < $a_depth) {
973 break;
974 }
975
976 if ($this->format_options[$i]["depth"] == $a_depth) {
977 return true;
978 }
979 }
980 return false;
981 }
982
983 // get index of format_options array from specific ref_id,parent_id
984 public function getIndex(array $a_data): int
985 {
986 if (!is_array($this->format_options)) {
987 return -1;
988 }
989
990 foreach ($this->format_options as $key => $value) {
991 if (($value["child"] == $a_data["parent"])) {
992 return $key;
993 }
994 }
995
996 return -1;
997 }
998
999 public function addFilter(string $a_item): bool
1000 {
1001 if (is_array($this->filter)) {
1002 //run through filter
1003 foreach ($this->filter as $item) {
1004 if ($item === $a_item) {
1005 return false;
1006 }
1007 }
1008 } else {
1009 $this->filter = array();
1010 }
1011 $this->filter[] = $a_item;
1012
1013 return true;
1014 }
1015
1016 public function delFilter(string $a_item): bool
1017 {
1018 $deleted = 0;
1019 //check if a filter exists
1020 if (is_array($this->filter)) {
1021 //build copy of the existing filter without the given item
1022 $tmp = array();
1023
1024 foreach ($this->filter as $item) {
1025 if ($item !== $a_item) {
1026 $tmp[] = $item;
1027 } else {
1028 $deleted = 1;
1029 }
1030 }
1031
1032 $this->filter = $tmp;
1033 } else {
1034 return false;
1035 }
1036
1037 return $deleted === 1;
1038 }
1039
1044 public function setExpand($a_node_id): void
1045 {
1046 // IF ISN'T SET CREATE SESSION VARIABLE
1047 if (!is_array(ilSession::get($this->expand_variable))) {
1048 ilSession::set($this->expand_variable, [$this->getRoot()]);
1049 }
1050 if ($a_node_id > 0 && !in_array($a_node_id, ilSession::get($this->expand_variable))) {
1051 $exp = ilSession::get($this->expand_variable);
1052 $exp[] = $a_node_id;
1053 ilSession::set($this->expand_variable, $exp);
1054 }
1055 if ($a_node_id < 0) {
1056 $key = array_keys(ilSession::get($this->expand_variable), -(int) $a_node_id);
1057 $exp = ilSession::get($this->expand_variable);
1058 if (isset($key[0]) && isset($exp[$key[0]])) {
1059 unset($exp[$key[0]]);
1060 }
1061 ilSession::set($this->expand_variable, $exp);
1062 }
1063 $this->expanded = (array) ilSession::get($this->expand_variable);
1064 }
1065
1070 public function forceExpandAll(
1071 bool $a_mode,
1072 bool $a_show_minus = true
1073 ): void {
1074 $this->expand_all = $a_mode;
1075 $this->show_minus = $a_show_minus;
1076 }
1077
1078 public function setFiltered(bool $a_bool): bool
1079 {
1080 $this->filtered = $a_bool;
1081 return true;
1082 }
1083
1084 public function checkFilter(string $a_item): bool
1085 {
1086 if (is_array($this->filter)) {
1087 if (in_array($a_item, $this->filter)) {
1088 $ret = true;
1089 } else {
1090 $ret = false;
1091 }
1092 } else {
1093 $ret = false;
1094 }
1095
1096 if ($this->getFilterMode() === IL_FM_NEGATIVE) {
1097 return $ret;
1098 } else {
1099 return !$ret;
1100 }
1101 }
1102
1106 public function sortNodes(array $a_nodes, $a_parent_obj_id): array
1107 {
1108 $adm_node = null;
1109 foreach ($a_nodes as $key => $node) {
1110 if ($node["type"] === "adm") {
1111 $match = $key;
1112 $adm_node = $node;
1113 break;
1114 }
1115 }
1116
1117 // cut off adm node
1118 if (isset($match)) {
1119 array_splice($a_nodes, $match, 1);
1120 }
1121
1122 $a_nodes = ilArrayUtil::sortArray($a_nodes, $this->order_column, $this->order_direction);
1123
1124 // append adm node to end of list
1125 if (isset($match)) {
1126 $a_nodes[] = $adm_node;
1127 }
1128
1129 return $a_nodes;
1130 }
1131}
static return function(ContainerConfigurator $containerConfigurator)
Definition: basic_rector.php:9
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 uses PEAR error class.
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
touchBlock(string $block)
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
Util class various functions, usage as namespace.
static getStyleSheetLocation(string $mode="output", string $a_css_name="", string $a_css_location="")
get full style sheet file name (path inclusive) of current user
static getImagePath(string $img, string $module_path="", string $mode="output", bool $offline=false)
get image path (for images located in a template directory)
static initConnection(?ilGlobalTemplateInterface $a_main_tpl=null)
Init YUI Connection module.
if(!file_exists(getcwd() . '/ilias.ini.php'))
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
Definition: confirmReg.php:20
const ROOT_FOLDER_ID
Definition: constants.php:32
return['3gp', '7z', 'ai', 'aif', 'aifc', 'aiff', 'au', 'arw', 'avi', 'backup', 'bak', 'bas', 'bpmn', 'bpmn2', 'bmp', 'bib', 'bibtex', 'bz', 'bz2', 'c', 'c++', 'cc', 'cct', 'cdf', 'cer', 'class', 'cls', 'conf', 'cpp', 'crt', 'crs', 'crw', 'cr2', 'css', 'cst', 'csv', 'cur', 'db', 'dcr', 'des', 'dng', 'doc', 'docx', 'dot', 'dotx', 'dtd', 'dvi', 'el', 'eps', 'epub', 'f', 'f77', 'f90', 'flv', 'for', 'g3', 'gif', 'gl', 'gan', 'ggb', 'gsd', 'gsm', 'gtar', 'gz', 'gzip', 'h', 'hpp', 'htm', 'html', 'htmls', 'ibooks', 'ico', 'ics', 'ini', 'ipynb', 'java', 'jbf', 'jpeg', 'jpg', 'js', 'jsf', 'jso', 'json', 'latex', 'lang', 'less', 'log', 'lsp', 'ltx', 'm1v', 'm2a', 'm2v', 'm3u', 'm4a', 'm4v', 'markdown', 'm', 'mat', 'md', 'mdl', 'mdown', 'mid', 'min', 'midi', 'mobi', 'mod', 'mov', 'movie', 'mp2', 'mp3', 'mp4', 'mpa', 'mpeg', 'mpg', 'mph', 'mpga', 'mpp', 'mpt', 'mpv', 'mpx', 'mv', 'mw', 'mv4', 'nb', 'nbp', 'nef', 'nif', 'niff', 'obj', 'obm', 'odt', 'ods', 'odp', 'odg', 'odf', 'oga', 'ogg', 'ogv', 'old', 'p', 'pas', 'pbm', 'pcl', 'pct', 'pcx', 'pdf', 'pgm', 'pic', 'pict', 'png', 'por', 'pov', 'project', 'properties', 'ppa', 'ppm', 'pps', 'ppsx', 'ppt', 'pptx', 'ppz', 'ps', 'psd', 'pwz', 'qt', 'qtc', 'qti', 'qtif', 'r', 'ra', 'ram', 'rar', 'rast', 'rda', 'rev', 'rexx', 'ris', 'rf', 'rgb', 'rm', 'rmd', 'rmi', 'rmm', 'rmp', 'rt', 'rtf', 'rtx', 'rv', 's', 's3m', 'sav', 'sbs', 'sec', 'sdml', 'sgm', 'sgml', 'smi', 'smil', 'srt', 'sps', 'spv', 'stl', 'svg', 'swa', 'swf', 'swz', 'tar', 'tex', 'texi', 'texinfo', 'text', 'tgz', 'tif', 'tiff', 'ttf', 'txt', 'tmp', 'uvproj', 'vdf', 'vimeo', 'viv', 'vivo', 'vrml', 'vsdx', 'wav', 'webm', 'wmv', 'wmx', 'wmz', 'woff', 'wwd', 'xhtml', 'xif', 'xls', 'xlsx', 'xmind', 'xml', 'xsl', 'xsd', 'zip']
global $DIC
Definition: feed.php:28
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
if($DIC->http() ->request() ->getMethod()=="GET" &&isset($DIC->http() ->request() ->getQueryParams()['tex'])) $tpl
Definition: latex.php:41
$ref_id
Definition: ltiauth.php:67
$i
Definition: metadata.php:41
__construct(Container $dic, ilPlugin $plugin)
@inheritDoc
string $key
Consumer key/client ID value.
Definition: System.php:193
$type
$_SERVER['HTTP_HOST']
Definition: raiseError.php:10
$ilErr
Definition: raiseError.php:17
$lng