38use ILIAS\components\ResourceStorage\Container\View\PreviewDefinition;
110 private \ILIAS\ResourceStorage\Services
$irss;
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();
131 $this->
language->loadLanguageModule(
'irss');
132 $this->irss =
$DIC->resourceStorage();
133 $this->
upload = $DIC->upload();
135 $this->view_request =
new Request(
137 $DIC->http()->wrapper()->query(),
138 $this->view_configuration
142 $this->view_request->init($this);
146 $this->view_configuration->getActionProvider()
154 $DIC->ui()->factory(),
157 $this->action_provider
164 $DIC->ui()->factory(),
171 $DIC->ui()->factory(),
178 $this->action_builder,
188 $this->main_tpl->setOnScreenMessage(
'failure', $this->
language->txt(
'msg_no_perm_read'),
true);
189 $this->
ctrl->redirect($this, self::CMD_INDEX);
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);
203 switch ($this->
ctrl->getCmd(self::CMD_INDEX)) {
244 $this->action_provider->getComponents()
248 foreach ($this->view_factory->getComponentProvider($this->view_request)->getComponents() as $component) {
252 $this->main_tpl->setContent(
253 $this->ui_renderer->render(
261 $this->irss->consume()->download(
262 $this->view_configuration->getContainer()->getIdentification()
263 )->overrideFileName($this->view_request->getTitle())->run();
268 if (!$this->view_request->canUserAdministrate()) {
272 $modal = $this->standard_action_provider->getAddDirectoryModal()->withRequest($this->
http->request());
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);
280 $directory_name = $this->view_request->getPath() . $directory_name;
282 $success = $this->irss->manageContainer()->createDirectoryInsideContainer(
283 $this->view_configuration->getContainer()->getIdentification(),
288 $this->main_tpl->setOnScreenMessage(
'failure', $this->
language->txt(
'msg_error_adding_directory'),
true);
289 $this->
ctrl->redirect($this, self::CMD_INDEX);
293 $this->main_tpl->setOnScreenMessage(
'success', $this->
language->txt(
'msg_success_adding_directory'),
true);
294 $this->
ctrl->redirect($this, self::CMD_INDEX);
299 if (!$this->view_request->canUserUplaod()) {
304 if (!$this->
upload->hasUploads()) {
307 $container = $this->view_configuration->getContainer();
309 foreach ($this->
upload->getResults() as $result) {
310 if (!$result->isOK()) {
314 $return = $this->irss->manageContainer()->addUploadToContainer(
317 $this->view_request->getPath()
324 $return ? BasicHandlerResult::STATUS_OK : BasicHandlerResult::STATUS_FAILED,
328 $response = $this->
http->response()->withBody(Streams::ofString(json_encode($upload_result)));
330 $this->
http->sendResponse();
331 $this->
http->close();
336 if (!$this->view_request->canUserUplaod()) {
340 if ($this->
http->request()->getParsedBody() === []) {
341 $this->main_tpl->setOnScreenMessage(
'failure', $this->
language->txt(
'rids_appended_failed'),
true);
343 $this->main_tpl->setOnScreenMessage(
'success', $this->
language->txt(
'rids_appended'),
true);
346 $this->
ctrl->redirect($this, self::CMD_INDEX);
353 $this->view_request->getWrapper()->download(
360 $unhash = fn(
string $path):
string => $this->unhash(
$path);
361 $unhash_array =
static fn(array $paths): array => array_map(
365 $to_string = $this->
refinery->kindlyTo()->string();
366 $to_array_of_strings = $this->
refinery->kindlyTo()->listOf(
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(
381 if ($this->
http->wrapper()->post()->has(
'interruptive_items')) {
382 return $unhash_array(
383 $this->
http->wrapper()->post()->retrieve(
384 'interruptive_items',
395 if (!$this->view_request->canUserAdministrate()) {
400 $this->view_request->getWrapper()->unzip(
404 $this->main_tpl->setOnScreenMessage(
'success', $this->
language->txt(
'rids_appended'),
true);
405 $this->
ctrl->redirect($this, self::CMD_INDEX);
410 if (!$this->view_request->canUserAdministrate()) {
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),
430 $this->
http->saveResponse($this->
http->response()->withBody($stream));
431 $this->
http->sendResponse();
432 $this->
http->close();
435 private function remove():
void
437 if (!$this->view_request->canUserAdministrate()) {
444 $this->main_tpl->setOnScreenMessage(
'failure', $this->
language->txt(
'msg_no_perm_read'),
true);
445 $this->
ctrl->redirect($this, self::CMD_INDEX);
449 foreach ($paths as $path_inside_zip) {
450 $this->irss->manageContainer()->removePathInsideContainer(
451 $this->view_configuration->getContainer()->getIdentification(),
456 $this->main_tpl->setOnScreenMessage(
'success', $this->
language->txt(
'msg_paths_deleted'),
true);
457 $this->
ctrl->redirect($this, self::CMD_INDEX);
469 return $this->
ctrl->getLinkTarget($this, self::CMD_UPLOAD);
479 return $this->
ctrl->getLinkTarget($this, self::CMD_INFO);
Class BasicHandlerResult.
Stream factory which enables the user to create streams without the knowledge of the concrete class.
ActionProvider $action_provider
__construct(private Configuration $view_configuration)
StandardActionProvider $standard_action_provider
getInfoForExistingFiles(array $file_ids)
ilGlobalTemplateInterface $main_tpl
ActionBuilder $action_builder
PreviewDefinition $preview_definition
ILIAS ResourceStorage Services $irss
abortWithPermissionDenied()
ViewFactory $view_factory
getFileIdentifierParameterName()
const CMD_RENDER_CONFIRM_REMOVE
getInfoResult(string $identifier)
ILIAS UI Factory $ui_factory
ViewControlBuilder $view_control_builder
Interface FileInfoResult.
Interface InterruptiveItem.
An entity that renders components to a string output.
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.