ILIAS  trunk Revision v12.0_alpha-377-g3641b37b9db
base.php
Go to the documentation of this file.
1<?php
2
19declare(strict_types=1);
20
22
27
34function base()
35{
36 global $DIC;
37 $f = $DIC['ui.factory'];
38 $r = $DIC['ui.renderer'];
39
40 $dummy_records = [123, 45.66, 78.9876];
41
42 $columns = [
43 'n1' => $f->table()->column()->number("some number"),
44 'n2' => $f->table()->column()->number("with decimals")
45 ->withDecimals(2),
46 'n3' => $f->table()->column()->number("with unit before")
47 ->withUnit('€', I\Column\Number::UNIT_POSITION_FORE),
48 'n4' => $f->table()->column()->number("with unit after")
49 ->withDecimals(2)
50 ->withUnit('Eur', I\Column\Number::UNIT_POSITION_AFT),
51 ];
52
53 $data_retrieval = new class ($dummy_records) implements I\DataRetrieval {
54 protected array $records;
55
56 public function __construct(array $dummy_records)
57 {
58 $this->records = $dummy_records;
59 }
60
61 public function getRows(
62 I\DataRowBuilder $row_builder,
63 array $visible_column_ids,
65 Order $order,
66 mixed $additional_viewcontrol_data,
67 mixed $filter_data,
68 mixed $additional_parameters
69 ): \Generator {
70 foreach ($this->records as $number) {
71 $row_id = '';
72 for ($i = 1; $i < 5; $i++) {
73 $record['n' . $i] = $number;
74 }
75 yield $row_builder->buildDataRow($row_id, $record);
76 }
77 }
78
79 public function getTotalRowCount(
80 mixed $additional_viewcontrol_data,
81 mixed $filter_data,
82 mixed $additional_parameters
83 ): ?int {
84 return count($this->records);
85 }
86 };
87
88 $table = $f->table()->data($data_retrieval, 'Number Columns', $columns)
89 ->withRequest($DIC->http()->request());
90 return $r->render($table);
91}
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
__construct()
Constructor setup ILIAS global object @access public.
Definition: class.ilias.php:76