ILIAS  trunk Revision v11.0_alpha-3011-gc6b235a2e85
StandardActionProvider.php
Go to the documentation of this file.
1<?php
2
19declare(strict_types=1);
20
22
29
35{
39 private const ACTION_UNZIP = 'unzip';
43 private const ACTION_DOWNLOAD = 'download';
47 private const ACTION_REMOVE = 'remove';
48
49 private \ilLanguage $language;
50 private \ilCtrlInterface $ctrl;
53 private bool $show_paths = false;
54
55 public function __construct(
56 private Request $request
57 ) {
58 global $DIC;
59 $this->ui_factory = $DIC->ui()->factory();
60 $this->language = $DIC->language();
61 $this->ctrl = $DIC->ctrl();
62 $this->initModals();
63 }
64
65 protected function initModals(): void
66 {
67 $this->add_directory_modal = $this->ui_factory->modal()->roundtrip(
68 $this->language->txt('create_directory'),
69 [],
70 [
71 $this->ui_factory->input()->field()->text(
72 $this->language->txt('directory_name'),
73 $this->language->txt('directory_name_info'),
74 )->withRequired(true)
75 ],
76 $this->ctrl->getFormActionByClass(\ilContainerResourceGUI::class, \ilContainerResourceGUI::ADD_DIRECTORY)
77 );
78 }
79
81 {
83 }
84
85 public function getComponents(): array
86 {
87 $components = [
89 ];
90
91 if ($this->show_paths) {
92 $components[] = $this->ui_factory->messageBox()->info(
93 implode('<br>', array_keys($this->request->getWrapper()->getData()))
94 );
95 }
96
97 return $components;
98 }
99
100 public function getTopActions(): array
101 {
102 return [
103 new TopAction(
104 $this->language->txt('create_directory'),
105 $this->add_directory_modal->getShowSignal()
106 ),
107 new TopAction(
108 $this->language->txt('download_zip'),
110 ),
111 ];
112 }
113
114 public function getSingleActions(Request $view_request): array
115 {
116 $single_actions = [
117 self::ACTION_DOWNLOAD => new SingleAction(
118 $this->language->txt(self::ACTION_DOWNLOAD),
119 $this->buildURI(\ilContainerResourceGUI::CMD_DOWNLOAD),
120 false,
121 false,
122 false
123 )
124 ];
125 if ($view_request->canUserAdministrate()) {
126 $single_actions[self::ACTION_REMOVE] = new SingleAction(
127 $this->language->txt(self::ACTION_REMOVE),
129 true,
130 true,
131 true
132 );
133
134 $single_actions[self::ACTION_UNZIP] = new SingleAction(
135 $this->language->txt(self::ACTION_UNZIP),
136 $this->buildURI(\ilContainerResourceGUI::CMD_UNZIP),
137 false,
138 false,
139 false,
140 ['application/zip', 'application/x-zip-compressed']
141 );
142 }
143
144 return $single_actions;
145 }
146
147 private function buildURI(
148 string $command
149 ): URI {
150 return $this->retrieveURI(
152 $command
153 );
154 }
155
156 public function retrieveURI(
157 string $class,
158 string $command
159 ): URI {
160 return new URI(
161 ILIAS_HTTP_PATH . '/' . $this->ctrl->getLinkTargetByClass(
162 $class,
163 $command
164 )
165 );
166 }
167
168}
$components
Builds a Color from either hex- or rgb values.
Definition: Factory.php:31
The scope of this class is split ilias-conform URI's into components.
Definition: URI.php:35
return['delivery_method'=> 'php',]
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
This is how the factory for UI elements looks.
Definition: Factory.php:38
global $DIC
Definition: shib_login.php:26