ILIAS  trunk Revision v11.0_alpha-3011-gc6b235a2e85
File.php
Go to the documentation of this file.
1<?php
2
19declare(strict_types=1);
20
22
25use ILIAS\UI\Implementation\Component\ComponentHelper;
34use Psr\Http\Message\ServerRequestInterface;
38
42abstract class File implements FileDropzone
43{
45 use ComponentHelper;
46 use Triggerer;
47
50 protected RoundTrip $modal;
51
52 public function __construct(
54 FieldFactory $field_factory,
55 NameSource $name_source,
56 string $title,
57 string $post_url,
58 FileInput $file_input,
59 ?FormInput $additional_input
60 ) {
61 $this->signal_generator = $signal_generator;
62 $this->clear_signal = $signal_generator->create();
63
64 if (null !== $additional_input) {
65 $inputs = [$file_input, $additional_input];
66 } else {
67 $inputs = [$file_input];
68 }
69
70 $this->modal = new RoundTrip(
72 $field_factory,
73 $name_source,
74 $title,
75 null,
76 $inputs,
77 $post_url
78 );
79 }
80
81 public function getModal(): RoundTrip
82 {
83 return $this->modal;
84 }
85
86 public function getClearSignal(): Signal
87 {
89 }
90
91 public function getTitle(): string
92 {
93 return $this->modal->getTitle();
94 }
95
96 public function withOnClose(Signal $signal): self
97 {
98 $clone = clone $this;
100 $clone->modal = $clone->modal->withOnClose($signal);
101 return $clone;
102 }
103
104 public function appendOnClose(Signal $signal): self
105 {
106 $clone = clone $this;
108 $clone->modal = $clone->modal->appendOnClose($signal);
109 return $clone;
110 }
111
112 public function getAsyncRenderUrl(): string
113 {
114 return $this->modal->getAsyncRenderUrl();
115 }
116
117 public function withAsyncRenderUrl(string $url)
118 {
119 $clone = clone $this;
120 $clone->modal = $clone->modal->withAsyncRenderUrl($url);
121 return $clone;
122 }
123
124 public function withCloseWithKeyboard(bool $state): self
125 {
126 $clone = clone $this;
127 $clone->modal = $clone->modal->withCloseWithKeyboard($state);
128 return $clone;
129 }
130
131 public function getCloseWithKeyboard(): bool
132 {
133 return $this->modal->getCloseWithKeyboard();
134 }
135
136 public function getShowSignal(): Signal
137 {
138 return $this->modal->getShowSignal();
139 }
140
141 public function getCloseSignal(): Signal
142 {
143 return $this->modal->getCloseSignal();
144 }
145
146 public function withOnLoad(Signal $signal)
147 {
148 $clone = clone $this;
149 $clone->modal = $clone->modal->withOnLoad($signal);
150 return $clone;
151 }
152
153 public function appendOnLoad(Signal $signal)
154 {
155 $clone = clone $this;
156 $clone->modal = $clone->modal->appendOnLoad($signal);
157 return $clone;
158 }
159
160 public function getContent(): array
161 {
162 return $this->modal->getContent();
163 }
164
165 public function getActionButtons(): array
166 {
167 return $this->modal->getActionButtons();
168 }
169
170 public function getCancelButtonLabel(): ?string
171 {
172 return $this->modal->getCancelButtonLabel();
173 }
174
175 public function withActionButtons(array $buttons): self
176 {
177 $clone = clone $this;
178 $clone->modal = $clone->modal->withActionButtons($buttons);
179 return $clone;
180 }
181
182 public function withCancelButtonLabel(string $label): self
183 {
184 $clone = clone $this;
185 $clone->modal = $clone->modal->withCancelButtonLabel($label);
186 return $clone;
187 }
188
190 {
191 return $this->modal->getReplaceSignal();
192 }
193
194 public function getPostURL(): string
195 {
196 return $this->modal->getPostURL();
197 }
198
199 public function withSubmitLabel(string $caption): self
200 {
201 $clone = clone $this;
202 $clone->modal = $clone->modal->withSubmitLabel($caption);
203 return $clone;
204 }
205
206 public function getSubmitLabel(): ?string
207 {
208 return $this->modal->getSubmitLabel();
209 }
210
211 public function getInputs(): array
212 {
213 return $this->modal->getInputs();
214 }
215
216 public function withRequest(ServerRequestInterface $request): self
217 {
218 $clone = clone $this;
219 $clone->modal = $clone->modal->withRequest($request);
220 return $clone;
221 }
222
223 public function withInput(InputData $input_data): self
224 {
225 $clone = clone $this;
226 $clone->modal = $clone->modal->withInput($request);
227 return $clone;
228 }
229
230 public function withAdditionalTransformation(Transformation $trafo): self
231 {
232 $clone = clone $this;
233 $clone->modal = $clone->modal->withAdditionalTransformation($trafo);
234 return $clone;
235 }
236
237 public function getData()
238 {
239 return $this->modal->getData();
240 }
241
242 public function getError(): ?string
243 {
244 return $this->modal->getError();
245 }
246
247 public function withOnDrop(Signal $signal): self
248 {
249 return $this->withTriggeredSignal($signal, 'drop');
250 }
251
252 public function withAdditionalDrop(Signal $signal): self
253 {
254 return $this->appendTriggeredSignal($signal, 'drop');
255 }
256
257 public function withResetSignals(): self
258 {
259 $clone = clone $this;
260 $clone->initSignals();
261 return $clone;
262 }
263
264 public function initSignals(): void
265 {
266 $this->clear_signal = $this->signal_generator->create();
267 $this->modal->initSignals();
268 }
269
273 public function withDedicatedName(string $dedicated_name): self
274 {
275 return $this;
276 }
277
281 public function getPromptButtons(): array
282 {
283 return $this->buttons;
284 }
285
289 public function getPromptTitle(): string
290 {
291 return $this->type;
292 }
293}
getAsyncRenderUrl()
Get the url returning the rendered modal, if the modals content should be rendered via ajax.
Definition: File.php:112
getTitle()
Get the custom title if set.
Definition: File.php:91
appendOnClose(Signal $signal)
Get a component like this, triggering a signal of another component on close.
Definition: File.php:104
initSignals()
Init the default signals plus extra signals like Replace.
Definition: File.php:264
getCancelButtonLabel()
Get the custom label of the cancel button in the footer.
Definition: File.php:170
getCloseWithKeyboard()
Returns if this modal can be closed with the keyboard (ESC key)
Definition: File.php:131
getClearSignal()
Returns a signal that can be used to clear the current file queue.
Definition: File.php:86
withRequest(ServerRequestInterface $request)
Definition: File.php:216
withDedicatedName(string $dedicated_name)
No dedicated name can be set for this subform.
Definition: File.php:273
withOnLoad(Signal $signal)
Trigger a signal of another component on load.
Definition: File.php:146
withCancelButtonLabel(string $label)
Get the modal like this with the provided cancel button string.
Definition: File.php:182
withActionButtons(array $buttons)
Get a modal like this with the provided action buttons in the footer.
Definition: File.php:175
getShowSignal()
Get the signal to show this modal in the frontend.
Definition: File.php:136
withAsyncRenderUrl(string $url)
Get a modal like this who's content is rendered via ajax by the given $url before the modal is shown.
Definition: File.php:117
withAdditionalTransformation(Transformation $trafo)
Definition: File.php:230
withAdditionalDrop(Signal $signal)
Get a component like this, triggering a signal of another component when files have been dropped.
Definition: File.php:252
withResetSignals()
Get a component like this but reset (regenerate) its signals.
Definition: File.php:257
getContent()
Get the components representing the content of the modal.
Definition: File.php:160
appendOnLoad(Signal $signal)
Get a component like this, triggering a signal of another component on load.
Definition: File.php:153
getCloseSignal()
Get the signal to close this modal in the frontend.
Definition: File.php:141
withOnClose(Signal $signal)
Get a component like this, triggering a signal of another component on close.
Definition: File.php:96
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:124
withOnDrop(Signal $signal)
Get a component like this, triggering a signal of another component when files have been dropped.
Definition: File.php:247
getReplaceSignal()
Get the signal to replace the content of this modal.
Definition: File.php:189
getActionButtons()
Get all action buttons in the footer of the modal.
Definition: File.php:165
__construct(SignalGeneratorInterface $signal_generator, FieldFactory $field_factory, NameSource $name_source, string $title, string $post_url, FileInput $file_input, ?FormInput $additional_input)
Definition: File.php:52
SignalGeneratorInterface $signal_generator
Definition: File.php:48
A transformation is a function from one datatype to another.
This describes inputs that can be used in forms.
Definition: FormInput.php:33
This is what a factory for input fields looks like.
Definition: Factory.php:31
This describes file field.
Definition: File.php:29
Describes how Input-Elements want to interact with posted data.
Definition: InputData.php:30
This signal replaces a component by ajax.
Describes a source for input names.
Definition: NameSource.php:27
create(string $class='')
Create a signal, each created signal MUST have a unique ID.
modal(string $title="", string $cancel_label="")
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.
$url
Definition: shib_logout.php:68