ILIAS  trunk Revision v11.0_alpha-3011-gc6b235a2e85
ilWebDAVMountInstructionsDocumentFormGUI Class Reference
+ Inheritance diagram for ilWebDAVMountInstructionsDocumentFormGUI:
+ Collaboration diagram for ilWebDAVMountInstructionsDocumentFormGUI:

Public Member Functions

 __construct (protected ilWebDAVMountInstructionsDocument $document, protected ilWebDAVMountInstructionsRepository $mount_instructions_repository, protected ilHtmlPurifierInterface $document_purifier, protected ilObjUser $actor, protected Filesystem $tmp_filesystem, protected FileUpload $file_upload, protected string $form_action, protected string $save_command, protected string $cancel_command, protected bool $is_editable)
 
 saveObject ()
 
 updateObject ()
 
 hasTranslatedInfo ()
 
 hasTranslatedError ()
 
 getTranslatedInfo ()
 
 getTranslatedError ()
 
- Public Member Functions inherited from ilPropertyFormGUI
 __construct ()
 
 executeCommand ()
 
 setTableWidth (string $a_width)
 
 getTableWidth ()
 
 setMode (string $a_mode)
 
 getMode ()
 
 setTitle (string $a_title)
 
 getTitle ()
 
 setTitleIcon (string $a_titleicon)
 
 getTitleIcon ()
 
 setDescription (string $a_val)
 
 getDescription ()
 
 setTopAnchor (string $a_val)
 
 getTopAnchor ()
 
 setShowTopButtons (bool $a_val)
 
 getShowTopButtons ()
 
 setForceTopButtons (bool $a_val)
 
 getForceTopButtons ()
 
 addItem ($a_item)
 
 removeItemByPostVar (string $a_post_var, bool $a_remove_unused_headers=false)
 
 getItemByPostVar (string $a_post_var)
 
 setItems (array $a_items)
 
 getItems ()
 
 getInputItemsRecursive ()
 returns a flat array of all input items including the possibly existing subitems recursively More...
 
 setDisableStandardMessage (bool $a_val)
 
 getDisableStandardMessage ()
 
 getHideLabels ()
 
 setHideLabels (bool $a_value=true)
 
 setValuesByArray (array $a_values, bool $a_restrict_to_value_keys=false)
 
 setValuesByPost ()
 
 checkInput ()
 
 getInput (string $a_post_var, bool $ensureValidation=true)
 Returns the input of an item, if item provides getInput method and as fallback the value of the HTTP-POST variable, identified by the passed postvar. More...
 
 addCommandButton (string $a_cmd, string $a_text, string $a_id="")
 
 getCommandButtons ()
 
 clearCommandButtons ()
 
 getContent ()
 
 insertItem ( $item, bool $a_sub_item=false)
 
 addAsyncOnloadCode (string $code)
 
 getHTML ()
 
 getHTMLAsync ()
 
 getFileUpload (string $a_field, ?string $a_index=null, ?string $a_sub_index=null)
 Get file upload data. More...
 
 hasFileUpload (string $a_field, ?string $a_index=null, ?string $a_sub_index=null)
 
 moveFileUpload (string $a_target_directory, string $a_field, ?string $a_target_name=null, ?string $a_index=null, ?string $a_sub_index=null)
 Move upload to target directory. More...
 
- Public Member Functions inherited from ilFormGUI
 setFormAction (string $a_formaction)
 
 getFormAction ()
 
 setTarget (string $a_target)
 
 getTarget ()
 
 setMultipart (bool $a_multipart)
 
 getMultipart ()
 
 setId (string $a_id)
 
 getId ()
 
 setName (string $a_name)
 
 getName ()
 
 setKeepOpen (bool $a_keepopen)
 
 getKeepOpen ()
 
 setOpenTag (bool $a_open)
 
 getOpenTag ()
 
 setCloseTag (bool $a_val)
 
 getCloseTag ()
 
 setPreventDoubleSubmission (bool $a_val)
 
 getPreventDoubleSubmission ()
 
 getHTML ()
 
 getContent ()
 

Protected Member Functions

 initForm ()
 
 createFilledObject (ilWebDAVMountInstructionsDocument $document)
 
 getRawMountInstructionsFromFileUpload (UploadResult $upload_result)
 
 getFileUploadResult ()
 
- Protected Member Functions inherited from ilPropertyFormGUI
 getRequestedPostVar ()
 
 getFileHash ()
 
 hideRequired (string $a_type)
 
 appendOnloadCode (string $html)
 
 rebuildUploadedFiles ()
 
 checkForRequiredField ()
 

Protected Attributes

string $translated_error = ''
 
string $translated_info = ''
 
- Protected Attributes inherited from ilPropertyFormGUI
bool $required_text = false
 
ilLanguage $lng
 
ilCtrl $ctrl
 
ilTemplate $tpl
 
ilObjUser $user = null
 
ilSetting $settings = null
 
string $mode = "std"
 
bool $check_input_called = false
 
bool $disable_standard_message = false
 
string $top_anchor = "il_form_top"
 
string $title = ''
 
string $titleicon = ""
 
string $description = ""
 
string $tbl_width = ""
 
bool $show_top_buttons = true
 
bool $hide_labels = false
 
bool $force_top_buttons = false
 
HTTP Services $http
 
Refinery Factory $refinery = null
 
ilGlobalTemplateInterface $global_tpl = null
 
 $onload_code = []
 
- Protected Attributes inherited from ilFormGUI
string $formaction = ""
 
bool $multipart = false
 
bool $keepopen = false
 
bool $opentag = true
 
string $id = ''
 
string $name = ''
 
string $target = ''
 
bool $prevent_double_submission = false
 

Detailed Description

Constructor & Destructor Documentation

◆ __construct()

ilWebDAVMountInstructionsDocumentFormGUI::__construct ( protected ilWebDAVMountInstructionsDocument  $document,
protected ilWebDAVMountInstructionsRepository  $mount_instructions_repository,
protected ilHtmlPurifierInterface  $document_purifier,
protected ilObjUser  $actor,
protected Filesystem  $tmp_filesystem,
protected FileUpload  $file_upload,
protected string  $form_action,
protected string  $save_command,
protected string  $cancel_command,
protected bool  $is_editable 
)

Definition at line 31 of file class.ilWebDAVMountInstructionsDocumentFormGUI.php.

References ILIAS\GlobalScreen\Provider\__construct(), and initForm().

+ Here is the call graph for this function:

Member Function Documentation

◆ createFilledObject()

ilWebDAVMountInstructionsDocumentFormGUI::createFilledObject ( ilWebDAVMountInstructionsDocument  $document)
protected

Definition at line 154 of file class.ilWebDAVMountInstructionsDocumentFormGUI.php.

157 if (!$this->checkInput()) {
158 throw new InvalidArgumentException($this->lng->txt('form_input_not_valid'));
159 }
160
161 $document_already_exists = $document->getId() > 0;
162
163 if (!$document_already_exists) {
164 $upload_result = $this->getFileUploadResult();
165 }
166
167 if (!$document_already_exists && !$upload_result->isOK()) {
168 throw new InvalidArgumentException($this->lng->txt('form_input_not_valid'));
169 }
170
171 $title = $this->getInput('title');
172 $language = $this->getInput('lng');
173 $creation_ts = $document_already_exists ? $document->getCreationTs() : ilUtil::now();
174 $modification_ts = $document_already_exists ? ilUtil::now() : $creation_ts;
175 $owner_id = $document_already_exists ? $document->getOwnerUsrId() : $this->actor->getId();
176 $last_modified_usr_id = $this->actor->getId();
177 $sorting = $document_already_exists ? $document->getSorting(
178 ) : $this->mount_instructions_repository->getHighestSortingNumber() + 1;
179
180 $mount_instruction_for_language_exists = $this->mount_instructions_repository->doMountInstructionsExistByLanguage(
181 $language
182 );
183
184 if (!$document_already_exists && $mount_instruction_for_language_exists) {
185 throw new InvalidArgumentException($this->lng->txt("webdav_choosen_language_already_used"));
186 }
187
188 if ($document_already_exists && $document->getLanguage() != $language &&
189 $mount_instruction_for_language_exists > 0 &&
190 $mount_instruction_for_language_exists != $document->getId()) {
191 throw new InvalidArgumentException($this->lng->txt("webdav_chosen_language_already_used"));
192 }
193
194 if ($document_already_exists) {
195 $raw_mount_instructions = '';
196 $processed_mount_instructions = '';
197 } else {
198 $raw_mount_instructions = $this->getRawMountInstructionsFromFileUpload($upload_result);
199 $document_processor = $upload_result->getMimeType() === 'text/html'
200 ? new ilWebDAVMountInstructionsHtmlDocumentProcessor($this->document_purifier)
202 $processed_mount_instructions = $document_processor->processMountInstructions($raw_mount_instructions);
203 }
204
205 $id = $document_already_exists ? $document->getId()
206 : $this->mount_instructions_repository->getNextMountInstructionsDocumentId();
207
209 $id,
210 $title,
211 $raw_mount_instructions,
212 json_encode($processed_mount_instructions),
213 $language,
214 $creation_ts,
215 $modification_ts,
216 $owner_id,
217 $last_modified_usr_id,
218 $sorting
219 );
220 }
getInput(string $a_post_var, bool $ensureValidation=true)
Returns the input of an item, if item provides getInput method and as fallback the value of the HTTP-...
static now()
Return current timestamp in Y-m-d H:i:s format.

References ILIAS\Repository\lng().

Referenced by saveObject(), and updateObject().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getFileUploadResult()

ilWebDAVMountInstructionsDocumentFormGUI::getFileUploadResult ( )
protected

Definition at line 254 of file class.ilWebDAVMountInstructionsDocumentFormGUI.php.

255 {
256 if (!$this->file_upload->hasUploads()) {
257 throw new InvalidArgumentException("webdav_error_no_upload");
258 }
259 if (!$this->file_upload->hasBeenProcessed()) {
260 $this->file_upload->process();
261 }
262
263 $upload_result = array_values($this->file_upload->getResults())[0];
264
265 if (!$upload_result) {
266 $this->getItemByPostVar('document')->setAlert($this->lng->txt('form_msg_file_no_upload'));
267 throw new InvalidArgumentException($this->lng->txt('form_input_not_valid'));
268 }
269
270 return $upload_result;
271 }
getItemByPostVar(string $a_post_var)

References ILIAS\Repository\lng().

+ Here is the call graph for this function:

◆ getRawMountInstructionsFromFileUpload()

ilWebDAVMountInstructionsDocumentFormGUI::getRawMountInstructionsFromFileUpload ( UploadResult  $upload_result)
protected

Definition at line 222 of file class.ilWebDAVMountInstructionsDocumentFormGUI.php.

222 : string
223 {
224 if ($upload_result->getName() === '') {
225 throw new InvalidArgumentException('uploaded file has no name');
226 }
227
228 if (!$upload_result->isOK()) {
229 $this->getItemByPostVar('document')->setAlert($upload_result->getStatus()->getMessage());
230 throw new InvalidArgumentException($this->lng->txt('form_input_not_valid'));
231 }
232
233 $this->file_upload->moveOneFileTo(
234 $upload_result,
235 '/mount_instructions',
236 Location::TEMPORARY,
237 '',
238 true
239 );
240
241 $path_to_file = '/mount_instructions/' . $upload_result->getName();
242 if (!$this->tmp_filesystem->has($path_to_file)) {
243 $this->getItemByPostVar('document')->setAlert($this->lng->txt('form_msg_file_no_upload'));
244 throw new InvalidArgumentException($this->lng->txt('form_input_not_valid'));
245 }
246
247 $raw_content = $this->tmp_filesystem->read($path_to_file);
248
249 $this->tmp_filesystem->delete($path_to_file);
250
251 return $raw_content;
252 }

References ILIAS\FileUpload\DTO\UploadResult\getName(), ILIAS\FileUpload\DTO\UploadResult\getStatus(), ILIAS\FileUpload\DTO\UploadResult\isOK(), and ILIAS\Repository\lng().

+ Here is the call graph for this function:

◆ getTranslatedError()

ilWebDAVMountInstructionsDocumentFormGUI::getTranslatedError ( )

◆ getTranslatedInfo()

ilWebDAVMountInstructionsDocumentFormGUI::getTranslatedInfo ( )

◆ hasTranslatedError()

ilWebDAVMountInstructionsDocumentFormGUI::hasTranslatedError ( )

Definition at line 139 of file class.ilWebDAVMountInstructionsDocumentFormGUI.php.

139 : bool
140 {
141 return strlen($this->translated_error) > 0;
142 }

◆ hasTranslatedInfo()

ilWebDAVMountInstructionsDocumentFormGUI::hasTranslatedInfo ( )

Definition at line 134 of file class.ilWebDAVMountInstructionsDocumentFormGUI.php.

134 : bool
135 {
136 return strlen($this->translated_info) > 0;
137 }

◆ initForm()

ilWebDAVMountInstructionsDocumentFormGUI::initForm ( )
protected

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

48 : void
49 {
50 $document_already_exists = $this->document->getId() > 0;
51 if ($document_already_exists) {
52 $this->setTitle($this->lng->txt('webdav_form_edit_doc_head'));
53 } else {
54 $this->setTitle($this->lng->txt('webdav_form_new_doc_head'));
55 }
56
57 $this->setFormAction($this->form_action);
58
59 $title = new ilTextInputGUI($this->lng->txt('webdav_form_document_title'), 'title');
60 $title->setInfo($this->lng->txt('webdav_form_document_title_info'));
61 $title->setRequired(true);
62 $title->setDisabled(!$this->is_editable);
63 $title->setValue($this->document->getTitle());
64 $title->setMaxLength(255);
65 $this->addItem($title);
66
67 $document_label = $this->lng->txt('webdav_form_document');
68 $document_by_line = $this->lng->txt('webdav_form_document_info');
69
70 $language_selection = new ilSelectInputGUI(
71 $this->lng->txt('language'),
72 'lng'
73 );
74 $language_selection->setRequired(true);
75
76 $options = [];
77 foreach ($this->lng->getInstalledLanguages() as $lng) {
78 $options[$lng] = $this->lng->txt('meta_l_' . $lng, 'meta');
79 }
80
81 asort($options);
82
83 $language_selection->setOptions(['' => $this->lng->txt('please_choose')] + $options);
84 $language_selection->setValue($this->document->getLanguage());
85
86 $this->addItem($language_selection);
87
88 if ($document_already_exists) {
89 $document_id = new ilHiddenInputGUI('document_id');
90 $document_id->setValue((string) $this->document->getId());
91 $this->addItem($document_id);
92 } else {
93 $document_upload = new ilFileInputGUI($document_label, 'document');
94 $document_upload->setInfo($document_by_line);
95 $document_upload->setRequired(true);
96 $document_upload->setDisabled(!$this->is_editable);
97 $document_upload->setSuffixes(['html', 'htm', 'txt']);
98 $this->addItem($document_upload);
99 }
100
101 if ($this->is_editable) {
102 $this->addCommandButton($this->save_command, $this->lng->txt('save'));
103 }
104 }
This class represents a file property in a property form.
setFormAction(string $a_formaction)
This class represents a hidden form property in a property form.
addCommandButton(string $a_cmd, string $a_text, string $a_id="")
This class represents a selection list property in a property form.
This class represents a text property in a property form.

References ilPropertyFormGUI\$lng, ilPropertyFormGUI\$title, ilPropertyFormGUI\addCommandButton(), ilPropertyFormGUI\addItem(), ILIAS\Repository\lng(), ilFormGUI\setFormAction(), and ilPropertyFormGUI\setTitle().

Referenced by __construct().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ saveObject()

ilWebDAVMountInstructionsDocumentFormGUI::saveObject ( )

Definition at line 106 of file class.ilWebDAVMountInstructionsDocumentFormGUI.php.

106 : bool
107 {
108 try {
109 $this->document = $this->createFilledObject($this->document);
110 $this->mount_instructions_repository->createMountInstructionsDocumentEntry($this->document);
111 } catch (InvalidArgumentException $e) {
112 $this->setValuesByPost();
113 $this->translated_error .= $e->getMessage();
114 return false;
115 }
116
117 return true;
118 }

References Vendor\Package\$e, createFilledObject(), and ilPropertyFormGUI\setValuesByPost().

+ Here is the call graph for this function:

◆ updateObject()

ilWebDAVMountInstructionsDocumentFormGUI::updateObject ( )

Definition at line 120 of file class.ilWebDAVMountInstructionsDocumentFormGUI.php.

120 : bool
121 {
122 try {
123 $this->document = $this->createFilledObject($this->document);
124 $this->mount_instructions_repository->updateMountInstructions($this->document);
125 } catch (InvalidArgumentException $e) {
126 $this->setValuesByPost();
127 $this->translated_error .= $e->getMessage();
128 return false;
129 }
130
131 return true;
132 }

References Vendor\Package\$e, createFilledObject(), and ilPropertyFormGUI\setValuesByPost().

+ Here is the call graph for this function:

Field Documentation

◆ $translated_error

string ilWebDAVMountInstructionsDocumentFormGUI::$translated_error = ''
protected

◆ $translated_info

string ilWebDAVMountInstructionsDocumentFormGUI::$translated_info = ''
protected

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