ILIAS  trunk Revision v11.0_alpha-3011-gc6b235a2e85
class.ilLTIConsumerProviderUsageTableGUI.php
Go to the documentation of this file.
1<?php
2
19declare(strict_types=1);
20
29
39{
40 protected ilLanguage $lng;
42 protected \ILIAS\UI\Renderer $ui_renderer;
43 protected $request;
44 protected array $records;
45
46 public function __construct()
47 {
48 global $DIC;
49
50 $this->lng = $DIC->language();
51 $this->ui_factory = $DIC->ui()->factory();
52 $this->ui_renderer = $DIC->ui()->renderer();
53 $this->request = $DIC->http()->request();
54 }
55
56 public function getRows(DataRowBuilder $row_builder, array $visible_column_ids, Range $range, Order $order, ?array $filter_data, ?array $additional_parameters): Generator
57 {
58 global $DIC;
59
61 $static_url = $DIC["static_url"];
62
63 foreach ($this->records as $record) {
64 $record['icon'] = $record['icon'] ?? "lti";
65 $record['icon'] = $this->ui_factory->symbol()->icon()->standard($record['icon'], $record['icon'], Icon::SMALL);
66
67 $link = (string) $static_url->builder()->build(
68 ilObject::_lookupType($record['usedByObjId']),
69 new ReferenceId($record['usedByRefId'])
70 );
71
72 $record['used_by'] = $this->ui_factory->link()->standard(
73 $record['usedByTitle'],
74 $link
75 );
76
77 yield $row_builder->buildDataRow((string) $record['id'], $record);
78 }
79 }
80
81 public function getTotalRowCount(?array $filter_data, ?array $additional_parameters): ?int
82 {
83 return count($this->records);
84 }
85
86 public function setData(array $data): void
87 {
88 $this->records = $data;
89 }
90
91 public function getHTML(): string
92 {
93 $table = $this->ui_factory->table()
94 ->data($this->lng->txt('tbl_provider_usage_header'), $this->getColumns(), $this)
95 ->withOrder(new Order('title', Order::ASC))
96 ->withRequest($this->request);
97
98 return $this->ui_renderer->render($table);
99 }
100
101 private function getColumns(): array
102 {
103 return [
104 "icon" => $this->ui_factory->table()->column()->statusIcon($this->lng->txt('tbl_lti_prov_icon')),
105 "title" => $this->ui_factory->table()->column()->text($this->lng->txt('tbl_lti_prov_title')),
106 "usedByIsTrashed" => $this->ui_factory->table()->column()->boolean(
107 $this->lng->txt('tbl_lti_prov_usages_trashed'),
108 $this->ui_factory->symbol()->icon()->custom('assets/images/standard/icon_ok.svg', $this->lng->txt('icon_ok'), Icon::SMALL),
109 $this->ui_factory->symbol()->icon()->custom('assets/images/standard/icon_not_ok.svg', $this->lng->txt('icon_not_ok'), Icon::SMALL)
110 ),
111 "used_by" => $this->ui_factory->table()->column()->link($this->lng->txt('tbl_lti_prov_used_by'))
112 ];
113 }
114}
Builds a Color from either hex- or rgb values.
Definition: Factory.php:31
Both the subject and the direction need to be specified when expressing an order.
Definition: Order.php:29
A simple class to express a naive range of whole positive numbers.
Definition: Range.php:29
Class Services.
Definition: Services.php:38
getTotalRowCount(?array $filter_data, ?array $additional_parameters)
Mainly for the purpose of pagination-support, it is important to know about the total number of recor...
language handling
static _lookupType(int $id, bool $reference=false)
$static_url
Definition: goto.php:29
This describes how an icon could be modified during construction of UI.
Definition: Icon.php:29
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....
buildDataRow(string $id, array $record)
This is how the factory for UI elements looks.
Definition: Factory.php:38
global $DIC
Definition: shib_login.php:26