ILIAS  release_5-2 Revision v5.2.25-18-g3f80b828510
ilFileSystemStorage5069 Class Reference
+ Inheritance diagram for ilFileSystemStorage5069:
+ Collaboration diagram for ilFileSystemStorage5069:

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

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...
 
static _copyDirectory ($a_source, $a_target)
 Copy directory and all contents. 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...
 

Protected Attributes

 $path
 

Private Attributes

 $container_id
 
 $storage_type
 
 $path_conversion = false
 

Detailed Description

Definition at line 30 of file class.ilFileSystemStorage5069.php.

Constructor & Destructor Documentation

◆ __construct()

ilFileSystemStorage5069::__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 55 of file class.ilFileSystemStorage5069.php.

56 {
57 $this->storage_type = $a_storage_type;
58 $this->path_conversion = $a_path_conversion;
59 $this->container_id = $a_container_id;
60
61 // Get path info
62 $this->init();
63 }

References init().

+ Here is the call graph for this function:

Member Function Documentation

◆ _copyDirectory()

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

Copy directory and all contents.

Parameters
string$a_sourceabsolute source path
string$a_targetabsolute target path

Definition at line 286 of file class.ilFileSystemStorage5069.php.

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

References ilUtil\rCopy().

+ Here is the call graph for this function:

◆ _createPathFromId()

static ilFileSystemStorage5069::_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 79 of file class.ilFileSystemStorage5069.php.

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

References $path.

Referenced by init().

+ Here is the caller graph for this function:

◆ appendToPath()

ilFileSystemStorage5069::appendToPath (   $a_appendix)

Definition at line 291 of file class.ilFileSystemStorage5069.php.

292 {
293 $this->path .= $a_appendix;
294 }

◆ copyFile()

ilFileSystemStorage5069::copyFile (   $a_from,
  $a_to 
)

Copy files.

@access public

Parameters
stringabsolute source
stringabsolute target

Definition at line 270 of file class.ilFileSystemStorage5069.php.

271 {
272 if(@file_exists($a_from))
273 {
274 @copy($a_from,$a_to);
275 return true;
276 }
277 return false;
278 }

◆ create()

ilFileSystemStorage5069::create ( )

Create directory.

@access public

Reimplemented in ilFSStorageExercise5069.

Definition at line 131 of file class.ilFileSystemStorage5069.php.

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

References ilUtil\makeDirParents().

+ Here is the call graph for this function:

◆ delete()

ilFileSystemStorage5069::delete ( )

Delete complete directory.

@access public

Parameters

Definition at line 256 of file class.ilFileSystemStorage5069.php.

257 {
258 return ilUtil::delDir($this->getAbsolutePath());
259 }
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()

ilFileSystemStorage5069::deleteDirectory (   $a_abs_name)

Delete directory.

@access public

Parameters
stringabsolute name

Definition at line 238 of file class.ilFileSystemStorage5069.php.

239 {
240 if(@file_exists($a_abs_name))
241 {
242 ilUtil::delDir($a_abs_name);
243 return true;
244 }
245 return false;
246 }

References ilUtil\delDir().

+ Here is the call graph for this function:

◆ deleteFile()

ilFileSystemStorage5069::deleteFile (   $a_abs_name)

Delete file.

@access public

Parameters
stringabsolute name

Definition at line 221 of file class.ilFileSystemStorage5069.php.

222 {
223 if(@file_exists($a_abs_name))
224 {
225 @unlink($a_abs_name);
226 return true;
227 }
228 return false;
229 }

◆ getAbsolutePath()

ilFileSystemStorage5069::getAbsolutePath ( )

Get absolute path of storage directory.

@access public

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

148 {
149 return $this->path;
150 }

References $path.

Referenced by delete(), and ilFSStorageExercise5069\getAssignmentFilePath().

+ Here is the caller graph for this function:

◆ getContainerId()

ilFileSystemStorage5069::getContainerId ( )

◆ getPath()

ilFileSystemStorage5069::getPath ( )

Get path.

Definition at line 304 of file class.ilFileSystemStorage5069.php.

305 {
306 return $this->path;
307 }

References $path.

◆ getPathPostfix()

ilFileSystemStorage5069::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 ilFSStorageExercise5069.

Referenced by init().

+ Here is the caller graph for this function:

◆ getPathPrefix()

ilFileSystemStorage5069::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 ilFSStorageExercise5069.

Referenced by init().

+ Here is the caller graph for this function:

◆ getStorageType()

ilFileSystemStorage5069::getStorageType ( )

Definition at line 296 of file class.ilFileSystemStorage5069.php.

References $storage_type.

◆ init()

ilFileSystemStorage5069::init ( )
protected

Read path info.

@access private

Reimplemented in ilFSStorageExercise5069.

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

158 {
159 switch($this->storage_type)
160 {
162 $this->path = ilUtil::getDataDir();
163 break;
164
166 $this->path = ilUtil::getWebspaceDir();
167 break;
168
170 $this->path = ilUtil::getWebspaceDir();
171 $this->path = ilUtil::removeTrailingPathSeparators($this->path);
172 $this->path .= '/'.self::SECURED_DIRECTORY;
173 break;
174 }
175 $this->path = ilUtil::removeTrailingPathSeparators($this->path);
176 $this->path .= '/';
177
178 // Append path prefix
179 $this->path .= ($this->getPathPrefix().'/');
180
181 if($this->path_conversion)
182 {
183 $this->path .= self::_createPathFromId($this->container_id,$this->getPathPostfix());
184 }
185 else
186 {
187 $this->path .= ($this->getPathPostfix().'_'.$this->container_id);
188 }
189 return true;
190 }
getPathPostfix()
Get directory name.
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.
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:

◆ writeToFile()

ilFileSystemStorage5069::writeToFile (   $a_data,
  $a_absolute_path 
)

Write data to file.

@access public

Parameters

Definition at line 199 of file class.ilFileSystemStorage5069.php.

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

Field Documentation

◆ $container_id

ilFileSystemStorage5069::$container_id
private

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

Referenced by getContainerId(), and init().

◆ $path

◆ $path_conversion

ilFileSystemStorage5069::$path_conversion = false
private

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

◆ $storage_type

ilFileSystemStorage5069::$storage_type
private

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

Referenced by getStorageType().

◆ FACTOR

const ilFileSystemStorage5069::FACTOR = 100

Definition at line 36 of file class.ilFileSystemStorage5069.php.

◆ MAX_EXPONENT

const ilFileSystemStorage5069::MAX_EXPONENT = 3

Definition at line 37 of file class.ilFileSystemStorage5069.php.

◆ SECURED_DIRECTORY

const ilFileSystemStorage5069::SECURED_DIRECTORY = "sec"

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

◆ STORAGE_DATA

const ilFileSystemStorage5069::STORAGE_DATA = 2

Definition at line 33 of file class.ilFileSystemStorage5069.php.

Referenced by init().

◆ STORAGE_SECURED

const ilFileSystemStorage5069::STORAGE_SECURED = 3

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

Referenced by init().

◆ STORAGE_WEB

const ilFileSystemStorage5069::STORAGE_WEB = 1

Definition at line 32 of file class.ilFileSystemStorage5069.php.

Referenced by init().


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