ILIAS  release_5-1 Revision 5.0.0-5477-g43f3e3fab5f
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 203 of file class.ilFileDataImportGroup.php.

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

◆ __readFiles()

ilFileDataImportGroup::__readFiles (   $a_dir = '')

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

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

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

174  {
175  $a_dir = $a_dir ? $a_dir : $this->getPath();
176 
177  $this->files = array();
178  $dp = opendir($a_dir);
179 
180  while($file = readdir($dp))
181  {
182  if($file == "." or $file == "..")
183  {
184  continue;
185  }
186  $this->files[] = array(
187  'name' => $file,
188  'abs_path' => $a_dir."/".$file,
189  'size' => filesize($a_dir."/".$file),
190  'ctime' => ilFormat::formatDate(date('Y-m-d H:i:s',filectime($a_dir.'/'.$file))));
191  }
192  closedir($dp);
193 
194  return true;
195  }
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 221 of file class.ilFileDataImportGroup.php.

References ilUtil\makeDir().

Referenced by ilFileDataImportGroup().

222  {
223  if(!@file_exists($this->group_path))
224  {
225  ilUtil::makeDir($this->group_path);
226  }
227  return true;
228  }
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 114 of file class.ilFileDataImportGroup.php.

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

115  {
116  $a_dir = $a_dir ? $a_dir : $this->getPath();
117 
118  $this->__readFiles($a_dir);
119 
120  foreach($this->getFiles() as $file_data)
121  {
122  if(is_dir($file_data["abs_path"]))
123  {
124  $this->findObjectFile($a_file,$file_data["abs_path"]);
125  }
126  if($file_data["name"] == $a_file)
127  {
128  return $this->object_file = $file_data["abs_path"];
129  }
130  }
131  return $this->object_file;
132  }
getPath()
get exercise path public
+ Here is the call graph for this function:

◆ findXMLFile()

ilFileDataImportGroup::findXMLFile (   $a_dir = '')

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

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

92  {
93  $a_dir = $a_dir ? $a_dir : $this->getPath();
94 
95  $this->__readFiles($a_dir);
96 
97  foreach($this->getFiles() as $file_data)
98  {
99  if(is_dir($file_data["abs_path"]))
100  {
101  $this->findXMLFile($file_data["abs_path"]);
102  }
103  if(($tmp = explode(".",$file_data["name"])) !== false)
104  {
105  if($tmp[count($tmp) - 1] == "xml")
106  {
107  return $this->xml_file = $file_data["abs_path"];
108  }
109  }
110  }
111  return $this->xml_file;
112  }
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 152 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 
82  // UPDATE FILES LIST
83  $this->__readFiles();
84  return true;
85  }
86  else
87  {
88  return false;
89  }
90  }
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 157 of file class.ilFileDataImportGroup.php.

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

Referenced by storeUploadedFile().

158  {
159  foreach($this->getFiles() as $file_data)
160  {
161  if(is_dir($file_data["abs_path"]))
162  {
163  ilUtil::delDir($file_data["abs_path"]);
164  }
165  else
166  {
167  unlink($file_data["abs_path"]);
168  }
169  }
170  return true;
171  }
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 136 of file class.ilFileDataImportGroup.php.

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

137  {
138  foreach($this->getFiles() as $file_data)
139  {
140  ilUtil::unzip($file_data["abs_path"]);
141 
142  return true;
143  }
144  return false;
145  }
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: