4 include_once
'Services/UIComponent/Toolbar/interfaces/interface.ilToolbarItem.php';
5 include_once(
"./Services/Form/classes/class.ilSubEnabledFormPropertyGUI.php");
56 $this->value = $a_value;
76 $this->size = $a_size;
96 $this->filename = $a_val;
118 $this->suffixes = $a_suffixes;
128 return $this->suffixes;
140 $this->filename_selection =
true;
141 $this->filename_post = $a_post_var;
152 return $this->filename_selection ?
true :
false;
177 while (substr($_FILES[$this->
getPostVar()][
"name"],-1) ==
'/')
183 $filename_arr = pathinfo($_FILES[$this->
getPostVar()][
"name"]);
184 $suffix = $filename_arr[
"extension"];
185 $mimetype = $_FILES[$this->
getPostVar()][
"type"];
186 $size_bytes = $_FILES[$this->
getPostVar()][
"size"];
187 $temp_name = $_FILES[$this->
getPostVar()][
"tmp_name"];
196 case UPLOAD_ERR_INI_SIZE:
197 $this->
setAlert($lng->txt(
"form_msg_file_size_exceeds"));
201 case UPLOAD_ERR_FORM_SIZE:
202 $this->
setAlert($lng->txt(
"form_msg_file_size_exceeds"));
206 case UPLOAD_ERR_PARTIAL:
207 $this->
setAlert($lng->txt(
"form_msg_file_partially_uploaded"));
211 case UPLOAD_ERR_NO_FILE:
216 $this->
setAlert($lng->txt(
"form_msg_file_no_upload"));
222 case UPLOAD_ERR_NO_TMP_DIR:
223 $this->
setAlert($lng->txt(
"form_msg_file_missing_tmp_dir"));
227 case UPLOAD_ERR_CANT_WRITE:
228 $this->
setAlert($lng->txt(
"form_msg_file_cannot_write_to_disk"));
232 case UPLOAD_ERR_EXTENSION:
233 $this->
setAlert($lng->txt(
"form_msg_file_upload_stopped_ext"));
240 if ($_FILES[$this->
getPostVar()][
"tmp_name"] !=
"" &&
243 if (!in_array(strtolower($suffix), $this->
getSuffixes()))
245 $this->
setAlert($lng->txt(
"form_msg_file_wrong_file_type"));
251 if ($_FILES[$this->
getPostVar()][
"tmp_name"] !=
"")
254 if ($vir[0] ==
false)
256 $this->
setAlert($lng->txt(
"form_msg_file_virus_found").
"<br />".$vir[1]);
271 $f_tpl =
new ilTemplate(
"tpl.prop_file.html",
true,
true,
"Services/Form");
277 $f_tpl->setCurrentBlock(
'filename');
279 $f_tpl->setVariable(
'VAL_FILENAME',$this->
getFilename());
280 $f_tpl->setVariable(
'FILENAME_ID',$this->
getFieldId());
281 $f_tpl->setVAriable(
'TXT_FILENAME_HINT',$lng->txt(
'if_no_title_then_filename'));
282 $f_tpl->parseCurrentBlock();
288 $f_tpl->setCurrentBlock(
'prop_file_propval');
289 $f_tpl->setVariable(
'FILE_VAL', $this->
getValue());
290 $f_tpl->parseCurrentBlock();
294 if ($a_mode !=
"toolbar")
298 $f_tpl->setCurrentBlock(
"max_size");
299 $f_tpl->setVariable(
"TXT_MAX_SIZE", $lng->txt(
"file_notice").
" ".
301 $f_tpl->parseCurrentBlock();
304 $f_tpl->setVariable(
"POST_VAR", $this->
getPostVar());
305 $f_tpl->setVariable(
"ID", $this->
getFieldId());
306 $f_tpl->setVariable(
"SIZE", $this->
getSize());
308 return $f_tpl->get();
320 $a_tpl->setCurrentBlock(
"prop_generic");
321 $a_tpl->setVariable(
"PROP_GENERIC", $html);
322 $a_tpl->parseCurrentBlock();
332 $suff_str = $delim =
"";
335 $suff_str.= $delim.
".".$suffix;
338 $a_tpl->setCurrentBlock($a_block);
339 $a_tpl->setVariable(
"TXT_ALLOWED_SUFFIXES",
340 $lng->txt(
"file_allowed_suffixes").
" ".$suff_str);
341 $a_tpl->parseCurrentBlock();
348 $umf = ini_get(
"upload_max_filesize");
350 $pms = ini_get(
"post_max_size");
353 $multiplier_a=array(
"K"=>1024,
"M"=>1024*1024,
"G"=>1024*1024*1024);
355 $umf_parts=preg_split(
"/(\d+)([K|G|M])/", $umf, -1, PREG_SPLIT_DELIM_CAPTURE|PREG_SPLIT_NO_EMPTY);
356 $pms_parts=preg_split(
"/(\d+)([K|G|M])/", $pms, -1, PREG_SPLIT_DELIM_CAPTURE|PREG_SPLIT_NO_EMPTY);
358 if (count($umf_parts) == 2) { $umf = $umf_parts[0]*$multiplier_a[$umf_parts[1]]; }
359 if (count($pms_parts) == 2) { $pms = $pms_parts[0]*$multiplier_a[$pms_parts[1]]; }
362 $max_filesize = min($umf, $pms);
364 if (!$max_filesize) $max_filesize=max($umf, $pms);
367 $max_filesize = sprintf(
"%.1f MB",$max_filesize/1024/1024);
369 return $max_filesize;
377 $html = $this->
render(
"toolbar");