19declare(strict_types=1);
38 private readonly
int $current_version,
39 private readonly
bool $current_version_is_draft,
40 private readonly
int $amount_of_versions,
44 private readonly UIFactory $ui_factory
49 I\DataRowBuilder $row_builder,
50 array $visible_column_ids,
53 mixed $additional_viewcontrol_data,
55 mixed $additional_parameters
58 foreach ($records as $record) {
59 $row_id = (string) $record[
'hist_entry_id'];
60 $version_number = (
int) $record[
'version'];
61 $is_current = $version_number === $this->current_version;
63 yield $row_builder->buildDataRow($row_id, $this->
mapRecord($record))
66 $this->current_version_is_draft
69 self::ACTION_ROLLBACK,
70 $this->current_version_is_draft || $is_current
74 !($this->current_version_is_draft && $is_current)
77 self::ACTION_UNPUBLISH,
78 $this->current_version_is_draft || !$is_current || $this->amount_of_versions <= 1
84 mixed $additional_viewcontrol_data,
86 mixed $additional_parameters
88 return count($this->file->getVersions());
97 foreach ($this->file->getVersions() as
$version) {
98 $records[] =
$version->getArrayCopy();
101 [$order_field, $order_direction] = $order->
join([], fn($ret, $key, $value): array => [$key, $value]);
102 if ($order_field ===
'version') {
103 usort($records,
static fn(array
$a, array
$b):
int => (
int)
$a[
'version'] <=> (
int)
$b[
'version']);
105 usort($records,
static fn(array
$a, array
$b):
int => (
$a[$order_field] ??
null) <=> (
$b[$order_field] ??
null));
107 if ($order_direction ===
'DESC') {
108 $records = array_reverse($records);
119 $hist_id = (
int) $record[
'hist_entry_id'];
122 $username = trim(($name[
'title'] ??
'') .
' ' . ($name[
'firstname'] ??
'') .
' ' . ($name[
'lastname'] ??
''));
124 $action_label = $this->
lng->txt(
'file_version_' . $record[
'action']);
125 if ($record[
'action'] ===
'rollback') {
127 $rollback_username = trim(
128 ($rollback_name[
'title'] ??
'') .
' ' .
129 ($rollback_name[
'firstname'] ??
'') .
' ' .
130 ($rollback_name[
'lastname'] ??
'')
132 $action_label = sprintf($action_label, $record[
'rollback_version'], $rollback_username);
139 $filename_link = $this->ui_factory->link()->standard((
string) $record[
'filename'], $download_url);
141 $size =
new DataSize((
int) ($record[
'size'] ?? 0), DataSize::KB);
144 'version' => (
int) $record[
'version'],
145 'filename' => $filename_link,
146 'date' =>
new \DateTimeImmutable((
string) $record[
'date']),
147 'uploaded_by' => $username,
148 'versionname' => (
string) ($record[
'title'] ??
''),
149 'filesize' => (
string) $size,
150 'status' => $action_label,
Builds a Color from either hex- or rgb values.
This class provides the data size with additional information to remove the work to calculate the siz...
Both the subject and the direction need to be specified when expressing an order.
join($init, callable $fn)
A simple class to express a naive range of whole positive numbers.
const string ACTION_PUBLISH
__construct(private readonly \ilObjFile $file, private readonly int $current_version, private readonly bool $current_version_is_draft, private readonly int $amount_of_versions, private readonly \ilCtrlInterface $ctrl, private readonly \ilFileVersionsGUI $parent_gui, private readonly \ilLanguage $lng, private readonly UIFactory $ui_factory)
const string ACTION_ROLLBACK
const string ACTION_UNPUBLISH
getRows(I\DataRowBuilder $row_builder, array $visible_column_ids, Range $range, Order $order, mixed $additional_viewcontrol_data, mixed $filter_data, mixed $additional_parameters)
const string ACTION_DELETE
getTotalRowCount(mixed $additional_viewcontrol_data, mixed $filter_data, mixed $additional_parameters)
Mainly for the purpose of pagination-support, it is important to know about the total number of recor...
const CMD_DOWNLOAD_VERSION
static _lookupName(int $a_user_id)
return['delivery_method'=> 'php',]
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
$a
thx to https://mlocati.github.io/php-cs-fixer-configurator for the examples