4 include_once
'Services/UIComponent/Toolbar/interfaces/interface.ilToolbarItem.php';
5 include_once(
"./Services/Form/classes/class.ilSubEnabledFormPropertyGUI.php");
58 $this->value = $a_value;
78 $this->size = $a_size;
98 $this->filename = $a_val;
120 $this->suffixes = $a_suffixes;
130 return $this->suffixes;
140 $this->pending = $a_val;
162 $this->filename_selection =
true;
163 $this->filename_post = $a_post_var;
174 return $this->filename_selection ?
true :
false;
196 $this->allow_deletion = $a_val;
221 while (substr($_FILES[$this->
getPostVar()][
"name"],-1) ==
'/')
227 $filename_arr = pathinfo($_FILES[$this->
getPostVar()][
"name"]);
228 $suffix = $filename_arr[
"extension"];
229 $mimetype = $_FILES[$this->
getPostVar()][
"type"];
230 $size_bytes = $_FILES[$this->
getPostVar()][
"size"];
231 $temp_name = $_FILES[$this->
getPostVar()][
"tmp_name"];
232 $error = $_FILES[$this->
getPostVar()][
"error"];
239 $this->
setAlert($lng->txt(
"form_msg_file_size_exceeds"));
248 case UPLOAD_ERR_INI_SIZE:
249 $this->
setAlert($lng->txt(
"form_msg_file_size_exceeds"));
253 case UPLOAD_ERR_FORM_SIZE:
254 $this->
setAlert($lng->txt(
"form_msg_file_size_exceeds"));
258 case UPLOAD_ERR_PARTIAL:
259 $this->
setAlert($lng->txt(
"form_msg_file_partially_uploaded"));
263 case UPLOAD_ERR_NO_FILE:
268 $this->
setAlert($lng->txt(
"form_msg_file_no_upload"));
274 case UPLOAD_ERR_NO_TMP_DIR:
275 $this->
setAlert($lng->txt(
"form_msg_file_missing_tmp_dir"));
279 case UPLOAD_ERR_CANT_WRITE:
280 $this->
setAlert($lng->txt(
"form_msg_file_cannot_write_to_disk"));
284 case UPLOAD_ERR_EXTENSION:
285 $this->
setAlert($lng->txt(
"form_msg_file_upload_stopped_ext"));
292 if ($_FILES[$this->
getPostVar()][
"tmp_name"] !=
"" &&
295 if (!in_array(strtolower($suffix), $this->
getSuffixes()))
297 $this->
setAlert($lng->txt(
"form_msg_file_wrong_file_type"));
303 if ($_FILES[$this->
getPostVar()][
"tmp_name"] !=
"")
306 if ($vir[0] ==
false)
308 $this->
setAlert($lng->txt(
"form_msg_file_virus_found").
"<br />".$vir[1]);
323 $f_tpl =
new ilTemplate(
"tpl.prop_file.html",
true,
true,
"Services/Form");
329 $f_tpl->setCurrentBlock(
'filename');
331 $f_tpl->setVariable(
'VAL_FILENAME',$this->
getFilename());
332 $f_tpl->setVariable(
'FILENAME_ID',$this->
getFieldId());
333 $f_tpl->setVAriable(
'TXT_FILENAME_HINT',$lng->txt(
'if_no_title_then_filename'));
334 $f_tpl->parseCurrentBlock();
342 $f_tpl->setCurrentBlock(
"delete_bl");
343 $f_tpl->setVariable(
"POST_VAR_D", $this->
getPostVar());
344 $f_tpl->setVariable(
"TXT_DELETE_EXISTING",
345 $lng->txt(
"delete_existing_file"));
346 $f_tpl->parseCurrentBlock();
349 $f_tpl->setCurrentBlock(
'prop_file_propval');
350 $f_tpl->setVariable(
'FILE_VAL', $this->
getValue());
351 $f_tpl->parseCurrentBlock();
355 if ($a_mode !=
"toolbar")
359 $f_tpl->setCurrentBlock(
"max_size");
360 $f_tpl->setVariable(
"TXT_MAX_SIZE", $lng->txt(
"file_notice").
" ".
362 $f_tpl->parseCurrentBlock();
368 $f_tpl->setCurrentBlock(
"pending");
369 $f_tpl->setVariable(
"TXT_PENDING", $lng->txt(
"file_upload_pending").
371 $f_tpl->parseCurrentBlock();
374 $f_tpl->setVariable(
"POST_VAR", $this->
getPostVar());
375 $f_tpl->setVariable(
"ID", $this->
getFieldId());
376 $f_tpl->setVariable(
"SIZE", $this->
getSize());
378 return $f_tpl->get();
390 $a_tpl->setCurrentBlock(
"prop_generic");
391 $a_tpl->setVariable(
"PROP_GENERIC", $html);
392 $a_tpl->parseCurrentBlock();
402 $suff_str = $delim =
"";
405 $suff_str.= $delim.
".".$suffix;
408 $a_tpl->setCurrentBlock($a_block);
409 $a_tpl->setVariable(
"TXT_ALLOWED_SUFFIXES",
410 $lng->txt(
"file_allowed_suffixes").
" ".$suff_str);
411 $a_tpl->parseCurrentBlock();
418 $umf = ini_get(
"upload_max_filesize");
420 $pms = ini_get(
"post_max_size");
423 $multiplier_a=array(
"K"=>1024,
"M"=>1024*1024,
"G"=>1024*1024*1024);
425 $umf_parts=preg_split(
"/(\d+)([K|G|M])/", $umf, -1, PREG_SPLIT_DELIM_CAPTURE|PREG_SPLIT_NO_EMPTY);
426 $pms_parts=preg_split(
"/(\d+)([K|G|M])/", $pms, -1, PREG_SPLIT_DELIM_CAPTURE|PREG_SPLIT_NO_EMPTY);
428 if (count($umf_parts) == 2) { $umf = $umf_parts[0]*$multiplier_a[$umf_parts[1]]; }
429 if (count($pms_parts) == 2) { $pms = $pms_parts[0]*$multiplier_a[$pms_parts[1]]; }
432 $max_filesize = min($umf, $pms);
434 if (!$max_filesize) $max_filesize=max($umf, $pms);
437 $max_filesize = sprintf(
"%.1f MB",$max_filesize/1024/1024);
439 return $max_filesize;
459 $html = $this->
render(
"toolbar");