ILIAS  release_6 Revision v6.24-5-g0c8bfefb3b8
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 273 of file class.ilFileSystemStorage5069.php.

274 {
275 return ilUtil::rCopy($a_source, $a_target);
276 }
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 $factor = pow(self::FACTOR, $i);
86 if (($tmp = (int) ($num / $factor)) or $found) {
87 $path[] = $tmp;
88 $num = $num % $factor;
89 $found = true;
90 }
91 }
92
93 if (count($path)) {
94 $path_string = (implode('/', $path) . '/');
95 }
96 return $path_string . $a_name . '_' . $a_container_id;
97 }
$i
Definition: metadata.php:24

References $i, and $path.

Referenced by init().

+ Here is the caller graph for this function:

◆ appendToPath()

ilFileSystemStorage5069::appendToPath (   $a_appendix)

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

279 {
280 $this->path .= $a_appendix;
281 }

◆ copyFile()

ilFileSystemStorage5069::copyFile (   $a_from,
  $a_to 
)

Copy files.

@access public

Parameters
stringabsolute source
stringabsolute target

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

259 {
260 if (@file_exists($a_from)) {
261 @copy($a_from, $a_to);
262 return true;
263 }
264 return false;
265 }

◆ create()

ilFileSystemStorage5069::create ( )

Create directory.

@access public

Reimplemented in ilFSStorageExercise5069.

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

129 {
130 if (!file_exists($this->path)) {
131 ilUtil::makeDirParents($this->path);
132 }
133 return true;
134 }
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 244 of file class.ilFileSystemStorage5069.php.

245 {
246 return ilUtil::delDir($this->getAbsolutePath());
247 }
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 227 of file class.ilFileSystemStorage5069.php.

228 {
229 if (@file_exists($a_abs_name)) {
230 ilUtil::delDir($a_abs_name);
231 return true;
232 }
233 return false;
234 }

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 211 of file class.ilFileSystemStorage5069.php.

212 {
213 if (@file_exists($a_abs_name)) {
214 @unlink($a_abs_name);
215 return true;
216 }
217 return false;
218 }

◆ getAbsolutePath()

ilFileSystemStorage5069::getAbsolutePath ( )

Get absolute path of storage directory.

@access public

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

144 {
145 return $this->path;
146 }

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 291 of file class.ilFileSystemStorage5069.php.

292 {
293 return $this->path;
294 }

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 283 of file class.ilFileSystemStorage5069.php.

References $storage_type.

◆ init()

ilFileSystemStorage5069::init ( )
protected

Read path info.

@access private

Reimplemented in ilFSStorageExercise5069.

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

154 {
155 switch ($this->storage_type) {
157 $this->path = ilUtil::getDataDir();
158 break;
159
161 $this->path = ilUtil::getWebspaceDir();
162 break;
163
165 $this->path = ilUtil::getWebspaceDir();
166 $this->path = ilUtil::removeTrailingPathSeparators($this->path);
167 $this->path .= '/' . self::SECURED_DIRECTORY;
168 break;
169 }
170 $this->path = ilUtil::removeTrailingPathSeparators($this->path);
171 $this->path .= '/';
172
173 // Append path prefix
174 $this->path .= ($this->getPathPrefix() . '/');
175
176 if ($this->path_conversion) {
177 $this->path .= self::_createPathFromId($this->container_id, $this->getPathPostfix());
178 } else {
179 $this->path .= ($this->getPathPostfix() . '_' . $this->container_id);
180 }
181 return true;
182 }
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(), SECURED_DIRECTORY, 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 191 of file class.ilFileSystemStorage5069.php.

192 {
193 if (!$fp = @fopen($a_absolute_path, 'w+')) {
194 return false;
195 }
196 if (@fwrite($fp, $a_data) === false) {
197 @fclose($fp);
198 return false;
199 }
200 @fclose($fp);
201 return true;
202 }

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.

Referenced by init().

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