19 declare(strict_types=1);
39 $f = $DIC[
'ui.factory'];
40 $r = $DIC[
'ui.renderer'];
41 $df = new \ILIAS\Data\Factory();
43 $request = $DIC->http()->request();
51 'usr_id' =>
$f->table()->column()->number(
"User ID")
52 ->withIsSortable(
false),
53 'login' =>
$f->table()->column()->text(
"Login")
54 ->withHighlight(
true),
55 'email' =>
$f->table()->column()->eMail(
"eMail"),
56 'last' =>
$f->table()->column()->date(
"last login", $df->dateFormat()->germanLong()),
57 'achieve' =>
$f->table()->column()->statusIcon(
"progress")
58 ->withIsOptional(
true),
59 'achieve_txt' =>
$f->table()->column()->status(
"success")
60 ->withIsSortable(
true)
61 ->withIsOptional(
true,
false),
62 'repeat' =>
$f->table()->column()->boolean(
"repeat",
'yes',
'no')
63 ->withIsSortable(
false),
64 'fee' =>
$f->table()->column()->number(
"Fee")
66 ->withUnit(
'£',
I\Column\Number::UNIT_POSITION_FORE)
67 ->withOrderingLabels(
'cheapest first',
'most expensive first'),
68 'failure_txt' =>
$f->table()->column()->status(
"failure")
69 ->withIsSortable(
false)
70 ->withIsOptional(
true,
false),
82 $here_uri = $df->uri($DIC->http()->request()->getUri()->__toString());
89 $query_params_namespace = [
'datatable',
'example'];
97 list($url_builder, $action_parameter_token, $row_id_token) =
98 $url_builder->acquireParameters(
99 $query_params_namespace,
108 'edit' =>
$f->table()->action()->single(
112 $url_builder->withParameter($action_parameter_token,
"edit"),
116 'compare' =>
$f->table()->action()->multi(
118 $url_builder->withParameter($action_parameter_token,
"compare"),
122 $f->table()->action()->standard(
124 $url_builder->withParameter($action_parameter_token,
"delete"),
135 $f->table()->action()->standard(
137 $url_builder->withParameter($action_parameter_token,
"info"),
161 public function getRows(
163 array $visible_column_ids,
167 ?array $additional_parameters
169 $records = $this->getRecords($range, $order);
170 foreach ($records as $idx => $record) {
171 $row_id = (string) $record[
'usr_id'];
172 $record[
'achieve_txt'] = $record[
'achieve'] > 80 ?
'passed' :
'failed';
173 $record[
'failure_txt'] =
"not " . $record[
"achieve_txt"];
174 $record[
'repeat'] = $record[
'achieve'] < 80;
177 $this->ui_factory->symbol()->icon()->custom(
'assets/images/standard/icon_checked.svg',
'',
'small'),
178 $this->ui_factory->symbol()->icon()->custom(
'assets/images/standard/icon_unchecked.svg',
'',
'small'),
179 $this->ui_factory->symbol()->icon()->custom(
'assets/images/standard/icon_x.svg',
'',
'small'),
182 if ($record[
'achieve'] > 80) {
185 if ($record[
'achieve'] < 30) {
188 $record[
'achieve'] = $icon;
190 yield $row_builder->buildDataRow($row_id, $record)
192 ->withDisabledAction(
'delete', ($record[
'login'] ===
'superuser'));
196 public function getTotalRowCount(
198 ?array $additional_parameters
200 return count($this->getRecords());
206 [
'usr_id' => 123,
'login' =>
'superuser',
'email' =>
'user@example.com',
207 'last' => (new \DateTimeImmutable())->modify(
'-1 day') ,
'achieve' => 20,
'fee' => 0
209 [
'usr_id' => 867,
'login' =>
'student1',
'email' =>
'student1@example.com',
210 'last' => (new \DateTimeImmutable())->modify(
'-10 day'),
'achieve' => 90,
'fee' => 40
212 [
'usr_id' => 8923,
'login' =>
'student2',
'email' =>
'student2@example.com',
213 'last' => (new \DateTimeImmutable())->modify(
'-8 day'),
'achieve' => 66,
'fee' => 36.789
215 [
'usr_id' => 8748,
'login' =>
'student3_longname',
'email' =>
'student3_long_email@example.com',
216 'last' => (new \DateTimeImmutable())->modify(
'-300 day'),
'achieve' => 8,
'fee' => 36.789
218 [
'usr_id' => 8749,
'login' =>
'studentAB',
'email' =>
'studentAB@example.com',
219 'last' => (new \DateTimeImmutable())->modify(
'-7 day'),
'achieve' => 100,
'fee' => 114
221 [
'usr_id' => 8750,
'login' =>
'student5',
'email' =>
'student5@example.com',
222 'last' => new \DateTimeImmutable(),
'achieve' => 76,
'fee' => 3.789
224 [
'usr_id' => 8751,
'login' =>
'student6',
'email' =>
'student6@example.com',
225 'last' => (new \DateTimeImmutable())->modify(
'-2 day'),
'achieve' => 66,
'fee' => 67
229 list($order_field, $order_direction) = $order->
join([], fn($ret, $key, $value) => [$key, $value]);
230 usort($records, fn(
$a,
$b) =>
$a[$order_field] <=>
$b[$order_field]);
231 if ($order_direction ===
'DESC') {
232 $records = array_reverse($records);
249 ->data($data_retrieval,
'a data table', $columns)
250 ->withId(
'example_base')
251 ->withActions($actions)
255 ->withRange(
new Range(0, 2))
258 ->withRequest($request);
269 $query = $DIC->http()->wrapper()->query();
270 if ($query->has($action_parameter_token->getName())) {
271 $action = $query->retrieve($action_parameter_token->getName(),
$refinery->to()->string());
273 $ids = $query->retrieve($row_id_token->getName(),
$refinery->custom()->transformation(fn($v) => $v));
274 $listing =
$f->listing()->characteristicValue()->text([
275 'table_action' => $action,
276 'id' => print_r($ids,
true),
280 if ($action ===
'delete') {
282 foreach ($ids as
$id) {
283 $items[] =
$f->modal()->interruptiveItem()->keyValue($id, $row_id_token->getName(),
$id);
285 echo(
$r->renderAsync([
286 $f->modal()->interruptive(
288 'You are about to delete items!',
290 )->withAffectedItems($items)
291 ->withAdditionalOnLoadCode(
static fn($id):
string =>
"console.log('ASYNC JS');")
295 if ($action ===
'info') {
297 $r->render(
$f->messageBox()->info(
'an info message: <br><li>' . implode(
'<li>', $ids)))
298 .
'<script data-replace-marker="script">console.log("ASYNC JS, too");</script>' 304 $out[] =
$f->divider()->horizontal();
join($init, callable $fn)
Interface Observer Contains several chained tasks and infos about them.
Both the subject and the direction need to be specified when expressing an order. ...
while($session_entry=$r->fetchRow(ilDBConstants::FETCHMODE_ASSOC)) return null
__construct()
Constructor setup ILIAS global object public.
base()
expected output: > ILIAS shows the rendered Component.
$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 naive range of whole positive numbers.