55 $this->
ui = $DIC->ui();
56 $this->irss = $DIC->resourceStorage();
57 $this->
setId(self::class);
59 $this->file = $calling_gui_class->
getFile();
60 $this->current_version = $this->file->getVersion(
true);
61 $rid = $this->irss->manage()->find(
62 $this->file->getResourceId()
64 $revision = $this->irss->manage()->getCurrentRevisionIncludingDraft(
67 $this->amount_of_versions = count(
68 $this->irss->manage()->getResource($rid)->getAllRevisionsIncludingDraft()
74 $this->dic->language()->loadLanguageModule(
'file');
77 $this->
setRowTemplate(
"tpl.file_version_row.html",
"components/ILIAS/File");
81 $this->
setTitle($this->dic->language()->txt(
"versions"));
85 $this->
setFormAction($this->dic->ctrl()->getFormAction($calling_gui_class));
92 $this->dic->language()->txt(
"file_rollback")
97 $this->
addColumn($this->dic->language()->txt(
"version"),
"",
"auto");
98 $this->
addColumn($this->dic->language()->txt(
"filename"));
99 $this->
addColumn($this->dic->language()->txt(
"date"));
100 $this->
addColumn($this->dic->language()->txt(
"file_uploaded_by"));
101 $this->
addColumn($this->dic->language()->txt(
"versionname"));
102 $this->
addColumn($this->dic->language()->txt(
"filesize"),
"",
"",
false);
103 $this->
addColumn($this->dic->language()->txt(
"status"));
104 $this->
addColumn($this->dic->language()->txt(
"action"));
113 foreach ($this->file->getVersions() as
$version) {
114 $versions[] =
$version->getArrayCopy();
116 usort($versions,
static fn(array $i1, array $i2):
int => $i2[
'version'] - $i1[
'version']);
119 $this->
setMaxCount(is_array($versions) ? count($versions) : 0);
123 protected function fillRow(array $a_set): void
125 $action_entries = [];
126 $hist_id = $a_set[
"hist_entry_id"];
131 $rollback_version = $a_set[
"rollback_version"];
132 $rollback_user_id = $a_set[
"rollback_user_id"];
136 $username = trim($name[
"title"] .
" " . $name[
"firstname"] .
" " . $name[
"lastname"]);
140 (
int) ($a_set[
"size"] ?? 0),
143 $filesize = (string) $data_size;
146 $action = $this->dic->language()->txt(
147 "file_version_" . $a_set[
"action"]
149 if ($a_set[
"action"] ==
"rollback") {
151 $rollback_username = trim($name[
"title"] .
" " . $name[
"firstname"] .
" " . $name[
"lastname"]);
152 $action = sprintf($action, $rollback_version, $rollback_username);
160 $pseudo_modal = $this->
ui->factory()->modal()->interruptive(
'',
'',
'')->withAsyncRenderUrl(
161 $this->
ctrl->getLinkTargetByClass(
162 ilFileVersionsGUI::class,
169 $this->modals[] = $pseudo_modal;
170 $buttons = $this->dic->ui()->factory()->button();
173 if (!$this->current_version_is_draft) {
174 $action_entries[
'delete'] =
$buttons 176 $this->dic->language()->txt(
"delete"),
180 $pseudo_modal->getShowSignal()
184 if ($this->current_version !== (
int)
$version) {
185 $action_entries[
'file_rollback'] =
$buttons 187 $this->dic->language()->txt(
"file_rollback"),
190 } elseif ($this->amount_of_versions > 1) {
191 $action_entries[
'unpublish'] =
$buttons 193 $this->dic->language()->txt(
"file_unpublish"),
197 } elseif ($this->current_version === (
int)
$version) {
198 $action_entries[
'publish'] =
$buttons 200 $this->dic->language()->txt(
"file_publish"),
206 $actions = $this->dic->ui()->renderer()->render(
207 $this->dic->ui()->factory()->dropdown()
208 ->standard($action_entries)
209 ->withLabel($this->
lng->txt(
'actions'))
216 $this->tpl->setVariable(
"TXT_VERSION", $version);
217 $this->tpl->setVariable(
221 $this->tpl->setVariable(
"TXT_UPLOADED_BY", $username);
222 $this->tpl->setVariable(
"DL_LINK", $link);
223 $this->tpl->setVariable(
"TXT_FILENAME",
$filename);
224 $this->tpl->setVariable(
"TXT_VERSIONNAME", $a_set[
'title']);
225 $this->tpl->setVariable(
"TXT_FILESIZE", $data_size);
228 $this->tpl->setCurrentBlock(
"version_selection");
229 $this->tpl->setVariable(
"OBJ_ID", $hist_id);
230 $this->tpl->parseCurrentBlock();
232 $this->tpl->setCurrentBlock(
"version_txt_actions");
233 $this->tpl->setVariable(
"TXT_ACTION", $action);
234 $this->tpl->parseCurrentBlock();
236 $this->tpl->setCurrentBlock(
"version_actions");
238 $this->tpl->setVariable(
"ACTIONS", $actions);
240 $this->tpl->parseCurrentBlock();
252 return parent::getHTML() . $this->
ui->renderer()->render($this->modals);
const CMD_DELETE_VERSIONS
getHTML()
Enables rendering modals OUTSIDE of the table.
setFormAction(string $a_form_action, bool $a_multipart=false)
setSelectAllCheckbox(string $a_select_all_checkbox, bool $a_select_all_on_top=false)
This class provides the data size with additional information to remove the work to calculate the siz...
static _lookupName(int $a_user_id)
lookup user name
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
const CMD_DOWNLOAD_VERSION
Customizing of pimple-DIC for ILIAS.
while($session_entry=$r->fetchRow(ilDBConstants::FETCHMODE_ASSOC)) return null
Provides fluid interface to RBAC services.
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
setRowTemplate(string $a_template, string $a_template_dir="")
Set row template.
Class ilFileVersionsTableGUI.
setTitle(string $a_title, string $a_icon="", string $a_icon_alt="")
bool $current_version_is_draft
__construct(Container $dic, ilPlugin $plugin)
setLimit(int $a_limit=0, int $a_default_limit=0)
static formatDate(ilDateTime $date, bool $a_skip_day=false, bool $a_include_wd=false, bool $include_seconds=false, ?ilObjUser $user=null,)
addColumn(string $a_text, string $a_sort_field="", string $a_width="", bool $a_is_checkbox_action_column=false, string $a_class="", string $a_tooltip="", bool $a_tooltip_with_html=false)
disable(string $a_module_name)
const CMD_ROLLBACK_VERSION
addMultiCommand(string $a_cmd, string $a_text)
__construct(ilFileVersionsGUI $calling_gui_class, string $a_parent_cmd=ilFileVersionsGUI::CMD_DEFAULT)
ilFileVersionsTableGUI constructor.
setEnableHeader(bool $a_enableheader)
setMaxCount(int $a_max_count)
set max.
const CMD_RENDER_DELETE_SELECTED_VERSIONS_MODAL
setPrefix(string $a_prefix)