ILIAS  trunk Revision v11.0_alpha-3011-gc6b235a2e85
class.ilConditionSelector.php
Go to the documentation of this file.
1<?php
2
19declare(strict_types=1);
20
26{
27 protected ?int $highlighted_parent = null;
28 protected ?int $ref_id = null;
29
33 public function __construct(
34 $a_parent_obj,
35 string $a_parent_cmd,
36 $a_selection_gui = null,
37 string $a_selection_cmd = 'addConditionTrigger',
38 string $a_selection_par = "source_id"
39 ) {
41 $a_parent_obj,
42 $a_parent_cmd,
43 $a_selection_gui,
44 $a_selection_cmd,
45 $a_selection_par
46 );
47
48 $this->setAjax(true);
49 }
50
54 public function isNodeVisible($a_node): bool
55 {
56 global $DIC;
57
58 $ilAccess = $DIC['ilAccess'];
59 $tree = $DIC['tree'];
60
61 if (!$ilAccess->checkAccess('read', '', (int) $a_node["child"])) {
62 return false;
63 }
64 //remove childs of target object
65 if ($tree->getParentId((int) $a_node["child"]) === $this->getRefId()) {
66 return false;
67 }
68
69 return true;
70 }
71
75 public function isNodeClickable($a_node): bool
76 {
77 if (!parent::isNodeClickable($a_node)) {
78 return false;
79 }
80
81 if ($a_node["child"] == $this->getRefId()) {
82 return false;
83 }
84
85 return true;
86 }
87
88 public function setRefId(int $a_ref_id): void
89 {
90 $this->ref_id = $a_ref_id;
91
92 //can target object be highlighted?
93 $target_type = ilObject::_lookupType($a_ref_id, true);
94
95 if (!in_array($target_type, $this->getTypeWhiteList(), true)) {
96 $this->highlighted_parent = $this->tree->getParentId($a_ref_id);
97 }
98 }
99
100 public function getRefId(): ?int
101 {
102 return $this->ref_id;
103 }
104
108 public function isNodeHighlighted($a_node): bool
109 {
110 //highlight parent if target object cant be highlighted
111 if ($this->highlighted_parent == $a_node["child"]) {
112 return true;
113 }
114
115 return parent::isNodeHighlighted($a_node);
116 }
117}
isNodeHighlighted($a_node)
@inheritDoc
__construct( $a_parent_obj, string $a_parent_cmd, $a_selection_gui=null, string $a_selection_cmd='addConditionTrigger', string $a_selection_par="source_id")
@inheritDoc
isNodeVisible($a_node)
@inheritDoc
isNodeClickable($a_node)
@inheritDoc
static _lookupType(int $id, bool $reference=false)
Explorer for selecting repository items.
getTypeWhiteList()
Get type white list.
getParentId(int $a_node_id)
get parent id of given node
__construct(Container $dic, ilPlugin $plugin)
@inheritDoc
global $DIC
Definition: shib_login.php:26