ILIAS  release_8 Revision v8.19
All Data Structures Namespaces Files Functions Variables Modules Pages
base.php
Go to the documentation of this file.
1 <?php
2 
3 declare(strict_types=1);
4 
6 
11 
12 function base()
13 {
14  global $DIC;
15  $f = $DIC['ui.factory'];
16  $r = $DIC['ui.renderer'];
17 
18  $dummy_records = [123, 45.66, 78.9876];
19 
20  $columns = [
21  'n1' => $f->table()->column()->number("some number"),
22  'n2' => $f->table()->column()->number("with decimals")
23  ->withDecimals(2),
24  'n3' => $f->table()->column()->number("with unit before")
25  ->withUnit('€', I\Column\Number::UNIT_POSITION_FORE),
26  'n4' => $f->table()->column()->number("with unit after")
27  ->withDecimals(2)
28  ->withUnit('Eur', I\Column\Number::UNIT_POSITION_AFT),
29  ];
30 
31  $data_retrieval = new class ($dummy_records) implements I\DataRetrieval {
32  protected array $records;
33 
34  public function __construct(array $dummy_records)
35  {
36  $this->records = $dummy_records;
37  }
38 
39  public function getRows(
40  I\DataRowBuilder $row_builder,
41  array $visible_column_ids,
42  Range $range,
43  Order $order,
44  ?array $filter_data,
45  ?array $additional_parameters
46  ): \Generator {
47  foreach ($this->records as $number) {
48  $row_id = '';
49  for ($i = 1; $i < 5; $i++) {
50  $record['n' . $i] = $number;
51  }
52  yield $row_builder->buildDataRow($row_id, $record);
53  }
54  }
55 
56  public function getTotalRowCount(
57  ?array $filter_data,
58  ?array $additional_parameters
59  ): ?int {
60  return count($this->records);
61  }
62  };
63 
64  $table = $f->table()->data('Number Columns', $columns, $data_retrieval)
65  ->withRequest($DIC->http()->request());
66  return $r->render($table);
67 }
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
Both the subject and the direction need to be specified when expressing an order. ...
Definition: Order.php:12
global $DIC
Definition: feed.php:28
__construct()
Constructor setup ILIAS global object public.
Definition: class.ilias.php:62
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
A simple class to express a range of whole positive numbers.
Definition: Range.php:30
$i
Definition: metadata.php:41