ILIAS  release_6 Revision v6.24-5-g0c8bfefb3b8
Glyph.php
Go to the documentation of this file.
1<?php
2
3/* Copyright (c) 2016 Richard Klees <richard.klees@concepts-and-training.de> Extended GPL, see docs/LICENSE */
4
6
13
15{
18 use Triggerer;
19
23 private $type;
24
28 private $action;
29
33 private $aria_label;
34
38 private $counters;
39
43 private $highlighted = false;
44
48 private $active = true;
49
50 private static $types = array(self::SETTINGS
51 , self::COLLAPSE
52 , self::EXPAND
53 , self::ADD
54 , self::REMOVE
55 , self::UP
56 , self::DOWN
57 , self::BACK
58 , self::NEXT
59 , self::SORT_ASCENDING
60 , self::SORT_DESCENDING
61 , self::USER
62 , self::MAIL
63 , self::NOTIFICATION
64 , self::TAG
65 , self::NOTE
66 , self::COMMENT
67 , self::BRIEFCASE
68 , self::LIKE
69 , self::LOVE
70 , self::DISLIKE
71 , self::LAUGH
72 , self::ASTOUNDED
73 , self::SAD
74 , self::ANGRY
75 , self::EYEOPEN
76 , self::EYECLOSED
77 , self::ATTACHMENT
78 , self::RESET
79 , self::APPLY
80 , self::SEARCH
81 , self::HELP
82 , self::CALENDAR
83 , self::TIME
84 , self::CLOSE
85 , self::MORE
86 , self::DISCLOSURE
87 , self::LANGUAGE
88 , self::LOGIN
89 , self::LOGOUT
90 );
91
92
97 public function __construct($type, $aria_label, $action = null)
98 {
99 $this->checkArgIsElement("type", $type, self::$types, "glyph type");
100 $this->checkStringArg("string", $aria_label);
101
102 if ($action !== null) {
103 $this->checkStringArg("action", $action);
104 }
105 $this->type = $type;
106 $this->aria_label = $aria_label;
107 $this->action = $action;
108 $this->counters = array();
109 $this->highlighted = false;
110 }
111
115 public function getType()
116 {
117 return $this->type;
118 }
122 public function getAriaLabel()
123 {
124 return $this->aria_label;
125 }
126
130 public function getAction()
131 {
132 return $this->action;
133 }
134
138 public function getCounters()
139 {
140 return array_values($this->counters);
141 }
142
146 public function withCounter(Counter $counter)
147 {
148 $clone = clone $this;
149 $clone->counters[$counter->getType()] = $counter;
150 return $clone;
151 }
152
156 public function isHighlighted()
157 {
158 return $this->highlighted;
159 }
160
164 public function withHighlight()
165 {
166 $clone = clone $this;
167 $clone->highlighted = true;
168 return $clone;
169 }
170
174 public function isActive()
175 {
176 return $this->active;
177 }
178
182 public function withUnavailableAction()
183 {
184 $clone = clone $this;
185 $clone->active = false;
186 return $clone;
187 }
188
189
193 public function withOnClick(Signal $signal)
194 {
195 return $this->withTriggeredSignal($signal, 'click');
196 }
197
201 public function appendOnClick(Signal $signal)
202 {
203 return $this->appendTriggeredSignal($signal, 'click');
204 }
205
209 public function withAction($action)
210 {
211 $clone = clone $this;
212 $clone->action = $action;
213 return $clone;
214 }
215}
An exception for terminatinating execution or to throw for unit testing.
__construct($type, $aria_label, $action=null)
Definition: Glyph.php:97
This tags a counter object.
Definition: Counter.php:11
getType()
Get the type of the counter.
withTriggeredSignal(Component\Signal $signal, $event)
Add a triggered signal, replacing any other signals registered on the same event.
Definition: Triggerer.php:48
checkStringArg($which, $value)
Throw an InvalidArgumentException if $value is no string.
appendTriggeredSignal(Component\Signal $signal, $event)
Append a triggered signal to other signals of the same event.
Definition: Triggerer.php:31
trait JavaScriptBindable
Trait for components implementing JavaScriptBindable providing standard implementation.
trait ComponentHelper
Provides common functionality for component implementations.
checkArgIsElement($which, $value, $array, $name)
Throw an InvalidArgumentException if $value is not an element of array.