ILIAS  release_5-4 Revision v5.4.26-12-gabc799a52e6
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 ilFileInputGUI
static setPersonalWorkspaceQuotaCheck ($a_value)
 
- 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: saml.php:7

References $DIC, and getNextUniqueId().

+ Here is the call graph for this function:

Member Function Documentation

◆ buildSuffixList()

ilDragDropFileInputGUI::buildSuffixList (   $suffixes)
protected

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

194 {
195 $list = $delim = "";
196
197 if (is_array($suffixes) && count($suffixes) > 0) {
198 foreach ($suffixes as $suffix) {
199 $list .= $delim . "\"" . $suffix . "\"";
200 $delim = ", ";
201 }
202 }
203
204 return $list;
205 }
if(isset($_REQUEST['delete'])) $list
Definition: registry.php:41

References $list.

◆ 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 144 of file class.ilDragDropFileInputGUI.php.

145 {
147
148 // if no information is received, something went wrong
149 // this is e.g. the case, if the post_max_size has been exceeded
150 if (!is_array($_FILES[$this->getPostVar()])) {
151 $this->setAlert($lng->txt("form_msg_file_size_exceeds"));
152 return false;
153 }
154
155 // empty file, could be a folder
156 if ($_FILES[$this->getPostVar()]["size"] < 1) {
157 $this->setAlert($lng->txt("error_upload_was_zero_bytes"));
158 return false;
159 }
160
161 // call base
162 $inputValid = parent::checkInput();
163
164 // set additionally sent input on post array
165 if ($inputValid) {
166 $_POST[$this->getPostVar()]["extract"] = isset($_POST["extract"]) ? (bool) $_POST["extract"] : false;
167 $_POST[$this->getPostVar()]["title"] = isset($_POST["title"]) ? $_POST["title"] : "";
168 $_POST[$this->getPostVar()]["description"] = isset($_POST["description"]) ? $_POST["description"] : "";
169 $_POST[$this->getPostVar()]["keep_structure"] = isset($_POST["keep_structure"]) ? (bool) $_POST["keep_structure"] : true;
170
171 include_once("./Services/Utilities/classes/class.ilStr.php");
172 $_POST[$this->getPostVar()]["name"] = ilStr::normalizeUtf8String($_POST[$this->getPostVar()]["name"]);
173 $_POST[$this->getPostVar()]["title"] = ilStr::normalizeUtf8String($_POST[$this->getPostVar()]["title"]);
174 }
175
176 return $inputValid;
177 }
$_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 179 of file class.ilDragDropFileInputGUI.php.

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

References $list.

Referenced by render().

+ Here is the caller graph for this function:

◆ getMaxFileSize()

ilDragDropFileInputGUI::getMaxFileSize ( )
protected

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

208 {
209 // get the value for the maximal uploadable filesize from the php.ini (if available)
210 $umf = ini_get("upload_max_filesize");
211 // get the value for the maximal post data from the php.ini (if available)
212 $pms = ini_get("post_max_size");
213
214 //convert from short-string representation to "real" bytes
215 $multiplier_a = array("K" => 1024, "M" => 1024 * 1024, "G" => 1024 * 1024 * 1024);
216
217 $umf_parts = preg_split("/(\d+)([K|G|M])/", $umf, -1, PREG_SPLIT_DELIM_CAPTURE | PREG_SPLIT_NO_EMPTY);
218 $pms_parts = preg_split("/(\d+)([K|G|M])/", $pms, -1, PREG_SPLIT_DELIM_CAPTURE | PREG_SPLIT_NO_EMPTY);
219
220 if (count($umf_parts) == 2) {
221 $umf = $umf_parts[0] * $multiplier_a[$umf_parts[1]];
222 }
223 if (count($pms_parts) == 2) {
224 $pms = $pms_parts[0] * $multiplier_a[$pms_parts[1]];
225 }
226
227 // use the smaller one as limit
228 $max_filesize = min($umf, $pms);
229
230 if (!$max_filesize) {
231 $max_filesize = max($umf, $pms);
232 }
233
234 return $max_filesize;
235 }
echo;exit;}function LogoutNotification($SessionID){ global $ilDB;$q="SELECT session_id, data FROM usr_session WHERE expires > (\w+)\|/" PREG_SPLIT_NO_EMPTY PREG_SPLIT_DELIM_CAPTURE

References PREG_SPLIT_DELIM_CAPTURE.

◆ 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 $quota_exceeded = $quota_legend = false;
81 if (self::$check_wsp_quota) {
82 include_once "Services/DiskQuota/classes/class.ilDiskQuotaHandler.php";
84 $lng->loadLanguageModule("file");
85 return $lng->txt("personal_workspace_quota_exceeded_warning");
86 } else {
88 }
89 }
90
91 // make sure jQuery is loaded
93
94 // add file upload scripts
95 include_once("./Services/FileUpload/classes/class.ilFileUploadGUI.php");
97
98 // load template
99 $this->tpl = new ilTemplate("tpl.prop_dndfiles.html", true, true, "Services/Form");
100
101 // general variables
102 $this->tpl->setVariable("UPLOAD_ID", $this->uniqueId);
103
104 // input
105 $this->tpl->setVariable("FILE_SELECT_ICON", ilObject::_getIcon("", "", "fold"));
106 $this->tpl->setVariable("TXT_SHOW_ALL_DETAILS", $lng->txt('show_all_details'));
107 $this->tpl->setVariable("TXT_HIDE_ALL_DETAILS", $lng->txt('hide_all_details'));
108 $this->tpl->setVariable("TXT_SELECTED_FILES", $lng->txt('selected_files'));
109 $this->tpl->setVariable("TXT_DRAG_FILES_HERE", $lng->txt('drag_files_here'));
110 $this->tpl->setVariable("TXT_NUM_OF_SELECTED_FILES", $lng->txt('num_of_selected_files'));
111 $this->tpl->setVariable("TXT_SELECT_FILES_FROM_COMPUTER", $lng->txt('select_files_from_computer'));
112 $this->tpl->setVariable("TXT_OR", $lng->txt('logic_or'));
113 $this->tpl->setVariable("INPUT_ACCEPT_SUFFIXES", $this->getInputAcceptSuffixes($this->getSuffixes()));
114
115 // info
116 $this->tpl->setCurrentBlock("max_size");
117 $this->tpl->setVariable("TXT_MAX_SIZE", $lng->txt("file_notice") . " " . $this->getMaxFileSizeString());
118 $this->tpl->parseCurrentBlock();
119
120 if ($quota_legend) {
121 $this->tpl->setVariable("TXT_MAX_SIZE", $quota_legend);
122 $this->tpl->parseCurrentBlock();
123 }
124
125 $this->outputSuffixes($this->tpl);
126
127 // create file upload object
128 $upload = new ilFileUploadGUI("ilFileUploadDropZone_" . $this->uniqueId, $this->uniqueId, false);
129 $upload->enableFormSubmit("ilFileUploadInput_" . $this->uniqueId, $this->submit_button_name, $this->cancel_button_name);
130 $upload->setDropAreaId("ilFileUploadDropArea_" . $this->uniqueId);
131 $upload->setFileListId("ilFileUploadList_" . $this->uniqueId);
132 $upload->setFileSelectButtonId("ilFileUploadFileSelect_" . $this->uniqueId);
133
134 $this->tpl->setVariable("FILE_UPLOAD", $upload->getHTML());
135
136 return $this->tpl->get();
137 }
static isUploadPossible($a_additional_size=null)
outputSuffixes($a_tpl, $a_block="allowed_suffixes")
getSuffixes()
Get Accepted Suffixes.
static initFileUpload()
Initializes the file upload and loads the needed javascripts and styles.
special template class to simplify handling of ITX/PEAR
static initjQuery($a_tpl=null)
inits and adds the jQuery JS-File to the global or a passed template

References $lng, getInputAcceptSuffixes(), ilDiskQuotaHandler\getStatusLegend(), ilFileInputGUI\getSuffixes(), ilFileUploadGUI\initFileUpload(), iljQueryUtil\initjQuery(), ilDiskQuotaHandler\isUploadPossible(), 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: