19 declare(strict_types=1);
21 require_once(__DIR__ .
"/../../../../../../../vendor/composer/vendor/autoload.php");
22 require_once(__DIR__ .
"/../../../Base.php");
23 require_once(__DIR__ .
"/InputTest.php");
24 require_once(__DIR__ .
"/CommonFieldRendering.php");
70 $html = str_replace(
" />",
"/>", $html);
71 return parent::brutallyTrimHTML($html);
84 public function getFileIdentifierParameterName():
string 89 public function getUploadURL():
string 94 public function getFileRemovalURL():
string 102 public function getExistingFileInfoURL():
string 110 public function getInfoForExistingFiles(array $file_ids): array
115 public function getInfoResult(
string $identifier): ?
FileInfoResult 117 if (
null !== $this->file && $identifier === $this->file->getFileIdentifier()) {
124 public function supportsChunkedUploads():
bool 134 $f = $this->getFieldFactory();
136 $text =
$f->file($this->getUploadHandler(),
"label",
"byline");
138 $this->assertInstanceOf(\
ILIAS\
UI\
Component\Input\Container\Form\FormInput::class, $text);
139 $this->assertInstanceOf(Field\File::class, $text);
145 $f = $this->getFieldFactory();
148 $file_input =
$f->file($this->getUploadHandler(), $label, $byline)->withNameFrom($this->name_source);
150 $expected = $this->getFormWrappedHtml(
154 <div class="ui-input-file"> 155 <div class="ui-input-file-input-list"> 157 <div class="ui-input-file-input"> 158 <div class="ui-input-file-info"><span data-action="expand"></span><span 159 data-action="collapse"></span><span data-dz-name></span><span data-dz-size></span><span 160 data-action="remove"><a tabindex="0" class="glyph" href="#" aria-label="close"><span 161 class="glyphicon glyphicon-remove" aria-hidden="true"></span></a></span><span 162 class="ui-input-file-input-error-msg" data-dz-error-msg></span></div> 163 <div class="ui-input-file-metadata" style="display: none;"><input id="id_1" type="hidden" 164 name="name_0[input_0][]" value="" /></div> 165 <div class="ui-input-file-input-progress-container"> 166 <div class="ui-input-file-input-progress-indicator"></div> 171 <div class="ui-input-file-input-dropzone"> 172 <button class="btn btn-link" data-action="#" id="id_2">select_files_from_computer</button> 173 <span class="ui-input-file-input-error-msg" data-dz-error-msg></span> 175 <div class="help-block"> file_notice 0 B | ui_file_upload_max_nr 1</div> 182 $this->assertEquals($expected, $this->render($file_input));
187 $f = $this->getFieldFactory();
188 $file_input =
$f->file($this->getUploadHandler(),
'label',
null)
189 ->withNameFrom($this->name_source);
190 $this->testWithError($file_input);
191 $this->testWithNoByline($file_input);
192 $this->testWithRequired($file_input);
193 $this->testWithDisabled($file_input);
194 $this->testWithAdditionalOnloadCodeRendersId($file_input);
199 $test_file_id =
"test_file_id_1";
200 $test_file_name =
"test file name 1";
202 $test_file_info = $this->createMock(FileInfoResult::class);
203 $test_file_info->method(
'getFileIdentifier')->willReturn(
"test_file_id_1");
204 $test_file_info->method(
'getName')->willReturn(
"test file name 1");
205 $test_file_info->method(
'getSize')->willReturn(1001);
207 $file_input = $this->getFieldFactory()->file(
208 $this->getUploadHandler($test_file_info),
212 ])->withNameFrom($this->name_source);
214 $expected = $this->getFormWrappedHtml(
218 <div class="ui-input-file"> 219 <div class="ui-input-file-input-list"> 220 <div class="ui-input-file-input"> 221 <div class="ui-input-file-info"> 222 <span data-action="expand"></span> 223 <span data-action="collapse"></span> 224 <span data-dz-name>test file name 1</span> 225 <span data-dz-size>1 KB</span> 226 <span data-action="remove"> 227 <a tabindex="0" class="glyph" href="#" aria-label="close"> 228 <span class="glyphicon glyphicon-remove" aria-hidden="true"></span> 231 <span class="ui-input-file-input-error-msg" data-dz-error-msg></span> 233 <div class="ui-input-file-metadata" style="display: none;"> 234 <input id="id_1" type="hidden" name="name_0[input_0][]" value="test_file_id_1"/> 236 <div class="ui-input-file-input-progress-container"> 237 <div class="ui-input-file-input-progress-indicator"></div> 241 <div class="ui-input-file-input"> 242 <div class="ui-input-file-info"><span data-action="expand"></span><span 243 data-action="collapse"></span><span data-dz-name></span><span data-dz-size></span><span 244 data-action="remove"><a tabindex="0" class="glyph" href="#" aria-label="close"><span 245 class="glyphicon glyphicon-remove" aria-hidden="true"></span></a></span><span 246 class="ui-input-file-input-error-msg" data-dz-error-msg></span></div> 247 <div class="ui-input-file-metadata" style="display: none;"><input id="id_2" type="hidden" 248 name="name_0[input_0][]" value="" /></div> 249 <div class="ui-input-file-input-progress-container"> 250 <div class="ui-input-file-input-progress-indicator"></div> 255 <div class="ui-input-file-input-dropzone"> 256 <button class="btn btn-link" data-action="#" id="id_3">select_files_from_computer</button> 257 <span class="ui-input-file-input-error-msg" data-dz-error-msg></span> 259 <div class="help-block"> file_notice 0 B | ui_file_upload_max_nr 1</div> 266 $this->assertEquals($expected, $this->render($file_input));
272 $factory = $this->getFieldFactory();
273 $label =
'file_input';
274 $metadata_input = $factory->text(
"text_input");
275 $file_input = $factory->file(
276 ($u = $this->getUploadHandler()),
282 $u->getFileIdentifierParameterName() =>
"file_id",
287 $expected = $this->getFormWrappedHtml(
291 <div class="ui-input-file"> 292 <div class="ui-input-file-input-list"> 293 <div class="ui-input-file-input"> 294 <div class="ui-input-file-info"> 295 <span data-action="expand"> 296 <a tabindex="0" class="glyph" href="#" aria-label="expand_content"> 297 <span class="glyphicon glyphicon-triangle-right" aria-hidden="true"></span> 300 <span data-action="collapse"> 301 <a tabindex="0" class="glyph" href="#" aria-label="collapse_content"> 302 <span class="glyphicon glyphicon-triangle-bottom" aria-hidden="true"></span> 305 <span data-dz-name></span> 306 <span data-dz-size></span> 307 <span data-action="remove"> 308 <a tabindex="0" class="glyph" href="#" aria-label="close"> 309 <span class="glyphicon glyphicon-remove" aria-hidden="true"></span> 312 <span class="ui-input-file-input-error-msg" data-dz-error-msg></span> 314 <div class="ui-input-file-metadata" style="display: none;"> 315 <fieldset class="c-input" data-il-ui-component="text-field-input" data-il-ui-input-name="name_0[input_1][]"> 316 <label for="id_1">text_input</label> 317 <div class="c-input__field"> 318 <input id="id_1" type="text" name="name_0[input_1][]" class="c-field-text"/> 321 <input id="id_2" type="hidden" name="name_0[input_2][]" value="file_id"/> 323 <div class="ui-input-file-input-progress-container"> 324 <div class="ui-input-file-input-progress-indicator"></div> 328 <div class="ui-input-file-input"> 329 <div class="ui-input-file-info"><span data-action="expand"><a tabindex="0" class="glyph" 330 href="#" aria-label="expand_content"><span 331 class="glyphicon glyphicon-triangle-right" 332 aria-hidden="true"></span></a></span><span data-action="collapse"><a 333 tabindex="0" class="glyph" href="#" aria-label="collapse_content"><span 334 class="glyphicon glyphicon-triangle-bottom" 335 aria-hidden="true"></span></a></span><span data-dz-name></span><span 336 data-dz-size></span><span data-action="remove"><a tabindex="0" class="glyph" href="#" 337 aria-label="close"><span class="glyphicon glyphicon-remove" 338 aria-hidden="true"></span></a></span><span class="ui-input-file-input-error-msg" 339 data-dz-error-msg></span></div> 340 <div class="ui-input-file-metadata" style="display: none;"> 341 <fieldset class="c-input" data-il-ui-component="text-field-input" 342 data-il-ui-input-name="name_0[input_1][]"><label for="id_3">text_input</label> 343 <div class="c-input__field"><input id="id_3" type="text" name="name_0[input_1][]" 344 class="c-field-text" /></div> 345 </fieldset><input id="id_4" type="hidden" name="name_0[input_2][]" value="" /> 347 <div class="ui-input-file-input-progress-container"> 348 <div class="ui-input-file-input-progress-indicator"></div> 353 <div class="ui-input-file-input-dropzone"> 354 <button class="btn btn-link" data-action="#" id="id_5">select_files_from_computer</button> 355 <span class="ui-input-file-input-error-msg" data-dz-error-msg></span> 357 <div class="help-block"> file_notice 0 B | ui_file_upload_max_nr 1</div> 364 $this->assertEquals($expected, $this->render($file_input));
370 $test_file_id =
"test_file_id_1";
371 $test_file_name =
"test file name 1";
373 $test_file_info = $this->createMock(FileInfoResult::class);
374 $test_file_info->method(
'getFileIdentifier')->willReturn(
"test_file_id_1");
375 $test_file_info->method(
'getName')->willReturn(
"test file name 1");
376 $test_file_info->method(
'getSize')->willReturn(1000 * 1000 + 1);
378 $factory = $this->getFieldFactory();
379 $label =
'file_input';
380 $metadata_input = $factory->text(
"text_input");
381 $file_input = $factory->file(
382 $u = $this->getUploadHandler($test_file_info),
388 $u->getFileIdentifierParameterName() => $test_file_id,
394 $expected = $this->getFormWrappedHtml(
398 <div class="ui-input-file"> 399 <div class="ui-input-file-input-list"> 400 <div class="ui-input-file-input"> 401 <div class="ui-input-file-info"> 402 <span data-action="expand"> 403 <a tabindex="0" class="glyph" href="#" aria-label="expand_content"> 404 <span class="glyphicon glyphicon-triangle-right" aria-hidden="true"></span> 407 <span data-action="collapse"> 408 <a tabindex="0" class="glyph" href="#" aria-label="collapse_content"> 409 <span class="glyphicon glyphicon-triangle-bottom" aria-hidden="true"></span> 412 <span data-dz-name>test file name 1</span> 413 <span data-dz-size>1 MB</span> 414 <span data-action="remove"> 415 <a tabindex="0" class="glyph" href="#" aria-label="close"> 416 <span class="glyphicon glyphicon-remove" aria-hidden="true"></span> 419 <span class="ui-input-file-input-error-msg" data-dz-error-msg></span> 421 <div class="ui-input-file-metadata" style="display: none;"> 422 <fieldset class="c-input" data-il-ui-component="text-field-input" data-il-ui-input-name="name_0[input_1][]"> 423 <label for="id_1">text_input</label> 424 <div class="c-input__field"> 425 <input id="id_1" type="text" value="test" name="name_0[input_1][]" class="c-field-text"/> 428 <input id="id_2" type="hidden" name="name_0[input_2][]" value="test_file_id_1"/> 430 <div class="ui-input-file-input-progress-container"> 431 <div class="ui-input-file-input-progress-indicator"></div> 435 <div class="ui-input-file-input"> 436 <div class="ui-input-file-info"> 437 <span data-action="expand"> 438 <a tabindex="0" class="glyph" href="#" aria-label="expand_content"> 439 <span class="glyphicon glyphicon-triangle-right" aria-hidden="true"></span> 442 <span data-action="collapse"> 443 <a tabindex="0" class="glyph" href="#" aria-label="collapse_content"> 444 <span class="glyphicon glyphicon-triangle-bottom" aria-hidden="true"></span> 447 <span data-dz-name></span> 448 <span data-dz-size></span> 450 data-action="remove"><a tabindex="0" class="glyph" href="#" aria-label="close"><span 451 class="glyphicon glyphicon-remove" aria-hidden="true"></span></a></span><span 452 class="ui-input-file-input-error-msg" data-dz-error-msg></span></div> 453 <div class="ui-input-file-metadata" style="display: none;"> 454 <fieldset class="c-input" data-il-ui-component="text-field-input" 455 data-il-ui-input-name="name_0[input_1][]"><label for="id_3">text_input</label> 456 <div class="c-input__field"><input id="id_3" type="text" name="name_0[input_1][]" 457 class="c-field-text" /></div> 458 </fieldset><input id="id_4" type="hidden" name="name_0[input_2][]" value="" /> 460 <div class="ui-input-file-input-progress-container"> 461 <div class="ui-input-file-input-progress-indicator"></div> 466 <div class="ui-input-file-input-dropzone"> 467 <button class="btn btn-link" data-action="#" id="id_5">select_files_from_computer</button> 468 <span class="ui-input-file-input-error-msg" data-dz-error-msg></span> 470 <div class="help-block"> file_notice 0 B | ui_file_upload_max_nr 1</div> 477 $this->assertEquals($expected, $this->render($file_input));
482 return new I\Button\Factory();
487 return new I\Symbol\Factory(
497 $this->buildButtonFactory(),
498 $this->buildSymbolFactory()
Interface Observer Contains several chained tasks and infos about them.
while($session_entry=$r->fetchRow(ilDBConstants::FETCHMODE_ASSOC)) return null
Interface FileInfoResult.