71     private \ILIAS\ResourceStorage\Services 
$storage;
    74     protected \ILIAS\DI\UIServices 
$ui;
    97         $this->
ctrl = $DIC->ctrl();
    98         $this->tpl = $DIC->ui()->mainTemplate();
    99         $this->
tabs = $DIC->tabs();
   100         $this->
http = $DIC->http();
   101         $this->
lng = $DIC->language();
   102         $this->ref_id = $this->
http->wrapper()->query()->retrieve(
'ref_id', $DIC->refinery()->kindlyTo()->int());
   103         $this->
toolbar = $DIC->toolbar();
   104         $this->
access = $DIC->access();
   105         $this->storage = $DIC->resourceStorage();
   106         $this->file_service_settings = $DIC->fileServiceSettings();
   107         $this->
ui = $DIC->ui();
   111         $this->lom_services = $DIC->learningObjectMetadata();
   113         $this->parent_id = $this->tree->getParentId($this->file->getRefId()) ?? $this->
getParentIdType();
   115         $this->version_id = $this->
http->wrapper()->query()->has(self::HIST_ID)
   116             ? $this->
http->wrapper()->query()->retrieve(self::HIST_ID, $DIC->refinery()->kindlyTo()->int())
   130         match ($this->
ctrl->getCmd(self::CMD_DEFAULT)) {
   131             self::CMD_DEFAULT => $this->
index(),
   144             self::CMD_PUBLISH => $this->
publish(),
   145             self::CMD_UNPUBLISH => $this->
unpublish()
   154         $this->
tabs->clearTargets();
   155         $this->
tabs->setBackTarget(
   156             $this->
lng->txt(
'back'),
   157             $this->
ctrl->getLinkTarget($this, self::CMD_DEFAULT)
   165             $this->tpl->setOnScreenMessage(
'failure', $this->
lng->txt(
'permission_denied'), 
true);
   166             $this->
ctrl->returnToParent($this);
   168         switch ($this->
ctrl->getNextClass()) {
   169             case strtolower(ilFileVersionsUploadHandlerGUI::class):
   170                 $this->
ctrl->forwardCommand(
   176             case strtolower(ilWOPIEmbeddedApplicationGUI::class):
   177                 $action = $this->action_repo->getEditActionForSuffix(
   178                     $this->current_revision->getInformation()->getSuffix()
   182                     $this->current_revision->getIdentification(),
   185                     new URI(rtrim(ILIAS_HTTP_PATH, 
"/") . 
"/" . $this->
ctrl->getLinkTarget($this, self::CMD_DEFAULT))
   188                 $this->
ctrl->forwardCommand(
   203         $this->tpl->setContent(
   204             $this->
ui->renderer()->render(
   212         $this->file->enableNotification();
   214         $this->file->updateObjectFromCurrentRevision();
   215         $this->tpl->setOnScreenMessage(
'success', $this->
lng->txt(
'msg_obj_modified'), 
true);
   216         $this->
ctrl->redirect($this, self::CMD_DEFAULT);
   221         $this->file->enableNotification();
   222         if ($this->current_revision->getVersionNumber() === 1) {
   223             $this->tpl->setOnScreenMessage(
'failure', $this->
lng->txt(
'msg_cant_unpublish'), 
true);
   224             $this->
ctrl->redirect($this, self::CMD_DEFAULT);
   228         $this->file->updateObjectFromCurrentRevision();
   229         $this->tpl->setOnScreenMessage(
'success', $this->
lng->txt(
'msg_obj_modified'), 
true);
   230         $this->
ctrl->redirect($this, self::CMD_DEFAULT);
   236         $data = $form->getData();
   239             $file_rid = $this->storage->manage()->find(
$data[self::KEY_FILE_RID]);
   240             if (null !== $file_rid) {
   241                 $copyright_id = 
$data[self::KEY_COPYRIGHT_OPTION][1][self::KEY_COPYRIGHT_ID] ?? null;
   243                 $processor->process($file_rid, null, null, $copyright_id);
   245                 if ($processor->getInvalidFileNames() !== []) {
   246                     $this->
ui->mainTemplate()->setOnScreenMessage(
   249                             $this->
lng->txt(
'file_upload_info_file_with_critical_extension'),
   250                             implode(
', ', $processor->getInvalidFileNames())
   256                 $this->tpl->setOnScreenMessage(
'success', $this->
lng->txt(
'msg_unzip_success'), 
true);
   257                 $this->
ctrl->setParameterByClass(ilRepositoryGUI::class, 
"ref_id", $this->parent_id);
   258                 $this->
ctrl->redirectByClass(ilRepositoryGUI::class);
   261             $this->tpl->setOnScreenMessage(
'failure', $this->
lng->txt(
'file_not_found'));
   264         $this->tpl->setContent(
   265             $this->
ui->renderer()->render(
   274         $status = $this->current_revision?->getStatus();
   276         $btn_add_version = $this->
ui->factory()->button()->standard(
   277             $this->
lng->txt(
'file_new_version'),
   278             $this->
ctrl->getLinkTarget($this, self::CMD_ADD_NEW_VERSION)
   281             $btn_add_version = $btn_add_version->withUnavailableAction();
   283         $this->
toolbar->addComponent($btn_add_version);
   285         $btn_replace_version = $this->
ui->factory()->button()->standard(
   286             $this->
lng->txt(
'replace_file'),
   287             $this->
ctrl->getLinkTarget($this, self::CMD_ADD_REPLACING_VERSION)
   290             $btn_replace_version = $btn_replace_version->withUnavailableAction();
   292         $this->
toolbar->addComponent($btn_replace_version);
   295         if (null !== $this->current_revision &&
   296             in_array($this->current_revision->getInformation()->getMimeType(), [MimeType::APPLICATION__ZIP, MimeType::APPLICATION__X_ZIP_COMPRESSED], 
true)
   298             $btn_unzip = $this->
ui->factory()->button()->standard(
   299                 $this->
lng->txt(
'unzip'),
   300                 $this->
ctrl->getLinkTarget($this, self::CMD_UNZIP_CURRENT_REVISION)
   302             $this->
toolbar->addComponent($btn_unzip);
   306         $suffix = $this->current_revision?->getInformation()?->getSuffix();
   308         if ($this->action_repo->hasEditActionForSuffix(
   309             $this->current_revision->getInformation()->getSuffix()
   311             $external_editor = $this->
ui->factory()
   314                                             $this->
lng->txt(
'open_external_editor'),
   315                                             $this->
ctrl->getLinkTargetByClass(
   316                                                 [self::class, ilWOPIEmbeddedApplicationGUI::class],
   320             $this->
toolbar->addComponent($external_editor);
   326             $this->tpl->setOnScreenMessage(
'info', $this->
lng->txt(
'file_version_draft_info'));
   328             $btn_publish = $this->
ui->factory()->button()->standard(
   329                 $this->
lng->txt(
'file_publish'),
   330                 $this->
ctrl->getLinkTarget($this, self::CMD_PUBLISH)
   332             $this->
toolbar->addComponent($btn_publish);
   336         $this->tpl->setContent($table->getHTML());
   344         $this->tpl->setContent($form->getHTML());
   354         if ($form->saveObject()) {
   355             $this->tpl->setOnScreenMessage(
'success', $this->
lng->txt(
'msg_obj_modified'), 
true);
   356             $this->
ctrl->redirect($this, self::CMD_DEFAULT);
   358         $this->tpl->setContent($form->getHTML());
   364             $this->file->sendFile($this->version_id);
   374         if (count($version_ids) !== 1) {
   375             $this->tpl->setOnScreenMessage(
'failure', $this->
lng->txt(
"file_rollback_select_exact_one"), 
true);
   376             $this->
ctrl->redirect($this, self::CMD_DEFAULT);
   380             $this->tpl->setOnScreenMessage(
'failure', $this->
lng->txt(
"file_rollback_rollback_first"), 
true);
   381             $this->
ctrl->redirect($this, self::CMD_DEFAULT);
   385         $version_id = $version_ids[0];
   386         if ($version_id === $this->current_revision->getVersionNumber()) {
   387             $this->tpl->setOnScreenMessage(
'info', $this->
lng->txt(
"file_rollback_same_version"), 
true);
   388             $this->
ctrl->redirect($this, self::CMD_DEFAULT);
   391         $this->file->rollback($version_id);
   393         $this->tpl->setOnScreenMessage(
'success', sprintf($this->
lng->txt(
"file_rollback_done"), (string) $version_id), 
true);
   394         $this->
ctrl->redirect($this, self::CMD_DEFAULT);
   401         if (is_array($versions_to_delete) && $versions_to_delete !== []) {
   402             $this->file->deleteVersions($versions_to_delete);
   403             $this->tpl->setOnScreenMessage(
'success', $this->
lng->txt(
"file_versions_deleted"), 
true);
   406         $this->
ctrl->setParameter($this, self::HIST_ID, 
"");
   407         $this->
ctrl->redirect($this, self::CMD_DEFAULT);
   412         $parent_id = $this->tree->getParentId($this->ref_id);
   417         $this->
ctrl->setParameterByClass(ilRepositoryGUI::class, 
"ref_id", $parent_id);
   418         $this->
ctrl->redirectByClass(ilRepositoryGUI::class);
   428         if (
'GET' === $this->
http->request()->getMethod() &&
   429             $this->
http->wrapper()->query()->has(self::HIST_ID)
   432                 $this->
http->wrapper()->query()->retrieve(self::HIST_ID, $this->
refinery->kindlyTo()->int()),
   437         if ($this->
http->wrapper()->post()->has(
'interruptive_items')) {
   438             return $this->
http->wrapper()->post()->retrieve(
   439                 'interruptive_items',
   444         if ($this->
http->wrapper()->post()->has(self::HIST_ID)) {
   445             return $this->
http->wrapper()->post()->retrieve(
   456         $versions_to_keep = $this->file->getVersions();
   457         array_udiff($versions_to_keep, $version_ids, 
static function ($v1, $v2): 
bool {
   459                 $v1 = (
int) $v1[
"hist_entry_id"];
   460             } elseif (!is_numeric($v1)) {
   464             if (is_array($v2) || $v2 instanceof ilObjFileVersion) {
   465                 $v2 = (
int) $v2[
"hist_entry_id"];
   466             } elseif (!is_numeric($v2)) {
   473         return $versions_to_keep;
   486             if ($this->wsp_access->checkAccess($a_permission, 
"", $this->ref_id)) {
   489         } elseif ($this->
access->checkAccess($a_permission, 
'', $this->ref_id)) {
   501         $this->
http->saveResponse(
   502             $this->
http->response()->withBody(
   504                     (null !== $delete_selected_versions_modal) ?
   505                         $this->
ui->renderer()->renderAsync([$delete_selected_versions_modal]) :
   508             )->withHeader(
'Content-Type', 
'application/json; charset=utf-8')
   511         $this->
http->sendResponse();
   512         $this->
http->close();
   518         $existing_versions = $this->file->getVersions();
   520         $non_deletion_versions = array_udiff(
   522             $deletion_version_ids,
   523             static function (
$a, 
$b) {
   525                     $a = 
$a->getHistEntryId();
   527                 if (
$b instanceof ilObjFileVersion) {
   528                     $b = 
$b->getHistEntryId();
   536         if (count($non_deletion_versions) < 1) {
   537             return $this->file_component_builder->buildConfirmDeleteAllVersionsModal(
   538                 $this->
ctrl->getFormActionByClass(self::class, self::CMD_CONFIRMED_DELETE_FILE),
   544         if (count($non_deletion_versions) >= 1) {
   545             return $this->file_component_builder->buildConfirmDeleteSpecificVersionsModal(
   546                 $this->
ctrl->getFormActionByClass(self::class, self::CMD_CONFIRMED_DELETE_VERSIONS),
   548                 $deletion_version_ids
   561             $this->tpl->setOnScreenMessage(
'failure', $this->
lng->txt(
'publish_before_delete'), $redirect);
   563                 $this->
ctrl->redirect($this, self::CMD_DEFAULT);
   568         if (count($requested_deletion_version) < 1) {
   569             $this->tpl->setOnScreenMessage(
'failure', $this->
lng->txt(
"no_checkbox"), $redirect);
   571                 $this->
ctrl->redirect($this, self::CMD_DEFAULT);
   581         $existing_versions = $this->file->getVersions();
   582         $remaining_versions = array_udiff(
   585             static function (
$a, 
$b) {
   587                     $a = 
$a->getHistEntryId();
   589                 if (
$b instanceof ilObjFileVersion) {
   590                     $b = 
$b->getHistEntryId();
   599         $conf_gui->setFormAction($this->
ctrl->getFormAction($this, self::CMD_DEFAULT));
   600         $conf_gui->setCancel($this->
lng->txt(
"cancel"), self::CMD_DEFAULT);
   603         $alt = $this->
lng->txt(
"icon") . 
" " . $this->
lng->txt(
"obj_" . $this->file->getType());
   606         if (count($remaining_versions) < 1) {
   608             $conf_gui->setHeaderText($this->
lng->txt(
'file_confirm_delete_all_versions'));
   609             $conf_gui->setConfirm($this->
lng->txt(
"confirm"), self::CMD_CONFIRMED_DELETE_FILE);
   613                 $this->file->getTitle(),
   619             $conf_gui->setHeaderText($this->
lng->txt(
'file_confirm_delete_versions'));
   620             $conf_gui->setConfirm($this->
lng->txt(
"confirm"), self::CMD_CONFIRMED_DELETE_VERSIONS);
   622             foreach ($this->file->getVersions($version_ids) as 
$version) {
   623                 $a_text = 
$version[
'filename'] ?? 
$version->getFilename() ?? $this->file->getTitle();
   625                 $a_text .= 
" (v" . $version_string . 
")";
   636         $this->tpl->setContent($conf_gui->getHTML());
   642         $copyright_options = [];
   643         $form_action = $this->
ctrl->getFormActionByClass(self::class, self::CMD_PROCESS_UNZIP);
   645         $inputs[self::KEY_FILE_RID] = $this->
ui->factory()->input()->field()->hidden()->withValue(
   646             $this->file->getResourceId()
   648         $inputs[self::KEY_FILE_STRUCTURE] = $this->
ui->factory()->input()->field()->checkbox(
   649             $this->
lng->txt(
'take_over_structure'),
   650             $this->
lng->txt(
'take_over_structure_info'),
   653         if (!$this->lom_services->copyrightHelper()->isCopyrightSelectionActive()) {
   654             return $this->
ui->factory()->input()->container()->form()->standard($form_action, 
$inputs);
   657         $lom_reader = $this->lom_services->read($this->file->getId(), 0, $this->file->getType());
   658         $lom_cp_helper = $this->lom_services->copyrightHelper();
   660         if ($lom_cp_helper->hasPresetCopyright($lom_reader)) {
   661             $zip_copyright = $lom_cp_helper->readPresetCopyright($lom_reader);
   662             $zip_copyright_id = $zip_copyright->identifier();
   663             $zip_copyright_title = $zip_copyright->title();
   665             $zip_copyright_id = $zip_copyright_title = $lom_cp_helper->readCustomCopyright($lom_reader);
   667         if ($zip_copyright_id !== 
'') {
   668             $copyright_inheritance_input = $this->
ui->factory()->input()->field()->hidden()->withValue(
   671             $copyright_options[self::KEY_INHERIT_COPYRIGHT] = $this->
ui->factory()->input()->field()->group(
   672                 [self::KEY_COPYRIGHT_ID => $copyright_inheritance_input],
   673                 $this->
lng->txt(
"copyright_inherited"),
   675                     $this->
lng->txt(
"copyright_inherited_info"),
   681         $copyright_selection_input = $this->getCopyrightSelectionInput(
'set_license_for_all_files');
   682         $copyright_options[self::KEY_SELECT_COPYRIGHT] = $this->
ui->factory()->input()->field()->group(
   683             [self::KEY_COPYRIGHT_ID => $copyright_selection_input],
   684             $this->
lng->txt(
"copyright_custom"),
   685             $this->
lng->txt(
"copyright_custom_info")
   688         $inputs[self::KEY_COPYRIGHT_OPTION] = $this->
ui->factory()->input()->field()->switchableGroup(
   690             $this->
lng->txt(
"md_copyright")
   691         )->
withValue(self::KEY_SELECT_COPYRIGHT);
   693         return $this->
ui->factory()->input()->container()->form()->standard($form_action, 
$inputs);
   700         if ($keep_structure) {
   704                     $this->file->getId(),
   709                 $this->file_service_settings,
   717                 $this->file->getId(),
   722             $this->file_service_settings,
   729         return $this->storage->manage()->find($this->file->getResourceId());
   735         if (null !== $file_rid) {
   736             return $this->storage->manage()->getCurrentRevisionIncludingDraft($file_rid);
   751         return $this->
http->wrapper()->query()->has(
'wsp_id');
   756         return $this->
ui->factory();
 
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
 
getVersionIdsFromRequest()
 
const CMD_DELETE_VERSIONS
 
Class ilObjFileStakeholder. 
 
__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. 
 
getDeleteSelectedVersionsModal()
 
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)
 
Interface Observer  Contains several chained tasks and infos about them. 
 
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...
 
ILIAS ResourceStorage Services $storage
 
const CMD_DOWNLOAD_VERSION
 
LOMServices $lom_services
 
ilGlobalTemplateInterface $tpl
 
const CMD_CONFIRMED_DELETE_VERSIONS
 
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
 
Revision $current_revision
 
static http()
Fetches the global http state from ILIAS. 
 
ilWorkspaceAccessHandler $wsp_access
 
const KEY_SELECT_COPYRIGHT
 
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...
 
const CMD_UNZIP_CURRENT_REVISION
 
Class ilFileVersionsUploadHandlerGUI. 
 
ilObjFileComponentBuilder $file_component_builder
 
Class ilFileVersionsTableGUI. 
 
The scope of this class is split ilias-conform URI's into components. 
 
ActionTarget
Officialy supported action targets, see https://learn.microsoft.com/en-us/openspecs/office_protocols/...
 
const CMD_CONFIRMED_DELETE_FILE
 
renderDeleteSelectedVersionsModal()
 
const CMD_ADD_REPLACING_VERSION
 
getVersionsToKeep(array $version_ids)
 
GUI class for file objects. 
 
const KEY_INHERIT_COPYRIGHT
 
ActionRepository $action_repo
 
const CMD_ADD_NEW_VERSION
 
$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. 
 
const CMD_ROLLBACK_VERSION
 
getFileProcessor(bool $keep_structure)
 
Class ilObjFileUnzipRecursiveProcessor. 
 
const KEY_COPYRIGHT_OPTION
 
const CMD_CREATE_REPLACING_VERSION
 
const CMD_RENDER_DELETE_SELECTED_VERSIONS_MODAL
 
const CMD_CREATE_NEW_VERSION
 
checkSanityOfDeletionRequest(array $requested_deletion_version, bool $redirect)
 
Class ilObjFileUnzipFlatProcessor.