ILIAS  trunk Revision v11.0_alpha-3011-gc6b235a2e85
ILIAS\Badge\ilBadgeUserTableGUI Class Reference
+ Inheritance diagram for ILIAS\Badge\ilBadgeUserTableGUI:
+ Collaboration diagram for ILIAS\Badge\ilBadgeUserTableGUI:

Public Member Functions

 __construct (private readonly ?int $parent_ref_id=null, private readonly ?ilBadge $award_badge=null, private readonly ?int $parent_obj_id=null, private readonly ?int $restrict_badge_id=null)
 
 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...
 
 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...
 
 getColumns ()
 
 renderTable (string $url)
 
 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...
 
 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...
 

Private Member Functions

 getActions (URLBuilder $url_builder, URLBuilderToken $action_parameter_token, URLBuilderToken $row_id_token,)
 

Private Attributes

readonly Factory $factory
 
readonly Renderer $renderer
 
readonly ServerRequestInterface RequestInterface $request
 
readonly ilLanguage $lng
 
readonly ilGlobalTemplateInterface $tpl
 
readonly ilTree $tree
 
readonly ilObjUser $user
 
DateFormat $date_format
 
bool $is_container_context = false
 
array $cached_records = null
 

Detailed Description

Definition at line 50 of file class.ilBadgeUserTableGUI.php.

Constructor & Destructor Documentation

◆ __construct()

ILIAS\Badge\ilBadgeUserTableGUI::__construct ( private readonly ?int  $parent_ref_id = null,
private readonly ?ilBadge  $award_badge = null,
private readonly ?int  $parent_obj_id = null,
private readonly ?int  $restrict_badge_id = null 
)

Definition at line 76 of file class.ilBadgeUserTableGUI.php.

81 {
82 global $DIC;
83
84 $this->lng = $DIC->language();
85 $this->tpl = $DIC->ui()->mainTemplate();
86 $this->factory = $DIC->ui()->factory();
87 $this->renderer = $DIC->ui()->renderer();
88 $this->request = $DIC->http()->request();
89 $this->tree = $DIC->repositoryTree();
90 $this->user = $DIC->user();
91
92 if ($this->parent_ref_id) {
93 $parent_type = ilObject::_lookupType($this->parent_ref_id, true);
94 if (\in_array($parent_type, ['grp', 'crs'], true)) {
95 $this->is_container_context = $this->parent_obj_id === null && $this->award_badge === null;
96 }
97 }
98 }
renderer()
factory()
static _lookupType(int $id, bool $reference=false)
global $DIC
Definition: shib_login.php:26

References $DIC, ilObject\_lookupType(), factory(), ILIAS\Repository\lng(), renderer(), and ILIAS\Repository\user().

+ Here is the call graph for this function:

Member Function Documentation

◆ getActions()

ILIAS\Badge\ilBadgeUserTableGUI::getActions ( URLBuilder  $url_builder,
URLBuilderToken  $action_parameter_token,
URLBuilderToken  $row_id_token 
)
private
Returns
array<string, Action>

Definition at line 322 of file class.ilBadgeUserTableGUI.php.

326 : array {
327 return ($this->award_badge instanceof ilBadge) ? [
328 'badge_award_badge' =>
329 $this->factory->table()->action()->multi(
330 $this->lng->txt('badge_award_badge'),
331 $url_builder->withParameter($action_parameter_token, 'assignBadge'),
332 $row_id_token
333 ),
334 'badge_revoke_badge' =>
335 $this->factory->table()->action()->multi(
336 $this->lng->txt('badge_remove_badge'),
337 $url_builder->withParameter($action_parameter_token, 'revokeBadge'),
338 $row_id_token
339 )
340 ] : [];
341 }
withParameter(URLBuilderToken $token, string|array $value)
Change an acquired parameter's value if the supplied token is valid.
Definition: URLBuilder.php:166

◆ getColumns()

ILIAS\Badge\ilBadgeUserTableGUI::getColumns ( )
Returns
array<string, Column>

Definition at line 301 of file class.ilBadgeUserTableGUI.php.

301 : array
302 {
303 $columns = [
304 'name' => $this->factory->table()->column()->text($this->lng->txt('name')),
305 'login' => $this->factory->table()->column()->text($this->lng->txt('login')),
306 'type' => $this->factory->table()->column()->text($this->lng->txt('type')),
307 'title' => $this->factory->table()->column()->text($this->lng->txt('title')),
308 // Cannot be a date column, because when awarding/revoking badges for uses, the list items may contain NULL values for `issued`
309 'issued' => $this->factory->table()->column()->text($this->lng->txt('badge_issued_on'))
310 ];
311
312 if ($this->is_container_context) {
313 $columns['parent'] = $this->factory->table()->column()->text($this->lng->txt('object'));
314 }
315
316 return $columns;
317 }

References factory(), and ILIAS\Repository\lng().

+ Here is the call graph for this function:

◆ getRows()

ILIAS\Badge\ilBadgeUserTableGUI::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.

yield $row_builder->buildStandardRow($row_id, $record).

Parameters
string[]$visible_column_ids

Implements ILIAS\UI\Component\Table\DataRetrieval.

Definition at line 236 of file class.ilBadgeUserTableGUI.php.

243 : Generator {
244 $records = $this->getRecords();
245
246 if ($order) {
247 [$order_field, $order_direction] = $order->join(
248 [],
249 fn($ret, $key, $value) => [$key, $value]
250 );
251 usort($records, static function (array $left, array $right) use ($order_field): int {
252 if (\in_array($order_field, ['name', 'login', 'type', 'title', 'parent'], true)) {
253 if ($order_field === 'parent') {
254 $order_field .= '_sortable';
255 }
256
257 return \ilStr::strCmp(
258 $left[$order_field] ?? '',
259 $right[$order_field] ?? ''
260 );
261 }
262
263 if ($order_field === 'issued') {
264 $order_field .= '_sortable';
265 return $left[$order_field] <=> $right[$order_field];
266 }
267
268 return $left[$order_field] <=> $right[$order_field];
269 });
270
271 if ($order_direction === ORDER::DESC) {
272 $records = array_reverse($records);
273 }
274 }
275
276 if ($range) {
277 $records = \array_slice($records, $range->getStart(), $range->getLength());
278 }
279
280 foreach ($records as $record) {
281 yield $row_builder->buildDataRow($record['id'], $record)->withDisabledAction(
282 'badge_award_badge',
283 $record['issued'] === null
284 )->withDisabledAction(
285 'badge_revoke_badge',
286 $record['issued'] !== null
287 );
288 }
289 }
join($init, callable $fn)
Definition: Order.php:75
buildDataRow(string $id, array $record)

References ILIAS\Data\Order\join().

+ Here is the call graph for this function:

◆ getTotalRowCount()

ILIAS\Badge\ilBadgeUserTableGUI::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 291 of file class.ilBadgeUserTableGUI.php.

294 : ?int {
295 return \count($this->getRecords());
296 }

◆ renderTable()

ILIAS\Badge\ilBadgeUserTableGUI::renderTable ( string  $url)

Definition at line 343 of file class.ilBadgeUserTableGUI.php.

343 : void
344 {
345 $df = new \ILIAS\Data\Factory();
346 $this->date_format = $this->user->getDateTimeFormat();
347
348 $table_uri = $df->uri($url);
349 $url_builder = new URLBuilder($table_uri);
350 $query_params_namespace = ['tid'];
351
352 [$url_builder, $action_parameter_token, $row_id_token] = $url_builder->acquireParameters(
353 $query_params_namespace,
354 'table_action',
355 'id',
356 );
357
358 if ($this->award_badge instanceof ilBadge) {
359 $title = $this->lng->txt('badge_award_badge') . ': ' . $this->award_badge->getTitle();
360 } else {
361 $parent = '';
362 if ($this->parent_obj_id) {
363 $title = ilObject::_lookupTitle($this->parent_obj_id);
364 if (!$title) {
365 $title = ilObjectDataDeletionLog::get($this->parent_obj_id);
366 if ($title) {
367 $title = $title['title'];
368 }
369 }
370
371 if ($this->restrict_badge_id) {
372 $badge = new ilBadge($this->restrict_badge_id);
373 $title .= ' - ' . $badge->getTitle();
374 }
375
376 $parent = $title . ': ';
377 }
378 $title = $parent . $this->lng->txt('users');
379 }
380
381 $table = $this->factory
382 ->table()
383 ->data($this, $title, $this->getColumns())
384 ->withId(self::class . '_' . $this->parent_ref_id)
385 ->withOrder(new Order('name', Order::ASC))
386 ->withActions($this->getActions($url_builder, $action_parameter_token, $row_id_token))
387 ->withRequest($this->request);
388
389 $out = [$table];
390
391 $this->tpl->setContent($this->renderer->render($out));
392 }
$out
Definition: buildRTE.php:24
getActions(URLBuilder $url_builder, URLBuilderToken $action_parameter_token, URLBuilderToken $row_id_token,)
static _lookupTitle(int $obj_id)
$url
Definition: shib_logout.php:68

References $out, $url, ilObject\_lookupTitle(), factory(), ilObjectDataDeletionLog\get(), ILIAS\Repository\lng(), renderer(), and ILIAS\Repository\user().

+ Here is the call graph for this function:

Field Documentation

◆ $cached_records

array ILIAS\Badge\ilBadgeUserTableGUI::$cached_records = null
private

Definition at line 74 of file class.ilBadgeUserTableGUI.php.

◆ $date_format

DateFormat ILIAS\Badge\ilBadgeUserTableGUI::$date_format
private

Definition at line 59 of file class.ilBadgeUserTableGUI.php.

◆ $factory

readonly Factory ILIAS\Badge\ilBadgeUserTableGUI::$factory
private

Definition at line 52 of file class.ilBadgeUserTableGUI.php.

◆ $is_container_context

bool ILIAS\Badge\ilBadgeUserTableGUI::$is_container_context = false
private

Definition at line 60 of file class.ilBadgeUserTableGUI.php.

◆ $lng

readonly ilLanguage ILIAS\Badge\ilBadgeUserTableGUI::$lng
private

Definition at line 55 of file class.ilBadgeUserTableGUI.php.

◆ $renderer

readonly Renderer ILIAS\Badge\ilBadgeUserTableGUI::$renderer
private

Definition at line 53 of file class.ilBadgeUserTableGUI.php.

◆ $request

readonly ServerRequestInterface RequestInterface ILIAS\Badge\ilBadgeUserTableGUI::$request
private

Definition at line 54 of file class.ilBadgeUserTableGUI.php.

◆ $tpl

readonly ilGlobalTemplateInterface ILIAS\Badge\ilBadgeUserTableGUI::$tpl
private

Definition at line 56 of file class.ilBadgeUserTableGUI.php.

◆ $tree

readonly ilTree ILIAS\Badge\ilBadgeUserTableGUI::$tree
private

Definition at line 57 of file class.ilBadgeUserTableGUI.php.

◆ $user

readonly ilObjUser ILIAS\Badge\ilBadgeUserTableGUI::$user
private

Definition at line 58 of file class.ilBadgeUserTableGUI.php.


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