ILIAS  release_7 Revision v7.30-3-g800a261c036
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 , self::BULLETLIST
91 , self::NUMBEREDLIST
92 , self::LISTINDENT
93 , self::LISTOUTDENT
94 , self::FILTER
95 );
96
97
102 public function __construct($type, $aria_label, $action = null)
103 {
104 $this->checkArgIsElement("type", $type, self::$types, "glyph type");
105 $this->checkStringArg("string", $aria_label);
106
107 if ($action !== null) {
108 $this->checkStringArg("action", $action);
109 }
110 $this->type = $type;
111 $this->aria_label = $aria_label;
112 $this->action = $action;
113 $this->counters = array();
114 $this->highlighted = false;
115 }
116
120 public function getType()
121 {
122 return $this->type;
123 }
127 public function getAriaLabel()
128 {
129 return $this->aria_label;
130 }
131
135 public function getAction()
136 {
137 return $this->action;
138 }
139
143 public function getCounters()
144 {
145 return array_values($this->counters);
146 }
147
151 public function withCounter(Counter $counter)
152 {
153 $clone = clone $this;
154 $clone->counters[$counter->getType()] = $counter;
155 return $clone;
156 }
157
161 public function isHighlighted()
162 {
163 return $this->highlighted;
164 }
165
169 public function withHighlight()
170 {
171 $clone = clone $this;
172 $clone->highlighted = true;
173 return $clone;
174 }
175
179 public function isActive()
180 {
181 return $this->active;
182 }
183
187 public function withUnavailableAction()
188 {
189 $clone = clone $this;
190 $clone->active = false;
191 return $clone;
192 }
193
194
198 public function withOnClick(Signal $signal)
199 {
200 return $this->withTriggeredSignal($signal, 'click');
201 }
202
206 public function appendOnClick(Signal $signal)
207 {
208 return $this->appendTriggeredSignal($signal, 'click');
209 }
210
214 public function withAction($action)
215 {
216 $clone = clone $this;
217 $clone->action = $action;
218 return $clone;
219 }
220}
An exception for terminatinating execution or to throw for unit testing.
__construct($type, $aria_label, $action=null)
Definition: Glyph.php:102
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.