ILIAS  release_7 Revision v7.30-3-g800a261c036
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(
49 session_id(),
50 $a_hash,
51 $a_field,
52 $a_index,
53 $a_sub_index,
54 str_replace("/", "~~", $a_type),
55 str_replace("~~", "_", $a_name),
56 )
57 );
58
59 // make sure temp directory exists
60 $temp_path = ilUtil::getDataDir() . "/temp/";
61
62 return $temp_path . $tmp_file_name;
63 }
64
65
73 public static function rebuildTempFileByHash($hash)
74 {
75 $temp_path = ilUtil::getDataDir() . "/temp";
76 if (is_dir($temp_path)) {
77 $temp_files = glob($temp_path . "/" . session_id() . "~~" . $hash . "~~*");
78 if (is_array($temp_files)) {
79 foreach ($temp_files as $full_file) {
80 $file = explode("~~", basename($full_file));
81 $field = $file[2];
82 $idx = $file[3];
83 $idx2 = $file[4];
84 $type = $file[5] . "/" . $file[6];
85 $name = $file[7];
86
87 if ($idx2 != "") {
88 if (!$_FILES[$field]["tmp_name"][$idx][$idx2]) {
89 $_FILES[$field]["tmp_name"][$idx][$idx2] = $full_file;
90 $_FILES[$field]["name"][$idx][$idx2] = $name;
91 $_FILES[$field]["type"][$idx][$idx2] = $type;
92 $_FILES[$field]["error"][$idx][$idx2] = 0;
93 $_FILES[$field]["size"][$idx][$idx2] = filesize($full_file);
94 }
95 } else {
96 if ($idx != "") {
97 if (!$_FILES[$field]["tmp_name"][$idx]) {
98 $_FILES[$field]["tmp_name"][$idx] = $full_file;
99 $_FILES[$field]["name"][$idx] = $name;
100 $_FILES[$field]["type"][$idx] = $type;
101 $_FILES[$field]["error"][$idx] = 0;
102 $_FILES[$field]["size"][$idx] = filesize($full_file);
103 }
104 } else {
105 if (!$_FILES[$field]["tmp_name"]) {
106 $_FILES[$field]["tmp_name"] = $full_file;
107 $_FILES[$field]["name"] = $name;
108 $_FILES[$field]["type"] = $type;
109 $_FILES[$field]["error"] = 0;
110 $_FILES[$field]["size"] = filesize($full_file);
111 }
112 }
113 }
114 }
115 }
116 } else {
117 throw new ilDclException('temp dir path "' . $temp_path . '" is not a directory');
118 }
119 }
120
121
127 public function cleanupTempFiles($hash)
128 {
129 $files = glob(ilUtil::getDataDir() . "/temp/" . session_id() . "~~" . $hash . "~~*");
130
131 foreach ($files as $file) {
132 if (file_exists($file)) {
133 unlink($file);
134 }
135 }
136 }
137}
An exception for terminatinating execution or to throw for unit testing.
Class ilDclException.
Class ilDclPropertyFormGUI.
static rebuildTempFileByHash($hash)
Return temp files.
keepTempFileUpload($a_hash, $a_field, $a_tmp_name, $a_name, $a_type, $a_index=null, $a_sub_index=null)
Expose method for save confirmation.
cleanupTempFiles($hash)
Cleanup temp-files.
static getTempFilename($a_hash, $a_field, $a_name, $a_type, $a_index=null, $a_sub_index=null)
return temp-filename
This class represents a property form user interface.
static getDataDir()
get data directory (outside webspace)
$type