4 include_once
'Services/UIComponent/Toolbar/interfaces/interface.ilToolbarItem.php';
5 include_once(
"./Services/Form/classes/class.ilSubEnabledFormPropertyGUI.php");
39 parent::__construct($a_title, $a_postvar);
65 $this->value = $a_value;
85 $this->size = $a_size;
105 $this->filename = $a_val;
127 $this->suffixes = $a_suffixes;
137 return $this->suffixes;
147 $this->forbidden_suffixes = $a_suffixes;
167 $this->pending = $a_val;
189 $this->filename_selection =
true;
190 $this->filename_post = $a_post_var;
201 return $this->filename_selection ? true :
false;
223 $this->allow_deletion = $a_val;
255 $this->
setAlert($lng->txt(
"form_msg_file_size_exceeds"));
262 include_once(
"./Services/Utilities/classes/class.ilStr.php");
266 while (substr($_FILES[$this->
getPostVar()][
"name"],-1) ==
'/')
272 $filename_arr = pathinfo($_FILES[$this->
getPostVar()][
"name"]);
273 $suffix = $filename_arr[
"extension"];
274 $mimetype = $_FILES[$this->
getPostVar()][
"type"];
275 $size_bytes = $_FILES[$this->
getPostVar()][
"size"];
276 $temp_name = $_FILES[$this->
getPostVar()][
"tmp_name"];
277 $error = $_FILES[$this->
getPostVar()][
"error"];
285 case UPLOAD_ERR_INI_SIZE:
286 $this->
setAlert($lng->txt(
"form_msg_file_size_exceeds"));
290 case UPLOAD_ERR_FORM_SIZE:
291 $this->
setAlert($lng->txt(
"form_msg_file_size_exceeds"));
295 case UPLOAD_ERR_PARTIAL:
296 $this->
setAlert($lng->txt(
"form_msg_file_partially_uploaded"));
300 case UPLOAD_ERR_NO_FILE:
305 $this->
setAlert($lng->txt(
"form_msg_file_no_upload"));
311 case UPLOAD_ERR_NO_TMP_DIR:
312 $this->
setAlert($lng->txt(
"form_msg_file_missing_tmp_dir"));
316 case UPLOAD_ERR_CANT_WRITE:
317 $this->
setAlert($lng->txt(
"form_msg_file_cannot_write_to_disk"));
321 case UPLOAD_ERR_EXTENSION:
322 $this->
setAlert($lng->txt(
"form_msg_file_upload_stopped_ext"));
329 if ($_FILES[$this->
getPostVar()][
"tmp_name"] !=
"")
331 if (is_array($this->forbidden_suffixes) && in_array(strtolower($suffix), $this->forbidden_suffixes))
333 $this->
setAlert($lng->txt(
"form_msg_file_type_is_not_allowed").
" (".$suffix.
")");
338 if (!in_array(strtolower($suffix), $this->
getSuffixes()))
340 $this->
setAlert($lng->txt(
"form_msg_file_wrong_file_type"));
347 if ($_FILES[$this->
getPostVar()][
"tmp_name"] !=
"")
350 if ($vir[0] ==
false)
352 $this->
setAlert($lng->txt(
"form_msg_file_virus_found").
"<br />".$vir[1]);
367 $quota_exceeded = $quota_legend =
false;
368 if(self::$check_wsp_quota)
370 include_once
"Services/DiskQuota/classes/class.ilDiskQuotaHandler.php";
373 $lng->loadLanguageModule(
"file");
374 $quota_exceeded = $lng->txt(
"personal_workspace_quota_exceeded_warning");
382 $f_tpl =
new ilTemplate(
"tpl.prop_file.html",
true,
true,
"Services/Form");
388 $f_tpl->setCurrentBlock(
'filename');
390 $f_tpl->setVariable(
'VAL_FILENAME',$this->
getFilename());
391 $f_tpl->setVariable(
'FILENAME_ID',$this->
getFieldId());
392 $f_tpl->setVAriable(
'TXT_FILENAME_HINT',$lng->txt(
'if_no_title_then_filename'));
393 $f_tpl->parseCurrentBlock();
401 $f_tpl->setCurrentBlock(
"delete_bl");
402 $f_tpl->setVariable(
"POST_VAR_D", $this->
getPostVar());
403 $f_tpl->setVariable(
"TXT_DELETE_EXISTING",
404 $lng->txt(
"delete_existing_file"));
405 $f_tpl->parseCurrentBlock();
408 $f_tpl->setCurrentBlock(
'prop_file_propval');
409 $f_tpl->setVariable(
'FILE_VAL', $this->
getValue());
410 $f_tpl->parseCurrentBlock();
414 if ($a_mode !=
"toolbar")
420 $f_tpl->setCurrentBlock(
"max_size");
421 $f_tpl->setVariable(
"TXT_MAX_SIZE", $lng->txt(
"file_notice").
" ".
423 $f_tpl->parseCurrentBlock();
427 $f_tpl->setVariable(
"TXT_MAX_SIZE", $quota_legend);
428 $f_tpl->parseCurrentBlock();
433 $f_tpl->setCurrentBlock(
"max_size");
434 $f_tpl->setVariable(
"TXT_MAX_SIZE", $quota_exceeded);
435 $f_tpl->parseCurrentBlock();
438 else if($quota_exceeded)
440 return $quota_exceeded;
446 $f_tpl->setCurrentBlock(
"pending");
447 $f_tpl->setVariable(
"TXT_PENDING", $lng->txt(
"file_upload_pending").
449 $f_tpl->parseCurrentBlock();
454 $f_tpl->setVariable(
"DISABLED",
455 " disabled=\"disabled\"");
458 $f_tpl->setVariable(
"POST_VAR", $this->
getPostVar());
459 $f_tpl->setVariable(
"ID", $this->
getFieldId());
460 $f_tpl->setVariable(
"SIZE", $this->
getSize());
462 return $f_tpl->get();
474 $a_tpl->setCurrentBlock(
"prop_generic");
475 $a_tpl->setVariable(
"PROP_GENERIC",
$html);
476 $a_tpl->parseCurrentBlock();
486 $suff_str = $delim =
"";
489 $suff_str.= $delim.
".".$suffix;
492 $a_tpl->setCurrentBlock($a_block);
493 $a_tpl->setVariable(
"TXT_ALLOWED_SUFFIXES",
494 $lng->txt(
"file_allowed_suffixes").
" ".$suff_str);
495 $a_tpl->parseCurrentBlock();
502 $umf = ini_get(
"upload_max_filesize");
504 $pms = ini_get(
"post_max_size");
507 $multiplier_a=array(
"K"=>1024,
"M"=>1024*1024,
"G"=>1024*1024*1024);
509 $umf_parts=preg_split(
"/(\d+)([K|G|M])/", $umf, -1, PREG_SPLIT_DELIM_CAPTURE|PREG_SPLIT_NO_EMPTY);
510 $pms_parts=preg_split(
"/(\d+)([K|G|M])/", $pms, -1, PREG_SPLIT_DELIM_CAPTURE|PREG_SPLIT_NO_EMPTY);
512 if (count($umf_parts) == 2) { $umf = $umf_parts[0]*$multiplier_a[$umf_parts[1]]; }
513 if (count($pms_parts) == 2) { $pms = $pms_parts[0]*$multiplier_a[$pms_parts[1]]; }
516 $max_filesize = min($umf, $pms);
518 if (!$max_filesize) $max_filesize=max($umf, $pms);
521 $max_filesize = sprintf(
"%.1f MB",$max_filesize/1024/1024);
523 return $max_filesize;
551 include_once
"Services/WebDAV/classes/class.ilDiskQuotaActivationChecker.php";
554 self::$check_wsp_quota =
true;
558 self::$check_wsp_quota =
false;
static virusHandling($a_file, $a_orig_name="", $a_clean=true)
scan file for viruses and clean files if possible
static _isPersonalWorkspaceActive()
Static getter.
normalizeUtf8String($a_str)
Normalize UTF8 string.
special template class to simplify handling of ITX/PEAR
static isUploadPossible($a_additional_size=null)
static stripSlashes($a_str, $a_strip_html=true, $a_allow="")
strip slashes if magic qoutes is enabled