ILIAS  release_7 Revision v7.30-3-g800a261c036
ilWebDAVMountInstructionsDocumentFormGUI Class Reference
+ Inheritance diagram for ilWebDAVMountInstructionsDocumentFormGUI:
+ Collaboration diagram for ilWebDAVMountInstructionsDocumentFormGUI:

Public Member Functions

 __construct (ilWebDAVMountInstructionsDocument $a_document, ilWebDAVMountInstructionsRepository $mount_instructions_repository, ?ilHtmlPurifierInterface $a_document_purifier, ilObjUser $a_actor, FileSystem $a_tmp_filesystem, FileUpload $a_fileupload, string $a_form_action, string $a_save_command, string $a_cancel_command, bool $a_is_editable)
 ilWebDAVMountInstructionsDocumentFormGUI constructor. More...
 
 saveObject ()
 Save uploaded mount instructions document. More...
 
 updateObject ()
 Update the document with id from form. More...
 
 hasTranslatedInfo ()
 
 hasTranslatedError ()
 
 getTranslatedInfo ()
 
 getTranslatedError ()
 
- Public Member Functions inherited from ilPropertyFormGUI
 __construct ()
 Constructor. More...
 
 executeCommand ()
 Execute command. More...
 
 setTableWidth ($a_width)
 Set table width. More...
 
 getTableWidth ()
 get table width More...
 
 setMode ($a_mode)
 Set Mode ('std', 'subform'). More...
 
 getMode ()
 Get Mode ('std', 'subform'). More...
 
 setTitle ($a_title)
 Set Title. More...
 
 getTitle ()
 Get Title. More...
 
 setTitleIcon ($a_titleicon)
 Set TitleIcon. More...
 
 getTitleIcon ()
 Get TitleIcon. More...
 
 setDescription ($a_val)
 Set description. More...
 
 getDescription ()
 Get description. More...
 
 setTopAnchor ($a_val)
 Set top anchor. More...
 
 getTopAnchor ()
 Get top anchor. More...
 
 setShowTopButtons ($a_val)
 Get show top buttons. More...
 
 getShowTopButtons ()
 Set show top buttons. More...
 
 setForceTopButtons ($a_val)
 Set force top buttons. More...
 
 getForceTopButtons ()
 Get force top buttons. More...
 
 addItem ($a_item)
 Add Item (Property, SectionHeader). More...
 
 removeItemByPostVar ($a_post_var, $a_remove_unused_headers=false)
 Remove Item. More...
 
 getItemByPostVar ($a_post_var)
 Get Item by POST variable. More...
 
 setItems ($a_items)
 Set Items. More...
 
 getItems ()
 Get Items. More...
 
 getInputItemsRecursive ()
 returns a flat array of all input items including the possibly existing subitems recursively More...
 
 setDisableStandardMessage ($a_val)
 Set disable standard message. More...
 
 getDisableStandardMessage ()
 Get disable standard message. More...
 
 getHideLabels ()
 Get a value indicating whether the labels should be hidden or not. More...
 
 setHideLabels ($a_value=true)
 Set a value indicating whether the labels should be hidden or not. More...
 
 setValuesByArray ($a_values, $a_restrict_to_value_keys=false)
 Set form values from an array. More...
 
 setValuesByPost ()
 Set form values from POST values. More...
 
 checkInput ()
 Check Post Input. More...
 
 getInput ($a_post_var, $ensureValidation=true)
 Returns the value of a HTTP-POST variable, identified by the passed id. More...
 
 addCustomProperty ( $a_title, $a_html, $a_info="", $a_alert="", $a_required=false)
 Add a custom property. More...
 
 addCommandButton ($a_cmd, $a_text, $a_id="")
 Add Command button. More...
 
 getCommandButtons ()
 Return all Command buttons. More...
 
 clearCommandButtons ()
 Remove all command buttons. More...
 
 getContent ()
 Get Content. More...
 
 insertItem ($item, $a_sub_item=false)
 
 getHTML ()
 Get HTML. More...
 
 getFileUpload ($a_field, $a_index=null, $a_sub_index=null)
 Get file upload data. More...
 
 hasFileUpload ($a_field, $a_index=null, $a_sub_index=null)
 Was any file uploaded? More...
 
 moveFileUpload ($a_target_directory, $a_field, $a_target_name=null, $a_index=null, $a_sub_index=null)
 Move upload to target directory. More...
 
- Public Member Functions inherited from ilFormGUI
 setFormAction ($a_formaction)
 Set FormAction. More...
 
 getFormAction ()
 Get FormAction. More...
 
 setTarget ($a_target)
 Set Target. More...
 
 getTarget ()
 Get Target. More...
 
 setMultipart ($a_multipart)
 Set Enctype Multipart/Formdata true/false. More...
 
 getMultipart ()
 Get Enctype Multipart/Formdata true/false. More...
 
 setId ($a_id)
 Set Id. More...
 
 getId ()
 Get Id. More...
 
 setName ($a_name)
 Set Name. More...
 
 getName ()
 Get Name. More...
 
 setKeepOpen ($a_keepopen)
 Set Keep Form Tag Open. More...
 
 getKeepOpen ()
 Get Keep Form Tag Open. More...
 
 setOpenTag ($a_open)
 Enable/Disable Open Form Tag. More...
 
 getOpenTag ()
 Get Open Form Tag Enabled. More...
 
 setCloseTag ($a_val)
 Set close tag. More...
 
 getCloseTag ()
 Get close tag. More...
 
 setPreventDoubleSubmission ($a_val)
 Set prevent double submission. More...
 
 getPreventDoubleSubmission ()
 Get prevent double submission. More...
 
 getHTML ()
 Get HTML. More...
 
 getContent ()
 Get Content. More...
 

Protected Member Functions

 initForm ()
 Initializes the property form. More...
 
 getRawMountInstructionsFromFileUpload (UploadResult $upload_result)
 Gets the content of the uploaded file. More...
 
- Protected Member Functions inherited from ilPropertyFormGUI
 hideRequired ($a_type)
 
 rebuildUploadedFiles ()
 try to rebuild files More...
 

Protected Attributes

 $document
 
 $mount_instructions_repository
 
 $document_purifier
 
 $actor
 
 $file_upload
 
 $tmp_filesystem
 
 $form_action
 
 $save_command
 
 $cancel_command
 
 $is_editable = false
 
 $translated_error
 
 $translated_info
 
- Protected Attributes inherited from ilPropertyFormGUI
 $lng
 
 $ctrl
 
 $tpl
 
 $user
 
 $settings
 
 $mode = "std"
 
 $check_input_called = false
 
 $disable_standard_message = false
 
 $top_anchor = "il_form_top"
 
 $titleicon = false
 
 $description = ""
 
 $tbl_width = false
 
 $show_top_buttons = true
 
 $hide_labels = false
 
 $force_top_buttons = false
 
- Protected Attributes inherited from ilFormGUI
 $formaction
 
 $multipart = false
 
 $keepopen = false
 
 $opentag = true
 
 $id
 
 $name
 
 $prevent_double_submission = false
 

Detailed Description

Constructor & Destructor Documentation

◆ __construct()

ilWebDAVMountInstructionsDocumentFormGUI::__construct ( ilWebDAVMountInstructionsDocument  $a_document,
ilWebDAVMountInstructionsRepository  $mount_instructions_repository,
?ilHtmlPurifierInterface  $a_document_purifier,
ilObjUser  $a_actor,
FileSystem  $a_tmp_filesystem,
FileUpload  $a_fileupload,
string  $a_form_action,
string  $a_save_command,
string  $a_cancel_command,
bool  $a_is_editable 
)

ilWebDAVMountInstructionsDocumentFormGUI constructor.

Parameters
ilWebDAVMountInstructionsDocument$a_document
ilWebDAVMountInstructionsRepository$mount_instructions_repository
ilHtmlPurifierInterface | null$a_document_purifier
ilObjUser$a_actor
Filesystem$a_tmp_filesystem
FileUpload$a_fileupload
string$a_form_action
string$a_save_command
string$a_cancel_command
bool$a_is_editable

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

71 {
72 $this->document = $a_document;
73 $this->mount_instructions_repository = $mount_instructions_repository;
74 $this->document_purifier = $a_document_purifier;
75 $this->actor = $a_actor;
76 $this->tmp_filesystem = $a_tmp_filesystem;
77 $this->file_upload = $a_fileupload;
78 $this->form_action = $a_form_action;
79 $this->save_command = $a_save_command;
80 $this->cancel_command = $a_cancel_command;
81 $this->is_editable = $a_is_editable;
82
84
85 $this->initForm();
86 }
__construct(Container $dic, ilPlugin $plugin)
@inheritDoc

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

+ Here is the call graph for this function:

Member Function Documentation

◆ getRawMountInstructionsFromFileUpload()

ilWebDAVMountInstructionsDocumentFormGUI::getRawMountInstructionsFromFileUpload ( UploadResult  $upload_result)
protected

Gets the content of the uploaded file.

Parameters
UploadResult$upload_result
Returns
string
Exceptions

ILIAS\Filesystem\Exception\FileNotFoundException

Exceptions

ILIAS\Filesystem\Exception\IOException

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

308 : string
309 {
310 // Check uploaded name
311 if ($upload_result->getName() === '') {
312 throw new InvalidArgumentException('uploaded file has no name');
313 }
314
315 // Check status
316 if ($upload_result->getStatus()->getCode() != ProcessingStatus::OK) {
317 $this->getItemByPostVar('document')->setAlert($upload_result->getStatus()->getMessage());
318 throw new InvalidArgumentException($this->lng->txt('form_input_not_valid'));
319 }
320
321 // Move uploaded file to a temporary directory to read it
322 $this->file_upload->moveOneFileTo(
323 $upload_result,
324 '/mount_instructions',
325 Location::TEMPORARY,
326 '',
327 true
328 );
329
330 $path_to_file = '/mount_instructions/' . $upload_result->getName();
331 if (!$this->tmp_filesystem->has($path_to_file)) {
332 $this->getItemByPostVar('document')->setAlert($this->lng->txt('form_msg_file_no_upload'));
333 throw new InvalidArgumentException($this->lng->txt('form_input_not_valid'));
334 }
335
336 // Get conetent of file
337 $raw_content = $content = $this->tmp_filesystem->read($path_to_file);
338
339 // Delete temporary file
340 $this->tmp_filesystem->delete($path_to_file);
341
342 return $raw_content;
343 }
getItemByPostVar($a_post_var)
Get Item by POST variable.

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

+ Here is the call graph for this function:

◆ getTranslatedError()

ilWebDAVMountInstructionsDocumentFormGUI::getTranslatedError ( )

◆ getTranslatedInfo()

ilWebDAVMountInstructionsDocumentFormGUI::getTranslatedInfo ( )

◆ hasTranslatedError()

ilWebDAVMountInstructionsDocumentFormGUI::hasTranslatedError ( )
Returns
bool

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

201 {
202 return strlen($this->translated_error) > 0;
203 }

◆ hasTranslatedInfo()

ilWebDAVMountInstructionsDocumentFormGUI::hasTranslatedInfo ( )
Returns
bool

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

193 {
194 return strlen($this->translated_info) > 0;
195 }

◆ initForm()

ilWebDAVMountInstructionsDocumentFormGUI::initForm ( )
protected

Initializes the property form.

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

91 : void
92 {
93 $document_already_exists = $this->document->getId() > 0;
94 if ($document_already_exists) {
95 $this->setTitle($this->lng->txt('webdav_form_edit_doc_head'));
96 } else {
97 $this->setTitle($this->lng->txt('webdav_form_new_doc_head'));
98 }
99
100 $this->setFormAction($this->form_action);
101
102 $title = new ilTextInputGUI($this->lng->txt('webdav_form_document_title'), 'title');
103 $title->setInfo($this->lng->txt('webdav_form_document_title_info'));
104 $title->setRequired(true);
105 $title->setDisabled(!$this->is_editable);
106 $title->setValue($this->document->getTitle());
107 $title->setMaxLength(255);
108 $this->addItem($title);
109
110 if ($document_already_exists) {
111 $document_label = $this->lng->txt('webdav_form_document');
112 $document_by_line = $this->lng->txt('webdav_form_document_info');
113 } else {
114 $document_label = $this->lng->txt('webdav_form_document');
115 $document_by_line = $this->lng->txt('webdav_form_document_info');
116 }
117
118 $language_selection = new ilSelectInputGUI(
119 $this->lng->txt('language'),
120 'lng'
121 );
122 $language_selection->setRequired(true);
123
124 $options = [];
125 foreach ($this->lng->getInstalledLanguages() as $lng) {
126 $options[$lng] = $this->lng->txt('meta_l_' . $lng, 'meta');
127 }
128
129 asort($options);
130
131 $language_selection->setOptions(['' => $this->lng->txt('please_choose')] + $options);
132 $language_selection->setValue((string) ($this->document->getLanguage() ?? ''));
133
134 $this->addItem($language_selection);
135
136 if ($document_already_exists) {
137 $webdav_id = new ilHiddenInputGUI('webdav_id');
138 $webdav_id->setValue($this->document->getId());
139 $this->addItem($webdav_id);
140 } else {
141 $document_upload = new ilFileInputGUI($document_label, 'document');
142 $document_upload->setInfo($document_by_line);
143 $document_upload->setRequired($document_already_exists ? false : true);
144 $document_upload->setDisabled(!$this->is_editable);
145 $document_upload->setSuffixes(['html', 'htm', 'txt']);
146 $this->addItem($document_upload);
147 }
148
149 if ($this->is_editable) {
150 $this->addCommandButton($this->save_command, $this->lng->txt('save'));
151 }
152 }
This class represents a file property in a property form.
setFormAction($a_formaction)
Set FormAction.
This class represents a hidden form property in a property form.
addItem($a_item)
Add Item (Property, SectionHeader).
addCommandButton($a_cmd, $a_text, $a_id="")
Add Command button.
setTitle($a_title)
Set Title.
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\addCommandButton(), ilPropertyFormGUI\addItem(), 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 ( )

Save uploaded mount instructions document.

Returns
bool

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

159 {
160 try {
161 $this->document = $this->createFilledObject($this->document);
162 $this->mount_instructions_repository->createMountInstructionsDocumentEntry($this->document);
163 } catch (InvalidArgumentException $e) {
164 $this->setValuesByPost();
165 $this->translated_error .= $e->getMessage();
166 return false;
167 }
168
169 return true;
170 }
setValuesByPost()
Set form values from POST values.

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

+ Here is the call graph for this function:

◆ updateObject()

ilWebDAVMountInstructionsDocumentFormGUI::updateObject ( )

Update the document with id from form.

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

176 {
177 try {
178 $this->document = $this->createFilledObject($this->document);
179 $this->mount_instructions_repository->updateMountInstructions($this->document);
180 } catch (InvalidArgumentException $e) {
181 $this->setValuesByPost();
182 $this->translated_error .= $e->getMessage();
183 return false;
184 }
185
186 return true;
187 }

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

+ Here is the call graph for this function:

Field Documentation

◆ $actor

ilWebDAVMountInstructionsDocumentFormGUI::$actor
protected

◆ $cancel_command

ilWebDAVMountInstructionsDocumentFormGUI::$cancel_command
protected

◆ $document

ilWebDAVMountInstructionsDocumentFormGUI::$document
protected

◆ $document_purifier

ilWebDAVMountInstructionsDocumentFormGUI::$document_purifier
protected

◆ $file_upload

ilWebDAVMountInstructionsDocumentFormGUI::$file_upload
protected

◆ $form_action

ilWebDAVMountInstructionsDocumentFormGUI::$form_action
protected

◆ $is_editable

ilWebDAVMountInstructionsDocumentFormGUI::$is_editable = false
protected

◆ $mount_instructions_repository

ilWebDAVMountInstructionsDocumentFormGUI::$mount_instructions_repository
protected

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

Referenced by __construct().

◆ $save_command

ilWebDAVMountInstructionsDocumentFormGUI::$save_command
protected

◆ $tmp_filesystem

ilWebDAVMountInstructionsDocumentFormGUI::$tmp_filesystem
protected

◆ $translated_error

ilWebDAVMountInstructionsDocumentFormGUI::$translated_error
protected

◆ $translated_info

ilWebDAVMountInstructionsDocumentFormGUI::$translated_info
protected

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