ILIAS  trunk Revision v11.0_alpha-2662-g519ff7d528f
ILIAS\COPage\Editor\Server\UI\ServerTable Class Reference
+ Inheritance diagram for ILIAS\COPage\Editor\Server\UI\ServerTable:
+ Collaboration diagram for ILIAS\COPage\Editor\Server\UI\ServerTable:

Public Member Functions

 __construct (private array $servers, private \ilLDAPSettingsGUI $parent_gui, private \ILIAS\UI\Factory $ui_factory, private \ILIAS\UI\Renderer $ui_renderer, private \ilLanguage $lng, private \ilCtrlInterface $ctrl, private \Psr\Http\Message\ServerRequestInterface $http_request, private \ILIAS\Data\Factory $df, private string $parent_cmd, private bool $has_write_access)
 
 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...
 
 getComponent ()
 
- 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

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

Private Attributes

ILIAS UI URLBuilder $url_builder
 
ILIAS UI URLBuilderToken $action_parameter_token
 
ILIAS UI URLBuilderToken $row_id_token
 

Detailed Description

Definition at line 23 of file ServerTable.php.

Constructor & Destructor Documentation

◆ __construct()

ILIAS\COPage\Editor\Server\UI\ServerTable::__construct ( private array  $servers,
private \ilLDAPSettingsGUI  $parent_gui,
private \ILIAS\UI\Factory  $ui_factory,
private \ILIAS\UI\Renderer  $ui_renderer,
private \ilLanguage  $lng,
private \ilCtrlInterface  $ctrl,
private \Psr\Http\Message\ServerRequestInterface  $http_request,
private \ILIAS\Data\Factory  $df,
private string  $parent_cmd,
private bool  $has_write_access 
)
Parameters
list<array<string,string|int|float|null>>$servers

Definition at line 32 of file ServerTable.php.

References ILIAS\COPage\Editor\Server\UI\ServerTable\$action_parameter_token, ILIAS\COPage\Editor\Server\UI\ServerTable\$row_id_token, ILIAS\COPage\Editor\Server\UI\ServerTable\$url_builder, ilUtil\_getHttpPath(), and ILIAS\Repository\ctrl().

43  {
44  $form_action = $this->df->uri(
45  \ilUtil::_getHttpPath() . '/' .
46  $this->ctrl->getLinkTarget($this->parent_gui, $this->parent_cmd)
47  );
48 
49  [
53  ] = (new \ILIAS\UI\URLBuilder($form_action))->acquireParameters(
54  ['ldap', 'servers'],
55  'table_action',
56  'server_id'
57  );
58  }
ILIAS UI URLBuilderToken $row_id_token
Definition: ServerTable.php:27
ILIAS UI URLBuilderToken $action_parameter_token
Definition: ServerTable.php:26
static _getHttpPath()
+ Here is the call graph for this function:

Member Function Documentation

◆ getActions()

ILIAS\COPage\Editor\Server\UI\ServerTable::getActions ( )
private
Returns
array<string, >

Definition at line 182 of file ServerTable.php.

References ILIAS\COPage\Editor\Server\UI\ServerTable\$row_id_token, and ILIAS\Repository\lng().

Referenced by ILIAS\COPage\Editor\Server\UI\ServerTable\getComponent().

182  : array
183  {
184  if (!$this->has_write_access) {
185  return [];
186  }
187 
188  return [
189  'editServerSettings' => $this->ui_factory->table()->action()->single(
190  $this->lng->txt('edit'),
191  $this->url_builder->withParameter($this->action_parameter_token, 'editServerSettings'),
193  ),
194  'activateServer' => $this->ui_factory->table()->action()->single(
195  $this->lng->txt('activate'),
196  $this->url_builder->withParameter($this->action_parameter_token, 'activateServer'),
198  ),
199  'deactivateServer' => $this->ui_factory->table()->action()->single(
200  $this->lng->txt('deactivate'),
201  $this->url_builder->withParameter($this->action_parameter_token, 'deactivateServer'),
203  ),
204  'confirmDeleteServerSettings' => $this->ui_factory->table()->action()->single(
205  $this->lng->txt('delete'),
206  $this->url_builder->withParameter($this->action_parameter_token, 'confirmDeleteServerSettings'),
208  )
209  ];
210  }
ILIAS UI URLBuilderToken $row_id_token
Definition: ServerTable.php:27
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getColumnDefinition()

ILIAS\COPage\Editor\Server\UI\ServerTable::getColumnDefinition ( )
private
Returns
array<string, >

Definition at line 142 of file ServerTable.php.

References ILIAS\Repository\lng().

Referenced by ILIAS\COPage\Editor\Server\UI\ServerTable\getComponent().

142  : array
143  {
144  return [
145  'active' => $this->ui_factory
146  ->table()
147  ->column()
148  ->boolean(
149  $this->lng->txt('status'),
150  $this->ui_factory->symbol()->icon()->custom(
151  'assets/images/standard/icon_ok.svg',
152  $this->lng->txt('active'),
153  'small'
154  ),
155  $this->ui_factory->symbol()->icon()->custom(
156  'assets/images/standard/icon_not_ok.svg',
157  $this->lng->txt('inactive'),
158  'small'
159  )
160  )
161  ->withIsSortable(true)
162  ->withOrderingLabels(
163  "{$this->lng->txt('status')}, {$this->lng->txt('active')} {$this->lng->txt('order_option_first')}",
164  "{$this->lng->txt('status')}, {$this->lng->txt('inactive')} {$this->lng->txt('order_option_first')}"
165  ),
166  'title' => $this->ui_factory
167  ->table()
168  ->column()
169  ->text($this->lng->txt('title'))
170  ->withIsSortable(true),
171  'user' => $this->ui_factory
172  ->table()
173  ->column()
174  ->number($this->lng->txt('user'))
175  ->withIsSortable(true)
176  ];
177  }
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getComponent()

ILIAS\COPage\Editor\Server\UI\ServerTable::getComponent ( )

Definition at line 212 of file ServerTable.php.

References ILIAS\Data\Order\ASC, ILIAS\COPage\Editor\Server\UI\ServerTable\getActions(), ILIAS\COPage\Editor\Server\UI\ServerTable\getColumnDefinition(), and ILIAS\Repository\lng().

212  : \ILIAS\UI\Component\Table\Table
213  {
214  return $this->ui_factory
215  ->table()
216  ->data(
217  $this,
218  $this->lng->txt('ldap_servers'),
219  $this->getColumnDefinition(),
220  )
221  ->withId(self::class)
222  ->withOrder(new \ILIAS\Data\Order('title', \ILIAS\Data\Order::ASC))
223  ->withActions($this->getActions())
224  ->withRequest($this->http_request);
225  }
Interface Observer Contains several chained tasks and infos about them.
+ Here is the call graph for this function:

◆ getRecords()

ILIAS\COPage\Editor\Server\UI\ServerTable::getRecords ( \ILIAS\Data\Range  $range,
\ILIAS\Data\Order  $order 
)
private
Returns
list<array<string, string|int|float|null>>

Definition at line 63 of file ServerTable.php.

References $server, ilObjUser\_getExternalAccountsByAuthMode(), and ilArrayUtil\sortArray().

Referenced by ILIAS\COPage\Editor\Server\UI\ServerTable\getRows().

63  : array
64  {
65  $servers = $this->servers;
66 
67  [$order_field, $order_direction] = $order->join([], static function ($ret, $key, $value) {
68  return [$key, $value];
69  });
70 
71  array_walk(
72  $servers,
73  static function (array &$server): void {
74  $server['user'] = \count(\ilObjUser::_getExternalAccountsByAuthMode('ldap_' . $server['server_id']));
75  }
76  );
77 
78  $records = \ilArrayUtil::sortArray(
79  $servers,
80  $order_field,
81  strtolower($order_direction),
82  \in_array($order_field, ['user', 'active'], true)
83  );
84 
85  if ($order_field === 'active') {
86  $records = array_reverse($records);
87  }
88 
89  $records = \array_slice($records, $range->getStart(), $range->getLength());
90 
91  return $records;
92  }
static _getExternalAccountsByAuthMode(string $a_auth_mode, bool $a_read_auth_default=false)
Get list of external account by authentication method Note: If login == ext_account for two user with...
$server
Definition: shib_login.php:28
static sortArray(array $array, string $a_array_sortby_key, string $a_array_sortorder="asc", bool $a_numeric=false, bool $a_keep_keys=false)
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getRows()

ILIAS\COPage\Editor\Server\UI\ServerTable::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 94 of file ServerTable.php.

References $server, ILIAS\Repository\ctrl(), and ILIAS\COPage\Editor\Server\UI\ServerTable\getRecords().

101  : \Generator {
102  foreach ($this->getRecords($range, $order) as $server) {
103  $title = $server['name'];
104  if ($this->has_write_access) {
105  $this->ctrl->setParameter($this->parent_gui, 'ldap_server_id', $server['server_id']);
106  $title = $this->ui_renderer->render(
107  $this->ui_factory->link()->standard(
108  $title,
109  $this->ctrl->getLinkTarget($this->parent_gui, 'editServerSettings')
110  )
111  );
112  }
113 
114  yield $row_builder
115  ->buildDataRow(
116  (string) $server['server_id'],
117  [
118  'title' => $title,
119  'active' => (bool) $server['active'],
120  'user' => $server['user']
121  ]
122  )
123  ->withDisabledAction(
124  'activateServer',
125  (bool) $server['active'],
126  )
127  ->withDisabledAction(
128  'deactivateServer',
129  !$server['active'],
130  );
131  }
132  }
$server
Definition: shib_login.php:28
getRecords(\ILIAS\Data\Range $range, \ILIAS\Data\Order $order)
Definition: ServerTable.php:63
+ Here is the call graph for this function:

◆ getTotalRowCount()

ILIAS\COPage\Editor\Server\UI\ServerTable::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 134 of file ServerTable.php.

134  : ?int
135  {
136  return \count($this->servers);
137  }

Field Documentation

◆ $action_parameter_token

ILIAS UI URLBuilderToken ILIAS\COPage\Editor\Server::UI\ServerTable::$action_parameter_token
private

◆ $row_id_token

ILIAS UI URLBuilderToken ILIAS\COPage\Editor\Server::UI\ServerTable::$row_id_token
private

◆ $url_builder

ILIAS UI URLBuilder ILIAS\COPage\Editor\Server::UI\ServerTable::$url_builder
private

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