ILIAS  release_5-1 Revision 5.0.0-5477-g43f3e3fab5f
ilFileSystemStorage Class Reference
+ Inheritance diagram for ilFileSystemStorage:
+ Collaboration diagram for ilFileSystemStorage:

Public Member Functions

 __construct ($a_storage_type, $a_path_conversion, $a_container_id)
 Constructor. More...
 
 getContainerId ()
 
 create ()
 Create directory. More...
 
 getAbsolutePath ()
 Get absolute path of storage directory. More...
 
 writeToFile ($a_data, $a_absolute_path)
 Write data to file. More...
 
 deleteFile ($a_abs_name)
 Delete file. More...
 
 deleteDirectory ($a_abs_name)
 Delete directory. More...
 
 delete ()
 Delete complete directory. More...
 
 copyFile ($a_from, $a_to)
 Copy files. More...
 
 appendToPath ($a_appendix)
 
 getStorageType ()
 
 getPath ()
 Get path. More...
 
 __construct ($a_storage_type, $a_path_conversion, $a_container_id)
 Constructor. More...
 
 create ()
 Create directory. More...
 
 getAbsolutePath ()
 Get absolute path of storage directory. More...
 
 getShortPath ()
 
 rename ($from, $to)
 

Static Public Member Functions

static _createPathFromId ($a_container_id, $a_name)
 Create a path from an id: e.g 12345 will be converted to 12/34/<name>_5. More...
 
 _copyDirectory ($a_source, $a_target)
 Copy directory and all contents. More...
 
static _createPathFromId ($a_container_id, $a_name)
 Create a path from an id: e.g 12345 will be converted to 12/34/<name>_5. More...
 

Data Fields

const STORAGE_WEB = 1
 
const STORAGE_DATA = 2
 
const STORAGE_SECURED = 3
 
const FACTOR = 100
 
const MAX_EXPONENT = 3
 
const SECURED_DIRECTORY = "sec"
 

Protected Member Functions

 getPathPrefix ()
 Get path prefix. More...
 
 getPathPostfix ()
 Get directory name. More...
 
 init ()
 Read path info. More...
 
 getPathPrefix ()
 Get path prefix. More...
 
 getPathPostfix ()
 Get directory name. More...
 

Protected Attributes

 $path
 

Private Member Functions

 init ()
 Read path info. More...
 

Private Attributes

 $container_id
 
 $storage_type
 
 $path_conversion = false
 
 $short_path
 

Detailed Description

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

Constructor & Destructor Documentation

◆ __construct() [1/2]

ilFileSystemStorage::__construct (   $a_storage_type,
  $a_path_conversion,
  $a_container_id 
)

Constructor.

@access public

Parameters
intstorage type
boolEn/Disable automatic path conversion. If enabled files with id 123 will be stored in directory files/1/file_123
intobject id of container (e.g file_id or mob_id)

Definition at line 59 of file class.ilFileSystemStorage.php.

60 {
61 $this->storage_type = $a_storage_type;
62 $this->path_conversion = $a_path_conversion;
63 $this->container_id = $a_container_id;
64
65 // Get path info
66 $this->init();
67 }

References init().

+ Here is the call graph for this function:

◆ __construct() [2/2]

ilFileSystemStorage::__construct (   $a_storage_type,
  $a_path_conversion,
  $a_container_id 
)

Constructor.

@access public

Parameters
intstorage type
boolEn/Disable automatic path conversion. If enabled files with id 123 will be stored in directory files/1/file_123
intobject id of container (e.g file_id or mob_id)

Definition at line 50 of file class.ilFileSystemStorage.php.

51 {
52 $this->storage_type = $a_storage_type;
53 $this->path_conversion = $a_path_conversion;
54 $this->container_id = $a_container_id;
55
56 // Get path info
57 $this->init();
58 }

References init().

+ Here is the call graph for this function:

Member Function Documentation

◆ _copyDirectory()

ilFileSystemStorage::_copyDirectory (   $a_source,
  $a_target 
)
static

Copy directory and all contents.

@access public

Parameters
stringabsolute source path
stringabsolute target path

Definition at line 293 of file class.ilFileSystemStorage.php.

294 {
295 return ilUtil::rCopy($a_source,$a_target);
296 }
static rCopy($a_sdir, $a_tdir, $preserveTimeAttributes=false)
Copies content of a directory $a_sdir recursively to a directory $a_tdir.

References ilUtil\rCopy().

Referenced by ilFSStorageCourse\_clone(), and ilObjPortfolioBase\cloneBasics().

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

◆ _createPathFromId() [1/2]

static ilFileSystemStorage::_createPathFromId (   $a_container_id,
  $a_name 
)
static

Create a path from an id: e.g 12345 will be converted to 12/34/<name>_5.

@access public

Parameters
intcontainer id
stringname

Definition at line 83 of file class.ilFileSystemStorage.php.

84 {
85 $path = array();
86 $found = false;
87 $num = $a_container_id;
88 for($i = self::MAX_EXPONENT; $i > 0;$i--)
89 {
90 $factor = pow(self::FACTOR,$i);
91 if(($tmp = (int) ($num / $factor)) or $found)
92 {
93 $path[] = $tmp;
94 $num = $num % $factor;
95 $found = true;
96 }
97 }
98
99 if(count($path))
100 {
101 $path_string = (implode('/',$path).'/');
102 }
103 return $path_string.$a_name.'_'.$a_container_id;
104 }

References $path.

Referenced by ilExport\_getExportDirectory(), and init().

+ Here is the caller graph for this function:

◆ _createPathFromId() [2/2]

static ilFileSystemStorage::_createPathFromId (   $a_container_id,
  $a_name 
)
static

Create a path from an id: e.g 12345 will be converted to 12/34/<name>_5.

@access public

Parameters
intcontainer id
stringname

Definition at line 69 of file class.ilFileSystemStorage.php.

70 {
71 $path = array();
72 $found = false;
73 $num = $a_container_id;
74 for($i = self::MAX_EXPONENT; $i > 0;$i--)
75 {
76 $factor = pow(self::FACTOR,$i);
77 if(($tmp = (int) ($num / $factor)) or $found)
78 {
79 $path[] = $tmp;
80 $num = $num % $factor;
81 $found = true;
82 }
83 }
84
85 if(count($path))
86 {
87 $path_string = (implode('/',$path));
88 }
89 return $path_string;
90 }

References $path.

◆ appendToPath()

ilFileSystemStorage::appendToPath (   $a_appendix)

Definition at line 298 of file class.ilFileSystemStorage.php.

299 {
300 $this->path .= $a_appendix;
301 }

Referenced by ilFSStorageMail\__construct().

+ Here is the caller graph for this function:

◆ copyFile()

ilFileSystemStorage::copyFile (   $a_from,
  $a_to 
)

Copy files.

@access public

Parameters
stringabsolute source
stringabsolute target

Definition at line 274 of file class.ilFileSystemStorage.php.

275 {
276 if(@file_exists($a_from))
277 {
278 @copy($a_from,$a_to);
279 return true;
280 }
281 return false;
282 }

◆ create() [1/2]

ilFileSystemStorage::create ( )

Create directory.

@access public

Reimplemented in ilFSStorageExercise, ilTestProcessLockFileStorage, and ilAssQuestionProcessLockFileStorage.

Definition at line 135 of file class.ilFileSystemStorage.php.

136 {
137 if(!file_exists($this->path))
138 {
139 ilUtil::makeDirParents($this->path);
140 }
141 return true;
142 }
static makeDirParents($a_dir)
Create a new directory and all parent directories.

References ilUtil\makeDirParents().

Referenced by ilRestFileStorage\init().

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

◆ create() [2/2]

ilFileSystemStorage::create ( )

Create directory.

@access public

Reimplemented in ilFSStorageExercise, ilTestProcessLockFileStorage, and ilAssQuestionProcessLockFileStorage.

Definition at line 121 of file class.ilFileSystemStorage.php.

122 {
123 if(!file_exists($this->short_path))
124 {
126 }
127 return true;
128 }
removeTrailingPathSeparators($path)
makeDirParents($a_dir)
Create a new directory and all parent directories.

References ilUpdateUtils\makeDirParents(), and ilUpdateUtils\removeTrailingPathSeparators().

+ Here is the call graph for this function:

◆ delete()

ilFileSystemStorage::delete ( )

Delete complete directory.

@access public

Parameters

Definition at line 260 of file class.ilFileSystemStorage.php.

261 {
262 return ilUtil::delDir($this->getAbsolutePath());
263 }
getAbsolutePath()
Get absolute path of storage directory.
static delDir($a_dir, $a_clean_only=false)
removes a dir and all its content (subdirs and files) recursively

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

+ Here is the call graph for this function:

◆ deleteDirectory()

ilFileSystemStorage::deleteDirectory (   $a_abs_name)

Delete directory.

@access public

Parameters
stringabsolute name

Definition at line 242 of file class.ilFileSystemStorage.php.

243 {
244 if(@file_exists($a_abs_name))
245 {
246 ilUtil::delDir($a_abs_name);
247 return true;
248 }
249 return false;
250 }

References ilUtil\delDir().

Referenced by ilFSStorageCourse\deleteArchive().

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

◆ deleteFile()

ilFileSystemStorage::deleteFile (   $a_abs_name)

Delete file.

@access public

Parameters
stringabsolute name

Definition at line 225 of file class.ilFileSystemStorage.php.

226 {
227 if(@file_exists($a_abs_name))
228 {
229 @unlink($a_abs_name);
230 return true;
231 }
232 return false;
233 }

Referenced by ilFSStorageCourse\deleteArchive(), ilFSStorageCourse\deleteMemberExportFile(), and ilFSStorageGroup\deleteMemberExportFile().

+ Here is the caller graph for this function:

◆ getAbsolutePath() [1/2]

◆ getAbsolutePath() [2/2]

ilFileSystemStorage::getAbsolutePath ( )

Get absolute path of storage directory.

@access public

Definition at line 137 of file class.ilFileSystemStorage.php.

138 {
139 return $this->path;
140 }

References $path.

◆ getContainerId()

ilFileSystemStorage::getContainerId ( )

Definition at line 69 of file class.ilFileSystemStorage.php.

References $container_id.

Referenced by ilFSStorageCourse\getMemberExportFiles(), and ilFSStorageGroup\getMemberExportFiles().

+ Here is the caller graph for this function:

◆ getPath()

ilFileSystemStorage::getPath ( )

◆ getPathPostfix() [1/2]

ilFileSystemStorage::getPathPostfix ( )
abstractprotected

Get directory name.

E.g for files => file Only relative path, no trailing slash '_<obj_id>' will be appended automatically

@abstract @access protected

Returns
string directory name

Reimplemented in ilFSStorageBlog, ilFSStorageBooking, ilFSStorageCourse, ilFSStorageExercise, ilFSStorageFile, ilFSStorageGroup, ilFSStoragePoll, ilFSStoragePortfolio, ilFSStorageSession, ilTestProcessLockFileStorage, ilAssQuestionProcessLockFileStorage, ilFSStorageMail, ilFSStorageCourse, ilFSStorageEvent, ilFSStorageFile, ilFSStoragePreview, ilFSStorageUserFolder, ilVerificationStorageFile, and ilRestFileStorage.

Referenced by init().

+ Here is the caller graph for this function:

◆ getPathPostfix() [2/2]

ilFileSystemStorage::getPathPostfix ( )
abstractprotected

Get directory name.

E.g for files => file Only relative path, no trailing slash '_<obj_id>' will be appended automatically

@abstract @access protected

Returns
string directory name

Reimplemented in ilFSStorageBlog, ilFSStorageBooking, ilFSStorageCourse, ilFSStorageExercise, ilFSStorageFile, ilFSStorageGroup, ilFSStoragePoll, ilFSStoragePortfolio, ilFSStorageSession, ilTestProcessLockFileStorage, ilAssQuestionProcessLockFileStorage, ilFSStorageMail, ilFSStorageCourse, ilFSStorageEvent, ilFSStorageFile, ilFSStoragePreview, ilFSStorageUserFolder, ilVerificationStorageFile, and ilRestFileStorage.

◆ getPathPrefix() [1/2]

ilFileSystemStorage::getPathPrefix ( )
abstractprotected

Get path prefix.

Prefix that will be prepended to the path No trailing slash. E.g ilFiles for files

@abstract @access protected

Returns
string path prefix e.g files

Reimplemented in ilFSStorageBlog, ilFSStorageBooking, ilFSStorageCourse, ilFSStorageExercise, ilFSStorageFile, ilFSStorageGroup, ilFSStoragePoll, ilFSStoragePortfolio, ilFSStorageSession, ilTestProcessLockFileStorage, ilAssQuestionProcessLockFileStorage, ilFSStorageMail, ilFSStorageCourse, ilFSStorageEvent, ilFSStorageFile, ilFSStoragePreview, ilFSStorageUserFolder, ilVerificationStorageFile, and ilRestFileStorage.

Referenced by init().

+ Here is the caller graph for this function:

◆ getPathPrefix() [2/2]

ilFileSystemStorage::getPathPrefix ( )
abstractprotected

◆ getShortPath()

ilFileSystemStorage::getShortPath ( )

Definition at line 142 of file class.ilFileSystemStorage.php.

References $short_path.

◆ getStorageType()

ilFileSystemStorage::getStorageType ( )

Definition at line 303 of file class.ilFileSystemStorage.php.

References $storage_type.

Referenced by ilFSStorageMail\getRelativePathExMailDirectory().

+ Here is the caller graph for this function:

◆ init() [1/2]

ilFileSystemStorage::init ( )
protected

Read path info.

@access private

Reimplemented in ilFSStorageExercise, and ilRestFileStorage.

Definition at line 161 of file class.ilFileSystemStorage.php.

162 {
163 switch($this->storage_type)
164 {
166 $this->path = ilUtil::getDataDir();
167 break;
168
170 $this->path = ilUtil::getWebspaceDir();
171 break;
172
174 $this->path = ilUtil::getWebspaceDir();
175 $this->path = ilUtil::removeTrailingPathSeparators($this->path);
176 $this->path .= '/'.self::SECURED_DIRECTORY;
177 break;
178 }
179 $this->path = ilUtil::removeTrailingPathSeparators($this->path);
180 $this->path .= '/';
181
182 // Append path prefix
183 $this->path .= ($this->getPathPrefix().'/');
184
185 if($this->path_conversion)
186 {
187 $this->path .= self::_createPathFromId($this->container_id,$this->getPathPostfix());
188 }
189 else
190 {
191 $this->path .= ($this->getPathPostfix().'_'.$this->container_id);
192 }
193 return true;
194 }
getPathPrefix()
Get path prefix.
static _createPathFromId($a_container_id, $a_name)
Create a path from an id: e.g 12345 will be converted to 12/34/<name>_5.
getPathPostfix()
Get directory name.
static getDataDir()
get data directory (outside webspace)
static getWebspaceDir($mode="filesystem")
get webspace directory
static removeTrailingPathSeparators($path)

References $container_id, _createPathFromId(), ilUtil\getDataDir(), getPathPostfix(), getPathPrefix(), ilUtil\getWebspaceDir(), ilUtil\removeTrailingPathSeparators(), STORAGE_DATA, STORAGE_SECURED, and STORAGE_WEB.

Referenced by __construct().

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

◆ init() [2/2]

ilFileSystemStorage::init ( )
private

Read path info.

@access private

Reimplemented in ilFSStorageExercise, and ilRestFileStorage.

Definition at line 157 of file class.ilFileSystemStorage.php.

158 {
159 switch($this->storage_type)
160 {
162 $this->path = ilUpdateUtils::getDataDir();
163 break;
164
166 $this->path = ilUpdateUtils::getWebspaceDir();
167 break;
168 }
169 $this->path = ilUpdateUtils::removeTrailingPathSeparators($this->path);
170 $this->path .= '/';
171
172 // Append path prefix
173 $this->path .= ($this->getPathPrefix().'/');
174
175 if($this->path_conversion)
176 {
177 if($path_id = self::_createPathFromId($this->container_id,$this->getPathPostfix()))
178 {
179 $this->path = $this->path.'/'.$path_id;
180 $this->path .= '/';
181 $this->short_path = $this->path;
182 }
183 else
184 {
185 $this->short_path = $this->path;
186 }
187 $this->path .= ($this->getPathPostfix().'_'.$this->container_id);
188 }
189 else
190 {
191 $this->short_path = $this->path;
192 $this->path .= ($this->getPathPostfix().'_'.$this->container_id);
193 }
194 return true;
195 }
getWebspaceDir($mode="filesystem")
get webspace directory
getDataDir()
get data directory (outside webspace)

References $container_id, $path, ilUpdateUtils\getDataDir(), getPathPostfix(), getPathPrefix(), ilUpdateUtils\getWebspaceDir(), ilUpdateUtils\removeTrailingPathSeparators(), STORAGE_DATA, and STORAGE_WEB.

+ Here is the call graph for this function:

◆ rename()

ilFileSystemStorage::rename (   $from,
  $to 
)

Definition at line 147 of file class.ilFileSystemStorage.php.

148 {
149 return @rename($from,$to);
150 }

References rename().

Referenced by rename(), and ilFSStorageExercise\uploadFile().

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

◆ writeToFile()

ilFileSystemStorage::writeToFile (   $a_data,
  $a_absolute_path 
)

Write data to file.

@access public

Parameters

Definition at line 203 of file class.ilFileSystemStorage.php.

204 {
205 if(!$fp = @fopen($a_absolute_path,'w+'))
206 {
207 return false;
208 }
209 if(@fwrite($fp,$a_data) === false)
210 {
211 @fclose($fp);
212 return false;
213 }
214 @fclose($fp);
215 return true;
216 }

Referenced by ilFSStorageCourse\addMemberExportFile(), ilFSStorageGroup\addMemberExportFile(), ilRestFileStorage\createFile(), ilRestFileStorage\storeFileForRest(), and ilFSStorageCourse\writeArchiveFile().

+ Here is the caller graph for this function:

Field Documentation

◆ $container_id

ilFileSystemStorage::$container_id
private

Definition at line 44 of file class.ilFileSystemStorage.php.

Referenced by getContainerId(), and init().

◆ $path

◆ $path_conversion

ilFileSystemStorage::$path_conversion = false
private

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

◆ $short_path

ilFileSystemStorage::$short_path
private

Definition at line 39 of file class.ilFileSystemStorage.php.

Referenced by getShortPath().

◆ $storage_type

ilFileSystemStorage::$storage_type
private

Definition at line 45 of file class.ilFileSystemStorage.php.

Referenced by getStorageType().

◆ FACTOR

const ilFileSystemStorage::FACTOR = 100

Definition at line 40 of file class.ilFileSystemStorage.php.

◆ MAX_EXPONENT

const ilFileSystemStorage::MAX_EXPONENT = 3

Definition at line 41 of file class.ilFileSystemStorage.php.

◆ SECURED_DIRECTORY

const ilFileSystemStorage::SECURED_DIRECTORY = "sec"

Definition at line 42 of file class.ilFileSystemStorage.php.

◆ STORAGE_DATA

◆ STORAGE_SECURED

const ilFileSystemStorage::STORAGE_SECURED = 3

Definition at line 38 of file class.ilFileSystemStorage.php.

Referenced by init().

◆ STORAGE_WEB

const ilFileSystemStorage::STORAGE_WEB = 1

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