4 require_once(
"./Services/FileUpload/classes/class.ilFileUploadUtil.php");
5 require_once(
"./Services/FileUpload/classes/class.ilFileUploadSettings.php");
41 $ilCtrl = $DIC[
'ilCtrl'];
43 $this->drop_zone_id = $a_drop_zone_id;
44 $this->ref_id = $a_ref_id;
57 $tpl->addJavaScript(
"./Services/FileUpload/js/tmpl.js");
58 $tpl->addJavaScript(
"./Services/FileUpload/js/jquery.ui.widget.js");
59 $tpl->addJavaScript(
"./Services/FileUpload/js/jquery.iframe-transport.js");
60 $tpl->addJavaScript(
"./Services/FileUpload/js/jquery.fileupload.js");
61 $tpl->addJavaScript(
"./Services/FileUpload/js/jquery.ba-dotimeout.min.js");
62 $tpl->addJavaScript(
"./Services/FileUpload/js/ilFileUpload.js",
true, 3);
76 $ilCtrl = $DIC[
'ilCtrl'];
84 $options->dropZone = $this->
makeJqueryId($this->drop_zone_id);
97 if ($this->ref_id != null && !$this->use_form) {
99 $title = str_replace(
"\"",
""", $title);
100 $title = str_replace(
"'",
"'", $title);
101 $options->listTitle = $title;
105 if ($this->input_field_id != null) {
106 $options->fileInput = $this->
makeJqueryId($this->input_field_id);
107 } elseif ($this->input_field_name != null) {
112 if ($this->submit_button_name != null) {
115 if ($this->cancel_button_name != null) {
120 if ($this->drop_area_id != null) {
121 $options->dropArea = $this->
makeJqueryId($this->drop_area_id);
125 if ($this->file_list_id != null) {
126 $options->fileList = $this->
makeJqueryId($this->file_list_id);
130 if ($this->file_select_button_id != null) {
131 $options->fileSelectButton = $this->
makeJqueryId($this->file_select_button_id);
136 if ($max_size != null) {
137 $options->maxFileSize = $max_size;
142 if ($allowed_suffixes !=
"") {
143 $options->allowedExtensions =
"[" . $allowed_suffixes .
"]";
148 if ($supported_archives !=
"") {
149 $options->supportedArchives =
"[" . $supported_archives .
"]";
153 include_once(
"./Services/JSON/classes/class.ilJsonUtil.php");
156 if ($this->use_form) {
157 $onLoadCode =
"var fileUpload$id = new ilFileUpload($id, " .
ilJsonUtil::encode($options) .
");";
159 $onLoadCode =
"il.FileUpload.add(\"$id\", " .
ilJsonUtil::encode($options) .
", " . ($this->current_obj ?
"true" :
"false") .
");";
162 $tpl->addOnLoadCode($onLoadCode);
179 if (self::$shared_code_loaded) {
184 self::initFileUpload();
187 $tpl_shared =
new ilTemplate(
"tpl.fileupload_shared.html",
true,
true,
"Services/FileUpload");
190 $lng->loadLanguageModule(
"form");
191 $tpl_shared->setCurrentBlock(
"fileupload_texts");
192 $tpl_shared->setVariable(
"ERROR_MSG_FILE_TOO_LARGE",
$lng->txt(
"form_msg_file_size_exceeds"));
193 $tpl_shared->setVariable(
"ERROR_MSG_WRONG_FILE_TYPE",
$lng->txt(
"form_msg_file_wrong_file_type"));
194 $tpl_shared->setVariable(
"ERROR_MSG_EMPTY_FILE_OR_FOLDER",
$lng->txt(
"error_empty_file_or_folder"));
195 $tpl_shared->setVariable(
"ERROR_MSG_UPLOAD_ZERO_BYTES",
$lng->txt(
"error_upload_was_zero_bytes"));
196 $tpl_shared->setVariable(
"QUESTION_CANCEL_ALL",
$lng->txt(
"cancel_file_upload"));
197 $tpl_shared->setVariable(
"ERROR_MSG_EXTRACT_FAILED",
$lng->txt(
"error_extraction_failed"));
198 $tpl_shared->setVariable(
"PROGRESS_UPLOADING",
$lng->txt(
"uploading"));
199 $tpl_shared->setVariable(
"PROGRESS_EXTRACTING",
$lng->txt(
"extracting"));
200 $tpl_shared->setVariable(
"DROP_FILES_HERE",
$lng->txt(
"drop_files_on_repo_obj_info"));
201 $tpl_shared->parseCurrentBlock();
204 $tpl_shared->setCurrentBlock(
"fileupload_defaults");
207 $tpl_shared->setVariable(
"ALLOWED_SUFFIXES",
"");
208 $tpl_shared->setVariable(
"SUPPORTED_ARCHIVES",
"\"zip\"");
209 $tpl_shared->parseCurrentBlock();
212 $tpl_panel =
new ilTemplate(
"tpl.fileupload_panel_template.html",
true,
true,
"Services/FileUpload");
213 $tpl_panel->setVariable(
"TXT_HEADER",
$lng->txt(
"upload_files_title"));
214 $tpl_panel->setVariable(
"TXT_SHOW_ALL_DETAILS",
$lng->txt(
'show_all_details'));
215 $tpl_panel->setVariable(
"TXT_HIDE_ALL_DETAILS",
$lng->txt(
'hide_all_details'));
216 $tpl_panel->setVariable(
"TXT_SUBMIT",
$lng->txt(
'upload_files'));
217 $tpl_panel->setVariable(
"TXT_CANCEL",
$lng->txt(
'cancel'));
219 $tpl_shared->setCurrentBlock(
"fileupload_panel_tmpl");
220 $tpl_shared->setVariable(
"PANEL_TEMPLATE_HTML", $tpl_panel->get());
221 $tpl_shared->parseCurrentBlock();
224 $tpl_row =
new ilTemplate(
"tpl.fileupload_row_template.html",
true,
true,
"Services/FileUpload");
226 $tpl_row->setVariable(
"ALT_ALERT",
$lng->txt(
"alert"));
227 $tpl_row->setVariable(
"TXT_CANCEL",
$lng->txt(
"cancel"));
228 $tpl_row->setVariable(
"TXT_REMOVE",
$lng->txt(
"remove"));
229 $tpl_row->setVariable(
"TXT_TITLE",
$lng->txt(
"title"));
230 $tpl_row->setVariable(
"TXT_DESCRIPTION",
$lng->txt(
"description"));
231 $tpl_row->setVariable(
"TXT_EXTRACT",
$lng->txt(
"unzip"));
232 $tpl_row->setVariable(
"TXT_KEEP_STRUCTURE",
$lng->txt(
"take_over_structure"));
233 $tpl_row->setVariable(
"TXT_KEEP_STRUCTURE_INFO",
$lng->txt(
"take_over_structure_info"));
234 $tpl_row->setVariable(
"TXT_PENDING",
$lng->txt(
"upload_pending"));
236 $tpl_shared->setCurrentBlock(
"fileupload_row_tmpl");
237 $tpl_shared->setVariable(
"ROW_TEMPLATE_HTML", $tpl_row->get());
238 $tpl_shared->parseCurrentBlock();
241 self::$shared_code_loaded =
true;
244 return $tpl_shared->get();
253 $list .= $delim .
"\"" . $suffix .
"\"";
263 $this->use_form =
true;
265 $this->submit_button_name = $a_submit_name;
266 $this->cancel_button_name = $a_cancel_name;
276 $this->max_file_size = $a_max;
294 $this->archive_suffixes = $a_suffixes;
314 $this->suffixes = $a_suffixes;
334 $this->input_field_name = $a_name;
349 $this->drop_area_id = $a_id;
359 $this->file_list_id = $a_id;
369 $this->file_select_button_id = $a_id;
380 $ilCtrl = $DIC[
'ilCtrl'];
383 if ($this->use_form) {
393 include_once(
"Modules/File/classes/class.ilObjFileGUI.php");
394 $ilCtrl->setParameterByClass(self::FILE_OBJ_GUI_CLASS,
"ref_id", $this->ref_id);
395 $ilCtrl->setParameterByClass(self::FILE_OBJ_GUI_CLASS,
"new_type",
"file");
397 return $ilCtrl->getFormActionByClass(self::FILE_OBJ_GUI_CLASS,
"uploadFiles",
"",
true,
false);
406 if (is_string($a_id) && strlen($a_id) > 0 && $a_id[0] !==
'#') {
static initFileUpload()
Initializes the file upload and loads the needed javascripts and styles.
setSuffixes($a_suffixes)
Set accepted suffixes.
static $shared_code_loaded
static getStyleSheetLocation($mode="output", $a_css_name="", $a_css_location="")
get full style sheet file name (path inclusive) of current user
static getConcurrentUploads()
Gets the number of files that can be uploaded at the same time.
setInputFieldName($a_name)
Sets the name of the input field the files are submitted with.
enableFormSubmit($input_field_id, $a_submit_name, $a_cancel_name)
static _lookupTitle($a_id)
lookup object title
__construct($a_drop_zone_id, $a_ref_id=null, $current_obj=false)
Creates a new file upload GUI.
getMaxFileSize()
Gets the maximum file size in bytes.
static getMaxFileSize()
Gets the maximum upload file size allowed in bytes.
setMaxFileSize($a_max)
Sets the maximum file size in bytes.
static encode($mixed, $suppress_native=false)
static getImagePath($img, $module_path="", $mode="output", $offline=false)
get image path (for images located in a template directory)
static _lookupObjId($a_id)
setArchiveSuffixes($a_suffixes)
Set accepted archive suffixes.
getArchiveSuffixes()
Get accepted archive suffixes.
getInputFieldName()
Gets the name of the input field the files are submitted with.
static isUploadSupported()
Determines whether file upload is supported at the current location.
getSuffixes()
Get accepted suffixes.
buildSuffixList($suffixes)
if($DIC->http() ->request() ->getMethod()=="GET" &&isset($DIC->http() ->request() ->getQueryParams()['tex'])) $tpl
getSharedHtml()
Gets the code that is shared by all upload instances.
setFileSelectButtonId($a_id)
getHTML()
Gets the HTML code to enable the file upload.