ILIAS  trunk Revision v12.0_alpha-1540-g00f839d5fa1
ilFileVersionsGUI Class Reference
+ Collaboration diagram for ilFileVersionsGUI:

Public Member Functions

 __construct (private ilObjFile $file, private CapabilityCollection $capabilities)
 ilFileVersionsGUI constructor. More...
 
 executeCommand ()
 
 getFile ()
 

Data Fields

const KEY_FILE_RID = 'file_rid'
 
const KEY_FILE_EXTRACT = 'file_extract'
 
const KEY_FILE_STRUCTURE = 'file_structure'
 
const KEY_COPYRIGHT_OPTION = "copyright_option"
 
const KEY_INHERIT_COPYRIGHT = "inherit_copyright"
 
const KEY_SELECT_COPYRIGHT = "select_copyright"
 
const KEY_COPYRIGHT_ID = "copyright_id"
 
const CMD_DEFAULT = 'index'
 
const CMD_ROLLBACK_VERSION = "rollbackVersion"
 
const CMD_DOWNLOAD_VERSION = "sendFile"
 
const HIST_ID = 'hist_id'
 
const CMD_CANCEL_DELETE = "cancelDeleteFile"
 
const CMD_CONFIRMED_DELETE_FILE = "confirmDeleteFile"
 
const CMD_CONFIRMED_DELETE_VERSIONS = 'confirmDeleteVersions'
 
const CMD_ADD_NEW_VERSION = 'addNewVersion'
 
const CMD_CREATE_NEW_VERSION = 'saveVersion'
 
const CMD_ADD_REPLACING_VERSION = 'addReplacingVersion'
 
const CMD_CREATE_REPLACING_VERSION = 'createReplacingVersion'
 
const CMD_UNZIP_CURRENT_REVISION = Capabilities::UNZIP->value
 
const CMD_PROCESS_UNZIP = 'processUnzip'
 
const CMD_RENDER_DELETE_SELECTED_VERSIONS_MODAL = 'renderDeleteSelectedVersionsModal'
 
const CMD_PUBLISH = 'publish'
 
const CMD_UNPUBLISH = 'unpublish'
 

Protected Member Functions

 performCommand ()
 
 setBackTab ()
 
 renderDeleteSelectedVersionsModal ()
 
 getDeleteSelectedVersionsModal ()
 
 checkSanityOfDeletionRequest (array $requested_deletion_version, bool $redirect)
 
 getUIFactory ()
 
 getLanguage ()
 

Protected Attributes

UIServices $ui
 
ilLanguage $lng
 
ilCtrl $ctrl
 
int $version_id = null
 
ilTree $tree
 
int $parent_id
 
Refinery $refinery
 
LOMServices $lom_services
 

Private Member Functions

 unzipCurrentRevision ()
 
 publish ()
 
 unpublish ()
 
 processUnzip ()
 
 index ()
 
 addVersion (int $mode=ilFileVersionFormGUI::MODE_ADD)
 
 saveVersion (int $mode=ilFileVersionFormGUI::MODE_ADD)
 
 downloadVersion ()
 
 rollbackVersion ()
 
 confirmDeleteVersions ()
 
 confirmDeleteFile ()
 
 getTable ()
 
 getVersionIdsFromRequest ()
 
 hasPermission (string $a_permission)
 bugfix mantis 26007: this function was created to ensure that the access check not only works for repository objects but for workspace objects too More...
 
 getFileZipOptionsForm ()
 
 getFileProcessor (bool $keep_structure)
 
 getIdentification ()
 
 getCurrentFileRevision ()
 
 getParentIdType ()
 
 isWorkspaceContext ()
 

Private Attributes

ilToolbarGUI $toolbar
 
VersionsTable $table = null
 
ILIAS ResourceStorage Services $storage
 
ActionRepository $action_repo
 
Revision $current_revision
 
ilAccessHandler $access
 
ilWorkspaceAccessHandler $wsp_access
 
int $ref_id
 
Services $http
 
ilTabsGUI $tabs
 
ilGlobalTemplateInterface $tpl
 
ilFileServicesSettings $file_service_settings
 
ilObjFileComponentBuilder $file_component_builder
 

Detailed Description

Constructor & Destructor Documentation

◆ __construct()

ilFileVersionsGUI::__construct ( private ilObjFile  $file,
private CapabilityCollection  $capabilities 
)

ilFileVersionsGUI constructor.

Definition at line 99 of file class.ilFileVersionsGUI.php.

102 {
103 global $DIC;
104 $this->ctrl = $DIC->ctrl();
105 $this->tpl = $DIC->ui()->mainTemplate();
106 $this->tabs = $DIC->tabs();
107 $this->http = $DIC->http();
108 $this->lng = $DIC->language();
109 $this->ref_id = $this->http->wrapper()->query()->retrieve('ref_id', $DIC->refinery()->kindlyTo()->int());
110 $this->toolbar = $DIC->toolbar();
111 $this->access = $DIC->access();
112 $this->storage = $DIC->resourceStorage();
113 $this->file_service_settings = $DIC->fileServiceSettings();
114 $this->ui = $DIC->ui();
115 $this->tree = $this->isWorkspaceContext() ? new ilWorkspaceTree($DIC->user()->getId()) : $DIC->repositoryTree();
116 $this->file_component_builder = new ilObjFileComponentBuilder($this->lng, $this->ui);
117 $this->refinery = $DIC->refinery();
118 $this->lom_services = $DIC->learningObjectMetadata();
119
120 $this->parent_id = $this->tree->getParentId($this->file->getRefId()) ?? $this->getParentIdType();
121 $this->wsp_access = new ilWorkspaceAccessHandler($this->tree);
122 $this->version_id = $this->http->wrapper()->query()->has(self::HIST_ID)
123 ? $this->http->wrapper()->query()->retrieve(self::HIST_ID, $DIC->refinery()->kindlyTo()->int())
124 : null;
125 $this->action_repo = new ActionDBRepository($DIC->database());
126 $this->current_revision = $this->getCurrentFileRevision();
127 }
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...
static http()
Fetches the global http state from ILIAS.
global $DIC
Definition: shib_login.php:26

References $DIC, ILIAS\Repository\access(), ILIAS\Repository\ctrl(), getCurrentFileRevision(), getParentIdType(), ILIAS\FileDelivery\http(), isWorkspaceContext(), ILIAS\Repository\lng(), ILIAS\Repository\refinery(), ILIAS\Repository\tabs(), ILIAS\Repository\toolbar(), and ILIAS\Repository\ui().

+ Here is the call graph for this function:

Member Function Documentation

◆ addVersion()

ilFileVersionsGUI::addVersion ( int  $mode = ilFileVersionFormGUI::MODE_ADD)
private

Definition at line 354 of file class.ilFileVersionsGUI.php.

354 : void
355 {
356 $this->setBackTab();
357
358 $form = new ilFileVersionFormGUI($this, $mode);
359 $this->tpl->setContent($form->getHTML());
360 }
Class ilFileVersionFormGUI.

References setBackTab().

Referenced by performCommand().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ checkSanityOfDeletionRequest()

ilFileVersionsGUI::checkSanityOfDeletionRequest ( array  $requested_deletion_version,
bool  $redirect 
)
protected

Definition at line 548 of file class.ilFileVersionsGUI.php.

548 : 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 }

References ILIAS\Repository\ctrl(), ILIAS\ResourceStorage\Revision\DRAFT, and ILIAS\Repository\lng().

Referenced by getDeleteSelectedVersionsModal().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ confirmDeleteFile()

ilFileVersionsGUI::confirmDeleteFile ( )
private

Definition at line 425 of file class.ilFileVersionsGUI.php.

425 : void
426 {
427 $parent_id = $this->tree->getParentId($this->ref_id);
428
429 ilRepUtil::deleteObjects($parent_id, [$this->ref_id]);
430
431 // redirect to parent object
432 $this->ctrl->setParameterByClass(ilRepositoryGUI::class, "ref_id", $parent_id);
433 $this->ctrl->redirectByClass(ilRepositoryGUI::class);
434 }
static deleteObjects(int $a_cur_ref_id, array $a_ids)
Delete objects.

References $parent_id, ILIAS\Repository\ctrl(), and ilRepUtil\deleteObjects().

Referenced by performCommand().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ confirmDeleteVersions()

ilFileVersionsGUI::confirmDeleteVersions ( )
private

Definition at line 412 of file class.ilFileVersionsGUI.php.

412 : void
413 {
414 // delete versions after confirmation
415 $versions_to_delete = $this->getVersionIdsFromRequest();
416 if ($versions_to_delete !== []) {
417 $this->file->deleteVersions($versions_to_delete);
418 $this->tpl->setOnScreenMessage('success', $this->lng->txt("file_versions_deleted"), true);
419 }
420
421 $this->ctrl->setParameter($this, self::HIST_ID, "");
422 $this->ctrl->redirect($this, self::CMD_DEFAULT);
423 }

References ILIAS\Repository\ctrl(), getVersionIdsFromRequest(), and ILIAS\Repository\lng().

Referenced by performCommand().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ downloadVersion()

ilFileVersionsGUI::downloadVersion ( )
private

Definition at line 376 of file class.ilFileVersionsGUI.php.

376 : void
377 {
378 try {
379 $this->file->sendFile($this->version_id);
380 } catch (FileNotFoundException) {
381 }
382 }
Indicates that a file is missing or not found.

Referenced by performCommand().

+ Here is the caller graph for this function:

◆ executeCommand()

ilFileVersionsGUI::executeCommand ( )

Definition at line 167 of file class.ilFileVersionsGUI.php.

167 : void
168 {
169 // bugfix mantis 26007: use new function hasPermission to ensure that the check also works for workspace files
170 if (!$this->hasPermission('write')) {
171 $this->tpl->setOnScreenMessage('failure', $this->lng->txt('permission_denied'), true);
172 $this->ctrl->returnToParent($this);
173 }
174 switch ($this->ctrl->getNextClass()) {
175 case strtolower(ilFileVersionsUploadHandlerGUI::class):
176 $this->ctrl->forwardCommand(
178 $this->file
179 )
180 );
181 return;
182 case strtolower(ilWOPIEmbeddedApplicationGUI::class):
183 $action = $this->action_repo->getEditActionForSuffix(
184 $this->current_revision->getInformation()->getSuffix()
185 );
186
187 // select best of the following
188 $cap = $this->capabilities->getBestOf(
189 Capabilities::MANAGE_VERSIONS,
190 Capabilities::VIEW_EXTERNAL,
191 Capabilities::INFO_PAGE
192 );
193 $goto_link = $cap->getUri();
194
195 $embeded_application = new EmbeddedApplication(
196 $this->current_revision->getIdentification(),
197 $action,
199 $goto_link,
200 false,
201 $this->lng->getLangKey()
202 );
203
204 $this->ctrl->forwardCommand(
206 $embeded_application
207 )
208 );
209 break;
210 default:
211 $this->performCommand();
212 break;
213 }
214 }
hasPermission(string $a_permission)
bugfix mantis 26007: this function was created to ensure that the access check not only works for rep...
Class ilFileVersionsUploadHandlerGUI.
Class ilObjFileStakeholder.

References ILIAS\Repository\ctrl(), hasPermission(), ILIAS\Repository\lng(), and performCommand().

+ Here is the call graph for this function:

◆ getCurrentFileRevision()

ilFileVersionsGUI::getCurrentFileRevision ( )
private

Definition at line 663 of file class.ilFileVersionsGUI.php.

663 : ?Revision
664 {
665 $file_rid = $this->getIdentification();
666 if (null !== $file_rid) {
667 return $this->storage->manage()->getCurrentRevisionIncludingDraft($file_rid);
668 }
669
670 return null;
671 }

References getIdentification().

Referenced by __construct().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getDeleteSelectedVersionsModal()

ilFileVersionsGUI::getDeleteSelectedVersionsModal ( )
protected

Definition at line 513 of file class.ilFileVersionsGUI.php.

513 : ?Interruptive
514 {
515 $deletion_version_ids = $this->getVersionIdsFromRequest();
516 $existing_versions = $this->file->getVersions();
517
518 $non_deletion_versions = array_udiff(
519 $existing_versions,
520 $deletion_version_ids,
521 static function ($a, $b): int|float {
522 if ($a instanceof ilObjFileVersion) {
523 $a = $a->getHistEntryId();
524 }
525 if ($b instanceof ilObjFileVersion) {
526 $b = $b->getHistEntryId();
527 }
528 return $a - $b;
529 }
530 );
531 $this->checkSanityOfDeletionRequest($deletion_version_ids, false);
532
533 // no version will remain after deletion, so we can delete the whole file
534 if (count($non_deletion_versions) < 1) {
535 return $this->file_component_builder->buildConfirmDeleteAllVersionsModal(
536 $this->ctrl->getFormActionByClass(self::class, self::CMD_CONFIRMED_DELETE_FILE),
537 $this->file
538 );
539 }
540 // confirm the deletion of the selected versions
541 return $this->file_component_builder->buildConfirmDeleteSpecificVersionsModal(
542 $this->ctrl->getFormActionByClass(self::class, self::CMD_CONFIRMED_DELETE_VERSIONS),
543 $this->file,
544 $deletion_version_ids
545 );
546 }
checkSanityOfDeletionRequest(array $requested_deletion_version, bool $redirect)
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
$a
thx to https://mlocati.github.io/php-cs-fixer-configurator for the examples

References Vendor\Package\$a, Vendor\Package\$b, checkSanityOfDeletionRequest(), ILIAS\Repository\ctrl(), and getVersionIdsFromRequest().

Referenced by renderDeleteSelectedVersionsModal().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getFile()

ilFileVersionsGUI::getFile ( )

Definition at line 436 of file class.ilFileVersionsGUI.php.

436 : ilObjFile
437 {
438 return $this->file;
439 }
Class ilObjFile.

Referenced by ilFileVersionFormGUI\__construct().

+ Here is the caller graph for this function:

◆ getFileProcessor()

ilFileVersionsGUI::getFileProcessor ( bool  $keep_structure)
private

Definition at line 627 of file class.ilFileVersionsGUI.php.

628 {
629 $context = $this->getParentIdType();
630
631 if ($keep_structure) {
634 new ilObjFileGUI(
635 $this->file->getId(),
636 $context,
637 $this->parent_id
638 ),
639 $this->storage,
640 $this->file_service_settings,
641 $this->tree
642 );
643 }
644
647 new ilObjFileGUI(
648 $this->file->getId(),
649 $context,
650 $this->parent_id
651 ),
652 $this->storage,
653 $this->file_service_settings,
654 $this->tree
655 );
656 }
GUI class for file objects.
Class ilObjFileUnzipFlatProcessor.
Interface ilObjFileProcessorInterface.

References getParentIdType().

Referenced by processUnzip().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getFileZipOptionsForm()

ilFileVersionsGUI::getFileZipOptionsForm ( )
private

Definition at line 570 of file class.ilFileVersionsGUI.php.

570 : Form
571 {
572 $inputs = [];
573 $copyright_options = [];
574 $form_action = $this->ctrl->getFormActionByClass(self::class, self::CMD_PROCESS_UNZIP);
575
576 $inputs[self::KEY_FILE_RID] = $this->ui->factory()->input()->field()->hidden()->withValue(
577 $this->file->getResourceId()
578 );
579 $inputs[self::KEY_FILE_STRUCTURE] = $this->ui->factory()->input()->field()->checkbox(
580 $this->lng->txt('take_over_structure'),
581 $this->lng->txt('take_over_structure_info'),
582 );
583
584 if (!$this->lom_services->copyrightHelper()->isCopyrightSelectionActive()) {
585 return $this->ui->factory()->input()->container()->form()->standard($form_action, $inputs);
586 }
587
588 $lom_reader = $this->lom_services->read($this->file->getId(), 0, $this->file->getType());
589 $lom_cp_helper = $this->lom_services->copyrightHelper();
590
591 if ($lom_cp_helper->hasPresetCopyright($lom_reader)) {
592 $zip_copyright = $lom_cp_helper->readPresetCopyright($lom_reader);
593 $zip_copyright_id = $zip_copyright->identifier();
594 $zip_copyright_title = $zip_copyright->title();
595 } else {
596 $zip_copyright_id = $zip_copyright_title = $lom_cp_helper->readCustomCopyright($lom_reader);
597 }
598 if ($zip_copyright_id !== '') {
599 $copyright_inheritance_input = $this->ui->factory()->input()->field()->hidden()->withValue(
600 $zip_copyright_id
601 );
602 $copyright_options[self::KEY_INHERIT_COPYRIGHT] = $this->ui->factory()->input()->field()->group(
603 [self::KEY_COPYRIGHT_ID => $copyright_inheritance_input],
604 $this->lng->txt("copyright_inherited"),
605 sprintf(
606 $this->lng->txt("copyright_inherited_info"),
607 $zip_copyright_title
608 )
609 );
610 }
611
612 $copyright_selection_input = $this->getCopyrightSelectionInput('set_license_for_all_files');
613 $copyright_options[self::KEY_SELECT_COPYRIGHT] = $this->ui->factory()->input()->field()->group(
614 [self::KEY_COPYRIGHT_ID => $copyright_selection_input],
615 $this->lng->txt("copyright_custom"),
616 $this->lng->txt("copyright_custom_info")
617 );
618
619 $inputs[self::KEY_COPYRIGHT_OPTION] = $this->ui->factory()->input()->field()->switchableGroup(
620 $copyright_options,
621 $this->lng->txt("md_copyright")
622 )->withValue(self::KEY_SELECT_COPYRIGHT);
623
624 return $this->ui->factory()->input()->container()->form()->standard($form_action, $inputs);
625 }
This describes commonalities between all forms.
Definition: Form.php:34

References ILIAS\UI\Implementation\Component\Input\$inputs, ILIAS\Repository\ctrl(), KEY_COPYRIGHT_OPTION, KEY_FILE_RID, KEY_FILE_STRUCTURE, KEY_INHERIT_COPYRIGHT, KEY_SELECT_COPYRIGHT, ILIAS\Repository\lng(), and ILIAS\Repository\ui().

Referenced by processUnzip().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getIdentification()

ilFileVersionsGUI::getIdentification ( )
private

Definition at line 658 of file class.ilFileVersionsGUI.php.

659 {
660 return $this->storage->manage()->find($this->file->getResourceId());
661 }

Referenced by getCurrentFileRevision(), publish(), and unpublish().

+ Here is the caller graph for this function:

◆ getLanguage()

ilFileVersionsGUI::getLanguage ( )
protected

Definition at line 690 of file class.ilFileVersionsGUI.php.

691 {
692 return $this->lng;
693 }
language handling

References $lng.

◆ getParentIdType()

ilFileVersionsGUI::getParentIdType ( )
private

Definition at line 673 of file class.ilFileVersionsGUI.php.

673 : int
674 {
675 return ($this->isWorkspaceContext()) ?
678 }

References isWorkspaceContext(), ilObject2GUI\REPOSITORY_NODE_ID, and ilObject2GUI\WORKSPACE_NODE_ID.

Referenced by __construct(), and getFileProcessor().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getTable()

ilFileVersionsGUI::getTable ( )
private

Definition at line 441 of file class.ilFileVersionsGUI.php.

441 : VersionsTable
442 {
443 return $this->table ??= new VersionsTable($this);
444 }

Referenced by getVersionIdsFromRequest(), and index().

+ Here is the caller graph for this function:

◆ getUIFactory()

ilFileVersionsGUI::getUIFactory ( )
protected

Definition at line 685 of file class.ilFileVersionsGUI.php.

686 {
687 return $this->ui->factory();
688 }
Builds a Color from either hex- or rgb values.
Definition: Factory.php:31

References ILIAS\Repository\ui().

+ Here is the call graph for this function:

◆ getVersionIdsFromRequest()

ilFileVersionsGUI::getVersionIdsFromRequest ( )
private

in case request is triggered by

See also
self::CMD_RENDER_DELETE_SELECTED_VERSIONS_MODAL

Definition at line 446 of file class.ilFileVersionsGUI.php.

446 : array
447 {
448 $token_name = $this->getTable()->getIdToken()->getName();
449 $query_params = $this->http->request()->getQueryParams();
450
451 if (array_key_exists($token_name, $query_params)) {
452 $raw = $query_params[$token_name];
453 $values = is_array($raw) ? $raw : [$raw];
454 return array_values(array_map(static fn($v): int => (int) $v, $values));
455 }
456
458 if ($this->http->wrapper()->post()->has('interruptive_items')) {
459 return $this->http->wrapper()->post()->retrieve(
460 'interruptive_items',
461 $this->refinery->kindlyTo()->listOf($this->refinery->kindlyTo()->int())
462 );
463 }
464
465 if ($this->http->wrapper()->query()->has(self::HIST_ID)) {
466 return [
467 $this->http->wrapper()->query()->retrieve(self::HIST_ID, $this->refinery->kindlyTo()->int()),
468 ];
469 }
470
471 return [];
472 }

References getTable(), ILIAS\FileDelivery\http(), and ILIAS\Repository\refinery().

Referenced by confirmDeleteVersions(), getDeleteSelectedVersionsModal(), and rollbackVersion().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ hasPermission()

ilFileVersionsGUI::hasPermission ( string  $a_permission)
private

bugfix mantis 26007: this function was created to ensure that the access check not only works for repository objects but for workspace objects too

Definition at line 479 of file class.ilFileVersionsGUI.php.

479 : bool
480 {
481 // determine if the permission check concerns a workspace- or repository-object
482 if ($this->isWorkspaceContext()) {
483 // permission-check concerning a workspace object
484 if ($this->wsp_access->checkAccess($a_permission, "", $this->ref_id)) {
485 return true;
486 }
487 } elseif ($this->access->checkAccess($a_permission, '', $this->ref_id)) {
488 // permission-check concerning a repository object
489 return true;
490 }
491
492 return false;
493 }

References ILIAS\Repository\access(), and isWorkspaceContext().

Referenced by executeCommand().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ index()

ilFileVersionsGUI::index ( )
private

Definition at line 287 of file class.ilFileVersionsGUI.php.

287 : void
288 {
289 // Buttons
290 $status = $this->current_revision?->getStatus();
291
292 $btn_add_version = $this->ui->factory()->button()->standard(
293 $this->lng->txt('file_new_version'),
294 $this->ctrl->getLinkTarget($this, self::CMD_ADD_NEW_VERSION)
295 );
296 if ($status === RevisionStatus::DRAFT) {
297 $btn_add_version = $btn_add_version->withUnavailableAction();
298 }
299 $this->toolbar->addComponent($btn_add_version);
300
301 $btn_replace_version = $this->ui->factory()->button()->standard(
302 $this->lng->txt('replace_file'),
303 $this->ctrl->getLinkTarget($this, self::CMD_ADD_REPLACING_VERSION)
304 );
305 if ($status === RevisionStatus::DRAFT) {
306 $btn_replace_version = $btn_replace_version->withUnavailableAction();
307 }
308 $this->toolbar->addComponent($btn_replace_version);
309
310 // only add unzip button if the current revision is a zip.
311 if (null !== $this->current_revision &&
312 in_array($this->current_revision->getInformation()->getMimeType(), [MimeType::APPLICATION__ZIP, MimeType::APPLICATION__X_ZIP_COMPRESSED], true)
313 ) {
314 $btn_unzip = $this->ui->factory()->button()->standard(
315 $this->lng->txt('unzip'),
316 $this->ctrl->getLinkTarget($this, self::CMD_UNZIP_CURRENT_REVISION)
317 );
318 $this->toolbar->addComponent($btn_unzip);
319 }
320
321 // Editor
322 $this->current_revision?->getInformation()?->getSuffix();
323
324 if ($this->action_repo->hasEditActionForSuffix(
325 $this->current_revision->getInformation()->getSuffix()
326 )) {
327 $external_editor = $this->ui->factory()
328 ->button()
329 ->standard(
330 $this->lng->txt('open_external_editor'),
331 $this->ctrl->getLinkTargetByClass(
332 [self::class, ilWOPIEmbeddedApplicationGUI::class],
334 )
335 );
336 $this->toolbar->addComponent($external_editor);
337 }
338
339
340 // Publish
341 if ($status === RevisionStatus::DRAFT) {
342 $this->tpl->setOnScreenMessage('info', $this->lng->txt('file_version_draft_info'));
343
344 $btn_publish = $this->ui->factory()->button()->standard(
345 $this->lng->txt('file_publish'),
346 $this->ctrl->getLinkTarget($this, self::CMD_PUBLISH)
347 );
348 $this->toolbar->addComponent($btn_publish);
349 }
350
351 $this->tpl->setContent($this->getTable()->getHTML());
352 }

References ilWOPIEmbeddedApplicationGUI\CMD_EDIT, ILIAS\ResourceStorage\Revision\DRAFT, getTable(), ILIAS\Repository\lng(), ILIAS\Repository\toolbar(), and ILIAS\Repository\ui().

Referenced by performCommand().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ isWorkspaceContext()

ilFileVersionsGUI::isWorkspaceContext ( )
private

Definition at line 680 of file class.ilFileVersionsGUI.php.

680 : bool
681 {
682 return $this->http->wrapper()->query()->has('wsp_id');
683 }

References ILIAS\FileDelivery\http().

Referenced by __construct(), getParentIdType(), and hasPermission().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ performCommand()

ilFileVersionsGUI::performCommand ( )
protected
Exceptions
NoSuchElementException
IllegalStateException

Definition at line 135 of file class.ilFileVersionsGUI.php.

135 : void
136 {
137 match ($this->ctrl->getCmd(self::CMD_DEFAULT)) {
138 self::CMD_DEFAULT => $this->index(),
139 self::CMD_DOWNLOAD_VERSION => $this->downloadVersion(),
140 self::CMD_ROLLBACK_VERSION => $this->rollbackVersion(),
141 self::CMD_ADD_NEW_VERSION => $this->addVersion(ilFileVersionFormGUI::MODE_ADD),
142 self::CMD_ADD_REPLACING_VERSION => $this->addVersion(ilFileVersionFormGUI::MODE_REPLACE),
143 self::CMD_CREATE_NEW_VERSION => $this->saveVersion(ilFileVersionFormGUI::MODE_ADD),
144 self::CMD_CREATE_REPLACING_VERSION => $this->saveVersion(ilFileVersionFormGUI::MODE_REPLACE),
145 self::CMD_CONFIRMED_DELETE_VERSIONS => $this->confirmDeleteVersions(),
146 self::CMD_CONFIRMED_DELETE_FILE => $this->confirmDeleteFile(),
147 self::CMD_UNZIP_CURRENT_REVISION => $this->unzipCurrentRevision(),
148 self::CMD_PROCESS_UNZIP => $this->processUnzip(),
149 self::CMD_RENDER_DELETE_SELECTED_VERSIONS_MODAL => $this->renderDeleteSelectedVersionsModal(),
150 self::CMD_PUBLISH => $this->publish(),
151 self::CMD_UNPUBLISH => $this->unpublish()
152 };
153 }
saveVersion(int $mode=ilFileVersionFormGUI::MODE_ADD)
addVersion(int $mode=ilFileVersionFormGUI::MODE_ADD)

References addVersion(), confirmDeleteFile(), confirmDeleteVersions(), ILIAS\Repository\ctrl(), downloadVersion(), index(), ilFileVersionFormGUI\MODE_ADD, ilFileVersionFormGUI\MODE_REPLACE, processUnzip(), publish(), renderDeleteSelectedVersionsModal(), rollbackVersion(), saveVersion(), unpublish(), and unzipCurrentRevision().

Referenced by executeCommand().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ processUnzip()

ilFileVersionsGUI::processUnzip ( )
private

Definition at line 249 of file class.ilFileVersionsGUI.php.

249 : void
250 {
251 $form = $this->getFileZipOptionsForm()->withRequest($this->http->request());
252 $data = $form->getData();
253
254 if (!empty($data)) {
255 $file_rid = $this->storage->manage()->find($data[self::KEY_FILE_RID]);
256 if (null !== $file_rid) {
257 $copyright_id = $data[self::KEY_COPYRIGHT_OPTION][1][self::KEY_COPYRIGHT_ID] ?? null;
258 $processor = $this->getFileProcessor($data[self::KEY_FILE_STRUCTURE]);
259 $processor->process($file_rid, null, null, $copyright_id);
260
261 if ($processor->getInvalidFileNames() !== []) {
262 $this->ui->mainTemplate()->setOnScreenMessage(
263 'info',
264 sprintf(
265 $this->lng->txt('file_upload_info_file_with_critical_extension'),
266 implode(', ', $processor->getInvalidFileNames())
267 ),
268 true
269 );
270 }
271
272 $this->tpl->setOnScreenMessage('success', $this->lng->txt('msg_unzip_success'), true);
273 $this->ctrl->setParameterByClass(ilRepositoryGUI::class, "ref_id", $this->parent_id);
274 $this->ctrl->redirectByClass(ilRepositoryGUI::class);
275 }
276
277 $this->tpl->setOnScreenMessage('failure', $this->lng->txt('file_not_found'));
278 }
279
280 $this->tpl->setContent(
281 $this->ui->renderer()->render(
282 $this->getFileZipOptionsForm()
283 )
284 );
285 }
getFileProcessor(bool $keep_structure)

References $data, ILIAS\Repository\ctrl(), getFileProcessor(), getFileZipOptionsForm(), ILIAS\FileDelivery\http(), KEY_COPYRIGHT_ID, KEY_COPYRIGHT_OPTION, ILIAS\Repository\lng(), and ILIAS\Repository\ui().

Referenced by performCommand().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ publish()

ilFileVersionsGUI::publish ( )
private

Definition at line 226 of file class.ilFileVersionsGUI.php.

226 : void
227 {
228 $this->file->enableNotification();
229 $this->storage->manage()->publish($this->getIdentification());
230 $this->file->updateObjectFromCurrentRevision();
231 $this->tpl->setOnScreenMessage('success', $this->lng->txt('msg_obj_modified'), true);
232 $this->ctrl->redirect($this, self::CMD_DEFAULT);
233 }

References ILIAS\Repository\ctrl(), getIdentification(), and ILIAS\Repository\lng().

Referenced by performCommand().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ renderDeleteSelectedVersionsModal()

ilFileVersionsGUI::renderDeleteSelectedVersionsModal ( )
protected

Definition at line 495 of file class.ilFileVersionsGUI.php.

495 : void
496 {
497 $delete_selected_versions_modal = $this->getDeleteSelectedVersionsModal();
498
499 $this->http->saveResponse(
500 $this->http->response()->withBody(
501 Streams::ofString(
502 (null !== $delete_selected_versions_modal) ?
503 $this->ui->renderer()->renderAsync([$delete_selected_versions_modal]) :
504 ''
505 )
506 )->withHeader('Content-Type', 'application/json; charset=utf-8')
507 );
508
509 $this->http->sendResponse();
510 $this->http->close();
511 }

References getDeleteSelectedVersionsModal(), and ILIAS\FileDelivery\http().

Referenced by performCommand().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ rollbackVersion()

ilFileVersionsGUI::rollbackVersion ( )
private

Definition at line 384 of file class.ilFileVersionsGUI.php.

384 : void
385 {
386 $version_ids = $this->getVersionIdsFromRequest();
387
388 // more than one entry selected?
389 if (count($version_ids) !== 1) {
390 $this->tpl->setOnScreenMessage('failure', $this->lng->txt("file_rollback_select_exact_one"), true);
391 $this->ctrl->redirect($this, self::CMD_DEFAULT);
392 }
393
394 if ($this->current_revision->getStatus() === RevisionStatus::DRAFT) {
395 $this->tpl->setOnScreenMessage('failure', $this->lng->txt("file_rollback_rollback_first"), true);
396 $this->ctrl->redirect($this, self::CMD_DEFAULT);
397 }
398
399 // rollback the version
400 $version_id = $version_ids[0];
401 if ($version_id === $this->current_revision->getVersionNumber()) {
402 $this->tpl->setOnScreenMessage('info', $this->lng->txt("file_rollback_same_version"), true);
403 $this->ctrl->redirect($this, self::CMD_DEFAULT);
404 }
405
406 $this->file->rollback($version_id);
407
408 $this->tpl->setOnScreenMessage('success', sprintf($this->lng->txt("file_rollback_done"), (string) $version_id), true);
409 $this->ctrl->redirect($this, self::CMD_DEFAULT);
410 }

References $version_id, ILIAS\Repository\ctrl(), ILIAS\ResourceStorage\Revision\DRAFT, getVersionIdsFromRequest(), and ILIAS\Repository\lng().

Referenced by performCommand().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ saveVersion()

ilFileVersionsGUI::saveVersion ( int  $mode = ilFileVersionFormGUI::MODE_ADD)
private
Exceptions
NoSuchElementException
IllegalStateException

Definition at line 366 of file class.ilFileVersionsGUI.php.

366 : void
367 {
368 $form = new ilFileVersionFormGUI($this, $mode);
369 if ($form->saveObject()) {
370 $this->tpl->setOnScreenMessage('success', $this->lng->txt('msg_obj_modified'), true);
371 $this->ctrl->redirect($this, self::CMD_DEFAULT);
372 }
373 $this->tpl->setContent($form->getHTML());
374 }

References ILIAS\Repository\ctrl(), and ILIAS\Repository\lng().

Referenced by performCommand().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ setBackTab()

ilFileVersionsGUI::setBackTab ( )
protected
Exceptions
ilCtrlException

Definition at line 158 of file class.ilFileVersionsGUI.php.

158 : void
159 {
160 $this->tabs->clearTargets();
161 $this->tabs->setBackTarget(
162 $this->lng->txt('back'),
163 $this->ctrl->getLinkTarget($this, self::CMD_DEFAULT)
164 );
165 }

References ILIAS\Repository\lng(), and ILIAS\Repository\tabs().

Referenced by addVersion(), and unzipCurrentRevision().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ unpublish()

ilFileVersionsGUI::unpublish ( )
private

Definition at line 235 of file class.ilFileVersionsGUI.php.

235 : void
236 {
237 $this->file->enableNotification();
238 if ($this->current_revision->getVersionNumber() === 1) {
239 $this->tpl->setOnScreenMessage('failure', $this->lng->txt('msg_cant_unpublish'), true);
240 $this->ctrl->redirect($this, self::CMD_DEFAULT);
241 }
242
243 $this->storage->manage()->unpublish($this->getIdentification());
244 $this->file->updateObjectFromCurrentRevision();
245 $this->tpl->setOnScreenMessage('success', $this->lng->txt('msg_obj_modified'), true);
246 $this->ctrl->redirect($this, self::CMD_DEFAULT);
247 }

References ILIAS\Repository\ctrl(), getIdentification(), and ILIAS\Repository\lng().

Referenced by performCommand().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ unzipCurrentRevision()

ilFileVersionsGUI::unzipCurrentRevision ( )
private

Definition at line 216 of file class.ilFileVersionsGUI.php.

216 : void
217 {
218 $this->setBackTab();
219 $this->tpl->setContent(
220 $this->ui->renderer()->render(
221 $this->getFileZipOptionsForm()
222 )
223 );
224 }

References setBackTab(), and ILIAS\Repository\ui().

Referenced by performCommand().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

Field Documentation

◆ $access

ilAccessHandler ilFileVersionsGUI::$access
private

Definition at line 80 of file class.ilFileVersionsGUI.php.

◆ $action_repo

ActionRepository ilFileVersionsGUI::$action_repo
private

Definition at line 77 of file class.ilFileVersionsGUI.php.

◆ $ctrl

ilCtrl ilFileVersionsGUI::$ctrl
protected

Definition at line 86 of file class.ilFileVersionsGUI.php.

◆ $current_revision

Revision ilFileVersionsGUI::$current_revision
private

Definition at line 78 of file class.ilFileVersionsGUI.php.

◆ $file_component_builder

ilObjFileComponentBuilder ilFileVersionsGUI::$file_component_builder
private

Definition at line 89 of file class.ilFileVersionsGUI.php.

◆ $file_service_settings

ilFileServicesSettings ilFileVersionsGUI::$file_service_settings
private

Definition at line 88 of file class.ilFileVersionsGUI.php.

◆ $http

Services ilFileVersionsGUI::$http
private

Definition at line 84 of file class.ilFileVersionsGUI.php.

◆ $lng

ilLanguage ilFileVersionsGUI::$lng
protected

Definition at line 83 of file class.ilFileVersionsGUI.php.

Referenced by getLanguage().

◆ $lom_services

LOMServices ilFileVersionsGUI::$lom_services
protected

Definition at line 94 of file class.ilFileVersionsGUI.php.

◆ $parent_id

int ilFileVersionsGUI::$parent_id
protected

Definition at line 92 of file class.ilFileVersionsGUI.php.

Referenced by confirmDeleteFile().

◆ $ref_id

int ilFileVersionsGUI::$ref_id
private

Definition at line 82 of file class.ilFileVersionsGUI.php.

◆ $refinery

Refinery ilFileVersionsGUI::$refinery
protected

Definition at line 93 of file class.ilFileVersionsGUI.php.

◆ $storage

ILIAS ResourceStorage Services ilFileVersionsGUI::$storage
private

Definition at line 76 of file class.ilFileVersionsGUI.php.

◆ $table

VersionsTable ilFileVersionsGUI::$table = null
private

Definition at line 75 of file class.ilFileVersionsGUI.php.

◆ $tabs

ilTabsGUI ilFileVersionsGUI::$tabs
private

Definition at line 85 of file class.ilFileVersionsGUI.php.

◆ $toolbar

ilToolbarGUI ilFileVersionsGUI::$toolbar
private

Definition at line 74 of file class.ilFileVersionsGUI.php.

◆ $tpl

ilGlobalTemplateInterface ilFileVersionsGUI::$tpl
private

Definition at line 87 of file class.ilFileVersionsGUI.php.

◆ $tree

ilTree ilFileVersionsGUI::$tree
protected

Definition at line 91 of file class.ilFileVersionsGUI.php.

◆ $ui

UIServices ilFileVersionsGUI::$ui
protected

Definition at line 79 of file class.ilFileVersionsGUI.php.

◆ $version_id

int ilFileVersionsGUI::$version_id = null
protected

Definition at line 90 of file class.ilFileVersionsGUI.php.

Referenced by rollbackVersion().

◆ $wsp_access

ilWorkspaceAccessHandler ilFileVersionsGUI::$wsp_access
private

Definition at line 81 of file class.ilFileVersionsGUI.php.

◆ CMD_ADD_NEW_VERSION

const ilFileVersionsGUI::CMD_ADD_NEW_VERSION = 'addNewVersion'

Definition at line 64 of file class.ilFileVersionsGUI.php.

◆ CMD_ADD_REPLACING_VERSION

const ilFileVersionsGUI::CMD_ADD_REPLACING_VERSION = 'addReplacingVersion'

Definition at line 66 of file class.ilFileVersionsGUI.php.

◆ CMD_CANCEL_DELETE

const ilFileVersionsGUI::CMD_CANCEL_DELETE = "cancelDeleteFile"

Definition at line 61 of file class.ilFileVersionsGUI.php.

◆ CMD_CONFIRMED_DELETE_FILE

const ilFileVersionsGUI::CMD_CONFIRMED_DELETE_FILE = "confirmDeleteFile"

Definition at line 62 of file class.ilFileVersionsGUI.php.

◆ CMD_CONFIRMED_DELETE_VERSIONS

const ilFileVersionsGUI::CMD_CONFIRMED_DELETE_VERSIONS = 'confirmDeleteVersions'

Definition at line 63 of file class.ilFileVersionsGUI.php.

◆ CMD_CREATE_NEW_VERSION

const ilFileVersionsGUI::CMD_CREATE_NEW_VERSION = 'saveVersion'

◆ CMD_CREATE_REPLACING_VERSION

const ilFileVersionsGUI::CMD_CREATE_REPLACING_VERSION = 'createReplacingVersion'

◆ CMD_DEFAULT

const ilFileVersionsGUI::CMD_DEFAULT = 'index'

◆ CMD_DOWNLOAD_VERSION

const ilFileVersionsGUI::CMD_DOWNLOAD_VERSION = "sendFile"

◆ CMD_PROCESS_UNZIP

const ilFileVersionsGUI::CMD_PROCESS_UNZIP = 'processUnzip'

Definition at line 69 of file class.ilFileVersionsGUI.php.

◆ CMD_PUBLISH

const ilFileVersionsGUI::CMD_PUBLISH = 'publish'

◆ CMD_RENDER_DELETE_SELECTED_VERSIONS_MODAL

const ilFileVersionsGUI::CMD_RENDER_DELETE_SELECTED_VERSIONS_MODAL = 'renderDeleteSelectedVersionsModal'

◆ CMD_ROLLBACK_VERSION

const ilFileVersionsGUI::CMD_ROLLBACK_VERSION = "rollbackVersion"

◆ CMD_UNPUBLISH

const ilFileVersionsGUI::CMD_UNPUBLISH = 'unpublish'

◆ CMD_UNZIP_CURRENT_REVISION

const ilFileVersionsGUI::CMD_UNZIP_CURRENT_REVISION = Capabilities::UNZIP->value

Definition at line 68 of file class.ilFileVersionsGUI.php.

◆ HIST_ID

const ilFileVersionsGUI::HIST_ID = 'hist_id'

◆ KEY_COPYRIGHT_ID

const ilFileVersionsGUI::KEY_COPYRIGHT_ID = "copyright_id"

Definition at line 55 of file class.ilFileVersionsGUI.php.

Referenced by processUnzip().

◆ KEY_COPYRIGHT_OPTION

const ilFileVersionsGUI::KEY_COPYRIGHT_OPTION = "copyright_option"

Definition at line 52 of file class.ilFileVersionsGUI.php.

Referenced by getFileZipOptionsForm(), and processUnzip().

◆ KEY_FILE_EXTRACT

const ilFileVersionsGUI::KEY_FILE_EXTRACT = 'file_extract'

Definition at line 50 of file class.ilFileVersionsGUI.php.

◆ KEY_FILE_RID

const ilFileVersionsGUI::KEY_FILE_RID = 'file_rid'

Definition at line 49 of file class.ilFileVersionsGUI.php.

Referenced by getFileZipOptionsForm().

◆ KEY_FILE_STRUCTURE

const ilFileVersionsGUI::KEY_FILE_STRUCTURE = 'file_structure'

Definition at line 51 of file class.ilFileVersionsGUI.php.

Referenced by getFileZipOptionsForm().

◆ KEY_INHERIT_COPYRIGHT

const ilFileVersionsGUI::KEY_INHERIT_COPYRIGHT = "inherit_copyright"

Definition at line 53 of file class.ilFileVersionsGUI.php.

Referenced by getFileZipOptionsForm().

◆ KEY_SELECT_COPYRIGHT

const ilFileVersionsGUI::KEY_SELECT_COPYRIGHT = "select_copyright"

Definition at line 54 of file class.ilFileVersionsGUI.php.

Referenced by getFileZipOptionsForm().


The documentation for this class was generated from the following file: