ILIAS  trunk Revision v11.0_alpha-3011-gc6b235a2e85
OverviewActionGenerator.php
Go to the documentation of this file.
1<?php
2
19declare(strict_types=1);
20
22
27
34{
36 private \ilLanguage $language;
37 private \ilCtrlInterface $ctrl;
38 private array $collected_modals = [];
39 private Services $irss;
40
41 public function __construct()
42 {
43 global $DIC;
44 $this->ui_factory = $DIC->ui()->factory();
45 $this->language = $DIC->language();
46 $this->ctrl = $DIC->ctrl();
47 $this->irss = $DIC->resourceStorage();
48 }
49
50 public function getActionsForRevision(
51 Revision $revision
52 ): array {
53 $this->ctrl->setParameterByClass(
55 \ilResourceOverviewGUI::P_RESOURCE_ID,
56 $revision->getIdentification()->serialize()
57 );
58 $actions = [
59 $this->ui_factory->button()->shy(
60 $this->language->txt('action_show_revisions'),
61 $this->ctrl->getLinkTargetByClass(
62 \ilResourceOverviewGUI::class,
64 )
65 ),
66 $this->ui_factory->button()->shy(
67 $this->language->txt('action_goto'),
68 $this->ctrl->getLinkTargetByClass(
69 \ilResourceOverviewGUI::class,
71 )
72 ),
73 $this->ui_factory->button()->shy(
74 $this->language->txt('action_download'),
75 $this->ctrl->getLinkTargetByClass(
76 \ilResourceOverviewGUI::class,
78 )
79 ),
80 ];
81 $resource = $this->irss->manage()->getResource($revision->getIdentification());
82 if ($resource->getStakeholders() === []) {
83 $this->collected_modals[] = $modal = $this->getRemoveConfirmationModal($revision);
84 $actions[] = $this->ui_factory->button()->shy(
85 $this->language->txt('action_remove_resource'),
86 '#'
87 )->withOnClick($modal->getShowSignal());
88 }
89
90 return $actions;
91 }
92
93
94 public function getCollectedModals(): array
95 {
96 return $this->collected_modals;
97 }
98
99
100 private function getRemoveConfirmationModal(Revision $revision): Modal
101 {
102 $action = $this->ctrl->getLinkTargetByClass(
103 \ilResourceOverviewGUI::class,
105 );
106 return $this->ui_factory->modal()->interruptive(
108 $this->language->txt('confirm_delete'),
109 $action
110 )->withAffectedItems([
111 $this->ui_factory->modal()->interruptiveItem()->standard(
112 $revision->getIdentification()->serialize(),
113 $revision->getInformation()->getTitle(),
114 )
115 ]);
116 }
117}
Builds a Color from either hex- or rgb values.
Definition: Factory.php:31
This describes commonalities between the different modals.
Definition: Modal.php:35
This is how the factory for UI elements looks.
Definition: Factory.php:38
global $DIC
Definition: shib_login.php:26