ILIAS  release_8 Revision v8.23
ilFileWizardInputGUI Class Reference

This class represents a file wizard property in a property form. More...

+ Inheritance diagram for ilFileWizardInputGUI:
+ Collaboration diagram for ilFileWizardInputGUI:

Public Member Functions

 __construct (string $a_title="", string $a_postvar="")
 
 setImagePathWeb (string $a_path)
 
 getImagePathWeb ()
 
 setFilenames (array $a_filenames)
 
 getFilenames ()
 
 setAllowMove (bool $a_allow_move)
 
 getAllowMove ()
 
 checkInput ()
 
 insert (ilTemplate $a_tpl)
 
- Public Member Functions inherited from ilFileInputGUI
 __construct (string $a_title="", string $a_postvar="")
 
 setValueByArray (array $a_values)
 
 setValue (string $a_value)
 Set Value. More...
 
 getValue ()
 
 setSize (int $a_size)
 
 getSize ()
 
 setFilename (string $a_val)
 
 getFilename ()
 
 setSuffixes (array $a_suffixes)
 
 getSuffixes ()
 
 setForbiddenSuffixes (array $a_suffixes)
 
 getForbiddenSuffixes ()
 
 setPending (string $a_val)
 
 getPending ()
 
 enableFileNameSelection (string $a_post_var)
 
 isFileNameSelectionEnabled ()
 
 getFileNamePostVar ()
 
 setAllowDeletion (bool $a_val)
 
 getALlowDeletion ()
 
 checkInput ()
 
 getInput ()
 
 render (string $a_mode="")
 
 insert (ilTemplate $a_tpl)
 
 getDeletionFlag ()
 
 getToolbarHTML ()
 Get input item HTML to be inserted into ilToolbarGUI. More...
 
- Public Member Functions inherited from ilSubEnabledFormPropertyGUI
 addSubItem (ilFormPropertyGUI $a_item)
 
 getSubItems ()
 
 getSubInputItemsRecursive ()
 returns a flat array of possibly existing subitems recursively More...
 
 checkSubItemsInput ()
 Check SubItems. More...
 
 getSubForm ()
 
 getItemByPostVar (string $a_post_var)
 
- Public Member Functions inherited from ilFormPropertyGUI
 __construct (string $a_title="", string $a_postvar="")
 
 executeCommand ()
 
 getType ()
 
 setTitle (string $a_title)
 
 getTitle ()
 
 setPostVar (string $a_postvar)
 
 getPostVar ()
 
 getFieldId ()
 
 setInfo (string $a_info)
 
 getInfo ()
 
 setAlert (string $a_alert)
 
 getAlert ()
 
 setRequired (bool $a_required)
 
 getRequired ()
 
 setDisabled (bool $a_disabled)
 
 getDisabled ()
 
 checkInput ()
 Check input, strip slashes etc. More...
 
 setParentForm (ilPropertyFormGUI $a_parentform)
 
 getParentForm ()
 
 setParent (ilFormPropertyGUI $a_val)
 
 getParent ()
 
 getSubForm ()
 
 hideSubForm ()
 
 setHiddenTitle (string $a_val)
 
 getHiddenTitle ()
 
 getItemByPostVar (string $a_post_var)
 Get item by post var. More...
 
 serializeData ()
 
 unserializeData (string $a_data)
 
 setParentTable ($a_val)
 Set parent table. More...
 
 getParentTable ()
 Get parent table. More...
 
 writeToSession ()
 
 clearFromSession ()
 
 readFromSession ()
 
 getHiddenTag (string $a_post_var, string $a_value)
 
 setMulti (bool $a_multi, bool $a_sortable=false, bool $a_addremove=true)
 
 getMulti ()
 
 setMultiValues (array $a_values)
 
 getMultiValues ()
 
 getContentOutsideFormTag ()
 Get content that has to reside outside of the parent form tag, e.g. More...
 
 stripSlashesAddSpaceFallback (string $a_str)
 Strip slashes with add space fallback, see https://www.ilias.de/mantis/view.php?id=19727. More...
 
 getTableFilterLabelFor ()
 Get label "for" attribute value for filter. More...
 
 getFormLabelFor ()
 Get label "for" attribute value for form. More...
 
 setRequestParam (string $key, $val)
 This writes the request (aka post) values. More...
 

Protected Attributes

ilGlobalTemplateInterface $tpl
 
array $filenames = array()
 
bool $allowMove = false
 
string $imagepath_web = ""
 
- Protected Attributes inherited from ilFileInputGUI
int $size = 40
 
string $pending = ""
 
bool $allow_deletion = false
 
bool $filename_selection = false
 
array $forbidden_suffixes = []
 
array $suffixes = []
 
string $value = ""
 
ILIAS FileUpload FileUpload $upload_service
 
- Protected Attributes inherited from ilSubEnabledFormPropertyGUI
array $sub_items = array()
 
- Protected Attributes inherited from ilFormPropertyGUI
array $set_params = []
 
ilTable2GUI $parent_table = null
 
ilFormPropertyGUI $parent_gui = null
 
ilCtrl $ctrl
 
ilLanguage $lng
 
string $type = ""
 
string $title = ""
 
string $postvar = ""
 
string $info = ""
 
string $alert = ""
 
bool $required = false
 
ilPropertyFormGUI $parentform = null
 
string $hidden_title = ""
 
bool $multi = false
 
bool $multi_sortable = false
 
bool $multi_addremove = true
 
array $multi_values = []
 
RequestInterface $request
 
HTTP Services $http
 
Refinery Factory $refinery = null
 
bool $disabled = false
 
ilGlobalTemplateInterface $global_tpl = null
 

Additional Inherited Members

- Static Public Member Functions inherited from ilFormPropertyGUI
static removeProhibitedCharacters (string $a_text)
 Remove prohibited characters see #19159. More...
 
- Protected Member Functions inherited from ilFileInputGUI
 outputSuffixes (ilTemplate $a_tpl, string $a_block="allowed_suffixes")
 
 getMaxFileSizeString ()
 
 getMaxFileUploads ()
 Get number of maximum file uploads as declared in php.ini. More...
 
- Protected Member Functions inherited from ilFormPropertyGUI
 setType (string $a_type)
 
 checkParentFormTable ()
 
 getSessionKey ()
 
 getMultiIconsHTML ()
 
 int ($key)
 
 intArray ($key)
 
 str ($key)
 
 raw ($key)
 
 strArray ($key)
 
 arrayArray ($key)
 
 isRequestParamArray (string $key)
 
 getRequestParam (string $key, Refinery\Transformation $t)
 

Detailed Description

This class represents a file wizard property in a property form.

Author
Helmut Schottmüller ilias.nosp@m.@aur.nosp@m.ealis.nosp@m..de

Definition at line 28 of file class.ilFileWizardInputGUI.php.

Constructor & Destructor Documentation

◆ __construct()

ilFileWizardInputGUI::__construct ( string  $a_title = "",
string  $a_postvar = "" 
)

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

References $DIC, ILIAS\GlobalScreen\Provider\__construct(), and ILIAS\Repository\lng().

38  {
39  global $DIC;
40 
41  $this->lng = $DIC->language();
42  $this->lng->loadLanguageModule("form");
43  $this->tpl = $DIC["tpl"];
44  parent::__construct($a_title, $a_postvar);
45  }
global $DIC
Definition: feed.php:28
__construct(Container $dic, ilPlugin $plugin)
+ Here is the call graph for this function:

Member Function Documentation

◆ checkInput()

ilFileWizardInputGUI::checkInput ( )

Definition at line 77 of file class.ilFileWizardInputGUI.php.

References ilFileInputGUI\$filename, $index, ilFormPropertyGUI\$lng, $name, ilSubEnabledFormPropertyGUI\checkSubItemsInput(), ilFormPropertyGUI\getPostVar(), ilFormPropertyGUI\getRequired(), ilFileInputGUI\getSuffixes(), ilFormPropertyGUI\setAlert(), ilLanguage\txt(), and ilVirusScanner\virusHandling().

77  : bool
78  {
79  $lng = $this->lng;
80 
81  // see ilFileInputGUI
82  // if no information is received, something went wrong
83  // this is e.g. the case, if the post_max_size has been exceeded
84  if (!isset($_FILES[$this->getPostVar()]) || !is_array($_FILES[$this->getPostVar()])) {
85  $this->setAlert($lng->txt("form_msg_file_size_exceeds"));
86  return false;
87  }
88 
89  $pictures = $_FILES[$this->getPostVar()];
90  $uploadcheck = true;
91  if (is_array($pictures)) {
92  foreach ($pictures['name'] as $index => $name) {
93  // remove trailing '/'
94  $name = rtrim($name, '/');
95 
96  $filename = $name;
97  $filename_arr = pathinfo($name);
98  $suffix = $filename_arr["extension"] ?? "";
99  $temp_name = $pictures["tmp_name"][$index];
100  $error = $pictures["error"][$index];
101 
102  $_FILES[$this->getPostVar()]["name"][$index] = Util::sanitizeFileName($_FILES[$this->getPostVar()]["name"][$index]);
103 
104 
105  // error handling
106  if ($error > 0) {
107  switch ($error) {
108  case UPLOAD_ERR_FORM_SIZE:
109  case UPLOAD_ERR_INI_SIZE:
110  $this->setAlert($lng->txt("form_msg_file_size_exceeds"));
111  $uploadcheck = false;
112  break;
113 
114  case UPLOAD_ERR_PARTIAL:
115  $this->setAlert($lng->txt("form_msg_file_partially_uploaded"));
116  $uploadcheck = false;
117  break;
118 
119  case UPLOAD_ERR_NO_FILE:
120  if ($this->getRequired()) {
121  $filename = $this->filenames[$index];
122  if (!strlen($filename)) {
123  $this->setAlert($lng->txt("form_msg_file_no_upload"));
124  $uploadcheck = false;
125  }
126  }
127  break;
128 
129  case UPLOAD_ERR_NO_TMP_DIR:
130  $this->setAlert($lng->txt("form_msg_file_missing_tmp_dir"));
131  $uploadcheck = false;
132  break;
133 
134  case UPLOAD_ERR_CANT_WRITE:
135  $this->setAlert($lng->txt("form_msg_file_cannot_write_to_disk"));
136  $uploadcheck = false;
137  break;
138 
139  case UPLOAD_ERR_EXTENSION:
140  $this->setAlert($lng->txt("form_msg_file_upload_stopped_ext"));
141  $uploadcheck = false;
142  break;
143  }
144  }
145 
146  // check suffixes
147  if ($pictures["tmp_name"][$index] != "" && is_array($this->getSuffixes()) && count($this->getSuffixes()) > 0) {
148  if (!in_array(strtolower($suffix), $this->getSuffixes())) {
149  $this->setAlert($lng->txt("form_msg_file_wrong_file_type"));
150  $uploadcheck = false;
151  }
152  }
153 
154  // virus handling
155  if ($pictures["tmp_name"][$index] != "") {
156  $vir = ilVirusScanner::virusHandling($temp_name, $filename);
157  if ($vir[0] == false) {
158  $this->setAlert($lng->txt("form_msg_file_virus_found") . "<br />" . $vir[1]);
159  $uploadcheck = false;
160  }
161  }
162  }
163  }
164 
165  if (!$uploadcheck) {
166  return false;
167  }
168 
169  return $this->checkSubItemsInput();
170  }
txt(string $a_topic, string $a_default_lang_fallback_mod="")
gets the text for a given topic if the topic is not in the list, the topic itself with "-" will be re...
static virusHandling(string $a_file, string $a_orig_name='', bool $a_clean=true)
$index
Definition: metadata.php:145
if($format !==null) $name
Definition: metadata.php:247
+ Here is the call graph for this function:

◆ getAllowMove()

ilFileWizardInputGUI::getAllowMove ( )

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

References $allowMove.

Referenced by insert().

72  : bool
73  {
74  return $this->allowMove;
75  }
+ Here is the caller graph for this function:

◆ getFilenames()

ilFileWizardInputGUI::getFilenames ( )

Definition at line 62 of file class.ilFileWizardInputGUI.php.

References $filenames.

62  : array
63  {
64  return $this->filenames;
65  }

◆ getImagePathWeb()

ilFileWizardInputGUI::getImagePathWeb ( )

Definition at line 52 of file class.ilFileWizardInputGUI.php.

References $imagepath_web.

Referenced by insert().

52  : string
53  {
54  return $this->imagepath_web;
55  }
+ Here is the caller graph for this function:

◆ insert()

ilFileWizardInputGUI::insert ( ilTemplate  $a_tpl)

Definition at line 172 of file class.ilFileWizardInputGUI.php.

References $i, ilFormPropertyGUI\$lng, $tpl, ilFileInputGUI\$value, ilGlyphGUI\ADD, ilGlyphGUI\DOWN, ilGlyphGUI\get(), ilGlobalTemplateInterface\get(), getAllowMove(), ilFormPropertyGUI\getDisabled(), ilFormPropertyGUI\getFieldId(), getImagePathWeb(), ilFileInputGUI\getMaxFileSizeString(), ilFileInputGUI\getMaxFileUploads(), ilFormPropertyGUI\getPostVar(), ilFileInputGUI\outputSuffixes(), ilTemplate\parseCurrentBlock(), ilGlobalTemplateInterface\parseCurrentBlock(), ilLegacyFormElementsUtil\prepareFormOutput(), ilGlyphGUI\REMOVE, ilTemplate\setCurrentBlock(), ilGlobalTemplateInterface\setCurrentBlock(), ilGlobalTemplateInterface\setVariable(), HTML_Template_IT\setVariable(), ilLanguage\txt(), and ilGlyphGUI\UP.

172  : void
173  {
174  $lng = $this->lng;
175 
176  $tpl = new ilTemplate("tpl.prop_filewizardinput.html", true, true, "Services/Form");
177 
178  $i = 0;
179  foreach ($this->filenames as $value) {
180  if (strlen($value)) {
181  $tpl->setCurrentBlock("image");
182  $tpl->setVariable(
183  "SRC_IMAGE",
185  $value
186  )
187  );
189  $tpl->setVariable("ID", $this->getFieldId() . "[$i]");
192  }
193  if ($this->getAllowMove()) {
194  $tpl->setCurrentBlock("move");
195  $tpl->setVariable("CMD_UP", "cmd[up" . $this->getFieldId() . "][$i]");
196  $tpl->setVariable("CMD_DOWN", "cmd[down" . $this->getFieldId() . "][$i]");
197  $tpl->setVariable("ID", $this->getFieldId() . "[$i]");
201  }
202 
203  $this->outputSuffixes($tpl, "allowed_image_suffixes");
204 
205  $tpl->setCurrentBlock("row");
206  $tpl->setVariable("POST_VAR", $this->getPostVar() . "[$i]");
207  $tpl->setVariable("ID", $this->getFieldId() . "[$i]");
208  $tpl->setVariable("CMD_ADD", "cmd[add" . $this->getFieldId() . "][$i]");
209  $tpl->setVariable("CMD_REMOVE", "cmd[remove" . $this->getFieldId() . "][$i]");
210  $tpl->setVariable("ALT_ADD", $lng->txt("add"));
211  $tpl->setVariable("ALT_REMOVE", $lng->txt("remove"));
212  if ($this->getDisabled()) {
213  $tpl->setVariable(
214  "DISABLED",
215  " disabled=\"disabled\""
216  );
217  }
218 
221  $tpl->setVariable("TXT_MAX_SIZE", $lng->txt("file_notice") . " " . $this->getMaxFileSizeString());
222  $tpl->setVariable("MAX_UPLOAD_VALUE", $this->getMaxFileUploads());
223  $tpl->setVariable("TXT_MAX_UPLOADS", $lng->txt("form_msg_max_upload") . " " . $this->getMaxFileUploads());
225  $i++;
226  }
227  $tpl->setVariable("ELEMENT_ID", $this->getFieldId());
228 
229  $a_tpl->setCurrentBlock("prop_generic");
230  $a_tpl->setVariable("PROP_GENERIC", $tpl->get());
231  $a_tpl->parseCurrentBlock();
232 
233  $main_tpl = $this->tpl;
234  $main_tpl->addJavascript("./Services/Form/js/ServiceFormWizardInput.js");
235  $main_tpl->addJavascript("./Services/Form/templates/default/filewizard.js");
236  }
parseCurrentBlock(string $part=ilGlobalTemplateInterface::DEFAULT_BLOCK)
txt(string $a_topic, string $a_default_lang_fallback_mod="")
gets the text for a given topic if the topic is not in the list, the topic itself with "-" will be re...
static get(string $a_glyph, string $a_text="")
get(string $part=self::DEFAULT_BLOCK)
Renders the given block and returns the html string.
outputSuffixes(ilTemplate $a_tpl, string $a_block="allowed_suffixes")
setVariable(string $variable, $value='')
Sets the given variable to the given value.
static prepareFormOutput($a_str, bool $a_strip=false)
setVariable($variable, $value='')
Sets a variable value.
Definition: IT.php:514
setCurrentBlock(string $part=self::DEFAULT_BLOCK)
Sets the template to the given block.
setCurrentBlock(string $part=ilGlobalTemplateInterface::DEFAULT_BLOCK)
parseCurrentBlock(string $block_name=self::DEFAULT_BLOCK)
Parses the given block.
ilGlobalTemplateInterface $tpl
getMaxFileUploads()
Get number of maximum file uploads as declared in php.ini.
$i
Definition: metadata.php:41
+ Here is the call graph for this function:

◆ setAllowMove()

ilFileWizardInputGUI::setAllowMove ( bool  $a_allow_move)

Definition at line 67 of file class.ilFileWizardInputGUI.php.

67  : void
68  {
69  $this->allowMove = $a_allow_move;
70  }

◆ setFilenames()

ilFileWizardInputGUI::setFilenames ( array  $a_filenames)

Definition at line 57 of file class.ilFileWizardInputGUI.php.

Referenced by ilForumThreadFormGUI\addFileUploadInput(), ilExAssignmentEditorGUI\initAssignmentForm(), ilObjSessionGUI\initForm(), ilObjForumGUI\initReplyEditForm(), and ilExSubmissionFileGUI\initUploadForm().

57  : void
58  {
59  $this->filenames = $a_filenames;
60  }
+ Here is the caller graph for this function:

◆ setImagePathWeb()

ilFileWizardInputGUI::setImagePathWeb ( string  $a_path)

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

47  : void
48  {
49  $this->imagepath_web = $a_path;
50  }

Field Documentation

◆ $allowMove

bool ilFileWizardInputGUI::$allowMove = false
protected

Definition at line 32 of file class.ilFileWizardInputGUI.php.

Referenced by getAllowMove().

◆ $filenames

array ilFileWizardInputGUI::$filenames = array()
protected

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

Referenced by getFilenames().

◆ $imagepath_web

string ilFileWizardInputGUI::$imagepath_web = ""
protected

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

Referenced by getImagePathWeb().

◆ $tpl

ilGlobalTemplateInterface ilFileWizardInputGUI::$tpl
protected

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

Referenced by insert().


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