65 private \ILIAS\HTTP\Services
$http;
67 private \ILIAS\ResourceStorage\Services
$irss;
71 private \ILIAS\FileUpload\FileUpload
$upload;
72 private \ILIAS\Filesystem\Util\Archive\Archives
$archive;
81 $this->
ctrl = $DIC->ctrl();
82 $this->main_tpl = $DIC->ui()->mainTemplate();
83 $this->ui_renderer = $DIC->ui()->renderer();
84 $this->ui_factory = $DIC->ui()->factory();
85 $this->
http = $DIC->http();
88 $this->
language->loadLanguageModule(
'irss');
89 $this->irss = $DIC->resourceStorage();
90 $this->
upload = $DIC->upload();
92 $this->view_request =
new Request(
94 $DIC->http()->wrapper()->query(),
95 $this->view_configuration
99 $this->view_request->init($this);
103 $this->view_configuration->getActionProvider()
111 $DIC->ui()->factory(),
121 $DIC->ui()->factory(),
128 $DIC->ui()->factory(),
135 $this->action_builder,
136 $view_control_builder,
145 $this->main_tpl->setOnScreenMessage(
'failure', $this->
language->txt(
'msg_no_perm_read'),
true);
146 $this->
ctrl->redirect($this, self::CMD_INDEX);
151 if ($this->view_request->handleViewTitle()) {
152 $title = $this->view_request->getTitle();
153 if ($title !== null) {
154 $this->main_tpl->setTitle($title);
156 $description = $this->view_request->getDescription();
157 if ($description !== null) {
158 $this->main_tpl->setDescription($description);
162 switch ($this->
ctrl->getCmd(self::CMD_INDEX)) {
163 case self::CMD_INDEX:
166 case self::CMD_UPLOAD:
169 case self::CMD_POST_UPLOAD:
172 case self::CMD_REMOVE:
175 case self::CMD_DOWNLOAD:
178 case self::CMD_UNZIP:
181 case self::CMD_RENDER_CONFIRM_REMOVE:
184 case self::ADD_DIRECTORY:
187 case self::CMD_DOWNLOAD_ZIP:
203 $this->action_provider->getComponents()
207 foreach ($this->view_factory->getComponentProvider($this->view_request)->getComponents() as $component) {
211 $this->main_tpl->setContent(
212 $this->ui_renderer->render(
220 $this->irss->consume()->download(
221 $this->view_configuration->getContainer()->getIdentification()
222 )->overrideFileName($this->view_request->getTitle())->run();
227 if (!$this->view_request->canUserAdministrate()) {
231 $modal = $this->standard_action_provider->getAddDirectoryModal()->withRequest($this->
http->request());
233 $directory_name = $modal->getData()[0] ??
'';
234 if (empty($directory_name)) {
235 $this->main_tpl->setOnScreenMessage(
'failure', $this->
language->txt(
'msg_error_adding_directory'),
true);
236 $this->
ctrl->redirect($this, self::CMD_INDEX);
239 $directory_name = $this->view_request->getPath() . $directory_name;
241 $success = $this->irss->manageContainer()->createDirectoryInsideContainer(
242 $this->view_configuration->getContainer()->getIdentification(),
247 $this->main_tpl->setOnScreenMessage(
'failure', $this->
language->txt(
'msg_error_adding_directory'),
true);
248 $this->
ctrl->redirect($this, self::CMD_INDEX);
252 $this->main_tpl->setOnScreenMessage(
'success', $this->
language->txt(
'msg_success_adding_directory'),
true);
253 $this->
ctrl->redirect($this, self::CMD_INDEX);
258 if (!$this->view_request->canUserUplaod()) {
263 if (!$this->
upload->hasUploads()) {
266 $container = $this->view_configuration->getContainer();
268 foreach ($this->
upload->getResults() as $result) {
269 if (!$result->isOK()) {
273 $return = $this->irss->manageContainer()->addUploadToContainer(
276 $this->view_request->getPath()
283 $return ? BasicHandlerResult::STATUS_OK : BasicHandlerResult::STATUS_FAILED,
287 $response = $this->
http->response()->withBody(Streams::ofString(json_encode($upload_result)));
289 $this->
http->sendResponse();
290 $this->
http->close();
295 if (!$this->view_request->canUserUplaod()) {
299 if ($this->
http->request()->getParsedBody() === []) {
300 $this->main_tpl->setOnScreenMessage(
'failure', $this->
language->txt(
'rids_appended_failed'),
true);
302 $this->main_tpl->setOnScreenMessage(
'success', $this->
language->txt(
'rids_appended'),
true);
305 $this->
ctrl->redirect($this, self::CMD_INDEX);
312 $this->view_request->getWrapper()->download(
314 $this->view_request->getPath()
320 $unhash = fn(
string $path) => $this->unhash($path);
321 $unhash_array =
static fn(array $paths) =>
array_map(
325 $to_string = $this->
refinery->kindlyTo()->string();
326 $to_array_of_strings = $this->
refinery->kindlyTo()->listOf(
331 $token_name = $this->action_builder->getUrlToken()->getName();
332 if ($this->
http->wrapper()->query()->has($token_name)) {
333 return $unhash_array(
334 $this->
http->wrapper()->query()->retrieve(
341 if ($this->
http->wrapper()->post()->has(
'interruptive_items')) {
342 return $unhash_array(
343 $this->
http->wrapper()->post()->retrieve(
344 'interruptive_items',
355 if (!$this->view_request->canUserAdministrate()) {
360 $this->view_request->getWrapper()->unzip(
369 if (!$this->view_request->canUserAdministrate()) {
375 $stream = Streams::ofString(
376 $this->ui_renderer->render(
377 $this->ui_factory->modal()->interruptive(
378 $this->
language->txt(
'action_remove_zip_path'),
379 $this->
language->txt(
'action_remove_zip_path_msg'),
380 $this->
ctrl->getLinkTarget($this, self::CMD_REMOVE)
381 )->withAffectedItems(
382 array_map(
function (
string $path_inside_zip) {
383 return $this->ui_factory->modal()->interruptiveItem()->standard(
384 $this->
hash($path_inside_zip),
391 $this->
http->saveResponse($this->
http->response()->withBody($stream));
392 $this->
http->sendResponse();
393 $this->
http->close();
396 private function remove():
void 398 if (!$this->view_request->canUserAdministrate()) {
405 $this->main_tpl->setOnScreenMessage(
'failure', $this->
language->txt(
'msg_no_perm_read'),
true);
406 $this->
ctrl->redirect($this, self::CMD_INDEX);
410 foreach ($paths as $path_inside_zip) {
411 $this->irss->manageContainer()->removePathInsideContainer(
412 $this->view_configuration->getContainer()->getIdentification(),
417 $this->main_tpl->setOnScreenMessage(
'success', $this->
language->txt(
'msg_paths_deleted'),
true);
418 $this->
ctrl->redirect($this, self::CMD_INDEX);
428 $token = $this->action_builder->getUrlToken();
429 $wrapper = $this->
http->wrapper();
430 $to_string = $this->
refinery->kindlyTo()->string();
431 $to_array_of_string = $this->
refinery->to()->listOf($to_string);
434 if ($wrapper->query()->has(
$token->getName())) {
436 $rid_string = $wrapper->query()->retrieve(
440 $rid_strings = explode(
',', $rid_string);
442 $rid_strings = $wrapper->query()->retrieve(
449 if ($wrapper->post()->has(
'interruptive_items')) {
450 $rid_strings = $wrapper->post()->retrieve(
451 'interruptive_items',
456 if ($rid_strings[0] ===
'ALL_OBJECTS') {
457 return $this->view_request->getWrapper()->getResourceIdentifications();
460 if ($rid_strings === []) {
463 $resource_identifications = [];
464 foreach ($rid_strings as $rid_string) {
465 $resource_identification = $this->irss->manage()->find($this->unhash($rid_string));
466 if ($resource_identification === null) {
469 $resource_identifications[] = $resource_identification;
471 return $resource_identifications;
483 return $this->
ctrl->getLinkTarget($this, self::CMD_UPLOAD);
493 return $this->
ctrl->getLinkTarget($this, self::CMD_INFO);
ILIAS UI Factory $ui_factory
ILIAS Refinery Factory $refinery
ilGlobalTemplateInterface $main_tpl
getInfoForExistingFiles(array $file_ids)
getResourceIdsFromRequest()
ILIAS ResourceStorage Services $irss
StandardActionProvider $standard_action_provider
ActionBuilder ActionProvider $action_provider
ViewControlBuilder $view_control_builder
abortWithPermissionDenied()
ILIAS HTTP Services $http
const CMD_RENDER_CONFIRM_REMOVE
__construct(private Configuration $view_configuration)
static http()
Fetches the global http state from ILIAS.
getFileIdentifierParameterName()
Class BasicHandlerResult.
ActionBuilder $action_builder
Interface FileInfoResult.
ILIAS UI Renderer $ui_renderer
ILIAS FileUpload FileUpload $upload
ILIAS Filesystem Util Archive Archives $archive
getInfoResult(string $identifier)
PreviewDefinition $preview_definition
language()
description: > Example for rendring a language glyph.
ViewFactory $view_factory