19 declare(strict_types=1);
41 private readonly array $records,
48 private readonly
string $parent_cmd,
51 $form_action = $this->df->uri(
53 $this->
ctrl->getLinkTarget($this->parent_gui, $this->parent_cmd)
60 ] = (new \ILIAS\UI\URLBuilder($form_action))->acquireParameters(
61 [
'mail',
'attachments'],
66 $this->data_factory = new \ILIAS\Data\Factory();
71 return $this->ui_factory
75 $this->
lng->txt(
'attachment'),
78 ->withId(self::class .
'_' . $this->mode->name)
81 ->withRequest($this->http_request);
90 $date_format = $this->data_factory->dateFormat()->withTime12($this->actor->getDateFormat());
92 $date_format = $this->data_factory->dateFormat()->withTime24($this->actor->getDateFormat());
96 'filename' => $this->ui_factory
99 ->text($this->
lng->txt(
'mail_file_name'))
100 ->withIsSortable(
true),
101 'filesize' => $this->ui_factory
104 ->text($this->
lng->txt(
'mail_file_size'))
105 ->withIsSortable(
true),
106 'filecreatedate' => $this->ui_factory
109 ->date($this->
lng->txt(
'create_date'), $date_format)
110 ->withIsSortable(
true),
122 $actions[
'saveAttachments'] = $this->ui_factory->table()->action()->multi(
123 $this->
lng->txt(
'adopt'),
124 $this->url_builder->withParameter($this->action_parameter_token,
'saveAttachments'),
128 $actions[
'deleteAttachments'] = $this->ui_factory->table()->action()->multi(
129 $this->
lng->txt(
'delete'),
130 $this->url_builder->withParameter($this->action_parameter_token,
'deleteAttachments'),
143 $records = $this->records;
145 [$order_field, $order_direction] = $order->join([],
static function ($ret, $key, $value) {
146 return [$key, $value];
149 usort($records,
static function (array $left, array $right) use ($order_field):
int {
150 if ($order_field ===
'filename') {
151 return ilStr::strCmp($left[$order_field], $right[$order_field]);
154 return $left[$order_field] <=> $right[$order_field];
157 if ($order_direction ===
'DESC') {
158 $records = array_reverse($records);
161 $records = \array_slice($records, $range->getStart(), $range->getLength());
168 array $visible_column_ids,
172 ?array $additional_parameters
174 foreach ($this->
getRecords($range, $order) as $item) {
176 'filename' => $item[
'filename'],
178 'filecreatedate' => (new \DateTimeImmutable(
'@' . $item[
'filecreatedate']))->setTimezone(
184 ->buildDataRow(urlencode($record[
'filename']), $record);
190 return \count($this->records);
__construct(private readonly \ilMailAttachmentGUI $parent_gui, private readonly \ilObjUser $actor, private readonly array $records, private readonly \ILIAS\UI\Factory $ui_factory, private readonly \ILIAS\UI\Renderer $ui_renderer, private readonly \ilLanguage $lng, private readonly \ilCtrlInterface $ctrl, private readonly \Psr\Http\Message\ServerRequestInterface $http_request, private readonly \ILIAS\Data\Factory $df, private readonly string $parent_cmd, private readonly AttachmentManagement $mode)
readonly ILIAS UI URLBuilder $url_builder
Interface Observer Contains several chained tasks and infos about them.
readonly ILIAS Data Factory $data_factory
Both the subject and the direction need to be specified when expressing an order. ...
readonly ILIAS UI URLBuilderToken $row_id_token
static formatSize(int $size, string $a_mode='short', ?ilLanguage $a_lng=null)
Returns the specified file size value in a human friendly form.
getRows(\ILIAS\UI\Component\Table\DataRowBuilder $row_builder, array $visible_column_ids, \ILIAS\Data\Range $range, \ILIAS\Data\Order $order, ?array $filter_data, ?array $additional_parameters)
static strCmp(string $a, string $b)
getTotalRowCount(?array $filter_data, ?array $additional_parameters)
Mainly for the purpose of pagination-support, it is important to know about the total number of recor...
readonly ILIAS UI URLBuilderToken $action_parameter_token
A simple class to express a naive range of whole positive numbers.
getRecords(\ILIAS\Data\Range $range, \ILIAS\Data\Order $order)