ILIAS  release_8 Revision v8.23
File.php
Go to the documentation of this file.
1 <?php
2 
18 declare(strict_types=1);
19 
21 
29 use ILIAS\UI\Component\Dropzone\File\File as FileDropzone;
36 
40 abstract class File implements FileDropzone
41 {
43  use ComponentHelper;
44  use Triggerer;
45 
47  protected Signal $clear_signal;
48  protected RoundTrip $modal;
49 
50  public function __construct(
51  SignalGeneratorInterface $signal_generator,
52  FieldFactory $field_factory,
53  NameSource $name_source,
54  string $title,
55  string $post_url,
56  FileInput $file_input,
57  ?FormInput $additional_input
58  ) {
59  $this->signal_generator = $signal_generator;
60  $this->clear_signal = $signal_generator->create();
61 
62  if (null !== $additional_input) {
63  $inputs = [$file_input, $additional_input];
64  } else {
65  $inputs = [$file_input];
66  }
67 
68  $this->modal = new RoundTrip(
69  $signal_generator,
70  $field_factory,
71  $name_source,
72  $title,
73  null,
74  $inputs,
75  $post_url
76  );
77  }
78 
79  public function getModal(): RoundTrip
80  {
81  return $this->modal;
82  }
83 
84  public function getClearSignal(): Signal
85  {
86  return $this->clear_signal;
87  }
88 
89  public function getTitle(): string
90  {
91  return $this->modal->getTitle();
92  }
93 
94  public function withOnClose(Signal $signal): self
95  {
96  $clone = clone $this;
98  $clone->modal = $clone->modal->withOnClose($signal);
99  return $clone;
100  }
101 
102  public function appendOnClose(Signal $signal): self
103  {
104  $clone = clone $this;
106  $clone->modal = $clone->modal->appendOnClose($signal);
107  return $clone;
108  }
109 
110  public function getAsyncRenderUrl(): string
111  {
112  return $this->modal->getAsyncRenderUrl();
113  }
114 
115  public function withAsyncRenderUrl(string $url)
116  {
117  $clone = clone $this;
118  $clone->modal = $clone->modal->withAsyncRenderUrl($url);
119  return $clone;
120  }
121 
122  public function withCloseWithKeyboard(bool $state): self
123  {
124  $clone = clone $this;
125  $clone->modal = $clone->modal->withCloseWithKeyboard($state);
126  return $clone;
127  }
128 
129  public function getCloseWithKeyboard(): bool
130  {
131  return $this->modal->getCloseWithKeyboard();
132  }
133 
134  public function getShowSignal(): Signal
135  {
136  return $this->modal->getShowSignal();
137  }
138 
139  public function getCloseSignal(): Signal
140  {
141  return $this->modal->getCloseSignal();
142  }
143 
144  public function withOnLoad(Signal $signal)
145  {
146  $clone = clone $this;
147  $clone->modal = $clone->modal->withOnLoad($signal);
148  return $clone;
149  }
150 
151  public function appendOnLoad(Signal $signal)
152  {
153  $clone = clone $this;
154  $clone->modal = $clone->modal->appendOnLoad($signal);
155  return $clone;
156  }
157 
158  public function getContent(): array
159  {
160  return $this->modal->getContent();
161  }
162 
163  public function getActionButtons(): array
164  {
165  return $this->modal->getActionButtons();
166  }
167 
168  public function getCancelButtonLabel(): string
169  {
170  return $this->modal->getCancelButtonLabel();
171  }
172 
173  public function withActionButtons(array $buttons): self
174  {
175  $clone = clone $this;
176  $clone->modal = $clone->modal->withActionButtons($buttons);
177  return $clone;
178  }
179 
180  public function withCancelButtonLabel(string $label): self
181  {
182  $clone = clone $this;
183  $clone->modal = $clone->modal->withCancelButtonLabel($label);
184  return $clone;
185  }
186 
187  public function getReplaceSignal(): ReplaceSignal
188  {
189  return $this->modal->getReplaceSignal();
190  }
191 
192  public function getPostURL(): string
193  {
194  return $this->modal->getPostURL();
195  }
196 
197  public function withSubmitCaption(string $caption): self
198  {
199  $clone = clone $this;
200  $clone->modal = $clone->modal->withSubmitCaption($caption);
201  return $clone;
202  }
203 
204  public function getSubmitCaption(): ?string
205  {
206  return $this->modal->getSubmitCaption();
207  }
208 
209  public function getInputs(): array
210  {
211  return $this->modal->getInputs();
212  }
213 
214  public function withRequest(ServerRequestInterface $request): self
215  {
216  $clone = clone $this;
217  $clone->modal = $clone->modal->withRequest($request);
218  return $clone;
219  }
220 
221  public function withAdditionalTransformation(Transformation $trafo): self
222  {
223  $clone = clone $this;
224  $clone->modal = $clone->modal->withAdditionalTransformation($trafo);
225  return $clone;
226  }
227 
228  public function getData()
229  {
230  return $this->modal->getData();
231  }
232 
233  public function getError(): ?string
234  {
235  return $this->modal->getError();
236  }
237 
238  public function withOnDrop(Signal $signal): self
239  {
240  return $this->withTriggeredSignal($signal, 'drop');
241  }
242 
243  public function withAdditionalDrop(Signal $signal): self
244  {
245  return $this->appendTriggeredSignal($signal, 'drop');
246  }
247 
248  public function withResetSignals(): self
249  {
250  $clone = clone $this;
251  $clone->initSignals();
252  return $clone;
253  }
254 
255  public function initSignals(): void
256  {
257  $this->clear_signal = $this->signal_generator->create();
258  $this->modal->initSignals();
259  }
260 
264  public function withDedicatedName(string $dedicated_name): self
265  {
266  return $this;
267  }
268 }
This is what a factory for input fields looks like.
Definition: Factory.php:28
withCloseWithKeyboard(bool $state)
Get a modal like this which can or cannot be closed by keyboard (ESC), depending on the given $state...
Definition: File.php:122
appendTriggeredSignal(C\Signal $signal, string $event)
Append a triggered signal to other signals of the same event.
Definition: Triggerer.php:47
withOnDrop(Signal $signal)
Get a component like this, triggering a signal of another component when files have been dropped...
Definition: File.php:238
getShowSignal()
Get the signal to show this modal in the frontend.
Definition: File.php:134
getCancelButtonLabel()
Get the label of the cancel button in the footer, as language key.
Definition: File.php:168
withTriggeredSignal(C\Signal $signal, string $event)
Add a triggered signal, replacing any other signals registered on the same event. ...
Definition: Triggerer.php:62
withCancelButtonLabel(string $label)
Get the modal like this with the provided cancel button string.
Definition: File.php:180
initSignals()
Init the default signals plus extra signals like Replace.
Definition: File.php:255
withRequest(ServerRequestInterface $request)
Definition: File.php:214
trait JavaScriptBindable
Trait for components implementing JavaScriptBindable providing standard implementation.
getClearSignal()
Returns a signal that can be used to clear the current file queue.
Definition: File.php:84
getReplaceSignal()
Get the signal to replace the content of this modal.
Definition: File.php:187
modal()
This second example shows a scenario in which the Close Button is used in an overlay as indicated in ...
Definition: modal.php:12
getContent()
Get the components representing the content of the modal.
Definition: File.php:158
withAdditionalDrop(Signal $signal)
Get a component like this, triggering a signal of another component when files have been dropped...
Definition: File.php:243
appendOnLoad(Signal $signal)
Get a component like this, triggering a signal of another component on load.
Definition: File.php:151
withOnLoad(Signal $signal)
Trigger a signal of another component on load.
Definition: File.php:144
getAsyncRenderUrl()
Get the url returning the rendered modal, if the modals content should be rendered via ajax...
Definition: File.php:110
getCloseSignal()
Get the signal to close this modal in the frontend.
Definition: File.php:139
withOnClose(Signal $signal)
Get a component like this, triggering a signal of another component on close.
Definition: File.php:94
withAdditionalTransformation(Transformation $trafo)
Definition: File.php:221
This signal replaces a component by ajax.
SignalGeneratorInterface $signal_generator
Definition: File.php:46
getTitle()
Get the custom title if set.
Definition: File.php:89
create(string $class='')
Create a signal, each created signal MUST have a unique ID.
getActionButtons()
Get all action buttons in the footer of the modal.
Definition: File.php:163
A transformation is a function from one datatype to another.
__construct(SignalGeneratorInterface $signal_generator, FieldFactory $field_factory, NameSource $name_source, string $title, string $post_url, FileInput $file_input, ?FormInput $additional_input)
Definition: File.php:50
withResetSignals()
Get a component like this but reset (regenerate) its signals.
Definition: File.php:248
withActionButtons(array $buttons)
Get a modal like this with the provided action buttons in the footer.
Definition: File.php:173
$url
This describes inputs that can be used in forms.
Definition: FormInput.php:31
Describes a source for input names.
Definition: NameSource.php:26
appendOnClose(Signal $signal)
Get a component like this, triggering a signal of another component on close.
Definition: File.php:102
getCloseWithKeyboard()
Returns if this modal can be closed with the keyboard (ESC key)
Definition: File.php:129
withAsyncRenderUrl(string $url)
Get a modal like this who&#39;s content is rendered via ajax by the given $url before the modal is shown...
Definition: File.php:115
withDedicatedName(string $dedicated_name)
No dedicated name can be set for this subform.
Definition: File.php:264