ILIAS  release_5-4 Revision v5.4.26-12-gabc799a52e6
class.ilDclPropertyFormGUI.php
Go to the documentation of this file.
1 <?php
2 
11 {
12 
24  public function keepTempFileUpload($a_hash, $a_field, $a_tmp_name, $a_name, $a_type, $a_index = null, $a_sub_index = null)
25  {
26  $this->keepFileUpload($a_hash, $a_field, $a_tmp_name, $a_name, $a_type, $a_index, $a_sub_index);
27  }
28 
29 
42  public static function getTempFilename($a_hash, $a_field, $a_name, $a_type, $a_index = null, $a_sub_index = null)
43  {
44  $a_name = ilUtil::getAsciiFileName($a_name);
45 
46  $tmp_file_name = implode(
47  "~~",
48  array(session_id(),
49  $a_hash,
50  $a_field,
51  $a_index,
52  $a_sub_index,
53  str_replace("/", "~~", $a_type),
54  str_replace("~~", "_", $a_name))
55  );
56 
57  // make sure temp directory exists
58  $temp_path = ilUtil::getDataDir() . "/temp/";
59 
60  return $temp_path . $tmp_file_name;
61  }
62 
63 
71  public static function rebuildTempFileByHash($hash)
72  {
73  $temp_path = ilUtil::getDataDir() . "/temp";
74  if (is_dir($temp_path)) {
75  $temp_files = glob($temp_path . "/" . session_id() . "~~" . $hash . "~~*");
76  if (is_array($temp_files)) {
77  foreach ($temp_files as $full_file) {
78  $file = explode("~~", basename($full_file));
79  $field = $file[2];
80  $idx = $file[3];
81  $idx2 = $file[4];
82  $type = $file[5] . "/" . $file[6];
83  $name = $file[7];
84 
85  if ($idx2 != "") {
86  if (!$_FILES[$field]["tmp_name"][$idx][$idx2]) {
87  $_FILES[$field]["tmp_name"][$idx][$idx2] = $full_file;
88  $_FILES[$field]["name"][$idx][$idx2] = $name;
89  $_FILES[$field]["type"][$idx][$idx2] = $type;
90  $_FILES[$field]["error"][$idx][$idx2] = 0;
91  $_FILES[$field]["size"][$idx][$idx2] = filesize($full_file);
92  }
93  } else {
94  if ($idx != "") {
95  if (!$_FILES[$field]["tmp_name"][$idx]) {
96  $_FILES[$field]["tmp_name"][$idx] = $full_file;
97  $_FILES[$field]["name"][$idx] = $name;
98  $_FILES[$field]["type"][$idx] = $type;
99  $_FILES[$field]["error"][$idx] = 0;
100  $_FILES[$field]["size"][$idx] = filesize($full_file);
101  }
102  } else {
103  if (!$_FILES[$field]["tmp_name"]) {
104  $_FILES[$field]["tmp_name"] = $full_file;
105  $_FILES[$field]["name"] = $name;
106  $_FILES[$field]["type"] = $type;
107  $_FILES[$field]["error"] = 0;
108  $_FILES[$field]["size"] = filesize($full_file);
109  }
110  }
111  }
112  }
113  }
114  } else {
115  throw new ilDclException('temp dir path "' . $temp_path . '" is not a directory');
116  }
117  }
118 
119 
125  public function cleanupTempFiles($hash)
126  {
127  $files = glob(ilUtil::getDataDir() . "/temp/" . session_id() . "~~" . $hash . "~~*");
128 
129  foreach ($files as $file) {
130  if (file_exists($file)) {
131  unlink($file);
132  }
133  }
134  }
135 }
Class ilDclPropertyFormGUI.
$files
Definition: metarefresh.php:49
This class represents a property form user interface.
$type
cleanupTempFiles($hash)
Cleanup temp-files.
$a_type
Definition: workflow.php:92
static rebuildTempFileByHash($hash)
Return temp files.
static getDataDir()
get data directory (outside webspace)
Class ilDclException.
keepTempFileUpload($a_hash, $a_field, $a_tmp_name, $a_name, $a_type, $a_index=null, $a_sub_index=null)
Expose method for save confirmation.
static getTempFilename($a_hash, $a_field, $a_name, $a_type, $a_index=null, $a_sub_index=null)
return temp-filename