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;
79 $this->
ctrl = $DIC->ctrl();
80 $this->main_tpl = $DIC->ui()->mainTemplate();
81 $this->ui_renderer = $DIC->ui()->renderer();
82 $this->ui_factory = $DIC->ui()->factory();
83 $this->
http = $DIC->http();
86 $this->
language->loadLanguageModule(
'irss');
87 $this->irss = $DIC->resourceStorage();
88 $this->
upload = $DIC->upload();
89 $this->archive = $DIC->archives();
92 $this->view_request =
new Request(
94 $DIC->http()->wrapper()->query(),
95 $this->view_configuration
103 $DIC->ui()->factory(),
112 $DIC->ui()->factory(),
119 $DIC->ui()->factory(),
126 $this->action_builder,
127 $view_control_builder,
141 if ($rid === null || !$this->view_request->getCollection()->isIn($rid)) {
149 $this->main_tpl->setOnScreenMessage(
'failure', $this->
language->txt(
'msg_no_perm_read'),
true);
150 $this->
ctrl->redirect($this, self::CMD_INDEX);
155 if ($this->view_request->handleViewTitle()) {
156 $title = $this->view_request->getTitle();
157 if ($title !== null) {
158 $this->main_tpl->setTitle($title);
160 $description = $this->view_request->getDescription();
161 if ($description !== null) {
162 $this->main_tpl->setDescription($description);
166 $this->view_request->init($this);
168 switch ($this->
ctrl->getCmd(self::CMD_INDEX)) {
169 case self::CMD_INDEX:
172 case self::CMD_UPLOAD:
175 case self::CMD_POST_UPLOAD:
178 case self::CMD_REMOVE:
181 case self::CMD_DOWNLOAD:
184 case self::CMD_UNZIP:
187 case self::CMD_RENDER_CONFIRM_REMOVE:
193 case self::CMD_STORE:
203 $provider = $this->view_factory->getComponentProvider($this->view_request);
205 foreach (
$provider->getComponents() as $component) {
206 $components[] = $component;
209 $this->main_tpl->setContent($this->ui_renderer->render($components));
214 if (!$this->view_request->canUserUplaod()) {
219 if (!$this->
upload->hasUploads()) {
222 $collection = $this->view_request->getCollection();
223 foreach ($this->
upload->getResults() as $result) {
224 if (!$result->isOK()) {
227 $rid = $this->irss->manage()->upload(
229 $this->view_configuration->getStakeholder()
231 $collection->add($rid);
234 $this->irss->flavours()->ensure(
236 $this->preview_definition
239 $this->irss->collection()->store($collection);
242 BasicHandlerResult::STATUS_OK,
246 $response = $this->
http->response()->withBody(Streams::ofString(json_encode($upload_result)));
247 $this->
http->saveResponse($response);
248 $this->
http->sendResponse();
249 $this->
http->close();
254 if (!$this->view_request->canUserUplaod()) {
258 $this->main_tpl->setOnScreenMessage(
'success', $this->
language->txt(
'rids_appended'),
true);
259 $this->
ctrl->redirect($this, self::CMD_INDEX);
265 $this->irss->consume()->download($rid)->run();
270 if (!$this->view_request->canUserAdministrate()) {
275 $zip_stream = $this->irss->consume()->stream($rid)->getStream();
277 $collection = $this->view_request->getCollection();
279 $unzip_options = $this->archive->unzipOptions()
282 foreach ($this->archive->unzip($zip_stream, $unzip_options)->getFileStreams() as $stream) {
283 $rid = $this->irss->manage()->stream(
284 Streams::ofString($stream->getContents()),
285 $this->view_configuration->getStakeholder(),
286 basename($stream->getMetadata()[
'uri'])
288 $collection->add($rid);
292 $this->irss->flavours()->ensure(
294 $this->preview_definition
299 $this->irss->collection()->store($collection);
305 if (!$this->view_request->canUserAdministrate()) {
310 $this->
ctrl->setParameter(
313 $this->
hash($rid->serialize())
322 $modal = $this->ui_factory->modal()->roundtrip(
326 $this->
ctrl->getLinkTarget($this, self::CMD_STORE)
329 $signal = $modal->getForm()->getSubmitSignal();
331 $stream = Streams::ofString(
332 $this->ui_renderer->renderAsync(
337 $this->
http->saveResponse($this->
http->response()->withBody($stream));
338 $this->
http->sendResponse();
339 $this->
http->close();
344 if (!$this->view_request->canUserAdministrate()) {
352 ))->getAsForm($this->
ctrl->getLinkTarget($this, self::CMD_STORE))
354 $this->
http->request()
358 $this->main_tpl->setOnScreenMessage(
'success', $this->
language->txt(
'rids_updated'),
true);
359 $this->
ctrl->redirect($this, self::CMD_INDEX);
364 if (!$this->view_request->canUserAdministrate()) {
369 $stream = Streams::ofString(
370 $this->ui_renderer->render(
371 $this->ui_factory->modal()->interruptive(
372 $this->
language->txt(
'action_remove_resource'),
373 $this->
language->txt(
'action_remove_resource_msg'),
374 $this->
ctrl->getLinkTarget($this, self::CMD_REMOVE)
375 )->withAffectedItems(
377 $revision = $this->irss->manage()->getCurrentRevision($rid);
379 return $this->ui_factory->modal()->interruptiveItem()->standard(
381 $revision->getTitle()
387 $this->
http->saveResponse($this->
http->response()->withBody($stream));
388 $this->
http->sendResponse();
389 $this->
http->close();
392 private function remove():
void 394 if (!$this->view_request->canUserAdministrate()) {
400 $this->main_tpl->setOnScreenMessage(
'failure', $this->
language->txt(
'msg_no_perm_read'),
true);
401 $this->
ctrl->redirect($this, self::CMD_INDEX);
404 foreach ($rids as $rid) {
405 if (!$this->view_request->getCollection()->isIn($rid)) {
406 $this->main_tpl->setOnScreenMessage(
'failure', $this->
language->txt(
'msg_no_perm_read'),
true);
407 $this->
ctrl->redirect($this, self::CMD_INDEX);
412 foreach ($rids as $rid) {
413 $this->irss->manage()->remove($rid, $this->view_configuration->getStakeholder());
416 $this->main_tpl->setOnScreenMessage(
'success', $this->
language->txt(
'rids_deleted'),
true);
417 $this->
ctrl->redirect($this, self::CMD_INDEX);
427 $token = $this->action_builder->getUrlToken();
428 $wrapper = $this->
http->wrapper();
429 $to_string = $this->
refinery->kindlyTo()->string();
430 $to_array_of_string = $this->
refinery->to()->listOf($to_string);
433 if ($wrapper->query()->has(
$token->getName())) {
435 $rid_string = $wrapper->query()->retrieve(
439 $rid_strings = explode(
',', $rid_string);
441 $rid_strings = $wrapper->query()->retrieve(
448 if ($wrapper->post()->has(
'interruptive_items')) {
449 $rid_strings = $wrapper->post()->retrieve(
450 'interruptive_items',
455 if(empty($rid_strings)) {
457 $rid_strings = $this->
http->wrapper()->query()->has(self::P_RESOURCE_ID)
458 ? [$this->
http->wrapper()->query()->retrieve(self::P_RESOURCE_ID, $this->
refinery->kindlyTo()->string())]
462 if (isset($rid_strings[0]) && $rid_strings[0] ===
'ALL_OBJECTS') {
463 return $this->view_request->getCollection()->getResourceIdentifications();
466 if ($rid_strings === []) {
469 $resource_identifications = [];
470 foreach ($rid_strings as $rid_string) {
471 $resource_identification = $this->irss->manage()->find($this->unhash($rid_string));
472 if ($resource_identification === null) {
475 $resource_identifications[] = $resource_identification;
477 return $resource_identifications;
483 return self::P_RESOURCE_ID;
488 return $this->
ctrl->getLinkTarget($this, self::CMD_UPLOAD);
498 return $this->
ctrl->getLinkTarget($this, self::CMD_INFO);
Will keep the top directory of the ZIP file if there is one (simple unzip).
getInfoResult(string $identifier)
ViewFactory $view_factory
ILIAS UI Renderer $ui_renderer
const CMD_RENDER_CONFIRM_REMOVE
ActionBuilder $action_builder
ILIAS Filesystem Util Archive Archives $archive
ILIAS UI Factory $ui_factory
static http()
Fetches the global http state from ILIAS.
__construct(private Configuration $view_configuration)
Class ResourceIdentification.
abortWithPermissionDenied()
Class BasicHandlerResult.
Interface FileInfoResult.
ILIAS HTTP Services $http
ILIAS Refinery Factory $refinery
ILIAS ResourceStorage Services $irss
checkResourceOrRedirect()
ViewControlBuilder $view_control_builder
PreviewDefinition $preview_definition
getFileIdentifierParameterName()
getResourceIdsFromRequest()
ILIAS FileUpload FileUpload $upload
getInfoForExistingFiles(array $file_ids)
ilGlobalTemplateInterface $main_tpl