ILIAS  trunk Revision v12.0_alpha-1221-g4e438232683
ilContainerResourceGUI Class Reference
+ Inheritance diagram for ilContainerResourceGUI:
+ Collaboration diagram for ilContainerResourceGUI:

Public Member Functions

 __construct (private Configuration $view_configuration)
 
 executeCommand ()
 
 upload ()
 
 getFileIdentifierParameterName ()
 
 getUploadURL ()
 
 getFileRemovalURL ()
 
 getExistingFileInfoURL ()
 
 getInfoForExistingFiles (array $file_ids)
 
 getInfoResult (string $identifier)
 
 supportsChunkedUploads ()
 
 getFileIdentifierParameterName ()
 
 getUploadURL ()
 
 getFileRemovalURL ()
 
 getExistingFileInfoURL ()
 
 getInfoForExistingFiles (array $file_ids)
 
 getInfoResult (string $identifier)
 
 supportsChunkedUploads ()
 

Data Fields

const P_PATH = 'path'
 
const P_PATHS = 'paths'
 
const CMD_INDEX = 'index'
 
const CMD_INFO = 'info'
 
const CMD_UPLOAD = 'upload'
 
const CMD_POST_UPLOAD = 'postUpload'
 
const CMD_REMOVE = 'remove'
 
const CMD_DOWNLOAD = 'download'
 
const CMD_DOWNLOAD_ZIP = 'downloadZIP'
 
const CMD_UNZIP = 'unzip'
 
const CMD_RENDER_CONFIRM_REMOVE = 'renderConfirmRemove'
 
const ADD_DIRECTORY = 'addDirectory'
 
- Data Fields inherited from ILIAS\UI\Component\Input\Field\UploadHandler
const DEFAULT_FILE_ID_PARAMETER = 'file_id'
 

Private Member Functions

 abortWithPermissionDenied ()
 
 index ()
 
 downloadZIP ()
 
 addDirectory ()
 
 postUpload ()
 
 download ()
 
 getPathsFromRequest ()
 
 unzip ()
 
 renderConfirmRemove ()
 
 remove ()
 

Private Attributes

ilCtrlInterface $ctrl
 
ilGlobalTemplateInterface $main_tpl
 
Request $view_request
 
ViewFactory $view_factory
 
Renderer $ui_renderer
 
Factory $refinery
 
Services $http
 
ilLanguage $language
 
ILIAS ResourceStorage Services $irss
 
ActionBuilder $action_builder
 
ViewControlBuilder $view_control_builder
 
ILIAS UI Factory $ui_factory
 
FileUpload $upload
 
Archives $archive
 
PreviewDefinition $preview_definition
 
ActionProvider $action_provider
 
StandardActionProvider $standard_action_provider
 

Detailed Description

Constructor & Destructor Documentation

◆ __construct()

ilContainerResourceGUI::__construct ( private Configuration  $view_configuration)
final

Definition at line 120 of file class.ilContainerResourceGUI.php.

122 {
123 global $DIC;
124 $this->ctrl = $DIC->ctrl();
125 $this->main_tpl = $DIC->ui()->mainTemplate();
126 $this->ui_renderer = $DIC->ui()->renderer();
127 $this->ui_factory = $DIC->ui()->factory();
128 $this->http = $DIC->http();
129 $this->refinery = $DIC->refinery();
130 $this->language = $DIC->language();
131 $this->language->loadLanguageModule('irss');
132 $this->irss = $DIC->resourceStorage();
133 $this->upload = $DIC->upload();
134
135 $this->view_request = new Request(
136 $DIC->ctrl(),
137 $DIC->http()->wrapper()->query(),
138 $this->view_configuration
139 );
140
141 // to store paramaters needed in GUI
142 $this->view_request->init($this);
143
144 $this->action_provider = new CombinedActionProvider(
145 $this->standard_action_provider = new StandardActionProvider($this->view_request),
146 $this->view_configuration->getActionProvider()
147 );
148
149 $data_provider = new TableDataProvider($this->view_request);
150
151 $this->action_builder = new ActionBuilder(
152 $this->view_request,
153 $this->ctrl,
154 $DIC->ui()->factory(),
155 $DIC->language(),
156 $this->irss,
157 $this->action_provider
158 );
159
161 $this->view_request,
162 $data_provider,
163 $this->ctrl,
164 $DIC->ui()->factory(),
165 $DIC->language()
166 );
167
168 $upload_builder = new UploadBuilder(
169 $this->view_request,
170 $this->ctrl,
171 $DIC->ui()->factory(),
172 $DIC->language(),
173 $this
174 );
175
176 $this->view_factory = new ViewFactory(
177 $data_provider,
178 $this->action_builder,
180 $upload_builder
181 );
182 }
static http()
Fetches the global http state from ILIAS.
global $DIC
Definition: shib_login.php:26

References $DIC, $view_control_builder, ILIAS\Repository\ctrl(), ILIAS\FileDelivery\http(), ILIAS\UI\examples\Symbol\Glyph\Language\language(), ILIAS\Repository\refinery(), and upload().

+ Here is the call graph for this function:

Member Function Documentation

◆ abortWithPermissionDenied()

ilContainerResourceGUI::abortWithPermissionDenied ( )
private

Definition at line 186 of file class.ilContainerResourceGUI.php.

186 : void
187 {
188 $this->main_tpl->setOnScreenMessage('failure', $this->language->txt('msg_no_perm_read'), true);
189 $this->ctrl->redirect($this, self::CMD_INDEX);
190 }

References ILIAS\Repository\ctrl(), and ILIAS\UI\examples\Symbol\Glyph\Language\language().

Referenced by addDirectory(), postUpload(), remove(), renderConfirmRemove(), unzip(), and upload().

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

◆ addDirectory()

ilContainerResourceGUI::addDirectory ( )
private

Definition at line 266 of file class.ilContainerResourceGUI.php.

266 : void
267 {
268 if (!$this->view_request->canUserAdministrate()) {
270 return;
271 }
272 $modal = $this->standard_action_provider->getAddDirectoryModal()->withRequest($this->http->request());
273
274 $directory_name = $modal->getData()[0] ?? '';
275 if (empty($directory_name)) {
276 $this->main_tpl->setOnScreenMessage('failure', $this->language->txt('msg_error_adding_directory'), true);
277 $this->ctrl->redirect($this, self::CMD_INDEX);
278 return;
279 }
280 $directory_name = $this->view_request->getPath() . $directory_name;
281
282 $success = $this->irss->manageContainer()->createDirectoryInsideContainer(
283 $this->view_configuration->getContainer()->getIdentification(),
284 $directory_name
285 );
286
287 if (!$success) {
288 $this->main_tpl->setOnScreenMessage('failure', $this->language->txt('msg_error_adding_directory'), true);
289 $this->ctrl->redirect($this, self::CMD_INDEX);
290 return;
291 }
292
293 $this->main_tpl->setOnScreenMessage('success', $this->language->txt('msg_success_adding_directory'), true);
294 $this->ctrl->redirect($this, self::CMD_INDEX);
295 }

References abortWithPermissionDenied(), ILIAS\Repository\ctrl(), ILIAS\FileDelivery\http(), and ILIAS\UI\examples\Symbol\Glyph\Language\language().

Referenced by executeCommand().

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

◆ download()

ilContainerResourceGUI::download ( )
private

Definition at line 349 of file class.ilContainerResourceGUI.php.

349 : never
350 {
351 $paths = $this->getPathsFromRequest();
352
353 $this->view_request->getWrapper()->download(
354 $paths[0]
355 );
356 }

References getPathsFromRequest().

Referenced by executeCommand().

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

◆ downloadZIP()

ilContainerResourceGUI::downloadZIP ( )
private

Definition at line 259 of file class.ilContainerResourceGUI.php.

259 : never
260 {
261 $this->irss->consume()->download(
262 $this->view_configuration->getContainer()->getIdentification()
263 )->overrideFileName($this->view_request->getTitle())->run();
264 }

Referenced by executeCommand().

+ Here is the caller graph for this function:

◆ executeCommand()

ilContainerResourceGUI::executeCommand ( )

Definition at line 192 of file class.ilContainerResourceGUI.php.

192 : void
193 {
194 if ($this->view_request->handleViewTitle()) {
195 $title = $this->view_request->getTitle();
196 $this->main_tpl->setTitle($title);
197 $description = $this->view_request->getDescription();
198 if ($description !== null) {
199 $this->main_tpl->setDescription($description);
200 }
201 }
202
203 switch ($this->ctrl->getCmd(self::CMD_INDEX)) {
204 case self::CMD_INDEX:
205 $this->index();
206 break;
207 case self::CMD_UPLOAD:
208 $this->upload();
209 break;
211 $this->postUpload();
212 break;
213 case self::CMD_REMOVE:
214 $this->remove();
215 break;
217 $this->download();
218 break;
219 case self::CMD_UNZIP:
220 $this->unzip();
221 break;
223 $this->renderConfirmRemove();
224 break;
226 $this->addDirectory();
227 break;
229 $this->downloadZIP();
230 break;
231 }
232 }

References ADD_DIRECTORY, addDirectory(), CMD_DOWNLOAD, CMD_DOWNLOAD_ZIP, CMD_INDEX, CMD_POST_UPLOAD, CMD_REMOVE, CMD_RENDER_CONFIRM_REMOVE, CMD_UNZIP, CMD_UPLOAD, ILIAS\Repository\ctrl(), download(), downloadZIP(), index(), postUpload(), renderConfirmRemove(), unzip(), and upload().

+ Here is the call graph for this function:

◆ getExistingFileInfoURL()

ilContainerResourceGUI::getExistingFileInfoURL ( )
Returns
string of the URL where in GUI existing files are handled. The URL is called by GET with a field with name from getFileIdentifierParameterName() and the FileID of the desired file. Return a FI

Implements ILIAS\UI\Component\Input\Field\UploadHandler.

Definition at line 477 of file class.ilContainerResourceGUI.php.

477 : string
478 {
479 return $this->ctrl->getLinkTarget($this, self::CMD_INFO);
480 }

References ILIAS\Repository\ctrl().

+ Here is the call graph for this function:

◆ getFileIdentifierParameterName()

ilContainerResourceGUI::getFileIdentifierParameterName ( )
Returns
string defaults to self::DEFAULT_FILE_ID_PARAMETER

Implements ILIAS\UI\Component\Input\Field\UploadHandler.

Definition at line 462 of file class.ilContainerResourceGUI.php.

462 : string
463 {
464 return self::P_PATH;
465 }

References P_PATH.

◆ getFileRemovalURL()

ilContainerResourceGUI::getFileRemovalURL ( )
Returns
string of the URL where in GUI deleted files are handled. The URL is called by POST with a field with name from getFileIdentifierParameterName() and the FileID of the deleted file.

Implements ILIAS\UI\Component\Input\Field\UploadHandler.

Definition at line 472 of file class.ilContainerResourceGUI.php.

472 : string
473 {
474 return '';
475 }

◆ getInfoForExistingFiles()

ilContainerResourceGUI::getInfoForExistingFiles ( array  $file_ids)
Parameters
array$file_ids
Returns
BasicFileInfoResult[]

Implements ILIAS\UI\Component\Input\Field\UploadHandler.

Definition at line 482 of file class.ilContainerResourceGUI.php.

482 : array
483 {
484 return [];
485 }

◆ getInfoResult()

ilContainerResourceGUI::getInfoResult ( string  $identifier)
Returns
null|FileInfoResult for the file with the given identifier or null if the file does not exist.

Implements ILIAS\UI\Component\Input\Field\UploadHandler.

Definition at line 487 of file class.ilContainerResourceGUI.php.

488 {
489 return null;
490 }

◆ getPathsFromRequest()

ilContainerResourceGUI::getPathsFromRequest ( )
private

Definition at line 358 of file class.ilContainerResourceGUI.php.

358 : array
359 {
360 $unhash = fn(string $path): string => $this->unhash($path);
361 $unhash_array = static fn(array $paths): array => array_map(
362 $unhash,
363 $paths
364 );
365 $to_string = $this->refinery->kindlyTo()->string();
366 $to_array_of_strings = $this->refinery->kindlyTo()->listOf(
367 $to_string
368 );
369
370 // Get item from table
371 $token_name = $this->action_builder->getUrlToken()->getName();
372 if ($this->http->wrapper()->query()->has($token_name)) {
373 return $unhash_array(
374 $this->http->wrapper()->query()->retrieve(
375 $token_name,
376 $to_array_of_strings
377 ) ?? []
378 );
379 }
380
381 if ($this->http->wrapper()->post()->has('interruptive_items')) {
382 return $unhash_array(
383 $this->http->wrapper()->post()->retrieve(
384 'interruptive_items',
385 $to_array_of_strings
386 )
387 );
388 }
389
390 return [];
391 }
$path
Definition: ltiservices.php:30

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

Referenced by download(), remove(), renderConfirmRemove(), and unzip().

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

◆ getUploadURL()

ilContainerResourceGUI::getUploadURL ( )
Returns
string of the URL where dropped files are sent to. This URL must make sure the upload is handled and a \ILIAS\FileUpload\Handler\HandlerResult is returned as JSON.

Implements ILIAS\UI\Component\Input\Field\UploadHandler.

Definition at line 467 of file class.ilContainerResourceGUI.php.

467 : string
468 {
469 return $this->ctrl->getLinkTarget($this, self::CMD_UPLOAD);
470 }

References ILIAS\Repository\ctrl().

+ Here is the call graph for this function:

◆ index()

ilContainerResourceGUI::index ( )
private

Definition at line 236 of file class.ilContainerResourceGUI.php.

236 : void
237 {
238 global $DIC;
239 $components = [];
240
241 // Add components from Actions
242 $components = array_merge(
244 $this->action_provider->getComponents()
245 );
246
247 // Add components from the selected view (currently data-table)
248 foreach ($this->view_factory->getComponentProvider($this->view_request)->getComponents() as $component) {
249 $components[] = $component;
250 }
251
252 $this->main_tpl->setContent(
253 $this->ui_renderer->render(
255 )
256 );
257 }
$components

References $components, and $DIC.

Referenced by executeCommand().

+ Here is the caller graph for this function:

◆ postUpload()

ilContainerResourceGUI::postUpload ( )
private

Definition at line 334 of file class.ilContainerResourceGUI.php.

334 : void
335 {
336 if (!$this->view_request->canUserUplaod()) {
338 return;
339 }
340 if ($this->http->request()->getParsedBody() === []) { // nothing uploaded
341 $this->main_tpl->setOnScreenMessage('failure', $this->language->txt('rids_appended_failed'), true);
342 } else {
343 $this->main_tpl->setOnScreenMessage('success', $this->language->txt('rids_appended'), true);
344 }
345
346 $this->ctrl->redirect($this, self::CMD_INDEX);
347 }

References abortWithPermissionDenied(), ILIAS\Repository\ctrl(), ILIAS\FileDelivery\http(), and ILIAS\UI\examples\Symbol\Glyph\Language\language().

Referenced by executeCommand().

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

◆ remove()

ilContainerResourceGUI::remove ( )
private

Definition at line 435 of file class.ilContainerResourceGUI.php.

435 : void
436 {
437 if (!$this->view_request->canUserAdministrate()) {
439 return;
440 }
441 $paths = $this->getPathsFromRequest();
442
443 if (empty($paths)) {
444 $this->main_tpl->setOnScreenMessage('failure', $this->language->txt('msg_no_perm_read'), true);
445 $this->ctrl->redirect($this, self::CMD_INDEX);
446 return;
447 }
448
449 foreach ($paths as $path_inside_zip) {
450 $this->irss->manageContainer()->removePathInsideContainer(
451 $this->view_configuration->getContainer()->getIdentification(),
452 $path_inside_zip
453 );
454 }
455
456 $this->main_tpl->setOnScreenMessage('success', $this->language->txt('msg_paths_deleted'), true);
457 $this->ctrl->redirect($this, self::CMD_INDEX);
458 }

References abortWithPermissionDenied(), ILIAS\Repository\ctrl(), getPathsFromRequest(), and ILIAS\UI\examples\Symbol\Glyph\Language\language().

+ Here is the call graph for this function:

◆ renderConfirmRemove()

ilContainerResourceGUI::renderConfirmRemove ( )
private

Definition at line 408 of file class.ilContainerResourceGUI.php.

408 : void
409 {
410 if (!$this->view_request->canUserAdministrate()) {
412 return;
413 }
414 $paths = $this->getPathsFromRequest();
415
416 $stream = Streams::ofString(
417 $this->ui_renderer->render(
418 $this->ui_factory->modal()->interruptive(
419 $this->language->txt('action_remove_zip_path'),
420 $this->language->txt('action_remove_zip_path_msg'),
421 $this->ctrl->getLinkTarget($this, self::CMD_REMOVE)
422 )->withAffectedItems(
423 array_map(fn(string $path_inside_zip): Standard => $this->ui_factory->modal()->interruptiveItem()->standard(
424 $this->hash($path_inside_zip),
425 $path_inside_zip
426 ), $paths)
427 )
428 )
429 );
430 $this->http->saveResponse($this->http->response()->withBody($stream));
431 $this->http->sendResponse();
432 $this->http->close();
433 }

References abortWithPermissionDenied(), getPathsFromRequest(), and ILIAS\FileDelivery\http().

Referenced by executeCommand().

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

◆ supportsChunkedUploads()

ilContainerResourceGUI::supportsChunkedUploads ( )
Returns
bool if this uploadhandler chan handle Chunked Uploads. These come in multiple requests and must be combined to a single file. If your UploadHandler can handle Chunked Uploads, you can use a UI\Component\Input\Field\Upload\File with .

Implements ILIAS\UI\Component\Input\Field\UploadHandler.

Definition at line 492 of file class.ilContainerResourceGUI.php.

492 : bool
493 {
494 return false;
495 }

◆ unzip()

ilContainerResourceGUI::unzip ( )
private

Definition at line 393 of file class.ilContainerResourceGUI.php.

393 : void
394 {
395 if (!$this->view_request->canUserAdministrate()) {
397 return;
398 }
399 $paths = $this->getPathsFromRequest()[0];
400 $this->view_request->getWrapper()->unzip(
401 $paths
402 );
403
404 $this->main_tpl->setOnScreenMessage('success', $this->language->txt('rids_appended'), true);
405 $this->ctrl->redirect($this, self::CMD_INDEX);
406 }

References abortWithPermissionDenied(), ILIAS\Repository\ctrl(), getPathsFromRequest(), and ILIAS\UI\examples\Symbol\Glyph\Language\language().

Referenced by executeCommand().

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

◆ upload()

ilContainerResourceGUI::upload ( )

Definition at line 297 of file class.ilContainerResourceGUI.php.

297 : void
298 {
299 if (!$this->view_request->canUserUplaod()) {
301 return;
302 }
303 $this->upload->process();
304 if (!$this->upload->hasUploads()) {
305 return;
306 }
307 $container = $this->view_configuration->getContainer();
308
309 foreach ($this->upload->getResults() as $result) {
310 if (!$result->isOK()) {
311 continue;
312 }
313 // store to zip
314 $return = $this->irss->manageContainer()->addUploadToContainer(
315 $container->getIdentification(),
316 $result,
317 $this->view_request->getPath()
318 );
319 }
320
321 // OK
322 $upload_result = new BasicHandlerResult(
323 self::P_PATH,
324 $return ? BasicHandlerResult::STATUS_OK : BasicHandlerResult::STATUS_FAILED,
325 '-',
326 'undefined error'
327 );
328 $response = $this->http->response()->withBody(Streams::ofString(json_encode($upload_result)));
329 $this->http->saveResponse($response);
330 $this->http->sendResponse();
331 $this->http->close();
332 }
$container
@noRector
Definition: wac.php:37
$response
Definition: xapitoken.php:90

References $container, $response, abortWithPermissionDenied(), ILIAS\FileDelivery\http(), and upload().

Referenced by __construct(), executeCommand(), and upload().

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

Field Documentation

◆ $action_builder

ActionBuilder ilContainerResourceGUI::$action_builder
private

Definition at line 111 of file class.ilContainerResourceGUI.php.

◆ $action_provider

ActionProvider ilContainerResourceGUI::$action_provider
private

Definition at line 117 of file class.ilContainerResourceGUI.php.

◆ $archive

Archives ilContainerResourceGUI::$archive
private

Definition at line 115 of file class.ilContainerResourceGUI.php.

◆ $ctrl

ilCtrlInterface ilContainerResourceGUI::$ctrl
private

Definition at line 102 of file class.ilContainerResourceGUI.php.

◆ $http

Services ilContainerResourceGUI::$http
private

Definition at line 108 of file class.ilContainerResourceGUI.php.

◆ $irss

ILIAS ResourceStorage Services ilContainerResourceGUI::$irss
private

Definition at line 110 of file class.ilContainerResourceGUI.php.

◆ $language

ilLanguage ilContainerResourceGUI::$language
private

Definition at line 109 of file class.ilContainerResourceGUI.php.

◆ $main_tpl

ilGlobalTemplateInterface ilContainerResourceGUI::$main_tpl
private

Definition at line 103 of file class.ilContainerResourceGUI.php.

◆ $preview_definition

PreviewDefinition ilContainerResourceGUI::$preview_definition
private

Definition at line 116 of file class.ilContainerResourceGUI.php.

◆ $refinery

Factory ilContainerResourceGUI::$refinery
private

Definition at line 107 of file class.ilContainerResourceGUI.php.

◆ $standard_action_provider

StandardActionProvider ilContainerResourceGUI::$standard_action_provider
private

Definition at line 118 of file class.ilContainerResourceGUI.php.

◆ $ui_factory

ILIAS UI Factory ilContainerResourceGUI::$ui_factory
private

Definition at line 113 of file class.ilContainerResourceGUI.php.

◆ $ui_renderer

Renderer ilContainerResourceGUI::$ui_renderer
private

Definition at line 106 of file class.ilContainerResourceGUI.php.

◆ $upload

FileUpload ilContainerResourceGUI::$upload
private

Definition at line 114 of file class.ilContainerResourceGUI.php.

◆ $view_control_builder

ViewControlBuilder ilContainerResourceGUI::$view_control_builder
private

Definition at line 112 of file class.ilContainerResourceGUI.php.

Referenced by __construct().

◆ $view_factory

ViewFactory ilContainerResourceGUI::$view_factory
private

Definition at line 105 of file class.ilContainerResourceGUI.php.

◆ $view_request

Request ilContainerResourceGUI::$view_request
private

Definition at line 104 of file class.ilContainerResourceGUI.php.

◆ ADD_DIRECTORY

const ilContainerResourceGUI::ADD_DIRECTORY = 'addDirectory'

◆ CMD_DOWNLOAD

const ilContainerResourceGUI::CMD_DOWNLOAD = 'download'

◆ CMD_DOWNLOAD_ZIP

const ilContainerResourceGUI::CMD_DOWNLOAD_ZIP = 'downloadZIP'

◆ CMD_INDEX

◆ CMD_INFO

const ilContainerResourceGUI::CMD_INFO = 'info'

Definition at line 65 of file class.ilContainerResourceGUI.php.

◆ CMD_POST_UPLOAD

const ilContainerResourceGUI::CMD_POST_UPLOAD = 'postUpload'

◆ CMD_REMOVE

const ilContainerResourceGUI::CMD_REMOVE = 'remove'

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

Referenced by executeCommand().

◆ CMD_RENDER_CONFIRM_REMOVE

const ilContainerResourceGUI::CMD_RENDER_CONFIRM_REMOVE = 'renderConfirmRemove'

◆ CMD_UNZIP

const ilContainerResourceGUI::CMD_UNZIP = 'unzip'

◆ CMD_UPLOAD

const ilContainerResourceGUI::CMD_UPLOAD = 'upload'

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

Referenced by executeCommand().

◆ P_PATH

const ilContainerResourceGUI::P_PATH = 'path'

◆ P_PATHS

const ilContainerResourceGUI::P_PATHS = 'paths'

Definition at line 56 of file class.ilContainerResourceGUI.php.


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