ILIAS  trunk Revision v12.0_alpha-454-g178fcb218fa
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, 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...
 
 getColumns ()
 
 renderTable (string $url)
 
 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

 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 49 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 75 of file class.ilBadgeUserTableGUI.php.

80 {
81 global $DIC;
82
83 $this->lng = $DIC->language();
84 $this->tpl = $DIC->ui()->mainTemplate();
85 $this->factory = $DIC->ui()->factory();
86 $this->renderer = $DIC->ui()->renderer();
87 $this->request = $DIC->http()->request();
88 $this->tree = $DIC->repositoryTree();
89 $this->user = $DIC->user();
90
91 if ($this->parent_ref_id) {
92 $parent_type = ilObject::_lookupType($this->parent_ref_id, true);
93 if (\in_array($parent_type, ['grp', 'crs'], true)) {
94 $this->is_container_context = $this->parent_obj_id === null && $this->award_badge === null;
95 }
96 }
97 }
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 323 of file class.ilBadgeUserTableGUI.php.

327 : array {
328 return ($this->award_badge instanceof ilBadge) ? [
329 'badge_award_badge' =>
330 $this->factory->table()->action()->multi(
331 $this->lng->txt('badge_award_badge'),
332 $url_builder->withParameter($action_parameter_token, 'assignBadge'),
333 $row_id_token
334 ),
335 'badge_revoke_badge' =>
336 $this->factory->table()->action()->multi(
337 $this->lng->txt('badge_remove_badge'),
338 $url_builder->withParameter($action_parameter_token, 'revokeBadge'),
339 $row_id_token
340 )
341 ] : [];
342 }
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 302 of file class.ilBadgeUserTableGUI.php.

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

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,
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.

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

Parameters
string[]$visible_column_ids

Implements ILIAS\UI\Component\Table\DataRetrieval.

Definition at line 235 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 ( 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 291 of file class.ilBadgeUserTableGUI.php.

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

◆ renderTable()

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

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

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

◆ $date_format

DateFormat ILIAS\Badge\ilBadgeUserTableGUI::$date_format
private

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

◆ $factory

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

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

◆ $is_container_context

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

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

◆ $lng

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

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

◆ $renderer

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

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

◆ $request

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

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

◆ $tpl

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

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

◆ $tree

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

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

◆ $user

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

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


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