ILIAS  trunk Revision v11.0_alpha-1761-g6dbbfa7b760
All Data Structures Namespaces Files Functions Variables Enumerations Enumerator Modules Pages
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, ?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

 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 32 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 40 of file MailingListsTable.php.

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

Member Function Documentation

◆ getActions()

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

Definition at line 106 of file MailingListsTable.php.

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

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

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

Definition at line 82 of file MailingListsTable.php.

References ILIAS\Repository\lng().

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

82  : array
83  {
84  return [
85  'title' => $this->ui_factory
86  ->table()
87  ->column()
88  ->text($this->lng->txt('title'))
89  ->withIsSortable(true),
90  'description' => $this->ui_factory
91  ->table()
92  ->column()
93  ->text($this->lng->txt('description'))
94  ->withIsSortable(true),
95  'members' => $this->ui_factory
96  ->table()
97  ->column()
98  ->number($this->lng->txt('members'))
99  ->withIsSortable(true),
100  ];
101  }
+ 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 61 of file MailingListsTable.php.

References ILIAS\Data\Order\ASC, ILIAS\Contact\MailingLists\MailingListsTable\getActions(), ILIAS\Contact\MailingLists\MailingListsTable\getColumns(), ILIAS\Repository\lng(), and ILIAS\UI\Implementation\Component\Table\withOrder().

61  : UI\Component\Table\Data
62  {
63  $columns = $this->getColumns();
64  $actions = $this->getActions();
65 
66  return $this->ui_factory
67  ->table()
68  ->data(
69  $this,
70  $this->lng->txt('mail_mailing_lists'),
71  $columns,
72  )
73  ->withOrder(new \ILIAS\Data\Order('title', \ILIAS\Data\Order::ASC))
74  ->withId(self::class)
75  ->withActions($actions)
76  ->withRequest($this->request);
77  }
Interface Observer Contains several chained tasks and infos about them.
+ 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,
?array  $filter_data,
?array  $additional_parameters 
)

Definition at line 179 of file MailingListsTable.php.

References ILIAS\Contact\MailingLists\MailingListsTable\getRecords().

186  : \Generator {
187  $records = $this->getRecords($range, $order);
188 
189  foreach ($records as $record) {
190  $row_id = (string) $record['ml_id'];
191  yield $row_builder->buildDataRow($row_id, $record);
192  }
193  }
getRecords(Data\Range $range, Data\Order $order)
+ Here is the call graph for this function:

◆ getTotalRowCount()

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

References ILIAS\Contact\MailingLists\MailingListsTable\initRecords().

198  : ?int {
199  $this->initRecords();
200 
201  return \count($this->records);
202  }
+ Here is the call graph for this function:

◆ initRecords()

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

Definition at line 157 of file MailingListsTable.php.

References ilMailingList\MODE_TEMPORARY, and null.

Referenced by ILIAS\Contact\MailingLists\MailingListsTable\getRecords(), and ILIAS\Contact\MailingLists\MailingListsTable\getTotalRowCount().

157  : void
158  {
159  if ($this->records === null) {
160  $this->records = [];
161  $counter = 0;
162  $entries = $this->mailing_lists->getAll();
163 
164  foreach ($entries as $entry) {
165  if ($entry->getMode() === ilMailingList::MODE_TEMPORARY) {
166  continue;
167  }
168 
169  $this->records[$counter]['ml_id'] = $entry->getId();
170  $this->records[$counter]['title'] = $entry->getTitle() . ' [#il_ml_' . $entry->getId() . ']';
171  $this->records[$counter]['description'] = $entry->getDescription() ?? '';
172  $this->records[$counter]['members'] = \count($entry->getAssignedEntries());
173 
174  ++$counter;
175  }
176  }
177  }
while($session_entry=$r->fetchRow(ilDBConstants::FETCHMODE_ASSOC)) return null
final const MODE_TEMPORARY
+ Here is the caller graph for this function:

◆ isMailingAllowed()

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

Definition at line 51 of file MailingListsTable.php.

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

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

51  : bool
52  {
54  }
+ 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 235 of file MailingListsTable.php.

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

+ Here is the caller graph for this function:

◆ setMailingAllowed()

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

Definition at line 56 of file MailingListsTable.php.

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

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

◆ sortedRecords()

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

Definition at line 207 of file MailingListsTable.php.

References ILIAS\Contact\MailingLists\MailingListsTable\$records, and ilArrayUtil\stableSortArray().

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

207  : array
208  {
210  [$order_field, $order_direction] = $order->join([], fn($ret, $key, $value) => [$key, $value]);
211 
213  $records,
214  $order_field,
215  strtolower($order_direction),
216  $order_field === 'members'
217  );
218  }
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...
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

Field Documentation

◆ $data_factory

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

Definition at line 35 of file MailingListsTable.php.

◆ $mailing_allowed

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

◆ $records

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

◆ $request

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

Definition at line 34 of file MailingListsTable.php.


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