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