ILIAS  release_10 Revision v10.1-43-ga1241a92c2f
base.php
Go to the documentation of this file.
1 <?php
2 
3 declare(strict_types=1);
4 
6 
11 
18 function base()
19 {
20  global $DIC;
21  $f = $DIC['ui.factory'];
22  $r = $DIC['ui.renderer'];
23 
24  $dummy_records = [123, 45.66, 78.9876];
25 
26  $columns = [
27  'n1' => $f->table()->column()->number("some number"),
28  'n2' => $f->table()->column()->number("with decimals")
29  ->withDecimals(2),
30  'n3' => $f->table()->column()->number("with unit before")
31  ->withUnit('€', I\Column\Number::UNIT_POSITION_FORE),
32  'n4' => $f->table()->column()->number("with unit after")
33  ->withDecimals(2)
34  ->withUnit('Eur', I\Column\Number::UNIT_POSITION_AFT),
35  ];
36 
37  $data_retrieval = new class ($dummy_records) implements I\DataRetrieval {
38  protected array $records;
39 
40  public function __construct(array $dummy_records)
41  {
42  $this->records = $dummy_records;
43  }
44 
45  public function getRows(
46  I\DataRowBuilder $row_builder,
47  array $visible_column_ids,
48  Range $range,
49  Order $order,
50  ?array $filter_data,
51  ?array $additional_parameters
52  ): \Generator {
53  foreach ($this->records as $number) {
54  $row_id = '';
55  for ($i = 1; $i < 5; $i++) {
56  $record['n' . $i] = $number;
57  }
58  yield $row_builder->buildDataRow($row_id, $record);
59  }
60  }
61 
62  public function getTotalRowCount(
63  ?array $filter_data,
64  ?array $additional_parameters
65  ): ?int {
66  return count($this->records);
67  }
68  };
69 
70  $table = $f->table()->data('Number Columns', $columns, $data_retrieval)
71  ->withRequest($DIC->http()->request());
72  return $r->render($table);
73 }
base()
expected output: > ILIAS shows the rendered Component.
Definition: base.php:18
Both the subject and the direction need to be specified when expressing an order. ...
Definition: Order.php:12
__construct()
Constructor setup ILIAS global object public.
Definition: class.ilias.php:76
global $DIC
Definition: shib_login.php:25
A simple class to express a naive range of whole positive numbers.
Definition: Range.php:28
$r