ILIAS  release_8 Revision v8.24
Glyph.php
Go to the documentation of this file.
1<?php
2
19declare(strict_types=1);
20
22
26use ILIAS\UI\Implementation\Component\ComponentHelper;
29
31{
32 use ComponentHelper;
34 use Triggerer;
35
36 private static array $types = [
37 self::SETTINGS,
38 self::COLLAPSE,
39 self::COLLAPSE_HORIZONTAL,
40 self::EXPAND,
41 self::ADD,
42 self::REMOVE,
43 self::UP,
44 self::DOWN,
45 self::BACK,
46 self::NEXT,
47 self::SORT_ASCENDING,
48 self::SORT_DESCENDING,
49 self::USER,
50 self::MAIL,
51 self::NOTIFICATION,
52 self::TAG,
53 self::NOTE,
54 self::COMMENT,
55 self::BRIEFCASE,
56 self::LIKE,
57 self::LOVE,
58 self::DISLIKE,
59 self::LAUGH,
60 self::ASTOUNDED,
61 self::SAD,
62 self::ANGRY,
63 self::EYEOPEN,
64 self::EYECLOSED,
65 self::ATTACHMENT,
66 self::RESET,
67 self::APPLY,
68 self::SEARCH,
69 self::HELP,
70 self::CALENDAR,
71 self::TIME,
72 self::CLOSE,
73 self::MORE,
74 self::DISCLOSURE,
75 self::LANGUAGE,
76 self::LOGIN,
77 self::LOGOUT,
78 self::BULLETLIST,
79 self::NUMBEREDLIST,
80 self::LISTINDENT,
81 self::LISTOUTDENT,
82 self::FILTER
83 ];
84
85 private string $type;
86 private ?string $action;
87 private string $label;
88 private array $counters;
89 private bool $highlighted;
90 private bool $active = true;
91
92 public function __construct(string $type, string $label, string $action = null)
93 {
94 $this->checkArgIsElement("type", $type, self::$types, "glyph type");
95
96 $this->type = $type;
97 $this->label = $label;
98 $this->action = $action;
99 $this->counters = array();
100 $this->highlighted = false;
101 }
102
106 public function getType(): string
107 {
108 return $this->type;
109 }
110
114 public function getLabel(): string
115 {
116 return $this->label;
117 }
118
122 public function getAction(): ?string
123 {
124 return $this->action;
125 }
126
130 public function getCounters(): array
131 {
132 return array_values($this->counters);
133 }
134
138 public function withCounter(Counter $counter): C\Symbol\Glyph\Glyph
139 {
140 $clone = clone $this;
141 $clone->counters[$counter->getType()] = $counter;
142 return $clone;
143 }
144
148 public function isHighlighted(): bool
149 {
150 return $this->highlighted;
151 }
152
156 public function withHighlight(): C\Symbol\Glyph\Glyph
157 {
158 $clone = clone $this;
159 $clone->highlighted = true;
160 return $clone;
161 }
162
166 public function isActive(): bool
167 {
168 return $this->active;
169 }
170
174 public function withUnavailableAction(): C\Symbol\Glyph\Glyph
175 {
176 $clone = clone $this;
177 $clone->active = false;
178 return $clone;
179 }
180
184 public function withOnClick(Signal $signal): C\Clickable
185 {
186 return $this->withTriggeredSignal($signal, 'click');
187 }
188
192 public function appendOnClick(Signal $signal): C\Clickable
193 {
194 return $this->appendTriggeredSignal($signal, 'click');
195 }
196
200 public function withAction($action): C\Symbol\Glyph\Glyph
201 {
202 $clone = clone $this;
203 $clone->action = $action;
204 return $clone;
205 }
206
210 public function isTabbable(): bool
211 {
212 $has_action = ($this->action !== null && $this->action !== "");
213 $has_signal = isset($this->triggered_signals['click']) && $this->triggered_signals['click'] !== null;
214 return ($has_signal || $has_action) && $this->isActive();
215 }
216}
__construct(string $type, string $label, string $action=null)
Definition: Glyph.php:92
This tags a counter object.
Definition: Counter.php:29
getType()
Get the type of the counter.
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
appendTriggeredSignal(C\Signal $signal, string $event)
Append a triggered signal to other signals of the same event.
Definition: Triggerer.php:47
withTriggeredSignal(C\Signal $signal, string $event)
Add a triggered signal, replacing any other signals registered on the same event.
Definition: Triggerer.php:62
trait JavaScriptBindable
Trait for components implementing JavaScriptBindable providing standard implementation.