4 include_once
'Services/UIComponent/Toolbar/interfaces/interface.ilToolbarItem.php';
5 include_once(
"./Services/Form/classes/class.ilSubEnabledFormPropertyGUI.php");
60 $this->value = $a_value;
80 $this->size = $a_size;
100 $this->filename = $a_val;
122 $this->suffixes = $a_suffixes;
132 return $this->suffixes;
142 $this->pending = $a_val;
164 $this->filename_selection =
true;
165 $this->filename_post = $a_post_var;
176 return $this->filename_selection ?
true :
false;
198 $this->allow_deletion = $a_val;
225 $filename_arr = pathinfo($_FILES[$this->
getPostVar()][
"name"]);
226 $suffix = $filename_arr[
"extension"];
227 $mimetype = $_FILES[$this->
getPostVar()][
"type"];
228 $size_bytes = $_FILES[$this->
getPostVar()][
"size"];
229 $temp_name = $_FILES[$this->
getPostVar()][
"tmp_name"];
230 $error = $_FILES[$this->
getPostVar()][
"error"];
237 $this->
setAlert($lng->txt(
"form_msg_file_size_exceeds"));
246 case UPLOAD_ERR_INI_SIZE:
247 $this->
setAlert($lng->txt(
"form_msg_file_size_exceeds"));
251 case UPLOAD_ERR_FORM_SIZE:
252 $this->
setAlert($lng->txt(
"form_msg_file_size_exceeds"));
256 case UPLOAD_ERR_PARTIAL:
257 $this->
setAlert($lng->txt(
"form_msg_file_partially_uploaded"));
261 case UPLOAD_ERR_NO_FILE:
266 $this->
setAlert($lng->txt(
"form_msg_file_no_upload"));
272 case UPLOAD_ERR_NO_TMP_DIR:
273 $this->
setAlert($lng->txt(
"form_msg_file_missing_tmp_dir"));
277 case UPLOAD_ERR_CANT_WRITE:
278 $this->
setAlert($lng->txt(
"form_msg_file_cannot_write_to_disk"));
282 case UPLOAD_ERR_EXTENSION:
283 $this->
setAlert($lng->txt(
"form_msg_file_upload_stopped_ext"));
290 if ($_FILES[$this->
getPostVar()][
"tmp_name"] !=
"" &&
293 if (!in_array(strtolower($suffix), $this->
getSuffixes()))
295 $this->
setAlert($lng->txt(
"form_msg_file_wrong_file_type"));
301 if ($_FILES[$this->
getPostVar()][
"tmp_name"] !=
"")
304 if ($vir[0] ==
false)
306 $this->
setAlert($lng->txt(
"form_msg_file_virus_found").
"<br />".$vir[1]);
321 $quota_exceeded = $quota_legend =
false;
322 if(self::$check_wsp_quota)
324 include_once
"Services/DiskQuota/classes/class.ilDiskQuotaHandler.php";
327 $lng->loadLanguageModule(
"file");
328 $quota_exceeded = $lng->txt(
"personal_workspace_quota_exceeded_warning");
336 $f_tpl =
new ilTemplate(
"tpl.prop_file.html",
true,
true,
"Services/Form");
342 $f_tpl->setCurrentBlock(
'filename');
344 $f_tpl->setVariable(
'VAL_FILENAME',$this->
getFilename());
345 $f_tpl->setVariable(
'FILENAME_ID',$this->
getFieldId());
346 $f_tpl->setVAriable(
'TXT_FILENAME_HINT',$lng->txt(
'if_no_title_then_filename'));
347 $f_tpl->parseCurrentBlock();
355 $f_tpl->setCurrentBlock(
"delete_bl");
356 $f_tpl->setVariable(
"POST_VAR_D", $this->
getPostVar());
357 $f_tpl->setVariable(
"TXT_DELETE_EXISTING",
358 $lng->txt(
"delete_existing_file"));
359 $f_tpl->parseCurrentBlock();
362 $f_tpl->setCurrentBlock(
'prop_file_propval');
363 $f_tpl->setVariable(
'FILE_VAL', $this->
getValue());
364 $f_tpl->parseCurrentBlock();
368 if ($a_mode !=
"toolbar")
374 $f_tpl->setCurrentBlock(
"max_size");
375 $f_tpl->setVariable(
"TXT_MAX_SIZE", $lng->txt(
"file_notice").
" ".
377 $f_tpl->parseCurrentBlock();
381 $f_tpl->setVariable(
"TXT_MAX_SIZE", $quota_legend);
382 $f_tpl->parseCurrentBlock();
387 $f_tpl->setCurrentBlock(
"max_size");
388 $f_tpl->setVariable(
"TXT_MAX_SIZE", $quota_exceeded);
389 $f_tpl->parseCurrentBlock();
392 else if($quota_exceeded)
394 return $quota_exceeded;
400 $f_tpl->setCurrentBlock(
"pending");
401 $f_tpl->setVariable(
"TXT_PENDING", $lng->txt(
"file_upload_pending").
403 $f_tpl->parseCurrentBlock();
408 $f_tpl->setVariable(
"DISABLED",
409 " disabled=\"disabled\"");
412 $f_tpl->setVariable(
"POST_VAR", $this->
getPostVar());
413 $f_tpl->setVariable(
"ID", $this->
getFieldId());
414 $f_tpl->setVariable(
"SIZE", $this->
getSize());
416 return $f_tpl->get();
428 $a_tpl->setCurrentBlock(
"prop_generic");
429 $a_tpl->setVariable(
"PROP_GENERIC", $html);
430 $a_tpl->parseCurrentBlock();
440 $suff_str = $delim =
"";
443 $suff_str.= $delim.
".".$suffix;
446 $a_tpl->setCurrentBlock($a_block);
447 $a_tpl->setVariable(
"TXT_ALLOWED_SUFFIXES",
448 $lng->txt(
"file_allowed_suffixes").
" ".$suff_str);
449 $a_tpl->parseCurrentBlock();
456 $umf = ini_get(
"upload_max_filesize");
458 $pms = ini_get(
"post_max_size");
461 $multiplier_a=array(
"K"=>1024,
"M"=>1024*1024,
"G"=>1024*1024*1024);
463 $umf_parts=preg_split(
"/(\d+)([K|G|M])/", $umf, -1, PREG_SPLIT_DELIM_CAPTURE|PREG_SPLIT_NO_EMPTY);
464 $pms_parts=preg_split(
"/(\d+)([K|G|M])/", $pms, -1, PREG_SPLIT_DELIM_CAPTURE|PREG_SPLIT_NO_EMPTY);
466 if (count($umf_parts) == 2) { $umf = $umf_parts[0]*$multiplier_a[$umf_parts[1]]; }
467 if (count($pms_parts) == 2) { $pms = $pms_parts[0]*$multiplier_a[$pms_parts[1]]; }
470 $max_filesize = min($umf, $pms);
472 if (!$max_filesize) $max_filesize=max($umf, $pms);
475 $max_filesize = sprintf(
"%.1f MB",$max_filesize/1024/1024);
477 return $max_filesize;
497 $html = $this->
render(
"toolbar");
505 include_once
"Services/WebDAV/classes/class.ilDiskQuotaActivationChecker.php";
508 self::$check_wsp_quota =
true;
512 self::$check_wsp_quota =
false;