ILIAS  release_4-4 Revision
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 public More...
 
 unlinkLast ()
 
 __readFiles ($a_dir='')
 
 __checkReadWrite ()
 check if directory is writable overwritten method from base class 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 public More...
 
 __checkPath ()
 
 __checkReadWrite ()
 check if directory is writable overwritten method from base class 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 public. More...
 
 checkPath ($a_path)
 check if path exists and is writable More...
 
 getPath ()
 get Path public More...
 
- Public Member Functions inherited from ilFile
 ilFile ()
 Constructor get ilias object public. More...
 
 deleteTrailingSlash ($a_path)
 delete trailing slash of path variables More...
 

Static Public Member Functions

 _initDirectory ()
 init directory overwritten method public More...
 
- Static Public Member Functions inherited from ilFileDataImport
 _initDirectory ()
 init directory overwritten method 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 private

Returns
bool

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.

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

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

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 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 public ...
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ _initDirectory()

ilFileDataImportGroup::_initDirectory ( )
static

init directory overwritten method public

Returns
boolean

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

References ilUtil\makeDir().

Referenced by ilFileDataImportGroup().

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 ...
+ 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.

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

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  }
getPath()
get exercise path public
+ Here is the call graph for this function:

◆ findXMLFile()

ilFileDataImportGroup::findXMLFile (   $a_dir = '')

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

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

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  }
getPath()
get exercise path public
+ Here is the call graph for this function:

◆ getFiles()

ilFileDataImportGroup::getFiles ( )

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

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

47  {
48  return $this->files ? $this->files : array();
49  }
+ 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 public

Returns
string path

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.

References $xml_file.

◆ ilFileDataImportGroup()

ilFileDataImportGroup::ilFileDataImportGroup ( )

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

Parameters
integeregerobj_id public

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

References __readFiles(), and _initDirectory().

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 public
+ Here is the call graph for this function:

◆ storeUploadedFile()

ilFileDataImportGroup::storeUploadedFile (   $a_http_post_file)

store uploaded file in filesystem

Parameters
arrayHTTP_POST_FILES public
Returns
bool

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

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

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  }
getPath()
get exercise path public
static moveUploadedFile($a_file, $a_name, $a_target, $a_raise_errors=true, $a_mode="move_uploaded")
move uploaded file
+ Here is the call graph for this function:

◆ unlinkLast()

ilFileDataImportGroup::unlinkLast ( )

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

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

Referenced by storeUploadedFile().

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
+ 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.

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

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
+ 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: