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"));
261 include_once(
"./Services/Utilities/classes/class.ilStr.php");
268 $filename_arr = pathinfo($_FILES[$this->
getPostVar()][
"name"]);
269 $suffix = $filename_arr[
"extension"];
270 $mimetype = $_FILES[$this->
getPostVar()][
"type"];
271 $size_bytes = $_FILES[$this->
getPostVar()][
"size"];
272 $temp_name = $_FILES[$this->
getPostVar()][
"tmp_name"];
281 case UPLOAD_ERR_INI_SIZE:
282 $this->
setAlert($lng->txt(
"form_msg_file_size_exceeds"));
286 case UPLOAD_ERR_FORM_SIZE:
287 $this->
setAlert($lng->txt(
"form_msg_file_size_exceeds"));
291 case UPLOAD_ERR_PARTIAL:
292 $this->
setAlert($lng->txt(
"form_msg_file_partially_uploaded"));
296 case UPLOAD_ERR_NO_FILE:
301 $this->
setAlert($lng->txt(
"form_msg_file_no_upload"));
307 case UPLOAD_ERR_NO_TMP_DIR:
308 $this->
setAlert($lng->txt(
"form_msg_file_missing_tmp_dir"));
312 case UPLOAD_ERR_CANT_WRITE:
313 $this->
setAlert($lng->txt(
"form_msg_file_cannot_write_to_disk"));
317 case UPLOAD_ERR_EXTENSION:
318 $this->
setAlert($lng->txt(
"form_msg_file_upload_stopped_ext"));
325 if ($_FILES[$this->
getPostVar()][
"tmp_name"] !=
"")
327 if (is_array($this->forbidden_suffixes) && in_array(strtolower($suffix), $this->forbidden_suffixes))
329 $this->
setAlert($lng->txt(
"form_msg_file_type_is_not_allowed").
" (".$suffix.
")");
334 if (!in_array(strtolower($suffix), $this->
getSuffixes()))
336 $this->
setAlert($lng->txt(
"form_msg_file_wrong_file_type"));
343 if ($_FILES[$this->
getPostVar()][
"tmp_name"] !=
"")
346 if ($vir[0] ==
false)
348 $this->
setAlert($lng->txt(
"form_msg_file_virus_found").
"<br />".$vir[1]);
363 $quota_exceeded = $quota_legend =
false;
364 if(self::$check_wsp_quota)
366 include_once
"Services/DiskQuota/classes/class.ilDiskQuotaHandler.php";
369 $lng->loadLanguageModule(
"file");
370 $quota_exceeded = $lng->txt(
"personal_workspace_quota_exceeded_warning");
378 $f_tpl =
new ilTemplate(
"tpl.prop_file.html",
true,
true,
"Services/Form");
384 $f_tpl->setCurrentBlock(
'filename');
386 $f_tpl->setVariable(
'VAL_FILENAME',$this->
getFilename());
387 $f_tpl->setVariable(
'FILENAME_ID',$this->
getFieldId());
388 $f_tpl->setVAriable(
'TXT_FILENAME_HINT',$lng->txt(
'if_no_title_then_filename'));
389 $f_tpl->parseCurrentBlock();
397 $f_tpl->setCurrentBlock(
"delete_bl");
398 $f_tpl->setVariable(
"POST_VAR_D", $this->
getPostVar());
399 $f_tpl->setVariable(
"TXT_DELETE_EXISTING",
400 $lng->txt(
"delete_existing_file"));
401 $f_tpl->parseCurrentBlock();
404 $f_tpl->setCurrentBlock(
'prop_file_propval');
405 $f_tpl->setVariable(
'FILE_VAL', $this->
getValue());
406 $f_tpl->parseCurrentBlock();
410 if ($a_mode !=
"toolbar")
416 $f_tpl->setCurrentBlock(
"max_size");
417 $f_tpl->setVariable(
"TXT_MAX_SIZE", $lng->txt(
"file_notice").
" ".
419 $f_tpl->parseCurrentBlock();
423 $f_tpl->setVariable(
"TXT_MAX_SIZE", $quota_legend);
424 $f_tpl->parseCurrentBlock();
429 $f_tpl->setCurrentBlock(
"max_size");
430 $f_tpl->setVariable(
"TXT_MAX_SIZE", $quota_exceeded);
431 $f_tpl->parseCurrentBlock();
434 else if($quota_exceeded)
436 return $quota_exceeded;
442 $f_tpl->setCurrentBlock(
"pending");
443 $f_tpl->setVariable(
"TXT_PENDING", $lng->txt(
"file_upload_pending").
445 $f_tpl->parseCurrentBlock();
450 $f_tpl->setVariable(
"DISABLED",
451 " disabled=\"disabled\"");
454 $f_tpl->setVariable(
"POST_VAR", $this->
getPostVar());
455 $f_tpl->setVariable(
"ID", $this->
getFieldId());
456 $f_tpl->setVariable(
"SIZE", $this->
getSize());
460 $f_tpl->setVariable(
"TXT_BROWSE", $lng->txt(
"select_file"));
463 return $f_tpl->get();
475 $a_tpl->setCurrentBlock(
"prop_generic");
476 $a_tpl->setVariable(
"PROP_GENERIC",
$html);
477 $a_tpl->parseCurrentBlock();
487 $suff_str = $delim =
"";
490 $suff_str.= $delim.
".".$suffix;
493 $a_tpl->setCurrentBlock($a_block);
494 $a_tpl->setVariable(
"TXT_ALLOWED_SUFFIXES",
495 $lng->txt(
"file_allowed_suffixes").
" ".$suff_str);
496 $a_tpl->parseCurrentBlock();
503 $umf = ini_get(
"upload_max_filesize");
505 $pms = ini_get(
"post_max_size");
508 $multiplier_a=
array(
"K"=>1024,
"M"=>1024*1024,
"G"=>1024*1024*1024);
510 $umf_parts=preg_split(
"/(\d+)([K|G|M])/", $umf, -1, PREG_SPLIT_DELIM_CAPTURE|PREG_SPLIT_NO_EMPTY);
511 $pms_parts=preg_split(
"/(\d+)([K|G|M])/", $pms, -1, PREG_SPLIT_DELIM_CAPTURE|PREG_SPLIT_NO_EMPTY);
513 if (count($umf_parts) == 2) { $umf = $umf_parts[0]*$multiplier_a[$umf_parts[1]]; }
514 if (count($pms_parts) == 2) { $pms = $pms_parts[0]*$multiplier_a[$pms_parts[1]]; }
517 $max_filesize = min($umf, $pms);
519 if (!$max_filesize) $max_filesize=max($umf, $pms);
522 $max_filesize = sprintf(
"%.1f MB",$max_filesize/1024/1024);
524 return $max_filesize;
552 include_once
"Services/WebDAV/classes/class.ilDiskQuotaActivationChecker.php";
555 self::$check_wsp_quota =
true;
559 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 normalizeUtf8String($a_str)
Normalize UTF8 string.
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
Create styles array
The data for the language used.