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;
 
  179                 while (substr($_FILES[$this->
getPostVar()][
"name"],-1) == 
'/')
 
  185                 $filename_arr = pathinfo($_FILES[$this->
getPostVar()][
"name"]);
 
  186                 $suffix = $filename_arr[
"extension"];
 
  187                 $mimetype = $_FILES[$this->
getPostVar()][
"type"];
 
  188                 $size_bytes = $_FILES[$this->
getPostVar()][
"size"];
 
  189                 $temp_name = $_FILES[$this->
getPostVar()][
"tmp_name"];
 
  190                 $error = $_FILES[$this->
getPostVar()][
"error"];
 
  197                         $this->
setAlert($lng->txt(
"form_msg_file_size_exceeds"));
 
  206                                 case UPLOAD_ERR_INI_SIZE:
 
  207                                         $this->
setAlert($lng->txt(
"form_msg_file_size_exceeds"));
 
  211                                 case UPLOAD_ERR_FORM_SIZE:
 
  212                                         $this->
setAlert($lng->txt(
"form_msg_file_size_exceeds"));
 
  216                                 case UPLOAD_ERR_PARTIAL:
 
  217                                         $this->
setAlert($lng->txt(
"form_msg_file_partially_uploaded"));
 
  221                                 case UPLOAD_ERR_NO_FILE:
 
  226                                                         $this->
setAlert($lng->txt(
"form_msg_file_no_upload"));
 
  232                                 case UPLOAD_ERR_NO_TMP_DIR:
 
  233                                         $this->
setAlert($lng->txt(
"form_msg_file_missing_tmp_dir"));
 
  237                                 case UPLOAD_ERR_CANT_WRITE:
 
  238                                         $this->
setAlert($lng->txt(
"form_msg_file_cannot_write_to_disk"));
 
  242                                 case UPLOAD_ERR_EXTENSION:
 
  243                                         $this->
setAlert($lng->txt(
"form_msg_file_upload_stopped_ext"));
 
  250                 if ($_FILES[$this->
getPostVar()][
"tmp_name"] != 
"" &&
 
  253                         if (!in_array(strtolower($suffix), $this->
getSuffixes()))
 
  255                                 $this->
setAlert($lng->txt(
"form_msg_file_wrong_file_type"));
 
  261                 if ($_FILES[$this->
getPostVar()][
"tmp_name"] != 
"")
 
  264                         if ($vir[0] == 
false)
 
  266                                 $this->
setAlert($lng->txt(
"form_msg_file_virus_found").
"<br />".$vir[1]);
 
  281                 $f_tpl = 
new ilTemplate(
"tpl.prop_file.html", 
true, 
true, 
"Services/Form");
 
  287                         $f_tpl->setCurrentBlock(
'filename');
 
  289                         $f_tpl->setVariable(
'VAL_FILENAME',$this->
getFilename());
 
  290                         $f_tpl->setVariable(
'FILENAME_ID',$this->
getFieldId());
 
  291                         $f_tpl->setVAriable(
'TXT_FILENAME_HINT',$lng->txt(
'if_no_title_then_filename'));
 
  292                         $f_tpl->parseCurrentBlock();
 
  298                                 $f_tpl->setCurrentBlock(
'prop_file_propval');
 
  299                                 $f_tpl->setVariable(
'FILE_VAL', $this->
getValue());
 
  300                                 $f_tpl->parseCurrentBlock();
 
  304                 if ($a_mode != 
"toolbar")
 
  308                         $f_tpl->setCurrentBlock(
"max_size");
 
  309                         $f_tpl->setVariable(
"TXT_MAX_SIZE", $lng->txt(
"file_notice").
" ".
 
  311                         $f_tpl->parseCurrentBlock();
 
  314                 $f_tpl->setVariable(
"POST_VAR", $this->
getPostVar());
 
  315                 $f_tpl->setVariable(
"ID", $this->
getFieldId());
 
  316                 $f_tpl->setVariable(
"SIZE", $this->
getSize());
 
  318                 return $f_tpl->get();
 
  330                 $a_tpl->setCurrentBlock(
"prop_generic");
 
  331                 $a_tpl->setVariable(
"PROP_GENERIC", $html);
 
  332                 $a_tpl->parseCurrentBlock();
 
  342                         $suff_str = $delim = 
"";
 
  345                                 $suff_str.= $delim.
".".$suffix;
 
  348                         $a_tpl->setCurrentBlock($a_block);
 
  349                         $a_tpl->setVariable(
"TXT_ALLOWED_SUFFIXES",
 
  350                                 $lng->txt(
"file_allowed_suffixes").
" ".$suff_str);
 
  351                         $a_tpl->parseCurrentBlock();
 
  358                 $umf = ini_get(
"upload_max_filesize");
 
  360                 $pms = ini_get(
"post_max_size");
 
  363                 $multiplier_a=array(
"K"=>1024, 
"M"=>1024*1024, 
"G"=>1024*1024*1024);
 
  365                 $umf_parts=preg_split(
"/(\d+)([K|G|M])/", $umf, -1, PREG_SPLIT_DELIM_CAPTURE|PREG_SPLIT_NO_EMPTY);
 
  366         $pms_parts=preg_split(
"/(\d+)([K|G|M])/", $pms, -1, PREG_SPLIT_DELIM_CAPTURE|PREG_SPLIT_NO_EMPTY);
 
  368         if (count($umf_parts) == 2) { $umf = $umf_parts[0]*$multiplier_a[$umf_parts[1]]; }
 
  369         if (count($pms_parts) == 2) { $pms = $pms_parts[0]*$multiplier_a[$pms_parts[1]]; }
 
  372                 $max_filesize = min($umf, $pms);
 
  374                 if (!$max_filesize) $max_filesize=max($umf, $pms);
 
  377                 $max_filesize = sprintf(
"%.1f MB",$max_filesize/1024/1024);
 
  379                 return $max_filesize;
 
  387                 $html = $this->
render(
"toolbar");