ILIAS  release_5-2 Revision v5.2.25-18-g3f80b828510
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 ($a_title="", $a_postvar="")
 Constructor. More...
 
 setImagePathWeb ($a_path)
 Set the web image path. More...
 
 getImagePathWeb ()
 Get the web image path. More...
 
 setFilenames ($a_filenames)
 Set filenames. More...
 
 getFilenames ()
 Get filenames. More...
 
 setAllowMove ($a_allow_move)
 Set allow move. More...
 
 getAllowMove ()
 Get allow move. More...
 
 checkInput ()
 Check input, strip slashes etc. More...
 
 insert ($a_tpl)
 Insert property html. More...
 
- Public Member Functions inherited from ilFileInputGUI
 __construct ($a_title="", $a_postvar="")
 Constructor. More...
 
 setValueByArray ($a_values)
 Set value by array. More...
 
 setValue ($a_value)
 Set Value. More...
 
 getValue ()
 Get Value. More...
 
 setSize ($a_size)
 Set Size. More...
 
 getSize ()
 Get Size. More...
 
 setFilename ($a_val)
 Set filename value (if filename selection is enabled) More...
 
 getFilename ()
 Get Value. More...
 
 setSuffixes ($a_suffixes)
 Set Accepted Suffixes. More...
 
 getSuffixes ()
 Get Accepted Suffixes. More...
 
 setForbiddenSuffixes ($a_suffixes)
 Set forbidden Suffixes. More...
 
 getForbiddenSuffixes ()
 Get Accepted Suffixes. More...
 
 setPending ($a_val)
 Set pending filename value. More...
 
 getPending ()
 Get pending filename. More...
 
 enableFileNameSelection ($a_post_var)
 If enabled, users get the possibility to enter a filename for the uploaded file. More...
 
 isFileNameSelectionEnabled ()
 Check if filename selection is enabled. More...
 
 getFileNamePostVar ()
 Get file name post var. More...
 
 setALlowDeletion ($a_val)
 Set allow deletion. More...
 
 getALlowDeletion ()
 Get allow deletion. More...
 
 checkInput ()
 Check input, strip slashes etc. More...
 
 render ($a_mode="")
 Render html. More...
 
 insert ($a_tpl)
 Insert property html. More...
 
 getDeletionFlag ()
 Get deletion flag. More...
 
 getToolbarHTML ()
 Get HTML for toolbar. More...
 
- Public Member Functions inherited from ilSubEnabledFormPropertyGUI
 addSubItem ($a_item)
 Add Subitem. More...
 
 getSubItems ()
 Get Subitems. More...
 
 getSubInputItemsRecursive ()
 returns a flat array of possibly existing subitems recursively More...
 
 checkSubItemsInput ()
 Check SubItems. More...
 
 getSubForm ()
 Get sub form html. More...
 
 getItemByPostVar ($a_post_var)
 Get item by post var. More...
 
- Public Member Functions inherited from ilFormPropertyGUI
 __construct ($a_title="", $a_postvar="")
 Constructor. More...
 
 executeCommand ()
 Execute command. More...
 
 getType ()
 Get Type. More...
 
 setTitle ($a_title)
 Set Title. More...
 
 getTitle ()
 Get Title. More...
 
 setPostVar ($a_postvar)
 Set Post Variable. More...
 
 getPostVar ()
 Get Post Variable. More...
 
 getFieldId ()
 Get Post Variable. More...
 
 setInfo ($a_info)
 Set Information Text. More...
 
 getInfo ()
 Get Information Text. More...
 
 setAlert ($a_alert)
 Set Alert Text. More...
 
 getAlert ()
 Get Alert Text. More...
 
 setRequired ($a_required)
 Set Required. More...
 
 getRequired ()
 Get Required. More...
 
 setDisabled ($a_disabled)
 Set Disabled. More...
 
 getDisabled ()
 Get Disabled. More...
 
 checkInput ()
 Check input, strip slashes etc. More...
 
 setParentForm ($a_parentform)
 Set Parent Form. More...
 
 getParentForm ()
 Get Parent Form. More...
 
 setParent ($a_val)
 Set Parent GUI object. More...
 
 getParent ()
 Get Parent GUI object. More...
 
 getSubForm ()
 Get sub form html. More...
 
 hideSubForm ()
 Sub form hidden on init? More...
 
 setHiddenTitle ($a_val)
 Set hidden title (for screenreaders) More...
 
 getHiddenTitle ()
 Get hidden title. More...
 
 getItemByPostVar ($a_post_var)
 Get item by post var. More...
 
 serializeData ()
 serialize data More...
 
 unserializeData ($a_data)
 unserialize data More...
 
 writeToSession ()
 Write to session. More...
 
 clearFromSession ()
 Clear session value. More...
 
 readFromSession ()
 Read from session. More...
 
 getHiddenTag ($a_post_var, $a_value)
 Get hidden tag (used for disabled properties) More...
 
 setMulti ($a_multi, $a_sortable=false, $a_addremove=true)
 Set Multi. More...
 
 getMulti ()
 Get Multi. More...
 
 setMultiValues (array $a_values)
 Set multi values. More...
 
 getMultiValues ()
 Get multi values. More...
 
 getContentOutsideFormTag ()
 Get content that has to reside outside of the parent form tag, e.g. More...
 
 stripSlashesAddSpaceFallback ($a_str)
 Strip slashes with add space fallback, see https://www.ilias.de/mantis/view.php?id=19727. More...
 

Protected Attributes

 $filenames = array()
 
 $allowMove = false
 
 $imagepath_web = ""
 
- Protected Attributes inherited from ilFileInputGUI
 $size = 40
 
 $pending
 
 $allow_deletion
 
 $forbidden_suffixes = array()
 
- Protected Attributes inherited from ilSubEnabledFormPropertyGUI
 $sub_items = array()
 
- Protected Attributes inherited from ilFormPropertyGUI
 $type
 
 $title
 
 $postvar
 
 $info
 
 $alert
 
 $required = false
 
 $parentgui
 
 $parentform
 
 $hidden_title = ""
 
 $multi = false
 
 $multi_sortable = false
 
 $multi_addremove = true
 
 $multi_values
 

Additional Inherited Members

- Static Public Member Functions inherited from ilFileInputGUI
static setPersonalWorkspaceQuotaCheck ($a_value)
 
- Static Public Member Functions inherited from ilFormPropertyGUI
static removeProhibitedCharacters ($a_text)
 Remove prohibited characters see #19159. More...
 
- Protected Member Functions inherited from ilFileInputGUI
 outputSuffixes ($a_tpl, $a_block="allowed_suffixes")
 
 getMaxFileSizeString ()
 
- Protected Member Functions inherited from ilFormPropertyGUI
 setType ($a_type)
 Set Type. More...
 
 getMultiIconsHTML ()
 Get HTML for multiple value icons. More...
 
- Static Protected Attributes inherited from ilFileInputGUI
static $check_wsp_quota
 

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
Version
Id
class.ilFileWizardInputGUI.php 18834 2009-02-03 10:10:29Z hschottm

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

Constructor & Destructor Documentation

◆ __construct()

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

Constructor.

Parameters
string$a_titleTitle
string$a_postvarPost Variable

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

44  {
45  parent::__construct($a_title, $a_postvar);
46  }

Member Function Documentation

◆ checkInput()

ilFileWizardInputGUI::checkInput ( )

Check input, strip slashes etc.

set alert, if input is not ok.

Returns
boolean Input ok, true/false

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

References $error, ilFileInputGUI\$filename, $lng, ilSubEnabledFormPropertyGUI\checkSubItemsInput(), ilFormPropertyGUI\getPostVar(), ilFormPropertyGUI\getRequired(), ilFileInputGUI\getSuffixes(), ilStr\normalizeUtf8String(), ilFormPropertyGUI\setAlert(), and ilUtil\virusHandling().

114  {
115  global $lng;
116 
117  // see ilFileInputGUI
118  // if no information is received, something went wrong
119  // this is e.g. the case, if the post_max_size has been exceeded
120  if (!is_array($_FILES[$this->getPostVar()]))
121  {
122  $this->setAlert($lng->txt("form_msg_file_size_exceeds"));
123  return false;
124  }
125 
126  $pictures = $_FILES[$this->getPostVar()];
127  $uploadcheck = true;
128  if (is_array($pictures))
129  {
130  foreach ($pictures['name'] as $index => $name)
131  {
132  // remove trailing '/'
133  $name = rtrim($name, '/');
134 
135  $filename = $name;
136  $filename_arr = pathinfo($name);
137  $suffix = $filename_arr["extension"];
138  $mimetype = $pictures["type"][$index];
139  $size_bytes = $pictures["size"][$index];
140  $temp_name = $pictures["tmp_name"][$index];
141  $error = $pictures["error"][$index];
142 
143  include_once("./Services/Utilities/classes/class.ilStr.php");
144  $_FILES[$this->getPostVar()]["name"][$index] = ilStr::normalizeUtf8String($_FILES[$this->getPostVar()]["name"][$index]);
145 
146 
147  // error handling
148  if ($error > 0)
149  {
150  switch ($error)
151  {
152  case UPLOAD_ERR_INI_SIZE:
153  $this->setAlert($lng->txt("form_msg_file_size_exceeds"));
154  $uploadcheck = false;
155  break;
156 
157  case UPLOAD_ERR_FORM_SIZE:
158  $this->setAlert($lng->txt("form_msg_file_size_exceeds"));
159  $uploadcheck = false;
160  break;
161 
162  case UPLOAD_ERR_PARTIAL:
163  $this->setAlert($lng->txt("form_msg_file_partially_uploaded"));
164  $uploadcheck = false;
165  break;
166 
167  case UPLOAD_ERR_NO_FILE:
168  if ($this->getRequired())
169  {
170  $filename = $this->filenames[$index];
171  if (!strlen($filename))
172  {
173  $this->setAlert($lng->txt("form_msg_file_no_upload"));
174  $uploadcheck = false;
175  }
176  }
177  break;
178 
179  case UPLOAD_ERR_NO_TMP_DIR:
180  $this->setAlert($lng->txt("form_msg_file_missing_tmp_dir"));
181  $uploadcheck = false;
182  break;
183 
184  case UPLOAD_ERR_CANT_WRITE:
185  $this->setAlert($lng->txt("form_msg_file_cannot_write_to_disk"));
186  $uploadcheck = false;
187  break;
188 
189  case UPLOAD_ERR_EXTENSION:
190  $this->setAlert($lng->txt("form_msg_file_upload_stopped_ext"));
191  $uploadcheck = false;
192  break;
193  }
194  }
195 
196  // check suffixes
197  if ($pictures["tmp_name"][$index] != "" && is_array($this->getSuffixes()))
198  {
199  if (!in_array(strtolower($suffix), $this->getSuffixes()))
200  {
201  $this->setAlert($lng->txt("form_msg_file_wrong_file_type"));
202  $uploadcheck = false;
203  }
204  }
205 
206  // virus handling
207  if ($pictures["tmp_name"][$index] != "")
208  {
209  $vir = ilUtil::virusHandling($temp_name, $filename);
210  if ($vir[0] == false)
211  {
212  $this->setAlert($lng->txt("form_msg_file_virus_found")."<br />".$vir[1]);
213  $uploadcheck = false;
214  }
215  }
216  }
217 
218  }
219 
220  if (!$uploadcheck)
221  {
222  return FALSE;
223  }
224 
225  return $this->checkSubItemsInput();
226  }
getSuffixes()
Get Accepted Suffixes.
$error
Definition: Error.php:17
static virusHandling($a_file, $a_orig_name="", $a_clean=true)
scan file for viruses and clean files if possible
getPostVar()
Get Post Variable.
static normalizeUtf8String($a_str)
Normalize UTF8 string.
setAlert($a_alert)
Set Alert Text.
global $lng
Definition: privfeed.php:17
+ Here is the call graph for this function:

◆ getAllowMove()

ilFileWizardInputGUI::getAllowMove ( )

Get allow move.

Returns
boolean Allow move

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

References $allowMove.

Referenced by insert().

104  {
105  return $this->allowMove;
106  }
+ Here is the caller graph for this function:

◆ getFilenames()

ilFileWizardInputGUI::getFilenames ( )

Get filenames.

Returns
array filenames

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

References $filenames.

◆ getImagePathWeb()

ilFileWizardInputGUI::getImagePathWeb ( )

Get the web image path.

Returns
string Path

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

References $imagepath_web.

Referenced by insert().

+ Here is the caller graph for this function:

◆ insert()

ilFileWizardInputGUI::insert (   $a_tpl)

Insert property html.

Returns
int Size

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

References $lng, $tpl, ilGlyphGUI\ADD, ilGlyphGUI\DOWN, ilGlyphGUI\get(), getAllowMove(), ilFormPropertyGUI\getDisabled(), ilFormPropertyGUI\getFieldId(), getImagePathWeb(), ilFileInputGUI\getMaxFileSizeString(), ilFormPropertyGUI\getPostVar(), ilFileInputGUI\outputSuffixes(), ilUtil\prepareFormOutput(), ilGlyphGUI\REMOVE, and ilGlyphGUI\UP.

234  {
235  global $lng;
236 
237  $tpl = new ilTemplate("tpl.prop_filewizardinput.html", true, true, "Services/Form");
238 
239  $i = 0;
240  foreach ($this->filenames as $value)
241  {
242  if (strlen($value))
243  {
244  $tpl->setCurrentBlock("image");
245  $tpl->setVariable("SRC_IMAGE", $this->getImagePathWeb() . ilUtil::prepareFormOutput($value));
246  $tpl->setVariable("PICTURE_FILE", ilUtil::prepareFormOutput($value));
247  $tpl->setVariable("ID", $this->getFieldId() . "[$i]");
248  $tpl->setVariable("ALT_IMAGE", ilUtil::prepareFormOutput($value));
249  $tpl->parseCurrentBlock();
250  }
251  if ($this->getAllowMove())
252  {
253  $tpl->setCurrentBlock("move");
254  $tpl->setVariable("CMD_UP", "cmd[up" . $this->getFieldId() . "][$i]");
255  $tpl->setVariable("CMD_DOWN", "cmd[down" . $this->getFieldId() . "][$i]");
256  $tpl->setVariable("ID", $this->getFieldId() . "[$i]");
257  include_once("./Services/UIComponent/Glyph/classes/class.ilGlyphGUI.php");
258  $tpl->setVariable("UP_BUTTON", ilGlyphGUI::get(ilGlyphGUI::UP));
259  $tpl->setVariable("DOWN_BUTTON", ilGlyphGUI::get(ilGlyphGUI::DOWN));
260  $tpl->parseCurrentBlock();
261  }
262 
263  $this->outputSuffixes($tpl, "allowed_image_suffixes");
264 
265  $tpl->setCurrentBlock("row");
266  $tpl->setVariable("POST_VAR", $this->getPostVar() . "[$i]");
267  $tpl->setVariable("ID", $this->getFieldId() . "[$i]");
268  $tpl->setVariable("CMD_ADD", "cmd[add" . $this->getFieldId() . "][$i]");
269  $tpl->setVariable("CMD_REMOVE", "cmd[remove" . $this->getFieldId() . "][$i]");
270  $tpl->setVariable("ALT_ADD", $lng->txt("add"));
271  $tpl->setVariable("ALT_REMOVE", $lng->txt("remove"));
272  if ($this->getDisabled())
273  {
274  $tpl->setVariable("DISABLED",
275  " disabled=\"disabled\"");
276  }
277 
278  include_once("./Services/UIComponent/Glyph/classes/class.ilGlyphGUI.php");
279  $tpl->setVariable("ADD_BUTTON", ilGlyphGUI::get(ilGlyphGUI::ADD));
280  $tpl->setVariable("REMOVE_BUTTON", ilGlyphGUI::get(ilGlyphGUI::REMOVE));
281  $tpl->setVariable("TXT_MAX_SIZE", $lng->txt("file_notice") . " " . $this->getMaxFileSizeString());
282  $tpl->parseCurrentBlock();
283  $i++;
284  }
285  $tpl->setVariable("ELEMENT_ID", $this->getFieldId());
286 
287  $a_tpl->setCurrentBlock("prop_generic");
288  $a_tpl->setVariable("PROP_GENERIC", $tpl->get());
289  $a_tpl->parseCurrentBlock();
290 
291  global $tpl;
292  $tpl->addJavascript("./Services/Form/js/ServiceFormWizardInput.js");
293  $tpl->addJavascript("./Services/Form/templates/default/filewizard.js");
294  }
static prepareFormOutput($a_str, $a_strip=false)
prepares string output for html forms public
getPostVar()
Get Post Variable.
static get($a_glyph, $a_text="")
Get glyph html.
global $tpl
Definition: ilias.php:8
getFieldId()
Get Post Variable.
special template class to simplify handling of ITX/PEAR
outputSuffixes($a_tpl, $a_block="allowed_suffixes")
getImagePathWeb()
Get the web image path.
global $lng
Definition: privfeed.php:17
+ Here is the call graph for this function:

◆ setAllowMove()

ilFileWizardInputGUI::setAllowMove (   $a_allow_move)

Set allow move.

Parameters
boolean$a_allow_moveAllow move

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

94  {
95  $this->allowMove = $a_allow_move;
96  }

◆ setFilenames()

ilFileWizardInputGUI::setFilenames (   $a_filenames)

Set filenames.

Parameters
array$a_valueValue

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

Referenced by ilObjForumGUI\cancelDraftObject(), ilExSubmissionFileGUI\initUploadForm(), and ilObjForumGUI\isWritingWithPseudonymAllowed().

74  {
75  $this->filenames = $a_filenames;
76  }
+ Here is the caller graph for this function:

◆ setImagePathWeb()

ilFileWizardInputGUI::setImagePathWeb (   $a_path)

Set the web image path.

Parameters
string$a_pathPath

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

54  {
55  $this->imagepath_web = $a_path;
56  }

Field Documentation

◆ $allowMove

ilFileWizardInputGUI::$allowMove = false
protected

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

Referenced by getAllowMove().

◆ $filenames

ilFileWizardInputGUI::$filenames = array()
protected

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

Referenced by getFilenames().

◆ $imagepath_web

ilFileWizardInputGUI::$imagepath_web = ""
protected

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

Referenced by getImagePathWeb().


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