ILIAS  release_5-2 Revision v5.2.25-18-g3f80b828510
class.ilDclPropertyFormGUI.php
Go to the documentation of this file.
1<?php
2require_once("./Services/Form/classes/class.ilPropertyFormGUI.php");
3
12
24 public function keepTempFileUpload($a_hash, $a_field, $a_tmp_name, $a_name, $a_type, $a_index = null, $a_sub_index = null) {
25 $this->keepFileUpload($a_hash, $a_field, $a_tmp_name, $a_name, $a_type, $a_index, $a_sub_index);
26 }
27
39 public static function getTempFilename($a_hash, $a_field, $a_name, $a_type, $a_index = null, $a_sub_index = null) {
40 $a_name = ilUtil::getAsciiFileName($a_name);
41
42 $tmp_file_name = implode(
43 "~~", array(session_id(),
44 $a_hash,
45 $a_field,
46 $a_index,
47 $a_sub_index,
48 str_replace("/", "~~", $a_type),
49 str_replace("~~", "_", $a_name))
50 );
51
52 // make sure temp directory exists
53 $temp_path = ilUtil::getDataDir() . "/temp/";
54 return $temp_path.$tmp_file_name;
55 }
56
57
64 public static function rebuildTempFileByHash($hash) {
65 $temp_path = ilUtil::getDataDir() . "/temp";
66 if (is_dir($temp_path)) {
67 $temp_files = glob($temp_path . "/" . session_id() . "~~" . $hash . "~~*");
68 if (is_array($temp_files)) {
69 foreach ($temp_files as $full_file) {
70 $file = explode("~~", basename($full_file));
71 $field = $file[2];
72 $idx = $file[3];
73 $idx2 = $file[4];
74 $type = $file[5] . "/" . $file[6];
75 $name = $file[7];
76
77 if ($idx2 != "") {
78 if (!$_FILES[$field]["tmp_name"][$idx][$idx2]) {
79 $_FILES[$field]["tmp_name"][$idx][$idx2] = $full_file;
80 $_FILES[$field]["name"][$idx][$idx2] = $name;
81 $_FILES[$field]["type"][$idx][$idx2] = $type;
82 $_FILES[$field]["error"][$idx][$idx2] = 0;
83 $_FILES[$field]["size"][$idx][$idx2] = filesize($full_file);
84 }
85 } else {
86 if ($idx != "") {
87 if (!$_FILES[$field]["tmp_name"][$idx]) {
88 $_FILES[$field]["tmp_name"][$idx] = $full_file;
89 $_FILES[$field]["name"][$idx] = $name;
90 $_FILES[$field]["type"][$idx] = $type;
91 $_FILES[$field]["error"][$idx] = 0;
92 $_FILES[$field]["size"][$idx] = filesize($full_file);
93 }
94 } else {
95 if (!$_FILES[$field]["tmp_name"]) {
96 $_FILES[$field]["tmp_name"] = $full_file;
97 $_FILES[$field]["name"] = $name;
98 $_FILES[$field]["type"] = $type;
99 $_FILES[$field]["error"] = 0;
100 $_FILES[$field]["size"] = filesize($full_file);
101 }
102 }
103 }
104 }
105 }
106 } else {
107 throw new ilDclException('temp dir path "' . $temp_path . '" is not a directory');
108 }
109 }
110
111
116 public function cleanupTempFiles($hash) {
117 $files = glob(ilUtil::getDataDir() . "/temp/" . session_id() . "~~" . $hash . "~~*");
118
119 foreach($files as $file) {
120 if(file_exists($file)) {
121 unlink($file);
122 }
123 }
124 }
125}
$files
Definition: add-vimline.php:18
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)
if(!file_exists("$old.txt")) if( $old===$new) if(file_exists("$new.txt")) $file
$a_type
Definition: workflow.php:93