ILIAS  trunk Revision v11.0_alpha-1715-g7fc467680fb
All Data Structures Namespaces Files Functions Variables Enumerations Enumerator Modules Pages
Slate.php
Go to the documentation of this file.
1 <?php
2 
19 declare(strict_types=1);
20 
22 
33 
34 abstract class Slate implements ISlate\Slate
35 {
36  use ComponentHelper;
38  use Triggerer;
39  use HasHelpTopics;
40 
41  // allowed ARIA roles
42  public const MENU = 'menu';
43 
47  protected static array $allowed_aria_roles = array(
48  self::MENU
49  );
50 
51  protected string $name;
52  protected Symbol $symbol;
55  protected ?Signal $replace_signal = null;
56  protected bool $engaged = false;
57  protected ?string $mainbar_tree_position = null;
58  protected ?string $aria_role = null;
60 
64  public function __construct(
65  SignalGeneratorInterface $signal_generator,
66  string $name,
67  Symbol $symbol
68  ) {
69  $this->signal_generator = $signal_generator;
70  $this->name = $name;
71  $this->symbol = $symbol;
72 
73  $this->initSignals();
74  }
75 
79  protected function initSignals(): void
80  {
81  $this->toggle_signal = $this->signal_generator->create();
82  $this->engage_signal = $this->signal_generator->create();
83  $signal = $this->signal_generator->create(ReplaceSignalImplementation::class);
84  $this->replace_signal = $signal;
85  }
86 
90  public function getName(): string
91  {
92  return $this->name;
93  }
94 
98  public function getSymbol(): Symbol
99  {
100  return $this->symbol;
101  }
102 
106  public function getToggleSignal(): Signal
107  {
108  return $this->toggle_signal;
109  }
110 
114  public function getEngageSignal(): Signal
115  {
116  return $this->engage_signal;
117  }
118 
122  public function withEngaged(bool $state): ISlate\Slate
123  {
124  $clone = clone $this;
125  $clone->engaged = $state;
126  return $clone;
127  }
128 
132  public function getEngaged(): bool
133  {
134  return $this->engaged;
135  }
136 
140  abstract public function getContents(): array;
141 
145  public function getReplaceSignal(): ?Signal
146  {
147  return $this->replace_signal;
148  }
149 
153  public function appendOnInView(Signal $signal): ISlate\Slate
154  {
155  return $this->appendTriggeredSignal($signal, 'in_view');
156  }
157 
158 
159  abstract public function withMappedSubNodes(callable $f): ISlate\Slate;
160 
164  public function withMainBarTreePosition(string $tree_pos): ISlate\Slate
165  {
166  $clone = clone $this;
167  $clone->mainbar_tree_position = $tree_pos;
168  return $clone;
169  }
170 
171  public function getMainBarTreePosition(): ?string
172  {
174  }
175 
176  public function getMainBarTreeDepth(): int
177  {
178  $pos = explode(':', $this->mainbar_tree_position);
179  return count($pos) - 1;
180  }
181 
185  public function withAriaRole(string $aria_role): ISlate\Slate
186  {
187  $this->checkArgIsElement(
188  "role",
189  $aria_role,
190  self::$allowed_aria_roles,
191  implode('/', self::$allowed_aria_roles)
192  );
193  $clone = clone $this;
194  $clone->aria_role = $aria_role;
195  return $clone;
196  }
197 
201  public function getAriaRole(): ?string
202  {
203  return $this->aria_role;
204  }
205 }
appendTriggeredSignal(C\Signal $signal, string $event)
Append a triggered signal to other signals of the same event.
Definition: Triggerer.php:47
__construct(SignalGeneratorInterface $signal_generator, string $name, Symbol $symbol)
Definition: Slate.php:64
This describes a symbol.
Definition: Symbol.php:29
getReplaceSignal()
Signal to replace the contents of the slate.
Definition: Slate.php:145
trait JavaScriptBindable
Trait for components implementing JavaScriptBindable providing standard implementation.
withMainBarTreePosition(string $tree_pos)
Slates in the main bar need to be addressable via JS, a.o.for storing current activation states or tr...
Definition: Slate.php:164
getEngaged()
Should the slate be rendered as engaged?
Definition: Slate.php:132
while($session_entry=$r->fetchRow(ilDBConstants::FETCHMODE_ASSOC)) return null
withEngaged(bool $state)
Configures the slate to be rendered as engaged (or not).
Definition: Slate.php:122
initSignals()
Set the signals for this component.
Definition: Slate.php:79
appendOnInView(Signal $signal)
A Signal that is triggered when the slate "comes into view", i.e.is being engaged.
Definition: Slate.php:153
getAriaRole()
Get the ARIA role on the slate.
Definition: Slate.php:201
getEngageSignal()
Signal that engages the slate when triggered.
Definition: Slate.php:114
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
Definition: Combined.php:21
withAriaRole(string $aria_role)
Get a slate like this, but with an additional ARIA role.
Definition: Slate.php:185
getToggleSignal()
Signal that toggles the slate when triggered.
Definition: Slate.php:106