ILIAS  trunk Revision v11.0_alpha-1744-gb0451eebef4
All Data Structures Namespaces Files Functions Variables Enumerations Enumerator Modules Pages
DataRetrieval.php
Go to the documentation of this file.
1 <?php
2 
20 
25 
30 class DataRetrieval implements I\OrderingRetrieval
31 {
32  private \ilLanguage $lng;
33 
34  public function __construct(
35  protected \ilBiblAdminFactoryFacadeInterface $facade
36  ) {
37  global $DIC;
38  $this->lng = $DIC['lng'];
39  }
40 
41  public function getRows(
42  OrderingRowBuilder $row_builder,
43  array $visible_column_ids
44  ): \Generator {
45  $records = $this->getRecords(new Order('position', 'ASC'));
46  foreach ($records as $idx => $record) {
47  $row_id = (string) $record['id'];
48  $field = $this->facade->fieldFactory()->findById($record['id']);
49  $record['data_type'] = $this->facade->translationFactory()->translate($field);
50  $record['is_standard_field'] = $field->isStandardField() ? $this->lng->txt('standard') : $this->lng->txt('custom');
51  yield $row_builder->buildOrderingRow($row_id, $record);
52  }
53  }
54 
55  public function getRows22(
56  I\DataRowBuilder $row_builder,
57  array $visible_column_ids,
58  Range $range,
59  Order $order,
60  ?array $filter_data,
61  ?array $additional_parameters
62  ): \Generator {
63  $records = $this->getRecords($order);
64  foreach ($records as $idx => $record) {
65  $row_id = (string) $record['id'];
66  $field = $this->facade->fieldFactory()->findById($record['id']);
67  $record['data_type'] = $this->facade->translationFactory()->translate($field);
68  $record['is_standard_field'] = $field->isStandardField() ? $this->lng->txt('standard') : $this->lng->txt('custom');
69  yield $row_builder->buildDataRow($row_id, $record);
70  }
71  }
72 
73  protected function getRecords(Order $order): array
74  {
75  $records = $this->facade->fieldFactory()->filterAllFieldsForTypeAsArray($this->facade->type());
76  [$order_field, $order_direction] = $order->join([], fn($ret, $key, $value): array => [$key, $value]);
77  usort($records, fn($a, $b): int => $a[$order_field] <=> $b[$order_field]);
78  if ($order_direction === 'DESC') {
79  return array_reverse($records);
80  }
81  return $records;
82  }
83 
84  public function getTotalRowCount(
85  ?array $filter_data,
86  ?array $additional_parameters
87  ): ?int {
88  return count($this->facade->fieldFactory()->getAvailableFieldsForObjId($this->facade->iliasObjId()));
89  }
90 }
join($init, callable $fn)
Definition: Order.php:75
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
getRows(OrderingRowBuilder $row_builder, array $visible_column_ids)
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:28
getRows22(I\DataRowBuilder $row_builder, array $visible_column_ids, Range $range, Order $order, ?array $filter_data, ?array $additional_parameters)
global $DIC
Definition: shib_login.php:22
$a
thx to https://mlocati.github.io/php-cs-fixer-configurator for the examples
getTotalRowCount(?array $filter_data, ?array $additional_parameters)
A simple class to express a naive range of whole positive numbers.
Definition: Range.php:28
__construct(protected \ilBiblAdminFactoryFacadeInterface $facade)