ILIAS  release_5-3 Revision v5.3.23-19-g915713cf615
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 
40  public static function getTempFilename($a_hash, $a_field, $a_name, $a_type, $a_index = null, $a_sub_index = null)
41  {
42  $a_name = ilUtil::getAsciiFileName($a_name);
43 
44  $tmp_file_name = implode(
45  "~~",
46  array(session_id(),
47  $a_hash,
48  $a_field,
49  $a_index,
50  $a_sub_index,
51  str_replace("/", "~~", $a_type),
52  str_replace("~~", "_", $a_name))
53  );
54 
55  // make sure temp directory exists
56  $temp_path = ilUtil::getDataDir() . "/temp/";
57  return $temp_path . $tmp_file_name;
58  }
59 
60 
67  public static function rebuildTempFileByHash($hash)
68  {
69  $temp_path = ilUtil::getDataDir() . "/temp";
70  if (is_dir($temp_path)) {
71  $temp_files = glob($temp_path . "/" . session_id() . "~~" . $hash . "~~*");
72  if (is_array($temp_files)) {
73  foreach ($temp_files as $full_file) {
74  $file = explode("~~", basename($full_file));
75  $field = $file[2];
76  $idx = $file[3];
77  $idx2 = $file[4];
78  $type = $file[5] . "/" . $file[6];
79  $name = $file[7];
80 
81  if ($idx2 != "") {
82  if (!$_FILES[$field]["tmp_name"][$idx][$idx2]) {
83  $_FILES[$field]["tmp_name"][$idx][$idx2] = $full_file;
84  $_FILES[$field]["name"][$idx][$idx2] = $name;
85  $_FILES[$field]["type"][$idx][$idx2] = $type;
86  $_FILES[$field]["error"][$idx][$idx2] = 0;
87  $_FILES[$field]["size"][$idx][$idx2] = filesize($full_file);
88  }
89  } else {
90  if ($idx != "") {
91  if (!$_FILES[$field]["tmp_name"][$idx]) {
92  $_FILES[$field]["tmp_name"][$idx] = $full_file;
93  $_FILES[$field]["name"][$idx] = $name;
94  $_FILES[$field]["type"][$idx] = $type;
95  $_FILES[$field]["error"][$idx] = 0;
96  $_FILES[$field]["size"][$idx] = filesize($full_file);
97  }
98  } else {
99  if (!$_FILES[$field]["tmp_name"]) {
100  $_FILES[$field]["tmp_name"] = $full_file;
101  $_FILES[$field]["name"] = $name;
102  $_FILES[$field]["type"] = $type;
103  $_FILES[$field]["error"] = 0;
104  $_FILES[$field]["size"] = filesize($full_file);
105  }
106  }
107  }
108  }
109  }
110  } else {
111  throw new ilDclException('temp dir path "' . $temp_path . '" is not a directory');
112  }
113  }
114 
115 
120  public function cleanupTempFiles($hash)
121  {
122  $files = glob(ilUtil::getDataDir() . "/temp/" . session_id() . "~~" . $hash . "~~*");
123 
124  foreach ($files as $file) {
125  if (file_exists($file)) {
126  unlink($file);
127  }
128  }
129  }
130 }
$files
Definition: add-vimline.php:18
Class ilDclPropertyFormGUI.
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.
Create styles array
The data for the language used.
static getDataDir()
get data directory (outside webspace)
Class ilDclException.
if(!file_exists("$old.txt")) if($old===$new) if(file_exists("$new.txt")) $file
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