ILIAS  trunk Revision v12.0_alpha-1221-g4e438232683
ILIAS\Mail\Attachments\MailAttachmentTableGUI Class Reference
+ Inheritance diagram for ILIAS\Mail\Attachments\MailAttachmentTableGUI:
+ Collaboration diagram for ILIAS\Mail\Attachments\MailAttachmentTableGUI:

Public Member Functions

 __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)
 
 get ()
 
 getRows (\ILIAS\UI\Component\Table\DataRowBuilder $row_builder, array $visible_column_ids, \ILIAS\Data\Range $range, \ILIAS\Data\Order $order, mixed $additional_viewcontrol_data, mixed $filter_data, mixed $additional_parameters)
 
 getTotalRowCount (mixed $additional_viewcontrol_data, mixed $filter_data, mixed $additional_parameters)
 Mainly for the purpose of pagination-support, it is important to know about the total number of records available. More...
 
- Public Member Functions inherited from ILIAS\UI\Component\Table\DataRetrieval
 getRows (DataRowBuilder $row_builder, array $visible_column_ids, Range $range, Order $order, mixed $additional_viewcontrol_data, mixed $filter_data, mixed $additional_parameters)
 This is called by the table to retrieve rows; map data-records to rows using the $row_builder e.g. More...
 
 getTotalRowCount (mixed $additional_viewcontrol_data, mixed $filter_data, mixed $additional_parameters)
 Mainly for the purpose of pagination-support, it is important to know about the total number of records available. More...
 

Private Member Functions

 getColumnDefinition ()
 
 getActions ()
 
 getRecords (\ILIAS\Data\Range $range, \ILIAS\Data\Order $order)
 

Private Attributes

readonly ILIAS UI URLBuilder $url_builder
 
readonly ILIAS UI URLBuilderToken $action_parameter_token
 
readonly ILIAS UI URLBuilderToken $row_id_token
 
readonly ILIAS Data Factory $data_factory
 

Additional Inherited Members

- Data Fields inherited from ILIAS\Mail\Attachments\MailAttachmentCommands
const string CMD_SHOW_ATTACHMENTS = 'showAttachments'
 
const string CMD_CANCEL_SAVE_ATTACHMENTS = 'cancelSaveAttachments'
 
const string CMD_DELETE_ATTACHMENTS = 'deleteAttachments'
 
const string CMD_HANDLE_TABLE_ACTIONS = 'handleTableActions'
 
const string DEFAULT_CMD = self::CMD_SHOW_ATTACHMENTS
 
const string TABLE_CONFIRM_DELETE_ATTACHMENTS = 'confirmDeleteAttachments'
 
const string TABLE_ACTION_SAVE_ATTACHMENTS = 'saveAttachments'
 

Detailed Description

Definition at line 26 of file MailAttachmentTableGUI.php.

Constructor & Destructor Documentation

◆ __construct()

ILIAS\Mail\Attachments\MailAttachmentTableGUI::__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 
)
Parameters
list<array{"filename"string, "filesize": int, "filecreatedate": int}> $records

Definition at line 36 of file MailAttachmentTableGUI.php.

48 {
49 $form_action = $this->df->uri(
50 ilUtil::_getHttpPath() . '/' .
51 $this->ctrl->getLinkTarget($this->parent_gui, $this->parent_cmd)
52 );
53
54 [
58 ] = (new \ILIAS\UI\URLBuilder($form_action))->acquireParameters(
59 ['mail', 'attachments'],
60 'table_action',
61 'filename'
62 );
63
64 $this->data_factory = new \ILIAS\Data\Factory();
65 }
readonly ILIAS UI URLBuilderToken $row_id_token
readonly ILIAS UI URLBuilderToken $action_parameter_token
static _getHttpPath()

References ILIAS\Mail\Attachments\MailAttachmentTableGUI\$action_parameter_token, ILIAS\Mail\Attachments\MailAttachmentTableGUI\$row_id_token, ILIAS\Mail\Attachments\MailAttachmentTableGUI\$url_builder, ilUtil\_getHttpPath(), and ILIAS\Repository\ctrl().

+ Here is the call graph for this function:

Member Function Documentation

◆ get()

ILIAS\Mail\Attachments\MailAttachmentTableGUI::get ( )

Definition at line 67 of file MailAttachmentTableGUI.php.

68 {
69 return $this->ui_factory
70 ->table()
71 ->data(
72 $this,
73 $this->lng->txt('attachment'),
74 $this->getColumnDefinition(),
75 )
76 ->withId(str_replace('\\', '', self::class) . '_' . $this->mode->name)
77 ->withOrder(new \ILIAS\Data\Order('filename', \ILIAS\Data\Order::ASC))
78 ->withRange(new \ILIAS\Data\Range(0, 50))
79 ->withActions($this->getActions())
80 ->withRequest($this->http_request);
81 }
This describes a Data Table.
Definition: Data.php:33
withId(string $id)
The DataTable comes with a storage to keep e.g.
Interface Observer \BackgroundTasks Contains several chained tasks and infos about them.

References ILIAS\Data\Order\ASC, ILIAS\Mail\Attachments\MailAttachmentTableGUI\getActions(), ILIAS\Mail\Attachments\MailAttachmentTableGUI\getColumnDefinition(), ILIAS\Repository\lng(), ILIAS\UI\Implementation\Component\Table\withOrder(), and ILIAS\UI\Implementation\Component\Table\withRange().

+ Here is the call graph for this function:

◆ getActions()

ILIAS\Mail\Attachments\MailAttachmentTableGUI::getActions ( )
private
Returns
array<string, \ILIAS\UI\Component\Table\Action\Action>

Definition at line 116 of file MailAttachmentTableGUI.php.

116 : array
117 {
118 $actions = [];
119
120 if ($this->mode === AttachmentManagement::CONSUME) {
121 $actions['saveAttachments'] = $this->ui_factory->table()->action()->multi(
122 $this->lng->txt('mail_adopt_selected_attachements'),
123 $this->url_builder->withParameter(
124 $this->action_parameter_token,
125 self::TABLE_ACTION_SAVE_ATTACHMENTS
126 ),
127 $this->row_id_token
128 );
129 } else {
130 $actions['deleteAttachments'] = $this->ui_factory->table()->action()->multi(
131 $this->lng->txt('delete'),
132 $this->url_builder->withParameter(
133 $this->action_parameter_token,
134 self::TABLE_CONFIRM_DELETE_ATTACHMENTS
135 ),
136 $this->row_id_token
137 );
138 }
139
140 return $actions;
141 }

References ILIAS\Mail\Attachments\CONSUME, and ILIAS\Repository\lng().

Referenced by ILIAS\Mail\Attachments\MailAttachmentTableGUI\get().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getColumnDefinition()

ILIAS\Mail\Attachments\MailAttachmentTableGUI::getColumnDefinition ( )
private
Returns
array<string, \ILIAS\UI\Component\Table\Column\Column>

Definition at line 86 of file MailAttachmentTableGUI.php.

86 : array
87 {
88 if ((int) $this->actor->getTimeFormat() === \ilCalendarSettings::TIME_FORMAT_12) {
89 $date_format = $this->data_factory->dateFormat()->withTime12($this->actor->getDateFormat());
90 } else {
91 $date_format = $this->data_factory->dateFormat()->withTime24($this->actor->getDateFormat());
92 }
93
94 return [
95 'filename' => $this->ui_factory
96 ->table()
97 ->column()
98 ->text($this->lng->txt('mail_file_name'))
99 ->withIsSortable(true),
100 'filesize' => $this->ui_factory
101 ->table()
102 ->column()
103 ->text($this->lng->txt('mail_file_size'))
104 ->withIsSortable(true),
105 'filecreatedate' => $this->ui_factory
106 ->table()
107 ->column()
108 ->date($this->lng->txt('create_date'), $date_format)
109 ->withIsSortable(true),
110 ];
111 }

References ILIAS\Repository\lng(), and ilCalendarSettings\TIME_FORMAT_12.

Referenced by ILIAS\Mail\Attachments\MailAttachmentTableGUI\get().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getRecords()

ILIAS\Mail\Attachments\MailAttachmentTableGUI::getRecords ( \ILIAS\Data\Range  $range,
\ILIAS\Data\Order  $order 
)
private
Returns
list<array{"filename": string, "filesize": int, "filecreatedate": int}>

Definition at line 146 of file MailAttachmentTableGUI.php.

146 : array
147 {
148 $records = $this->records;
149
150 [$order_field, $order_direction] = $order->join([], static fn($ret, $key, $value) => [$key, $value]);
151
152 usort($records, static function (array $left, array $right) use ($order_field): int {
153 if ($order_field === 'filename') {
154 return ilStr::strCmp($left[$order_field], $right[$order_field]);
155 }
156
157 return $left[$order_field] <=> $right[$order_field];
158 });
159
160 if ($order_direction === 'DESC') {
161 $records = array_reverse($records);
162 }
163
164 $records = \array_slice($records, $range->getStart(), $range->getLength());
165
166 return $records;
167 }
static strCmp(string $a, string $b)
Definition: class.ilStr.php:87

References ILIAS\UI\Implementation\Component\Table\$range, ILIAS\Data\Range\getLength(), ILIAS\Data\Range\getStart(), and ilStr\strCmp().

+ Here is the call graph for this function:

◆ getRows()

ILIAS\Mail\Attachments\MailAttachmentTableGUI::getRows ( \ILIAS\UI\Component\Table\DataRowBuilder  $row_builder,
array  $visible_column_ids,
\ILIAS\Data\Range  $range,
\ILIAS\Data\Order  $order,
mixed  $additional_viewcontrol_data,
mixed  $filter_data,
mixed  $additional_parameters 
)

Definition at line 169 of file MailAttachmentTableGUI.php.

177 : \Generator {
178 foreach ($this->getRecords($range, $order) as $item) {
179 $record = [
180 'filename' => $item['filename'],
181 'filesize' => ilUtil::formatSize($item['filesize'], 'long'),
182 'filecreatedate' => (new \DateTimeImmutable('@' . $item['filecreatedate']))->setTimezone(
183 new \DateTimeZone($this->actor->getTimeZone())
184 )
185 ];
186
187 yield $row_builder
188 ->buildDataRow(urlencode($record['filename']), $record);
189 }
190 }
getRecords(\ILIAS\Data\Range $range, \ILIAS\Data\Order $order)
static formatSize(int $size, string $a_mode='short', ?ilLanguage $a_lng=null)
Returns the specified file size value in a human friendly form.

References ilUtil\formatSize().

+ Here is the call graph for this function:

◆ getTotalRowCount()

ILIAS\Mail\Attachments\MailAttachmentTableGUI::getTotalRowCount ( mixed  $additional_viewcontrol_data,
mixed  $filter_data,
mixed  $additional_parameters 
)

Mainly for the purpose of pagination-support, it is important to know about the total number of records available.

Given the nature of a DataTable, which is, opposite to a PresentationTable, rather administrative than explorative, this information will increase user experience quite a bit. However, you may return null, if the call is to costly, but expect the View Control to look a little different in this case.

Make sure that potential filters or user restrictions are being applied to the count.

Implements ILIAS\UI\Component\Table\DataRetrieval.

Definition at line 192 of file MailAttachmentTableGUI.php.

196 : ?int {
197 return \count($this->records);
198 }

Field Documentation

◆ $action_parameter_token

readonly ILIAS UI URLBuilderToken ILIAS\Mail\Attachments\MailAttachmentTableGUI::$action_parameter_token
private

◆ $data_factory

readonly ILIAS Data Factory ILIAS\Mail\Attachments\MailAttachmentTableGUI::$data_factory
private

Definition at line 31 of file MailAttachmentTableGUI.php.

◆ $row_id_token

readonly ILIAS UI URLBuilderToken ILIAS\Mail\Attachments\MailAttachmentTableGUI::$row_id_token
private

◆ $url_builder

readonly ILIAS UI URLBuilder ILIAS\Mail\Attachments\MailAttachmentTableGUI::$url_builder
private

The documentation for this class was generated from the following file: