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;
250 $filename_arr = pathinfo($_FILES[$this->
getPostVar()][
"name"]);
251 $suffix = $filename_arr[
"extension"];
252 $mimetype = $_FILES[$this->
getPostVar()][
"type"];
253 $size_bytes = $_FILES[$this->
getPostVar()][
"size"];
254 $temp_name = $_FILES[$this->
getPostVar()][
"tmp_name"];
255 $error = $_FILES[$this->
getPostVar()][
"error"];
262 $this->
setAlert($lng->txt(
"form_msg_file_size_exceeds"));
271 case UPLOAD_ERR_INI_SIZE:
272 $this->
setAlert($lng->txt(
"form_msg_file_size_exceeds"));
276 case UPLOAD_ERR_FORM_SIZE:
277 $this->
setAlert($lng->txt(
"form_msg_file_size_exceeds"));
281 case UPLOAD_ERR_PARTIAL:
282 $this->
setAlert($lng->txt(
"form_msg_file_partially_uploaded"));
286 case UPLOAD_ERR_NO_FILE:
291 $this->
setAlert($lng->txt(
"form_msg_file_no_upload"));
297 case UPLOAD_ERR_NO_TMP_DIR:
298 $this->
setAlert($lng->txt(
"form_msg_file_missing_tmp_dir"));
302 case UPLOAD_ERR_CANT_WRITE:
303 $this->
setAlert($lng->txt(
"form_msg_file_cannot_write_to_disk"));
307 case UPLOAD_ERR_EXTENSION:
308 $this->
setAlert($lng->txt(
"form_msg_file_upload_stopped_ext"));
315 if ($_FILES[$this->
getPostVar()][
"tmp_name"] !=
"")
317 if (is_array($this->forbidden_suffixes) && in_array(strtolower($suffix), $this->forbidden_suffixes))
319 $this->
setAlert($lng->txt(
"form_msg_file_type_is_not_allowed").
" (".$suffix.
")");
324 if (!in_array(strtolower($suffix), $this->
getSuffixes()))
326 $this->
setAlert($lng->txt(
"form_msg_file_wrong_file_type"));
333 if ($_FILES[$this->
getPostVar()][
"tmp_name"] !=
"")
336 if ($vir[0] ==
false)
338 $this->
setAlert($lng->txt(
"form_msg_file_virus_found").
"<br />".$vir[1]);
353 $quota_exceeded = $quota_legend =
false;
354 if(self::$check_wsp_quota)
356 include_once
"Services/DiskQuota/classes/class.ilDiskQuotaHandler.php";
359 $lng->loadLanguageModule(
"file");
360 $quota_exceeded = $lng->txt(
"personal_workspace_quota_exceeded_warning");
368 $f_tpl =
new ilTemplate(
"tpl.prop_file.html",
true,
true,
"Services/Form");
374 $f_tpl->setCurrentBlock(
'filename');
376 $f_tpl->setVariable(
'VAL_FILENAME',$this->
getFilename());
377 $f_tpl->setVariable(
'FILENAME_ID',$this->
getFieldId());
378 $f_tpl->setVAriable(
'TXT_FILENAME_HINT',$lng->txt(
'if_no_title_then_filename'));
379 $f_tpl->parseCurrentBlock();
387 $f_tpl->setCurrentBlock(
"delete_bl");
388 $f_tpl->setVariable(
"POST_VAR_D", $this->
getPostVar());
389 $f_tpl->setVariable(
"TXT_DELETE_EXISTING",
390 $lng->txt(
"delete_existing_file"));
391 $f_tpl->parseCurrentBlock();
394 $f_tpl->setCurrentBlock(
'prop_file_propval');
395 $f_tpl->setVariable(
'FILE_VAL', $this->
getValue());
396 $f_tpl->parseCurrentBlock();
400 if ($a_mode !=
"toolbar")
406 $f_tpl->setCurrentBlock(
"max_size");
407 $f_tpl->setVariable(
"TXT_MAX_SIZE", $lng->txt(
"file_notice").
" ".
409 $f_tpl->parseCurrentBlock();
413 $f_tpl->setVariable(
"TXT_MAX_SIZE", $quota_legend);
414 $f_tpl->parseCurrentBlock();
419 $f_tpl->setCurrentBlock(
"max_size");
420 $f_tpl->setVariable(
"TXT_MAX_SIZE", $quota_exceeded);
421 $f_tpl->parseCurrentBlock();
424 else if($quota_exceeded)
426 return $quota_exceeded;
432 $f_tpl->setCurrentBlock(
"pending");
433 $f_tpl->setVariable(
"TXT_PENDING", $lng->txt(
"file_upload_pending").
435 $f_tpl->parseCurrentBlock();
440 $f_tpl->setVariable(
"DISABLED",
441 " disabled=\"disabled\"");
444 $f_tpl->setVariable(
"POST_VAR", $this->
getPostVar());
445 $f_tpl->setVariable(
"ID", $this->
getFieldId());
446 $f_tpl->setVariable(
"SIZE", $this->
getSize());
448 return $f_tpl->get();
460 $a_tpl->setCurrentBlock(
"prop_generic");
461 $a_tpl->setVariable(
"PROP_GENERIC", $html);
462 $a_tpl->parseCurrentBlock();
472 $suff_str = $delim =
"";
475 $suff_str.= $delim.
".".$suffix;
478 $a_tpl->setCurrentBlock($a_block);
479 $a_tpl->setVariable(
"TXT_ALLOWED_SUFFIXES",
480 $lng->txt(
"file_allowed_suffixes").
" ".$suff_str);
481 $a_tpl->parseCurrentBlock();
488 $umf = ini_get(
"upload_max_filesize");
490 $pms = ini_get(
"post_max_size");
493 $multiplier_a=array(
"K"=>1024,
"M"=>1024*1024,
"G"=>1024*1024*1024);
495 $umf_parts=preg_split(
"/(\d+)([K|G|M])/", $umf, -1, PREG_SPLIT_DELIM_CAPTURE|PREG_SPLIT_NO_EMPTY);
496 $pms_parts=preg_split(
"/(\d+)([K|G|M])/", $pms, -1, PREG_SPLIT_DELIM_CAPTURE|PREG_SPLIT_NO_EMPTY);
498 if (count($umf_parts) == 2) { $umf = $umf_parts[0]*$multiplier_a[$umf_parts[1]]; }
499 if (count($pms_parts) == 2) { $pms = $pms_parts[0]*$multiplier_a[$pms_parts[1]]; }
502 $max_filesize = min($umf, $pms);
504 if (!$max_filesize) $max_filesize=max($umf, $pms);
507 $max_filesize = sprintf(
"%.1f MB",$max_filesize/1024/1024);
509 return $max_filesize;
529 $html = $this->
render(
"toolbar");
537 include_once
"Services/WebDAV/classes/class.ilDiskQuotaActivationChecker.php";
540 self::$check_wsp_quota =
true;
544 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.
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