ILIAS  release_8 Revision v8.25-1-g13de6a5eca6
ilWebDAVMountInstructionsDocumentFormGUI Class Reference
+ Inheritance diagram for ilWebDAVMountInstructionsDocumentFormGUI:
+ Collaboration diagram for ilWebDAVMountInstructionsDocumentFormGUI:

Public Member Functions

 __construct (ilWebDAVMountInstructionsDocument $document, ilWebDAVMountInstructionsRepository $mount_instructions_repository, ?ilHtmlPurifierInterface $document_purifier, ilObjUser $actor, Filesystem $tmp_filesystem, FileUpload $fileupload, string $form_action, string $save_command, string $cancel_command, 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 ()
 

Protected Attributes

ilWebDAVMountInstructionsDocument $document
 
ilWebDAVMountInstructionsRepository $mount_instructions_repository
 
ilHtmlPurifierInterface $document_purifier
 
ilObjUser $actor
 
FileUpload $file_upload
 
Filesystem $tmp_filesystem
 
string $form_action
 
string $save_command
 
string $cancel_command
 
bool $is_editable = false
 
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 ( ilWebDAVMountInstructionsDocument  $document,
ilWebDAVMountInstructionsRepository  $mount_instructions_repository,
?ilHtmlPurifierInterface  $document_purifier,
ilObjUser  $actor,
Filesystem  $tmp_filesystem,
FileUpload  $fileupload,
string  $form_action,
string  $save_command,
string  $cancel_command,
bool  $is_editable 
)

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

52 {
53 $this->document = $document;
54 $this->mount_instructions_repository = $mount_instructions_repository;
55 $this->document_purifier = $document_purifier;
56 $this->actor = $actor;
57 $this->tmp_filesystem = $tmp_filesystem;
58 $this->file_upload = $fileupload;
59 $this->form_action = $form_action;
60 $this->save_command = $save_command;
61 $this->cancel_command = $cancel_command;
62 $this->is_editable = $is_editable;
63
65
66 $this->initForm();
67 }
__construct(Container $dic, ilPlugin $plugin)
@inheritDoc

References $actor, $cancel_command, $document, $document_purifier, $form_action, $is_editable, $mount_instructions_repository, $save_command, $tmp_filesystem, 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 175 of file class.ilWebDAVMountInstructionsDocumentFormGUI.php.

176 {
177 if (!$this->checkInput()) {
178 throw new InvalidArgumentException($this->lng->txt('form_input_not_valid'));
179 }
180
181 $document_already_exists = $document->getId() > 0;
182
183 if (!$document_already_exists) {
184 $upload_result = $this->getFileUploadResult();
185 }
186
187 if (!$document_already_exists && !$upload_result->isOK()) {
188 throw new InvalidArgumentException($this->lng->txt('form_input_not_valid'));
189 }
190
191 $title = $this->getInput('title');
192 $language = $this->getInput('lng');
193 $creation_ts = $document_already_exists ? $document->getCreationTs() : ilUtil::now();
194 $modification_ts = $document_already_exists ? ilUtil::now() : $creation_ts;
195 $owner_id = $document_already_exists ? $document->getOwnerUsrId() : $this->actor->getId();
196 $last_modified_usr_id = $this->actor->getId();
197 $sorting = $document_already_exists ? $document->getSorting() : $this->mount_instructions_repository->getHighestSortingNumber() + 1;
198
199 $mount_instruction_for_language_exists = $this->mount_instructions_repository->doMountInstructionsExistByLanguage($language);
200
201 if (!$document_already_exists && $mount_instruction_for_language_exists) {
202 throw new InvalidArgumentException($this->lng->txt("webdav_choosen_language_already_used"));
203 }
204
205 if ($document_already_exists && $document->getLanguage() != $language &&
206 $mount_instruction_for_language_exists > 0 &&
207 $mount_instruction_for_language_exists != $document->getId()) {
208 throw new InvalidArgumentException($this->lng->txt("webdav_chosen_language_already_used"));
209 }
210
211 if ($document_already_exists) {
212 $raw_mount_instructions = '';
213 $processed_mount_instructions = '';
214 } else {
215 $raw_mount_instructions = $this->getRawMountInstructionsFromFileUpload($upload_result);
216 $document_processor = $upload_result->getMimeType() == 'text/html'
217 ? new ilWebDAVMountInstructionsHtmlDocumentProcessor($this->document_purifier)
219 $processed_mount_instructions = $document_processor->processMountInstructions($raw_mount_instructions);
220 }
221
222 $id = $document_already_exists ? $document->getId()
223 : $this->mount_instructions_repository->getNextMountInstructionsDocumentId();
224
226 $id,
227 $title,
228 $raw_mount_instructions,
229 json_encode($processed_mount_instructions),
230 $language,
231 $creation_ts,
232 $modification_ts,
233 $owner_id,
234 $last_modified_usr_id,
235 $sorting
236 );
237 }
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.
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...

References $document, ilFormGUI\$id, ilPropertyFormGUI\$title, ilPropertyFormGUI\checkInput(), ilWebDAVMountInstructionsDocument\getCreationTs(), getFileUploadResult(), ilWebDAVMountInstructionsDocument\getId(), ilPropertyFormGUI\getInput(), ilWebDAVMountInstructionsDocument\getLanguage(), ilWebDAVMountInstructionsDocument\getOwnerUsrId(), getRawMountInstructionsFromFileUpload(), ilWebDAVMountInstructionsDocument\getSorting(), ILIAS\Repository\lng(), and ilUtil\now().

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 271 of file class.ilWebDAVMountInstructionsDocumentFormGUI.php.

272 {
273 if (!$this->file_upload->hasUploads()) {
274 throw new InvalidArgumentException("webdav_error_no_upload");
275 } elseif ($this->file_upload->hasBeenProcessed()) {
276 throw new InvalidArgumentException("webdav_error_upload_already_processed");
277 }
278
279 $this->file_upload->process();
280
281 $upload_result = array_values($this->file_upload->getResults())[0];
282
283 if (!$upload_result) {
284 $this->getItemByPostVar('document')->setAlert($this->lng->txt('form_msg_file_no_upload'));
285 throw new InvalidArgumentException($this->lng->txt('form_input_not_valid'));
286 }
287
288 return $upload_result;
289 }
getItemByPostVar(string $a_post_var)

References ilPropertyFormGUI\getItemByPostVar(), and ILIAS\Repository\lng().

Referenced by createFilledObject().

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

◆ getRawMountInstructionsFromFileUpload()

ilWebDAVMountInstructionsDocumentFormGUI::getRawMountInstructionsFromFileUpload ( UploadResult  $upload_result)
protected

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

239 : string
240 {
241 if ($upload_result->getName() === '') {
242 throw new InvalidArgumentException('uploaded file has no name');
243 }
244
245 if (!$upload_result->isOK()) {
246 $this->getItemByPostVar('document')->setAlert($upload_result->getStatus()->getMessage());
247 throw new InvalidArgumentException($this->lng->txt('form_input_not_valid'));
248 }
249
250 $this->file_upload->moveOneFileTo(
251 $upload_result,
252 '/mount_instructions',
253 Location::TEMPORARY,
254 '',
255 true
256 );
257
258 $path_to_file = '/mount_instructions/' . $upload_result->getName();
259 if (!$this->tmp_filesystem->has($path_to_file)) {
260 $this->getItemByPostVar('document')->setAlert($this->lng->txt('form_msg_file_no_upload'));
261 throw new InvalidArgumentException($this->lng->txt('form_input_not_valid'));
262 }
263
264 $raw_content = $this->tmp_filesystem->read($path_to_file);
265
266 $this->tmp_filesystem->delete($path_to_file);
267
268 return $raw_content;
269 }

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

Referenced by createFilledObject().

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

◆ getTranslatedError()

ilWebDAVMountInstructionsDocumentFormGUI::getTranslatedError ( )

◆ getTranslatedInfo()

ilWebDAVMountInstructionsDocumentFormGUI::getTranslatedInfo ( )

◆ hasTranslatedError()

ilWebDAVMountInstructionsDocumentFormGUI::hasTranslatedError ( )

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

160 : bool
161 {
162 return strlen($this->translated_error) > 0;
163 }

◆ hasTranslatedInfo()

ilWebDAVMountInstructionsDocumentFormGUI::hasTranslatedInfo ( )

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

155 : bool
156 {
157 return strlen($this->translated_info) > 0;
158 }

◆ initForm()

ilWebDAVMountInstructionsDocumentFormGUI::initForm ( )
protected

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

69 : void
70 {
71 $document_already_exists = $this->document->getId() > 0;
72 if ($document_already_exists) {
73 $this->setTitle($this->lng->txt('webdav_form_edit_doc_head'));
74 } else {
75 $this->setTitle($this->lng->txt('webdav_form_new_doc_head'));
76 }
77
78 $this->setFormAction($this->form_action);
79
80 $title = new ilTextInputGUI($this->lng->txt('webdav_form_document_title'), 'title');
81 $title->setInfo($this->lng->txt('webdav_form_document_title_info'));
82 $title->setRequired(true);
83 $title->setDisabled(!$this->is_editable);
84 $title->setValue($this->document->getTitle());
85 $title->setMaxLength(255);
86 $this->addItem($title);
87
88 $document_label = $this->lng->txt('webdav_form_document');
89 $document_by_line = $this->lng->txt('webdav_form_document_info');
90
91 $language_selection = new ilSelectInputGUI(
92 $this->lng->txt('language'),
93 'lng'
94 );
95 $language_selection->setRequired(true);
96
97 $options = [];
98 foreach ($this->lng->getInstalledLanguages() as $lng) {
99 $options[$lng] = $this->lng->txt('meta_l_' . $lng, 'meta');
100 }
101
102 asort($options);
103
104 $language_selection->setOptions(['' => $this->lng->txt('please_choose')] + $options);
105 $language_selection->setValue($this->document->getLanguage());
106
107 $this->addItem($language_selection);
108
109 if ($document_already_exists) {
110 $document_id = new ilHiddenInputGUI('document_id');
111 $document_id->setValue((string) $this->document->getId());
112 $this->addItem($document_id);
113 } else {
114 $document_upload = new ilFileInputGUI($document_label, 'document');
115 $document_upload->setInfo($document_by_line);
116 $document_upload->setRequired(true);
117 $document_upload->setDisabled(!$this->is_editable);
118 $document_upload->setSuffixes(['html', 'htm', 'txt']);
119 $this->addItem($document_upload);
120 }
121
122 if ($this->is_editable) {
123 $this->addCommandButton($this->save_command, $this->lng->txt('save'));
124 }
125 }
This class represents a file property in a property form.
setFormAction(string $a_formaction)
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
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 127 of file class.ilWebDAVMountInstructionsDocumentFormGUI.php.

127 : bool
128 {
129 try {
130 $this->document = $this->createFilledObject($this->document);
131 $this->mount_instructions_repository->createMountInstructionsDocumentEntry($this->document);
132 } catch (InvalidArgumentException $e) {
133 $this->setValuesByPost();
134 $this->translated_error .= $e->getMessage();
135 return false;
136 }
137
138 return true;
139 }

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

+ Here is the call graph for this function:

◆ updateObject()

ilWebDAVMountInstructionsDocumentFormGUI::updateObject ( )

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

141 : bool
142 {
143 try {
144 $this->document = $this->createFilledObject($this->document);
145 $this->mount_instructions_repository->updateMountInstructions($this->document);
146 } catch (InvalidArgumentException $e) {
147 $this->setValuesByPost();
148 $this->translated_error .= $e->getMessage();
149 return false;
150 }
151
152 return true;
153 }

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

+ Here is the call graph for this function:

Field Documentation

◆ $actor

ilObjUser ilWebDAVMountInstructionsDocumentFormGUI::$actor
protected

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

Referenced by __construct().

◆ $cancel_command

string ilWebDAVMountInstructionsDocumentFormGUI::$cancel_command
protected

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

Referenced by __construct().

◆ $document

ilWebDAVMountInstructionsDocument ilWebDAVMountInstructionsDocumentFormGUI::$document
protected

◆ $document_purifier

ilHtmlPurifierInterface ilWebDAVMountInstructionsDocumentFormGUI::$document_purifier
protected

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

Referenced by __construct().

◆ $file_upload

FileUpload ilWebDAVMountInstructionsDocumentFormGUI::$file_upload
protected

◆ $form_action

string ilWebDAVMountInstructionsDocumentFormGUI::$form_action
protected

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

Referenced by __construct().

◆ $is_editable

bool ilWebDAVMountInstructionsDocumentFormGUI::$is_editable = false
protected

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

Referenced by __construct().

◆ $mount_instructions_repository

ilWebDAVMountInstructionsRepository ilWebDAVMountInstructionsDocumentFormGUI::$mount_instructions_repository
protected

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

Referenced by __construct().

◆ $save_command

string ilWebDAVMountInstructionsDocumentFormGUI::$save_command
protected

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

Referenced by __construct().

◆ $tmp_filesystem

Filesystem ilWebDAVMountInstructionsDocumentFormGUI::$tmp_filesystem
protected

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

Referenced by __construct().

◆ $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: