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;
223 while (substr($_FILES[$this->
getPostVar()][
"name"],-1) ==
'/')
229 $filename_arr = pathinfo($_FILES[$this->
getPostVar()][
"name"]);
230 $suffix = $filename_arr[
"extension"];
231 $mimetype = $_FILES[$this->
getPostVar()][
"type"];
232 $size_bytes = $_FILES[$this->
getPostVar()][
"size"];
233 $temp_name = $_FILES[$this->
getPostVar()][
"tmp_name"];
234 $error = $_FILES[$this->
getPostVar()][
"error"];
241 $this->
setAlert($lng->txt(
"form_msg_file_size_exceeds"));
250 case UPLOAD_ERR_INI_SIZE:
251 $this->
setAlert($lng->txt(
"form_msg_file_size_exceeds"));
255 case UPLOAD_ERR_FORM_SIZE:
256 $this->
setAlert($lng->txt(
"form_msg_file_size_exceeds"));
260 case UPLOAD_ERR_PARTIAL:
261 $this->
setAlert($lng->txt(
"form_msg_file_partially_uploaded"));
265 case UPLOAD_ERR_NO_FILE:
270 $this->
setAlert($lng->txt(
"form_msg_file_no_upload"));
276 case UPLOAD_ERR_NO_TMP_DIR:
277 $this->
setAlert($lng->txt(
"form_msg_file_missing_tmp_dir"));
281 case UPLOAD_ERR_CANT_WRITE:
282 $this->
setAlert($lng->txt(
"form_msg_file_cannot_write_to_disk"));
286 case UPLOAD_ERR_EXTENSION:
287 $this->
setAlert($lng->txt(
"form_msg_file_upload_stopped_ext"));
294 if ($_FILES[$this->
getPostVar()][
"tmp_name"] !=
"" &&
297 if (!in_array(strtolower($suffix), $this->
getSuffixes()))
299 $this->
setAlert($lng->txt(
"form_msg_file_wrong_file_type"));
305 if ($_FILES[$this->
getPostVar()][
"tmp_name"] !=
"")
308 if ($vir[0] ==
false)
310 $this->
setAlert($lng->txt(
"form_msg_file_virus_found").
"<br />".$vir[1]);
325 $quota_exceeded = $quota_legend =
false;
326 if(self::$check_wsp_quota)
328 include_once
"Services/DiskQuota/classes/class.ilDiskQuotaHandler.php";
331 $lng->loadLanguageModule(
"file");
332 $quota_exceeded = $lng->txt(
"personal_workspace_quota_exceeded_warning");
340 $f_tpl =
new ilTemplate(
"tpl.prop_file.html",
true,
true,
"Services/Form");
346 $f_tpl->setCurrentBlock(
'filename');
348 $f_tpl->setVariable(
'VAL_FILENAME',$this->
getFilename());
349 $f_tpl->setVariable(
'FILENAME_ID',$this->
getFieldId());
350 $f_tpl->setVAriable(
'TXT_FILENAME_HINT',$lng->txt(
'if_no_title_then_filename'));
351 $f_tpl->parseCurrentBlock();
359 $f_tpl->setCurrentBlock(
"delete_bl");
360 $f_tpl->setVariable(
"POST_VAR_D", $this->
getPostVar());
361 $f_tpl->setVariable(
"TXT_DELETE_EXISTING",
362 $lng->txt(
"delete_existing_file"));
363 $f_tpl->parseCurrentBlock();
366 $f_tpl->setCurrentBlock(
'prop_file_propval');
367 $f_tpl->setVariable(
'FILE_VAL', $this->
getValue());
368 $f_tpl->parseCurrentBlock();
372 if ($a_mode !=
"toolbar")
378 $f_tpl->setCurrentBlock(
"max_size");
379 $f_tpl->setVariable(
"TXT_MAX_SIZE", $lng->txt(
"file_notice").
" ".
381 $f_tpl->parseCurrentBlock();
385 $f_tpl->setVariable(
"TXT_MAX_SIZE", $quota_legend);
386 $f_tpl->parseCurrentBlock();
391 $f_tpl->setCurrentBlock(
"max_size");
392 $f_tpl->setVariable(
"TXT_MAX_SIZE", $quota_exceeded);
393 $f_tpl->parseCurrentBlock();
396 else if($quota_exceeded)
398 return $quota_exceeded;
404 $f_tpl->setCurrentBlock(
"pending");
405 $f_tpl->setVariable(
"TXT_PENDING", $lng->txt(
"file_upload_pending").
407 $f_tpl->parseCurrentBlock();
412 $f_tpl->setVariable(
"DISABLED",
413 " disabled=\"disabled\"");
416 $f_tpl->setVariable(
"POST_VAR", $this->
getPostVar());
417 $f_tpl->setVariable(
"ID", $this->
getFieldId());
418 $f_tpl->setVariable(
"SIZE", $this->
getSize());
420 return $f_tpl->get();
432 $a_tpl->setCurrentBlock(
"prop_generic");
433 $a_tpl->setVariable(
"PROP_GENERIC", $html);
434 $a_tpl->parseCurrentBlock();
444 $suff_str = $delim =
"";
447 $suff_str.= $delim.
".".$suffix;
450 $a_tpl->setCurrentBlock($a_block);
451 $a_tpl->setVariable(
"TXT_ALLOWED_SUFFIXES",
452 $lng->txt(
"file_allowed_suffixes").
" ".$suff_str);
453 $a_tpl->parseCurrentBlock();
460 $umf = ini_get(
"upload_max_filesize");
462 $pms = ini_get(
"post_max_size");
465 $multiplier_a=array(
"K"=>1024,
"M"=>1024*1024,
"G"=>1024*1024*1024);
467 $umf_parts=preg_split(
"/(\d+)([K|G|M])/", $umf, -1, PREG_SPLIT_DELIM_CAPTURE|PREG_SPLIT_NO_EMPTY);
468 $pms_parts=preg_split(
"/(\d+)([K|G|M])/", $pms, -1, PREG_SPLIT_DELIM_CAPTURE|PREG_SPLIT_NO_EMPTY);
470 if (count($umf_parts) == 2) { $umf = $umf_parts[0]*$multiplier_a[$umf_parts[1]]; }
471 if (count($pms_parts) == 2) { $pms = $pms_parts[0]*$multiplier_a[$pms_parts[1]]; }
474 $max_filesize = min($umf, $pms);
476 if (!$max_filesize) $max_filesize=max($umf, $pms);
479 $max_filesize = sprintf(
"%.1f MB",$max_filesize/1024/1024);
481 return $max_filesize;
501 $html = $this->
render(
"toolbar");
509 include_once
"Services/WebDAV/classes/class.ilDiskQuotaActivationChecker.php";
512 self::$check_wsp_quota =
true;
516 self::$check_wsp_quota =
false;