ILIAS  trunk Revision v12.0_alpha-1221-g4e438232683
ILIAS\Contact\MailingLists\MailingListsTable Class Reference
+ Inheritance diagram for ILIAS\Contact\MailingLists\MailingListsTable:
+ Collaboration diagram for ILIAS\Contact\MailingLists\MailingListsTable:

Public Member Functions

 __construct (private readonly ilMailingLists $mailing_lists, private readonly \ilCtrlInterface $ctrl, private readonly ilLanguage $lng, private readonly \ILIAS\UI\Factory $ui_factory, \ILIAS\HTTP\GlobalHttpState $http)
 
 setMailingAllowed (bool $mailing_allowed)
 
 getComponent ()
 
 getRows (UI\Component\Table\DataRowBuilder $row_builder, array $visible_column_ids, Data\Range $range, 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

 isMailingAllowed ()
 
 getColumns ()
 
 getActions ()
 
 initRecords ()
 
 sortedRecords (Data\Order $order)
 
 getRecords (Data\Range $range, Data\Order $order)
 
 limitRecords (array $records, Data\Range $range)
 

Private Attributes

readonly ServerRequestInterface $request
 
readonly Data Factory $data_factory
 
bool $mailing_allowed = false
 
array $records = null
 

Detailed Description

Definition at line 33 of file MailingListsTable.php.

Constructor & Destructor Documentation

◆ __construct()

ILIAS\Contact\MailingLists\MailingListsTable::__construct ( private readonly ilMailingLists  $mailing_lists,
private readonly \ilCtrlInterface  $ctrl,
private readonly ilLanguage  $lng,
private readonly \ILIAS\UI\Factory  $ui_factory,
\ILIAS\HTTP\GlobalHttpState  $http 
)

Definition at line 41 of file MailingListsTable.php.

47 {
48 $this->request = $http->request();
49 $this->data_factory = new Data\Factory();
50 }
$http
Definition: deliver.php:30

References $http.

Member Function Documentation

◆ getActions()

ILIAS\Contact\MailingLists\MailingListsTable::getActions ( )
private
Returns
array<string, \ILIAS\UI\Component\Table\Action\Action>

Definition at line 108 of file MailingListsTable.php.

108 : array
109 {
110 $query_params_namespace = ['contact', 'mailinglist', 'list'];
111
112 $uri = $this->data_factory->uri(
113 ILIAS_HTTP_PATH . '/' . $this->ctrl->getLinkTargetByClass(
114 ilMailingListsGUI::class,
115 'handleMailingListActions'
116 )
117 );
118
119 $url_builder = new UI\URLBuilder($uri);
120 [
121 $url_builder,
122 $action_parameter_token_copy,
123 $row_id_token
124 ] = $url_builder->acquireParameters(
125 $query_params_namespace,
126 'action',
127 'ml_ids'
128 );
129
130 $actions = [
131 'confirmDelete' => $this->ui_factory->table()->action()->standard(
132 $this->lng->txt('delete'),
133 $url_builder->withParameter($action_parameter_token_copy, 'confirmDelete'),
134 $row_id_token
135 ),
136 'showForm' => $this->ui_factory->table()->action()->single(
137 $this->lng->txt('edit'),
138 $url_builder->withParameter($action_parameter_token_copy, 'showForm'),
139 $row_id_token
140 ),
141 'showMembersList' => $this->ui_factory->table()->action()->single(
142 $this->lng->txt('members'),
143 $url_builder->withParameter($action_parameter_token_copy, 'showMembersList'),
144 $row_id_token
145 )
146 ];
147
148 if ($this->isMailingAllowed()) {
149 $actions['mailToList'] = $this->ui_factory->table()->action()->standard(
150 $this->lng->txt('send_mail_to'),
151 $url_builder->withParameter($action_parameter_token_copy, 'mailToList'),
152 $row_id_token
153 );
154 }
155
156 return $actions;
157 }

References ILIAS\Repository\ctrl(), ILIAS\Contact\MailingLists\MailingListsTable\isMailingAllowed(), and ILIAS\Repository\lng().

Referenced by ILIAS\Contact\MailingLists\MailingListsTable\getComponent().

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

◆ getColumns()

ILIAS\Contact\MailingLists\MailingListsTable::getColumns ( )
private
Returns
array<string, \ILIAS\UI\Component\Table\Column\Column>

Definition at line 84 of file MailingListsTable.php.

84 : array
85 {
86 return [
87 'title' => $this->ui_factory
88 ->table()
89 ->column()
90 ->text($this->lng->txt('title'))
91 ->withIsSortable(true),
92 'description' => $this->ui_factory
93 ->table()
94 ->column()
95 ->text($this->lng->txt('description'))
96 ->withIsSortable(true),
97 'members' => $this->ui_factory
98 ->table()
99 ->column()
100 ->number($this->lng->txt('members'))
101 ->withIsSortable(true),
102 ];
103 }

References ILIAS\Repository\lng().

Referenced by ILIAS\Contact\MailingLists\MailingListsTable\getComponent().

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

◆ getComponent()

ILIAS\Contact\MailingLists\MailingListsTable::getComponent ( )

Definition at line 62 of file MailingListsTable.php.

62 : UI\Component\Table\Data
63 {
64 $columns = $this->getColumns();
65 $actions = $this->getActions();
66
67 return $this->ui_factory
68 ->table()
69 ->data(
70 $this,
71 $this->lng->txt('mail_mailing_lists'),
72 $columns,
73 )
74 ->withOrder(new \ILIAS\Data\Order('title', \ILIAS\Data\Order::ASC))
75 ->withRange(new Range(0, 50))
76 ->withId(str_replace('\\', '', self::class))
77 ->withActions($actions)
78 ->withRequest($this->request);
79 }
Interface Observer \BackgroundTasks Contains several chained tasks and infos about them.

References ILIAS\Data\Order\ASC, ILIAS\Contact\MailingLists\MailingListsTable\getActions(), ILIAS\Contact\MailingLists\MailingListsTable\getColumns(), and ILIAS\Repository\lng().

+ Here is the call graph for this function:

◆ getRecords()

ILIAS\Contact\MailingLists\MailingListsTable::getRecords ( Data\Range  $range,
Data\Order  $order 
)
private

◆ getRows()

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

Definition at line 181 of file MailingListsTable.php.

189 : \Generator {
190 $records = $this->getRecords($range, $order);
191
192 foreach ($records as $record) {
193 $row_id = (string) $record['ml_id'];
194 yield $row_builder->buildDataRow($row_id, $record);
195 }
196 }
getRecords(Data\Range $range, Data\Order $order)

◆ getTotalRowCount()

ILIAS\Contact\MailingLists\MailingListsTable::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 198 of file MailingListsTable.php.

202 : ?int {
203 $this->initRecords();
204
205 return \count($this->records);
206 }

◆ initRecords()

ILIAS\Contact\MailingLists\MailingListsTable::initRecords ( )
private

Definition at line 159 of file MailingListsTable.php.

159 : void
160 {
161 if ($this->records === null) {
162 $this->records = [];
163 $counter = 0;
164 $entries = $this->mailing_lists->getAll();
165
166 foreach ($entries as $entry) {
167 if ($entry->getMode() === ilMailingList::MODE_TEMPORARY) {
168 continue;
169 }
170
171 $this->records[$counter]['ml_id'] = $entry->getId();
172 $this->records[$counter]['title'] = $entry->getTitle() . ' [#il_ml_' . $entry->getId() . ']';
173 $this->records[$counter]['description'] = $entry->getDescription() ?? '';
174 $this->records[$counter]['members'] = \count($entry->getAssignedEntries());
175
176 ++$counter;
177 }
178 }
179 }
final const int MODE_TEMPORARY
$counter

References $counter, and ilMailingList\MODE_TEMPORARY.

◆ isMailingAllowed()

ILIAS\Contact\MailingLists\MailingListsTable::isMailingAllowed ( )
private

Definition at line 52 of file MailingListsTable.php.

References ILIAS\Contact\MailingLists\MailingListsTable\$mailing_allowed.

Referenced by ILIAS\Contact\MailingLists\MailingListsTable\getActions().

+ Here is the caller graph for this function:

◆ limitRecords()

ILIAS\Contact\MailingLists\MailingListsTable::limitRecords ( array  $records,
Data\Range  $range 
)
private
Parameters
list<array<string,mixed>>$records
Returns
list<array<string, mixed>>

Definition at line 239 of file MailingListsTable.php.

239 : array
240 {
241 return \array_slice($records, $range->getStart(), $range->getLength());
242 }

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

+ Here is the call graph for this function:

◆ setMailingAllowed()

ILIAS\Contact\MailingLists\MailingListsTable::setMailingAllowed ( bool  $mailing_allowed)

Definition at line 57 of file MailingListsTable.php.

57 : void
58 {
59 $this->mailing_allowed = $mailing_allowed;
60 }

References ILIAS\Contact\MailingLists\MailingListsTable\$mailing_allowed.

◆ sortedRecords()

ILIAS\Contact\MailingLists\MailingListsTable::sortedRecords ( Data\Order  $order)
private
Returns
list<array<string, mixed>>

Definition at line 211 of file MailingListsTable.php.

211 : array
212 {
214 [$order_field, $order_direction] = $order->join([], fn($ret, $key, $value) => [$key, $value]);
215
217 $records,
218 $order_field,
219 strtolower($order_direction),
220 $order_field === 'members'
221 );
222 }
static stableSortArray(array $array, string $a_array_sortby, string $a_array_sortorder="asc", bool $a_numeric=false)
Sort an aray using a stable sort algorithm, which preveserves the sequence of array elements which ha...

References ilArrayUtil\stableSortArray().

+ Here is the call graph for this function:

Field Documentation

◆ $data_factory

readonly Data Factory ILIAS\Contact\MailingLists\MailingListsTable::$data_factory
private

Definition at line 36 of file MailingListsTable.php.

◆ $mailing_allowed

bool ILIAS\Contact\MailingLists\MailingListsTable::$mailing_allowed = false
private

◆ $records

array ILIAS\Contact\MailingLists\MailingListsTable::$records = null
private

Definition at line 39 of file MailingListsTable.php.

◆ $request

readonly ServerRequestInterface ILIAS\Contact\MailingLists\MailingListsTable::$request
private

Definition at line 35 of file MailingListsTable.php.


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