ILIAS  trunk Revision v11.0_alpha-1831-g8615d53dadb
All Data Structures Namespaces Files Functions Variables Enumerations Enumerator Modules Pages
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, ?array $filter_data, ?array $additional_parameters)
 
 getTotalRowCount (?array $filter_data, ?array $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, ?array $filter_data, ?array $additional_parameters)
 This is called by the table to retrieve rows; map data-records to rows using the $row_builder e.g. 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
 

Detailed Description

Definition at line 28 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 38 of file MailAttachmentTableGUI.php.

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().

50  {
51  $form_action = $this->df->uri(
52  \ilUtil::_getHttpPath() . '/' .
53  $this->ctrl->getLinkTarget($this->parent_gui, $this->parent_cmd)
54  );
55 
56  [
60  ] = (new \ILIAS\UI\URLBuilder($form_action))->acquireParameters(
61  ['mail', 'attachments'],
62  'table_action',
63  'filename'
64  );
65 
66  $this->data_factory = new \ILIAS\Data\Factory();
67  }
readonly ILIAS UI URLBuilderToken $row_id_token
static _getHttpPath()
readonly ILIAS UI URLBuilderToken $action_parameter_token
+ Here is the call graph for this function:

Member Function Documentation

◆ get()

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

Definition at line 69 of file MailAttachmentTableGUI.php.

References ILIAS\Data\Order\ASC, ILIAS\Mail\Attachments\MailAttachmentTableGUI\getActions(), ILIAS\Mail\Attachments\MailAttachmentTableGUI\getColumnDefinition(), and ILIAS\Repository\lng().

69  : \ILIAS\UI\Component\Table\Data
70  {
71  return $this->ui_factory
72  ->table()
73  ->data(
74  $this,
75  $this->lng->txt('attachment'),
76  $this->getColumnDefinition(),
77  )
78  ->withId(self::class . '_' . $this->mode->name)
79  ->withOrder(new \ILIAS\Data\Order('filename', \ILIAS\Data\Order::ASC))
80  ->withActions($this->getActions())
81  ->withRequest($this->http_request);
82  }
Interface Observer Contains several chained tasks and infos about them.
+ Here is the call graph for this function:

◆ getActions()

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

Definition at line 117 of file MailAttachmentTableGUI.php.

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

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

117  : array
118  {
119  $actions = [];
120 
121  if ($this->mode === AttachmentManagement::CONSUME) {
122  $actions['saveAttachments'] = $this->ui_factory->table()->action()->multi(
123  $this->lng->txt('adopt'),
124  $this->url_builder->withParameter($this->action_parameter_token, 'saveAttachments'),
126  );
127  } else {
128  $actions['deleteAttachments'] = $this->ui_factory->table()->action()->multi(
129  $this->lng->txt('delete'),
130  $this->url_builder->withParameter($this->action_parameter_token, 'deleteAttachments'),
132  );
133  }
134 
135  return $actions;
136  }
readonly ILIAS UI URLBuilderToken $row_id_token
+ 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, >

Definition at line 87 of file MailAttachmentTableGUI.php.

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

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

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

References ilStr\strCmp().

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

141  : array
142  {
143  $records = $this->records;
144 
145  [$order_field, $order_direction] = $order->join([], static function ($ret, $key, $value) {
146  return [$key, $value];
147  });
148 
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]);
152  }
153 
154  return $left[$order_field] <=> $right[$order_field];
155  });
156 
157  if ($order_direction === 'DESC') {
158  $records = array_reverse($records);
159  }
160 
161  $records = \array_slice($records, $range->getStart(), $range->getLength());
162 
163  return $records;
164  }
static strCmp(string $a, string $b)
Definition: class.ilStr.php:90
+ Here is the call graph for this function:
+ Here is the caller 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,
?array  $filter_data,
?array  $additional_parameters 
)

Definition at line 166 of file MailAttachmentTableGUI.php.

References ilUtil\formatSize(), and ILIAS\Mail\Attachments\MailAttachmentTableGUI\getRecords().

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

◆ getTotalRowCount()

ILIAS\Mail\Attachments\MailAttachmentTableGUI::getTotalRowCount ( ?array  $filter_data,
?array  $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 188 of file MailAttachmentTableGUI.php.

188  : ?int
189  {
190  return \count($this->records);
191  }

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 33 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: