55 $this->file = $file_version_gui->
getFile();
57 $this->
lng = $DIC->language();
58 $this->ui_factory = $DIC->ui()->factory();
59 $this->ui_renderer = $DIC->ui()->renderer();
60 $this->request = $DIC->http()->request();
61 $this->global_tpl = $DIC->ui()->mainTemplate();
62 $this->resource_services = $DIC->resourceStorage();
63 $this->post_url = $DIC->ctrl()->getFormAction(
67 $this->
lng->loadLanguageModule(
'file');
68 $this->upload_limit = $DIC[
'ui.upload_limit_resolver'];
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 $this->upload_limit->getBestPossibleUploadLimitInBytes($upload_handler),
99 self::F_TITLE => $this->ui_factory->input()->field()->text(
100 $this->
lng->txt(self::F_TITLE),
101 $this->
lng->txt(
"if_no_title_then_filename")
102 )->withRequired(
false)
104 ->withValue($this->file->getTitle()),
106 self::F_DESCRIPTION => $this->ui_factory->input()->field()->textarea(
107 $this->
lng->txt(self::F_DESCRIPTION)
109 self::F_FILE => $this->ui_factory->input()->field()->file(
111 $this->
lng->txt(self::F_FILE),
113 $this->
lng->txt(
'upload_files_limit'),
117 ->withRequired(
true),
120 $group = $this->ui_factory->input()->field()->group($inputs, $group_title);
122 $this->
form = $this->ui_factory->input()->container()->form()->standard($this->post_url, [$group]);
127 $this->
form = $this->
form->withRequest($this->request);
128 $data = $this->
form->getData()[0] ?? null;
129 if (
$data === null) {
133 $title = !empty(
$data[self::F_TITLE]) ?
$data[self::F_TITLE] : $this->file->getTitle();
134 $description =
$data[self::F_DESCRIPTION] !==
'' ?
$data[self::F_DESCRIPTION] : $this->file->getDescription();
135 $revision_number =
$data[self::F_FILE][0] ?? null;
136 if ($revision_number === null) {
139 $revision_number = (
int) $revision_number;
142 $rid = $this->resource_services->manage()->find($this->file->getResourceId());
143 $resource = $this->resource_services->manage()->getResource($rid);
144 $new_revision = $resource->getSpecificRevision($revision_number);
146 $new_revision->setTitle(
147 $this->
ensureSuffix($title, $new_revision->getInformation()->getSuffix())
149 $this->resource_services->manage()->updateRevision($new_revision);
151 $this->file->setDescription($description);
152 $this->file->updateObjectFromCurrentRevision();
159 return $this->ui_renderer->render($this->
form);
164 return match ($mode) {
This class provides the data size with additional information to remove the work to calculate the siz...
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
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