3 declare(strict_types=1);
17 $f = $DIC[
'ui.factory'];
18 $r = $DIC[
'ui.renderer'];
19 $df = new \ILIAS\Data\Factory();
21 $request = $DIC->http()->request();
29 'usr_id' =>
$f->table()->column()->number(
"User ID")
30 ->withIsSortable(
false),
31 'login' =>
$f->table()->column()->text(
"Login")
32 ->withHighlight(
true),
33 'email' =>
$f->table()->column()->eMail(
"eMail"),
34 'last' =>
$f->table()->column()->date(
"last login", $df->dateFormat()->germanLong()),
35 'achieve' =>
$f->table()->column()->statusIcon(
"progress")
36 ->withIsOptional(
true),
37 'achieve_txt' =>
$f->table()->column()->status(
"success")
38 ->withIsSortable(
false)
39 ->withIsOptional(
true),
40 'repeat' =>
$f->table()->column()->boolean(
"repeat",
'yes',
'no')
41 ->withIsSortable(
false),
42 'fee' =>
$f->table()->column()->number(
"Fee")
44 ->withUnit(
'£',
I\
Column\Number::UNIT_POSITION_FORE)
45 ->withOrderingLabels(
'cheapest first',
'most expensive first'),
46 'failure_txt' =>
$f->table()->column()->status(
"failure")
47 ->withIsSortable(
false)
48 ->withIsOptional(
true,
false),
60 $here_uri = $df->
uri($DIC->http()->request()->getUri()->__toString());
67 $query_params_namespace = [
'datatable',
'example'];
75 list($url_builder, $action_parameter_token, $row_id_token) =
76 $url_builder->acquireParameters(
77 $query_params_namespace,
86 'edit' =>
$f->table()->action()->single(
90 $url_builder->withParameter($action_parameter_token,
"edit"),
94 'compare' =>
$f->table()->action()->multi(
96 $url_builder->withParameter($action_parameter_token,
"compare"),
100 $f->table()->action()->standard(
102 $url_builder->withParameter($action_parameter_token,
"delete"),
113 $f->table()->action()->standard(
115 $url_builder->withParameter($action_parameter_token,
"info"),
134 protected \ILIAS\UI\Factory $ui_factory;
135 protected \ILIAS\UI\Renderer $ui_renderer;
141 $this->ui_factory = $ui_factory;
142 $this->ui_renderer = $ui_renderer;
145 public function getRows(
147 array $visible_column_ids,
151 ?array $additional_parameters
153 $records = $this->getRecords($range, $order);
154 foreach ($records as $idx => $record) {
155 $row_id = (string)$record[
'usr_id'];
156 $record[
'achieve_txt'] = $record[
'achieve'] > 80 ?
'passed' :
'failed';
157 $record[
'failure_txt'] =
"not " . $record[
"achieve_txt"];
158 $record[
'repeat'] = $record[
'achieve'] < 80;
161 $this->ui_factory->symbol()->icon()->custom(
'templates/default/images/standard/icon_checked.svg',
'',
'small'),
162 $this->ui_factory->symbol()->icon()->custom(
'templates/default/images/standard/icon_unchecked.svg',
'',
'small'),
163 $this->ui_factory->symbol()->icon()->custom(
'templates/default/images/standard/icon_x.svg',
'',
'small'),
166 if($record[
'achieve'] > 80) {
169 if($record[
'achieve'] < 30) {
172 $record[
'achieve'] = $icon;
174 yield $row_builder->buildDataRow($row_id, $record)
176 ->withDisabledAction(
'delete', ($record[
'login'] ===
'superuser'));
180 public function getTotalRowCount(
182 ?array $additional_parameters
184 return count($this->getRecords());
187 protected function getRecords(
Range $range = null,
Order $order = null): array
190 [
'usr_id' => 123,
'login' =>
'superuser',
'email' =>
'user@example.com',
191 'last' => (new \DateTimeImmutable())->modify(
'-1 day') ,
'achieve' => 20,
'fee' => 0
193 [
'usr_id' => 867,
'login' =>
'student1',
'email' =>
'student1@example.com',
194 'last' => (new \DateTimeImmutable())->modify(
'-10 day'),
'achieve' => 90,
'fee' => 40
196 [
'usr_id' => 8923,
'login' =>
'student2',
'email' =>
'student2@example.com',
197 'last' => (new \DateTimeImmutable())->modify(
'-8 day'),
'achieve' => 66,
'fee' => 36.789
199 [
'usr_id' => 8748,
'login' =>
'student3_longname',
'email' =>
'student3_long_email@example.com',
200 'last' => (new \DateTimeImmutable())->modify(
'-300 day'),
'achieve' => 8,
'fee' => 36.789
202 [
'usr_id' => 8749,
'login' =>
'studentAB',
'email' =>
'studentAB@example.com',
203 'last' => (new \DateTimeImmutable())->modify(
'-7 day'),
'achieve' => 100,
'fee' => 114
205 [
'usr_id' => 8750,
'login' =>
'student5',
'email' =>
'student5@example.com',
206 'last' => new \DateTimeImmutable(),
'achieve' => 76,
'fee' => 3.789
208 [
'usr_id' => 8751,
'login' =>
'student6',
'email' =>
'student6@example.com',
209 'last' => (new \DateTimeImmutable())->modify(
'-2 day'),
'achieve' => 66,
'fee' => 67
213 list($order_field, $order_direction) = $order->
join([], fn ($ret,
$key, $value) => [
$key, $value]);
214 usort($records, fn (
$a,
$b) =>
$a[$order_field] <=>
$b[$order_field]);
215 if ($order_direction ===
'DESC') {
216 $records = array_reverse($records);
233 ->data(
'a data table', $columns, $data_retrieval)
234 ->withId(
'example_base')
235 ->withActions($actions)
236 ->withRequest($request);
247 $query = $DIC->http()->wrapper()->query();
248 if (
$query->has($action_parameter_token->getName())) {
249 $action =
$query->retrieve($action_parameter_token->getName(),
$refinery->to()->string());
251 $ids =
$query->retrieve($row_id_token->getName(),
$refinery->custom()->transformation(fn ($v) => $v));
252 $listing =
$f->listing()->characteristicValue()->text([
253 'table_action' => $action,
254 'id' => print_r($ids,
true),
258 if ($action ===
'delete') {
260 foreach ($ids as
$id) {
261 $items[] =
$f->modal()->interruptiveItem(
263 $row_id_token->getName() .
' - ' .
$id 266 echo($r->renderAsync([
267 $f->modal()->interruptive(
269 'You are about to delete items!',
271 )->withAffectedItems($items)
272 ->withAdditionalOnLoadCode(
static fn ($id):
string =>
"console.log('ASYNC JS');")
276 if ($action ===
'info') {
278 $r->render(
$f->messageBox()->info(
'an info message: <br><li>' . implode(
'<li>', $ids)))
279 .
'<script data-replace-marker="script">console.log("ASYNC JS, too");</script>' 285 $out[] =
$f->divider()->horizontal();
289 return $r->render(
$out);
An entity that renders components to a string output.
join($init, callable $fn)
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
Class ChatMainBarProvider .
Both the subject and the direction need to be specified when expressing an order. ...
__construct()
Constructor setup ILIAS global object public.
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
uri(string $uri_string)
Object representing an uri valid according to RFC 3986 with restrictions imposed on valid characters ...
$id
plugin.php for ilComponentBuildPluginInfoObjectiveTest::testAddPlugins
$a
thx to https://mlocati.github.io/php-cs-fixer-configurator for the examples
A simple class to express a range of whole positive numbers.
Refinery Factory $refinery