4 require_once(
"./Services/FileUpload/classes/class.ilFileUploadUtil.php");
5 require_once(
"./Services/FileUpload/classes/class.ilFileUploadSettings.php");
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");
98 if ($this->ref_id != null && !$this->use_form) {
106 if ($this->input_field_id != null) {
108 } elseif ($this->input_field_name != null) {
113 if ($this->submit_button_name != null) {
116 if ($this->cancel_button_name != null) {
121 if ($this->drop_area_id != null) {
126 if ($this->file_list_id != null) {
131 if ($this->file_select_button_id != null) {
137 if ($max_size != null) {
143 if ($allowed_suffixes !=
"") {
144 $options->allowedExtensions =
"[" . $allowed_suffixes .
"]";
149 if ($supported_archives !=
"") {
150 $options->supportedArchives =
"[" . $supported_archives .
"]";
154 include_once(
"./Services/JSON/classes/class.ilJsonUtil.php");
157 if ($this->use_form) {
160 $onLoadCode =
"il.FileUpload.add(\"$id\", " .
ilJsonUtil::encode(
$options) .
", " . ($this->current_obj ?
"true" :
"false") .
");";
163 $tpl->addOnLoadCode($onLoadCode);
180 if (self::$shared_code_loaded) {
185 self::initFileUpload();
188 $tpl_shared =
new ilTemplate(
"tpl.fileupload_shared.html",
true,
true,
"Services/FileUpload");
191 $lng->loadLanguageModule(
"form");
192 $tpl_shared->setCurrentBlock(
"fileupload_texts");
193 $tpl_shared->setVariable(
"ERROR_MSG_FILE_TOO_LARGE",
$lng->txt(
"form_msg_file_size_exceeds"));
194 $tpl_shared->setVariable(
"ERROR_MSG_WRONG_FILE_TYPE",
$lng->txt(
"form_msg_file_wrong_file_type"));
195 $tpl_shared->setVariable(
"ERROR_MSG_EMPTY_FILE_OR_FOLDER",
$lng->txt(
"error_empty_file_or_folder"));
196 $tpl_shared->setVariable(
"ERROR_MSG_UPLOAD_ZERO_BYTES",
$lng->txt(
"error_upload_was_zero_bytes"));
197 $tpl_shared->setVariable(
"QUESTION_CANCEL_ALL",
$lng->txt(
"cancel_file_upload"));
198 $tpl_shared->setVariable(
"ERROR_MSG_EXTRACT_FAILED",
$lng->txt(
"error_extraction_failed"));
199 $tpl_shared->setVariable(
"PROGRESS_UPLOADING",
$lng->txt(
"uploading"));
200 $tpl_shared->setVariable(
"PROGRESS_EXTRACTING",
$lng->txt(
"extracting"));
201 $tpl_shared->setVariable(
"DROP_FILES_HERE",
$lng->txt(
"drop_files_on_repo_obj_info"));
202 $tpl_shared->parseCurrentBlock();
205 $tpl_shared->setCurrentBlock(
"fileupload_defaults");
208 $tpl_shared->setVariable(
"ALLOWED_SUFFIXES",
"");
209 $tpl_shared->setVariable(
"SUPPORTED_ARCHIVES",
"\"zip\"");
210 $tpl_shared->parseCurrentBlock();
213 $tpl_panel =
new ilTemplate(
"tpl.fileupload_panel_template.html",
true,
true,
"Services/FileUpload");
214 $tpl_panel->setVariable(
"TXT_HEADER",
$lng->txt(
"upload_files_title"));
215 $tpl_panel->setVariable(
"TXT_SHOW_ALL_DETAILS",
$lng->txt(
'show_all_details'));
216 $tpl_panel->setVariable(
"TXT_HIDE_ALL_DETAILS",
$lng->txt(
'hide_all_details'));
217 $tpl_panel->setVariable(
"TXT_SUBMIT",
$lng->txt(
'upload_files'));
218 $tpl_panel->setVariable(
"TXT_CANCEL",
$lng->txt(
'cancel'));
220 $tpl_shared->setCurrentBlock(
"fileupload_panel_tmpl");
221 $tpl_shared->setVariable(
"PANEL_TEMPLATE_HTML", $tpl_panel->get());
222 $tpl_shared->parseCurrentBlock();
225 $tpl_row =
new ilTemplate(
"tpl.fileupload_row_template.html",
true,
true,
"Services/FileUpload");
227 $tpl_row->setVariable(
"ALT_ALERT",
$lng->txt(
"alert"));
228 $tpl_row->setVariable(
"TXT_CANCEL",
$lng->txt(
"cancel"));
229 $tpl_row->setVariable(
"TXT_REMOVE",
$lng->txt(
"remove"));
230 $tpl_row->setVariable(
"TXT_TITLE",
$lng->txt(
"title"));
231 $tpl_row->setVariable(
"TXT_DESCRIPTION",
$lng->txt(
"description"));
232 $tpl_row->setVariable(
"TXT_EXTRACT",
$lng->txt(
"unzip"));
233 $tpl_row->setVariable(
"TXT_KEEP_STRUCTURE",
$lng->txt(
"take_over_structure"));
234 $tpl_row->setVariable(
"TXT_KEEP_STRUCTURE_INFO",
$lng->txt(
"take_over_structure_info"));
235 $tpl_row->setVariable(
"TXT_PENDING",
$lng->txt(
"upload_pending"));
237 $tpl_shared->setCurrentBlock(
"fileupload_row_tmpl");
238 $tpl_shared->setVariable(
"ROW_TEMPLATE_HTML", $tpl_row->get());
239 $tpl_shared->parseCurrentBlock();
242 self::$shared_code_loaded =
true;
245 return $tpl_shared->get();
254 $list .= $delim .
"\"" . $suffix .
"\"";
264 $this->use_form =
true;
266 $this->submit_button_name = $a_submit_name;
267 $this->cancel_button_name = $a_cancel_name;
277 $this->max_file_size = $a_max;
295 $this->archive_suffixes = $a_suffixes;
315 $this->suffixes = $a_suffixes;
335 $this->input_field_name = $a_name;
350 $this->drop_area_id = $a_id;
360 $this->file_list_id = $a_id;
370 $this->file_select_button_id = $a_id;
384 if ($this->use_form) {
394 include_once(
"Modules/File/classes/class.ilObjFileGUI.php");
395 $ilCtrl->setParameterByClass(self::FILE_OBJ_GUI_CLASS,
"ref_id", $this->ref_id);
396 $ilCtrl->setParameterByClass(self::FILE_OBJ_GUI_CLASS,
"new_type",
"file");
398 return $ilCtrl->getFormActionByClass(self::FILE_OBJ_GUI_CLASS,
"uploadFiles",
"",
true,
false);
407 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
if(isset($_REQUEST['delete'])) $list
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.
if(!array_key_exists('StateId', $_REQUEST)) $id
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)
special template class to simplify handling of ITX/PEAR
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)
getSharedHtml()
Gets the code that is shared by all upload instances.
setFileSelectButtonId($a_id)
getHTML()
Gets the HTML code to enable the file upload.