19 declare(strict_types=1);
44 class Handler implements ilExportHandlerTableInterface
73 protected ilExportHandlerConsumerContextInterface
$context;
82 ilExportHandler $export_handler,
89 $this->
lng->loadLanguageModule(
"export");
99 $format = $this->data_factory->dateFormat()->withTime12($this->
user->getDateFormat());
101 $format = $this->data_factory->dateFormat()->withTime24($this->
user->getDateFormat());
104 self::TABLE_COL_TYPE => $this->ui_services->factory()->table()->column()->text(
105 $this->
lng->txt(self::TABLE_COL_LNG_TYPE)
106 )->withHighlight(
true),
107 self::TABLE_COL_FILE => $this->ui_services->factory()->table()->column()->text(
108 $this->
lng->txt(self::TABLE_COL_LNG_FILE)
109 )->withHighlight(
true),
110 self::TABLE_COL_SIZE => $this->ui_services->factory()->table()->column()->number(
111 $this->
lng->txt(self::TABLE_COL_LNG_SIZE)
113 ->withHighlight(
true)
115 self::TABLE_COL_TIMESTAMP => $this->ui_services->factory()->table()->column()->date(
116 $this->
lng->txt(self::TABLE_COL_LNG_TIMESTAMP),
119 self::TABLE_COL_PUBLIC_ACCESS => $this->ui_services->factory()->table()->column()->status(
120 $this->
lng->txt(self::TABLE_COL_LNG_PUBLIC_ACCESS),
127 $this->url_builder =
new URLBuilder($this->data_factory->uri($this->http_services->request()->getUri()->__toString()));
128 list($this->url_builder, $this->action_parameter_token, $this->row_id_token) =
129 $this->url_builder->acquireParameters(
130 [
'datatable', self::TABLE_ID],
131 self::TABLE_ACTION_ID,
135 self::ACTION_PUBLIC_ACCESS => $this->ui_services->factory()->table()->action()->single(
136 $this->
lng->txt(
'exp_toggle_public_access'),
137 $this->url_builder->withParameter($this->action_parameter_token, self::ACTION_PUBLIC_ACCESS),
140 self::ACTION_DOWNLOAD => $this->ui_services->factory()->table()->action()->single(
141 $this->
lng->txt(
'download'),
142 $this->url_builder->withParameter($this->action_parameter_token, self::ACTION_DOWNLOAD),
145 self::ACTION_DELETE => $this->ui_services->factory()->table()->action()->standard(
146 $this->
lng->txt(
'delete'),
147 $this->url_builder->withParameter($this->action_parameter_token, self::ACTION_DELETE),
156 #[NoReturn] protected function showDeleteModal(array $ids_sorted): void 160 foreach ($ids_sorted as $export_option_id => $file_identifiers) {
161 $export_option = $this->export_options->getById($export_option_id);
162 foreach ($export_option->getFileSelection($this->context, $file_identifiers) as $file_info) {
163 $table_row_id = $this->export_handler->table()->rowId()->handler()
164 ->withExportOptionId($export_option_id)
165 ->withFileIdentifier($file_info->getFileIdentifier());
166 $ids[] = $table_row_id->getCompositId();
167 $items[] = $this->ui_services->factory()->modal()->interruptiveItem()->standard(
168 $table_row_id->getCompositId(),
169 $file_info->getFileName()
173 echo($this->ui_services->renderer()->renderAsync([
174 $this->ui_services->factory()->modal()->interruptive(
175 $this->
lng->txt(
'confirm'),
176 $this->
lng->txt(
'exp_really_delete'),
177 (string) $this->url_builder
179 $this->action_parameter_token,
180 self::ACTION_CONFIRM_DELETE
185 )->withAffectedItems($items)
195 $object_id = $this->data_factory->objId($this->context->exportObject()->getId());
196 foreach ($ids_sorted as $export_option_id => $file_identifiers) {
197 $export_option = $this->export_options->getById($export_option_id);
199 $this->export_handler->publicAccess()->handler()->hasPublicAccessFile($object_id) and
200 $this->export_handler->publicAccess()->handler()->getPublicAccessFileExportOptionId($object_id) === $export_option->getExportOptionId() and
201 in_array($this->export_handler->publicAccess()->handler()->getPublicAccessFileIdentifier($object_id), $file_identifiers->toStringArray())
203 $this->export_handler->publicAccess()->handler()->removePublicAccessFile($object_id);
205 $export_option->onDeleteFiles(
217 $pa_repository = $this->export_handler->publicAccess()->repository()->handler();
218 $pa_repository_element_factory = $this->export_handler->publicAccess()->repository()->element();
219 $pa_repository_key_factory = $this->export_handler->publicAccess()->repository()->key();
220 $pa_repository_values_factory = $this->export_handler->publicAccess()->repository()->values();
221 $obj_id = $this->data_factory->objId($this->context->exportObject()->getId());
222 foreach ($ids_sorted as $export_option_id => $file_identifiers) {
223 $export_option = $this->export_options->getById($export_option_id);
224 $type_allowed = $export_option->isPublicAccessPossible();
225 foreach ($export_option->getFileSelection($this->context, $file_identifiers) as $file_info) {
226 $key = $pa_repository_key_factory->handler()
227 ->withObjectId($obj_id);
228 if ($file_info->getPublicAccessEnabled() and $pa_repository->hasElement($key)) {
229 $pa_repository->deleteElement($key);
233 !$export_option->isPublicAccessPossible() or
234 !$file_info->getPublicAccessPossible() or
239 $values = $pa_repository_values_factory->handler()
240 ->withIdentification($file_info->getFileIdentifier())
241 ->withExportOptionId($export_option->getExportOptionId());
242 $element = $pa_repository_element_factory->handler()
244 ->withValues($values);
245 $pa_repository->storeElement($element);
248 $this->
ctrl->redirect($this->context->exportGUIObject(), $this->context->exportGUIObject()::CMD_LIST_EXPORT_FILES);
256 foreach ($ids_sorted as $export_option_id => $file_identifiers) {
257 $export_option = $this->export_options->getById($export_option_id);
258 $export_option->onDownloadFiles(
267 if (isset($this->table)) {
270 $this->table = $this->ui_services->factory()->table()->data(
271 $this->export_handler->table()->dataRetrieval()
272 ->withExportOptions($this->export_options)
273 ->withExportObject($this->context->exportObject())
274 ->withExportGUI($this->context->exportGUIObject()),
275 $this->
lng->txt(
"exp_export_files"),
278 ->withId(self::TABLE_ID)
280 ->withRequest($this->http_services->request());
289 $key = $this->export_handler->repository()->key()->handler()
290 ->withObjectId($this->data_factory->objId($this->context->exportObject()->getId()));
291 $key_collection = $this->export_handler->repository()->key()->collection()
293 $elements = $this->export_handler->repository()->handler()->getElements($key_collection);
294 foreach ($this->export_options as $export_option) {
295 $export_option_id = $export_option->getExportOptionId();
296 $ids_sorted[$export_option_id] = $this->export_handler->consumer()->file()->identifier()->collection();
297 foreach ($export_option->getFiles($this->context) as $file_info) {
298 $file_identifier = $this->export_handler->consumer()->file()->identifier()->handler()
299 ->withIdentifier($file_info->getFileIdentifier());
300 $ids_sorted[$export_option_id] = $ids_sorted[$export_option_id]
301 ->withElement($file_identifier);
312 $tokens = $this->http_services->wrapper()->query()->retrieve(
313 $this->row_id_token->getName(),
314 $this->
refinery->custom()->transformation(fn($v) => $v)
316 $composit_ids = is_array($tokens) ? $tokens : [$tokens];
318 foreach ($composit_ids as $composit_id) {
319 $table_row_id = $this->export_handler->table()->rowId()->handler()
320 ->withCompositId($composit_id);
321 $file_identifier = $this->export_handler->consumer()->file()->identifier()->handler()
322 ->withIdentifier($table_row_id->getFileIdentifier());
323 $export_option = $this->export_options->getById($table_row_id->getExportOptionId());
324 if (!isset($ids_sorted[$table_row_id->getExportOptionId()])) {
325 $ids_sorted[$table_row_id->getExportOptionId()] = $this->export_handler->consumer()->file()->identifier()->collection();
327 $ids_sorted[$table_row_id->getExportOptionId()] = $ids_sorted[$table_row_id->getExportOptionId()]
328 ->withElement($file_identifier);
336 if (!$this->http_services->wrapper()->query()->has($this->action_parameter_token->getName())) {
339 $action = $this->http_services->wrapper()->query()->retrieve(
340 $this->action_parameter_token->getName(),
343 $tokens = $this->http_services->wrapper()->query()->retrieve(
344 $this->row_id_token->getName(),
345 $this->
refinery->custom()->transformation(fn($v) => $v)
347 $all_entries = ($tokens[0] ??
"") === self::ALL_OBJECTS;
356 case self::ACTION_PUBLIC_ACCESS:
359 case self::ACTION_DOWNLOAD:
362 case self::ACTION_DELETE:
363 $this->showDeleteModal($ids_sorted);
365 case self::ACTION_CONFIRM_DELETE:
374 return $this->ui_services->renderer()->render([$this->table]);
378 ilExportHandlerConsumerExportOptionCollectionInterface $export_options
379 ): ilExportHandlerTableInterface {
380 $clone = clone $this;
385 public function withContext(ilExportHandlerConsumerContextInterface $context): ilExportHandlerTableInterface
387 $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
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
withExportOptions(ilExportHandlerConsumerExportOptionCollectionInterface $export_options)
ilDataFactory $data_factory
markAsPublicAccess(array $ids_sorted)
exit
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
ilExportHandlerConsumerContextInterface $context
ilExportHandler $export_handler