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();
22 $current_user_date_format = $df->
dateFormat()->withTime24(
23 $DIC[
'ilUser']->getDateFormat()
32 'usr_id' =>
$f->table()->column()->number(
"User ID")
33 ->withIsSortable(
false),
34 'login' =>
$f->table()->column()->text(
"Login")
35 ->withHighlight(
true),
36 'email' =>
$f->table()->column()->eMail(
"eMail"),
37 'last' =>
$f->table()->column()->date(
"last login", $current_user_date_format),
38 'achieve' =>
$f->table()->column()->statusIcon(
"progress")
39 ->withIsOptional(
true),
40 'achieve_txt' =>
$f->table()->column()->status(
"success")
41 ->withIsSortable(
false)
42 ->withIsOptional(
true),
43 'repeat' =>
$f->table()->column()->boolean(
"repeat",
'yes',
'no')
44 ->withIsSortable(
false),
45 'fee' =>
$f->table()->column()->number(
"Fee")
47 ->withUnit(
'£',
I\
Column\Number::UNIT_POSITION_FORE)
48 ->withOrderingLabels(
'cheapest first',
'most expensive first'),
49 'failure_txt' =>
$f->table()->column()->status(
"failure")
50 ->withIsSortable(
false)
51 ->withIsOptional(
true,
false),
63 $here_uri = $df->uri($DIC->http()->request()->getUri()->__toString());
70 $query_params_namespace = [
'datatable',
'example'];
78 list($url_builder, $action_parameter_token, $row_id_token) =
79 $url_builder->acquireParameters(
80 $query_params_namespace,
89 'edit' =>
$f->table()->action()->single(
93 $url_builder->withParameter($action_parameter_token,
"edit"),
97 'compare' =>
$f->table()->action()->multi(
99 $url_builder->withParameter($action_parameter_token,
"compare"),
103 $f->table()->action()->standard(
105 $url_builder->withParameter($action_parameter_token,
"delete"),
116 $f->table()->action()->standard(
118 $url_builder->withParameter($action_parameter_token,
"info"),
142 public function getRows(
144 array $visible_column_ids,
148 ?array $additional_parameters
150 $records = $this->getRecords($range, $order);
151 foreach ($records as $idx => $record) {
152 $row_id = (string) $record[
'usr_id'];
153 $record[
'achieve_txt'] = $record[
'achieve'] > 80 ?
'passed' :
'failed';
154 $record[
'failure_txt'] =
"not " . $record[
"achieve_txt"];
155 $record[
'repeat'] = $record[
'achieve'] < 80;
158 $this->ui_factory->symbol()->icon()->custom(
'templates/default/images/standard/icon_checked.svg',
'',
'small'),
159 $this->ui_factory->symbol()->icon()->custom(
'templates/default/images/standard/icon_unchecked.svg',
'',
'small'),
160 $this->ui_factory->symbol()->icon()->custom(
'templates/default/images/standard/icon_x.svg',
'',
'small'),
163 if($record[
'achieve'] > 80) {
166 if($record[
'achieve'] < 30) {
169 $record[
'achieve'] = $icon;
171 yield $row_builder->buildDataRow($row_id, $record)
173 ->withDisabledAction(
'delete', ($record[
'login'] ===
'superuser'));
177 public function getTotalRowCount(
179 ?array $additional_parameters
181 return count($this->getRecords());
184 protected function getRecords(
Range $range = null,
Order $order = null): array
187 [
'usr_id' => 123,
'login' =>
'superuser',
'email' =>
'user@example.com',
188 'last' => (new \DateTimeImmutable())->modify(
'-1 day') ,
'achieve' => 20,
'fee' => 0
190 [
'usr_id' => 867,
'login' =>
'student1',
'email' =>
'student1@example.com',
191 'last' => (new \DateTimeImmutable())->modify(
'-10 day'),
'achieve' => 90,
'fee' => 40
193 [
'usr_id' => 8923,
'login' =>
'student2',
'email' =>
'student2@example.com',
194 'last' => (new \DateTimeImmutable())->modify(
'-8 day'),
'achieve' => 66,
'fee' => 36.789
196 [
'usr_id' => 8748,
'login' =>
'student3_longname',
'email' =>
'student3_long_email@example.com',
197 'last' => (new \DateTimeImmutable())->modify(
'-300 day'),
'achieve' => 8,
'fee' => 36.789
199 [
'usr_id' => 8749,
'login' =>
'studentAB',
'email' =>
'studentAB@example.com',
200 'last' => (new \DateTimeImmutable())->modify(
'-7 day'),
'achieve' => 100,
'fee' => 114
202 [
'usr_id' => 8750,
'login' =>
'student5',
'email' =>
'student5@example.com',
203 'last' => new \DateTimeImmutable(),
'achieve' => 76,
'fee' => 3.789
205 [
'usr_id' => 8751,
'login' =>
'student6',
'email' =>
'student6@example.com',
206 'last' => (new \DateTimeImmutable())->modify(
'-2 day'),
'achieve' => 66,
'fee' => 67
210 list($order_field, $order_direction) = $order->
join([], fn($ret,
$key, $value) => [
$key, $value]);
211 usort($records, fn(
$a,
$b) =>
$a[$order_field] <=>
$b[$order_field]);
212 if ($order_direction ===
'DESC') {
213 $records = array_reverse($records);
230 ->data(
'a data table', $columns, $data_retrieval)
231 ->withId(
'example_base')
232 ->withActions($actions)
233 ->withRequest($request);
244 $query = $DIC->http()->wrapper()->query();
245 if ($query->has($action_parameter_token->getName())) {
246 $action = $query->retrieve($action_parameter_token->getName(),
$refinery->to()->string());
248 $ids = $query->retrieve($row_id_token->getName(),
$refinery->custom()->transformation(fn($v) => $v));
249 $listing =
$f->listing()->characteristicValue()->text([
250 'table_action' => $action,
251 'id' => print_r($ids,
true),
255 if ($action ===
'delete') {
257 foreach ($ids as
$id) {
258 $items[] =
$f->modal()->interruptiveItem()->keyValue($id, $row_id_token->getName(),
$id);
260 echo(
$r->renderAsync([
261 $f->modal()->interruptive(
263 'You are about to delete items!',
265 )->withAffectedItems($items)
266 ->withAdditionalOnLoadCode(
static fn($id):
string =>
"console.log('ASYNC JS');")
270 if ($action ===
'info') {
272 $r->render(
$f->messageBox()->info(
'an info message: <br><li>' . implode(
'<li>', $ids)))
273 .
'<script data-replace-marker="script">console.log("ASYNC JS, too");</script>' 279 $out[] =
$f->divider()->horizontal();
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.
$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