ILIAS  trunk Revision v11.0_alpha-1702-gfd3ecb7f852
All Data Structures Namespaces Files Functions Variables Enumerations Enumerator Modules Pages
ilFileVersionFormGUI Class Reference

Class ilFileVersionFormGUI. More...

+ Collaboration diagram for ilFileVersionFormGUI:

Public Member Functions

 __construct (ilFileVersionsGUI $file_version_gui, private int $save_mode=self::MODE_ADD)
 ilFileVersionFormGUI constructor. More...
 
 saveObject ()
 
 getHTML ()
 

Data Fields

const MODE_ADD = 1
 
const MODE_REPLACE = 2
 
const F_TITLE = 'title'
 
const F_DESCRIPTION = "description"
 
const F_FILE = "file"
 
const F_SAVE_MODE = 'save_mode'
 

Private Member Functions

 initForm ()
 
 resolveParentCommand (int $mode)
 

Private Attributes

ilObjFile $file
 
Standard $form
 
Factory $ui_factory
 
Renderer $ui_renderer
 
RequestInterface $request
 
ilGlobalTemplateInterface $global_tpl
 
ilLanguage $lng
 
Services $resource_services
 
string $post_url
 

Detailed Description

Constructor & Destructor Documentation

◆ __construct()

ilFileVersionFormGUI::__construct ( ilFileVersionsGUI  $file_version_gui,
private int  $save_mode = self::MODE_ADD 
)

ilFileVersionFormGUI constructor.

Definition at line 53 of file class.ilFileVersionFormGUI.php.

References $DIC, ilFileVersionsGUI\getFile(), initForm(), ILIAS\Repository\lng(), and resolveParentCommand().

54  {
55  global $DIC;
56  $this->file = $file_version_gui->getFile();
57  ;
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(
65  $file_version_gui,
66  $this->resolveParentCommand($save_mode)
67  );
68  $this->lng->loadLanguageModule('file');
69  $this->initForm();
70  }
global $DIC
Definition: shib_login.php:22
+ Here is the call graph for this function:

Member Function Documentation

◆ getHTML()

ilFileVersionFormGUI::getHTML ( )

Definition at line 148 of file class.ilFileVersionFormGUI.php.

References ILIAS\Repository\form().

148  : string
149  {
150  return $this->ui_renderer->render($this->form);
151  }
form( $class_path, string $cmd, string $submit_caption="")
+ Here is the call graph for this function:

◆ initForm()

ilFileVersionFormGUI::initForm ( )
private

Definition at line 72 of file class.ilFileVersionFormGUI.php.

References ILIAS\UI\Implementation\Component\Input\$inputs, ILIAS\Repository\form(), ILIAS\Repository\lng(), ilFileVersionsUploadHandlerGUI\MODE_APPEND, ilFileVersionsUploadHandlerGUI\MODE_REPLACE, and ilObject\TITLE_LENGTH.

Referenced by __construct().

72  : void
73  {
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');
78  break;
79  case self::MODE_ADD:
80  default:
81  $this->global_tpl->setOnScreenMessage('info', $this->lng->txt('file_new_version_info'));
82  $group_title = $this->lng->txt('file_new_version');
83  break;
84  }
85 
86  $upload_handler = new ilFileVersionsUploadHandlerGUI(
87  $this->file,
88  $this->save_mode === self::MODE_REPLACE
91  );
92 
93  $inputs = [
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)
98  ->withMaxLength(ilObject::TITLE_LENGTH)
99  ->withValue($this->file->getTitle()),
100 
101  self::F_DESCRIPTION => $this->ui_factory->input()->field()->textarea(
102  $this->lng->txt(self::F_DESCRIPTION)
103  ),
104  self::F_FILE => $this->ui_factory->input()->field()->file(
105  $upload_handler,
106  $this->lng->txt(self::F_FILE)
107  )->withMaxFiles(1)
108  ->withRequired(true),
109  ];
110 
111  $group = $this->ui_factory->input()->field()->group($inputs, $group_title);
112 
113  $this->form = $this->ui_factory->input()->container()->form()->standard($this->post_url, [$group]);
114  }
const TITLE_LENGTH
Class ilFileVersionsUploadHandlerGUI.
form( $class_path, string $cmd, string $submit_caption="")
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ resolveParentCommand()

ilFileVersionFormGUI::resolveParentCommand ( int  $mode)
private

Definition at line 153 of file class.ilFileVersionFormGUI.php.

References ilFileVersionsGUI\CMD_CREATE_NEW_VERSION, and ilFileVersionsGUI\CMD_CREATE_REPLACING_VERSION.

Referenced by __construct().

153  : string
154  {
155  return match ($mode) {
158  };
159  }
+ Here is the caller graph for this function:

◆ saveObject()

ilFileVersionFormGUI::saveObject ( )

Definition at line 116 of file class.ilFileVersionFormGUI.php.

References $data, ensureSuffix(), ILIAS\Repository\form(), ILIAS\Repository\int(), and null.

116  : bool
117  {
118  $this->form = $this->form->withRequest($this->request);
119  $data = $this->form->getData()[0] ?? null;
120  if ($data === null) {
121  return false;
122  }
123 
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) {
128  return false;
129  }
130  $revision_number = (int) $revision_number;
131 
132  // Title differs, update Revision and Object
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);
136 
137  $new_revision->setTitle(
138  $this->ensureSuffix($title, $new_revision->getInformation()->getSuffix())
139  );
140  $this->resource_services->manage()->updateRevision($new_revision);
141 
142  $this->file->setDescription($description);
143  $this->file->updateObjectFromCurrentRevision();
144 
145  return true;
146  }
while($session_entry=$r->fetchRow(ilDBConstants::FETCHMODE_ASSOC)) return null
form( $class_path, string $cmd, string $submit_caption="")
ensureSuffix(string $title, ?string $suffix=null)
+ Here is the call graph for this function:

Field Documentation

◆ $file

ilObjFile ilFileVersionFormGUI::$file
private

Definition at line 40 of file class.ilFileVersionFormGUI.php.

◆ $form

Standard ilFileVersionFormGUI::$form
private

Definition at line 41 of file class.ilFileVersionFormGUI.php.

◆ $global_tpl

ilGlobalTemplateInterface ilFileVersionFormGUI::$global_tpl
private

Definition at line 45 of file class.ilFileVersionFormGUI.php.

◆ $lng

ilLanguage ilFileVersionFormGUI::$lng
private

Definition at line 46 of file class.ilFileVersionFormGUI.php.

◆ $post_url

string ilFileVersionFormGUI::$post_url
private

Definition at line 48 of file class.ilFileVersionFormGUI.php.

◆ $request

RequestInterface ilFileVersionFormGUI::$request
private

Definition at line 44 of file class.ilFileVersionFormGUI.php.

◆ $resource_services

Services ilFileVersionFormGUI::$resource_services
private

Definition at line 47 of file class.ilFileVersionFormGUI.php.

◆ $ui_factory

Factory ilFileVersionFormGUI::$ui_factory
private

Definition at line 42 of file class.ilFileVersionFormGUI.php.

◆ $ui_renderer

Renderer ilFileVersionFormGUI::$ui_renderer
private

Definition at line 43 of file class.ilFileVersionFormGUI.php.

◆ F_DESCRIPTION

const ilFileVersionFormGUI::F_DESCRIPTION = "description"

Definition at line 36 of file class.ilFileVersionFormGUI.php.

◆ F_FILE

const ilFileVersionFormGUI::F_FILE = "file"

Definition at line 37 of file class.ilFileVersionFormGUI.php.

◆ F_SAVE_MODE

const ilFileVersionFormGUI::F_SAVE_MODE = 'save_mode'

Definition at line 38 of file class.ilFileVersionFormGUI.php.

◆ F_TITLE

const ilFileVersionFormGUI::F_TITLE = 'title'

Definition at line 35 of file class.ilFileVersionFormGUI.php.

◆ MODE_ADD

const ilFileVersionFormGUI::MODE_ADD = 1

Definition at line 33 of file class.ilFileVersionFormGUI.php.

Referenced by ilFileVersionsGUI\performCommand().

◆ MODE_REPLACE

const ilFileVersionFormGUI::MODE_REPLACE = 2

Definition at line 34 of file class.ilFileVersionFormGUI.php.

Referenced by ilFileVersionsGUI\performCommand().


The documentation for this class was generated from the following file: