ILIAS  trunk Revision v11.0_alpha-1744-gb0451eebef4
All Data Structures Namespaces Files Functions Variables Enumerations Enumerator Modules Pages
base.php
Go to the documentation of this file.
1 <?php
2 
19 declare(strict_types=1);
20 
22 
27 
34 function 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,
64  Range $range,
65  Order $order,
66  ?array $filter_data,
67  ?array $additional_parameters
68  ): \Generator {
69  foreach ($this->records as $number) {
70  $row_id = '';
71  for ($i = 1; $i < 5; $i++) {
72  $record['n' . $i] = $number;
73  }
74  yield $row_builder->buildDataRow($row_id, $record);
75  }
76  }
77 
78  public function getTotalRowCount(
79  ?array $filter_data,
80  ?array $additional_parameters
81  ): ?int {
82  return count($this->records);
83  }
84  };
85 
86  $table = $f->table()->data($data_retrieval, 'Number Columns', $columns)
87  ->withRequest($DIC->http()->request());
88  return $r->render($table);
89 }
base()
expected output: > ILIAS shows the rendered Component.
Definition: base.php:34
Both the subject and the direction need to be specified when expressing an order. ...
Definition: Order.php:28
__construct()
Constructor setup ILIAS global object public.
Definition: class.ilias.php:76
global $DIC
Definition: shib_login.php:22
A simple class to express a naive range of whole positive numbers.
Definition: Range.php:28
$r