ILIAS  trunk Revision v11.0_alpha-3011-gc6b235a2e85
class.ilFileVersionsGUI.php
Go to the documentation of this file.
1<?php
2
29use ILIAS\Refinery\Factory as Refinery;
38
44{
46
47 public const KEY_FILE_RID = 'file_rid';
48 public const KEY_FILE_EXTRACT = 'file_extract';
49 public const KEY_FILE_STRUCTURE = 'file_structure';
50 public const KEY_COPYRIGHT_OPTION = "copyright_option";
51 public const KEY_INHERIT_COPYRIGHT = "inherit_copyright";
52 public const KEY_SELECT_COPYRIGHT = "select_copyright";
53 public const KEY_COPYRIGHT_ID = "copyright_id";
54
55 public const CMD_DEFAULT = 'index';
56 public const CMD_DELETE_VERSIONS = "deleteVersions";
57 public const CMD_ROLLBACK_VERSION = "rollbackVersion";
58 public const CMD_DOWNLOAD_VERSION = "sendFile";
59 public const HIST_ID = 'hist_id';
60 public const CMD_CANCEL_DELETE = "cancelDeleteFile";
61 public const CMD_CONFIRMED_DELETE_FILE = "confirmDeleteFile";
62 public const CMD_CONFIRMED_DELETE_VERSIONS = 'confirmDeleteVersions';
63 public const CMD_ADD_NEW_VERSION = 'addNewVersion';
64 public const CMD_CREATE_NEW_VERSION = 'saveVersion';
65 public const CMD_ADD_REPLACING_VERSION = 'addReplacingVersion';
66 public const CMD_CREATE_REPLACING_VERSION = 'createReplacingVersion';
67 public const CMD_UNZIP_CURRENT_REVISION = Capabilities::UNZIP->value;
68 public const CMD_PROCESS_UNZIP = 'processUnzip';
69 public const CMD_RENDER_DELETE_SELECTED_VERSIONS_MODAL = 'renderDeleteSelectedVersionsModal';
70 public const CMD_PUBLISH = 'publish';
71 public const CMD_UNPUBLISH = 'unpublish';
72
74 private \ILIAS\ResourceStorage\Services $storage;
77 protected UIServices $ui;
79 private \ilWorkspaceAccessHandler $wsp_access;
80 private int $ref_id;
81 protected ilLanguage $lng;
82 private Services $http;
84 protected ilCtrl $ctrl;
88 protected ?int $version_id = null;
89 protected ilTree $tree;
90 protected int $parent_id;
91 protected Refinery $refinery;
92 protected LOMServices $lom_services;
93
97 public function __construct(private ilObjFile $file)
98 {
99 global $DIC;
100 $this->ctrl = $DIC->ctrl();
101 $this->tpl = $DIC->ui()->mainTemplate();
102 $this->tabs = $DIC->tabs();
103 $this->http = $DIC->http();
104 $this->lng = $DIC->language();
105 $this->ref_id = $this->http->wrapper()->query()->retrieve('ref_id', $DIC->refinery()->kindlyTo()->int());
106 $this->toolbar = $DIC->toolbar();
107 $this->access = $DIC->access();
108 $this->storage = $DIC->resourceStorage();
109 $this->file_service_settings = $DIC->fileServiceSettings();
110 $this->ui = $DIC->ui();
111 $this->tree = $this->isWorkspaceContext() ? new ilWorkspaceTree($DIC->user()->getId()) : $DIC->repositoryTree();
112 $this->file_component_builder = new ilObjFileComponentBuilder($this->lng, $this->ui);
113 $this->refinery = $DIC->refinery();
114 $this->lom_services = $DIC->learningObjectMetadata();
115
116 $this->parent_id = $this->tree->getParentId($this->file->getRefId()) ?? $this->getParentIdType();
117 $this->wsp_access = new ilWorkspaceAccessHandler($this->tree);
118 $this->version_id = $this->http->wrapper()->query()->has(self::HIST_ID)
119 ? $this->http->wrapper()->query()->retrieve(self::HIST_ID, $DIC->refinery()->kindlyTo()->int())
120 : null;
121 $this->action_repo = new ActionDBRepository($DIC->database());
122 $this->current_revision = $this->getCurrentFileRevision();
123 }
124
125
126
131 protected function performCommand(): void
132 {
133 match ($this->ctrl->getCmd(self::CMD_DEFAULT)) {
134 self::CMD_DEFAULT => $this->index(),
135 self::CMD_DOWNLOAD_VERSION => $this->downloadVersion(),
136 self::CMD_DELETE_VERSIONS => $this->deleteVersions(),
137 self::CMD_ROLLBACK_VERSION => $this->rollbackVersion(),
138 self::CMD_ADD_NEW_VERSION => $this->addVersion(ilFileVersionFormGUI::MODE_ADD),
139 self::CMD_ADD_REPLACING_VERSION => $this->addVersion(ilFileVersionFormGUI::MODE_REPLACE),
140 self::CMD_CREATE_NEW_VERSION => $this->saveVersion(ilFileVersionFormGUI::MODE_ADD),
141 self::CMD_CREATE_REPLACING_VERSION => $this->saveVersion(ilFileVersionFormGUI::MODE_REPLACE),
142 self::CMD_CONFIRMED_DELETE_VERSIONS => $this->confirmDeleteVersions(),
143 self::CMD_CONFIRMED_DELETE_FILE => $this->confirmDeleteFile(),
144 self::CMD_UNZIP_CURRENT_REVISION => $this->unzipCurrentRevision(),
145 self::CMD_PROCESS_UNZIP => $this->processUnzip(),
146 self::CMD_RENDER_DELETE_SELECTED_VERSIONS_MODAL => $this->renderDeleteSelectedVersionsModal(),
147 self::CMD_PUBLISH => $this->publish(),
148 self::CMD_UNPUBLISH => $this->unpublish()
149 };
150 }
151
155 protected function setBackTab(): void
156 {
157 $this->tabs->clearTargets();
158 $this->tabs->setBackTarget(
159 $this->lng->txt('back'),
160 $this->ctrl->getLinkTarget($this, self::CMD_DEFAULT)
161 );
162 }
163
164 public function executeCommand(): void
165 {
166 // bugfix mantis 26007: use new function hasPermission to ensure that the check also works for workspace files
167 if (!$this->hasPermission('write')) {
168 $this->tpl->setOnScreenMessage('failure', $this->lng->txt('permission_denied'), true);
169 $this->ctrl->returnToParent($this);
170 }
171 switch ($this->ctrl->getNextClass()) {
172 case strtolower(ilFileVersionsUploadHandlerGUI::class):
173 $this->ctrl->forwardCommand(
175 $this->file
176 )
177 );
178 return;
179 case strtolower(ilWOPIEmbeddedApplicationGUI::class):
180 $action = $this->action_repo->getEditActionForSuffix(
181 $this->current_revision->getInformation()->getSuffix()
182 );
183
184 $embeded_application = new EmbeddedApplication(
185 $this->current_revision->getIdentification(),
186 $action,
188 new URI(rtrim(ILIAS_HTTP_PATH, "/") . "/" . $this->ctrl->getLinkTarget($this, self::CMD_DEFAULT)),
189 false,
190 $this->lng->getLangKey()
191 );
192
193 $this->ctrl->forwardCommand(
195 $embeded_application
196 )
197 );
198 break;
199 default:
200 $this->performCommand();
201 break;
202 }
203 }
204
205 private function unzipCurrentRevision(): void
206 {
207 $this->setBackTab();
208 $this->tpl->setContent(
209 $this->ui->renderer()->render(
210 $this->getFileZipOptionsForm()
211 )
212 );
213 }
214
215 private function publish(): void
216 {
217 $this->file->enableNotification();
218 $this->storage->manage()->publish($this->getIdentification());
219 $this->file->updateObjectFromCurrentRevision();
220 $this->tpl->setOnScreenMessage('success', $this->lng->txt('msg_obj_modified'), true);
221 $this->ctrl->redirect($this, self::CMD_DEFAULT);
222 }
223
224 private function unpublish(): void
225 {
226 $this->file->enableNotification();
227 if ($this->current_revision->getVersionNumber() === 1) {
228 $this->tpl->setOnScreenMessage('failure', $this->lng->txt('msg_cant_unpublish'), true);
229 $this->ctrl->redirect($this, self::CMD_DEFAULT);
230 }
231
232 $this->storage->manage()->unpublish($this->getIdentification());
233 $this->file->updateObjectFromCurrentRevision();
234 $this->tpl->setOnScreenMessage('success', $this->lng->txt('msg_obj_modified'), true);
235 $this->ctrl->redirect($this, self::CMD_DEFAULT);
236 }
237
238 private function processUnzip(): void
239 {
240 $form = $this->getFileZipOptionsForm()->withRequest($this->http->request());
241 $data = $form->getData();
242
243 if (!empty($data)) {
244 $file_rid = $this->storage->manage()->find($data[self::KEY_FILE_RID]);
245 if (null !== $file_rid) {
246 $copyright_id = $data[self::KEY_COPYRIGHT_OPTION][1][self::KEY_COPYRIGHT_ID] ?? null;
247 $processor = $this->getFileProcessor($data[self::KEY_FILE_STRUCTURE]);
248 $processor->process($file_rid, null, null, $copyright_id);
249
250 if ($processor->getInvalidFileNames() !== []) {
251 $this->ui->mainTemplate()->setOnScreenMessage(
252 'info',
253 sprintf(
254 $this->lng->txt('file_upload_info_file_with_critical_extension'),
255 implode(', ', $processor->getInvalidFileNames())
256 ),
257 true
258 );
259 }
260
261 $this->tpl->setOnScreenMessage('success', $this->lng->txt('msg_unzip_success'), true);
262 $this->ctrl->setParameterByClass(ilRepositoryGUI::class, "ref_id", $this->parent_id);
263 $this->ctrl->redirectByClass(ilRepositoryGUI::class);
264 }
265
266 $this->tpl->setOnScreenMessage('failure', $this->lng->txt('file_not_found'));
267 }
268
269 $this->tpl->setContent(
270 $this->ui->renderer()->render(
271 $this->getFileZipOptionsForm()
272 )
273 );
274 }
275
276 private function index(): void
277 {
278 // Buttons
279 $status = $this->current_revision?->getStatus();
280
281 $btn_add_version = $this->ui->factory()->button()->standard(
282 $this->lng->txt('file_new_version'),
283 $this->ctrl->getLinkTarget($this, self::CMD_ADD_NEW_VERSION)
284 );
285 if ($status === RevisionStatus::DRAFT) {
286 $btn_add_version = $btn_add_version->withUnavailableAction();
287 }
288 $this->toolbar->addComponent($btn_add_version);
289
290 $btn_replace_version = $this->ui->factory()->button()->standard(
291 $this->lng->txt('replace_file'),
292 $this->ctrl->getLinkTarget($this, self::CMD_ADD_REPLACING_VERSION)
293 );
294 if ($status === RevisionStatus::DRAFT) {
295 $btn_replace_version = $btn_replace_version->withUnavailableAction();
296 }
297 $this->toolbar->addComponent($btn_replace_version);
298
299 // only add unzip button if the current revision is a zip.
300 if (null !== $this->current_revision &&
301 in_array($this->current_revision->getInformation()->getMimeType(), [MimeType::APPLICATION__ZIP, MimeType::APPLICATION__X_ZIP_COMPRESSED], true)
302 ) {
303 $btn_unzip = $this->ui->factory()->button()->standard(
304 $this->lng->txt('unzip'),
305 $this->ctrl->getLinkTarget($this, self::CMD_UNZIP_CURRENT_REVISION)
306 );
307 $this->toolbar->addComponent($btn_unzip);
308 }
309
310 // Editor
311 $this->current_revision?->getInformation()?->getSuffix();
312
313 if ($this->action_repo->hasEditActionForSuffix(
314 $this->current_revision->getInformation()->getSuffix()
315 )) {
316 $external_editor = $this->ui->factory()
317 ->button()
318 ->standard(
319 $this->lng->txt('open_external_editor'),
320 $this->ctrl->getLinkTargetByClass(
321 [self::class, ilWOPIEmbeddedApplicationGUI::class],
323 )
324 );
325 $this->toolbar->addComponent($external_editor);
326 }
327
328
329 // Publish
330 if ($status === RevisionStatus::DRAFT) {
331 $this->tpl->setOnScreenMessage('info', $this->lng->txt('file_version_draft_info'));
332
333 $btn_publish = $this->ui->factory()->button()->standard(
334 $this->lng->txt('file_publish'),
335 $this->ctrl->getLinkTarget($this, self::CMD_PUBLISH)
336 );
337 $this->toolbar->addComponent($btn_publish);
338 }
339
340 $table = new ilFileVersionsTableGUI($this, self::CMD_DEFAULT);
341 $this->tpl->setContent($table->getHTML());
342 }
343
344 private function addVersion(int $mode = ilFileVersionFormGUI::MODE_ADD): void
345 {
346 $this->setBackTab();
347
348 $form = new ilFileVersionFormGUI($this, $mode);
349 $this->tpl->setContent($form->getHTML());
350 }
351
356 private function saveVersion(int $mode = ilFileVersionFormGUI::MODE_ADD): void
357 {
358 $form = new ilFileVersionFormGUI($this, $mode);
359 if ($form->saveObject()) {
360 $this->tpl->setOnScreenMessage('success', $this->lng->txt('msg_obj_modified'), true);
361 $this->ctrl->redirect($this, self::CMD_DEFAULT);
362 }
363 $this->tpl->setContent($form->getHTML());
364 }
365
366 private function downloadVersion(): void
367 {
368 try {
369 $this->file->sendFile($this->version_id);
370 } catch (FileNotFoundException) {
371 }
372 }
373
374 private function rollbackVersion(): void
375 {
376 $version_ids = $this->getVersionIdsFromRequest();
377
378 // more than one entry selected?
379 if (count($version_ids) !== 1) {
380 $this->tpl->setOnScreenMessage('failure', $this->lng->txt("file_rollback_select_exact_one"), true);
381 $this->ctrl->redirect($this, self::CMD_DEFAULT);
382 }
383
384 if ($this->current_revision->getStatus() === RevisionStatus::DRAFT) {
385 $this->tpl->setOnScreenMessage('failure', $this->lng->txt("file_rollback_rollback_first"), true);
386 $this->ctrl->redirect($this, self::CMD_DEFAULT);
387 }
388
389 // rollback the version
390 $version_id = $version_ids[0];
391 if ($version_id === $this->current_revision->getVersionNumber()) {
392 $this->tpl->setOnScreenMessage('info', $this->lng->txt("file_rollback_same_version"), true);
393 $this->ctrl->redirect($this, self::CMD_DEFAULT);
394 }
395
396 $this->file->rollback($version_id);
397
398 $this->tpl->setOnScreenMessage('success', sprintf($this->lng->txt("file_rollback_done"), (string) $version_id), true);
399 $this->ctrl->redirect($this, self::CMD_DEFAULT);
400 }
401
402 private function confirmDeleteVersions(): void
403 {
404 // delete versions after confirmation
405 $versions_to_delete = $this->getVersionIdsFromRequest();
406 if ($versions_to_delete !== []) {
407 $this->file->deleteVersions($versions_to_delete);
408 $this->tpl->setOnScreenMessage('success', $this->lng->txt("file_versions_deleted"), true);
409 }
410
411 $this->ctrl->setParameter($this, self::HIST_ID, "");
412 $this->ctrl->redirect($this, self::CMD_DEFAULT);
413 }
414
415 private function confirmDeleteFile(): void
416 {
417 $parent_id = $this->tree->getParentId($this->ref_id);
418
419 ilRepUtil::deleteObjects($parent_id, [$this->ref_id]);
420
421 // redirect to parent object
422 $this->ctrl->setParameterByClass(ilRepositoryGUI::class, "ref_id", $parent_id);
423 $this->ctrl->redirectByClass(ilRepositoryGUI::class);
424 }
425
426 public function getFile(): ilObjFile
427 {
428 return $this->file;
429 }
430
431 private function getVersionIdsFromRequest(): array
432 {
433 if ('GET' === $this->http->request()->getMethod() &&
434 $this->http->wrapper()->query()->has(self::HIST_ID)
435 ) {
436 return [
437 $this->http->wrapper()->query()->retrieve(self::HIST_ID, $this->refinery->kindlyTo()->int()),
438 ];
439 }
440
442 if ($this->http->wrapper()->post()->has('interruptive_items')) {
443 return $this->http->wrapper()->post()->retrieve(
444 'interruptive_items',
445 $this->refinery->kindlyTo()->listOf($this->refinery->kindlyTo()->int())
446 );
447 }
448
449 if ($this->http->wrapper()->post()->has(self::HIST_ID)) {
450 return $this->http->wrapper()->post()->retrieve(
451 self::HIST_ID,
452 $this->refinery->kindlyTo()->listOf($this->refinery->kindlyTo()->int())
453 );
454 }
455
456 return [];
457 }
458
464 private function hasPermission(string $a_permission): bool
465 {
466 // determine if the permission check concerns a workspace- or repository-object
467 if ($this->isWorkspaceContext()) {
468 // permission-check concerning a workspace object
469 if ($this->wsp_access->checkAccess($a_permission, "", $this->ref_id)) {
470 return true;
471 }
472 } elseif ($this->access->checkAccess($a_permission, '', $this->ref_id)) {
473 // permission-check concerning a repository object
474 return true;
475 }
476
477 return false;
478 }
479
480 protected function renderDeleteSelectedVersionsModal(): void
481 {
482 $delete_selected_versions_modal = $this->getDeleteSelectedVersionsModal();
483
484 $this->http->saveResponse(
485 $this->http->response()->withBody(
486 Streams::ofString(
487 (null !== $delete_selected_versions_modal) ?
488 $this->ui->renderer()->renderAsync([$delete_selected_versions_modal]) :
489 ''
490 )
491 )->withHeader('Content-Type', 'application/json; charset=utf-8')
492 );
493
494 $this->http->sendResponse();
495 $this->http->close();
496 }
497
499 {
500 $deletion_version_ids = $this->getVersionIdsFromRequest();
501 $existing_versions = $this->file->getVersions();
502
503 $non_deletion_versions = array_udiff(
504 $existing_versions,
505 $deletion_version_ids,
506 static function ($a, $b): int|float {
507 if ($a instanceof ilObjFileVersion) {
508 $a = $a->getHistEntryId();
509 }
510 if ($b instanceof ilObjFileVersion) {
511 $b = $b->getHistEntryId();
512 }
513 return $a - $b;
514 }
515 );
516 $this->checkSanityOfDeletionRequest($deletion_version_ids, false);
517
518 // no version will remain after deletion, so we can delete the whole file
519 if (count($non_deletion_versions) < 1) {
520 return $this->file_component_builder->buildConfirmDeleteAllVersionsModal(
521 $this->ctrl->getFormActionByClass(self::class, self::CMD_CONFIRMED_DELETE_FILE),
522 $this->file
523 );
524 }
525 // confirm the deletion of the selected versions
526 return $this->file_component_builder->buildConfirmDeleteSpecificVersionsModal(
527 $this->ctrl->getFormActionByClass(self::class, self::CMD_CONFIRMED_DELETE_VERSIONS),
528 $this->file,
529 $deletion_version_ids
530 );
531 }
532
533 protected function checkSanityOfDeletionRequest(array $requested_deletion_version, bool $redirect): void
534 {
535 // Check Sanity of request
536 // Cant delete version if current is a DRAFT
537 if (
538 $this->current_revision->getStatus() === RevisionStatus::DRAFT
539 ) {
540 $this->tpl->setOnScreenMessage('failure', $this->lng->txt('publish_before_delete'), $redirect);
541 if ($redirect) {
542 $this->ctrl->redirect($this, self::CMD_DEFAULT);
543 }
544 }
545
546 // no checkbox has been selected
547 if (count($requested_deletion_version) < 1) {
548 $this->tpl->setOnScreenMessage('failure', $this->lng->txt("no_checkbox"), $redirect);
549 if ($redirect) {
550 $this->ctrl->redirect($this, self::CMD_DEFAULT);
551 }
552 }
553 }
554
555 //TODO: Remove this function and replace its calls with calls to "getDeleteSelectedVersionsModal" as soon as the new table gui is introduced.
556 // This function and its deprecated ilConfirmationGUI are only needed because the old ilTable2GUI doesn't support calling modals from its MultiCommands
557 private function deleteVersions(): void
558 {
559 $version_ids = $this->getVersionIdsFromRequest();
560 $existing_versions = $this->file->getVersions();
561 $remaining_versions = array_udiff(
562 $existing_versions,
563 $version_ids,
564 static function ($a, $b): int|float {
565 if ($a instanceof ilObjFileVersion) {
566 $a = $a->getHistEntryId();
567 }
568 if ($b instanceof ilObjFileVersion) {
569 $b = $b->getHistEntryId();
570 }
571 return $a - $b;
572 }
573 );
574
575 $this->checkSanityOfDeletionRequest($version_ids, true);
576
577 $conf_gui = new ilConfirmationGUI();
578 $conf_gui->setFormAction($this->ctrl->getFormAction($this, self::CMD_DEFAULT));
579 $conf_gui->setCancel($this->lng->txt("cancel"), self::CMD_DEFAULT);
580
581 $icon = ilObject::_getIcon($this->file->getId(), "small", $this->file->getType());
582 $alt = $this->lng->txt("icon") . " " . $this->lng->txt("obj_" . $this->file->getType());
583
584 // only one version left, delete the whole file
585 if (count($remaining_versions) < 1) {
586 // Ask
587 $conf_gui->setHeaderText($this->lng->txt('file_confirm_delete_all_versions'));
588 $conf_gui->setConfirm($this->lng->txt("confirm"), self::CMD_CONFIRMED_DELETE_FILE);
589 $conf_gui->addItem(
590 "id[]",
591 $this->ref_id,
592 $this->file->getTitle(),
593 $icon,
594 $alt
595 );
596 } else {
597 // Ask to delete version
598 $conf_gui->setHeaderText($this->lng->txt('file_confirm_delete_versions'));
599 $conf_gui->setConfirm($this->lng->txt("confirm"), self::CMD_CONFIRMED_DELETE_VERSIONS);
600
601 foreach ($this->file->getVersions($version_ids) as $version) {
602 $a_text = $version['filename'] ?? $version->getFilename() ?? $this->file->getTitle();
603 $version_string = $version['hist_id'] ?? $version->getVersion();
604 $a_text .= " (v" . $version_string . ")";
605 $conf_gui->addItem(
606 "hist_id[]",
607 $version['hist_entry_id'],
608 $a_text,
609 $icon,
610 $alt
611 );
612 }
613 }
614
615 $this->tpl->setContent($conf_gui->getHTML());
616 }
617
618 private function getFileZipOptionsForm(): Form
619 {
620 $inputs = [];
621 $copyright_options = [];
622 $form_action = $this->ctrl->getFormActionByClass(self::class, self::CMD_PROCESS_UNZIP);
623
624 $inputs[self::KEY_FILE_RID] = $this->ui->factory()->input()->field()->hidden()->withValue(
625 $this->file->getResourceId()
626 );
627 $inputs[self::KEY_FILE_STRUCTURE] = $this->ui->factory()->input()->field()->checkbox(
628 $this->lng->txt('take_over_structure'),
629 $this->lng->txt('take_over_structure_info'),
630 );
631
632 if (!$this->lom_services->copyrightHelper()->isCopyrightSelectionActive()) {
633 return $this->ui->factory()->input()->container()->form()->standard($form_action, $inputs);
634 }
635
636 $lom_reader = $this->lom_services->read($this->file->getId(), 0, $this->file->getType());
637 $lom_cp_helper = $this->lom_services->copyrightHelper();
638
639 if ($lom_cp_helper->hasPresetCopyright($lom_reader)) {
640 $zip_copyright = $lom_cp_helper->readPresetCopyright($lom_reader);
641 $zip_copyright_id = $zip_copyright->identifier();
642 $zip_copyright_title = $zip_copyright->title();
643 } else {
644 $zip_copyright_id = $zip_copyright_title = $lom_cp_helper->readCustomCopyright($lom_reader);
645 }
646 if ($zip_copyright_id !== '') {
647 $copyright_inheritance_input = $this->ui->factory()->input()->field()->hidden()->withValue(
648 $zip_copyright_id
649 );
650 $copyright_options[self::KEY_INHERIT_COPYRIGHT] = $this->ui->factory()->input()->field()->group(
651 [self::KEY_COPYRIGHT_ID => $copyright_inheritance_input],
652 $this->lng->txt("copyright_inherited"),
653 sprintf(
654 $this->lng->txt("copyright_inherited_info"),
655 $zip_copyright_title
656 )
657 );
658 }
659
660 $copyright_selection_input = $this->getCopyrightSelectionInput('set_license_for_all_files');
661 $copyright_options[self::KEY_SELECT_COPYRIGHT] = $this->ui->factory()->input()->field()->group(
662 [self::KEY_COPYRIGHT_ID => $copyright_selection_input],
663 $this->lng->txt("copyright_custom"),
664 $this->lng->txt("copyright_custom_info")
665 );
666
667 $inputs[self::KEY_COPYRIGHT_OPTION] = $this->ui->factory()->input()->field()->switchableGroup(
668 $copyright_options,
669 $this->lng->txt("md_copyright")
670 )->withValue(self::KEY_SELECT_COPYRIGHT);
671
672 return $this->ui->factory()->input()->container()->form()->standard($form_action, $inputs);
673 }
674
675 private function getFileProcessor(bool $keep_structure): ilObjFileProcessorInterface
676 {
677 $context = $this->getParentIdType();
678
679 if ($keep_structure) {
682 new ilObjFileGUI(
683 $this->file->getId(),
684 $context,
685 $this->parent_id
686 ),
687 $this->storage,
688 $this->file_service_settings,
689 $this->tree
690 );
691 }
692
695 new ilObjFileGUI(
696 $this->file->getId(),
697 $context,
698 $this->parent_id
699 ),
700 $this->storage,
701 $this->file_service_settings,
702 $this->tree
703 );
704 }
705
707 {
708 return $this->storage->manage()->find($this->file->getResourceId());
709 }
710
711 private function getCurrentFileRevision(): ?Revision
712 {
713 $file_rid = $this->getIdentification();
714 if (null !== $file_rid) {
715 return $this->storage->manage()->getCurrentRevisionIncludingDraft($file_rid);
716 }
717
718 return null;
719 }
720
721 private function getParentIdType(): int
722 {
723 return ($this->isWorkspaceContext()) ?
726 }
727
728 private function isWorkspaceContext(): bool
729 {
730 return $this->http->wrapper()->query()->has('wsp_id');
731 }
732
733 protected function getUIFactory(): ILIAS\UI\Factory
734 {
735 return $this->ui->factory();
736 }
737
738 protected function getLanguage(): \ilLanguage
739 {
740 return $this->lng;
741 }
742}
$version
Definition: plugin.php:24
Provides fluid interface to RBAC services.
Definition: UIServices.php:25
Builds data types.
Definition: Factory.php:36
The scope of this class is split ilias-conform URI's into components.
Definition: URI.php:35
Mime type determination.
Definition: MimeType.php:30
Indicates that a file is missing or not found.
Stream factory which enables the user to create streams without the knowledge of the concrete class.
Definition: Streams.php:32
Class Services.
Definition: Services.php:38
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
Class ilCtrl provides processing control methods.
Class ilFileVersionFormGUI.
ActionRepository $action_repo
ILIAS ResourceStorage Services $storage
getFileProcessor(bool $keep_structure)
ilObjFileComponentBuilder $file_component_builder
ilGlobalTemplateInterface $tpl
checkSanityOfDeletionRequest(array $requested_deletion_version, bool $redirect)
saveVersion(int $mode=ilFileVersionFormGUI::MODE_ADD)
__construct(private ilObjFile $file)
ilFileVersionsGUI constructor.
addVersion(int $mode=ilFileVersionFormGUI::MODE_ADD)
hasPermission(string $a_permission)
bugfix mantis 26007: this function was created to ensure that the access check not only works for rep...
ilFileServicesSettings $file_service_settings
ilWorkspaceAccessHandler $wsp_access
Class ilFileVersionsTableGUI.
Class ilFileVersionsUploadHandlerGUI.
language handling
GUI class for file objects.
Class ilObjFileStakeholder.
Class ilObjFileUnzipFlatProcessor.
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
Class ilObjFile.
static _getIcon(int $obj_id=0, string $size="big", string $type="", bool $offline=false)
Get icon for repository item.
static deleteObjects(int $a_cur_ref_id, array $a_ids)
Delete objects.
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
Tree class data representation in hierachical trees using the Nested Set Model with Gaps by Joe Celco...
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
This describes commonalities between all forms.
Definition: Form.php:33
Interface ilAccessHandler This interface combines all available interfaces which can be called via gl...
Interface ilObjFileProcessorInterface.
static http()
Fetches the global http state from ILIAS.
Interface Observer \BackgroundTasks Contains several chained tasks and infos about them.
$a
thx to https://mlocati.github.io/php-cs-fixer-configurator for the examples
global $DIC
Definition: shib_login.php:26
trait ilObjFileCopyrightInput
$context
Definition: webdav.php:31