ILIAS  release_5-0 Revision 5.0.0-1144-gc4397b1f870
ilFileDataImportGroup Class Reference

This class handles all operations on files for the exercise object. More...

+ Inheritance diagram for ilFileDataImportGroup:
+ Collaboration diagram for ilFileDataImportGroup:

Public Member Functions

 ilFileDataImportGroup ()
 Constructor call base constructors checks if directory is writable and sets the optional obj_id. More...
 
 getFiles ()
 
 getXMLFile ()
 
 getObjectFile ()
 
 storeUploadedFile ($a_http_post_file)
 store uploaded file in filesystem More...
 
 findXMLFile ($a_dir='')
 
 findObjectFile ($a_file, $a_dir='')
 
 unzip ()
 
 getPath ()
 get exercise path @access public More...
 
 unlinkLast ()
 
 __readFiles ($a_dir='')
 
 __checkReadWrite ()
 check if directory is writable overwritten method from base class @access private More...
 
- Public Member Functions inherited from ilFileDataImport
 ilFileDataImport ()
 Constructor call base constructors checks if directory is writable and sets the optional obj_id. More...
 
 getPath ()
 get exercise path @access public More...
 
 __checkPath ()
 
 __checkReadWrite ()
 check if directory is writable overwritten method from base class @access private More...
 
- Public Member Functions inherited from ilFileData
 ilFileData ()
 Constructor class bas constructor and read path of directory from ilias.ini setup an mail object @access public. More...
 
 checkPath ($a_path)
 check if path exists and is writable More...
 
 getPath ()
 get Path @access public More...
 
- Public Member Functions inherited from ilFile
 ilFile ()
 Constructor get ilias object @access public. More...
 
 deleteTrailingSlash ($a_path)
 delete trailing slash of path variables More...
 

Static Public Member Functions

 _initDirectory ()
 init directory overwritten method @access public More...
 
 _initDirectory ()
 init directory overwritten method @access public More...
 

Data Fields

 $group_path
 
 $files
 
 $xml_file
 
- Data Fields inherited from ilFileDataImport
 $import_path
 
- Data Fields inherited from ilFile
 $path
 
 $ilias
 

Detailed Description

This class handles all operations on files for the exercise object.

Author
Stefan Meyer meyer.nosp@m.@lei.nosp@m.fos.c.nosp@m.om
Version
$Id$

Definition at line 14 of file class.ilFileDataImportGroup.php.

Member Function Documentation

◆ __checkReadWrite()

ilFileDataImportGroup::__checkReadWrite ( )

check if directory is writable overwritten method from base class @access private

Returns
bool

Reimplemented from ilFileDataImport.

Definition at line 205 of file class.ilFileDataImportGroup.php.

206 {
207 if(is_writable($this->group_path) && is_readable($this->group_path))
208 {
209 return true;
210 }
211 else
212 {
213 $this->ilias->raiseError("Group import directory is not readable/writable by webserver",$this->ilias->error_obj->FATAL);
214 }
215 }
redirection script todo: (a better solution should control the processing via a xml file)

◆ __readFiles()

ilFileDataImportGroup::__readFiles (   $a_dir = '')

Definition at line 175 of file class.ilFileDataImportGroup.php.

176 {
177 $a_dir = $a_dir ? $a_dir : $this->getPath();
178
179 $this->files = array();
180 $dp = opendir($a_dir);
181
182 while($file = readdir($dp))
183 {
184 if($file == "." or $file == "..")
185 {
186 continue;
187 }
188 $this->files[] = array(
189 'name' => $file,
190 'abs_path' => $a_dir."/".$file,
191 'size' => filesize($a_dir."/".$file),
192 'ctime' => ilFormat::formatDate(date('Y-m-d H:i:s',filectime($a_dir.'/'.$file))));
193 }
194 closedir($dp);
195
196 return true;
197 }
print $file
getPath()
get exercise path @access public
formatDate($a_date, $a_mode="datetime", $a_omit_seconds=false, $a_relative=TRUE)
format a date according to the user language shortcut for Format::fmtDateTime @access public

References $file, ilFormat\formatDate(), and getPath().

Referenced by findObjectFile(), findXMLFile(), ilFileDataImportGroup(), and storeUploadedFile().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ _initDirectory()

ilFileDataImportGroup::_initDirectory ( )
static

init directory overwritten method @access public

Returns
boolean

Reimplemented from ilFileDataImport.

Definition at line 223 of file class.ilFileDataImportGroup.php.

224 {
225 if(!@file_exists($this->group_path))
226 {
227 ilUtil::makeDir($this->group_path);
228 }
229 return true;
230 }
static makeDir($a_dir)
creates a new directory and inherits all filesystem permissions of the parent directory You may pass ...

References ilUtil\makeDir().

Referenced by ilFileDataImportGroup().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ findObjectFile()

ilFileDataImportGroup::findObjectFile (   $a_file,
  $a_dir = '' 
)

Definition at line 116 of file class.ilFileDataImportGroup.php.

117 {
118 $a_dir = $a_dir ? $a_dir : $this->getPath();
119
120 $this->__readFiles($a_dir);
121
122 foreach($this->getFiles() as $file_data)
123 {
124 if(is_dir($file_data["abs_path"]))
125 {
126 $this->findObjectFile($a_file,$file_data["abs_path"]);
127 }
128 if($file_data["name"] == $a_file)
129 {
130 return $this->object_file = $file_data["abs_path"];
131 }
132 }
133 return $this->object_file;
134 }

References __readFiles(), findObjectFile(), getFiles(), and getPath().

Referenced by findObjectFile().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ findXMLFile()

ilFileDataImportGroup::findXMLFile (   $a_dir = '')

Definition at line 93 of file class.ilFileDataImportGroup.php.

94 {
95 $a_dir = $a_dir ? $a_dir : $this->getPath();
96
97 $this->__readFiles($a_dir);
98
99 foreach($this->getFiles() as $file_data)
100 {
101 if(is_dir($file_data["abs_path"]))
102 {
103 $this->findXMLFile($file_data["abs_path"]);
104 }
105 if(($tmp = explode(".",$file_data["name"])) !== false)
106 {
107 if($tmp[count($tmp) - 1] == "xml")
108 {
109 return $this->xml_file = $file_data["abs_path"];
110 }
111 }
112 }
113 return $this->xml_file;
114 }

References $xml_file, __readFiles(), findXMLFile(), getFiles(), and getPath().

Referenced by findXMLFile().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getFiles()

ilFileDataImportGroup::getFiles ( )

Definition at line 46 of file class.ilFileDataImportGroup.php.

47 {
48 return $this->files ? $this->files : array();
49 }

Referenced by findObjectFile(), findXMLFile(), unlinkLast(), and unzip().

+ Here is the caller graph for this function:

◆ getObjectFile()

ilFileDataImportGroup::getObjectFile ( )

Definition at line 56 of file class.ilFileDataImportGroup.php.

57 {
58 return $this->object_file;
59 }

◆ getPath()

ilFileDataImportGroup::getPath ( )

get exercise path @access public

Returns
string path

Reimplemented from ilFileDataImport.

Definition at line 154 of file class.ilFileDataImportGroup.php.

References $group_path.

Referenced by __readFiles(), findObjectFile(), findXMLFile(), and storeUploadedFile().

+ Here is the caller graph for this function:

◆ getXMLFile()

ilFileDataImportGroup::getXMLFile ( )

Definition at line 51 of file class.ilFileDataImportGroup.php.

52 {
53 return $this->xml_file;
54 }

References $xml_file.

◆ ilFileDataImportGroup()

ilFileDataImportGroup::ilFileDataImportGroup ( )

Constructor call base constructors checks if directory is writable and sets the optional obj_id.

Parameters
integeregerobj_id @access public

Definition at line 34 of file class.ilFileDataImportGroup.php.

35 {
36 define('GROUP_IMPORT_PATH','group');
37 parent::ilFileDataImport();
38 $this->group_path = parent::getPath()."/".GROUP_IMPORT_PATH;
39
40 // IF DIRECTORY ISN'T CREATED CREATE IT
41 // CALL STATIC TO AVOID OVERWRITE PROBLEMS
43 $this->__readFiles();
44 }
_initDirectory()
init directory overwritten method @access public

References __readFiles(), and _initDirectory().

+ Here is the call graph for this function:

◆ storeUploadedFile()

ilFileDataImportGroup::storeUploadedFile (   $a_http_post_file)

store uploaded file in filesystem

Parameters
arrayHTTP_POST_FILES @access public
Returns
bool

Definition at line 67 of file class.ilFileDataImportGroup.php.

68 {
69 // TODO:
70 // CHECK UPLOAD LIMIT
71 //
72
73 if(isset($a_http_post_file) && $a_http_post_file['size'])
74 {
75 // DELETE OLD FILES
76 $this->unlinkLast();
77
78 ilUtil::moveUploadedFile($a_http_post_file['tmp_name'],
79 $a_http_post_file['name'], $this->getPath().'/'.$a_http_post_file['name']);
80
81 // CHECK IF FILE WITH SAME NAME EXISTS
82 //move_uploaded_file($a_http_post_file['tmp_name'],$this->getPath().'/'.$a_http_post_file['name']);
83
84 // UPDATE FILES LIST
85 $this->__readFiles();
86 return true;
87 }
88 else
89 {
90 return false;
91 }
92 }
static moveUploadedFile($a_file, $a_name, $a_target, $a_raise_errors=true, $a_mode="move_uploaded")
move uploaded file

References __readFiles(), getPath(), ilUtil\moveUploadedFile(), and unlinkLast().

+ Here is the call graph for this function:

◆ unlinkLast()

ilFileDataImportGroup::unlinkLast ( )

Definition at line 159 of file class.ilFileDataImportGroup.php.

160 {
161 foreach($this->getFiles() as $file_data)
162 {
163 if(is_dir($file_data["abs_path"]))
164 {
165 ilUtil::delDir($file_data["abs_path"]);
166 }
167 else
168 {
169 unlink($file_data["abs_path"]);
170 }
171 }
172 return true;
173 }
static delDir($a_dir, $a_clean_only=false)
removes a dir and all its content (subdirs and files) recursively

References ilUtil\delDir(), and getFiles().

Referenced by storeUploadedFile().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ unzip()

ilFileDataImportGroup::unzip ( )

Definition at line 138 of file class.ilFileDataImportGroup.php.

139 {
140 foreach($this->getFiles() as $file_data)
141 {
142 ilUtil::unzip($file_data["abs_path"]);
143
144 return true;
145 }
146 return false;
147 }
static unzip($a_file, $overwrite=false, $a_flat=false)
unzip file

References getFiles(), and ilUtil\unzip().

+ Here is the call graph for this function:

Field Documentation

◆ $files

ilFileDataImportGroup::$files

Definition at line 23 of file class.ilFileDataImportGroup.php.

◆ $group_path

ilFileDataImportGroup::$group_path

Definition at line 21 of file class.ilFileDataImportGroup.php.

Referenced by getPath().

◆ $xml_file

ilFileDataImportGroup::$xml_file

Definition at line 24 of file class.ilFileDataImportGroup.php.

Referenced by findXMLFile(), and getXMLFile().


The documentation for this class was generated from the following file: