74 private \ILIAS\ResourceStorage\Services
$storage;
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();
114 $this->lom_services =
$DIC->learningObjectMetadata();
116 $this->parent_id = $this->tree->getParentId($this->file->getRefId()) ?? $this->
getParentIdType();
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())
133 match ($this->
ctrl->getCmd(self::CMD_DEFAULT)) {
134 self::CMD_DEFAULT => $this->
index(),
147 self::CMD_PUBLISH => $this->
publish(),
148 self::CMD_UNPUBLISH => $this->
unpublish()
157 $this->
tabs->clearTargets();
158 $this->
tabs->setBackTarget(
159 $this->
lng->txt(
'back'),
160 $this->ctrl->getLinkTarget($this, self::CMD_DEFAULT)
168 $this->tpl->setOnScreenMessage(
'failure', $this->
lng->txt(
'permission_denied'),
true);
169 $this->
ctrl->returnToParent($this);
171 switch ($this->
ctrl->getNextClass()) {
172 case strtolower(ilFileVersionsUploadHandlerGUI::class):
173 $this->
ctrl->forwardCommand(
179 case strtolower(ilWOPIEmbeddedApplicationGUI::class):
180 $action = $this->action_repo->getEditActionForSuffix(
181 $this->current_revision->getInformation()->getSuffix()
185 $this->current_revision->getIdentification(),
188 new URI(rtrim(ILIAS_HTTP_PATH,
"/") .
"/" . $this->
ctrl->getLinkTarget($this, self::CMD_DEFAULT)),
190 $this->lng->getLangKey()
193 $this->
ctrl->forwardCommand(
208 $this->tpl->setContent(
209 $this->
ui->renderer()->render(
210 $this->getFileZipOptionsForm()
217 $this->file->enableNotification();
219 $this->file->updateObjectFromCurrentRevision();
220 $this->tpl->setOnScreenMessage(
'success', $this->
lng->txt(
'msg_obj_modified'),
true);
221 $this->
ctrl->redirect($this, self::CMD_DEFAULT);
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);
233 $this->file->updateObjectFromCurrentRevision();
234 $this->tpl->setOnScreenMessage(
'success', $this->
lng->txt(
'msg_obj_modified'),
true);
235 $this->
ctrl->redirect($this, self::CMD_DEFAULT);
241 $data = $form->getData();
244 $file_rid = $this->storage->manage()->find(
$data[self::KEY_FILE_RID]);
245 if (
null !== $file_rid) {
248 $processor->process($file_rid,
null,
null, $copyright_id);
250 if ($processor->getInvalidFileNames() !== []) {
251 $this->
ui->mainTemplate()->setOnScreenMessage(
254 $this->
lng->txt(
'file_upload_info_file_with_critical_extension'),
255 implode(
', ', $processor->getInvalidFileNames())
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);
266 $this->tpl->setOnScreenMessage(
'failure', $this->
lng->txt(
'file_not_found'));
269 $this->tpl->setContent(
270 $this->
ui->renderer()->render(
271 $this->getFileZipOptionsForm()
279 $status = $this->current_revision?->getStatus();
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)
286 $btn_add_version = $btn_add_version->withUnavailableAction();
288 $this->
toolbar->addComponent($btn_add_version);
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)
295 $btn_replace_version = $btn_replace_version->withUnavailableAction();
297 $this->
toolbar->addComponent($btn_replace_version);
300 if (
null !== $this->current_revision &&
301 in_array($this->current_revision->getInformation()->getMimeType(), [MimeType::APPLICATION__ZIP, MimeType::APPLICATION__X_ZIP_COMPRESSED],
true)
303 $btn_unzip = $this->
ui->factory()->button()->standard(
304 $this->
lng->txt(
'unzip'),
305 $this->ctrl->getLinkTarget($this, self::CMD_UNZIP_CURRENT_REVISION)
307 $this->
toolbar->addComponent($btn_unzip);
311 $this->current_revision?->getInformation()?->getSuffix();
313 if ($this->action_repo->hasEditActionForSuffix(
314 $this->current_revision->getInformation()->getSuffix()
316 $external_editor = $this->
ui->factory()
319 $this->
lng->txt(
'open_external_editor'),
320 $this->ctrl->getLinkTargetByClass(
321 [self::class, ilWOPIEmbeddedApplicationGUI::class],
325 $this->
toolbar->addComponent($external_editor);
331 $this->tpl->setOnScreenMessage(
'info', $this->
lng->txt(
'file_version_draft_info'));
333 $btn_publish = $this->
ui->factory()->button()->standard(
334 $this->
lng->txt(
'file_publish'),
335 $this->ctrl->getLinkTarget($this, self::CMD_PUBLISH)
337 $this->
toolbar->addComponent($btn_publish);
341 $this->tpl->setContent($table->getHTML());
349 $this->tpl->setContent($form->getHTML());
359 if ($form->saveObject()) {
360 $this->tpl->setOnScreenMessage(
'success', $this->
lng->txt(
'msg_obj_modified'),
true);
361 $this->
ctrl->redirect($this, self::CMD_DEFAULT);
363 $this->tpl->setContent($form->getHTML());
369 $this->file->sendFile($this->version_id);
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);
385 $this->tpl->setOnScreenMessage(
'failure', $this->
lng->txt(
"file_rollback_rollback_first"),
true);
386 $this->
ctrl->redirect($this, self::CMD_DEFAULT);
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);
398 $this->tpl->setOnScreenMessage(
'success', sprintf($this->
lng->txt(
"file_rollback_done"), (
string) $version_id),
true);
399 $this->
ctrl->redirect($this, self::CMD_DEFAULT);
406 if ($versions_to_delete !== []) {
407 $this->file->deleteVersions($versions_to_delete);
408 $this->tpl->setOnScreenMessage(
'success', $this->
lng->txt(
"file_versions_deleted"),
true);
411 $this->
ctrl->setParameter($this, self::HIST_ID,
"");
412 $this->
ctrl->redirect($this, self::CMD_DEFAULT);
417 $parent_id = $this->tree->getParentId($this->ref_id);
422 $this->
ctrl->setParameterByClass(ilRepositoryGUI::class,
"ref_id",
$parent_id);
423 $this->
ctrl->redirectByClass(ilRepositoryGUI::class);
433 if (
'GET' === $this->
http->request()->getMethod() &&
434 $this->http->wrapper()->query()->has(self::HIST_ID)
437 $this->
http->wrapper()->query()->retrieve(self::HIST_ID, $this->
refinery->kindlyTo()->int()),
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())
449 if ($this->
http->wrapper()->post()->has(self::HIST_ID)) {
450 return $this->
http->wrapper()->post()->retrieve(
452 $this->
refinery->kindlyTo()->listOf($this->refinery->kindlyTo()->int())
469 if ($this->wsp_access->checkAccess($a_permission,
"", $this->ref_id)) {
472 } elseif ($this->
access->checkAccess($a_permission,
'', $this->ref_id)) {
484 $this->
http->saveResponse(
485 $this->
http->response()->withBody(
487 (
null !== $delete_selected_versions_modal) ?
488 $this->ui->renderer()->renderAsync([$delete_selected_versions_modal]) :
491 )->withHeader(
'Content-Type',
'application/json; charset=utf-8')
494 $this->
http->sendResponse();
495 $this->
http->close();
501 $existing_versions = $this->file->getVersions();
503 $non_deletion_versions = array_udiff(
505 $deletion_version_ids,
506 static function (
$a,
$b):
int|
float {
508 $a =
$a->getHistEntryId();
511 $b =
$b->getHistEntryId();
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),
526 return $this->file_component_builder->buildConfirmDeleteSpecificVersionsModal(
527 $this->
ctrl->getFormActionByClass(self::class, self::CMD_CONFIRMED_DELETE_VERSIONS),
529 $deletion_version_ids
540 $this->tpl->setOnScreenMessage(
'failure', $this->
lng->txt(
'publish_before_delete'), $redirect);
542 $this->
ctrl->redirect($this, self::CMD_DEFAULT);
547 if (count($requested_deletion_version) < 1) {
548 $this->tpl->setOnScreenMessage(
'failure', $this->
lng->txt(
"no_checkbox"), $redirect);
550 $this->
ctrl->redirect($this, self::CMD_DEFAULT);
560 $existing_versions = $this->file->getVersions();
561 $remaining_versions = array_udiff(
564 static function (
$a,
$b):
int|
float {
566 $a =
$a->getHistEntryId();
569 $b =
$b->getHistEntryId();
578 $conf_gui->setFormAction($this->
ctrl->getFormAction($this, self::CMD_DEFAULT));
579 $conf_gui->setCancel($this->
lng->txt(
"cancel"), self::CMD_DEFAULT);
582 $alt = $this->
lng->txt(
"icon") .
" " . $this->
lng->txt(
"obj_" . $this->file->getType());
585 if (count($remaining_versions) < 1) {
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);
592 $this->file->getTitle(),
598 $conf_gui->setHeaderText($this->
lng->txt(
'file_confirm_delete_versions'));
599 $conf_gui->setConfirm($this->
lng->txt(
"confirm"), self::CMD_CONFIRMED_DELETE_VERSIONS);
601 foreach ($this->file->getVersions($version_ids) as
$version) {
602 $a_text =
$version[
'filename'] ??
$version->getFilename() ?? $this->file->getTitle();
604 $a_text .=
" (v" . $version_string .
")";
615 $this->tpl->setContent($conf_gui->getHTML());
621 $copyright_options = [];
622 $form_action = $this->
ctrl->getFormActionByClass(self::class, self::CMD_PROCESS_UNZIP);
625 $this->file->getResourceId()
628 $this->
lng->txt(
'take_over_structure'),
629 $this->lng->txt(
'take_over_structure_info'),
632 if (!$this->lom_services->copyrightHelper()->isCopyrightSelectionActive()) {
633 return $this->
ui->factory()->input()->container()->form()->standard($form_action,
$inputs);
636 $lom_reader = $this->lom_services->read($this->file->getId(), 0, $this->file->getType());
637 $lom_cp_helper = $this->lom_services->copyrightHelper();
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();
644 $zip_copyright_id = $zip_copyright_title = $lom_cp_helper->readCustomCopyright($lom_reader);
646 if ($zip_copyright_id !==
'') {
647 $copyright_inheritance_input = $this->
ui->factory()->input()->field()->hidden()->withValue(
651 [self::KEY_COPYRIGHT_ID => $copyright_inheritance_input],
652 $this->
lng->txt(
"copyright_inherited"),
654 $this->
lng->txt(
"copyright_inherited_info"),
660 $copyright_selection_input = $this->getCopyrightSelectionInput(
'set_license_for_all_files');
662 [self::KEY_COPYRIGHT_ID => $copyright_selection_input],
663 $this->
lng->txt(
"copyright_custom"),
664 $this->lng->txt(
"copyright_custom_info")
669 $this->
lng->txt(
"md_copyright")
670 )->withValue(self::KEY_SELECT_COPYRIGHT);
672 return $this->
ui->factory()->input()->container()->form()->standard($form_action,
$inputs);
679 if ($keep_structure) {
683 $this->file->getId(),
688 $this->file_service_settings,
696 $this->file->getId(),
701 $this->file_service_settings,
708 return $this->storage->manage()->find($this->file->getResourceId());
714 if (
null !== $file_rid) {
715 return $this->storage->manage()->getCurrentRevisionIncludingDraft($file_rid);
730 return $this->
http->wrapper()->query()->has(
'wsp_id');
735 return $this->
ui->factory();
Provides fluid interface to RBAC services.
The scope of this class is split ilias-conform URI's into components.
Class MetadataNotFoundException.
Class IllegalStateException.
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.
Class ResourceIdentification.
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
Class ilCtrl provides processing control methods.
ActionRepository $action_repo
const CMD_DELETE_VERSIONS
renderDeleteSelectedVersionsModal()
ILIAS ResourceStorage Services $storage
const CMD_RENDER_DELETE_SELECTED_VERSIONS_MODAL
getFileProcessor(bool $keep_structure)
ilObjFileComponentBuilder $file_component_builder
const KEY_COPYRIGHT_OPTION
ilGlobalTemplateInterface $tpl
checkSanityOfDeletionRequest(array $requested_deletion_version, bool $redirect)
const CMD_CREATE_REPLACING_VERSION
saveVersion(int $mode=ilFileVersionFormGUI::MODE_ADD)
Revision $current_revision
const CMD_CONFIRMED_DELETE_FILE
__construct(private ilObjFile $file)
ilFileVersionsGUI constructor.
const CMD_ROLLBACK_VERSION
const KEY_INHERIT_COPYRIGHT
const CMD_CREATE_NEW_VERSION
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
const CMD_DOWNLOAD_VERSION
getVersionIdsFromRequest()
const CMD_ADD_REPLACING_VERSION
const CMD_UNZIP_CURRENT_REVISION
const CMD_CONFIRMED_DELETE_VERSIONS
const CMD_ADD_NEW_VERSION
getDeleteSelectedVersionsModal()
LOMServices $lom_services
const KEY_SELECT_COPYRIGHT
Class ilFileVersionsTableGUI.
Class ilFileVersionsUploadHandlerGUI.
GUI class for file objects.
Class ilObjFileStakeholder.
Class ilObjFileUnzipFlatProcessor.
Class ilObjFileUnzipRecursiveProcessor.
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
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...
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...
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