56 $this->file = $file_version_gui->
getFile();
58 $this->
lng = $DIC->language();
59 $this->ui_factory = $DIC->ui()->factory();
60 $this->ui_renderer = $DIC->ui()->renderer();
61 $this->request = $DIC->http()->request();
62 $this->global_tpl = $DIC->ui()->mainTemplate();
63 $this->resource_services = $DIC->resourceStorage();
64 $this->post_url = $DIC->ctrl()->getFormAction(
68 $this->
lng->loadLanguageModule(
'file');
74 switch ($this->save_mode) {
75 case self::MODE_REPLACE:
76 $this->global_tpl->setOnScreenMessage(
'info', $this->
lng->txt(
'replace_file_info'));
77 $group_title = $this->
lng->txt(
'replace_file');
81 $this->global_tpl->setOnScreenMessage(
'info', $this->
lng->txt(
'file_new_version_info'));
82 $group_title = $this->
lng->txt(
'file_new_version');
88 $this->save_mode === self::MODE_REPLACE
94 self::F_TITLE => $this->ui_factory->input()->field()->text(
95 $this->
lng->txt(self::F_TITLE),
96 $this->
lng->txt(
"if_no_title_then_filename")
97 )->withRequired(
false)
99 ->withValue($this->file->getTitle()),
101 self::F_DESCRIPTION => $this->ui_factory->input()->field()->textarea(
102 $this->
lng->txt(self::F_DESCRIPTION)
104 self::F_FILE => $this->ui_factory->input()->field()->file(
106 $this->
lng->txt(self::F_FILE)
108 ->withRequired(
true),
111 $group = $this->ui_factory->input()->field()->group(
$inputs, $group_title);
113 $this->
form = $this->ui_factory->input()->container()->form()->standard($this->post_url, [$group]);
118 $this->
form = $this->
form->withRequest($this->request);
124 $title = empty(
$data[self::F_TITLE]) ? $this->file->getTitle() :
$data[self::F_TITLE];
125 $description =
$data[self::F_DESCRIPTION] !==
'' ?
$data[self::F_DESCRIPTION] : $this->file->getDescription();
126 $revision_number =
$data[self::F_FILE][0] ??
null;
127 if ($revision_number === null) {
130 $revision_number = (
int) $revision_number;
133 $rid = $this->resource_services->manage()->find($this->file->getResourceId());
134 $resource = $this->resource_services->manage()->getResource($rid);
135 $new_revision = $resource->getSpecificRevision($revision_number);
137 $new_revision->setTitle(
138 $this->
ensureSuffix($title, $new_revision->getInformation()->getSuffix())
140 $this->resource_services->manage()->updateRevision($new_revision);
142 $this->file->setDescription($description);
143 $this->file->updateObjectFromCurrentRevision();
150 return $this->ui_renderer->render($this->
form);
155 return match ($mode) {
while($session_entry=$r->fetchRow(ilDBConstants::FETCHMODE_ASSOC)) return null
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
This is how the factory for UI elements looks.
Class ilFileVersionsUploadHandlerGUI.
trait ilObjFileSecureString
Trait ilObjFileSecureString.
form( $class_path, string $cmd, string $submit_caption="")
const CMD_CREATE_REPLACING_VERSION
ensureSuffix(string $title, ?string $suffix=null)
const CMD_CREATE_NEW_VERSION