ILIAS  release_7 Revision v7.30-3-g800a261c036
ilDragDropFileInputGUI Class Reference

This class represents a file input property where multiple files can be dopped in a property form. More...

+ Inheritance diagram for ilDragDropFileInputGUI:
+ Collaboration diagram for ilDragDropFileInputGUI:

Public Member Functions

 __construct ($a_title="", $a_postvar="")
 Constructor. More...
 
 setArchiveSuffixes ($a_suffixes)
 Set accepted archive suffixes. More...
 
 getArchiveSuffixes ()
 Get accepted archive suffixes. More...
 
 setCommandButtonNames ($a_submit_name, $a_cancel_name)
 
 render ($a_mode="")
 Render html. More...
 
 checkInput ()
 Check input, strip slashes etc. 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...
 
 getTableFilterLabelFor ()
 Get label "for" attribute value for filter. More...
 
 getFormLabelFor ()
 Get label "for" attribute value for form. More...
 
 getToolbarHTML ()
 Get input item HTML to be inserted into ilToolbarGUI. More...
 

Protected Member Functions

 getInputAcceptSuffixes ($suffixes)
 
 buildSuffixList ($suffixes)
 
 getMaxFileSize ()
 
- Protected Member Functions inherited from ilFileInputGUI
 outputSuffixes ($a_tpl, $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 ($a_type)
 Set Type. More...
 
 getMultiIconsHTML ()
 Get HTML for multiple value icons. More...
 

Protected Attributes

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

Static Private Member Functions

static getNextUniqueId ()
 

Private Attributes

 $uniqueId = 0
 
 $archive_suffixes = array()
 
 $submit_button_name = null
 
 $cancel_button_name = null
 

Static Private Attributes

static $uniqueInc = 1
 

Additional Inherited Members

- Static Public Member Functions inherited from ilFormPropertyGUI
static removeProhibitedCharacters ($a_text)
 Remove prohibited characters see #19159. More...
 
- Static Protected Attributes inherited from ilFileInputGUI
static $check_wsp_quota
 

Detailed Description

This class represents a file input property where multiple files can be dopped in a property form.

Author
Stefan Born stefa.nosp@m.n.bo.nosp@m.rn@ph.nosp@m.zh.c.nosp@m.h
Version
$Id$

Definition at line 13 of file class.ilDragDropFileInputGUI.php.

Constructor & Destructor Documentation

◆ __construct()

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

Constructor.

Parameters
string$a_titleTitle
string$a_postvarPost Variable

Reimplemented from ilFileInputGUI.

Definition at line 38 of file class.ilDragDropFileInputGUI.php.

39 {
40 global $DIC;
41
42 $this->lng = $DIC->language();
43 parent::__construct($a_title, $a_postvar);
44 $this->uniqueId = self::getNextUniqueId();
45 }
global $DIC
Definition: goto.php:24
__construct(Container $dic, ilPlugin $plugin)
@inheritDoc

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

+ Here is the call graph for this function:

Member Function Documentation

◆ buildSuffixList()

ilDragDropFileInputGUI::buildSuffixList (   $suffixes)
protected

Definition at line 182 of file class.ilDragDropFileInputGUI.php.

183 {
184 $list = $delim = "";
185
186 if (is_array($suffixes) && count($suffixes) > 0) {
187 foreach ($suffixes as $suffix) {
188 $list .= $delim . "\"" . $suffix . "\"";
189 $delim = ", ";
190 }
191 }
192
193 return $list;
194 }

◆ checkInput()

ilDragDropFileInputGUI::checkInput ( )

Check input, strip slashes etc.

set alert, if input is not ok.

Returns
boolean Input ok, true/false

Reimplemented from ilFileInputGUI.

Definition at line 133 of file class.ilDragDropFileInputGUI.php.

134 {
136
137 // if no information is received, something went wrong
138 // this is e.g. the case, if the post_max_size has been exceeded
139 if (!is_array($_FILES[$this->getPostVar()])) {
140 $this->setAlert($lng->txt("form_msg_file_size_exceeds"));
141 return false;
142 }
143
144 // empty file, could be a folder
145 if ($_FILES[$this->getPostVar()]["size"] < 1) {
146 $this->setAlert($lng->txt("error_upload_was_zero_bytes"));
147 return false;
148 }
149
150 // call base
151 $inputValid = parent::checkInput();
152
153 // set additionally sent input on post array
154 if ($inputValid) {
155 $_POST[$this->getPostVar()]["extract"] = isset($_POST["extract"]) ? (bool) $_POST["extract"] : false;
156 $_POST[$this->getPostVar()]["title"] = isset($_POST["title"]) ? $_POST["title"] : "";
157 $_POST[$this->getPostVar()]["description"] = isset($_POST["description"]) ? $_POST["description"] : "";
158 $_POST[$this->getPostVar()]["keep_structure"] = isset($_POST["keep_structure"]) ? (bool) $_POST["keep_structure"] : true;
159
160 include_once("./Services/Utilities/classes/class.ilStr.php");
161 $_POST[$this->getPostVar()]["name"] = ilStr::normalizeUtf8String($_POST[$this->getPostVar()]["name"]);
162 $_POST[$this->getPostVar()]["title"] = ilStr::normalizeUtf8String($_POST[$this->getPostVar()]["title"]);
163 }
164
165 return $inputValid;
166 }
$_POST["username"]
getPostVar()
Get Post Variable.
setAlert($a_alert)
Set Alert Text.
static normalizeUtf8String($a_str)
Normalize UTF8 string.

References $_POST, $lng, ilFormPropertyGUI\getPostVar(), ilStr\normalizeUtf8String(), and ilFormPropertyGUI\setAlert().

+ Here is the call graph for this function:

◆ getArchiveSuffixes()

ilDragDropFileInputGUI::getArchiveSuffixes ( )

Get accepted archive suffixes.

Returns
array Accepted archive suffixes.

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

References $archive_suffixes.

◆ getInputAcceptSuffixes()

ilDragDropFileInputGUI::getInputAcceptSuffixes (   $suffixes)
protected

Definition at line 168 of file class.ilDragDropFileInputGUI.php.

169 {
170 $list = $delim = "";
171
172 if (is_array($suffixes) && count($suffixes) > 0) {
173 foreach ($suffixes as $suffix) {
174 $list .= $delim . "." . $suffix;
175 $delim = ",";
176 }
177 }
178
179 return $list;
180 }

Referenced by render().

+ Here is the caller graph for this function:

◆ getMaxFileSize()

ilDragDropFileInputGUI::getMaxFileSize ( )
protected

Definition at line 196 of file class.ilDragDropFileInputGUI.php.

197 {
198 // get the value for the maximal uploadable filesize from the php.ini (if available)
199 $umf = ini_get("upload_max_filesize");
200 // get the value for the maximal post data from the php.ini (if available)
201 $pms = ini_get("post_max_size");
202
203 //convert from short-string representation to "real" bytes
204 $multiplier_a = array("K" => 1024, "M" => 1024 * 1024, "G" => 1024 * 1024 * 1024);
205
206 $umf_parts = preg_split("/(\d+)([K|G|M])/", $umf, -1, PREG_SPLIT_DELIM_CAPTURE | PREG_SPLIT_NO_EMPTY);
207 $pms_parts = preg_split("/(\d+)([K|G|M])/", $pms, -1, PREG_SPLIT_DELIM_CAPTURE | PREG_SPLIT_NO_EMPTY);
208
209 if (count($umf_parts) == 2) {
210 $umf = $umf_parts[0] * $multiplier_a[$umf_parts[1]];
211 }
212 if (count($pms_parts) == 2) {
213 $pms = $pms_parts[0] * $multiplier_a[$pms_parts[1]];
214 }
215
216 // use the smaller one as limit
217 $max_filesize = min($umf, $pms);
218
219 if (!$max_filesize) {
220 $max_filesize = max($umf, $pms);
221 }
222
223 return $max_filesize;
224 }

◆ getNextUniqueId()

static ilDragDropFileInputGUI::getNextUniqueId ( )
staticprivate

Definition at line 27 of file class.ilDragDropFileInputGUI.php.

28 {
29 return self::$uniqueInc++;
30 }

Referenced by __construct().

+ Here is the caller graph for this function:

◆ render()

ilDragDropFileInputGUI::render (   $a_mode = "")

Render html.

Reimplemented from ilFileInputGUI.

Definition at line 76 of file class.ilDragDropFileInputGUI.php.

77 {
79
80 // make sure jQuery is loaded
82
83 // add file upload scripts
84 include_once("./Services/FileUpload/classes/class.ilFileUploadGUI.php");
86
87 // load template
88 $this->tpl = new ilTemplate("tpl.prop_dndfiles.html", true, true, "Services/Form");
89
90 // general variables
91 $this->tpl->setVariable("UPLOAD_ID", $this->uniqueId);
92
93 // input
94 $this->tpl->setVariable("FILE_SELECT_ICON", ilObject::_getIcon("", "", "fold"));
95 $this->tpl->setVariable("TXT_SHOW_ALL_DETAILS", $lng->txt('show_all_details'));
96 $this->tpl->setVariable("TXT_HIDE_ALL_DETAILS", $lng->txt('hide_all_details'));
97 $this->tpl->setVariable("TXT_SELECTED_FILES", $lng->txt('selected_files'));
98 $this->tpl->setVariable("TXT_DRAG_FILES_HERE", $lng->txt('drag_files_here'));
99 $this->tpl->setVariable("TXT_NUM_OF_SELECTED_FILES", $lng->txt('num_of_selected_files'));
100 $this->tpl->setVariable("TXT_SELECT_FILES_FROM_COMPUTER", $lng->txt('select_files_from_computer'));
101 $this->tpl->setVariable("TXT_OR", $lng->txt('logic_or'));
102 $this->tpl->setVariable("INPUT_ACCEPT_SUFFIXES", $this->getInputAcceptSuffixes($this->getSuffixes()));
103
104 // info
105 $this->tpl->setCurrentBlock("max_size");
106 $this->tpl->setVariable("TXT_MAX_SIZE", $lng->txt("file_notice") . " " . $this->getMaxFileSizeString());
107 $this->tpl->parseCurrentBlock();
108
109 if ($quota_legend) {
110 $this->tpl->setVariable("TXT_MAX_SIZE", $quota_legend);
111 $this->tpl->parseCurrentBlock();
112 }
113
114 $this->outputSuffixes($this->tpl);
115
116 // create file upload object
117 $upload = new ilFileUploadGUI("ilFileUploadDropZone_" . $this->uniqueId, $this->uniqueId, false);
118 $upload->enableFormSubmit("ilFileUploadInput_" . $this->uniqueId, $this->submit_button_name, $this->cancel_button_name);
119 $upload->setDropAreaId("ilFileUploadDropArea_" . $this->uniqueId);
120 $upload->setFileListId("ilFileUploadList_" . $this->uniqueId);
121 $upload->setFileSelectButtonId("ilFileUploadFileSelect_" . $this->uniqueId);
122
123 $this->tpl->setVariable("FILE_UPLOAD", $upload->getHTML());
124
125 return $this->tpl->get();
126 }
outputSuffixes($a_tpl, $a_block="allowed_suffixes")
getSuffixes()
Get Accepted Suffixes.
static initFileUpload()
Initializes the file upload and loads the needed javascripts and styles.
static _getIcon( $a_obj_id="", $a_size="big", $a_type="", $a_offline=false)
Get icon for repository item.
special template class to simplify handling of ITX/PEAR
static initjQuery(ilGlobalTemplateInterface $a_tpl=null)
inits and adds the jQuery JS-File to the global or a passed template

References $lng, ilObject\_getIcon(), getInputAcceptSuffixes(), ilFileInputGUI\getSuffixes(), ilFileUploadGUI\initFileUpload(), iljQueryUtil\initjQuery(), and ilFileInputGUI\outputSuffixes().

+ Here is the call graph for this function:

◆ setArchiveSuffixes()

ilDragDropFileInputGUI::setArchiveSuffixes (   $a_suffixes)

Set accepted archive suffixes.

Parameters
array$a_suffixesAccepted archive suffixes.

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

53 {
54 $this->archive_suffixes = $a_suffixes;
55 }

◆ setCommandButtonNames()

ilDragDropFileInputGUI::setCommandButtonNames (   $a_submit_name,
  $a_cancel_name 
)

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

68 {
69 $this->submit_button_name = $a_submit_name;
70 $this->cancel_button_name = $a_cancel_name;
71 }

Field Documentation

◆ $archive_suffixes

ilDragDropFileInputGUI::$archive_suffixes = array()
private

Definition at line 21 of file class.ilDragDropFileInputGUI.php.

Referenced by getArchiveSuffixes().

◆ $cancel_button_name

ilDragDropFileInputGUI::$cancel_button_name = null
private

Definition at line 23 of file class.ilDragDropFileInputGUI.php.

◆ $lng

ilDragDropFileInputGUI::$lng
protected

Definition at line 18 of file class.ilDragDropFileInputGUI.php.

Referenced by checkInput(), and render().

◆ $submit_button_name

ilDragDropFileInputGUI::$submit_button_name = null
private

Definition at line 22 of file class.ilDragDropFileInputGUI.php.

◆ $uniqueId

ilDragDropFileInputGUI::$uniqueId = 0
private

Definition at line 20 of file class.ilDragDropFileInputGUI.php.

◆ $uniqueInc

ilDragDropFileInputGUI::$uniqueInc = 1
staticprivate

Definition at line 25 of file class.ilDragDropFileInputGUI.php.


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