19 declare(strict_types=1);
41 class Handler implements ilExportHandlerTableInterface
70 protected ilExportHandlerConsumerContextInterface
$context;
80 ilExportHandler $export_handler,
87 $this->
lng->loadLanguageModule(
"export");
92 $this->public_access_enabled =
true;
98 $format = $this->data_factory->dateFormat()->withTime12($this->
user->getDateFormat());
100 $format = $this->data_factory->dateFormat()->withTime24($this->
user->getDateFormat());
103 self::TABLE_COL_TYPE => $this->ui_services->factory()->table()->column()->text(
104 $this->
lng->txt(self::TABLE_COL_LNG_TYPE)
105 )->withHighlight(
true),
106 self::TABLE_COL_FILE => $this->ui_services->factory()->table()->column()->text(
107 $this->
lng->txt(self::TABLE_COL_LNG_FILE)
108 )->withHighlight(
true),
109 self::TABLE_COL_SIZE => $this->ui_services->factory()->table()->column()->number(
110 $this->
lng->txt(self::TABLE_COL_LNG_SIZE)
112 ->withHighlight(
true)
114 self::TABLE_COL_TIMESTAMP => $this->ui_services->factory()->table()->column()->date(
115 $this->
lng->txt(self::TABLE_COL_LNG_TIMESTAMP),
120 $columns[self::TABLE_COL_PUBLIC_ACCESS] = $this->ui_services->factory()->table()->column()->status(
121 $this->
lng->txt(self::TABLE_COL_LNG_PUBLIC_ACCESS),
129 $this->url_builder =
new URLBuilder($this->data_factory->uri($this->http_services->request()->getUri()->__toString()));
130 list($this->url_builder, $this->action_parameter_token, $this->row_id_token) =
131 $this->url_builder->acquireParameters(
132 [
'datatable', self::TABLE_ID],
133 self::TABLE_ACTION_ID,
137 self::ACTION_DOWNLOAD => $this->ui_services->factory()->table()->action()->single(
138 $this->
lng->txt(
'download'),
139 $this->url_builder->withParameter($this->action_parameter_token, self::ACTION_DOWNLOAD),
142 self::ACTION_DELETE => $this->ui_services->factory()->table()->action()->standard(
143 $this->
lng->txt(
'delete'),
144 $this->url_builder->withParameter($this->action_parameter_token, self::ACTION_DELETE),
149 $actions[self::ACTION_PUBLIC_ACCESS] = $this->ui_services->factory()->table()->action()->single(
150 $this->
lng->txt(
'exp_toggle_public_access'),
151 $this->url_builder->withParameter($this->action_parameter_token, self::ACTION_PUBLIC_ACCESS),
161 #[NoReturn] protected function showDeleteModal(array $ids_sorted): void 165 foreach ($ids_sorted as $export_option_id => $file_identifiers) {
166 $export_option = $this->export_options->getById($export_option_id);
167 foreach ($export_option->getFileSelection($this->context, $file_identifiers) as $file_info) {
168 $table_row_id = $this->export_handler->table()->rowId()->handler()
169 ->withExportOptionId($export_option_id)
170 ->withFileIdentifier($file_info->getFileIdentifier());
171 $ids[] = $table_row_id->getCompositId();
172 $items[] = $this->ui_services->factory()->modal()->interruptiveItem()->standard(
173 $table_row_id->getCompositId(),
174 $file_info->getFileName()
178 echo($this->ui_services->renderer()->renderAsync([
179 $this->ui_services->factory()->modal()->interruptive(
180 $this->
lng->txt(
'confirm'),
181 $this->
lng->txt(
'exp_really_delete'),
182 (string) $this->url_builder
184 $this->action_parameter_token,
185 self::ACTION_CONFIRM_DELETE
190 )->withAffectedItems($items)
200 $object_id = $this->data_factory->objId($this->context->exportObject()->getId());
201 foreach ($ids_sorted as $export_option_id => $file_identifiers) {
202 $export_option = $this->export_options->getById($export_option_id);
204 $this->export_handler->publicAccess()->handler()->hasPublicAccessFile($object_id) and
205 $this->export_handler->publicAccess()->handler()->getPublicAccessFileExportOptionId($object_id) === $export_option->getExportOptionId() and
206 in_array($this->export_handler->publicAccess()->handler()->getPublicAccessFileIdentifier($object_id), $file_identifiers->toStringArray())
208 $this->export_handler->publicAccess()->handler()->removePublicAccessFile($object_id);
210 $export_option->onDeleteFiles(
223 $this->
ctrl->redirect(
224 $this->context->exportGUIObject(),
225 $this->context->exportGUIObject()::CMD_LIST_EXPORT_FILES
229 $pa_repository = $this->export_handler->publicAccess()->repository()->handler();
230 $pa_repository_element_factory = $this->export_handler->publicAccess()->repository()->element();
231 $pa_repository_key_factory = $this->export_handler->publicAccess()->repository()->key();
232 $pa_repository_values_factory = $this->export_handler->publicAccess()->repository()->values();
233 $obj_id = $this->data_factory->objId($this->context->exportObject()->getId());
234 foreach ($ids_sorted as $export_option_id => $file_identifiers) {
235 $export_option = $this->export_options->getById($export_option_id);
236 $type_allowed = $export_option->isPublicAccessPossible();
237 foreach ($export_option->getFileSelection($this->context, $file_identifiers) as $file_info) {
238 $key = $pa_repository_key_factory->handler()
239 ->withObjectId($obj_id);
240 if ($file_info->getPublicAccessEnabled() and $pa_repository->hasElement($key)) {
241 $pa_repository->deleteElement($key);
245 !$export_option->isPublicAccessPossible() or
246 !$file_info->getPublicAccessPossible() or
251 $values = $pa_repository_values_factory->handler()
252 ->withIdentification($file_info->getFileIdentifier())
253 ->withExportOptionId($export_option->getExportOptionId());
254 $element = $pa_repository_element_factory->handler()
256 ->withValues($values);
257 $pa_repository->storeElement($element);
260 $this->
ctrl->redirect(
261 $this->context->exportGUIObject(),
262 $this->context->exportGUIObject()::CMD_LIST_EXPORT_FILES
271 foreach ($ids_sorted as $export_option_id => $file_identifiers) {
272 $export_option = $this->export_options->getById($export_option_id);
273 $export_option->onDownloadFiles(
282 if (isset($this->table)) {
285 $this->table = $this->ui_services->factory()->table()->data(
286 $this->export_handler->table()->dataRetrieval()
287 ->withExportOptions($this->export_options)
288 ->withExportObject($this->context->exportObject())
289 ->withExportGUI($this->context->exportGUIObject()),
290 $this->
lng->txt(
"exp_export_files"),
293 ->withId(self::TABLE_ID)
295 ->withRequest($this->http_services->request());
304 $key = $this->export_handler->repository()->key()->handler()
305 ->withObjectId($this->data_factory->objId($this->context->exportObject()->getId()));
306 $key_collection = $this->export_handler->repository()->key()->collection()
308 $elements = $this->export_handler->repository()->handler()->getElements($key_collection);
309 foreach ($this->export_options as $export_option) {
310 $export_option_id = $export_option->getExportOptionId();
311 $ids_sorted[$export_option_id] = $this->export_handler->consumer()->file()->identifier()->collection();
312 foreach ($export_option->getFiles($this->context) as $file_info) {
313 $file_identifier = $this->export_handler->consumer()->file()->identifier()->handler()
314 ->withIdentifier($file_info->getFileIdentifier());
315 $ids_sorted[$export_option_id] = $ids_sorted[$export_option_id]
316 ->withElement($file_identifier);
327 $tokens = $this->http_services->wrapper()->query()->retrieve(
328 $this->row_id_token->getName(),
329 $this->
refinery->custom()->transformation(fn($v) => $v)
331 $composit_ids = is_array($tokens) ? $tokens : [$tokens];
333 foreach ($composit_ids as $composit_id) {
334 if (is_null($composit_id)) {
337 $table_row_id = $this->export_handler->table()->rowId()->handler()
338 ->withCompositId($composit_id);
339 $file_identifier = $this->export_handler->consumer()->file()->identifier()->handler()
340 ->withIdentifier($table_row_id->getFileIdentifier());
341 $export_option = $this->export_options->getById($table_row_id->getExportOptionId());
342 if (!isset($ids_sorted[$table_row_id->getExportOptionId()])) {
343 $ids_sorted[$table_row_id->getExportOptionId()] = $this->export_handler->consumer()->file()->identifier()->collection();
345 $ids_sorted[$table_row_id->getExportOptionId()] = $ids_sorted[$table_row_id->getExportOptionId()]
346 ->withElement($file_identifier);
354 if (!$this->http_services->wrapper()->query()->has($this->action_parameter_token->getName())) {
357 $action = $this->http_services->wrapper()->query()->retrieve(
358 $this->action_parameter_token->getName(),
361 $tokens = $this->http_services->wrapper()->query()->retrieve(
362 $this->row_id_token->getName(),
363 $this->
refinery->custom()->transformation(fn($v) => $v)
365 $all_entries = ($tokens[0] ??
"") === self::ALL_OBJECTS;
374 case self::ACTION_PUBLIC_ACCESS:
377 case self::ACTION_DOWNLOAD:
380 case self::ACTION_DELETE:
381 $this->showDeleteModal($ids_sorted);
383 case self::ACTION_CONFIRM_DELETE:
392 return $this->ui_services->renderer()->render([$this->table]);
396 ilExportHandlerConsumerExportOptionCollectionInterface $export_options
397 ): ilExportHandlerTableInterface {
398 $clone = clone $this;
404 ilExportHandlerConsumerContextInterface $context
405 ): ilExportHandlerTableInterface {
406 $clone = clone $this;
412 bool $public_access_enabled
413 ): ilExportHandlerTableInterface {
414 $clone = clone $this;
downloadItems(array $ids_sorted)
deleteItems(array $ids_sorted)
withContext(ilExportHandlerConsumerContextInterface $context)
const ACTION_CONFIRM_DELETE
ilURLBuilderToken $row_id_token
ilHTTPServices $http_services
withPublicAccessEnabled(bool $public_access_enabled)
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
const TABLE_COL_LNG_PUBLIC_ACCESS
readIdsFromExportOptions()
ilRefineryFactory $refinery
ilURLBuilderToken $action_parameter_token
const TABLE_COL_LNG_TIMESTAMP
const ACTION_PUBLIC_ACCESS
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
__construct(ilUIServices $ui_services, ilHTTPServices $http_services, ilRefineryFactory $refinery, ilObjUser $user, ilLanguage $lng, ilCtrl $ctrl, ilExportHandler $export_handler, ilDataFactory $data_factory)
ilExportHandlerConsumerExportOptionCollectionInterface $export_options
ilUIServices $ui_services
bool $public_access_enabled
withExportOptions(ilExportHandlerConsumerExportOptionCollectionInterface $export_options)
ilDataFactory $data_factory
markAsPublicAccess(array $ids_sorted)
ilExportHandlerConsumerContextInterface $context
ilExportHandler $export_handler